pax_global_header00006660000000000000000000000064143576272310014524gustar00rootroot0000000000000052 comment=1a9bfc2472c0bd897c00a7f5f1a6e3a9982262f5 goxel-0.11.0/000077500000000000000000000000001435762723100127215ustar00rootroot00000000000000goxel-0.11.0/.gitattributes000066400000000000000000000002201435762723100156060ustar00rootroot00000000000000src/assets/sounds.inl binary src/assets/samples.inl binary src/assets/images.inl binary src/assets/icons.inl binary src/assets/fonts.inl binary goxel-0.11.0/.travis.yml000066400000000000000000000014261435762723100150350ustar00rootroot00000000000000# Travis configuration for automatic build language: c++ matrix: include: - os: linux sudo: required dist: xenial compiler: gcc - os: linux sudo: required dist: xenial compiler: clang - os: osx osx_image: xcode10.1 before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -qq update; sudo apt-get install -y libgtk-3-dev mesa-common-dev libgl1-mesa-dev; sudo apt-get install -y scons libglfw3-dev; fi script: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make release || travis_terminate 1; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cd osx/goxel; xcodebuild build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO || travis_terminate 1; cd ../..; fi goxel-0.11.0/AUTHORS000066400000000000000000000007421435762723100137740ustar00rootroot00000000000000Goxel was created by: Guillaume Chereau Other contributors: Dustin Willis Webber Pablo Hugo Reda Othelarian (https://github.com/othelarian) Michał (https://github.com/YarlBoro) Goxel uses the font DejaVu (GPL-2+ licence): Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc. DejaVu changes are in public domain. goxel-0.11.0/CHANGELOG.md000066400000000000000000000035021435762723100145320ustar00rootroot00000000000000#Changelog ## [0.10.6] - 2020-07-09 Minor update that improves glTF color export: we can now export the models with the colors put into a texture instead of vertices attributes. ## [0.10.5] - 2020-01-06 Minor update to attempt to fix a crash with AMD cards. ### Fixed - Reintroduced layer bounding box edit widget. ## [0.10.4] - 2019-07-29 ### Added - Line tool (same as brush tool with shift pressed). ### Changed - Better plane tool: on click the plane move just before the clicked voxel for quick editing. The plane rendering has also been improved. - Slightly better looking grid effect. ### Fixed - Fixed the behavior of snapping to always select the closest snapped point. - Fixed bug with selections on top of planes. ## [0.10.0] ### Added - 'Magic Wand' tool. Allows to select adjacent voxels. - Show mirror axis on image box. ### Fixed - Fixed bug in KVX export. - Fixed crash with undo when we change materials or cameras. ## [0.9.0] - 2019-06-04 This major release brings proper material support, and better pathtracing rendering. The code has changed a lot, so expect a few bugs! ### Added - Layer materials: each layer can now have its own material. - Transparent materials. - Emission materials. - Support for png palettes. - Add new view settings. - Allow to scale a layer (only by factors of two). ### Changed - Marching cube rendering default to 'flat' colors. - Layer visibility is saved. - Materials now use metallic/roughness settings. ### Fixed - Bug with retina display on OSX. ## [0.8.3] - 2017-03-30 Minor release. ### Added - Shape layers, for non destructible shapes creation. - New path tracer, based on yocto-gl. Totally remove the old one based on cycles. - Support for exporting to KVX. - Support for build engine palettes. ### Changed - New default material used: lower the specular reflection. goxel-0.11.0/CONTRIBUTING.md000066400000000000000000000051201435762723100151500ustar00rootroot00000000000000# Contributing to Goxel Please read this file first before making a pull request to Goxel. ## CLA In your first pull request, you must add your name in a CLA file in 'doc/cla/individual'. This gives me the right to release special version of Goxel under a commercial licence. It doesn't change the license of the current code. See: https://github.com/guillaumechereau/goxel/blob/master/doc/cla/sign-cla.md For more information about that. ## Coding style Try to follow the code style I used for Goxel, as I am unlikely to merge a pull request that doesn't. The coding style is almost the one used by the linux kernel, but using four spaces for indentation (I also accept typedef). When in doubt, just look at other part of the code. The most important rules are: - Use 4 spaces indentations. No tabs characters anywhere in the code. - 80 columns max line width. - No trailing white space. - function and variable names all in lowercase, with underscore to separate parts if needed: int nb_block; // Good int nbBlock; // Bad - K&R style braces (opening brace on same line): if (something) { ... } else { ... } - Except for functions, where we put the opening brace on the next line: int my_func(void) { ... return 0; } - I also accept exceptions to the K&R braces for multi line conditions (but that should be avoided if possible by making the condition shorter): if (a_very_long_condition || that_uses_several_lines) { ... } - No space between function and argument parenthesis: func(10, 20) // Good func (10, 20) // BAD! - One space after keywords, except `sizeof`: if (something) // Good if(something) // BAD - One space around binary operators, no space after unary operators and before postfix operators. x = 10 + 20 * 3; // Good x = 10+20*3; // BAD x++; // Good x ++; // BAD y = &x; // Good y = & x; // VERY BAD - Use 'C' style variable declarations: int *x; // Good int* x; // BAD - Put all the variable declarations on top of the function, so that we can see them all at the same place. ## Git commit style - Keep the summary line under about 50 characters. - The rest of the commit message separated by a blank line. Wrap lines at 72 characters. - Try to separate the commits into small logical parts. For example if you need to add a new public function in order to fix a bug, the first commit should be about adding the function, and the second one about fixing the bug. goxel-0.11.0/COPYING000066400000000000000000001045131435762723100137600ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . goxel-0.11.0/INTERNALS.md000066400000000000000000000024451435762723100146070ustar00rootroot00000000000000 Small explanation of the internals of goxel code ================================================ The voxels data are stored as blocks of 16^3 voxels (`block_t`). The blocks implement a copy on write mechanism with references counting, so that it is very fast to copy blocks, the actual data (`block_data_t`) is copied only when we make change to a block. Several blocks together form a mesh (`mesh_t`), the meshes also use a copy on write mechanism to make copy basically free. An `image_t` contains several `layer_t`, which is basically a mesh plus a few attributes. The image also keeps snapshots of the layers at every changes for undo history (since we use copy on write on individual blocks, this does not require much memory). The basic function to operate on a mesh is `mesh_op`, we give it a `painter_t` pointer that defines the operation: shape, color, mode, etc. All the rendering functions are differed. The `render_xxx` calls just build a list of operations, that is executed when we call `render_render`. The assets are stored directly in the C code (`src/assets.inl`), a python script (`tools/create_assets`) takes care of generating this file. We can then use `assets_get` to retrieve them. The gui is using Ocornut imgui library, with a few custom widgets defined in `src/imgui_user.inl`. goxel-0.11.0/Makefile000066400000000000000000000033421435762723100143630ustar00rootroot00000000000000SHELL = bash .ONESHELL: all: scons -j 8 release: scons mode=release profile: scons mode=profile run: ./goxel clean: scons -c analyze: scan-build scons mode=analyze # Make the doc using natualdocs. On debian, we only have an old version # of naturaldocs available, where it is not possible to exclude files by # pattern. I don't want to parse the C files (only the headers), so for # the moment I use a tmp file to copy the sources and remove the C files. # It's a bit ugly. .PHONY: doc doc: rm -rf /tmp/goxel_src cp -rf src /tmp/goxel_src find /tmp/goxel_src -name '*.c' | xargs rm mkdir -p doc ndconfig naturaldocs -i /tmp/goxel_src -o html doc -p ndconfig # Targets to install/uninstall goxel and its data files on unix system. PREFIX ?= /usr/local .PHONY: install install: install -Dm755 goxel $(DESTDIR)$(PREFIX)/bin/goxel for size in 16 24 32 48 64 128 256; do install -Dm644 data/icons/icon$${size}.png \ $$(printf '%s%s' $(DESTDIR)$(PREFIX)/share/icons/hicolor/ \ $${size}x$${size}/apps/goxel.png) done install -Dm644 snap/gui/goxel.desktop \ $(DESTDIR)$(PREFIX)/share/applications/goxel.desktop install -Dm644 \ snap/gui/io.github.guillaumechereau.Goxel.appdata.xml \ $$(printf '%s%s' $(DESTDIR)$(PREFIX)/share/metainfo/ \ io.github.guillaumechereau.Goxel.appdata.xml) .PHONY: uninstall uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/goxel for size in 16 24 32 48 64 128 256; do \ rm -f $$(printf '%s%s' $(DESTDIR)$(PREFIX)/share/icons/hicolor/ \ $${size}x$${size}/apps/goxel.png) done rm -f $(DESTDIR)$(PREFIX)/share/applications/goxel.desktop rm -f $$(printf '%s%s' $(DESTDIR)$(PREFIX)/share/metainfo/ \ io.github.guillaumechereau.Goxel.appdata.xml) goxel-0.11.0/README.md000066400000000000000000000056401435762723100142050ustar00rootroot00000000000000 Goxel ===== Version 0.10.7 By Guillaume Chereau [![Build Status]( https://travis-ci.org/guillaumechereau/goxel.svg?branch=master)]( https://travis-ci.org/guillaumechereau/goxel) [![DebianBadge](https://badges.debian.net/badges/debian/unstable/goxel/version.svg)](https://packages.debian.org/unstable/goxel) Official webpage: https://goxel.xyz About ----- You can use goxel to create voxel graphics (3D images formed of cubes). It works on Linux, BSD, Windows and macOS. Download -------- The last release files can be downloaded from [there]( https://github.com/guillaumechereau/goxel/releases/latest). Goxel is also available for [iOS]( https://itunes.apple.com/us/app/goxel-3d-voxel-editor/id1259097826) and [Android]( https://play.google.com/store/apps/details?id=com.noctuasoftware.goxel). ![goxel screenshot 0](https://goxel.xyz/gallery/thibault-fisherman-house.jpg) Fisherman house, made with Goxel by [Thibault Simar](https://www.artstation.com/exm) Licence ------- Goxel is released under the GNU GPL3 licence. If you want to use the code with a commercial project please contact me: I am willing to provide a version of the code under a commercial license. Features -------- - 24 bits RGB colors. - Unlimited scene size. - Unlimited undo buffer. - Layers. - Marching Cube rendering. - Procedural rendering. - Export to obj, pyl, png, magica voxel, qubicle. - Ray tracing. Usage ----- - Left click: apply selected tool operation. - Middle click: rotate the view. - right click: pan the view. - Left/Right arrow: rotate the view. - Mouse wheel: zoom in and out. Building -------- The building system uses scons. You can compile in debug with 'scons', and in release with 'scons mode=release'. On Windows, currently possible to build with [msys2](https://www.msys2.org/) or try prebuilt [goxel](https://packages.msys2.org/base/mingw-w64-goxel) package directly. The code is in C99, using some gnu extensions, so it does not compile with msvc. # Linux/BSD Install dependencies using your package manager. On Debian/Ubuntu: - scons - pkg-config - libglfw3-dev - libgtk-3-dev Then to build, run the command: make release # Windows You need to install msys2 mingw, and the following packages: pacman -S mingw-w64-x86_64-gcc pacman -S mingw-w64-x86_64-glfw pacman -S mingw-w64-x86_64-libtre-git pacman -S scons pacman -S make Then to build: make release Contributing ------------ In order for your contribution to Goxel to be accepted, you have to sign the [Goxel Contributor License Agreement (CLA)](doc/cla/sign-cla.md). This is mostly to allow me to distribute the mobile branch goxel under a non GPL licence. Also, please read the [contributing document](CONTRIBUTING.md). Donations --------- I you feel like it, you can support the development of Goxel with a donation at the following bitcoin address: 1QCQeWTi6Xnh3UJbwhLMgSZQAypAouTVrY goxel-0.11.0/SConstruct000066400000000000000000000112451435762723100147560ustar00rootroot00000000000000# Goxel 3D voxels editor # # copyright (c) 2018 Guillaume Chereau # # Goxel is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # Goxel is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # goxel. If not, see . import glob import os import sys vars = Variables('settings.py') vars.AddVariables( EnumVariable('mode', 'Build mode', 'debug', allowed_values=('debug', 'release', 'profile', 'analyze')), BoolVariable('werror', 'Warnings as error', True), BoolVariable('sound', 'Enable sound', False), BoolVariable('yocto', 'Enable yocto renderer', True), PathVariable('config_file', 'Config file to use', 'src/config.h'), ) target_os = str(Platform()) env = Environment(variables = vars, ENV = os.environ) conf = env.Configure() if env['mode'] == 'analyze': # Make sure clang static analyzer has a chance to override de compiler # and set CCC settings env["CC"] = os.getenv("CC") or env["CC"] env["CXX"] = os.getenv("CXX") or env["CXX"] env["ENV"].update(x for x in os.environ.items() if x[0].startswith("CCC_")) if os.environ.get('CC') == 'clang': env.Replace(CC='clang', CXX='clang++') # Hack for gcc <= 5, since pragma diagnostic push doesn't seem to work. if env['CCVERSION'] and int(env['CCVERSION'].split('.')[0]) <= 5: env.Append(CCFLAGS=['-Wno-unused-function']) # Asan & Ubsan (need to come first). if env['mode'] == 'debug' and target_os == 'posix': env.Append(CCFLAGS=['-fsanitize=address', '-fsanitize=undefined'], LINKFLAGS=['-fsanitize=address', '-fsanitize=undefined'], LIBS=['asan', 'ubsan']) # Global compilation flags. # CCFLAGS : C and C++ # CFLAGS : only C # CXXFLAGS : only C++ env.Append( CFLAGS=['-std=gnu99', '-Wall', '-Wno-unknow-pragma', '-Wno-unknown-warning-option'], CXXFLAGS=['-std=gnu++17', '-Wall', '-Wno-narrowing'] ) if env['werror']: env.Append(CCFLAGS='-Werror') if env['mode'] not in ['debug', 'analyze']: env.Append(CPPDEFINES='NDEBUG', CCFLAGS='-Ofast') if env['mode'] == 'debug': env.Append(CCFLAGS=['-O0']) if env['mode'] in ('profile', 'debug'): env.Append(CCFLAGS='-g') env.Append(CPPPATH=['src']) env.Append(CCFLAGS=['-include', '$config_file']) # Get all the c and c++ files in src, recursively. sources = [] for root, dirnames, filenames in os.walk('src'): for filename in filenames: if filename.endswith('.c') or filename.endswith('.cpp'): sources.append(os.path.join(root, filename)) # Check for libpng. if conf.CheckLibWithHeader('libpng', 'png.h', 'c'): env.Append(CPPDEFINES='HAVE_LIBPNG=1') # Linux compilation support. if target_os == 'posix': env.Append(LIBS=['GL', 'm']) # Note: add '--static' to link with all the libs needed by glfw3. env.ParseConfig('pkg-config --libs glfw3') env.ParseConfig('pkg-config --cflags --libs gtk+-3.0') # Windows compilation support. if target_os == 'msys': env.Append(CXXFLAGS=['-Wno-attributes', '-Wno-unused-variable', '-Wno-unused-function']) env.Append(LIBS=['glfw3', 'opengl32', 'Imm32', 'gdi32', 'Comdlg32', 'z', 'tre', 'intl', 'iconv'], LINKFLAGS='--static') sources += glob.glob('ext_src/glew/glew.c') env.Append(CPPPATH=['ext_src/glew']) env.Append(CPPDEFINES=['GLEW_STATIC', 'FREE_WINDOWS']) # OSX Compilation support. if target_os == 'darwin': sources += glob.glob('src/*.m') env.Append(FRAMEWORKS=['OpenGL', 'Cocoa']) env.Append(LIBS=['m', 'glfw', 'objc']) # Fix warning in noc_file_dialog (the code should be fixed instead). env.Append(CCFLAGS=['-Wno-deprecated-declarations']) env['sound'] = False # Add external libs. env.Append(CPPPATH=['ext_src/uthash']) env.Append(CPPPATH=['ext_src/stb']) env.Append(CPPPATH=['ext_src/noc']) env.Append(CPPPATH=['ext_src/xxhash']) if env['sound']: env.Append(LIBS='openal') env.Append(CPPDEFINES='SOUND=1') if not env['yocto']: env.Append(CPPDEFINES='YOCTO=0') # Append external environment flags env.Append( CFLAGS=os.environ.get("CFLAGS", "").split(), CXXFLAGS=os.environ.get("CXXFLAGS", "").split(), LINKFLAGS=os.environ.get("LDFLAGS", "").split() ) env.Program(target='goxel', source=sorted(sources)) goxel-0.11.0/data/000077500000000000000000000000001435762723100136325ustar00rootroot00000000000000goxel-0.11.0/data/fonts/000077500000000000000000000000001435762723100147635ustar00rootroot00000000000000goxel-0.11.0/data/fonts/DejaVuSans-light.ttf000066400000000000000000001357501435762723100206250ustar00rootroot000000000000000FFTMo9<GDEF&(GPOSvyl$GSUBtMATHXOS/2Y,Vcmap rUcvt z} pfpgmq4vj\gasp glyf??@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\_]`^, %Id@QX Y!-,%Id@QX Y!-,  P y PXY%%# P y PXY%-,KPX EDY!-,%E`D-,KSX%%EDY!!-,ED-,%%I%%I` ch #:e:-@%2%%A:B2SAS//2ݖ}ٻ֊A}G}G͖2ƅ%]%]@@%d%d%A2dA  d   A(]%]@%..%A  %d%@~}}~}}|d{T{%zyxw v utsrqponl!kjBjSih}gBfedcba:`^ ][ZYX YX WW2VUTUBTSSRQJQP ONMNMLKJKJIJI IH GFEDC-CBAK@?>=>=<=<; <@; :987876765 65 43 21 21 0/ 0 / .- .- ,2+*%+d*)*%)('%(A'%&% &% $#"!! d d BBBdB-B}d       -d@--d++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++5fqu-J3T99NR7s`s3VV9s3D{o{RoHT3fs +b-{T#\q#H99`#fy```{w``b{{Rffw;{J/}oo5jo{-{T7fD)fsD,,,,^@tPz(`T~.  R ~ T  :  L& |Zn.z06.j \DVh*vZ  N ! DdU./<2<2/<2<23!%!!D $hUD5 5@ K TX8Y<2991/0 P ]%3#3#5qeB@KTKT[X8Y1<20@0 @ P ` p ]#!#o$++`@1      91/<<<<<<<2220@   ]!! !3!!!!#!#!5!!5!T%Dh$ig8R>hggh`TifaabbNm!(/@U" '&( /)/))/B" ) *!#*- ) " & 0K TX8YK TKT[KT[X@8Y<<<1/299990KSX99Y"#.'5.546753.'>54&dijfod]SS\dtzq{---@A$*.U# jXV`OnZXhq) #'3@6$%&%&'$'B .$ &($4'!%   ! + 1 4K TK T[K T[KT[KT[K T[X18Y9912<0KSXY""32654&'2#"&546"32654&%3#2#"&546WccWUccUVcbWWcd1Zܻۻa ۻۼ 0@      !         B  (('+'$ .  .'.'!!199999991/9990KSX99999999Y"2]@ " ) **&:4D ^YZ UZZY0g{ "-  ' (   2'') #**(/2; 49?2J LKFO2VZ Y UY\_2j i`2uy z 2229]]3267 >73#'#"5467.54632.#"[UԠ_I{;B h]hΆ02޸SUWDi;#QX?@Yr~YW׀c?}<$$/1oX3go7@ KTKT[X8Y10@ @P`p]#o+{ 7@  KTX 8YKTX @8Y29910#&547{>;o @ <99103#654<:=JN@,       <2<2991<22990 %#'-73%g:r:g:PrPbybcy #@   <<1/<<0!!#!5!-Ө-Ӫ--@ 1073#ӤR@d10!!d1/073#B-@B/9910KSXY"3#m #@  10"32'2#"  P3343ssyzZ @@B  KTX@8Y1/20KSXY"]7!5%3!!JeJsHHժJ@'B   KTKT[KT[X8Y91/20KSX9Y"@2UVVzzvtvust]]%!!567>54&#"5>32Ls3aM_xzXE[w:mIwBC12\ps(p@.    #)&  )KTKT[X 8Y99190@ daa d!]!"&'532654&+532654&#"5>32?^jTmǹSrsY %Đ%%12wps{$& Ѳ|d @   B    K TK T[X 8Y<291/<290KSXY"@* *HYiw+&+6NO O Vfuz ]] !33##!55^%3`d^@#    KTKT[X8YKTX@8Y190!!>32!"&'532654&#",X,$^hZkʭQTժ 10$& $X@$  "% " !%190@]]"32654&.#">32# !2 LL;kPL;y$&W]ybhc@B991/0KSXY"KTX@878Y@X9Hg]]!#!3V+ #/C@% '-'0 $*$ !0991990"32654&%.54$32#"$54632654&#"HŚV г "Əُattt$X@# %!"" %190@]]7532#"543 !"&2654&#"LK:lL>$& V\s[#@<21/073#3##^M@*B$#29190KSXY" 5Ѧ`@ #<210!!!!^O@+B$#<9190KSXY"55//m$e@+$     &%K TX8Y99991/9990y z z ]%3##546?>54&#"5>32ſ8ZZ93lOa^gHZX/'eVY5^1YnFC98ŸLVV/5<4q L@2  L4307$7CM34( (+(I+*(I,=M<9912990K TK T[KT[KT[KT[XMMM@878Y@ NN/N?N]32654&#"#"&5463253>54&'&$#"3267#"$'&5476$32|{zy!orqp ˘s'6@   0210].# !267# !2'ffjzSb_^^_HHghG.@   2 99991/0`]3 !%! )5BhPa/w.,~ .@   21/0 ]!!!!!!9>ժF# )@ 21/0 ]!!!!#ZpPժH7s9@ 43 1990%!5!# !2.# !26uu^opkSUmnHF_`%; ,@ 8  221/<20P ]3!3#!#"d+9.KTX@8Y1/0@ 0@P`]3#+f B@  9 KTX@8Y991990@ 0 @ P ` ]3+53265M?nj @(B  291/<290KSXY"]@ ((764GFCUgvw    (+*66650 A@E@@@ b`hgwp  ,]q]q3! !#3wH1j%@ :1/0@ 0P]3!!_ժ @4  B    >  91/<290KSXY"p]@V   && & 45 i|{y   #,'( 4<VY ej vy ]]! !###-}-+3 y@B6 991/<2990KSXY" ]@068HGif FIWXeiy ]]!3!#j+s #@  310"32' ! ':xyLHH[[bb:@   ? 291/0@ ?_]32654&#%!2+#8/ϒs R@*  B     39991990KSX9Y""32#'# ! '? !#y;:xLHHab[T@5  B    ?  299991/<9990KSX9Y"@]@Bz%%%&'&&& 66FFhuuw]]#.+#! 32654&#A{>ٿJx~hb؍O'~@<    B %( "-"(9999190KSX99Y")])/)O)].#"!"&'532654&/.54$32Hs_wzj{r{i76vce+ٶ0/EF~n|-&J@@@1/20K TX@878Y@  @ p ]!!#!ժ+)@@   8AKTX8Y1299990]332653! ˮ®u\*$h@'B91/290KSXY"P]@b*GGZ} *&&))% 833<<7HEEIIGYVfiizvvyyu)]]!3 3J+D {@I      B     91/<2290KSXY"]@  ($ >>4 0 LMB @ Yjkg ` {|      !   # $ %  <:5306 9 ? 0FFJ@E@BBB@@ D M @@XVY Pfgab```d d d wv{xwtyywpx   []]3 3 3# #D:9:9+=; f@  1 ]@ /<20KBPX@   @    Y3 3 # #su \Y+3{@(B@@ 91/290KSXY" ]@<5000F@@@QQQe &)78@ ghxp ]]3 3#f9\ @BB K TK T[X8Y991/0KSXY"@@ )&8HGH    / 59? GJO UYfio wx ]]!!!5!sP=g՚oX;@CK TX@8YKTKT[X8Y210!#3!Xo0@CKTKT[X@8Y<10!53#5oXޏ@ 91290 # #HHu-10!5{-{ %@'   #   E&22991/9990@n0000 0!0"?'@@@@ @!@"PPPP P!P"P'p' !"'''000 0!@@@ @!PPP P!``` `!ppp p! !]]"326=7#5#"&5463!54&#"5>32߬o?`TeZ3f{bsٴ)Lfa..'' 8@  G F221/0`]4&#"326>32#"&'#3姒:{{:/Rdaadq{?@  HE210@ ].#"3267#"!2NPƳPNM]-U5++++$$>:#qZ8@G E221/0`]3#5#"3232654&#":||ǧ^daDDaq{p@$   KE9190@)?p?????,// , ooooo ]q]!3267# 32.#" ͷjbck)^Z44*,8 Cė/Y@     LK TX @8YKTX 8Y<<991/22990@P]#"!!##535463cM/ѹPhc/яNqVZ{ (J@#  &#' & G E)221/990`***]4&#"326!"&'5326=#"3253aQQR9||9=,*[cb::bcd4@  N  F21/<90`]#4&#"#3>32d||Bu\edy+@F<21/0@  @ P ` p ]3#3#`Vy D@   O  F<2991990@ @P`p]3+532653#F1iL`a( @)B F 291/<90KSXY" ]@_ ')+Vfgsw    ('(++@ h` ]q]33 ##%kǹi#y"F1/0@ @P`p]3#{"Z@&   PPF#291/<<<290@0$P$p$$$$$$$ ]>32#4&#"#4&#"#3>32)Erurw?yz|v\`gb|d{6@  N  F21/<90`]#4&#"#3>32d||Bu\`edqu{ J@  QE10@#?{{   {  {]"32654&'2#"s98V{>@ GF2210@ `]%#3>32#"&4&#"326s:{{8 daaqVZ{ >@   GE2210@ `]32654&#"#"3253#/s:||:/daDDadJ{0@    F21/90P].#"#3>32JI,:.˾`fco{'@<  S  SB %( R"E(9999190KSX99Y"']@m   . , , , ; ; ; ; $( ( *//*(() )!$'      '/)?)_))))))]]q.#"#"&'532654&/.54632NZb?ĥZlfae@f?((TT@I!*##55YQKP%$78@  F<<2991/<2990]!!;#"&5#53w{KsբN`>X{;@    NF921/290o]332653#5#"&||Cua{fc=`@'BK TX@8YKTKT[X8Y91/290KSXY"@Hj{  &&)) 55::0FFIIFH@VVYYPffiigh`ut{{uz>]]3 3#=^^\`TV5` @IU U U U   B     K TKT[KT[KT[K T[X@8YK TK T[KT[X8Y91/<2290KSXY"@" 5 IIF @ [[U P nnf yy          %%#'!%""%' $ ! # 9669 0FHF@B@@@D D D @@VVVPQRRPS T U cdejejjjn a g ouuy}x}zzxy  { v } @/   y]]333# #V`jjj;y` C@F      B   K TKT[KT[KT[X@8YKTX8Y91/<290KSXY"@   & =1 UWX f vzvt        )&% * :9746 9 0 IFE J @ YVYYWVYVV Y P o x  /]] # # 3 dkr))`HJq=V`@C        B     K TKT[X @8YKTX 8Y9129990KSX2Y"@     # 5 I O N Z Z j        '$$  )( % $ $ ' ** 755008 6 6 8 990A@@@@@@@@B E G II@TQQUPPVUVW W U U YYPffh ii`{xx   e]]+5326?3 3N|lLT3!;^^hzHTNlX` @B K TK T[X8YKTX@8Y2991/0KSXY"@B&GI  + 690 @@E@@CWY_ ``f``b ]]!!!5!qjL}e`ۓ%$w@4 %   !  % $  C %K TX@8Y<<29999999199999990&]#"&=4&+5326=46;#"3>l==k>DV[noZVtsݓXX$@6%   #%#C %K TX8YKTX@8Y<2<9999999199999990&]326=467.=4&+532;#"+FUZooZUF?l>>l?VWstݔ/IC@&=>:A$104G$ 7aD=0^* D^ J21/02#"$'&5476$"3267>54&'..#"3267#"&54632mmllmmmmllmm^^``^^⃄^]]^\^BB@zBCFInmmmmnnmmmmng^^^傁^^__^]⃅]^^! "b+/10K TKT[X@878Y!!Vu=  @  Z[Z10"32654&'2#"&546PnnPPnoO@v+..ooPOmmOOp1.-rB .@     <2<21/<<0!!#!5!!!-Ө-}}!$   7 !$ !$!$!!$p @ 104767632#"'&'&pihѵhiihҵhiѶiiiiѶiiii>2   : `   (Z4;b ;; 0    " F m " : %: h: ; ;Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. DejaVu changes are in public domain Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. DejaVu changes are in public domain DejaVu SansDejaVu SansBookBookDejaVu SansDejaVu SansDejaVu SansDejaVu SansVersion 2.35Version 2.35DejaVuSansDejaVuSansDejaVu fonts teamDejaVu fonts teamhttp://dejavu.sourceforge.nethttp://dejavu.sourceforge.netFonts are (c) Bitstream (see below). DejaVu changes are in public domain. Glyphs imported from Arev fonts are (c) Tavmjung Bah (see below) Bitstream Vera Fonts Copyright ------------------------------ Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces. The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words "Bitstream" or the word "Vera". This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "Bitstream Vera" names. The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. Except as contained in this notice, the names of Gnome, the Gnome Foundation, and Bitstream Inc., shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from the Gnome Foundation or Bitstream Inc., respectively. For further information, contact: fonts at gnome dot org. Arev Fonts Copyright ------------------------------ Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the modifications to the Bitstream Vera Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces. The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words "Tavmjong Bah" or the word "Arev". This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "Tavmjong Bah Arev" names. The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. Except as contained in this notice, the name of Tavmjong Bah shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from Tavmjong Bah. For further information, contact: tavmjong @ free . fr.Fonts are (c) Bitstream (see below). DejaVu changes are in public domain. Glyphs imported from Arev fonts are (c) Tavmjung Bah (see below) Bitstream Vera Fonts Copyright ------------------------------ Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces. The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words "Bitstream" or the word "Vera". This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "Bitstream Vera" names. The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. Except as contained in this notice, the names of Gnome, the Gnome Foundation, and Bitstream Inc., shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from the Gnome Foundation or Bitstream Inc., respectively. For further information, contact: fonts at gnome dot org. Arev Fonts Copyright ------------------------------ Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the modifications to the Bitstream Vera Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces. The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words "Tavmjong Bah" or the word "Arev". This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "Tavmjong Bah Arev" names. The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. Except as contained in this notice, the name of Tavmjong Bah shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from Tavmjong Bah. For further information, contact: tavmjong @ free . fr.http://dejavu.sourceforge.net/wiki/index.php/Licensehttp://dejavu.sourceforge.net/wiki/index.php/LicenseDejaVu SansDejaVu SansBookBook~Zh  !"#$%&'()*+,-./0123456789:;<=>@ABDEFGHIJKLMNOPQRSTUVWXYZ[\]^`triagupuni25B4uni25B6triagdnuni25BEuni25C0H18533 g DFLTzarabarmnbraicanschercyrlgeorgrekhanihebrkanalao (latn4mathpnko |ogamrunrtfngthaiKUR SND URD MKD SRB 4ISM 4KSM 4LSM 4MOL 4NSM 4ROM 4SKS 4SSM 4 RQDccmp ccmp&ccmp. " 2n <~D"V&R~IJ#<BBDDFFHHIJKLTT&4&4&4&4&4&&&&& DFLTzarabarmnbraicanschercyrlgeorgrekhanihebrkanalao (latn4mathpnko |ogamrunrtfngthaiKUR SND URD MKD SRB 4ISM 4KSM 4LSM 4MOL 4NSM 4ROM 4SKS 4SSM 4kernkern""d!0!5PKr9KD &&K9a}au9aauaau/&DaDDkkDDDDkDD)ak}/DDa9}D}&&9}k}k}&D aDY}aaauNaaau}}k}ka aakkAk&k}}DHVaD)kkDN9a}au9aau/9a}au9aau/9a}au9aau/&kD&9a}au9aau/9a}a9aa/D?}DVD aDKr9KD &&Kk}k&/<&J  !J      !"#$%& #&(*,.1< EFKKNORRVY4$,=}} P< ```h`UvZZZZZZZZrZZ8<( $(,048<$Dd "8( u(( ( ( u(( ( ( u(( ( q( f(( ~( q( r(( (( (( ( ( r(( (( (( ( ((@((@((^(V^(V =>[\@^goxel-0.11.0/data/icons/000077500000000000000000000000001435762723100147455ustar00rootroot00000000000000goxel-0.11.0/data/icons/icon128.png000066400000000000000000000246041435762723100166440ustar00rootroot00000000000000PNG  IHDR>a)KIDATx}ydWyZz].d&,!o`C Nr/矜c$qv,ab0aI6, kUo˗?{U]3]3#\95]}~.0c1c1c1c1c1c1cp]4 9;u_dRѥK[^{¥Я[={0A\elV 櫧5۾l"p]g2|e& 8ws"; TItLƍvsY{TxIG>`Or BZm)O8lrGz Y{wSn1.]&'eC*\ bwbE.A-$j>r}o?(N| RAa8sqT}?tR%?Xg8npovq]%oa!~q}\xs>xoxp bU)OYU/?NHˎOn[nam jj 97@0F0ExA L82:_ɸ9fg~`F/S\Vx˧8-_~qv-l &KGX>08}$/"i "3.\\_O+dNZ[GԑOeAS :O /)Ν 10ZmB"V$v2l np< @D0*R0M;ސwNZIUJX=<{HKN~+; axW0? H+@j!#/@%mCFMp ;> 7%D"--AT[kIm7>KIqvKKF>mwq'Wob\l>&d <bh!^\`w<8n\i\ *d2 zJNI_a%V*\ {? ZoF%h!j,AF+@+ "Ȩ.܍ \p (DP-c$ɆSI %Áe+uJJ 7w]O9^uqgeUFX1H>$) )は" .u10VPIZ {I w/Q?|9xϫb?q&~1>MFa~+FCF $a F%Ct]2 J/W@* U !ƺĠks<^`m1o-j-C57kk* @MQ &[ #hT^Da kۂ%B>R( [H*ljR0Fތ![IsK8"l+D3Xjwэ,!$"/@`|KB^hVN5t4*ѪFNLӻoA~rpW"3$t…_E0 #n-]_DZ7[xȑa[ k)"r0c \xµ!D2@dg0Q[V~qX.'6Q^xarNpuiսu/AqnPQRmV/ k,NB0!켼Nױx TXy5,?fx>L܈b 8N}YQwgxAy$ 3^sۃxX%soey { s`O֡uFvgQ>0n*BvI9LN_5h#1'a>rroԅ̗鳟y7^P"PkD`#("?^PB~jsh,UF/hJmTAeYhaks0cH[ XYJWcjUd pjpV8q1",w 3$[0Gaf?r]Zejk]Sch7ϡQ=c0.ax,Ft#@ X(-\ƟF~rD9DdcRbGN"]E֠eI^H/& xs#w<'w#(ar tIgaӶ8Xqf-QuI[ܮW#?Y9 8Yкb c dLBj%q m+j\pCTVe\6ORahmP"D΁˽C8 v]㘹V‹O,L:祢4S C{}fe.2m?`j嘚6.uA H5f%Q pIm%M8Z5j}9q$!# 4&ɜ1/(aǕczͨ/ѯaa$6zVd"#Yb A0WPػ(čeDw1y@}ƶ?,T%.8%B)$LDH%ᚼu};pX0mȀDЖe8Nӳ7cnve 8w:B-E@2Q! 0d[|mögi2+DdXdA|YI ppa7󥝘u#0qٯt]^Faz?v&goXk2T! kK6ch-jisb1 @l;Ȩ 1heD\xPIhWdP`wLM.gĵ}X<8#-<A7 P܇+{ &mH#aTw!UF*C뤓DFg#P q4Sqe{,=l 1"YFS'\/%Cxs"0xy`1./ƁW {O}{OC&]Op͸֟Cˮ!.\֐qa}IXIw]h,YD}(|VW*C_x1 nʜwFCmAJk:mXx3Mۚ{o;z*gշ¾ٙqhJ5+=^wľIؘ8`Tҳ* }Z7(m;Kytj;gܻ&`~fKǿ%w;t ؑ$w=Fw0%CAv `\@X-6XooM8"(6Bw& &dhWd+Q /h4$YϞҎVijf@A& TA^1 D] m'@+ö͌ ϹiJ>4Jn^/=V4!n&6J!(N#(rPJ1VklщlԛVI*FZDedҴfg 8ۆm' GMsmκ^l@g4d c ZiDm G4WNr*iF0݀V ^nAa+BZ$ uS@3Fub_)ĢcLJNz4nEabvy@"ί@H"@ru %5ⶄ'NhGX_퇷 cmhm"CUlУWJԫЬJ{foDLlq9ra}eW܍U/@DRēU;Zth(QJxnp 1?aR$zXL_7νҕ߰5~GN%!ݹv1=D3Jݔ?]eFIҼŴӳџ':>tբs+#%p 1t!|0d;_1y;I;4<x<[Kp_xw:Ak]ȴv(H狑1¦^%W8T =_1i\I`a*פzJZX.SA lRNt~/ 2)Bf)`3z3qߡupW?}ם'd$F@bt:b L(/>zkPZ(td:dH*|+qƻeehJXI!\oLco2#\&'? 6<) X@1 kl~zJGXgU!Fq*ɯVy_ə ,V- [ X<-zbNSWpaG\8+,ܯ^#s7Wꅇ47#!C~۹ jգh6Ncb*ZLL]ݿ$k]3F8BV;~2 9D'VPYy_&W5F7'xHJA%J_`Nkɹw-.B\%\Hon! h C-ZǨRr*iKWPY;^ 7YjDu9,= )AݶV{Jd`t%4R`iR6; @N`$V*GP'BG /U&M,j壝!Fͳ h 奧1՘u TwP^*^t:f9t| N@x} Vݫ1Pq&LR6 Ŵی j @ۋX8wh7Vb+'FGakg?PY6}(l&$`B 6BZ70D cMW'3yINH"9eDhTarzj/"* l/A>Ҧ6fLMER 1p.9v}\^S &:׃RVFuKH!ŚP NX]lϪi658^vG`@Zu%:)x>#l2$ZET [բ{ 2n[q3b *I`w}u.qnv>U +ysai *_`VzE}l3WoO{L=FC:]ą |{2'7y 1bR#b[I%zkl6\zF 0aHI$[(j(;斍6 t ^7i8`.8Hf%W>ΊYfNBCyMI"ؚRo-f"Y1.T `CHݰqZ`pnH =7K0%S (ݮApKױVMsB.CI g[L`Q= :}t;:BV0Q+Z:h I>oDbY:J:<. M SOM>\X2$$" 8-Dq )7m I%1NhQ;7`U.{Xp#S@`ƀcn:\i绩tQ! Amw*Qm_0&! F,.3\gy%QuLO.ak/x=@G[7 nh`=޻ͬ}La hSGw7'(e'0|[ Kneׯt$@oj|1FHULy@qCXȐtʓut>Ҵp Y Ȍ~W0i._K0Sm{Y\udjWTgνh1/ILbt;֓Lu^"0љHz7l.YpVhaAC"MXFDB:W'r׳;1։fɞR$IlwI%}.` C/ n`d?s+MJ m7wXM˖2r 2 -+ܾ·1[tY0h3 "Cd1lΡtr8^PԖ:cBpO UZuC %dmyUb֝uM/Mֱ>CevƧ%8YNnd^"5Lo:π.zpSVm \aZ1^n{ݪEJBSb L↝yp|9™ZD0guݭCӚ:p ]YL:D0s8~Vg{a$D*lU"]ߖgG'S%@{*nWJ3\A1x}oxtĪz7 :I51S R-IdAU-WjdVY\Tb=t`t$|V\}>kPi^K`%|6fHZX+(-85@ˠ;a٢3' ZْZk}:6<:9 ZMz6suP\Qv WB2i!͈k:DޖmFJ$JT0+}S53uHe:D s7 CX4bk* ALtm1p q0c M+WK-Iޞ=3"T/5D&P-p5[) mҥfu, 8n`o[x%J[C t ݽAz­ F-$J#FpsDW'`ؽKccq "unZ{&&Fߵͯ+5sW pnS9-Sy(`&@!U=&uv9frsxDŽ0&rA."@ [L,6X׿?ѝ/'zWM)¹ɚD+N~ @T[ [%[m9f4`. s9AX  &:]:\0$h͍ZRJ?"[{ w8:7+}RC0շ.9-]d=ـ~wyij8Z-}?z$ۙGng]rz0qGw(n oB`0vg2Ɩ?=6UOZ&d=1)7KGnޖőpUsrt]7s]0TGC>Eqp`13[O& u8.#!P mN"HT[K ȊD؟Z uS,hߒ>|XM7j3]7/csl7:E:I߮;(w[73bc90S2#@' .XiɎK\Qr0Z+(%Ds98q B!Ŗ|Sh eBzc䃏(r Hxqg6Sjf*2F$O7ʖ p]}=RݾW5A@z^7g1-E tWN ]c(K\B?1t}4cH0FZ^>wnmRqm{pq?K4DQN2H?[\j:$&\BarϹ?#@P(8YԖqE^"Z)UHyKׅp8w/JI,; )nLֱBee{gYbMnY ?x3NdU>euo__|72}nc|cA>X+,/0F3DUN) 829l/bG/TWc?W[m;'}tw<`BT[*jttO=eE yǦۋ=~.w ΢Y \A.S:}:Kf Ig[Ƈ翆 \~dPq/QrO'GeI콿v{|?8J*h ql7\;119A.7# }$Hˋ 鮡QEO7{K=[l Josn+~O/p8t=Raɩ@FZJ$n5_l7+ g0QP(AQ8+KYn>aZk_v~/mdq áCtXD˽u݁UH Ibj6V_>ڙORavb _x^r(//Cq>٨V>_S]_tdL1?GΪtH8n7P?/2[v sBp[-,-RQ7ᇨ ,=qUqf}b:r{ $qYo|&,ǿm=N^UįVAO,k_.6^8xMMd\6&`YT+F;gydzt]-RCRʹS^_F/idϻ3PX޸8p̿ ,|e|mz1CA ᄍl4jÏrQ41./3c1c1c1c1c1c1c18&\IENDB`goxel-0.11.0/data/icons/icon16.png000066400000000000000000000012561435762723100165560ustar00rootroot00000000000000PNG  IHDRauIDATxkSaƟ|Ӝ1)mvAtt JqpSDDpPq pq$(TtQZRJmM/19\rs؂> }x9tU[Ì3݉䯀;U]09E2Sԫޑ!@[oeP{( _B?ל\_x<I$^ۮ UEm#DERJJA{Gύ/l3 B:?3$QD3Z~?W PSyEVe'1?i-O<IfO@Sp+_`K΢X] \n~iAJVZ2BφBNgSTR%1;e`Y;Q5wxu0F` I7 e~+'쪐KmMVJEBA@(bAoGpZVWC170ĝDA@y A!E~2ϮP}&OeVdJM}a2i X172<,nj7;jYsj|xrtLR)9'srԡ_ /m_IENDB`goxel-0.11.0/data/icons/icon24.png000066400000000000000000000022041435762723100165470ustar00rootroot00000000000000PNG  IHDRw=KIDATx[UUk}>\38VjcVdHԓC[Ey*!ނ(c/ݜ@RQ42s.zvΜ>`88=E~|E,J{if͆ti1<_LL$T.&0|O—\ǞpС/ڹ}71En}kB4 0m-E^BE㧎??@]b<:Nh(~ܫ#T)+'JĎ~G~g߾[m ' ccZ^{PQ5vžHA+ f)ff{8M0jTƁVoX#CKn*S'Q).l!U8{g|&n8-`4X* C $rM@Cvt~\+yq#׿1V*㰬"܅d-A}~$!`4aBČCl^+! D/"=JAT@)bׂKgI)-dsUD*cJ(5@KB@@R 6@d̡* _NoUep=X0  ,[cA+ °24L 2*Q"zhM94jx5݊ 5(3`,YaQT,T ?7NJgkm輻M/z-4kq!r((I?:U&ojW,+}؏I?(ʵ ~my%sIT&=ܶkRՅʕdh`#Qx r\֪:vU*VӘC IENDB`goxel-0.11.0/data/icons/icon256.png000066400000000000000000000607231435762723100166500ustar00rootroot00000000000000PNG  IHDR\rfaIDATxydW}&XsM,h ؍lWŲoݶnhgzO=c{zfi/2㥍X$*T[n2^ȌǪ̏z*#cyラo2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C @zaq?k-.JkF念*z W ]jӧA3!#}S]-u3S~䣿cM5οQMC%gCAVp #)˹V<׮|*t6<ǚ齿sڅ2ң'T>)xkTNA ?]j> ad0%|w7sGʕު%ГoUNIGngwjO]zϟ 7V_NM]'dZ& Of8z}B00ϡ_Ӡ^晿|:z]'h^A+ 5d0A͂S__ɴAF>F:џ73GlaR@0_^wj_;}/ZӏWbGt3w#զf0")BU /zOڧO~, 12^,!)n4cNP-A5^ Zx\[S<@0s'qnm<u62##1p)mKGr~@3!R/x9X{>(,fn"T o+hәfZR/ _ 柇ы/fZAF#B)w]E5#;hWΣ"N[`a8eX9h r.!@>ڇ" A5_Onς'?SOʰ=2'O>j,rKۨn-^vV~ (,C-hpЌ HBʽkT3`:efu2FZ V5tk_'XVpp`<ǜ/a&H)j]CЮTBĴ8P B#_-t :D؍p7 ,h#p|&4̴ $SNi/i~X3TzJBSU>S?=!"@`Xyon0 u0ylL+;x8g{]݀"M2y$LD+UU إ}]!ň%]M{b~Ŵt!K|N k&BFtw{)%$!84q T% *G_Й? (T_w2pmsqHq g?gX꦳L*/J0=D0 KhwGY# ~9Ǩe\pjf0s0LU xGd 对CkT_?yY\/T]vʶՌHUޝd}ןРS hR@xr@֔y5=^V0{hfnݻb'x~h<訒`] #JR2mBBjLGu.̋2 JЃ߮"*R:/0e`f uRr _n9G ."?A3@M-^ ط]GzݍɫRЈ$IpvRBL&xMUW᷒"iY80SݩR@2IXð+$*7돡)IRoj__6töiRu 9{PU{gHnoU} hV_D\(Kw0 LuLP{$z#% 9dd͜t̃"knW^W?1bkơ%SNiG&;WW6/~@U]ܨ#_ygxXeUXkϠtJw-xB? tO!zx j@7hM7Э2X]äy "lէta3CKX|,?w)S %BJvfG^o 4k"ڤT_ s`ː/Nz)$dԿCU)!%R&UKU[4Ԕ' Yؘ0- [.Ter)O!ۚ*pE*~i!RrPYy ~gska:TM4/ WGCqVV1}L%.1s=ɔV02x&*=2I۽ORʶMs¡%<蒐6XHTb_=-Asm{#y~ ;\}o1o'GsKK[~/Dj7iJ[ؠ@` {5Y"kUJ¡%g>#r7?T5" !y$(ͰU"ICSoovUT~K)VP5tZ+#(kmkoʋwbˑ//|z[^=n.,/(! va B ~E<ݑRBB6B5CKk7+"]Uas`~KW寠, s`(.`iK;µPu3 .%"ŀi#pkZ:S>)% _AP8->};}]F 4H !$ #vCFVN걷 wT yj[|| SƕY r@G )Amw85CMVaaRrCv;v2bTsToU99 tЮ^Azߊ[;ƿ\޻ V!*!Xh6q<J[a%Aix5IXT|= am`]W87o'rɏ?v] < lI/_TE I!8-x 9Hx!lIdꀤ/Eҿ,젺M֞ߩoXP!6iZ6joY{NFt3tH!Tf:|oo@G[鼢]]WY?uCMM- oma VtSV_It>.!7w^sex A;' `Xzޫ\*{~sتqx eX- fE}0D}XAЩ#p,\2|.n5B`Xn$:L..#hWiD-\h' \=@-ɥ <*BcR%^!3ۑ^a7Qm-Ѝ\@SU'']9"f~ ArB 9Xj_Rhl{~tVAۣI*,"pkphmZG赒ɸy!jJQ}Z9^q Qx&/4:wrysy򽰜9FZ4<^[MQcW o"i':WwÇCM7;[FQͰa8%Vq];s4Â3wK>vr@b(ոF#P ?MHAJ}G 4mb瘉 UЅS8܍ {Ñ h$M!n ? uU8*y!󮫖a>~ J9vi׻v':"-h.zhfoY;S?#Vp*T苜%I@ H _7(/ pv6}bJnSI[;XH;wk{?PӧȄRniƞwrMhEN[W8ͫOM~oxO8S(;HDA}QBcdZtvx1(հp8~/T1N1`![ ݞ4B)%8sW/Yo| yݴL _,T3 A7/8pJG0~מ3hTΪtWFT\[<+{@) $T粭0(o=nooa :UtF"GHGB"+8M0B?$T:|!C>|b$!xڂЭGE'`0hl_F}95vGv=],^D6iØqkJw8w #wp3 <TXlzo52$ӱaJ5_:*:Ԥ &aD &4RJ}8j?=*TG?+7<_Au;n`K 2 ])@P TTot<XCp";8Bn-Iqq:#9vDі[ ƙ׺z0 A &ӊ#Cp>yB0g{&yB,.݁#Q5T.͋. H *5ɖ Ph$v9 y_+@TN8HY"1L=LF fthIG@p 4 S 4xG|熠C!%8*XX7K_'Ѯ]LS]DjPS% 4DjC3ǁ٘Qb:eĉ0oW0ᖼ".$i "]Ɂ@{\p\HK6 49|#C6HB78y#?oy-6/?OAH- *% *\,i&D0fKKFiv_2շ߭to)Ꮬ}RHdoC #mOH!:&իz4"$ b"D/鰘;ga۟(*>*@_ ,|/|T|4d;b"R9!@4MU/j\S<M3'F5PBgh规L$LruϯCCONh ȬIA໑F`E/j5x!8c[v*)EѷiRfpѬ'P֥ZK)A)^2aB3C HƔЗgAr,. 3 @J `*TU_SݞU)oRV5WCgjAU0й&0{# t0- _`4."s戛Э2GC}[X9Y]x^smjLtIBA$\ x΢Q-5$ zˢ.; ju`aT8IJqTTzQf_*2B{]__$:rnev `0㽝>mG`)"p,G4[`~琴"tU݂ㆵ N2D P2a( h jOȱעPnW7u5a~yG~{aЎ ej-1HR&2s~* Ɨ0+"T~T5@}7$<CQ>vnx` Cr[F)%,XDi.)tG~M@ЮL'H%ѭHAXRp:#CR"B@ 0"t <3q;j:toJ"K=o GcG"0zANy:c? {C|)K}Ղ/M{MxnVzp `36iB<` 5afAc@52UȢFN Ga&!t/|o !B; nVtE' F*&rr)_v-2U\?Ǜg^1=>rcM#j8A5ns0L, i9[NȡT r8zۃ\:V^Wo'Tܑ{qP%һY}~0mP{tw`^+vIyeЯj~p[>⺜~ "lJ!jwRLVG#`76ՔnJ[9a`擨<>ʥ=D{t3wNţ`G'ЌhoU>^RvP!.J]<͕)xpv%Ah76)KaB娡wC/)vZZ8"N܏Xyظxn{]>)؅e[M=> $Ia~~vvCCKzQ@3 Ǭ8fL+Wn>a4 "ӁnX)"/I5^Tazn2^*߃s_ƅ'i\#w~7rKaUEr +)ONξt0eK! nEXBe)4k QeuF). !`,M6x# :!W *??0{nؾ B\P\'nx5)oET7B@$c.vT؁v~?=B$4"*05t+ѩ'j]0fu#_v!{թQȪKaA3,pG)"hAUET3a-E\N tMe ?(  oE]yx_1Wխ:Rw罂ξ㡭96g )!Wq1P[x-8:" RU ˦`!TOqDn}ϥL59gະr%X"B,d?)8:D]=1/y["@}y4k硦8 OV yp]&3BA]G.dR驓R%`` aT &DB!xE [}] B+Wa `!G{FMDx\զ;$e[39-A @V#һ% ,L%igY,y,0I ۓLSu)="OPKp+fla)8{-0}XN(Dƫ#D `~G :)!}"z)TsNgG>I/Âu ,L|ʚ|#?}'0/.Ec`!Xڛ*`5קԿxC~0_H[bQ?BIUuЃJI   zG;YGun=*+kBk3AϬ{JKUastZ+Xމ`RA1<pOD~v튲y/raׯ|g! a`!|G'h!*uQӕH׾+m'2 ^g_g,Dv"SbR`4z H!갍j h3A8}zUR!^} }aNrLDD $B)$ imE,sƋBp YD ӄQB[ACh#>~&&@"cڍzl?@7&G =H@VȂ[n\+sp2`i"\&} L#}$/|ĦA;ѿ Ic $[ $U B`CungUJ#2 Э c]|rڞ ;YnB\nwq&'ws\m&C*1~ɇi6G:FT2+9WWӎ߮_ z"{.Z |w3bҦ@Ꮖ 4 Sj7II-^KN_mrg 3C=䜉 tګ(nl]L#rʋwoK4gK6{&&wnNgu=M4]ӿž !lyh sQ'ox\=s54h7Rؚ\z5h7/m"?W L"vCb'gr@$ V![EywFاUBS3,oo Kl3g~13 q)զ)DV":'=Y h^\XS׶Go/ ![˹V%k`>#)Սt;  q ]z≙$ȳ&ic@`j&nN0kNq޿L0Gv2${[g_B "߱(tK4üMr?wsnxя[~_< lʇ3Cg]c82vMRG9=N=H(aAz$>tw- p~w СiwK &$R5)yHcv~To߇tӂU<嵥Ļ3vwӯ8@lA +_Gaha " t`O}o~sp)!nM3r--#ě?TN,@MӉSD//mbZ@=RsT}=9>]d)๛ظU$ʡB jx* @WiB> 8z~,7L$FFhfٯa} `Ϟ=CX4Ku$#CtW/ވWL& *6ןFs(-J# -N @lj TJMtĦAo0_/-Jޛ}ʭa<{f[|rӇjLlIUp ڋh7/R+W<AVC0)0B AAJ˯ļy/t}bwkEz,jςmĂ ^UQ<{1tL{8d ̧ByƳS \_pڧw˜J' 'DmcD  PhIn,J~' 57SȽZ%}L&LcDpg|$JP^ =፴;  :~緔0`bn?RJP)![%&Bn07jVuF}|Btr幃H,-]8QXBVLR:Fy_Bq1ɱG=T$Ԕ029¸_o"&M7uӾ_rqa׀3sN9YWUfpkQ*ߪ<ڣ`Zel|[n;WJ߭bm>{12=Rʮ%^'ibP2٣>o$Q' I4M7!u3^F0DӠSG!7]<5h'KE~"&Vwa(oҐB07͵jRGI){U]~Սg1t'hlʪRBUO"js)JS @_~AzC8 @3@c@pzA7<Za62fZ+[h2`SWϢ<hD0B7u-ImcʗQ6‘+I>@ zX93'n^+HI׏|bXtCU9=Z"Rfœ m:Av'{U_2ڍKѸaP4Hä*X%*Byn,{5]"v`=l>/e*O| R@3,Pӂ@pلHwc_EPcmL@QgP%R ߿+_۩lL~D}IE54gQ^^BF赵K_THOm$[;%ɀR("`4 A %8]0M ~@vll3Egݧ}42kؑz̀Sclg_ODFDU6(ݎ>混N Jֶ-Q BMD"Q`0PUARx%ݝ\TO3f-7Ic+DtSO)j Q({ v:lMt Ma" *#RJ0)%y<́491cBӵAb"8ٿB+G^<6מӃ-i'msmw$wM>g8 ` ,aat 0 ,E ?@Hx\y$gK 5N``aWϠVyKȱWX FywgN]%! >_tXrsm~NmMF)%$S4Р4݄4|!Ĥc?A1D~Vթ&7L3G`^ `ֲcCL߻s%̠Bp#U6OzC8 R!Du.)8x Nۙ RP?<ܖ#nvPvW9|կ4$ns t:}w2ӿ-lШBtA OHY-!!8? }-( @Aоb2n4a)8Bn:P &;ك)8 |_En0@K).~#JBzRt@ݹ~cF?;=RpA:DCvaԧX4ƤL@rL]F*`q`E 3tj]0HDU{FS 450ߍrFmRJ"#!) N.Lmq#`4 >(z}DJc6ePd}ίiQv^+5'&,fݾ}ײMGKA٠LcMbp|{àdHȢ:y+I4=*!M'sTn9} >"aN}%Aځ(xwЌh'42#tP$j\@~mRvd@wIAJ1 EvLruڵ-jD̞@n䖖P!&(˜80%TSe"J#`a|. 1@x΀ڞȪ,5S}٬Qx`Gb:oy%G˴" e+o?J^z*p̘~om%6F?0pYW&el7a"ѧ{=G{ n)p_$syb?@Rj?2z;_GL&0D4c)Dr¯)8sfQ i#!N!lr:?O!y#)_/ R0 0/6qáP-gX YJ j(]l@=ockXGS>繮D%DǠ~Ÿ>נ{BB?wBrryaf43A@MQC B!$~IgQJ^, VDP'?9%Ѩl>-8T$Q? DE2/XQy3 ؁Lcv %dtHA@(!>ɓ/a$;逬wNq pO*ŷ7s :gjtPB,h;mki(sGE1F|Fcf  ̻'A vx"@(MDF?Gw/SdͤXRrU +-9|dP!QJx}j3K<*.bG"~ *p, ݱ]Z2% #\pJ(B\DUM <G4_SVEIŵէh%帎wr8^pa MDl:1P- e 5S"gۖώv'?]:u䳤@Ӣ:!X-@ dh~" ܱ j"0`6\]0m5pÜC;L;LL-vGn7֋l5nE{rIv `!Tt+ʁ&@=?"lC㖗K)"[qf5@`1oXo8f&!@F$2aGߠ$/bAS>ΖO>~3 %͟܆^lM(Rw jj~a&9 UN"+246fթ(Se yW>W<4-|] TZ`~wU_\ 8--Lbh "t ?VafM3>V)n]t[Kh9S;B@4 fcLFF8oIC][:(J@AI }Z_ˉJ(2enG੆1 xg`^낒كښ9kD9S=Grxݭ%ܲh]>Qա%xtzHcBر>!2 JK0rm}{2A2S\ؘY8}4,geG' 8yK t@,m;yϲ0dgO;-rPFA"c@ Oe;G8 K&=`f}$6"QJ\00X}}RhqCP=8!=GBsI|\0bھӲz҈e@2tkk"U<=@ !$pBlZV80vA0ga1oJ(l*ҁF;,$4svxo ]$m6oRRM_5D>i4 ōHumKMr# FFÉ =R{tt;awI9ݿa FZـsLa9 ?H.N6E4@%`i{Ѣ!V[ !"ؒ@( IdFNu3۶q =N}'}hk駉 B?#em3($Ä?:gK~L@Zi8 cG5/2\t8+vĠKw4,P%M.$Ht==tmyi @6|نbتatH9&BPÄkC:{K[?1p__ڬBP|r:*njhAǼa9 }>DH`$7u)Y4˝9GhK(rFLo<7G!|01СRf)x'd07!֧=b =W?)?+1MKۏfFpӜKun8]G(Gs: ˶ @×` n^ߩkpޔaCjM#"Н%ؐk_4FڨOqQL"?zBW/^|Vծa(ْBAq碉ntp; DbqCلe- /ZsBN2sK-KJwI&&xLrǹdJhD@vc H.4-XvhTiTD XiqxLBƅG45AYoU}7Y8^ 0HTX<F<'iǾ7VԴ?;5"G753@ UwN@ar~Jkk xԩSYX'77ӅRr#a\PҦ:xKA%n(w"&9 ӄm; h$Dp-C!PՔIY<-!"f 3`엾tlo?Sډ7$܏v=I4pZ=7$ᷪ;F ;BW}PL ?xJP*ϽqrS^ew@ )\Õ`T2P DVDZBTT(hktBj3z#i\\( @"?'?Un" !/Gg?Tcae8^u¡HEq˜[' CsA5'1"`^A10k\x衇^vm'|N>ƞ9*BU7]dļ9D s<Pݰ !\&CkX0*~ &!j pBgIyo>ZnO3s TDammYL2;Ί$8ucޔ+~X*cujy 7=\z®&"9:n*iBd%` A   R!8G!8&)?~2̛vC{XyJuMR"4vӜKw^G/>>udЇw#w͕~:W(ʶm}\`7CH ↋ ! N Nth]O@P0 e;0-  * s]TVa$ ?ս$bXpHtZŸW2yͺUI=YN9I&R  s?k42 Gry'r͆iQz/ f+*(h7pDhASOR$]wP`c})\0ɐ{>*'ˆm=9Ci(ŒRpɼ~ #mCGo;Jw8>B1!9TXh7j0u މ$ cv`&P6*kmOtS.V6> \5meȰsj#ڰZUΔU}˘A2 裹0R,~6_,vrviœ$@9MT77 f*m&EF.t-lnsiOG0z;/@/{BΰZGuݴx!h X ~Gk?\y}tih*KJY=Pi-*`Lr)ELy=;Bff_[ Ǩ}@she. 5!Qo?ݍ;/ ?zת c;痲z] xno=/jVi!~:suWfw8Grw3ׂk|Q䋥-ߟq44Zfeʀi1֦b|m;NL?(z٨V݌&d|׫Uk7C:woLݺ+W~8 >w,obyƒ4MSQ xno֪FjcBreMS @QQFC}$BxL׍a\`a([ӵz|};փ>>/r0Ds1ll͋RZ[7f[7K凝|m`_6/4k_?$ٱz9kvα4MB4L@J67jRs;zu_j0-o/?S(_cٻkK6Ag?}bZ򦷽X8|B˶5-hS)%j ڭ|K)vF~sxC3CL=RybCdð# YVzm}wu}_P*DT\!i٤17 DNQno 2':uJ/+)H._Xu}$NnlTfu_}sS'O7|SbN!hfp!P؀iCJvڨ>67Lg3zFJss?[*r w]׭תV6N9K|S.WhTzK._(%.FZjV~̙3nnG/|gҫ-6T[9<Ӫ6]3;OCxb~BᣅR,]8GeuFn "#GϿT{T4 @pӪת߸ܨgNmJwXBb|/4҅s^Z˄6!jKˋҏE%K VkVxUY>F3/'ŋO߳? !#CSN9.?[*}sM\_GYYW+>~P>jthqޯTy<FF_+-<7RUe \p\e}vOm8} # G~湅//?j4j%T BF>ayEקqdȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2v;l_IENDB`goxel-0.11.0/data/icons/icon32.png000066400000000000000000000032601435762723100165510ustar00rootroot00000000000000PNG  IHDR szzwIDATxMl\W7_c;qj'!!BբڢTbXDvQ@dQP`b@B(HHT"- RBTB붉73xƞ7ͼqXӦ'R սϹ8nwSAJ57w=%Vؤ\Mܑ#xع1.xZu:'0)Ȁe04ǴO6F yJ0#~Z qTRz1rb.7pC8yCVlvT G~pf2m(Y@np]=)T"4U2Y궟y#T]ՙWk' B%!n ֤PYEq0. 8`دqpV FO9 Y-`U$1.Aҋ,FܩȀ44)q+- t%5C%mxzu P+])܃Odp|wj6/m{ҏ.Ch-ΟX~*n A=[ռص~8^?@kTޛD;R ۫  h(}ĽX֯G`B1) Os `ii1;~ą %`\@>v&DP;'^[06Ep.aAm!/! א +;0Hi{@c+@%w hAHd-tE,!*h7QOto ^' 2 s>|:Ю-¨Y :2*Z}Cw=rԿvI N.z YrcPI[. Ktu^!kdž/[a0mQQ< ˽~p.[G_Eyu!s>dg2p~Kw#&m=Y>V]qő [C*Yi Kex@}`,BAF'cY@uC,L.]n2] bw .0KE-$#(]YX@Ƭq@p0cpHzt|ZkaT QJV` S,mm\>a= uQd5|?6Y@:bX-k#, KajA܀v֭{3T/bwaεùQ_rR(\Jp ,|I kҤ5PIήnεjj = |LI9 8Xwzw9 "9(i"&Q՛[z6qog{>ѬU~2w򷦧}Cͨ>?[<̌'8W_iq|<IENDB`goxel-0.11.0/data/icons/icon48.png000066400000000000000000000056741435762723100165730ustar00rootroot00000000000000PNG  IHDR00W IDATx{ld]?{Ϭ}z7:aXڴKB Ѥ?(-ȕDD %H@V2Q $ TPRB%JBVM6 ws~q]>!OrCnkQjH0Ȃo٧[dO=ܨ᧔K/sk]k#jϙ趽 ~K`eߥyN~퇿)f峞UY?%0=4T5X'sCW Y֎mvW ;7=?|ԏs%q9"z.2rm^PFiW *(AD-l4h|kg]W.O~;-G ~EigUqtТzS'To"ن_Q޲Kb*n&#l_E%&Y "Vn}r_.)gAkp.f Z{R?o1j&hgȓy'4o~u#[=-I(e@=j96_x!ae;ZyZ,Kwi,&I۩#_n}:oAvLMP_&"Q}dIF2ҩ:Ҹ2ae yWI KwOt6^FR̿>@(IZi,)Jxjϓŝ4y#Oz4"t ~F+{诬o^89zmqs6z(!M:\}ѱ[ٺCT"l>,8Ԋ~pyFtiCopF;7٧iv|{С0( ,Ro3/ 9-g3:c,mdi(U}v(JkLўLPBK_ xh{ O "7h5c;پ.FY^ADUpy8ki~$/_x%.chXP(֍_#UÒ#R+<*v;Of(e8g%==-4ϩ*1^1.RIWY0AK .OJ$ΊwITL&vb%ɇAÊE*znx+QОK[ wnDqeid&iSx}{=)' Qk!6wWꨜrrָqoc>[a #@35d2S%*_a[gg1>+6m~;VqΉ7,nXBme,qmZqK-'V"άeFFT5)<:! J_./ORTS t.z/fyXȫ́+{hf&ܦuRƉƬ̟&DV5Fj5S (/Γ%i+|1eFt}Aei}4zr tUW}2{w*Me9}^{ZDCJf^^\d^}gg6{}*gu!<x/Xn:sdl}I'?ѱ_|4l\??l5F033%a#׻KMמOO=[Յ3?33s !7 \rYIENDB`goxel-0.11.0/data/icons/icon64.png000066400000000000000000000104551435762723100165620ustar00rootroot00000000000000PNG  IHDR@@iqIDATxkWy23ދk'qB Iq(m(h?$JT *cUQ4mJJ!T`BԸiC`'^_2;;w۹;;{qvױAf=;{3ys9˸˸˸8qǿ:Fhu~ݚX7k<!{is~\t9wI}Zuz;!{냏һePjs6u&?+:JO.·G+I%{TΚԚG&;sr{C;g-0o#ZOu9]Z(uC B|!BU#Ա2VFgP~<55XǏk?$ZGR=k4i/Eu*{ +(? jY댞;OōGSO\ujpRAZCϒt6:PKPށTPaReX1yzey<:{+y=N]_mn?7xz৽rT*\;9K3$yL'CujPA@P"1cBJ@F :H:&OY2bngճ&~ݜWC| 䓻O{ABNb"NI5<2Z52Vg*BHۓƭwn퉻V8jT!ۄ>sgrddq'8зxk2YTX ++sZ1:9 88G7ae ?$+4Hek_xY7%# sB*C) S?Mܜ&O:d8T0@Xynkk f\ڸbd,.@up/^=0*%7dZd R/UBea]U;AcfO}V㥞s8~#G4ig~F&P8@g\qhH |e-`@u8 BTe}w T'5贃3yBCˑ *S:`n4\R{my=C9y謋>ؕigē̟/YhbQBe'R?K4Fm:(%%3T(O>:ӌ<1yjgνobdMO0}^.IgstaM`F o`-(bMfY&nMm3aYd\pH%^kM΁1-t;{ako5wǾɧHy.01VF'ވY19h5Q]Cgq/.pgIڱ}kb.oeW~P`:btNy*/ Vexj3L$3'3#"MN}F8c4"ug4O{ ͌<38U:B,"F #RTaϙ@O9&l0#,rrΑ LM~s>3t̜~3WtZgHy38t /&jO^.8A S+eu4x>E@ǖs;Ϲ'Y=GU= yW3Sݹޚ]_@֖!QACt^fΡ.&Kr}ֹ@h,|j8gs,ԞWYaY!_s(t)8IyA@R\Pi#APVg9"6ϖ^m􈰅9Ak\^i[&={D4Ηl_n+NyÓ g4is9Vp}i i[!u!dQnKI R"='ĉ%O_;K*.WyJ.uL 5,9;u6m=K̵L?}MHT>Rga* zZAD)o9v1ϰFѣX+ a(4hfDݱhF!/%s=3cu35wr/]mxb gݪG{J^ oz5Mp>r,w1x Sbu3 @^e™͖-nڌOSkyUN8YY\q˧F#LV~3v1yu1i|[hY3=?R20\V  ]ͩŜz7a1T\_/ d2'-x',sxJJ W)*Oٓ ˤY?yΚ5<齷] ?܊LΉ箮|~JK9d=fr!! :Эyv8a:80, Z3d(,qKoӿ=fR+ 8vũ56wӦ髺&w~~Qߣ^"@yA;ռ435ȰYdgHg-աJe0Dy>QfiMgsDQg>jhql=r0q+^uv>$%ie&K:-%n>X6;Ka< C學 ),%M1fǎaA8MO9ΘZw?U;}Gntɀѷ54w*!Isi;4q6E+X WT?J7^zdY,%F'$_To/U?2?;Ci|];Ç7udϰ[\=7u?'藥<(ڻ:80~S*G!z}>j7ھ3*GJι63u&Do>_-.}W^r9[Sg&DG{KG ʽR_͜ /G]0\\OIWΞc˼nxPT3:33.,ft@YY7n$--- ͜9˗?Ll\QSVVC%e2R@ށ6@ѻG;@))`מR } en7_up@6Mk&'rRukų 3j!4'SmOTZRjs;w7H-%s58o^?[3%`f< ܅w; |ߖ_D\E4¬tromƖ85uj3dp;] o5Gy'ǻ68߶ x3>jȬqѣC: 77ӧswҹs/d.}7C{t5 $e(  j)V|>C)0&)`™G+CHYcR+OORJqI}6֩vegh]i()Ę|B#ٞhÎ{wRyؔW@Ͻ㱻h_{*\-n٘]q,Km6mh @V<γ0ۙ}/_D)M`۫kNG/2݉}^``S 㲳:>l0kJJVTTmܸE-[:]y+ MXQPZ3rK0/Y  ]^04]APX +|OW ]WZAjqt ~ w?w[0^~0iH=5';;IsG)ݕonwL샹WX9;x#sj(m);kQJ$)6Ɲ<9;Ю]3&ᅷݏ9yn^m׆It,t6 kҷr^3z׫kn?`4&}u;~(J>?#<vJ~~>{ZV:vGMnݒ̙s޽{ƒI!C.ްaۏ>5==EX\\իׯvb׮] k.JKKټysJH]ah ? {Q _7foC)s?-[# =ax1QԌ_&\{WSϿ4i"J\}v/upC!n=z]壀/rWV%Ǿm[ٷnܔk&jRx ^sڦe{xax_w#8b믿\ZZ޽xiڵ⨲Ai#7n߉'Zp>RRRºuի!`V^͐!CZ&1M'* RdZ pnk? '.\~J|@jZw>RF`ݲL;9vD ;=|օvty+K%qڭ@~u=?Wx/6|0CަdG/@ρZs%;\4QԩWlH5O iǥO<񄽁OAA8ʮ Say͢Ͽ=%[R_)X/3`>hW miS M_0~+GuO~өJ- 0aچtVPX\6jkj+HfcSKKn?x83Z`[1?uǪ8s=iϛm!=﹞V[6KM} `T;U=xhb7Q%;nOKiCKjܻTxW.9묳5wޝݻwۀC>w߁;;w]j  @WAs)t9Ģ̯uW5y?i,++j {vJhV$+̠:n֌t vMۧ D {K܂$ly#L~j:yc^y:=OS#H-82oɢ.n;h<9|\X:thX<}jY.oMQ5++`=r/ܤृlkQ`U fvZ[rw?-wMMi16rl겅,+LlD8.mg\vsf|VGaYles,^:t\kw)K/Muwy]?ҥKe@si55O?غu+W5xsNW+/ەO س۬>;}_N]O Hk=  }w[)#aU);vnMk$7' @ﴚ[Sӿ躻 ?jO?l:l1Ko/=U>eu7J?ڲjsbk/ Y_w ٕx5KȳI q=JN$?C!--L^xR|UC?umꫯӧK,m^*t?G({h]^+|6hnXn&ϩ.Xw_1vk8mlImm7 toQm78O_|2b TkOKK#--Ǔw܁W|> ?a{ٿUVqӽ{w6m2(frDjpm_u#^x gyf|ӝ;ws5o%ٱ[[K)uhW P-j[)|uǭry#ߠC\)-q9}c,)ܳM)a*kzo"IԱ 9MLX4mW#<\yvj(#9@]|=2#BOv R|ѣ6ͭ뺍ۀOm۶_ҿ]󎿁o4@*WSU Rb>Z/++#??~1I@ pTrr|{̗=U7Er2r6zNEfєcqɓoOsoβ-! Qjܔ_s'//_d]@g̕PknTAH7.]ʙgYvOMqv۶v mm6IֿZ4<௶{Nnܘg4s9%оz`<?gXE$+877߭xzij V`Qֵ_Ţg C 2 ҔckD}npH?~e]jz ;h\Xϋ;n7>/7me| E0 ,M /?&>Ո߽{Hw c+2iK _ÿV(@~x7\{Í_/>)_hV9Xhc(߁$%~>dvY ݮ+7_tvZ1[gyoC{p:Hy> wMԱ 5{'Lˬ@o/~1{}ڱgv3S t؞Ñ,P4 H0f@O$ FA #0, WA$ൗ_js-nKIE;*eX,wâ9ڜta!Cb/4o)eE]_x۴ ^9 G qu&39)z)Ң+9?έ?r>@P;?fW:o0 0֯5ZsǏ?qUW]>1k֬PVd baV(lH`6C8z 7o7W jk}o-<6k(ظ1jؕW<73Pen-{vzD.8 x٧Soa::Y}co{iy ?򞶏~p^d^ƕKuϿ<J/Ȁml/>VlΫ>:6ܓN?ꫯ ?&R QW}lYiO; )Z|w:;tC>f sI4H,>U}?@7 o~Ρ{ݨvDh#99~ѻW/*+MɶC݊`϶_i*Ur4Yq< ;uq9LZtm)*\bӒr0j"c=䓦\s5?$D%WdXjS}Qb[-TEIJ --ɪo J܆R@i^nU(u8njM)8o8ĭ@, {h?X03Ʈ .uT>mII <{I./kѴ$dTgNէu٫'Uucbw^ztU~y@MCY>l`#I1u:OruVwy&Cd]'90kE ZP7ߥ^7f?LJJqe9>E8˝NgsOzj̛765=>[[W[1T$ mn?OT, VXQ9կSV2TmE?OUPJ܆sqZڵkb2oVK#%ٖY.I}(+`ՔbĶWv} >"fuY,[{U>.ȱ5v#4Iٷt=#=㬦lw_g:I{ꩧL*om̜X"}ӄC4Tn-ku^mZx?)))7ch֭|e4`~L/[JW!*oNT?`h*>Zv;999̛?_&lIbz\;o,)ٓکtT*/3άH=Ar>b?߽<1 Jh@`PPFSN:#9jufBL:SOrWz  @dû ˲K;%ݷOJ ѷoߐ9r[<⪨_~%Ճ]k\7Ƽg;]O nЩS'<oOXvƵ)tTye[׻mqwX~}#'ZvJt HSɚb&B˳6 癆}ݫ&ĺVLsO;)7tce3f|lk`ݵDneNȚd2 tիW/}QTTĒ%K<%*UoX,tؑ">dag%qa^ o't%g;[JẸZ`8w޶?2nʤIʽ^3))vN<~7h_kw̰[7mʳ(G:DWsmC)d%[r*{h? EZUkdSll7$-pGnj+◛bՔYɖB@UL])6-;򉃙)V- U->7rСCvE~~>F]Ϫt+>ݹsy@KU^:{oyµwu?K7Q⪾$v~Jbcه7}ws45;Ϟr睷W7|wx.IX>W~ݿBcNi\>e=O\h֯_ɓ4iRo׬Y×_~vKmذ!c^/_DUƖ.93)h?E*vj S ޲*LJk/"Z9OAsmo_YZn+UVvn:LBHH>nI@Uv=-^wף)(|`@NF2w?Ť<α$ߠAz=wUn~lk/>g%Uۭ9t~Y>e{m^q` U '֋4IgioՂOnZ\_^XA%;j?Y]ߐ3{&fu ~sz/Rפ'Swl0v^G3{Df_yo)Xjug.Sc;Tk[RJ|>f~!D565[ЫC ،fK-=+'ߙj,u‚|>}.[i'Jl+8YϛIL"a!Xֿ%;˓Vo.B!bHK!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!BEwhѵ>6Z"|6=hdc .t o< ۀ_5c%X; s<ƶǀ{ؿ=%XVc`TŻB@8Sgzlbꅖ[ݛSQGo`lzjH muiEunXmVaQ \N3g+Q]+qج\0<9O8 $˖$"F93:{6lΆM;hf7V,wī`M%Şru5iBZrZ!8t.L,U)UGQXZ{g~^ moҊRC<P` a`dVlqPa v"?J3ʑ1Vʵ,߱幋"[r,9xuYiYz̶*\e{²Bb[_sOǻ!hj=̣Nwp=+= 2#c דW|Ta. 3}W+}F&`Oj1bGpwmOh?D! n)[,3:4eCҺb3[ne喕 6,(_\e+]:KKI9m|PrY+fuI_DG `%scx} 7Nr5e[B.!..?YSwړ췟4#nK&=3itjݙ:9xlʊ-Odnody7włdefLթw4]#5Gt`፩n_$'w!, @$FEhgh$W&=5~] g:AAoxߢY8 o~_6%[.? @ TjjI@TQnBğb9gARlV[L5ǰVruc9Bx /a` 34H$@2y#+8}/fNAz$]}) c+Wܭm׸d[vv"D%Y%C7dqf~T#:Zc-Nߒs&`ۣ~ocŒ%P*Ib[VZ^׃}v-} V ]:$j2 Ftspđs }-| QS_zyG &XNN~n /)#ccnZI:xr-I8w/V9<>&%_)hF}wꐨ pI@Q6mB ϚYGg[ؼis4.RSSiϿd_h۶MOg*/cO#_)E sh\&?/>$'MEeE6R-I-+$j$)]uEEZ7nP0Y8~X~ ~ 3yVbU,Y{2_Ye!;%:+زwGqI:_tԼCԹ~SK$i@W$i;՛7zfsk\}Cu?]rfYn{ʂ 3plE4+XcyoܾBDV̓$'x,.MnnneO+0ÞПNɔ-^Kǎ|?wG.\'\(ǩ}[~HAZ,^q΂]q$Q]<;w2+mq207׵k}'Dڽ{|oΝ0}fb'f?Dt?Q3|U2W}-1o~96KOtW ~_say/Z%aΝ|m۶MگHw*Uwbo?^'t+VBW`j?zJ4ZƊfHKOzYiWh=y[^yI뽟J4Zz, ~R UoW/ebg3V~vŻB@TfHKOzo,w?]sI_/4UH^ #5  \oV ?;8,/(? X_(󔞪kCM%EeŞxW5 (Q:w7&'_O릻|TG׹ngQ1o}^q_.pަg9&m?Yݞ[ݛQ]`\WOz7NwHl/5?bOIm:uݖPxnolon_LWĞSIyQ̜=:TZs_:cŅ%>%q3ߐ#yT%;1.hi*0'׬] OtH@)怦54H͸0=;40(knZ$Ym膁G@kڿawIyŻwZ, Oſ1[/Qiv>_<4j9uaO@H^XO']8]_ӿv H e" p7d|O&bj7q:r h <_c1[ ""cj06Ͱ(@_5=}Ic^X`3kVKж =٘]u8GedȾ!E;?`&Bo ՃŃ5x02R@Dj'sc^YLz% H|$[^ k|3^[Q be"O!gk|H@D$צ$v́Ik2]SC!p"qh1~j|*A!A@D |O0gG4; ?x 8 S,` (ѯAVfqͤA_{d_?F"qO#I@ o,,20PTfo2Ͽ/0ڟgj*f` /@\ũI-?sV5D zk=fYc21[L[>oI٤74d4@kIB klk| `Xc[Ͳ ݉\sU}- aTkEcXx^PS?U$ |pJl}A&h >͡cxJUu`iG{N؟ H? ԓD#!(wh/PEaN r+ձϧ+h @Cf}pT$/ E]X"[pb>J83$\PcO|Iԝ4wq_8@jjuI&bNܠϻaN͋4k;UQ'fs%?c?鞉)q_8 @SrnkA[I]I@ p$-ͺʾ!~`a)͟YT,.:6{1&c&*G~]H oLl^h_d`aЪX󀏂 9RÔzm;e 7Ip} )m2YmBXmdZ218"iK?EL2cX,5:Ao=-A|"! ڒ,$IJ{w6s݂ ђySpfӲH\`&Ig.ib/acpw@V'b^!уO N>L6@5_X^U20 0߾nx8jOo^,@D$i.??wnjp k1 x g#<կ0T L4f @DS]![szݘ׾W Jt5y|RLjvkH_*nRkPL[Jq30Wztj,`C2`sW/+&,}v~oޣ< @Ü֛-7 ,<I L\,  f1Mڝ3H0 |ՏAjN}8F͊4%@Z[-k\[3s:4@h;/D4c_6<9ݴ-)_ ԥ4! b_{ EPTs0z`6q7ԅ,SGzy=ވ9T\"b$$,7?r90U@UBFpZms _?ޔ&c*Ab?xLD"A'R*ŒD C/ `dc.G(jq"=9;߉A% o +fj>u x3+G# 8#Uhi_ߜHFs!1Mu!@s+0L$LF`If!xsc>긮ߊ+9 xI% " BH?'EZ܉%́~x/p*Ǻb s=ݿ}3Z _^TtH/oNRH 1RO%GKNǹ0W h_]Še@^=pjA?Fc/^ZGٚQ(;ZIBTcځٷ.l" 8տPoo 6Q/B 1=.IU^n/F#@{&@FU FfIÑ?h9@ࡪ^ƖF7L$ w'Eu !̌h700|98ʿ$7~Y/H'<wT K%I$z~/]A[d#5pa/f |A15 h i`*y(D"/X!A17A sp @~C*fHT(SR[T*.VJi %N/eܩWclG?a_RfYJ5ݫVWJ!Ѭr\勴T~jhw\Wn 0k 0-1> ڡ6Կտ濣̠j 8:xC[i 8 QZ`ƾx\XhoX0sբPsÅN}ߧ!yH#iKYm8&K>41?)"AsWA?c7Eh2[K1HkDl=FӂVX9M8>453(NPJTR::P)y,UJה&&RmWf7A8͠Կ_ԿԿRjWRQc-)1]x831r\RR݈V3XRjϿ)-GbOk`?s0L( Zlᵐ1y#mfS|v=Аpꟁyth{+XIU⥾~)A |+v؋D7Xc0`C Ps)gq1g4$sJDF\zaNKa$z3o1EhD\w"pDb;?.)wyɘ󫃻x4EY0_%iDc(K~ƾ?s<)}eXnb߀ˆ¾Mp3ű$ soԞUZ%!,`pMKœ8 sgKIٿnI@CR f߿v8:Mj3_x!~ ڷRjY=,|A*giD_,>eN[ VۘlKX'cP^R8>𺯖|qC/RZR$p{(6RR&P(?ir S ToKso ̮;ܡӁ"lpmL#h[m-E1~8sJP<˾!+&]+ο% ;v"Z!—n7x*cj m ]Y)h; )O:c/ \S\ߊ3Euz#u y+^lj(By*WN53cknƣap_uտ`5 هO0Okl&&.$Dv3X- K)ބ>Gkk'p5}!Tn{p}IJD!ՖBN`춆q@WApKlt/]zDlRR{C\Nո./mJ~*6KaFLpږ nZ\5.Gx SJ(RGDqyJ)RjRgU)^JOHHPHXRjk#UW[Ϛ(laտVa6gל^'0áaN e}p:k4Eꊁgh| ttS 8seD$wbbހXD*5e\7-Ҿ ἁG>Bʀ3!7"]@<$ 0]p @csTJDS77jcl131>]s?\/J阫M|*B-tE٘K _ծq%1%,DuEvx"Z,I +S0wLRA"(Tu'뿉=o3&q?B##XT|IXp! bo9mD/|̇U?RKc>4\;'A,_۳8&-W9s-ޮ 0k \wOϻxQ#ZB4-_`/6xhLp?~6p \?׃6>"U4<0PD&_T7bmM=I4ucO21ˍaɶ; c9=7>(/B 3ٍr5f[E $! "N$L1XsK_2,Uc5?paNG.z οEi-ӟJ:`&D?!k|E1m_&vߤ>"5 0i`1NA~c[?$R׿oH܃_G;s J2 0?C@r/]9'Vj%QտU--# ?¬L\:fa?RmX'D;a޵_9(<[0W ’$/@4\jԿ^R$5).jn$œf?P̮a t\ ̙c1yb&uh$/@I$7'Rخ(B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!BĝJh#4-䪅D/oNRH[\!B$X'1.B߉e@+ }M4I#I/oNRPIJwZ)D8!~' @8A]0 }tkb?0m (6=ߧ{ :x.>EBS&4:F\˫@z e(\`)D-uSJ+֨*VJUJڡoRlTR*ԊWJ%VտסJ=M{`pOzFݼW#q8bP|J :BRÚ: vuB.I;]57yP>]80$ 8 `̮ӘwmKr fymA|-5cy!ʺJLIRߔ}c _vBkD 0ss#m60YϠ{8̮@ q. \߁ 9?Zj212G] f|9 獅np+>.;Ҹ1Bƶ KF@d`N[ =p4pp306ceT jl P`8?-M ?Zj< ~!?2hQ<4Ԝ_Z~7EA_7׵ wBhLp"nc7sW5֑łx\"71|ʍg9R].߁`D$@"fp80Hn>.ü M&6pv#Fs!M@I{ vH&0o`Y8OCx RK#ֿ1-00 ߷sc;A?ʞ%d60\ܦZ4 3'Gɉ$n|Gh&TߜP`! _!B4Fcf5FW8^|BA3OQlI@m1\6XɌL`XP{,HPJ xF&^3Қ˝= gZP5ڿE,4~`![S+Tcc`7tLG)]'+5- 22g1ڦThʳ",MI3i{pPfo}4Nڅq. ##Oc% P<1FBB&ce 0CxhrD7֖(?Rbx19˜zv+C]CD)B$ý< ]}-Y} ]ef]iMwJ74փmk'Cj u?I1ט =v(AÀnyl(>#3ka9jnk$BjJ?cH~ǜ j+A8?'5M8'e%fmy g`>ZGWk<@N?-Mce&J !J=jM"Bb-B QR?xO($ˬc.ԗ(&(G&^-0ɣro?Q}\&~we~_l.1UјwG?v84cw!ۀu7uvGh#:O t< S/iGԿe? @&Cj6b _spi5M$a"yƜ[~$oC>Jظ7C<s !3Z)Dc59U!" @8A]s M+$B0b9Pr1G_ߜHe @!03_!e @LI($Կ9KC!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!"x Di@/@gq~B:]X6˝v;A;j_Ow}b1X8&3rz( aYìR9nHie똙ٿ$-Y{t]RJu*](!D5IF-FE\$r`q$k\t'=)͔n[R:}pyP&^[M^#z 3:;+-g죓5\nϲ϶w2ڑ!cŻ hYzgY, `fd,p| !K?b^8lnͫTUs%'Yxo^S' @`A }I/F.d[A^43K߲WmDvVݻ qݰRMVhG-6?::Ц!`{etri6mz8P۸ykrFVxt] \{g0' 獴t?((7?ug~ U|#ŖֳKN㇥үSIV JKK2|­y *Vr+Qj^Mk IVx଴(}+~L4b\]iZ뫯&/:lٗ_ /R^^@Vv+mm'a;ŵM,@.f7V^$%%=7x`:Ȉxy̛7!?HOOO\VVs7]铿‹`dNhڪ̴n={_KpUb)4#3Z)㖧E%EJq"w!4Tz%bp8pgєԻs+u諶c1)aXl:bgn:')-=kSRZb3Q#y'$v]Qq40+5iA)s1c۴IpkVY1} Uq$ M;?+'ɧ7o^Di;찜YfD eٟ>iP3]nh/x\x^/^jt]u|e}zh1cҒ荎c9;u9Vm H|)8zSGuyVϿm^ 'ヌ?ヒlڴiË?#٭s@DJ:NTlOJJa#}}$Q_ŖdSNL{bƷ3F~}..5 iii/L:9i:GKJJJ-u去x8`III\w<ì^Wܹ _bqX\']?>WWlwm=h 02Xqx7]ˊ+Gs?{gfxܵ;/,*90Cy嵗.p#^'`ij냃NԒM:q~~!nGzzCN+?&~1Ud_̯ UiTw?i)XZU'v}C+ysꄈy>%^'B)+PwG͏}.ztZs*o.sq93<3H?wo?7m˯䒋&p͕WlӻA|[;ʫ+.,pz= 6}維gQf2l/\ꮝyl|5;m$u _M,jo h3K/$ݷ{8:ui^ڵa!tի7qo:thh ^ZY-Fg(a(k zR|7EJPi( }VVR4bnW/EPt3W~4P^6#@ 9& ra2[rr|.M3>|8O> S^`]yy/6򨣘۴b嫖,ز~ݪ{u`C׻w ?!3+sC~]jm۶m6\W*߻ZuV(سj\nOs)@hT <}RTTv6] gt=tIR8D9)--mstRTTfW~]']y.ǀ,Gsa…pq{byӎ QsmJvY{61M-deeM[bUVlݱ!C{{ ?M=^ZaUVX,222x9xٕW~'1mڴ>DX>1 cG)O>d0*Qo莾.0k3'o1b~YSLUMH_uo2꓄ $tGuYr%Gf֬Ydf7H۝; JlY6k~z^䛄x'!nTbkJzTOˁ7SON]aihvI[@yNna\t|ٰ!cvT c&g2}ϥ5SQn18"fOlj?$b_F{9xMbpԑGGSx˯zQtŢ|7 n.={Fk@AA!{ӵkZOҦM[KAA!6mTHcNakpoBł̜xfg(^3՜ AJZ8c>{E[d+oԛslR5ň}՜+w'ز9E=8q&v{Xzo >@]~ .ʖ>`iq2)_~w]3oզ>Zw^͚5k85k;J)iE𡳹}4#(?+6;p '+[?i”X$}uWfysgn't:zw\/w cw]Ljj UP@|jEw @GrL-ElZZ,U[7m,+u daIm~7^KRR^9;z-aÇdR<#ʰCq~=5Չ JyAT;iɕC54:w@ٱ}ϥx<!}8: Nya9.͸1gNӺ[n~2 8m?$qJ=|_rRu;36?qdŘ#m> O3!4o^cˎћ#FEZzZew;7o>۶n_yNs͡oU:vpf}UP^0`?U{e% ڮ?ex0&fc |>G (VM0ۊKXȃz?WYmy+Wbw^-Kfgnr] 1WR Ӎ!ّaJ4.];ҩs{Yέ[[dHIOiR:j6E֕-+Wcg=,Q={?OFsd7v˱_; ΞtG6mpζQJQZZʂ Xat:GQ .W [5y! ?C. %#%:= 88$1#rn{|9brwֻ.ر#s~CfV&cxْh:ƴo'{e>U)RTWv>W 5fيMc5f͚$WKJIEy]QbRZـ@sVVP9ul޶8HQQ1 /dZ9(RD>{t<%e*w> =)8p )yyջ;\ڷo-[o=QqR^V ,޻7믹W^)5++uUf_Acǎ̟7={uϯdfe݊$rwWShv{ntؒmx+~2[1cǎe9mUsߘP,JF#uj_m͝Ǽ ӧXt:O@mu*-,#b1~\~͵V++.+?nG)EVV0c+"O^kLNjO=:1PVZi;iM:{^oҒRJf9 g-npDH@O>4X$7gu6k@NnzG^~\q_gڵg}Y-2ET{6Bm:oOvv.6m۠Yrbk{9il݉EJX!D@pϷi#.bpU,45{ޮ /3p@~G_vb)vw[x1Ck%m b%ESMMKJJXh1 ,򤧧Ts-D*+1.VM8F~G;jvWu]_qOB ~ԨvsWcm߱ŋ5t:uHfVp~~~>EE*ai@vtk[k"+5aCA^Q\}QQ#G6z-ߟ '֗?tK*t=ClT䧟*e4Ͽs| ϴo/*++; e]șڼ l o{zZc 7cdlں+;P됃+z܆tЁLV;hV;|8K,#??6w\U{"`>B1\Bv xhY?V~>6۵3}-˗-Mmm z.elUX&A46hTyszZ}xb{dSz>:#=#KJ)-)mqtC:&w+:xGۓB:RcKqmw/Zmȣ,^Eebf"?tʯ]6ʁ\Zf?@+wynWWӓҷ. 0 m{ݩ?<2;$SSSg,[Ѫuw gӦ;|Wyy(yegбSl.ѩcg 1cON"##XwToQL>~뮾n\WoP $ vyfn6&O<9JE ׯ)~IW\6[t=crYx9·oR۶mURwc۷mzeΣ$+ٟ?ޣxJNEE% o{tz3ċ$ uОA_-CyEc.\Ec&fRIO;GGt:xX D#sAGZ oޱCcXZQQqqǝP6\{<1=2(͟Z? VTTj[nVEE~p,V7p@fϞMFFz6#0XӍϸEKi8l)M@rz}F]eٙNP+_Fk97\w_}!#u'ٻwS9è/Ѽ)uǏ9?}L@wI֭[RSSiպlRE_K7G\6(D{*eȑTTTߐSc-f3@` pY;+쵇.N?DKіy^[Ҫt7oN3z}Sg3``6 \)Mt]g'|5;/9%e9綩>peZK^@nƌ$>n׮̘13 %ͮXΌd\ޅІ'M)߃):kyڣ~șΟM߻ܾîgw\ڦm](֪ mA?v{|x/.{0 >LujM `ÏQ@NE8~.)wψu:%чftH&V؈ŭAaɠk's=6`cmkޟ\2OyN=pm#; \V9,Δ8}'1tUwnHX- 8,Z"&>hD"/s/Y~'߻[ĻqwImWr^{/o/'>vQ[v38j_1kW oTMk ڈk,RL|Y<h~"D۶8k߶$"Br2>ʑ47̙_??3#zmL:X PmᅥXcTlXmۚLs^5M͔3Q>P㽏K]QH&?\#1iH$_l߾=e ͮ3{'gώKظEɇz8eD4NG 4 _a;͇xސWcb$}ݢDh5fx NFŻ~M*G4m%٘s/CVvU$uLގ O1g!yr~B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!B!BQ_B!OtpZ BC A+&PV>FB%%Kzk.ii֯k Gqq8]W i.@ v0-yB#`shŊ{9n>y@: NUkʟuVĻlMp| \V7-љiIăl}>`zv¢#e ױ|cCL뷿}9ѾmJ)v0΢4x:1/ח@[ JK΃&e76q%G\?6ݫ2+h>q-?qxvTOg4/iڬh_rIY#3RmaLRl-k0gvԙ]eu$Ypn$hvXQ. Xm5KFo>樬\v^۴>ii~4ջ=4+ 蕚l+wG:(_!"V />hoZ[,J)a.0ۍY6ntlyyj59 GM52+-w<^_'ٿ6VErv|_JdN6mak̶nuJZ%V tg̻kGG$G$wN‘%)ҔRxsWb}_\D#nZw麞9ڻwouʟΛkRVZAZzp6a߭}a]\"~"պEwg!q)׷ߦGnroݼ#>NE)TBXŞ|/ E6)oc{:%fKڍ^`mp|-۵@>|% .8MԱvִj=,X^k6M}rrrVݻ&@!l`nZ=lPuqb/0~P?> o:Y4 f|2?_|1&L\iӾ|V냺߈9*}Xy+RŷwۍzʎYĜE[y|x8e\MhM:ϵ-ח9 Fն1wy~!%R}V뻺>l0uYgi=6mKx*.Iz͢aj,V׮ob`>\rETTظq&}h^ڢi 51}X-5?ɀ3WxOlZG$9R,2/[F6UsbӖR;i;|kޚ+ .!ltBh(DZ冘- Y2 PH`XJKK]z?,Gy$)))p@O:w̍7ʟsHMs`X`oհ>T[;xؼy3{棔?fҤɺ.uL!\1mf_3rsKG.i{wQ+*|x&J\)|E6ٷy_wC؎`v'Xxv$۩un&ܺskI=NUI[@iMY X :?駟1:QFҵkW>p _…?՞n ˞9{ ưab̘1_v5SӴk"aiIޝxZ9.~ 3W&ϝp5VvfJ0៛ϮMlPQJ2PS$z{XDʨJ6m`j3 B4KM p1pѺuk>`p:<\p+XR 4PT.jWkG_'pѦM99GqF4M﷼Լy_2PptkRY; R ~׺g݊YTsbbe,[9Vl x'cKJs:tzWg(vm´[w[z@/4<Nvv+n&mOW7[:[P;zĚ0hiۣ^ )L0 20@70[ ]a$x1=^Pr =ʂ4RJ[ iB1D;v,>zbX,OW5}uC1a?@M~ןSެ|,}L6ڹ9#+`hpǹOUfOJ8H;ܻ#i۶n02-UJJQQ 9'gƔRpqfr߃H~ŷB|FhСC_F^8ڻ@/_N^CB%̜>>½yLܾ?p.۷79a Cx Z>}X,b. 3PtjsNisشuj+~_?>C板P qFe>݋1 gd})ϵuԴC_qqB4[ᄒdaVVkz;NqQi_L</^GAq]7y?0 JrR]w!@ر7tp8Rl6ۧӴZ@N 쯥Z̰N{^9Oݞd5YF]i>?psDwCG O @7 uaa:J),ƋNJ׾LI1u(B(k-pwUV9H@fdȠ(pR-R:CԺXRaU ֡]VoRZH/֡zE4!!$g|sNHHÐsZg9yzó~BS4 uV1cƎ+kQYyr|Z :T[Ƙ3$یhvY 7v̹PoOdI$fdG6&~e5$t:_ 5l-M'gmB#ydc<}#-z5uΩVC Y PNUk{u}tYc䂹u#]kعc TUVs ;}ԌX?ԥc|5^|ƙgj˺Ond+ C5&/zG$c{4u:uW} 6젍 B;) 7P3٪NeUMMT;1rN{y}r%8^ۛWO +VIl:+k3\+gMb@` ӜqM<n 6l~/8R="25$F q~ Ww {mwjwR?D6|"c"ѿ3%}rFUmv1v]Y B h՚[hԼ;~} CɄZ3FIc5 X}6vkvq"D-qc|`ԛuw*6htȳޭx4(b\ɟjjoywsM عs&Mʾ+9,J X\qSnɓ%g}.--U E+.ĺN@b`.>/WUv_7fh̝"t5:c1|Is^xE7zf/u-3Uk<Xzb5:}`_=&ol2=ƬX—t9Z  IjBkօx칊sN^YU6ml(-*k-Ӗ-{WsNO=!wm~xh0 I%#7<{NdggkOh޼w e2\:w3UٮO÷ϒUz59///׬Y kI3 +V`W@@ rrs9;Ң(;;(%Yw۟5~8՝TkyޓsNrPLI˱;,Hkf,Y_?]xIޅ^oF-tuj„+`pakg$S.:lMB'hͿHs>Bk%2<,10ߤޙ}TvʢZ=P?d+Yg^cdlrZ?1O{ݣ>=2..oπ6;sWp8T@">/iҥK>[nK袋4bٚ2eL,Iu=H(iժUz뭷x_@Z[IOH*9h[7};go⟜M٦ SW7 K&'?Yjs;ToϠfݖ/i>=<y;m4̖4rk~/r$u rzG^핗'kc3o angle {{angle}} transform { matrix {{modelview}} inverse } } {{/camera}} #declare Voxel = box {<-0.5, -0.5, -0.5>, <0.5, 0.5, 0.5>} #macro Vox(Pos, Color) object { Voxel translate Pos translate <0.5, 0.5, 0.5> texture { pigment {color rgb Color / 255} } } #end {{#light}} global_settings { ambient_light rgb<1, 1, 1> * {{ambient}} } light_source { <0, 0, 1024> color rgb <2, 2, 2> parallel point_at {{point_at}} } {{/light}} union { {{#voxels}} Vox({{pos}}, {{color}}) {{/voxels}} } goxel-0.11.0/data/palettes/000077500000000000000000000000001435762723100154535ustar00rootroot00000000000000goxel-0.11.0/data/palettes/Blues.gpl000066400000000000000000000121231435762723100172300ustar00rootroot00000000000000GIMP Palette Name: Blues # # For them rainy days ... by Daniel Egnor # 0 0 0 #000000 128 128 128 #808080 255 255 255 #FFFFFF 0 0 4 #000004 0 0 12 #00000C 0 0 16 #000010 0 0 24 #000018 0 0 32 #000020 0 0 36 #000024 0 0 44 #00002C 0 0 48 #000030 0 0 56 #000038 0 0 64 #000040 0 0 68 #000044 0 0 76 #00004C 0 0 80 #000050 0 0 88 #000058 0 0 96 #000060 0 0 100 #000064 0 0 108 #00006C 0 0 116 #000074 0 0 120 #000078 0 0 128 #000080 0 0 132 #000084 0 0 140 #00008C 0 0 148 #000094 0 0 152 #000098 0 0 160 #0000A0 0 0 164 #0000A4 0 0 172 #0000AC 0 0 180 #0000B4 0 0 184 #0000B8 0 0 192 #0000C0 0 0 200 #0000C8 0 4 200 #0004C8 0 12 200 #000CC8 0 16 204 #0010CC 0 24 204 #0018CC 0 28 208 #001CD0 0 36 208 #0024D0 0 40 208 #0028D0 0 48 212 #0030D4 0 56 212 #0038D4 0 60 216 #003CD8 0 68 216 #0044D8 0 72 216 #0048D8 0 80 220 #0050DC 0 84 220 #0054DC 0 92 224 #005CE0 0 100 224 #0064E0 0 104 224 #0068E0 0 112 228 #0070E4 0 116 228 #0074E4 0 124 232 #007CE8 0 128 232 #0080E8 0 136 232 #0088E8 0 140 236 #008CEC 0 148 236 #0094EC 0 156 240 #009CF0 0 160 240 #00A0F0 0 168 240 #00A8F0 0 172 244 #00ACF4 0 180 244 #00B4F4 0 184 248 #00B8F8 0 192 248 #00C0F8 0 200 252 #00C8FC 4 200 252 #04C8FC 12 200 252 #0CC8FC 20 204 252 #14CCFC 28 204 252 #1CCCFC 36 208 252 #24D0FC 44 208 252 #2CD0FC 52 208 252 #34D0FC 60 212 252 #3CD4FC 68 212 252 #44D4FC 76 216 252 #4CD8FC 84 216 252 #54D8FC 92 216 252 #5CD8FC 100 220 252 #64DCFC 108 220 252 #6CDCFC 116 224 252 #74E0FC 124 224 252 #7CE0FC 132 224 252 #84E0FC 140 228 252 #8CE4FC 148 228 252 #94E4FC 156 232 252 #9CE8FC 164 232 252 #A4E8FC 172 232 252 #ACE8FC 180 236 252 #B4ECFC 188 236 252 #BCECFC 196 240 252 #C4F0FC 204 240 252 #CCF0FC 212 240 252 #D4F0FC 220 244 252 #DCF4FC 228 244 252 #E4F4FC 236 248 252 #ECF8FC 244 248 252 #F4F8FC 252 252 252 #FCFCFC 248 252 252 #F8FCFC 244 252 252 #F4FCFC 240 252 252 #F0FCFC 232 252 252 #E8FCFC 228 252 252 #E4FCFC 224 252 252 #E0FCFC 216 252 252 #D8FCFC 212 252 252 #D4FCFC 208 252 252 #D0FCFC 200 252 252 #C8FCFC 196 252 252 #C4FCFC 192 252 252 #C0FCFC 184 252 252 #B8FCFC 180 252 252 #B4FCFC 176 252 252 #B0FCFC 168 252 252 #A8FCFC 164 252 252 #A4FCFC 160 252 252 #A0FCFC 156 252 252 #9CFCFC 148 252 252 #94FCFC 144 252 252 #90FCFC 140 252 252 #8CFCFC 132 252 252 #84FCFC 128 252 252 #80FCFC 124 252 252 #7CFCFC 116 252 252 #74FCFC 112 252 252 #70FCFC 108 252 252 #6CFCFC 100 252 252 #64FCFC 96 252 252 #60FCFC 92 252 252 #5CFCFC 84 252 252 #54FCFC 80 252 252 #50FCFC 76 252 252 #4CFCFC 72 252 252 #48FCFC 64 252 252 #40FCFC 60 252 252 #3CFCFC 56 252 252 #38FCFC 48 252 252 #30FCFC 44 252 252 #2CFCFC 40 252 252 #28FCFC 32 252 252 #20FCFC 28 252 252 #1CFCFC 24 252 252 #18FCFC 16 252 252 #10FCFC 12 252 252 #0CFCFC 8 252 252 #08FCFC 0 252 252 #00FCFC 0 248 252 #00F8FC 0 244 252 #00F4FC 0 240 252 #00F0FC 0 232 252 #00E8FC 0 228 252 #00E4FC 0 224 252 #00E0FC 0 216 252 #00D8FC 0 212 252 #00D4FC 0 208 252 #00D0FC 0 200 252 #00C8FC 0 196 252 #00C4FC 0 192 252 #00C0FC 0 184 252 #00B8FC 0 180 252 #00B4FC 0 176 252 #00B0FC 0 168 252 #00A8FC 0 164 252 #00A4FC 0 160 252 #00A0FC 0 156 252 #009CFC 0 148 252 #0094FC 0 144 252 #0090FC 0 140 252 #008CFC 0 132 252 #0084FC 0 128 252 #0080FC 0 124 252 #007CFC 0 116 252 #0074FC 0 112 252 #0070FC 0 108 252 #006CFC 0 100 252 #0064FC 0 96 252 #0060FC 0 92 252 #005CFC 0 84 252 #0054FC 0 80 252 #0050FC 0 76 252 #004CFC 0 72 252 #0048FC 0 64 252 #0040FC 0 60 252 #003CFC 0 56 252 #0038FC 0 48 252 #0030FC 0 44 252 #002CFC 0 40 252 #0028FC 0 32 252 #0020FC 0 28 252 #001CFC 0 24 252 #0018FC 0 16 252 #0010FC 0 12 252 #000CFC 0 8 252 #0008FC 0 0 252 #0000FC 0 0 248 #0000F8 0 0 244 #0000F4 0 0 240 #0000F0 0 0 236 #0000EC 0 0 232 #0000E8 0 0 228 #0000E4 0 0 224 #0000E0 0 0 220 #0000DC 0 0 216 #0000D8 0 0 212 #0000D4 0 0 208 #0000D0 0 0 204 #0000CC 0 0 200 #0000C8 0 0 196 #0000C4 0 0 192 #0000C0 0 0 188 #0000BC 0 0 184 #0000B8 0 0 180 #0000B4 0 0 176 #0000B0 0 0 172 #0000AC 0 0 168 #0000A8 0 0 164 #0000A4 0 0 160 #0000A0 0 0 156 #00009C 0 0 152 #000098 0 0 148 #000094 0 0 144 #000090 0 0 140 #00008C 0 0 136 #000088 0 0 132 #000084 0 0 128 #000080 0 0 124 #00007C 0 0 120 #000078 0 0 116 #000074 0 0 112 #000070 0 0 108 #00006C 0 0 104 #000068 0 0 100 #000064 0 0 96 #000060 0 0 92 #00005C 0 0 88 #000058 0 0 84 #000054 0 0 80 #000050 0 0 76 #00004C 0 0 72 #000048 0 0 68 #000044 0 0 64 #000040 0 0 60 #00003C 0 0 56 #000038 0 0 52 #000034 0 0 48 #000030 0 0 44 #00002C 0 0 40 #000028 0 0 36 #000024 0 0 32 #000020 0 0 28 #00001C 0 0 24 #000018 0 0 20 #000014 0 0 16 #000010 0 0 12 #00000C 0 0 8 #000008 0 0 0 #000000 goxel-0.11.0/data/palettes/Caramel.gpl000066400000000000000000000060471435762723100175320ustar00rootroot00000000000000GIMP Palette Name: Caramel # 48 48 48 grey19 164 136 192 172 140 192 180 144 192 188 148 192 196 152 192 204 152 192 212 156 192 220 160 192 228 164 192 236 168 192 228 160 188 216 148 184 204 136 180 192 124 176 180 112 168 168 104 164 156 92 160 144 80 156 132 68 152 120 56 144 140 84 140 160 116 132 180 144 128 200 176 120 224 208 112 212 200 120 196 188 132 184 176 144 168 168 156 156 156 164 140 144 176 128 136 188 112 124 200 96 112 212 108 112 192 124 116 172 136 116 148 152 120 128 168 120 108 180 124 84 196 124 64 212 128 40 212 128 44 212 132 48 212 136 52 212 140 56 216 144 60 216 148 64 216 148 68 216 152 72 220 156 76 220 160 80 220 164 84 220 168 88 224 168 92 224 172 96 224 176 100 224 180 104 228 184 108 228 188 112 228 188 116 228 192 120 232 196 124 232 200 128 232 204 132 232 208 136 236 212 140 232 208 140 224 204 140 216 196 140 208 192 136 200 188 136 192 180 136 188 176 132 180 172 132 172 164 132 164 160 128 156 156 128 148 148 128 144 144 124 136 136 124 128 132 124 120 128 120 112 120 120 104 116 120 100 112 116 92 104 116 84 100 116 76 96 112 68 88 112 60 84 112 52 76 108 56 80 108 60 88 108 64 96 108 72 100 108 76 108 108 80 116 108 88 120 108 92 128 108 96 136 108 104 144 104 108 148 104 112 156 104 116 164 104 124 168 104 128 176 104 132 184 104 140 188 104 144 196 104 148 204 104 156 212 100 156 208 100 156 204 100 156 200 96 156 196 96 156 192 92 156 188 92 156 184 88 156 180 88 156 176 84 156 172 84 156 168 80 156 164 80 156 160 76 156 156 76 156 152 72 156 148 72 156 144 68 156 140 68 156 136 64 156 132 64 156 124 60 160 124 72 164 128 84 168 132 96 176 136 112 180 136 124 184 140 136 188 144 148 196 148 164 196 148 164 196 148 160 196 144 156 196 144 152 192 140 148 192 140 144 192 140 140 192 136 136 192 136 132 188 132 128 188 132 124 188 132 120 188 128 116 184 128 112 184 124 108 184 124 104 184 124 104 184 120 100 180 120 96 180 116 92 180 116 88 180 116 84 176 112 80 176 112 76 176 108 72 176 108 68 176 108 64 172 104 60 172 104 56 172 100 52 172 100 48 168 96 44 160 96 44 152 96 48 140 100 52 132 100 56 120 100 60 112 104 60 100 104 64 92 104 68 80 108 72 72 108 76 60 108 80 52 112 80 40 112 84 32 112 88 20 116 92 12 116 96 0 120 100 0 120 100 0 116 100 0 112 104 0 112 104 0 108 104 0 104 108 0 104 108 0 100 112 0 96 112 0 96 112 0 92 116 4 88 116 4 84 120 4 84 120 4 80 120 4 76 124 4 76 124 4 72 128 4 68 128 4 68 128 4 64 132 4 60 132 8 56 136 28 60 136 48 68 140 72 76 144 92 80 148 116 88 152 136 96 156 160 100 160 180 108 164 204 116 168 204 116 168 204 120 168 200 124 168 200 128 168 200 128 168 196 132 168 196 136 168 192 140 168 192 140 168 192 144 168 188 148 168 188 152 168 184 156 168 184 156 168 184 160 168 180 164 168 180 168 168 180 168 168 176 172 168 176 176 168 172 180 168 172 184 168 172 184 168 168 188 168 168 192 168 164 196 168 164 196 168 164 200 168 160 204 168 160 208 168 156 212 164 148 212 168 136 216 176 goxel-0.11.0/data/palettes/Gold.gpl000066400000000000000000000040361435762723100170470ustar00rootroot00000000000000GIMP Palette Name: Gold # 0 0 0 #000000 128 128 128 #808080 255 255 255 #FFFFFF 252 252 128 #FCFC80 252 248 124 #FCF87C 252 244 120 #FCF478 248 244 120 #F8F478 248 240 116 #F8F074 248 240 112 #F8F070 248 236 112 #F8EC70 244 236 108 #F4EC6C 244 232 108 #F4E86C 244 232 104 #F4E868 244 228 104 #F4E468 240 228 100 #F0E464 240 224 96 #F0E060 240 220 92 #F0DC5C 236 220 92 #ECDC5C 236 216 88 #ECD858 236 216 84 #ECD854 236 212 84 #ECD454 236 212 80 #ECD450 232 208 80 #E8D050 232 208 76 #E8D04C 232 204 76 #E8CC4C 232 204 72 #E8CC48 228 200 68 #E4C844 228 196 64 #E4C440 224 192 60 #E0C03C 224 192 56 #E0C038 224 188 56 #E0BC38 224 188 52 #E0BC34 220 184 52 #DCB834 220 184 48 #DCB830 220 180 48 #DCB430 220 180 44 #DCB42C 220 176 40 #DCB028 216 176 40 #D8B028 216 172 36 #D8AC24 216 168 32 #D8A820 212 168 28 #D4A81C 212 164 28 #D4A41C 212 164 24 #D4A418 212 160 24 #D4A018 208 160 20 #D0A014 208 156 20 #D09C14 208 156 16 #D09C10 208 152 12 #D0980C 204 152 12 #CC980C 204 148 8 #CC9408 204 144 4 #CC9004 200 140 0 #C88C00 196 136 0 #C48800 192 132 0 #C08400 188 128 0 #BC8000 184 124 0 #B87C00 180 120 0 #B47800 176 116 0 #B07400 172 112 0 #AC7000 168 108 0 #A86C00 164 104 0 #A46800 160 100 0 #A06400 156 96 0 #9C6000 152 92 0 #985C00 148 88 0 #945800 144 84 0 #905400 140 80 0 #8C5000 136 76 0 #884C00 132 72 0 #844800 128 68 0 #804400 124 64 0 #7C4000 120 60 0 #783C00 116 56 0 #743800 112 52 0 #703400 108 48 0 #6C3000 104 44 0 #682C00 100 40 0 #642800 96 36 0 #602400 92 32 0 #5C2000 88 28 0 #581C00 84 24 0 #541800 80 20 0 #501400 76 16 0 #4C1000 72 12 0 #480C00 68 8 0 #440800 64 4 0 #400400 60 0 0 #3C0000 56 0 0 #380000 52 0 0 #340000 48 0 0 #300000 44 0 0 #2C0000 40 0 0 #280000 36 0 0 #240000 32 0 0 #200000 28 0 0 #1C0000 24 0 0 #180000 20 0 0 #140000 16 0 0 #100000 12 0 0 #0C0000 8 0 0 #080000 4 0 0 #040000 0 0 0 #000000 goxel-0.11.0/data/palettes/Gray.gpl000066400000000000000000000146701435762723100170710ustar00rootroot00000000000000GIMP Palette Name: Gray Columns: 3 # 0 0 0 00 hex (0) 1 1 1 01 hex (1) 2 2 2 02 hex (2) 3 3 3 03 hex (3) 4 4 4 04 hex (4) 5 5 5 05 hex (5) 6 6 6 06 hex (6) 7 7 7 07 hex (7) 8 8 8 08 hex (8) 9 9 9 09 hex (9) 10 10 10 0A hex (10) 11 11 11 0B hex (11) 12 12 12 0C hex (12) 13 13 13 0D hex (13) 14 14 14 0E hex (14) 15 15 15 0F hex (15) 16 16 16 10 hex (16) 17 17 17 11 hex (17) 18 18 18 12 hex (18) 19 19 19 13 hex (19) 20 20 20 14 hex (20) 21 21 21 15 hex (21) 22 22 22 16 hex (22) 23 23 23 17 hex (23) 24 24 24 18 hex (24) 25 25 25 19 hex (25) 26 26 26 1A hex (26) 27 27 27 1B hex (27) 28 28 28 1C hex (28) 29 29 29 1D hex (29) 30 30 30 1E hex (30) 31 31 31 1F hex (31) 32 32 32 20 hex (32) 33 33 33 21 hex (33) 34 34 34 22 hex (34) 35 35 35 23 hex (35) 36 36 36 24 hex (36) 37 37 37 25 hex (37) 38 38 38 26 hex (38) 39 39 39 27 hex (39) 40 40 40 28 hex (40) 41 41 41 29 hex (41) 42 42 42 2A hex (42) 43 43 43 2B hex (43) 44 44 44 2C hex (44) 45 45 45 2D hex (45) 46 46 46 2E hex (46) 47 47 47 2F hex (47) 48 48 48 30 hex (48) 49 49 49 31 hex (49) 50 50 50 32 hex (50) 51 51 51 33 hex (51) 52 52 52 34 hex (52) 53 53 53 35 hex (53) 54 54 54 36 hex (54) 55 55 55 37 hex (55) 56 56 56 38 hex (56) 57 57 57 39 hex (57) 58 58 58 3A hex (58) 59 59 59 3B hex (59) 60 60 60 3C hex (60) 61 61 61 3D hex (61) 62 62 62 3E hex (62) 63 63 63 3F hex (63) 64 64 64 40 hex (64) 65 65 65 41 hex (65) 66 66 66 42 hex (66) 67 67 67 43 hex (67) 68 68 68 44 hex (68) 69 69 69 45 hex (69) 70 70 70 46 hex (70) 71 71 71 47 hex (71) 72 72 72 48 hex (72) 73 73 73 49 hex (73) 74 74 74 4A hex (74) 75 75 75 4B hex (75) 76 76 76 4C hex (76) 77 77 77 4D hex (77) 78 78 78 4E hex (78) 79 79 79 4F hex (79) 80 80 80 50 hex (80) 81 81 81 51 hex (81) 82 82 82 52 hex (82) 83 83 83 53 hex (83) 84 84 84 54 hex (84) 85 85 85 55 hex (85) 86 86 86 56 hex (86) 87 87 87 57 hex (87) 88 88 88 58 hex (88) 89 89 89 59 hex (89) 90 90 90 5A hex (90) 91 91 91 5B hex (91) 92 92 92 5C hex (92) 93 93 93 5D hex (93) 94 94 94 5E hex (94) 95 95 95 5F hex (95) 96 96 96 60 hex (96) 97 97 97 61 hex (97) 98 98 98 62 hex (98) 99 99 99 63 hex (99) 100 100 100 64 hex (100) 101 101 101 65 hex (101) 102 102 102 66 hex (102) 103 103 103 67 hex (103) 104 104 104 68 hex (104) 105 105 105 69 hex (105) 106 106 106 6A hex (106) 107 107 107 6B hex (107) 108 108 108 6C hex (108) 109 109 109 6D hex (109) 110 110 110 6E hex (110) 111 111 111 6F hex (111) 112 112 112 70 hex (112) 113 113 113 71 hex (113) 114 114 114 72 hex (114) 115 115 115 73 hex (115) 116 116 116 74 hex (116) 117 117 117 75 hex (117) 118 118 118 76 hex (118) 119 119 119 77 hex (119) 120 120 120 78 hex (120) 121 121 121 79 hex (121) 122 122 122 7A hex (122) 123 123 123 7B hex (123) 124 124 124 7C hex (124) 125 125 125 7D hex (125) 126 126 126 7E hex (126) 127 127 127 7F hex (127) 128 128 128 80 hex (128) 129 129 129 81 hex (129) 130 130 130 82 hex (130) 131 131 131 83 hex (131) 132 132 132 84 hex (132) 133 133 133 85 hex (133) 134 134 134 86 hex (134) 135 135 135 87 hex (135) 136 136 136 88 hex (136) 137 137 137 89 hex (137) 138 138 138 8A hex (138) 139 139 139 8B hex (139) 140 140 140 8C hex (140) 141 141 141 8D hex (141) 142 142 142 8E hex (142) 143 143 143 8F hex (143) 144 144 144 90 hex (144) 145 145 145 91 hex (145) 146 146 146 92 hex (146) 147 147 147 93 hex (147) 148 148 148 94 hex (148) 149 149 149 95 hex (149) 150 150 150 96 hex (150) 151 151 151 97 hex (151) 152 152 152 98 hex (152) 153 153 153 99 hex (153) 154 154 154 9A hex (154) 155 155 155 9B hex (155) 156 156 156 9C hex (156) 157 157 157 9D hex (157) 158 158 158 9E hex (158) 159 159 159 9F hex (159) 160 160 160 A0 hex (160) 161 161 161 A1 hex (161) 162 162 162 A2 hex (162) 163 163 163 A3 hex (163) 164 164 164 A4 hex (164) 165 165 165 A5 hex (165) 166 166 166 A6 hex (166) 167 167 167 A7 hex (167) 168 168 168 A8 hex (168) 169 169 169 A9 hex (169) 170 170 170 AA hex (170) 171 171 171 AB hex (171) 172 172 172 AC hex (172) 173 173 173 AD hex (173) 174 174 174 AE hex (174) 175 175 175 AF hex (175) 176 176 176 B0 hex (176) 177 177 177 B1 hex (177) 178 178 178 B2 hex (178) 179 179 179 B3 hex (179) 180 180 180 B4 hex (180) 181 181 181 B5 hex (181) 182 182 182 B6 hex (182) 183 183 183 B7 hex (183) 184 184 184 B8 hex (184) 185 185 185 B9 hex (185) 186 186 186 BA hex (186) 187 187 187 BB hex (187) 188 188 188 BC hex (188) 189 189 189 BD hex (189) 190 190 190 BE hex (190) 191 191 191 BF hex (191) 192 192 192 C0 hex (192) 193 193 193 C1 hex (193) 194 194 194 C2 hex (194) 195 195 195 C3 hex (195) 196 196 196 C4 hex (196) 197 197 197 C5 hex (197) 198 198 198 C6 hex (198) 199 199 199 C7 hex (199) 200 200 200 C8 hex (200) 201 201 201 C9 hex (201) 202 202 202 CA hex (202) 203 203 203 CB hex (203) 204 204 204 CC hex (204) 205 205 205 CD hex (205) 206 206 206 CE hex (206) 207 207 207 CF hex (207) 208 208 208 D0 hex (208) 209 209 209 D1 hex (209) 210 210 210 D2 hex (210) 211 211 211 D3 hex (211) 212 212 212 D4 hex (212) 213 213 213 D5 hex (213) 214 214 214 D6 hex (214) 215 215 215 D7 hex (215) 216 216 216 D8 hex (216) 217 217 217 D9 hex (217) 218 218 218 DA hex (218) 219 219 219 DB hex (219) 220 220 220 DC hex (220) 221 221 221 DD hex (221) 222 222 222 DE hex (222) 223 223 223 DF hex (223) 224 224 224 E0 hex (224) 225 225 225 E1 hex (225) 226 226 226 E2 hex (226) 227 227 227 E3 hex (227) 228 228 228 E4 hex (228) 229 229 229 E5 hex (229) 230 230 230 E6 hex (230) 231 231 231 E7 hex (231) 232 232 232 E8 hex (232) 233 233 233 E9 hex (233) 234 234 234 EA hex (234) 235 235 235 EB hex (235) 236 236 236 EC hex (236) 237 237 237 ED hex (237) 238 238 238 EE hex (238) 239 239 239 EF hex (239) 240 240 240 F0 hex (240) 241 241 241 F1 hex (241) 242 242 242 F2 hex (242) 243 243 243 F3 hex (243) 244 244 244 F4 hex (244) 245 245 245 F5 hex (245) 246 246 246 F6 hex (246) 247 247 247 F7 hex (247) 248 248 248 F8 hex (248) 249 249 249 F9 hex (249) 250 250 250 FA hex (250) 251 251 251 FB hex (251) 252 252 252 FC hex (252) 253 253 253 FD hex (253) 254 254 254 FE hex (254) 255 255 255 FF hex (255) goxel-0.11.0/data/palettes/Grays.gpl000066400000000000000000000011121435762723100172370ustar00rootroot00000000000000GIMP Palette Name: Grays # 0 0 0 gray0 7 7 7 gray3 15 15 15 gray6 23 23 23 gray9 31 31 31 gray12 39 39 39 gray15 47 47 47 gray18 55 55 55 gray21 63 63 63 gray25 71 71 71 gray28 79 79 79 gray31 87 87 87 gray34 95 95 95 gray37 103 103 103 gray40 111 111 111 gray43 119 119 119 gray46 127 127 127 gray50 135 135 135 gray53 143 143 143 gray56 151 151 151 gray59 159 159 159 gray62 167 167 167 gray65 175 175 175 gray68 183 183 183 gray71 191 191 191 gray75 199 199 199 gray78 207 207 207 gray81 215 215 215 gray84 223 223 223 gray87 231 231 231 gray90 239 239 239 gray93 247 247 247 gray96 goxel-0.11.0/data/palettes/Greens.gpl000066400000000000000000000120501435762723100174000ustar00rootroot00000000000000GIMP Palette Name: Greens # 0 0 0 #000000 128 128 128 #808080 255 255 255 #FFFFFF 0 4 0 #000400 0 12 0 #000C00 0 16 0 #001000 0 24 0 #001800 0 32 0 #002000 0 36 0 #002400 0 44 0 #002C00 0 48 0 #003000 0 56 0 #003800 0 64 0 #004000 0 68 0 #004400 0 76 0 #004C00 0 80 0 #005000 0 88 0 #005800 0 96 0 #006000 0 100 0 #006400 0 108 0 #006C00 0 116 0 #007400 0 120 0 #007800 0 128 0 #008000 0 132 0 #008400 0 140 0 #008C00 0 148 0 #009400 0 152 0 #009800 0 160 0 #00A000 0 164 0 #00A400 0 172 0 #00AC00 0 180 0 #00B400 0 184 0 #00B800 0 192 0 #00C000 0 200 0 #00C800 4 200 0 #04C800 12 200 0 #0CC800 16 204 0 #10CC00 24 204 0 #18CC00 28 208 0 #1CD000 36 208 0 #24D000 40 208 0 #28D000 48 212 0 #30D400 56 212 0 #38D400 60 216 0 #3CD800 68 216 0 #44D800 72 216 0 #48D800 80 220 0 #50DC00 84 220 0 #54DC00 92 224 0 #5CE000 100 224 0 #64E000 104 224 0 #68E000 112 228 0 #70E400 116 228 0 #74E400 124 232 0 #7CE800 128 232 0 #80E800 136 232 0 #88E800 140 236 0 #8CEC00 148 236 0 #94EC00 156 240 0 #9CF000 160 240 0 #A0F000 168 240 0 #A8F000 172 244 0 #ACF400 180 244 0 #B4F400 184 248 0 #B8F800 192 248 0 #C0F800 200 252 0 #C8FC00 200 252 4 #C8FC04 200 252 12 #C8FC0C 204 252 20 #CCFC14 204 252 28 #CCFC1C 208 252 36 #D0FC24 208 252 44 #D0FC2C 208 252 52 #D0FC34 212 252 60 #D4FC3C 212 252 68 #D4FC44 216 252 76 #D8FC4C 216 252 84 #D8FC54 216 252 92 #D8FC5C 220 252 100 #DCFC64 220 252 108 #DCFC6C 224 252 116 #E0FC74 224 252 124 #E0FC7C 224 252 132 #E0FC84 228 252 140 #E4FC8C 228 252 148 #E4FC94 232 252 156 #E8FC9C 232 252 164 #E8FCA4 232 252 172 #E8FCAC 236 252 180 #ECFCB4 236 252 188 #ECFCBC 240 252 196 #F0FCC4 240 252 204 #F0FCCC 240 252 212 #F0FCD4 244 252 220 #F4FCDC 244 252 228 #F4FCE4 248 252 236 #F8FCEC 248 252 244 #F8FCF4 252 252 252 #FCFCFC 252 252 248 #FCFCF8 252 252 244 #FCFCF4 252 252 240 #FCFCF0 252 252 232 #FCFCE8 252 252 228 #FCFCE4 252 252 224 #FCFCE0 252 252 216 #FCFCD8 252 252 212 #FCFCD4 252 252 208 #FCFCD0 252 252 200 #FCFCC8 252 252 196 #FCFCC4 252 252 192 #FCFCC0 252 252 184 #FCFCB8 252 252 180 #FCFCB4 252 252 176 #FCFCB0 252 252 168 #FCFCA8 252 252 164 #FCFCA4 252 252 160 #FCFCA0 252 252 156 #FCFC9C 252 252 148 #FCFC94 252 252 144 #FCFC90 252 252 140 #FCFC8C 252 252 132 #FCFC84 252 252 128 #FCFC80 252 252 124 #FCFC7C 252 252 116 #FCFC74 252 252 112 #FCFC70 252 252 108 #FCFC6C 252 252 100 #FCFC64 252 252 96 #FCFC60 252 252 92 #FCFC5C 252 252 84 #FCFC54 252 252 80 #FCFC50 252 252 76 #FCFC4C 252 252 72 #FCFC48 252 252 64 #FCFC40 252 252 60 #FCFC3C 252 252 56 #FCFC38 252 252 48 #FCFC30 252 252 44 #FCFC2C 252 252 40 #FCFC28 252 252 32 #FCFC20 252 252 28 #FCFC1C 252 252 24 #FCFC18 252 252 16 #FCFC10 252 252 12 #FCFC0C 252 252 8 #FCFC08 252 252 0 #FCFC00 248 252 0 #F8FC00 244 252 0 #F4FC00 240 252 0 #F0FC00 232 252 0 #E8FC00 228 252 0 #E4FC00 224 252 0 #E0FC00 216 252 0 #D8FC00 212 252 0 #D4FC00 208 252 0 #D0FC00 200 252 0 #C8FC00 196 252 0 #C4FC00 192 252 0 #C0FC00 184 252 0 #B8FC00 180 252 0 #B4FC00 176 252 0 #B0FC00 168 252 0 #A8FC00 164 252 0 #A4FC00 160 252 0 #A0FC00 156 252 0 #9CFC00 148 252 0 #94FC00 144 252 0 #90FC00 140 252 0 #8CFC00 132 252 0 #84FC00 128 252 0 #80FC00 124 252 0 #7CFC00 116 252 0 #74FC00 112 252 0 #70FC00 108 252 0 #6CFC00 100 252 0 #64FC00 96 252 0 #60FC00 92 252 0 #5CFC00 84 252 0 #54FC00 80 252 0 #50FC00 76 252 0 #4CFC00 72 252 0 #48FC00 64 252 0 #40FC00 60 252 0 #3CFC00 56 252 0 #38FC00 48 252 0 #30FC00 44 252 0 #2CFC00 40 252 0 #28FC00 32 252 0 #20FC00 28 252 0 #1CFC00 24 252 0 #18FC00 16 252 0 #10FC00 12 252 0 #0CFC00 8 252 0 #08FC00 0 252 0 #00FC00 0 248 0 #00F800 0 244 0 #00F400 0 240 0 #00F000 0 236 0 #00EC00 0 232 0 #00E800 0 228 0 #00E400 0 224 0 #00E000 0 220 0 #00DC00 0 216 0 #00D800 0 212 0 #00D400 0 208 0 #00D000 0 204 0 #00CC00 0 200 0 #00C800 0 196 0 #00C400 0 192 0 #00C000 0 188 0 #00BC00 0 184 0 #00B800 0 180 0 #00B400 0 176 0 #00B000 0 172 0 #00AC00 0 168 0 #00A800 0 164 0 #00A400 0 160 0 #00A000 0 156 0 #009C00 0 152 0 #009800 0 148 0 #009400 0 144 0 #009000 0 140 0 #008C00 0 136 0 #008800 0 132 0 #008400 0 128 0 #008000 0 124 0 #007C00 0 120 0 #007800 0 116 0 #007400 0 112 0 #007000 0 108 0 #006C00 0 104 0 #006800 0 100 0 #006400 0 96 0 #006000 0 92 0 #005C00 0 88 0 #005800 0 84 0 #005400 0 80 0 #005000 0 76 0 #004C00 0 72 0 #004800 0 68 0 #004400 0 64 0 #004000 0 60 0 #003C00 0 56 0 #003800 0 52 0 #003400 0 48 0 #003000 0 44 0 #002C00 0 40 0 #002800 0 36 0 #002400 0 32 0 #002000 0 28 0 #001C00 0 24 0 #001800 0 20 0 #001400 0 16 0 #001000 0 12 0 #000C00 0 8 0 #000800 0 0 0 #000000 goxel-0.11.0/data/palettes/Hilite.gpl000066400000000000000000000065601435762723100174040ustar00rootroot00000000000000GIMP Palette Name: Hilite # 0 0 0 #000000 128 128 128 #808080 255 255 255 #FFFFFF 164 144 180 #A490B4 160 144 180 #A090B4 160 144 176 #A090B0 160 140 172 #A08CAC 160 140 168 #A08CA8 160 140 164 #A08CA4 160 136 164 #A088A4 156 136 160 #9C88A0 156 136 156 #9C889C 156 132 152 #9C8498 156 132 148 #9C8494 156 132 144 #9C8490 152 128 144 #988090 152 128 140 #98808C 152 128 136 #988088 152 128 132 #988084 152 124 132 #987C84 152 124 128 #987C80 152 124 124 #987C7C 148 124 124 #947C7C 148 124 120 #947C78 148 120 120 #947878 148 120 116 #947874 148 120 112 #947870 148 116 108 #94746C 144 116 108 #90746C 144 116 104 #907468 144 116 100 #907464 144 112 100 #907064 144 112 96 #907060 144 112 92 #90705C 144 112 88 #907058 140 108 88 #8C6C58 140 108 84 #8C6C54 140 108 80 #8C6C50 140 104 76 #8C684C 140 104 72 #8C6848 136 104 68 #886844 136 100 68 #886444 136 100 64 #886440 136 100 60 #88643C 136 96 56 #886038 136 96 52 #886034 132 96 48 #846030 132 92 44 #845C2C 132 92 40 #845C28 132 92 36 #845C24 132 88 36 #845824 132 88 32 #845820 128 88 32 #805820 128 88 28 #80581C 128 88 24 #805818 128 84 24 #805418 128 84 20 #805414 128 84 16 #805410 124 80 12 #7C500C 124 84 16 #7C5410 128 84 16 #805410 128 88 20 #805814 128 92 24 #805C18 132 92 24 #845C18 132 92 28 #845C1C 132 96 28 #84601C 136 96 32 #886020 136 100 32 #886420 136 104 36 #886824 140 104 36 #8C6824 140 108 40 #8C6C28 144 108 44 #906C2C 144 112 44 #90702C 144 112 48 #907030 144 116 48 #907430 148 116 52 #947434 148 120 52 #947834 148 120 56 #947838 152 120 56 #987838 152 124 56 #987C38 152 124 60 #987C3C 152 128 60 #98803C 156 128 64 #9C8040 156 132 64 #9C8440 156 132 68 #9C8444 160 136 68 #A08844 160 136 72 #A08848 160 140 76 #A08C4C 164 140 76 #A48C4C 164 144 76 #A4904C 164 144 80 #A49050 164 148 80 #A49450 168 148 84 #A89454 168 152 88 #A89858 172 152 88 #AC9858 172 156 92 #AC9C5C 172 160 96 #ACA060 176 160 96 #B0A060 176 164 100 #B0A464 180 164 100 #B4A464 180 168 104 #B4A868 180 172 108 #B4AC6C 184 172 108 #B8AC6C 184 176 112 #B8B070 188 176 116 #BCB074 188 180 116 #BCB474 188 180 120 #BCB478 188 184 120 #BCB878 192 184 120 #C0B878 192 188 124 #C0BC7C 196 192 128 #C4C080 196 192 132 #C4C084 196 196 132 #C4C484 200 196 136 #C8C488 200 200 136 #C8C888 200 200 140 #C8C88C 200 204 140 #C8CC8C 204 204 144 #CCCC90 204 208 144 #CCD090 208 208 148 #D0D094 208 212 148 #D0D494 208 212 152 #D0D498 208 216 152 #D0D898 212 216 156 #D4D89C 212 220 156 #D4DC9C 212 220 160 #D4DCA0 216 220 160 #D8DCA0 216 224 164 #D8E0A4 216 228 164 #D8E4A4 220 228 168 #DCE4A8 220 232 168 #DCE8A8 220 232 172 #DCE8AC 224 232 172 #E0E8AC 224 236 176 #E0ECB0 224 240 180 #E0F0B4 228 240 180 #E4F0B4 228 244 184 #E4F4B8 232 248 188 #E8F8BC 228 244 188 #E4F4BC 224 244 188 #E0F4BC 224 240 188 #E0F0BC 220 240 188 #DCF0BC 220 236 188 #DCECBC 216 236 188 #D8ECBC 216 232 188 #D8E8BC 212 232 188 #D4E8BC 212 232 184 #D4E8B8 212 228 184 #D4E4B8 208 228 184 #D0E4B8 204 224 184 #CCE0B8 204 220 184 #CCDCB8 200 220 184 #C8DCB8 196 216 184 #C4D8B8 192 212 184 #C0D4B8 192 212 180 #C0D4B4 188 212 180 #BCD4B4 188 208 180 #BCD0B4 184 208 180 #B8D0B4 184 204 180 #B8CCB4 180 204 180 #B4CCB4 180 200 180 #B4C8B4 176 200 180 #B0C8B4 176 196 180 #B0C4B4 172 196 180 #ACC4B4 172 192 180 #ACC0B4 168 192 176 #A8C0B0 168 188 176 #A8BCB0 164 188 176 #A4BCB0 160 184 176 #A0B8B0 156 180 176 #9CB4B0 goxel-0.11.0/data/palettes/Khaki.gpl000066400000000000000000000061271435762723100172140ustar00rootroot00000000000000GIMP Palette Name: Khaki # 0 0 0 #000000 128 128 128 #808080 255 255 255 #FFFFFF 144 132 108 #90846C 144 132 112 #908470 144 132 116 #908474 144 136 116 #908874 144 136 120 #908878 144 140 120 #908C78 144 140 124 #908C7C 144 140 128 #908C80 144 144 128 #909080 144 144 132 #909084 144 144 136 #909088 144 148 136 #909488 144 148 140 #90948C 144 152 140 #90988C 144 152 144 #909890 144 152 148 #909894 144 156 148 #909C94 144 156 152 #909C98 144 160 152 #90A098 144 160 156 #90A09C 144 160 160 #90A0A0 144 164 160 #90A4A0 144 164 164 #90A4A4 144 164 168 #90A4A8 144 168 168 #90A8A8 144 168 172 #90A8AC 144 172 172 #90ACAC 144 172 176 #90ACB0 144 172 180 #90ACB4 144 176 180 #90B0B4 144 176 184 #90B0B8 144 180 184 #90B4B8 144 180 188 #90B4BC 144 180 192 #90B4C0 144 184 192 #90B8C0 144 184 196 #90B8C4 148 188 192 #94BCC0 152 188 192 #98BCC0 152 188 188 #98BCBC 156 188 188 #9CBCBC 160 188 184 #A0BCB8 164 188 184 #A4BCB8 164 188 180 #A4BCB4 164 192 180 #A4C0B4 168 192 180 #A8C0B4 172 192 176 #ACC0B0 176 192 176 #B0C0B0 176 192 172 #B0C0AC 180 192 172 #B4C0AC 180 192 168 #B4C0A8 184 192 168 #B8C0A8 184 196 168 #B8C4A8 188 196 164 #BCC4A4 192 196 164 #C0C4A4 192 196 160 #C0C4A0 196 196 160 #C4C4A0 200 196 156 #C8C49C 200 200 156 #C8C89C 204 200 156 #CCC89C 204 200 152 #CCC898 208 200 152 #D0C898 208 200 148 #D0C894 212 200 148 #D4C894 216 200 148 #D8C894 216 200 144 #D8C890 220 200 144 #DCC890 220 204 144 #DCCC90 220 204 140 #DCCC8C 224 204 140 #E0CC8C 228 204 136 #E4CC88 232 204 136 #E8CC88 232 204 132 #E8CC84 236 204 132 #ECCC84 232 200 128 #E8C880 228 200 128 #E4C880 228 196 128 #E4C480 228 196 124 #E4C47C 224 196 124 #E0C47C 220 192 124 #DCC07C 220 192 120 #DCC078 216 192 120 #D8C078 216 188 120 #D8BC78 212 188 120 #D4BC78 212 188 116 #D4BC74 208 188 116 #D0BC74 208 184 116 #D0B874 204 184 116 #CCB874 204 184 112 #CCB870 204 180 112 #CCB470 200 180 112 #C8B470 196 180 108 #C4B46C 196 176 108 #C4B06C 192 176 108 #C0B06C 188 172 104 #BCAC68 184 172 104 #B8AC68 184 168 104 #B8A868 180 168 100 #B4A864 176 168 100 #B0A864 176 164 100 #B0A464 176 164 96 #B0A460 172 164 96 #ACA460 172 160 96 #ACA060 168 160 96 #A8A060 168 160 92 #A8A05C 164 160 92 #A4A05C 164 156 92 #A49C5C 160 156 92 #A09C5C 160 156 88 #A09C58 156 152 88 #9C9858 152 152 88 #989858 152 152 84 #989854 152 148 84 #989454 148 148 84 #949454 144 144 80 #909050 140 144 80 #8C9050 140 140 80 #8C8C50 140 140 76 #8C8C4C 136 140 76 #888C4C 132 136 76 #84884C 132 136 72 #848848 128 136 72 #808848 128 132 72 #808448 124 132 72 #7C8448 124 132 68 #7C8444 120 132 68 #788444 120 128 68 #788044 116 128 68 #748044 116 128 64 #748040 116 124 64 #747C40 112 124 64 #707C40 108 124 60 #6C7C3C 108 120 60 #6C783C 104 120 60 #68783C 100 116 56 #647438 96 116 56 #607438 96 112 56 #607038 92 112 52 #5C7034 88 112 52 #587034 88 108 52 #586C34 88 108 48 #586C30 84 108 48 #546C30 84 104 48 #546830 80 104 48 #506830 80 104 44 #50682C 76 104 44 #4C682C 76 100 44 #4C642C 72 100 44 #48642C 72 100 40 #486428 68 96 40 #446028 64 96 40 #406028 64 96 36 #406024 64 92 36 #405C24 60 92 36 #3C5C24 goxel-0.11.0/data/palettes/MagicaVoxel.gpl000066400000000000000000000120411435762723100203540ustar00rootroot00000000000000GIMP Palette Name: MagicaVoxel # 255 255 255 #FFFFFF 255 255 204 #FFFFCC 255 255 153 #FFFF99 255 255 102 #FFFF66 255 255 51 #FFFF33 255 255 0 #FFFF00 255 204 255 #FFCCFF 255 204 204 #FFCCCC 255 204 153 #FFCC99 255 204 102 #FFCC66 255 204 51 #FFCC33 255 204 0 #FFCC00 255 153 255 #FF99FF 255 153 204 #FF99CC 255 153 153 #FF9999 255 153 102 #FF9966 255 153 51 #FF9933 255 153 0 #FF9900 255 102 255 #FF66FF 255 102 204 #FF66CC 255 102 153 #FF6699 255 102 102 #FF6666 255 102 51 #FF6633 255 102 0 #FF6600 255 51 255 #FF33FF 255 51 204 #FF33CC 255 51 153 #FF3399 255 51 102 #FF3366 255 51 51 #FF3333 255 51 0 #FF3300 255 0 255 #FF00FF 255 0 204 #FF00CC 255 0 153 #FF0099 255 0 102 #FF0066 255 0 51 #FF0033 255 0 0 #FF0000 204 255 255 #CCFFFF 204 255 204 #CCFFCC 204 255 153 #CCFF99 204 255 102 #CCFF66 204 255 51 #CCFF33 204 255 0 #CCFF00 204 204 255 #CCCCFF 204 204 204 #CCCCCC 204 204 153 #CCCC99 204 204 102 #CCCC66 204 204 51 #CCCC33 204 204 0 #CCCC00 204 153 255 #CC99FF 204 153 204 #CC99CC 204 153 153 #CC9999 204 153 102 #CC9966 204 153 51 #CC9933 204 153 0 #CC9900 204 102 255 #CC66FF 204 102 204 #CC66CC 204 102 153 #CC6699 204 102 102 #CC6666 204 102 51 #CC6633 204 102 0 #CC6600 204 51 255 #CC33FF 204 51 204 #CC33CC 204 51 153 #CC3399 204 51 102 #CC3366 204 51 51 #CC3333 204 51 0 #CC3300 204 0 255 #CC00FF 204 0 204 #CC00CC 204 0 153 #CC0099 204 0 102 #CC0066 204 0 51 #CC0033 204 0 0 #CC0000 153 255 255 #99FFFF 153 255 204 #99FFCC 153 255 153 #99FF99 153 255 102 #99FF66 153 255 51 #99FF33 153 255 0 #99FF00 153 204 255 #99CCFF 153 204 204 #99CCCC 153 204 153 #99CC99 153 204 102 #99CC66 153 204 51 #99CC33 153 204 0 #99CC00 153 153 255 #9999FF 153 153 204 #9999CC 153 153 153 #999999 153 153 102 #999966 153 153 51 #999933 153 153 0 #999900 153 102 255 #9966FF 153 102 204 #9966CC 153 102 153 #996699 153 102 102 #996666 153 102 51 #996633 153 102 0 #996600 153 51 255 #9933FF 153 51 204 #9933CC 153 51 153 #993399 153 51 102 #993366 153 51 51 #993333 153 51 0 #993300 153 0 255 #9900FF 153 0 204 #9900CC 153 0 153 #990099 153 0 102 #990066 153 0 51 #990033 153 0 0 #990000 102 255 255 #66FFFF 102 255 204 #66FFCC 102 255 153 #66FF99 102 255 102 #66FF66 102 255 51 #66FF33 102 255 0 #66FF00 102 204 255 #66CCFF 102 204 204 #66CCCC 102 204 153 #66CC99 102 204 102 #66CC66 102 204 51 #66CC33 102 204 0 #66CC00 102 153 255 #6699FF 102 153 204 #6699CC 102 153 153 #669999 102 153 102 #669966 102 153 51 #669933 102 153 0 #669900 102 102 255 #6666FF 102 102 204 #6666CC 102 102 153 #666699 102 102 102 #666666 102 102 51 #666633 102 102 0 #666600 102 51 255 #6633FF 102 51 204 #6633CC 102 51 153 #663399 102 51 102 #663366 102 51 51 #663333 102 51 0 #663300 102 0 255 #6600FF 102 0 204 #6600CC 102 0 153 #660099 102 0 102 #660066 102 0 51 #660033 102 0 0 #660000 51 255 255 #33FFFF 51 255 204 #33FFCC 51 255 153 #33FF99 51 255 102 #33FF66 51 255 51 #33FF33 51 255 0 #33FF00 51 204 255 #33CCFF 51 204 204 #33CCCC 51 204 153 #33CC99 51 204 102 #33CC66 51 204 51 #33CC33 51 204 0 #33CC00 51 153 255 #3399FF 51 153 204 #3399CC 51 153 153 #339999 51 153 102 #339966 51 153 51 #339933 51 153 0 #339900 51 102 255 #3366FF 51 102 204 #3366CC 51 102 153 #336699 51 102 102 #336666 51 102 51 #336633 51 102 0 #336600 51 51 255 #3333FF 51 51 204 #3333CC 51 51 153 #333399 51 51 102 #333366 51 51 51 #333333 51 51 0 #333300 51 0 255 #3300FF 51 0 204 #3300CC 51 0 153 #330099 51 0 102 #330066 51 0 51 #330033 51 0 0 #330000 0 255 255 #00FFFF 0 255 204 #00FFCC 0 255 153 #00FF99 0 255 102 #00FF66 0 255 51 #00FF33 0 255 0 #00FF00 0 204 255 #00CCFF 0 204 204 #00CCCC 0 204 153 #00CC99 0 204 102 #00CC66 0 204 51 #00CC33 0 204 0 #00CC00 0 153 255 #0099FF 0 153 204 #0099CC 0 153 153 #009999 0 153 102 #009966 0 153 51 #009933 0 153 0 #009900 0 102 255 #0066FF 0 102 204 #0066CC 0 102 153 #006699 0 102 102 #006666 0 102 51 #006633 0 102 0 #006600 0 51 255 #0033FF 0 51 204 #0033CC 0 51 153 #003399 0 51 102 #003366 0 51 51 #003333 0 51 0 #003300 0 0 255 #0000FF 0 0 204 #0000CC 0 0 153 #000099 0 0 102 #000066 0 0 51 #000033 238 0 0 #EE0000 221 0 0 #DD0000 187 0 0 #BB0000 170 0 0 #AA0000 136 0 0 #880000 119 0 0 #770000 85 0 0 #550000 68 0 0 #440000 34 0 0 #220000 17 0 0 #110000 0 238 0 #00EE00 0 221 0 #00DD00 0 187 0 #00BB00 0 170 0 #00AA00 0 136 0 #008800 0 119 0 #007700 0 85 0 #005500 0 68 0 #004400 0 34 0 #002200 0 17 0 #001100 0 0 238 #0000EE 0 0 221 #0000DD 0 0 187 #0000BB 0 0 170 #0000AA 0 0 136 #000088 0 0 119 #000077 0 0 85 #000055 0 0 68 #000044 0 0 34 #000022 0 0 17 #000011 238 238 238 #EEEEEE 221 221 221 #DDDDDD 187 187 187 #BBBBBB 170 170 170 #AAAAAA 136 136 136 #888888 119 119 119 #777777 85 85 85 #555555 68 68 68 #444444 34 34 34 #222222 17 17 17 #111111 0 0 0 #000000 goxel-0.11.0/data/palettes/Pastels.gpl000066400000000000000000000006621435762723100175760ustar00rootroot00000000000000GIMP Palette Name: Pastels # Pastels -- GIMP Palette file 226 145 145 Untitled 153 221 146 Untitled 147 216 185 Untitled 148 196 211 Untitled 148 154 206 Untitled 179 148 204 Untitled 204 150 177 Untitled 204 164 153 Untitled 223 229 146 Untitled 255 165 96 Untitled 107 255 99 Untitled 101 255 204 Untitled 101 196 255 Untitled 101 107 255 Untitled 173 101 255 Untitled 255 101 244 Untitled 255 101 132 Untitled 255 101 101 Untitled goxel-0.11.0/data/palettes/Plasma.gpl000066400000000000000000000060461435762723100174020ustar00rootroot00000000000000GIMP Palette Name: Plasma # 240 240 0 240 224 0 240 208 0 240 192 0 240 176 0 240 160 0 240 144 0 240 128 0 240 112 0 240 96 0 240 80 0 240 64 0 240 48 0 240 32 0 240 16 0 240 0 0 224 224 16 224 212 16 224 200 16 224 184 16 224 172 12 224 156 12 224 144 12 224 128 12 224 116 8 224 100 8 224 88 8 224 72 8 224 60 4 224 44 4 224 32 4 224 16 0 208 208 32 208 200 32 208 188 28 208 176 28 208 164 24 208 152 24 208 140 20 208 128 20 208 116 16 208 104 16 208 92 12 208 80 12 208 68 8 208 56 8 208 44 4 208 32 0 192 192 48 192 184 48 192 176 44 192 164 40 192 156 36 192 144 32 192 136 32 192 128 28 192 116 24 192 108 20 192 96 16 192 88 16 192 80 12 192 68 8 192 60 4 192 48 0 176 176 64 176 172 60 176 164 56 176 156 52 176 148 48 176 140 44 176 132 40 176 124 36 176 120 32 176 112 28 176 104 24 176 96 20 176 88 16 176 80 12 176 72 8 176 64 0 160 160 80 160 156 76 160 152 72 160 144 64 160 140 60 160 136 56 160 128 48 160 124 44 160 120 40 160 112 32 160 108 28 160 104 24 160 96 16 160 92 12 160 88 8 160 80 0 144 144 96 144 144 92 144 140 84 144 136 80 144 132 72 144 128 64 144 128 60 144 124 52 144 120 48 144 116 40 144 112 32 144 112 28 144 108 20 144 104 16 144 100 8 144 96 0 128 128 112 128 128 108 128 128 100 128 128 92 128 124 84 128 124 76 128 124 68 128 124 60 128 120 56 128 120 48 128 120 40 128 120 32 128 116 24 128 116 16 128 116 8 128 112 0 112 112 128 112 112 120 112 112 112 grey44 112 112 104 112 116 96 112 116 88 112 116 80 112 116 72 112 120 60 112 120 52 112 120 44 112 120 36 112 124 28 112 124 20 112 124 12 112 128 0 96 96 144 96 96 136 96 100 128 96 104 116 96 108 108 96 112 96 96 112 88 96 116 80 96 120 68 96 124 60 96 128 48 96 128 40 96 132 32 96 136 20 96 140 12 96 144 0 80 80 160 80 84 152 80 88 140 80 96 128 80 100 120 80 104 108 80 112 96 80 116 88 80 120 76 80 128 64 80 132 56 80 136 44 80 144 32 80 148 24 80 152 12 80 160 0 64 64 176 64 68 168 64 76 156 64 84 144 64 92 132 64 100 120 64 108 108 64 116 96 64 120 84 64 128 72 64 136 60 64 144 48 64 152 36 64 160 24 64 168 12 64 176 0 48 48 192 48 56 180 48 64 168 48 76 156 48 84 144 48 96 128 48 104 116 48 112 104 48 124 92 48 132 80 48 144 64 48 152 52 48 160 40 48 172 28 48 180 16 48 192 0 32 32 208 32 40 196 32 52 184 32 64 168 32 76 156 32 88 140 32 100 128 32 112 112 32 124 100 32 136 84 32 148 72 32 160 56 32 172 44 32 184 28 32 196 16 32 208 0 16 16 224 16 28 212 16 40 196 16 56 180 16 68 168 16 84 152 16 96 136 16 112 120 16 124 108 16 140 92 16 152 76 16 168 60 16 180 48 16 196 32 16 208 16 16 224 0 0 0 240 0 16 224 0 32 208 0 48 192 0 64 176 0 80 160 0 96 144 0 112 128 0 128 112 0 144 96 0 160 80 0 176 64 0 192 48 0 208 32 0 224 16 0 240 0 goxel-0.11.0/data/palettes/Reds.gpl000066400000000000000000000067721435762723100170700ustar00rootroot00000000000000GIMP Palette Name: Reds # 0 0 0 #000000 128 128 128 #808080 255 255 255 #FFFFFF 76 0 0 #4C0000 72 0 0 #480000 68 0 0 #440000 64 0 0 #400000 60 0 0 #3C0000 56 0 0 #380000 52 0 0 #340000 48 0 0 #300000 44 0 0 #2C0000 40 0 0 #280000 36 0 0 #240000 32 0 0 #200000 28 0 0 #1C0000 24 0 0 #180000 20 0 0 #140000 16 0 0 #100000 12 0 0 #0C0000 8 0 0 #080000 4 0 0 #040000 0 0 0 #000000 4 0 0 #040000 4 4 4 #040404 8 4 4 #080404 12 8 8 #0C0808 16 8 8 #100808 16 12 12 #100C0C 20 12 12 #140C0C 24 16 16 #181010 28 16 16 #1C1010 28 20 20 #1C1414 32 20 20 #201414 36 24 24 #241818 40 24 24 #281818 40 28 28 #281C1C 44 28 28 #2C1C1C 48 32 32 #302020 52 32 32 #342020 52 36 36 #342424 56 36 36 #382424 60 40 40 #3C2828 64 40 40 #402828 64 44 44 #402C2C 68 44 44 #442C2C 72 48 48 #483030 76 48 48 #4C3030 76 52 52 #4C3434 80 52 52 #503434 84 56 56 #543838 88 56 56 #583838 88 60 60 #583C3C 92 60 60 #5C3C3C 92 64 64 #5C4040 96 64 64 #604040 100 64 64 #644040 100 68 68 #644444 104 68 68 #684444 104 72 72 #684848 108 72 72 #6C4848 112 72 72 #704848 112 76 76 #704C4C 116 76 76 #744C4C 116 80 80 #745050 120 80 80 #785050 124 84 84 #7C5454 128 84 84 #805454 128 88 88 #805858 132 88 88 #845858 252 252 252 #FCFCFC 252 248 248 #FCF8F8 252 244 244 #FCF4F4 252 240 240 #FCF0F0 252 236 236 #FCECEC 252 232 232 #FCE8E8 252 228 228 #FCE4E4 252 224 224 #FCE0E0 252 220 220 #FCDCDC 252 216 216 #FCD8D8 252 212 212 #FCD4D4 252 208 208 #FCD0D0 252 204 204 #FCCCCC 252 200 200 #FCC8C8 252 196 196 #FCC4C4 252 192 192 #FCC0C0 252 188 188 #FCBCBC 252 184 184 #FCB8B8 252 180 180 #FCB4B4 252 176 176 #FCB0B0 252 172 172 #FCACAC 252 168 168 #FCA8A8 252 164 164 #FCA4A4 252 160 160 #FCA0A0 252 156 156 #FC9C9C 252 152 152 #FC9898 252 148 148 #FC9494 252 144 144 #FC9090 252 140 140 #FC8C8C 252 136 136 #FC8888 252 132 132 #FC8484 252 128 128 #FC8080 252 124 124 #FC7C7C 252 120 120 #FC7878 252 116 116 #FC7474 252 112 112 #FC7070 252 108 108 #FC6C6C 252 104 104 #FC6868 252 100 100 #FC6464 252 96 96 #FC6060 252 92 92 #FC5C5C 252 88 88 #FC5858 252 84 84 #FC5454 252 80 80 #FC5050 252 76 76 #FC4C4C 252 72 72 #FC4848 252 68 68 #FC4444 252 64 64 #FC4040 252 60 60 #FC3C3C 252 56 56 #FC3838 252 52 52 #FC3434 252 48 48 #FC3030 252 44 44 #FC2C2C 252 40 40 #FC2828 252 36 36 #FC2424 252 32 32 #FC2020 252 28 28 #FC1C1C 252 24 24 #FC1818 252 20 20 #FC1414 252 16 16 #FC1010 252 12 12 #FC0C0C 252 8 8 #FC0808 252 4 4 #FC0404 252 0 0 #FC0000 248 0 0 #F80000 244 0 0 #F40000 240 0 0 #F00000 236 0 0 #EC0000 232 0 0 #E80000 228 0 0 #E40000 224 0 0 #E00000 220 0 0 #DC0000 216 0 0 #D80000 212 0 0 #D40000 208 0 0 #D00000 204 0 0 #CC0000 200 0 0 #C80000 196 0 0 #C40000 192 0 0 #C00000 188 0 0 #BC0000 184 0 0 #B80000 180 0 0 #B40000 176 0 0 #B00000 172 0 0 #AC0000 168 0 0 #A80000 164 0 0 #A40000 160 0 0 #A00000 156 0 0 #9C0000 152 0 0 #980000 148 0 0 #940000 144 0 0 #900000 140 0 0 #8C0000 136 0 0 #880000 132 0 0 #840000 128 0 0 #800000 124 0 0 #7C0000 120 0 0 #780000 116 0 0 #740000 112 0 0 #700000 108 0 0 #6C0000 104 0 0 #680000 100 0 0 #640000 96 0 0 #600000 92 0 0 #5C0000 88 0 0 #580000 84 0 0 #540000 80 0 0 #500000 goxel-0.11.0/data/palettes/Royal.gpl000066400000000000000000000105771435762723100172570ustar00rootroot00000000000000GIMP Palette Name: Royal # 0 0 0 #000000 128 128 128 #808080 255 255 255 #FFFFFF 60 0 80 #3C0050 60 0 84 #3C0054 64 0 84 #400054 64 0 88 #400058 68 0 88 #440058 68 0 92 #44005C 72 0 96 #480060 72 0 100 #480064 76 0 100 #4C0064 76 0 104 #4C0068 80 0 104 #500068 80 0 108 #50006C 84 0 112 #540070 84 0 116 #540074 88 0 116 #580074 88 0 120 #580078 92 0 120 #5C0078 92 0 124 #5C007C 96 0 128 #600080 96 0 132 #600084 100 0 132 #640084 100 0 136 #640088 104 0 136 #680088 104 0 140 #68008C 108 0 144 #6C0090 108 0 148 #6C0094 112 0 148 #700094 112 0 152 #700098 116 0 152 #740098 116 0 156 #74009C 120 0 160 #7800A0 124 4 160 #7C04A0 124 8 164 #7C08A4 128 12 164 #800CA4 128 16 164 #8010A4 132 20 168 #8414A8 132 24 168 #8418A8 136 28 168 #881CA8 136 32 172 #8820AC 140 36 172 #8C24AC 140 40 172 #8C28AC 144 44 176 #902CB0 144 48 176 #9030B0 148 52 180 #9434B4 148 56 180 #9438B4 152 60 180 #983CB4 152 64 184 #9840B8 156 68 184 #9C44B8 156 72 184 #9C48B8 160 76 188 #A04CBC 160 80 188 #A050BC 164 84 188 #A454BC 164 88 192 #A458C0 168 92 192 #A85CC0 168 96 192 #A860C0 172 100 196 #AC64C4 172 104 196 #AC68C4 176 108 200 #B06CC8 176 112 200 #B070C8 180 116 200 #B474C8 180 120 204 #B478CC 184 124 204 #B87CCC 188 128 204 #BC80CC 188 132 208 #BC84D0 192 136 208 #C088D0 192 140 208 #C08CD0 196 144 212 #C490D4 196 148 212 #C494D4 200 152 216 #C898D8 200 156 216 #C89CD8 204 160 216 #CCA0D8 204 164 220 #CCA4DC 208 168 220 #D0A8DC 208 172 220 #D0ACDC 212 176 224 #D4B0E0 212 180 224 #D4B4E0 216 184 224 #D8B8E0 216 188 228 #D8BCE4 220 192 228 #DCC0E4 220 196 228 #DCC4E4 224 200 232 #E0C8E8 224 204 232 #E0CCE8 228 208 236 #E4D0EC 228 212 236 #E4D4EC 232 216 236 #E8D8EC 232 220 240 #E8DCF0 236 224 240 #ECE0F0 236 228 240 #ECE4F0 240 232 244 #F0E8F4 240 236 244 #F0ECF4 244 240 244 #F4F0F4 244 244 248 #F4F4F8 248 248 248 #F8F8F8 252 252 252 #FCFCFC 252 252 248 #FCFCF8 252 252 244 #FCFCF4 252 252 240 #FCFCF0 252 252 236 #FCFCEC 252 252 232 #FCFCE8 252 252 228 #FCFCE4 252 252 224 #FCFCE0 252 252 220 #FCFCDC 252 252 216 #FCFCD8 252 252 212 #FCFCD4 252 252 208 #FCFCD0 252 252 204 #FCFCCC 252 252 200 #FCFCC8 252 252 196 #FCFCC4 252 252 192 #FCFCC0 252 252 188 #FCFCBC 252 252 184 #FCFCB8 252 252 180 #FCFCB4 252 252 176 #FCFCB0 252 252 172 #FCFCAC 252 252 168 #FCFCA8 252 252 164 #FCFCA4 252 252 160 #FCFCA0 252 252 156 #FCFC9C 252 252 152 #FCFC98 252 252 148 #FCFC94 252 252 144 #FCFC90 252 252 140 #FCFC8C 252 252 136 #FCFC88 252 252 132 #FCFC84 252 252 128 #FCFC80 252 252 124 #FCFC7C 252 252 120 #FCFC78 252 252 116 #FCFC74 252 252 112 #FCFC70 252 252 108 #FCFC6C 252 252 104 #FCFC68 252 252 100 #FCFC64 252 252 96 #FCFC60 252 252 92 #FCFC5C 252 252 88 #FCFC58 252 252 84 #FCFC54 252 252 80 #FCFC50 252 252 76 #FCFC4C 252 252 72 #FCFC48 252 252 68 #FCFC44 252 252 64 #FCFC40 252 252 60 #FCFC3C 252 252 56 #FCFC38 252 252 52 #FCFC34 252 252 48 #FCFC30 252 252 44 #FCFC2C 252 252 40 #FCFC28 252 252 36 #FCFC24 252 252 32 #FCFC20 252 252 28 #FCFC1C 252 252 24 #FCFC18 252 252 20 #FCFC14 252 252 16 #FCFC10 252 252 12 #FCFC0C 252 252 8 #FCFC08 252 252 4 #FCFC04 252 252 0 #FCFC00 252 248 0 #FCF800 248 244 0 #F8F400 244 240 0 #F4F000 240 236 4 #F0EC04 240 232 4 #F0E804 236 228 4 #ECE404 232 224 8 #E8E008 228 220 8 #E4DC08 228 216 8 #E4D808 224 212 12 #E0D40C 220 208 12 #DCD00C 216 204 12 #D8CC0C 212 200 16 #D4C810 212 196 16 #D4C410 208 192 16 #D0C010 204 188 20 #CCBC14 200 184 20 #C8B814 200 180 20 #C8B414 196 176 24 #C4B018 192 172 24 #C0AC18 188 168 24 #BCA818 184 164 28 #B8A41C 184 160 28 #B8A01C 180 156 28 #B49C1C 176 152 32 #B09820 172 148 32 #AC9420 172 144 32 #AC9020 168 140 36 #A88C24 164 136 36 #A48824 160 132 36 #A08424 160 128 36 #A08024 156 124 40 #9C7C28 152 120 40 #987828 148 116 40 #947428 144 112 44 #90702C 144 108 44 #906C2C 140 104 44 #8C682C 136 100 48 #886430 132 96 48 #846030 132 92 48 #845C30 128 88 52 #805834 124 84 52 #7C5434 120 80 52 #785034 116 76 56 #744C38 116 72 56 #744838 112 68 56 #704438 108 64 60 #6C403C 104 60 60 #683C3C 104 56 60 #68383C 100 52 64 #643440 96 48 64 #603040 92 44 64 #5C2C40 88 40 68 #582844 88 36 68 #582444 84 32 68 #542044 80 28 72 #501C48 76 24 72 #4C1848 76 20 72 #4C1448 72 16 76 #48104C 68 12 76 #440C4C 64 8 76 #40084C 60 0 80 #3C0050 goxel-0.11.0/data/palettes/Tango-Palette.gpl000066400000000000000000000013041435762723100206210ustar00rootroot00000000000000GIMP Palette Name: Tango icons Columns: 3 # 252 233 79 Butter 1 237 212 0 Butter 2 196 160 0 Butter 3 138 226 52 Chameleon 1 115 210 22 Chameleon 2 78 154 6 Chameleon 3 252 175 62 Orange 1 245 121 0 Orange 2 206 92 0 Orange 3 114 159 207 Sky Blue 1 52 101 164 Sky Blue 2 32 74 135 Sky Blue 3 173 127 168 Plum 1 117 80 123 Plum 2 92 53 102 Plum 3 233 185 110 Chocolate 1 193 125 17 Chocolate 2 143 89 2 Chocolate 3 239 41 41 Scarlet Red 1 204 0 0 Scarlet Red 2 164 0 0 Scarlet Red 3 255 255 255 Snowy White 238 238 236 Aluminium 1 211 215 207 Aluminium 2 186 189 182 Aluminium 3 136 138 133 Aluminium 4 85 87 83 Aluminium 5 46 52 54 Aluminium 6 0 0 0 Jet Black goxel-0.11.0/data/palettes/Ubuntu.gpl000066400000000000000000000021171435762723100174420ustar00rootroot00000000000000GIMP Palette Name: Ubuntu Columns: 0 # 238 199 62 Orange Hilight 240 165 19 Orange 251 139 0 Orange Base 244 72 0 Orange Shadow 255 255 153 Accent Yellow Highlight 255 255 0 Yellow 253 202 1 Accent Yellow Base 152 102 1 Accent Yellow Shadow 244 72 0 Accent Orange 253 51 1 Accent Red 212 0 0 Accent Red Base 152 1 1 Accent Deep Red 253 217 155 Human Highlight 217 187 122 Human 129 102 71 Human Base 86 82 72 Environmental Shadow 170 204 238 Environmental Blue Highlight 102 153 204 Environmental Blue Medium 51 102 153 Environmental Blue Base 0 51 102 Environmental Blue Shadow 179 222 253 Accent Blue Shadow 1 151 253 Accent Blue 1 105 201 Accent Blue Base 1 51 151 Accent Blue Shadow 204 255 153 Accent Green Highlight 152 252 102 Accent Green 51 153 0 Accent Green Base 1 90 1 Accent Green Shadow 0 43 61 Ubuntu Toner 255 155 255 Accent Magenta Highlight 255 0 255 Accent Magenta 102 0 204 Accent Dark Violet 238 238 238 Grey 1 204 204 207 Grey 2 170 170 170 Grey 3 136 136 136 Grey 4 102 102 102 Grey 5 51 51 51 Grey 6 0 0 0 Black goxel-0.11.0/data/palettes/db16.gpl000066400000000000000000000005751435762723100167220ustar00rootroot00000000000000GIMP Palette Name: DB16 Columns: 8 # 20 12 28 Dark1 68 36 52 Dark2 48 52 109 Dark3 78 74 78 Dark4 133 76 48 Dark5 52 101 36 Dark6 208 70 72 Dark7 117 113 97 Dark8 89 125 206 Light1 210 125 44 Light2 133 149 161 Light3 109 170 44 Light4 210 170 153 Light5 109 194 202 Light6 218 212 94 Light7 222 238 214 Light8 goxel-0.11.0/data/palettes/db32.gpl000066400000000000000000000012221435762723100167060ustar00rootroot00000000000000GIMP Palette Name: DB32 Columns: 8 # 0 0 0 Black 34 32 52 Valhalla 69 40 60 Loulou 102 57 49 Oiled cedar 143 86 59 Rope 223 113 38 Tahiti gold 217 160 102 Twine 238 195 154 Pancho 251 242 54 Golden fizz 153 229 80 Atlantis 106 190 48 Christi 55 148 110 Elf green 75 105 47 Dell 82 75 36 Verdigris 50 60 57 Opal 63 63 116 Deep koamaru 48 96 130 Venice blue 91 110 225 Royal blue 99 155 255 Cornflower 95 205 228 Viking 203 219 252 Light steel blue 255 255 255 White 155 173 183 Heather 132 126 135 Topaz 105 106 106 Dim gray 89 86 82 Smokey ash 118 66 138 Clairvoyant 172 50 50 Brown 217 87 99 Mandy 215 123 186 Plum 143 151 74 Rain forest 138 111 48 Stinger goxel-0.11.0/data/palettes/echo-palette.gpl000066400000000000000000000012501435762723100205270ustar00rootroot00000000000000GIMP Palette Name: Echo Icon Theme Palette Columns: 3 # 25 174 255 Blue1 0 132 200 Blue2 0 92 148 Blue3 255 65 65 Red1 220 0 0 Red2 181 0 0 Red3 255 255 62 Orange1 255 153 0 Orange2 255 102 0 Orange3 255 192 34 Brown1 184 129 0 Brown2 128 77 0 Brown3 204 255 66 Green1 154 222 0 Green2 0 145 0 Green3 241 202 255 Purple1 215 108 255 Purple2 186 0 255 Purple3 189 205 212 Metalic1 158 171 176 Metalic2 54 78 89 Metalic3 14 35 46 Metalic4 255 255 255 Grey1 204 204 204 Grey2 153 153 153 Grey3 102 102 102 Grey4 45 45 45 Grey5 goxel-0.11.0/data/palettes/inkscape.gpl000066400000000000000000000220161435762723100177550ustar00rootroot00000000000000GIMP Palette Name: Inkscape default Columns: 3 # generated by PaletteGen.py 0 0 0 Black 26 26 26 90% Gray 51 51 51 80% Gray 77 77 77 70% Gray 102 102 102 60% Gray 128 128 128 50% Gray 153 153 153 40% Gray 179 179 179 30% Gray 204 204 204 20% Gray 230 230 230 10% Gray 236 236 236 7.5% Gray 242 242 242 5% Gray 249 249 249 2.5% Gray 255 255 255 White 128 0 0 Maroon (#800000) 255 0 0 Red (#FF0000) 128 128 0 Olive (#808000) 255 255 0 Yellow (#FFFF00) 0 128 0 Green (#008000) 0 255 0 Lime (#00FF00) 0 128 128 Teal (#008080) 0 255 255 Aqua (#00FFFF) 0 0 128 Navy (#000080) 0 0 255 Blue (#0000FF) 128 0 128 Purple (#800080) 255 0 255 Fuchsia (#FF00FF) 43 0 0 #2B0000 85 0 0 #550000 128 0 0 #800000 170 0 0 #AA0000 212 0 0 #D40000 255 0 0 #FF0000 255 42 42 #FF2A2A 255 85 85 #FF5555 255 128 128 #FF8080 255 170 170 #FFAAAA 255 213 213 #FFD5D5 40 11 11 #280B0B 80 22 22 #501616 120 33 33 #782121 160 44 44 #A02C2C 200 55 55 #C83737 211 95 95 #D35F5F 222 135 135 #DE8787 233 175 175 #E9AFAF 244 215 215 #F4D7D7 36 28 28 #241C1C 72 55 55 #483737 108 83 83 #6C5353 145 111 111 #916F6F 172 147 147 #AC9393 200 183 183 #C8B7B7 227 219 219 #E3DBDB 43 17 0 #2B1100 85 34 0 #552200 128 51 0 #803300 170 68 0 #AA4400 212 85 0 #D45500 255 102 0 #FF6600 255 127 42 #FF7F2A 255 153 85 #FF9955 255 179 128 #FFB380 255 204 170 #FFCCAA 255 230 213 #FFE6D5 40 23 11 #28170B 80 45 22 #502D16 120 68 33 #784421 160 90 44 #A05A2C 200 113 55 #C87137 211 141 95 #D38D5F 222 170 135 #DEAA87 233 198 175 #E9C6AF 244 227 215 #F4E3D7 36 31 28 #241F1C 72 62 55 #483E37 108 93 83 #6C5D53 145 124 111 #917C6F 172 157 147 #AC9D93 200 190 183 #C8BEB7 227 222 219 #E3DEDB 43 34 0 #2B2200 85 68 0 #554400 128 102 0 #806600 170 136 0 #AA8800 212 170 0 #D4AA00 255 204 0 #FFCC00 255 212 42 #FFD42A 255 221 85 #FFDD55 255 230 128 #FFE680 255 238 170 #FFEEAA 255 246 213 #FFF6D5 40 34 11 #28220B 80 68 22 #504416 120 103 33 #786721 160 137 44 #A0892C 200 171 55 #C8AB37 211 188 95 #D3BC5F 222 205 135 #DECD87 233 221 175 #E9DDAF 244 238 215 #F4EED7 36 34 28 #24221C 72 69 55 #484537 108 103 83 #6C6753 145 138 111 #918A6F 172 167 147 #ACA793 200 196 183 #C8C4B7 227 226 219 #E3E2DB 34 43 0 #222B00 68 85 0 #445500 102 128 0 #668000 136 170 0 #88AA00 170 212 0 #AAD400 204 255 0 #CCFF00 212 255 42 #D4FF2A 221 255 85 #DDFF55 229 255 128 #E5FF80 238 255 170 #EEFFAA 246 255 213 #F6FFD5 34 40 11 #22280B 68 80 22 #445016 103 120 33 #677821 137 160 44 #89A02C 171 200 55 #ABC837 188 211 95 #BCD35F 205 222 135 #CDDE87 221 233 175 #DDE9AF 238 244 215 #EEF4D7 34 36 28 #22241C 69 72 55 #454837 103 108 83 #676C53 138 145 111 #8A916F 167 172 147 #A7AC93 196 200 183 #C4C8B7 226 227 219 #E2E3DB 17 43 0 #112B00 34 85 0 #225500 51 128 0 #338000 68 170 0 #44AA00 85 212 0 #55D400 102 255 0 #66FF00 127 255 42 #7FFF2A 153 255 85 #99FF55 179 255 128 #B3FF80 204 255 170 #CCFFAA 229 255 213 #E5FFD5 23 40 11 #17280B 45 80 22 #2D5016 68 120 33 #447821 90 160 44 #5AA02C 113 200 55 #71C837 141 211 95 #8DD35F 170 222 135 #AADE87 198 233 175 #C6E9AF 227 244 215 #E3F4D7 31 36 28 #1F241C 62 72 55 #3E4837 93 108 83 #5D6C53 124 145 111 #7C916F 157 172 147 #9DAC93 190 200 183 #BEC8B7 222 227 219 #DEE3DB 0 43 0 #002B00 0 85 0 #005500 0 128 0 #008000 0 170 0 #00AA00 0 212 0 #00D400 0 255 0 #00FF00 42 255 42 #2AFF2A 85 255 85 #55FF55 128 255 128 #80FF80 170 255 170 #AAFFAA 213 255 213 #D5FFD5 11 40 11 #0B280B 22 80 22 #165016 33 120 33 #217821 44 160 44 #2CA02C 55 200 55 #37C837 95 211 95 #5FD35F 135 222 135 #87DE87 175 233 175 #AFE9AF 215 244 215 #D7F4D7 28 36 28 #1C241C 55 72 55 #374837 83 108 83 #536C53 111 145 111 #6F916F 147 172 147 #93AC93 183 200 183 #B7C8B7 219 227 219 #DBE3DB 0 43 17 #002B11 0 85 34 #005522 0 128 51 #008033 0 170 68 #00AA44 0 212 85 #00D455 0 255 102 #00FF66 42 255 128 #2AFF80 85 255 153 #55FF99 128 255 179 #80FFB3 170 255 204 #AAFFCC 213 255 230 #D5FFE6 11 40 23 #0B2817 22 80 45 #16502D 33 120 68 #217844 44 160 90 #2CA05A 55 200 113 #37C871 95 211 141 #5FD38D 135 222 170 #87DEAA 175 233 198 #AFE9C6 215 244 227 #D7F4E3 28 36 31 #1C241F 55 72 62 #37483E 83 108 93 #536C5D 111 145 124 #6F917C 147 172 157 #93AC9D 183 200 190 #B7C8BE 219 227 222 #DBE3DE 0 43 34 #002B22 0 85 68 #005544 0 128 102 #008066 0 170 136 #00AA88 0 212 170 #00D4AA 0 255 204 #00FFCC 42 255 213 #2AFFD5 85 255 221 #55FFDD 128 255 230 #80FFE6 170 255 238 #AAFFEE 213 255 246 #D5FFF6 11 40 34 #0B2822 22 80 68 #165044 33 120 103 #217867 44 160 137 #2CA089 55 200 171 #37C8AB 95 211 188 #5FD3BC 135 222 205 #87DECD 175 233 221 #AFE9DD 215 244 238 #D7F4EE 28 36 34 #1C2422 55 72 69 #374845 83 108 103 #536C67 111 145 138 #6F918A 147 172 167 #93ACA7 183 200 196 #B7C8C4 219 227 226 #DBE3E2 0 34 43 #00222B 0 68 85 #004455 0 102 128 #006680 0 136 170 #0088AA 0 170 212 #00AAD4 0 204 255 #00CCFF 42 212 255 #2AD4FF 85 221 255 #55DDFF 128 229 255 #80E5FF 170 238 255 #AAEEFF 213 246 255 #D5F6FF 11 34 40 #0B2228 22 68 80 #164450 33 103 120 #216778 44 137 160 #2C89A0 55 171 200 #37ABC8 95 188 211 #5FBCD3 135 205 222 #87CDDE 175 221 233 #AFDDE9 215 238 244 #D7EEF4 28 34 36 #1C2224 55 69 72 #374548 83 103 108 #53676C 111 138 145 #6F8A91 147 167 172 #93A7AC 183 196 200 #B7C4C8 219 226 227 #DBE2E3 0 17 43 #00112B 0 34 85 #002255 0 51 128 #003380 0 68 170 #0044AA 0 85 212 #0055D4 0 102 255 #0066FF 42 127 255 #2A7FFF 85 153 255 #5599FF 128 179 255 #80B3FF 170 204 255 #AACCFF 213 229 255 #D5E5FF 11 23 40 #0B1728 22 45 80 #162D50 33 68 120 #214478 44 90 160 #2C5AA0 55 113 200 #3771C8 95 141 211 #5F8DD3 135 170 222 #87AADE 175 198 233 #AFC6E9 215 227 244 #D7E3F4 28 31 36 #1C1F24 55 62 72 #373E48 83 93 108 #535D6C 111 124 145 #6F7C91 147 157 172 #939DAC 183 190 200 #B7BEC8 219 222 227 #DBDEE3 0 0 43 #00002B 0 0 85 #000055 0 0 128 #000080 0 0 170 #0000AA 0 0 212 #0000D4 0 0 255 #0000FF 42 42 255 #2A2AFF 85 85 255 #5555FF 128 128 255 #8080FF 170 170 255 #AAAAFF 213 213 255 #D5D5FF 11 11 40 #0B0B28 22 22 80 #161650 33 33 120 #212178 44 44 160 #2C2CA0 55 55 200 #3737C8 95 95 211 #5F5FD3 135 135 222 #8787DE 175 175 233 #AFAFE9 215 215 244 #D7D7F4 28 28 36 #1C1C24 55 55 72 #373748 83 83 108 #53536C 111 111 145 #6F6F91 147 147 172 #9393AC 183 183 200 #B7B7C8 219 219 227 #DBDBE3 17 0 43 #11002B 34 0 85 #220055 51 0 128 #330080 68 0 170 #4400AA 85 0 212 #5500D4 102 0 255 #6600FF 127 42 255 #7F2AFF 153 85 255 #9955FF 179 128 255 #B380FF 204 170 255 #CCAAFF 229 213 255 #E5D5FF 23 11 40 #170B28 45 22 80 #2D1650 68 33 120 #442178 90 44 160 #5A2CA0 113 55 200 #7137C8 141 95 211 #8D5FD3 170 135 222 #AA87DE 198 175 233 #C6AFE9 227 215 244 #E3D7F4 31 28 36 #1F1C24 62 55 72 #3E3748 93 83 108 #5D536C 124 111 145 #7C6F91 157 147 172 #9D93AC 190 183 200 #BEB7C8 222 219 227 #DEDBE3 34 0 43 #22002B 68 0 85 #440055 102 0 128 #660080 136 0 170 #8800AA 170 0 212 #AA00D4 204 0 255 #CC00FF 212 42 255 #D42AFF 221 85 255 #DD55FF 229 128 255 #E580FF 238 170 255 #EEAAFF 246 213 255 #F6D5FF 34 11 40 #220B28 68 22 80 #441650 103 33 120 #672178 137 44 160 #892CA0 171 55 200 #AB37C8 188 95 211 #BC5FD3 205 135 222 #CD87DE 221 175 233 #DDAFE9 238 215 244 #EED7F4 34 28 36 #221C24 69 55 72 #453748 103 83 108 #67536C 138 111 145 #8A6F91 167 147 172 #A793AC 196 183 200 #C4B7C8 226 219 227 #E2DBE3 43 0 34 #2B0022 85 0 68 #550044 128 0 102 #800066 170 0 136 #AA0088 212 0 170 #D400AA 255 0 204 #FF00CC 255 42 212 #FF2AD4 255 85 221 #FF55DD 255 128 229 #FF80E5 255 170 238 #FFAAEE 255 213 246 #FFD5F6 40 11 34 #280B22 80 22 68 #501644 120 33 103 #782167 160 44 137 #A02C89 200 55 171 #C837AB 211 95 188 #D35FBC 222 135 205 #DE87CD 233 175 221 #E9AFDD 244 215 238 #F4D7EE 36 28 34 #241C22 72 55 69 #483745 108 83 103 #6C5367 145 111 138 #916F8A 172 147 167 #AC93A7 200 183 196 #C8B7C4 227 219 226 #E3DBE2 43 0 17 #2B0011 85 0 34 #550022 128 0 51 #800033 170 0 68 #AA0044 212 0 85 #D40055 255 0 102 #FF0066 255 42 127 #FF2A7F 255 85 153 #FF5599 255 128 178 #FF80B2 255 170 204 #FFAACC 255 213 229 #FFD5E5 40 11 23 #280B17 80 22 45 #50162D 120 33 68 #782144 160 44 90 #A02C5A 200 55 113 #C83771 211 95 141 #D35F8D 222 135 170 #DE87AA 233 175 198 #E9AFC6 244 215 227 #F4D7E3 36 28 31 #241C1F 72 55 62 #48373E 108 83 93 #6C535D 145 111 124 #916F7C 172 147 157 #AC939D 200 183 190 #C8B7BE 227 219 222 #E3DBDE goxel-0.11.0/data/palettes/webhex.gpl000066400000000000000000000100441435762723100174400ustar00rootroot00000000000000GIMP Palette Name: WebHex # 255 255 255 FFFFFF 255 255 204 FFFFCC 255 255 153 FFFF99 255 255 102 FFFF66 255 255 51 FFFF33 255 255 0 FFFF00 255 204 255 FFCCFF 255 204 204 FFCCCC 255 204 153 FFCC99 255 204 102 FFCC66 255 204 51 FFCC33 255 204 0 FFCC00 255 153 255 FF99FF 255 153 204 FF99CC 255 153 153 FF9999 255 153 102 FF9966 255 153 51 FF9933 255 153 0 FF9900 255 102 255 FF66FF 255 102 204 FF66CC 255 102 153 FF6699 255 102 102 FF6666 255 102 51 FF6633 255 102 0 FF6600 255 51 255 FF33FF 255 51 204 FF33CC 255 51 153 FF3399 255 51 102 FF3366 255 51 51 FF3333 255 51 0 FF3300 255 0 255 FF00FF 255 0 204 FF00CC 255 0 153 FF0099 255 0 102 FF0066 255 0 51 FF0033 255 0 0 FF0000 204 255 255 CCFFFF 204 255 204 CCFFCC 204 255 153 CCFF99 204 255 102 CCFF66 204 255 51 CCFF33 204 255 0 CCFF00 204 204 255 CCCCFF 204 204 204 CCCCCC 204 204 153 CCCC99 204 204 102 CCCC66 204 204 51 CCCC33 204 204 0 CCCC00 204 153 255 CC99FF 204 153 204 CC99CC 204 153 153 CC9999 204 153 102 CC9966 204 153 51 CC9933 204 153 0 CC9900 204 102 255 CC66FF 204 102 204 CC66CC 204 102 153 CC6699 204 102 102 CC6666 204 102 51 CC6633 204 102 0 CC6600 204 51 255 CC33FF 204 51 204 CC33CC 204 51 153 CC3399 204 51 102 CC3366 204 51 51 CC3333 204 51 0 CC3300 204 0 255 CC00FF 204 0 204 CC00CC 204 0 153 CC0099 204 0 102 CC0066 204 0 51 CC0033 204 0 0 CC0000 153 255 255 99FFFF 153 255 204 99FFCC 153 255 153 99FF99 153 255 102 99FF66 153 255 51 99FF33 153 255 0 99FF00 153 204 255 99CCFF 153 204 204 99CCCC 153 204 153 99CC99 153 204 102 99CC66 153 204 51 99CC33 153 204 0 99CC00 153 153 255 9999FF 153 153 204 9999CC 153 153 153 999999 153 153 102 999966 153 153 51 999933 153 153 0 999900 153 102 255 9966FF 153 102 204 9966CC 153 102 153 996699 153 102 102 996666 153 102 51 996633 153 102 0 996600 153 51 255 9933FF 153 51 204 9933CC 153 51 153 993399 153 51 102 993366 153 51 51 993333 153 51 0 993300 153 0 255 9900FF 153 0 204 9900CC 153 0 153 990099 153 0 102 990066 153 0 51 990033 153 0 0 990000 102 255 255 66FFFF 102 255 204 66FFCC 102 255 153 66FF99 102 255 102 66FF66 102 255 51 66FF33 102 255 0 66FF00 102 204 255 66CCFF 102 204 204 66CCCC 102 204 153 66CC99 102 204 102 66CC66 102 204 51 66CC33 102 204 0 66CC00 102 153 255 6699FF 102 153 204 6699CC 102 153 153 669999 102 153 102 669966 102 153 51 669933 102 153 0 669900 102 102 255 6666FF 102 102 204 6666CC 102 102 153 666699 102 102 102 666666 102 102 51 666633 102 102 0 666600 102 51 255 6633FF 102 51 204 6633CC 102 51 153 663399 102 51 102 663366 102 51 51 663333 102 51 0 663300 102 0 255 6600FF 102 0 204 6600CC 102 0 153 660099 102 0 102 660066 102 0 51 660033 102 0 0 660000 51 255 255 33FFFF 51 255 204 33FFCC 51 255 153 33FF99 51 255 102 33FF66 51 255 51 33FF33 51 255 0 33FF00 51 204 255 33CCFF 51 204 204 33CCCC 51 204 153 33CC99 51 204 102 33CC66 51 204 51 33CC33 51 204 0 33CC00 51 153 255 3399FF 51 153 204 3399CC 51 153 153 339999 51 153 102 339966 51 153 51 339933 51 153 0 339900 51 102 255 3366FF 51 102 204 3366CC 51 102 153 336699 51 102 102 336666 51 102 51 336633 51 102 0 336600 51 51 255 3333FF 51 51 204 3333CC 51 51 153 333399 51 51 102 333366 51 51 51 333333 51 51 0 333300 51 0 255 3300FF 51 0 204 3300CC 51 0 153 330099 51 0 102 330066 51 0 51 330033 51 0 0 330000 0 255 255 00FFFF 0 255 204 00FFCC 0 255 153 00FF99 0 255 102 00FF66 0 255 51 00FF33 0 255 0 00FF00 0 204 255 00CCFF 0 204 204 00CCCC 0 204 153 00CC99 0 204 102 00CC66 0 204 51 00CC33 0 204 0 00CC00 0 153 255 0099FF 0 153 204 0099CC 0 153 153 009999 0 153 102 009966 0 153 51 009933 0 153 0 009900 0 102 255 0066FF 0 102 204 0066CC 0 102 153 006699 0 102 102 006666 0 102 51 006633 0 102 0 006600 0 51 255 0033FF 0 51 204 0033CC 0 51 153 003399 0 51 102 003366 0 51 51 003333 0 51 0 003300 0 0 255 0000FF 0 0 204 0000CC 0 0 153 000099 0 0 102 000066 0 0 51 000033 0 0 0 000000 goxel-0.11.0/data/progs/000077500000000000000000000000001435762723100147645ustar00rootroot00000000000000goxel-0.11.0/data/progs/cherry.goxcf000066400000000000000000000007241435762723100173130ustar00rootroot00000000000000shape main { [seed 7] tree(0, 40, 10)[s 10 light -0.9] } shape tree($n, $e, $f) rule { cylinder[] if ($n < $e) { tree($n + 1)[rz 0+-10 z 0.5 s 0.95 z 0.5 rx 4] } if (($n >= $e) || ($n > $f && 0+-1 > 0.5)) { flower[] } } rule 0.1 { tree[rz 180] } rule 0.08 { tree[] tree($n + 1)[rz 0+-180 rx -45] } shape flower { [light 0.5 sat 0.7 sn 1 s 6 z -0.5 x -1 hue -10] sphere[x 0+-0.5 0+-0.5 light 0+-0.2] }goxel-0.11.0/data/progs/city.goxcf000066400000000000000000000022561435762723100167710ustar00rootroot00000000000000shape main { [seed 4] city[] } shape ground { [s 128 128 1 light -0.6 sat 0.2 hue 50] cube[] loop 16 [] { cube[x 0+-0.4 0+-0.4 s 0.2+-0.1 0.2+-0.1 3+-1 light -0.3+-0.2] } } shape city { ground[] loop 128 [wait 1] { building[x 0+-58 0+-58 s 2+-0.5 sat 0.2+-0.1 hue 0+-180] } } shape building // Tall building rule 1 { [s 3] $n = int(10+-5) loop $n [z 1 wait 1] { $s = 2+-0.2 floor[s $s $s 1 z 0.5] } [z $n - 0.5] loop 1+-2 [] { antenna[] } } // Low building rule 1 { [s 8+-4 8+-4 4+-2 z 0.5] cube[light -0.3] windows(8)[] loop 2+-1 [] {antenna[]} } // Tree rule 10 { [z 0.5 sn 1 z 0.5] [sat 1 0.5 light 1 0.2 hue 1 20] cube[z 0.5 sz 5] loop 2 [] { sphere[z 4 s 4+-1 x 0+-0.1 0+-0.1 hue 100+-40] } } shape windows($n) { loop $n [rz 90] { cube[x 0.5 0+-0.4 sn s 1/3 x -0.5 light 1 1 light 0+-0.2] } } shape floor { cube[light -0.5+-0.1] windows(8)[] } shape antenna { [z 0.5 x 0+-0.4 0+-0.4 sn 1 sz 2+-1 z 0.5 light -0.5] cube[] }goxel-0.11.0/data/progs/intro.goxcf000066400000000000000000000047671435762723100171650ustar00rootroot00000000000000// The 'main' shape is always the entry point of the program. shape main { // Initial random seed of 2. // Remove this line to use different seed each time. [seed 2] // Improves marching cube rendering. [antialiased 1] // Render a single white voxel. cube [] // Put an other cube next to it. // 'x' applies a translation of 1 along x. // Those transformation are only applied // to this cube. cube [x 1] // Now render a bigger grey sphere. // light -0.5 move the light value to half // the current value of 1 and the target sphere [s 10 x 1 light -0.5] // We can also render cylinders: cylinder [s 10 x -1 light -0.9] // This time we use a user defined shape. // And we increase the saturation to give it a color. my_shape [z 20 light -0.5 sat 0.5] } // A user defined shape shape my_shape { // s 8 8 1 scales with different values // for each axis. // rx A applies a rotation along z of // 45 deg. // Note that the color is red, because we set the // Saturation when we called my_shape. cube [s 8 8 1 z 1 rz 45] // Loop 16 time, each time increasing the x // translation and the hue. loop 16 [x 2 hue 10] { cube [] } // The loop transformations only affect // the loop block, after it we return to // the previous context. sphere [s 6 z 1] // Let's try a recursive shape: tree [x -10 s 4] // And an other one with a bit or randomness: tree2 [x 10 s 4 rz 180 hue 180] // A shape with several rules: my_other_shape [y 10 rz 90 hue -60 s 3] } // Tree render a cylinder and then call itself. // Since we scale down the shape at each iteration // at some point it becomes too small, and is // then automatically stopped. shape tree { cylinder [] tree [z 1 s 0.99 ry -6] } shape tree2 { cylinder [] // 'A +- B' means that we use a random value in the range // A - B, A + B. this make the second spiral a bit // messy. tree2 [z 1 s 0.99 ry -6+-6] } // Here 'my_other_shape' defines several rules. The rule // used is picked randomly using the weight. shape my_other_shape // Most of the time, just keep growing in z. rule 15 { cube [] my_other_shape [z 1] } // Sometime split into two rule 1 { my_other_shape [rx 45 s 0.9] my_other_shape [rx -45 s 0.9] } // Some other times render a shpere and stop rule 0.5 { // 'hue 1 70' means that we immediately set the hue // to 70 (yellow). sphere [s 3 hue 1 70] } goxel-0.11.0/data/progs/planet.goxcf000066400000000000000000000010121435762723100172710ustar00rootroot00000000000000// Simple planet shape main { [s 50] sphere [sat 0.5 light -0.75 hue 200] loop 3 [] { continent[rz 0+-180 ry 0+-180 hue 1 40+-10 sat 1 0.5 light -0.5+-0.1] } loop 16 [wait 1] { cloud [rz 0+-180 ry 0+-180 hue 200 light -0.1 sat 0.5] } } shape continent { loop 30 [rz 10 rx 0+-80 wait 1] { sphere[x 0.3 s 0.4+-0.05] } } shape cloud { loop 5 [rz 2 rx 0+-180 wait 1] { sphere[x 0.5 s 0.04 +- 0.01] } } goxel-0.11.0/data/progs/test.goxcf000066400000000000000000000005021435762723100167700ustar00rootroot00000000000000// Simple Test shape branch rule { cylinder [sz 0.7] branch [rz 0 z 0.25 s 0.9 rx 30 z 0.25 light -0.1 hue 10 sat 0.1] } rule 0.2 { branch [rz 180] } rule 0.2 { branch [rz 90] } rule 0.1 { branch [rx -90 s 0.8 z 1] branch [] } shape main { [light 1 antialiased 1] branch [s 32] } goxel-0.11.0/data/progs/test2.goxcf000066400000000000000000000006421435762723100170570ustar00rootroot00000000000000shape main { [antialiased 1] [light 0.5 sat 0.5 s 100] loop 5 [s -0.95 light 0.1 sat 0.01 hue 5] { sphere [light -0.6 hue 30] } loop 30 [wait 1] { sphere [sub rz 0+-180 ry 0+-180 z 0.5 s 0.3] } loop 2 [rz 90] { loop 120 [ry 10 wait 1] { sphere [hue 30+-30 light -0.5+-0.4 z 0.5 s 0.05+-0.01 z 4+-0.5] } } } goxel-0.11.0/data/progs/test3.goxcf000066400000000000000000000004551435762723100170620ustar00rootroot00000000000000shape main { [antialiased 1] loop 8 [rz 45] { test [s 20 x 2] } } shape test { [sat 0.4 light -0.2 hue 240] sphere[] cube [z 0.5 sub] tige (15) [s 0.5 light -0.5] } shape tige ($n) { cylinder[] if $n { tige($n - 1)[z 0.5 ry $n z 0.5 sat -0.1] } } goxel-0.11.0/data/progs/tree-big.goxcf000066400000000000000000000010341435762723100175100ustar00rootroot00000000000000 shape leaf { cube[] leaf[x 0.5 s 0.9 0.9 0.8 ry 25 x 0.4] } shape top { loop 8 [rz 360 / 8] { [life 8 sy 2 z 0+-5] leaf[s 5 light -0.4 sat 0.5 hue 60+-20 ry -45] } } shape part($n) { loop $i = $n [z 1 rz 30+-10 rx 0+-10 wait 1] { cylinder[s 4 x 0.1 light 0+-0.1] if ($i == int($n - 2)) { top[] } } } shape main { [antialiased 1 hue 40 light -0.5 sat 0.5] $n = 40+-10 loop 3 [rz 120+-45] { [y 0.5] part($n)[light -0.3+-0.05] } } goxel-0.11.0/data/progs/tree-small.goxcf000066400000000000000000000005631435762723100200650ustar00rootroot00000000000000shape branch2 { cube[] branch2 [z 0.5 s 0.8 rx 20+-4 z 0.5] } shape branch { [rx 90] branch2[s 2] } shape tree($s) { loop $s [z 1] { cube[s 1 light -0.8+-0.1 sat 0.5] } [z $s] [sat 1 light -0.5 hue 50+-30] loop 6 [rz 360 / 6 rz 0+-10] { branch[light 0+-0.3] } } shape main { [antialiased 0] tree(8+-2)[] } goxel-0.11.0/data/shaders/000077500000000000000000000000001435762723100152635ustar00rootroot00000000000000goxel-0.11.0/data/shaders/background.glsl000066400000000000000000000010711435762723100202640ustar00rootroot00000000000000varying lowp vec4 v_color; #ifdef VERTEX_SHADER /************************************************************************/ attribute highp vec3 a_pos; attribute lowp vec4 a_color; void main() { gl_Position = vec4(a_pos, 1.0); v_color = a_color; } /************************************************************************/ #endif #ifdef FRAGMENT_SHADER /************************************************************************/ void main() { gl_FragColor = v_color; } /************************************************************************/ #endif goxel-0.11.0/data/shaders/mesh.glsl000066400000000000000000000212541435762723100171060ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ // Some of the algos come from glTF Sampler, under Apache Licence V2. uniform highp mat4 u_model; uniform highp mat4 u_view; uniform highp mat4 u_proj; uniform lowp float u_pos_scale; uniform highp vec3 u_camera; uniform highp float u_z_ofs; // Used for line rendering. // Light parameters uniform lowp vec3 u_l_dir; uniform lowp float u_l_int; uniform lowp float u_l_amb; // Ambient light coef. // Material parameters uniform lowp float u_m_metallic; uniform lowp float u_m_roughness; uniform lowp float u_m_smoothness; uniform lowp vec4 u_m_base_color; uniform lowp vec3 u_m_emissive_factor; uniform mediump sampler2D u_normal_sampler; uniform lowp float u_normal_scale; #ifdef HAS_OCCLUSION_MAP uniform mediump sampler2D u_occlusion_tex; uniform mediump float u_occlusion_strength; #endif #ifdef SHADOW uniform highp mat4 u_shadow_mvp; uniform mediump sampler2D u_shadow_tex; uniform mediump float u_shadow_strength; varying mediump vec4 v_shadow_coord; #endif varying highp vec3 v_Position; varying lowp vec4 v_color; varying mediump vec2 v_occlusion_uv; varying mediump vec2 v_UVCoord1; varying mediump vec3 v_gradient; #ifdef HAS_TANGENTS varying mediump mat3 v_TBN; #else varying mediump vec3 v_Normal; #endif const mediump float M_PI = 3.141592653589793; /* * Function: F_Schlick. * Compute Fresnel (specular). * * Optimized variant (presented by Epic at SIGGRAPH '13) * https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf */ mediump vec3 F_Schlick(mediump vec3 f0, mediump float LdotH) { mediump float fresnel = exp2((-5.55473 * LdotH - 6.98316) * LdotH); return (1.0 - f0) * fresnel + f0; } /* * Function: V_SmithGGXCorrelatedFast * Compute Geometic occlusion. * * Fast approximation from * https://google.github.io/filament/Filament.html#materialsystem/standardmodel */ mediump float V_GGX(mediump float NdotL, mediump float NdotV, mediump float alpha) { mediump float a = alpha; mediump float GGXV = NdotL * (NdotV * (1.0 - a) + a); mediump float GGXL = NdotV * (NdotL * (1.0 - a) + a); return 0.5 / (GGXV + GGXL); } /* * Function: D_GGX * Microfacet distribution */ mediump float D_GGX(mediump float NdotH, mediump float alpha) { mediump float a2 = alpha * alpha; mediump float f = (NdotH * a2 - NdotH) * NdotH + 1.0; return a2 / (M_PI * f * f); } mediump vec3 compute_light(mediump vec3 L, mediump float light_intensity, mediump float light_ambient, mediump vec3 base_color, mediump float metallic, mediump float roughness, mediump vec3 N, mediump vec3 V) { mediump vec3 H = normalize(L + V); mediump float NdotL = clamp(dot(N, L), 0.0, 1.0); mediump float NdotV = clamp(dot(N, V), 0.0, 1.0); mediump float NdotH = clamp(dot(N, H), 0.0, 1.0); mediump float LdotH = clamp(dot(L, H), 0.0, 1.0); mediump float VdotH = clamp(dot(V, H), 0.0, 1.0); mediump float a_roughness = roughness * roughness; // Schlick GGX model, as used by glTF2. mediump vec3 f0 = vec3(0.04); mediump vec3 diffuse_color = base_color * (vec3(1.0) - f0) * (1.0 - metallic); mediump vec3 specular_color = mix(f0, base_color, metallic); mediump vec3 F = F_Schlick(specular_color, LdotH); mediump float Vis = V_GGX(NdotL, NdotV, a_roughness); mediump float D = D_GGX(NdotH, a_roughness); // Calculation of analytical lighting contribution mediump vec3 diffuseContrib = (1.0 - F) * (diffuse_color / M_PI); mediump vec3 specContrib = F * (Vis * D); mediump vec3 shade = NdotL * (diffuseContrib + specContrib); shade = max(shade, vec3(0.0)); return light_intensity * shade + light_ambient * base_color; } mediump vec3 getNormal() { mediump vec3 ret; #ifdef HAS_TANGENTS mediump mat3 tbn = v_TBN; mediump vec3 n = texture2D(u_normal_sampler, v_UVCoord1).rgb; n = tbn * ((2.0 * n - 1.0) * vec3(u_normal_scale, u_normal_scale, 1.0)); ret = normalize(n); #else ret = normalize(v_Normal); #endif #ifdef SMOOTHNESS ret = normalize(mix(ret, normalize(v_gradient), u_m_smoothness)); #endif return ret; } #ifdef VERTEX_SHADER /************************************************************************/ attribute highp vec3 a_pos; attribute mediump vec3 a_normal; attribute mediump vec3 a_tangent; attribute mediump vec3 a_gradient; attribute lowp vec4 a_color; attribute mediump vec2 a_occlusion_uv; attribute mediump vec2 a_bump_uv; // bump tex base coordinates [0,255] attribute mediump vec2 a_uv; // uv coordinates [0,1] // Must match the value in goxel.h #define VOXEL_TEXTURE_SIZE 8.0 void main() { vec4 pos = u_model * vec4(a_pos * u_pos_scale, 1.0); v_Position = vec3(pos.xyz) / pos.w; v_color = a_color.rgba * a_color.rgba; // srgb to linear (fast). v_occlusion_uv = (a_occlusion_uv + 0.5) / (16.0 * VOXEL_TEXTURE_SIZE); gl_Position = u_proj * u_view * vec4(v_Position, 1.0); gl_Position.z += u_z_ofs; #ifdef SHADOW v_shadow_coord = u_shadow_mvp * vec4(v_Position, 1.0); #endif #ifdef HAS_TANGENTS mediump vec4 tangent = vec4(normalize(a_tangent), 1.0); mediump vec3 normalW = normalize(a_normal); mediump vec3 tangentW = normalize(vec3(u_model * vec4(tangent.xyz, 0.0))); mediump vec3 bitangentW = cross(normalW, tangentW) * tangent.w; v_TBN = mat3(tangentW, bitangentW, normalW); #else v_Normal = normalize(a_normal); #endif v_gradient = a_gradient; v_UVCoord1 = (a_bump_uv + 0.5 + a_uv * 15.0) / 256.0; #ifdef VERTEX_LIGHTNING mediump vec3 N = getNormal(); v_color.rgb = compute_light(normalize(u_l_dir), u_l_int, u_l_amb, (v_color * u_m_base_color).rgb, u_m_metallic, u_m_roughness, N, normalize(u_camera - v_Position)); #endif } #endif #ifdef FRAGMENT_SHADER #ifdef GL_ES precision mediump float; #endif /************************************************************************/ vec3 toneMap(vec3 color) { // color *= u_exposure; return sqrt(color); // Gamma correction. } void main() { #ifdef ONLY_EDGES mediump vec3 n = 2.0 * texture2D(u_normal_sampler, v_UVCoord1).rgb - 1.0; if (n.z > 0.75) discard; #endif float metallic = u_m_metallic; float roughness = u_m_roughness; vec4 base_color = u_m_base_color * v_color; #ifdef MATERIAL_UNLIT gl_FragColor = vec4(sqrt(base_color.rgb), base_color.a); return; #endif vec3 N = getNormal(); vec3 V = normalize(u_camera - v_Position); vec3 L = normalize(u_l_dir); #ifndef VERTEX_LIGHTNING vec3 color = compute_light(L, u_l_int, u_l_amb, base_color.rgb, metallic, roughness, N, V); #else vec3 color = v_color.rgb; #endif // Shadow map. #ifdef SHADOW float NdotL = clamp(dot(N, L), 0.0, 1.0); lowp vec2 PS[4]; // Poisson offsets used for the shadow map. float visibility = 1.0; mediump vec4 shadow_coord = v_shadow_coord / v_shadow_coord.w; lowp float bias = 0.005 * tan(acos(clamp(NdotL, 0.0, 1.0))); bias = clamp(bias, 0.0015, 0.015); shadow_coord.z -= bias; PS[0] = vec2(-0.94201624, -0.39906216) / 1024.0; PS[1] = vec2(+0.94558609, -0.76890725) / 1024.0; PS[2] = vec2(-0.09418410, -0.92938870) / 1024.0; PS[3] = vec2(+0.34495938, +0.29387760) / 1024.0; for (int i = 0; i < 4; i++) if (texture2D(u_shadow_tex, v_shadow_coord.xy + PS[i]).z < shadow_coord.z) visibility -= 0.2; if (NdotL <= 0.0) visibility = 0.5; float shade = mix(1.0, visibility, u_shadow_strength); color *= shade; #endif // SHADOW #ifdef HAS_OCCLUSION_MAP lowp float ao; ao = texture2D(u_occlusion_tex, v_occlusion_uv).r; color = mix(color, color * ao, u_occlusion_strength); #endif color += u_m_emissive_factor; gl_FragColor = vec4(toneMap(color), 1.0); } #endif goxel-0.11.0/data/shaders/model3d.glsl000066400000000000000000000053151435762723100175010ustar00rootroot00000000000000#if defined(GL_ES) && defined(FRAGMENT_SHADER) #extension GL_OES_standard_derivatives : enable #endif uniform highp mat4 u_model; uniform highp mat4 u_view; uniform highp mat4 u_proj; uniform highp mat4 u_clip; uniform lowp vec4 u_color; uniform mediump vec2 u_uv_scale; uniform lowp float u_grid_alpha; uniform mediump vec3 u_l_dir; uniform mediump float u_l_diff; uniform mediump float u_l_emit; uniform mediump sampler2D u_tex; uniform mediump float u_strip; uniform mediump float u_time; varying mediump vec3 v_normal; varying highp vec3 v_pos; varying lowp vec4 v_color; varying mediump vec2 v_uv; varying mediump vec4 v_clip_pos; #ifdef VERTEX_SHADER /************************************************************************/ attribute highp vec3 a_pos; attribute lowp vec4 a_color; attribute mediump vec3 a_normal; attribute mediump vec2 a_uv; void main() { lowp vec4 col = u_color * a_color; highp vec3 pos = (u_view * u_model * vec4(a_pos, 1.0)).xyz; if (u_clip[3][3] > 0.0) v_clip_pos = u_clip * u_model * vec4(a_pos, 1.0); gl_Position = u_proj * vec4(pos, 1.0); mediump float diff = max(0.0, dot(u_l_dir, a_normal)); col.rgb *= (u_l_emit + u_l_diff * diff); v_color = col; v_uv = a_uv * u_uv_scale; v_pos = (u_model * vec4(a_pos, 1.0)).xyz; v_normal = a_normal; } /************************************************************************/ #endif #ifdef FRAGMENT_SHADER /************************************************************************/ void main() { gl_FragColor = v_color * texture2D(u_tex, v_uv); if (u_strip > 0.0) { mediump float p = gl_FragCoord.x + gl_FragCoord.y + u_time * 4.0; if (mod(p, 8.0) < 4.0) gl_FragColor.rgb *= 0.5; } if (u_clip[3][3] > 0.0) { if ( v_clip_pos[0] < -v_clip_pos[3] || v_clip_pos[1] < -v_clip_pos[3] || v_clip_pos[2] < -v_clip_pos[3] || v_clip_pos[0] > +v_clip_pos[3] || v_clip_pos[1] > +v_clip_pos[3] || v_clip_pos[2] > +v_clip_pos[3]) discard; } // Grid effect. #if !defined(GL_ES) || defined(GL_OES_standard_derivatives) if (u_grid_alpha > 0.0) { mediump vec2 c; if (abs((u_model * vec4(v_normal, 0.0)).x) > 0.5) c = v_pos.yz; if (abs((u_model * vec4(v_normal, 0.0)).y) > 0.5) c = v_pos.zx; if (abs((u_model * vec4(v_normal, 0.0)).z) > 0.5) c = v_pos.xy; mediump vec2 grid = abs(fract(c - 0.5) - 0.5) / fwidth(c); mediump float line = min(grid.x, grid.y); gl_FragColor.rgb *= mix(1.0 - u_grid_alpha, 1.0, min(line, 1.0)); } #endif } /************************************************************************/ #endif goxel-0.11.0/data/shaders/pos_data.glsl000066400000000000000000000014251435762723100177420ustar00rootroot00000000000000varying lowp vec2 v_pos_data; uniform highp mat4 u_model; uniform highp mat4 u_view; uniform highp mat4 u_proj; uniform lowp vec2 u_block_id; #ifdef VERTEX_SHADER /************************************************************************/ attribute highp vec3 a_pos; attribute lowp vec2 a_pos_data; void main() { highp vec3 pos = a_pos; gl_Position = u_proj * u_view * u_model * vec4(pos, 1.0); v_pos_data = a_pos_data; } /************************************************************************/ #endif #ifdef FRAGMENT_SHADER /************************************************************************/ void main() { gl_FragColor.rg = u_block_id; gl_FragColor.ba = v_pos_data; } /************************************************************************/ #endif goxel-0.11.0/data/shaders/shadow_map.glsl000066400000000000000000000011761435762723100202750ustar00rootroot00000000000000#ifdef VERTEX_SHADER /************************************************************************/ attribute highp vec3 a_pos; uniform highp mat4 u_model; uniform highp mat4 u_view; uniform highp mat4 u_proj; uniform mediump float u_pos_scale; void main() { gl_Position = u_proj * u_view * u_model * vec4(a_pos * u_pos_scale, 1.0); } /************************************************************************/ #endif #ifdef FRAGMENT_SHADER /************************************************************************/ void main() {} /************************************************************************/ #endif goxel-0.11.0/data/sounds/000077500000000000000000000000001435762723100151455ustar00rootroot00000000000000goxel-0.11.0/data/sounds/build.wav000066400000000000000000000051461435762723100167710ustar00rootroot00000000000000RIFF^ WAVEfmt DXdata:  *136:;MHQZbjryOOhs=  W   } D0/irOf[:_ X.nN+Qt '@Wm ,7BLU^fov}9b$&" V:2;Ru n % v {3tz0g+Y+4]lX\-bxZ0qZvtX%0W Cv*Qv-F^u)5@JT]fnv~goxel-0.11.0/data/sounds/click.wav000066400000000000000000000010141435762723100167450ustar00rootroot00000000000000RIFFWAVEfmt Ddata@7UNS.'' h|fWOfjBI_ȜNVr*N@R+%ES\+4+S(zK黳u> stream xڥZ )H,@E΢gWtiv]7IQ.v8,S.b!o.?.ޗ`o1kwcܿYÙ; qu֦8z''©-(cL4<㙗YZ|dZ2[z/Uvno۲4;|VO]p![wl-@ IE2~\u9'[kx> | HhMgXAb)ûj5+btIIq,,Ϥ2Ye)*K #Y,{EJ,x( _(,8H|DaeG8ч3OEĺQԣ34]TL/zBi6we|v@fDtكPIW$%\55-xgTa[tІ&+NoDYpcrtZA&=".iiU! N', 2aF'NݲuGgBpѹZL2?+4c1q*yu"gٕR~,m,̆,϶owl «z %QɌG$wtt߆3yND(~ 蔸 G 3RUZe^USDCse!#FݕvKv>-j~xIJT 세N(62FBڍ-cE{' r+n>f^.TT-9PIO[QT:#8k4;|Os%5-qxbYbu/U?,}ݏї79d#e./ ,2Y'U1i15ڤQL`qd7ȖC&Y7ymԆ+_ YXC.Dg- $G~47>WZ5rP%]@eSܕrS,TR3׾4}dq20ȹor7gKR{Z9.TsnVKj ~^.e;UfJ%QnTK@lV FhCk9Dy~m.}`PvRNWrQԎɹH5{jTĊ&u Req@Uqu̵1e fz>0ѭ+WhTc#|F[V0o益όIK}J&*Ӥ`T|vEkS$zyćGH^XkIhn 8[s-Kh iC-[Hp&Wے@b÷@i;O( i) bW:*tJ:pMg_N֙I ?g=` : Ɣ Rx{$m97ҚaWofm'J?vF6G;* 4#{;]K8(^A/~XPV_iio;9ാOBEt4ϕU@ZٮmBZ:ZvyӋ%{+6M;ʼ&G,}U텟nf(K!6TM|7u2-|ișj9xk5TkT+7ŻuyK#u{;8kuO_i]rQmrH(j`;t:,{m4kFef3:r<&&ztkv;[1- [Ng߂Q9(iEK)mQՔзP;jZL4J G>Ҵd 4P K;F{O9.I UZ͛b9%nC1vd1N$ri/ F8P58Pb 3A=tF1溞.ۛ+slOo>B &׊թN3 T}_q\Yx5r!Jo% mn[y&فKg}ڗ8lTq)g:Y8)jIF1F_AfZDIg|0 96St6}5I[pp+j9&U(J|hNmTPH]x Bؽyv-E rؤ endstream endobj 15 0 obj <> stream xڵ,-Wt[4:0 630`jj'DuuW[ca(}h.ȋ8?>.M]-:.ߗnթw. !z\BoPӻGy?xfeFpɤoV⪫ wD&g!qa+yV#Vftd^NmD":-Mn,R& |~*-Zk(\{'qR+4 eJs1[Oo|U$r;dd)x ҚzW,AdT%eiA">"?!)#iØ R^LH()2Bh0yU̅u d"d.H;=ƎW~-Noa7CN1e:uB>\P~UuR]׷htݬy_꫉GO u?(̤'Na%NK0ͺ>=VUm;DX Y}Cܲ4`ecx9t,vsڙT7mu/ ق=3012*=q 0\FiƷT+ylU/[03bd}T N}@W*ygAUDc¼MftaѸ sHk/٩K\ 9Jru٫1uLC R iUf֯hCHb13B,_: Mve"2(Z=3 w,=" j-yEBģXDqie~2Qb<2fg`|HO./qʙiԌ)"/s^ #j>A9qG)], /hnKџg # I'9 eM8Yo_e%n}"Ot~7g3ѻ̂UMB"*iI Sab g%%lxøi(Gl]Z=0U_J0r]oM9Fz;P&`(lĢNk`W$4m^RHb^UgZTQND~vt+tѵfC~/`/\+Z+kRH|ڵ\ 4-9OI:=V9Bs%6kZCMSj׳Z|= ľFIz)8DŽW/&)A++RP쑻JNݙ+T62jҴz)|u!hZ?g]4݅ }J +ڝ"FM~Ý<.0ni$ԟLBWlIR0'K L)y;ZʾM^oa~Oll(r0F97Ʃw(j(ưJ/-7 5V_C2DC @mN)bLPYgjEz4J[RIb_# TKA]a!N7bU^o+MOrBMm1Q!bBlGSSpPIx3Az,QTrU54!vp4%{sX$ir{8BVB{3ޮR.Z$S"2$艑fK$~3Aؓtϛlw>J̱\!50͏* ץPn2θȧ烐+k׻ I~kgsZbbuqX?R53!np<=?n\*H[Չww 0K]_\+VTcc{"P#(J`!6)\M< 5EJ^`%0,|4!Fhp{t||`%q}Vþ!i)k~ix D,8`:w=`alѯl\d(ng%[M7m.(ʥ TG^`PtE{1p`XwG2)d~rdȶy72/t3U?wl0S %L*e"S<:xu AA3%_tCucons bYRȋu!/~A`.\tS"Kk&ZެsWsB m7fj^ËrÓe>E[ JOU zV;i s?o2W*q(\Qd) oKNezfEG"w%(.AwbMhaшV֍&*qn:e3QboBm~^'X=˳)jck%޲YՎ}'%h/O(1EgMfM^u >ƍkfm>'v$ )rbFVtZB]|(BP_78ƭҷ|>"i؊6n FNz}}EZ=9h$ b 'C|-) 6_ ]Bsy;UuGkJ~`@B?S-;EN8z^ݷJAVug/cgWU8ҷ`!ϻK~ =MB5]o"=Mc@q(%LS ,M"mZ&[ڐjGkimHm 5IWoD~5#gnEg5@4Xs'3ÄS *V.rY ]qsLE X&8w_8$e8xUD,U"$mP'43#Ô>Ax7='̾-akDM9Yh2acnAPlm%o:} endstream endobj 20 0 obj <> stream xX#7%70P`83pRogY>F3k81#HUnNMv2N 꿙N?ߦ/_a*s:8K90ݖ_q ~S?ԑ/-zƹV?|pVc='__nGw%9$FOg.Tw\ݕ{ޛ5gxgQXp_Ӄʭҭ cmmɶiJy>xPZL7R!/r|{TD8tqA0l] .˨m1:̈x!ĎWt;miV]4[Tqi<j%$ k+uF.VH> stream x]Qk0w?E;FQV[a ve69;&ڇ~i~I$ge^v`Ѣ5nn3]Z兜V N+l_uGUGtW0oUO"Kw.q+UYx1m06{L/ؗdZuaSVّWH ,Ԧ QВn}-B^Oʒb|R79΍ʹ> stream x]Mk@໿b)%& Ҧ-59htB\e5KgfuL4/9TͬD-i"vf-r4TeO4o^ΙYM ϏcE3043nmzS$;Ѳ%)ԛ>7I2H-g몡i,+hX-WdkSrM%ݲrb%υi!Ӎ#2=(C&ڈVqHw Nu{h%K:*3U-S nA:h-bZ`G#Wz,8=K956 wc9Z?:g endstream endobj 38 0 obj <> stream xڍW Xg4R1[ݵuj W $, O \"G,aV[junEۭo>+ϓy?{e%|–yiT}ڜŦ8H+!5'q$v$ȥIxZ~A1|3}=)(J x#O^W_(L$i_>-,V$l$A'"&y$0 c>%^0 X!b4[)#23HNL69Y w1Ũㄌ8Y&uQB)*JbL@AB՚ 8ؚd2'Ǔ9I`WGZdꨥA,o2 qF>)/w)c)_qj5 Bϩb*ZF"5Z*t2PIT*NYl9%s|Ǒ'*Zf}5.fyBdgҰ g_q_y!5+;e;a:rbW$@7, 9qĜD,}ޤر>b4fϹ>3WF^F3S^'u [ Sz]}DiX?L?TAF +!Ba**q]ș OIУH:ϊ{G}>(~&][>$uXnǝ7'p _ΎXɗ8%s?m^wc.Ɖso4g<E?|n6撈EI(?o4D.[$@-6.{ɷa.xsX]y `oi4/oPz!\WW?_f=a޽/AEB ZLR]Xr%I~Hu;yff*a.r gk mm}Cx.!nɥ3A[Xa.Ōҫ{C3ßnrT6"FTp'{Ed~o_8˖l؛˟9T|yF9S'e>=b/C66ZyIgJ֦<ϐ ]m'u)9L5\pRźk5b9dm*-(*)U5+T< a`bFW _*yĬ>2cW5 eǀ:Q`"[h?{ ~RS ;$il~& 0Ò'LԜSR^D[88 "(=]6chn.崛֫=?}[{Ќ },pgj;1S4BiZ?@7Dα@,k2YL e؟vI7!d/)x\5pXqJTڭKQ:9s40Ȫv U<< WW:ǒI~M#.LU쩭`"M&RMVN7sLP CF'OC^Kd En~QSS1ȗoVk9+Ar*䣷")Γ)^.KvM[mU_\pѬC8`]6u\#75 -leO74@ :_uje3}v|u,ZZ>MXtrqNyIհ@M6##'(w;j7^sVW;w'HNzتoN endstream endobj 40 0 obj <> stream xk``0T0T endstream endobj 42 0 obj <> stream xڥz\W,`Ce\3f XQWbWzQzXݥw) ࠀvwcI,Q7$& ^͂1y{c{9{$%!H_.z ;x0eX-Wq]դF ( S0X~*=ws0@Nxjw(歙>599$eng-P/9#ڼh_P >|7ųG(egi빮MdEYdI/Ppt _cf60g+Cnn*O Jͧra>\ɓOI!Fx~?#ޝ$}cFy֝Q|X^rK9('QTZj;Kxhf<߯H]̔"C%@I:{Yc($쎽#<V'J vd5IIG) ^ˬ;'.i8O*(+ر?a+o>+:^@ ɽRpuuuu,ikfD ,6JM#8; YJj3贬[, ^콣 s ~U3ėgWqWMEwG?)1VvG̓Ssr/$U0Ádc{+{!V`H_>-&9C6j9ʝW7 kQi|'y`Ҙ3oy{ո;( H˹0Ta]y>fTGv7IZU1 f*}Z>o:zn̰on$5Y <_ACoJơ!;--h:5sܴ).+{cqp:qnG͙5m i8rȔzo@慨 &`@@V -@(l${6:Pnh9ZH<^rP d֝5Q<${ݬig+x[e^!XO>4(}$TJ>ۣ o>H{d< ߮9*U\|;͙YWnb*p:{ PUR LAR%E*8abGRwӃr![7)K՟,cXm^ܧ.` iِж] `ݑ. ȌLT inQ3_z))ؘUPo)Q2hYeF2VT_SyPjI!^djQUH,(\m'm:``%ymE'F} 3j;q">;2 74|!{D7_LΡ,UP/rpKˁ3y쎄n~~Syx2X;EJte/N_T?Y=p<+)2)ԁ,.[% { {0rB[l3ݯ!o^Vd̾}kX 662=[ R:m.\SU< AQC\;#k-*lמZXacBD^ߵ|)%ǘ缑gŖܜ2eiz$* cK2+w5q!!q1akNG,5˿.YѮљ8"=n(OP( [@r6;2ONNMcq;>.k_3 X+e)yIt71XL=f_7SBho:a ʴly|~.{U_ND!r.A4\Lcf2!_XSAVWԉI'.&FA"n'S&{3]Nv{Pn^NTGWPQ*wA欑SM`&$uͶKŸᫍZHZR*aHᐮ8H8#3Yk EGe^fLF;9QG-dYY)L! S֝dk7M"R_tAè'|q 63ݗpx=b$)Ff&ɋZazH*K{ş\lJe)Z],? Th%\Zp;Ȭt6S%z<$)OaQN9'%wNTfװ\R].f2mRQbw;k$ywu;  %b^(~ OOĆdZF܂1nBB#݌NV`<\9?ʽqG|Fh/-LRa`>.hℳd5GKOBL YqڤNY>ݚ`o \m{RP)Bo&EB_ ~ƍoKm,THr7C1Fa(`yqJ;tr[T N^ܸ.fi:#Z]z-~{TUARֵ1/L2ц8.ӳR߶&VXlQ! *yBLdb$,J*Na$4ibgnL S$3 i'#ψ:ۇƳ}haFM23slX,p66"#6/^0bD?ѹ3XQLNOKS - u`/7wvF0MŽpg|y,FsW72_ٜNd)( |}fA.+:U<;(\y޿v}$&]fW*Oٿ ]+6V=r_վX^ȨӆҫRVgHDK3Qx0}e +b[&$ndV<d::yQF1 NxO烬o٨ QRҴ<\8>.v]ʇ>y&#?% :Une{dI- ^?^Z|XͯjssǝZG  "f,B  >U02'ڰ߹E{@u~X03#&f#O[|GZ=$!ۍez3+f> <̨eXvY*d ųwVx/[^}, 7c#9U鐪)BYl3iZmR$ lȈ4i7C϶LەVkUu+=oܩfWT_6ZkS4m( G/a!s v n? Viԗ mv#Gi'v%[s=r jZEք@=K)h?uAI:#9%CmU㉶3gi(>Vyuݘq'~.kT3IJEjmf+Kt[ӕz=җ[y8d\ӠaZE8JtLY sHI%zesy"A{-c*.d;Q9K)fWHaY/WM@ P w!||G;X]knA&˵Ӄl?̰")\'OjV{r5Q?]4I;$"w|g;N~:Xwl#ۋSQ4ܸ [Z+mj&IզiieiZ! }Ύs\C:oK7VG$~1HѣJn< ~9_# b於*5m1b"2hO~DcȰ&?UjJɦ̣3sԕtYbUT"M-rAlAx"GO݆V>PxFN0X?+,N A5T}4\'wݧ՗tw$. 'oX05q ߐTKݛH=ãYh<9}b;u-?ZKʅ%=Dk#ft&#Cɾs%TE(5ͨe^:}.e8AO/b2E̫ڱ]7eOp){A}Q bzpT[5VS5*ēD6SE:jE~ E(y45L%+1eJ֠1q/3} 9)K1b}Nht! fteE3e1E$| /)봗v: bs7jq i8oTFVElFeA=85j,UAPN>d TE}j 67YB!UT]?&2^u1A,лoS((P$F 5N_aw{f(Rr,5aA0&h^(GVjrt|֬d)HMUXH4Pˢ7tZS4ڰR-^W`9QXWrE*:%e{=~gVCݽ' @/m(I3$-1JUbq%^ GdiqYt)`v; oǖUr5Hu~3$§ M2gXv7ަ.ukKZMz>֊-Q̤kPeƑr_.IJKTȂ u#=r|f-J wR˙3,f.մJEsV"0HnB/8NvV -^++0OQ*cuO M`\RD:KrDCnvcrEAoizf,H1='sBlv1G_Upu=P1-T.elw x4)ϣїQXOy&fw{r.^&V=GYF ڑUgEn>lSsV(3[@jb놸qo"9|pR"^Bt;SXu"JI1||X Nu?0QRۤ- Jdr}w5&GVUH<&t9V{;g-7'r=9\/JEh ^qkɕ3,9ʒ[\%(/5FmfNd")Τs>t-ѕiqovְzK浿y!e=+{ #+Vgg:^>!Hl9_ zWIl^=a?lm bs6QFa.6ޖ.!}{}Wuz9zB߾C>`0degî endstream endobj 44 0 obj <> stream xk``(_y R1 endstream endobj 46 0 obj <> stream x}V TW 2kZQ֮R"(A $@DYh QPGʳ2b[kZ햵^ٝ39sߕD"񉊍ZƜlz>$0̜s,|?!%#0JMं;WJ*Ƿ㓾?$lϊo_Pt}8E%Oo_OxMgNѯM4kK͙i+7?$d]lNY zn8.lrQi[& 8^E֜ svjVq%8$Kk]`KãcÃyVn9i閠%˗3@󉗈W%DA ^'V1D,G$ID Fdۤĵb:1M|s'7I[SZ'ܗ)UɗʛG8#T‡ Vw@ӫ <@rJ+jQ7&ڎ6kHZ)Z'xg`G^|~ғM#p^v>o45CT,rJ:;P~'C%KKv31Fد f¨i?j;^|y)ֹuݑ/\8OÚ`<Шq>إo?NG9n*pLD%xJ`s1e %!=lN_1ܾ9o*bvizZ;:p ':aew-w~wTgTD E7LF?uĝZa3CfOn|3M鴲fC4;+6[ض(Mh(h!;>YPodY^n*=_qJ0sE>kapcy]QZRXCM̮omohaqzZ>\.8.ܼVlbA6>E[}rOP C\ɂ _+G}b9LܖS~_ ^68WO'ݍۖ0*$4&B:}>*a6Ia.{O$9"CF=02$% II=!ߎn!޵ٟł5 ᷓI,^ 3&@b2QMqtf1xLH$"R:`DD\]yn {=SpM7_SZ}.+f'"nMw =I곧,{ N~x{R# 3C'f1szzMQF>.sOc\wSC OnMBz>͹pItD* }`R&x 2 SoΆW7޵ ^}7N`=86Ճ6q0K`6B/JjpOA -Lh==<&I`Aq rD Hʯnc߯l/|& B$_C\`?v#D ֶLJoYee@FR{ m7iR:s;E;NvN Sft["ky͹ۨJ)nn/i[оf+Ut,C:!<}̣~Co] g74(/n-b *GZ/3!(5\ 0 ^0U6\ncf%fo3ǦHɹ9q剣06*x_ ],rºWmN3p牑]$uο[/kbRRX>%M@ WERKFY6jBG5%E.4Nr<ՆyVY76/wElMEs]Ғf6W?:w(rTUcTVg[E9wWaF lj_+g&ǙH9]^^a>T+k7 endstream endobj 48 0 obj <> stream xk``TTѰ P endstream endobj 50 0 obj <> stream xڅWyX"J(2ԺTEm_\ZABHd%MFQ`@6Eâ<}U*bU_[ֶOߝǛ}77ɽs9wwGD"{źАe##u~+J&^V= ϊ]"]_uY^ Q(1Q72csdBB/b,_D>.$QXH5Y uiYzRedfp_cClD]!EƧ&r6RF2Y5.MP5I.VeM*:SaV lN zFoP$D5Ul..WoR Ve4MJNOl ~#>Q~˗. Z&7f$MT|0(^!c1%frŸI7Pb $$VF"H TfF ڙPWb+X&nD\Ops}m9sz8dIH$bҌ"[>~eoّ `Y5cq ݙ~8?v 7Dp.xR|k:X~ZG B׵1gp ٜP"bxO?y(%=dMJ9zUF7z^vjhg<@qǝso| Y6UpsȄIlH*]MfB'GadN:j)hyj%gH6g.4!\ e|+3%`"S(?MA2}^X&pcuB~R㌭ہ"k1$^0*sIp'=eYt>[Za3u#OIg?-`kEb{;Y](].iLn%p闷ro^F.[?5&2@ '*ͪ ߢW6Kd(o.0i}T6}EF>sG1h/vd_{΍oIp{!S my 51?V}ʷG=7{*09ﵺ_޷KX2.nMLًӧ/\:~5@ƲS:][Vj*`݋UHh *Zdzhq(iKbՙEIPO-qC#49,ġ0ѭ^V؏!_IQ(G9 vc 膻g:\ '2Q3tFhj)x` m6ا,{f|8vH/F8c&P^aP P"2PGrttb20-0NwWKgOeGldd>3ŵMSM_@G55942%QyW Sf !2ydpHH'vͫ}܁U\%clh9"{Ͻ ^D۞Of<ށ5ݗb9ʛqz9*ߎҨcsM|54% dSm4}Q3}"^|[Cg@~sK*7#dy']<Pנ =k/pwنb!NjwW`ݗD7jkY15(HvUy2o/H8{AmPw|ϻn~]~@$P- 1U4e?10HFUۋdYouom=YV뾯6vj %foiekU߼;X#7!㐗X֐,rK-_\u`[;6mmݞVKQ)h4g|M8[ Y>IIWU~%[+FE (;/iv3q 1sX6g4\X̄J~WhS!CR gTP 5ZؠJ.ۜ "Vn1ү M *@s%Cz366{Hmʞ[_ۇg E>j2nhWĉ=@O6Zz`;]*-kW> stream xk```NTl endstream endobj 9 0 obj <> stream xڵXkO#G~t 3$Lfl?0ndÿs5 Vn{< &52r)ɴLYfbJ1chff0 i5Y]0LaEy& L+1aLbYi4*7xwxBz UC8#pI®" BU^=,Ł(\|tpюa] :˻Fe?8r% S ]W<4'ΧeG>]hqGK>wqhO1F|QN:1&6GƠ~wLBúj= vŇ LMD>ulrlo◆?mNw<^=E~ HC:D4?_Jg]_dZf[FjU:>Ԯ#hTi4sS6xt0^X%0c 0y'~D+;\ {j(ߐ7[w8q Brva{wif+Nv>dTlt[ם?BwvlMdͫ /n%K$)4tJa[%IK $WqQ/ b%D+m-;p颥Q1^+mJlV5,:"NOo'xaO~:5bt?L=!d9ϑD?VQ~RBf CV)?a)V1 w>,"m}="^.YYa?O&#lwWII85Y=V>V􅶹S0*8k0>X#†nf%`9O@]׳[togFc#N FLyyzC+4sz[N1'CuB$Bzbq /9N,2є0 ;z/O;Hrh 3+:'Hyu=RxX #}bưؙV2- Xz9eTy"Rp@ɭhڛoy(V'LMF_KoU ;yv1Q0{Df_`aIE* E}P endstream endobj 53 0 obj <]/Size 54/W[1 2 2]/Filter/FlateDecode/Length 154>> stream x%;P9T| db-ٸ9?ܹ"42#S2" I~ l ltȘHk.6K<2!CD~Tҏ ݭ8>=%ڠYQUV1?r endstream endobj startxref 27402 %%EOF goxel-0.11.0/doc/cla/icla-1.0.md000066400000000000000000000157631435762723100157670ustar00rootroot00000000000000# Goxel Individual Contributor License Agreement ## Goxel ICLA v1.0 Based on the Apache Software Foundation Individual Contributor License Agreement v2.0, with modifications Thank you for your interest in a Noctua Software Ltd (the "Project Leads" ) open source project. In order to clarify the intellectual property license granted with Contributions from any person or entity, the Goxel Project Leads must have a Contributor License Agreement (the "Agreement") on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of the Project, its users, and the Goxel Project Leads; it does not change your rights to use your own Contributions for any other purpose. If you have not already done so, please complete and sign the Agreement by: * following the electronic procedure to complete, sign and submit the ICLA [here](https://github.com/guillaumechereau/goxel/blob/master/doc/cla/sign-cla.md) * or scanning and emailing the signed Agreement to contact@noctua-software.com **Please read this document carefully before signing and keep a copy for your records.** You accept and agree to the following terms and conditions for Your present and future Contributions submitted to the Project. Except for the license granted herein to the Project Leads and recipients of software distributed by the Project Leads, You reserve all right, title, and interest in and to Your Contributions. 1. Definitions. "You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "Contribution" shall mean any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to the Project Leads for inclusion in, or documentation of, any of the products managed or maintained by the Project Leads (the "Work"). For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Project Leads or their representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Project Leads for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution." 2. Grant of Copyright License. Subject to the terms and conditions of this Agreement, You hereby grant to the Project Leads and to recipients of software distributed by the Project Leads a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works. 3. Grant of Patent License. Subject to the terms and conditions of this Agreement, You hereby grant to the Project Leads and to recipients of software distributed by the Project Leads a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed. 4. You represent that you are legally entitled to grant the above license. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer, that your employer has waived such rights for your Contributions to the Project Leads, or that your employer has executed a separate Corporate Contributor License Agreement with the Project Leads. 5. You represent that each of Your Contributions is Your original creation (see section 7 for submissions on behalf of others). You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions. 6. You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON- INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. 7. Should You wish to submit work that is not Your original creation, You may submit it to the Project Leads separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as "Submitted on behalf of a third-party: [named here]". 8. You agree to notify the Project Leads of any facts or circumstances of which you become aware that would make these representations inaccurate in any respect. ``` Full Name: _________________________________________________ Email: _____________________________________________________ Telephone: _________________________________________________ Mailing Address: ___________________________________________ ___________________________________________ Country: ___________________________________________________ Signature: _________________________________________________ Date: ______________________________________________________ ``` goxel-0.11.0/doc/cla/icla-1.0.pdf000066400000000000000000000656041435762723100161370ustar00rootroot00000000000000%PDF-1.5 % 12 0 obj <> stream xڥ;3ϯXl.EQ$%Rny4E.b]\{?ņ]~.^s.]._ތ6&Oo3&lƺl{~M6/__^~xqҫ@q~pqpr-%8\>\extsȣDTϏ*=W9n|p|@bvݧnt>}n9TdA h%dOgQYY冢$PvʎI,YbUx4WSՊy6JU:x}P`MT(NN"a FfNL wg~$Gog$=o=$ Y2 Ǖ^OՅqw' !!'jJ'd1j hNN߂= ^J(7e,O@:ޜ$<3 WV'i&C:?`K41xCz䇍 C$U1[Zh>Øv7;ڛ& . _'?Gͯh7Pp$!ξchA2Dh!r^i?"k?#ң[d =5CObUK[ w==֓8C mNm0Э3\_p #fDz/8ǨX^n}y20B]wޜB/OC "9U<D~Zu[86lhQ(q̧b/.U0O][a`o2"SzO:Œ݇Qm7ȖWxNZ㏼/:Iȝlw6@+2\o9 6fx9'jb,#oo5]~+J"vélUPUa$n=7pHRꢝoVLkxN֓ɡ\hEHu܊sQ*v,wq4$Z-C)XWγRawcuWT|[RRUiG޸]oSE/~s,Ʃܽd5̔s~%BS8kw}A3daK,w]ި7g-[vcM 8r[f9c5joz8oB9'u`Sp^|QLlUumQW"󓥲۠CӨ䅀TL&bAZymB}LQ[hY[7Ht,'}D<ϴ 9@2gI*# JH(k LZ˦4検v7Fab$K5iڰW%#x\bs윚*N+Z xbs•r4iد pMG^l܃Dfy[3 ^;v *o+/sei"2b>; "R}pby3!wF(54ϭ\y!@&",7wuG 5;'U铍ġْNe%U"8 !(N$DpsNaAz0Q&7هr{gɕ/5 $DJLRYSO7Ezb:pgAZU)%-mcEÖ7} 1sWA7sin]a`8b⛛:X,Ƙ4V ؓOԨٹy[g-ԔNk?zsa7 匤]!N9rxv >gףFECP޸](`JX@ n,ϒMŝǰ4=Ѳ44+)k aO,@|r&q&H:lpeJ8ɧ|7!/zj+()Y%gHrIMy}#p9ݙn޸8P}ځ+fCnI1݉qۧ˚\\M &e&.ӷv&(OiݢHyԇyF$; KW9I"COO1xPe\/PܹoL7֍|NFg&Smà+?q+\IP^$տ-Ȱtco.kJ`q˲B*ثrsc? -E endstream endobj 15 0 obj <> stream xڵ[9++$j0o OUfdZ3k7M:>VQI):}y￙S$oqv:{s ~;}}UܔلPʚ5R?O{j ?s>{^+38Ccߝ5bO OJΙG1ސZX$)k?;p6.lBgHrqrCl Ί.K|D9bFn.`+AB7ybZ&8D044sIx_{fw2L+D\’I[ M(T&]!FR ڹ䞤wHzrʉ(ae5ѻ뮞H+TWJTQA"3X[Fl=lIlO;STW#&6έ0/^ _꯹w۶mS&@lllޒt F]Jy~UW9 M#܍P/۬᳊XSU'')Ni"=Cv4L'j o!0wuNľPn3udksXP,kH@Aԭ(w/"zrO,7lyı̉)锪sqIYR'XojtwtvR]0X;܉FƮ7Znm*7H98g{Ѡ0ؼN"7#ܽ*"bӠD}CTUThB--HYR)Iշ]ExFɲ^8# Gs_= "A➑?j2ੲCvmc} *s=|ܫ Y籗30J>U3Өݩ);\`HP/qRD%N}1SʒɽxO/R/ XD]LA&C^ɲ''{Fcd=,pJ6TP{m;-Gl9f8B1td1&0$f"T>Hnp$Y8NEH![y`;-_J 31bRo ø0Y\7rZ+`| `qkk^@吘ԵpPMZT j5R;/|ѵ!0wEy,çnBΤӎJxJS[y_s~x#64oR&UOkH9Us Q]αH;U=5=|4;Wް gbOr*\AkGZdNF?W։L̀d0jE h=~ ̮}fײkbvGԘ7ʔb=]Nh% A2fZZ>5'l 'RDӦdTg&I +&P`znSZ}QPaq͏MA!ÙV_CfZi {89"s/'jє(iI'LqJ/C郅½Zָ`Z>MDEӳ:̭&&JiD\, 2%2Ǜ }& ޤDu7.k.dޛr@ {oV  :tDr6a)ܺ\vUX^ݤHrHR}v}k@:ovm2y96׌Qg)iy y $F慐H yb_i|^<-!'+E0(+*y #y&m '1ߍkk^(WY !ֈT?Hcpukd+ 9q\XuO<9޿pP0ufQЅ YqQz")!.BA[r̯Ƞ3Òa5td edT6:ӏ1  |;J`f8sW9 Ot&(@'kCG- 榖`:f6Vԝ8Ә[M.8s|q6L1{&"ұ 7]cx+;N_OjRB>ͳmƈt`B eS$@[?*K'}wtvݫS[$ء*0U%\QU%J!N6|M5b=bw}5ՁQGm-(g*%f? yqr%.Ϫ5&itmمC)H0:ۦ+Zb8'W/n0]#x\8fYf{7azYT*ά2yώ*v88^hp޵_]]lӴ}" X[ :ϦD!fzq9Pi$lX1!. Z5zVZ$,-KGẔЀ΃nMcT%K-WM^hvɓ\,Ʒmo<bor2Zq1DeIk+&ŭE ⼩c1^ɤr@ʴ._0XXLy! '(Qnpy䣛>?߾P1ܧŸycX7sQE,hՐaw 7ٲۭ7T.'Hc<.sz6Jg +o> stream xXn6 ~+Qd  sow/$Z &Eb8(>~3;?enz~M?~T M}ZӜ2]9-mŹ;WGsW^ JmuRic w+WR+%K? OVI7qtjܮQIs5~HQ94}q 3 2tLB[wUC-L$!=%u l:Jt)D$sx5%LO!`1dh hLc8AK}\0&!'#ɾ9\a'~-R.ecV|V`x;`//{۪&̜B.*zZ= եaTW4 dw5b`8G<3tAb^X8z!6&يΰΪKl I؃I3/NǮT`:H; oI=6jlWBh@F~R8zXfFL$dG|ΫQB];CWsSNR(hV`5џ[WZ9p`KVb-vL軙EhwVWwsU^ ~cdt !9i$l;Ζ93Vm4ŬgmZ]% D?#5aMzp`=VzjueЏN5q..3\j[=v.ȷ!s޾s'? >EsA?}g$[q`߅mECaX׹<kp9uBUkR> stream x]j0}\v;9u+};Fo?v/|_rryډG݋&ִJjĮtkLbdUwlQS.חss&A9 ,y'J,I@Vg)F,md]rPz7 x(KLQGfKBE'Ĩ(:ڀ B<}Mxh=̘1aQ{~< endstream endobj 32 0 obj <> stream x]Qk@F+RL2D.B]{LF7P~9VP8q{զ5ݷT7U/:sDIgy)hogqjv߾}o/Eď|(~XUΫTxݯlSHٸ]=,M~.<ݺ_|38Z,%m]Qh>k|SKv<~Z8K@JJ!J@zVВ}^B@@ˠ5 -f a J 9V aeZ*ZH̤AY8{&ϐx egV`:# k+$RO> stream x]]k0{E.;FQV[a ºvic'R{?z1AIr'2/U;05b': 9WtlW#>ݾjm#&]e^ݯujz$c~|̝^diH2:1HuB^t!jZKIYROꑒ9Gةٸ<0*ՂC+("Ő[[-]-2eɡzZPU-b'䈋aj$+/b/F;xx3^{Mͥ{=EʫO endstream endobj 34 0 obj <> stream x]n0> stream xڍW TWjH1ڥUew30*,4v7@ߍ+ ,mBČh&bNKb9[3gN9U]}P2%H/ ]fڪuC⌙~`q8XDN"2D^**el( UL+.GQ֗@z|UB"yq=HѴ<Ҕh ؜n3gMw?_+ [ָ̩XސɯCT5lN䍦C|oכdb-$~}LO5[xk1ś VS$i!t=dNb&Ϗ&c% %G-Q~/^:t-G-|fkj,5JM\BjL-VR!ZjN)#K%PIJR<FdT&"aXذKd;yK8C{!t}YiU{prϘ!ͩ~oa:+yVb/HcI^& Zvd&]p2-7d4ssGC"t| Z葫qN+Ej)A9.v5hw,v4 = :[ZdT&T\1mLKn z ~/wR9Q5syś-A ~y, _1gOֹ0ZLӲ3#h.Dkε/idzoqe5wBh+j'&Ew5dm;P~fQ|v) -gKPs[ޭM'^C辵 |{a@ӎ?`R8{ʎwI9VI1#K"C@6Z#^ @ۭ^q:qyfD6^C-KiF%m7EwtY5fP Z"(/2' jGar&rCS$di?Ҽ B Gk=6<1[j@𷸶 ݂ES[#i}F²2?eWdDpE0L9uxf? %~@rw籸,8}7m&_. iR(#RS/:T#ߎv`w*kQ%L0"+hqa:j1^D)j"G m4W]D5Cug,Tc?z}C/ 0B{F/OH]idB tɓ nv;;?3ֻ.s>W[, ҚGsIW4}n cB@֤SxYu+z_A[ rW`-vR$E" Ki΂Fy=e⛰G@J#WY^9#vy9̈́\u$V.=e2 @ |LC ^G>I*v[{09-EYZ=9H1#7cYBnuK#=pC-|sΛ: lȁOzJsvd%$IV&κ>4g@:TvFiqaǜ\y8ZvS!2O}]%)-+lYT/ yQ\p:J+oT{NTu;l8 endstream endobj 38 0 obj <> stream xk``0T0Hа endstream endobj 40 0 obj <> stream xڥzXW,`Ce\3f XQWbWzQzXݥw) ࠀvwkI,Q/$& ^fo|̽{=wҒH$C]W,_pN!AƏu 7. o' V* ki^b!I/[MwĿFl;|{iAH-#F];gOpȸvO?vƘߧ:. bmv튐ۑ!>!.>km"|#lCB#>ua`+~xDxF{F.tuv]ilOpر>>3ƍ +Ή3)b{c8pl+EFzDzl { @Baap]b$!1M!v8b1D|DL%Ӊ'lbaO8b!XB,%ˉ*‰p&\Wb5XKl wƒ$o‡'[""B0"$h"# y/_&?$b${0_UZN -}%%?C"Nr=>}ۿoxZSK $ tก 9OO)&); zCCj9GG0aߎ~Z.h{z`ug a/ltz HDŽJvdE障x&^JHWqkj?Txr]ƠC +eUt3 eICgh/AGnʬҸ҇G67u(Hx6 SR< OJ`'園lM6m(P<" u:]X/a,gxރi6X5.mb p"Hv<^Qq6)fF6'Ե|[7o8.s[a:)Hݻ^$޹eQ,R֝k=n7B3o\}:R_bi!/lE`^uU~'lD0LNEЇbX@+߭99uqGjܡfoVVEpBi j}q;B*)rg$妭纾7e%`/O@M)|5h ٯ)KD2 '\lPr}n'4G$܎z1HN(s,/9\% |Dd-M% vqXHWp z.fJdrQfdTvw vjv^+`Jlk2It$OFMJ/IeVOS`y~ ZHT͟0AOG7E/ )֊ꈺ:ߴ53DsS\h XR_gphRitZVFV[@yN /gLڹ( 30~sYa&0Vr XGlhӪ{KKv3ūQڸ+̢#Mɟk|`_y;#T9G9*S@1ؽƕ+0d$/SoPX!rK5olϴMuYrLClle|}V7=N7f7nd M۬VOqIyѯ 7vpeveA_z5s.~ΚS^8[dV>!ۆ=zpA 5QMoE7L nfR7rVr8#}&oNl9a(3fK9k8xA仹F Xw_ MWhp3of%Z$VBd#>&5| r+#GJPZ NG+fQ';`$6h94GOA4@pM 3&6*U٣luVG"ٔ1ʂڔSK5d DS{G&x%Pjqސɖ49n˕1ƒ 888 fSu6MU9dQbG~DBTN\ 0] l +Pv|̆|Y O6o=(7GL ny }rj9^2Κ(xnV聴3<2 'R[b*%d ^vA7\zr$WD=`2NoלE*`PX̬+f7g8=XUZ*&} "B0R#;MRX-X%nO1w/zS޿lHh[[֮^V0HdFt&Q4˙^^il*c(2#]Do+J*/ϩbmvd v|\g.)vAWʲS oc+ fb-z=yrs`{ WV=_[/|9A] gjd.@9uI4 0}w54d*vP^QO,]Qq]7?u&Gg~ZOh eE!kc_e Cq\1gp) HmM48٢B79U򄅘ZɮIX:U2?oI>i/ M%s\IfT*5ҔqOFugl&&!Vefd?P6(]QY|llDF0mN_`3.:~sqg %Ob[_n:툍. `fϛ{~`YG|Kodj39'RQ)̂\V0tdybMwtQ[HL&fq̀Uh>+6 v+j_,{bdTiCUPW+~3QxYm祏l(<|>X}ֲ `B72+bg_nZL('p' ATyg跊lTD)iZv?.Y}x;.CW߼pX ~*EZ=U$K[іn \D/A^->,rJN-I3HKP^ V_*`cm\=V :wE ,X{3Uّȧ#Ukc2SaEi3fJN_2,,2`;S+X<-/>y䅛OۜͪtHUr6u˙46)wyLdD4| \AF[gvJ ߺnYGWN/kH͈Q6VȐ^4˅6#4AA ٭޹V 5-"kBե ⟺ NנDVDlٿ4dgWVУ,.5 AfXE '5^v(FTA.$`_Hي;n[y[IG?qVcl_a;mgEL˩ IUan\І-p65BƤjӴɴ2`4-[>g9!7C+#$`G%7߀ɯRpOJsKnE1xsg4'Xf?n1dPRW㟪AZ5{dY9f,g *S*&H9 Qp?ܣ?xοnC{qm(~FwF}|R{K;sZڏ?R7,tq8KoHg&RO(rcNXN 9b]ˏr!A*d #D4Hf٧&mAd,P\l 2UDtM3*cE%jYN$*K"F`%dӋ̼|Q7vo ~Y$>om^FPk_Aj?VlUTţH4q3H]ٙ͌"NuK;{ F1vƸ`Z4x7R*PϢw6 юwղJ5\ ('v N2*d"ue>W{cZ,!ː*.~ƟqL}Ѝq/_ blꈷ)tZ(Z0 =Z]3ol)9l暰 mZKͣl+5t|rb]>kO|ϦKJ*t,U$HeuPqg:a)VltDNCWmX|} a~0Ԝ(CZQ m}sdʢx=TRYޓvFG6*1C/#4Ѹ,Ҕy{7s*J9? P$:W\Sمs3a,oS~:൥d&=}kŖ(df5M2H9/`T$|%*dRb9>3XJĖFD%mn;v̙j ejt9+I$j7Tx͏FzDa+/(ű\&`@.]d)" 9u!7SsQ t`4ԃqt9e6;cɯ*8_ͺyV*c;mfW~w˨]Ч<=nd9f/, H|EѪJ7t)9+`}P 5uCݿ@7X>Ƈ8NI U):$ј[@F>zhm,z} ԃFsw S()mRdZZ%{29޾#+XO*$ZX^UUKKC9S" H]̙K̜yeɭ[W#s6YQm_LBJŊVjg9_tٸc e;kXX=%y!e=w)GtW(fuz!}B6wr6)u6%k M%D; (g{[{_c }Z lٷueQ endstream endobj 42 0 obj <> stream xk``(_y 1 endstream endobj 44 0 obj <> stream x}V PAY5Kw^E-^+EUDTԠHD A(" geŶR[XcqZ-׶=ܻA[fv? EH$U&GXmH6iJ׺G³H !8O )<*F%^g B~6Mķ/*?RL#d_@ȃ']5iuFk5ovhx܅N7u6jufΪqKsMF+Eg踐tj͜fN 5Sös,a'YB^0*&.*Ԛk嶚̜VgMNK.!^_`"MLJ, "R bKDDiD͓WL&&{o^]!I\pyz ^zK+d e d,GȿNNa+moЂUM(Mj0}gʷlvhoϭ1owW 4r WTA0L+"QIʼn@|s@SF*r ~.d`"Q=`J<-r1 \%Ҳxp}ݑrª5hy_⳴L1@GiOB9l=6L QR*|z}ZLn fVB{JK謍 4fL?u6AQmW@cyE,C5%c; ^jy%;_/xaC'"\ޟ'WO$5:g7ivc $/5/?%~&\2ၪ?HR&(Bs_!!>l. <>o*dv檓- }R]0Y.n+n"D7L@UvgNMZ2%7NRtXYmz L-r[:a84u텟,bUoǭDtV"+ b(Eec4Lv7w<̶n(KKq溼ff6s9‰͛h&T5+6 2-;R,qL%rYb8@gzpB.)2 C`&H\a7=\ DFD_B7@PǠǟ_!L'38m$<^tHg>FTzgR^ 8")n¿:f :V$ӟN&x>͋k4,0=Q1M[acLHROEp(h}zzoا4dY >UZŎE(CO.{@gOYe#@ ~y![ s蹫7EX Hkd=s]9 Ix>ܤ=A Y?4%Qc}*S a#eix xs: 1> QE7N꺘wF! oT+;!^!!Nح5@„F #[7c !k8jZϣ uNHTGT9Hk̐4<{/LT}I ,Xt6qif̰SE82F_8sy( K~Ow )v)q F FOz WEKFw7!ģݢrb yh2q< +G KѻJB֩4>ՏΝie $Jk+iX> stream xk``TTѰ P endstream endobj 48 0 obj <> stream xڅW XW C&Z{jm (UU$$@""SnzjGn_kWj[k[M v۝7/Xz77T |6I:EڶzOAgex,mNJ9&g^louvފ~5"^t+rrsY<϶pB`GWb&_y$i ߢU \*ӊ^\`{.Bcv&4rQLR(T, Uiܪ\*I+(ExQ$RHT%k^"dr(MNqZh$q"]RD-$[6GUIZNIF"4H&juRJ-h4Q"=>֭ZyXūԢ86FЈW1 h‹O, Ą/'ˉWDJ'6akD!b !'Dj/I=o^" ;ݏ:/قyᎃSܜm 'Wvu(Z~sxh}ў5v k甃Rfx?o0)$=3xpߠF&hT!YvuA)-![KӠBy3m/H! >-tT:[-Rìk[xT6vT>q0k`%YjٍIopoi@*ϔ;a7wB-LTM4 a=SƸZ}Q+hg ! ¤bBa&[G/Х=.652VeFQ^a(Վ #i,LW Dhrm}:mBߕsY,[VT E|<XR kanbbI4.LL<5<opD<;2Ȃ7Ԇ`$vwJ ) ۸_V53?ٙ[<bR<wv*\ G fy1zIHnZ׆_rr>HgAohu-9&4f `܈th {؞>Y(t;l!tx  I[cS^rQl ;1`wz!mWс|gлdSCLP}gyFsaUz^%c-vZ65 sа!adm+=gEOսIzK(Ы:/[7YQ5.k[z[һY"D^ְYdǁt|SfVWpFP\p Q_;`ovLBz Y 0YFhafY\_߸>P]`Y1p?}!^):z떘uɓg;uс;{.ʞFPZ oCx<<\bTm#ʲik$兎ՅtyySZqUTs4 66 7IA.@N݋gkFT$hWfǩ,U}44 EWq̠GA4umwGmc-P q~0cfس짣.C5c JH?UL1 ٣(W*6 jJ# [*x2#0N)kdSF ;oE60"窙y슩{ wBqX`PPʕk/qHmAe39oEe(,y26;~WX2؉񾽇(y ].Sn/慕c!+;g9ǗF OG#n!_2 m#Wϋ41HkzWBJP Vsj@/{TKzO{Z루*cX1:h27vKuW, ˺ Tmv"ϭ;BfYNӾxIげDV$!CuWs(Zixи[PŞFŸ)'~۳m2ddvJej4EGt/./S]U)rW ;hsx|h/e&BL((H`V sha`A*"k@˞ц1N 7a=l%fMyZxAh1Xh轋wIo'7E^TDS499I/ I\ڃ+IoƱc;->/ceC+9_#sdP& FV^$ܢcqkCo[(Ayycc;UXo(Tp!A =Z',ʑ?^$_Vs]@R8WxŘ;BUe ewr7 v~#l|nU*rUY :D@g'Tӑ *o,pvmS`ޡf  ǯ_ endstream endobj 50 0 obj <> stream xk```NT5 endstream endobj 9 0 obj <> stream xڵWnH}ѐj/{⶝N >--D%Ո&tmw[*&Lˤcy$Z0e)Ō6Life2fڧpdYMrVyY,TNôybіs>nF|4-t1-Gm< eAx7aaʏ.Fb ]}{7ftW9姖_ΊIy5]sw Cy @WP?@:@zۡ^NkFu ]S\4s_||x!ZZ|#!Ba">c#9/ъo#dt1/*dogF;Gؓܒ՝ zY\zQ{:-YFm/Z"U5K$` שpTJ~Ko)I:d%mhQ "T7@vE&xLk[7+~䷩+^[_xAH35Wi)Þ6pjiUq_~d'G\C*rT>$%;媩ϋ<8E  t+YOF$WEi͸e;j'U.]$O*5) gE[L YYsm3lnTp^n|"C YYsg39n{9ﺮ͢ﴂ Ch=8ǐas)`R$/lļt]<_8<1-~Z,ʴzvfVR Nd^@I@Tvrp2npXʩڗCy~3JqPh^=鲤d@ լBň,S w7ܩG&O&1dHN D{i}/q褞LK&Ŵ+iYGbgD;Hմĥa2ZBo‘'5Zg*F`1l=vLKd%aoy$ VG'L oimw} ]GXv(WQ=xP Ab{İ"|_r$j endstream endobj 51 0 obj <<09ad94a378f724efedcd8d7430334960>]/Size 52/W[1 2 2]/Filter/FlateDecode/Length 151>> stream x-;Ps(*H5vDw`:tE&|'̽ځXE&K6bO6RL%6:b*3٢#z/b FC y25d߆nW<'5Պeݲ|ZEV)/1ϯ5u endstream endobj startxref 27160 %%EOF goxel-0.11.0/doc/cla/individual/000077500000000000000000000000001435762723100163555ustar00rootroot00000000000000goxel-0.11.0/doc/cla/individual/black-cat.md000066400000000000000000000004251435762723100205210ustar00rootroot00000000000000Russia, 2020-01-24 I hereby agree to the terms of the Goxel Individual Contributor License Agreement v1.0. I declare that I am authorized and able to make this agreement and sign this declaration. Signed, Artem Buryachenko iblackcatw@gmail.com https://github.com/Black-Cat goxel-0.11.0/doc/cla/individual/mailaender.md000066400000000000000000000004351435762723100210020ustar00rootroot00000000000000Germany, 2021-02-21 I hereby agree to the terms of the Goxel Individual Contributor License Agreement v1.0. I declare that I am authorized and able to make this agreement and sign this declaration. Signed, Matthias Mailänder matthias@mailaender.name https://github.com/Mailaender goxel-0.11.0/doc/cla/individual/ntfwc.md000066400000000000000000000004071435762723100200210ustar00rootroot00000000000000United States, 2019-07-09 I hereby agree to the terms of the Goxel Individual Contributor License Agreement v1.0. I declare that I am authorized and able to make this agreement and sign this declaration. Signed, ntfwc ntfwc@yahoo.com https://github.com/ntfwc goxel-0.11.0/doc/cla/individual/podsvirov.md000066400000000000000000000004341435762723100207330ustar00rootroot00000000000000Russia, 2021-04-26 I hereby agree to the terms of the Goxel Individual Contributor License Agreement v1.0. I declare that I am authorized and able to make this agreement and sign this declaration. Signed, Konstantin Podsvirov konstantin@podsvirov.pro https://github.com/podsvirov goxel-0.11.0/doc/cla/individual/ravencgg.md000066400000000000000000000004251435762723100204740ustar00rootroot00000000000000United States, 2021-06-04 I hereby agree to the terms of the Goxel Individual Contributor License Agreement v1.0. I declare that I am authorized and able to make this agreement and sign this declaration. Signed, Chris Genova raven.cgg@gmail.com https://github.com/ravencgg goxel-0.11.0/doc/cla/individual/sariug.md000066400000000000000000000004111435762723100201650ustar00rootroot00000000000000Turkey, 2020-03-02 I hereby agree to the terms of the Goxel Individual Contributor License Agreement v1.0. I declare that I am authorized and able to make this agreement and sign this declaration. Signed, sariug ugurcansari93@gmail.com https://github.com/sariuggoxel-0.11.0/doc/cla/individual/template.md000066400000000000000000000004111435762723100205060ustar00rootroot00000000000000, I hereby agree to the terms of the Goxel Individual Contributor License Agreement v1.0. I declare that I am authorized and able to make this agreement and sign this declaration. Signed, John Doe jd@example.com https://github.com/johndoe goxel-0.11.0/doc/cla/individual/vvbalashoff.md000066400000000000000000000004311435762723100211760ustar00rootroot00000000000000Russia, 2020-12-01 I hereby agree to the terms of the Goxel Individual Contributor License Agreement v1.0. I declare that I am authorized and able to make this agreement and sign this declaration. Signed, vadim v. balashoff vvb.backup@rambler.ru https://github.com/vvbalashoff goxel-0.11.0/doc/cla/sign-cla.md000066400000000000000000000132201435762723100162420ustar00rootroot00000000000000# Sign the Goxel CLA In order for your contribution to Goxel to be accepted, you have to sign the Goxel Contributor License Agreement (CLA). More information about this requirement is explained in the [FAQ](#faq). ## If you are an individual 1. Read the [Individual Contributor License Agreement](icla-1.0.md) 2. Modify your current pull request, or make a new pull request adding a new file `.md` under the [`doc/cla/individual`](individual/) directory. If your GitHub login is `xalioth`, the file would be `doc/cla/individual/xalioth.md`. The file should contain: ``` , I hereby agree to the terms of the Goxel Individual Contributor License Agreement v1.0. I declare that I am authorized and able to make this agreement and sign this declaration. Signed, https://github.com/ ``` Replacing the following placeholders: * ``: your country * ``: current date in the form `YYYY-MM-DD` * ``: your name * ``: your git committer email **(use `git config user.email` to see it)** * ``: your GitHub login 3. A Goxel Team member will verify and accept your Pull Request. You can make other pull requests, but we won't be able to merge them until your CLA signature is merged. ## If you work for a company 1. Read the [Corporate Contributor License Agreement](ccla-1.0.md) 2. Modify your current pull request, or make a new pull request adding a new file `.md` under the [`doc/cla/corporate`](corporate/) directory. If the name of the company is NocSoft, the file would be `doc/cla/corporate/nocsoft.md`. The file should contain: ``` , agrees to the terms of the Goxel Corporate Contributor License Agreement v1.0. I declare that I am authorized and able to make this agreement and sign this declaration. Signed, https://github.com/ List of contributors: https://github.com/ ``` The List of contributors should list the individual contributors working for the company. Replacing the following placeholders: * ``: your country * ``: current date in the form `YYYY-MM-DD` * ``: your name * ``: git committer email **(use `git config user.email` to see it)** * ``: your GitHub login 3. A Goxel Team member will verify and accept your Pull Request. You can make other pull requests, but we won't be able to merge them until your CLA signature is merged. ## If you don't have a github account If you cannot submit your signature using a pull request, you may alternatively print the CLA, complete it, sign it, scan it and send it by email to contact@noctua-software.com. In that case someone from the Goxel team will make the pull request on your behalf. * Printable Goxel CCLA v1.0 https://raw.githubusercontent.com/guillaumechereau/goxel/master/doc/cla/ccla-1.0.pdf * Printable Goxel ICLA v1.0 https://raw.githubusercontent.com/guillaumechereau/goxel/master/doc/cla/icla-1.0.pdf # FAQ ## Why do I need to accept a CLA ? The goal of having a Contributor License Agreement for Goxel is to: * clearly define the terms under which intellectual property (patches, pull requests, etc.) have been contributed to the Goxel project * protect the Goxel project and its users in case of legal dispute about the origin or ownership of any part of the code * protect the Goxel project and its users from bad actors who would contribute and then try to withdraw their contributions or cause legal trouble, e.g. in the form of patent lawsuits This is done by establishing a credible, non-repudiable record that each contributor really intended to contribute to the Goxel project under specific terms, and they had the right to make those contributions. The CLA is for the protection of the contributors, the project and its users. It does not change your rights to use your own contributions for any other purpose. The Goxel CLA is based on the Apache Software Foundation CLA v2.0, as can be found on the Apache website. This CLA is not a copyright assignment, it is a pure license agreement. You keep the full copyright for your contributions, you simply provide an irrevocable license to the project maintainer, Noctua Software Ltd to use, modify and distribute your contributions without further restrictions. ## How does it work? Each individual contributor (making contributions only on their own behalf) is required to sign and submit the Individual Contributor License Agreement (ICLA) of Goxel. The agreement is executed by adding your name and signature to the list of validated contributors inside the project source code. If someone is unable to sign the CLA, their contributions will have to be removed from the Goxel project. In addition, if some or all of someone's contributions are written as part of an employment by somebody else, the work may not belong to the contributor but to their employer, depending on the contract terms and local laws. In that case the employer needs to sign the Corporate Contributor License Agreement (CCLA), including the names of all contributors allowed to make those contributions in order for those contributions to be accepted. The contributors should still sign the Individual CLA, in order to cover the contributions that do not belong to the employer. Contributors who have signed the ICLA without a CCLA from their employer should be very careful. The ICLA (section 4) is a legal declaration where the contributor states they have the right to make the contributions. These contributors should only submit contributions they are really entitled to license. goxel-0.11.0/ext_src/000077500000000000000000000000001435762723100143705ustar00rootroot00000000000000goxel-0.11.0/ext_src/cgltf/000077500000000000000000000000001435762723100154675ustar00rootroot00000000000000goxel-0.11.0/ext_src/cgltf/cgltf.h000066400000000000000000005107521435762723100167510ustar00rootroot00000000000000/** * cgltf - a single-file glTF 2.0 parser written in C99. * * Version: 1.8 * * Website: https://github.com/jkuhlmann/cgltf * * Distributed under the MIT License, see notice at the end of this file. * * Building: * Include this file where you need the struct and function * declarations. Have exactly one source file where you define * `CGLTF_IMPLEMENTATION` before including this file to get the * function definitions. * * Reference: * `cgltf_result cgltf_parse(const cgltf_options*, const void*, * cgltf_size, cgltf_data**)` parses both glTF and GLB data. If * this function returns `cgltf_result_success`, you have to call * `cgltf_free()` on the created `cgltf_data*` variable. * Note that contents of external files for buffers and images are not * automatically loaded. You'll need to read these files yourself using * URIs in the `cgltf_data` structure. * * `cgltf_options` is the struct passed to `cgltf_parse()` to control * parts of the parsing process. You can use it to force the file type * and provide memory allocation as well as file operation callbacks. * Should be zero-initialized to trigger default behavior. * * `cgltf_data` is the struct allocated and filled by `cgltf_parse()`. * It generally mirrors the glTF format as described by the spec (see * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0). * * `void cgltf_free(cgltf_data*)` frees the allocated `cgltf_data` * variable. * * `cgltf_result cgltf_load_buffers(const cgltf_options*, cgltf_data*, * const char* gltf_path)` can be optionally called to open and read buffer * files using the `FILE*` APIs. The `gltf_path` argument is the path to * the original glTF file, which allows the parser to resolve the path to * buffer files. * * `cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, * cgltf_size size, const char* base64, void** out_data)` decodes * base64-encoded data content. Used internally by `cgltf_load_buffers()` * and may be useful if you're not dealing with normal files. * * `cgltf_result cgltf_parse_file(const cgltf_options* options, const * char* path, cgltf_data** out_data)` can be used to open the given * file using `FILE*` APIs and parse the data using `cgltf_parse()`. * * `cgltf_result cgltf_validate(cgltf_data*)` can be used to do additional * checks to make sure the parsed glTF data is valid. * * `cgltf_node_transform_local` converts the translation / rotation / scale properties of a node * into a mat4. * * `cgltf_node_transform_world` calls `cgltf_node_transform_local` on every ancestor in order * to compute the root-to-node transformation. * * `cgltf_accessor_unpack_floats` reads in the data from an accessor, applies sparse data (if any), * and converts them to floating point. Assumes that `cgltf_load_buffers` has already been called. * By passing null for the output pointer, users can find out how many floats are required in the * output buffer. * * `cgltf_accessor_num_components` is a tiny utility that tells you the dimensionality of * a certain accessor type. This can be used before `cgltf_accessor_unpack_floats` to help allocate * the necessary amount of memory. * * `cgltf_accessor_read_float` reads a certain element from a non-sparse accessor and converts it to * floating point, assuming that `cgltf_load_buffers` has already been called. The passed-in element * size is the number of floats in the output buffer, which should be in the range [1, 16]. Returns * false if the passed-in element_size is too small, or if the accessor is sparse. * * `cgltf_accessor_read_uint` is similar to its floating-point counterpart, but limited to reading * vector types and does not support matrix types. The passed-in element size is the number of uints * in the output buffer, which should be in the range [1, 4]. Returns false if the passed-in * element_size is too small, or if the accessor is sparse. * * `cgltf_accessor_read_index` is similar to its floating-point counterpart, but it returns size_t * and only works with single-component data types. * * `cgltf_result cgltf_copy_extras_json(const cgltf_data*, const cgltf_extras*, * char* dest, cgltf_size* dest_size)` allows users to retrieve the "extras" data that * can be attached to many glTF objects (which can be arbitrary JSON data). The * `cgltf_extras` struct stores the offsets of the start and end of the extras JSON data * as it appears in the complete glTF JSON data. This function copies the extras data * into the provided buffer. If `dest` is NULL, the length of the data is written into * `dest_size`. You can then parse this data using your own JSON parser * or, if you've included the cgltf implementation using the integrated JSMN JSON parser. */ #ifndef CGLTF_H_INCLUDED__ #define CGLTF_H_INCLUDED__ #include #ifdef __cplusplus extern "C" { #endif typedef size_t cgltf_size; typedef float cgltf_float; typedef int cgltf_int; typedef unsigned int cgltf_uint; typedef int cgltf_bool; typedef enum cgltf_file_type { cgltf_file_type_invalid, cgltf_file_type_gltf, cgltf_file_type_glb, } cgltf_file_type; typedef enum cgltf_result { cgltf_result_success, cgltf_result_data_too_short, cgltf_result_unknown_format, cgltf_result_invalid_json, cgltf_result_invalid_gltf, cgltf_result_invalid_options, cgltf_result_file_not_found, cgltf_result_io_error, cgltf_result_out_of_memory, cgltf_result_legacy_gltf, } cgltf_result; typedef struct cgltf_memory_options { void* (*alloc)(void* user, cgltf_size size); void (*free) (void* user, void* ptr); void* user_data; } cgltf_memory_options; typedef struct cgltf_file_options { cgltf_result(*read)(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, const char* path, cgltf_size* size, void** data); void (*release)(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, void* data); void* user_data; } cgltf_file_options; typedef struct cgltf_options { cgltf_file_type type; /* invalid == auto detect */ cgltf_size json_token_count; /* 0 == auto */ cgltf_memory_options memory; cgltf_file_options file; } cgltf_options; typedef enum cgltf_buffer_view_type { cgltf_buffer_view_type_invalid, cgltf_buffer_view_type_indices, cgltf_buffer_view_type_vertices, } cgltf_buffer_view_type; typedef enum cgltf_attribute_type { cgltf_attribute_type_invalid, cgltf_attribute_type_position, cgltf_attribute_type_normal, cgltf_attribute_type_tangent, cgltf_attribute_type_texcoord, cgltf_attribute_type_color, cgltf_attribute_type_joints, cgltf_attribute_type_weights, } cgltf_attribute_type; typedef enum cgltf_component_type { cgltf_component_type_invalid, cgltf_component_type_r_8, /* BYTE */ cgltf_component_type_r_8u, /* UNSIGNED_BYTE */ cgltf_component_type_r_16, /* SHORT */ cgltf_component_type_r_16u, /* UNSIGNED_SHORT */ cgltf_component_type_r_32u, /* UNSIGNED_INT */ cgltf_component_type_r_32f, /* FLOAT */ } cgltf_component_type; typedef enum cgltf_type { cgltf_type_invalid, cgltf_type_scalar, cgltf_type_vec2, cgltf_type_vec3, cgltf_type_vec4, cgltf_type_mat2, cgltf_type_mat3, cgltf_type_mat4, } cgltf_type; typedef enum cgltf_primitive_type { cgltf_primitive_type_points, cgltf_primitive_type_lines, cgltf_primitive_type_line_loop, cgltf_primitive_type_line_strip, cgltf_primitive_type_triangles, cgltf_primitive_type_triangle_strip, cgltf_primitive_type_triangle_fan, } cgltf_primitive_type; typedef enum cgltf_alpha_mode { cgltf_alpha_mode_opaque, cgltf_alpha_mode_mask, cgltf_alpha_mode_blend, } cgltf_alpha_mode; typedef enum cgltf_animation_path_type { cgltf_animation_path_type_invalid, cgltf_animation_path_type_translation, cgltf_animation_path_type_rotation, cgltf_animation_path_type_scale, cgltf_animation_path_type_weights, } cgltf_animation_path_type; typedef enum cgltf_interpolation_type { cgltf_interpolation_type_linear, cgltf_interpolation_type_step, cgltf_interpolation_type_cubic_spline, } cgltf_interpolation_type; typedef enum cgltf_camera_type { cgltf_camera_type_invalid, cgltf_camera_type_perspective, cgltf_camera_type_orthographic, } cgltf_camera_type; typedef enum cgltf_light_type { cgltf_light_type_invalid, cgltf_light_type_directional, cgltf_light_type_point, cgltf_light_type_spot, } cgltf_light_type; typedef struct cgltf_extras { cgltf_size start_offset; cgltf_size end_offset; } cgltf_extras; typedef struct cgltf_extension { char* name; char* data; } cgltf_extension; typedef struct cgltf_buffer { cgltf_size size; char* uri; void* data; /* loaded by cgltf_load_buffers */ cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_buffer; typedef enum cgltf_meshopt_compression_mode { cgltf_meshopt_compression_mode_invalid, cgltf_meshopt_compression_mode_attributes, cgltf_meshopt_compression_mode_triangles, cgltf_meshopt_compression_mode_indices, } cgltf_meshopt_compression_mode; typedef enum cgltf_meshopt_compression_filter { cgltf_meshopt_compression_filter_none, cgltf_meshopt_compression_filter_octahedral, cgltf_meshopt_compression_filter_quaternion, cgltf_meshopt_compression_filter_exponential, } cgltf_meshopt_compression_filter; typedef struct cgltf_meshopt_compression { cgltf_buffer* buffer; cgltf_size offset; cgltf_size size; cgltf_size stride; cgltf_size count; cgltf_meshopt_compression_mode mode; cgltf_meshopt_compression_filter filter; } cgltf_meshopt_compression; typedef struct cgltf_buffer_view { cgltf_buffer* buffer; cgltf_size offset; cgltf_size size; cgltf_size stride; /* 0 == automatically determined by accessor */ cgltf_buffer_view_type type; void* data; /* overrides buffer->data if present, filled by extensions */ cgltf_bool has_meshopt_compression; cgltf_meshopt_compression meshopt_compression; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_buffer_view; typedef struct cgltf_accessor_sparse { cgltf_size count; cgltf_buffer_view* indices_buffer_view; cgltf_size indices_byte_offset; cgltf_component_type indices_component_type; cgltf_buffer_view* values_buffer_view; cgltf_size values_byte_offset; cgltf_extras extras; cgltf_extras indices_extras; cgltf_extras values_extras; cgltf_size extensions_count; cgltf_extension* extensions; cgltf_size indices_extensions_count; cgltf_extension* indices_extensions; cgltf_size values_extensions_count; cgltf_extension* values_extensions; } cgltf_accessor_sparse; typedef struct cgltf_accessor { cgltf_component_type component_type; cgltf_bool normalized; cgltf_type type; cgltf_size offset; cgltf_size count; cgltf_size stride; cgltf_buffer_view* buffer_view; cgltf_bool has_min; cgltf_float min[16]; cgltf_bool has_max; cgltf_float max[16]; cgltf_bool is_sparse; cgltf_accessor_sparse sparse; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_accessor; typedef struct cgltf_attribute { char* name; cgltf_attribute_type type; cgltf_int index; cgltf_accessor* data; } cgltf_attribute; typedef struct cgltf_image { char* name; char* uri; cgltf_buffer_view* buffer_view; char* mime_type; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_image; typedef struct cgltf_sampler { cgltf_int mag_filter; cgltf_int min_filter; cgltf_int wrap_s; cgltf_int wrap_t; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_sampler; typedef struct cgltf_texture { char* name; cgltf_image* image; cgltf_sampler* sampler; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_texture; typedef struct cgltf_texture_transform { cgltf_float offset[2]; cgltf_float rotation; cgltf_float scale[2]; cgltf_int texcoord; } cgltf_texture_transform; typedef struct cgltf_texture_view { cgltf_texture* texture; cgltf_int texcoord; cgltf_float scale; /* equivalent to strength for occlusion_texture */ cgltf_bool has_transform; cgltf_texture_transform transform; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_texture_view; typedef struct cgltf_pbr_metallic_roughness { cgltf_texture_view base_color_texture; cgltf_texture_view metallic_roughness_texture; cgltf_float base_color_factor[4]; cgltf_float metallic_factor; cgltf_float roughness_factor; cgltf_extras extras; } cgltf_pbr_metallic_roughness; typedef struct cgltf_pbr_specular_glossiness { cgltf_texture_view diffuse_texture; cgltf_texture_view specular_glossiness_texture; cgltf_float diffuse_factor[4]; cgltf_float specular_factor[3]; cgltf_float glossiness_factor; } cgltf_pbr_specular_glossiness; typedef struct cgltf_clearcoat { cgltf_texture_view clearcoat_texture; cgltf_texture_view clearcoat_roughness_texture; cgltf_texture_view clearcoat_normal_texture; cgltf_float clearcoat_factor; cgltf_float clearcoat_roughness_factor; } cgltf_clearcoat; typedef struct cgltf_transmission { cgltf_texture_view transmission_texture; cgltf_float transmission_factor; } cgltf_transmission; typedef struct cgltf_ior { cgltf_float ior; } cgltf_ior; typedef struct cgltf_specular { cgltf_texture_view specular_texture; cgltf_float specular_color_factor[3]; cgltf_float specular_factor; } cgltf_specular; typedef struct cgltf_sheen { cgltf_texture_view sheen_color_texture; cgltf_float sheen_color_factor[3]; cgltf_texture_view sheen_roughness_texture; cgltf_float sheen_roughness_factor; } cgltf_sheen; typedef struct cgltf_material { char* name; cgltf_bool has_pbr_metallic_roughness; cgltf_bool has_pbr_specular_glossiness; cgltf_bool has_clearcoat; cgltf_bool has_transmission; cgltf_bool has_ior; cgltf_bool has_specular; cgltf_bool has_sheen; cgltf_pbr_metallic_roughness pbr_metallic_roughness; cgltf_pbr_specular_glossiness pbr_specular_glossiness; cgltf_clearcoat clearcoat; cgltf_ior ior; cgltf_specular specular; cgltf_sheen sheen; cgltf_transmission transmission; cgltf_texture_view normal_texture; cgltf_texture_view occlusion_texture; cgltf_texture_view emissive_texture; cgltf_float emissive_factor[3]; cgltf_alpha_mode alpha_mode; cgltf_float alpha_cutoff; cgltf_bool double_sided; cgltf_bool unlit; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_material; typedef struct cgltf_morph_target { cgltf_attribute* attributes; cgltf_size attributes_count; } cgltf_morph_target; typedef struct cgltf_draco_mesh_compression { cgltf_buffer_view* buffer_view; cgltf_attribute* attributes; cgltf_size attributes_count; } cgltf_draco_mesh_compression; typedef struct cgltf_primitive { cgltf_primitive_type type; cgltf_accessor* indices; cgltf_material* material; cgltf_attribute* attributes; cgltf_size attributes_count; cgltf_morph_target* targets; cgltf_size targets_count; cgltf_extras extras; cgltf_bool has_draco_mesh_compression; cgltf_draco_mesh_compression draco_mesh_compression; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_primitive; typedef struct cgltf_mesh { char* name; cgltf_primitive* primitives; cgltf_size primitives_count; cgltf_float* weights; cgltf_size weights_count; char** target_names; cgltf_size target_names_count; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_mesh; typedef struct cgltf_node cgltf_node; typedef struct cgltf_skin { char* name; cgltf_node** joints; cgltf_size joints_count; cgltf_node* skeleton; cgltf_accessor* inverse_bind_matrices; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_skin; typedef struct cgltf_camera_perspective { cgltf_float aspect_ratio; cgltf_float yfov; cgltf_float zfar; cgltf_float znear; cgltf_extras extras; } cgltf_camera_perspective; typedef struct cgltf_camera_orthographic { cgltf_float xmag; cgltf_float ymag; cgltf_float zfar; cgltf_float znear; cgltf_extras extras; } cgltf_camera_orthographic; typedef struct cgltf_camera { char* name; cgltf_camera_type type; union { cgltf_camera_perspective perspective; cgltf_camera_orthographic orthographic; } data; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_camera; typedef struct cgltf_light { char* name; cgltf_float color[3]; cgltf_float intensity; cgltf_light_type type; cgltf_float range; cgltf_float spot_inner_cone_angle; cgltf_float spot_outer_cone_angle; } cgltf_light; struct cgltf_node { char* name; cgltf_node* parent; cgltf_node** children; cgltf_size children_count; cgltf_skin* skin; cgltf_mesh* mesh; cgltf_camera* camera; cgltf_light* light; cgltf_float* weights; cgltf_size weights_count; cgltf_bool has_translation; cgltf_bool has_rotation; cgltf_bool has_scale; cgltf_bool has_matrix; cgltf_float translation[3]; cgltf_float rotation[4]; cgltf_float scale[3]; cgltf_float matrix[16]; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; }; typedef struct cgltf_scene { char* name; cgltf_node** nodes; cgltf_size nodes_count; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_scene; typedef struct cgltf_animation_sampler { cgltf_accessor* input; cgltf_accessor* output; cgltf_interpolation_type interpolation; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_animation_sampler; typedef struct cgltf_animation_channel { cgltf_animation_sampler* sampler; cgltf_node* target_node; cgltf_animation_path_type target_path; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_animation_channel; typedef struct cgltf_animation { char* name; cgltf_animation_sampler* samplers; cgltf_size samplers_count; cgltf_animation_channel* channels; cgltf_size channels_count; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_animation; typedef struct cgltf_asset { char* copyright; char* generator; char* version; char* min_version; cgltf_extras extras; cgltf_size extensions_count; cgltf_extension* extensions; } cgltf_asset; typedef struct cgltf_data { cgltf_file_type file_type; void* file_data; cgltf_asset asset; cgltf_mesh* meshes; cgltf_size meshes_count; cgltf_material* materials; cgltf_size materials_count; cgltf_accessor* accessors; cgltf_size accessors_count; cgltf_buffer_view* buffer_views; cgltf_size buffer_views_count; cgltf_buffer* buffers; cgltf_size buffers_count; cgltf_image* images; cgltf_size images_count; cgltf_texture* textures; cgltf_size textures_count; cgltf_sampler* samplers; cgltf_size samplers_count; cgltf_skin* skins; cgltf_size skins_count; cgltf_camera* cameras; cgltf_size cameras_count; cgltf_light* lights; cgltf_size lights_count; cgltf_node* nodes; cgltf_size nodes_count; cgltf_scene* scenes; cgltf_size scenes_count; cgltf_scene* scene; cgltf_animation* animations; cgltf_size animations_count; cgltf_extras extras; cgltf_size data_extensions_count; cgltf_extension* data_extensions; char** extensions_used; cgltf_size extensions_used_count; char** extensions_required; cgltf_size extensions_required_count; const char* json; cgltf_size json_size; const void* bin; cgltf_size bin_size; cgltf_memory_options memory; cgltf_file_options file; } cgltf_data; cgltf_result cgltf_parse( const cgltf_options* options, const void* data, cgltf_size size, cgltf_data** out_data); cgltf_result cgltf_parse_file( const cgltf_options* options, const char* path, cgltf_data** out_data); cgltf_result cgltf_load_buffers( const cgltf_options* options, cgltf_data* data, const char* gltf_path); cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data); void cgltf_decode_uri(char* uri); cgltf_result cgltf_validate(cgltf_data* data); void cgltf_free(cgltf_data* data); void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix); void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix); cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size); cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size); cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index); cgltf_size cgltf_num_components(cgltf_type type); cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count); cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* extras, char* dest, cgltf_size* dest_size); #ifdef __cplusplus } #endif #endif /* #ifndef CGLTF_H_INCLUDED__ */ /* * * Stop now, if you are only interested in the API. * Below, you find the implementation. * */ #if defined(__INTELLISENSE__) || defined(__JETBRAINS_IDE__) /* This makes MSVC/CLion intellisense work. */ #define CGLTF_IMPLEMENTATION #endif #ifdef CGLTF_IMPLEMENTATION #include /* For uint8_t, uint32_t */ #include /* For strncpy */ #include /* For fopen */ #include /* For UINT_MAX etc */ #if !defined(CGLTF_MALLOC) || !defined(CGLTF_FREE) || !defined(CGLTF_ATOI) || !defined(CGLTF_ATOF) #include /* For malloc, free, atoi, atof */ #endif /* JSMN_PARENT_LINKS is necessary to make parsing large structures linear in input size */ #define JSMN_PARENT_LINKS /* JSMN_STRICT is necessary to reject invalid JSON documents */ #define JSMN_STRICT /* * -- jsmn.h start -- * Source: https://github.com/zserge/jsmn * License: MIT */ typedef enum { JSMN_UNDEFINED = 0, JSMN_OBJECT = 1, JSMN_ARRAY = 2, JSMN_STRING = 3, JSMN_PRIMITIVE = 4 } jsmntype_t; enum jsmnerr { /* Not enough tokens were provided */ JSMN_ERROR_NOMEM = -1, /* Invalid character inside JSON string */ JSMN_ERROR_INVAL = -2, /* The string is not a full JSON packet, more bytes expected */ JSMN_ERROR_PART = -3 }; typedef struct { jsmntype_t type; int start; int end; int size; #ifdef JSMN_PARENT_LINKS int parent; #endif } jsmntok_t; typedef struct { unsigned int pos; /* offset in the JSON string */ unsigned int toknext; /* next token to allocate */ int toksuper; /* superior token node, e.g parent object or array */ } jsmn_parser; static void jsmn_init(jsmn_parser *parser); static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens); /* * -- jsmn.h end -- */ static const cgltf_size GlbHeaderSize = 12; static const cgltf_size GlbChunkHeaderSize = 8; static const uint32_t GlbVersion = 2; static const uint32_t GlbMagic = 0x46546C67; static const uint32_t GlbMagicJsonChunk = 0x4E4F534A; static const uint32_t GlbMagicBinChunk = 0x004E4942; #ifndef CGLTF_MALLOC #define CGLTF_MALLOC(size) malloc(size) #endif #ifndef CGLTF_FREE #define CGLTF_FREE(ptr) free(ptr) #endif #ifndef CGLTF_ATOI #define CGLTF_ATOI(str) atoi(str) #endif #ifndef CGLTF_ATOF #define CGLTF_ATOF(str) atof(str) #endif static void* cgltf_default_alloc(void* user, cgltf_size size) { (void)user; return CGLTF_MALLOC(size); } static void cgltf_default_free(void* user, void* ptr) { (void)user; CGLTF_FREE(ptr); } static void* cgltf_calloc(cgltf_options* options, size_t element_size, cgltf_size count) { if (SIZE_MAX / element_size < count) { return NULL; } void* result = options->memory.alloc(options->memory.user_data, element_size * count); if (!result) { return NULL; } memset(result, 0, element_size * count); return result; } static cgltf_result cgltf_default_file_read(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, const char* path, cgltf_size* size, void** data) { (void)file_options; void* (*memory_alloc)(void*, cgltf_size) = memory_options->alloc ? memory_options->alloc : &cgltf_default_alloc; void (*memory_free)(void*, void*) = memory_options->free ? memory_options->free : &cgltf_default_free; FILE* file = fopen(path, "rb"); if (!file) { return cgltf_result_file_not_found; } cgltf_size file_size = size ? *size : 0; if (file_size == 0) { fseek(file, 0, SEEK_END); long length = ftell(file); if (length < 0) { fclose(file); return cgltf_result_io_error; } fseek(file, 0, SEEK_SET); file_size = (cgltf_size)length; } char* file_data = (char*)memory_alloc(memory_options->user_data, file_size); if (!file_data) { fclose(file); return cgltf_result_out_of_memory; } cgltf_size read_size = fread(file_data, 1, file_size, file); fclose(file); if (read_size != file_size) { memory_free(memory_options->user_data, file_data); return cgltf_result_io_error; } if (size) { *size = file_size; } if (data) { *data = file_data; } return cgltf_result_success; } static void cgltf_default_file_release(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, void* data) { (void)file_options; void (*memfree)(void*, void*) = memory_options->free ? memory_options->free : &cgltf_default_free; memfree(memory_options->user_data, data); } static cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk, cgltf_size size, cgltf_data** out_data); cgltf_result cgltf_parse(const cgltf_options* options, const void* data, cgltf_size size, cgltf_data** out_data) { if (size < GlbHeaderSize) { return cgltf_result_data_too_short; } if (options == NULL) { return cgltf_result_invalid_options; } cgltf_options fixed_options = *options; if (fixed_options.memory.alloc == NULL) { fixed_options.memory.alloc = &cgltf_default_alloc; } if (fixed_options.memory.free == NULL) { fixed_options.memory.free = &cgltf_default_free; } uint32_t tmp; // Magic memcpy(&tmp, data, 4); if (tmp != GlbMagic) { if (fixed_options.type == cgltf_file_type_invalid) { fixed_options.type = cgltf_file_type_gltf; } else if (fixed_options.type == cgltf_file_type_glb) { return cgltf_result_unknown_format; } } if (fixed_options.type == cgltf_file_type_gltf) { cgltf_result json_result = cgltf_parse_json(&fixed_options, (const uint8_t*)data, size, out_data); if (json_result != cgltf_result_success) { return json_result; } (*out_data)->file_type = cgltf_file_type_gltf; return cgltf_result_success; } const uint8_t* ptr = (const uint8_t*)data; // Version memcpy(&tmp, ptr + 4, 4); uint32_t version = tmp; if (version != GlbVersion) { return version < GlbVersion ? cgltf_result_legacy_gltf : cgltf_result_unknown_format; } // Total length memcpy(&tmp, ptr + 8, 4); if (tmp > size) { return cgltf_result_data_too_short; } const uint8_t* json_chunk = ptr + GlbHeaderSize; if (GlbHeaderSize + GlbChunkHeaderSize > size) { return cgltf_result_data_too_short; } // JSON chunk: length uint32_t json_length; memcpy(&json_length, json_chunk, 4); if (GlbHeaderSize + GlbChunkHeaderSize + json_length > size) { return cgltf_result_data_too_short; } // JSON chunk: magic memcpy(&tmp, json_chunk + 4, 4); if (tmp != GlbMagicJsonChunk) { return cgltf_result_unknown_format; } json_chunk += GlbChunkHeaderSize; const void* bin = 0; cgltf_size bin_size = 0; if (GlbHeaderSize + GlbChunkHeaderSize + json_length + GlbChunkHeaderSize <= size) { // We can read another chunk const uint8_t* bin_chunk = json_chunk + json_length; // Bin chunk: length uint32_t bin_length; memcpy(&bin_length, bin_chunk, 4); if (GlbHeaderSize + GlbChunkHeaderSize + json_length + GlbChunkHeaderSize + bin_length > size) { return cgltf_result_data_too_short; } // Bin chunk: magic memcpy(&tmp, bin_chunk + 4, 4); if (tmp != GlbMagicBinChunk) { return cgltf_result_unknown_format; } bin_chunk += GlbChunkHeaderSize; bin = bin_chunk; bin_size = bin_length; } cgltf_result json_result = cgltf_parse_json(&fixed_options, json_chunk, json_length, out_data); if (json_result != cgltf_result_success) { return json_result; } (*out_data)->file_type = cgltf_file_type_glb; (*out_data)->bin = bin; (*out_data)->bin_size = bin_size; return cgltf_result_success; } cgltf_result cgltf_parse_file(const cgltf_options* options, const char* path, cgltf_data** out_data) { if (options == NULL) { return cgltf_result_invalid_options; } void (*memory_free)(void*, void*) = options->memory.free ? options->memory.free : &cgltf_default_free; cgltf_result (*file_read)(const struct cgltf_memory_options*, const struct cgltf_file_options*, const char*, cgltf_size*, void**) = options->file.read ? options->file.read : &cgltf_default_file_read; void* file_data = NULL; cgltf_size file_size = 0; cgltf_result result = file_read(&options->memory, &options->file, path, &file_size, &file_data); if (result != cgltf_result_success) { return result; } result = cgltf_parse(options, file_data, file_size, out_data); if (result != cgltf_result_success) { memory_free(options->memory.user_data, file_data); return result; } (*out_data)->file_data = file_data; return cgltf_result_success; } static void cgltf_combine_paths(char* path, const char* base, const char* uri) { const char* s0 = strrchr(base, '/'); const char* s1 = strrchr(base, '\\'); const char* slash = s0 ? (s1 && s1 > s0 ? s1 : s0) : s1; if (slash) { size_t prefix = slash - base + 1; strncpy(path, base, prefix); strcpy(path + prefix, uri); } else { strcpy(path, uri); } } static cgltf_result cgltf_load_buffer_file(const cgltf_options* options, cgltf_size size, const char* uri, const char* gltf_path, void** out_data) { void* (*memory_alloc)(void*, cgltf_size) = options->memory.alloc ? options->memory.alloc : &cgltf_default_alloc; void (*memory_free)(void*, void*) = options->memory.free ? options->memory.free : &cgltf_default_free; cgltf_result (*file_read)(const struct cgltf_memory_options*, const struct cgltf_file_options*, const char*, cgltf_size*, void**) = options->file.read ? options->file.read : &cgltf_default_file_read; char* path = (char*)memory_alloc(options->memory.user_data, strlen(uri) + strlen(gltf_path) + 1); if (!path) { return cgltf_result_out_of_memory; } cgltf_combine_paths(path, gltf_path, uri); // after combining, the tail of the resulting path is a uri; decode_uri converts it into path cgltf_decode_uri(path + strlen(path) - strlen(uri)); void* file_data = NULL; cgltf_result result = file_read(&options->memory, &options->file, path, &size, &file_data); memory_free(options->memory.user_data, path); *out_data = (result == cgltf_result_success) ? file_data : NULL; return result; } cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data) { void* (*memory_alloc)(void*, cgltf_size) = options->memory.alloc ? options->memory.alloc : &cgltf_default_alloc; void (*memory_free)(void*, void*) = options->memory.free ? options->memory.free : &cgltf_default_free; unsigned char* data = (unsigned char*)memory_alloc(options->memory.user_data, size); if (!data) { return cgltf_result_out_of_memory; } unsigned int buffer = 0; unsigned int buffer_bits = 0; for (cgltf_size i = 0; i < size; ++i) { while (buffer_bits < 8) { char ch = *base64++; int index = (unsigned)(ch - 'A') < 26 ? (ch - 'A') : (unsigned)(ch - 'a') < 26 ? (ch - 'a') + 26 : (unsigned)(ch - '0') < 10 ? (ch - '0') + 52 : ch == '+' ? 62 : ch == '/' ? 63 : -1; if (index < 0) { memory_free(options->memory.user_data, data); return cgltf_result_io_error; } buffer = (buffer << 6) | index; buffer_bits += 6; } data[i] = (unsigned char)(buffer >> (buffer_bits - 8)); buffer_bits -= 8; } *out_data = data; return cgltf_result_success; } static int cgltf_unhex(char ch) { return (unsigned)(ch - '0') < 10 ? (ch - '0') : (unsigned)(ch - 'A') < 6 ? (ch - 'A') + 10 : (unsigned)(ch - 'a') < 6 ? (ch - 'a') + 10 : -1; } void cgltf_decode_uri(char* uri) { char* write = uri; char* i = uri; while (*i) { if (*i == '%') { int ch1 = cgltf_unhex(i[1]); if (ch1 >= 0) { int ch2 = cgltf_unhex(i[2]); if (ch2 >= 0) { *write++ = (char)(ch1 * 16 + ch2); i += 3; continue; } } } *write++ = *i++; } *write = 0; } cgltf_result cgltf_load_buffers(const cgltf_options* options, cgltf_data* data, const char* gltf_path) { if (options == NULL) { return cgltf_result_invalid_options; } if (data->buffers_count && data->buffers[0].data == NULL && data->buffers[0].uri == NULL && data->bin) { if (data->bin_size < data->buffers[0].size) { return cgltf_result_data_too_short; } data->buffers[0].data = (void*)data->bin; } for (cgltf_size i = 0; i < data->buffers_count; ++i) { if (data->buffers[i].data) { continue; } const char* uri = data->buffers[i].uri; if (uri == NULL) { continue; } if (strncmp(uri, "data:", 5) == 0) { const char* comma = strchr(uri, ','); if (comma && comma - uri >= 7 && strncmp(comma - 7, ";base64", 7) == 0) { cgltf_result res = cgltf_load_buffer_base64(options, data->buffers[i].size, comma + 1, &data->buffers[i].data); if (res != cgltf_result_success) { return res; } } else { return cgltf_result_unknown_format; } } else if (strstr(uri, "://") == NULL && gltf_path) { cgltf_result res = cgltf_load_buffer_file(options, data->buffers[i].size, uri, gltf_path, &data->buffers[i].data); if (res != cgltf_result_success) { return res; } } else { return cgltf_result_unknown_format; } } return cgltf_result_success; } static cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type); static cgltf_size cgltf_calc_index_bound(cgltf_buffer_view* buffer_view, cgltf_size offset, cgltf_component_type component_type, cgltf_size count) { char* data = (char*)buffer_view->buffer->data + offset + buffer_view->offset; cgltf_size bound = 0; switch (component_type) { case cgltf_component_type_r_8u: for (size_t i = 0; i < count; ++i) { cgltf_size v = ((unsigned char*)data)[i]; bound = bound > v ? bound : v; } break; case cgltf_component_type_r_16u: for (size_t i = 0; i < count; ++i) { cgltf_size v = ((unsigned short*)data)[i]; bound = bound > v ? bound : v; } break; case cgltf_component_type_r_32u: for (size_t i = 0; i < count; ++i) { cgltf_size v = ((unsigned int*)data)[i]; bound = bound > v ? bound : v; } break; default: ; } return bound; } cgltf_result cgltf_validate(cgltf_data* data) { for (cgltf_size i = 0; i < data->accessors_count; ++i) { cgltf_accessor* accessor = &data->accessors[i]; cgltf_size element_size = cgltf_calc_size(accessor->type, accessor->component_type); if (accessor->buffer_view) { cgltf_size req_size = accessor->offset + accessor->stride * (accessor->count - 1) + element_size; if (accessor->buffer_view->size < req_size) { return cgltf_result_data_too_short; } } if (accessor->is_sparse) { cgltf_accessor_sparse* sparse = &accessor->sparse; cgltf_size indices_component_size = cgltf_calc_size(cgltf_type_scalar, sparse->indices_component_type); cgltf_size indices_req_size = sparse->indices_byte_offset + indices_component_size * sparse->count; cgltf_size values_req_size = sparse->values_byte_offset + element_size * sparse->count; if (sparse->indices_buffer_view->size < indices_req_size || sparse->values_buffer_view->size < values_req_size) { return cgltf_result_data_too_short; } if (sparse->indices_component_type != cgltf_component_type_r_8u && sparse->indices_component_type != cgltf_component_type_r_16u && sparse->indices_component_type != cgltf_component_type_r_32u) { return cgltf_result_invalid_gltf; } if (sparse->indices_buffer_view->buffer->data) { cgltf_size index_bound = cgltf_calc_index_bound(sparse->indices_buffer_view, sparse->indices_byte_offset, sparse->indices_component_type, sparse->count); if (index_bound >= accessor->count) { return cgltf_result_data_too_short; } } } } for (cgltf_size i = 0; i < data->buffer_views_count; ++i) { cgltf_size req_size = data->buffer_views[i].offset + data->buffer_views[i].size; if (data->buffer_views[i].buffer && data->buffer_views[i].buffer->size < req_size) { return cgltf_result_data_too_short; } if (data->buffer_views[i].has_meshopt_compression) { cgltf_meshopt_compression* mc = &data->buffer_views[i].meshopt_compression; if (mc->buffer == NULL || mc->buffer->size < mc->offset + mc->size) { return cgltf_result_data_too_short; } if (data->buffer_views[i].stride && mc->stride != data->buffer_views[i].stride) { return cgltf_result_invalid_gltf; } if (data->buffer_views[i].size != mc->stride * mc->count) { return cgltf_result_invalid_gltf; } if (mc->mode == cgltf_meshopt_compression_mode_invalid) { return cgltf_result_invalid_gltf; } if (mc->mode == cgltf_meshopt_compression_mode_attributes && !(mc->stride % 4 == 0 && mc->stride <= 256)) { return cgltf_result_invalid_gltf; } if (mc->mode == cgltf_meshopt_compression_mode_triangles && mc->count % 3 != 0) { return cgltf_result_invalid_gltf; } if ((mc->mode == cgltf_meshopt_compression_mode_triangles || mc->mode == cgltf_meshopt_compression_mode_indices) && mc->stride != 2 && mc->stride != 4) { return cgltf_result_invalid_gltf; } if ((mc->mode == cgltf_meshopt_compression_mode_triangles || mc->mode == cgltf_meshopt_compression_mode_indices) && mc->filter != cgltf_meshopt_compression_filter_none) { return cgltf_result_invalid_gltf; } if (mc->filter == cgltf_meshopt_compression_filter_octahedral && mc->stride != 4 && mc->stride != 8) { return cgltf_result_invalid_gltf; } if (mc->filter == cgltf_meshopt_compression_filter_quaternion && mc->stride != 8) { return cgltf_result_invalid_gltf; } } } for (cgltf_size i = 0; i < data->meshes_count; ++i) { if (data->meshes[i].weights) { if (data->meshes[i].primitives_count && data->meshes[i].primitives[0].targets_count != data->meshes[i].weights_count) { return cgltf_result_invalid_gltf; } } if (data->meshes[i].target_names) { if (data->meshes[i].primitives_count && data->meshes[i].primitives[0].targets_count != data->meshes[i].target_names_count) { return cgltf_result_invalid_gltf; } } for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j) { if (data->meshes[i].primitives[j].targets_count != data->meshes[i].primitives[0].targets_count) { return cgltf_result_invalid_gltf; } if (data->meshes[i].primitives[j].attributes_count) { cgltf_accessor* first = data->meshes[i].primitives[j].attributes[0].data; for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k) { if (data->meshes[i].primitives[j].attributes[k].data->count != first->count) { return cgltf_result_invalid_gltf; } } for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k) { for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m) { if (data->meshes[i].primitives[j].targets[k].attributes[m].data->count != first->count) { return cgltf_result_invalid_gltf; } } } cgltf_accessor* indices = data->meshes[i].primitives[j].indices; if (indices && indices->component_type != cgltf_component_type_r_8u && indices->component_type != cgltf_component_type_r_16u && indices->component_type != cgltf_component_type_r_32u) { return cgltf_result_invalid_gltf; } if (indices && indices->buffer_view && indices->buffer_view->buffer->data) { cgltf_size index_bound = cgltf_calc_index_bound(indices->buffer_view, indices->offset, indices->component_type, indices->count); if (index_bound >= first->count) { return cgltf_result_data_too_short; } } } } } for (cgltf_size i = 0; i < data->nodes_count; ++i) { if (data->nodes[i].weights && data->nodes[i].mesh) { if (data->nodes[i].mesh->primitives_count && data->nodes[i].mesh->primitives[0].targets_count != data->nodes[i].weights_count) { return cgltf_result_invalid_gltf; } } } for (cgltf_size i = 0; i < data->nodes_count; ++i) { cgltf_node* p1 = data->nodes[i].parent; cgltf_node* p2 = p1 ? p1->parent : NULL; while (p1 && p2) { if (p1 == p2) { return cgltf_result_invalid_gltf; } p1 = p1->parent; p2 = p2->parent ? p2->parent->parent : NULL; } } for (cgltf_size i = 0; i < data->scenes_count; ++i) { for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j) { if (data->scenes[i].nodes[j]->parent) { return cgltf_result_invalid_gltf; } } } for (cgltf_size i = 0; i < data->animations_count; ++i) { for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j) { cgltf_animation_channel* channel = &data->animations[i].channels[j]; if (!channel->target_node) { continue; } cgltf_size components = 1; if (channel->target_path == cgltf_animation_path_type_weights) { if (!channel->target_node->mesh || !channel->target_node->mesh->primitives_count) { return cgltf_result_invalid_gltf; } components = channel->target_node->mesh->primitives[0].targets_count; } cgltf_size values = channel->sampler->interpolation == cgltf_interpolation_type_cubic_spline ? 3 : 1; if (channel->sampler->input->count * components * values != channel->sampler->output->count) { return cgltf_result_data_too_short; } } } return cgltf_result_success; } cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* extras, char* dest, cgltf_size* dest_size) { cgltf_size json_size = extras->end_offset - extras->start_offset; if (!dest) { if (dest_size) { *dest_size = json_size + 1; return cgltf_result_success; } return cgltf_result_invalid_options; } if (*dest_size + 1 < json_size) { strncpy(dest, data->json + extras->start_offset, *dest_size - 1); dest[*dest_size - 1] = 0; } else { strncpy(dest, data->json + extras->start_offset, json_size); dest[json_size] = 0; } return cgltf_result_success; } void cgltf_free_extensions(cgltf_data* data, cgltf_extension* extensions, cgltf_size extensions_count) { for (cgltf_size i = 0; i < extensions_count; ++i) { data->memory.free(data->memory.user_data, extensions[i].name); data->memory.free(data->memory.user_data, extensions[i].data); } data->memory.free(data->memory.user_data, extensions); } void cgltf_free(cgltf_data* data) { if (!data) { return; } void (*file_release)(const struct cgltf_memory_options*, const struct cgltf_file_options*, void* data) = data->file.release ? data->file.release : cgltf_default_file_release; data->memory.free(data->memory.user_data, data->asset.copyright); data->memory.free(data->memory.user_data, data->asset.generator); data->memory.free(data->memory.user_data, data->asset.version); data->memory.free(data->memory.user_data, data->asset.min_version); cgltf_free_extensions(data, data->asset.extensions, data->asset.extensions_count); for (cgltf_size i = 0; i < data->accessors_count; ++i) { if(data->accessors[i].is_sparse) { cgltf_free_extensions(data, data->accessors[i].sparse.extensions, data->accessors[i].sparse.extensions_count); cgltf_free_extensions(data, data->accessors[i].sparse.indices_extensions, data->accessors[i].sparse.indices_extensions_count); cgltf_free_extensions(data, data->accessors[i].sparse.values_extensions, data->accessors[i].sparse.values_extensions_count); } cgltf_free_extensions(data, data->accessors[i].extensions, data->accessors[i].extensions_count); } data->memory.free(data->memory.user_data, data->accessors); for (cgltf_size i = 0; i < data->buffer_views_count; ++i) { data->memory.free(data->memory.user_data, data->buffer_views[i].data); cgltf_free_extensions(data, data->buffer_views[i].extensions, data->buffer_views[i].extensions_count); } data->memory.free(data->memory.user_data, data->buffer_views); for (cgltf_size i = 0; i < data->buffers_count; ++i) { if (data->buffers[i].data != data->bin) { file_release(&data->memory, &data->file, data->buffers[i].data); } data->memory.free(data->memory.user_data, data->buffers[i].uri); cgltf_free_extensions(data, data->buffers[i].extensions, data->buffers[i].extensions_count); } data->memory.free(data->memory.user_data, data->buffers); for (cgltf_size i = 0; i < data->meshes_count; ++i) { data->memory.free(data->memory.user_data, data->meshes[i].name); for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j) { for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k) { data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].attributes[k].name); } data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].attributes); for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k) { for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m) { data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].targets[k].attributes[m].name); } data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].targets[k].attributes); } data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].targets); if (data->meshes[i].primitives[j].has_draco_mesh_compression) { for (cgltf_size k = 0; k < data->meshes[i].primitives[j].draco_mesh_compression.attributes_count; ++k) { data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes[k].name); } data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes); } cgltf_free_extensions(data, data->meshes[i].primitives[j].extensions, data->meshes[i].primitives[j].extensions_count); } data->memory.free(data->memory.user_data, data->meshes[i].primitives); data->memory.free(data->memory.user_data, data->meshes[i].weights); for (cgltf_size j = 0; j < data->meshes[i].target_names_count; ++j) { data->memory.free(data->memory.user_data, data->meshes[i].target_names[j]); } cgltf_free_extensions(data, data->meshes[i].extensions, data->meshes[i].extensions_count); data->memory.free(data->memory.user_data, data->meshes[i].target_names); } data->memory.free(data->memory.user_data, data->meshes); for (cgltf_size i = 0; i < data->materials_count; ++i) { data->memory.free(data->memory.user_data, data->materials[i].name); if(data->materials[i].has_pbr_metallic_roughness) { cgltf_free_extensions(data, data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.extensions, data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.extensions_count); cgltf_free_extensions(data, data->materials[i].pbr_metallic_roughness.base_color_texture.extensions, data->materials[i].pbr_metallic_roughness.base_color_texture.extensions_count); } if(data->materials[i].has_pbr_specular_glossiness) { cgltf_free_extensions(data, data->materials[i].pbr_specular_glossiness.diffuse_texture.extensions, data->materials[i].pbr_specular_glossiness.diffuse_texture.extensions_count); cgltf_free_extensions(data, data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.extensions, data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.extensions_count); } if(data->materials[i].has_clearcoat) { cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_texture.extensions, data->materials[i].clearcoat.clearcoat_texture.extensions_count); cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_roughness_texture.extensions, data->materials[i].clearcoat.clearcoat_roughness_texture.extensions_count); cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_normal_texture.extensions, data->materials[i].clearcoat.clearcoat_normal_texture.extensions_count); } if(data->materials[i].has_specular) { cgltf_free_extensions(data, data->materials[i].specular.specular_texture.extensions, data->materials[i].specular.specular_texture.extensions_count); } if(data->materials[i].has_transmission) { cgltf_free_extensions(data, data->materials[i].transmission.transmission_texture.extensions, data->materials[i].transmission.transmission_texture.extensions_count); } if(data->materials[i].has_sheen) { cgltf_free_extensions(data, data->materials[i].sheen.sheen_color_texture.extensions, data->materials[i].sheen.sheen_color_texture.extensions_count); cgltf_free_extensions(data, data->materials[i].sheen.sheen_roughness_texture.extensions, data->materials[i].sheen.sheen_roughness_texture.extensions_count); } cgltf_free_extensions(data, data->materials[i].normal_texture.extensions, data->materials[i].normal_texture.extensions_count); cgltf_free_extensions(data, data->materials[i].occlusion_texture.extensions, data->materials[i].occlusion_texture.extensions_count); cgltf_free_extensions(data, data->materials[i].emissive_texture.extensions, data->materials[i].emissive_texture.extensions_count); cgltf_free_extensions(data, data->materials[i].extensions, data->materials[i].extensions_count); } data->memory.free(data->memory.user_data, data->materials); for (cgltf_size i = 0; i < data->images_count; ++i) { data->memory.free(data->memory.user_data, data->images[i].name); data->memory.free(data->memory.user_data, data->images[i].uri); data->memory.free(data->memory.user_data, data->images[i].mime_type); cgltf_free_extensions(data, data->images[i].extensions, data->images[i].extensions_count); } data->memory.free(data->memory.user_data, data->images); for (cgltf_size i = 0; i < data->textures_count; ++i) { data->memory.free(data->memory.user_data, data->textures[i].name); cgltf_free_extensions(data, data->textures[i].extensions, data->textures[i].extensions_count); } data->memory.free(data->memory.user_data, data->textures); for (cgltf_size i = 0; i < data->samplers_count; ++i) { cgltf_free_extensions(data, data->samplers[i].extensions, data->samplers[i].extensions_count); } data->memory.free(data->memory.user_data, data->samplers); for (cgltf_size i = 0; i < data->skins_count; ++i) { data->memory.free(data->memory.user_data, data->skins[i].name); data->memory.free(data->memory.user_data, data->skins[i].joints); cgltf_free_extensions(data, data->skins[i].extensions, data->skins[i].extensions_count); } data->memory.free(data->memory.user_data, data->skins); for (cgltf_size i = 0; i < data->cameras_count; ++i) { data->memory.free(data->memory.user_data, data->cameras[i].name); cgltf_free_extensions(data, data->cameras[i].extensions, data->cameras[i].extensions_count); } data->memory.free(data->memory.user_data, data->cameras); for (cgltf_size i = 0; i < data->lights_count; ++i) { data->memory.free(data->memory.user_data, data->lights[i].name); } data->memory.free(data->memory.user_data, data->lights); for (cgltf_size i = 0; i < data->nodes_count; ++i) { data->memory.free(data->memory.user_data, data->nodes[i].name); data->memory.free(data->memory.user_data, data->nodes[i].children); data->memory.free(data->memory.user_data, data->nodes[i].weights); cgltf_free_extensions(data, data->nodes[i].extensions, data->nodes[i].extensions_count); } data->memory.free(data->memory.user_data, data->nodes); for (cgltf_size i = 0; i < data->scenes_count; ++i) { data->memory.free(data->memory.user_data, data->scenes[i].name); data->memory.free(data->memory.user_data, data->scenes[i].nodes); cgltf_free_extensions(data, data->scenes[i].extensions, data->scenes[i].extensions_count); } data->memory.free(data->memory.user_data, data->scenes); for (cgltf_size i = 0; i < data->animations_count; ++i) { data->memory.free(data->memory.user_data, data->animations[i].name); for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j) { cgltf_free_extensions(data, data->animations[i].samplers[j].extensions, data->animations[i].samplers[j].extensions_count); } data->memory.free(data->memory.user_data, data->animations[i].samplers); for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j) { cgltf_free_extensions(data, data->animations[i].channels[j].extensions, data->animations[i].channels[j].extensions_count); } data->memory.free(data->memory.user_data, data->animations[i].channels); cgltf_free_extensions(data, data->animations[i].extensions, data->animations[i].extensions_count); } data->memory.free(data->memory.user_data, data->animations); cgltf_free_extensions(data, data->data_extensions, data->data_extensions_count); for (cgltf_size i = 0; i < data->extensions_used_count; ++i) { data->memory.free(data->memory.user_data, data->extensions_used[i]); } data->memory.free(data->memory.user_data, data->extensions_used); for (cgltf_size i = 0; i < data->extensions_required_count; ++i) { data->memory.free(data->memory.user_data, data->extensions_required[i]); } data->memory.free(data->memory.user_data, data->extensions_required); file_release(&data->memory, &data->file, data->file_data); data->memory.free(data->memory.user_data, data); } void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix) { cgltf_float* lm = out_matrix; if (node->has_matrix) { memcpy(lm, node->matrix, sizeof(float) * 16); } else { float tx = node->translation[0]; float ty = node->translation[1]; float tz = node->translation[2]; float qx = node->rotation[0]; float qy = node->rotation[1]; float qz = node->rotation[2]; float qw = node->rotation[3]; float sx = node->scale[0]; float sy = node->scale[1]; float sz = node->scale[2]; lm[0] = (1 - 2 * qy*qy - 2 * qz*qz) * sx; lm[1] = (2 * qx*qy + 2 * qz*qw) * sx; lm[2] = (2 * qx*qz - 2 * qy*qw) * sx; lm[3] = 0.f; lm[4] = (2 * qx*qy - 2 * qz*qw) * sy; lm[5] = (1 - 2 * qx*qx - 2 * qz*qz) * sy; lm[6] = (2 * qy*qz + 2 * qx*qw) * sy; lm[7] = 0.f; lm[8] = (2 * qx*qz + 2 * qy*qw) * sz; lm[9] = (2 * qy*qz - 2 * qx*qw) * sz; lm[10] = (1 - 2 * qx*qx - 2 * qy*qy) * sz; lm[11] = 0.f; lm[12] = tx; lm[13] = ty; lm[14] = tz; lm[15] = 1.f; } } void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix) { cgltf_float* lm = out_matrix; cgltf_node_transform_local(node, lm); const cgltf_node* parent = node->parent; while (parent) { float pm[16]; cgltf_node_transform_local(parent, pm); for (int i = 0; i < 4; ++i) { float l0 = lm[i * 4 + 0]; float l1 = lm[i * 4 + 1]; float l2 = lm[i * 4 + 2]; float r0 = l0 * pm[0] + l1 * pm[4] + l2 * pm[8]; float r1 = l0 * pm[1] + l1 * pm[5] + l2 * pm[9]; float r2 = l0 * pm[2] + l1 * pm[6] + l2 * pm[10]; lm[i * 4 + 0] = r0; lm[i * 4 + 1] = r1; lm[i * 4 + 2] = r2; } lm[12] += pm[12]; lm[13] += pm[13]; lm[14] += pm[14]; parent = parent->parent; } } static cgltf_size cgltf_component_read_index(const void* in, cgltf_component_type component_type) { switch (component_type) { case cgltf_component_type_r_16: return *((const int16_t*) in); case cgltf_component_type_r_16u: return *((const uint16_t*) in); case cgltf_component_type_r_32u: return *((const uint32_t*) in); case cgltf_component_type_r_32f: return (cgltf_size)*((const float*) in); case cgltf_component_type_r_8: return *((const int8_t*) in); case cgltf_component_type_r_8u: return *((const uint8_t*) in); default: return 0; } } static cgltf_float cgltf_component_read_float(const void* in, cgltf_component_type component_type, cgltf_bool normalized) { if (component_type == cgltf_component_type_r_32f) { return *((const float*) in); } if (normalized) { switch (component_type) { // note: glTF spec doesn't currently define normalized conversions for 32-bit integers case cgltf_component_type_r_16: return *((const int16_t*) in) / (cgltf_float)32767; case cgltf_component_type_r_16u: return *((const uint16_t*) in) / (cgltf_float)65535; case cgltf_component_type_r_8: return *((const int8_t*) in) / (cgltf_float)127; case cgltf_component_type_r_8u: return *((const uint8_t*) in) / (cgltf_float)255; default: return 0; } } return (cgltf_float)cgltf_component_read_index(in, component_type); } static cgltf_size cgltf_component_size(cgltf_component_type component_type); static cgltf_bool cgltf_element_read_float(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_bool normalized, cgltf_float* out, cgltf_size element_size) { cgltf_size num_components = cgltf_num_components(type); if (element_size < num_components) { return 0; } // There are three special cases for component extraction, see #data-alignment in the 2.0 spec. cgltf_size component_size = cgltf_component_size(component_type); if (type == cgltf_type_mat2 && component_size == 1) { out[0] = cgltf_component_read_float(element, component_type, normalized); out[1] = cgltf_component_read_float(element + 1, component_type, normalized); out[2] = cgltf_component_read_float(element + 4, component_type, normalized); out[3] = cgltf_component_read_float(element + 5, component_type, normalized); return 1; } if (type == cgltf_type_mat3 && component_size == 1) { out[0] = cgltf_component_read_float(element, component_type, normalized); out[1] = cgltf_component_read_float(element + 1, component_type, normalized); out[2] = cgltf_component_read_float(element + 2, component_type, normalized); out[3] = cgltf_component_read_float(element + 4, component_type, normalized); out[4] = cgltf_component_read_float(element + 5, component_type, normalized); out[5] = cgltf_component_read_float(element + 6, component_type, normalized); out[6] = cgltf_component_read_float(element + 8, component_type, normalized); out[7] = cgltf_component_read_float(element + 9, component_type, normalized); out[8] = cgltf_component_read_float(element + 10, component_type, normalized); return 1; } if (type == cgltf_type_mat3 && component_size == 2) { out[0] = cgltf_component_read_float(element, component_type, normalized); out[1] = cgltf_component_read_float(element + 2, component_type, normalized); out[2] = cgltf_component_read_float(element + 4, component_type, normalized); out[3] = cgltf_component_read_float(element + 8, component_type, normalized); out[4] = cgltf_component_read_float(element + 10, component_type, normalized); out[5] = cgltf_component_read_float(element + 12, component_type, normalized); out[6] = cgltf_component_read_float(element + 16, component_type, normalized); out[7] = cgltf_component_read_float(element + 18, component_type, normalized); out[8] = cgltf_component_read_float(element + 20, component_type, normalized); return 1; } for (cgltf_size i = 0; i < num_components; ++i) { out[i] = cgltf_component_read_float(element + component_size * i, component_type, normalized); } return 1; } const uint8_t* cgltf_buffer_view_data(const cgltf_buffer_view* view) { if (view->data) return (const uint8_t*)view->data; if (!view->buffer->data) return NULL; const uint8_t* result = (const uint8_t*)view->buffer->data; result += view->offset; return result; } cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size) { if (accessor->is_sparse) { return 0; } if (accessor->buffer_view == NULL) { memset(out, 0, element_size * sizeof(cgltf_float)); return 1; } const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view); if (element == NULL) { return 0; } element += accessor->offset + accessor->stride * index; return cgltf_element_read_float(element, accessor->type, accessor->component_type, accessor->normalized, out, element_size); } cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count) { cgltf_size floats_per_element = cgltf_num_components(accessor->type); cgltf_size available_floats = accessor->count * floats_per_element; if (out == NULL) { return available_floats; } float_count = available_floats < float_count ? available_floats : float_count; cgltf_size element_count = float_count / floats_per_element; // First pass: convert each element in the base accessor. cgltf_float* dest = out; cgltf_accessor dense = *accessor; dense.is_sparse = 0; for (cgltf_size index = 0; index < element_count; index++, dest += floats_per_element) { if (!cgltf_accessor_read_float(&dense, index, dest, floats_per_element)) { return 0; } } // Second pass: write out each element in the sparse accessor. if (accessor->is_sparse) { const cgltf_accessor_sparse* sparse = &dense.sparse; const uint8_t* index_data = cgltf_buffer_view_data(sparse->indices_buffer_view); const uint8_t* reader_head = cgltf_buffer_view_data(sparse->values_buffer_view); if (index_data == NULL || reader_head == NULL) { return 0; } index_data += sparse->indices_byte_offset; reader_head += sparse->values_byte_offset; cgltf_size index_stride = cgltf_component_size(sparse->indices_component_type); for (cgltf_size reader_index = 0; reader_index < sparse->count; reader_index++, index_data += index_stride) { size_t writer_index = cgltf_component_read_index(index_data, sparse->indices_component_type); float* writer_head = out + writer_index * floats_per_element; if (!cgltf_element_read_float(reader_head, dense.type, dense.component_type, dense.normalized, writer_head, floats_per_element)) { return 0; } reader_head += dense.stride; } } return element_count * floats_per_element; } static cgltf_uint cgltf_component_read_uint(const void* in, cgltf_component_type component_type) { switch (component_type) { case cgltf_component_type_r_8: return *((const int8_t*) in); case cgltf_component_type_r_8u: return *((const uint8_t*) in); case cgltf_component_type_r_16: return *((const int16_t*) in); case cgltf_component_type_r_16u: return *((const uint16_t*) in); case cgltf_component_type_r_32u: return *((const uint32_t*) in); default: return 0; } } static cgltf_bool cgltf_element_read_uint(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_uint* out, cgltf_size element_size) { cgltf_size num_components = cgltf_num_components(type); if (element_size < num_components) { return 0; } // Reading integer matrices is not a valid use case if (type == cgltf_type_mat2 || type == cgltf_type_mat3 || type == cgltf_type_mat4) { return 0; } cgltf_size component_size = cgltf_component_size(component_type); for (cgltf_size i = 0; i < num_components; ++i) { out[i] = cgltf_component_read_uint(element + component_size * i, component_type); } return 1; } cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size) { if (accessor->is_sparse) { return 0; } if (accessor->buffer_view == NULL) { memset(out, 0, element_size * sizeof( cgltf_uint )); return 1; } const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view); if (element == NULL) { return 0; } element += accessor->offset + accessor->stride * index; return cgltf_element_read_uint(element, accessor->type, accessor->component_type, out, element_size); } cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index) { if (accessor->is_sparse) { return 0; // This is an error case, but we can't communicate the error with existing interface. } if (accessor->buffer_view == NULL) { return 0; } const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view); if (element == NULL) { return 0; // This is an error case, but we can't communicate the error with existing interface. } element += accessor->offset + accessor->stride * index; return cgltf_component_read_index(element, accessor->component_type); } #define CGLTF_ERROR_JSON -1 #define CGLTF_ERROR_NOMEM -2 #define CGLTF_ERROR_LEGACY -3 #define CGLTF_CHECK_TOKTYPE(tok_, type_) if ((tok_).type != (type_)) { return CGLTF_ERROR_JSON; } #define CGLTF_CHECK_KEY(tok_) if ((tok_).type != JSMN_STRING || (tok_).size == 0) { return CGLTF_ERROR_JSON; } /* checking size for 0 verifies that a value follows the key */ #define CGLTF_PTRINDEX(type, idx) (type*)((cgltf_size)idx + 1) #define CGLTF_PTRFIXUP(var, data, size) if (var) { if ((cgltf_size)var > size) { return CGLTF_ERROR_JSON; } var = &data[(cgltf_size)var-1]; } #define CGLTF_PTRFIXUP_REQ(var, data, size) if (!var || (cgltf_size)var > size) { return CGLTF_ERROR_JSON; } var = &data[(cgltf_size)var-1]; static int cgltf_json_strcmp(jsmntok_t const* tok, const uint8_t* json_chunk, const char* str) { CGLTF_CHECK_TOKTYPE(*tok, JSMN_STRING); size_t const str_len = strlen(str); size_t const name_length = tok->end - tok->start; return (str_len == name_length) ? strncmp((const char*)json_chunk + tok->start, str, str_len) : 128; } static int cgltf_json_to_int(jsmntok_t const* tok, const uint8_t* json_chunk) { CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE); char tmp[128]; int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1); strncpy(tmp, (const char*)json_chunk + tok->start, size); tmp[size] = 0; return CGLTF_ATOI(tmp); } static cgltf_float cgltf_json_to_float(jsmntok_t const* tok, const uint8_t* json_chunk) { CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE); char tmp[128]; int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1); strncpy(tmp, (const char*)json_chunk + tok->start, size); tmp[size] = 0; return (cgltf_float)CGLTF_ATOF(tmp); } static cgltf_bool cgltf_json_to_bool(jsmntok_t const* tok, const uint8_t* json_chunk) { int size = tok->end - tok->start; return size == 4 && memcmp(json_chunk + tok->start, "true", 4) == 0; } static int cgltf_skip_json(jsmntok_t const* tokens, int i) { int end = i + 1; while (i < end) { switch (tokens[i].type) { case JSMN_OBJECT: end += tokens[i].size * 2; break; case JSMN_ARRAY: end += tokens[i].size; break; case JSMN_PRIMITIVE: case JSMN_STRING: break; default: return -1; } i++; } return i; } static void cgltf_fill_float_array(float* out_array, int size, float value) { for (int j = 0; j < size; ++j) { out_array[j] = value; } } static int cgltf_parse_json_float_array(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, float* out_array, int size) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY); if (tokens[i].size != size) { return CGLTF_ERROR_JSON; } ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); out_array[j] = cgltf_json_to_float(tokens + i, json_chunk); ++i; } return i; } static int cgltf_parse_json_string(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, char** out_string) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING); if (*out_string) { return CGLTF_ERROR_JSON; } int size = tokens[i].end - tokens[i].start; char* result = (char*)options->memory.alloc(options->memory.user_data, size + 1); if (!result) { return CGLTF_ERROR_NOMEM; } strncpy(result, (const char*)json_chunk + tokens[i].start, size); result[size] = 0; *out_string = result; return i + 1; } static int cgltf_parse_json_array(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, size_t element_size, void** out_array, cgltf_size* out_size) { (void)json_chunk; if (tokens[i].type != JSMN_ARRAY) { return tokens[i].type == JSMN_OBJECT ? CGLTF_ERROR_LEGACY : CGLTF_ERROR_JSON; } if (*out_array) { return CGLTF_ERROR_JSON; } int size = tokens[i].size; void* result = cgltf_calloc(options, element_size, size); if (!result) { return CGLTF_ERROR_NOMEM; } *out_array = result; *out_size = size; return i + 1; } static int cgltf_parse_json_string_array(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, char*** out_array, cgltf_size* out_size) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY); i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(char*), (void**)out_array, out_size); if (i < 0) { return i; } for (cgltf_size j = 0; j < *out_size; ++j) { i = cgltf_parse_json_string(options, tokens, i, json_chunk, j + (*out_array)); if (i < 0) { return i; } } return i; } static void cgltf_parse_attribute_type(const char* name, cgltf_attribute_type* out_type, int* out_index) { const char* us = strchr(name, '_'); size_t len = us ? (size_t)(us - name) : strlen(name); if (len == 8 && strncmp(name, "POSITION", 8) == 0) { *out_type = cgltf_attribute_type_position; } else if (len == 6 && strncmp(name, "NORMAL", 6) == 0) { *out_type = cgltf_attribute_type_normal; } else if (len == 7 && strncmp(name, "TANGENT", 7) == 0) { *out_type = cgltf_attribute_type_tangent; } else if (len == 8 && strncmp(name, "TEXCOORD", 8) == 0) { *out_type = cgltf_attribute_type_texcoord; } else if (len == 5 && strncmp(name, "COLOR", 5) == 0) { *out_type = cgltf_attribute_type_color; } else if (len == 6 && strncmp(name, "JOINTS", 6) == 0) { *out_type = cgltf_attribute_type_joints; } else if (len == 7 && strncmp(name, "WEIGHTS", 7) == 0) { *out_type = cgltf_attribute_type_weights; } else { *out_type = cgltf_attribute_type_invalid; } if (us && *out_type != cgltf_attribute_type_invalid) { *out_index = CGLTF_ATOI(us + 1); } } static int cgltf_parse_json_attribute_list(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_attribute** out_attributes, cgltf_size* out_attributes_count) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); if (*out_attributes) { return CGLTF_ERROR_JSON; } *out_attributes_count = tokens[i].size; *out_attributes = (cgltf_attribute*)cgltf_calloc(options, sizeof(cgltf_attribute), *out_attributes_count); ++i; if (!*out_attributes) { return CGLTF_ERROR_NOMEM; } for (cgltf_size j = 0; j < *out_attributes_count; ++j) { CGLTF_CHECK_KEY(tokens[i]); i = cgltf_parse_json_string(options, tokens, i, json_chunk, &(*out_attributes)[j].name); if (i < 0) { return CGLTF_ERROR_JSON; } cgltf_parse_attribute_type((*out_attributes)[j].name, &(*out_attributes)[j].type, &(*out_attributes)[j].index); (*out_attributes)[j].data = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } return i; } static int cgltf_parse_json_extras(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extras* out_extras) { (void)json_chunk; out_extras->start_offset = tokens[i].start; out_extras->end_offset = tokens[i].end; i = cgltf_skip_json(tokens, i); return i; } static int cgltf_parse_json_unprocessed_extension(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extension* out_extension) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING); CGLTF_CHECK_TOKTYPE(tokens[i+1], JSMN_OBJECT); if (out_extension->name) { return CGLTF_ERROR_JSON; } cgltf_size name_length = tokens[i].end - tokens[i].start; out_extension->name = (char*)options->memory.alloc(options->memory.user_data, name_length + 1); if (!out_extension->name) { return CGLTF_ERROR_NOMEM; } strncpy(out_extension->name, (const char*)json_chunk + tokens[i].start, name_length); out_extension->name[name_length] = 0; i++; size_t start = tokens[i].start; size_t size = tokens[i].end - start; out_extension->data = (char*)options->memory.alloc(options->memory.user_data, size + 1); if (!out_extension->data) { return CGLTF_ERROR_NOMEM; } strncpy(out_extension->data, (const char*)json_chunk + start, size); out_extension->data[size] = '\0'; i = cgltf_skip_json(tokens, i); return i; } static int cgltf_parse_json_unprocessed_extensions(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_size* out_extensions_count, cgltf_extension** out_extensions) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); if(*out_extensions) { return CGLTF_ERROR_JSON; } int extensions_size = tokens[i].size; *out_extensions_count = 0; *out_extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); if (!*out_extensions) { return CGLTF_ERROR_NOMEM; } ++i; for (int j = 0; j < extensions_size; ++j) { CGLTF_CHECK_KEY(tokens[i]); cgltf_size extension_index = (*out_extensions_count)++; cgltf_extension* extension = &((*out_extensions)[extension_index]); i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, extension); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_draco_mesh_compression(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_draco_mesh_compression* out_draco_mesh_compression) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "attributes") == 0) { i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_draco_mesh_compression->attributes, &out_draco_mesh_compression->attributes_count); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferView") == 0) { ++i; out_draco_mesh_compression->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } } return i; } static int cgltf_parse_json_primitive(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_primitive* out_prim) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); out_prim->type = cgltf_primitive_type_triangles; int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "mode") == 0) { ++i; out_prim->type = (cgltf_primitive_type) cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "indices") == 0) { ++i; out_prim->indices = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "material") == 0) { ++i; out_prim->material = CGLTF_PTRINDEX(cgltf_material, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "attributes") == 0) { i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_prim->attributes, &out_prim->attributes_count); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "targets") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_morph_target), (void**)&out_prim->targets, &out_prim->targets_count); if (i < 0) { return i; } for (cgltf_size k = 0; k < out_prim->targets_count; ++k) { i = cgltf_parse_json_attribute_list(options, tokens, i, json_chunk, &out_prim->targets[k].attributes, &out_prim->targets[k].attributes_count); if (i < 0) { return i; } } } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_prim->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); if(out_prim->extensions) { return CGLTF_ERROR_JSON; } int extensions_size = tokens[i].size; out_prim->extensions_count = 0; out_prim->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); if (!out_prim->extensions) { return CGLTF_ERROR_NOMEM; } ++i; for (int k = 0; k < extensions_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_draco_mesh_compression") == 0) { out_prim->has_draco_mesh_compression = 1; i = cgltf_parse_json_draco_mesh_compression(options, tokens, i + 1, json_chunk, &out_prim->draco_mesh_compression); } else { i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_prim->extensions[out_prim->extensions_count++])); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_mesh(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_mesh* out_mesh) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_mesh->name); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "primitives") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_primitive), (void**)&out_mesh->primitives, &out_mesh->primitives_count); if (i < 0) { return i; } for (cgltf_size prim_index = 0; prim_index < out_mesh->primitives_count; ++prim_index) { i = cgltf_parse_json_primitive(options, tokens, i, json_chunk, &out_mesh->primitives[prim_index]); if (i < 0) { return i; } } } else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_float), (void**)&out_mesh->weights, &out_mesh->weights_count); if (i < 0) { return i; } i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, out_mesh->weights, (int)out_mesh->weights_count); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { ++i; out_mesh->extras.start_offset = tokens[i].start; out_mesh->extras.end_offset = tokens[i].end; if (tokens[i].type == JSMN_OBJECT) { int extras_size = tokens[i].size; ++i; for (int k = 0; k < extras_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "targetNames") == 0) { i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_mesh->target_names, &out_mesh->target_names_count); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i); } } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_mesh->extensions_count, &out_mesh->extensions); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_meshes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_mesh), (void**)&out_data->meshes, &out_data->meshes_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->meshes_count; ++j) { i = cgltf_parse_json_mesh(options, tokens, i, json_chunk, &out_data->meshes[j]); if (i < 0) { return i; } } return i; } static cgltf_component_type cgltf_json_to_component_type(jsmntok_t const* tok, const uint8_t* json_chunk) { int type = cgltf_json_to_int(tok, json_chunk); switch (type) { case 5120: return cgltf_component_type_r_8; case 5121: return cgltf_component_type_r_8u; case 5122: return cgltf_component_type_r_16; case 5123: return cgltf_component_type_r_16u; case 5125: return cgltf_component_type_r_32u; case 5126: return cgltf_component_type_r_32f; default: return cgltf_component_type_invalid; } } static int cgltf_parse_json_accessor_sparse(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_accessor_sparse* out_sparse) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0) { ++i; out_sparse->count = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "indices") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int indices_size = tokens[i].size; ++i; for (int k = 0; k < indices_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0) { ++i; out_sparse->indices_buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0) { ++i; out_sparse->indices_byte_offset = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "componentType") == 0) { ++i; out_sparse->indices_component_type = cgltf_json_to_component_type(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->indices_extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sparse->indices_extensions_count, &out_sparse->indices_extensions); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else if (cgltf_json_strcmp(tokens+i, json_chunk, "values") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int values_size = tokens[i].size; ++i; for (int k = 0; k < values_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0) { ++i; out_sparse->values_buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0) { ++i; out_sparse->values_byte_offset = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->values_extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sparse->values_extensions_count, &out_sparse->values_extensions); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sparse->extensions_count, &out_sparse->extensions); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_accessor(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_accessor* out_accessor) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0) { ++i; out_accessor->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0) { ++i; out_accessor->offset = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "componentType") == 0) { ++i; out_accessor->component_type = cgltf_json_to_component_type(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "normalized") == 0) { ++i; out_accessor->normalized = cgltf_json_to_bool(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0) { ++i; out_accessor->count = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0) { ++i; if (cgltf_json_strcmp(tokens+i, json_chunk, "SCALAR") == 0) { out_accessor->type = cgltf_type_scalar; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC2") == 0) { out_accessor->type = cgltf_type_vec2; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC3") == 0) { out_accessor->type = cgltf_type_vec3; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC4") == 0) { out_accessor->type = cgltf_type_vec4; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT2") == 0) { out_accessor->type = cgltf_type_mat2; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT3") == 0) { out_accessor->type = cgltf_type_mat3; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT4") == 0) { out_accessor->type = cgltf_type_mat4; } ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "min") == 0) { ++i; out_accessor->has_min = 1; // note: we can't parse the precise number of elements since type may not have been computed yet int min_size = tokens[i].size > 16 ? 16 : tokens[i].size; i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->min, min_size); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "max") == 0) { ++i; out_accessor->has_max = 1; // note: we can't parse the precise number of elements since type may not have been computed yet int max_size = tokens[i].size > 16 ? 16 : tokens[i].size; i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->max, max_size); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "sparse") == 0) { out_accessor->is_sparse = 1; i = cgltf_parse_json_accessor_sparse(options, tokens, i + 1, json_chunk, &out_accessor->sparse); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_accessor->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_accessor->extensions_count, &out_accessor->extensions); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_texture_transform(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture_transform* out_texture_transform) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "offset") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_texture_transform->offset, 2); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "rotation") == 0) { ++i; out_texture_transform->rotation = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_texture_transform->scale, 2); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0) { ++i; out_texture_transform->texcoord = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_texture_view(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture_view* out_texture_view) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); out_texture_view->scale = 1.0f; cgltf_fill_float_array(out_texture_view->transform.scale, 2, 1.0f); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "index") == 0) { ++i; out_texture_view->texture = CGLTF_PTRINDEX(cgltf_texture, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0) { ++i; out_texture_view->texcoord = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0) { ++i; out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "strength") == 0) { ++i; out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_texture_view->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); if(out_texture_view->extensions) { return CGLTF_ERROR_JSON; } int extensions_size = tokens[i].size; out_texture_view->extensions_count = 0; out_texture_view->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); if (!out_texture_view->extensions) { return CGLTF_ERROR_NOMEM; } ++i; for (int k = 0; k < extensions_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_texture_transform") == 0) { out_texture_view->has_transform = 1; i = cgltf_parse_json_texture_transform(tokens, i + 1, json_chunk, &out_texture_view->transform); } else { i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_texture_view->extensions[out_texture_view->extensions_count++])); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_pbr_metallic_roughness(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_pbr_metallic_roughness* out_pbr) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "metallicFactor") == 0) { ++i; out_pbr->metallic_factor = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "roughnessFactor") == 0) { ++i; out_pbr->roughness_factor = cgltf_json_to_float(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "baseColorFactor") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->base_color_factor, 4); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "baseColorTexture") == 0) { i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->base_color_texture); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "metallicRoughnessTexture") == 0) { i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->metallic_roughness_texture); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_pbr->extras); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_pbr_specular_glossiness(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_pbr_specular_glossiness* out_pbr) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "diffuseFactor") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->diffuse_factor, 4); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularFactor") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->specular_factor, 3); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "glossinessFactor") == 0) { ++i; out_pbr->glossiness_factor = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "diffuseTexture") == 0) { i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->diffuse_texture); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularGlossinessTexture") == 0) { i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->specular_glossiness_texture); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_clearcoat(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_clearcoat* out_clearcoat) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatFactor") == 0) { ++i; out_clearcoat->clearcoat_factor = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatRoughnessFactor") == 0) { ++i; out_clearcoat->clearcoat_roughness_factor = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatTexture") == 0) { i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_texture); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatRoughnessTexture") == 0) { i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_roughness_texture); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatNormalTexture") == 0) { i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_normal_texture); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_ior(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_ior* out_ior) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; // Default values out_ior->ior = 1.5f; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "ior") == 0) { ++i; out_ior->ior = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_specular(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_specular* out_specular) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; // Default values out_specular->specular_factor = 1.0f; cgltf_fill_float_array(out_specular->specular_color_factor, 3, 1.0f); for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "specularFactor") == 0) { ++i; out_specular->specular_factor = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularColorFactor") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_specular->specular_color_factor, 3); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularTexture") == 0) { i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_specular->specular_texture); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_transmission(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_transmission* out_transmission) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "transmissionFactor") == 0) { ++i; out_transmission->transmission_factor = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "transmissionTexture") == 0) { i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_transmission->transmission_texture); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_sheen(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_sheen* out_sheen) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenColorFactor") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_sheen->sheen_color_factor, 3); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenColorTexture") == 0) { i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_sheen->sheen_color_texture); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenRoughnessFactor") == 0) { ++i; out_sheen->sheen_roughness_factor = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenRoughnessTexture") == 0) { i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_sheen->sheen_roughness_texture); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_image(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_image* out_image) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "uri") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->uri); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0) { ++i; out_image->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "mimeType") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->mime_type); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->name); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_image->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_image->extensions_count, &out_image->extensions); } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_sampler(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_sampler* out_sampler) { (void)options; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); out_sampler->wrap_s = 10497; out_sampler->wrap_t = 10497; int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "magFilter") == 0) { ++i; out_sampler->mag_filter = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "minFilter") == 0) { ++i; out_sampler->min_filter = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapS") == 0) { ++i; out_sampler->wrap_s = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapT") == 0) { ++i; out_sampler->wrap_t = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sampler->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sampler->extensions_count, &out_sampler->extensions); } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_texture(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture* out_texture) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_texture->name); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "sampler") == 0) { ++i; out_texture->sampler = CGLTF_PTRINDEX(cgltf_sampler, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0) { ++i; out_texture->image = CGLTF_PTRINDEX(cgltf_image, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_texture->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_texture->extensions_count, &out_texture->extensions); } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_material(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material* out_material) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); cgltf_fill_float_array(out_material->pbr_metallic_roughness.base_color_factor, 4, 1.0f); out_material->pbr_metallic_roughness.metallic_factor = 1.0f; out_material->pbr_metallic_roughness.roughness_factor = 1.0f; cgltf_fill_float_array(out_material->pbr_specular_glossiness.diffuse_factor, 4, 1.0f); cgltf_fill_float_array(out_material->pbr_specular_glossiness.specular_factor, 3, 1.0f); out_material->pbr_specular_glossiness.glossiness_factor = 1.0f; out_material->alpha_cutoff = 0.5f; int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_material->name); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "pbrMetallicRoughness") == 0) { out_material->has_pbr_metallic_roughness = 1; i = cgltf_parse_json_pbr_metallic_roughness(options, tokens, i + 1, json_chunk, &out_material->pbr_metallic_roughness); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "emissiveFactor") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_material->emissive_factor, 3); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "normalTexture") == 0) { i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_material->normal_texture); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "occlusionTexture") == 0) { i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_material->occlusion_texture); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "emissiveTexture") == 0) { i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_material->emissive_texture); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaMode") == 0) { ++i; if (cgltf_json_strcmp(tokens + i, json_chunk, "OPAQUE") == 0) { out_material->alpha_mode = cgltf_alpha_mode_opaque; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "MASK") == 0) { out_material->alpha_mode = cgltf_alpha_mode_mask; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "BLEND") == 0) { out_material->alpha_mode = cgltf_alpha_mode_blend; } ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaCutoff") == 0) { ++i; out_material->alpha_cutoff = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "doubleSided") == 0) { ++i; out_material->double_sided = cgltf_json_to_bool(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_material->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); if(out_material->extensions) { return CGLTF_ERROR_JSON; } int extensions_size = tokens[i].size; ++i; out_material->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); out_material->extensions_count= 0; if (!out_material->extensions) { return CGLTF_ERROR_NOMEM; } for (int k = 0; k < extensions_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_pbrSpecularGlossiness") == 0) { out_material->has_pbr_specular_glossiness = 1; i = cgltf_parse_json_pbr_specular_glossiness(options, tokens, i + 1, json_chunk, &out_material->pbr_specular_glossiness); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_unlit") == 0) { out_material->unlit = 1; i = cgltf_skip_json(tokens, i+1); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_clearcoat") == 0) { out_material->has_clearcoat = 1; i = cgltf_parse_json_clearcoat(options, tokens, i + 1, json_chunk, &out_material->clearcoat); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_ior") == 0) { out_material->has_ior = 1; i = cgltf_parse_json_ior(tokens, i + 1, json_chunk, &out_material->ior); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_specular") == 0) { out_material->has_specular = 1; i = cgltf_parse_json_specular(options, tokens, i + 1, json_chunk, &out_material->specular); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_transmission") == 0) { out_material->has_transmission = 1; i = cgltf_parse_json_transmission(options, tokens, i + 1, json_chunk, &out_material->transmission); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_sheen") == 0) { out_material->has_sheen = 1; i = cgltf_parse_json_sheen(options, tokens, i + 1, json_chunk, &out_material->sheen); } else { i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_material->extensions[out_material->extensions_count++])); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_accessors(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_accessor), (void**)&out_data->accessors, &out_data->accessors_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->accessors_count; ++j) { i = cgltf_parse_json_accessor(options, tokens, i, json_chunk, &out_data->accessors[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_materials(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_material), (void**)&out_data->materials, &out_data->materials_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->materials_count; ++j) { i = cgltf_parse_json_material(options, tokens, i, json_chunk, &out_data->materials[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_images(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_image), (void**)&out_data->images, &out_data->images_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->images_count; ++j) { i = cgltf_parse_json_image(options, tokens, i, json_chunk, &out_data->images[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_textures(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_texture), (void**)&out_data->textures, &out_data->textures_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->textures_count; ++j) { i = cgltf_parse_json_texture(options, tokens, i, json_chunk, &out_data->textures[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_samplers(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_sampler), (void**)&out_data->samplers, &out_data->samplers_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->samplers_count; ++j) { i = cgltf_parse_json_sampler(options, tokens, i, json_chunk, &out_data->samplers[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_meshopt_compression(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_meshopt_compression* out_meshopt_compression) { (void)options; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "buffer") == 0) { ++i; out_meshopt_compression->buffer = CGLTF_PTRINDEX(cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0) { ++i; out_meshopt_compression->offset = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0) { ++i; out_meshopt_compression->size = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteStride") == 0) { ++i; out_meshopt_compression->stride = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0) { ++i; out_meshopt_compression->count = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "mode") == 0) { ++i; if (cgltf_json_strcmp(tokens+i, json_chunk, "ATTRIBUTES") == 0) { out_meshopt_compression->mode = cgltf_meshopt_compression_mode_attributes; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "TRIANGLES") == 0) { out_meshopt_compression->mode = cgltf_meshopt_compression_mode_triangles; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "INDICES") == 0) { out_meshopt_compression->mode = cgltf_meshopt_compression_mode_indices; } ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "filter") == 0) { ++i; if (cgltf_json_strcmp(tokens+i, json_chunk, "NONE") == 0) { out_meshopt_compression->filter = cgltf_meshopt_compression_filter_none; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "OCTAHEDRAL") == 0) { out_meshopt_compression->filter = cgltf_meshopt_compression_filter_octahedral; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "QUATERNION") == 0) { out_meshopt_compression->filter = cgltf_meshopt_compression_filter_quaternion; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "EXPONENTIAL") == 0) { out_meshopt_compression->filter = cgltf_meshopt_compression_filter_exponential; } ++i; } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_buffer_view(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_buffer_view* out_buffer_view) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "buffer") == 0) { ++i; out_buffer_view->buffer = CGLTF_PTRINDEX(cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0) { ++i; out_buffer_view->offset = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0) { ++i; out_buffer_view->size = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteStride") == 0) { ++i; out_buffer_view->stride = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "target") == 0) { ++i; int type = cgltf_json_to_int(tokens+i, json_chunk); switch (type) { case 34962: type = cgltf_buffer_view_type_vertices; break; case 34963: type = cgltf_buffer_view_type_indices; break; default: type = cgltf_buffer_view_type_invalid; break; } out_buffer_view->type = (cgltf_buffer_view_type)type; ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_buffer_view->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); if(out_buffer_view->extensions) { return CGLTF_ERROR_JSON; } int extensions_size = tokens[i].size; out_buffer_view->extensions_count = 0; out_buffer_view->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); if (!out_buffer_view->extensions) { return CGLTF_ERROR_NOMEM; } ++i; for (int k = 0; k < extensions_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "EXT_meshopt_compression") == 0) { out_buffer_view->has_meshopt_compression = 1; i = cgltf_parse_json_meshopt_compression(options, tokens, i + 1, json_chunk, &out_buffer_view->meshopt_compression); } else { i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_buffer_view->extensions[out_buffer_view->extensions_count++])); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_buffer_views(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_buffer_view), (void**)&out_data->buffer_views, &out_data->buffer_views_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->buffer_views_count; ++j) { i = cgltf_parse_json_buffer_view(options, tokens, i, json_chunk, &out_data->buffer_views[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_buffer(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_buffer* out_buffer) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0) { ++i; out_buffer->size = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "uri") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer->uri); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_buffer->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_buffer->extensions_count, &out_buffer->extensions); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_buffers(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_buffer), (void**)&out_data->buffers, &out_data->buffers_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->buffers_count; ++j) { i = cgltf_parse_json_buffer(options, tokens, i, json_chunk, &out_data->buffers[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_skin(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_skin* out_skin) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_skin->name); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "joints") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_skin->joints, &out_skin->joints_count); if (i < 0) { return i; } for (cgltf_size k = 0; k < out_skin->joints_count; ++k) { out_skin->joints[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } } else if (cgltf_json_strcmp(tokens+i, json_chunk, "skeleton") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); out_skin->skeleton = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "inverseBindMatrices") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); out_skin->inverse_bind_matrices = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_skin->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_skin->extensions_count, &out_skin->extensions); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_skins(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_skin), (void**)&out_data->skins, &out_data->skins_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->skins_count; ++j) { i = cgltf_parse_json_skin(options, tokens, i, json_chunk, &out_data->skins[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_camera* out_camera) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_camera->name); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0) { ++i; if (cgltf_json_strcmp(tokens + i, json_chunk, "perspective") == 0) { out_camera->type = cgltf_camera_type_perspective; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "orthographic") == 0) { out_camera->type = cgltf_camera_type_orthographic; } ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "perspective") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int data_size = tokens[i].size; ++i; out_camera->type = cgltf_camera_type_perspective; for (int k = 0; k < data_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "aspectRatio") == 0) { ++i; out_camera->data.perspective.aspect_ratio = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "yfov") == 0) { ++i; out_camera->data.perspective.yfov = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "zfar") == 0) { ++i; out_camera->data.perspective.zfar = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "znear") == 0) { ++i; out_camera->data.perspective.znear = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->data.perspective.extras); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else if (cgltf_json_strcmp(tokens+i, json_chunk, "orthographic") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int data_size = tokens[i].size; ++i; out_camera->type = cgltf_camera_type_orthographic; for (int k = 0; k < data_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "xmag") == 0) { ++i; out_camera->data.orthographic.xmag = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "ymag") == 0) { ++i; out_camera->data.orthographic.ymag = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "zfar") == 0) { ++i; out_camera->data.orthographic.zfar = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "znear") == 0) { ++i; out_camera->data.orthographic.znear = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->data.orthographic.extras); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_camera->extensions_count, &out_camera->extensions); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_cameras(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_camera), (void**)&out_data->cameras, &out_data->cameras_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->cameras_count; ++j) { i = cgltf_parse_json_camera(options, tokens, i, json_chunk, &out_data->cameras[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_light(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_light* out_light) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_light->name); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "color") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_light->color, 3); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "intensity") == 0) { ++i; out_light->intensity = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0) { ++i; if (cgltf_json_strcmp(tokens + i, json_chunk, "directional") == 0) { out_light->type = cgltf_light_type_directional; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "point") == 0) { out_light->type = cgltf_light_type_point; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "spot") == 0) { out_light->type = cgltf_light_type_spot; } ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "range") == 0) { ++i; out_light->range = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "spot") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int data_size = tokens[i].size; ++i; for (int k = 0; k < data_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "innerConeAngle") == 0) { ++i; out_light->spot_inner_cone_angle = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "outerConeAngle") == 0) { ++i; out_light->spot_outer_cone_angle = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_lights(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_light), (void**)&out_data->lights, &out_data->lights_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->lights_count; ++j) { i = cgltf_parse_json_light(options, tokens, i, json_chunk, &out_data->lights[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_node(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_node* out_node) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); out_node->rotation[3] = 1.0f; out_node->scale[0] = 1.0f; out_node->scale[1] = 1.0f; out_node->scale[2] = 1.0f; out_node->matrix[0] = 1.0f; out_node->matrix[5] = 1.0f; out_node->matrix[10] = 1.0f; out_node->matrix[15] = 1.0f; int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_node->name); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "children") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_node->children, &out_node->children_count); if (i < 0) { return i; } for (cgltf_size k = 0; k < out_node->children_count; ++k) { out_node->children[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } } else if (cgltf_json_strcmp(tokens+i, json_chunk, "mesh") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); out_node->mesh = CGLTF_PTRINDEX(cgltf_mesh, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "skin") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); out_node->skin = CGLTF_PTRINDEX(cgltf_skin, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "camera") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); out_node->camera = CGLTF_PTRINDEX(cgltf_camera, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "translation") == 0) { out_node->has_translation = 1; i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->translation, 3); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "rotation") == 0) { out_node->has_rotation = 1; i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->rotation, 4); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "scale") == 0) { out_node->has_scale = 1; i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->scale, 3); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "matrix") == 0) { out_node->has_matrix = 1; i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->matrix, 16); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_float), (void**)&out_node->weights, &out_node->weights_count); if (i < 0) { return i; } i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, out_node->weights, (int)out_node->weights_count); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_node->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); if(out_node->extensions) { return CGLTF_ERROR_JSON; } int extensions_size = tokens[i].size; out_node->extensions_count= 0; out_node->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); if (!out_node->extensions) { return CGLTF_ERROR_NOMEM; } ++i; for (int k = 0; k < extensions_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_lights_punctual") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int data_size = tokens[i].size; ++i; for (int m = 0; m < data_size; ++m) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "light") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); out_node->light = CGLTF_PTRINDEX(cgltf_light, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } } else { i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_node->extensions[out_node->extensions_count++])); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_nodes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_node), (void**)&out_data->nodes, &out_data->nodes_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->nodes_count; ++j) { i = cgltf_parse_json_node(options, tokens, i, json_chunk, &out_data->nodes[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_scene(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_scene* out_scene) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_scene->name); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "nodes") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_scene->nodes, &out_scene->nodes_count); if (i < 0) { return i; } for (cgltf_size k = 0; k < out_scene->nodes_count; ++k) { out_scene->nodes[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_scene->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_scene->extensions_count, &out_scene->extensions); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_scenes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_scene), (void**)&out_data->scenes, &out_data->scenes_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->scenes_count; ++j) { i = cgltf_parse_json_scene(options, tokens, i, json_chunk, &out_data->scenes[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_animation_sampler(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation_sampler* out_sampler) { (void)options; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "input") == 0) { ++i; out_sampler->input = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "output") == 0) { ++i; out_sampler->output = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "interpolation") == 0) { ++i; if (cgltf_json_strcmp(tokens + i, json_chunk, "LINEAR") == 0) { out_sampler->interpolation = cgltf_interpolation_type_linear; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "STEP") == 0) { out_sampler->interpolation = cgltf_interpolation_type_step; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "CUBICSPLINE") == 0) { out_sampler->interpolation = cgltf_interpolation_type_cubic_spline; } ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sampler->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sampler->extensions_count, &out_sampler->extensions); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_animation_channel(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation_channel* out_channel) { (void)options; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "sampler") == 0) { ++i; out_channel->sampler = CGLTF_PTRINDEX(cgltf_animation_sampler, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "target") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int target_size = tokens[i].size; ++i; for (int k = 0; k < target_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "node") == 0) { ++i; out_channel->target_node = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "path") == 0) { ++i; if (cgltf_json_strcmp(tokens+i, json_chunk, "translation") == 0) { out_channel->target_path = cgltf_animation_path_type_translation; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "rotation") == 0) { out_channel->target_path = cgltf_animation_path_type_rotation; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "scale") == 0) { out_channel->target_path = cgltf_animation_path_type_scale; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "weights") == 0) { out_channel->target_path = cgltf_animation_path_type_weights; } ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_channel->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_channel->extensions_count, &out_channel->extensions); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_animation(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation* out_animation) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_animation->name); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "samplers") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_sampler), (void**)&out_animation->samplers, &out_animation->samplers_count); if (i < 0) { return i; } for (cgltf_size k = 0; k < out_animation->samplers_count; ++k) { i = cgltf_parse_json_animation_sampler(options, tokens, i, json_chunk, &out_animation->samplers[k]); if (i < 0) { return i; } } } else if (cgltf_json_strcmp(tokens+i, json_chunk, "channels") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_channel), (void**)&out_animation->channels, &out_animation->channels_count); if (i < 0) { return i; } for (cgltf_size k = 0; k < out_animation->channels_count; ++k) { i = cgltf_parse_json_animation_channel(options, tokens, i, json_chunk, &out_animation->channels[k]); if (i < 0) { return i; } } } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_animation->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_animation->extensions_count, &out_animation->extensions); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_animations(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_animation), (void**)&out_data->animations, &out_data->animations_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->animations_count; ++j) { i = cgltf_parse_json_animation(options, tokens, i, json_chunk, &out_data->animations[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_asset(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_asset* out_asset) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "copyright") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->copyright); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "generator") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->generator); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "version") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->version); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "minVersion") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->min_version); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_asset->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_asset->extensions_count, &out_asset->extensions); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } if (out_asset->version && CGLTF_ATOF(out_asset->version) < 2) { return CGLTF_ERROR_LEGACY; } return i; } cgltf_size cgltf_num_components(cgltf_type type) { switch (type) { case cgltf_type_vec2: return 2; case cgltf_type_vec3: return 3; case cgltf_type_vec4: return 4; case cgltf_type_mat2: return 4; case cgltf_type_mat3: return 9; case cgltf_type_mat4: return 16; case cgltf_type_invalid: case cgltf_type_scalar: default: return 1; } } static cgltf_size cgltf_component_size(cgltf_component_type component_type) { switch (component_type) { case cgltf_component_type_r_8: case cgltf_component_type_r_8u: return 1; case cgltf_component_type_r_16: case cgltf_component_type_r_16u: return 2; case cgltf_component_type_r_32u: case cgltf_component_type_r_32f: return 4; case cgltf_component_type_invalid: default: return 0; } } static cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type) { cgltf_size component_size = cgltf_component_size(component_type); if (type == cgltf_type_mat2 && component_size == 1) { return 8 * component_size; } else if (type == cgltf_type_mat3 && (component_size == 1 || component_size == 2)) { return 12 * component_size; } return component_size * cgltf_num_components(type); } static int cgltf_fixup_pointers(cgltf_data* out_data); static int cgltf_parse_json_root(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "asset") == 0) { i = cgltf_parse_json_asset(options, tokens, i + 1, json_chunk, &out_data->asset); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "meshes") == 0) { i = cgltf_parse_json_meshes(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "accessors") == 0) { i = cgltf_parse_json_accessors(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferViews") == 0) { i = cgltf_parse_json_buffer_views(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "buffers") == 0) { i = cgltf_parse_json_buffers(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "materials") == 0) { i = cgltf_parse_json_materials(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "images") == 0) { i = cgltf_parse_json_images(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "textures") == 0) { i = cgltf_parse_json_textures(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "samplers") == 0) { i = cgltf_parse_json_samplers(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "skins") == 0) { i = cgltf_parse_json_skins(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "cameras") == 0) { i = cgltf_parse_json_cameras(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "nodes") == 0) { i = cgltf_parse_json_nodes(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "scenes") == 0) { i = cgltf_parse_json_scenes(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "scene") == 0) { ++i; out_data->scene = CGLTF_PTRINDEX(cgltf_scene, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "animations") == 0) { i = cgltf_parse_json_animations(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "extras") == 0) { i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_data->extras); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); if(out_data->data_extensions) { return CGLTF_ERROR_JSON; } int extensions_size = tokens[i].size; out_data->data_extensions_count = 0; out_data->data_extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); if (!out_data->data_extensions) { return CGLTF_ERROR_NOMEM; } ++i; for (int k = 0; k < extensions_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_lights_punctual") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int data_size = tokens[i].size; ++i; for (int m = 0; m < data_size; ++m) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "lights") == 0) { i = cgltf_parse_json_lights(options, tokens, i + 1, json_chunk, out_data); } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } } else { i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_data->data_extensions[out_data->data_extensions_count++])); } if (i < 0) { return i; } } } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensionsUsed") == 0) { i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_data->extensions_used, &out_data->extensions_used_count); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensionsRequired") == 0) { i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_data->extensions_required, &out_data->extensions_required_count); } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } return i; } cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk, cgltf_size size, cgltf_data** out_data) { jsmn_parser parser = { 0, 0, 0 }; if (options->json_token_count == 0) { int token_count = jsmn_parse(&parser, (const char*)json_chunk, size, NULL, 0); if (token_count <= 0) { return cgltf_result_invalid_json; } options->json_token_count = token_count; } jsmntok_t* tokens = (jsmntok_t*)options->memory.alloc(options->memory.user_data, sizeof(jsmntok_t) * (options->json_token_count + 1)); if (!tokens) { return cgltf_result_out_of_memory; } jsmn_init(&parser); int token_count = jsmn_parse(&parser, (const char*)json_chunk, size, tokens, options->json_token_count); if (token_count <= 0) { options->memory.free(options->memory.user_data, tokens); return cgltf_result_invalid_json; } // this makes sure that we always have an UNDEFINED token at the end of the stream // for invalid JSON inputs this makes sure we don't perform out of bound reads of token data tokens[token_count].type = JSMN_UNDEFINED; cgltf_data* data = (cgltf_data*)options->memory.alloc(options->memory.user_data, sizeof(cgltf_data)); if (!data) { options->memory.free(options->memory.user_data, tokens); return cgltf_result_out_of_memory; } memset(data, 0, sizeof(cgltf_data)); data->memory = options->memory; data->file = options->file; int i = cgltf_parse_json_root(options, tokens, 0, json_chunk, data); options->memory.free(options->memory.user_data, tokens); if (i < 0) { cgltf_free(data); switch (i) { case CGLTF_ERROR_NOMEM: return cgltf_result_out_of_memory; case CGLTF_ERROR_LEGACY: return cgltf_result_legacy_gltf; default: return cgltf_result_invalid_gltf; } } if (cgltf_fixup_pointers(data) < 0) { cgltf_free(data); return cgltf_result_invalid_gltf; } data->json = (const char*)json_chunk; data->json_size = size; *out_data = data; return cgltf_result_success; } static int cgltf_fixup_pointers(cgltf_data* data) { for (cgltf_size i = 0; i < data->meshes_count; ++i) { for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j) { CGLTF_PTRFIXUP(data->meshes[i].primitives[j].indices, data->accessors, data->accessors_count); CGLTF_PTRFIXUP(data->meshes[i].primitives[j].material, data->materials, data->materials_count); for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k) { CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].attributes[k].data, data->accessors, data->accessors_count); } for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k) { for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m) { CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].targets[k].attributes[m].data, data->accessors, data->accessors_count); } } if (data->meshes[i].primitives[j].has_draco_mesh_compression) { CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].draco_mesh_compression.buffer_view, data->buffer_views, data->buffer_views_count); for (cgltf_size m = 0; m < data->meshes[i].primitives[j].draco_mesh_compression.attributes_count; ++m) { CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].draco_mesh_compression.attributes[m].data, data->accessors, data->accessors_count); } } } } for (cgltf_size i = 0; i < data->accessors_count; ++i) { CGLTF_PTRFIXUP(data->accessors[i].buffer_view, data->buffer_views, data->buffer_views_count); if (data->accessors[i].is_sparse) { CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.indices_buffer_view, data->buffer_views, data->buffer_views_count); CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.values_buffer_view, data->buffer_views, data->buffer_views_count); } if (data->accessors[i].buffer_view) { data->accessors[i].stride = data->accessors[i].buffer_view->stride; } if (data->accessors[i].stride == 0) { data->accessors[i].stride = cgltf_calc_size(data->accessors[i].type, data->accessors[i].component_type); } } for (cgltf_size i = 0; i < data->textures_count; ++i) { CGLTF_PTRFIXUP(data->textures[i].image, data->images, data->images_count); CGLTF_PTRFIXUP(data->textures[i].sampler, data->samplers, data->samplers_count); } for (cgltf_size i = 0; i < data->images_count; ++i) { CGLTF_PTRFIXUP(data->images[i].buffer_view, data->buffer_views, data->buffer_views_count); } for (cgltf_size i = 0; i < data->materials_count; ++i) { CGLTF_PTRFIXUP(data->materials[i].normal_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].emissive_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].occlusion_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].pbr_metallic_roughness.base_color_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].pbr_specular_glossiness.diffuse_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_roughness_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_normal_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].specular.specular_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].transmission.transmission_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_color_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_roughness_texture.texture, data->textures, data->textures_count); } for (cgltf_size i = 0; i < data->buffer_views_count; ++i) { CGLTF_PTRFIXUP_REQ(data->buffer_views[i].buffer, data->buffers, data->buffers_count); if (data->buffer_views[i].has_meshopt_compression) { CGLTF_PTRFIXUP_REQ(data->buffer_views[i].meshopt_compression.buffer, data->buffers, data->buffers_count); } } for (cgltf_size i = 0; i < data->skins_count; ++i) { for (cgltf_size j = 0; j < data->skins[i].joints_count; ++j) { CGLTF_PTRFIXUP_REQ(data->skins[i].joints[j], data->nodes, data->nodes_count); } CGLTF_PTRFIXUP(data->skins[i].skeleton, data->nodes, data->nodes_count); CGLTF_PTRFIXUP(data->skins[i].inverse_bind_matrices, data->accessors, data->accessors_count); } for (cgltf_size i = 0; i < data->nodes_count; ++i) { for (cgltf_size j = 0; j < data->nodes[i].children_count; ++j) { CGLTF_PTRFIXUP_REQ(data->nodes[i].children[j], data->nodes, data->nodes_count); if (data->nodes[i].children[j]->parent) { return CGLTF_ERROR_JSON; } data->nodes[i].children[j]->parent = &data->nodes[i]; } CGLTF_PTRFIXUP(data->nodes[i].mesh, data->meshes, data->meshes_count); CGLTF_PTRFIXUP(data->nodes[i].skin, data->skins, data->skins_count); CGLTF_PTRFIXUP(data->nodes[i].camera, data->cameras, data->cameras_count); CGLTF_PTRFIXUP(data->nodes[i].light, data->lights, data->lights_count); } for (cgltf_size i = 0; i < data->scenes_count; ++i) { for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j) { CGLTF_PTRFIXUP_REQ(data->scenes[i].nodes[j], data->nodes, data->nodes_count); if (data->scenes[i].nodes[j]->parent) { return CGLTF_ERROR_JSON; } } } CGLTF_PTRFIXUP(data->scene, data->scenes, data->scenes_count); for (cgltf_size i = 0; i < data->animations_count; ++i) { for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j) { CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].input, data->accessors, data->accessors_count); CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].output, data->accessors, data->accessors_count); } for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j) { CGLTF_PTRFIXUP_REQ(data->animations[i].channels[j].sampler, data->animations[i].samplers, data->animations[i].samplers_count); CGLTF_PTRFIXUP(data->animations[i].channels[j].target_node, data->nodes, data->nodes_count); } } return 0; } /* * -- jsmn.c start -- * Source: https://github.com/zserge/jsmn * License: MIT * * Copyright (c) 2010 Serge A. Zaitsev * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ /** * Allocates a fresh unused token from the token pull. */ static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens, size_t num_tokens) { jsmntok_t *tok; if (parser->toknext >= num_tokens) { return NULL; } tok = &tokens[parser->toknext++]; tok->start = tok->end = -1; tok->size = 0; #ifdef JSMN_PARENT_LINKS tok->parent = -1; #endif return tok; } /** * Fills token type and boundaries. */ static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type, int start, int end) { token->type = type; token->start = start; token->end = end; token->size = 0; } /** * Fills next available token with JSON primitive. */ static int jsmn_parse_primitive(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens) { jsmntok_t *token; int start; start = parser->pos; for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { switch (js[parser->pos]) { #ifndef JSMN_STRICT /* In strict mode primitive must be followed by "," or "}" or "]" */ case ':': #endif case '\t' : case '\r' : case '\n' : case ' ' : case ',' : case ']' : case '}' : goto found; } if (js[parser->pos] < 32 || js[parser->pos] >= 127) { parser->pos = start; return JSMN_ERROR_INVAL; } } #ifdef JSMN_STRICT /* In strict mode primitive must be followed by a comma/object/array */ parser->pos = start; return JSMN_ERROR_PART; #endif found: if (tokens == NULL) { parser->pos--; return 0; } token = jsmn_alloc_token(parser, tokens, num_tokens); if (token == NULL) { parser->pos = start; return JSMN_ERROR_NOMEM; } jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos); #ifdef JSMN_PARENT_LINKS token->parent = parser->toksuper; #endif parser->pos--; return 0; } /** * Fills next token with JSON string. */ static int jsmn_parse_string(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens) { jsmntok_t *token; int start = parser->pos; parser->pos++; /* Skip starting quote */ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { char c = js[parser->pos]; /* Quote: end of string */ if (c == '\"') { if (tokens == NULL) { return 0; } token = jsmn_alloc_token(parser, tokens, num_tokens); if (token == NULL) { parser->pos = start; return JSMN_ERROR_NOMEM; } jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos); #ifdef JSMN_PARENT_LINKS token->parent = parser->toksuper; #endif return 0; } /* Backslash: Quoted symbol expected */ if (c == '\\' && parser->pos + 1 < len) { int i; parser->pos++; switch (js[parser->pos]) { /* Allowed escaped symbols */ case '\"': case '/' : case '\\' : case 'b' : case 'f' : case 'r' : case 'n' : case 't' : break; /* Allows escaped symbol \uXXXX */ case 'u': parser->pos++; for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) { /* If it isn't a hex character we have an error */ if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */ (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */ (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */ parser->pos = start; return JSMN_ERROR_INVAL; } parser->pos++; } parser->pos--; break; /* Unexpected symbol */ default: parser->pos = start; return JSMN_ERROR_INVAL; } } } parser->pos = start; return JSMN_ERROR_PART; } /** * Parse JSON string and fill tokens. */ static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens) { int r; int i; jsmntok_t *token; int count = parser->toknext; for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { char c; jsmntype_t type; c = js[parser->pos]; switch (c) { case '{': case '[': count++; if (tokens == NULL) { break; } token = jsmn_alloc_token(parser, tokens, num_tokens); if (token == NULL) return JSMN_ERROR_NOMEM; if (parser->toksuper != -1) { tokens[parser->toksuper].size++; #ifdef JSMN_PARENT_LINKS token->parent = parser->toksuper; #endif } token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY); token->start = parser->pos; parser->toksuper = parser->toknext - 1; break; case '}': case ']': if (tokens == NULL) break; type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY); #ifdef JSMN_PARENT_LINKS if (parser->toknext < 1) { return JSMN_ERROR_INVAL; } token = &tokens[parser->toknext - 1]; for (;;) { if (token->start != -1 && token->end == -1) { if (token->type != type) { return JSMN_ERROR_INVAL; } token->end = parser->pos + 1; parser->toksuper = token->parent; break; } if (token->parent == -1) { if(token->type != type || parser->toksuper == -1) { return JSMN_ERROR_INVAL; } break; } token = &tokens[token->parent]; } #else for (i = parser->toknext - 1; i >= 0; i--) { token = &tokens[i]; if (token->start != -1 && token->end == -1) { if (token->type != type) { return JSMN_ERROR_INVAL; } parser->toksuper = -1; token->end = parser->pos + 1; break; } } /* Error if unmatched closing bracket */ if (i == -1) return JSMN_ERROR_INVAL; for (; i >= 0; i--) { token = &tokens[i]; if (token->start != -1 && token->end == -1) { parser->toksuper = i; break; } } #endif break; case '\"': r = jsmn_parse_string(parser, js, len, tokens, num_tokens); if (r < 0) return r; count++; if (parser->toksuper != -1 && tokens != NULL) tokens[parser->toksuper].size++; break; case '\t' : case '\r' : case '\n' : case ' ': break; case ':': parser->toksuper = parser->toknext - 1; break; case ',': if (tokens != NULL && parser->toksuper != -1 && tokens[parser->toksuper].type != JSMN_ARRAY && tokens[parser->toksuper].type != JSMN_OBJECT) { #ifdef JSMN_PARENT_LINKS parser->toksuper = tokens[parser->toksuper].parent; #else for (i = parser->toknext - 1; i >= 0; i--) { if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) { if (tokens[i].start != -1 && tokens[i].end == -1) { parser->toksuper = i; break; } } } #endif } break; #ifdef JSMN_STRICT /* In strict mode primitives are: numbers and booleans */ case '-': case '0': case '1' : case '2': case '3' : case '4': case '5': case '6': case '7' : case '8': case '9': case 't': case 'f': case 'n' : /* And they must not be keys of the object */ if (tokens != NULL && parser->toksuper != -1) { jsmntok_t *t = &tokens[parser->toksuper]; if (t->type == JSMN_OBJECT || (t->type == JSMN_STRING && t->size != 0)) { return JSMN_ERROR_INVAL; } } #else /* In non-strict mode every unquoted value is a primitive */ default: #endif r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens); if (r < 0) return r; count++; if (parser->toksuper != -1 && tokens != NULL) tokens[parser->toksuper].size++; break; #ifdef JSMN_STRICT /* Unexpected char in strict mode */ default: return JSMN_ERROR_INVAL; #endif } } if (tokens != NULL) { for (i = parser->toknext - 1; i >= 0; i--) { /* Unmatched opened object or array */ if (tokens[i].start != -1 && tokens[i].end == -1) { return JSMN_ERROR_PART; } } } return count; } /** * Creates a new parser based over a given buffer with an array of tokens * available. */ static void jsmn_init(jsmn_parser *parser) { parser->pos = 0; parser->toknext = 0; parser->toksuper = -1; } /* * -- jsmn.c end -- */ #endif /* #ifdef CGLTF_IMPLEMENTATION */ /* cgltf is distributed under MIT license: * * Copyright (c) 2018 Johannes Kuhlmann * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ goxel-0.11.0/ext_src/cgltf/cgltf_write.h000066400000000000000000001156311435762723100201600ustar00rootroot00000000000000/** * cgltf_write - a single-file glTF 2.0 writer written in C99. * * Version: 1.8 * * Website: https://github.com/jkuhlmann/cgltf * * Distributed under the MIT License, see notice at the end of this file. * * Building: * Include this file where you need the struct and function * declarations. Have exactly one source file where you define * `CGLTF_WRITE_IMPLEMENTATION` before including this file to get the * function definitions. * * Reference: * `cgltf_result cgltf_write_file(const cgltf_options* options, const char* * path, const cgltf_data* data)` writes JSON to the given file path. Buffer * files and external images are not written out. `data` is not deallocated. * * `cgltf_size cgltf_write(const cgltf_options* options, char* buffer, * cgltf_size size, const cgltf_data* data)` writes JSON into the given memory * buffer. Returns the number of bytes written to `buffer`, including a null * terminator. If buffer is null, returns the number of bytes that would have * been written. `data` is not deallocated. * * To write custom JSON into the `extras` field, aggregate all the custom JSON * into a single buffer, then set `file_data` to this buffer. By supplying * start_offset and end_offset values for various objects, you can select a * range of characters within the aggregated buffer. */ #ifndef CGLTF_WRITE_H_INCLUDED__ #define CGLTF_WRITE_H_INCLUDED__ #include "cgltf.h" #include #include #ifdef __cplusplus extern "C" { #endif cgltf_result cgltf_write_file(const cgltf_options* options, const char* path, const cgltf_data* data); cgltf_size cgltf_write(const cgltf_options* options, char* buffer, cgltf_size size, const cgltf_data* data); #ifdef __cplusplus } #endif #endif /* #ifndef CGLTF_WRITE_H_INCLUDED__ */ /* * * Stop now, if you are only interested in the API. * Below, you find the implementation. * */ #if defined(__INTELLISENSE__) || defined(__JETBRAINS_IDE__) /* This makes MSVC/CLion intellisense work. */ #define CGLTF_IMPLEMENTATION #endif #ifdef CGLTF_WRITE_IMPLEMENTATION #include #include #include #include #define CGLTF_EXTENSION_FLAG_TEXTURE_TRANSFORM (1 << 0) #define CGLTF_EXTENSION_FLAG_MATERIALS_UNLIT (1 << 1) #define CGLTF_EXTENSION_FLAG_SPECULAR_GLOSSINESS (1 << 2) #define CGLTF_EXTENSION_FLAG_LIGHTS_PUNCTUAL (1 << 3) #define CGLTF_EXTENSION_FLAG_DRACO_MESH_COMPRESSION (1 << 4) #define CGLTF_EXTENSION_FLAG_MATERIALS_CLEARCOAT (1 << 5) #define CGLTF_EXTENSION_FLAG_MATERIALS_IOR (1 << 6) #define CGLTF_EXTENSION_FLAG_MATERIALS_SPECULAR (1 << 7) #define CGLTF_EXTENSION_FLAG_MATERIALS_TRANSMISSION (1 << 8) #define CGLTF_EXTENSION_FLAG_MATERIALS_SHEEN (1 << 9) typedef struct { char* buffer; cgltf_size buffer_size; cgltf_size remaining; char* cursor; cgltf_size tmp; cgltf_size chars_written; const cgltf_data* data; int depth; const char* indent; int needs_comma; uint32_t extension_flags; uint32_t required_extension_flags; } cgltf_write_context; #define CGLTF_MIN(a, b) (a < b ? a : b) #ifdef FLT_DECIMAL_DIG // FLT_DECIMAL_DIG is C11 #define CGLTF_DECIMAL_DIG (FLT_DECIMAL_DIG) #else #define CGLTF_DECIMAL_DIG 9 #endif #define CGLTF_SPRINTF(...) { \ context->tmp = snprintf ( context->cursor, context->remaining, __VA_ARGS__ ); \ context->chars_written += context->tmp; \ if (context->cursor) { \ context->cursor += context->tmp; \ context->remaining -= context->tmp; \ } } #define CGLTF_SNPRINTF(length, ...) { \ context->tmp = snprintf ( context->cursor, CGLTF_MIN(length + 1, context->remaining), __VA_ARGS__ ); \ context->chars_written += length; \ if (context->cursor) { \ context->cursor += length; \ context->remaining -= length; \ } } #define CGLTF_WRITE_IDXPROP(label, val, start) if (val) { \ cgltf_write_indent(context); \ CGLTF_SPRINTF("\"%s\": %d", label, (int) (val - start)); \ context->needs_comma = 1; } #define CGLTF_WRITE_IDXARRPROP(label, dim, vals, start) if (vals) { \ cgltf_write_indent(context); \ CGLTF_SPRINTF("\"%s\": [", label); \ for (int i = 0; i < (int)(dim); ++i) { \ int idx = (int) (vals[i] - start); \ if (i != 0) CGLTF_SPRINTF(","); \ CGLTF_SPRINTF(" %d", idx); \ } \ CGLTF_SPRINTF(" ]"); \ context->needs_comma = 1; } #define CGLTF_WRITE_TEXTURE_INFO(label, info) if (info.texture) { \ cgltf_write_line(context, "\"" label "\": {"); \ CGLTF_WRITE_IDXPROP("index", info.texture, context->data->textures); \ cgltf_write_intprop(context, "texCoord", info.texcoord, 0); \ cgltf_write_floatprop(context, "scale", info.scale, 1.0f); \ if (info.has_transform) { \ context->extension_flags |= CGLTF_EXTENSION_FLAG_TEXTURE_TRANSFORM; \ cgltf_write_texture_transform(context, &info.transform); \ } \ cgltf_write_extras(context, &info.extras); \ cgltf_write_line(context, "}"); } static void cgltf_write_indent(cgltf_write_context* context) { if (context->needs_comma) { CGLTF_SPRINTF(",\n"); context->needs_comma = 0; } else { CGLTF_SPRINTF("\n"); } for (int i = 0; i < context->depth; ++i) { CGLTF_SPRINTF("%s", context->indent); } } static void cgltf_write_line(cgltf_write_context* context, const char* line) { if (line[0] == ']' || line[0] == '}') { --context->depth; context->needs_comma = 0; } cgltf_write_indent(context); CGLTF_SPRINTF("%s", line); cgltf_size last = (cgltf_size)(strlen(line) - 1); if (line[0] == ']' || line[0] == '}') { context->needs_comma = 1; } if (line[last] == '[' || line[last] == '{') { ++context->depth; context->needs_comma = 0; } } static void cgltf_write_strprop(cgltf_write_context* context, const char* label, const char* val) { if (val) { cgltf_write_indent(context); CGLTF_SPRINTF("\"%s\": \"%s\"", label, val); context->needs_comma = 1; } } static void cgltf_write_extras(cgltf_write_context* context, const cgltf_extras* extras) { cgltf_size length = extras->end_offset - extras->start_offset; if (length > 0 && context->data->file_data) { char* json_string = ((char*) context->data->file_data) + extras->start_offset; cgltf_write_indent(context); CGLTF_SPRINTF("%s", "\"extras\": "); CGLTF_SNPRINTF(length, "%s", json_string); context->needs_comma = 1; } } static void cgltf_write_stritem(cgltf_write_context* context, const char* item) { cgltf_write_indent(context); CGLTF_SPRINTF("\"%s\"", item); context->needs_comma = 1; } static void cgltf_write_intprop(cgltf_write_context* context, const char* label, int val, int def) { if (val != def) { cgltf_write_indent(context); CGLTF_SPRINTF("\"%s\": %d", label, val); context->needs_comma = 1; } } static void cgltf_write_floatprop(cgltf_write_context* context, const char* label, float val, float def) { if (val != def) { cgltf_write_indent(context); CGLTF_SPRINTF("\"%s\": ", label); CGLTF_SPRINTF("%.*g", CGLTF_DECIMAL_DIG, val); context->needs_comma = 1; if (context->cursor) { char *decimal_comma = strchr(context->cursor - context->tmp, ','); if (decimal_comma) { *decimal_comma = '.'; } } } } static void cgltf_write_boolprop_optional(cgltf_write_context* context, const char* label, bool val, bool def) { if (val != def) { cgltf_write_indent(context); CGLTF_SPRINTF("\"%s\": %s", label, val ? "true" : "false"); context->needs_comma = 1; } } static void cgltf_write_floatarrayprop(cgltf_write_context* context, const char* label, const cgltf_float* vals, cgltf_size dim) { cgltf_write_indent(context); CGLTF_SPRINTF("\"%s\": [", label); for (cgltf_size i = 0; i < dim; ++i) { if (i != 0) { CGLTF_SPRINTF(", %.*g", CGLTF_DECIMAL_DIG, vals[i]); } else { CGLTF_SPRINTF("%.*g", CGLTF_DECIMAL_DIG, vals[i]); } } CGLTF_SPRINTF("]"); context->needs_comma = 1; } static bool cgltf_check_floatarray(const float* vals, int dim, float val) { while (dim--) { if (vals[dim] != val) { return true; } } return false; } static int cgltf_int_from_component_type(cgltf_component_type ctype) { switch (ctype) { case cgltf_component_type_r_8: return 5120; case cgltf_component_type_r_8u: return 5121; case cgltf_component_type_r_16: return 5122; case cgltf_component_type_r_16u: return 5123; case cgltf_component_type_r_32u: return 5125; case cgltf_component_type_r_32f: return 5126; default: return 0; } } static const char* cgltf_str_from_alpha_mode(cgltf_alpha_mode alpha_mode) { switch (alpha_mode) { case cgltf_alpha_mode_mask: return "MASK"; case cgltf_alpha_mode_blend: return "BLEND"; default: return NULL; } } static const char* cgltf_str_from_type(cgltf_type type) { switch (type) { case cgltf_type_scalar: return "SCALAR"; case cgltf_type_vec2: return "VEC2"; case cgltf_type_vec3: return "VEC3"; case cgltf_type_vec4: return "VEC4"; case cgltf_type_mat2: return "MAT2"; case cgltf_type_mat3: return "MAT3"; case cgltf_type_mat4: return "MAT4"; default: return NULL; } } static cgltf_size cgltf_dim_from_type(cgltf_type type) { switch (type) { case cgltf_type_scalar: return 1; case cgltf_type_vec2: return 2; case cgltf_type_vec3: return 3; case cgltf_type_vec4: return 4; case cgltf_type_mat2: return 4; case cgltf_type_mat3: return 9; case cgltf_type_mat4: return 16; default: return 0; } } static const char* cgltf_str_from_camera_type(cgltf_camera_type camera_type) { switch (camera_type) { case cgltf_camera_type_perspective: return "perspective"; case cgltf_camera_type_orthographic: return "orthographic"; default: return NULL; } } static const char* cgltf_str_from_light_type(cgltf_light_type light_type) { switch (light_type) { case cgltf_light_type_directional: return "directional"; case cgltf_light_type_point: return "point"; case cgltf_light_type_spot: return "spot"; default: return NULL; } } static void cgltf_write_texture_transform(cgltf_write_context* context, const cgltf_texture_transform* transform) { cgltf_write_line(context, "\"extensions\": {"); cgltf_write_line(context, "\"KHR_texture_transform\": {"); if (cgltf_check_floatarray(transform->offset, 2, 0.0f)) { cgltf_write_floatarrayprop(context, "offset", transform->offset, 2); } cgltf_write_floatprop(context, "rotation", transform->rotation, 0.0f); if (cgltf_check_floatarray(transform->scale, 2, 1.0f)) { cgltf_write_floatarrayprop(context, "scale", transform->scale, 2); } cgltf_write_intprop(context, "texCoord", transform->texcoord, 0); cgltf_write_line(context, "}"); cgltf_write_line(context, "}"); } static void cgltf_write_asset(cgltf_write_context* context, const cgltf_asset* asset) { cgltf_write_line(context, "\"asset\": {"); cgltf_write_strprop(context, "copyright", asset->copyright); cgltf_write_strprop(context, "generator", asset->generator); cgltf_write_strprop(context, "version", asset->version); cgltf_write_strprop(context, "min_version", asset->min_version); cgltf_write_extras(context, &asset->extras); cgltf_write_line(context, "}"); } static void cgltf_write_primitive(cgltf_write_context* context, const cgltf_primitive* prim) { cgltf_write_intprop(context, "mode", (int) prim->type, 4); CGLTF_WRITE_IDXPROP("indices", prim->indices, context->data->accessors); CGLTF_WRITE_IDXPROP("material", prim->material, context->data->materials); cgltf_write_line(context, "\"attributes\": {"); for (cgltf_size i = 0; i < prim->attributes_count; ++i) { const cgltf_attribute* attr = prim->attributes + i; CGLTF_WRITE_IDXPROP(attr->name, attr->data, context->data->accessors); } cgltf_write_line(context, "}"); if (prim->targets_count) { cgltf_write_line(context, "\"targets\": ["); for (cgltf_size i = 0; i < prim->targets_count; ++i) { cgltf_write_line(context, "{"); for (cgltf_size j = 0; j < prim->targets[i].attributes_count; ++j) { const cgltf_attribute* attr = prim->targets[i].attributes + j; CGLTF_WRITE_IDXPROP(attr->name, attr->data, context->data->accessors); } cgltf_write_line(context, "}"); } cgltf_write_line(context, "]"); } cgltf_write_extras(context, &prim->extras); cgltf_bool has_extensions = prim->has_draco_mesh_compression; if (has_extensions) { cgltf_write_line(context, "\"extensions\": {"); if (prim->has_draco_mesh_compression) { context->extension_flags |= CGLTF_EXTENSION_FLAG_DRACO_MESH_COMPRESSION; if (prim->attributes_count == 0 || prim->indices == 0) { context->required_extension_flags |= CGLTF_EXTENSION_FLAG_DRACO_MESH_COMPRESSION; } cgltf_write_line(context, "\"KHR_draco_mesh_compression\": {"); CGLTF_WRITE_IDXPROP("bufferView", prim->draco_mesh_compression.buffer_view, context->data->buffer_views); cgltf_write_line(context, "\"attributes\": {"); for (cgltf_size i = 0; i < prim->draco_mesh_compression.attributes_count; ++i) { const cgltf_attribute* attr = prim->draco_mesh_compression.attributes + i; CGLTF_WRITE_IDXPROP(attr->name, attr->data, context->data->accessors); } cgltf_write_line(context, "}"); cgltf_write_line(context, "}"); } cgltf_write_line(context, "}"); } } static void cgltf_write_mesh(cgltf_write_context* context, const cgltf_mesh* mesh) { cgltf_write_line(context, "{"); cgltf_write_strprop(context, "name", mesh->name); cgltf_write_line(context, "\"primitives\": ["); for (cgltf_size i = 0; i < mesh->primitives_count; ++i) { cgltf_write_line(context, "{"); cgltf_write_primitive(context, mesh->primitives + i); cgltf_write_line(context, "}"); } cgltf_write_line(context, "]"); if (mesh->weights_count > 0) { cgltf_write_floatarrayprop(context, "weights", mesh->weights, mesh->weights_count); } cgltf_write_extras(context, &mesh->extras); cgltf_write_line(context, "}"); } static void cgltf_write_buffer_view(cgltf_write_context* context, const cgltf_buffer_view* view) { cgltf_write_line(context, "{"); CGLTF_WRITE_IDXPROP("buffer", view->buffer, context->data->buffers); cgltf_write_intprop(context, "byteLength", (int)view->size, -1); cgltf_write_intprop(context, "byteOffset", (int)view->offset, 0); cgltf_write_intprop(context, "byteStride", (int)view->stride, 0); // NOTE: We skip writing "target" because the spec says its usage can be inferred. cgltf_write_extras(context, &view->extras); cgltf_write_line(context, "}"); } static void cgltf_write_buffer(cgltf_write_context* context, const cgltf_buffer* buffer) { cgltf_write_line(context, "{"); cgltf_write_strprop(context, "uri", buffer->uri); cgltf_write_intprop(context, "byteLength", (int)buffer->size, -1); cgltf_write_extras(context, &buffer->extras); cgltf_write_line(context, "}"); } static void cgltf_write_material(cgltf_write_context* context, const cgltf_material* material) { cgltf_write_line(context, "{"); cgltf_write_strprop(context, "name", material->name); cgltf_write_floatprop(context, "alphaCutoff", material->alpha_cutoff, 0.5f); cgltf_write_boolprop_optional(context, "doubleSided", material->double_sided, false); // cgltf_write_boolprop_optional(context, "unlit", material->unlit, false); if (material->unlit) { context->extension_flags |= CGLTF_EXTENSION_FLAG_MATERIALS_UNLIT; } if (material->has_pbr_specular_glossiness) { context->extension_flags |= CGLTF_EXTENSION_FLAG_SPECULAR_GLOSSINESS; } if (material->has_clearcoat) { context->extension_flags |= CGLTF_EXTENSION_FLAG_MATERIALS_CLEARCOAT; } if (material->has_transmission) { context->extension_flags |= CGLTF_EXTENSION_FLAG_MATERIALS_TRANSMISSION; } if (material->has_ior) { context->extension_flags |= CGLTF_EXTENSION_FLAG_MATERIALS_IOR; } if (material->has_specular) { context->extension_flags |= CGLTF_EXTENSION_FLAG_MATERIALS_SPECULAR; } if (material->has_sheen) { context->extension_flags |= CGLTF_EXTENSION_FLAG_MATERIALS_SHEEN; } if (material->has_pbr_metallic_roughness) { const cgltf_pbr_metallic_roughness* params = &material->pbr_metallic_roughness; cgltf_write_line(context, "\"pbrMetallicRoughness\": {"); CGLTF_WRITE_TEXTURE_INFO("baseColorTexture", params->base_color_texture); CGLTF_WRITE_TEXTURE_INFO("metallicRoughnessTexture", params->metallic_roughness_texture); cgltf_write_floatprop(context, "metallicFactor", params->metallic_factor, 1.0f); cgltf_write_floatprop(context, "roughnessFactor", params->roughness_factor, 1.0f); if (cgltf_check_floatarray(params->base_color_factor, 4, 1.0f)) { cgltf_write_floatarrayprop(context, "baseColorFactor", params->base_color_factor, 4); } cgltf_write_extras(context, ¶ms->extras); cgltf_write_line(context, "}"); } if (material->unlit || material->has_pbr_specular_glossiness || material->has_clearcoat || material->has_ior || material->has_specular || material->has_transmission || material->has_sheen) { cgltf_write_line(context, "\"extensions\": {"); if (material->has_clearcoat) { const cgltf_clearcoat* params = &material->clearcoat; cgltf_write_line(context, "\"KHR_materials_clearcoat\": {"); CGLTF_WRITE_TEXTURE_INFO("clearcoatTexture", params->clearcoat_texture); CGLTF_WRITE_TEXTURE_INFO("clearcoatRoughnessTexture", params->clearcoat_roughness_texture); CGLTF_WRITE_TEXTURE_INFO("clearcoatNormalTexture", params->clearcoat_normal_texture); cgltf_write_floatprop(context, "clearcoatFactor", params->clearcoat_factor, 0.0f); cgltf_write_floatprop(context, "clearcoatRoughnessFactor", params->clearcoat_roughness_factor, 0.0f); cgltf_write_line(context, "}"); } if (material->has_ior) { const cgltf_ior* params = &material->ior; cgltf_write_line(context, "\"KHR_materials_ior\": {"); cgltf_write_floatprop(context, "ior", params->ior, 1.5f); cgltf_write_line(context, "}"); } if (material->has_specular) { const cgltf_specular* params = &material->specular; cgltf_write_line(context, "\"KHR_materials_specular\": {"); CGLTF_WRITE_TEXTURE_INFO("specularTexture", params->specular_texture); cgltf_write_floatprop(context, "specularFactor", params->specular_factor, 1.0f); if (cgltf_check_floatarray(params->specular_color_factor, 3, 1.0f)) { cgltf_write_floatarrayprop(context, "specularColorFactor", params->specular_color_factor, 3); } cgltf_write_line(context, "}"); } if (material->has_transmission) { const cgltf_transmission* params = &material->transmission; cgltf_write_line(context, "\"KHR_materials_transmission\": {"); CGLTF_WRITE_TEXTURE_INFO("transmissionTexture", params->transmission_texture); cgltf_write_floatprop(context, "transmissionFactor", params->transmission_factor, 0.0f); cgltf_write_line(context, "}"); } if (material->has_sheen) { const cgltf_sheen* params = &material->sheen; cgltf_write_line(context, "\"KHR_materials_sheen\": {"); CGLTF_WRITE_TEXTURE_INFO("sheenColorTexture", params->sheen_color_texture); CGLTF_WRITE_TEXTURE_INFO("sheenRoughnessTexture", params->sheen_roughness_texture); if (cgltf_check_floatarray(params->sheen_color_factor, 3, 0.0f)) { cgltf_write_floatarrayprop(context, "sheenColorFactor", params->sheen_color_factor, 3); } cgltf_write_floatprop(context, "sheenRoughnessFactor", params->sheen_roughness_factor, 0.0f); cgltf_write_line(context, "}"); } if (material->has_pbr_specular_glossiness) { const cgltf_pbr_specular_glossiness* params = &material->pbr_specular_glossiness; cgltf_write_line(context, "\"KHR_materials_pbrSpecularGlossiness\": {"); CGLTF_WRITE_TEXTURE_INFO("diffuseTexture", params->diffuse_texture); CGLTF_WRITE_TEXTURE_INFO("specularGlossinessTexture", params->specular_glossiness_texture); if (cgltf_check_floatarray(params->diffuse_factor, 4, 1.0f)) { cgltf_write_floatarrayprop(context, "dffuseFactor", params->diffuse_factor, 4); } if (cgltf_check_floatarray(params->specular_factor, 3, 1.0f)) { cgltf_write_floatarrayprop(context, "specularFactor", params->specular_factor, 3); } cgltf_write_floatprop(context, "glossinessFactor", params->glossiness_factor, 1.0f); cgltf_write_line(context, "}"); } if (material->unlit) { cgltf_write_line(context, "\"KHR_materials_unlit\": {}"); } cgltf_write_line(context, "}"); } CGLTF_WRITE_TEXTURE_INFO("normalTexture", material->normal_texture); CGLTF_WRITE_TEXTURE_INFO("occlusionTexture", material->occlusion_texture); CGLTF_WRITE_TEXTURE_INFO("emissiveTexture", material->emissive_texture); if (cgltf_check_floatarray(material->emissive_factor, 3, 0.0f)) { cgltf_write_floatarrayprop(context, "emissiveFactor", material->emissive_factor, 3); } cgltf_write_strprop(context, "alphaMode", cgltf_str_from_alpha_mode(material->alpha_mode)); cgltf_write_extras(context, &material->extras); cgltf_write_line(context, "}"); } static void cgltf_write_image(cgltf_write_context* context, const cgltf_image* image) { cgltf_write_line(context, "{"); cgltf_write_strprop(context, "name", image->name); cgltf_write_strprop(context, "uri", image->uri); CGLTF_WRITE_IDXPROP("bufferView", image->buffer_view, context->data->buffer_views); cgltf_write_strprop(context, "mimeType", image->mime_type); cgltf_write_extras(context, &image->extras); cgltf_write_line(context, "}"); } static void cgltf_write_texture(cgltf_write_context* context, const cgltf_texture* texture) { cgltf_write_line(context, "{"); cgltf_write_strprop(context, "name", texture->name); CGLTF_WRITE_IDXPROP("source", texture->image, context->data->images); CGLTF_WRITE_IDXPROP("sampler", texture->sampler, context->data->samplers); cgltf_write_extras(context, &texture->extras); cgltf_write_line(context, "}"); } static void cgltf_write_skin(cgltf_write_context* context, const cgltf_skin* skin) { cgltf_write_line(context, "{"); CGLTF_WRITE_IDXPROP("skeleton", skin->skeleton, context->data->nodes); CGLTF_WRITE_IDXPROP("inverseBindMatrices", skin->inverse_bind_matrices, context->data->accessors); CGLTF_WRITE_IDXARRPROP("joints", skin->joints_count, skin->joints, context->data->nodes); cgltf_write_strprop(context, "name", skin->name); cgltf_write_extras(context, &skin->extras); cgltf_write_line(context, "}"); } static const char* cgltf_write_str_path_type(cgltf_animation_path_type path_type) { switch (path_type) { case cgltf_animation_path_type_translation: return "translation"; case cgltf_animation_path_type_rotation: return "rotation"; case cgltf_animation_path_type_scale: return "scale"; case cgltf_animation_path_type_weights: return "weights"; case cgltf_animation_path_type_invalid: break; } return "invalid"; } static const char* cgltf_write_str_interpolation_type(cgltf_interpolation_type interpolation_type) { switch (interpolation_type) { case cgltf_interpolation_type_linear: return "LINEAR"; case cgltf_interpolation_type_step: return "STEP"; case cgltf_interpolation_type_cubic_spline: return "CUBICSPLINE"; } return "invalid"; } static void cgltf_write_path_type(cgltf_write_context* context, const char *label, cgltf_animation_path_type path_type) { cgltf_write_strprop(context, label, cgltf_write_str_path_type(path_type)); } static void cgltf_write_interpolation_type(cgltf_write_context* context, const char *label, cgltf_interpolation_type interpolation_type) { cgltf_write_strprop(context, label, cgltf_write_str_interpolation_type(interpolation_type)); } static void cgltf_write_animation_sampler(cgltf_write_context* context, const cgltf_animation_sampler* animation_sampler) { cgltf_write_line(context, "{"); cgltf_write_interpolation_type(context, "interpolation", animation_sampler->interpolation); CGLTF_WRITE_IDXPROP("input", animation_sampler->input, context->data->accessors); CGLTF_WRITE_IDXPROP("output", animation_sampler->output, context->data->accessors); cgltf_write_extras(context, &animation_sampler->extras); cgltf_write_line(context, "}"); } static void cgltf_write_animation_channel(cgltf_write_context* context, const cgltf_animation* animation, const cgltf_animation_channel* animation_channel) { cgltf_write_line(context, "{"); CGLTF_WRITE_IDXPROP("sampler", animation_channel->sampler, animation->samplers); cgltf_write_line(context, "\"target\": {"); CGLTF_WRITE_IDXPROP("node", animation_channel->target_node, context->data->nodes); cgltf_write_path_type(context, "path", animation_channel->target_path); cgltf_write_line(context, "}"); cgltf_write_extras(context, &animation_channel->extras); cgltf_write_line(context, "}"); } static void cgltf_write_animation(cgltf_write_context* context, const cgltf_animation* animation) { cgltf_write_line(context, "{"); cgltf_write_strprop(context, "name", animation->name); if (animation->samplers_count > 0) { cgltf_write_line(context, "\"samplers\": ["); for (cgltf_size i = 0; i < animation->samplers_count; ++i) { cgltf_write_animation_sampler(context, animation->samplers + i); } cgltf_write_line(context, "]"); } if (animation->channels_count > 0) { cgltf_write_line(context, "\"channels\": ["); for (cgltf_size i = 0; i < animation->channels_count; ++i) { cgltf_write_animation_channel(context, animation, animation->channels + i); } cgltf_write_line(context, "]"); } cgltf_write_extras(context, &animation->extras); cgltf_write_line(context, "}"); } static void cgltf_write_sampler(cgltf_write_context* context, const cgltf_sampler* sampler) { cgltf_write_line(context, "{"); cgltf_write_intprop(context, "magFilter", sampler->mag_filter, 0); cgltf_write_intprop(context, "minFilter", sampler->min_filter, 0); cgltf_write_intprop(context, "wrapS", sampler->wrap_s, 10497); cgltf_write_intprop(context, "wrapT", sampler->wrap_t, 10497); cgltf_write_extras(context, &sampler->extras); cgltf_write_line(context, "}"); } static void cgltf_write_node(cgltf_write_context* context, const cgltf_node* node) { cgltf_write_line(context, "{"); CGLTF_WRITE_IDXARRPROP("children", node->children_count, node->children, context->data->nodes); CGLTF_WRITE_IDXPROP("mesh", node->mesh, context->data->meshes); cgltf_write_strprop(context, "name", node->name); if (node->has_matrix) { cgltf_write_floatarrayprop(context, "matrix", node->matrix, 16); } if (node->has_translation) { cgltf_write_floatarrayprop(context, "translation", node->translation, 3); } if (node->has_rotation) { cgltf_write_floatarrayprop(context, "rotation", node->rotation, 4); } if (node->has_scale) { cgltf_write_floatarrayprop(context, "scale", node->scale, 3); } if (node->skin) { CGLTF_WRITE_IDXPROP("skin", node->skin, context->data->skins); } if (node->light) { context->extension_flags |= CGLTF_EXTENSION_FLAG_LIGHTS_PUNCTUAL; cgltf_write_line(context, "\"extensions\": {"); cgltf_write_line(context, "\"KHR_lights_punctual\": {"); CGLTF_WRITE_IDXPROP("light", node->light, context->data->lights); cgltf_write_line(context, "}"); cgltf_write_line(context, "}"); } if (node->weights_count > 0) { cgltf_write_floatarrayprop(context, "weights", node->weights, node->weights_count); } if (node->camera) { CGLTF_WRITE_IDXPROP("camera", node->camera, context->data->cameras); } cgltf_write_extras(context, &node->extras); cgltf_write_line(context, "}"); } static void cgltf_write_scene(cgltf_write_context* context, const cgltf_scene* scene) { cgltf_write_line(context, "{"); cgltf_write_strprop(context, "name", scene->name); CGLTF_WRITE_IDXARRPROP("nodes", scene->nodes_count, scene->nodes, context->data->nodes); cgltf_write_extras(context, &scene->extras); cgltf_write_line(context, "}"); } static void cgltf_write_accessor(cgltf_write_context* context, const cgltf_accessor* accessor) { cgltf_write_line(context, "{"); CGLTF_WRITE_IDXPROP("bufferView", accessor->buffer_view, context->data->buffer_views); cgltf_write_intprop(context, "componentType", cgltf_int_from_component_type(accessor->component_type), 0); cgltf_write_strprop(context, "type", cgltf_str_from_type(accessor->type)); cgltf_size dim = cgltf_dim_from_type(accessor->type); cgltf_write_boolprop_optional(context, "normalized", accessor->normalized, false); cgltf_write_intprop(context, "byteOffset", (int)accessor->offset, 0); cgltf_write_intprop(context, "count", (int)accessor->count, -1); if (accessor->has_min) { cgltf_write_floatarrayprop(context, "min", accessor->min, dim); } if (accessor->has_max) { cgltf_write_floatarrayprop(context, "max", accessor->max, dim); } if (accessor->is_sparse) { cgltf_write_line(context, "\"sparse\": {"); cgltf_write_intprop(context, "count", (int)accessor->sparse.count, 0); cgltf_write_line(context, "\"indices\": {"); cgltf_write_intprop(context, "byteOffset", (int)accessor->sparse.indices_byte_offset, 0); CGLTF_WRITE_IDXPROP("bufferView", accessor->sparse.indices_buffer_view, context->data->buffer_views); cgltf_write_intprop(context, "componentType", cgltf_int_from_component_type(accessor->sparse.indices_component_type), 0); cgltf_write_extras(context, &accessor->sparse.indices_extras); cgltf_write_line(context, "}"); cgltf_write_line(context, "\"values\": {"); cgltf_write_intprop(context, "byteOffset", (int)accessor->sparse.values_byte_offset, 0); CGLTF_WRITE_IDXPROP("bufferView", accessor->sparse.values_buffer_view, context->data->buffer_views); cgltf_write_extras(context, &accessor->sparse.values_extras); cgltf_write_line(context, "}"); cgltf_write_extras(context, &accessor->sparse.extras); cgltf_write_line(context, "}"); } cgltf_write_extras(context, &accessor->extras); cgltf_write_line(context, "}"); } static void cgltf_write_camera(cgltf_write_context* context, const cgltf_camera* camera) { cgltf_write_line(context, "{"); cgltf_write_strprop(context, "type", cgltf_str_from_camera_type(camera->type)); if (camera->name) { cgltf_write_strprop(context, "name", camera->name); } if (camera->type == cgltf_camera_type_orthographic) { cgltf_write_line(context, "\"orthographic\": {"); cgltf_write_floatprop(context, "xmag", camera->data.orthographic.xmag, -1.0f); cgltf_write_floatprop(context, "ymag", camera->data.orthographic.ymag, -1.0f); cgltf_write_floatprop(context, "zfar", camera->data.orthographic.zfar, -1.0f); cgltf_write_floatprop(context, "znear", camera->data.orthographic.znear, -1.0f); cgltf_write_extras(context, &camera->data.orthographic.extras); cgltf_write_line(context, "}"); } else if (camera->type == cgltf_camera_type_perspective) { cgltf_write_line(context, "\"perspective\": {"); cgltf_write_floatprop(context, "aspectRatio", camera->data.perspective.aspect_ratio, -1.0f); cgltf_write_floatprop(context, "yfov", camera->data.perspective.yfov, -1.0f); cgltf_write_floatprop(context, "zfar", camera->data.perspective.zfar, -1.0f); cgltf_write_floatprop(context, "znear", camera->data.perspective.znear, -1.0f); cgltf_write_extras(context, &camera->data.perspective.extras); cgltf_write_line(context, "}"); } cgltf_write_extras(context, &camera->extras); cgltf_write_line(context, "}"); } static void cgltf_write_light(cgltf_write_context* context, const cgltf_light* light) { cgltf_write_line(context, "{"); cgltf_write_strprop(context, "type", cgltf_str_from_light_type(light->type)); if (light->name) { cgltf_write_strprop(context, "name", light->name); } if (cgltf_check_floatarray(light->color, 3, 1.0f)) { cgltf_write_floatarrayprop(context, "color", light->color, 3); } cgltf_write_floatprop(context, "intensity", light->intensity, 1.0f); cgltf_write_floatprop(context, "range", light->range, 0.0f); if (light->type == cgltf_light_type_spot) { cgltf_write_line(context, "\"spot\": {"); cgltf_write_floatprop(context, "innerConeAngle", light->spot_inner_cone_angle, 0.0f); cgltf_write_floatprop(context, "outerConeAngle", light->spot_outer_cone_angle, 3.14159265358979323846f/4.0f); cgltf_write_line(context, "}"); } cgltf_write_line(context, "}"); } cgltf_result cgltf_write_file(const cgltf_options* options, const char* path, const cgltf_data* data) { cgltf_size expected = cgltf_write(options, NULL, 0, data); char* buffer = (char*) malloc(expected); cgltf_size actual = cgltf_write(options, buffer, expected, data); if (expected != actual) { fprintf(stderr, "Error: expected %zu bytes but wrote %zu bytes.\n", expected, actual); } FILE* file = fopen(path, "wt"); if (!file) { return cgltf_result_file_not_found; } // Note that cgltf_write() includes a null terminator, which we omit from the file content. fwrite(buffer, actual - 1, 1, file); fclose(file); free(buffer); return cgltf_result_success; } static void cgltf_write_extensions(cgltf_write_context* context, uint32_t extension_flags) { if (extension_flags & CGLTF_EXTENSION_FLAG_TEXTURE_TRANSFORM) { cgltf_write_stritem(context, "KHR_texture_transform"); } if (extension_flags & CGLTF_EXTENSION_FLAG_MATERIALS_UNLIT) { cgltf_write_stritem(context, "KHR_materials_unlit"); } if (extension_flags & CGLTF_EXTENSION_FLAG_SPECULAR_GLOSSINESS) { cgltf_write_stritem(context, "KHR_materials_pbrSpecularGlossiness"); } if (extension_flags & CGLTF_EXTENSION_FLAG_LIGHTS_PUNCTUAL) { cgltf_write_stritem(context, "KHR_lights_punctual"); } if (extension_flags & CGLTF_EXTENSION_FLAG_DRACO_MESH_COMPRESSION) { cgltf_write_stritem(context, "KHR_draco_mesh_compression"); } if (extension_flags & CGLTF_EXTENSION_FLAG_MATERIALS_CLEARCOAT) { cgltf_write_stritem(context, "KHR_materials_clearcoat"); } if (extension_flags & CGLTF_EXTENSION_FLAG_MATERIALS_IOR) { cgltf_write_stritem(context, "KHR_materials_ior"); } if (extension_flags & CGLTF_EXTENSION_FLAG_MATERIALS_SPECULAR) { cgltf_write_stritem(context, "KHR_materials_specular"); } if (extension_flags & CGLTF_EXTENSION_FLAG_MATERIALS_TRANSMISSION) { cgltf_write_stritem(context, "KHR_materials_transmission"); } if (extension_flags & CGLTF_EXTENSION_FLAG_MATERIALS_SHEEN) { cgltf_write_stritem(context, "KHR_materials_sheen"); } } cgltf_size cgltf_write(const cgltf_options* options, char* buffer, cgltf_size size, const cgltf_data* data) { (void)options; cgltf_write_context ctx; ctx.buffer = buffer; ctx.buffer_size = size; ctx.remaining = size; ctx.cursor = buffer; ctx.chars_written = 0; ctx.data = data; ctx.depth = 1; ctx.indent = " "; ctx.needs_comma = 0; ctx.extension_flags = 0; ctx.required_extension_flags = 0; cgltf_write_context* context = &ctx; CGLTF_SPRINTF("{"); if (data->accessors_count > 0) { cgltf_write_line(context, "\"accessors\": ["); for (cgltf_size i = 0; i < data->accessors_count; ++i) { cgltf_write_accessor(context, data->accessors + i); } cgltf_write_line(context, "]"); } cgltf_write_asset(context, &data->asset); if (data->buffer_views_count > 0) { cgltf_write_line(context, "\"bufferViews\": ["); for (cgltf_size i = 0; i < data->buffer_views_count; ++i) { cgltf_write_buffer_view(context, data->buffer_views + i); } cgltf_write_line(context, "]"); } if (data->buffers_count > 0) { cgltf_write_line(context, "\"buffers\": ["); for (cgltf_size i = 0; i < data->buffers_count; ++i) { cgltf_write_buffer(context, data->buffers + i); } cgltf_write_line(context, "]"); } if (data->images_count > 0) { cgltf_write_line(context, "\"images\": ["); for (cgltf_size i = 0; i < data->images_count; ++i) { cgltf_write_image(context, data->images + i); } cgltf_write_line(context, "]"); } if (data->meshes_count > 0) { cgltf_write_line(context, "\"meshes\": ["); for (cgltf_size i = 0; i < data->meshes_count; ++i) { cgltf_write_mesh(context, data->meshes + i); } cgltf_write_line(context, "]"); } if (data->materials_count > 0) { cgltf_write_line(context, "\"materials\": ["); for (cgltf_size i = 0; i < data->materials_count; ++i) { cgltf_write_material(context, data->materials + i); } cgltf_write_line(context, "]"); } if (data->nodes_count > 0) { cgltf_write_line(context, "\"nodes\": ["); for (cgltf_size i = 0; i < data->nodes_count; ++i) { cgltf_write_node(context, data->nodes + i); } cgltf_write_line(context, "]"); } if (data->samplers_count > 0) { cgltf_write_line(context, "\"samplers\": ["); for (cgltf_size i = 0; i < data->samplers_count; ++i) { cgltf_write_sampler(context, data->samplers + i); } cgltf_write_line(context, "]"); } CGLTF_WRITE_IDXPROP("scene", data->scene, data->scenes); if (data->scenes_count > 0) { cgltf_write_line(context, "\"scenes\": ["); for (cgltf_size i = 0; i < data->scenes_count; ++i) { cgltf_write_scene(context, data->scenes + i); } cgltf_write_line(context, "]"); } if (data->textures_count > 0) { cgltf_write_line(context, "\"textures\": ["); for (cgltf_size i = 0; i < data->textures_count; ++i) { cgltf_write_texture(context, data->textures + i); } cgltf_write_line(context, "]"); } if (data->skins_count > 0) { cgltf_write_line(context, "\"skins\": ["); for (cgltf_size i = 0; i < data->skins_count; ++i) { cgltf_write_skin(context, data->skins + i); } cgltf_write_line(context, "]"); } if (data->animations_count > 0) { cgltf_write_line(context, "\"animations\": ["); for (cgltf_size i = 0; i < data->animations_count; ++i) { cgltf_write_animation(context, data->animations + i); } cgltf_write_line(context, "]"); } if (data->cameras_count > 0) { cgltf_write_line(context, "\"cameras\": ["); for (cgltf_size i = 0; i < data->cameras_count; ++i) { cgltf_write_camera(context, data->cameras + i); } cgltf_write_line(context, "]"); } if (data->lights_count > 0) { cgltf_write_line(context, "\"extensions\": {"); cgltf_write_line(context, "\"KHR_lights_punctual\": {"); cgltf_write_line(context, "\"lights\": ["); for (cgltf_size i = 0; i < data->lights_count; ++i) { cgltf_write_light(context, data->lights + i); } cgltf_write_line(context, "]"); cgltf_write_line(context, "}"); cgltf_write_line(context, "}"); } if (context->extension_flags != 0) { cgltf_write_line(context, "\"extensionsUsed\": ["); cgltf_write_extensions(context, context->extension_flags); cgltf_write_line(context, "]"); } if (context->required_extension_flags != 0) { cgltf_write_line(context, "\"extensionsRequired\": ["); cgltf_write_extensions(context, context->required_extension_flags); cgltf_write_line(context, "]"); } cgltf_write_extras(context, &data->extras); CGLTF_SPRINTF("\n}\n"); // snprintf does not include the null terminator in its return value, so be sure to include it // in the returned byte count. return 1 + ctx.chars_written; } #endif /* #ifdef CGLTF_WRITE_IMPLEMENTATION */ /* cgltf is distributed under MIT license: * * Copyright (c) 2019 Philip Rideout * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ goxel-0.11.0/ext_src/glew/000077500000000000000000000000001435762723100153265ustar00rootroot00000000000000goxel-0.11.0/ext_src/glew/GL/000077500000000000000000000000001435762723100156305ustar00rootroot00000000000000goxel-0.11.0/ext_src/glew/GL/glew.h000066400000000000000000037543421435762723100167610ustar00rootroot00000000000000/* ** The OpenGL Extension Wrangler Library ** Copyright (C) 2008-2015, Nigel Stewart ** Copyright (C) 2002-2008, Milan Ikits ** Copyright (C) 2002-2008, Marcelo E. Magallon ** Copyright (C) 2002, Lev Povalahev ** 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. ** * The name of the author may be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** 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 OWNER 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. */ /* * Mesa 3-D graphics library * Version: 7.0 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* ** Copyright (c) 2007 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 __glew_h__ #define __glew_h__ #define __GLEW_H__ #if defined(__gl_h_) || defined(__GL_H__) || defined(_GL_H) || defined(__X_GL_H) #error gl.h included before glew.h #endif #if defined(__gl2_h_) #error gl2.h included before glew.h #endif #if defined(__gltypes_h_) #error gltypes.h included before glew.h #endif #if defined(__REGAL_H__) #error Regal.h included before glew.h #endif #if defined(__glext_h_) || defined(__GLEXT_H_) #error glext.h included before glew.h #endif #if defined(__gl_ATI_h_) #error glATI.h included before glew.h #endif #define __gl_h_ #define __gl2_h_ #define __GL_H__ #define _GL_H #define __gltypes_h_ #define __REGAL_H__ #define __X_GL_H #define __glext_h_ #define __GLEXT_H_ #define __gl_ATI_h_ #if defined(_WIN32) /* * GLEW does not include to avoid name space pollution. * GL needs GLAPI and GLAPIENTRY, GLU needs APIENTRY, CALLBACK, and wchar_t * defined properly. */ /* and */ #ifdef APIENTRY # ifndef GLAPIENTRY # define GLAPIENTRY APIENTRY # endif # ifndef GLEWAPIENTRY # define GLEWAPIENTRY APIENTRY # endif #else #define GLEW_APIENTRY_DEFINED # if defined(__MINGW32__) || defined(__CYGWIN__) || (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) # define APIENTRY __stdcall # ifndef GLAPIENTRY # define GLAPIENTRY __stdcall # endif # ifndef GLEWAPIENTRY # define GLEWAPIENTRY __stdcall # endif # else # define APIENTRY # endif #endif #ifndef GLAPI # if defined(__MINGW32__) || defined(__CYGWIN__) # define GLAPI extern # endif #endif /* */ #ifndef CALLBACK #define GLEW_CALLBACK_DEFINED # if defined(__MINGW32__) || defined(__CYGWIN__) # define CALLBACK __attribute__ ((__stdcall__)) # elif (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) # define CALLBACK __stdcall # else # define CALLBACK # endif #endif /* and */ #ifndef WINGDIAPI #define GLEW_WINGDIAPI_DEFINED #define WINGDIAPI __declspec(dllimport) #endif /* */ #if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(_WCHAR_T_DEFINED) typedef unsigned short wchar_t; # define _WCHAR_T_DEFINED #endif /* */ #if !defined(_W64) # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && defined(_MSC_VER) && _MSC_VER >= 1300 # define _W64 __w64 # else # define _W64 # endif #endif #if !defined(_PTRDIFF_T_DEFINED) && !defined(_PTRDIFF_T_) && !defined(__MINGW64__) # ifdef _WIN64 typedef __int64 ptrdiff_t; # else typedef _W64 int ptrdiff_t; # endif # define _PTRDIFF_T_DEFINED # define _PTRDIFF_T_ #endif #ifndef GLAPI # if defined(__MINGW32__) || defined(__CYGWIN__) # define GLAPI extern # else # define GLAPI WINGDIAPI # endif #endif /* * GLEW_STATIC is defined for static library. * GLEW_BUILD is defined for building the DLL library. */ #ifdef GLEW_STATIC # define GLEWAPI extern #else # ifdef GLEW_BUILD # define GLEWAPI extern __declspec(dllexport) # else # define GLEWAPI extern __declspec(dllimport) # endif #endif #else /* _UNIX */ /* * Needed for ptrdiff_t in turn needed by VBO. This is defined by ISO * C. On my system, this amounts to _3 lines_ of included code, all of * them pretty much harmless. If you know of a way of detecting 32 vs * 64 _targets_ at compile time you are free to replace this with * something that's portable. For now, _this_ is the portable solution. * (mem, 2004-01-04) */ #include /* SGI MIPSPro doesn't like stdint.h in C++ mode */ /* ID: 3376260 Solaris 9 has inttypes.h, but not stdint.h */ #if (defined(__sgi) || defined(__sun)) && !defined(__GNUC__) #include #else #include #endif #define GLEW_APIENTRY_DEFINED #define APIENTRY /* * GLEW_STATIC is defined for static library. */ #ifdef GLEW_STATIC # define GLEWAPI extern #else # if defined(__GNUC__) && __GNUC__>=4 # define GLEWAPI extern __attribute__ ((visibility("default"))) # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) # define GLEWAPI extern __global # else # define GLEWAPI extern # endif #endif /* */ #ifndef GLAPI #define GLAPI extern #endif #endif /* _WIN32 */ #ifndef GLAPIENTRY #define GLAPIENTRY #endif #ifndef GLEWAPIENTRY #define GLEWAPIENTRY #endif #ifdef __cplusplus extern "C" { #endif /* ----------------------------- GL_VERSION_1_1 ---------------------------- */ #ifndef GL_VERSION_1_1 #define GL_VERSION_1_1 1 typedef unsigned int GLenum; typedef unsigned int GLbitfield; typedef unsigned int GLuint; typedef int GLint; typedef int GLsizei; typedef unsigned char GLboolean; typedef signed char GLbyte; typedef short GLshort; typedef unsigned char GLubyte; typedef unsigned short GLushort; typedef unsigned long GLulong; typedef float GLfloat; typedef float GLclampf; typedef double GLdouble; typedef double GLclampd; typedef void GLvoid; #if defined(_MSC_VER) && _MSC_VER < 1400 typedef __int64 GLint64EXT; typedef unsigned __int64 GLuint64EXT; #elif defined(_MSC_VER) || defined(__BORLANDC__) typedef signed long long GLint64EXT; typedef unsigned long long GLuint64EXT; #else # if defined(__MINGW32__) || defined(__CYGWIN__) #include # endif typedef int64_t GLint64EXT; typedef uint64_t GLuint64EXT; #endif typedef GLint64EXT GLint64; typedef GLuint64EXT GLuint64; typedef struct __GLsync *GLsync; typedef char GLchar; #define GL_ZERO 0 #define GL_FALSE 0 #define GL_LOGIC_OP 0x0BF1 #define GL_NONE 0 #define GL_TEXTURE_COMPONENTS 0x1003 #define GL_NO_ERROR 0 #define GL_POINTS 0x0000 #define GL_CURRENT_BIT 0x00000001 #define GL_TRUE 1 #define GL_ONE 1 #define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 #define GL_LINES 0x0001 #define GL_LINE_LOOP 0x0002 #define GL_POINT_BIT 0x00000002 #define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 #define GL_LINE_STRIP 0x0003 #define GL_LINE_BIT 0x00000004 #define GL_TRIANGLES 0x0004 #define GL_TRIANGLE_STRIP 0x0005 #define GL_TRIANGLE_FAN 0x0006 #define GL_QUADS 0x0007 #define GL_QUAD_STRIP 0x0008 #define GL_POLYGON_BIT 0x00000008 #define GL_POLYGON 0x0009 #define GL_POLYGON_STIPPLE_BIT 0x00000010 #define GL_PIXEL_MODE_BIT 0x00000020 #define GL_LIGHTING_BIT 0x00000040 #define GL_FOG_BIT 0x00000080 #define GL_DEPTH_BUFFER_BIT 0x00000100 #define GL_ACCUM 0x0100 #define GL_LOAD 0x0101 #define GL_RETURN 0x0102 #define GL_MULT 0x0103 #define GL_ADD 0x0104 #define GL_NEVER 0x0200 #define GL_ACCUM_BUFFER_BIT 0x00000200 #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 #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 #define GL_DST_COLOR 0x0306 #define GL_ONE_MINUS_DST_COLOR 0x0307 #define GL_SRC_ALPHA_SATURATE 0x0308 #define GL_STENCIL_BUFFER_BIT 0x00000400 #define GL_FRONT_LEFT 0x0400 #define GL_FRONT_RIGHT 0x0401 #define GL_BACK_LEFT 0x0402 #define GL_BACK_RIGHT 0x0403 #define GL_FRONT 0x0404 #define GL_BACK 0x0405 #define GL_LEFT 0x0406 #define GL_RIGHT 0x0407 #define GL_FRONT_AND_BACK 0x0408 #define GL_AUX0 0x0409 #define GL_AUX1 0x040A #define GL_AUX2 0x040B #define GL_AUX3 0x040C #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 #define GL_2D 0x0600 #define GL_3D 0x0601 #define GL_3D_COLOR 0x0602 #define GL_3D_COLOR_TEXTURE 0x0603 #define GL_4D_COLOR_TEXTURE 0x0604 #define GL_PASS_THROUGH_TOKEN 0x0700 #define GL_POINT_TOKEN 0x0701 #define GL_LINE_TOKEN 0x0702 #define GL_POLYGON_TOKEN 0x0703 #define GL_BITMAP_TOKEN 0x0704 #define GL_DRAW_PIXEL_TOKEN 0x0705 #define GL_COPY_PIXEL_TOKEN 0x0706 #define GL_LINE_RESET_TOKEN 0x0707 #define GL_EXP 0x0800 #define GL_VIEWPORT_BIT 0x00000800 #define GL_EXP2 0x0801 #define GL_CW 0x0900 #define GL_CCW 0x0901 #define GL_COEFF 0x0A00 #define GL_ORDER 0x0A01 #define GL_DOMAIN 0x0A02 #define GL_CURRENT_COLOR 0x0B00 #define GL_CURRENT_INDEX 0x0B01 #define GL_CURRENT_NORMAL 0x0B02 #define GL_CURRENT_TEXTURE_COORDS 0x0B03 #define GL_CURRENT_RASTER_COLOR 0x0B04 #define GL_CURRENT_RASTER_INDEX 0x0B05 #define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 #define GL_CURRENT_RASTER_POSITION 0x0B07 #define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 #define GL_CURRENT_RASTER_DISTANCE 0x0B09 #define GL_POINT_SMOOTH 0x0B10 #define GL_POINT_SIZE 0x0B11 #define GL_POINT_SIZE_RANGE 0x0B12 #define GL_POINT_SIZE_GRANULARITY 0x0B13 #define GL_LINE_SMOOTH 0x0B20 #define GL_LINE_WIDTH 0x0B21 #define GL_LINE_WIDTH_RANGE 0x0B22 #define GL_LINE_WIDTH_GRANULARITY 0x0B23 #define GL_LINE_STIPPLE 0x0B24 #define GL_LINE_STIPPLE_PATTERN 0x0B25 #define GL_LINE_STIPPLE_REPEAT 0x0B26 #define GL_LIST_MODE 0x0B30 #define GL_MAX_LIST_NESTING 0x0B31 #define GL_LIST_BASE 0x0B32 #define GL_LIST_INDEX 0x0B33 #define GL_POLYGON_MODE 0x0B40 #define GL_POLYGON_SMOOTH 0x0B41 #define GL_POLYGON_STIPPLE 0x0B42 #define GL_EDGE_FLAG 0x0B43 #define GL_CULL_FACE 0x0B44 #define GL_CULL_FACE_MODE 0x0B45 #define GL_FRONT_FACE 0x0B46 #define GL_LIGHTING 0x0B50 #define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 #define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 #define GL_LIGHT_MODEL_AMBIENT 0x0B53 #define GL_SHADE_MODEL 0x0B54 #define GL_COLOR_MATERIAL_FACE 0x0B55 #define GL_COLOR_MATERIAL_PARAMETER 0x0B56 #define GL_COLOR_MATERIAL 0x0B57 #define GL_FOG 0x0B60 #define GL_FOG_INDEX 0x0B61 #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 #define GL_DEPTH_RANGE 0x0B70 #define GL_DEPTH_TEST 0x0B71 #define GL_DEPTH_WRITEMASK 0x0B72 #define GL_DEPTH_CLEAR_VALUE 0x0B73 #define GL_DEPTH_FUNC 0x0B74 #define GL_ACCUM_CLEAR_VALUE 0x0B80 #define GL_STENCIL_TEST 0x0B90 #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_NORMALIZE 0x0BA1 #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_ATTRIB_STACK_DEPTH 0x0BB0 #define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 #define GL_ALPHA_TEST 0x0BC0 #define GL_ALPHA_TEST_FUNC 0x0BC1 #define GL_ALPHA_TEST_REF 0x0BC2 #define GL_DITHER 0x0BD0 #define GL_BLEND_DST 0x0BE0 #define GL_BLEND_SRC 0x0BE1 #define GL_BLEND 0x0BE2 #define GL_LOGIC_OP_MODE 0x0BF0 #define GL_INDEX_LOGIC_OP 0x0BF1 #define GL_COLOR_LOGIC_OP 0x0BF2 #define GL_AUX_BUFFERS 0x0C00 #define GL_DRAW_BUFFER 0x0C01 #define GL_READ_BUFFER 0x0C02 #define GL_SCISSOR_BOX 0x0C10 #define GL_SCISSOR_TEST 0x0C11 #define GL_INDEX_CLEAR_VALUE 0x0C20 #define GL_INDEX_WRITEMASK 0x0C21 #define GL_COLOR_CLEAR_VALUE 0x0C22 #define GL_COLOR_WRITEMASK 0x0C23 #define GL_INDEX_MODE 0x0C30 #define GL_RGBA_MODE 0x0C31 #define GL_DOUBLEBUFFER 0x0C32 #define GL_STEREO 0x0C33 #define GL_RENDER_MODE 0x0C40 #define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 #define GL_POINT_SMOOTH_HINT 0x0C51 #define GL_LINE_SMOOTH_HINT 0x0C52 #define GL_POLYGON_SMOOTH_HINT 0x0C53 #define GL_FOG_HINT 0x0C54 #define GL_TEXTURE_GEN_S 0x0C60 #define GL_TEXTURE_GEN_T 0x0C61 #define GL_TEXTURE_GEN_R 0x0C62 #define GL_TEXTURE_GEN_Q 0x0C63 #define GL_PIXEL_MAP_I_TO_I 0x0C70 #define GL_PIXEL_MAP_S_TO_S 0x0C71 #define GL_PIXEL_MAP_I_TO_R 0x0C72 #define GL_PIXEL_MAP_I_TO_G 0x0C73 #define GL_PIXEL_MAP_I_TO_B 0x0C74 #define GL_PIXEL_MAP_I_TO_A 0x0C75 #define GL_PIXEL_MAP_R_TO_R 0x0C76 #define GL_PIXEL_MAP_G_TO_G 0x0C77 #define GL_PIXEL_MAP_B_TO_B 0x0C78 #define GL_PIXEL_MAP_A_TO_A 0x0C79 #define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 #define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 #define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 #define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 #define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 #define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 #define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 #define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 #define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 #define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 #define GL_UNPACK_SWAP_BYTES 0x0CF0 #define GL_UNPACK_LSB_FIRST 0x0CF1 #define GL_UNPACK_ROW_LENGTH 0x0CF2 #define GL_UNPACK_SKIP_ROWS 0x0CF3 #define GL_UNPACK_SKIP_PIXELS 0x0CF4 #define GL_UNPACK_ALIGNMENT 0x0CF5 #define GL_PACK_SWAP_BYTES 0x0D00 #define GL_PACK_LSB_FIRST 0x0D01 #define GL_PACK_ROW_LENGTH 0x0D02 #define GL_PACK_SKIP_ROWS 0x0D03 #define GL_PACK_SKIP_PIXELS 0x0D04 #define GL_PACK_ALIGNMENT 0x0D05 #define GL_MAP_COLOR 0x0D10 #define GL_MAP_STENCIL 0x0D11 #define GL_INDEX_SHIFT 0x0D12 #define GL_INDEX_OFFSET 0x0D13 #define GL_RED_SCALE 0x0D14 #define GL_RED_BIAS 0x0D15 #define GL_ZOOM_X 0x0D16 #define GL_ZOOM_Y 0x0D17 #define GL_GREEN_SCALE 0x0D18 #define GL_GREEN_BIAS 0x0D19 #define GL_BLUE_SCALE 0x0D1A #define GL_BLUE_BIAS 0x0D1B #define GL_ALPHA_SCALE 0x0D1C #define GL_ALPHA_BIAS 0x0D1D #define GL_DEPTH_SCALE 0x0D1E #define GL_DEPTH_BIAS 0x0D1F #define GL_MAX_EVAL_ORDER 0x0D30 #define GL_MAX_LIGHTS 0x0D31 #define GL_MAX_CLIP_PLANES 0x0D32 #define GL_MAX_TEXTURE_SIZE 0x0D33 #define GL_MAX_PIXEL_MAP_TABLE 0x0D34 #define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 #define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 #define GL_MAX_NAME_STACK_DEPTH 0x0D37 #define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 #define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 #define GL_MAX_VIEWPORT_DIMS 0x0D3A #define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B #define GL_SUBPIXEL_BITS 0x0D50 #define GL_INDEX_BITS 0x0D51 #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_ACCUM_RED_BITS 0x0D58 #define GL_ACCUM_GREEN_BITS 0x0D59 #define GL_ACCUM_BLUE_BITS 0x0D5A #define GL_ACCUM_ALPHA_BITS 0x0D5B #define GL_NAME_STACK_DEPTH 0x0D70 #define GL_AUTO_NORMAL 0x0D80 #define GL_MAP1_COLOR_4 0x0D90 #define GL_MAP1_INDEX 0x0D91 #define GL_MAP1_NORMAL 0x0D92 #define GL_MAP1_TEXTURE_COORD_1 0x0D93 #define GL_MAP1_TEXTURE_COORD_2 0x0D94 #define GL_MAP1_TEXTURE_COORD_3 0x0D95 #define GL_MAP1_TEXTURE_COORD_4 0x0D96 #define GL_MAP1_VERTEX_3 0x0D97 #define GL_MAP1_VERTEX_4 0x0D98 #define GL_MAP2_COLOR_4 0x0DB0 #define GL_MAP2_INDEX 0x0DB1 #define GL_MAP2_NORMAL 0x0DB2 #define GL_MAP2_TEXTURE_COORD_1 0x0DB3 #define GL_MAP2_TEXTURE_COORD_2 0x0DB4 #define GL_MAP2_TEXTURE_COORD_3 0x0DB5 #define GL_MAP2_TEXTURE_COORD_4 0x0DB6 #define GL_MAP2_VERTEX_3 0x0DB7 #define GL_MAP2_VERTEX_4 0x0DB8 #define GL_MAP1_GRID_DOMAIN 0x0DD0 #define GL_MAP1_GRID_SEGMENTS 0x0DD1 #define GL_MAP2_GRID_DOMAIN 0x0DD2 #define GL_MAP2_GRID_SEGMENTS 0x0DD3 #define GL_TEXTURE_1D 0x0DE0 #define GL_TEXTURE_2D 0x0DE1 #define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 #define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 #define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 #define GL_SELECTION_BUFFER_POINTER 0x0DF3 #define GL_SELECTION_BUFFER_SIZE 0x0DF4 #define GL_TEXTURE_WIDTH 0x1000 #define GL_TRANSFORM_BIT 0x00001000 #define GL_TEXTURE_HEIGHT 0x1001 #define GL_TEXTURE_INTERNAL_FORMAT 0x1003 #define GL_TEXTURE_BORDER_COLOR 0x1004 #define GL_TEXTURE_BORDER 0x1005 #define GL_DONT_CARE 0x1100 #define GL_FASTEST 0x1101 #define GL_NICEST 0x1102 #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 #define GL_COMPILE 0x1300 #define GL_COMPILE_AND_EXECUTE 0x1301 #define GL_BYTE 0x1400 #define GL_UNSIGNED_BYTE 0x1401 #define GL_SHORT 0x1402 #define GL_UNSIGNED_SHORT 0x1403 #define GL_INT 0x1404 #define GL_UNSIGNED_INT 0x1405 #define GL_FLOAT 0x1406 #define GL_2_BYTES 0x1407 #define GL_3_BYTES 0x1408 #define GL_4_BYTES 0x1409 #define GL_DOUBLE 0x140A #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 #define GL_EMISSION 0x1600 #define GL_SHININESS 0x1601 #define GL_AMBIENT_AND_DIFFUSE 0x1602 #define GL_COLOR_INDEXES 0x1603 #define GL_MODELVIEW 0x1700 #define GL_PROJECTION 0x1701 #define GL_TEXTURE 0x1702 #define GL_COLOR 0x1800 #define GL_DEPTH 0x1801 #define GL_STENCIL 0x1802 #define GL_COLOR_INDEX 0x1900 #define GL_STENCIL_INDEX 0x1901 #define GL_DEPTH_COMPONENT 0x1902 #define GL_RED 0x1903 #define GL_GREEN 0x1904 #define GL_BLUE 0x1905 #define GL_ALPHA 0x1906 #define GL_RGB 0x1907 #define GL_RGBA 0x1908 #define GL_LUMINANCE 0x1909 #define GL_LUMINANCE_ALPHA 0x190A #define GL_BITMAP 0x1A00 #define GL_POINT 0x1B00 #define GL_LINE 0x1B01 #define GL_FILL 0x1B02 #define GL_RENDER 0x1C00 #define GL_FEEDBACK 0x1C01 #define GL_SELECT 0x1C02 #define GL_FLAT 0x1D00 #define GL_SMOOTH 0x1D01 #define GL_KEEP 0x1E00 #define GL_REPLACE 0x1E01 #define GL_INCR 0x1E02 #define GL_DECR 0x1E03 #define GL_VENDOR 0x1F00 #define GL_RENDERER 0x1F01 #define GL_VERSION 0x1F02 #define GL_EXTENSIONS 0x1F03 #define GL_S 0x2000 #define GL_ENABLE_BIT 0x00002000 #define GL_T 0x2001 #define GL_R 0x2002 #define GL_Q 0x2003 #define GL_MODULATE 0x2100 #define GL_DECAL 0x2101 #define GL_TEXTURE_ENV_MODE 0x2200 #define GL_TEXTURE_ENV_COLOR 0x2201 #define GL_TEXTURE_ENV 0x2300 #define GL_EYE_LINEAR 0x2400 #define GL_OBJECT_LINEAR 0x2401 #define GL_SPHERE_MAP 0x2402 #define GL_TEXTURE_GEN_MODE 0x2500 #define GL_OBJECT_PLANE 0x2501 #define GL_EYE_PLANE 0x2502 #define GL_NEAREST 0x2600 #define GL_LINEAR 0x2601 #define GL_NEAREST_MIPMAP_NEAREST 0x2700 #define GL_LINEAR_MIPMAP_NEAREST 0x2701 #define GL_NEAREST_MIPMAP_LINEAR 0x2702 #define GL_LINEAR_MIPMAP_LINEAR 0x2703 #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_CLAMP 0x2900 #define GL_REPEAT 0x2901 #define GL_POLYGON_OFFSET_UNITS 0x2A00 #define GL_POLYGON_OFFSET_POINT 0x2A01 #define GL_POLYGON_OFFSET_LINE 0x2A02 #define GL_R3_G3_B2 0x2A10 #define GL_V2F 0x2A20 #define GL_V3F 0x2A21 #define GL_C4UB_V2F 0x2A22 #define GL_C4UB_V3F 0x2A23 #define GL_C3F_V3F 0x2A24 #define GL_N3F_V3F 0x2A25 #define GL_C4F_N3F_V3F 0x2A26 #define GL_T2F_V3F 0x2A27 #define GL_T4F_V4F 0x2A28 #define GL_T2F_C4UB_V3F 0x2A29 #define GL_T2F_C3F_V3F 0x2A2A #define GL_T2F_N3F_V3F 0x2A2B #define GL_T2F_C4F_N3F_V3F 0x2A2C #define GL_T4F_C4F_N3F_V4F 0x2A2D #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 #define GL_LIGHT0 0x4000 #define GL_COLOR_BUFFER_BIT 0x00004000 #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 #define GL_HINT_BIT 0x00008000 #define GL_POLYGON_OFFSET_FILL 0x8037 #define GL_POLYGON_OFFSET_FACTOR 0x8038 #define GL_ALPHA4 0x803B #define GL_ALPHA8 0x803C #define GL_ALPHA12 0x803D #define GL_ALPHA16 0x803E #define GL_LUMINANCE4 0x803F #define GL_LUMINANCE8 0x8040 #define GL_LUMINANCE12 0x8041 #define GL_LUMINANCE16 0x8042 #define GL_LUMINANCE4_ALPHA4 0x8043 #define GL_LUMINANCE6_ALPHA2 0x8044 #define GL_LUMINANCE8_ALPHA8 0x8045 #define GL_LUMINANCE12_ALPHA4 0x8046 #define GL_LUMINANCE12_ALPHA12 0x8047 #define GL_LUMINANCE16_ALPHA16 0x8048 #define GL_INTENSITY 0x8049 #define GL_INTENSITY4 0x804A #define GL_INTENSITY8 0x804B #define GL_INTENSITY12 0x804C #define GL_INTENSITY16 0x804D #define GL_RGB4 0x804F #define GL_RGB5 0x8050 #define GL_RGB8 0x8051 #define GL_RGB10 0x8052 #define GL_RGB12 0x8053 #define GL_RGB16 0x8054 #define GL_RGBA2 0x8055 #define GL_RGBA4 0x8056 #define GL_RGB5_A1 0x8057 #define GL_RGBA8 0x8058 #define GL_RGB10_A2 0x8059 #define GL_RGBA12 0x805A #define GL_RGBA16 0x805B #define GL_TEXTURE_RED_SIZE 0x805C #define GL_TEXTURE_GREEN_SIZE 0x805D #define GL_TEXTURE_BLUE_SIZE 0x805E #define GL_TEXTURE_ALPHA_SIZE 0x805F #define GL_TEXTURE_LUMINANCE_SIZE 0x8060 #define GL_TEXTURE_INTENSITY_SIZE 0x8061 #define GL_PROXY_TEXTURE_1D 0x8063 #define GL_PROXY_TEXTURE_2D 0x8064 #define GL_TEXTURE_PRIORITY 0x8066 #define GL_TEXTURE_RESIDENT 0x8067 #define GL_TEXTURE_BINDING_1D 0x8068 #define GL_TEXTURE_BINDING_2D 0x8069 #define GL_VERTEX_ARRAY 0x8074 #define GL_NORMAL_ARRAY 0x8075 #define GL_COLOR_ARRAY 0x8076 #define GL_INDEX_ARRAY 0x8077 #define GL_TEXTURE_COORD_ARRAY 0x8078 #define GL_EDGE_FLAG_ARRAY 0x8079 #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_INDEX_ARRAY_TYPE 0x8085 #define GL_INDEX_ARRAY_STRIDE 0x8086 #define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 #define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 #define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A #define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C #define GL_VERTEX_ARRAY_POINTER 0x808E #define GL_NORMAL_ARRAY_POINTER 0x808F #define GL_COLOR_ARRAY_POINTER 0x8090 #define GL_INDEX_ARRAY_POINTER 0x8091 #define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 #define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 #define GL_COLOR_INDEX1_EXT 0x80E2 #define GL_COLOR_INDEX2_EXT 0x80E3 #define GL_COLOR_INDEX4_EXT 0x80E4 #define GL_COLOR_INDEX8_EXT 0x80E5 #define GL_COLOR_INDEX12_EXT 0x80E6 #define GL_COLOR_INDEX16_EXT 0x80E7 #define GL_EVAL_BIT 0x00010000 #define GL_LIST_BIT 0x00020000 #define GL_TEXTURE_BIT 0x00040000 #define GL_SCISSOR_BIT 0x00080000 #define GL_ALL_ATTRIB_BITS 0x000fffff #define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff GLAPI void GLAPIENTRY glAccum (GLenum op, GLfloat value); GLAPI void GLAPIENTRY glAlphaFunc (GLenum func, GLclampf ref); GLAPI GLboolean GLAPIENTRY glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences); GLAPI void GLAPIENTRY glArrayElement (GLint i); GLAPI void GLAPIENTRY glBegin (GLenum mode); GLAPI void GLAPIENTRY glBindTexture (GLenum target, GLuint texture); GLAPI void GLAPIENTRY glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); GLAPI void GLAPIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); GLAPI void GLAPIENTRY glCallList (GLuint list); GLAPI void GLAPIENTRY glCallLists (GLsizei n, GLenum type, const void *lists); GLAPI void GLAPIENTRY glClear (GLbitfield mask); GLAPI void GLAPIENTRY glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GLAPI void GLAPIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); GLAPI void GLAPIENTRY glClearDepth (GLclampd depth); GLAPI void GLAPIENTRY glClearIndex (GLfloat c); GLAPI void GLAPIENTRY glClearStencil (GLint s); GLAPI void GLAPIENTRY glClipPlane (GLenum plane, const GLdouble *equation); GLAPI void GLAPIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue); GLAPI void GLAPIENTRY glColor3bv (const GLbyte *v); GLAPI void GLAPIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue); GLAPI void GLAPIENTRY glColor3dv (const GLdouble *v); GLAPI void GLAPIENTRY glColor3f (GLfloat red, GLfloat green, GLfloat blue); GLAPI void GLAPIENTRY glColor3fv (const GLfloat *v); GLAPI void GLAPIENTRY glColor3i (GLint red, GLint green, GLint blue); GLAPI void GLAPIENTRY glColor3iv (const GLint *v); GLAPI void GLAPIENTRY glColor3s (GLshort red, GLshort green, GLshort blue); GLAPI void GLAPIENTRY glColor3sv (const GLshort *v); GLAPI void GLAPIENTRY glColor3ub (GLubyte red, GLubyte green, GLubyte blue); GLAPI void GLAPIENTRY glColor3ubv (const GLubyte *v); GLAPI void GLAPIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue); GLAPI void GLAPIENTRY glColor3uiv (const GLuint *v); GLAPI void GLAPIENTRY glColor3us (GLushort red, GLushort green, GLushort blue); GLAPI void GLAPIENTRY glColor3usv (const GLushort *v); GLAPI void GLAPIENTRY glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); GLAPI void GLAPIENTRY glColor4bv (const GLbyte *v); GLAPI void GLAPIENTRY glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); GLAPI void GLAPIENTRY glColor4dv (const GLdouble *v); GLAPI void GLAPIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GLAPI void GLAPIENTRY glColor4fv (const GLfloat *v); GLAPI void GLAPIENTRY glColor4i (GLint red, GLint green, GLint blue, GLint alpha); GLAPI void GLAPIENTRY glColor4iv (const GLint *v); GLAPI void GLAPIENTRY glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha); GLAPI void GLAPIENTRY glColor4sv (const GLshort *v); GLAPI void GLAPIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); GLAPI void GLAPIENTRY glColor4ubv (const GLubyte *v); GLAPI void GLAPIENTRY glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha); GLAPI void GLAPIENTRY glColor4uiv (const GLuint *v); GLAPI void GLAPIENTRY glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha); GLAPI void GLAPIENTRY glColor4usv (const GLushort *v); GLAPI void GLAPIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); GLAPI void GLAPIENTRY glColorMaterial (GLenum face, GLenum mode); GLAPI void GLAPIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); GLAPI void GLAPIENTRY glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); GLAPI void GLAPIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); GLAPI void GLAPIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); GLAPI void GLAPIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); GLAPI void GLAPIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void GLAPIENTRY glCullFace (GLenum mode); GLAPI void GLAPIENTRY glDeleteLists (GLuint list, GLsizei range); GLAPI void GLAPIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); GLAPI void GLAPIENTRY glDepthFunc (GLenum func); GLAPI void GLAPIENTRY glDepthMask (GLboolean flag); GLAPI void GLAPIENTRY glDepthRange (GLclampd zNear, GLclampd zFar); GLAPI void GLAPIENTRY glDisable (GLenum cap); GLAPI void GLAPIENTRY glDisableClientState (GLenum array); GLAPI void GLAPIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); GLAPI void GLAPIENTRY glDrawBuffer (GLenum mode); GLAPI void GLAPIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); GLAPI void GLAPIENTRY glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); GLAPI void GLAPIENTRY glEdgeFlag (GLboolean flag); GLAPI void GLAPIENTRY glEdgeFlagPointer (GLsizei stride, const void *pointer); GLAPI void GLAPIENTRY glEdgeFlagv (const GLboolean *flag); GLAPI void GLAPIENTRY glEnable (GLenum cap); GLAPI void GLAPIENTRY glEnableClientState (GLenum array); GLAPI void GLAPIENTRY glEnd (void); GLAPI void GLAPIENTRY glEndList (void); GLAPI void GLAPIENTRY glEvalCoord1d (GLdouble u); GLAPI void GLAPIENTRY glEvalCoord1dv (const GLdouble *u); GLAPI void GLAPIENTRY glEvalCoord1f (GLfloat u); GLAPI void GLAPIENTRY glEvalCoord1fv (const GLfloat *u); GLAPI void GLAPIENTRY glEvalCoord2d (GLdouble u, GLdouble v); GLAPI void GLAPIENTRY glEvalCoord2dv (const GLdouble *u); GLAPI void GLAPIENTRY glEvalCoord2f (GLfloat u, GLfloat v); GLAPI void GLAPIENTRY glEvalCoord2fv (const GLfloat *u); GLAPI void GLAPIENTRY glEvalMesh1 (GLenum mode, GLint i1, GLint i2); GLAPI void GLAPIENTRY glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); GLAPI void GLAPIENTRY glEvalPoint1 (GLint i); GLAPI void GLAPIENTRY glEvalPoint2 (GLint i, GLint j); GLAPI void GLAPIENTRY glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer); GLAPI void GLAPIENTRY glFinish (void); GLAPI void GLAPIENTRY glFlush (void); GLAPI void GLAPIENTRY glFogf (GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glFogfv (GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glFogi (GLenum pname, GLint param); GLAPI void GLAPIENTRY glFogiv (GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glFrontFace (GLenum mode); GLAPI void GLAPIENTRY glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); GLAPI GLuint GLAPIENTRY glGenLists (GLsizei range); GLAPI void GLAPIENTRY glGenTextures (GLsizei n, GLuint *textures); GLAPI void GLAPIENTRY glGetBooleanv (GLenum pname, GLboolean *params); GLAPI void GLAPIENTRY glGetClipPlane (GLenum plane, GLdouble *equation); GLAPI void GLAPIENTRY glGetDoublev (GLenum pname, GLdouble *params); GLAPI GLenum GLAPIENTRY glGetError (void); GLAPI void GLAPIENTRY glGetFloatv (GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetIntegerv (GLenum pname, GLint *params); GLAPI void GLAPIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetLightiv (GLenum light, GLenum pname, GLint *params); GLAPI void GLAPIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v); GLAPI void GLAPIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v); GLAPI void GLAPIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v); GLAPI void GLAPIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetMaterialiv (GLenum face, GLenum pname, GLint *params); GLAPI void GLAPIENTRY glGetPixelMapfv (GLenum map, GLfloat *values); GLAPI void GLAPIENTRY glGetPixelMapuiv (GLenum map, GLuint *values); GLAPI void GLAPIENTRY glGetPixelMapusv (GLenum map, GLushort *values); GLAPI void GLAPIENTRY glGetPointerv (GLenum pname, void* *params); GLAPI void GLAPIENTRY glGetPolygonStipple (GLubyte *mask); GLAPI const GLubyte * GLAPIENTRY glGetString (GLenum name); GLAPI void GLAPIENTRY glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetTexEnviv (GLenum target, GLenum pname, GLint *params); GLAPI void GLAPIENTRY glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params); GLAPI void GLAPIENTRY glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetTexGeniv (GLenum coord, GLenum pname, GLint *params); GLAPI void GLAPIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, void *pixels); GLAPI void GLAPIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); GLAPI void GLAPIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); GLAPI void GLAPIENTRY glHint (GLenum target, GLenum mode); GLAPI void GLAPIENTRY glIndexMask (GLuint mask); GLAPI void GLAPIENTRY glIndexPointer (GLenum type, GLsizei stride, const void *pointer); GLAPI void GLAPIENTRY glIndexd (GLdouble c); GLAPI void GLAPIENTRY glIndexdv (const GLdouble *c); GLAPI void GLAPIENTRY glIndexf (GLfloat c); GLAPI void GLAPIENTRY glIndexfv (const GLfloat *c); GLAPI void GLAPIENTRY glIndexi (GLint c); GLAPI void GLAPIENTRY glIndexiv (const GLint *c); GLAPI void GLAPIENTRY glIndexs (GLshort c); GLAPI void GLAPIENTRY glIndexsv (const GLshort *c); GLAPI void GLAPIENTRY glIndexub (GLubyte c); GLAPI void GLAPIENTRY glIndexubv (const GLubyte *c); GLAPI void GLAPIENTRY glInitNames (void); GLAPI void GLAPIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const void *pointer); GLAPI GLboolean GLAPIENTRY glIsEnabled (GLenum cap); GLAPI GLboolean GLAPIENTRY glIsList (GLuint list); GLAPI GLboolean GLAPIENTRY glIsTexture (GLuint texture); GLAPI void GLAPIENTRY glLightModelf (GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glLightModelfv (GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glLightModeli (GLenum pname, GLint param); GLAPI void GLAPIENTRY glLightModeliv (GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glLightf (GLenum light, GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glLighti (GLenum light, GLenum pname, GLint param); GLAPI void GLAPIENTRY glLightiv (GLenum light, GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glLineStipple (GLint factor, GLushort pattern); GLAPI void GLAPIENTRY glLineWidth (GLfloat width); GLAPI void GLAPIENTRY glListBase (GLuint base); GLAPI void GLAPIENTRY glLoadIdentity (void); GLAPI void GLAPIENTRY glLoadMatrixd (const GLdouble *m); GLAPI void GLAPIENTRY glLoadMatrixf (const GLfloat *m); GLAPI void GLAPIENTRY glLoadName (GLuint name); GLAPI void GLAPIENTRY glLogicOp (GLenum opcode); GLAPI void GLAPIENTRY glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); GLAPI void GLAPIENTRY glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); GLAPI void GLAPIENTRY glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); GLAPI void GLAPIENTRY glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); GLAPI void GLAPIENTRY glMapGrid1d (GLint un, GLdouble u1, GLdouble u2); GLAPI void GLAPIENTRY glMapGrid1f (GLint un, GLfloat u1, GLfloat u2); GLAPI void GLAPIENTRY glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); GLAPI void GLAPIENTRY glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); GLAPI void GLAPIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glMateriali (GLenum face, GLenum pname, GLint param); GLAPI void GLAPIENTRY glMaterialiv (GLenum face, GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glMatrixMode (GLenum mode); GLAPI void GLAPIENTRY glMultMatrixd (const GLdouble *m); GLAPI void GLAPIENTRY glMultMatrixf (const GLfloat *m); GLAPI void GLAPIENTRY glNewList (GLuint list, GLenum mode); GLAPI void GLAPIENTRY glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz); GLAPI void GLAPIENTRY glNormal3bv (const GLbyte *v); GLAPI void GLAPIENTRY glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz); GLAPI void GLAPIENTRY glNormal3dv (const GLdouble *v); GLAPI void GLAPIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); GLAPI void GLAPIENTRY glNormal3fv (const GLfloat *v); GLAPI void GLAPIENTRY glNormal3i (GLint nx, GLint ny, GLint nz); GLAPI void GLAPIENTRY glNormal3iv (const GLint *v); GLAPI void GLAPIENTRY glNormal3s (GLshort nx, GLshort ny, GLshort nz); GLAPI void GLAPIENTRY glNormal3sv (const GLshort *v); GLAPI void GLAPIENTRY glNormalPointer (GLenum type, GLsizei stride, const void *pointer); GLAPI void GLAPIENTRY glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); GLAPI void GLAPIENTRY glPassThrough (GLfloat token); GLAPI void GLAPIENTRY glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat *values); GLAPI void GLAPIENTRY glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint *values); GLAPI void GLAPIENTRY glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort *values); GLAPI void GLAPIENTRY glPixelStoref (GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glPixelStorei (GLenum pname, GLint param); GLAPI void GLAPIENTRY glPixelTransferf (GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glPixelTransferi (GLenum pname, GLint param); GLAPI void GLAPIENTRY glPixelZoom (GLfloat xfactor, GLfloat yfactor); GLAPI void GLAPIENTRY glPointSize (GLfloat size); GLAPI void GLAPIENTRY glPolygonMode (GLenum face, GLenum mode); GLAPI void GLAPIENTRY glPolygonOffset (GLfloat factor, GLfloat units); GLAPI void GLAPIENTRY glPolygonStipple (const GLubyte *mask); GLAPI void GLAPIENTRY glPopAttrib (void); GLAPI void GLAPIENTRY glPopClientAttrib (void); GLAPI void GLAPIENTRY glPopMatrix (void); GLAPI void GLAPIENTRY glPopName (void); GLAPI void GLAPIENTRY glPrioritizeTextures (GLsizei n, const GLuint *textures, const GLclampf *priorities); GLAPI void GLAPIENTRY glPushAttrib (GLbitfield mask); GLAPI void GLAPIENTRY glPushClientAttrib (GLbitfield mask); GLAPI void GLAPIENTRY glPushMatrix (void); GLAPI void GLAPIENTRY glPushName (GLuint name); GLAPI void GLAPIENTRY glRasterPos2d (GLdouble x, GLdouble y); GLAPI void GLAPIENTRY glRasterPos2dv (const GLdouble *v); GLAPI void GLAPIENTRY glRasterPos2f (GLfloat x, GLfloat y); GLAPI void GLAPIENTRY glRasterPos2fv (const GLfloat *v); GLAPI void GLAPIENTRY glRasterPos2i (GLint x, GLint y); GLAPI void GLAPIENTRY glRasterPos2iv (const GLint *v); GLAPI void GLAPIENTRY glRasterPos2s (GLshort x, GLshort y); GLAPI void GLAPIENTRY glRasterPos2sv (const GLshort *v); GLAPI void GLAPIENTRY glRasterPos3d (GLdouble x, GLdouble y, GLdouble z); GLAPI void GLAPIENTRY glRasterPos3dv (const GLdouble *v); GLAPI void GLAPIENTRY glRasterPos3f (GLfloat x, GLfloat y, GLfloat z); GLAPI void GLAPIENTRY glRasterPos3fv (const GLfloat *v); GLAPI void GLAPIENTRY glRasterPos3i (GLint x, GLint y, GLint z); GLAPI void GLAPIENTRY glRasterPos3iv (const GLint *v); GLAPI void GLAPIENTRY glRasterPos3s (GLshort x, GLshort y, GLshort z); GLAPI void GLAPIENTRY glRasterPos3sv (const GLshort *v); GLAPI void GLAPIENTRY glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void GLAPIENTRY glRasterPos4dv (const GLdouble *v); GLAPI void GLAPIENTRY glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void GLAPIENTRY glRasterPos4fv (const GLfloat *v); GLAPI void GLAPIENTRY glRasterPos4i (GLint x, GLint y, GLint z, GLint w); GLAPI void GLAPIENTRY glRasterPos4iv (const GLint *v); GLAPI void GLAPIENTRY glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w); GLAPI void GLAPIENTRY glRasterPos4sv (const GLshort *v); GLAPI void GLAPIENTRY glReadBuffer (GLenum mode); GLAPI void GLAPIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); GLAPI void GLAPIENTRY glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); GLAPI void GLAPIENTRY glRectdv (const GLdouble *v1, const GLdouble *v2); GLAPI void GLAPIENTRY glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); GLAPI void GLAPIENTRY glRectfv (const GLfloat *v1, const GLfloat *v2); GLAPI void GLAPIENTRY glRecti (GLint x1, GLint y1, GLint x2, GLint y2); GLAPI void GLAPIENTRY glRectiv (const GLint *v1, const GLint *v2); GLAPI void GLAPIENTRY glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2); GLAPI void GLAPIENTRY glRectsv (const GLshort *v1, const GLshort *v2); GLAPI GLint GLAPIENTRY glRenderMode (GLenum mode); GLAPI void GLAPIENTRY glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z); GLAPI void GLAPIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); GLAPI void GLAPIENTRY glScaled (GLdouble x, GLdouble y, GLdouble z); GLAPI void GLAPIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z); GLAPI void GLAPIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void GLAPIENTRY glSelectBuffer (GLsizei size, GLuint *buffer); GLAPI void GLAPIENTRY glShadeModel (GLenum mode); GLAPI void GLAPIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); GLAPI void GLAPIENTRY glStencilMask (GLuint mask); GLAPI void GLAPIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); GLAPI void GLAPIENTRY glTexCoord1d (GLdouble s); GLAPI void GLAPIENTRY glTexCoord1dv (const GLdouble *v); GLAPI void GLAPIENTRY glTexCoord1f (GLfloat s); GLAPI void GLAPIENTRY glTexCoord1fv (const GLfloat *v); GLAPI void GLAPIENTRY glTexCoord1i (GLint s); GLAPI void GLAPIENTRY glTexCoord1iv (const GLint *v); GLAPI void GLAPIENTRY glTexCoord1s (GLshort s); GLAPI void GLAPIENTRY glTexCoord1sv (const GLshort *v); GLAPI void GLAPIENTRY glTexCoord2d (GLdouble s, GLdouble t); GLAPI void GLAPIENTRY glTexCoord2dv (const GLdouble *v); GLAPI void GLAPIENTRY glTexCoord2f (GLfloat s, GLfloat t); GLAPI void GLAPIENTRY glTexCoord2fv (const GLfloat *v); GLAPI void GLAPIENTRY glTexCoord2i (GLint s, GLint t); GLAPI void GLAPIENTRY glTexCoord2iv (const GLint *v); GLAPI void GLAPIENTRY glTexCoord2s (GLshort s, GLshort t); GLAPI void GLAPIENTRY glTexCoord2sv (const GLshort *v); GLAPI void GLAPIENTRY glTexCoord3d (GLdouble s, GLdouble t, GLdouble r); GLAPI void GLAPIENTRY glTexCoord3dv (const GLdouble *v); GLAPI void GLAPIENTRY glTexCoord3f (GLfloat s, GLfloat t, GLfloat r); GLAPI void GLAPIENTRY glTexCoord3fv (const GLfloat *v); GLAPI void GLAPIENTRY glTexCoord3i (GLint s, GLint t, GLint r); GLAPI void GLAPIENTRY glTexCoord3iv (const GLint *v); GLAPI void GLAPIENTRY glTexCoord3s (GLshort s, GLshort t, GLshort r); GLAPI void GLAPIENTRY glTexCoord3sv (const GLshort *v); GLAPI void GLAPIENTRY glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q); GLAPI void GLAPIENTRY glTexCoord4dv (const GLdouble *v); GLAPI void GLAPIENTRY glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q); GLAPI void GLAPIENTRY glTexCoord4fv (const GLfloat *v); GLAPI void GLAPIENTRY glTexCoord4i (GLint s, GLint t, GLint r, GLint q); GLAPI void GLAPIENTRY glTexCoord4iv (const GLint *v); GLAPI void GLAPIENTRY glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q); GLAPI void GLAPIENTRY glTexCoord4sv (const GLshort *v); GLAPI void GLAPIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); GLAPI void GLAPIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param); GLAPI void GLAPIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glTexGend (GLenum coord, GLenum pname, GLdouble param); GLAPI void GLAPIENTRY glTexGendv (GLenum coord, GLenum pname, const GLdouble *params); GLAPI void GLAPIENTRY glTexGenf (GLenum coord, GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glTexGenfv (GLenum coord, GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glTexGeni (GLenum coord, GLenum pname, GLint param); GLAPI void GLAPIENTRY glTexGeniv (GLenum coord, GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); GLAPI void GLAPIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); GLAPI void GLAPIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); GLAPI void GLAPIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); GLAPI void GLAPIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); GLAPI void GLAPIENTRY glTranslated (GLdouble x, GLdouble y, GLdouble z); GLAPI void GLAPIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z); GLAPI void GLAPIENTRY glVertex2d (GLdouble x, GLdouble y); GLAPI void GLAPIENTRY glVertex2dv (const GLdouble *v); GLAPI void GLAPIENTRY glVertex2f (GLfloat x, GLfloat y); GLAPI void GLAPIENTRY glVertex2fv (const GLfloat *v); GLAPI void GLAPIENTRY glVertex2i (GLint x, GLint y); GLAPI void GLAPIENTRY glVertex2iv (const GLint *v); GLAPI void GLAPIENTRY glVertex2s (GLshort x, GLshort y); GLAPI void GLAPIENTRY glVertex2sv (const GLshort *v); GLAPI void GLAPIENTRY glVertex3d (GLdouble x, GLdouble y, GLdouble z); GLAPI void GLAPIENTRY glVertex3dv (const GLdouble *v); GLAPI void GLAPIENTRY glVertex3f (GLfloat x, GLfloat y, GLfloat z); GLAPI void GLAPIENTRY glVertex3fv (const GLfloat *v); GLAPI void GLAPIENTRY glVertex3i (GLint x, GLint y, GLint z); GLAPI void GLAPIENTRY glVertex3iv (const GLint *v); GLAPI void GLAPIENTRY glVertex3s (GLshort x, GLshort y, GLshort z); GLAPI void GLAPIENTRY glVertex3sv (const GLshort *v); GLAPI void GLAPIENTRY glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void GLAPIENTRY glVertex4dv (const GLdouble *v); GLAPI void GLAPIENTRY glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void GLAPIENTRY glVertex4fv (const GLfloat *v); GLAPI void GLAPIENTRY glVertex4i (GLint x, GLint y, GLint z, GLint w); GLAPI void GLAPIENTRY glVertex4iv (const GLint *v); GLAPI void GLAPIENTRY glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w); GLAPI void GLAPIENTRY glVertex4sv (const GLshort *v); GLAPI void GLAPIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); #define GLEW_VERSION_1_1 GLEW_GET_VAR(__GLEW_VERSION_1_1) #endif /* GL_VERSION_1_1 */ /* ---------------------------------- GLU ---------------------------------- */ #ifndef GLEW_NO_GLU # ifdef __APPLE__ # include # if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) # define GLEW_NO_GLU # endif # endif #endif #ifndef GLEW_NO_GLU /* this is where we can safely include GLU */ # if defined(__APPLE__) && defined(__MACH__) # include # else # include # endif #endif /* ----------------------------- GL_VERSION_1_2 ---------------------------- */ #ifndef GL_VERSION_1_2 #define GL_VERSION_1_2 1 #define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 #define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 #define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 #define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 #define GL_UNSIGNED_BYTE_3_3_2 0x8032 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 #define GL_UNSIGNED_INT_8_8_8_8 0x8035 #define GL_UNSIGNED_INT_10_10_10_2 0x8036 #define GL_RESCALE_NORMAL 0x803A #define GL_TEXTURE_BINDING_3D 0x806A #define GL_PACK_SKIP_IMAGES 0x806B #define GL_PACK_IMAGE_HEIGHT 0x806C #define GL_UNPACK_SKIP_IMAGES 0x806D #define GL_UNPACK_IMAGE_HEIGHT 0x806E #define GL_TEXTURE_3D 0x806F #define GL_PROXY_TEXTURE_3D 0x8070 #define GL_TEXTURE_DEPTH 0x8071 #define GL_TEXTURE_WRAP_R 0x8072 #define GL_MAX_3D_TEXTURE_SIZE 0x8073 #define GL_BGR 0x80E0 #define GL_BGRA 0x80E1 #define GL_MAX_ELEMENTS_VERTICES 0x80E8 #define GL_MAX_ELEMENTS_INDICES 0x80E9 #define GL_CLAMP_TO_EDGE 0x812F #define GL_TEXTURE_MIN_LOD 0x813A #define GL_TEXTURE_MAX_LOD 0x813B #define GL_TEXTURE_BASE_LEVEL 0x813C #define GL_TEXTURE_MAX_LEVEL 0x813D #define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 #define GL_SINGLE_COLOR 0x81F9 #define GL_SEPARATE_SPECULAR_COLOR 0x81FA #define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 #define GL_UNSIGNED_SHORT_5_6_5 0x8363 #define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 #define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 #define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 #define GL_ALIASED_POINT_SIZE_RANGE 0x846D #define GL_ALIASED_LINE_WIDTH_RANGE 0x846E typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); #define glCopyTexSubImage3D GLEW_GET_FUN(__glewCopyTexSubImage3D) #define glDrawRangeElements GLEW_GET_FUN(__glewDrawRangeElements) #define glTexImage3D GLEW_GET_FUN(__glewTexImage3D) #define glTexSubImage3D GLEW_GET_FUN(__glewTexSubImage3D) #define GLEW_VERSION_1_2 GLEW_GET_VAR(__GLEW_VERSION_1_2) #endif /* GL_VERSION_1_2 */ /* ---------------------------- GL_VERSION_1_2_1 --------------------------- */ #ifndef GL_VERSION_1_2_1 #define GL_VERSION_1_2_1 1 #define GLEW_VERSION_1_2_1 GLEW_GET_VAR(__GLEW_VERSION_1_2_1) #endif /* GL_VERSION_1_2_1 */ /* ----------------------------- GL_VERSION_1_3 ---------------------------- */ #ifndef GL_VERSION_1_3 #define GL_VERSION_1_3 1 #define GL_MULTISAMPLE 0x809D #define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E #define GL_SAMPLE_ALPHA_TO_ONE 0x809F #define GL_SAMPLE_COVERAGE 0x80A0 #define GL_SAMPLE_BUFFERS 0x80A8 #define GL_SAMPLES 0x80A9 #define GL_SAMPLE_COVERAGE_VALUE 0x80AA #define GL_SAMPLE_COVERAGE_INVERT 0x80AB #define GL_CLAMP_TO_BORDER 0x812D #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 #define GL_MAX_TEXTURE_UNITS 0x84E2 #define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 #define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 #define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 #define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 #define GL_SUBTRACT 0x84E7 #define GL_COMPRESSED_ALPHA 0x84E9 #define GL_COMPRESSED_LUMINANCE 0x84EA #define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB #define GL_COMPRESSED_INTENSITY 0x84EC #define GL_COMPRESSED_RGB 0x84ED #define GL_COMPRESSED_RGBA 0x84EE #define GL_TEXTURE_COMPRESSION_HINT 0x84EF #define GL_NORMAL_MAP 0x8511 #define GL_REFLECTION_MAP 0x8512 #define GL_TEXTURE_CUBE_MAP 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A #define GL_PROXY_TEXTURE_CUBE_MAP 0x851B #define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C #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_SOURCE0_RGB 0x8580 #define GL_SOURCE1_RGB 0x8581 #define GL_SOURCE2_RGB 0x8582 #define GL_SOURCE0_ALPHA 0x8588 #define GL_SOURCE1_ALPHA 0x8589 #define GL_SOURCE2_ALPHA 0x858A #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_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 #define GL_TEXTURE_COMPRESSED 0x86A1 #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 #define GL_DOT3_RGB 0x86AE #define GL_DOT3_RGBA 0x86AF #define GL_MULTISAMPLE_BIT 0x20000000 typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture); typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, void *img); typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); #define glActiveTexture GLEW_GET_FUN(__glewActiveTexture) #define glClientActiveTexture GLEW_GET_FUN(__glewClientActiveTexture) #define glCompressedTexImage1D GLEW_GET_FUN(__glewCompressedTexImage1D) #define glCompressedTexImage2D GLEW_GET_FUN(__glewCompressedTexImage2D) #define glCompressedTexImage3D GLEW_GET_FUN(__glewCompressedTexImage3D) #define glCompressedTexSubImage1D GLEW_GET_FUN(__glewCompressedTexSubImage1D) #define glCompressedTexSubImage2D GLEW_GET_FUN(__glewCompressedTexSubImage2D) #define glCompressedTexSubImage3D GLEW_GET_FUN(__glewCompressedTexSubImage3D) #define glGetCompressedTexImage GLEW_GET_FUN(__glewGetCompressedTexImage) #define glLoadTransposeMatrixd GLEW_GET_FUN(__glewLoadTransposeMatrixd) #define glLoadTransposeMatrixf GLEW_GET_FUN(__glewLoadTransposeMatrixf) #define glMultTransposeMatrixd GLEW_GET_FUN(__glewMultTransposeMatrixd) #define glMultTransposeMatrixf GLEW_GET_FUN(__glewMultTransposeMatrixf) #define glMultiTexCoord1d GLEW_GET_FUN(__glewMultiTexCoord1d) #define glMultiTexCoord1dv GLEW_GET_FUN(__glewMultiTexCoord1dv) #define glMultiTexCoord1f GLEW_GET_FUN(__glewMultiTexCoord1f) #define glMultiTexCoord1fv GLEW_GET_FUN(__glewMultiTexCoord1fv) #define glMultiTexCoord1i GLEW_GET_FUN(__glewMultiTexCoord1i) #define glMultiTexCoord1iv GLEW_GET_FUN(__glewMultiTexCoord1iv) #define glMultiTexCoord1s GLEW_GET_FUN(__glewMultiTexCoord1s) #define glMultiTexCoord1sv GLEW_GET_FUN(__glewMultiTexCoord1sv) #define glMultiTexCoord2d GLEW_GET_FUN(__glewMultiTexCoord2d) #define glMultiTexCoord2dv GLEW_GET_FUN(__glewMultiTexCoord2dv) #define glMultiTexCoord2f GLEW_GET_FUN(__glewMultiTexCoord2f) #define glMultiTexCoord2fv GLEW_GET_FUN(__glewMultiTexCoord2fv) #define glMultiTexCoord2i GLEW_GET_FUN(__glewMultiTexCoord2i) #define glMultiTexCoord2iv GLEW_GET_FUN(__glewMultiTexCoord2iv) #define glMultiTexCoord2s GLEW_GET_FUN(__glewMultiTexCoord2s) #define glMultiTexCoord2sv GLEW_GET_FUN(__glewMultiTexCoord2sv) #define glMultiTexCoord3d GLEW_GET_FUN(__glewMultiTexCoord3d) #define glMultiTexCoord3dv GLEW_GET_FUN(__glewMultiTexCoord3dv) #define glMultiTexCoord3f GLEW_GET_FUN(__glewMultiTexCoord3f) #define glMultiTexCoord3fv GLEW_GET_FUN(__glewMultiTexCoord3fv) #define glMultiTexCoord3i GLEW_GET_FUN(__glewMultiTexCoord3i) #define glMultiTexCoord3iv GLEW_GET_FUN(__glewMultiTexCoord3iv) #define glMultiTexCoord3s GLEW_GET_FUN(__glewMultiTexCoord3s) #define glMultiTexCoord3sv GLEW_GET_FUN(__glewMultiTexCoord3sv) #define glMultiTexCoord4d GLEW_GET_FUN(__glewMultiTexCoord4d) #define glMultiTexCoord4dv GLEW_GET_FUN(__glewMultiTexCoord4dv) #define glMultiTexCoord4f GLEW_GET_FUN(__glewMultiTexCoord4f) #define glMultiTexCoord4fv GLEW_GET_FUN(__glewMultiTexCoord4fv) #define glMultiTexCoord4i GLEW_GET_FUN(__glewMultiTexCoord4i) #define glMultiTexCoord4iv GLEW_GET_FUN(__glewMultiTexCoord4iv) #define glMultiTexCoord4s GLEW_GET_FUN(__glewMultiTexCoord4s) #define glMultiTexCoord4sv GLEW_GET_FUN(__glewMultiTexCoord4sv) #define glSampleCoverage GLEW_GET_FUN(__glewSampleCoverage) #define GLEW_VERSION_1_3 GLEW_GET_VAR(__GLEW_VERSION_1_3) #endif /* GL_VERSION_1_3 */ /* ----------------------------- GL_VERSION_1_4 ---------------------------- */ #ifndef GL_VERSION_1_4 #define GL_VERSION_1_4 1 #define GL_BLEND_DST_RGB 0x80C8 #define GL_BLEND_SRC_RGB 0x80C9 #define GL_BLEND_DST_ALPHA 0x80CA #define GL_BLEND_SRC_ALPHA 0x80CB #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_GENERATE_MIPMAP 0x8191 #define GL_GENERATE_MIPMAP_HINT 0x8192 #define GL_DEPTH_COMPONENT16 0x81A5 #define GL_DEPTH_COMPONENT24 0x81A6 #define GL_DEPTH_COMPONENT32 0x81A7 #define GL_MIRRORED_REPEAT 0x8370 #define GL_FOG_COORDINATE_SOURCE 0x8450 #define GL_FOG_COORDINATE 0x8451 #define GL_FRAGMENT_DEPTH 0x8452 #define GL_CURRENT_FOG_COORDINATE 0x8453 #define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 #define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 #define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 #define GL_FOG_COORDINATE_ARRAY 0x8457 #define GL_COLOR_SUM 0x8458 #define GL_CURRENT_SECONDARY_COLOR 0x8459 #define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A #define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B #define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C #define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D #define GL_SECONDARY_COLOR_ARRAY 0x845E #define GL_MAX_TEXTURE_LOD_BIAS 0x84FD #define GL_TEXTURE_FILTER_CONTROL 0x8500 #define GL_TEXTURE_LOD_BIAS 0x8501 #define GL_INCR_WRAP 0x8507 #define GL_DECR_WRAP 0x8508 #define GL_TEXTURE_DEPTH_SIZE 0x884A #define GL_DEPTH_TEXTURE_MODE 0x884B #define GL_TEXTURE_COMPARE_MODE 0x884C #define GL_TEXTURE_COMPARE_FUNC 0x884D #define GL_COMPARE_R_TO_TEXTURE 0x884E typedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode); typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); typedef void (GLAPIENTRY * PFNGLFOGCOORDDPROC) (GLdouble coord); typedef void (GLAPIENTRY * PFNGLFOGCOORDDVPROC) (const GLdouble *coord); typedef void (GLAPIENTRY * PFNGLFOGCOORDFPROC) (GLfloat coord); typedef void (GLAPIENTRY * PFNGLFOGCOORDFVPROC) (const GLfloat *coord); typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const* indices, GLsizei drawcount); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVPROC) (const GLdouble *p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVPROC) (const GLfloat *p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVPROC) (const GLint *p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVPROC) (const GLshort *p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVPROC) (const GLdouble *p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVPROC) (const GLfloat *p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVPROC) (const GLint *p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVPROC) (const GLshort *p); #define glBlendColor GLEW_GET_FUN(__glewBlendColor) #define glBlendEquation GLEW_GET_FUN(__glewBlendEquation) #define glBlendFuncSeparate GLEW_GET_FUN(__glewBlendFuncSeparate) #define glFogCoordPointer GLEW_GET_FUN(__glewFogCoordPointer) #define glFogCoordd GLEW_GET_FUN(__glewFogCoordd) #define glFogCoorddv GLEW_GET_FUN(__glewFogCoorddv) #define glFogCoordf GLEW_GET_FUN(__glewFogCoordf) #define glFogCoordfv GLEW_GET_FUN(__glewFogCoordfv) #define glMultiDrawArrays GLEW_GET_FUN(__glewMultiDrawArrays) #define glMultiDrawElements GLEW_GET_FUN(__glewMultiDrawElements) #define glPointParameterf GLEW_GET_FUN(__glewPointParameterf) #define glPointParameterfv GLEW_GET_FUN(__glewPointParameterfv) #define glPointParameteri GLEW_GET_FUN(__glewPointParameteri) #define glPointParameteriv GLEW_GET_FUN(__glewPointParameteriv) #define glSecondaryColor3b GLEW_GET_FUN(__glewSecondaryColor3b) #define glSecondaryColor3bv GLEW_GET_FUN(__glewSecondaryColor3bv) #define glSecondaryColor3d GLEW_GET_FUN(__glewSecondaryColor3d) #define glSecondaryColor3dv GLEW_GET_FUN(__glewSecondaryColor3dv) #define glSecondaryColor3f GLEW_GET_FUN(__glewSecondaryColor3f) #define glSecondaryColor3fv GLEW_GET_FUN(__glewSecondaryColor3fv) #define glSecondaryColor3i GLEW_GET_FUN(__glewSecondaryColor3i) #define glSecondaryColor3iv GLEW_GET_FUN(__glewSecondaryColor3iv) #define glSecondaryColor3s GLEW_GET_FUN(__glewSecondaryColor3s) #define glSecondaryColor3sv GLEW_GET_FUN(__glewSecondaryColor3sv) #define glSecondaryColor3ub GLEW_GET_FUN(__glewSecondaryColor3ub) #define glSecondaryColor3ubv GLEW_GET_FUN(__glewSecondaryColor3ubv) #define glSecondaryColor3ui GLEW_GET_FUN(__glewSecondaryColor3ui) #define glSecondaryColor3uiv GLEW_GET_FUN(__glewSecondaryColor3uiv) #define glSecondaryColor3us GLEW_GET_FUN(__glewSecondaryColor3us) #define glSecondaryColor3usv GLEW_GET_FUN(__glewSecondaryColor3usv) #define glSecondaryColorPointer GLEW_GET_FUN(__glewSecondaryColorPointer) #define glWindowPos2d GLEW_GET_FUN(__glewWindowPos2d) #define glWindowPos2dv GLEW_GET_FUN(__glewWindowPos2dv) #define glWindowPos2f GLEW_GET_FUN(__glewWindowPos2f) #define glWindowPos2fv GLEW_GET_FUN(__glewWindowPos2fv) #define glWindowPos2i GLEW_GET_FUN(__glewWindowPos2i) #define glWindowPos2iv GLEW_GET_FUN(__glewWindowPos2iv) #define glWindowPos2s GLEW_GET_FUN(__glewWindowPos2s) #define glWindowPos2sv GLEW_GET_FUN(__glewWindowPos2sv) #define glWindowPos3d GLEW_GET_FUN(__glewWindowPos3d) #define glWindowPos3dv GLEW_GET_FUN(__glewWindowPos3dv) #define glWindowPos3f GLEW_GET_FUN(__glewWindowPos3f) #define glWindowPos3fv GLEW_GET_FUN(__glewWindowPos3fv) #define glWindowPos3i GLEW_GET_FUN(__glewWindowPos3i) #define glWindowPos3iv GLEW_GET_FUN(__glewWindowPos3iv) #define glWindowPos3s GLEW_GET_FUN(__glewWindowPos3s) #define glWindowPos3sv GLEW_GET_FUN(__glewWindowPos3sv) #define GLEW_VERSION_1_4 GLEW_GET_VAR(__GLEW_VERSION_1_4) #endif /* GL_VERSION_1_4 */ /* ----------------------------- GL_VERSION_1_5 ---------------------------- */ #ifndef GL_VERSION_1_5 #define GL_VERSION_1_5 1 #define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE #define GL_FOG_COORD GL_FOG_COORDINATE #define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY #define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING #define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER #define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE #define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE #define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE #define GL_SRC0_ALPHA GL_SOURCE0_ALPHA #define GL_SRC0_RGB GL_SOURCE0_RGB #define GL_SRC1_ALPHA GL_SOURCE1_ALPHA #define GL_SRC1_RGB GL_SOURCE1_RGB #define GL_SRC2_ALPHA GL_SOURCE2_ALPHA #define GL_SRC2_RGB GL_SOURCE2_RGB #define GL_BUFFER_SIZE 0x8764 #define GL_BUFFER_USAGE 0x8765 #define GL_QUERY_COUNTER_BITS 0x8864 #define GL_CURRENT_QUERY 0x8865 #define GL_QUERY_RESULT 0x8866 #define GL_QUERY_RESULT_AVAILABLE 0x8867 #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_INDEX_ARRAY_BUFFER_BINDING 0x8899 #define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A #define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B #define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C #define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D #define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F #define GL_READ_ONLY 0x88B8 #define GL_WRITE_ONLY 0x88B9 #define GL_READ_WRITE 0x88BA #define GL_BUFFER_ACCESS 0x88BB #define GL_BUFFER_MAPPED 0x88BC #define GL_BUFFER_MAP_POINTER 0x88BD #define GL_STREAM_DRAW 0x88E0 #define GL_STREAM_READ 0x88E1 #define GL_STREAM_COPY 0x88E2 #define GL_STATIC_DRAW 0x88E4 #define GL_STATIC_READ 0x88E5 #define GL_STATIC_COPY 0x88E6 #define GL_DYNAMIC_DRAW 0x88E8 #define GL_DYNAMIC_READ 0x88E9 #define GL_DYNAMIC_COPY 0x88EA #define GL_SAMPLES_PASSED 0x8914 typedef ptrdiff_t GLintptr; typedef ptrdiff_t GLsizeiptr; typedef void (GLAPIENTRY * PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); typedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void* data, GLenum usage); typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void* data); typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers); typedef void (GLAPIENTRY * PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint* ids); typedef void (GLAPIENTRY * PFNGLENDQUERYPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers); typedef void (GLAPIENTRY * PFNGLGENQUERIESPROC) (GLsizei n, GLuint* ids); typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void** params); typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void* data); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer); typedef GLboolean (GLAPIENTRY * PFNGLISQUERYPROC) (GLuint id); typedef void* (GLAPIENTRY * PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERPROC) (GLenum target); #define glBeginQuery GLEW_GET_FUN(__glewBeginQuery) #define glBindBuffer GLEW_GET_FUN(__glewBindBuffer) #define glBufferData GLEW_GET_FUN(__glewBufferData) #define glBufferSubData GLEW_GET_FUN(__glewBufferSubData) #define glDeleteBuffers GLEW_GET_FUN(__glewDeleteBuffers) #define glDeleteQueries GLEW_GET_FUN(__glewDeleteQueries) #define glEndQuery GLEW_GET_FUN(__glewEndQuery) #define glGenBuffers GLEW_GET_FUN(__glewGenBuffers) #define glGenQueries GLEW_GET_FUN(__glewGenQueries) #define glGetBufferParameteriv GLEW_GET_FUN(__glewGetBufferParameteriv) #define glGetBufferPointerv GLEW_GET_FUN(__glewGetBufferPointerv) #define glGetBufferSubData GLEW_GET_FUN(__glewGetBufferSubData) #define glGetQueryObjectiv GLEW_GET_FUN(__glewGetQueryObjectiv) #define glGetQueryObjectuiv GLEW_GET_FUN(__glewGetQueryObjectuiv) #define glGetQueryiv GLEW_GET_FUN(__glewGetQueryiv) #define glIsBuffer GLEW_GET_FUN(__glewIsBuffer) #define glIsQuery GLEW_GET_FUN(__glewIsQuery) #define glMapBuffer GLEW_GET_FUN(__glewMapBuffer) #define glUnmapBuffer GLEW_GET_FUN(__glewUnmapBuffer) #define GLEW_VERSION_1_5 GLEW_GET_VAR(__GLEW_VERSION_1_5) #endif /* GL_VERSION_1_5 */ /* ----------------------------- GL_VERSION_2_0 ---------------------------- */ #ifndef GL_VERSION_2_0 #define GL_VERSION_2_0 1 #define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 #define GL_CURRENT_VERTEX_ATTRIB 0x8626 #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 #define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 #define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 #define GL_STENCIL_BACK_FUNC 0x8800 #define GL_STENCIL_BACK_FAIL 0x8801 #define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 #define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 #define GL_MAX_DRAW_BUFFERS 0x8824 #define GL_DRAW_BUFFER0 0x8825 #define GL_DRAW_BUFFER1 0x8826 #define GL_DRAW_BUFFER2 0x8827 #define GL_DRAW_BUFFER3 0x8828 #define GL_DRAW_BUFFER4 0x8829 #define GL_DRAW_BUFFER5 0x882A #define GL_DRAW_BUFFER6 0x882B #define GL_DRAW_BUFFER7 0x882C #define GL_DRAW_BUFFER8 0x882D #define GL_DRAW_BUFFER9 0x882E #define GL_DRAW_BUFFER10 0x882F #define GL_DRAW_BUFFER11 0x8830 #define GL_DRAW_BUFFER12 0x8831 #define GL_DRAW_BUFFER13 0x8832 #define GL_DRAW_BUFFER14 0x8833 #define GL_DRAW_BUFFER15 0x8834 #define GL_BLEND_EQUATION_ALPHA 0x883D #define GL_POINT_SPRITE 0x8861 #define GL_COORD_REPLACE 0x8862 #define GL_MAX_VERTEX_ATTRIBS 0x8869 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A #define GL_MAX_TEXTURE_COORDS 0x8871 #define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 #define GL_FRAGMENT_SHADER 0x8B30 #define GL_VERTEX_SHADER 0x8B31 #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 #define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A #define GL_MAX_VARYING_FLOATS 0x8B4B #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D #define GL_SHADER_TYPE 0x8B4F #define GL_FLOAT_VEC2 0x8B50 #define GL_FLOAT_VEC3 0x8B51 #define GL_FLOAT_VEC4 0x8B52 #define GL_INT_VEC2 0x8B53 #define GL_INT_VEC3 0x8B54 #define GL_INT_VEC4 0x8B55 #define GL_BOOL 0x8B56 #define GL_BOOL_VEC2 0x8B57 #define GL_BOOL_VEC3 0x8B58 #define GL_BOOL_VEC4 0x8B59 #define GL_FLOAT_MAT2 0x8B5A #define GL_FLOAT_MAT3 0x8B5B #define GL_FLOAT_MAT4 0x8B5C #define GL_SAMPLER_1D 0x8B5D #define GL_SAMPLER_2D 0x8B5E #define GL_SAMPLER_3D 0x8B5F #define GL_SAMPLER_CUBE 0x8B60 #define GL_SAMPLER_1D_SHADOW 0x8B61 #define GL_SAMPLER_2D_SHADOW 0x8B62 #define GL_DELETE_STATUS 0x8B80 #define GL_COMPILE_STATUS 0x8B81 #define GL_LINK_STATUS 0x8B82 #define GL_VALIDATE_STATUS 0x8B83 #define GL_INFO_LOG_LENGTH 0x8B84 #define GL_ATTACHED_SHADERS 0x8B85 #define GL_ACTIVE_UNIFORMS 0x8B86 #define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 #define GL_SHADER_SOURCE_LENGTH 0x8B88 #define GL_ACTIVE_ATTRIBUTES 0x8B89 #define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B #define GL_SHADING_LANGUAGE_VERSION 0x8B8C #define GL_CURRENT_PROGRAM 0x8B8D #define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 #define GL_LOWER_LEFT 0x8CA1 #define GL_UPPER_LEFT 0x8CA2 #define GL_STENCIL_BACK_REF 0x8CA3 #define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 #define GL_STENCIL_BACK_WRITEMASK 0x8CA5 typedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name); typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); typedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader); typedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void); typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type); typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program); typedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader); typedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum* bufs); typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); typedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders); typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name); typedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param); typedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLuint obj, GLsizei maxLength, GLsizei* length, GLchar* source); typedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param); typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar* name); typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void** pointer); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program); typedef GLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader); typedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program); typedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const* string, const GLint* length); typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); typedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); typedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); typedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0); typedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); typedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); typedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); typedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); typedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); typedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program); typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer); #define glAttachShader GLEW_GET_FUN(__glewAttachShader) #define glBindAttribLocation GLEW_GET_FUN(__glewBindAttribLocation) #define glBlendEquationSeparate GLEW_GET_FUN(__glewBlendEquationSeparate) #define glCompileShader GLEW_GET_FUN(__glewCompileShader) #define glCreateProgram GLEW_GET_FUN(__glewCreateProgram) #define glCreateShader GLEW_GET_FUN(__glewCreateShader) #define glDeleteProgram GLEW_GET_FUN(__glewDeleteProgram) #define glDeleteShader GLEW_GET_FUN(__glewDeleteShader) #define glDetachShader GLEW_GET_FUN(__glewDetachShader) #define glDisableVertexAttribArray GLEW_GET_FUN(__glewDisableVertexAttribArray) #define glDrawBuffers GLEW_GET_FUN(__glewDrawBuffers) #define glEnableVertexAttribArray GLEW_GET_FUN(__glewEnableVertexAttribArray) #define glGetActiveAttrib GLEW_GET_FUN(__glewGetActiveAttrib) #define glGetActiveUniform GLEW_GET_FUN(__glewGetActiveUniform) #define glGetAttachedShaders GLEW_GET_FUN(__glewGetAttachedShaders) #define glGetAttribLocation GLEW_GET_FUN(__glewGetAttribLocation) #define glGetProgramInfoLog GLEW_GET_FUN(__glewGetProgramInfoLog) #define glGetProgramiv GLEW_GET_FUN(__glewGetProgramiv) #define glGetShaderInfoLog GLEW_GET_FUN(__glewGetShaderInfoLog) #define glGetShaderSource GLEW_GET_FUN(__glewGetShaderSource) #define glGetShaderiv GLEW_GET_FUN(__glewGetShaderiv) #define glGetUniformLocation GLEW_GET_FUN(__glewGetUniformLocation) #define glGetUniformfv GLEW_GET_FUN(__glewGetUniformfv) #define glGetUniformiv GLEW_GET_FUN(__glewGetUniformiv) #define glGetVertexAttribPointerv GLEW_GET_FUN(__glewGetVertexAttribPointerv) #define glGetVertexAttribdv GLEW_GET_FUN(__glewGetVertexAttribdv) #define glGetVertexAttribfv GLEW_GET_FUN(__glewGetVertexAttribfv) #define glGetVertexAttribiv GLEW_GET_FUN(__glewGetVertexAttribiv) #define glIsProgram GLEW_GET_FUN(__glewIsProgram) #define glIsShader GLEW_GET_FUN(__glewIsShader) #define glLinkProgram GLEW_GET_FUN(__glewLinkProgram) #define glShaderSource GLEW_GET_FUN(__glewShaderSource) #define glStencilFuncSeparate GLEW_GET_FUN(__glewStencilFuncSeparate) #define glStencilMaskSeparate GLEW_GET_FUN(__glewStencilMaskSeparate) #define glStencilOpSeparate GLEW_GET_FUN(__glewStencilOpSeparate) #define glUniform1f GLEW_GET_FUN(__glewUniform1f) #define glUniform1fv GLEW_GET_FUN(__glewUniform1fv) #define glUniform1i GLEW_GET_FUN(__glewUniform1i) #define glUniform1iv GLEW_GET_FUN(__glewUniform1iv) #define glUniform2f GLEW_GET_FUN(__glewUniform2f) #define glUniform2fv GLEW_GET_FUN(__glewUniform2fv) #define glUniform2i GLEW_GET_FUN(__glewUniform2i) #define glUniform2iv GLEW_GET_FUN(__glewUniform2iv) #define glUniform3f GLEW_GET_FUN(__glewUniform3f) #define glUniform3fv GLEW_GET_FUN(__glewUniform3fv) #define glUniform3i GLEW_GET_FUN(__glewUniform3i) #define glUniform3iv GLEW_GET_FUN(__glewUniform3iv) #define glUniform4f GLEW_GET_FUN(__glewUniform4f) #define glUniform4fv GLEW_GET_FUN(__glewUniform4fv) #define glUniform4i GLEW_GET_FUN(__glewUniform4i) #define glUniform4iv GLEW_GET_FUN(__glewUniform4iv) #define glUniformMatrix2fv GLEW_GET_FUN(__glewUniformMatrix2fv) #define glUniformMatrix3fv GLEW_GET_FUN(__glewUniformMatrix3fv) #define glUniformMatrix4fv GLEW_GET_FUN(__glewUniformMatrix4fv) #define glUseProgram GLEW_GET_FUN(__glewUseProgram) #define glValidateProgram GLEW_GET_FUN(__glewValidateProgram) #define glVertexAttrib1d GLEW_GET_FUN(__glewVertexAttrib1d) #define glVertexAttrib1dv GLEW_GET_FUN(__glewVertexAttrib1dv) #define glVertexAttrib1f GLEW_GET_FUN(__glewVertexAttrib1f) #define glVertexAttrib1fv GLEW_GET_FUN(__glewVertexAttrib1fv) #define glVertexAttrib1s GLEW_GET_FUN(__glewVertexAttrib1s) #define glVertexAttrib1sv GLEW_GET_FUN(__glewVertexAttrib1sv) #define glVertexAttrib2d GLEW_GET_FUN(__glewVertexAttrib2d) #define glVertexAttrib2dv GLEW_GET_FUN(__glewVertexAttrib2dv) #define glVertexAttrib2f GLEW_GET_FUN(__glewVertexAttrib2f) #define glVertexAttrib2fv GLEW_GET_FUN(__glewVertexAttrib2fv) #define glVertexAttrib2s GLEW_GET_FUN(__glewVertexAttrib2s) #define glVertexAttrib2sv GLEW_GET_FUN(__glewVertexAttrib2sv) #define glVertexAttrib3d GLEW_GET_FUN(__glewVertexAttrib3d) #define glVertexAttrib3dv GLEW_GET_FUN(__glewVertexAttrib3dv) #define glVertexAttrib3f GLEW_GET_FUN(__glewVertexAttrib3f) #define glVertexAttrib3fv GLEW_GET_FUN(__glewVertexAttrib3fv) #define glVertexAttrib3s GLEW_GET_FUN(__glewVertexAttrib3s) #define glVertexAttrib3sv GLEW_GET_FUN(__glewVertexAttrib3sv) #define glVertexAttrib4Nbv GLEW_GET_FUN(__glewVertexAttrib4Nbv) #define glVertexAttrib4Niv GLEW_GET_FUN(__glewVertexAttrib4Niv) #define glVertexAttrib4Nsv GLEW_GET_FUN(__glewVertexAttrib4Nsv) #define glVertexAttrib4Nub GLEW_GET_FUN(__glewVertexAttrib4Nub) #define glVertexAttrib4Nubv GLEW_GET_FUN(__glewVertexAttrib4Nubv) #define glVertexAttrib4Nuiv GLEW_GET_FUN(__glewVertexAttrib4Nuiv) #define glVertexAttrib4Nusv GLEW_GET_FUN(__glewVertexAttrib4Nusv) #define glVertexAttrib4bv GLEW_GET_FUN(__glewVertexAttrib4bv) #define glVertexAttrib4d GLEW_GET_FUN(__glewVertexAttrib4d) #define glVertexAttrib4dv GLEW_GET_FUN(__glewVertexAttrib4dv) #define glVertexAttrib4f GLEW_GET_FUN(__glewVertexAttrib4f) #define glVertexAttrib4fv GLEW_GET_FUN(__glewVertexAttrib4fv) #define glVertexAttrib4iv GLEW_GET_FUN(__glewVertexAttrib4iv) #define glVertexAttrib4s GLEW_GET_FUN(__glewVertexAttrib4s) #define glVertexAttrib4sv GLEW_GET_FUN(__glewVertexAttrib4sv) #define glVertexAttrib4ubv GLEW_GET_FUN(__glewVertexAttrib4ubv) #define glVertexAttrib4uiv GLEW_GET_FUN(__glewVertexAttrib4uiv) #define glVertexAttrib4usv GLEW_GET_FUN(__glewVertexAttrib4usv) #define glVertexAttribPointer GLEW_GET_FUN(__glewVertexAttribPointer) #define GLEW_VERSION_2_0 GLEW_GET_VAR(__GLEW_VERSION_2_0) #endif /* GL_VERSION_2_0 */ /* ----------------------------- GL_VERSION_2_1 ---------------------------- */ #ifndef GL_VERSION_2_1 #define GL_VERSION_2_1 1 #define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F #define GL_PIXEL_PACK_BUFFER 0x88EB #define GL_PIXEL_UNPACK_BUFFER 0x88EC #define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED #define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF #define GL_FLOAT_MAT2x3 0x8B65 #define GL_FLOAT_MAT2x4 0x8B66 #define GL_FLOAT_MAT3x2 0x8B67 #define GL_FLOAT_MAT3x4 0x8B68 #define GL_FLOAT_MAT4x2 0x8B69 #define GL_FLOAT_MAT4x3 0x8B6A #define GL_SRGB 0x8C40 #define GL_SRGB8 0x8C41 #define GL_SRGB_ALPHA 0x8C42 #define GL_SRGB8_ALPHA8 0x8C43 #define GL_SLUMINANCE_ALPHA 0x8C44 #define GL_SLUMINANCE8_ALPHA8 0x8C45 #define GL_SLUMINANCE 0x8C46 #define GL_SLUMINANCE8 0x8C47 #define GL_COMPRESSED_SRGB 0x8C48 #define GL_COMPRESSED_SRGB_ALPHA 0x8C49 #define GL_COMPRESSED_SLUMINANCE 0x8C4A #define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); #define glUniformMatrix2x3fv GLEW_GET_FUN(__glewUniformMatrix2x3fv) #define glUniformMatrix2x4fv GLEW_GET_FUN(__glewUniformMatrix2x4fv) #define glUniformMatrix3x2fv GLEW_GET_FUN(__glewUniformMatrix3x2fv) #define glUniformMatrix3x4fv GLEW_GET_FUN(__glewUniformMatrix3x4fv) #define glUniformMatrix4x2fv GLEW_GET_FUN(__glewUniformMatrix4x2fv) #define glUniformMatrix4x3fv GLEW_GET_FUN(__glewUniformMatrix4x3fv) #define GLEW_VERSION_2_1 GLEW_GET_VAR(__GLEW_VERSION_2_1) #endif /* GL_VERSION_2_1 */ /* ----------------------------- GL_VERSION_3_0 ---------------------------- */ #ifndef GL_VERSION_3_0 #define GL_VERSION_3_0 1 #define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0 #define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1 #define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2 #define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3 #define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4 #define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5 #define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB #define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES #define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS #define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 #define GL_MAJOR_VERSION 0x821B #define GL_MINOR_VERSION 0x821C #define GL_NUM_EXTENSIONS 0x821D #define GL_CONTEXT_FLAGS 0x821E #define GL_DEPTH_BUFFER 0x8223 #define GL_STENCIL_BUFFER 0x8224 #define GL_RGBA32F 0x8814 #define GL_RGB32F 0x8815 #define GL_RGBA16F 0x881A #define GL_RGB16F 0x881B #define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD #define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF #define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 #define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 #define GL_CLAMP_VERTEX_COLOR 0x891A #define GL_CLAMP_FRAGMENT_COLOR 0x891B #define GL_CLAMP_READ_COLOR 0x891C #define GL_FIXED_ONLY 0x891D #define GL_TEXTURE_RED_TYPE 0x8C10 #define GL_TEXTURE_GREEN_TYPE 0x8C11 #define GL_TEXTURE_BLUE_TYPE 0x8C12 #define GL_TEXTURE_ALPHA_TYPE 0x8C13 #define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 #define GL_TEXTURE_INTENSITY_TYPE 0x8C15 #define GL_TEXTURE_DEPTH_TYPE 0x8C16 #define GL_TEXTURE_1D_ARRAY 0x8C18 #define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 #define GL_TEXTURE_2D_ARRAY 0x8C1A #define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B #define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C #define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D #define GL_R11F_G11F_B10F 0x8C3A #define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B #define GL_RGB9_E5 0x8C3D #define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E #define GL_TEXTURE_SHARED_SIZE 0x8C3F #define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 #define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 #define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 #define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 #define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 #define GL_PRIMITIVES_GENERATED 0x8C87 #define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 #define GL_RASTERIZER_DISCARD 0x8C89 #define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B #define GL_INTERLEAVED_ATTRIBS 0x8C8C #define GL_SEPARATE_ATTRIBS 0x8C8D #define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E #define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F #define GL_RGBA32UI 0x8D70 #define GL_RGB32UI 0x8D71 #define GL_RGBA16UI 0x8D76 #define GL_RGB16UI 0x8D77 #define GL_RGBA8UI 0x8D7C #define GL_RGB8UI 0x8D7D #define GL_RGBA32I 0x8D82 #define GL_RGB32I 0x8D83 #define GL_RGBA16I 0x8D88 #define GL_RGB16I 0x8D89 #define GL_RGBA8I 0x8D8E #define GL_RGB8I 0x8D8F #define GL_RED_INTEGER 0x8D94 #define GL_GREEN_INTEGER 0x8D95 #define GL_BLUE_INTEGER 0x8D96 #define GL_ALPHA_INTEGER 0x8D97 #define GL_RGB_INTEGER 0x8D98 #define GL_RGBA_INTEGER 0x8D99 #define GL_BGR_INTEGER 0x8D9A #define GL_BGRA_INTEGER 0x8D9B #define GL_SAMPLER_1D_ARRAY 0x8DC0 #define GL_SAMPLER_2D_ARRAY 0x8DC1 #define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 #define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 #define GL_SAMPLER_CUBE_SHADOW 0x8DC5 #define GL_UNSIGNED_INT_VEC2 0x8DC6 #define GL_UNSIGNED_INT_VEC3 0x8DC7 #define GL_UNSIGNED_INT_VEC4 0x8DC8 #define GL_INT_SAMPLER_1D 0x8DC9 #define GL_INT_SAMPLER_2D 0x8DCA #define GL_INT_SAMPLER_3D 0x8DCB #define GL_INT_SAMPLER_CUBE 0x8DCC #define GL_INT_SAMPLER_1D_ARRAY 0x8DCE #define GL_INT_SAMPLER_2D_ARRAY 0x8DCF #define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 #define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 #define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 #define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 #define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 #define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 #define GL_QUERY_WAIT 0x8E13 #define GL_QUERY_NO_WAIT 0x8E14 #define GL_QUERY_BY_REGION_WAIT 0x8E15 #define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 typedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint colorNumber, const GLchar* name); typedef void (GLAPIENTRY * PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); typedef void (GLAPIENTRY * PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawBuffer, GLfloat depth, GLint stencil); typedef void (GLAPIENTRY * PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawBuffer, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawBuffer, const GLint* value); typedef void (GLAPIENTRY * PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawBuffer, const GLuint* value); typedef void (GLAPIENTRY * PFNGLCOLORMASKIPROC) (GLuint buf, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); typedef void (GLAPIENTRY * PFNGLDISABLEIPROC) (GLenum cap, GLuint index); typedef void (GLAPIENTRY * PFNGLENABLEIPROC) (GLenum cap, GLuint index); typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERPROC) (void); typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKPROC) (void); typedef void (GLAPIENTRY * PFNGLGETBOOLEANI_VPROC) (GLenum pname, GLuint index, GLboolean* data); typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar* name); typedef const GLubyte* (GLAPIENTRY * PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name); typedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint* params); typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDIPROC) (GLenum cap, GLuint index); typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint* params); typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode); typedef void (GLAPIENTRY * PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); typedef void (GLAPIENTRY * PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); typedef void (GLAPIENTRY * PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); typedef void (GLAPIENTRY * PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint v0); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint* v0); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint v0); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint* v0); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint v0, GLint v1); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint* v0); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint v0, GLuint v1); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint* v0); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint v0, GLint v1, GLint v2); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint* v0); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint v0, GLuint v1, GLuint v2); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint* v0); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte* v0); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint* v0); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort* v0); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte* v0); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint* v0); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort* v0); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void*pointer); #define glBeginConditionalRender GLEW_GET_FUN(__glewBeginConditionalRender) #define glBeginTransformFeedback GLEW_GET_FUN(__glewBeginTransformFeedback) #define glBindFragDataLocation GLEW_GET_FUN(__glewBindFragDataLocation) #define glClampColor GLEW_GET_FUN(__glewClampColor) #define glClearBufferfi GLEW_GET_FUN(__glewClearBufferfi) #define glClearBufferfv GLEW_GET_FUN(__glewClearBufferfv) #define glClearBufferiv GLEW_GET_FUN(__glewClearBufferiv) #define glClearBufferuiv GLEW_GET_FUN(__glewClearBufferuiv) #define glColorMaski GLEW_GET_FUN(__glewColorMaski) #define glDisablei GLEW_GET_FUN(__glewDisablei) #define glEnablei GLEW_GET_FUN(__glewEnablei) #define glEndConditionalRender GLEW_GET_FUN(__glewEndConditionalRender) #define glEndTransformFeedback GLEW_GET_FUN(__glewEndTransformFeedback) #define glGetBooleani_v GLEW_GET_FUN(__glewGetBooleani_v) #define glGetFragDataLocation GLEW_GET_FUN(__glewGetFragDataLocation) #define glGetStringi GLEW_GET_FUN(__glewGetStringi) #define glGetTexParameterIiv GLEW_GET_FUN(__glewGetTexParameterIiv) #define glGetTexParameterIuiv GLEW_GET_FUN(__glewGetTexParameterIuiv) #define glGetTransformFeedbackVarying GLEW_GET_FUN(__glewGetTransformFeedbackVarying) #define glGetUniformuiv GLEW_GET_FUN(__glewGetUniformuiv) #define glGetVertexAttribIiv GLEW_GET_FUN(__glewGetVertexAttribIiv) #define glGetVertexAttribIuiv GLEW_GET_FUN(__glewGetVertexAttribIuiv) #define glIsEnabledi GLEW_GET_FUN(__glewIsEnabledi) #define glTexParameterIiv GLEW_GET_FUN(__glewTexParameterIiv) #define glTexParameterIuiv GLEW_GET_FUN(__glewTexParameterIuiv) #define glTransformFeedbackVaryings GLEW_GET_FUN(__glewTransformFeedbackVaryings) #define glUniform1ui GLEW_GET_FUN(__glewUniform1ui) #define glUniform1uiv GLEW_GET_FUN(__glewUniform1uiv) #define glUniform2ui GLEW_GET_FUN(__glewUniform2ui) #define glUniform2uiv GLEW_GET_FUN(__glewUniform2uiv) #define glUniform3ui GLEW_GET_FUN(__glewUniform3ui) #define glUniform3uiv GLEW_GET_FUN(__glewUniform3uiv) #define glUniform4ui GLEW_GET_FUN(__glewUniform4ui) #define glUniform4uiv GLEW_GET_FUN(__glewUniform4uiv) #define glVertexAttribI1i GLEW_GET_FUN(__glewVertexAttribI1i) #define glVertexAttribI1iv GLEW_GET_FUN(__glewVertexAttribI1iv) #define glVertexAttribI1ui GLEW_GET_FUN(__glewVertexAttribI1ui) #define glVertexAttribI1uiv GLEW_GET_FUN(__glewVertexAttribI1uiv) #define glVertexAttribI2i GLEW_GET_FUN(__glewVertexAttribI2i) #define glVertexAttribI2iv GLEW_GET_FUN(__glewVertexAttribI2iv) #define glVertexAttribI2ui GLEW_GET_FUN(__glewVertexAttribI2ui) #define glVertexAttribI2uiv GLEW_GET_FUN(__glewVertexAttribI2uiv) #define glVertexAttribI3i GLEW_GET_FUN(__glewVertexAttribI3i) #define glVertexAttribI3iv GLEW_GET_FUN(__glewVertexAttribI3iv) #define glVertexAttribI3ui GLEW_GET_FUN(__glewVertexAttribI3ui) #define glVertexAttribI3uiv GLEW_GET_FUN(__glewVertexAttribI3uiv) #define glVertexAttribI4bv GLEW_GET_FUN(__glewVertexAttribI4bv) #define glVertexAttribI4i GLEW_GET_FUN(__glewVertexAttribI4i) #define glVertexAttribI4iv GLEW_GET_FUN(__glewVertexAttribI4iv) #define glVertexAttribI4sv GLEW_GET_FUN(__glewVertexAttribI4sv) #define glVertexAttribI4ubv GLEW_GET_FUN(__glewVertexAttribI4ubv) #define glVertexAttribI4ui GLEW_GET_FUN(__glewVertexAttribI4ui) #define glVertexAttribI4uiv GLEW_GET_FUN(__glewVertexAttribI4uiv) #define glVertexAttribI4usv GLEW_GET_FUN(__glewVertexAttribI4usv) #define glVertexAttribIPointer GLEW_GET_FUN(__glewVertexAttribIPointer) #define GLEW_VERSION_3_0 GLEW_GET_VAR(__GLEW_VERSION_3_0) #endif /* GL_VERSION_3_0 */ /* ----------------------------- GL_VERSION_3_1 ---------------------------- */ #ifndef GL_VERSION_3_1 #define GL_VERSION_3_1 1 #define GL_TEXTURE_RECTANGLE 0x84F5 #define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 #define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 #define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 #define GL_SAMPLER_2D_RECT 0x8B63 #define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 #define GL_TEXTURE_BUFFER 0x8C2A #define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B #define GL_TEXTURE_BINDING_BUFFER 0x8C2C #define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D #define GL_TEXTURE_BUFFER_FORMAT 0x8C2E #define GL_SAMPLER_BUFFER 0x8DC2 #define GL_INT_SAMPLER_2D_RECT 0x8DCD #define GL_INT_SAMPLER_BUFFER 0x8DD0 #define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 #define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 #define GL_RED_SNORM 0x8F90 #define GL_RG_SNORM 0x8F91 #define GL_RGB_SNORM 0x8F92 #define GL_RGBA_SNORM 0x8F93 #define GL_R8_SNORM 0x8F94 #define GL_RG8_SNORM 0x8F95 #define GL_RGB8_SNORM 0x8F96 #define GL_RGBA8_SNORM 0x8F97 #define GL_R16_SNORM 0x8F98 #define GL_RG16_SNORM 0x8F99 #define GL_RGB16_SNORM 0x8F9A #define GL_RGBA16_SNORM 0x8F9B #define GL_SIGNED_NORMALIZED 0x8F9C #define GL_PRIMITIVE_RESTART 0x8F9D #define GL_PRIMITIVE_RESTART_INDEX 0x8F9E #define GL_BUFFER_ACCESS_FLAGS 0x911F #define GL_BUFFER_MAP_LENGTH 0x9120 #define GL_BUFFER_MAP_OFFSET 0x9121 typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint buffer); typedef void (GLAPIENTRY * PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalFormat, GLuint buffer); #define glDrawArraysInstanced GLEW_GET_FUN(__glewDrawArraysInstanced) #define glDrawElementsInstanced GLEW_GET_FUN(__glewDrawElementsInstanced) #define glPrimitiveRestartIndex GLEW_GET_FUN(__glewPrimitiveRestartIndex) #define glTexBuffer GLEW_GET_FUN(__glewTexBuffer) #define GLEW_VERSION_3_1 GLEW_GET_VAR(__GLEW_VERSION_3_1) #endif /* GL_VERSION_3_1 */ /* ----------------------------- GL_VERSION_3_2 ---------------------------- */ #ifndef GL_VERSION_3_2 #define GL_VERSION_3_2 1 #define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 #define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 #define GL_LINES_ADJACENCY 0x000A #define GL_LINE_STRIP_ADJACENCY 0x000B #define GL_TRIANGLES_ADJACENCY 0x000C #define GL_TRIANGLE_STRIP_ADJACENCY 0x000D #define GL_PROGRAM_POINT_SIZE 0x8642 #define GL_GEOMETRY_VERTICES_OUT 0x8916 #define GL_GEOMETRY_INPUT_TYPE 0x8917 #define GL_GEOMETRY_OUTPUT_TYPE 0x8918 #define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 #define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 #define GL_GEOMETRY_SHADER 0x8DD9 #define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF #define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 #define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 #define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 #define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 #define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 #define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 #define GL_CONTEXT_PROFILE_MASK 0x9126 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum value, GLint64 * data); typedef void (GLAPIENTRY * PFNGLGETINTEGER64I_VPROC) (GLenum pname, GLuint index, GLint64 * data); #define glFramebufferTexture GLEW_GET_FUN(__glewFramebufferTexture) #define glGetBufferParameteri64v GLEW_GET_FUN(__glewGetBufferParameteri64v) #define glGetInteger64i_v GLEW_GET_FUN(__glewGetInteger64i_v) #define GLEW_VERSION_3_2 GLEW_GET_VAR(__GLEW_VERSION_3_2) #endif /* GL_VERSION_3_2 */ /* ----------------------------- GL_VERSION_3_3 ---------------------------- */ #ifndef GL_VERSION_3_3 #define GL_VERSION_3_3 1 #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE #define GL_RGB10_A2UI 0x906F typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); #define glVertexAttribDivisor GLEW_GET_FUN(__glewVertexAttribDivisor) #define GLEW_VERSION_3_3 GLEW_GET_VAR(__GLEW_VERSION_3_3) #endif /* GL_VERSION_3_3 */ /* ----------------------------- GL_VERSION_4_0 ---------------------------- */ #ifndef GL_VERSION_4_0 #define GL_VERSION_4_0 1 #define GL_SAMPLE_SHADING 0x8C36 #define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 #define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E #define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F #define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS 0x8F9F #define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 #define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A #define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B #define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C #define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D #define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E #define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); typedef void (GLAPIENTRY * PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); typedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGPROC) (GLclampf value); #define glBlendEquationSeparatei GLEW_GET_FUN(__glewBlendEquationSeparatei) #define glBlendEquationi GLEW_GET_FUN(__glewBlendEquationi) #define glBlendFuncSeparatei GLEW_GET_FUN(__glewBlendFuncSeparatei) #define glBlendFunci GLEW_GET_FUN(__glewBlendFunci) #define glMinSampleShading GLEW_GET_FUN(__glewMinSampleShading) #define GLEW_VERSION_4_0 GLEW_GET_VAR(__GLEW_VERSION_4_0) #endif /* GL_VERSION_4_0 */ /* ----------------------------- GL_VERSION_4_1 ---------------------------- */ #ifndef GL_VERSION_4_1 #define GL_VERSION_4_1 1 #define GLEW_VERSION_4_1 GLEW_GET_VAR(__GLEW_VERSION_4_1) #endif /* GL_VERSION_4_1 */ /* ----------------------------- GL_VERSION_4_2 ---------------------------- */ #ifndef GL_VERSION_4_2 #define GL_VERSION_4_2 1 #define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 #define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 #define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C #define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D #define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E #define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F #define GL_COPY_READ_BUFFER_BINDING 0x8F36 #define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 #define GLEW_VERSION_4_2 GLEW_GET_VAR(__GLEW_VERSION_4_2) #endif /* GL_VERSION_4_2 */ /* ----------------------------- GL_VERSION_4_3 ---------------------------- */ #ifndef GL_VERSION_4_3 #define GL_VERSION_4_3 1 #define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 #define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E #define GLEW_VERSION_4_3 GLEW_GET_VAR(__GLEW_VERSION_4_3) #endif /* GL_VERSION_4_3 */ /* ----------------------------- GL_VERSION_4_4 ---------------------------- */ #ifndef GL_VERSION_4_4 #define GL_VERSION_4_4 1 #define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 #define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 #define GL_TEXTURE_BUFFER_BINDING 0x8C2A #define GLEW_VERSION_4_4 GLEW_GET_VAR(__GLEW_VERSION_4_4) #endif /* GL_VERSION_4_4 */ /* ----------------------------- GL_VERSION_4_5 ---------------------------- */ #ifndef GL_VERSION_4_5 #define GL_VERSION_4_5 1 #define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 typedef GLenum (GLAPIENTRY * PFNGLGETGRAPHICSRESETSTATUSPROC) (void); typedef void (GLAPIENTRY * PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *pixels); typedef void (GLAPIENTRY * PFNGLGETNTEXIMAGEPROC) (GLenum tex, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *pixels); typedef void (GLAPIENTRY * PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); #define glGetGraphicsResetStatus GLEW_GET_FUN(__glewGetGraphicsResetStatus) #define glGetnCompressedTexImage GLEW_GET_FUN(__glewGetnCompressedTexImage) #define glGetnTexImage GLEW_GET_FUN(__glewGetnTexImage) #define glGetnUniformdv GLEW_GET_FUN(__glewGetnUniformdv) #define GLEW_VERSION_4_5 GLEW_GET_VAR(__GLEW_VERSION_4_5) #endif /* GL_VERSION_4_5 */ /* -------------------------- GL_3DFX_multisample -------------------------- */ #ifndef GL_3DFX_multisample #define GL_3DFX_multisample 1 #define GL_MULTISAMPLE_3DFX 0x86B2 #define GL_SAMPLE_BUFFERS_3DFX 0x86B3 #define GL_SAMPLES_3DFX 0x86B4 #define GL_MULTISAMPLE_BIT_3DFX 0x20000000 #define GLEW_3DFX_multisample GLEW_GET_VAR(__GLEW_3DFX_multisample) #endif /* GL_3DFX_multisample */ /* ---------------------------- GL_3DFX_tbuffer ---------------------------- */ #ifndef GL_3DFX_tbuffer #define GL_3DFX_tbuffer 1 typedef void (GLAPIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); #define glTbufferMask3DFX GLEW_GET_FUN(__glewTbufferMask3DFX) #define GLEW_3DFX_tbuffer GLEW_GET_VAR(__GLEW_3DFX_tbuffer) #endif /* GL_3DFX_tbuffer */ /* -------------------- GL_3DFX_texture_compression_FXT1 ------------------- */ #ifndef GL_3DFX_texture_compression_FXT1 #define GL_3DFX_texture_compression_FXT1 1 #define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 #define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 #define GLEW_3DFX_texture_compression_FXT1 GLEW_GET_VAR(__GLEW_3DFX_texture_compression_FXT1) #endif /* GL_3DFX_texture_compression_FXT1 */ /* ----------------------- GL_AMD_blend_minmax_factor ---------------------- */ #ifndef GL_AMD_blend_minmax_factor #define GL_AMD_blend_minmax_factor 1 #define GL_FACTOR_MIN_AMD 0x901C #define GL_FACTOR_MAX_AMD 0x901D #define GLEW_AMD_blend_minmax_factor GLEW_GET_VAR(__GLEW_AMD_blend_minmax_factor) #endif /* GL_AMD_blend_minmax_factor */ /* ----------------------- GL_AMD_conservative_depth ----------------------- */ #ifndef GL_AMD_conservative_depth #define GL_AMD_conservative_depth 1 #define GLEW_AMD_conservative_depth GLEW_GET_VAR(__GLEW_AMD_conservative_depth) #endif /* GL_AMD_conservative_depth */ /* -------------------------- GL_AMD_debug_output -------------------------- */ #ifndef GL_AMD_debug_output #define GL_AMD_debug_output 1 #define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 #define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 #define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 #define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 #define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 #define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 #define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 #define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A #define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B #define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C #define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D #define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E #define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F #define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 typedef void (GLAPIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, void* userParam); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar* buf); typedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum* categories, GLuint* severities, GLuint* ids, GLsizei* lengths, GLchar* message); #define glDebugMessageCallbackAMD GLEW_GET_FUN(__glewDebugMessageCallbackAMD) #define glDebugMessageEnableAMD GLEW_GET_FUN(__glewDebugMessageEnableAMD) #define glDebugMessageInsertAMD GLEW_GET_FUN(__glewDebugMessageInsertAMD) #define glGetDebugMessageLogAMD GLEW_GET_FUN(__glewGetDebugMessageLogAMD) #define GLEW_AMD_debug_output GLEW_GET_VAR(__GLEW_AMD_debug_output) #endif /* GL_AMD_debug_output */ /* ---------------------- GL_AMD_depth_clamp_separate ---------------------- */ #ifndef GL_AMD_depth_clamp_separate #define GL_AMD_depth_clamp_separate 1 #define GL_DEPTH_CLAMP_NEAR_AMD 0x901E #define GL_DEPTH_CLAMP_FAR_AMD 0x901F #define GLEW_AMD_depth_clamp_separate GLEW_GET_VAR(__GLEW_AMD_depth_clamp_separate) #endif /* GL_AMD_depth_clamp_separate */ /* ----------------------- GL_AMD_draw_buffers_blend ----------------------- */ #ifndef GL_AMD_draw_buffers_blend #define GL_AMD_draw_buffers_blend 1 typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); typedef void (GLAPIENTRY * PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); #define glBlendEquationIndexedAMD GLEW_GET_FUN(__glewBlendEquationIndexedAMD) #define glBlendEquationSeparateIndexedAMD GLEW_GET_FUN(__glewBlendEquationSeparateIndexedAMD) #define glBlendFuncIndexedAMD GLEW_GET_FUN(__glewBlendFuncIndexedAMD) #define glBlendFuncSeparateIndexedAMD GLEW_GET_FUN(__glewBlendFuncSeparateIndexedAMD) #define GLEW_AMD_draw_buffers_blend GLEW_GET_VAR(__GLEW_AMD_draw_buffers_blend) #endif /* GL_AMD_draw_buffers_blend */ /* --------------------------- GL_AMD_gcn_shader --------------------------- */ #ifndef GL_AMD_gcn_shader #define GL_AMD_gcn_shader 1 #define GLEW_AMD_gcn_shader GLEW_GET_VAR(__GLEW_AMD_gcn_shader) #endif /* GL_AMD_gcn_shader */ /* ------------------------ GL_AMD_gpu_shader_int64 ------------------------ */ #ifndef GL_AMD_gpu_shader_int64 #define GL_AMD_gpu_shader_int64 1 #define GLEW_AMD_gpu_shader_int64 GLEW_GET_VAR(__GLEW_AMD_gpu_shader_int64) #endif /* GL_AMD_gpu_shader_int64 */ /* ---------------------- GL_AMD_interleaved_elements ---------------------- */ #ifndef GL_AMD_interleaved_elements #define GL_AMD_interleaved_elements 1 #define GL_RED 0x1903 #define GL_GREEN 0x1904 #define GL_BLUE 0x1905 #define GL_ALPHA 0x1906 #define GL_RG8UI 0x8238 #define GL_RG16UI 0x823A #define GL_RGBA8UI 0x8D7C #define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 #define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); #define glVertexAttribParameteriAMD GLEW_GET_FUN(__glewVertexAttribParameteriAMD) #define GLEW_AMD_interleaved_elements GLEW_GET_VAR(__GLEW_AMD_interleaved_elements) #endif /* GL_AMD_interleaved_elements */ /* ----------------------- GL_AMD_multi_draw_indirect ---------------------- */ #ifndef GL_AMD_multi_draw_indirect #define GL_AMD_multi_draw_indirect 1 typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); #define glMultiDrawArraysIndirectAMD GLEW_GET_FUN(__glewMultiDrawArraysIndirectAMD) #define glMultiDrawElementsIndirectAMD GLEW_GET_FUN(__glewMultiDrawElementsIndirectAMD) #define GLEW_AMD_multi_draw_indirect GLEW_GET_VAR(__GLEW_AMD_multi_draw_indirect) #endif /* GL_AMD_multi_draw_indirect */ /* ------------------------- GL_AMD_name_gen_delete ------------------------ */ #ifndef GL_AMD_name_gen_delete #define GL_AMD_name_gen_delete 1 #define GL_DATA_BUFFER_AMD 0x9151 #define GL_PERFORMANCE_MONITOR_AMD 0x9152 #define GL_QUERY_OBJECT_AMD 0x9153 #define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 #define GL_SAMPLER_OBJECT_AMD 0x9155 typedef void (GLAPIENTRY * PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint* names); typedef void (GLAPIENTRY * PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint* names); typedef GLboolean (GLAPIENTRY * PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); #define glDeleteNamesAMD GLEW_GET_FUN(__glewDeleteNamesAMD) #define glGenNamesAMD GLEW_GET_FUN(__glewGenNamesAMD) #define glIsNameAMD GLEW_GET_FUN(__glewIsNameAMD) #define GLEW_AMD_name_gen_delete GLEW_GET_VAR(__GLEW_AMD_name_gen_delete) #endif /* GL_AMD_name_gen_delete */ /* ---------------------- GL_AMD_occlusion_query_event --------------------- */ #ifndef GL_AMD_occlusion_query_event #define GL_AMD_occlusion_query_event 1 #define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 #define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 #define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 #define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 #define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F #define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF typedef void (GLAPIENTRY * PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); #define glQueryObjectParameteruiAMD GLEW_GET_FUN(__glewQueryObjectParameteruiAMD) #define GLEW_AMD_occlusion_query_event GLEW_GET_VAR(__GLEW_AMD_occlusion_query_event) #endif /* GL_AMD_occlusion_query_event */ /* ----------------------- GL_AMD_performance_monitor ---------------------- */ #ifndef GL_AMD_performance_monitor #define GL_AMD_performance_monitor 1 #define GL_COUNTER_TYPE_AMD 0x8BC0 #define GL_COUNTER_RANGE_AMD 0x8BC1 #define GL_UNSIGNED_INT64_AMD 0x8BC2 #define GL_PERCENTAGE_AMD 0x8BC3 #define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 #define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 #define GL_PERFMON_RESULT_AMD 0x8BC6 typedef void (GLAPIENTRY * PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); typedef void (GLAPIENTRY * PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors); typedef void (GLAPIENTRY * PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); typedef void (GLAPIENTRY * PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors); typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint *bytesWritten); typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, GLchar *counterString); typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint* numCounters, GLint *maxActiveCounters, GLsizei countersSize, GLuint *counters); typedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei* length, GLchar *groupString); typedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint* numGroups, GLsizei groupsSize, GLuint *groups); typedef void (GLAPIENTRY * PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* counterList); #define glBeginPerfMonitorAMD GLEW_GET_FUN(__glewBeginPerfMonitorAMD) #define glDeletePerfMonitorsAMD GLEW_GET_FUN(__glewDeletePerfMonitorsAMD) #define glEndPerfMonitorAMD GLEW_GET_FUN(__glewEndPerfMonitorAMD) #define glGenPerfMonitorsAMD GLEW_GET_FUN(__glewGenPerfMonitorsAMD) #define glGetPerfMonitorCounterDataAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterDataAMD) #define glGetPerfMonitorCounterInfoAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterInfoAMD) #define glGetPerfMonitorCounterStringAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterStringAMD) #define glGetPerfMonitorCountersAMD GLEW_GET_FUN(__glewGetPerfMonitorCountersAMD) #define glGetPerfMonitorGroupStringAMD GLEW_GET_FUN(__glewGetPerfMonitorGroupStringAMD) #define glGetPerfMonitorGroupsAMD GLEW_GET_FUN(__glewGetPerfMonitorGroupsAMD) #define glSelectPerfMonitorCountersAMD GLEW_GET_FUN(__glewSelectPerfMonitorCountersAMD) #define GLEW_AMD_performance_monitor GLEW_GET_VAR(__GLEW_AMD_performance_monitor) #endif /* GL_AMD_performance_monitor */ /* -------------------------- GL_AMD_pinned_memory ------------------------- */ #ifndef GL_AMD_pinned_memory #define GL_AMD_pinned_memory 1 #define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 #define GLEW_AMD_pinned_memory GLEW_GET_VAR(__GLEW_AMD_pinned_memory) #endif /* GL_AMD_pinned_memory */ /* ----------------------- GL_AMD_query_buffer_object ---------------------- */ #ifndef GL_AMD_query_buffer_object #define GL_AMD_query_buffer_object 1 #define GL_QUERY_BUFFER_AMD 0x9192 #define GL_QUERY_BUFFER_BINDING_AMD 0x9193 #define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 #define GLEW_AMD_query_buffer_object GLEW_GET_VAR(__GLEW_AMD_query_buffer_object) #endif /* GL_AMD_query_buffer_object */ /* ------------------------ GL_AMD_sample_positions ------------------------ */ #ifndef GL_AMD_sample_positions #define GL_AMD_sample_positions 1 #define GL_SUBSAMPLE_DISTANCE_AMD 0x883F typedef void (GLAPIENTRY * PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat* val); #define glSetMultisamplefvAMD GLEW_GET_FUN(__glewSetMultisamplefvAMD) #define GLEW_AMD_sample_positions GLEW_GET_VAR(__GLEW_AMD_sample_positions) #endif /* GL_AMD_sample_positions */ /* ------------------ GL_AMD_seamless_cubemap_per_texture ------------------ */ #ifndef GL_AMD_seamless_cubemap_per_texture #define GL_AMD_seamless_cubemap_per_texture 1 #define GL_TEXTURE_CUBE_MAP_SEAMLESS_ARB 0x884F #define GLEW_AMD_seamless_cubemap_per_texture GLEW_GET_VAR(__GLEW_AMD_seamless_cubemap_per_texture) #endif /* GL_AMD_seamless_cubemap_per_texture */ /* -------------------- GL_AMD_shader_atomic_counter_ops ------------------- */ #ifndef GL_AMD_shader_atomic_counter_ops #define GL_AMD_shader_atomic_counter_ops 1 #define GLEW_AMD_shader_atomic_counter_ops GLEW_GET_VAR(__GLEW_AMD_shader_atomic_counter_ops) #endif /* GL_AMD_shader_atomic_counter_ops */ /* ---------------------- GL_AMD_shader_stencil_export --------------------- */ #ifndef GL_AMD_shader_stencil_export #define GL_AMD_shader_stencil_export 1 #define GLEW_AMD_shader_stencil_export GLEW_GET_VAR(__GLEW_AMD_shader_stencil_export) #endif /* GL_AMD_shader_stencil_export */ /* ------------------- GL_AMD_shader_stencil_value_export ------------------ */ #ifndef GL_AMD_shader_stencil_value_export #define GL_AMD_shader_stencil_value_export 1 #define GLEW_AMD_shader_stencil_value_export GLEW_GET_VAR(__GLEW_AMD_shader_stencil_value_export) #endif /* GL_AMD_shader_stencil_value_export */ /* ---------------------- GL_AMD_shader_trinary_minmax --------------------- */ #ifndef GL_AMD_shader_trinary_minmax #define GL_AMD_shader_trinary_minmax 1 #define GLEW_AMD_shader_trinary_minmax GLEW_GET_VAR(__GLEW_AMD_shader_trinary_minmax) #endif /* GL_AMD_shader_trinary_minmax */ /* ------------------------- GL_AMD_sparse_texture ------------------------- */ #ifndef GL_AMD_sparse_texture #define GL_AMD_sparse_texture 1 #define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 #define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 #define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 #define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 #define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 #define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 #define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A #define GL_MIN_SPARSE_LEVEL_AMD 0x919B #define GL_MIN_LOD_WARNING_AMD 0x919C typedef void (GLAPIENTRY * PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); #define glTexStorageSparseAMD GLEW_GET_FUN(__glewTexStorageSparseAMD) #define glTextureStorageSparseAMD GLEW_GET_FUN(__glewTextureStorageSparseAMD) #define GLEW_AMD_sparse_texture GLEW_GET_VAR(__GLEW_AMD_sparse_texture) #endif /* GL_AMD_sparse_texture */ /* ------------------- GL_AMD_stencil_operation_extended ------------------- */ #ifndef GL_AMD_stencil_operation_extended #define GL_AMD_stencil_operation_extended 1 #define GL_SET_AMD 0x874A #define GL_REPLACE_VALUE_AMD 0x874B #define GL_STENCIL_OP_VALUE_AMD 0x874C #define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D typedef void (GLAPIENTRY * PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); #define glStencilOpValueAMD GLEW_GET_FUN(__glewStencilOpValueAMD) #define GLEW_AMD_stencil_operation_extended GLEW_GET_VAR(__GLEW_AMD_stencil_operation_extended) #endif /* GL_AMD_stencil_operation_extended */ /* ------------------------ GL_AMD_texture_texture4 ------------------------ */ #ifndef GL_AMD_texture_texture4 #define GL_AMD_texture_texture4 1 #define GLEW_AMD_texture_texture4 GLEW_GET_VAR(__GLEW_AMD_texture_texture4) #endif /* GL_AMD_texture_texture4 */ /* --------------- GL_AMD_transform_feedback3_lines_triangles -------------- */ #ifndef GL_AMD_transform_feedback3_lines_triangles #define GL_AMD_transform_feedback3_lines_triangles 1 #define GLEW_AMD_transform_feedback3_lines_triangles GLEW_GET_VAR(__GLEW_AMD_transform_feedback3_lines_triangles) #endif /* GL_AMD_transform_feedback3_lines_triangles */ /* ----------------------- GL_AMD_transform_feedback4 ---------------------- */ #ifndef GL_AMD_transform_feedback4 #define GL_AMD_transform_feedback4 1 #define GL_STREAM_RASTERIZATION_AMD 0x91A0 #define GLEW_AMD_transform_feedback4 GLEW_GET_VAR(__GLEW_AMD_transform_feedback4) #endif /* GL_AMD_transform_feedback4 */ /* ----------------------- GL_AMD_vertex_shader_layer ---------------------- */ #ifndef GL_AMD_vertex_shader_layer #define GL_AMD_vertex_shader_layer 1 #define GLEW_AMD_vertex_shader_layer GLEW_GET_VAR(__GLEW_AMD_vertex_shader_layer) #endif /* GL_AMD_vertex_shader_layer */ /* -------------------- GL_AMD_vertex_shader_tessellator ------------------- */ #ifndef GL_AMD_vertex_shader_tessellator #define GL_AMD_vertex_shader_tessellator 1 #define GL_SAMPLER_BUFFER_AMD 0x9001 #define GL_INT_SAMPLER_BUFFER_AMD 0x9002 #define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 #define GL_TESSELLATION_MODE_AMD 0x9004 #define GL_TESSELLATION_FACTOR_AMD 0x9005 #define GL_DISCRETE_AMD 0x9006 #define GL_CONTINUOUS_AMD 0x9007 typedef void (GLAPIENTRY * PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); typedef void (GLAPIENTRY * PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); #define glTessellationFactorAMD GLEW_GET_FUN(__glewTessellationFactorAMD) #define glTessellationModeAMD GLEW_GET_FUN(__glewTessellationModeAMD) #define GLEW_AMD_vertex_shader_tessellator GLEW_GET_VAR(__GLEW_AMD_vertex_shader_tessellator) #endif /* GL_AMD_vertex_shader_tessellator */ /* ------------------ GL_AMD_vertex_shader_viewport_index ------------------ */ #ifndef GL_AMD_vertex_shader_viewport_index #define GL_AMD_vertex_shader_viewport_index 1 #define GLEW_AMD_vertex_shader_viewport_index GLEW_GET_VAR(__GLEW_AMD_vertex_shader_viewport_index) #endif /* GL_AMD_vertex_shader_viewport_index */ /* ------------------------- GL_ANGLE_depth_texture ------------------------ */ #ifndef GL_ANGLE_depth_texture #define GL_ANGLE_depth_texture 1 #define GLEW_ANGLE_depth_texture GLEW_GET_VAR(__GLEW_ANGLE_depth_texture) #endif /* GL_ANGLE_depth_texture */ /* ----------------------- GL_ANGLE_framebuffer_blit ----------------------- */ #ifndef GL_ANGLE_framebuffer_blit #define GL_ANGLE_framebuffer_blit 1 #define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 #define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 #define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 #define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #define glBlitFramebufferANGLE GLEW_GET_FUN(__glewBlitFramebufferANGLE) #define GLEW_ANGLE_framebuffer_blit GLEW_GET_VAR(__GLEW_ANGLE_framebuffer_blit) #endif /* GL_ANGLE_framebuffer_blit */ /* -------------------- GL_ANGLE_framebuffer_multisample ------------------- */ #ifndef GL_ANGLE_framebuffer_multisample #define GL_ANGLE_framebuffer_multisample 1 #define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 #define GL_MAX_SAMPLES_ANGLE 0x8D57 typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #define glRenderbufferStorageMultisampleANGLE GLEW_GET_FUN(__glewRenderbufferStorageMultisampleANGLE) #define GLEW_ANGLE_framebuffer_multisample GLEW_GET_VAR(__GLEW_ANGLE_framebuffer_multisample) #endif /* GL_ANGLE_framebuffer_multisample */ /* ----------------------- GL_ANGLE_instanced_arrays ----------------------- */ #ifndef GL_ANGLE_instanced_arrays #define GL_ANGLE_instanced_arrays 1 #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor); #define glDrawArraysInstancedANGLE GLEW_GET_FUN(__glewDrawArraysInstancedANGLE) #define glDrawElementsInstancedANGLE GLEW_GET_FUN(__glewDrawElementsInstancedANGLE) #define glVertexAttribDivisorANGLE GLEW_GET_FUN(__glewVertexAttribDivisorANGLE) #define GLEW_ANGLE_instanced_arrays GLEW_GET_VAR(__GLEW_ANGLE_instanced_arrays) #endif /* GL_ANGLE_instanced_arrays */ /* -------------------- GL_ANGLE_pack_reverse_row_order -------------------- */ #ifndef GL_ANGLE_pack_reverse_row_order #define GL_ANGLE_pack_reverse_row_order 1 #define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 #define GLEW_ANGLE_pack_reverse_row_order GLEW_GET_VAR(__GLEW_ANGLE_pack_reverse_row_order) #endif /* GL_ANGLE_pack_reverse_row_order */ /* ------------------------ GL_ANGLE_program_binary ------------------------ */ #ifndef GL_ANGLE_program_binary #define GL_ANGLE_program_binary 1 #define GL_PROGRAM_BINARY_ANGLE 0x93A6 #define GLEW_ANGLE_program_binary GLEW_GET_VAR(__GLEW_ANGLE_program_binary) #endif /* GL_ANGLE_program_binary */ /* ------------------- GL_ANGLE_texture_compression_dxt1 ------------------- */ #ifndef GL_ANGLE_texture_compression_dxt1 #define GL_ANGLE_texture_compression_dxt1 1 #define GL_COMPRESSED_RGB_S3TC_DXT1_ANGLE 0x83F0 #define GL_COMPRESSED_RGBA_S3TC_DXT1_ANGLE 0x83F1 #define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 #define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 #define GLEW_ANGLE_texture_compression_dxt1 GLEW_GET_VAR(__GLEW_ANGLE_texture_compression_dxt1) #endif /* GL_ANGLE_texture_compression_dxt1 */ /* ------------------- GL_ANGLE_texture_compression_dxt3 ------------------- */ #ifndef GL_ANGLE_texture_compression_dxt3 #define GL_ANGLE_texture_compression_dxt3 1 #define GL_COMPRESSED_RGB_S3TC_DXT1_ANGLE 0x83F0 #define GL_COMPRESSED_RGBA_S3TC_DXT1_ANGLE 0x83F1 #define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 #define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 #define GLEW_ANGLE_texture_compression_dxt3 GLEW_GET_VAR(__GLEW_ANGLE_texture_compression_dxt3) #endif /* GL_ANGLE_texture_compression_dxt3 */ /* ------------------- GL_ANGLE_texture_compression_dxt5 ------------------- */ #ifndef GL_ANGLE_texture_compression_dxt5 #define GL_ANGLE_texture_compression_dxt5 1 #define GL_COMPRESSED_RGB_S3TC_DXT1_ANGLE 0x83F0 #define GL_COMPRESSED_RGBA_S3TC_DXT1_ANGLE 0x83F1 #define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 #define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 #define GLEW_ANGLE_texture_compression_dxt5 GLEW_GET_VAR(__GLEW_ANGLE_texture_compression_dxt5) #endif /* GL_ANGLE_texture_compression_dxt5 */ /* ------------------------- GL_ANGLE_texture_usage ------------------------ */ #ifndef GL_ANGLE_texture_usage #define GL_ANGLE_texture_usage 1 #define GL_TEXTURE_USAGE_ANGLE 0x93A2 #define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 #define GLEW_ANGLE_texture_usage GLEW_GET_VAR(__GLEW_ANGLE_texture_usage) #endif /* GL_ANGLE_texture_usage */ /* -------------------------- GL_ANGLE_timer_query ------------------------- */ #ifndef GL_ANGLE_timer_query #define GL_ANGLE_timer_query 1 #define GL_QUERY_COUNTER_BITS_ANGLE 0x8864 #define GL_CURRENT_QUERY_ANGLE 0x8865 #define GL_QUERY_RESULT_ANGLE 0x8866 #define GL_QUERY_RESULT_AVAILABLE_ANGLE 0x8867 #define GL_TIME_ELAPSED_ANGLE 0x88BF #define GL_TIMESTAMP_ANGLE 0x8E28 typedef void (GLAPIENTRY * PFNGLBEGINQUERYANGLEPROC) (GLenum target, GLuint id); typedef void (GLAPIENTRY * PFNGLDELETEQUERIESANGLEPROC) (GLsizei n, const GLuint* ids); typedef void (GLAPIENTRY * PFNGLENDQUERYANGLEPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLGENQUERIESANGLEPROC) (GLsizei n, GLuint* ids); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VANGLEPROC) (GLuint id, GLenum pname, GLint64* params); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVANGLEPROC) (GLuint id, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VANGLEPROC) (GLuint id, GLenum pname, GLuint64* params); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVANGLEPROC) (GLuint id, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETQUERYIVANGLEPROC) (GLenum target, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISQUERYANGLEPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLQUERYCOUNTERANGLEPROC) (GLuint id, GLenum target); #define glBeginQueryANGLE GLEW_GET_FUN(__glewBeginQueryANGLE) #define glDeleteQueriesANGLE GLEW_GET_FUN(__glewDeleteQueriesANGLE) #define glEndQueryANGLE GLEW_GET_FUN(__glewEndQueryANGLE) #define glGenQueriesANGLE GLEW_GET_FUN(__glewGenQueriesANGLE) #define glGetQueryObjecti64vANGLE GLEW_GET_FUN(__glewGetQueryObjecti64vANGLE) #define glGetQueryObjectivANGLE GLEW_GET_FUN(__glewGetQueryObjectivANGLE) #define glGetQueryObjectui64vANGLE GLEW_GET_FUN(__glewGetQueryObjectui64vANGLE) #define glGetQueryObjectuivANGLE GLEW_GET_FUN(__glewGetQueryObjectuivANGLE) #define glGetQueryivANGLE GLEW_GET_FUN(__glewGetQueryivANGLE) #define glIsQueryANGLE GLEW_GET_FUN(__glewIsQueryANGLE) #define glQueryCounterANGLE GLEW_GET_FUN(__glewQueryCounterANGLE) #define GLEW_ANGLE_timer_query GLEW_GET_VAR(__GLEW_ANGLE_timer_query) #endif /* GL_ANGLE_timer_query */ /* ------------------- GL_ANGLE_translated_shader_source ------------------- */ #ifndef GL_ANGLE_translated_shader_source #define GL_ANGLE_translated_shader_source 1 #define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 typedef void (GLAPIENTRY * PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); #define glGetTranslatedShaderSourceANGLE GLEW_GET_FUN(__glewGetTranslatedShaderSourceANGLE) #define GLEW_ANGLE_translated_shader_source GLEW_GET_VAR(__GLEW_ANGLE_translated_shader_source) #endif /* GL_ANGLE_translated_shader_source */ /* ----------------------- GL_APPLE_aux_depth_stencil ---------------------- */ #ifndef GL_APPLE_aux_depth_stencil #define GL_APPLE_aux_depth_stencil 1 #define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 #define GLEW_APPLE_aux_depth_stencil GLEW_GET_VAR(__GLEW_APPLE_aux_depth_stencil) #endif /* GL_APPLE_aux_depth_stencil */ /* ------------------------ GL_APPLE_client_storage ------------------------ */ #ifndef GL_APPLE_client_storage #define GL_APPLE_client_storage 1 #define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 #define GLEW_APPLE_client_storage GLEW_GET_VAR(__GLEW_APPLE_client_storage) #endif /* GL_APPLE_client_storage */ /* ------------------------- GL_APPLE_element_array ------------------------ */ #ifndef GL_APPLE_element_array #define GL_APPLE_element_array 1 #define GL_ELEMENT_ARRAY_APPLE 0x8A0C #define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D #define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint* first, const GLsizei *count, GLsizei primcount); #define glDrawElementArrayAPPLE GLEW_GET_FUN(__glewDrawElementArrayAPPLE) #define glDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewDrawRangeElementArrayAPPLE) #define glElementPointerAPPLE GLEW_GET_FUN(__glewElementPointerAPPLE) #define glMultiDrawElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawElementArrayAPPLE) #define glMultiDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawRangeElementArrayAPPLE) #define GLEW_APPLE_element_array GLEW_GET_VAR(__GLEW_APPLE_element_array) #endif /* GL_APPLE_element_array */ /* ----------------------------- GL_APPLE_fence ---------------------------- */ #ifndef GL_APPLE_fence #define GL_APPLE_fence 1 #define GL_DRAW_PIXELS_APPLE 0x8A0A #define GL_FENCE_APPLE 0x8A0B typedef void (GLAPIENTRY * PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint* fences); typedef void (GLAPIENTRY * PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); typedef void (GLAPIENTRY * PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); typedef void (GLAPIENTRY * PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint* fences); typedef GLboolean (GLAPIENTRY * PFNGLISFENCEAPPLEPROC) (GLuint fence); typedef void (GLAPIENTRY * PFNGLSETFENCEAPPLEPROC) (GLuint fence); typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCEAPPLEPROC) (GLuint fence); typedef GLboolean (GLAPIENTRY * PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); #define glDeleteFencesAPPLE GLEW_GET_FUN(__glewDeleteFencesAPPLE) #define glFinishFenceAPPLE GLEW_GET_FUN(__glewFinishFenceAPPLE) #define glFinishObjectAPPLE GLEW_GET_FUN(__glewFinishObjectAPPLE) #define glGenFencesAPPLE GLEW_GET_FUN(__glewGenFencesAPPLE) #define glIsFenceAPPLE GLEW_GET_FUN(__glewIsFenceAPPLE) #define glSetFenceAPPLE GLEW_GET_FUN(__glewSetFenceAPPLE) #define glTestFenceAPPLE GLEW_GET_FUN(__glewTestFenceAPPLE) #define glTestObjectAPPLE GLEW_GET_FUN(__glewTestObjectAPPLE) #define GLEW_APPLE_fence GLEW_GET_VAR(__GLEW_APPLE_fence) #endif /* GL_APPLE_fence */ /* ------------------------- GL_APPLE_float_pixels ------------------------- */ #ifndef GL_APPLE_float_pixels #define GL_APPLE_float_pixels 1 #define GL_HALF_APPLE 0x140B #define GL_RGBA_FLOAT32_APPLE 0x8814 #define GL_RGB_FLOAT32_APPLE 0x8815 #define GL_ALPHA_FLOAT32_APPLE 0x8816 #define GL_INTENSITY_FLOAT32_APPLE 0x8817 #define GL_LUMINANCE_FLOAT32_APPLE 0x8818 #define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 #define GL_RGBA_FLOAT16_APPLE 0x881A #define GL_RGB_FLOAT16_APPLE 0x881B #define GL_ALPHA_FLOAT16_APPLE 0x881C #define GL_INTENSITY_FLOAT16_APPLE 0x881D #define GL_LUMINANCE_FLOAT16_APPLE 0x881E #define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F #define GL_COLOR_FLOAT_APPLE 0x8A0F #define GLEW_APPLE_float_pixels GLEW_GET_VAR(__GLEW_APPLE_float_pixels) #endif /* GL_APPLE_float_pixels */ /* ---------------------- GL_APPLE_flush_buffer_range ---------------------- */ #ifndef GL_APPLE_flush_buffer_range #define GL_APPLE_flush_buffer_range 1 #define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 #define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 typedef void (GLAPIENTRY * PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); #define glBufferParameteriAPPLE GLEW_GET_FUN(__glewBufferParameteriAPPLE) #define glFlushMappedBufferRangeAPPLE GLEW_GET_FUN(__glewFlushMappedBufferRangeAPPLE) #define GLEW_APPLE_flush_buffer_range GLEW_GET_VAR(__GLEW_APPLE_flush_buffer_range) #endif /* GL_APPLE_flush_buffer_range */ /* ----------------------- GL_APPLE_object_purgeable ----------------------- */ #ifndef GL_APPLE_object_purgeable #define GL_APPLE_object_purgeable 1 #define GL_BUFFER_OBJECT_APPLE 0x85B3 #define GL_RELEASED_APPLE 0x8A19 #define GL_VOLATILE_APPLE 0x8A1A #define GL_RETAINED_APPLE 0x8A1B #define GL_UNDEFINED_APPLE 0x8A1C #define GL_PURGEABLE_APPLE 0x8A1D typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint* params); typedef GLenum (GLAPIENTRY * PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); typedef GLenum (GLAPIENTRY * PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); #define glGetObjectParameterivAPPLE GLEW_GET_FUN(__glewGetObjectParameterivAPPLE) #define glObjectPurgeableAPPLE GLEW_GET_FUN(__glewObjectPurgeableAPPLE) #define glObjectUnpurgeableAPPLE GLEW_GET_FUN(__glewObjectUnpurgeableAPPLE) #define GLEW_APPLE_object_purgeable GLEW_GET_VAR(__GLEW_APPLE_object_purgeable) #endif /* GL_APPLE_object_purgeable */ /* ------------------------- GL_APPLE_pixel_buffer ------------------------- */ #ifndef GL_APPLE_pixel_buffer #define GL_APPLE_pixel_buffer 1 #define GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE 0x8A10 #define GLEW_APPLE_pixel_buffer GLEW_GET_VAR(__GLEW_APPLE_pixel_buffer) #endif /* GL_APPLE_pixel_buffer */ /* ---------------------------- GL_APPLE_rgb_422 --------------------------- */ #ifndef GL_APPLE_rgb_422 #define GL_APPLE_rgb_422 1 #define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA #define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB #define GL_RGB_422_APPLE 0x8A1F #define GL_RGB_RAW_422_APPLE 0x8A51 #define GLEW_APPLE_rgb_422 GLEW_GET_VAR(__GLEW_APPLE_rgb_422) #endif /* GL_APPLE_rgb_422 */ /* --------------------------- GL_APPLE_row_bytes -------------------------- */ #ifndef GL_APPLE_row_bytes #define GL_APPLE_row_bytes 1 #define GL_PACK_ROW_BYTES_APPLE 0x8A15 #define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 #define GLEW_APPLE_row_bytes GLEW_GET_VAR(__GLEW_APPLE_row_bytes) #endif /* GL_APPLE_row_bytes */ /* ------------------------ GL_APPLE_specular_vector ----------------------- */ #ifndef GL_APPLE_specular_vector #define GL_APPLE_specular_vector 1 #define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 #define GLEW_APPLE_specular_vector GLEW_GET_VAR(__GLEW_APPLE_specular_vector) #endif /* GL_APPLE_specular_vector */ /* ------------------------- GL_APPLE_texture_range ------------------------ */ #ifndef GL_APPLE_texture_range #define GL_APPLE_texture_range 1 #define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 #define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 #define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC #define GL_STORAGE_PRIVATE_APPLE 0x85BD #define GL_STORAGE_CACHED_APPLE 0x85BE #define GL_STORAGE_SHARED_APPLE 0x85BF typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); typedef void (GLAPIENTRY * PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, void *pointer); #define glGetTexParameterPointervAPPLE GLEW_GET_FUN(__glewGetTexParameterPointervAPPLE) #define glTextureRangeAPPLE GLEW_GET_FUN(__glewTextureRangeAPPLE) #define GLEW_APPLE_texture_range GLEW_GET_VAR(__GLEW_APPLE_texture_range) #endif /* GL_APPLE_texture_range */ /* ------------------------ GL_APPLE_transform_hint ------------------------ */ #ifndef GL_APPLE_transform_hint #define GL_APPLE_transform_hint 1 #define GL_TRANSFORM_HINT_APPLE 0x85B1 #define GLEW_APPLE_transform_hint GLEW_GET_VAR(__GLEW_APPLE_transform_hint) #endif /* GL_APPLE_transform_hint */ /* ---------------------- GL_APPLE_vertex_array_object --------------------- */ #ifndef GL_APPLE_vertex_array_object #define GL_APPLE_vertex_array_object 1 #define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); #define glBindVertexArrayAPPLE GLEW_GET_FUN(__glewBindVertexArrayAPPLE) #define glDeleteVertexArraysAPPLE GLEW_GET_FUN(__glewDeleteVertexArraysAPPLE) #define glGenVertexArraysAPPLE GLEW_GET_FUN(__glewGenVertexArraysAPPLE) #define glIsVertexArrayAPPLE GLEW_GET_FUN(__glewIsVertexArrayAPPLE) #define GLEW_APPLE_vertex_array_object GLEW_GET_VAR(__GLEW_APPLE_vertex_array_object) #endif /* GL_APPLE_vertex_array_object */ /* ---------------------- GL_APPLE_vertex_array_range ---------------------- */ #ifndef GL_APPLE_vertex_array_range #define GL_APPLE_vertex_array_range 1 #define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D #define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E #define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F #define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE 0x8520 #define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 #define GL_STORAGE_CLIENT_APPLE 0x85B4 #define GL_STORAGE_CACHED_APPLE 0x85BE #define GL_STORAGE_SHARED_APPLE 0x85BF typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); #define glFlushVertexArrayRangeAPPLE GLEW_GET_FUN(__glewFlushVertexArrayRangeAPPLE) #define glVertexArrayParameteriAPPLE GLEW_GET_FUN(__glewVertexArrayParameteriAPPLE) #define glVertexArrayRangeAPPLE GLEW_GET_FUN(__glewVertexArrayRangeAPPLE) #define GLEW_APPLE_vertex_array_range GLEW_GET_VAR(__GLEW_APPLE_vertex_array_range) #endif /* GL_APPLE_vertex_array_range */ /* ------------------- GL_APPLE_vertex_program_evaluators ------------------ */ #ifndef GL_APPLE_vertex_program_evaluators #define GL_APPLE_vertex_program_evaluators 1 #define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 #define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 #define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 #define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 #define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 #define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 #define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 #define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 #define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 #define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble* points); typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat* points); typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble* points); typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat* points); #define glDisableVertexAttribAPPLE GLEW_GET_FUN(__glewDisableVertexAttribAPPLE) #define glEnableVertexAttribAPPLE GLEW_GET_FUN(__glewEnableVertexAttribAPPLE) #define glIsVertexAttribEnabledAPPLE GLEW_GET_FUN(__glewIsVertexAttribEnabledAPPLE) #define glMapVertexAttrib1dAPPLE GLEW_GET_FUN(__glewMapVertexAttrib1dAPPLE) #define glMapVertexAttrib1fAPPLE GLEW_GET_FUN(__glewMapVertexAttrib1fAPPLE) #define glMapVertexAttrib2dAPPLE GLEW_GET_FUN(__glewMapVertexAttrib2dAPPLE) #define glMapVertexAttrib2fAPPLE GLEW_GET_FUN(__glewMapVertexAttrib2fAPPLE) #define GLEW_APPLE_vertex_program_evaluators GLEW_GET_VAR(__GLEW_APPLE_vertex_program_evaluators) #endif /* GL_APPLE_vertex_program_evaluators */ /* --------------------------- GL_APPLE_ycbcr_422 -------------------------- */ #ifndef GL_APPLE_ycbcr_422 #define GL_APPLE_ycbcr_422 1 #define GL_YCBCR_422_APPLE 0x85B9 #define GLEW_APPLE_ycbcr_422 GLEW_GET_VAR(__GLEW_APPLE_ycbcr_422) #endif /* GL_APPLE_ycbcr_422 */ /* ------------------------ GL_ARB_ES2_compatibility ----------------------- */ #ifndef GL_ARB_ES2_compatibility #define GL_ARB_ES2_compatibility 1 #define GL_FIXED 0x140C #define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A #define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B #define GL_RGB565 0x8D62 #define GL_LOW_FLOAT 0x8DF0 #define GL_MEDIUM_FLOAT 0x8DF1 #define GL_HIGH_FLOAT 0x8DF2 #define GL_LOW_INT 0x8DF3 #define GL_MEDIUM_INT 0x8DF4 #define GL_HIGH_INT 0x8DF5 #define GL_SHADER_BINARY_FORMATS 0x8DF8 #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 #define GL_SHADER_COMPILER 0x8DFA #define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB #define GL_MAX_VARYING_VECTORS 0x8DFC #define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD typedef int GLfixed; typedef void (GLAPIENTRY * PFNGLCLEARDEPTHFPROC) (GLclampf d); typedef void (GLAPIENTRY * PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f); typedef void (GLAPIENTRY * PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint* range, GLint *precision); typedef void (GLAPIENTRY * PFNGLRELEASESHADERCOMPILERPROC) (void); typedef void (GLAPIENTRY * PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint* shaders, GLenum binaryformat, const void*binary, GLsizei length); #define glClearDepthf GLEW_GET_FUN(__glewClearDepthf) #define glDepthRangef GLEW_GET_FUN(__glewDepthRangef) #define glGetShaderPrecisionFormat GLEW_GET_FUN(__glewGetShaderPrecisionFormat) #define glReleaseShaderCompiler GLEW_GET_FUN(__glewReleaseShaderCompiler) #define glShaderBinary GLEW_GET_FUN(__glewShaderBinary) #define GLEW_ARB_ES2_compatibility GLEW_GET_VAR(__GLEW_ARB_ES2_compatibility) #endif /* GL_ARB_ES2_compatibility */ /* ----------------------- GL_ARB_ES3_1_compatibility ---------------------- */ #ifndef GL_ARB_ES3_1_compatibility #define GL_ARB_ES3_1_compatibility 1 typedef void (GLAPIENTRY * PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); #define glMemoryBarrierByRegion GLEW_GET_FUN(__glewMemoryBarrierByRegion) #define GLEW_ARB_ES3_1_compatibility GLEW_GET_VAR(__GLEW_ARB_ES3_1_compatibility) #endif /* GL_ARB_ES3_1_compatibility */ /* ----------------------- GL_ARB_ES3_2_compatibility ---------------------- */ #ifndef GL_ARB_ES3_2_compatibility #define GL_ARB_ES3_2_compatibility 1 #define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE #define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 #define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 typedef void (GLAPIENTRY * PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); #define glPrimitiveBoundingBoxARB GLEW_GET_FUN(__glewPrimitiveBoundingBoxARB) #define GLEW_ARB_ES3_2_compatibility GLEW_GET_VAR(__GLEW_ARB_ES3_2_compatibility) #endif /* GL_ARB_ES3_2_compatibility */ /* ------------------------ GL_ARB_ES3_compatibility ----------------------- */ #ifndef GL_ARB_ES3_compatibility #define GL_ARB_ES3_compatibility 1 #define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF #define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 #define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A #define GL_MAX_ELEMENT_INDEX 0x8D6B #define GL_COMPRESSED_R11_EAC 0x9270 #define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 #define GL_COMPRESSED_RG11_EAC 0x9272 #define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 #define GL_COMPRESSED_RGB8_ETC2 0x9274 #define GL_COMPRESSED_SRGB8_ETC2 0x9275 #define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 #define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 #define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 #define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 #define GLEW_ARB_ES3_compatibility GLEW_GET_VAR(__GLEW_ARB_ES3_compatibility) #endif /* GL_ARB_ES3_compatibility */ /* ------------------------ GL_ARB_arrays_of_arrays ------------------------ */ #ifndef GL_ARB_arrays_of_arrays #define GL_ARB_arrays_of_arrays 1 #define GLEW_ARB_arrays_of_arrays GLEW_GET_VAR(__GLEW_ARB_arrays_of_arrays) #endif /* GL_ARB_arrays_of_arrays */ /* -------------------------- GL_ARB_base_instance ------------------------- */ #ifndef GL_ARB_base_instance #define GL_ARB_base_instance 1 typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); #define glDrawArraysInstancedBaseInstance GLEW_GET_FUN(__glewDrawArraysInstancedBaseInstance) #define glDrawElementsInstancedBaseInstance GLEW_GET_FUN(__glewDrawElementsInstancedBaseInstance) #define glDrawElementsInstancedBaseVertexBaseInstance GLEW_GET_FUN(__glewDrawElementsInstancedBaseVertexBaseInstance) #define GLEW_ARB_base_instance GLEW_GET_VAR(__GLEW_ARB_base_instance) #endif /* GL_ARB_base_instance */ /* ------------------------ GL_ARB_bindless_texture ------------------------ */ #ifndef GL_ARB_bindless_texture #define GL_ARB_bindless_texture 1 #define GL_UNSIGNED_INT64_ARB 0x140F typedef GLuint64 (GLAPIENTRY * PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); typedef GLuint64 (GLAPIENTRY * PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); typedef GLuint64 (GLAPIENTRY * PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT* params); typedef GLboolean (GLAPIENTRY * PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); typedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); typedef void (GLAPIENTRY * PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); typedef void (GLAPIENTRY * PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); typedef void (GLAPIENTRY * PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); typedef void (GLAPIENTRY * PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* values); typedef void (GLAPIENTRY * PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); typedef void (GLAPIENTRY * PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT* v); #define glGetImageHandleARB GLEW_GET_FUN(__glewGetImageHandleARB) #define glGetTextureHandleARB GLEW_GET_FUN(__glewGetTextureHandleARB) #define glGetTextureSamplerHandleARB GLEW_GET_FUN(__glewGetTextureSamplerHandleARB) #define glGetVertexAttribLui64vARB GLEW_GET_FUN(__glewGetVertexAttribLui64vARB) #define glIsImageHandleResidentARB GLEW_GET_FUN(__glewIsImageHandleResidentARB) #define glIsTextureHandleResidentARB GLEW_GET_FUN(__glewIsTextureHandleResidentARB) #define glMakeImageHandleNonResidentARB GLEW_GET_FUN(__glewMakeImageHandleNonResidentARB) #define glMakeImageHandleResidentARB GLEW_GET_FUN(__glewMakeImageHandleResidentARB) #define glMakeTextureHandleNonResidentARB GLEW_GET_FUN(__glewMakeTextureHandleNonResidentARB) #define glMakeTextureHandleResidentARB GLEW_GET_FUN(__glewMakeTextureHandleResidentARB) #define glProgramUniformHandleui64ARB GLEW_GET_FUN(__glewProgramUniformHandleui64ARB) #define glProgramUniformHandleui64vARB GLEW_GET_FUN(__glewProgramUniformHandleui64vARB) #define glUniformHandleui64ARB GLEW_GET_FUN(__glewUniformHandleui64ARB) #define glUniformHandleui64vARB GLEW_GET_FUN(__glewUniformHandleui64vARB) #define glVertexAttribL1ui64ARB GLEW_GET_FUN(__glewVertexAttribL1ui64ARB) #define glVertexAttribL1ui64vARB GLEW_GET_FUN(__glewVertexAttribL1ui64vARB) #define GLEW_ARB_bindless_texture GLEW_GET_VAR(__GLEW_ARB_bindless_texture) #endif /* GL_ARB_bindless_texture */ /* ----------------------- GL_ARB_blend_func_extended ---------------------- */ #ifndef GL_ARB_blend_func_extended #define GL_ARB_blend_func_extended 1 #define GL_SRC1_COLOR 0x88F9 #define GL_ONE_MINUS_SRC1_COLOR 0x88FA #define GL_ONE_MINUS_SRC1_ALPHA 0x88FB #define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar * name); typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar * name); #define glBindFragDataLocationIndexed GLEW_GET_FUN(__glewBindFragDataLocationIndexed) #define glGetFragDataIndex GLEW_GET_FUN(__glewGetFragDataIndex) #define GLEW_ARB_blend_func_extended GLEW_GET_VAR(__GLEW_ARB_blend_func_extended) #endif /* GL_ARB_blend_func_extended */ /* ------------------------- GL_ARB_buffer_storage ------------------------- */ #ifndef GL_ARB_buffer_storage #define GL_ARB_buffer_storage 1 #define GL_MAP_READ_BIT 0x0001 #define GL_MAP_WRITE_BIT 0x0002 #define GL_MAP_PERSISTENT_BIT 0x00000040 #define GL_MAP_COHERENT_BIT 0x00000080 #define GL_DYNAMIC_STORAGE_BIT 0x0100 #define GL_CLIENT_STORAGE_BIT 0x0200 #define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 #define GL_BUFFER_IMMUTABLE_STORAGE 0x821F #define GL_BUFFER_STORAGE_FLAGS 0x8220 typedef void (GLAPIENTRY * PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); #define glBufferStorage GLEW_GET_FUN(__glewBufferStorage) #define glNamedBufferStorageEXT GLEW_GET_FUN(__glewNamedBufferStorageEXT) #define GLEW_ARB_buffer_storage GLEW_GET_VAR(__GLEW_ARB_buffer_storage) #endif /* GL_ARB_buffer_storage */ /* ---------------------------- GL_ARB_cl_event ---------------------------- */ #ifndef GL_ARB_cl_event #define GL_ARB_cl_event 1 #define GL_SYNC_CL_EVENT_ARB 0x8240 #define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 typedef struct _cl_context *cl_context; typedef struct _cl_event *cl_event; typedef GLsync (GLAPIENTRY * PFNGLCREATESYNCFROMCLEVENTARBPROC) (cl_context context, cl_event event, GLbitfield flags); #define glCreateSyncFromCLeventARB GLEW_GET_FUN(__glewCreateSyncFromCLeventARB) #define GLEW_ARB_cl_event GLEW_GET_VAR(__GLEW_ARB_cl_event) #endif /* GL_ARB_cl_event */ /* ----------------------- GL_ARB_clear_buffer_object ---------------------- */ #ifndef GL_ARB_clear_buffer_object #define GL_ARB_clear_buffer_object 1 typedef void (GLAPIENTRY * PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); typedef void (GLAPIENTRY * PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); typedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); typedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); #define glClearBufferData GLEW_GET_FUN(__glewClearBufferData) #define glClearBufferSubData GLEW_GET_FUN(__glewClearBufferSubData) #define glClearNamedBufferDataEXT GLEW_GET_FUN(__glewClearNamedBufferDataEXT) #define glClearNamedBufferSubDataEXT GLEW_GET_FUN(__glewClearNamedBufferSubDataEXT) #define GLEW_ARB_clear_buffer_object GLEW_GET_VAR(__GLEW_ARB_clear_buffer_object) #endif /* GL_ARB_clear_buffer_object */ /* -------------------------- GL_ARB_clear_texture ------------------------- */ #ifndef GL_ARB_clear_texture #define GL_ARB_clear_texture 1 #define GL_CLEAR_TEXTURE 0x9365 typedef void (GLAPIENTRY * PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); typedef void (GLAPIENTRY * PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); #define glClearTexImage GLEW_GET_FUN(__glewClearTexImage) #define glClearTexSubImage GLEW_GET_FUN(__glewClearTexSubImage) #define GLEW_ARB_clear_texture GLEW_GET_VAR(__GLEW_ARB_clear_texture) #endif /* GL_ARB_clear_texture */ /* -------------------------- GL_ARB_clip_control -------------------------- */ #ifndef GL_ARB_clip_control #define GL_ARB_clip_control 1 #define GL_LOWER_LEFT 0x8CA1 #define GL_UPPER_LEFT 0x8CA2 #define GL_CLIP_ORIGIN 0x935C #define GL_CLIP_DEPTH_MODE 0x935D #define GL_NEGATIVE_ONE_TO_ONE 0x935E #define GL_ZERO_TO_ONE 0x935F typedef void (GLAPIENTRY * PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth); #define glClipControl GLEW_GET_FUN(__glewClipControl) #define GLEW_ARB_clip_control GLEW_GET_VAR(__GLEW_ARB_clip_control) #endif /* GL_ARB_clip_control */ /* ----------------------- GL_ARB_color_buffer_float ----------------------- */ #ifndef GL_ARB_color_buffer_float #define GL_ARB_color_buffer_float 1 #define GL_RGBA_FLOAT_MODE_ARB 0x8820 #define GL_CLAMP_VERTEX_COLOR_ARB 0x891A #define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B #define GL_CLAMP_READ_COLOR_ARB 0x891C #define GL_FIXED_ONLY_ARB 0x891D typedef void (GLAPIENTRY * PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); #define glClampColorARB GLEW_GET_FUN(__glewClampColorARB) #define GLEW_ARB_color_buffer_float GLEW_GET_VAR(__GLEW_ARB_color_buffer_float) #endif /* GL_ARB_color_buffer_float */ /* -------------------------- GL_ARB_compatibility ------------------------- */ #ifndef GL_ARB_compatibility #define GL_ARB_compatibility 1 #define GLEW_ARB_compatibility GLEW_GET_VAR(__GLEW_ARB_compatibility) #endif /* GL_ARB_compatibility */ /* ---------------- GL_ARB_compressed_texture_pixel_storage ---------------- */ #ifndef GL_ARB_compressed_texture_pixel_storage #define GL_ARB_compressed_texture_pixel_storage 1 #define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 #define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 #define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 #define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A #define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B #define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C #define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D #define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E #define GLEW_ARB_compressed_texture_pixel_storage GLEW_GET_VAR(__GLEW_ARB_compressed_texture_pixel_storage) #endif /* GL_ARB_compressed_texture_pixel_storage */ /* ------------------------- GL_ARB_compute_shader ------------------------- */ #ifndef GL_ARB_compute_shader #define GL_ARB_compute_shader 1 #define GL_COMPUTE_SHADER_BIT 0x00000020 #define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 #define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 #define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 #define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 #define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 #define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 #define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB #define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED #define GL_DISPATCH_INDIRECT_BUFFER 0x90EE #define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF #define GL_COMPUTE_SHADER 0x91B9 #define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB #define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC #define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD #define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE #define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF typedef void (GLAPIENTRY * PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); typedef void (GLAPIENTRY * PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); #define glDispatchCompute GLEW_GET_FUN(__glewDispatchCompute) #define glDispatchComputeIndirect GLEW_GET_FUN(__glewDispatchComputeIndirect) #define GLEW_ARB_compute_shader GLEW_GET_VAR(__GLEW_ARB_compute_shader) #endif /* GL_ARB_compute_shader */ /* ------------------- GL_ARB_compute_variable_group_size ------------------ */ #ifndef GL_ARB_compute_variable_group_size #define GL_ARB_compute_variable_group_size 1 #define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB #define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF #define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 #define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 typedef void (GLAPIENTRY * PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); #define glDispatchComputeGroupSizeARB GLEW_GET_FUN(__glewDispatchComputeGroupSizeARB) #define GLEW_ARB_compute_variable_group_size GLEW_GET_VAR(__GLEW_ARB_compute_variable_group_size) #endif /* GL_ARB_compute_variable_group_size */ /* ------------------- GL_ARB_conditional_render_inverted ------------------ */ #ifndef GL_ARB_conditional_render_inverted #define GL_ARB_conditional_render_inverted 1 #define GL_QUERY_WAIT_INVERTED 0x8E17 #define GL_QUERY_NO_WAIT_INVERTED 0x8E18 #define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 #define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A #define GLEW_ARB_conditional_render_inverted GLEW_GET_VAR(__GLEW_ARB_conditional_render_inverted) #endif /* GL_ARB_conditional_render_inverted */ /* ----------------------- GL_ARB_conservative_depth ----------------------- */ #ifndef GL_ARB_conservative_depth #define GL_ARB_conservative_depth 1 #define GLEW_ARB_conservative_depth GLEW_GET_VAR(__GLEW_ARB_conservative_depth) #endif /* GL_ARB_conservative_depth */ /* --------------------------- GL_ARB_copy_buffer -------------------------- */ #ifndef GL_ARB_copy_buffer #define GL_ARB_copy_buffer 1 #define GL_COPY_READ_BUFFER 0x8F36 #define GL_COPY_WRITE_BUFFER 0x8F37 typedef void (GLAPIENTRY * PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readtarget, GLenum writetarget, GLintptr readoffset, GLintptr writeoffset, GLsizeiptr size); #define glCopyBufferSubData GLEW_GET_FUN(__glewCopyBufferSubData) #define GLEW_ARB_copy_buffer GLEW_GET_VAR(__GLEW_ARB_copy_buffer) #endif /* GL_ARB_copy_buffer */ /* --------------------------- GL_ARB_copy_image --------------------------- */ #ifndef GL_ARB_copy_image #define GL_ARB_copy_image 1 typedef void (GLAPIENTRY * PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); #define glCopyImageSubData GLEW_GET_FUN(__glewCopyImageSubData) #define GLEW_ARB_copy_image GLEW_GET_VAR(__GLEW_ARB_copy_image) #endif /* GL_ARB_copy_image */ /* -------------------------- GL_ARB_cull_distance ------------------------- */ #ifndef GL_ARB_cull_distance #define GL_ARB_cull_distance 1 #define GL_MAX_CULL_DISTANCES 0x82F9 #define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA #define GLEW_ARB_cull_distance GLEW_GET_VAR(__GLEW_ARB_cull_distance) #endif /* GL_ARB_cull_distance */ /* -------------------------- GL_ARB_debug_output -------------------------- */ #ifndef GL_ARB_debug_output #define GL_ARB_debug_output 1 #define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 #define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 #define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 #define GL_DEBUG_SOURCE_API_ARB 0x8246 #define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 #define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 #define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 #define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A #define GL_DEBUG_SOURCE_OTHER_ARB 0x824B #define GL_DEBUG_TYPE_ERROR_ARB 0x824C #define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D #define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E #define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F #define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 #define GL_DEBUG_TYPE_OTHER_ARB 0x8251 #define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 #define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 #define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 #define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 #define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 #define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 typedef void (GLAPIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf); typedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog); #define glDebugMessageCallbackARB GLEW_GET_FUN(__glewDebugMessageCallbackARB) #define glDebugMessageControlARB GLEW_GET_FUN(__glewDebugMessageControlARB) #define glDebugMessageInsertARB GLEW_GET_FUN(__glewDebugMessageInsertARB) #define glGetDebugMessageLogARB GLEW_GET_FUN(__glewGetDebugMessageLogARB) #define GLEW_ARB_debug_output GLEW_GET_VAR(__GLEW_ARB_debug_output) #endif /* GL_ARB_debug_output */ /* ----------------------- GL_ARB_depth_buffer_float ----------------------- */ #ifndef GL_ARB_depth_buffer_float #define GL_ARB_depth_buffer_float 1 #define GL_DEPTH_COMPONENT32F 0x8CAC #define GL_DEPTH32F_STENCIL8 0x8CAD #define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD #define GLEW_ARB_depth_buffer_float GLEW_GET_VAR(__GLEW_ARB_depth_buffer_float) #endif /* GL_ARB_depth_buffer_float */ /* --------------------------- GL_ARB_depth_clamp -------------------------- */ #ifndef GL_ARB_depth_clamp #define GL_ARB_depth_clamp 1 #define GL_DEPTH_CLAMP 0x864F #define GLEW_ARB_depth_clamp GLEW_GET_VAR(__GLEW_ARB_depth_clamp) #endif /* GL_ARB_depth_clamp */ /* -------------------------- GL_ARB_depth_texture ------------------------- */ #ifndef GL_ARB_depth_texture #define GL_ARB_depth_texture 1 #define GL_DEPTH_COMPONENT16_ARB 0x81A5 #define GL_DEPTH_COMPONENT24_ARB 0x81A6 #define GL_DEPTH_COMPONENT32_ARB 0x81A7 #define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A #define GL_DEPTH_TEXTURE_MODE_ARB 0x884B #define GLEW_ARB_depth_texture GLEW_GET_VAR(__GLEW_ARB_depth_texture) #endif /* GL_ARB_depth_texture */ /* ----------------------- GL_ARB_derivative_control ----------------------- */ #ifndef GL_ARB_derivative_control #define GL_ARB_derivative_control 1 #define GLEW_ARB_derivative_control GLEW_GET_VAR(__GLEW_ARB_derivative_control) #endif /* GL_ARB_derivative_control */ /* ----------------------- GL_ARB_direct_state_access ---------------------- */ #ifndef GL_ARB_direct_state_access #define GL_ARB_direct_state_access 1 #define GL_TEXTURE_TARGET 0x1006 #define GL_QUERY_TARGET 0x82EA typedef void (GLAPIENTRY * PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture); typedef void (GLAPIENTRY * PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); typedef GLenum (GLAPIENTRY * PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); typedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); typedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); typedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLfloat depth, GLint stencil); typedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint* value); typedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint* value); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint* buffers); typedef void (GLAPIENTRY * PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint* framebuffers); typedef void (GLAPIENTRY * PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint* pipelines); typedef void (GLAPIENTRY * PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint* ids); typedef void (GLAPIENTRY * PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint* renderbuffers); typedef void (GLAPIENTRY * PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint* samplers); typedef void (GLAPIENTRY * PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint* textures); typedef void (GLAPIENTRY * PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint* ids); typedef void (GLAPIENTRY * PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays); typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); typedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); typedef void (GLAPIENTRY * PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture); typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels); typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void** params); typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); typedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint* param); typedef void (GLAPIENTRY * PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id,GLuint buffer,GLenum pname,GLintptr offset); typedef void (GLAPIENTRY * PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id,GLuint buffer,GLenum pname,GLintptr offset); typedef void (GLAPIENTRY * PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id,GLuint buffer,GLenum pname,GLintptr offset); typedef void (GLAPIENTRY * PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id,GLuint buffer,GLenum pname,GLintptr offset); typedef void (GLAPIENTRY * PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64* param); typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint* param); typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint* param); typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64* param); typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint* param); typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint* param); typedef void (GLAPIENTRY * PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum* attachments); typedef void (GLAPIENTRY * PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height); typedef void * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access); typedef void * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum mode); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum* bufs); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum mode); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer); typedef void (GLAPIENTRY * PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint* params); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat* param); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint* param); typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer); typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint* buffers, const GLintptr *offsets, const GLsizei *strides); #define glBindTextureUnit GLEW_GET_FUN(__glewBindTextureUnit) #define glBlitNamedFramebuffer GLEW_GET_FUN(__glewBlitNamedFramebuffer) #define glCheckNamedFramebufferStatus GLEW_GET_FUN(__glewCheckNamedFramebufferStatus) #define glClearNamedBufferData GLEW_GET_FUN(__glewClearNamedBufferData) #define glClearNamedBufferSubData GLEW_GET_FUN(__glewClearNamedBufferSubData) #define glClearNamedFramebufferfi GLEW_GET_FUN(__glewClearNamedFramebufferfi) #define glClearNamedFramebufferfv GLEW_GET_FUN(__glewClearNamedFramebufferfv) #define glClearNamedFramebufferiv GLEW_GET_FUN(__glewClearNamedFramebufferiv) #define glClearNamedFramebufferuiv GLEW_GET_FUN(__glewClearNamedFramebufferuiv) #define glCompressedTextureSubImage1D GLEW_GET_FUN(__glewCompressedTextureSubImage1D) #define glCompressedTextureSubImage2D GLEW_GET_FUN(__glewCompressedTextureSubImage2D) #define glCompressedTextureSubImage3D GLEW_GET_FUN(__glewCompressedTextureSubImage3D) #define glCopyNamedBufferSubData GLEW_GET_FUN(__glewCopyNamedBufferSubData) #define glCopyTextureSubImage1D GLEW_GET_FUN(__glewCopyTextureSubImage1D) #define glCopyTextureSubImage2D GLEW_GET_FUN(__glewCopyTextureSubImage2D) #define glCopyTextureSubImage3D GLEW_GET_FUN(__glewCopyTextureSubImage3D) #define glCreateBuffers GLEW_GET_FUN(__glewCreateBuffers) #define glCreateFramebuffers GLEW_GET_FUN(__glewCreateFramebuffers) #define glCreateProgramPipelines GLEW_GET_FUN(__glewCreateProgramPipelines) #define glCreateQueries GLEW_GET_FUN(__glewCreateQueries) #define glCreateRenderbuffers GLEW_GET_FUN(__glewCreateRenderbuffers) #define glCreateSamplers GLEW_GET_FUN(__glewCreateSamplers) #define glCreateTextures GLEW_GET_FUN(__glewCreateTextures) #define glCreateTransformFeedbacks GLEW_GET_FUN(__glewCreateTransformFeedbacks) #define glCreateVertexArrays GLEW_GET_FUN(__glewCreateVertexArrays) #define glDisableVertexArrayAttrib GLEW_GET_FUN(__glewDisableVertexArrayAttrib) #define glEnableVertexArrayAttrib GLEW_GET_FUN(__glewEnableVertexArrayAttrib) #define glFlushMappedNamedBufferRange GLEW_GET_FUN(__glewFlushMappedNamedBufferRange) #define glGenerateTextureMipmap GLEW_GET_FUN(__glewGenerateTextureMipmap) #define glGetCompressedTextureImage GLEW_GET_FUN(__glewGetCompressedTextureImage) #define glGetNamedBufferParameteri64v GLEW_GET_FUN(__glewGetNamedBufferParameteri64v) #define glGetNamedBufferParameteriv GLEW_GET_FUN(__glewGetNamedBufferParameteriv) #define glGetNamedBufferPointerv GLEW_GET_FUN(__glewGetNamedBufferPointerv) #define glGetNamedBufferSubData GLEW_GET_FUN(__glewGetNamedBufferSubData) #define glGetNamedFramebufferAttachmentParameteriv GLEW_GET_FUN(__glewGetNamedFramebufferAttachmentParameteriv) #define glGetNamedFramebufferParameteriv GLEW_GET_FUN(__glewGetNamedFramebufferParameteriv) #define glGetNamedRenderbufferParameteriv GLEW_GET_FUN(__glewGetNamedRenderbufferParameteriv) #define glGetQueryBufferObjecti64v GLEW_GET_FUN(__glewGetQueryBufferObjecti64v) #define glGetQueryBufferObjectiv GLEW_GET_FUN(__glewGetQueryBufferObjectiv) #define glGetQueryBufferObjectui64v GLEW_GET_FUN(__glewGetQueryBufferObjectui64v) #define glGetQueryBufferObjectuiv GLEW_GET_FUN(__glewGetQueryBufferObjectuiv) #define glGetTextureImage GLEW_GET_FUN(__glewGetTextureImage) #define glGetTextureLevelParameterfv GLEW_GET_FUN(__glewGetTextureLevelParameterfv) #define glGetTextureLevelParameteriv GLEW_GET_FUN(__glewGetTextureLevelParameteriv) #define glGetTextureParameterIiv GLEW_GET_FUN(__glewGetTextureParameterIiv) #define glGetTextureParameterIuiv GLEW_GET_FUN(__glewGetTextureParameterIuiv) #define glGetTextureParameterfv GLEW_GET_FUN(__glewGetTextureParameterfv) #define glGetTextureParameteriv GLEW_GET_FUN(__glewGetTextureParameteriv) #define glGetTransformFeedbacki64_v GLEW_GET_FUN(__glewGetTransformFeedbacki64_v) #define glGetTransformFeedbacki_v GLEW_GET_FUN(__glewGetTransformFeedbacki_v) #define glGetTransformFeedbackiv GLEW_GET_FUN(__glewGetTransformFeedbackiv) #define glGetVertexArrayIndexed64iv GLEW_GET_FUN(__glewGetVertexArrayIndexed64iv) #define glGetVertexArrayIndexediv GLEW_GET_FUN(__glewGetVertexArrayIndexediv) #define glGetVertexArrayiv GLEW_GET_FUN(__glewGetVertexArrayiv) #define glInvalidateNamedFramebufferData GLEW_GET_FUN(__glewInvalidateNamedFramebufferData) #define glInvalidateNamedFramebufferSubData GLEW_GET_FUN(__glewInvalidateNamedFramebufferSubData) #define glMapNamedBuffer GLEW_GET_FUN(__glewMapNamedBuffer) #define glMapNamedBufferRange GLEW_GET_FUN(__glewMapNamedBufferRange) #define glNamedBufferData GLEW_GET_FUN(__glewNamedBufferData) #define glNamedBufferStorage GLEW_GET_FUN(__glewNamedBufferStorage) #define glNamedBufferSubData GLEW_GET_FUN(__glewNamedBufferSubData) #define glNamedFramebufferDrawBuffer GLEW_GET_FUN(__glewNamedFramebufferDrawBuffer) #define glNamedFramebufferDrawBuffers GLEW_GET_FUN(__glewNamedFramebufferDrawBuffers) #define glNamedFramebufferParameteri GLEW_GET_FUN(__glewNamedFramebufferParameteri) #define glNamedFramebufferReadBuffer GLEW_GET_FUN(__glewNamedFramebufferReadBuffer) #define glNamedFramebufferRenderbuffer GLEW_GET_FUN(__glewNamedFramebufferRenderbuffer) #define glNamedFramebufferTexture GLEW_GET_FUN(__glewNamedFramebufferTexture) #define glNamedFramebufferTextureLayer GLEW_GET_FUN(__glewNamedFramebufferTextureLayer) #define glNamedRenderbufferStorage GLEW_GET_FUN(__glewNamedRenderbufferStorage) #define glNamedRenderbufferStorageMultisample GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisample) #define glTextureBuffer GLEW_GET_FUN(__glewTextureBuffer) #define glTextureBufferRange GLEW_GET_FUN(__glewTextureBufferRange) #define glTextureParameterIiv GLEW_GET_FUN(__glewTextureParameterIiv) #define glTextureParameterIuiv GLEW_GET_FUN(__glewTextureParameterIuiv) #define glTextureParameterf GLEW_GET_FUN(__glewTextureParameterf) #define glTextureParameterfv GLEW_GET_FUN(__glewTextureParameterfv) #define glTextureParameteri GLEW_GET_FUN(__glewTextureParameteri) #define glTextureParameteriv GLEW_GET_FUN(__glewTextureParameteriv) #define glTextureStorage1D GLEW_GET_FUN(__glewTextureStorage1D) #define glTextureStorage2D GLEW_GET_FUN(__glewTextureStorage2D) #define glTextureStorage2DMultisample GLEW_GET_FUN(__glewTextureStorage2DMultisample) #define glTextureStorage3D GLEW_GET_FUN(__glewTextureStorage3D) #define glTextureStorage3DMultisample GLEW_GET_FUN(__glewTextureStorage3DMultisample) #define glTextureSubImage1D GLEW_GET_FUN(__glewTextureSubImage1D) #define glTextureSubImage2D GLEW_GET_FUN(__glewTextureSubImage2D) #define glTextureSubImage3D GLEW_GET_FUN(__glewTextureSubImage3D) #define glTransformFeedbackBufferBase GLEW_GET_FUN(__glewTransformFeedbackBufferBase) #define glTransformFeedbackBufferRange GLEW_GET_FUN(__glewTransformFeedbackBufferRange) #define glUnmapNamedBuffer GLEW_GET_FUN(__glewUnmapNamedBuffer) #define glVertexArrayAttribBinding GLEW_GET_FUN(__glewVertexArrayAttribBinding) #define glVertexArrayAttribFormat GLEW_GET_FUN(__glewVertexArrayAttribFormat) #define glVertexArrayAttribIFormat GLEW_GET_FUN(__glewVertexArrayAttribIFormat) #define glVertexArrayAttribLFormat GLEW_GET_FUN(__glewVertexArrayAttribLFormat) #define glVertexArrayBindingDivisor GLEW_GET_FUN(__glewVertexArrayBindingDivisor) #define glVertexArrayElementBuffer GLEW_GET_FUN(__glewVertexArrayElementBuffer) #define glVertexArrayVertexBuffer GLEW_GET_FUN(__glewVertexArrayVertexBuffer) #define glVertexArrayVertexBuffers GLEW_GET_FUN(__glewVertexArrayVertexBuffers) #define GLEW_ARB_direct_state_access GLEW_GET_VAR(__GLEW_ARB_direct_state_access) #endif /* GL_ARB_direct_state_access */ /* -------------------------- GL_ARB_draw_buffers -------------------------- */ #ifndef GL_ARB_draw_buffers #define GL_ARB_draw_buffers 1 #define GL_MAX_DRAW_BUFFERS_ARB 0x8824 #define GL_DRAW_BUFFER0_ARB 0x8825 #define GL_DRAW_BUFFER1_ARB 0x8826 #define GL_DRAW_BUFFER2_ARB 0x8827 #define GL_DRAW_BUFFER3_ARB 0x8828 #define GL_DRAW_BUFFER4_ARB 0x8829 #define GL_DRAW_BUFFER5_ARB 0x882A #define GL_DRAW_BUFFER6_ARB 0x882B #define GL_DRAW_BUFFER7_ARB 0x882C #define GL_DRAW_BUFFER8_ARB 0x882D #define GL_DRAW_BUFFER9_ARB 0x882E #define GL_DRAW_BUFFER10_ARB 0x882F #define GL_DRAW_BUFFER11_ARB 0x8830 #define GL_DRAW_BUFFER12_ARB 0x8831 #define GL_DRAW_BUFFER13_ARB 0x8832 #define GL_DRAW_BUFFER14_ARB 0x8833 #define GL_DRAW_BUFFER15_ARB 0x8834 typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum* bufs); #define glDrawBuffersARB GLEW_GET_FUN(__glewDrawBuffersARB) #define GLEW_ARB_draw_buffers GLEW_GET_VAR(__GLEW_ARB_draw_buffers) #endif /* GL_ARB_draw_buffers */ /* ----------------------- GL_ARB_draw_buffers_blend ----------------------- */ #ifndef GL_ARB_draw_buffers_blend #define GL_ARB_draw_buffers_blend 1 typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); typedef void (GLAPIENTRY * PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); #define glBlendEquationSeparateiARB GLEW_GET_FUN(__glewBlendEquationSeparateiARB) #define glBlendEquationiARB GLEW_GET_FUN(__glewBlendEquationiARB) #define glBlendFuncSeparateiARB GLEW_GET_FUN(__glewBlendFuncSeparateiARB) #define glBlendFunciARB GLEW_GET_FUN(__glewBlendFunciARB) #define GLEW_ARB_draw_buffers_blend GLEW_GET_VAR(__GLEW_ARB_draw_buffers_blend) #endif /* GL_ARB_draw_buffers_blend */ /* -------------------- GL_ARB_draw_elements_base_vertex ------------------- */ #ifndef GL_ARB_draw_elements_base_vertex #define GL_ARB_draw_elements_base_vertex 1 typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex); typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei* count, GLenum type, const void *const *indices, GLsizei primcount, const GLint *basevertex); #define glDrawElementsBaseVertex GLEW_GET_FUN(__glewDrawElementsBaseVertex) #define glDrawElementsInstancedBaseVertex GLEW_GET_FUN(__glewDrawElementsInstancedBaseVertex) #define glDrawRangeElementsBaseVertex GLEW_GET_FUN(__glewDrawRangeElementsBaseVertex) #define glMultiDrawElementsBaseVertex GLEW_GET_FUN(__glewMultiDrawElementsBaseVertex) #define GLEW_ARB_draw_elements_base_vertex GLEW_GET_VAR(__GLEW_ARB_draw_elements_base_vertex) #endif /* GL_ARB_draw_elements_base_vertex */ /* -------------------------- GL_ARB_draw_indirect ------------------------- */ #ifndef GL_ARB_draw_indirect #define GL_ARB_draw_indirect 1 #define GL_DRAW_INDIRECT_BUFFER 0x8F3F #define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); #define glDrawArraysIndirect GLEW_GET_FUN(__glewDrawArraysIndirect) #define glDrawElementsIndirect GLEW_GET_FUN(__glewDrawElementsIndirect) #define GLEW_ARB_draw_indirect GLEW_GET_VAR(__GLEW_ARB_draw_indirect) #endif /* GL_ARB_draw_indirect */ /* ------------------------- GL_ARB_draw_instanced ------------------------- */ #ifndef GL_ARB_draw_instanced #define GL_ARB_draw_instanced 1 #define GLEW_ARB_draw_instanced GLEW_GET_VAR(__GLEW_ARB_draw_instanced) #endif /* GL_ARB_draw_instanced */ /* ------------------------ GL_ARB_enhanced_layouts ------------------------ */ #ifndef GL_ARB_enhanced_layouts #define GL_ARB_enhanced_layouts 1 #define GL_LOCATION_COMPONENT 0x934A #define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B #define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C #define GLEW_ARB_enhanced_layouts GLEW_GET_VAR(__GLEW_ARB_enhanced_layouts) #endif /* GL_ARB_enhanced_layouts */ /* -------------------- GL_ARB_explicit_attrib_location -------------------- */ #ifndef GL_ARB_explicit_attrib_location #define GL_ARB_explicit_attrib_location 1 #define GLEW_ARB_explicit_attrib_location GLEW_GET_VAR(__GLEW_ARB_explicit_attrib_location) #endif /* GL_ARB_explicit_attrib_location */ /* -------------------- GL_ARB_explicit_uniform_location ------------------- */ #ifndef GL_ARB_explicit_uniform_location #define GL_ARB_explicit_uniform_location 1 #define GL_MAX_UNIFORM_LOCATIONS 0x826E #define GLEW_ARB_explicit_uniform_location GLEW_GET_VAR(__GLEW_ARB_explicit_uniform_location) #endif /* GL_ARB_explicit_uniform_location */ /* ------------------- GL_ARB_fragment_coord_conventions ------------------- */ #ifndef GL_ARB_fragment_coord_conventions #define GL_ARB_fragment_coord_conventions 1 #define GLEW_ARB_fragment_coord_conventions GLEW_GET_VAR(__GLEW_ARB_fragment_coord_conventions) #endif /* GL_ARB_fragment_coord_conventions */ /* --------------------- GL_ARB_fragment_layer_viewport -------------------- */ #ifndef GL_ARB_fragment_layer_viewport #define GL_ARB_fragment_layer_viewport 1 #define GLEW_ARB_fragment_layer_viewport GLEW_GET_VAR(__GLEW_ARB_fragment_layer_viewport) #endif /* GL_ARB_fragment_layer_viewport */ /* ------------------------ GL_ARB_fragment_program ------------------------ */ #ifndef GL_ARB_fragment_program #define GL_ARB_fragment_program 1 #define GL_FRAGMENT_PROGRAM_ARB 0x8804 #define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 #define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 #define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 #define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 #define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 #define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A #define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B #define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C #define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D #define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E #define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F #define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 #define GL_MAX_TEXTURE_COORDS_ARB 0x8871 #define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 #define GLEW_ARB_fragment_program GLEW_GET_VAR(__GLEW_ARB_fragment_program) #endif /* GL_ARB_fragment_program */ /* --------------------- GL_ARB_fragment_program_shadow -------------------- */ #ifndef GL_ARB_fragment_program_shadow #define GL_ARB_fragment_program_shadow 1 #define GLEW_ARB_fragment_program_shadow GLEW_GET_VAR(__GLEW_ARB_fragment_program_shadow) #endif /* GL_ARB_fragment_program_shadow */ /* ------------------------- GL_ARB_fragment_shader ------------------------ */ #ifndef GL_ARB_fragment_shader #define GL_ARB_fragment_shader 1 #define GL_FRAGMENT_SHADER_ARB 0x8B30 #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B #define GLEW_ARB_fragment_shader GLEW_GET_VAR(__GLEW_ARB_fragment_shader) #endif /* GL_ARB_fragment_shader */ /* -------------------- GL_ARB_fragment_shader_interlock ------------------- */ #ifndef GL_ARB_fragment_shader_interlock #define GL_ARB_fragment_shader_interlock 1 #define GLEW_ARB_fragment_shader_interlock GLEW_GET_VAR(__GLEW_ARB_fragment_shader_interlock) #endif /* GL_ARB_fragment_shader_interlock */ /* ------------------- GL_ARB_framebuffer_no_attachments ------------------- */ #ifndef GL_ARB_framebuffer_no_attachments #define GL_ARB_framebuffer_no_attachments 1 #define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 #define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 #define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 #define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 #define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 #define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 #define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 #define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 #define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); #define glFramebufferParameteri GLEW_GET_FUN(__glewFramebufferParameteri) #define glGetFramebufferParameteriv GLEW_GET_FUN(__glewGetFramebufferParameteriv) #define glGetNamedFramebufferParameterivEXT GLEW_GET_FUN(__glewGetNamedFramebufferParameterivEXT) #define glNamedFramebufferParameteriEXT GLEW_GET_FUN(__glewNamedFramebufferParameteriEXT) #define GLEW_ARB_framebuffer_no_attachments GLEW_GET_VAR(__GLEW_ARB_framebuffer_no_attachments) #endif /* GL_ARB_framebuffer_no_attachments */ /* ----------------------- GL_ARB_framebuffer_object ----------------------- */ #ifndef GL_ARB_framebuffer_object #define GL_ARB_framebuffer_object 1 #define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 #define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 #define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 #define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 #define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 #define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 #define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 #define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 #define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 #define GL_FRAMEBUFFER_DEFAULT 0x8218 #define GL_FRAMEBUFFER_UNDEFINED 0x8219 #define GL_DEPTH_STENCIL_ATTACHMENT 0x821A #define GL_INDEX 0x8222 #define GL_MAX_RENDERBUFFER_SIZE 0x84E8 #define GL_DEPTH_STENCIL 0x84F9 #define GL_UNSIGNED_INT_24_8 0x84FA #define GL_DEPTH24_STENCIL8 0x88F0 #define GL_TEXTURE_STENCIL_SIZE 0x88F1 #define GL_UNSIGNED_NORMALIZED 0x8C17 #define GL_SRGB 0x8C40 #define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 #define GL_FRAMEBUFFER_BINDING 0x8CA6 #define GL_RENDERBUFFER_BINDING 0x8CA7 #define GL_READ_FRAMEBUFFER 0x8CA8 #define GL_DRAW_FRAMEBUFFER 0x8CA9 #define GL_READ_FRAMEBUFFER_BINDING 0x8CAA #define GL_RENDERBUFFER_SAMPLES 0x8CAB #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 #define GL_FRAMEBUFFER_COMPLETE 0x8CD5 #define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 #define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 #define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB #define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC #define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD #define GL_MAX_COLOR_ATTACHMENTS 0x8CDF #define GL_COLOR_ATTACHMENT0 0x8CE0 #define GL_COLOR_ATTACHMENT1 0x8CE1 #define GL_COLOR_ATTACHMENT2 0x8CE2 #define GL_COLOR_ATTACHMENT3 0x8CE3 #define GL_COLOR_ATTACHMENT4 0x8CE4 #define GL_COLOR_ATTACHMENT5 0x8CE5 #define GL_COLOR_ATTACHMENT6 0x8CE6 #define GL_COLOR_ATTACHMENT7 0x8CE7 #define GL_COLOR_ATTACHMENT8 0x8CE8 #define GL_COLOR_ATTACHMENT9 0x8CE9 #define GL_COLOR_ATTACHMENT10 0x8CEA #define GL_COLOR_ATTACHMENT11 0x8CEB #define GL_COLOR_ATTACHMENT12 0x8CEC #define GL_COLOR_ATTACHMENT13 0x8CED #define GL_COLOR_ATTACHMENT14 0x8CEE #define GL_COLOR_ATTACHMENT15 0x8CEF #define GL_DEPTH_ATTACHMENT 0x8D00 #define GL_STENCIL_ATTACHMENT 0x8D20 #define GL_FRAMEBUFFER 0x8D40 #define GL_RENDERBUFFER 0x8D41 #define GL_RENDERBUFFER_WIDTH 0x8D42 #define GL_RENDERBUFFER_HEIGHT 0x8D43 #define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 #define GL_STENCIL_INDEX1 0x8D46 #define GL_STENCIL_INDEX4 0x8D47 #define GL_STENCIL_INDEX8 0x8D48 #define GL_STENCIL_INDEX16 0x8D49 #define GL_RENDERBUFFER_RED_SIZE 0x8D50 #define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 #define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 #define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 #define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 #define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 #define GL_MAX_SAMPLES 0x8D57 typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers); typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer); typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint* framebuffers); typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint* renderbuffers); typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #define glBindFramebuffer GLEW_GET_FUN(__glewBindFramebuffer) #define glBindRenderbuffer GLEW_GET_FUN(__glewBindRenderbuffer) #define glBlitFramebuffer GLEW_GET_FUN(__glewBlitFramebuffer) #define glCheckFramebufferStatus GLEW_GET_FUN(__glewCheckFramebufferStatus) #define glDeleteFramebuffers GLEW_GET_FUN(__glewDeleteFramebuffers) #define glDeleteRenderbuffers GLEW_GET_FUN(__glewDeleteRenderbuffers) #define glFramebufferRenderbuffer GLEW_GET_FUN(__glewFramebufferRenderbuffer) #define glFramebufferTexture1D GLEW_GET_FUN(__glewFramebufferTexture1D) #define glFramebufferTexture2D GLEW_GET_FUN(__glewFramebufferTexture2D) #define glFramebufferTexture3D GLEW_GET_FUN(__glewFramebufferTexture3D) #define glFramebufferTextureLayer GLEW_GET_FUN(__glewFramebufferTextureLayer) #define glGenFramebuffers GLEW_GET_FUN(__glewGenFramebuffers) #define glGenRenderbuffers GLEW_GET_FUN(__glewGenRenderbuffers) #define glGenerateMipmap GLEW_GET_FUN(__glewGenerateMipmap) #define glGetFramebufferAttachmentParameteriv GLEW_GET_FUN(__glewGetFramebufferAttachmentParameteriv) #define glGetRenderbufferParameteriv GLEW_GET_FUN(__glewGetRenderbufferParameteriv) #define glIsFramebuffer GLEW_GET_FUN(__glewIsFramebuffer) #define glIsRenderbuffer GLEW_GET_FUN(__glewIsRenderbuffer) #define glRenderbufferStorage GLEW_GET_FUN(__glewRenderbufferStorage) #define glRenderbufferStorageMultisample GLEW_GET_FUN(__glewRenderbufferStorageMultisample) #define GLEW_ARB_framebuffer_object GLEW_GET_VAR(__GLEW_ARB_framebuffer_object) #endif /* GL_ARB_framebuffer_object */ /* ------------------------ GL_ARB_framebuffer_sRGB ------------------------ */ #ifndef GL_ARB_framebuffer_sRGB #define GL_ARB_framebuffer_sRGB 1 #define GL_FRAMEBUFFER_SRGB 0x8DB9 #define GLEW_ARB_framebuffer_sRGB GLEW_GET_VAR(__GLEW_ARB_framebuffer_sRGB) #endif /* GL_ARB_framebuffer_sRGB */ /* ------------------------ GL_ARB_geometry_shader4 ------------------------ */ #ifndef GL_ARB_geometry_shader4 #define GL_ARB_geometry_shader4 1 #define GL_LINES_ADJACENCY_ARB 0xA #define GL_LINE_STRIP_ADJACENCY_ARB 0xB #define GL_TRIANGLES_ADJACENCY_ARB 0xC #define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0xD #define GL_PROGRAM_POINT_SIZE_ARB 0x8642 #define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 #define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 #define GL_GEOMETRY_SHADER_ARB 0x8DD9 #define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA #define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB #define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC #define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD #define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE #define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF #define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 #define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); #define glFramebufferTextureARB GLEW_GET_FUN(__glewFramebufferTextureARB) #define glFramebufferTextureFaceARB GLEW_GET_FUN(__glewFramebufferTextureFaceARB) #define glFramebufferTextureLayerARB GLEW_GET_FUN(__glewFramebufferTextureLayerARB) #define glProgramParameteriARB GLEW_GET_FUN(__glewProgramParameteriARB) #define GLEW_ARB_geometry_shader4 GLEW_GET_VAR(__GLEW_ARB_geometry_shader4) #endif /* GL_ARB_geometry_shader4 */ /* ----------------------- GL_ARB_get_program_binary ----------------------- */ #ifndef GL_ARB_get_program_binary #define GL_ARB_get_program_binary 1 #define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 #define GL_PROGRAM_BINARY_LENGTH 0x8741 #define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE #define GL_PROGRAM_BINARY_FORMATS 0x87FF typedef void (GLAPIENTRY * PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLenum *binaryFormat, void*binary); typedef void (GLAPIENTRY * PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); #define glGetProgramBinary GLEW_GET_FUN(__glewGetProgramBinary) #define glProgramBinary GLEW_GET_FUN(__glewProgramBinary) #define glProgramParameteri GLEW_GET_FUN(__glewProgramParameteri) #define GLEW_ARB_get_program_binary GLEW_GET_VAR(__GLEW_ARB_get_program_binary) #endif /* GL_ARB_get_program_binary */ /* ---------------------- GL_ARB_get_texture_sub_image --------------------- */ #ifndef GL_ARB_get_texture_sub_image #define GL_ARB_get_texture_sub_image 1 typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); typedef void (GLAPIENTRY * PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); #define glGetCompressedTextureSubImage GLEW_GET_FUN(__glewGetCompressedTextureSubImage) #define glGetTextureSubImage GLEW_GET_FUN(__glewGetTextureSubImage) #define GLEW_ARB_get_texture_sub_image GLEW_GET_VAR(__GLEW_ARB_get_texture_sub_image) #endif /* GL_ARB_get_texture_sub_image */ /* --------------------------- GL_ARB_gpu_shader5 -------------------------- */ #ifndef GL_ARB_gpu_shader5 #define GL_ARB_gpu_shader5 1 #define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F #define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A #define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B #define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C #define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D #define GL_MAX_VERTEX_STREAMS 0x8E71 #define GLEW_ARB_gpu_shader5 GLEW_GET_VAR(__GLEW_ARB_gpu_shader5) #endif /* GL_ARB_gpu_shader5 */ /* ------------------------- GL_ARB_gpu_shader_fp64 ------------------------ */ #ifndef GL_ARB_gpu_shader_fp64 #define GL_ARB_gpu_shader_fp64 1 #define GL_DOUBLE_MAT2 0x8F46 #define GL_DOUBLE_MAT3 0x8F47 #define GL_DOUBLE_MAT4 0x8F48 #define GL_DOUBLE_MAT2x3 0x8F49 #define GL_DOUBLE_MAT2x4 0x8F4A #define GL_DOUBLE_MAT3x2 0x8F4B #define GL_DOUBLE_MAT3x4 0x8F4C #define GL_DOUBLE_MAT4x2 0x8F4D #define GL_DOUBLE_MAT4x3 0x8F4E #define GL_DOUBLE_VEC2 0x8FFC #define GL_DOUBLE_VEC3 0x8FFD #define GL_DOUBLE_VEC4 0x8FFE typedef void (GLAPIENTRY * PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble* params); typedef void (GLAPIENTRY * PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); typedef void (GLAPIENTRY * PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); #define glGetUniformdv GLEW_GET_FUN(__glewGetUniformdv) #define glUniform1d GLEW_GET_FUN(__glewUniform1d) #define glUniform1dv GLEW_GET_FUN(__glewUniform1dv) #define glUniform2d GLEW_GET_FUN(__glewUniform2d) #define glUniform2dv GLEW_GET_FUN(__glewUniform2dv) #define glUniform3d GLEW_GET_FUN(__glewUniform3d) #define glUniform3dv GLEW_GET_FUN(__glewUniform3dv) #define glUniform4d GLEW_GET_FUN(__glewUniform4d) #define glUniform4dv GLEW_GET_FUN(__glewUniform4dv) #define glUniformMatrix2dv GLEW_GET_FUN(__glewUniformMatrix2dv) #define glUniformMatrix2x3dv GLEW_GET_FUN(__glewUniformMatrix2x3dv) #define glUniformMatrix2x4dv GLEW_GET_FUN(__glewUniformMatrix2x4dv) #define glUniformMatrix3dv GLEW_GET_FUN(__glewUniformMatrix3dv) #define glUniformMatrix3x2dv GLEW_GET_FUN(__glewUniformMatrix3x2dv) #define glUniformMatrix3x4dv GLEW_GET_FUN(__glewUniformMatrix3x4dv) #define glUniformMatrix4dv GLEW_GET_FUN(__glewUniformMatrix4dv) #define glUniformMatrix4x2dv GLEW_GET_FUN(__glewUniformMatrix4x2dv) #define glUniformMatrix4x3dv GLEW_GET_FUN(__glewUniformMatrix4x3dv) #define GLEW_ARB_gpu_shader_fp64 GLEW_GET_VAR(__GLEW_ARB_gpu_shader_fp64) #endif /* GL_ARB_gpu_shader_fp64 */ /* ------------------------ GL_ARB_gpu_shader_int64 ------------------------ */ #ifndef GL_ARB_gpu_shader_int64 #define GL_ARB_gpu_shader_int64 1 #define GL_INT64_ARB 0x140E #define GL_UNSIGNED_INT64_ARB 0x140F #define GL_INT64_VEC2_ARB 0x8FE9 #define GL_INT64_VEC3_ARB 0x8FEA #define GL_INT64_VEC4_ARB 0x8FEB #define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 #define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 #define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 typedef void (GLAPIENTRY * PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64* params); typedef void (GLAPIENTRY * PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64* params); typedef void (GLAPIENTRY * PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64* params); typedef void (GLAPIENTRY * PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64* params); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* value); typedef void (GLAPIENTRY * PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x); typedef void (GLAPIENTRY * PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64* value); typedef void (GLAPIENTRY * PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x); typedef void (GLAPIENTRY * PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y); typedef void (GLAPIENTRY * PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y); typedef void (GLAPIENTRY * PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z); typedef void (GLAPIENTRY * PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); typedef void (GLAPIENTRY * PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); typedef void (GLAPIENTRY * PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); typedef void (GLAPIENTRY * PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value); #define glGetUniformi64vARB GLEW_GET_FUN(__glewGetUniformi64vARB) #define glGetUniformui64vARB GLEW_GET_FUN(__glewGetUniformui64vARB) #define glGetnUniformi64vARB GLEW_GET_FUN(__glewGetnUniformi64vARB) #define glGetnUniformui64vARB GLEW_GET_FUN(__glewGetnUniformui64vARB) #define glProgramUniform1i64ARB GLEW_GET_FUN(__glewProgramUniform1i64ARB) #define glProgramUniform1i64vARB GLEW_GET_FUN(__glewProgramUniform1i64vARB) #define glProgramUniform1ui64ARB GLEW_GET_FUN(__glewProgramUniform1ui64ARB) #define glProgramUniform1ui64vARB GLEW_GET_FUN(__glewProgramUniform1ui64vARB) #define glProgramUniform2i64ARB GLEW_GET_FUN(__glewProgramUniform2i64ARB) #define glProgramUniform2i64vARB GLEW_GET_FUN(__glewProgramUniform2i64vARB) #define glProgramUniform2ui64ARB GLEW_GET_FUN(__glewProgramUniform2ui64ARB) #define glProgramUniform2ui64vARB GLEW_GET_FUN(__glewProgramUniform2ui64vARB) #define glProgramUniform3i64ARB GLEW_GET_FUN(__glewProgramUniform3i64ARB) #define glProgramUniform3i64vARB GLEW_GET_FUN(__glewProgramUniform3i64vARB) #define glProgramUniform3ui64ARB GLEW_GET_FUN(__glewProgramUniform3ui64ARB) #define glProgramUniform3ui64vARB GLEW_GET_FUN(__glewProgramUniform3ui64vARB) #define glProgramUniform4i64ARB GLEW_GET_FUN(__glewProgramUniform4i64ARB) #define glProgramUniform4i64vARB GLEW_GET_FUN(__glewProgramUniform4i64vARB) #define glProgramUniform4ui64ARB GLEW_GET_FUN(__glewProgramUniform4ui64ARB) #define glProgramUniform4ui64vARB GLEW_GET_FUN(__glewProgramUniform4ui64vARB) #define glUniform1i64ARB GLEW_GET_FUN(__glewUniform1i64ARB) #define glUniform1i64vARB GLEW_GET_FUN(__glewUniform1i64vARB) #define glUniform1ui64ARB GLEW_GET_FUN(__glewUniform1ui64ARB) #define glUniform1ui64vARB GLEW_GET_FUN(__glewUniform1ui64vARB) #define glUniform2i64ARB GLEW_GET_FUN(__glewUniform2i64ARB) #define glUniform2i64vARB GLEW_GET_FUN(__glewUniform2i64vARB) #define glUniform2ui64ARB GLEW_GET_FUN(__glewUniform2ui64ARB) #define glUniform2ui64vARB GLEW_GET_FUN(__glewUniform2ui64vARB) #define glUniform3i64ARB GLEW_GET_FUN(__glewUniform3i64ARB) #define glUniform3i64vARB GLEW_GET_FUN(__glewUniform3i64vARB) #define glUniform3ui64ARB GLEW_GET_FUN(__glewUniform3ui64ARB) #define glUniform3ui64vARB GLEW_GET_FUN(__glewUniform3ui64vARB) #define glUniform4i64ARB GLEW_GET_FUN(__glewUniform4i64ARB) #define glUniform4i64vARB GLEW_GET_FUN(__glewUniform4i64vARB) #define glUniform4ui64ARB GLEW_GET_FUN(__glewUniform4ui64ARB) #define glUniform4ui64vARB GLEW_GET_FUN(__glewUniform4ui64vARB) #define GLEW_ARB_gpu_shader_int64 GLEW_GET_VAR(__GLEW_ARB_gpu_shader_int64) #endif /* GL_ARB_gpu_shader_int64 */ /* ------------------------ GL_ARB_half_float_pixel ------------------------ */ #ifndef GL_ARB_half_float_pixel #define GL_ARB_half_float_pixel 1 #define GL_HALF_FLOAT_ARB 0x140B #define GLEW_ARB_half_float_pixel GLEW_GET_VAR(__GLEW_ARB_half_float_pixel) #endif /* GL_ARB_half_float_pixel */ /* ------------------------ GL_ARB_half_float_vertex ----------------------- */ #ifndef GL_ARB_half_float_vertex #define GL_ARB_half_float_vertex 1 #define GL_HALF_FLOAT 0x140B #define GLEW_ARB_half_float_vertex GLEW_GET_VAR(__GLEW_ARB_half_float_vertex) #endif /* GL_ARB_half_float_vertex */ /* ----------------------------- GL_ARB_imaging ---------------------------- */ #ifndef GL_ARB_imaging #define GL_ARB_imaging 1 #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 #define GL_BLEND_COLOR 0x8005 #define GL_FUNC_ADD 0x8006 #define GL_MIN 0x8007 #define GL_MAX 0x8008 #define GL_BLEND_EQUATION 0x8009 #define GL_FUNC_SUBTRACT 0x800A #define GL_FUNC_REVERSE_SUBTRACT 0x800B #define GL_CONVOLUTION_1D 0x8010 #define GL_CONVOLUTION_2D 0x8011 #define GL_SEPARABLE_2D 0x8012 #define GL_CONVOLUTION_BORDER_MODE 0x8013 #define GL_CONVOLUTION_FILTER_SCALE 0x8014 #define GL_CONVOLUTION_FILTER_BIAS 0x8015 #define GL_REDUCE 0x8016 #define GL_CONVOLUTION_FORMAT 0x8017 #define GL_CONVOLUTION_WIDTH 0x8018 #define GL_CONVOLUTION_HEIGHT 0x8019 #define GL_MAX_CONVOLUTION_WIDTH 0x801A #define GL_MAX_CONVOLUTION_HEIGHT 0x801B #define GL_POST_CONVOLUTION_RED_SCALE 0x801C #define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D #define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E #define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F #define GL_POST_CONVOLUTION_RED_BIAS 0x8020 #define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 #define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 #define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 #define GL_HISTOGRAM 0x8024 #define GL_PROXY_HISTOGRAM 0x8025 #define GL_HISTOGRAM_WIDTH 0x8026 #define GL_HISTOGRAM_FORMAT 0x8027 #define GL_HISTOGRAM_RED_SIZE 0x8028 #define GL_HISTOGRAM_GREEN_SIZE 0x8029 #define GL_HISTOGRAM_BLUE_SIZE 0x802A #define GL_HISTOGRAM_ALPHA_SIZE 0x802B #define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C #define GL_HISTOGRAM_SINK 0x802D #define GL_MINMAX 0x802E #define GL_MINMAX_FORMAT 0x802F #define GL_MINMAX_SINK 0x8030 #define GL_TABLE_TOO_LARGE 0x8031 #define GL_COLOR_MATRIX 0x80B1 #define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 #define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 #define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 #define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 #define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 #define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 #define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 #define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 #define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA #define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB #define GL_COLOR_TABLE 0x80D0 #define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 #define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 #define GL_PROXY_COLOR_TABLE 0x80D3 #define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 #define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 #define GL_COLOR_TABLE_SCALE 0x80D6 #define GL_COLOR_TABLE_BIAS 0x80D7 #define GL_COLOR_TABLE_FORMAT 0x80D8 #define GL_COLOR_TABLE_WIDTH 0x80D9 #define GL_COLOR_TABLE_RED_SIZE 0x80DA #define GL_COLOR_TABLE_GREEN_SIZE 0x80DB #define GL_COLOR_TABLE_BLUE_SIZE 0x80DC #define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD #define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE #define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF #define GL_IGNORE_BORDER 0x8150 #define GL_CONSTANT_BORDER 0x8151 #define GL_WRAP_BORDER 0x8152 #define GL_REPLICATE_BORDER 0x8153 #define GL_CONVOLUTION_BORDER_COLOR 0x8154 typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); typedef void (GLAPIENTRY * PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GLAPIENTRY * PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum types, void *values); typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); typedef void (GLAPIENTRY * PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); typedef void (GLAPIENTRY * PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLRESETMINMAXPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); #define glColorSubTable GLEW_GET_FUN(__glewColorSubTable) #define glColorTable GLEW_GET_FUN(__glewColorTable) #define glColorTableParameterfv GLEW_GET_FUN(__glewColorTableParameterfv) #define glColorTableParameteriv GLEW_GET_FUN(__glewColorTableParameteriv) #define glConvolutionFilter1D GLEW_GET_FUN(__glewConvolutionFilter1D) #define glConvolutionFilter2D GLEW_GET_FUN(__glewConvolutionFilter2D) #define glConvolutionParameterf GLEW_GET_FUN(__glewConvolutionParameterf) #define glConvolutionParameterfv GLEW_GET_FUN(__glewConvolutionParameterfv) #define glConvolutionParameteri GLEW_GET_FUN(__glewConvolutionParameteri) #define glConvolutionParameteriv GLEW_GET_FUN(__glewConvolutionParameteriv) #define glCopyColorSubTable GLEW_GET_FUN(__glewCopyColorSubTable) #define glCopyColorTable GLEW_GET_FUN(__glewCopyColorTable) #define glCopyConvolutionFilter1D GLEW_GET_FUN(__glewCopyConvolutionFilter1D) #define glCopyConvolutionFilter2D GLEW_GET_FUN(__glewCopyConvolutionFilter2D) #define glGetColorTable GLEW_GET_FUN(__glewGetColorTable) #define glGetColorTableParameterfv GLEW_GET_FUN(__glewGetColorTableParameterfv) #define glGetColorTableParameteriv GLEW_GET_FUN(__glewGetColorTableParameteriv) #define glGetConvolutionFilter GLEW_GET_FUN(__glewGetConvolutionFilter) #define glGetConvolutionParameterfv GLEW_GET_FUN(__glewGetConvolutionParameterfv) #define glGetConvolutionParameteriv GLEW_GET_FUN(__glewGetConvolutionParameteriv) #define glGetHistogram GLEW_GET_FUN(__glewGetHistogram) #define glGetHistogramParameterfv GLEW_GET_FUN(__glewGetHistogramParameterfv) #define glGetHistogramParameteriv GLEW_GET_FUN(__glewGetHistogramParameteriv) #define glGetMinmax GLEW_GET_FUN(__glewGetMinmax) #define glGetMinmaxParameterfv GLEW_GET_FUN(__glewGetMinmaxParameterfv) #define glGetMinmaxParameteriv GLEW_GET_FUN(__glewGetMinmaxParameteriv) #define glGetSeparableFilter GLEW_GET_FUN(__glewGetSeparableFilter) #define glHistogram GLEW_GET_FUN(__glewHistogram) #define glMinmax GLEW_GET_FUN(__glewMinmax) #define glResetHistogram GLEW_GET_FUN(__glewResetHistogram) #define glResetMinmax GLEW_GET_FUN(__glewResetMinmax) #define glSeparableFilter2D GLEW_GET_FUN(__glewSeparableFilter2D) #define GLEW_ARB_imaging GLEW_GET_VAR(__GLEW_ARB_imaging) #endif /* GL_ARB_imaging */ /* ----------------------- GL_ARB_indirect_parameters ---------------------- */ #ifndef GL_ARB_indirect_parameters #define GL_ARB_indirect_parameters 1 #define GL_PARAMETER_BUFFER_ARB 0x80EE #define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #define glMultiDrawArraysIndirectCountARB GLEW_GET_FUN(__glewMultiDrawArraysIndirectCountARB) #define glMultiDrawElementsIndirectCountARB GLEW_GET_FUN(__glewMultiDrawElementsIndirectCountARB) #define GLEW_ARB_indirect_parameters GLEW_GET_VAR(__GLEW_ARB_indirect_parameters) #endif /* GL_ARB_indirect_parameters */ /* ------------------------ GL_ARB_instanced_arrays ------------------------ */ #ifndef GL_ARB_instanced_arrays #define GL_ARB_instanced_arrays 1 #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); #define glDrawArraysInstancedARB GLEW_GET_FUN(__glewDrawArraysInstancedARB) #define glDrawElementsInstancedARB GLEW_GET_FUN(__glewDrawElementsInstancedARB) #define glVertexAttribDivisorARB GLEW_GET_FUN(__glewVertexAttribDivisorARB) #define GLEW_ARB_instanced_arrays GLEW_GET_VAR(__GLEW_ARB_instanced_arrays) #endif /* GL_ARB_instanced_arrays */ /* ---------------------- GL_ARB_internalformat_query ---------------------- */ #ifndef GL_ARB_internalformat_query #define GL_ARB_internalformat_query 1 #define GL_NUM_SAMPLE_COUNTS 0x9380 typedef void (GLAPIENTRY * PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params); #define glGetInternalformativ GLEW_GET_FUN(__glewGetInternalformativ) #define GLEW_ARB_internalformat_query GLEW_GET_VAR(__GLEW_ARB_internalformat_query) #endif /* GL_ARB_internalformat_query */ /* ---------------------- GL_ARB_internalformat_query2 --------------------- */ #ifndef GL_ARB_internalformat_query2 #define GL_ARB_internalformat_query2 1 #define GL_INTERNALFORMAT_SUPPORTED 0x826F #define GL_INTERNALFORMAT_PREFERRED 0x8270 #define GL_INTERNALFORMAT_RED_SIZE 0x8271 #define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 #define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 #define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 #define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 #define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 #define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 #define GL_INTERNALFORMAT_RED_TYPE 0x8278 #define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 #define GL_INTERNALFORMAT_BLUE_TYPE 0x827A #define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B #define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C #define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D #define GL_MAX_WIDTH 0x827E #define GL_MAX_HEIGHT 0x827F #define GL_MAX_DEPTH 0x8280 #define GL_MAX_LAYERS 0x8281 #define GL_MAX_COMBINED_DIMENSIONS 0x8282 #define GL_COLOR_COMPONENTS 0x8283 #define GL_DEPTH_COMPONENTS 0x8284 #define GL_STENCIL_COMPONENTS 0x8285 #define GL_COLOR_RENDERABLE 0x8286 #define GL_DEPTH_RENDERABLE 0x8287 #define GL_STENCIL_RENDERABLE 0x8288 #define GL_FRAMEBUFFER_RENDERABLE 0x8289 #define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A #define GL_FRAMEBUFFER_BLEND 0x828B #define GL_READ_PIXELS 0x828C #define GL_READ_PIXELS_FORMAT 0x828D #define GL_READ_PIXELS_TYPE 0x828E #define GL_TEXTURE_IMAGE_FORMAT 0x828F #define GL_TEXTURE_IMAGE_TYPE 0x8290 #define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 #define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 #define GL_MIPMAP 0x8293 #define GL_MANUAL_GENERATE_MIPMAP 0x8294 #define GL_AUTO_GENERATE_MIPMAP 0x8295 #define GL_COLOR_ENCODING 0x8296 #define GL_SRGB_READ 0x8297 #define GL_SRGB_WRITE 0x8298 #define GL_SRGB_DECODE_ARB 0x8299 #define GL_FILTER 0x829A #define GL_VERTEX_TEXTURE 0x829B #define GL_TESS_CONTROL_TEXTURE 0x829C #define GL_TESS_EVALUATION_TEXTURE 0x829D #define GL_GEOMETRY_TEXTURE 0x829E #define GL_FRAGMENT_TEXTURE 0x829F #define GL_COMPUTE_TEXTURE 0x82A0 #define GL_TEXTURE_SHADOW 0x82A1 #define GL_TEXTURE_GATHER 0x82A2 #define GL_TEXTURE_GATHER_SHADOW 0x82A3 #define GL_SHADER_IMAGE_LOAD 0x82A4 #define GL_SHADER_IMAGE_STORE 0x82A5 #define GL_SHADER_IMAGE_ATOMIC 0x82A6 #define GL_IMAGE_TEXEL_SIZE 0x82A7 #define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 #define GL_IMAGE_PIXEL_FORMAT 0x82A9 #define GL_IMAGE_PIXEL_TYPE 0x82AA #define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC #define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD #define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE #define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF #define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 #define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 #define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 #define GL_CLEAR_BUFFER 0x82B4 #define GL_TEXTURE_VIEW 0x82B5 #define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 #define GL_FULL_SUPPORT 0x82B7 #define GL_CAVEAT_SUPPORT 0x82B8 #define GL_IMAGE_CLASS_4_X_32 0x82B9 #define GL_IMAGE_CLASS_2_X_32 0x82BA #define GL_IMAGE_CLASS_1_X_32 0x82BB #define GL_IMAGE_CLASS_4_X_16 0x82BC #define GL_IMAGE_CLASS_2_X_16 0x82BD #define GL_IMAGE_CLASS_1_X_16 0x82BE #define GL_IMAGE_CLASS_4_X_8 0x82BF #define GL_IMAGE_CLASS_2_X_8 0x82C0 #define GL_IMAGE_CLASS_1_X_8 0x82C1 #define GL_IMAGE_CLASS_11_11_10 0x82C2 #define GL_IMAGE_CLASS_10_10_10_2 0x82C3 #define GL_VIEW_CLASS_128_BITS 0x82C4 #define GL_VIEW_CLASS_96_BITS 0x82C5 #define GL_VIEW_CLASS_64_BITS 0x82C6 #define GL_VIEW_CLASS_48_BITS 0x82C7 #define GL_VIEW_CLASS_32_BITS 0x82C8 #define GL_VIEW_CLASS_24_BITS 0x82C9 #define GL_VIEW_CLASS_16_BITS 0x82CA #define GL_VIEW_CLASS_8_BITS 0x82CB #define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC #define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD #define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE #define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF #define GL_VIEW_CLASS_RGTC1_RED 0x82D0 #define GL_VIEW_CLASS_RGTC2_RG 0x82D1 #define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 #define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 typedef void (GLAPIENTRY * PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64* params); #define glGetInternalformati64v GLEW_GET_FUN(__glewGetInternalformati64v) #define GLEW_ARB_internalformat_query2 GLEW_GET_VAR(__GLEW_ARB_internalformat_query2) #endif /* GL_ARB_internalformat_query2 */ /* ----------------------- GL_ARB_invalidate_subdata ----------------------- */ #ifndef GL_ARB_invalidate_subdata #define GL_ARB_invalidate_subdata 1 typedef void (GLAPIENTRY * PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); typedef void (GLAPIENTRY * PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); typedef void (GLAPIENTRY * PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum* attachments); typedef void (GLAPIENTRY * PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); #define glInvalidateBufferData GLEW_GET_FUN(__glewInvalidateBufferData) #define glInvalidateBufferSubData GLEW_GET_FUN(__glewInvalidateBufferSubData) #define glInvalidateFramebuffer GLEW_GET_FUN(__glewInvalidateFramebuffer) #define glInvalidateSubFramebuffer GLEW_GET_FUN(__glewInvalidateSubFramebuffer) #define glInvalidateTexImage GLEW_GET_FUN(__glewInvalidateTexImage) #define glInvalidateTexSubImage GLEW_GET_FUN(__glewInvalidateTexSubImage) #define GLEW_ARB_invalidate_subdata GLEW_GET_VAR(__GLEW_ARB_invalidate_subdata) #endif /* GL_ARB_invalidate_subdata */ /* ---------------------- GL_ARB_map_buffer_alignment ---------------------- */ #ifndef GL_ARB_map_buffer_alignment #define GL_ARB_map_buffer_alignment 1 #define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC #define GLEW_ARB_map_buffer_alignment GLEW_GET_VAR(__GLEW_ARB_map_buffer_alignment) #endif /* GL_ARB_map_buffer_alignment */ /* ------------------------ GL_ARB_map_buffer_range ------------------------ */ #ifndef GL_ARB_map_buffer_range #define GL_ARB_map_buffer_range 1 #define GL_MAP_READ_BIT 0x0001 #define GL_MAP_WRITE_BIT 0x0002 #define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 #define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 #define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 #define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); typedef void * (GLAPIENTRY * PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); #define glFlushMappedBufferRange GLEW_GET_FUN(__glewFlushMappedBufferRange) #define glMapBufferRange GLEW_GET_FUN(__glewMapBufferRange) #define GLEW_ARB_map_buffer_range GLEW_GET_VAR(__GLEW_ARB_map_buffer_range) #endif /* GL_ARB_map_buffer_range */ /* ------------------------- GL_ARB_matrix_palette ------------------------- */ #ifndef GL_ARB_matrix_palette #define GL_ARB_matrix_palette 1 #define GL_MATRIX_PALETTE_ARB 0x8840 #define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 #define GL_MAX_PALETTE_MATRICES_ARB 0x8842 #define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 #define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 #define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 #define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 #define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 #define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 #define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 typedef void (GLAPIENTRY * PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); typedef void (GLAPIENTRY * PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, void *pointer); typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUBVARBPROC) (GLint size, GLubyte *indices); typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUIVARBPROC) (GLint size, GLuint *indices); typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUSVARBPROC) (GLint size, GLushort *indices); #define glCurrentPaletteMatrixARB GLEW_GET_FUN(__glewCurrentPaletteMatrixARB) #define glMatrixIndexPointerARB GLEW_GET_FUN(__glewMatrixIndexPointerARB) #define glMatrixIndexubvARB GLEW_GET_FUN(__glewMatrixIndexubvARB) #define glMatrixIndexuivARB GLEW_GET_FUN(__glewMatrixIndexuivARB) #define glMatrixIndexusvARB GLEW_GET_FUN(__glewMatrixIndexusvARB) #define GLEW_ARB_matrix_palette GLEW_GET_VAR(__GLEW_ARB_matrix_palette) #endif /* GL_ARB_matrix_palette */ /* --------------------------- GL_ARB_multi_bind --------------------------- */ #ifndef GL_ARB_multi_bind #define GL_ARB_multi_bind 1 typedef void (GLAPIENTRY * PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint* buffers); typedef void (GLAPIENTRY * PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint* buffers, const GLintptr *offsets, const GLsizeiptr *sizes); typedef void (GLAPIENTRY * PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint* textures); typedef void (GLAPIENTRY * PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint* samplers); typedef void (GLAPIENTRY * PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint* textures); typedef void (GLAPIENTRY * PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint* buffers, const GLintptr *offsets, const GLsizei *strides); #define glBindBuffersBase GLEW_GET_FUN(__glewBindBuffersBase) #define glBindBuffersRange GLEW_GET_FUN(__glewBindBuffersRange) #define glBindImageTextures GLEW_GET_FUN(__glewBindImageTextures) #define glBindSamplers GLEW_GET_FUN(__glewBindSamplers) #define glBindTextures GLEW_GET_FUN(__glewBindTextures) #define glBindVertexBuffers GLEW_GET_FUN(__glewBindVertexBuffers) #define GLEW_ARB_multi_bind GLEW_GET_VAR(__GLEW_ARB_multi_bind) #endif /* GL_ARB_multi_bind */ /* ----------------------- GL_ARB_multi_draw_indirect ---------------------- */ #ifndef GL_ARB_multi_draw_indirect #define GL_ARB_multi_draw_indirect 1 typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); #define glMultiDrawArraysIndirect GLEW_GET_FUN(__glewMultiDrawArraysIndirect) #define glMultiDrawElementsIndirect GLEW_GET_FUN(__glewMultiDrawElementsIndirect) #define GLEW_ARB_multi_draw_indirect GLEW_GET_VAR(__GLEW_ARB_multi_draw_indirect) #endif /* GL_ARB_multi_draw_indirect */ /* --------------------------- GL_ARB_multisample -------------------------- */ #ifndef GL_ARB_multisample #define GL_ARB_multisample 1 #define GL_MULTISAMPLE_ARB 0x809D #define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E #define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F #define GL_SAMPLE_COVERAGE_ARB 0x80A0 #define GL_SAMPLE_BUFFERS_ARB 0x80A8 #define GL_SAMPLES_ARB 0x80A9 #define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA #define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB #define GL_MULTISAMPLE_BIT_ARB 0x20000000 typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); #define glSampleCoverageARB GLEW_GET_FUN(__glewSampleCoverageARB) #define GLEW_ARB_multisample GLEW_GET_VAR(__GLEW_ARB_multisample) #endif /* GL_ARB_multisample */ /* -------------------------- GL_ARB_multitexture -------------------------- */ #ifndef GL_ARB_multitexture #define GL_ARB_multitexture 1 #define GL_TEXTURE0_ARB 0x84C0 #define GL_TEXTURE1_ARB 0x84C1 #define GL_TEXTURE2_ARB 0x84C2 #define GL_TEXTURE3_ARB 0x84C3 #define GL_TEXTURE4_ARB 0x84C4 #define GL_TEXTURE5_ARB 0x84C5 #define GL_TEXTURE6_ARB 0x84C6 #define GL_TEXTURE7_ARB 0x84C7 #define GL_TEXTURE8_ARB 0x84C8 #define GL_TEXTURE9_ARB 0x84C9 #define GL_TEXTURE10_ARB 0x84CA #define GL_TEXTURE11_ARB 0x84CB #define GL_TEXTURE12_ARB 0x84CC #define GL_TEXTURE13_ARB 0x84CD #define GL_TEXTURE14_ARB 0x84CE #define GL_TEXTURE15_ARB 0x84CF #define GL_TEXTURE16_ARB 0x84D0 #define GL_TEXTURE17_ARB 0x84D1 #define GL_TEXTURE18_ARB 0x84D2 #define GL_TEXTURE19_ARB 0x84D3 #define GL_TEXTURE20_ARB 0x84D4 #define GL_TEXTURE21_ARB 0x84D5 #define GL_TEXTURE22_ARB 0x84D6 #define GL_TEXTURE23_ARB 0x84D7 #define GL_TEXTURE24_ARB 0x84D8 #define GL_TEXTURE25_ARB 0x84D9 #define GL_TEXTURE26_ARB 0x84DA #define GL_TEXTURE27_ARB 0x84DB #define GL_TEXTURE28_ARB 0x84DC #define GL_TEXTURE29_ARB 0x84DD #define GL_TEXTURE30_ARB 0x84DE #define GL_TEXTURE31_ARB 0x84DF #define GL_ACTIVE_TEXTURE_ARB 0x84E0 #define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 #define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture); typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); #define glActiveTextureARB GLEW_GET_FUN(__glewActiveTextureARB) #define glClientActiveTextureARB GLEW_GET_FUN(__glewClientActiveTextureARB) #define glMultiTexCoord1dARB GLEW_GET_FUN(__glewMultiTexCoord1dARB) #define glMultiTexCoord1dvARB GLEW_GET_FUN(__glewMultiTexCoord1dvARB) #define glMultiTexCoord1fARB GLEW_GET_FUN(__glewMultiTexCoord1fARB) #define glMultiTexCoord1fvARB GLEW_GET_FUN(__glewMultiTexCoord1fvARB) #define glMultiTexCoord1iARB GLEW_GET_FUN(__glewMultiTexCoord1iARB) #define glMultiTexCoord1ivARB GLEW_GET_FUN(__glewMultiTexCoord1ivARB) #define glMultiTexCoord1sARB GLEW_GET_FUN(__glewMultiTexCoord1sARB) #define glMultiTexCoord1svARB GLEW_GET_FUN(__glewMultiTexCoord1svARB) #define glMultiTexCoord2dARB GLEW_GET_FUN(__glewMultiTexCoord2dARB) #define glMultiTexCoord2dvARB GLEW_GET_FUN(__glewMultiTexCoord2dvARB) #define glMultiTexCoord2fARB GLEW_GET_FUN(__glewMultiTexCoord2fARB) #define glMultiTexCoord2fvARB GLEW_GET_FUN(__glewMultiTexCoord2fvARB) #define glMultiTexCoord2iARB GLEW_GET_FUN(__glewMultiTexCoord2iARB) #define glMultiTexCoord2ivARB GLEW_GET_FUN(__glewMultiTexCoord2ivARB) #define glMultiTexCoord2sARB GLEW_GET_FUN(__glewMultiTexCoord2sARB) #define glMultiTexCoord2svARB GLEW_GET_FUN(__glewMultiTexCoord2svARB) #define glMultiTexCoord3dARB GLEW_GET_FUN(__glewMultiTexCoord3dARB) #define glMultiTexCoord3dvARB GLEW_GET_FUN(__glewMultiTexCoord3dvARB) #define glMultiTexCoord3fARB GLEW_GET_FUN(__glewMultiTexCoord3fARB) #define glMultiTexCoord3fvARB GLEW_GET_FUN(__glewMultiTexCoord3fvARB) #define glMultiTexCoord3iARB GLEW_GET_FUN(__glewMultiTexCoord3iARB) #define glMultiTexCoord3ivARB GLEW_GET_FUN(__glewMultiTexCoord3ivARB) #define glMultiTexCoord3sARB GLEW_GET_FUN(__glewMultiTexCoord3sARB) #define glMultiTexCoord3svARB GLEW_GET_FUN(__glewMultiTexCoord3svARB) #define glMultiTexCoord4dARB GLEW_GET_FUN(__glewMultiTexCoord4dARB) #define glMultiTexCoord4dvARB GLEW_GET_FUN(__glewMultiTexCoord4dvARB) #define glMultiTexCoord4fARB GLEW_GET_FUN(__glewMultiTexCoord4fARB) #define glMultiTexCoord4fvARB GLEW_GET_FUN(__glewMultiTexCoord4fvARB) #define glMultiTexCoord4iARB GLEW_GET_FUN(__glewMultiTexCoord4iARB) #define glMultiTexCoord4ivARB GLEW_GET_FUN(__glewMultiTexCoord4ivARB) #define glMultiTexCoord4sARB GLEW_GET_FUN(__glewMultiTexCoord4sARB) #define glMultiTexCoord4svARB GLEW_GET_FUN(__glewMultiTexCoord4svARB) #define GLEW_ARB_multitexture GLEW_GET_VAR(__GLEW_ARB_multitexture) #endif /* GL_ARB_multitexture */ /* ------------------------- GL_ARB_occlusion_query ------------------------ */ #ifndef GL_ARB_occlusion_query #define GL_ARB_occlusion_query 1 #define GL_QUERY_COUNTER_BITS_ARB 0x8864 #define GL_CURRENT_QUERY_ARB 0x8865 #define GL_QUERY_RESULT_ARB 0x8866 #define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 #define GL_SAMPLES_PASSED_ARB 0x8914 typedef void (GLAPIENTRY * PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); typedef void (GLAPIENTRY * PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint* ids); typedef void (GLAPIENTRY * PFNGLENDQUERYARBPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint* ids); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISQUERYARBPROC) (GLuint id); #define glBeginQueryARB GLEW_GET_FUN(__glewBeginQueryARB) #define glDeleteQueriesARB GLEW_GET_FUN(__glewDeleteQueriesARB) #define glEndQueryARB GLEW_GET_FUN(__glewEndQueryARB) #define glGenQueriesARB GLEW_GET_FUN(__glewGenQueriesARB) #define glGetQueryObjectivARB GLEW_GET_FUN(__glewGetQueryObjectivARB) #define glGetQueryObjectuivARB GLEW_GET_FUN(__glewGetQueryObjectuivARB) #define glGetQueryivARB GLEW_GET_FUN(__glewGetQueryivARB) #define glIsQueryARB GLEW_GET_FUN(__glewIsQueryARB) #define GLEW_ARB_occlusion_query GLEW_GET_VAR(__GLEW_ARB_occlusion_query) #endif /* GL_ARB_occlusion_query */ /* ------------------------ GL_ARB_occlusion_query2 ------------------------ */ #ifndef GL_ARB_occlusion_query2 #define GL_ARB_occlusion_query2 1 #define GL_ANY_SAMPLES_PASSED 0x8C2F #define GLEW_ARB_occlusion_query2 GLEW_GET_VAR(__GLEW_ARB_occlusion_query2) #endif /* GL_ARB_occlusion_query2 */ /* --------------------- GL_ARB_parallel_shader_compile -------------------- */ #ifndef GL_ARB_parallel_shader_compile #define GL_ARB_parallel_shader_compile 1 #define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 #define GL_COMPLETION_STATUS_ARB 0x91B1 typedef void (GLAPIENTRY * PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count); #define glMaxShaderCompilerThreadsARB GLEW_GET_FUN(__glewMaxShaderCompilerThreadsARB) #define GLEW_ARB_parallel_shader_compile GLEW_GET_VAR(__GLEW_ARB_parallel_shader_compile) #endif /* GL_ARB_parallel_shader_compile */ /* -------------------- GL_ARB_pipeline_statistics_query ------------------- */ #ifndef GL_ARB_pipeline_statistics_query #define GL_ARB_pipeline_statistics_query 1 #define GL_VERTICES_SUBMITTED_ARB 0x82EE #define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF #define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0 #define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1 #define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2 #define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3 #define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4 #define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5 #define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6 #define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7 #define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F #define GLEW_ARB_pipeline_statistics_query GLEW_GET_VAR(__GLEW_ARB_pipeline_statistics_query) #endif /* GL_ARB_pipeline_statistics_query */ /* ----------------------- GL_ARB_pixel_buffer_object ---------------------- */ #ifndef GL_ARB_pixel_buffer_object #define GL_ARB_pixel_buffer_object 1 #define GL_PIXEL_PACK_BUFFER_ARB 0x88EB #define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC #define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED #define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF #define GLEW_ARB_pixel_buffer_object GLEW_GET_VAR(__GLEW_ARB_pixel_buffer_object) #endif /* GL_ARB_pixel_buffer_object */ /* ------------------------ GL_ARB_point_parameters ------------------------ */ #ifndef GL_ARB_point_parameters #define GL_ARB_point_parameters 1 #define GL_POINT_SIZE_MIN_ARB 0x8126 #define GL_POINT_SIZE_MAX_ARB 0x8127 #define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 #define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat* params); #define glPointParameterfARB GLEW_GET_FUN(__glewPointParameterfARB) #define glPointParameterfvARB GLEW_GET_FUN(__glewPointParameterfvARB) #define GLEW_ARB_point_parameters GLEW_GET_VAR(__GLEW_ARB_point_parameters) #endif /* GL_ARB_point_parameters */ /* -------------------------- GL_ARB_point_sprite -------------------------- */ #ifndef GL_ARB_point_sprite #define GL_ARB_point_sprite 1 #define GL_POINT_SPRITE_ARB 0x8861 #define GL_COORD_REPLACE_ARB 0x8862 #define GLEW_ARB_point_sprite GLEW_GET_VAR(__GLEW_ARB_point_sprite) #endif /* GL_ARB_point_sprite */ /* ----------------------- GL_ARB_post_depth_coverage ---------------------- */ #ifndef GL_ARB_post_depth_coverage #define GL_ARB_post_depth_coverage 1 #define GLEW_ARB_post_depth_coverage GLEW_GET_VAR(__GLEW_ARB_post_depth_coverage) #endif /* GL_ARB_post_depth_coverage */ /* --------------------- GL_ARB_program_interface_query -------------------- */ #ifndef GL_ARB_program_interface_query #define GL_ARB_program_interface_query 1 #define GL_UNIFORM 0x92E1 #define GL_UNIFORM_BLOCK 0x92E2 #define GL_PROGRAM_INPUT 0x92E3 #define GL_PROGRAM_OUTPUT 0x92E4 #define GL_BUFFER_VARIABLE 0x92E5 #define GL_SHADER_STORAGE_BLOCK 0x92E6 #define GL_IS_PER_PATCH 0x92E7 #define GL_VERTEX_SUBROUTINE 0x92E8 #define GL_TESS_CONTROL_SUBROUTINE 0x92E9 #define GL_TESS_EVALUATION_SUBROUTINE 0x92EA #define GL_GEOMETRY_SUBROUTINE 0x92EB #define GL_FRAGMENT_SUBROUTINE 0x92EC #define GL_COMPUTE_SUBROUTINE 0x92ED #define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE #define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF #define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 #define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 #define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 #define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 #define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 #define GL_ACTIVE_RESOURCES 0x92F5 #define GL_MAX_NAME_LENGTH 0x92F6 #define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 #define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 #define GL_NAME_LENGTH 0x92F9 #define GL_TYPE 0x92FA #define GL_ARRAY_SIZE 0x92FB #define GL_OFFSET 0x92FC #define GL_BLOCK_INDEX 0x92FD #define GL_ARRAY_STRIDE 0x92FE #define GL_MATRIX_STRIDE 0x92FF #define GL_IS_ROW_MAJOR 0x9300 #define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 #define GL_BUFFER_BINDING 0x9302 #define GL_BUFFER_DATA_SIZE 0x9303 #define GL_NUM_ACTIVE_VARIABLES 0x9304 #define GL_ACTIVE_VARIABLES 0x9305 #define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 #define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 #define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 #define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 #define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A #define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B #define GL_TOP_LEVEL_ARRAY_SIZE 0x930C #define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D #define GL_LOCATION 0x930E #define GL_LOCATION_INDEX 0x930F typedef void (GLAPIENTRY * PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint* params); typedef GLuint (GLAPIENTRY * PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar* name); typedef GLint (GLAPIENTRY * PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar* name); typedef GLint (GLAPIENTRY * PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar* name); typedef void (GLAPIENTRY * PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei* length, GLchar *name); typedef void (GLAPIENTRY * PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum* props, GLsizei bufSize, GLsizei *length, GLint *params); #define glGetProgramInterfaceiv GLEW_GET_FUN(__glewGetProgramInterfaceiv) #define glGetProgramResourceIndex GLEW_GET_FUN(__glewGetProgramResourceIndex) #define glGetProgramResourceLocation GLEW_GET_FUN(__glewGetProgramResourceLocation) #define glGetProgramResourceLocationIndex GLEW_GET_FUN(__glewGetProgramResourceLocationIndex) #define glGetProgramResourceName GLEW_GET_FUN(__glewGetProgramResourceName) #define glGetProgramResourceiv GLEW_GET_FUN(__glewGetProgramResourceiv) #define GLEW_ARB_program_interface_query GLEW_GET_VAR(__GLEW_ARB_program_interface_query) #endif /* GL_ARB_program_interface_query */ /* ------------------------ GL_ARB_provoking_vertex ------------------------ */ #ifndef GL_ARB_provoking_vertex #define GL_ARB_provoking_vertex 1 #define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C #define GL_FIRST_VERTEX_CONVENTION 0x8E4D #define GL_LAST_VERTEX_CONVENTION 0x8E4E #define GL_PROVOKING_VERTEX 0x8E4F typedef void (GLAPIENTRY * PFNGLPROVOKINGVERTEXPROC) (GLenum mode); #define glProvokingVertex GLEW_GET_FUN(__glewProvokingVertex) #define GLEW_ARB_provoking_vertex GLEW_GET_VAR(__GLEW_ARB_provoking_vertex) #endif /* GL_ARB_provoking_vertex */ /* ----------------------- GL_ARB_query_buffer_object ---------------------- */ #ifndef GL_ARB_query_buffer_object #define GL_ARB_query_buffer_object 1 #define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 #define GL_QUERY_BUFFER 0x9192 #define GL_QUERY_BUFFER_BINDING 0x9193 #define GL_QUERY_RESULT_NO_WAIT 0x9194 #define GLEW_ARB_query_buffer_object GLEW_GET_VAR(__GLEW_ARB_query_buffer_object) #endif /* GL_ARB_query_buffer_object */ /* ------------------ GL_ARB_robust_buffer_access_behavior ----------------- */ #ifndef GL_ARB_robust_buffer_access_behavior #define GL_ARB_robust_buffer_access_behavior 1 #define GLEW_ARB_robust_buffer_access_behavior GLEW_GET_VAR(__GLEW_ARB_robust_buffer_access_behavior) #endif /* GL_ARB_robust_buffer_access_behavior */ /* --------------------------- GL_ARB_robustness --------------------------- */ #ifndef GL_ARB_robustness #define GL_ARB_robustness 1 #define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 #define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 #define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 #define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 #define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 #define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 #define GL_NO_RESET_NOTIFICATION_ARB 0x8261 typedef GLenum (GLAPIENTRY * PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); typedef void (GLAPIENTRY * PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void* table); typedef void (GLAPIENTRY * PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void* img); typedef void (GLAPIENTRY * PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void* image); typedef void (GLAPIENTRY * PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void* values); typedef void (GLAPIENTRY * PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble* v); typedef void (GLAPIENTRY * PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat* v); typedef void (GLAPIENTRY * PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint* v); typedef void (GLAPIENTRY * PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void* values); typedef void (GLAPIENTRY * PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat* values); typedef void (GLAPIENTRY * PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint* values); typedef void (GLAPIENTRY * PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort* values); typedef void (GLAPIENTRY * PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte* pattern); typedef void (GLAPIENTRY * PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void* row, GLsizei columnBufSize, void*column, void*span); typedef void (GLAPIENTRY * PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void* img); typedef void (GLAPIENTRY * PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint* params); typedef void (GLAPIENTRY * PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void* data); #define glGetGraphicsResetStatusARB GLEW_GET_FUN(__glewGetGraphicsResetStatusARB) #define glGetnColorTableARB GLEW_GET_FUN(__glewGetnColorTableARB) #define glGetnCompressedTexImageARB GLEW_GET_FUN(__glewGetnCompressedTexImageARB) #define glGetnConvolutionFilterARB GLEW_GET_FUN(__glewGetnConvolutionFilterARB) #define glGetnHistogramARB GLEW_GET_FUN(__glewGetnHistogramARB) #define glGetnMapdvARB GLEW_GET_FUN(__glewGetnMapdvARB) #define glGetnMapfvARB GLEW_GET_FUN(__glewGetnMapfvARB) #define glGetnMapivARB GLEW_GET_FUN(__glewGetnMapivARB) #define glGetnMinmaxARB GLEW_GET_FUN(__glewGetnMinmaxARB) #define glGetnPixelMapfvARB GLEW_GET_FUN(__glewGetnPixelMapfvARB) #define glGetnPixelMapuivARB GLEW_GET_FUN(__glewGetnPixelMapuivARB) #define glGetnPixelMapusvARB GLEW_GET_FUN(__glewGetnPixelMapusvARB) #define glGetnPolygonStippleARB GLEW_GET_FUN(__glewGetnPolygonStippleARB) #define glGetnSeparableFilterARB GLEW_GET_FUN(__glewGetnSeparableFilterARB) #define glGetnTexImageARB GLEW_GET_FUN(__glewGetnTexImageARB) #define glGetnUniformdvARB GLEW_GET_FUN(__glewGetnUniformdvARB) #define glGetnUniformfvARB GLEW_GET_FUN(__glewGetnUniformfvARB) #define glGetnUniformivARB GLEW_GET_FUN(__glewGetnUniformivARB) #define glGetnUniformuivARB GLEW_GET_FUN(__glewGetnUniformuivARB) #define glReadnPixelsARB GLEW_GET_FUN(__glewReadnPixelsARB) #define GLEW_ARB_robustness GLEW_GET_VAR(__GLEW_ARB_robustness) #endif /* GL_ARB_robustness */ /* ---------------- GL_ARB_robustness_application_isolation ---------------- */ #ifndef GL_ARB_robustness_application_isolation #define GL_ARB_robustness_application_isolation 1 #define GLEW_ARB_robustness_application_isolation GLEW_GET_VAR(__GLEW_ARB_robustness_application_isolation) #endif /* GL_ARB_robustness_application_isolation */ /* ---------------- GL_ARB_robustness_share_group_isolation ---------------- */ #ifndef GL_ARB_robustness_share_group_isolation #define GL_ARB_robustness_share_group_isolation 1 #define GLEW_ARB_robustness_share_group_isolation GLEW_GET_VAR(__GLEW_ARB_robustness_share_group_isolation) #endif /* GL_ARB_robustness_share_group_isolation */ /* ------------------------ GL_ARB_sample_locations ------------------------ */ #ifndef GL_ARB_sample_locations #define GL_ARB_sample_locations 1 #define GL_SAMPLE_LOCATION_ARB 0x8E50 #define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D #define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E #define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F #define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 #define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 #define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 #define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat* v); #define glFramebufferSampleLocationsfvARB GLEW_GET_FUN(__glewFramebufferSampleLocationsfvARB) #define glNamedFramebufferSampleLocationsfvARB GLEW_GET_FUN(__glewNamedFramebufferSampleLocationsfvARB) #define GLEW_ARB_sample_locations GLEW_GET_VAR(__GLEW_ARB_sample_locations) #endif /* GL_ARB_sample_locations */ /* ------------------------- GL_ARB_sample_shading ------------------------- */ #ifndef GL_ARB_sample_shading #define GL_ARB_sample_shading 1 #define GL_SAMPLE_SHADING_ARB 0x8C36 #define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 typedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value); #define glMinSampleShadingARB GLEW_GET_FUN(__glewMinSampleShadingARB) #define GLEW_ARB_sample_shading GLEW_GET_VAR(__GLEW_ARB_sample_shading) #endif /* GL_ARB_sample_shading */ /* ------------------------- GL_ARB_sampler_objects ------------------------ */ #ifndef GL_ARB_sampler_objects #define GL_ARB_sampler_objects 1 #define GL_SAMPLER_BINDING 0x8919 typedef void (GLAPIENTRY * PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); typedef void (GLAPIENTRY * PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint * samplers); typedef void (GLAPIENTRY * PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint* samplers); typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISSAMPLERPROC) (GLuint sampler); typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint* params); typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint* params); #define glBindSampler GLEW_GET_FUN(__glewBindSampler) #define glDeleteSamplers GLEW_GET_FUN(__glewDeleteSamplers) #define glGenSamplers GLEW_GET_FUN(__glewGenSamplers) #define glGetSamplerParameterIiv GLEW_GET_FUN(__glewGetSamplerParameterIiv) #define glGetSamplerParameterIuiv GLEW_GET_FUN(__glewGetSamplerParameterIuiv) #define glGetSamplerParameterfv GLEW_GET_FUN(__glewGetSamplerParameterfv) #define glGetSamplerParameteriv GLEW_GET_FUN(__glewGetSamplerParameteriv) #define glIsSampler GLEW_GET_FUN(__glewIsSampler) #define glSamplerParameterIiv GLEW_GET_FUN(__glewSamplerParameterIiv) #define glSamplerParameterIuiv GLEW_GET_FUN(__glewSamplerParameterIuiv) #define glSamplerParameterf GLEW_GET_FUN(__glewSamplerParameterf) #define glSamplerParameterfv GLEW_GET_FUN(__glewSamplerParameterfv) #define glSamplerParameteri GLEW_GET_FUN(__glewSamplerParameteri) #define glSamplerParameteriv GLEW_GET_FUN(__glewSamplerParameteriv) #define GLEW_ARB_sampler_objects GLEW_GET_VAR(__GLEW_ARB_sampler_objects) #endif /* GL_ARB_sampler_objects */ /* ------------------------ GL_ARB_seamless_cube_map ----------------------- */ #ifndef GL_ARB_seamless_cube_map #define GL_ARB_seamless_cube_map 1 #define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F #define GLEW_ARB_seamless_cube_map GLEW_GET_VAR(__GLEW_ARB_seamless_cube_map) #endif /* GL_ARB_seamless_cube_map */ /* ------------------ GL_ARB_seamless_cubemap_per_texture ------------------ */ #ifndef GL_ARB_seamless_cubemap_per_texture #define GL_ARB_seamless_cubemap_per_texture 1 #define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F #define GLEW_ARB_seamless_cubemap_per_texture GLEW_GET_VAR(__GLEW_ARB_seamless_cubemap_per_texture) #endif /* GL_ARB_seamless_cubemap_per_texture */ /* --------------------- GL_ARB_separate_shader_objects -------------------- */ #ifndef GL_ARB_separate_shader_objects #define GL_ARB_separate_shader_objects 1 #define GL_VERTEX_SHADER_BIT 0x00000001 #define GL_FRAGMENT_SHADER_BIT 0x00000002 #define GL_GEOMETRY_SHADER_BIT 0x00000004 #define GL_TESS_CONTROL_SHADER_BIT 0x00000008 #define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 #define GL_PROGRAM_SEPARABLE 0x8258 #define GL_ACTIVE_PROGRAM 0x8259 #define GL_PROGRAM_PIPELINE_BINDING 0x825A #define GL_ALL_SHADER_BITS 0xFFFFFFFF typedef void (GLAPIENTRY * PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); typedef void (GLAPIENTRY * PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar * const * strings); typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint* pipelines); typedef void (GLAPIENTRY * PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint* pipelines); typedef void (GLAPIENTRY * PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei* length, GLchar *infoLog); typedef void (GLAPIENTRY * PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint x, GLint y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint x, GLuint y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint x, GLuint y, GLuint z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); #define glActiveShaderProgram GLEW_GET_FUN(__glewActiveShaderProgram) #define glBindProgramPipeline GLEW_GET_FUN(__glewBindProgramPipeline) #define glCreateShaderProgramv GLEW_GET_FUN(__glewCreateShaderProgramv) #define glDeleteProgramPipelines GLEW_GET_FUN(__glewDeleteProgramPipelines) #define glGenProgramPipelines GLEW_GET_FUN(__glewGenProgramPipelines) #define glGetProgramPipelineInfoLog GLEW_GET_FUN(__glewGetProgramPipelineInfoLog) #define glGetProgramPipelineiv GLEW_GET_FUN(__glewGetProgramPipelineiv) #define glIsProgramPipeline GLEW_GET_FUN(__glewIsProgramPipeline) #define glProgramUniform1d GLEW_GET_FUN(__glewProgramUniform1d) #define glProgramUniform1dv GLEW_GET_FUN(__glewProgramUniform1dv) #define glProgramUniform1f GLEW_GET_FUN(__glewProgramUniform1f) #define glProgramUniform1fv GLEW_GET_FUN(__glewProgramUniform1fv) #define glProgramUniform1i GLEW_GET_FUN(__glewProgramUniform1i) #define glProgramUniform1iv GLEW_GET_FUN(__glewProgramUniform1iv) #define glProgramUniform1ui GLEW_GET_FUN(__glewProgramUniform1ui) #define glProgramUniform1uiv GLEW_GET_FUN(__glewProgramUniform1uiv) #define glProgramUniform2d GLEW_GET_FUN(__glewProgramUniform2d) #define glProgramUniform2dv GLEW_GET_FUN(__glewProgramUniform2dv) #define glProgramUniform2f GLEW_GET_FUN(__glewProgramUniform2f) #define glProgramUniform2fv GLEW_GET_FUN(__glewProgramUniform2fv) #define glProgramUniform2i GLEW_GET_FUN(__glewProgramUniform2i) #define glProgramUniform2iv GLEW_GET_FUN(__glewProgramUniform2iv) #define glProgramUniform2ui GLEW_GET_FUN(__glewProgramUniform2ui) #define glProgramUniform2uiv GLEW_GET_FUN(__glewProgramUniform2uiv) #define glProgramUniform3d GLEW_GET_FUN(__glewProgramUniform3d) #define glProgramUniform3dv GLEW_GET_FUN(__glewProgramUniform3dv) #define glProgramUniform3f GLEW_GET_FUN(__glewProgramUniform3f) #define glProgramUniform3fv GLEW_GET_FUN(__glewProgramUniform3fv) #define glProgramUniform3i GLEW_GET_FUN(__glewProgramUniform3i) #define glProgramUniform3iv GLEW_GET_FUN(__glewProgramUniform3iv) #define glProgramUniform3ui GLEW_GET_FUN(__glewProgramUniform3ui) #define glProgramUniform3uiv GLEW_GET_FUN(__glewProgramUniform3uiv) #define glProgramUniform4d GLEW_GET_FUN(__glewProgramUniform4d) #define glProgramUniform4dv GLEW_GET_FUN(__glewProgramUniform4dv) #define glProgramUniform4f GLEW_GET_FUN(__glewProgramUniform4f) #define glProgramUniform4fv GLEW_GET_FUN(__glewProgramUniform4fv) #define glProgramUniform4i GLEW_GET_FUN(__glewProgramUniform4i) #define glProgramUniform4iv GLEW_GET_FUN(__glewProgramUniform4iv) #define glProgramUniform4ui GLEW_GET_FUN(__glewProgramUniform4ui) #define glProgramUniform4uiv GLEW_GET_FUN(__glewProgramUniform4uiv) #define glProgramUniformMatrix2dv GLEW_GET_FUN(__glewProgramUniformMatrix2dv) #define glProgramUniformMatrix2fv GLEW_GET_FUN(__glewProgramUniformMatrix2fv) #define glProgramUniformMatrix2x3dv GLEW_GET_FUN(__glewProgramUniformMatrix2x3dv) #define glProgramUniformMatrix2x3fv GLEW_GET_FUN(__glewProgramUniformMatrix2x3fv) #define glProgramUniformMatrix2x4dv GLEW_GET_FUN(__glewProgramUniformMatrix2x4dv) #define glProgramUniformMatrix2x4fv GLEW_GET_FUN(__glewProgramUniformMatrix2x4fv) #define glProgramUniformMatrix3dv GLEW_GET_FUN(__glewProgramUniformMatrix3dv) #define glProgramUniformMatrix3fv GLEW_GET_FUN(__glewProgramUniformMatrix3fv) #define glProgramUniformMatrix3x2dv GLEW_GET_FUN(__glewProgramUniformMatrix3x2dv) #define glProgramUniformMatrix3x2fv GLEW_GET_FUN(__glewProgramUniformMatrix3x2fv) #define glProgramUniformMatrix3x4dv GLEW_GET_FUN(__glewProgramUniformMatrix3x4dv) #define glProgramUniformMatrix3x4fv GLEW_GET_FUN(__glewProgramUniformMatrix3x4fv) #define glProgramUniformMatrix4dv GLEW_GET_FUN(__glewProgramUniformMatrix4dv) #define glProgramUniformMatrix4fv GLEW_GET_FUN(__glewProgramUniformMatrix4fv) #define glProgramUniformMatrix4x2dv GLEW_GET_FUN(__glewProgramUniformMatrix4x2dv) #define glProgramUniformMatrix4x2fv GLEW_GET_FUN(__glewProgramUniformMatrix4x2fv) #define glProgramUniformMatrix4x3dv GLEW_GET_FUN(__glewProgramUniformMatrix4x3dv) #define glProgramUniformMatrix4x3fv GLEW_GET_FUN(__glewProgramUniformMatrix4x3fv) #define glUseProgramStages GLEW_GET_FUN(__glewUseProgramStages) #define glValidateProgramPipeline GLEW_GET_FUN(__glewValidateProgramPipeline) #define GLEW_ARB_separate_shader_objects GLEW_GET_VAR(__GLEW_ARB_separate_shader_objects) #endif /* GL_ARB_separate_shader_objects */ /* -------------------- GL_ARB_shader_atomic_counter_ops ------------------- */ #ifndef GL_ARB_shader_atomic_counter_ops #define GL_ARB_shader_atomic_counter_ops 1 #define GLEW_ARB_shader_atomic_counter_ops GLEW_GET_VAR(__GLEW_ARB_shader_atomic_counter_ops) #endif /* GL_ARB_shader_atomic_counter_ops */ /* --------------------- GL_ARB_shader_atomic_counters --------------------- */ #ifndef GL_ARB_shader_atomic_counters #define GL_ARB_shader_atomic_counters 1 #define GL_ATOMIC_COUNTER_BUFFER 0x92C0 #define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 #define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 #define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 #define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 #define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 #define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB #define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC #define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD #define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE #define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF #define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 #define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 #define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 #define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 #define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 #define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 #define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 #define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 #define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 #define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 #define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA #define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB #define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC typedef void (GLAPIENTRY * PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint* params); #define glGetActiveAtomicCounterBufferiv GLEW_GET_FUN(__glewGetActiveAtomicCounterBufferiv) #define GLEW_ARB_shader_atomic_counters GLEW_GET_VAR(__GLEW_ARB_shader_atomic_counters) #endif /* GL_ARB_shader_atomic_counters */ /* -------------------------- GL_ARB_shader_ballot ------------------------- */ #ifndef GL_ARB_shader_ballot #define GL_ARB_shader_ballot 1 #define GLEW_ARB_shader_ballot GLEW_GET_VAR(__GLEW_ARB_shader_ballot) #endif /* GL_ARB_shader_ballot */ /* ----------------------- GL_ARB_shader_bit_encoding ---------------------- */ #ifndef GL_ARB_shader_bit_encoding #define GL_ARB_shader_bit_encoding 1 #define GLEW_ARB_shader_bit_encoding GLEW_GET_VAR(__GLEW_ARB_shader_bit_encoding) #endif /* GL_ARB_shader_bit_encoding */ /* -------------------------- GL_ARB_shader_clock -------------------------- */ #ifndef GL_ARB_shader_clock #define GL_ARB_shader_clock 1 #define GLEW_ARB_shader_clock GLEW_GET_VAR(__GLEW_ARB_shader_clock) #endif /* GL_ARB_shader_clock */ /* --------------------- GL_ARB_shader_draw_parameters --------------------- */ #ifndef GL_ARB_shader_draw_parameters #define GL_ARB_shader_draw_parameters 1 #define GLEW_ARB_shader_draw_parameters GLEW_GET_VAR(__GLEW_ARB_shader_draw_parameters) #endif /* GL_ARB_shader_draw_parameters */ /* ------------------------ GL_ARB_shader_group_vote ----------------------- */ #ifndef GL_ARB_shader_group_vote #define GL_ARB_shader_group_vote 1 #define GLEW_ARB_shader_group_vote GLEW_GET_VAR(__GLEW_ARB_shader_group_vote) #endif /* GL_ARB_shader_group_vote */ /* --------------------- GL_ARB_shader_image_load_store -------------------- */ #ifndef GL_ARB_shader_image_load_store #define GL_ARB_shader_image_load_store 1 #define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 #define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 #define GL_UNIFORM_BARRIER_BIT 0x00000004 #define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 #define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 #define GL_COMMAND_BARRIER_BIT 0x00000040 #define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 #define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 #define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 #define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 #define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 #define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 #define GL_MAX_IMAGE_UNITS 0x8F38 #define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 #define GL_IMAGE_BINDING_NAME 0x8F3A #define GL_IMAGE_BINDING_LEVEL 0x8F3B #define GL_IMAGE_BINDING_LAYERED 0x8F3C #define GL_IMAGE_BINDING_LAYER 0x8F3D #define GL_IMAGE_BINDING_ACCESS 0x8F3E #define GL_IMAGE_1D 0x904C #define GL_IMAGE_2D 0x904D #define GL_IMAGE_3D 0x904E #define GL_IMAGE_2D_RECT 0x904F #define GL_IMAGE_CUBE 0x9050 #define GL_IMAGE_BUFFER 0x9051 #define GL_IMAGE_1D_ARRAY 0x9052 #define GL_IMAGE_2D_ARRAY 0x9053 #define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 #define GL_IMAGE_2D_MULTISAMPLE 0x9055 #define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 #define GL_INT_IMAGE_1D 0x9057 #define GL_INT_IMAGE_2D 0x9058 #define GL_INT_IMAGE_3D 0x9059 #define GL_INT_IMAGE_2D_RECT 0x905A #define GL_INT_IMAGE_CUBE 0x905B #define GL_INT_IMAGE_BUFFER 0x905C #define GL_INT_IMAGE_1D_ARRAY 0x905D #define GL_INT_IMAGE_2D_ARRAY 0x905E #define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F #define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 #define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 #define GL_UNSIGNED_INT_IMAGE_1D 0x9062 #define GL_UNSIGNED_INT_IMAGE_2D 0x9063 #define GL_UNSIGNED_INT_IMAGE_3D 0x9064 #define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 #define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 #define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 #define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 #define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 #define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C #define GL_MAX_IMAGE_SAMPLES 0x906D #define GL_IMAGE_BINDING_FORMAT 0x906E #define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 #define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 #define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 #define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA #define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB #define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC #define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD #define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE #define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF #define GL_ALL_BARRIER_BITS 0xFFFFFFFF typedef void (GLAPIENTRY * PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); typedef void (GLAPIENTRY * PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); #define glBindImageTexture GLEW_GET_FUN(__glewBindImageTexture) #define glMemoryBarrier GLEW_GET_FUN(__glewMemoryBarrier) #define GLEW_ARB_shader_image_load_store GLEW_GET_VAR(__GLEW_ARB_shader_image_load_store) #endif /* GL_ARB_shader_image_load_store */ /* ------------------------ GL_ARB_shader_image_size ----------------------- */ #ifndef GL_ARB_shader_image_size #define GL_ARB_shader_image_size 1 #define GLEW_ARB_shader_image_size GLEW_GET_VAR(__GLEW_ARB_shader_image_size) #endif /* GL_ARB_shader_image_size */ /* ------------------------- GL_ARB_shader_objects ------------------------- */ #ifndef GL_ARB_shader_objects #define GL_ARB_shader_objects 1 #define GL_PROGRAM_OBJECT_ARB 0x8B40 #define GL_SHADER_OBJECT_ARB 0x8B48 #define GL_OBJECT_TYPE_ARB 0x8B4E #define GL_OBJECT_SUBTYPE_ARB 0x8B4F #define GL_FLOAT_VEC2_ARB 0x8B50 #define GL_FLOAT_VEC3_ARB 0x8B51 #define GL_FLOAT_VEC4_ARB 0x8B52 #define GL_INT_VEC2_ARB 0x8B53 #define GL_INT_VEC3_ARB 0x8B54 #define GL_INT_VEC4_ARB 0x8B55 #define GL_BOOL_ARB 0x8B56 #define GL_BOOL_VEC2_ARB 0x8B57 #define GL_BOOL_VEC3_ARB 0x8B58 #define GL_BOOL_VEC4_ARB 0x8B59 #define GL_FLOAT_MAT2_ARB 0x8B5A #define GL_FLOAT_MAT3_ARB 0x8B5B #define GL_FLOAT_MAT4_ARB 0x8B5C #define GL_SAMPLER_1D_ARB 0x8B5D #define GL_SAMPLER_2D_ARB 0x8B5E #define GL_SAMPLER_3D_ARB 0x8B5F #define GL_SAMPLER_CUBE_ARB 0x8B60 #define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 #define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 #define GL_SAMPLER_2D_RECT_ARB 0x8B63 #define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 #define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 #define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 #define GL_OBJECT_LINK_STATUS_ARB 0x8B82 #define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 #define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 #define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 #define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 #define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 #define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 typedef char GLcharARB; typedef unsigned int GLhandleARB; typedef void (GLAPIENTRY * PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); typedef void (GLAPIENTRY * PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); typedef GLhandleARB (GLAPIENTRY * PFNGLCREATEPROGRAMOBJECTARBPROC) (void); typedef GLhandleARB (GLAPIENTRY * PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); typedef void (GLAPIENTRY * PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); typedef void (GLAPIENTRY * PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); typedef void (GLAPIENTRY * PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei* count, GLhandleARB *obj); typedef GLhandleARB (GLAPIENTRY * PFNGLGETHANDLEARBPROC) (GLenum pname); typedef void (GLAPIENTRY * PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *infoLog); typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *source); typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint* params); typedef void (GLAPIENTRY * PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); typedef void (GLAPIENTRY * PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string, const GLint *length); typedef void (GLAPIENTRY * PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); typedef void (GLAPIENTRY * PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); typedef void (GLAPIENTRY * PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); typedef void (GLAPIENTRY * PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); typedef void (GLAPIENTRY * PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); typedef void (GLAPIENTRY * PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); typedef void (GLAPIENTRY * PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); typedef void (GLAPIENTRY * PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (GLAPIENTRY * PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); #define glAttachObjectARB GLEW_GET_FUN(__glewAttachObjectARB) #define glCompileShaderARB GLEW_GET_FUN(__glewCompileShaderARB) #define glCreateProgramObjectARB GLEW_GET_FUN(__glewCreateProgramObjectARB) #define glCreateShaderObjectARB GLEW_GET_FUN(__glewCreateShaderObjectARB) #define glDeleteObjectARB GLEW_GET_FUN(__glewDeleteObjectARB) #define glDetachObjectARB GLEW_GET_FUN(__glewDetachObjectARB) #define glGetActiveUniformARB GLEW_GET_FUN(__glewGetActiveUniformARB) #define glGetAttachedObjectsARB GLEW_GET_FUN(__glewGetAttachedObjectsARB) #define glGetHandleARB GLEW_GET_FUN(__glewGetHandleARB) #define glGetInfoLogARB GLEW_GET_FUN(__glewGetInfoLogARB) #define glGetObjectParameterfvARB GLEW_GET_FUN(__glewGetObjectParameterfvARB) #define glGetObjectParameterivARB GLEW_GET_FUN(__glewGetObjectParameterivARB) #define glGetShaderSourceARB GLEW_GET_FUN(__glewGetShaderSourceARB) #define glGetUniformLocationARB GLEW_GET_FUN(__glewGetUniformLocationARB) #define glGetUniformfvARB GLEW_GET_FUN(__glewGetUniformfvARB) #define glGetUniformivARB GLEW_GET_FUN(__glewGetUniformivARB) #define glLinkProgramARB GLEW_GET_FUN(__glewLinkProgramARB) #define glShaderSourceARB GLEW_GET_FUN(__glewShaderSourceARB) #define glUniform1fARB GLEW_GET_FUN(__glewUniform1fARB) #define glUniform1fvARB GLEW_GET_FUN(__glewUniform1fvARB) #define glUniform1iARB GLEW_GET_FUN(__glewUniform1iARB) #define glUniform1ivARB GLEW_GET_FUN(__glewUniform1ivARB) #define glUniform2fARB GLEW_GET_FUN(__glewUniform2fARB) #define glUniform2fvARB GLEW_GET_FUN(__glewUniform2fvARB) #define glUniform2iARB GLEW_GET_FUN(__glewUniform2iARB) #define glUniform2ivARB GLEW_GET_FUN(__glewUniform2ivARB) #define glUniform3fARB GLEW_GET_FUN(__glewUniform3fARB) #define glUniform3fvARB GLEW_GET_FUN(__glewUniform3fvARB) #define glUniform3iARB GLEW_GET_FUN(__glewUniform3iARB) #define glUniform3ivARB GLEW_GET_FUN(__glewUniform3ivARB) #define glUniform4fARB GLEW_GET_FUN(__glewUniform4fARB) #define glUniform4fvARB GLEW_GET_FUN(__glewUniform4fvARB) #define glUniform4iARB GLEW_GET_FUN(__glewUniform4iARB) #define glUniform4ivARB GLEW_GET_FUN(__glewUniform4ivARB) #define glUniformMatrix2fvARB GLEW_GET_FUN(__glewUniformMatrix2fvARB) #define glUniformMatrix3fvARB GLEW_GET_FUN(__glewUniformMatrix3fvARB) #define glUniformMatrix4fvARB GLEW_GET_FUN(__glewUniformMatrix4fvARB) #define glUseProgramObjectARB GLEW_GET_FUN(__glewUseProgramObjectARB) #define glValidateProgramARB GLEW_GET_FUN(__glewValidateProgramARB) #define GLEW_ARB_shader_objects GLEW_GET_VAR(__GLEW_ARB_shader_objects) #endif /* GL_ARB_shader_objects */ /* ------------------------ GL_ARB_shader_precision ------------------------ */ #ifndef GL_ARB_shader_precision #define GL_ARB_shader_precision 1 #define GLEW_ARB_shader_precision GLEW_GET_VAR(__GLEW_ARB_shader_precision) #endif /* GL_ARB_shader_precision */ /* ---------------------- GL_ARB_shader_stencil_export --------------------- */ #ifndef GL_ARB_shader_stencil_export #define GL_ARB_shader_stencil_export 1 #define GLEW_ARB_shader_stencil_export GLEW_GET_VAR(__GLEW_ARB_shader_stencil_export) #endif /* GL_ARB_shader_stencil_export */ /* ------------------ GL_ARB_shader_storage_buffer_object ------------------ */ #ifndef GL_ARB_shader_storage_buffer_object #define GL_ARB_shader_storage_buffer_object 1 #define GL_SHADER_STORAGE_BARRIER_BIT 0x2000 #define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 #define GL_SHADER_STORAGE_BUFFER 0x90D2 #define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 #define GL_SHADER_STORAGE_BUFFER_START 0x90D4 #define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 #define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 #define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 #define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 #define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 #define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA #define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB #define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC #define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD #define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE #define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF typedef void (GLAPIENTRY * PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); #define glShaderStorageBlockBinding GLEW_GET_FUN(__glewShaderStorageBlockBinding) #define GLEW_ARB_shader_storage_buffer_object GLEW_GET_VAR(__GLEW_ARB_shader_storage_buffer_object) #endif /* GL_ARB_shader_storage_buffer_object */ /* ------------------------ GL_ARB_shader_subroutine ----------------------- */ #ifndef GL_ARB_shader_subroutine #define GL_ARB_shader_subroutine 1 #define GL_ACTIVE_SUBROUTINES 0x8DE5 #define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 #define GL_MAX_SUBROUTINES 0x8DE7 #define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 #define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 #define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 #define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 #define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A #define GL_COMPATIBLE_SUBROUTINES 0x8E4B typedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei* length, GLchar *name); typedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei* length, GLchar *name); typedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint* values); typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint* values); typedef GLuint (GLAPIENTRY * PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar* name); typedef GLint (GLAPIENTRY * PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar* name); typedef void (GLAPIENTRY * PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint* params); typedef void (GLAPIENTRY * PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint* indices); #define glGetActiveSubroutineName GLEW_GET_FUN(__glewGetActiveSubroutineName) #define glGetActiveSubroutineUniformName GLEW_GET_FUN(__glewGetActiveSubroutineUniformName) #define glGetActiveSubroutineUniformiv GLEW_GET_FUN(__glewGetActiveSubroutineUniformiv) #define glGetProgramStageiv GLEW_GET_FUN(__glewGetProgramStageiv) #define glGetSubroutineIndex GLEW_GET_FUN(__glewGetSubroutineIndex) #define glGetSubroutineUniformLocation GLEW_GET_FUN(__glewGetSubroutineUniformLocation) #define glGetUniformSubroutineuiv GLEW_GET_FUN(__glewGetUniformSubroutineuiv) #define glUniformSubroutinesuiv GLEW_GET_FUN(__glewUniformSubroutinesuiv) #define GLEW_ARB_shader_subroutine GLEW_GET_VAR(__GLEW_ARB_shader_subroutine) #endif /* GL_ARB_shader_subroutine */ /* ------------------ GL_ARB_shader_texture_image_samples ------------------ */ #ifndef GL_ARB_shader_texture_image_samples #define GL_ARB_shader_texture_image_samples 1 #define GLEW_ARB_shader_texture_image_samples GLEW_GET_VAR(__GLEW_ARB_shader_texture_image_samples) #endif /* GL_ARB_shader_texture_image_samples */ /* ----------------------- GL_ARB_shader_texture_lod ----------------------- */ #ifndef GL_ARB_shader_texture_lod #define GL_ARB_shader_texture_lod 1 #define GLEW_ARB_shader_texture_lod GLEW_GET_VAR(__GLEW_ARB_shader_texture_lod) #endif /* GL_ARB_shader_texture_lod */ /* ------------------- GL_ARB_shader_viewport_layer_array ------------------ */ #ifndef GL_ARB_shader_viewport_layer_array #define GL_ARB_shader_viewport_layer_array 1 #define GLEW_ARB_shader_viewport_layer_array GLEW_GET_VAR(__GLEW_ARB_shader_viewport_layer_array) #endif /* GL_ARB_shader_viewport_layer_array */ /* ---------------------- GL_ARB_shading_language_100 ---------------------- */ #ifndef GL_ARB_shading_language_100 #define GL_ARB_shading_language_100 1 #define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C #define GLEW_ARB_shading_language_100 GLEW_GET_VAR(__GLEW_ARB_shading_language_100) #endif /* GL_ARB_shading_language_100 */ /* -------------------- GL_ARB_shading_language_420pack -------------------- */ #ifndef GL_ARB_shading_language_420pack #define GL_ARB_shading_language_420pack 1 #define GLEW_ARB_shading_language_420pack GLEW_GET_VAR(__GLEW_ARB_shading_language_420pack) #endif /* GL_ARB_shading_language_420pack */ /* -------------------- GL_ARB_shading_language_include -------------------- */ #ifndef GL_ARB_shading_language_include #define GL_ARB_shading_language_include 1 #define GL_SHADER_INCLUDE_ARB 0x8DAE #define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 #define GL_NAMED_STRING_TYPE_ARB 0x8DEA typedef void (GLAPIENTRY * PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* const *path, const GLint *length); typedef void (GLAPIENTRY * PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar* name); typedef void (GLAPIENTRY * PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar* name, GLsizei bufSize, GLint *stringlen, GLchar *string); typedef void (GLAPIENTRY * PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar* name, GLenum pname, GLint *params); typedef GLboolean (GLAPIENTRY * PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar* name); typedef void (GLAPIENTRY * PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar* name, GLint stringlen, const GLchar *string); #define glCompileShaderIncludeARB GLEW_GET_FUN(__glewCompileShaderIncludeARB) #define glDeleteNamedStringARB GLEW_GET_FUN(__glewDeleteNamedStringARB) #define glGetNamedStringARB GLEW_GET_FUN(__glewGetNamedStringARB) #define glGetNamedStringivARB GLEW_GET_FUN(__glewGetNamedStringivARB) #define glIsNamedStringARB GLEW_GET_FUN(__glewIsNamedStringARB) #define glNamedStringARB GLEW_GET_FUN(__glewNamedStringARB) #define GLEW_ARB_shading_language_include GLEW_GET_VAR(__GLEW_ARB_shading_language_include) #endif /* GL_ARB_shading_language_include */ /* -------------------- GL_ARB_shading_language_packing -------------------- */ #ifndef GL_ARB_shading_language_packing #define GL_ARB_shading_language_packing 1 #define GLEW_ARB_shading_language_packing GLEW_GET_VAR(__GLEW_ARB_shading_language_packing) #endif /* GL_ARB_shading_language_packing */ /* ----------------------------- GL_ARB_shadow ----------------------------- */ #ifndef GL_ARB_shadow #define GL_ARB_shadow 1 #define GL_TEXTURE_COMPARE_MODE_ARB 0x884C #define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D #define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E #define GLEW_ARB_shadow GLEW_GET_VAR(__GLEW_ARB_shadow) #endif /* GL_ARB_shadow */ /* ------------------------- GL_ARB_shadow_ambient ------------------------- */ #ifndef GL_ARB_shadow_ambient #define GL_ARB_shadow_ambient 1 #define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF #define GLEW_ARB_shadow_ambient GLEW_GET_VAR(__GLEW_ARB_shadow_ambient) #endif /* GL_ARB_shadow_ambient */ /* -------------------------- GL_ARB_sparse_buffer ------------------------- */ #ifndef GL_ARB_sparse_buffer #define GL_ARB_sparse_buffer 1 #define GL_SPARSE_STORAGE_BIT_ARB 0x0400 #define GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8 typedef void (GLAPIENTRY * PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); #define glBufferPageCommitmentARB GLEW_GET_FUN(__glewBufferPageCommitmentARB) #define GLEW_ARB_sparse_buffer GLEW_GET_VAR(__GLEW_ARB_sparse_buffer) #endif /* GL_ARB_sparse_buffer */ /* ------------------------- GL_ARB_sparse_texture ------------------------- */ #ifndef GL_ARB_sparse_texture #define GL_ARB_sparse_texture 1 #define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 #define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 #define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 #define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 #define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 #define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A #define GL_TEXTURE_SPARSE_ARB 0x91A6 #define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 #define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 #define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 #define GL_NUM_SPARSE_LEVELS_ARB 0x91AA typedef void (GLAPIENTRY * PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); typedef void (GLAPIENTRY * PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); #define glTexPageCommitmentARB GLEW_GET_FUN(__glewTexPageCommitmentARB) #define glTexturePageCommitmentEXT GLEW_GET_FUN(__glewTexturePageCommitmentEXT) #define GLEW_ARB_sparse_texture GLEW_GET_VAR(__GLEW_ARB_sparse_texture) #endif /* GL_ARB_sparse_texture */ /* ------------------------- GL_ARB_sparse_texture2 ------------------------ */ #ifndef GL_ARB_sparse_texture2 #define GL_ARB_sparse_texture2 1 #define GLEW_ARB_sparse_texture2 GLEW_GET_VAR(__GLEW_ARB_sparse_texture2) #endif /* GL_ARB_sparse_texture2 */ /* ---------------------- GL_ARB_sparse_texture_clamp ---------------------- */ #ifndef GL_ARB_sparse_texture_clamp #define GL_ARB_sparse_texture_clamp 1 #define GLEW_ARB_sparse_texture_clamp GLEW_GET_VAR(__GLEW_ARB_sparse_texture_clamp) #endif /* GL_ARB_sparse_texture_clamp */ /* ------------------------ GL_ARB_stencil_texturing ----------------------- */ #ifndef GL_ARB_stencil_texturing #define GL_ARB_stencil_texturing 1 #define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA #define GLEW_ARB_stencil_texturing GLEW_GET_VAR(__GLEW_ARB_stencil_texturing) #endif /* GL_ARB_stencil_texturing */ /* ------------------------------ GL_ARB_sync ------------------------------ */ #ifndef GL_ARB_sync #define GL_ARB_sync 1 #define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 #define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 #define GL_OBJECT_TYPE 0x9112 #define GL_SYNC_CONDITION 0x9113 #define GL_SYNC_STATUS 0x9114 #define GL_SYNC_FLAGS 0x9115 #define GL_SYNC_FENCE 0x9116 #define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 #define GL_UNSIGNALED 0x9118 #define GL_SIGNALED 0x9119 #define GL_ALREADY_SIGNALED 0x911A #define GL_TIMEOUT_EXPIRED 0x911B #define GL_CONDITION_SATISFIED 0x911C #define GL_WAIT_FAILED 0x911D #define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF typedef GLenum (GLAPIENTRY * PFNGLCLIENTWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout); typedef void (GLAPIENTRY * PFNGLDELETESYNCPROC) (GLsync GLsync); typedef GLsync (GLAPIENTRY * PFNGLFENCESYNCPROC) (GLenum condition,GLbitfield flags); typedef void (GLAPIENTRY * PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64* params); typedef void (GLAPIENTRY * PFNGLGETSYNCIVPROC) (GLsync GLsync,GLenum pname,GLsizei bufSize,GLsizei* length, GLint *values); typedef GLboolean (GLAPIENTRY * PFNGLISSYNCPROC) (GLsync GLsync); typedef void (GLAPIENTRY * PFNGLWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout); #define glClientWaitSync GLEW_GET_FUN(__glewClientWaitSync) #define glDeleteSync GLEW_GET_FUN(__glewDeleteSync) #define glFenceSync GLEW_GET_FUN(__glewFenceSync) #define glGetInteger64v GLEW_GET_FUN(__glewGetInteger64v) #define glGetSynciv GLEW_GET_FUN(__glewGetSynciv) #define glIsSync GLEW_GET_FUN(__glewIsSync) #define glWaitSync GLEW_GET_FUN(__glewWaitSync) #define GLEW_ARB_sync GLEW_GET_VAR(__GLEW_ARB_sync) #endif /* GL_ARB_sync */ /* ----------------------- GL_ARB_tessellation_shader ---------------------- */ #ifndef GL_ARB_tessellation_shader #define GL_ARB_tessellation_shader 1 #define GL_PATCHES 0xE #define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 #define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 #define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C #define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D #define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E #define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F #define GL_PATCH_VERTICES 0x8E72 #define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 #define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 #define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 #define GL_TESS_GEN_MODE 0x8E76 #define GL_TESS_GEN_SPACING 0x8E77 #define GL_TESS_GEN_VERTEX_ORDER 0x8E78 #define GL_TESS_GEN_POINT_MODE 0x8E79 #define GL_ISOLINES 0x8E7A #define GL_FRACTIONAL_ODD 0x8E7B #define GL_FRACTIONAL_EVEN 0x8E7C #define GL_MAX_PATCH_VERTICES 0x8E7D #define GL_MAX_TESS_GEN_LEVEL 0x8E7E #define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F #define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 #define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 #define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 #define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 #define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 #define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 #define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 #define GL_TESS_EVALUATION_SHADER 0x8E87 #define GL_TESS_CONTROL_SHADER 0x8E88 #define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 #define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A typedef void (GLAPIENTRY * PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat* values); typedef void (GLAPIENTRY * PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); #define glPatchParameterfv GLEW_GET_FUN(__glewPatchParameterfv) #define glPatchParameteri GLEW_GET_FUN(__glewPatchParameteri) #define GLEW_ARB_tessellation_shader GLEW_GET_VAR(__GLEW_ARB_tessellation_shader) #endif /* GL_ARB_tessellation_shader */ /* ------------------------- GL_ARB_texture_barrier ------------------------ */ #ifndef GL_ARB_texture_barrier #define GL_ARB_texture_barrier 1 typedef void (GLAPIENTRY * PFNGLTEXTUREBARRIERPROC) (void); #define glTextureBarrier GLEW_GET_FUN(__glewTextureBarrier) #define GLEW_ARB_texture_barrier GLEW_GET_VAR(__GLEW_ARB_texture_barrier) #endif /* GL_ARB_texture_barrier */ /* ---------------------- GL_ARB_texture_border_clamp ---------------------- */ #ifndef GL_ARB_texture_border_clamp #define GL_ARB_texture_border_clamp 1 #define GL_CLAMP_TO_BORDER_ARB 0x812D #define GLEW_ARB_texture_border_clamp GLEW_GET_VAR(__GLEW_ARB_texture_border_clamp) #endif /* GL_ARB_texture_border_clamp */ /* ---------------------- GL_ARB_texture_buffer_object --------------------- */ #ifndef GL_ARB_texture_buffer_object #define GL_ARB_texture_buffer_object 1 #define GL_TEXTURE_BUFFER_ARB 0x8C2A #define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B #define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C #define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D #define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E typedef void (GLAPIENTRY * PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); #define glTexBufferARB GLEW_GET_FUN(__glewTexBufferARB) #define GLEW_ARB_texture_buffer_object GLEW_GET_VAR(__GLEW_ARB_texture_buffer_object) #endif /* GL_ARB_texture_buffer_object */ /* ------------------- GL_ARB_texture_buffer_object_rgb32 ------------------ */ #ifndef GL_ARB_texture_buffer_object_rgb32 #define GL_ARB_texture_buffer_object_rgb32 1 #define GLEW_ARB_texture_buffer_object_rgb32 GLEW_GET_VAR(__GLEW_ARB_texture_buffer_object_rgb32) #endif /* GL_ARB_texture_buffer_object_rgb32 */ /* ---------------------- GL_ARB_texture_buffer_range ---------------------- */ #ifndef GL_ARB_texture_buffer_range #define GL_ARB_texture_buffer_range 1 #define GL_TEXTURE_BUFFER_OFFSET 0x919D #define GL_TEXTURE_BUFFER_SIZE 0x919E #define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F typedef void (GLAPIENTRY * PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (GLAPIENTRY * PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); #define glTexBufferRange GLEW_GET_FUN(__glewTexBufferRange) #define glTextureBufferRangeEXT GLEW_GET_FUN(__glewTextureBufferRangeEXT) #define GLEW_ARB_texture_buffer_range GLEW_GET_VAR(__GLEW_ARB_texture_buffer_range) #endif /* GL_ARB_texture_buffer_range */ /* ----------------------- GL_ARB_texture_compression ---------------------- */ #ifndef GL_ARB_texture_compression #define GL_ARB_texture_compression 1 #define GL_COMPRESSED_ALPHA_ARB 0x84E9 #define GL_COMPRESSED_LUMINANCE_ARB 0x84EA #define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB #define GL_COMPRESSED_INTENSITY_ARB 0x84EC #define GL_COMPRESSED_RGB_ARB 0x84ED #define GL_COMPRESSED_RGBA_ARB 0x84EE #define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF #define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 #define GL_TEXTURE_COMPRESSED_ARB 0x86A1 #define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, void *img); #define glCompressedTexImage1DARB GLEW_GET_FUN(__glewCompressedTexImage1DARB) #define glCompressedTexImage2DARB GLEW_GET_FUN(__glewCompressedTexImage2DARB) #define glCompressedTexImage3DARB GLEW_GET_FUN(__glewCompressedTexImage3DARB) #define glCompressedTexSubImage1DARB GLEW_GET_FUN(__glewCompressedTexSubImage1DARB) #define glCompressedTexSubImage2DARB GLEW_GET_FUN(__glewCompressedTexSubImage2DARB) #define glCompressedTexSubImage3DARB GLEW_GET_FUN(__glewCompressedTexSubImage3DARB) #define glGetCompressedTexImageARB GLEW_GET_FUN(__glewGetCompressedTexImageARB) #define GLEW_ARB_texture_compression GLEW_GET_VAR(__GLEW_ARB_texture_compression) #endif /* GL_ARB_texture_compression */ /* -------------------- GL_ARB_texture_compression_bptc -------------------- */ #ifndef GL_ARB_texture_compression_bptc #define GL_ARB_texture_compression_bptc 1 #define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C #define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D #define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E #define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F #define GLEW_ARB_texture_compression_bptc GLEW_GET_VAR(__GLEW_ARB_texture_compression_bptc) #endif /* GL_ARB_texture_compression_bptc */ /* -------------------- GL_ARB_texture_compression_rgtc -------------------- */ #ifndef GL_ARB_texture_compression_rgtc #define GL_ARB_texture_compression_rgtc 1 #define GL_COMPRESSED_RED_RGTC1 0x8DBB #define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC #define GL_COMPRESSED_RG_RGTC2 0x8DBD #define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE #define GLEW_ARB_texture_compression_rgtc GLEW_GET_VAR(__GLEW_ARB_texture_compression_rgtc) #endif /* GL_ARB_texture_compression_rgtc */ /* ------------------------ GL_ARB_texture_cube_map ------------------------ */ #ifndef GL_ARB_texture_cube_map #define GL_ARB_texture_cube_map 1 #define GL_NORMAL_MAP_ARB 0x8511 #define GL_REFLECTION_MAP_ARB 0x8512 #define GL_TEXTURE_CUBE_MAP_ARB 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A #define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B #define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C #define GLEW_ARB_texture_cube_map GLEW_GET_VAR(__GLEW_ARB_texture_cube_map) #endif /* GL_ARB_texture_cube_map */ /* --------------------- GL_ARB_texture_cube_map_array --------------------- */ #ifndef GL_ARB_texture_cube_map_array #define GL_ARB_texture_cube_map_array 1 #define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 #define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A #define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B #define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C #define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D #define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E #define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F #define GLEW_ARB_texture_cube_map_array GLEW_GET_VAR(__GLEW_ARB_texture_cube_map_array) #endif /* GL_ARB_texture_cube_map_array */ /* ------------------------- GL_ARB_texture_env_add ------------------------ */ #ifndef GL_ARB_texture_env_add #define GL_ARB_texture_env_add 1 #define GLEW_ARB_texture_env_add GLEW_GET_VAR(__GLEW_ARB_texture_env_add) #endif /* GL_ARB_texture_env_add */ /* ----------------------- GL_ARB_texture_env_combine ---------------------- */ #ifndef GL_ARB_texture_env_combine #define GL_ARB_texture_env_combine 1 #define GL_SUBTRACT_ARB 0x84E7 #define GL_COMBINE_ARB 0x8570 #define GL_COMBINE_RGB_ARB 0x8571 #define GL_COMBINE_ALPHA_ARB 0x8572 #define GL_RGB_SCALE_ARB 0x8573 #define GL_ADD_SIGNED_ARB 0x8574 #define GL_INTERPOLATE_ARB 0x8575 #define GL_CONSTANT_ARB 0x8576 #define GL_PRIMARY_COLOR_ARB 0x8577 #define GL_PREVIOUS_ARB 0x8578 #define GL_SOURCE0_RGB_ARB 0x8580 #define GL_SOURCE1_RGB_ARB 0x8581 #define GL_SOURCE2_RGB_ARB 0x8582 #define GL_SOURCE0_ALPHA_ARB 0x8588 #define GL_SOURCE1_ALPHA_ARB 0x8589 #define GL_SOURCE2_ALPHA_ARB 0x858A #define GL_OPERAND0_RGB_ARB 0x8590 #define GL_OPERAND1_RGB_ARB 0x8591 #define GL_OPERAND2_RGB_ARB 0x8592 #define GL_OPERAND0_ALPHA_ARB 0x8598 #define GL_OPERAND1_ALPHA_ARB 0x8599 #define GL_OPERAND2_ALPHA_ARB 0x859A #define GLEW_ARB_texture_env_combine GLEW_GET_VAR(__GLEW_ARB_texture_env_combine) #endif /* GL_ARB_texture_env_combine */ /* ---------------------- GL_ARB_texture_env_crossbar ---------------------- */ #ifndef GL_ARB_texture_env_crossbar #define GL_ARB_texture_env_crossbar 1 #define GLEW_ARB_texture_env_crossbar GLEW_GET_VAR(__GLEW_ARB_texture_env_crossbar) #endif /* GL_ARB_texture_env_crossbar */ /* ------------------------ GL_ARB_texture_env_dot3 ------------------------ */ #ifndef GL_ARB_texture_env_dot3 #define GL_ARB_texture_env_dot3 1 #define GL_DOT3_RGB_ARB 0x86AE #define GL_DOT3_RGBA_ARB 0x86AF #define GLEW_ARB_texture_env_dot3 GLEW_GET_VAR(__GLEW_ARB_texture_env_dot3) #endif /* GL_ARB_texture_env_dot3 */ /* ---------------------- GL_ARB_texture_filter_minmax --------------------- */ #ifndef GL_ARB_texture_filter_minmax #define GL_ARB_texture_filter_minmax 1 #define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 #define GL_WEIGHTED_AVERAGE_ARB 0x9367 #define GLEW_ARB_texture_filter_minmax GLEW_GET_VAR(__GLEW_ARB_texture_filter_minmax) #endif /* GL_ARB_texture_filter_minmax */ /* -------------------------- GL_ARB_texture_float ------------------------- */ #ifndef GL_ARB_texture_float #define GL_ARB_texture_float 1 #define GL_RGBA32F_ARB 0x8814 #define GL_RGB32F_ARB 0x8815 #define GL_ALPHA32F_ARB 0x8816 #define GL_INTENSITY32F_ARB 0x8817 #define GL_LUMINANCE32F_ARB 0x8818 #define GL_LUMINANCE_ALPHA32F_ARB 0x8819 #define GL_RGBA16F_ARB 0x881A #define GL_RGB16F_ARB 0x881B #define GL_ALPHA16F_ARB 0x881C #define GL_INTENSITY16F_ARB 0x881D #define GL_LUMINANCE16F_ARB 0x881E #define GL_LUMINANCE_ALPHA16F_ARB 0x881F #define GL_TEXTURE_RED_TYPE_ARB 0x8C10 #define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 #define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 #define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 #define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 #define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 #define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 #define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 #define GLEW_ARB_texture_float GLEW_GET_VAR(__GLEW_ARB_texture_float) #endif /* GL_ARB_texture_float */ /* ------------------------- GL_ARB_texture_gather ------------------------- */ #ifndef GL_ARB_texture_gather #define GL_ARB_texture_gather 1 #define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E #define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F #define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F #define GLEW_ARB_texture_gather GLEW_GET_VAR(__GLEW_ARB_texture_gather) #endif /* GL_ARB_texture_gather */ /* ------------------ GL_ARB_texture_mirror_clamp_to_edge ------------------ */ #ifndef GL_ARB_texture_mirror_clamp_to_edge #define GL_ARB_texture_mirror_clamp_to_edge 1 #define GL_MIRROR_CLAMP_TO_EDGE 0x8743 #define GLEW_ARB_texture_mirror_clamp_to_edge GLEW_GET_VAR(__GLEW_ARB_texture_mirror_clamp_to_edge) #endif /* GL_ARB_texture_mirror_clamp_to_edge */ /* --------------------- GL_ARB_texture_mirrored_repeat -------------------- */ #ifndef GL_ARB_texture_mirrored_repeat #define GL_ARB_texture_mirrored_repeat 1 #define GL_MIRRORED_REPEAT_ARB 0x8370 #define GLEW_ARB_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_ARB_texture_mirrored_repeat) #endif /* GL_ARB_texture_mirrored_repeat */ /* ----------------------- GL_ARB_texture_multisample ---------------------- */ #ifndef GL_ARB_texture_multisample #define GL_ARB_texture_multisample 1 #define GL_SAMPLE_POSITION 0x8E50 #define GL_SAMPLE_MASK 0x8E51 #define GL_SAMPLE_MASK_VALUE 0x8E52 #define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 #define GL_TEXTURE_2D_MULTISAMPLE 0x9100 #define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 #define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 #define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 #define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 #define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 #define GL_TEXTURE_SAMPLES 0x9106 #define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 #define GL_SAMPLER_2D_MULTISAMPLE 0x9108 #define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 #define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A #define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B #define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C #define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D #define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E #define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F #define GL_MAX_INTEGER_SAMPLES 0x9110 typedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat* val); typedef void (GLAPIENTRY * PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); #define glGetMultisamplefv GLEW_GET_FUN(__glewGetMultisamplefv) #define glSampleMaski GLEW_GET_FUN(__glewSampleMaski) #define glTexImage2DMultisample GLEW_GET_FUN(__glewTexImage2DMultisample) #define glTexImage3DMultisample GLEW_GET_FUN(__glewTexImage3DMultisample) #define GLEW_ARB_texture_multisample GLEW_GET_VAR(__GLEW_ARB_texture_multisample) #endif /* GL_ARB_texture_multisample */ /* -------------------- GL_ARB_texture_non_power_of_two -------------------- */ #ifndef GL_ARB_texture_non_power_of_two #define GL_ARB_texture_non_power_of_two 1 #define GLEW_ARB_texture_non_power_of_two GLEW_GET_VAR(__GLEW_ARB_texture_non_power_of_two) #endif /* GL_ARB_texture_non_power_of_two */ /* ---------------------- GL_ARB_texture_query_levels ---------------------- */ #ifndef GL_ARB_texture_query_levels #define GL_ARB_texture_query_levels 1 #define GLEW_ARB_texture_query_levels GLEW_GET_VAR(__GLEW_ARB_texture_query_levels) #endif /* GL_ARB_texture_query_levels */ /* ------------------------ GL_ARB_texture_query_lod ----------------------- */ #ifndef GL_ARB_texture_query_lod #define GL_ARB_texture_query_lod 1 #define GLEW_ARB_texture_query_lod GLEW_GET_VAR(__GLEW_ARB_texture_query_lod) #endif /* GL_ARB_texture_query_lod */ /* ------------------------ GL_ARB_texture_rectangle ----------------------- */ #ifndef GL_ARB_texture_rectangle #define GL_ARB_texture_rectangle 1 #define GL_TEXTURE_RECTANGLE_ARB 0x84F5 #define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 #define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 #define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 #define GL_SAMPLER_2D_RECT_ARB 0x8B63 #define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 #define GLEW_ARB_texture_rectangle GLEW_GET_VAR(__GLEW_ARB_texture_rectangle) #endif /* GL_ARB_texture_rectangle */ /* --------------------------- GL_ARB_texture_rg --------------------------- */ #ifndef GL_ARB_texture_rg #define GL_ARB_texture_rg 1 #define GL_COMPRESSED_RED 0x8225 #define GL_COMPRESSED_RG 0x8226 #define GL_RG 0x8227 #define GL_RG_INTEGER 0x8228 #define GL_R8 0x8229 #define GL_R16 0x822A #define GL_RG8 0x822B #define GL_RG16 0x822C #define GL_R16F 0x822D #define GL_R32F 0x822E #define GL_RG16F 0x822F #define GL_RG32F 0x8230 #define GL_R8I 0x8231 #define GL_R8UI 0x8232 #define GL_R16I 0x8233 #define GL_R16UI 0x8234 #define GL_R32I 0x8235 #define GL_R32UI 0x8236 #define GL_RG8I 0x8237 #define GL_RG8UI 0x8238 #define GL_RG16I 0x8239 #define GL_RG16UI 0x823A #define GL_RG32I 0x823B #define GL_RG32UI 0x823C #define GLEW_ARB_texture_rg GLEW_GET_VAR(__GLEW_ARB_texture_rg) #endif /* GL_ARB_texture_rg */ /* ----------------------- GL_ARB_texture_rgb10_a2ui ----------------------- */ #ifndef GL_ARB_texture_rgb10_a2ui #define GL_ARB_texture_rgb10_a2ui 1 #define GL_RGB10_A2UI 0x906F #define GLEW_ARB_texture_rgb10_a2ui GLEW_GET_VAR(__GLEW_ARB_texture_rgb10_a2ui) #endif /* GL_ARB_texture_rgb10_a2ui */ /* ------------------------ GL_ARB_texture_stencil8 ------------------------ */ #ifndef GL_ARB_texture_stencil8 #define GL_ARB_texture_stencil8 1 #define GL_STENCIL_INDEX 0x1901 #define GL_STENCIL_INDEX8 0x8D48 #define GLEW_ARB_texture_stencil8 GLEW_GET_VAR(__GLEW_ARB_texture_stencil8) #endif /* GL_ARB_texture_stencil8 */ /* ------------------------- GL_ARB_texture_storage ------------------------ */ #ifndef GL_ARB_texture_storage #define GL_ARB_texture_storage 1 #define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F typedef void (GLAPIENTRY * PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (GLAPIENTRY * PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #define glTexStorage1D GLEW_GET_FUN(__glewTexStorage1D) #define glTexStorage2D GLEW_GET_FUN(__glewTexStorage2D) #define glTexStorage3D GLEW_GET_FUN(__glewTexStorage3D) #define glTextureStorage1DEXT GLEW_GET_FUN(__glewTextureStorage1DEXT) #define glTextureStorage2DEXT GLEW_GET_FUN(__glewTextureStorage2DEXT) #define glTextureStorage3DEXT GLEW_GET_FUN(__glewTextureStorage3DEXT) #define GLEW_ARB_texture_storage GLEW_GET_VAR(__GLEW_ARB_texture_storage) #endif /* GL_ARB_texture_storage */ /* ------------------- GL_ARB_texture_storage_multisample ------------------ */ #ifndef GL_ARB_texture_storage_multisample #define GL_ARB_texture_storage_multisample 1 typedef void (GLAPIENTRY * PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); typedef void (GLAPIENTRY * PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); #define glTexStorage2DMultisample GLEW_GET_FUN(__glewTexStorage2DMultisample) #define glTexStorage3DMultisample GLEW_GET_FUN(__glewTexStorage3DMultisample) #define glTextureStorage2DMultisampleEXT GLEW_GET_FUN(__glewTextureStorage2DMultisampleEXT) #define glTextureStorage3DMultisampleEXT GLEW_GET_FUN(__glewTextureStorage3DMultisampleEXT) #define GLEW_ARB_texture_storage_multisample GLEW_GET_VAR(__GLEW_ARB_texture_storage_multisample) #endif /* GL_ARB_texture_storage_multisample */ /* ------------------------- GL_ARB_texture_swizzle ------------------------ */ #ifndef GL_ARB_texture_swizzle #define GL_ARB_texture_swizzle 1 #define GL_TEXTURE_SWIZZLE_R 0x8E42 #define GL_TEXTURE_SWIZZLE_G 0x8E43 #define GL_TEXTURE_SWIZZLE_B 0x8E44 #define GL_TEXTURE_SWIZZLE_A 0x8E45 #define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 #define GLEW_ARB_texture_swizzle GLEW_GET_VAR(__GLEW_ARB_texture_swizzle) #endif /* GL_ARB_texture_swizzle */ /* -------------------------- GL_ARB_texture_view -------------------------- */ #ifndef GL_ARB_texture_view #define GL_ARB_texture_view 1 #define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB #define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC #define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD #define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE #define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF typedef void (GLAPIENTRY * PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); #define glTextureView GLEW_GET_FUN(__glewTextureView) #define GLEW_ARB_texture_view GLEW_GET_VAR(__GLEW_ARB_texture_view) #endif /* GL_ARB_texture_view */ /* --------------------------- GL_ARB_timer_query -------------------------- */ #ifndef GL_ARB_timer_query #define GL_ARB_timer_query 1 #define GL_TIME_ELAPSED 0x88BF #define GL_TIMESTAMP 0x8E28 typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64* params); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64* params); typedef void (GLAPIENTRY * PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); #define glGetQueryObjecti64v GLEW_GET_FUN(__glewGetQueryObjecti64v) #define glGetQueryObjectui64v GLEW_GET_FUN(__glewGetQueryObjectui64v) #define glQueryCounter GLEW_GET_FUN(__glewQueryCounter) #define GLEW_ARB_timer_query GLEW_GET_VAR(__GLEW_ARB_timer_query) #endif /* GL_ARB_timer_query */ /* ----------------------- GL_ARB_transform_feedback2 ---------------------- */ #ifndef GL_ARB_transform_feedback2 #define GL_ARB_transform_feedback2 1 #define GL_TRANSFORM_FEEDBACK 0x8E22 #define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 #define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 #define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 typedef void (GLAPIENTRY * PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); typedef void (GLAPIENTRY * PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint* ids); typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); typedef void (GLAPIENTRY * PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint* ids); typedef GLboolean (GLAPIENTRY * PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); typedef void (GLAPIENTRY * PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); #define glBindTransformFeedback GLEW_GET_FUN(__glewBindTransformFeedback) #define glDeleteTransformFeedbacks GLEW_GET_FUN(__glewDeleteTransformFeedbacks) #define glDrawTransformFeedback GLEW_GET_FUN(__glewDrawTransformFeedback) #define glGenTransformFeedbacks GLEW_GET_FUN(__glewGenTransformFeedbacks) #define glIsTransformFeedback GLEW_GET_FUN(__glewIsTransformFeedback) #define glPauseTransformFeedback GLEW_GET_FUN(__glewPauseTransformFeedback) #define glResumeTransformFeedback GLEW_GET_FUN(__glewResumeTransformFeedback) #define GLEW_ARB_transform_feedback2 GLEW_GET_VAR(__GLEW_ARB_transform_feedback2) #endif /* GL_ARB_transform_feedback2 */ /* ----------------------- GL_ARB_transform_feedback3 ---------------------- */ #ifndef GL_ARB_transform_feedback3 #define GL_ARB_transform_feedback3 1 #define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 #define GL_MAX_VERTEX_STREAMS 0x8E71 typedef void (GLAPIENTRY * PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); typedef void (GLAPIENTRY * PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); typedef void (GLAPIENTRY * PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params); #define glBeginQueryIndexed GLEW_GET_FUN(__glewBeginQueryIndexed) #define glDrawTransformFeedbackStream GLEW_GET_FUN(__glewDrawTransformFeedbackStream) #define glEndQueryIndexed GLEW_GET_FUN(__glewEndQueryIndexed) #define glGetQueryIndexediv GLEW_GET_FUN(__glewGetQueryIndexediv) #define GLEW_ARB_transform_feedback3 GLEW_GET_VAR(__GLEW_ARB_transform_feedback3) #endif /* GL_ARB_transform_feedback3 */ /* ------------------ GL_ARB_transform_feedback_instanced ------------------ */ #ifndef GL_ARB_transform_feedback_instanced #define GL_ARB_transform_feedback_instanced 1 typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); #define glDrawTransformFeedbackInstanced GLEW_GET_FUN(__glewDrawTransformFeedbackInstanced) #define glDrawTransformFeedbackStreamInstanced GLEW_GET_FUN(__glewDrawTransformFeedbackStreamInstanced) #define GLEW_ARB_transform_feedback_instanced GLEW_GET_VAR(__GLEW_ARB_transform_feedback_instanced) #endif /* GL_ARB_transform_feedback_instanced */ /* ---------------- GL_ARB_transform_feedback_overflow_query --------------- */ #ifndef GL_ARB_transform_feedback_overflow_query #define GL_ARB_transform_feedback_overflow_query 1 #define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC #define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED #define GLEW_ARB_transform_feedback_overflow_query GLEW_GET_VAR(__GLEW_ARB_transform_feedback_overflow_query) #endif /* GL_ARB_transform_feedback_overflow_query */ /* ------------------------ GL_ARB_transpose_matrix ------------------------ */ #ifndef GL_ARB_transpose_matrix #define GL_ARB_transpose_matrix 1 #define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 #define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 #define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 #define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); #define glLoadTransposeMatrixdARB GLEW_GET_FUN(__glewLoadTransposeMatrixdARB) #define glLoadTransposeMatrixfARB GLEW_GET_FUN(__glewLoadTransposeMatrixfARB) #define glMultTransposeMatrixdARB GLEW_GET_FUN(__glewMultTransposeMatrixdARB) #define glMultTransposeMatrixfARB GLEW_GET_FUN(__glewMultTransposeMatrixfARB) #define GLEW_ARB_transpose_matrix GLEW_GET_VAR(__GLEW_ARB_transpose_matrix) #endif /* GL_ARB_transpose_matrix */ /* ---------------------- GL_ARB_uniform_buffer_object --------------------- */ #ifndef GL_ARB_uniform_buffer_object #define GL_ARB_uniform_buffer_object 1 #define GL_UNIFORM_BUFFER 0x8A11 #define GL_UNIFORM_BUFFER_BINDING 0x8A28 #define GL_UNIFORM_BUFFER_START 0x8A29 #define GL_UNIFORM_BUFFER_SIZE 0x8A2A #define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B #define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C #define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D #define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E #define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F #define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 #define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 #define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 #define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 #define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 #define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 #define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 #define GL_UNIFORM_TYPE 0x8A37 #define GL_UNIFORM_SIZE 0x8A38 #define GL_UNIFORM_NAME_LENGTH 0x8A39 #define GL_UNIFORM_BLOCK_INDEX 0x8A3A #define GL_UNIFORM_OFFSET 0x8A3B #define GL_UNIFORM_ARRAY_STRIDE 0x8A3C #define GL_UNIFORM_MATRIX_STRIDE 0x8A3D #define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E #define GL_UNIFORM_BLOCK_BINDING 0x8A3F #define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 #define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 #define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 #define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 #define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 #define GL_INVALID_INDEX 0xFFFFFFFF typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName); typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformName); typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint* data); typedef GLuint (GLAPIENTRY * PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar* uniformBlockName); typedef void (GLAPIENTRY * PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* const * uniformNames, GLuint* uniformIndices); typedef void (GLAPIENTRY * PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); #define glBindBufferBase GLEW_GET_FUN(__glewBindBufferBase) #define glBindBufferRange GLEW_GET_FUN(__glewBindBufferRange) #define glGetActiveUniformBlockName GLEW_GET_FUN(__glewGetActiveUniformBlockName) #define glGetActiveUniformBlockiv GLEW_GET_FUN(__glewGetActiveUniformBlockiv) #define glGetActiveUniformName GLEW_GET_FUN(__glewGetActiveUniformName) #define glGetActiveUniformsiv GLEW_GET_FUN(__glewGetActiveUniformsiv) #define glGetIntegeri_v GLEW_GET_FUN(__glewGetIntegeri_v) #define glGetUniformBlockIndex GLEW_GET_FUN(__glewGetUniformBlockIndex) #define glGetUniformIndices GLEW_GET_FUN(__glewGetUniformIndices) #define glUniformBlockBinding GLEW_GET_FUN(__glewUniformBlockBinding) #define GLEW_ARB_uniform_buffer_object GLEW_GET_VAR(__GLEW_ARB_uniform_buffer_object) #endif /* GL_ARB_uniform_buffer_object */ /* ------------------------ GL_ARB_vertex_array_bgra ----------------------- */ #ifndef GL_ARB_vertex_array_bgra #define GL_ARB_vertex_array_bgra 1 #define GL_BGRA 0x80E1 #define GLEW_ARB_vertex_array_bgra GLEW_GET_VAR(__GLEW_ARB_vertex_array_bgra) #endif /* GL_ARB_vertex_array_bgra */ /* ----------------------- GL_ARB_vertex_array_object ---------------------- */ #ifndef GL_ARB_vertex_array_object #define GL_ARB_vertex_array_object 1 #define GL_VERTEX_ARRAY_BINDING 0x85B5 typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYPROC) (GLuint array); typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint* arrays); typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays); typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYPROC) (GLuint array); #define glBindVertexArray GLEW_GET_FUN(__glewBindVertexArray) #define glDeleteVertexArrays GLEW_GET_FUN(__glewDeleteVertexArrays) #define glGenVertexArrays GLEW_GET_FUN(__glewGenVertexArrays) #define glIsVertexArray GLEW_GET_FUN(__glewIsVertexArray) #define GLEW_ARB_vertex_array_object GLEW_GET_VAR(__GLEW_ARB_vertex_array_object) #endif /* GL_ARB_vertex_array_object */ /* ----------------------- GL_ARB_vertex_attrib_64bit ---------------------- */ #ifndef GL_ARB_vertex_attrib_64bit #define GL_ARB_vertex_attrib_64bit 1 typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer); #define glGetVertexAttribLdv GLEW_GET_FUN(__glewGetVertexAttribLdv) #define glVertexAttribL1d GLEW_GET_FUN(__glewVertexAttribL1d) #define glVertexAttribL1dv GLEW_GET_FUN(__glewVertexAttribL1dv) #define glVertexAttribL2d GLEW_GET_FUN(__glewVertexAttribL2d) #define glVertexAttribL2dv GLEW_GET_FUN(__glewVertexAttribL2dv) #define glVertexAttribL3d GLEW_GET_FUN(__glewVertexAttribL3d) #define glVertexAttribL3dv GLEW_GET_FUN(__glewVertexAttribL3dv) #define glVertexAttribL4d GLEW_GET_FUN(__glewVertexAttribL4d) #define glVertexAttribL4dv GLEW_GET_FUN(__glewVertexAttribL4dv) #define glVertexAttribLPointer GLEW_GET_FUN(__glewVertexAttribLPointer) #define GLEW_ARB_vertex_attrib_64bit GLEW_GET_VAR(__GLEW_ARB_vertex_attrib_64bit) #endif /* GL_ARB_vertex_attrib_64bit */ /* ---------------------- GL_ARB_vertex_attrib_binding --------------------- */ #ifndef GL_ARB_vertex_attrib_binding #define GL_ARB_vertex_attrib_binding 1 #define GL_VERTEX_ATTRIB_BINDING 0x82D4 #define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 #define GL_VERTEX_BINDING_DIVISOR 0x82D6 #define GL_VERTEX_BINDING_OFFSET 0x82D7 #define GL_VERTEX_BINDING_STRIDE 0x82D8 #define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 #define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA #define GL_VERTEX_BINDING_BUFFER 0x8F4F typedef void (GLAPIENTRY * PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); typedef void (GLAPIENTRY * PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); #define glBindVertexBuffer GLEW_GET_FUN(__glewBindVertexBuffer) #define glVertexArrayBindVertexBufferEXT GLEW_GET_FUN(__glewVertexArrayBindVertexBufferEXT) #define glVertexArrayVertexAttribBindingEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribBindingEXT) #define glVertexArrayVertexAttribFormatEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribFormatEXT) #define glVertexArrayVertexAttribIFormatEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribIFormatEXT) #define glVertexArrayVertexAttribLFormatEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribLFormatEXT) #define glVertexArrayVertexBindingDivisorEXT GLEW_GET_FUN(__glewVertexArrayVertexBindingDivisorEXT) #define glVertexAttribBinding GLEW_GET_FUN(__glewVertexAttribBinding) #define glVertexAttribFormat GLEW_GET_FUN(__glewVertexAttribFormat) #define glVertexAttribIFormat GLEW_GET_FUN(__glewVertexAttribIFormat) #define glVertexAttribLFormat GLEW_GET_FUN(__glewVertexAttribLFormat) #define glVertexBindingDivisor GLEW_GET_FUN(__glewVertexBindingDivisor) #define GLEW_ARB_vertex_attrib_binding GLEW_GET_VAR(__GLEW_ARB_vertex_attrib_binding) #endif /* GL_ARB_vertex_attrib_binding */ /* -------------------------- GL_ARB_vertex_blend -------------------------- */ #ifndef GL_ARB_vertex_blend #define GL_ARB_vertex_blend 1 #define GL_MODELVIEW0_ARB 0x1700 #define GL_MODELVIEW1_ARB 0x850A #define GL_MAX_VERTEX_UNITS_ARB 0x86A4 #define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 #define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 #define GL_VERTEX_BLEND_ARB 0x86A7 #define GL_CURRENT_WEIGHT_ARB 0x86A8 #define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 #define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA #define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB #define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC #define GL_WEIGHT_ARRAY_ARB 0x86AD #define GL_MODELVIEW2_ARB 0x8722 #define GL_MODELVIEW3_ARB 0x8723 #define GL_MODELVIEW4_ARB 0x8724 #define GL_MODELVIEW5_ARB 0x8725 #define GL_MODELVIEW6_ARB 0x8726 #define GL_MODELVIEW7_ARB 0x8727 #define GL_MODELVIEW8_ARB 0x8728 #define GL_MODELVIEW9_ARB 0x8729 #define GL_MODELVIEW10_ARB 0x872A #define GL_MODELVIEW11_ARB 0x872B #define GL_MODELVIEW12_ARB 0x872C #define GL_MODELVIEW13_ARB 0x872D #define GL_MODELVIEW14_ARB 0x872E #define GL_MODELVIEW15_ARB 0x872F #define GL_MODELVIEW16_ARB 0x8730 #define GL_MODELVIEW17_ARB 0x8731 #define GL_MODELVIEW18_ARB 0x8732 #define GL_MODELVIEW19_ARB 0x8733 #define GL_MODELVIEW20_ARB 0x8734 #define GL_MODELVIEW21_ARB 0x8735 #define GL_MODELVIEW22_ARB 0x8736 #define GL_MODELVIEW23_ARB 0x8737 #define GL_MODELVIEW24_ARB 0x8738 #define GL_MODELVIEW25_ARB 0x8739 #define GL_MODELVIEW26_ARB 0x873A #define GL_MODELVIEW27_ARB 0x873B #define GL_MODELVIEW28_ARB 0x873C #define GL_MODELVIEW29_ARB 0x873D #define GL_MODELVIEW30_ARB 0x873E #define GL_MODELVIEW31_ARB 0x873F typedef void (GLAPIENTRY * PFNGLVERTEXBLENDARBPROC) (GLint count); typedef void (GLAPIENTRY * PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, void *pointer); typedef void (GLAPIENTRY * PFNGLWEIGHTBVARBPROC) (GLint size, GLbyte *weights); typedef void (GLAPIENTRY * PFNGLWEIGHTDVARBPROC) (GLint size, GLdouble *weights); typedef void (GLAPIENTRY * PFNGLWEIGHTFVARBPROC) (GLint size, GLfloat *weights); typedef void (GLAPIENTRY * PFNGLWEIGHTIVARBPROC) (GLint size, GLint *weights); typedef void (GLAPIENTRY * PFNGLWEIGHTSVARBPROC) (GLint size, GLshort *weights); typedef void (GLAPIENTRY * PFNGLWEIGHTUBVARBPROC) (GLint size, GLubyte *weights); typedef void (GLAPIENTRY * PFNGLWEIGHTUIVARBPROC) (GLint size, GLuint *weights); typedef void (GLAPIENTRY * PFNGLWEIGHTUSVARBPROC) (GLint size, GLushort *weights); #define glVertexBlendARB GLEW_GET_FUN(__glewVertexBlendARB) #define glWeightPointerARB GLEW_GET_FUN(__glewWeightPointerARB) #define glWeightbvARB GLEW_GET_FUN(__glewWeightbvARB) #define glWeightdvARB GLEW_GET_FUN(__glewWeightdvARB) #define glWeightfvARB GLEW_GET_FUN(__glewWeightfvARB) #define glWeightivARB GLEW_GET_FUN(__glewWeightivARB) #define glWeightsvARB GLEW_GET_FUN(__glewWeightsvARB) #define glWeightubvARB GLEW_GET_FUN(__glewWeightubvARB) #define glWeightuivARB GLEW_GET_FUN(__glewWeightuivARB) #define glWeightusvARB GLEW_GET_FUN(__glewWeightusvARB) #define GLEW_ARB_vertex_blend GLEW_GET_VAR(__GLEW_ARB_vertex_blend) #endif /* GL_ARB_vertex_blend */ /* ---------------------- GL_ARB_vertex_buffer_object ---------------------- */ #ifndef GL_ARB_vertex_buffer_object #define GL_ARB_vertex_buffer_object 1 #define GL_BUFFER_SIZE_ARB 0x8764 #define GL_BUFFER_USAGE_ARB 0x8765 #define GL_ARRAY_BUFFER_ARB 0x8892 #define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 #define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 #define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 #define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 #define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 #define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 #define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 #define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A #define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B #define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C #define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D #define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F #define GL_READ_ONLY_ARB 0x88B8 #define GL_WRITE_ONLY_ARB 0x88B9 #define GL_READ_WRITE_ARB 0x88BA #define GL_BUFFER_ACCESS_ARB 0x88BB #define GL_BUFFER_MAPPED_ARB 0x88BC #define GL_BUFFER_MAP_POINTER_ARB 0x88BD #define GL_STREAM_DRAW_ARB 0x88E0 #define GL_STREAM_READ_ARB 0x88E1 #define GL_STREAM_COPY_ARB 0x88E2 #define GL_STATIC_DRAW_ARB 0x88E4 #define GL_STATIC_READ_ARB 0x88E5 #define GL_STATIC_COPY_ARB 0x88E6 #define GL_DYNAMIC_DRAW_ARB 0x88E8 #define GL_DYNAMIC_READ_ARB 0x88E9 #define GL_DYNAMIC_COPY_ARB 0x88EA typedef ptrdiff_t GLintptrARB; typedef ptrdiff_t GLsizeiptrARB; typedef void (GLAPIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); typedef void (GLAPIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint* buffers); typedef void (GLAPIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint* buffers); typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void** params); typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERARBPROC) (GLuint buffer); typedef void * (GLAPIENTRY * PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERARBPROC) (GLenum target); #define glBindBufferARB GLEW_GET_FUN(__glewBindBufferARB) #define glBufferDataARB GLEW_GET_FUN(__glewBufferDataARB) #define glBufferSubDataARB GLEW_GET_FUN(__glewBufferSubDataARB) #define glDeleteBuffersARB GLEW_GET_FUN(__glewDeleteBuffersARB) #define glGenBuffersARB GLEW_GET_FUN(__glewGenBuffersARB) #define glGetBufferParameterivARB GLEW_GET_FUN(__glewGetBufferParameterivARB) #define glGetBufferPointervARB GLEW_GET_FUN(__glewGetBufferPointervARB) #define glGetBufferSubDataARB GLEW_GET_FUN(__glewGetBufferSubDataARB) #define glIsBufferARB GLEW_GET_FUN(__glewIsBufferARB) #define glMapBufferARB GLEW_GET_FUN(__glewMapBufferARB) #define glUnmapBufferARB GLEW_GET_FUN(__glewUnmapBufferARB) #define GLEW_ARB_vertex_buffer_object GLEW_GET_VAR(__GLEW_ARB_vertex_buffer_object) #endif /* GL_ARB_vertex_buffer_object */ /* ------------------------- GL_ARB_vertex_program ------------------------- */ #ifndef GL_ARB_vertex_program #define GL_ARB_vertex_program 1 #define GL_COLOR_SUM_ARB 0x8458 #define GL_VERTEX_PROGRAM_ARB 0x8620 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 #define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 #define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 #define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 #define GL_PROGRAM_LENGTH_ARB 0x8627 #define GL_PROGRAM_STRING_ARB 0x8628 #define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E #define GL_MAX_PROGRAM_MATRICES_ARB 0x862F #define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 #define GL_CURRENT_MATRIX_ARB 0x8641 #define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 #define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 #define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 #define GL_PROGRAM_ERROR_POSITION_ARB 0x864B #define GL_PROGRAM_BINDING_ARB 0x8677 #define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A #define GL_PROGRAM_ERROR_STRING_ARB 0x8874 #define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 #define GL_PROGRAM_FORMAT_ARB 0x8876 #define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 #define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 #define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 #define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 #define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 #define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 #define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 #define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 #define GL_PROGRAM_PARAMETERS_ARB 0x88A8 #define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 #define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA #define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB #define GL_PROGRAM_ATTRIBS_ARB 0x88AC #define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD #define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE #define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF #define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 #define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 #define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 #define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 #define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 #define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 #define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 #define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 #define GL_MATRIX0_ARB 0x88C0 #define GL_MATRIX1_ARB 0x88C1 #define GL_MATRIX2_ARB 0x88C2 #define GL_MATRIX3_ARB 0x88C3 #define GL_MATRIX4_ARB 0x88C4 #define GL_MATRIX5_ARB 0x88C5 #define GL_MATRIX6_ARB 0x88C6 #define GL_MATRIX7_ARB 0x88C7 #define GL_MATRIX8_ARB 0x88C8 #define GL_MATRIX9_ARB 0x88C9 #define GL_MATRIX10_ARB 0x88CA #define GL_MATRIX11_ARB 0x88CB #define GL_MATRIX12_ARB 0x88CC #define GL_MATRIX13_ARB 0x88CD #define GL_MATRIX14_ARB 0x88CE #define GL_MATRIX15_ARB 0x88CF #define GL_MATRIX16_ARB 0x88D0 #define GL_MATRIX17_ARB 0x88D1 #define GL_MATRIX18_ARB 0x88D2 #define GL_MATRIX19_ARB 0x88D3 #define GL_MATRIX20_ARB 0x88D4 #define GL_MATRIX21_ARB 0x88D5 #define GL_MATRIX22_ARB 0x88D6 #define GL_MATRIX23_ARB 0x88D7 #define GL_MATRIX24_ARB 0x88D8 #define GL_MATRIX25_ARB 0x88D9 #define GL_MATRIX26_ARB 0x88DA #define GL_MATRIX27_ARB 0x88DB #define GL_MATRIX28_ARB 0x88DC #define GL_MATRIX29_ARB 0x88DD #define GL_MATRIX30_ARB 0x88DE #define GL_MATRIX31_ARB 0x88DF typedef void (GLAPIENTRY * PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint* programs); typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); typedef void (GLAPIENTRY * PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint* programs); typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void** pointer); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMARBPROC) (GLuint program); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); #define glBindProgramARB GLEW_GET_FUN(__glewBindProgramARB) #define glDeleteProgramsARB GLEW_GET_FUN(__glewDeleteProgramsARB) #define glDisableVertexAttribArrayARB GLEW_GET_FUN(__glewDisableVertexAttribArrayARB) #define glEnableVertexAttribArrayARB GLEW_GET_FUN(__glewEnableVertexAttribArrayARB) #define glGenProgramsARB GLEW_GET_FUN(__glewGenProgramsARB) #define glGetProgramEnvParameterdvARB GLEW_GET_FUN(__glewGetProgramEnvParameterdvARB) #define glGetProgramEnvParameterfvARB GLEW_GET_FUN(__glewGetProgramEnvParameterfvARB) #define glGetProgramLocalParameterdvARB GLEW_GET_FUN(__glewGetProgramLocalParameterdvARB) #define glGetProgramLocalParameterfvARB GLEW_GET_FUN(__glewGetProgramLocalParameterfvARB) #define glGetProgramStringARB GLEW_GET_FUN(__glewGetProgramStringARB) #define glGetProgramivARB GLEW_GET_FUN(__glewGetProgramivARB) #define glGetVertexAttribPointervARB GLEW_GET_FUN(__glewGetVertexAttribPointervARB) #define glGetVertexAttribdvARB GLEW_GET_FUN(__glewGetVertexAttribdvARB) #define glGetVertexAttribfvARB GLEW_GET_FUN(__glewGetVertexAttribfvARB) #define glGetVertexAttribivARB GLEW_GET_FUN(__glewGetVertexAttribivARB) #define glIsProgramARB GLEW_GET_FUN(__glewIsProgramARB) #define glProgramEnvParameter4dARB GLEW_GET_FUN(__glewProgramEnvParameter4dARB) #define glProgramEnvParameter4dvARB GLEW_GET_FUN(__glewProgramEnvParameter4dvARB) #define glProgramEnvParameter4fARB GLEW_GET_FUN(__glewProgramEnvParameter4fARB) #define glProgramEnvParameter4fvARB GLEW_GET_FUN(__glewProgramEnvParameter4fvARB) #define glProgramLocalParameter4dARB GLEW_GET_FUN(__glewProgramLocalParameter4dARB) #define glProgramLocalParameter4dvARB GLEW_GET_FUN(__glewProgramLocalParameter4dvARB) #define glProgramLocalParameter4fARB GLEW_GET_FUN(__glewProgramLocalParameter4fARB) #define glProgramLocalParameter4fvARB GLEW_GET_FUN(__glewProgramLocalParameter4fvARB) #define glProgramStringARB GLEW_GET_FUN(__glewProgramStringARB) #define glVertexAttrib1dARB GLEW_GET_FUN(__glewVertexAttrib1dARB) #define glVertexAttrib1dvARB GLEW_GET_FUN(__glewVertexAttrib1dvARB) #define glVertexAttrib1fARB GLEW_GET_FUN(__glewVertexAttrib1fARB) #define glVertexAttrib1fvARB GLEW_GET_FUN(__glewVertexAttrib1fvARB) #define glVertexAttrib1sARB GLEW_GET_FUN(__glewVertexAttrib1sARB) #define glVertexAttrib1svARB GLEW_GET_FUN(__glewVertexAttrib1svARB) #define glVertexAttrib2dARB GLEW_GET_FUN(__glewVertexAttrib2dARB) #define glVertexAttrib2dvARB GLEW_GET_FUN(__glewVertexAttrib2dvARB) #define glVertexAttrib2fARB GLEW_GET_FUN(__glewVertexAttrib2fARB) #define glVertexAttrib2fvARB GLEW_GET_FUN(__glewVertexAttrib2fvARB) #define glVertexAttrib2sARB GLEW_GET_FUN(__glewVertexAttrib2sARB) #define glVertexAttrib2svARB GLEW_GET_FUN(__glewVertexAttrib2svARB) #define glVertexAttrib3dARB GLEW_GET_FUN(__glewVertexAttrib3dARB) #define glVertexAttrib3dvARB GLEW_GET_FUN(__glewVertexAttrib3dvARB) #define glVertexAttrib3fARB GLEW_GET_FUN(__glewVertexAttrib3fARB) #define glVertexAttrib3fvARB GLEW_GET_FUN(__glewVertexAttrib3fvARB) #define glVertexAttrib3sARB GLEW_GET_FUN(__glewVertexAttrib3sARB) #define glVertexAttrib3svARB GLEW_GET_FUN(__glewVertexAttrib3svARB) #define glVertexAttrib4NbvARB GLEW_GET_FUN(__glewVertexAttrib4NbvARB) #define glVertexAttrib4NivARB GLEW_GET_FUN(__glewVertexAttrib4NivARB) #define glVertexAttrib4NsvARB GLEW_GET_FUN(__glewVertexAttrib4NsvARB) #define glVertexAttrib4NubARB GLEW_GET_FUN(__glewVertexAttrib4NubARB) #define glVertexAttrib4NubvARB GLEW_GET_FUN(__glewVertexAttrib4NubvARB) #define glVertexAttrib4NuivARB GLEW_GET_FUN(__glewVertexAttrib4NuivARB) #define glVertexAttrib4NusvARB GLEW_GET_FUN(__glewVertexAttrib4NusvARB) #define glVertexAttrib4bvARB GLEW_GET_FUN(__glewVertexAttrib4bvARB) #define glVertexAttrib4dARB GLEW_GET_FUN(__glewVertexAttrib4dARB) #define glVertexAttrib4dvARB GLEW_GET_FUN(__glewVertexAttrib4dvARB) #define glVertexAttrib4fARB GLEW_GET_FUN(__glewVertexAttrib4fARB) #define glVertexAttrib4fvARB GLEW_GET_FUN(__glewVertexAttrib4fvARB) #define glVertexAttrib4ivARB GLEW_GET_FUN(__glewVertexAttrib4ivARB) #define glVertexAttrib4sARB GLEW_GET_FUN(__glewVertexAttrib4sARB) #define glVertexAttrib4svARB GLEW_GET_FUN(__glewVertexAttrib4svARB) #define glVertexAttrib4ubvARB GLEW_GET_FUN(__glewVertexAttrib4ubvARB) #define glVertexAttrib4uivARB GLEW_GET_FUN(__glewVertexAttrib4uivARB) #define glVertexAttrib4usvARB GLEW_GET_FUN(__glewVertexAttrib4usvARB) #define glVertexAttribPointerARB GLEW_GET_FUN(__glewVertexAttribPointerARB) #define GLEW_ARB_vertex_program GLEW_GET_VAR(__GLEW_ARB_vertex_program) #endif /* GL_ARB_vertex_program */ /* -------------------------- GL_ARB_vertex_shader ------------------------- */ #ifndef GL_ARB_vertex_shader #define GL_ARB_vertex_shader 1 #define GL_VERTEX_SHADER_ARB 0x8B31 #define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A #define GL_MAX_VARYING_FLOATS_ARB 0x8B4B #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D #define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 #define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB* name); typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); #define glBindAttribLocationARB GLEW_GET_FUN(__glewBindAttribLocationARB) #define glGetActiveAttribARB GLEW_GET_FUN(__glewGetActiveAttribARB) #define glGetAttribLocationARB GLEW_GET_FUN(__glewGetAttribLocationARB) #define GLEW_ARB_vertex_shader GLEW_GET_VAR(__GLEW_ARB_vertex_shader) #endif /* GL_ARB_vertex_shader */ /* ------------------- GL_ARB_vertex_type_10f_11f_11f_rev ------------------ */ #ifndef GL_ARB_vertex_type_10f_11f_11f_rev #define GL_ARB_vertex_type_10f_11f_11f_rev 1 #define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B #define GLEW_ARB_vertex_type_10f_11f_11f_rev GLEW_GET_VAR(__GLEW_ARB_vertex_type_10f_11f_11f_rev) #endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ /* ------------------- GL_ARB_vertex_type_2_10_10_10_rev ------------------- */ #ifndef GL_ARB_vertex_type_2_10_10_10_rev #define GL_ARB_vertex_type_2_10_10_10_rev 1 #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #define GL_INT_2_10_10_10_REV 0x8D9F typedef void (GLAPIENTRY * PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); typedef void (GLAPIENTRY * PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint* color); typedef void (GLAPIENTRY * PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); typedef void (GLAPIENTRY * PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint* color); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint* color); typedef void (GLAPIENTRY * PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); typedef void (GLAPIENTRY * PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); typedef void (GLAPIENTRY * PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint* value); typedef void (GLAPIENTRY * PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); typedef void (GLAPIENTRY * PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint* value); typedef void (GLAPIENTRY * PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); typedef void (GLAPIENTRY * PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint* value); #define glColorP3ui GLEW_GET_FUN(__glewColorP3ui) #define glColorP3uiv GLEW_GET_FUN(__glewColorP3uiv) #define glColorP4ui GLEW_GET_FUN(__glewColorP4ui) #define glColorP4uiv GLEW_GET_FUN(__glewColorP4uiv) #define glMultiTexCoordP1ui GLEW_GET_FUN(__glewMultiTexCoordP1ui) #define glMultiTexCoordP1uiv GLEW_GET_FUN(__glewMultiTexCoordP1uiv) #define glMultiTexCoordP2ui GLEW_GET_FUN(__glewMultiTexCoordP2ui) #define glMultiTexCoordP2uiv GLEW_GET_FUN(__glewMultiTexCoordP2uiv) #define glMultiTexCoordP3ui GLEW_GET_FUN(__glewMultiTexCoordP3ui) #define glMultiTexCoordP3uiv GLEW_GET_FUN(__glewMultiTexCoordP3uiv) #define glMultiTexCoordP4ui GLEW_GET_FUN(__glewMultiTexCoordP4ui) #define glMultiTexCoordP4uiv GLEW_GET_FUN(__glewMultiTexCoordP4uiv) #define glNormalP3ui GLEW_GET_FUN(__glewNormalP3ui) #define glNormalP3uiv GLEW_GET_FUN(__glewNormalP3uiv) #define glSecondaryColorP3ui GLEW_GET_FUN(__glewSecondaryColorP3ui) #define glSecondaryColorP3uiv GLEW_GET_FUN(__glewSecondaryColorP3uiv) #define glTexCoordP1ui GLEW_GET_FUN(__glewTexCoordP1ui) #define glTexCoordP1uiv GLEW_GET_FUN(__glewTexCoordP1uiv) #define glTexCoordP2ui GLEW_GET_FUN(__glewTexCoordP2ui) #define glTexCoordP2uiv GLEW_GET_FUN(__glewTexCoordP2uiv) #define glTexCoordP3ui GLEW_GET_FUN(__glewTexCoordP3ui) #define glTexCoordP3uiv GLEW_GET_FUN(__glewTexCoordP3uiv) #define glTexCoordP4ui GLEW_GET_FUN(__glewTexCoordP4ui) #define glTexCoordP4uiv GLEW_GET_FUN(__glewTexCoordP4uiv) #define glVertexAttribP1ui GLEW_GET_FUN(__glewVertexAttribP1ui) #define glVertexAttribP1uiv GLEW_GET_FUN(__glewVertexAttribP1uiv) #define glVertexAttribP2ui GLEW_GET_FUN(__glewVertexAttribP2ui) #define glVertexAttribP2uiv GLEW_GET_FUN(__glewVertexAttribP2uiv) #define glVertexAttribP3ui GLEW_GET_FUN(__glewVertexAttribP3ui) #define glVertexAttribP3uiv GLEW_GET_FUN(__glewVertexAttribP3uiv) #define glVertexAttribP4ui GLEW_GET_FUN(__glewVertexAttribP4ui) #define glVertexAttribP4uiv GLEW_GET_FUN(__glewVertexAttribP4uiv) #define glVertexP2ui GLEW_GET_FUN(__glewVertexP2ui) #define glVertexP2uiv GLEW_GET_FUN(__glewVertexP2uiv) #define glVertexP3ui GLEW_GET_FUN(__glewVertexP3ui) #define glVertexP3uiv GLEW_GET_FUN(__glewVertexP3uiv) #define glVertexP4ui GLEW_GET_FUN(__glewVertexP4ui) #define glVertexP4uiv GLEW_GET_FUN(__glewVertexP4uiv) #define GLEW_ARB_vertex_type_2_10_10_10_rev GLEW_GET_VAR(__GLEW_ARB_vertex_type_2_10_10_10_rev) #endif /* GL_ARB_vertex_type_2_10_10_10_rev */ /* ------------------------- GL_ARB_viewport_array ------------------------- */ #ifndef GL_ARB_viewport_array #define GL_ARB_viewport_array 1 #define GL_DEPTH_RANGE 0x0B70 #define GL_VIEWPORT 0x0BA2 #define GL_SCISSOR_BOX 0x0C10 #define GL_SCISSOR_TEST 0x0C11 #define GL_MAX_VIEWPORTS 0x825B #define GL_VIEWPORT_SUBPIXEL_BITS 0x825C #define GL_VIEWPORT_BOUNDS_RANGE 0x825D #define GL_LAYER_PROVOKING_VERTEX 0x825E #define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F #define GL_UNDEFINED_VERTEX 0x8260 #define GL_FIRST_VERTEX_CONVENTION 0x8E4D #define GL_LAST_VERTEX_CONVENTION 0x8E4E #define GL_PROVOKING_VERTEX 0x8E4F typedef void (GLAPIENTRY * PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLclampd * v); typedef void (GLAPIENTRY * PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLclampd n, GLclampd f); typedef void (GLAPIENTRY * PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble* data); typedef void (GLAPIENTRY * PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat* data); typedef void (GLAPIENTRY * PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint * v); typedef void (GLAPIENTRY * PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint * v); typedef void (GLAPIENTRY * PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat * v); typedef void (GLAPIENTRY * PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); typedef void (GLAPIENTRY * PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat * v); #define glDepthRangeArrayv GLEW_GET_FUN(__glewDepthRangeArrayv) #define glDepthRangeIndexed GLEW_GET_FUN(__glewDepthRangeIndexed) #define glGetDoublei_v GLEW_GET_FUN(__glewGetDoublei_v) #define glGetFloati_v GLEW_GET_FUN(__glewGetFloati_v) #define glScissorArrayv GLEW_GET_FUN(__glewScissorArrayv) #define glScissorIndexed GLEW_GET_FUN(__glewScissorIndexed) #define glScissorIndexedv GLEW_GET_FUN(__glewScissorIndexedv) #define glViewportArrayv GLEW_GET_FUN(__glewViewportArrayv) #define glViewportIndexedf GLEW_GET_FUN(__glewViewportIndexedf) #define glViewportIndexedfv GLEW_GET_FUN(__glewViewportIndexedfv) #define GLEW_ARB_viewport_array GLEW_GET_VAR(__GLEW_ARB_viewport_array) #endif /* GL_ARB_viewport_array */ /* --------------------------- GL_ARB_window_pos --------------------------- */ #ifndef GL_ARB_window_pos #define GL_ARB_window_pos 1 typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVARBPROC) (const GLdouble* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVARBPROC) (const GLfloat* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVARBPROC) (const GLint* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVARBPROC) (const GLshort* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVARBPROC) (const GLdouble* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVARBPROC) (const GLfloat* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVARBPROC) (const GLint* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVARBPROC) (const GLshort* p); #define glWindowPos2dARB GLEW_GET_FUN(__glewWindowPos2dARB) #define glWindowPos2dvARB GLEW_GET_FUN(__glewWindowPos2dvARB) #define glWindowPos2fARB GLEW_GET_FUN(__glewWindowPos2fARB) #define glWindowPos2fvARB GLEW_GET_FUN(__glewWindowPos2fvARB) #define glWindowPos2iARB GLEW_GET_FUN(__glewWindowPos2iARB) #define glWindowPos2ivARB GLEW_GET_FUN(__glewWindowPos2ivARB) #define glWindowPos2sARB GLEW_GET_FUN(__glewWindowPos2sARB) #define glWindowPos2svARB GLEW_GET_FUN(__glewWindowPos2svARB) #define glWindowPos3dARB GLEW_GET_FUN(__glewWindowPos3dARB) #define glWindowPos3dvARB GLEW_GET_FUN(__glewWindowPos3dvARB) #define glWindowPos3fARB GLEW_GET_FUN(__glewWindowPos3fARB) #define glWindowPos3fvARB GLEW_GET_FUN(__glewWindowPos3fvARB) #define glWindowPos3iARB GLEW_GET_FUN(__glewWindowPos3iARB) #define glWindowPos3ivARB GLEW_GET_FUN(__glewWindowPos3ivARB) #define glWindowPos3sARB GLEW_GET_FUN(__glewWindowPos3sARB) #define glWindowPos3svARB GLEW_GET_FUN(__glewWindowPos3svARB) #define GLEW_ARB_window_pos GLEW_GET_VAR(__GLEW_ARB_window_pos) #endif /* GL_ARB_window_pos */ /* ------------------------- GL_ATIX_point_sprites ------------------------- */ #ifndef GL_ATIX_point_sprites #define GL_ATIX_point_sprites 1 #define GL_TEXTURE_POINT_MODE_ATIX 0x60B0 #define GL_TEXTURE_POINT_ONE_COORD_ATIX 0x60B1 #define GL_TEXTURE_POINT_SPRITE_ATIX 0x60B2 #define GL_POINT_SPRITE_CULL_MODE_ATIX 0x60B3 #define GL_POINT_SPRITE_CULL_CENTER_ATIX 0x60B4 #define GL_POINT_SPRITE_CULL_CLIP_ATIX 0x60B5 #define GLEW_ATIX_point_sprites GLEW_GET_VAR(__GLEW_ATIX_point_sprites) #endif /* GL_ATIX_point_sprites */ /* ---------------------- GL_ATIX_texture_env_combine3 --------------------- */ #ifndef GL_ATIX_texture_env_combine3 #define GL_ATIX_texture_env_combine3 1 #define GL_MODULATE_ADD_ATIX 0x8744 #define GL_MODULATE_SIGNED_ADD_ATIX 0x8745 #define GL_MODULATE_SUBTRACT_ATIX 0x8746 #define GLEW_ATIX_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATIX_texture_env_combine3) #endif /* GL_ATIX_texture_env_combine3 */ /* ----------------------- GL_ATIX_texture_env_route ----------------------- */ #ifndef GL_ATIX_texture_env_route #define GL_ATIX_texture_env_route 1 #define GL_SECONDARY_COLOR_ATIX 0x8747 #define GL_TEXTURE_OUTPUT_RGB_ATIX 0x8748 #define GL_TEXTURE_OUTPUT_ALPHA_ATIX 0x8749 #define GLEW_ATIX_texture_env_route GLEW_GET_VAR(__GLEW_ATIX_texture_env_route) #endif /* GL_ATIX_texture_env_route */ /* ---------------- GL_ATIX_vertex_shader_output_point_size ---------------- */ #ifndef GL_ATIX_vertex_shader_output_point_size #define GL_ATIX_vertex_shader_output_point_size 1 #define GL_OUTPUT_POINT_SIZE_ATIX 0x610E #define GLEW_ATIX_vertex_shader_output_point_size GLEW_GET_VAR(__GLEW_ATIX_vertex_shader_output_point_size) #endif /* GL_ATIX_vertex_shader_output_point_size */ /* -------------------------- GL_ATI_draw_buffers -------------------------- */ #ifndef GL_ATI_draw_buffers #define GL_ATI_draw_buffers 1 #define GL_MAX_DRAW_BUFFERS_ATI 0x8824 #define GL_DRAW_BUFFER0_ATI 0x8825 #define GL_DRAW_BUFFER1_ATI 0x8826 #define GL_DRAW_BUFFER2_ATI 0x8827 #define GL_DRAW_BUFFER3_ATI 0x8828 #define GL_DRAW_BUFFER4_ATI 0x8829 #define GL_DRAW_BUFFER5_ATI 0x882A #define GL_DRAW_BUFFER6_ATI 0x882B #define GL_DRAW_BUFFER7_ATI 0x882C #define GL_DRAW_BUFFER8_ATI 0x882D #define GL_DRAW_BUFFER9_ATI 0x882E #define GL_DRAW_BUFFER10_ATI 0x882F #define GL_DRAW_BUFFER11_ATI 0x8830 #define GL_DRAW_BUFFER12_ATI 0x8831 #define GL_DRAW_BUFFER13_ATI 0x8832 #define GL_DRAW_BUFFER14_ATI 0x8833 #define GL_DRAW_BUFFER15_ATI 0x8834 typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum* bufs); #define glDrawBuffersATI GLEW_GET_FUN(__glewDrawBuffersATI) #define GLEW_ATI_draw_buffers GLEW_GET_VAR(__GLEW_ATI_draw_buffers) #endif /* GL_ATI_draw_buffers */ /* -------------------------- GL_ATI_element_array ------------------------- */ #ifndef GL_ATI_element_array #define GL_ATI_element_array 1 #define GL_ELEMENT_ARRAY_ATI 0x8768 #define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 #define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); #define glDrawElementArrayATI GLEW_GET_FUN(__glewDrawElementArrayATI) #define glDrawRangeElementArrayATI GLEW_GET_FUN(__glewDrawRangeElementArrayATI) #define glElementPointerATI GLEW_GET_FUN(__glewElementPointerATI) #define GLEW_ATI_element_array GLEW_GET_VAR(__GLEW_ATI_element_array) #endif /* GL_ATI_element_array */ /* ------------------------- GL_ATI_envmap_bumpmap ------------------------- */ #ifndef GL_ATI_envmap_bumpmap #define GL_ATI_envmap_bumpmap 1 #define GL_BUMP_ROT_MATRIX_ATI 0x8775 #define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 #define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 #define GL_BUMP_TEX_UNITS_ATI 0x8778 #define GL_DUDV_ATI 0x8779 #define GL_DU8DV8_ATI 0x877A #define GL_BUMP_ENVMAP_ATI 0x877B #define GL_BUMP_TARGET_ATI 0x877C typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); #define glGetTexBumpParameterfvATI GLEW_GET_FUN(__glewGetTexBumpParameterfvATI) #define glGetTexBumpParameterivATI GLEW_GET_FUN(__glewGetTexBumpParameterivATI) #define glTexBumpParameterfvATI GLEW_GET_FUN(__glewTexBumpParameterfvATI) #define glTexBumpParameterivATI GLEW_GET_FUN(__glewTexBumpParameterivATI) #define GLEW_ATI_envmap_bumpmap GLEW_GET_VAR(__GLEW_ATI_envmap_bumpmap) #endif /* GL_ATI_envmap_bumpmap */ /* ------------------------- GL_ATI_fragment_shader ------------------------ */ #ifndef GL_ATI_fragment_shader #define GL_ATI_fragment_shader 1 #define GL_2X_BIT_ATI 0x00000001 #define GL_RED_BIT_ATI 0x00000001 #define GL_4X_BIT_ATI 0x00000002 #define GL_COMP_BIT_ATI 0x00000002 #define GL_GREEN_BIT_ATI 0x00000002 #define GL_8X_BIT_ATI 0x00000004 #define GL_BLUE_BIT_ATI 0x00000004 #define GL_NEGATE_BIT_ATI 0x00000004 #define GL_BIAS_BIT_ATI 0x00000008 #define GL_HALF_BIT_ATI 0x00000008 #define GL_QUARTER_BIT_ATI 0x00000010 #define GL_EIGHTH_BIT_ATI 0x00000020 #define GL_SATURATE_BIT_ATI 0x00000040 #define GL_FRAGMENT_SHADER_ATI 0x8920 #define GL_REG_0_ATI 0x8921 #define GL_REG_1_ATI 0x8922 #define GL_REG_2_ATI 0x8923 #define GL_REG_3_ATI 0x8924 #define GL_REG_4_ATI 0x8925 #define GL_REG_5_ATI 0x8926 #define GL_CON_0_ATI 0x8941 #define GL_CON_1_ATI 0x8942 #define GL_CON_2_ATI 0x8943 #define GL_CON_3_ATI 0x8944 #define GL_CON_4_ATI 0x8945 #define GL_CON_5_ATI 0x8946 #define GL_CON_6_ATI 0x8947 #define GL_CON_7_ATI 0x8948 #define GL_MOV_ATI 0x8961 #define GL_ADD_ATI 0x8963 #define GL_MUL_ATI 0x8964 #define GL_SUB_ATI 0x8965 #define GL_DOT3_ATI 0x8966 #define GL_DOT4_ATI 0x8967 #define GL_MAD_ATI 0x8968 #define GL_LERP_ATI 0x8969 #define GL_CND_ATI 0x896A #define GL_CND0_ATI 0x896B #define GL_DOT2_ADD_ATI 0x896C #define GL_SECONDARY_INTERPOLATOR_ATI 0x896D #define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E #define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F #define GL_NUM_PASSES_ATI 0x8970 #define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 #define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 #define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 #define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 #define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 #define GL_SWIZZLE_STR_ATI 0x8976 #define GL_SWIZZLE_STQ_ATI 0x8977 #define GL_SWIZZLE_STR_DR_ATI 0x8978 #define GL_SWIZZLE_STQ_DQ_ATI 0x8979 #define GL_SWIZZLE_STRQ_ATI 0x897A #define GL_SWIZZLE_STRQ_DQ_ATI 0x897B typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); typedef void (GLAPIENTRY * PFNGLBEGINFRAGMENTSHADERATIPROC) (void); typedef void (GLAPIENTRY * PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); typedef void (GLAPIENTRY * PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLENDFRAGMENTSHADERATIPROC) (void); typedef GLuint (GLAPIENTRY * PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); typedef void (GLAPIENTRY * PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); typedef void (GLAPIENTRY * PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); typedef void (GLAPIENTRY * PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat* value); #define glAlphaFragmentOp1ATI GLEW_GET_FUN(__glewAlphaFragmentOp1ATI) #define glAlphaFragmentOp2ATI GLEW_GET_FUN(__glewAlphaFragmentOp2ATI) #define glAlphaFragmentOp3ATI GLEW_GET_FUN(__glewAlphaFragmentOp3ATI) #define glBeginFragmentShaderATI GLEW_GET_FUN(__glewBeginFragmentShaderATI) #define glBindFragmentShaderATI GLEW_GET_FUN(__glewBindFragmentShaderATI) #define glColorFragmentOp1ATI GLEW_GET_FUN(__glewColorFragmentOp1ATI) #define glColorFragmentOp2ATI GLEW_GET_FUN(__glewColorFragmentOp2ATI) #define glColorFragmentOp3ATI GLEW_GET_FUN(__glewColorFragmentOp3ATI) #define glDeleteFragmentShaderATI GLEW_GET_FUN(__glewDeleteFragmentShaderATI) #define glEndFragmentShaderATI GLEW_GET_FUN(__glewEndFragmentShaderATI) #define glGenFragmentShadersATI GLEW_GET_FUN(__glewGenFragmentShadersATI) #define glPassTexCoordATI GLEW_GET_FUN(__glewPassTexCoordATI) #define glSampleMapATI GLEW_GET_FUN(__glewSampleMapATI) #define glSetFragmentShaderConstantATI GLEW_GET_FUN(__glewSetFragmentShaderConstantATI) #define GLEW_ATI_fragment_shader GLEW_GET_VAR(__GLEW_ATI_fragment_shader) #endif /* GL_ATI_fragment_shader */ /* ------------------------ GL_ATI_map_object_buffer ----------------------- */ #ifndef GL_ATI_map_object_buffer #define GL_ATI_map_object_buffer 1 typedef void * (GLAPIENTRY * PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); typedef void (GLAPIENTRY * PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); #define glMapObjectBufferATI GLEW_GET_FUN(__glewMapObjectBufferATI) #define glUnmapObjectBufferATI GLEW_GET_FUN(__glewUnmapObjectBufferATI) #define GLEW_ATI_map_object_buffer GLEW_GET_VAR(__GLEW_ATI_map_object_buffer) #endif /* GL_ATI_map_object_buffer */ /* ----------------------------- GL_ATI_meminfo ---------------------------- */ #ifndef GL_ATI_meminfo #define GL_ATI_meminfo 1 #define GL_VBO_FREE_MEMORY_ATI 0x87FB #define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC #define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD #define GLEW_ATI_meminfo GLEW_GET_VAR(__GLEW_ATI_meminfo) #endif /* GL_ATI_meminfo */ /* -------------------------- GL_ATI_pn_triangles -------------------------- */ #ifndef GL_ATI_pn_triangles #define GL_ATI_pn_triangles 1 #define GL_PN_TRIANGLES_ATI 0x87F0 #define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 #define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 #define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 #define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 #define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 #define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 #define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 #define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 typedef void (GLAPIENTRY * PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); #define glPNTrianglesfATI GLEW_GET_FUN(__glewPNTrianglesfATI) #define glPNTrianglesiATI GLEW_GET_FUN(__glewPNTrianglesiATI) #define GLEW_ATI_pn_triangles GLEW_GET_VAR(__GLEW_ATI_pn_triangles) #endif /* GL_ATI_pn_triangles */ /* ------------------------ GL_ATI_separate_stencil ------------------------ */ #ifndef GL_ATI_separate_stencil #define GL_ATI_separate_stencil 1 #define GL_STENCIL_BACK_FUNC_ATI 0x8800 #define GL_STENCIL_BACK_FAIL_ATI 0x8801 #define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 #define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); #define glStencilFuncSeparateATI GLEW_GET_FUN(__glewStencilFuncSeparateATI) #define glStencilOpSeparateATI GLEW_GET_FUN(__glewStencilOpSeparateATI) #define GLEW_ATI_separate_stencil GLEW_GET_VAR(__GLEW_ATI_separate_stencil) #endif /* GL_ATI_separate_stencil */ /* ----------------------- GL_ATI_shader_texture_lod ----------------------- */ #ifndef GL_ATI_shader_texture_lod #define GL_ATI_shader_texture_lod 1 #define GLEW_ATI_shader_texture_lod GLEW_GET_VAR(__GLEW_ATI_shader_texture_lod) #endif /* GL_ATI_shader_texture_lod */ /* ---------------------- GL_ATI_text_fragment_shader ---------------------- */ #ifndef GL_ATI_text_fragment_shader #define GL_ATI_text_fragment_shader 1 #define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 #define GLEW_ATI_text_fragment_shader GLEW_GET_VAR(__GLEW_ATI_text_fragment_shader) #endif /* GL_ATI_text_fragment_shader */ /* --------------------- GL_ATI_texture_compression_3dc -------------------- */ #ifndef GL_ATI_texture_compression_3dc #define GL_ATI_texture_compression_3dc 1 #define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 #define GLEW_ATI_texture_compression_3dc GLEW_GET_VAR(__GLEW_ATI_texture_compression_3dc) #endif /* GL_ATI_texture_compression_3dc */ /* ---------------------- GL_ATI_texture_env_combine3 ---------------------- */ #ifndef GL_ATI_texture_env_combine3 #define GL_ATI_texture_env_combine3 1 #define GL_MODULATE_ADD_ATI 0x8744 #define GL_MODULATE_SIGNED_ADD_ATI 0x8745 #define GL_MODULATE_SUBTRACT_ATI 0x8746 #define GLEW_ATI_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATI_texture_env_combine3) #endif /* GL_ATI_texture_env_combine3 */ /* -------------------------- GL_ATI_texture_float ------------------------- */ #ifndef GL_ATI_texture_float #define GL_ATI_texture_float 1 #define GL_RGBA_FLOAT32_ATI 0x8814 #define GL_RGB_FLOAT32_ATI 0x8815 #define GL_ALPHA_FLOAT32_ATI 0x8816 #define GL_INTENSITY_FLOAT32_ATI 0x8817 #define GL_LUMINANCE_FLOAT32_ATI 0x8818 #define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 #define GL_RGBA_FLOAT16_ATI 0x881A #define GL_RGB_FLOAT16_ATI 0x881B #define GL_ALPHA_FLOAT16_ATI 0x881C #define GL_INTENSITY_FLOAT16_ATI 0x881D #define GL_LUMINANCE_FLOAT16_ATI 0x881E #define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F #define GLEW_ATI_texture_float GLEW_GET_VAR(__GLEW_ATI_texture_float) #endif /* GL_ATI_texture_float */ /* ----------------------- GL_ATI_texture_mirror_once ---------------------- */ #ifndef GL_ATI_texture_mirror_once #define GL_ATI_texture_mirror_once 1 #define GL_MIRROR_CLAMP_ATI 0x8742 #define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 #define GLEW_ATI_texture_mirror_once GLEW_GET_VAR(__GLEW_ATI_texture_mirror_once) #endif /* GL_ATI_texture_mirror_once */ /* ----------------------- GL_ATI_vertex_array_object ---------------------- */ #ifndef GL_ATI_vertex_array_object #define GL_ATI_vertex_array_object 1 #define GL_STATIC_ATI 0x8760 #define GL_DYNAMIC_ATI 0x8761 #define GL_PRESERVE_ATI 0x8762 #define GL_DISCARD_ATI 0x8763 #define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 #define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 #define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 #define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 typedef void (GLAPIENTRY * PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); typedef void (GLAPIENTRY * PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); typedef GLuint (GLAPIENTRY * PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); typedef void (GLAPIENTRY * PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); typedef void (GLAPIENTRY * PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); #define glArrayObjectATI GLEW_GET_FUN(__glewArrayObjectATI) #define glFreeObjectBufferATI GLEW_GET_FUN(__glewFreeObjectBufferATI) #define glGetArrayObjectfvATI GLEW_GET_FUN(__glewGetArrayObjectfvATI) #define glGetArrayObjectivATI GLEW_GET_FUN(__glewGetArrayObjectivATI) #define glGetObjectBufferfvATI GLEW_GET_FUN(__glewGetObjectBufferfvATI) #define glGetObjectBufferivATI GLEW_GET_FUN(__glewGetObjectBufferivATI) #define glGetVariantArrayObjectfvATI GLEW_GET_FUN(__glewGetVariantArrayObjectfvATI) #define glGetVariantArrayObjectivATI GLEW_GET_FUN(__glewGetVariantArrayObjectivATI) #define glIsObjectBufferATI GLEW_GET_FUN(__glewIsObjectBufferATI) #define glNewObjectBufferATI GLEW_GET_FUN(__glewNewObjectBufferATI) #define glUpdateObjectBufferATI GLEW_GET_FUN(__glewUpdateObjectBufferATI) #define glVariantArrayObjectATI GLEW_GET_FUN(__glewVariantArrayObjectATI) #define GLEW_ATI_vertex_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_array_object) #endif /* GL_ATI_vertex_array_object */ /* ------------------- GL_ATI_vertex_attrib_array_object ------------------- */ #ifndef GL_ATI_vertex_attrib_array_object #define GL_ATI_vertex_attrib_array_object 1 typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); #define glGetVertexAttribArrayObjectfvATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectfvATI) #define glGetVertexAttribArrayObjectivATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectivATI) #define glVertexAttribArrayObjectATI GLEW_GET_FUN(__glewVertexAttribArrayObjectATI) #define GLEW_ATI_vertex_attrib_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_attrib_array_object) #endif /* GL_ATI_vertex_attrib_array_object */ /* ------------------------- GL_ATI_vertex_streams ------------------------- */ #ifndef GL_ATI_vertex_streams #define GL_ATI_vertex_streams 1 #define GL_MAX_VERTEX_STREAMS_ATI 0x876B #define GL_VERTEX_SOURCE_ATI 0x876C #define GL_VERTEX_STREAM0_ATI 0x876D #define GL_VERTEX_STREAM1_ATI 0x876E #define GL_VERTEX_STREAM2_ATI 0x876F #define GL_VERTEX_STREAM3_ATI 0x8770 #define GL_VERTEX_STREAM4_ATI 0x8771 #define GL_VERTEX_STREAM5_ATI 0x8772 #define GL_VERTEX_STREAM6_ATI 0x8773 #define GL_VERTEX_STREAM7_ATI 0x8774 typedef void (GLAPIENTRY * PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte x, GLbyte y, GLbyte z); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); #define glClientActiveVertexStreamATI GLEW_GET_FUN(__glewClientActiveVertexStreamATI) #define glNormalStream3bATI GLEW_GET_FUN(__glewNormalStream3bATI) #define glNormalStream3bvATI GLEW_GET_FUN(__glewNormalStream3bvATI) #define glNormalStream3dATI GLEW_GET_FUN(__glewNormalStream3dATI) #define glNormalStream3dvATI GLEW_GET_FUN(__glewNormalStream3dvATI) #define glNormalStream3fATI GLEW_GET_FUN(__glewNormalStream3fATI) #define glNormalStream3fvATI GLEW_GET_FUN(__glewNormalStream3fvATI) #define glNormalStream3iATI GLEW_GET_FUN(__glewNormalStream3iATI) #define glNormalStream3ivATI GLEW_GET_FUN(__glewNormalStream3ivATI) #define glNormalStream3sATI GLEW_GET_FUN(__glewNormalStream3sATI) #define glNormalStream3svATI GLEW_GET_FUN(__glewNormalStream3svATI) #define glVertexBlendEnvfATI GLEW_GET_FUN(__glewVertexBlendEnvfATI) #define glVertexBlendEnviATI GLEW_GET_FUN(__glewVertexBlendEnviATI) #define glVertexStream1dATI GLEW_GET_FUN(__glewVertexStream1dATI) #define glVertexStream1dvATI GLEW_GET_FUN(__glewVertexStream1dvATI) #define glVertexStream1fATI GLEW_GET_FUN(__glewVertexStream1fATI) #define glVertexStream1fvATI GLEW_GET_FUN(__glewVertexStream1fvATI) #define glVertexStream1iATI GLEW_GET_FUN(__glewVertexStream1iATI) #define glVertexStream1ivATI GLEW_GET_FUN(__glewVertexStream1ivATI) #define glVertexStream1sATI GLEW_GET_FUN(__glewVertexStream1sATI) #define glVertexStream1svATI GLEW_GET_FUN(__glewVertexStream1svATI) #define glVertexStream2dATI GLEW_GET_FUN(__glewVertexStream2dATI) #define glVertexStream2dvATI GLEW_GET_FUN(__glewVertexStream2dvATI) #define glVertexStream2fATI GLEW_GET_FUN(__glewVertexStream2fATI) #define glVertexStream2fvATI GLEW_GET_FUN(__glewVertexStream2fvATI) #define glVertexStream2iATI GLEW_GET_FUN(__glewVertexStream2iATI) #define glVertexStream2ivATI GLEW_GET_FUN(__glewVertexStream2ivATI) #define glVertexStream2sATI GLEW_GET_FUN(__glewVertexStream2sATI) #define glVertexStream2svATI GLEW_GET_FUN(__glewVertexStream2svATI) #define glVertexStream3dATI GLEW_GET_FUN(__glewVertexStream3dATI) #define glVertexStream3dvATI GLEW_GET_FUN(__glewVertexStream3dvATI) #define glVertexStream3fATI GLEW_GET_FUN(__glewVertexStream3fATI) #define glVertexStream3fvATI GLEW_GET_FUN(__glewVertexStream3fvATI) #define glVertexStream3iATI GLEW_GET_FUN(__glewVertexStream3iATI) #define glVertexStream3ivATI GLEW_GET_FUN(__glewVertexStream3ivATI) #define glVertexStream3sATI GLEW_GET_FUN(__glewVertexStream3sATI) #define glVertexStream3svATI GLEW_GET_FUN(__glewVertexStream3svATI) #define glVertexStream4dATI GLEW_GET_FUN(__glewVertexStream4dATI) #define glVertexStream4dvATI GLEW_GET_FUN(__glewVertexStream4dvATI) #define glVertexStream4fATI GLEW_GET_FUN(__glewVertexStream4fATI) #define glVertexStream4fvATI GLEW_GET_FUN(__glewVertexStream4fvATI) #define glVertexStream4iATI GLEW_GET_FUN(__glewVertexStream4iATI) #define glVertexStream4ivATI GLEW_GET_FUN(__glewVertexStream4ivATI) #define glVertexStream4sATI GLEW_GET_FUN(__glewVertexStream4sATI) #define glVertexStream4svATI GLEW_GET_FUN(__glewVertexStream4svATI) #define GLEW_ATI_vertex_streams GLEW_GET_VAR(__GLEW_ATI_vertex_streams) #endif /* GL_ATI_vertex_streams */ /* --------------------------- GL_EXT_422_pixels --------------------------- */ #ifndef GL_EXT_422_pixels #define GL_EXT_422_pixels 1 #define GL_422_EXT 0x80CC #define GL_422_REV_EXT 0x80CD #define GL_422_AVERAGE_EXT 0x80CE #define GL_422_REV_AVERAGE_EXT 0x80CF #define GLEW_EXT_422_pixels GLEW_GET_VAR(__GLEW_EXT_422_pixels) #endif /* GL_EXT_422_pixels */ /* ---------------------------- GL_EXT_Cg_shader --------------------------- */ #ifndef GL_EXT_Cg_shader #define GL_EXT_Cg_shader 1 #define GL_CG_VERTEX_SHADER_EXT 0x890E #define GL_CG_FRAGMENT_SHADER_EXT 0x890F #define GLEW_EXT_Cg_shader GLEW_GET_VAR(__GLEW_EXT_Cg_shader) #endif /* GL_EXT_Cg_shader */ /* ------------------------------ GL_EXT_abgr ------------------------------ */ #ifndef GL_EXT_abgr #define GL_EXT_abgr 1 #define GL_ABGR_EXT 0x8000 #define GLEW_EXT_abgr GLEW_GET_VAR(__GLEW_EXT_abgr) #endif /* GL_EXT_abgr */ /* ------------------------------ GL_EXT_bgra ------------------------------ */ #ifndef GL_EXT_bgra #define GL_EXT_bgra 1 #define GL_BGR_EXT 0x80E0 #define GL_BGRA_EXT 0x80E1 #define GLEW_EXT_bgra GLEW_GET_VAR(__GLEW_EXT_bgra) #endif /* GL_EXT_bgra */ /* ------------------------ GL_EXT_bindable_uniform ------------------------ */ #ifndef GL_EXT_bindable_uniform #define GL_EXT_bindable_uniform 1 #define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 #define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 #define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 #define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED #define GL_UNIFORM_BUFFER_EXT 0x8DEE #define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); typedef GLintptr (GLAPIENTRY * PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); typedef void (GLAPIENTRY * PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); #define glGetUniformBufferSizeEXT GLEW_GET_FUN(__glewGetUniformBufferSizeEXT) #define glGetUniformOffsetEXT GLEW_GET_FUN(__glewGetUniformOffsetEXT) #define glUniformBufferEXT GLEW_GET_FUN(__glewUniformBufferEXT) #define GLEW_EXT_bindable_uniform GLEW_GET_VAR(__GLEW_EXT_bindable_uniform) #endif /* GL_EXT_bindable_uniform */ /* --------------------------- GL_EXT_blend_color -------------------------- */ #ifndef GL_EXT_blend_color #define GL_EXT_blend_color 1 #define GL_CONSTANT_COLOR_EXT 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 #define GL_CONSTANT_ALPHA_EXT 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 #define GL_BLEND_COLOR_EXT 0x8005 typedef void (GLAPIENTRY * PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); #define glBlendColorEXT GLEW_GET_FUN(__glewBlendColorEXT) #define GLEW_EXT_blend_color GLEW_GET_VAR(__GLEW_EXT_blend_color) #endif /* GL_EXT_blend_color */ /* --------------------- GL_EXT_blend_equation_separate -------------------- */ #ifndef GL_EXT_blend_equation_separate #define GL_EXT_blend_equation_separate 1 #define GL_BLEND_EQUATION_RGB_EXT 0x8009 #define GL_BLEND_EQUATION_ALPHA_EXT 0x883D typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); #define glBlendEquationSeparateEXT GLEW_GET_FUN(__glewBlendEquationSeparateEXT) #define GLEW_EXT_blend_equation_separate GLEW_GET_VAR(__GLEW_EXT_blend_equation_separate) #endif /* GL_EXT_blend_equation_separate */ /* ----------------------- GL_EXT_blend_func_separate ---------------------- */ #ifndef GL_EXT_blend_func_separate #define GL_EXT_blend_func_separate 1 #define GL_BLEND_DST_RGB_EXT 0x80C8 #define GL_BLEND_SRC_RGB_EXT 0x80C9 #define GL_BLEND_DST_ALPHA_EXT 0x80CA #define GL_BLEND_SRC_ALPHA_EXT 0x80CB typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #define glBlendFuncSeparateEXT GLEW_GET_FUN(__glewBlendFuncSeparateEXT) #define GLEW_EXT_blend_func_separate GLEW_GET_VAR(__GLEW_EXT_blend_func_separate) #endif /* GL_EXT_blend_func_separate */ /* ------------------------- GL_EXT_blend_logic_op ------------------------- */ #ifndef GL_EXT_blend_logic_op #define GL_EXT_blend_logic_op 1 #define GLEW_EXT_blend_logic_op GLEW_GET_VAR(__GLEW_EXT_blend_logic_op) #endif /* GL_EXT_blend_logic_op */ /* -------------------------- GL_EXT_blend_minmax -------------------------- */ #ifndef GL_EXT_blend_minmax #define GL_EXT_blend_minmax 1 #define GL_FUNC_ADD_EXT 0x8006 #define GL_MIN_EXT 0x8007 #define GL_MAX_EXT 0x8008 #define GL_BLEND_EQUATION_EXT 0x8009 typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); #define glBlendEquationEXT GLEW_GET_FUN(__glewBlendEquationEXT) #define GLEW_EXT_blend_minmax GLEW_GET_VAR(__GLEW_EXT_blend_minmax) #endif /* GL_EXT_blend_minmax */ /* ------------------------- GL_EXT_blend_subtract ------------------------- */ #ifndef GL_EXT_blend_subtract #define GL_EXT_blend_subtract 1 #define GL_FUNC_SUBTRACT_EXT 0x800A #define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B #define GLEW_EXT_blend_subtract GLEW_GET_VAR(__GLEW_EXT_blend_subtract) #endif /* GL_EXT_blend_subtract */ /* ------------------------ GL_EXT_clip_volume_hint ------------------------ */ #ifndef GL_EXT_clip_volume_hint #define GL_EXT_clip_volume_hint 1 #define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 #define GLEW_EXT_clip_volume_hint GLEW_GET_VAR(__GLEW_EXT_clip_volume_hint) #endif /* GL_EXT_clip_volume_hint */ /* ------------------------------ GL_EXT_cmyka ----------------------------- */ #ifndef GL_EXT_cmyka #define GL_EXT_cmyka 1 #define GL_CMYK_EXT 0x800C #define GL_CMYKA_EXT 0x800D #define GL_PACK_CMYK_HINT_EXT 0x800E #define GL_UNPACK_CMYK_HINT_EXT 0x800F #define GLEW_EXT_cmyka GLEW_GET_VAR(__GLEW_EXT_cmyka) #endif /* GL_EXT_cmyka */ /* ------------------------- GL_EXT_color_subtable ------------------------- */ #ifndef GL_EXT_color_subtable #define GL_EXT_color_subtable 1 typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); #define glColorSubTableEXT GLEW_GET_FUN(__glewColorSubTableEXT) #define glCopyColorSubTableEXT GLEW_GET_FUN(__glewCopyColorSubTableEXT) #define GLEW_EXT_color_subtable GLEW_GET_VAR(__GLEW_EXT_color_subtable) #endif /* GL_EXT_color_subtable */ /* ---------------------- GL_EXT_compiled_vertex_array --------------------- */ #ifndef GL_EXT_compiled_vertex_array #define GL_EXT_compiled_vertex_array 1 #define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 #define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 typedef void (GLAPIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); typedef void (GLAPIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void); #define glLockArraysEXT GLEW_GET_FUN(__glewLockArraysEXT) #define glUnlockArraysEXT GLEW_GET_FUN(__glewUnlockArraysEXT) #define GLEW_EXT_compiled_vertex_array GLEW_GET_VAR(__GLEW_EXT_compiled_vertex_array) #endif /* GL_EXT_compiled_vertex_array */ /* --------------------------- GL_EXT_convolution -------------------------- */ #ifndef GL_EXT_convolution #define GL_EXT_convolution 1 #define GL_CONVOLUTION_1D_EXT 0x8010 #define GL_CONVOLUTION_2D_EXT 0x8011 #define GL_SEPARABLE_2D_EXT 0x8012 #define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 #define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 #define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 #define GL_REDUCE_EXT 0x8016 #define GL_CONVOLUTION_FORMAT_EXT 0x8017 #define GL_CONVOLUTION_WIDTH_EXT 0x8018 #define GL_CONVOLUTION_HEIGHT_EXT 0x8019 #define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A #define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B #define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C #define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D #define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E #define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F #define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 #define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 #define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 #define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); #define glConvolutionFilter1DEXT GLEW_GET_FUN(__glewConvolutionFilter1DEXT) #define glConvolutionFilter2DEXT GLEW_GET_FUN(__glewConvolutionFilter2DEXT) #define glConvolutionParameterfEXT GLEW_GET_FUN(__glewConvolutionParameterfEXT) #define glConvolutionParameterfvEXT GLEW_GET_FUN(__glewConvolutionParameterfvEXT) #define glConvolutionParameteriEXT GLEW_GET_FUN(__glewConvolutionParameteriEXT) #define glConvolutionParameterivEXT GLEW_GET_FUN(__glewConvolutionParameterivEXT) #define glCopyConvolutionFilter1DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter1DEXT) #define glCopyConvolutionFilter2DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter2DEXT) #define glGetConvolutionFilterEXT GLEW_GET_FUN(__glewGetConvolutionFilterEXT) #define glGetConvolutionParameterfvEXT GLEW_GET_FUN(__glewGetConvolutionParameterfvEXT) #define glGetConvolutionParameterivEXT GLEW_GET_FUN(__glewGetConvolutionParameterivEXT) #define glGetSeparableFilterEXT GLEW_GET_FUN(__glewGetSeparableFilterEXT) #define glSeparableFilter2DEXT GLEW_GET_FUN(__glewSeparableFilter2DEXT) #define GLEW_EXT_convolution GLEW_GET_VAR(__GLEW_EXT_convolution) #endif /* GL_EXT_convolution */ /* ------------------------ GL_EXT_coordinate_frame ------------------------ */ #ifndef GL_EXT_coordinate_frame #define GL_EXT_coordinate_frame 1 #define GL_TANGENT_ARRAY_EXT 0x8439 #define GL_BINORMAL_ARRAY_EXT 0x843A #define GL_CURRENT_TANGENT_EXT 0x843B #define GL_CURRENT_BINORMAL_EXT 0x843C #define GL_TANGENT_ARRAY_TYPE_EXT 0x843E #define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F #define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 #define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 #define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 #define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 #define GL_MAP1_TANGENT_EXT 0x8444 #define GL_MAP2_TANGENT_EXT 0x8445 #define GL_MAP1_BINORMAL_EXT 0x8446 #define GL_MAP2_BINORMAL_EXT 0x8447 typedef void (GLAPIENTRY * PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, void *pointer); typedef void (GLAPIENTRY * PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, void *pointer); #define glBinormalPointerEXT GLEW_GET_FUN(__glewBinormalPointerEXT) #define glTangentPointerEXT GLEW_GET_FUN(__glewTangentPointerEXT) #define GLEW_EXT_coordinate_frame GLEW_GET_VAR(__GLEW_EXT_coordinate_frame) #endif /* GL_EXT_coordinate_frame */ /* -------------------------- GL_EXT_copy_texture -------------------------- */ #ifndef GL_EXT_copy_texture #define GL_EXT_copy_texture 1 typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #define glCopyTexImage1DEXT GLEW_GET_FUN(__glewCopyTexImage1DEXT) #define glCopyTexImage2DEXT GLEW_GET_FUN(__glewCopyTexImage2DEXT) #define glCopyTexSubImage1DEXT GLEW_GET_FUN(__glewCopyTexSubImage1DEXT) #define glCopyTexSubImage2DEXT GLEW_GET_FUN(__glewCopyTexSubImage2DEXT) #define glCopyTexSubImage3DEXT GLEW_GET_FUN(__glewCopyTexSubImage3DEXT) #define GLEW_EXT_copy_texture GLEW_GET_VAR(__GLEW_EXT_copy_texture) #endif /* GL_EXT_copy_texture */ /* --------------------------- GL_EXT_cull_vertex -------------------------- */ #ifndef GL_EXT_cull_vertex #define GL_EXT_cull_vertex 1 #define GL_CULL_VERTEX_EXT 0x81AA #define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB #define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC typedef void (GLAPIENTRY * PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params); #define glCullParameterdvEXT GLEW_GET_FUN(__glewCullParameterdvEXT) #define glCullParameterfvEXT GLEW_GET_FUN(__glewCullParameterfvEXT) #define GLEW_EXT_cull_vertex GLEW_GET_VAR(__GLEW_EXT_cull_vertex) #endif /* GL_EXT_cull_vertex */ /* --------------------------- GL_EXT_debug_label -------------------------- */ #ifndef GL_EXT_debug_label #define GL_EXT_debug_label 1 #define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F #define GL_PROGRAM_OBJECT_EXT 0x8B40 #define GL_SHADER_OBJECT_EXT 0x8B48 #define GL_BUFFER_OBJECT_EXT 0x9151 #define GL_QUERY_OBJECT_EXT 0x9153 #define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 typedef void (GLAPIENTRY * PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei* length, GLchar *label); typedef void (GLAPIENTRY * PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar* label); #define glGetObjectLabelEXT GLEW_GET_FUN(__glewGetObjectLabelEXT) #define glLabelObjectEXT GLEW_GET_FUN(__glewLabelObjectEXT) #define GLEW_EXT_debug_label GLEW_GET_VAR(__GLEW_EXT_debug_label) #endif /* GL_EXT_debug_label */ /* -------------------------- GL_EXT_debug_marker -------------------------- */ #ifndef GL_EXT_debug_marker #define GL_EXT_debug_marker 1 typedef void (GLAPIENTRY * PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar* marker); typedef void (GLAPIENTRY * PFNGLPOPGROUPMARKEREXTPROC) (void); typedef void (GLAPIENTRY * PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar* marker); #define glInsertEventMarkerEXT GLEW_GET_FUN(__glewInsertEventMarkerEXT) #define glPopGroupMarkerEXT GLEW_GET_FUN(__glewPopGroupMarkerEXT) #define glPushGroupMarkerEXT GLEW_GET_FUN(__glewPushGroupMarkerEXT) #define GLEW_EXT_debug_marker GLEW_GET_VAR(__GLEW_EXT_debug_marker) #endif /* GL_EXT_debug_marker */ /* ------------------------ GL_EXT_depth_bounds_test ----------------------- */ #ifndef GL_EXT_depth_bounds_test #define GL_EXT_depth_bounds_test 1 #define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 #define GL_DEPTH_BOUNDS_EXT 0x8891 typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); #define glDepthBoundsEXT GLEW_GET_FUN(__glewDepthBoundsEXT) #define GLEW_EXT_depth_bounds_test GLEW_GET_VAR(__GLEW_EXT_depth_bounds_test) #endif /* GL_EXT_depth_bounds_test */ /* ----------------------- GL_EXT_direct_state_access ---------------------- */ #ifndef GL_EXT_direct_state_access #define GL_EXT_direct_state_access 1 #define GL_PROGRAM_MATRIX_EXT 0x8E2D #define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E #define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F typedef void (GLAPIENTRY * PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); typedef GLenum (GLAPIENTRY * PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); typedef void (GLAPIENTRY * PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); typedef void (GLAPIENTRY * PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); typedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); typedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); typedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); typedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); typedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum* bufs); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); typedef void (GLAPIENTRY * PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); typedef void (GLAPIENTRY * PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, void *img); typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, void *img); typedef void (GLAPIENTRY * PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint* param); typedef void (GLAPIENTRY * PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); typedef void (GLAPIENTRY * PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void** params); typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); typedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void** params); typedef void (GLAPIENTRY * PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void** params); typedef void (GLAPIENTRY * PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint* param); typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint* param); typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void** param); typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void** param); typedef void * (GLAPIENTRY * PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); typedef void * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); typedef void (GLAPIENTRY * PFNGLMATRIXFRUSTUMEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f); typedef void (GLAPIENTRY * PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum matrixMode); typedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m); typedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum matrixMode, const GLfloat* m); typedef void (GLAPIENTRY * PFNGLMATRIXLOADDEXTPROC) (GLenum matrixMode, const GLdouble* m); typedef void (GLAPIENTRY * PFNGLMATRIXLOADFEXTPROC) (GLenum matrixMode, const GLfloat* m); typedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m); typedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum matrixMode, const GLfloat* m); typedef void (GLAPIENTRY * PFNGLMATRIXMULTDEXTPROC) (GLenum matrixMode, const GLdouble* m); typedef void (GLAPIENTRY * PFNGLMATRIXMULTFEXTPROC) (GLenum matrixMode, const GLfloat* m); typedef void (GLAPIENTRY * PFNGLMATRIXORTHOEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f); typedef void (GLAPIENTRY * PFNGLMATRIXPOPEXTPROC) (GLenum matrixMode); typedef void (GLAPIENTRY * PFNGLMATRIXPUSHEXTPROC) (GLenum matrixMode); typedef void (GLAPIENTRY * PFNGLMATRIXROTATEDEXTPROC) (GLenum matrixMode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLMATRIXROTATEFEXTPROC) (GLenum matrixMode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLMATRIXSCALEDEXTPROC) (GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLMATRIXSCALEFEXTPROC) (GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); typedef void (GLAPIENTRY * PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); typedef void (GLAPIENTRY * PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble* params); typedef void (GLAPIENTRY * PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint* params); typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat* param); typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* param); typedef void (GLAPIENTRY * PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); typedef void (GLAPIENTRY * PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble* params); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint* params); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint* params); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint* params); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint* params); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); typedef void (GLAPIENTRY * PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint* params); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat* param); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint* param); typedef void (GLAPIENTRY * PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); #define glBindMultiTextureEXT GLEW_GET_FUN(__glewBindMultiTextureEXT) #define glCheckNamedFramebufferStatusEXT GLEW_GET_FUN(__glewCheckNamedFramebufferStatusEXT) #define glClientAttribDefaultEXT GLEW_GET_FUN(__glewClientAttribDefaultEXT) #define glCompressedMultiTexImage1DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage1DEXT) #define glCompressedMultiTexImage2DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage2DEXT) #define glCompressedMultiTexImage3DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage3DEXT) #define glCompressedMultiTexSubImage1DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage1DEXT) #define glCompressedMultiTexSubImage2DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage2DEXT) #define glCompressedMultiTexSubImage3DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage3DEXT) #define glCompressedTextureImage1DEXT GLEW_GET_FUN(__glewCompressedTextureImage1DEXT) #define glCompressedTextureImage2DEXT GLEW_GET_FUN(__glewCompressedTextureImage2DEXT) #define glCompressedTextureImage3DEXT GLEW_GET_FUN(__glewCompressedTextureImage3DEXT) #define glCompressedTextureSubImage1DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage1DEXT) #define glCompressedTextureSubImage2DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage2DEXT) #define glCompressedTextureSubImage3DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage3DEXT) #define glCopyMultiTexImage1DEXT GLEW_GET_FUN(__glewCopyMultiTexImage1DEXT) #define glCopyMultiTexImage2DEXT GLEW_GET_FUN(__glewCopyMultiTexImage2DEXT) #define glCopyMultiTexSubImage1DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage1DEXT) #define glCopyMultiTexSubImage2DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage2DEXT) #define glCopyMultiTexSubImage3DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage3DEXT) #define glCopyTextureImage1DEXT GLEW_GET_FUN(__glewCopyTextureImage1DEXT) #define glCopyTextureImage2DEXT GLEW_GET_FUN(__glewCopyTextureImage2DEXT) #define glCopyTextureSubImage1DEXT GLEW_GET_FUN(__glewCopyTextureSubImage1DEXT) #define glCopyTextureSubImage2DEXT GLEW_GET_FUN(__glewCopyTextureSubImage2DEXT) #define glCopyTextureSubImage3DEXT GLEW_GET_FUN(__glewCopyTextureSubImage3DEXT) #define glDisableClientStateIndexedEXT GLEW_GET_FUN(__glewDisableClientStateIndexedEXT) #define glDisableClientStateiEXT GLEW_GET_FUN(__glewDisableClientStateiEXT) #define glDisableVertexArrayAttribEXT GLEW_GET_FUN(__glewDisableVertexArrayAttribEXT) #define glDisableVertexArrayEXT GLEW_GET_FUN(__glewDisableVertexArrayEXT) #define glEnableClientStateIndexedEXT GLEW_GET_FUN(__glewEnableClientStateIndexedEXT) #define glEnableClientStateiEXT GLEW_GET_FUN(__glewEnableClientStateiEXT) #define glEnableVertexArrayAttribEXT GLEW_GET_FUN(__glewEnableVertexArrayAttribEXT) #define glEnableVertexArrayEXT GLEW_GET_FUN(__glewEnableVertexArrayEXT) #define glFlushMappedNamedBufferRangeEXT GLEW_GET_FUN(__glewFlushMappedNamedBufferRangeEXT) #define glFramebufferDrawBufferEXT GLEW_GET_FUN(__glewFramebufferDrawBufferEXT) #define glFramebufferDrawBuffersEXT GLEW_GET_FUN(__glewFramebufferDrawBuffersEXT) #define glFramebufferReadBufferEXT GLEW_GET_FUN(__glewFramebufferReadBufferEXT) #define glGenerateMultiTexMipmapEXT GLEW_GET_FUN(__glewGenerateMultiTexMipmapEXT) #define glGenerateTextureMipmapEXT GLEW_GET_FUN(__glewGenerateTextureMipmapEXT) #define glGetCompressedMultiTexImageEXT GLEW_GET_FUN(__glewGetCompressedMultiTexImageEXT) #define glGetCompressedTextureImageEXT GLEW_GET_FUN(__glewGetCompressedTextureImageEXT) #define glGetDoubleIndexedvEXT GLEW_GET_FUN(__glewGetDoubleIndexedvEXT) #define glGetDoublei_vEXT GLEW_GET_FUN(__glewGetDoublei_vEXT) #define glGetFloatIndexedvEXT GLEW_GET_FUN(__glewGetFloatIndexedvEXT) #define glGetFloati_vEXT GLEW_GET_FUN(__glewGetFloati_vEXT) #define glGetFramebufferParameterivEXT GLEW_GET_FUN(__glewGetFramebufferParameterivEXT) #define glGetMultiTexEnvfvEXT GLEW_GET_FUN(__glewGetMultiTexEnvfvEXT) #define glGetMultiTexEnvivEXT GLEW_GET_FUN(__glewGetMultiTexEnvivEXT) #define glGetMultiTexGendvEXT GLEW_GET_FUN(__glewGetMultiTexGendvEXT) #define glGetMultiTexGenfvEXT GLEW_GET_FUN(__glewGetMultiTexGenfvEXT) #define glGetMultiTexGenivEXT GLEW_GET_FUN(__glewGetMultiTexGenivEXT) #define glGetMultiTexImageEXT GLEW_GET_FUN(__glewGetMultiTexImageEXT) #define glGetMultiTexLevelParameterfvEXT GLEW_GET_FUN(__glewGetMultiTexLevelParameterfvEXT) #define glGetMultiTexLevelParameterivEXT GLEW_GET_FUN(__glewGetMultiTexLevelParameterivEXT) #define glGetMultiTexParameterIivEXT GLEW_GET_FUN(__glewGetMultiTexParameterIivEXT) #define glGetMultiTexParameterIuivEXT GLEW_GET_FUN(__glewGetMultiTexParameterIuivEXT) #define glGetMultiTexParameterfvEXT GLEW_GET_FUN(__glewGetMultiTexParameterfvEXT) #define glGetMultiTexParameterivEXT GLEW_GET_FUN(__glewGetMultiTexParameterivEXT) #define glGetNamedBufferParameterivEXT GLEW_GET_FUN(__glewGetNamedBufferParameterivEXT) #define glGetNamedBufferPointervEXT GLEW_GET_FUN(__glewGetNamedBufferPointervEXT) #define glGetNamedBufferSubDataEXT GLEW_GET_FUN(__glewGetNamedBufferSubDataEXT) #define glGetNamedFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetNamedFramebufferAttachmentParameterivEXT) #define glGetNamedProgramLocalParameterIivEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterIivEXT) #define glGetNamedProgramLocalParameterIuivEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterIuivEXT) #define glGetNamedProgramLocalParameterdvEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterdvEXT) #define glGetNamedProgramLocalParameterfvEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterfvEXT) #define glGetNamedProgramStringEXT GLEW_GET_FUN(__glewGetNamedProgramStringEXT) #define glGetNamedProgramivEXT GLEW_GET_FUN(__glewGetNamedProgramivEXT) #define glGetNamedRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetNamedRenderbufferParameterivEXT) #define glGetPointerIndexedvEXT GLEW_GET_FUN(__glewGetPointerIndexedvEXT) #define glGetPointeri_vEXT GLEW_GET_FUN(__glewGetPointeri_vEXT) #define glGetTextureImageEXT GLEW_GET_FUN(__glewGetTextureImageEXT) #define glGetTextureLevelParameterfvEXT GLEW_GET_FUN(__glewGetTextureLevelParameterfvEXT) #define glGetTextureLevelParameterivEXT GLEW_GET_FUN(__glewGetTextureLevelParameterivEXT) #define glGetTextureParameterIivEXT GLEW_GET_FUN(__glewGetTextureParameterIivEXT) #define glGetTextureParameterIuivEXT GLEW_GET_FUN(__glewGetTextureParameterIuivEXT) #define glGetTextureParameterfvEXT GLEW_GET_FUN(__glewGetTextureParameterfvEXT) #define glGetTextureParameterivEXT GLEW_GET_FUN(__glewGetTextureParameterivEXT) #define glGetVertexArrayIntegeri_vEXT GLEW_GET_FUN(__glewGetVertexArrayIntegeri_vEXT) #define glGetVertexArrayIntegervEXT GLEW_GET_FUN(__glewGetVertexArrayIntegervEXT) #define glGetVertexArrayPointeri_vEXT GLEW_GET_FUN(__glewGetVertexArrayPointeri_vEXT) #define glGetVertexArrayPointervEXT GLEW_GET_FUN(__glewGetVertexArrayPointervEXT) #define glMapNamedBufferEXT GLEW_GET_FUN(__glewMapNamedBufferEXT) #define glMapNamedBufferRangeEXT GLEW_GET_FUN(__glewMapNamedBufferRangeEXT) #define glMatrixFrustumEXT GLEW_GET_FUN(__glewMatrixFrustumEXT) #define glMatrixLoadIdentityEXT GLEW_GET_FUN(__glewMatrixLoadIdentityEXT) #define glMatrixLoadTransposedEXT GLEW_GET_FUN(__glewMatrixLoadTransposedEXT) #define glMatrixLoadTransposefEXT GLEW_GET_FUN(__glewMatrixLoadTransposefEXT) #define glMatrixLoaddEXT GLEW_GET_FUN(__glewMatrixLoaddEXT) #define glMatrixLoadfEXT GLEW_GET_FUN(__glewMatrixLoadfEXT) #define glMatrixMultTransposedEXT GLEW_GET_FUN(__glewMatrixMultTransposedEXT) #define glMatrixMultTransposefEXT GLEW_GET_FUN(__glewMatrixMultTransposefEXT) #define glMatrixMultdEXT GLEW_GET_FUN(__glewMatrixMultdEXT) #define glMatrixMultfEXT GLEW_GET_FUN(__glewMatrixMultfEXT) #define glMatrixOrthoEXT GLEW_GET_FUN(__glewMatrixOrthoEXT) #define glMatrixPopEXT GLEW_GET_FUN(__glewMatrixPopEXT) #define glMatrixPushEXT GLEW_GET_FUN(__glewMatrixPushEXT) #define glMatrixRotatedEXT GLEW_GET_FUN(__glewMatrixRotatedEXT) #define glMatrixRotatefEXT GLEW_GET_FUN(__glewMatrixRotatefEXT) #define glMatrixScaledEXT GLEW_GET_FUN(__glewMatrixScaledEXT) #define glMatrixScalefEXT GLEW_GET_FUN(__glewMatrixScalefEXT) #define glMatrixTranslatedEXT GLEW_GET_FUN(__glewMatrixTranslatedEXT) #define glMatrixTranslatefEXT GLEW_GET_FUN(__glewMatrixTranslatefEXT) #define glMultiTexBufferEXT GLEW_GET_FUN(__glewMultiTexBufferEXT) #define glMultiTexCoordPointerEXT GLEW_GET_FUN(__glewMultiTexCoordPointerEXT) #define glMultiTexEnvfEXT GLEW_GET_FUN(__glewMultiTexEnvfEXT) #define glMultiTexEnvfvEXT GLEW_GET_FUN(__glewMultiTexEnvfvEXT) #define glMultiTexEnviEXT GLEW_GET_FUN(__glewMultiTexEnviEXT) #define glMultiTexEnvivEXT GLEW_GET_FUN(__glewMultiTexEnvivEXT) #define glMultiTexGendEXT GLEW_GET_FUN(__glewMultiTexGendEXT) #define glMultiTexGendvEXT GLEW_GET_FUN(__glewMultiTexGendvEXT) #define glMultiTexGenfEXT GLEW_GET_FUN(__glewMultiTexGenfEXT) #define glMultiTexGenfvEXT GLEW_GET_FUN(__glewMultiTexGenfvEXT) #define glMultiTexGeniEXT GLEW_GET_FUN(__glewMultiTexGeniEXT) #define glMultiTexGenivEXT GLEW_GET_FUN(__glewMultiTexGenivEXT) #define glMultiTexImage1DEXT GLEW_GET_FUN(__glewMultiTexImage1DEXT) #define glMultiTexImage2DEXT GLEW_GET_FUN(__glewMultiTexImage2DEXT) #define glMultiTexImage3DEXT GLEW_GET_FUN(__glewMultiTexImage3DEXT) #define glMultiTexParameterIivEXT GLEW_GET_FUN(__glewMultiTexParameterIivEXT) #define glMultiTexParameterIuivEXT GLEW_GET_FUN(__glewMultiTexParameterIuivEXT) #define glMultiTexParameterfEXT GLEW_GET_FUN(__glewMultiTexParameterfEXT) #define glMultiTexParameterfvEXT GLEW_GET_FUN(__glewMultiTexParameterfvEXT) #define glMultiTexParameteriEXT GLEW_GET_FUN(__glewMultiTexParameteriEXT) #define glMultiTexParameterivEXT GLEW_GET_FUN(__glewMultiTexParameterivEXT) #define glMultiTexRenderbufferEXT GLEW_GET_FUN(__glewMultiTexRenderbufferEXT) #define glMultiTexSubImage1DEXT GLEW_GET_FUN(__glewMultiTexSubImage1DEXT) #define glMultiTexSubImage2DEXT GLEW_GET_FUN(__glewMultiTexSubImage2DEXT) #define glMultiTexSubImage3DEXT GLEW_GET_FUN(__glewMultiTexSubImage3DEXT) #define glNamedBufferDataEXT GLEW_GET_FUN(__glewNamedBufferDataEXT) #define glNamedBufferSubDataEXT GLEW_GET_FUN(__glewNamedBufferSubDataEXT) #define glNamedCopyBufferSubDataEXT GLEW_GET_FUN(__glewNamedCopyBufferSubDataEXT) #define glNamedFramebufferRenderbufferEXT GLEW_GET_FUN(__glewNamedFramebufferRenderbufferEXT) #define glNamedFramebufferTexture1DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture1DEXT) #define glNamedFramebufferTexture2DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture2DEXT) #define glNamedFramebufferTexture3DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture3DEXT) #define glNamedFramebufferTextureEXT GLEW_GET_FUN(__glewNamedFramebufferTextureEXT) #define glNamedFramebufferTextureFaceEXT GLEW_GET_FUN(__glewNamedFramebufferTextureFaceEXT) #define glNamedFramebufferTextureLayerEXT GLEW_GET_FUN(__glewNamedFramebufferTextureLayerEXT) #define glNamedProgramLocalParameter4dEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4dEXT) #define glNamedProgramLocalParameter4dvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4dvEXT) #define glNamedProgramLocalParameter4fEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4fEXT) #define glNamedProgramLocalParameter4fvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4fvEXT) #define glNamedProgramLocalParameterI4iEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4iEXT) #define glNamedProgramLocalParameterI4ivEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4ivEXT) #define glNamedProgramLocalParameterI4uiEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4uiEXT) #define glNamedProgramLocalParameterI4uivEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4uivEXT) #define glNamedProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameters4fvEXT) #define glNamedProgramLocalParametersI4ivEXT GLEW_GET_FUN(__glewNamedProgramLocalParametersI4ivEXT) #define glNamedProgramLocalParametersI4uivEXT GLEW_GET_FUN(__glewNamedProgramLocalParametersI4uivEXT) #define glNamedProgramStringEXT GLEW_GET_FUN(__glewNamedProgramStringEXT) #define glNamedRenderbufferStorageEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageEXT) #define glNamedRenderbufferStorageMultisampleCoverageEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisampleCoverageEXT) #define glNamedRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisampleEXT) #define glProgramUniform1fEXT GLEW_GET_FUN(__glewProgramUniform1fEXT) #define glProgramUniform1fvEXT GLEW_GET_FUN(__glewProgramUniform1fvEXT) #define glProgramUniform1iEXT GLEW_GET_FUN(__glewProgramUniform1iEXT) #define glProgramUniform1ivEXT GLEW_GET_FUN(__glewProgramUniform1ivEXT) #define glProgramUniform1uiEXT GLEW_GET_FUN(__glewProgramUniform1uiEXT) #define glProgramUniform1uivEXT GLEW_GET_FUN(__glewProgramUniform1uivEXT) #define glProgramUniform2fEXT GLEW_GET_FUN(__glewProgramUniform2fEXT) #define glProgramUniform2fvEXT GLEW_GET_FUN(__glewProgramUniform2fvEXT) #define glProgramUniform2iEXT GLEW_GET_FUN(__glewProgramUniform2iEXT) #define glProgramUniform2ivEXT GLEW_GET_FUN(__glewProgramUniform2ivEXT) #define glProgramUniform2uiEXT GLEW_GET_FUN(__glewProgramUniform2uiEXT) #define glProgramUniform2uivEXT GLEW_GET_FUN(__glewProgramUniform2uivEXT) #define glProgramUniform3fEXT GLEW_GET_FUN(__glewProgramUniform3fEXT) #define glProgramUniform3fvEXT GLEW_GET_FUN(__glewProgramUniform3fvEXT) #define glProgramUniform3iEXT GLEW_GET_FUN(__glewProgramUniform3iEXT) #define glProgramUniform3ivEXT GLEW_GET_FUN(__glewProgramUniform3ivEXT) #define glProgramUniform3uiEXT GLEW_GET_FUN(__glewProgramUniform3uiEXT) #define glProgramUniform3uivEXT GLEW_GET_FUN(__glewProgramUniform3uivEXT) #define glProgramUniform4fEXT GLEW_GET_FUN(__glewProgramUniform4fEXT) #define glProgramUniform4fvEXT GLEW_GET_FUN(__glewProgramUniform4fvEXT) #define glProgramUniform4iEXT GLEW_GET_FUN(__glewProgramUniform4iEXT) #define glProgramUniform4ivEXT GLEW_GET_FUN(__glewProgramUniform4ivEXT) #define glProgramUniform4uiEXT GLEW_GET_FUN(__glewProgramUniform4uiEXT) #define glProgramUniform4uivEXT GLEW_GET_FUN(__glewProgramUniform4uivEXT) #define glProgramUniformMatrix2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2fvEXT) #define glProgramUniformMatrix2x3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x3fvEXT) #define glProgramUniformMatrix2x4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x4fvEXT) #define glProgramUniformMatrix3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3fvEXT) #define glProgramUniformMatrix3x2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x2fvEXT) #define glProgramUniformMatrix3x4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x4fvEXT) #define glProgramUniformMatrix4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4fvEXT) #define glProgramUniformMatrix4x2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x2fvEXT) #define glProgramUniformMatrix4x3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x3fvEXT) #define glPushClientAttribDefaultEXT GLEW_GET_FUN(__glewPushClientAttribDefaultEXT) #define glTextureBufferEXT GLEW_GET_FUN(__glewTextureBufferEXT) #define glTextureImage1DEXT GLEW_GET_FUN(__glewTextureImage1DEXT) #define glTextureImage2DEXT GLEW_GET_FUN(__glewTextureImage2DEXT) #define glTextureImage3DEXT GLEW_GET_FUN(__glewTextureImage3DEXT) #define glTextureParameterIivEXT GLEW_GET_FUN(__glewTextureParameterIivEXT) #define glTextureParameterIuivEXT GLEW_GET_FUN(__glewTextureParameterIuivEXT) #define glTextureParameterfEXT GLEW_GET_FUN(__glewTextureParameterfEXT) #define glTextureParameterfvEXT GLEW_GET_FUN(__glewTextureParameterfvEXT) #define glTextureParameteriEXT GLEW_GET_FUN(__glewTextureParameteriEXT) #define glTextureParameterivEXT GLEW_GET_FUN(__glewTextureParameterivEXT) #define glTextureRenderbufferEXT GLEW_GET_FUN(__glewTextureRenderbufferEXT) #define glTextureSubImage1DEXT GLEW_GET_FUN(__glewTextureSubImage1DEXT) #define glTextureSubImage2DEXT GLEW_GET_FUN(__glewTextureSubImage2DEXT) #define glTextureSubImage3DEXT GLEW_GET_FUN(__glewTextureSubImage3DEXT) #define glUnmapNamedBufferEXT GLEW_GET_FUN(__glewUnmapNamedBufferEXT) #define glVertexArrayColorOffsetEXT GLEW_GET_FUN(__glewVertexArrayColorOffsetEXT) #define glVertexArrayEdgeFlagOffsetEXT GLEW_GET_FUN(__glewVertexArrayEdgeFlagOffsetEXT) #define glVertexArrayFogCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayFogCoordOffsetEXT) #define glVertexArrayIndexOffsetEXT GLEW_GET_FUN(__glewVertexArrayIndexOffsetEXT) #define glVertexArrayMultiTexCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayMultiTexCoordOffsetEXT) #define glVertexArrayNormalOffsetEXT GLEW_GET_FUN(__glewVertexArrayNormalOffsetEXT) #define glVertexArraySecondaryColorOffsetEXT GLEW_GET_FUN(__glewVertexArraySecondaryColorOffsetEXT) #define glVertexArrayTexCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayTexCoordOffsetEXT) #define glVertexArrayVertexAttribDivisorEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribDivisorEXT) #define glVertexArrayVertexAttribIOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribIOffsetEXT) #define glVertexArrayVertexAttribOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribOffsetEXT) #define glVertexArrayVertexOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexOffsetEXT) #define GLEW_EXT_direct_state_access GLEW_GET_VAR(__GLEW_EXT_direct_state_access) #endif /* GL_EXT_direct_state_access */ /* -------------------------- GL_EXT_draw_buffers2 ------------------------- */ #ifndef GL_EXT_draw_buffers2 #define GL_EXT_draw_buffers2 1 typedef void (GLAPIENTRY * PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint buf, GLboolean r, GLboolean g, GLboolean b, GLboolean a); typedef void (GLAPIENTRY * PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); typedef void (GLAPIENTRY * PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); typedef void (GLAPIENTRY * PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum value, GLuint index, GLboolean* data); typedef void (GLAPIENTRY * PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum value, GLuint index, GLint* data); typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); #define glColorMaskIndexedEXT GLEW_GET_FUN(__glewColorMaskIndexedEXT) #define glDisableIndexedEXT GLEW_GET_FUN(__glewDisableIndexedEXT) #define glEnableIndexedEXT GLEW_GET_FUN(__glewEnableIndexedEXT) #define glGetBooleanIndexedvEXT GLEW_GET_FUN(__glewGetBooleanIndexedvEXT) #define glGetIntegerIndexedvEXT GLEW_GET_FUN(__glewGetIntegerIndexedvEXT) #define glIsEnabledIndexedEXT GLEW_GET_FUN(__glewIsEnabledIndexedEXT) #define GLEW_EXT_draw_buffers2 GLEW_GET_VAR(__GLEW_EXT_draw_buffers2) #endif /* GL_EXT_draw_buffers2 */ /* ------------------------- GL_EXT_draw_instanced ------------------------- */ #ifndef GL_EXT_draw_instanced #define GL_EXT_draw_instanced 1 typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); #define glDrawArraysInstancedEXT GLEW_GET_FUN(__glewDrawArraysInstancedEXT) #define glDrawElementsInstancedEXT GLEW_GET_FUN(__glewDrawElementsInstancedEXT) #define GLEW_EXT_draw_instanced GLEW_GET_VAR(__GLEW_EXT_draw_instanced) #endif /* GL_EXT_draw_instanced */ /* ----------------------- GL_EXT_draw_range_elements ---------------------- */ #ifndef GL_EXT_draw_range_elements #define GL_EXT_draw_range_elements 1 #define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 #define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); #define glDrawRangeElementsEXT GLEW_GET_FUN(__glewDrawRangeElementsEXT) #define GLEW_EXT_draw_range_elements GLEW_GET_VAR(__GLEW_EXT_draw_range_elements) #endif /* GL_EXT_draw_range_elements */ /* ---------------------------- GL_EXT_fog_coord --------------------------- */ #ifndef GL_EXT_fog_coord #define GL_EXT_fog_coord 1 #define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 #define GL_FOG_COORDINATE_EXT 0x8451 #define GL_FRAGMENT_DEPTH_EXT 0x8452 #define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 #define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 #define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 #define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 #define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); typedef void (GLAPIENTRY * PFNGLFOGCOORDDEXTPROC) (GLdouble coord); typedef void (GLAPIENTRY * PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); typedef void (GLAPIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord); typedef void (GLAPIENTRY * PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); #define glFogCoordPointerEXT GLEW_GET_FUN(__glewFogCoordPointerEXT) #define glFogCoorddEXT GLEW_GET_FUN(__glewFogCoorddEXT) #define glFogCoorddvEXT GLEW_GET_FUN(__glewFogCoorddvEXT) #define glFogCoordfEXT GLEW_GET_FUN(__glewFogCoordfEXT) #define glFogCoordfvEXT GLEW_GET_FUN(__glewFogCoordfvEXT) #define GLEW_EXT_fog_coord GLEW_GET_VAR(__GLEW_EXT_fog_coord) #endif /* GL_EXT_fog_coord */ /* ------------------------ GL_EXT_fragment_lighting ----------------------- */ #ifndef GL_EXT_fragment_lighting #define GL_EXT_fragment_lighting 1 #define GL_FRAGMENT_LIGHTING_EXT 0x8400 #define GL_FRAGMENT_COLOR_MATERIAL_EXT 0x8401 #define GL_FRAGMENT_COLOR_MATERIAL_FACE_EXT 0x8402 #define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_EXT 0x8403 #define GL_MAX_FRAGMENT_LIGHTS_EXT 0x8404 #define GL_MAX_ACTIVE_LIGHTS_EXT 0x8405 #define GL_CURRENT_RASTER_NORMAL_EXT 0x8406 #define GL_LIGHT_ENV_MODE_EXT 0x8407 #define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_EXT 0x8408 #define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_EXT 0x8409 #define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_EXT 0x840A #define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_EXT 0x840B #define GL_FRAGMENT_LIGHT0_EXT 0x840C #define GL_FRAGMENT_LIGHT7_EXT 0x8413 typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALEXTPROC) (GLenum face, GLenum mode); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFEXTPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVEXTPROC) (GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIEXTPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVEXTPROC) (GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFEXTPROC) (GLenum light, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIEXTPROC) (GLenum light, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFEXTPROC) (GLenum face, GLenum pname, const GLfloat param); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIEXTPROC) (GLenum face, GLenum pname, const GLint param); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLLIGHTENVIEXTPROC) (GLenum pname, GLint param); #define glFragmentColorMaterialEXT GLEW_GET_FUN(__glewFragmentColorMaterialEXT) #define glFragmentLightModelfEXT GLEW_GET_FUN(__glewFragmentLightModelfEXT) #define glFragmentLightModelfvEXT GLEW_GET_FUN(__glewFragmentLightModelfvEXT) #define glFragmentLightModeliEXT GLEW_GET_FUN(__glewFragmentLightModeliEXT) #define glFragmentLightModelivEXT GLEW_GET_FUN(__glewFragmentLightModelivEXT) #define glFragmentLightfEXT GLEW_GET_FUN(__glewFragmentLightfEXT) #define glFragmentLightfvEXT GLEW_GET_FUN(__glewFragmentLightfvEXT) #define glFragmentLightiEXT GLEW_GET_FUN(__glewFragmentLightiEXT) #define glFragmentLightivEXT GLEW_GET_FUN(__glewFragmentLightivEXT) #define glFragmentMaterialfEXT GLEW_GET_FUN(__glewFragmentMaterialfEXT) #define glFragmentMaterialfvEXT GLEW_GET_FUN(__glewFragmentMaterialfvEXT) #define glFragmentMaterialiEXT GLEW_GET_FUN(__glewFragmentMaterialiEXT) #define glFragmentMaterialivEXT GLEW_GET_FUN(__glewFragmentMaterialivEXT) #define glGetFragmentLightfvEXT GLEW_GET_FUN(__glewGetFragmentLightfvEXT) #define glGetFragmentLightivEXT GLEW_GET_FUN(__glewGetFragmentLightivEXT) #define glGetFragmentMaterialfvEXT GLEW_GET_FUN(__glewGetFragmentMaterialfvEXT) #define glGetFragmentMaterialivEXT GLEW_GET_FUN(__glewGetFragmentMaterialivEXT) #define glLightEnviEXT GLEW_GET_FUN(__glewLightEnviEXT) #define GLEW_EXT_fragment_lighting GLEW_GET_VAR(__GLEW_EXT_fragment_lighting) #endif /* GL_EXT_fragment_lighting */ /* ------------------------ GL_EXT_framebuffer_blit ------------------------ */ #ifndef GL_EXT_framebuffer_blit #define GL_EXT_framebuffer_blit 1 #define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 #define GL_READ_FRAMEBUFFER_EXT 0x8CA8 #define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 #define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #define glBlitFramebufferEXT GLEW_GET_FUN(__glewBlitFramebufferEXT) #define GLEW_EXT_framebuffer_blit GLEW_GET_VAR(__GLEW_EXT_framebuffer_blit) #endif /* GL_EXT_framebuffer_blit */ /* --------------------- GL_EXT_framebuffer_multisample -------------------- */ #ifndef GL_EXT_framebuffer_multisample #define GL_EXT_framebuffer_multisample 1 #define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 #define GL_MAX_SAMPLES_EXT 0x8D57 typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #define glRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewRenderbufferStorageMultisampleEXT) #define GLEW_EXT_framebuffer_multisample GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample) #endif /* GL_EXT_framebuffer_multisample */ /* --------------- GL_EXT_framebuffer_multisample_blit_scaled -------------- */ #ifndef GL_EXT_framebuffer_multisample_blit_scaled #define GL_EXT_framebuffer_multisample_blit_scaled 1 #define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA #define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB #define GLEW_EXT_framebuffer_multisample_blit_scaled GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample_blit_scaled) #endif /* GL_EXT_framebuffer_multisample_blit_scaled */ /* ----------------------- GL_EXT_framebuffer_object ----------------------- */ #ifndef GL_EXT_framebuffer_object #define GL_EXT_framebuffer_object 1 #define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 #define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 #define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 #define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 #define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 #define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 #define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 #define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 #define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA #define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB #define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC #define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD #define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF #define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 #define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 #define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 #define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 #define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 #define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 #define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 #define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 #define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 #define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 #define GL_COLOR_ATTACHMENT10_EXT 0x8CEA #define GL_COLOR_ATTACHMENT11_EXT 0x8CEB #define GL_COLOR_ATTACHMENT12_EXT 0x8CEC #define GL_COLOR_ATTACHMENT13_EXT 0x8CED #define GL_COLOR_ATTACHMENT14_EXT 0x8CEE #define GL_COLOR_ATTACHMENT15_EXT 0x8CEF #define GL_DEPTH_ATTACHMENT_EXT 0x8D00 #define GL_STENCIL_ATTACHMENT_EXT 0x8D20 #define GL_FRAMEBUFFER_EXT 0x8D40 #define GL_RENDERBUFFER_EXT 0x8D41 #define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 #define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 #define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 #define GL_STENCIL_INDEX1_EXT 0x8D46 #define GL_STENCIL_INDEX4_EXT 0x8D47 #define GL_STENCIL_INDEX8_EXT 0x8D48 #define GL_STENCIL_INDEX16_EXT 0x8D49 #define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 #define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 #define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 #define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 #define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 #define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint* framebuffers); typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint* renderbuffers); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint* framebuffers); typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint* renderbuffers); typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); #define glBindFramebufferEXT GLEW_GET_FUN(__glewBindFramebufferEXT) #define glBindRenderbufferEXT GLEW_GET_FUN(__glewBindRenderbufferEXT) #define glCheckFramebufferStatusEXT GLEW_GET_FUN(__glewCheckFramebufferStatusEXT) #define glDeleteFramebuffersEXT GLEW_GET_FUN(__glewDeleteFramebuffersEXT) #define glDeleteRenderbuffersEXT GLEW_GET_FUN(__glewDeleteRenderbuffersEXT) #define glFramebufferRenderbufferEXT GLEW_GET_FUN(__glewFramebufferRenderbufferEXT) #define glFramebufferTexture1DEXT GLEW_GET_FUN(__glewFramebufferTexture1DEXT) #define glFramebufferTexture2DEXT GLEW_GET_FUN(__glewFramebufferTexture2DEXT) #define glFramebufferTexture3DEXT GLEW_GET_FUN(__glewFramebufferTexture3DEXT) #define glGenFramebuffersEXT GLEW_GET_FUN(__glewGenFramebuffersEXT) #define glGenRenderbuffersEXT GLEW_GET_FUN(__glewGenRenderbuffersEXT) #define glGenerateMipmapEXT GLEW_GET_FUN(__glewGenerateMipmapEXT) #define glGetFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetFramebufferAttachmentParameterivEXT) #define glGetRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetRenderbufferParameterivEXT) #define glIsFramebufferEXT GLEW_GET_FUN(__glewIsFramebufferEXT) #define glIsRenderbufferEXT GLEW_GET_FUN(__glewIsRenderbufferEXT) #define glRenderbufferStorageEXT GLEW_GET_FUN(__glewRenderbufferStorageEXT) #define GLEW_EXT_framebuffer_object GLEW_GET_VAR(__GLEW_EXT_framebuffer_object) #endif /* GL_EXT_framebuffer_object */ /* ------------------------ GL_EXT_framebuffer_sRGB ------------------------ */ #ifndef GL_EXT_framebuffer_sRGB #define GL_EXT_framebuffer_sRGB 1 #define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 #define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA #define GLEW_EXT_framebuffer_sRGB GLEW_GET_VAR(__GLEW_EXT_framebuffer_sRGB) #endif /* GL_EXT_framebuffer_sRGB */ /* ------------------------ GL_EXT_geometry_shader4 ------------------------ */ #ifndef GL_EXT_geometry_shader4 #define GL_EXT_geometry_shader4 1 #define GL_LINES_ADJACENCY_EXT 0xA #define GL_LINE_STRIP_ADJACENCY_EXT 0xB #define GL_TRIANGLES_ADJACENCY_EXT 0xC #define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD #define GL_PROGRAM_POINT_SIZE_EXT 0x8642 #define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B #define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 #define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 #define GL_GEOMETRY_SHADER_EXT 0x8DD9 #define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA #define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB #define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC #define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD #define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE #define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF #define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 #define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); #define glFramebufferTextureEXT GLEW_GET_FUN(__glewFramebufferTextureEXT) #define glFramebufferTextureFaceEXT GLEW_GET_FUN(__glewFramebufferTextureFaceEXT) #define glProgramParameteriEXT GLEW_GET_FUN(__glewProgramParameteriEXT) #define GLEW_EXT_geometry_shader4 GLEW_GET_VAR(__GLEW_EXT_geometry_shader4) #endif /* GL_EXT_geometry_shader4 */ /* --------------------- GL_EXT_gpu_program_parameters --------------------- */ #ifndef GL_EXT_gpu_program_parameters #define GL_EXT_gpu_program_parameters 1 typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); #define glProgramEnvParameters4fvEXT GLEW_GET_FUN(__glewProgramEnvParameters4fvEXT) #define glProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewProgramLocalParameters4fvEXT) #define GLEW_EXT_gpu_program_parameters GLEW_GET_VAR(__GLEW_EXT_gpu_program_parameters) #endif /* GL_EXT_gpu_program_parameters */ /* --------------------------- GL_EXT_gpu_shader4 -------------------------- */ #ifndef GL_EXT_gpu_shader4 #define GL_EXT_gpu_shader4 1 #define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD #define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 #define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 #define GL_SAMPLER_BUFFER_EXT 0x8DC2 #define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 #define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 #define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 #define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 #define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 #define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 #define GL_INT_SAMPLER_1D_EXT 0x8DC9 #define GL_INT_SAMPLER_2D_EXT 0x8DCA #define GL_INT_SAMPLER_3D_EXT 0x8DCB #define GL_INT_SAMPLER_CUBE_EXT 0x8DCC #define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD #define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE #define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF #define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 #define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 #define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 #define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 #define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 #define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 #define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 #define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 #define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); typedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); typedef void (GLAPIENTRY * PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (GLAPIENTRY * PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); typedef void (GLAPIENTRY * PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (GLAPIENTRY * PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); typedef void (GLAPIENTRY * PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (GLAPIENTRY * PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); typedef void (GLAPIENTRY * PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); #define glBindFragDataLocationEXT GLEW_GET_FUN(__glewBindFragDataLocationEXT) #define glGetFragDataLocationEXT GLEW_GET_FUN(__glewGetFragDataLocationEXT) #define glGetUniformuivEXT GLEW_GET_FUN(__glewGetUniformuivEXT) #define glGetVertexAttribIivEXT GLEW_GET_FUN(__glewGetVertexAttribIivEXT) #define glGetVertexAttribIuivEXT GLEW_GET_FUN(__glewGetVertexAttribIuivEXT) #define glUniform1uiEXT GLEW_GET_FUN(__glewUniform1uiEXT) #define glUniform1uivEXT GLEW_GET_FUN(__glewUniform1uivEXT) #define glUniform2uiEXT GLEW_GET_FUN(__glewUniform2uiEXT) #define glUniform2uivEXT GLEW_GET_FUN(__glewUniform2uivEXT) #define glUniform3uiEXT GLEW_GET_FUN(__glewUniform3uiEXT) #define glUniform3uivEXT GLEW_GET_FUN(__glewUniform3uivEXT) #define glUniform4uiEXT GLEW_GET_FUN(__glewUniform4uiEXT) #define glUniform4uivEXT GLEW_GET_FUN(__glewUniform4uivEXT) #define glVertexAttribI1iEXT GLEW_GET_FUN(__glewVertexAttribI1iEXT) #define glVertexAttribI1ivEXT GLEW_GET_FUN(__glewVertexAttribI1ivEXT) #define glVertexAttribI1uiEXT GLEW_GET_FUN(__glewVertexAttribI1uiEXT) #define glVertexAttribI1uivEXT GLEW_GET_FUN(__glewVertexAttribI1uivEXT) #define glVertexAttribI2iEXT GLEW_GET_FUN(__glewVertexAttribI2iEXT) #define glVertexAttribI2ivEXT GLEW_GET_FUN(__glewVertexAttribI2ivEXT) #define glVertexAttribI2uiEXT GLEW_GET_FUN(__glewVertexAttribI2uiEXT) #define glVertexAttribI2uivEXT GLEW_GET_FUN(__glewVertexAttribI2uivEXT) #define glVertexAttribI3iEXT GLEW_GET_FUN(__glewVertexAttribI3iEXT) #define glVertexAttribI3ivEXT GLEW_GET_FUN(__glewVertexAttribI3ivEXT) #define glVertexAttribI3uiEXT GLEW_GET_FUN(__glewVertexAttribI3uiEXT) #define glVertexAttribI3uivEXT GLEW_GET_FUN(__glewVertexAttribI3uivEXT) #define glVertexAttribI4bvEXT GLEW_GET_FUN(__glewVertexAttribI4bvEXT) #define glVertexAttribI4iEXT GLEW_GET_FUN(__glewVertexAttribI4iEXT) #define glVertexAttribI4ivEXT GLEW_GET_FUN(__glewVertexAttribI4ivEXT) #define glVertexAttribI4svEXT GLEW_GET_FUN(__glewVertexAttribI4svEXT) #define glVertexAttribI4ubvEXT GLEW_GET_FUN(__glewVertexAttribI4ubvEXT) #define glVertexAttribI4uiEXT GLEW_GET_FUN(__glewVertexAttribI4uiEXT) #define glVertexAttribI4uivEXT GLEW_GET_FUN(__glewVertexAttribI4uivEXT) #define glVertexAttribI4usvEXT GLEW_GET_FUN(__glewVertexAttribI4usvEXT) #define glVertexAttribIPointerEXT GLEW_GET_FUN(__glewVertexAttribIPointerEXT) #define GLEW_EXT_gpu_shader4 GLEW_GET_VAR(__GLEW_EXT_gpu_shader4) #endif /* GL_EXT_gpu_shader4 */ /* ---------------------------- GL_EXT_histogram --------------------------- */ #ifndef GL_EXT_histogram #define GL_EXT_histogram 1 #define GL_HISTOGRAM_EXT 0x8024 #define GL_PROXY_HISTOGRAM_EXT 0x8025 #define GL_HISTOGRAM_WIDTH_EXT 0x8026 #define GL_HISTOGRAM_FORMAT_EXT 0x8027 #define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 #define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 #define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A #define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B #define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C #define GL_HISTOGRAM_SINK_EXT 0x802D #define GL_MINMAX_EXT 0x802E #define GL_MINMAX_FORMAT_EXT 0x802F #define GL_MINMAX_SINK_EXT 0x8030 typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); typedef void (GLAPIENTRY * PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLRESETMINMAXEXTPROC) (GLenum target); #define glGetHistogramEXT GLEW_GET_FUN(__glewGetHistogramEXT) #define glGetHistogramParameterfvEXT GLEW_GET_FUN(__glewGetHistogramParameterfvEXT) #define glGetHistogramParameterivEXT GLEW_GET_FUN(__glewGetHistogramParameterivEXT) #define glGetMinmaxEXT GLEW_GET_FUN(__glewGetMinmaxEXT) #define glGetMinmaxParameterfvEXT GLEW_GET_FUN(__glewGetMinmaxParameterfvEXT) #define glGetMinmaxParameterivEXT GLEW_GET_FUN(__glewGetMinmaxParameterivEXT) #define glHistogramEXT GLEW_GET_FUN(__glewHistogramEXT) #define glMinmaxEXT GLEW_GET_FUN(__glewMinmaxEXT) #define glResetHistogramEXT GLEW_GET_FUN(__glewResetHistogramEXT) #define glResetMinmaxEXT GLEW_GET_FUN(__glewResetMinmaxEXT) #define GLEW_EXT_histogram GLEW_GET_VAR(__GLEW_EXT_histogram) #endif /* GL_EXT_histogram */ /* ----------------------- GL_EXT_index_array_formats ---------------------- */ #ifndef GL_EXT_index_array_formats #define GL_EXT_index_array_formats 1 #define GLEW_EXT_index_array_formats GLEW_GET_VAR(__GLEW_EXT_index_array_formats) #endif /* GL_EXT_index_array_formats */ /* --------------------------- GL_EXT_index_func --------------------------- */ #ifndef GL_EXT_index_func #define GL_EXT_index_func 1 typedef void (GLAPIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLfloat ref); #define glIndexFuncEXT GLEW_GET_FUN(__glewIndexFuncEXT) #define GLEW_EXT_index_func GLEW_GET_VAR(__GLEW_EXT_index_func) #endif /* GL_EXT_index_func */ /* ------------------------- GL_EXT_index_material ------------------------- */ #ifndef GL_EXT_index_material #define GL_EXT_index_material 1 typedef void (GLAPIENTRY * PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); #define glIndexMaterialEXT GLEW_GET_FUN(__glewIndexMaterialEXT) #define GLEW_EXT_index_material GLEW_GET_VAR(__GLEW_EXT_index_material) #endif /* GL_EXT_index_material */ /* -------------------------- GL_EXT_index_texture ------------------------- */ #ifndef GL_EXT_index_texture #define GL_EXT_index_texture 1 #define GLEW_EXT_index_texture GLEW_GET_VAR(__GLEW_EXT_index_texture) #endif /* GL_EXT_index_texture */ /* -------------------------- GL_EXT_light_texture ------------------------- */ #ifndef GL_EXT_light_texture #define GL_EXT_light_texture 1 #define GL_FRAGMENT_MATERIAL_EXT 0x8349 #define GL_FRAGMENT_NORMAL_EXT 0x834A #define GL_FRAGMENT_COLOR_EXT 0x834C #define GL_ATTENUATION_EXT 0x834D #define GL_SHADOW_ATTENUATION_EXT 0x834E #define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F #define GL_TEXTURE_LIGHT_EXT 0x8350 #define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 #define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 typedef void (GLAPIENTRY * PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); typedef void (GLAPIENTRY * PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); typedef void (GLAPIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); #define glApplyTextureEXT GLEW_GET_FUN(__glewApplyTextureEXT) #define glTextureLightEXT GLEW_GET_FUN(__glewTextureLightEXT) #define glTextureMaterialEXT GLEW_GET_FUN(__glewTextureMaterialEXT) #define GLEW_EXT_light_texture GLEW_GET_VAR(__GLEW_EXT_light_texture) #endif /* GL_EXT_light_texture */ /* ------------------------- GL_EXT_misc_attribute ------------------------- */ #ifndef GL_EXT_misc_attribute #define GL_EXT_misc_attribute 1 #define GLEW_EXT_misc_attribute GLEW_GET_VAR(__GLEW_EXT_misc_attribute) #endif /* GL_EXT_misc_attribute */ /* ------------------------ GL_EXT_multi_draw_arrays ----------------------- */ #ifndef GL_EXT_multi_draw_arrays #define GL_EXT_multi_draw_arrays 1 typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, GLsizei* count, GLenum type, const void *const *indices, GLsizei primcount); #define glMultiDrawArraysEXT GLEW_GET_FUN(__glewMultiDrawArraysEXT) #define glMultiDrawElementsEXT GLEW_GET_FUN(__glewMultiDrawElementsEXT) #define GLEW_EXT_multi_draw_arrays GLEW_GET_VAR(__GLEW_EXT_multi_draw_arrays) #endif /* GL_EXT_multi_draw_arrays */ /* --------------------------- GL_EXT_multisample -------------------------- */ #ifndef GL_EXT_multisample #define GL_EXT_multisample 1 #define GL_MULTISAMPLE_EXT 0x809D #define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E #define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F #define GL_SAMPLE_MASK_EXT 0x80A0 #define GL_1PASS_EXT 0x80A1 #define GL_2PASS_0_EXT 0x80A2 #define GL_2PASS_1_EXT 0x80A3 #define GL_4PASS_0_EXT 0x80A4 #define GL_4PASS_1_EXT 0x80A5 #define GL_4PASS_2_EXT 0x80A6 #define GL_4PASS_3_EXT 0x80A7 #define GL_SAMPLE_BUFFERS_EXT 0x80A8 #define GL_SAMPLES_EXT 0x80A9 #define GL_SAMPLE_MASK_VALUE_EXT 0x80AA #define GL_SAMPLE_MASK_INVERT_EXT 0x80AB #define GL_SAMPLE_PATTERN_EXT 0x80AC #define GL_MULTISAMPLE_BIT_EXT 0x20000000 typedef void (GLAPIENTRY * PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); #define glSampleMaskEXT GLEW_GET_FUN(__glewSampleMaskEXT) #define glSamplePatternEXT GLEW_GET_FUN(__glewSamplePatternEXT) #define GLEW_EXT_multisample GLEW_GET_VAR(__GLEW_EXT_multisample) #endif /* GL_EXT_multisample */ /* ---------------------- GL_EXT_packed_depth_stencil ---------------------- */ #ifndef GL_EXT_packed_depth_stencil #define GL_EXT_packed_depth_stencil 1 #define GL_DEPTH_STENCIL_EXT 0x84F9 #define GL_UNSIGNED_INT_24_8_EXT 0x84FA #define GL_DEPTH24_STENCIL8_EXT 0x88F0 #define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 #define GLEW_EXT_packed_depth_stencil GLEW_GET_VAR(__GLEW_EXT_packed_depth_stencil) #endif /* GL_EXT_packed_depth_stencil */ /* -------------------------- GL_EXT_packed_float -------------------------- */ #ifndef GL_EXT_packed_float #define GL_EXT_packed_float 1 #define GL_R11F_G11F_B10F_EXT 0x8C3A #define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B #define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C #define GLEW_EXT_packed_float GLEW_GET_VAR(__GLEW_EXT_packed_float) #endif /* GL_EXT_packed_float */ /* -------------------------- GL_EXT_packed_pixels ------------------------- */ #ifndef GL_EXT_packed_pixels #define GL_EXT_packed_pixels 1 #define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 #define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 #define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 #define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 #define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 #define GLEW_EXT_packed_pixels GLEW_GET_VAR(__GLEW_EXT_packed_pixels) #endif /* GL_EXT_packed_pixels */ /* ------------------------ GL_EXT_paletted_texture ------------------------ */ #ifndef GL_EXT_paletted_texture #define GL_EXT_paletted_texture 1 #define GL_TEXTURE_1D 0x0DE0 #define GL_TEXTURE_2D 0x0DE1 #define GL_PROXY_TEXTURE_1D 0x8063 #define GL_PROXY_TEXTURE_2D 0x8064 #define GL_COLOR_TABLE_FORMAT_EXT 0x80D8 #define GL_COLOR_TABLE_WIDTH_EXT 0x80D9 #define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA #define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB #define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC #define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD #define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE #define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF #define GL_COLOR_INDEX1_EXT 0x80E2 #define GL_COLOR_INDEX2_EXT 0x80E3 #define GL_COLOR_INDEX4_EXT 0x80E4 #define GL_COLOR_INDEX8_EXT 0x80E5 #define GL_COLOR_INDEX12_EXT 0x80E6 #define GL_COLOR_INDEX16_EXT 0x80E7 #define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED #define GL_TEXTURE_CUBE_MAP_ARB 0x8513 #define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B typedef void (GLAPIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *data); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); #define glColorTableEXT GLEW_GET_FUN(__glewColorTableEXT) #define glGetColorTableEXT GLEW_GET_FUN(__glewGetColorTableEXT) #define glGetColorTableParameterfvEXT GLEW_GET_FUN(__glewGetColorTableParameterfvEXT) #define glGetColorTableParameterivEXT GLEW_GET_FUN(__glewGetColorTableParameterivEXT) #define GLEW_EXT_paletted_texture GLEW_GET_VAR(__GLEW_EXT_paletted_texture) #endif /* GL_EXT_paletted_texture */ /* ----------------------- GL_EXT_pixel_buffer_object ---------------------- */ #ifndef GL_EXT_pixel_buffer_object #define GL_EXT_pixel_buffer_object 1 #define GL_PIXEL_PACK_BUFFER_EXT 0x88EB #define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC #define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED #define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF #define GLEW_EXT_pixel_buffer_object GLEW_GET_VAR(__GLEW_EXT_pixel_buffer_object) #endif /* GL_EXT_pixel_buffer_object */ /* ------------------------- GL_EXT_pixel_transform ------------------------ */ #ifndef GL_EXT_pixel_transform #define GL_EXT_pixel_transform 1 #define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 #define GL_PIXEL_MAG_FILTER_EXT 0x8331 #define GL_PIXEL_MIN_FILTER_EXT 0x8332 #define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 #define GL_CUBIC_EXT 0x8334 #define GL_AVERAGE_EXT 0x8335 #define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 #define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 #define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, const GLfloat param); typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, const GLint param); typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); #define glGetPixelTransformParameterfvEXT GLEW_GET_FUN(__glewGetPixelTransformParameterfvEXT) #define glGetPixelTransformParameterivEXT GLEW_GET_FUN(__glewGetPixelTransformParameterivEXT) #define glPixelTransformParameterfEXT GLEW_GET_FUN(__glewPixelTransformParameterfEXT) #define glPixelTransformParameterfvEXT GLEW_GET_FUN(__glewPixelTransformParameterfvEXT) #define glPixelTransformParameteriEXT GLEW_GET_FUN(__glewPixelTransformParameteriEXT) #define glPixelTransformParameterivEXT GLEW_GET_FUN(__glewPixelTransformParameterivEXT) #define GLEW_EXT_pixel_transform GLEW_GET_VAR(__GLEW_EXT_pixel_transform) #endif /* GL_EXT_pixel_transform */ /* ------------------- GL_EXT_pixel_transform_color_table ------------------ */ #ifndef GL_EXT_pixel_transform_color_table #define GL_EXT_pixel_transform_color_table 1 #define GLEW_EXT_pixel_transform_color_table GLEW_GET_VAR(__GLEW_EXT_pixel_transform_color_table) #endif /* GL_EXT_pixel_transform_color_table */ /* ------------------------ GL_EXT_point_parameters ------------------------ */ #ifndef GL_EXT_point_parameters #define GL_EXT_point_parameters 1 #define GL_POINT_SIZE_MIN_EXT 0x8126 #define GL_POINT_SIZE_MAX_EXT 0x8127 #define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 #define GL_DISTANCE_ATTENUATION_EXT 0x8129 typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat* params); #define glPointParameterfEXT GLEW_GET_FUN(__glewPointParameterfEXT) #define glPointParameterfvEXT GLEW_GET_FUN(__glewPointParameterfvEXT) #define GLEW_EXT_point_parameters GLEW_GET_VAR(__GLEW_EXT_point_parameters) #endif /* GL_EXT_point_parameters */ /* ------------------------- GL_EXT_polygon_offset ------------------------- */ #ifndef GL_EXT_polygon_offset #define GL_EXT_polygon_offset 1 #define GL_POLYGON_OFFSET_EXT 0x8037 #define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 #define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); #define glPolygonOffsetEXT GLEW_GET_FUN(__glewPolygonOffsetEXT) #define GLEW_EXT_polygon_offset GLEW_GET_VAR(__GLEW_EXT_polygon_offset) #endif /* GL_EXT_polygon_offset */ /* ---------------------- GL_EXT_polygon_offset_clamp ---------------------- */ #ifndef GL_EXT_polygon_offset_clamp #define GL_EXT_polygon_offset_clamp 1 #define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); #define glPolygonOffsetClampEXT GLEW_GET_FUN(__glewPolygonOffsetClampEXT) #define GLEW_EXT_polygon_offset_clamp GLEW_GET_VAR(__GLEW_EXT_polygon_offset_clamp) #endif /* GL_EXT_polygon_offset_clamp */ /* ----------------------- GL_EXT_post_depth_coverage ---------------------- */ #ifndef GL_EXT_post_depth_coverage #define GL_EXT_post_depth_coverage 1 #define GLEW_EXT_post_depth_coverage GLEW_GET_VAR(__GLEW_EXT_post_depth_coverage) #endif /* GL_EXT_post_depth_coverage */ /* ------------------------ GL_EXT_provoking_vertex ------------------------ */ #ifndef GL_EXT_provoking_vertex #define GL_EXT_provoking_vertex 1 #define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C #define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D #define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E #define GL_PROVOKING_VERTEX_EXT 0x8E4F typedef void (GLAPIENTRY * PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); #define glProvokingVertexEXT GLEW_GET_FUN(__glewProvokingVertexEXT) #define GLEW_EXT_provoking_vertex GLEW_GET_VAR(__GLEW_EXT_provoking_vertex) #endif /* GL_EXT_provoking_vertex */ /* ----------------------- GL_EXT_raster_multisample ----------------------- */ #ifndef GL_EXT_raster_multisample #define GL_EXT_raster_multisample 1 #define GL_COLOR_SAMPLES_NV 0x8E20 #define GL_RASTER_MULTISAMPLE_EXT 0x9327 #define GL_RASTER_SAMPLES_EXT 0x9328 #define GL_MAX_RASTER_SAMPLES_EXT 0x9329 #define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A #define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B #define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C #define GL_DEPTH_SAMPLES_NV 0x932D #define GL_STENCIL_SAMPLES_NV 0x932E #define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F #define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 #define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 #define GL_COVERAGE_MODULATION_NV 0x9332 #define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 typedef void (GLAPIENTRY * PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); typedef void (GLAPIENTRY * PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufsize, GLfloat* v); typedef void (GLAPIENTRY * PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); #define glCoverageModulationNV GLEW_GET_FUN(__glewCoverageModulationNV) #define glCoverageModulationTableNV GLEW_GET_FUN(__glewCoverageModulationTableNV) #define glGetCoverageModulationTableNV GLEW_GET_FUN(__glewGetCoverageModulationTableNV) #define glRasterSamplesEXT GLEW_GET_FUN(__glewRasterSamplesEXT) #define GLEW_EXT_raster_multisample GLEW_GET_VAR(__GLEW_EXT_raster_multisample) #endif /* GL_EXT_raster_multisample */ /* ------------------------- GL_EXT_rescale_normal ------------------------- */ #ifndef GL_EXT_rescale_normal #define GL_EXT_rescale_normal 1 #define GL_RESCALE_NORMAL_EXT 0x803A #define GLEW_EXT_rescale_normal GLEW_GET_VAR(__GLEW_EXT_rescale_normal) #endif /* GL_EXT_rescale_normal */ /* -------------------------- GL_EXT_scene_marker -------------------------- */ #ifndef GL_EXT_scene_marker #define GL_EXT_scene_marker 1 typedef void (GLAPIENTRY * PFNGLBEGINSCENEEXTPROC) (void); typedef void (GLAPIENTRY * PFNGLENDSCENEEXTPROC) (void); #define glBeginSceneEXT GLEW_GET_FUN(__glewBeginSceneEXT) #define glEndSceneEXT GLEW_GET_FUN(__glewEndSceneEXT) #define GLEW_EXT_scene_marker GLEW_GET_VAR(__GLEW_EXT_scene_marker) #endif /* GL_EXT_scene_marker */ /* ------------------------- GL_EXT_secondary_color ------------------------ */ #ifndef GL_EXT_secondary_color #define GL_EXT_secondary_color 1 #define GL_COLOR_SUM_EXT 0x8458 #define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 #define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A #define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B #define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C #define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D #define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); #define glSecondaryColor3bEXT GLEW_GET_FUN(__glewSecondaryColor3bEXT) #define glSecondaryColor3bvEXT GLEW_GET_FUN(__glewSecondaryColor3bvEXT) #define glSecondaryColor3dEXT GLEW_GET_FUN(__glewSecondaryColor3dEXT) #define glSecondaryColor3dvEXT GLEW_GET_FUN(__glewSecondaryColor3dvEXT) #define glSecondaryColor3fEXT GLEW_GET_FUN(__glewSecondaryColor3fEXT) #define glSecondaryColor3fvEXT GLEW_GET_FUN(__glewSecondaryColor3fvEXT) #define glSecondaryColor3iEXT GLEW_GET_FUN(__glewSecondaryColor3iEXT) #define glSecondaryColor3ivEXT GLEW_GET_FUN(__glewSecondaryColor3ivEXT) #define glSecondaryColor3sEXT GLEW_GET_FUN(__glewSecondaryColor3sEXT) #define glSecondaryColor3svEXT GLEW_GET_FUN(__glewSecondaryColor3svEXT) #define glSecondaryColor3ubEXT GLEW_GET_FUN(__glewSecondaryColor3ubEXT) #define glSecondaryColor3ubvEXT GLEW_GET_FUN(__glewSecondaryColor3ubvEXT) #define glSecondaryColor3uiEXT GLEW_GET_FUN(__glewSecondaryColor3uiEXT) #define glSecondaryColor3uivEXT GLEW_GET_FUN(__glewSecondaryColor3uivEXT) #define glSecondaryColor3usEXT GLEW_GET_FUN(__glewSecondaryColor3usEXT) #define glSecondaryColor3usvEXT GLEW_GET_FUN(__glewSecondaryColor3usvEXT) #define glSecondaryColorPointerEXT GLEW_GET_FUN(__glewSecondaryColorPointerEXT) #define GLEW_EXT_secondary_color GLEW_GET_VAR(__GLEW_EXT_secondary_color) #endif /* GL_EXT_secondary_color */ /* --------------------- GL_EXT_separate_shader_objects -------------------- */ #ifndef GL_EXT_separate_shader_objects #define GL_EXT_separate_shader_objects 1 #define GL_ACTIVE_PROGRAM_EXT 0x8B8D typedef void (GLAPIENTRY * PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar* string); typedef void (GLAPIENTRY * PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); #define glActiveProgramEXT GLEW_GET_FUN(__glewActiveProgramEXT) #define glCreateShaderProgramEXT GLEW_GET_FUN(__glewCreateShaderProgramEXT) #define glUseShaderProgramEXT GLEW_GET_FUN(__glewUseShaderProgramEXT) #define GLEW_EXT_separate_shader_objects GLEW_GET_VAR(__GLEW_EXT_separate_shader_objects) #endif /* GL_EXT_separate_shader_objects */ /* --------------------- GL_EXT_separate_specular_color -------------------- */ #ifndef GL_EXT_separate_specular_color #define GL_EXT_separate_specular_color 1 #define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 #define GL_SINGLE_COLOR_EXT 0x81F9 #define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA #define GLEW_EXT_separate_specular_color GLEW_GET_VAR(__GLEW_EXT_separate_specular_color) #endif /* GL_EXT_separate_specular_color */ /* ------------------- GL_EXT_shader_image_load_formatted ------------------ */ #ifndef GL_EXT_shader_image_load_formatted #define GL_EXT_shader_image_load_formatted 1 #define GLEW_EXT_shader_image_load_formatted GLEW_GET_VAR(__GLEW_EXT_shader_image_load_formatted) #endif /* GL_EXT_shader_image_load_formatted */ /* --------------------- GL_EXT_shader_image_load_store -------------------- */ #ifndef GL_EXT_shader_image_load_store #define GL_EXT_shader_image_load_store 1 #define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 #define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 #define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 #define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 #define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 #define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 #define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 #define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 #define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 #define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 #define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 #define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 #define GL_MAX_IMAGE_UNITS_EXT 0x8F38 #define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 #define GL_IMAGE_BINDING_NAME_EXT 0x8F3A #define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B #define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C #define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D #define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E #define GL_IMAGE_1D_EXT 0x904C #define GL_IMAGE_2D_EXT 0x904D #define GL_IMAGE_3D_EXT 0x904E #define GL_IMAGE_2D_RECT_EXT 0x904F #define GL_IMAGE_CUBE_EXT 0x9050 #define GL_IMAGE_BUFFER_EXT 0x9051 #define GL_IMAGE_1D_ARRAY_EXT 0x9052 #define GL_IMAGE_2D_ARRAY_EXT 0x9053 #define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 #define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 #define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 #define GL_INT_IMAGE_1D_EXT 0x9057 #define GL_INT_IMAGE_2D_EXT 0x9058 #define GL_INT_IMAGE_3D_EXT 0x9059 #define GL_INT_IMAGE_2D_RECT_EXT 0x905A #define GL_INT_IMAGE_CUBE_EXT 0x905B #define GL_INT_IMAGE_BUFFER_EXT 0x905C #define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D #define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E #define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F #define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 #define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 #define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 #define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 #define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 #define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 #define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 #define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 #define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 #define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 #define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C #define GL_MAX_IMAGE_SAMPLES_EXT 0x906D #define GL_IMAGE_BINDING_FORMAT_EXT 0x906E #define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF typedef void (GLAPIENTRY * PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); typedef void (GLAPIENTRY * PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); #define glBindImageTextureEXT GLEW_GET_FUN(__glewBindImageTextureEXT) #define glMemoryBarrierEXT GLEW_GET_FUN(__glewMemoryBarrierEXT) #define GLEW_EXT_shader_image_load_store GLEW_GET_VAR(__GLEW_EXT_shader_image_load_store) #endif /* GL_EXT_shader_image_load_store */ /* ----------------------- GL_EXT_shader_integer_mix ----------------------- */ #ifndef GL_EXT_shader_integer_mix #define GL_EXT_shader_integer_mix 1 #define GLEW_EXT_shader_integer_mix GLEW_GET_VAR(__GLEW_EXT_shader_integer_mix) #endif /* GL_EXT_shader_integer_mix */ /* -------------------------- GL_EXT_shadow_funcs -------------------------- */ #ifndef GL_EXT_shadow_funcs #define GL_EXT_shadow_funcs 1 #define GLEW_EXT_shadow_funcs GLEW_GET_VAR(__GLEW_EXT_shadow_funcs) #endif /* GL_EXT_shadow_funcs */ /* --------------------- GL_EXT_shared_texture_palette --------------------- */ #ifndef GL_EXT_shared_texture_palette #define GL_EXT_shared_texture_palette 1 #define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB #define GLEW_EXT_shared_texture_palette GLEW_GET_VAR(__GLEW_EXT_shared_texture_palette) #endif /* GL_EXT_shared_texture_palette */ /* ------------------------- GL_EXT_sparse_texture2 ------------------------ */ #ifndef GL_EXT_sparse_texture2 #define GL_EXT_sparse_texture2 1 #define GLEW_EXT_sparse_texture2 GLEW_GET_VAR(__GLEW_EXT_sparse_texture2) #endif /* GL_EXT_sparse_texture2 */ /* ------------------------ GL_EXT_stencil_clear_tag ----------------------- */ #ifndef GL_EXT_stencil_clear_tag #define GL_EXT_stencil_clear_tag 1 #define GL_STENCIL_TAG_BITS_EXT 0x88F2 #define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 #define GLEW_EXT_stencil_clear_tag GLEW_GET_VAR(__GLEW_EXT_stencil_clear_tag) #endif /* GL_EXT_stencil_clear_tag */ /* ------------------------ GL_EXT_stencil_two_side ------------------------ */ #ifndef GL_EXT_stencil_two_side #define GL_EXT_stencil_two_side 1 #define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 #define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 typedef void (GLAPIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); #define glActiveStencilFaceEXT GLEW_GET_FUN(__glewActiveStencilFaceEXT) #define GLEW_EXT_stencil_two_side GLEW_GET_VAR(__GLEW_EXT_stencil_two_side) #endif /* GL_EXT_stencil_two_side */ /* -------------------------- GL_EXT_stencil_wrap -------------------------- */ #ifndef GL_EXT_stencil_wrap #define GL_EXT_stencil_wrap 1 #define GL_INCR_WRAP_EXT 0x8507 #define GL_DECR_WRAP_EXT 0x8508 #define GLEW_EXT_stencil_wrap GLEW_GET_VAR(__GLEW_EXT_stencil_wrap) #endif /* GL_EXT_stencil_wrap */ /* --------------------------- GL_EXT_subtexture --------------------------- */ #ifndef GL_EXT_subtexture #define GL_EXT_subtexture 1 typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); #define glTexSubImage1DEXT GLEW_GET_FUN(__glewTexSubImage1DEXT) #define glTexSubImage2DEXT GLEW_GET_FUN(__glewTexSubImage2DEXT) #define glTexSubImage3DEXT GLEW_GET_FUN(__glewTexSubImage3DEXT) #define GLEW_EXT_subtexture GLEW_GET_VAR(__GLEW_EXT_subtexture) #endif /* GL_EXT_subtexture */ /* ----------------------------- GL_EXT_texture ---------------------------- */ #ifndef GL_EXT_texture #define GL_EXT_texture 1 #define GL_ALPHA4_EXT 0x803B #define GL_ALPHA8_EXT 0x803C #define GL_ALPHA12_EXT 0x803D #define GL_ALPHA16_EXT 0x803E #define GL_LUMINANCE4_EXT 0x803F #define GL_LUMINANCE8_EXT 0x8040 #define GL_LUMINANCE12_EXT 0x8041 #define GL_LUMINANCE16_EXT 0x8042 #define GL_LUMINANCE4_ALPHA4_EXT 0x8043 #define GL_LUMINANCE6_ALPHA2_EXT 0x8044 #define GL_LUMINANCE8_ALPHA8_EXT 0x8045 #define GL_LUMINANCE12_ALPHA4_EXT 0x8046 #define GL_LUMINANCE12_ALPHA12_EXT 0x8047 #define GL_LUMINANCE16_ALPHA16_EXT 0x8048 #define GL_INTENSITY_EXT 0x8049 #define GL_INTENSITY4_EXT 0x804A #define GL_INTENSITY8_EXT 0x804B #define GL_INTENSITY12_EXT 0x804C #define GL_INTENSITY16_EXT 0x804D #define GL_RGB2_EXT 0x804E #define GL_RGB4_EXT 0x804F #define GL_RGB5_EXT 0x8050 #define GL_RGB8_EXT 0x8051 #define GL_RGB10_EXT 0x8052 #define GL_RGB12_EXT 0x8053 #define GL_RGB16_EXT 0x8054 #define GL_RGBA2_EXT 0x8055 #define GL_RGBA4_EXT 0x8056 #define GL_RGB5_A1_EXT 0x8057 #define GL_RGBA8_EXT 0x8058 #define GL_RGB10_A2_EXT 0x8059 #define GL_RGBA12_EXT 0x805A #define GL_RGBA16_EXT 0x805B #define GL_TEXTURE_RED_SIZE_EXT 0x805C #define GL_TEXTURE_GREEN_SIZE_EXT 0x805D #define GL_TEXTURE_BLUE_SIZE_EXT 0x805E #define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F #define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 #define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 #define GL_REPLACE_EXT 0x8062 #define GL_PROXY_TEXTURE_1D_EXT 0x8063 #define GL_PROXY_TEXTURE_2D_EXT 0x8064 #define GLEW_EXT_texture GLEW_GET_VAR(__GLEW_EXT_texture) #endif /* GL_EXT_texture */ /* ---------------------------- GL_EXT_texture3D --------------------------- */ #ifndef GL_EXT_texture3D #define GL_EXT_texture3D 1 #define GL_PACK_SKIP_IMAGES_EXT 0x806B #define GL_PACK_IMAGE_HEIGHT_EXT 0x806C #define GL_UNPACK_SKIP_IMAGES_EXT 0x806D #define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E #define GL_TEXTURE_3D_EXT 0x806F #define GL_PROXY_TEXTURE_3D_EXT 0x8070 #define GL_TEXTURE_DEPTH_EXT 0x8071 #define GL_TEXTURE_WRAP_R_EXT 0x8072 #define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); #define glTexImage3DEXT GLEW_GET_FUN(__glewTexImage3DEXT) #define GLEW_EXT_texture3D GLEW_GET_VAR(__GLEW_EXT_texture3D) #endif /* GL_EXT_texture3D */ /* -------------------------- GL_EXT_texture_array ------------------------- */ #ifndef GL_EXT_texture_array #define GL_EXT_texture_array 1 #define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E #define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF #define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 #define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 #define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A #define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B #define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C #define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); #define glFramebufferTextureLayerEXT GLEW_GET_FUN(__glewFramebufferTextureLayerEXT) #define GLEW_EXT_texture_array GLEW_GET_VAR(__GLEW_EXT_texture_array) #endif /* GL_EXT_texture_array */ /* ---------------------- GL_EXT_texture_buffer_object --------------------- */ #ifndef GL_EXT_texture_buffer_object #define GL_EXT_texture_buffer_object 1 #define GL_TEXTURE_BUFFER_EXT 0x8C2A #define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B #define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C #define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D #define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E typedef void (GLAPIENTRY * PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); #define glTexBufferEXT GLEW_GET_FUN(__glewTexBufferEXT) #define GLEW_EXT_texture_buffer_object GLEW_GET_VAR(__GLEW_EXT_texture_buffer_object) #endif /* GL_EXT_texture_buffer_object */ /* -------------------- GL_EXT_texture_compression_dxt1 -------------------- */ #ifndef GL_EXT_texture_compression_dxt1 #define GL_EXT_texture_compression_dxt1 1 #define GLEW_EXT_texture_compression_dxt1 GLEW_GET_VAR(__GLEW_EXT_texture_compression_dxt1) #endif /* GL_EXT_texture_compression_dxt1 */ /* -------------------- GL_EXT_texture_compression_latc -------------------- */ #ifndef GL_EXT_texture_compression_latc #define GL_EXT_texture_compression_latc 1 #define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 #define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 #define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 #define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 #define GLEW_EXT_texture_compression_latc GLEW_GET_VAR(__GLEW_EXT_texture_compression_latc) #endif /* GL_EXT_texture_compression_latc */ /* -------------------- GL_EXT_texture_compression_rgtc -------------------- */ #ifndef GL_EXT_texture_compression_rgtc #define GL_EXT_texture_compression_rgtc 1 #define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB #define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC #define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD #define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE #define GLEW_EXT_texture_compression_rgtc GLEW_GET_VAR(__GLEW_EXT_texture_compression_rgtc) #endif /* GL_EXT_texture_compression_rgtc */ /* -------------------- GL_EXT_texture_compression_s3tc -------------------- */ #ifndef GL_EXT_texture_compression_s3tc #define GL_EXT_texture_compression_s3tc 1 #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 #define GLEW_EXT_texture_compression_s3tc GLEW_GET_VAR(__GLEW_EXT_texture_compression_s3tc) #endif /* GL_EXT_texture_compression_s3tc */ /* ------------------------ GL_EXT_texture_cube_map ------------------------ */ #ifndef GL_EXT_texture_cube_map #define GL_EXT_texture_cube_map 1 #define GL_NORMAL_MAP_EXT 0x8511 #define GL_REFLECTION_MAP_EXT 0x8512 #define GL_TEXTURE_CUBE_MAP_EXT 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A #define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B #define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C #define GLEW_EXT_texture_cube_map GLEW_GET_VAR(__GLEW_EXT_texture_cube_map) #endif /* GL_EXT_texture_cube_map */ /* ----------------------- GL_EXT_texture_edge_clamp ----------------------- */ #ifndef GL_EXT_texture_edge_clamp #define GL_EXT_texture_edge_clamp 1 #define GL_CLAMP_TO_EDGE_EXT 0x812F #define GLEW_EXT_texture_edge_clamp GLEW_GET_VAR(__GLEW_EXT_texture_edge_clamp) #endif /* GL_EXT_texture_edge_clamp */ /* --------------------------- GL_EXT_texture_env -------------------------- */ #ifndef GL_EXT_texture_env #define GL_EXT_texture_env 1 #define GLEW_EXT_texture_env GLEW_GET_VAR(__GLEW_EXT_texture_env) #endif /* GL_EXT_texture_env */ /* ------------------------- GL_EXT_texture_env_add ------------------------ */ #ifndef GL_EXT_texture_env_add #define GL_EXT_texture_env_add 1 #define GLEW_EXT_texture_env_add GLEW_GET_VAR(__GLEW_EXT_texture_env_add) #endif /* GL_EXT_texture_env_add */ /* ----------------------- GL_EXT_texture_env_combine ---------------------- */ #ifndef GL_EXT_texture_env_combine #define GL_EXT_texture_env_combine 1 #define GL_COMBINE_EXT 0x8570 #define GL_COMBINE_RGB_EXT 0x8571 #define GL_COMBINE_ALPHA_EXT 0x8572 #define GL_RGB_SCALE_EXT 0x8573 #define GL_ADD_SIGNED_EXT 0x8574 #define GL_INTERPOLATE_EXT 0x8575 #define GL_CONSTANT_EXT 0x8576 #define GL_PRIMARY_COLOR_EXT 0x8577 #define GL_PREVIOUS_EXT 0x8578 #define GL_SOURCE0_RGB_EXT 0x8580 #define GL_SOURCE1_RGB_EXT 0x8581 #define GL_SOURCE2_RGB_EXT 0x8582 #define GL_SOURCE0_ALPHA_EXT 0x8588 #define GL_SOURCE1_ALPHA_EXT 0x8589 #define GL_SOURCE2_ALPHA_EXT 0x858A #define GL_OPERAND0_RGB_EXT 0x8590 #define GL_OPERAND1_RGB_EXT 0x8591 #define GL_OPERAND2_RGB_EXT 0x8592 #define GL_OPERAND0_ALPHA_EXT 0x8598 #define GL_OPERAND1_ALPHA_EXT 0x8599 #define GL_OPERAND2_ALPHA_EXT 0x859A #define GLEW_EXT_texture_env_combine GLEW_GET_VAR(__GLEW_EXT_texture_env_combine) #endif /* GL_EXT_texture_env_combine */ /* ------------------------ GL_EXT_texture_env_dot3 ------------------------ */ #ifndef GL_EXT_texture_env_dot3 #define GL_EXT_texture_env_dot3 1 #define GL_DOT3_RGB_EXT 0x8740 #define GL_DOT3_RGBA_EXT 0x8741 #define GLEW_EXT_texture_env_dot3 GLEW_GET_VAR(__GLEW_EXT_texture_env_dot3) #endif /* GL_EXT_texture_env_dot3 */ /* ------------------- GL_EXT_texture_filter_anisotropic ------------------- */ #ifndef GL_EXT_texture_filter_anisotropic #define GL_EXT_texture_filter_anisotropic 1 #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF #define GLEW_EXT_texture_filter_anisotropic GLEW_GET_VAR(__GLEW_EXT_texture_filter_anisotropic) #endif /* GL_EXT_texture_filter_anisotropic */ /* ---------------------- GL_EXT_texture_filter_minmax --------------------- */ #ifndef GL_EXT_texture_filter_minmax #define GL_EXT_texture_filter_minmax 1 #define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 #define GL_WEIGHTED_AVERAGE_EXT 0x9367 #define GLEW_EXT_texture_filter_minmax GLEW_GET_VAR(__GLEW_EXT_texture_filter_minmax) #endif /* GL_EXT_texture_filter_minmax */ /* ------------------------- GL_EXT_texture_integer ------------------------ */ #ifndef GL_EXT_texture_integer #define GL_EXT_texture_integer 1 #define GL_RGBA32UI_EXT 0x8D70 #define GL_RGB32UI_EXT 0x8D71 #define GL_ALPHA32UI_EXT 0x8D72 #define GL_INTENSITY32UI_EXT 0x8D73 #define GL_LUMINANCE32UI_EXT 0x8D74 #define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 #define GL_RGBA16UI_EXT 0x8D76 #define GL_RGB16UI_EXT 0x8D77 #define GL_ALPHA16UI_EXT 0x8D78 #define GL_INTENSITY16UI_EXT 0x8D79 #define GL_LUMINANCE16UI_EXT 0x8D7A #define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B #define GL_RGBA8UI_EXT 0x8D7C #define GL_RGB8UI_EXT 0x8D7D #define GL_ALPHA8UI_EXT 0x8D7E #define GL_INTENSITY8UI_EXT 0x8D7F #define GL_LUMINANCE8UI_EXT 0x8D80 #define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 #define GL_RGBA32I_EXT 0x8D82 #define GL_RGB32I_EXT 0x8D83 #define GL_ALPHA32I_EXT 0x8D84 #define GL_INTENSITY32I_EXT 0x8D85 #define GL_LUMINANCE32I_EXT 0x8D86 #define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 #define GL_RGBA16I_EXT 0x8D88 #define GL_RGB16I_EXT 0x8D89 #define GL_ALPHA16I_EXT 0x8D8A #define GL_INTENSITY16I_EXT 0x8D8B #define GL_LUMINANCE16I_EXT 0x8D8C #define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D #define GL_RGBA8I_EXT 0x8D8E #define GL_RGB8I_EXT 0x8D8F #define GL_ALPHA8I_EXT 0x8D90 #define GL_INTENSITY8I_EXT 0x8D91 #define GL_LUMINANCE8I_EXT 0x8D92 #define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 #define GL_RED_INTEGER_EXT 0x8D94 #define GL_GREEN_INTEGER_EXT 0x8D95 #define GL_BLUE_INTEGER_EXT 0x8D96 #define GL_ALPHA_INTEGER_EXT 0x8D97 #define GL_RGB_INTEGER_EXT 0x8D98 #define GL_RGBA_INTEGER_EXT 0x8D99 #define GL_BGR_INTEGER_EXT 0x8D9A #define GL_BGRA_INTEGER_EXT 0x8D9B #define GL_LUMINANCE_INTEGER_EXT 0x8D9C #define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D #define GL_RGBA_INTEGER_MODE_EXT 0x8D9E typedef void (GLAPIENTRY * PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); typedef void (GLAPIENTRY * PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); #define glClearColorIiEXT GLEW_GET_FUN(__glewClearColorIiEXT) #define glClearColorIuiEXT GLEW_GET_FUN(__glewClearColorIuiEXT) #define glGetTexParameterIivEXT GLEW_GET_FUN(__glewGetTexParameterIivEXT) #define glGetTexParameterIuivEXT GLEW_GET_FUN(__glewGetTexParameterIuivEXT) #define glTexParameterIivEXT GLEW_GET_FUN(__glewTexParameterIivEXT) #define glTexParameterIuivEXT GLEW_GET_FUN(__glewTexParameterIuivEXT) #define GLEW_EXT_texture_integer GLEW_GET_VAR(__GLEW_EXT_texture_integer) #endif /* GL_EXT_texture_integer */ /* ------------------------ GL_EXT_texture_lod_bias ------------------------ */ #ifndef GL_EXT_texture_lod_bias #define GL_EXT_texture_lod_bias 1 #define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD #define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 #define GL_TEXTURE_LOD_BIAS_EXT 0x8501 #define GLEW_EXT_texture_lod_bias GLEW_GET_VAR(__GLEW_EXT_texture_lod_bias) #endif /* GL_EXT_texture_lod_bias */ /* ---------------------- GL_EXT_texture_mirror_clamp ---------------------- */ #ifndef GL_EXT_texture_mirror_clamp #define GL_EXT_texture_mirror_clamp 1 #define GL_MIRROR_CLAMP_EXT 0x8742 #define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 #define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 #define GLEW_EXT_texture_mirror_clamp GLEW_GET_VAR(__GLEW_EXT_texture_mirror_clamp) #endif /* GL_EXT_texture_mirror_clamp */ /* ------------------------- GL_EXT_texture_object ------------------------- */ #ifndef GL_EXT_texture_object #define GL_EXT_texture_object 1 #define GL_TEXTURE_PRIORITY_EXT 0x8066 #define GL_TEXTURE_RESIDENT_EXT 0x8067 #define GL_TEXTURE_1D_BINDING_EXT 0x8068 #define GL_TEXTURE_2D_BINDING_EXT 0x8069 #define GL_TEXTURE_3D_BINDING_EXT 0x806A typedef GLboolean (GLAPIENTRY * PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint* textures, GLboolean* residences); typedef void (GLAPIENTRY * PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); typedef void (GLAPIENTRY * PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint* textures); typedef void (GLAPIENTRY * PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint* textures); typedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREEXTPROC) (GLuint texture); typedef void (GLAPIENTRY * PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint* textures, const GLclampf* priorities); #define glAreTexturesResidentEXT GLEW_GET_FUN(__glewAreTexturesResidentEXT) #define glBindTextureEXT GLEW_GET_FUN(__glewBindTextureEXT) #define glDeleteTexturesEXT GLEW_GET_FUN(__glewDeleteTexturesEXT) #define glGenTexturesEXT GLEW_GET_FUN(__glewGenTexturesEXT) #define glIsTextureEXT GLEW_GET_FUN(__glewIsTextureEXT) #define glPrioritizeTexturesEXT GLEW_GET_FUN(__glewPrioritizeTexturesEXT) #define GLEW_EXT_texture_object GLEW_GET_VAR(__GLEW_EXT_texture_object) #endif /* GL_EXT_texture_object */ /* --------------------- GL_EXT_texture_perturb_normal --------------------- */ #ifndef GL_EXT_texture_perturb_normal #define GL_EXT_texture_perturb_normal 1 #define GL_PERTURB_EXT 0x85AE #define GL_TEXTURE_NORMAL_EXT 0x85AF typedef void (GLAPIENTRY * PFNGLTEXTURENORMALEXTPROC) (GLenum mode); #define glTextureNormalEXT GLEW_GET_FUN(__glewTextureNormalEXT) #define GLEW_EXT_texture_perturb_normal GLEW_GET_VAR(__GLEW_EXT_texture_perturb_normal) #endif /* GL_EXT_texture_perturb_normal */ /* ------------------------ GL_EXT_texture_rectangle ----------------------- */ #ifndef GL_EXT_texture_rectangle #define GL_EXT_texture_rectangle 1 #define GL_TEXTURE_RECTANGLE_EXT 0x84F5 #define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6 #define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7 #define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8 #define GLEW_EXT_texture_rectangle GLEW_GET_VAR(__GLEW_EXT_texture_rectangle) #endif /* GL_EXT_texture_rectangle */ /* -------------------------- GL_EXT_texture_sRGB -------------------------- */ #ifndef GL_EXT_texture_sRGB #define GL_EXT_texture_sRGB 1 #define GL_SRGB_EXT 0x8C40 #define GL_SRGB8_EXT 0x8C41 #define GL_SRGB_ALPHA_EXT 0x8C42 #define GL_SRGB8_ALPHA8_EXT 0x8C43 #define GL_SLUMINANCE_ALPHA_EXT 0x8C44 #define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 #define GL_SLUMINANCE_EXT 0x8C46 #define GL_SLUMINANCE8_EXT 0x8C47 #define GL_COMPRESSED_SRGB_EXT 0x8C48 #define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 #define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A #define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B #define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F #define GLEW_EXT_texture_sRGB GLEW_GET_VAR(__GLEW_EXT_texture_sRGB) #endif /* GL_EXT_texture_sRGB */ /* ----------------------- GL_EXT_texture_sRGB_decode ---------------------- */ #ifndef GL_EXT_texture_sRGB_decode #define GL_EXT_texture_sRGB_decode 1 #define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 #define GL_DECODE_EXT 0x8A49 #define GL_SKIP_DECODE_EXT 0x8A4A #define GLEW_EXT_texture_sRGB_decode GLEW_GET_VAR(__GLEW_EXT_texture_sRGB_decode) #endif /* GL_EXT_texture_sRGB_decode */ /* --------------------- GL_EXT_texture_shared_exponent -------------------- */ #ifndef GL_EXT_texture_shared_exponent #define GL_EXT_texture_shared_exponent 1 #define GL_RGB9_E5_EXT 0x8C3D #define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E #define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F #define GLEW_EXT_texture_shared_exponent GLEW_GET_VAR(__GLEW_EXT_texture_shared_exponent) #endif /* GL_EXT_texture_shared_exponent */ /* -------------------------- GL_EXT_texture_snorm ------------------------- */ #ifndef GL_EXT_texture_snorm #define GL_EXT_texture_snorm 1 #define GL_RED_SNORM 0x8F90 #define GL_RG_SNORM 0x8F91 #define GL_RGB_SNORM 0x8F92 #define GL_RGBA_SNORM 0x8F93 #define GL_R8_SNORM 0x8F94 #define GL_RG8_SNORM 0x8F95 #define GL_RGB8_SNORM 0x8F96 #define GL_RGBA8_SNORM 0x8F97 #define GL_R16_SNORM 0x8F98 #define GL_RG16_SNORM 0x8F99 #define GL_RGB16_SNORM 0x8F9A #define GL_RGBA16_SNORM 0x8F9B #define GL_SIGNED_NORMALIZED 0x8F9C #define GL_ALPHA_SNORM 0x9010 #define GL_LUMINANCE_SNORM 0x9011 #define GL_LUMINANCE_ALPHA_SNORM 0x9012 #define GL_INTENSITY_SNORM 0x9013 #define GL_ALPHA8_SNORM 0x9014 #define GL_LUMINANCE8_SNORM 0x9015 #define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 #define GL_INTENSITY8_SNORM 0x9017 #define GL_ALPHA16_SNORM 0x9018 #define GL_LUMINANCE16_SNORM 0x9019 #define GL_LUMINANCE16_ALPHA16_SNORM 0x901A #define GL_INTENSITY16_SNORM 0x901B #define GLEW_EXT_texture_snorm GLEW_GET_VAR(__GLEW_EXT_texture_snorm) #endif /* GL_EXT_texture_snorm */ /* ------------------------- GL_EXT_texture_swizzle ------------------------ */ #ifndef GL_EXT_texture_swizzle #define GL_EXT_texture_swizzle 1 #define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 #define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 #define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 #define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 #define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 #define GLEW_EXT_texture_swizzle GLEW_GET_VAR(__GLEW_EXT_texture_swizzle) #endif /* GL_EXT_texture_swizzle */ /* --------------------------- GL_EXT_timer_query -------------------------- */ #ifndef GL_EXT_timer_query #define GL_EXT_timer_query 1 #define GL_TIME_ELAPSED_EXT 0x88BF typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); #define glGetQueryObjecti64vEXT GLEW_GET_FUN(__glewGetQueryObjecti64vEXT) #define glGetQueryObjectui64vEXT GLEW_GET_FUN(__glewGetQueryObjectui64vEXT) #define GLEW_EXT_timer_query GLEW_GET_VAR(__GLEW_EXT_timer_query) #endif /* GL_EXT_timer_query */ /* ----------------------- GL_EXT_transform_feedback ----------------------- */ #ifndef GL_EXT_transform_feedback #define GL_EXT_transform_feedback 1 #define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 #define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 #define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 #define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 #define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 #define GL_PRIMITIVES_GENERATED_EXT 0x8C87 #define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 #define GL_RASTERIZER_DISCARD_EXT 0x8C89 #define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B #define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C #define GL_SEPARATE_ATTRIBS_EXT 0x8C8D #define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E #define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); typedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei *size, GLenum *type, GLchar *name); typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar * const* varyings, GLenum bufferMode); #define glBeginTransformFeedbackEXT GLEW_GET_FUN(__glewBeginTransformFeedbackEXT) #define glBindBufferBaseEXT GLEW_GET_FUN(__glewBindBufferBaseEXT) #define glBindBufferOffsetEXT GLEW_GET_FUN(__glewBindBufferOffsetEXT) #define glBindBufferRangeEXT GLEW_GET_FUN(__glewBindBufferRangeEXT) #define glEndTransformFeedbackEXT GLEW_GET_FUN(__glewEndTransformFeedbackEXT) #define glGetTransformFeedbackVaryingEXT GLEW_GET_FUN(__glewGetTransformFeedbackVaryingEXT) #define glTransformFeedbackVaryingsEXT GLEW_GET_FUN(__glewTransformFeedbackVaryingsEXT) #define GLEW_EXT_transform_feedback GLEW_GET_VAR(__GLEW_EXT_transform_feedback) #endif /* GL_EXT_transform_feedback */ /* -------------------------- GL_EXT_vertex_array -------------------------- */ #ifndef GL_EXT_vertex_array #define GL_EXT_vertex_array 1 #define GL_DOUBLE_EXT 0x140A #define GL_VERTEX_ARRAY_EXT 0x8074 #define GL_NORMAL_ARRAY_EXT 0x8075 #define GL_COLOR_ARRAY_EXT 0x8076 #define GL_INDEX_ARRAY_EXT 0x8077 #define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 #define GL_EDGE_FLAG_ARRAY_EXT 0x8079 #define GL_VERTEX_ARRAY_SIZE_EXT 0x807A #define GL_VERTEX_ARRAY_TYPE_EXT 0x807B #define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C #define GL_VERTEX_ARRAY_COUNT_EXT 0x807D #define GL_NORMAL_ARRAY_TYPE_EXT 0x807E #define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F #define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 #define GL_COLOR_ARRAY_SIZE_EXT 0x8081 #define GL_COLOR_ARRAY_TYPE_EXT 0x8082 #define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 #define GL_COLOR_ARRAY_COUNT_EXT 0x8084 #define GL_INDEX_ARRAY_TYPE_EXT 0x8085 #define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 #define GL_INDEX_ARRAY_COUNT_EXT 0x8087 #define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 #define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 #define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A #define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B #define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C #define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D #define GL_VERTEX_ARRAY_POINTER_EXT 0x808E #define GL_NORMAL_ARRAY_POINTER_EXT 0x808F #define GL_COLOR_ARRAY_POINTER_EXT 0x8090 #define GL_INDEX_ARRAY_POINTER_EXT 0x8091 #define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 #define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 typedef void (GLAPIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i); typedef void (GLAPIENTRY * PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); typedef void (GLAPIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean* pointer); typedef void (GLAPIENTRY * PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); typedef void (GLAPIENTRY * PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); typedef void (GLAPIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); #define glArrayElementEXT GLEW_GET_FUN(__glewArrayElementEXT) #define glColorPointerEXT GLEW_GET_FUN(__glewColorPointerEXT) #define glDrawArraysEXT GLEW_GET_FUN(__glewDrawArraysEXT) #define glEdgeFlagPointerEXT GLEW_GET_FUN(__glewEdgeFlagPointerEXT) #define glIndexPointerEXT GLEW_GET_FUN(__glewIndexPointerEXT) #define glNormalPointerEXT GLEW_GET_FUN(__glewNormalPointerEXT) #define glTexCoordPointerEXT GLEW_GET_FUN(__glewTexCoordPointerEXT) #define glVertexPointerEXT GLEW_GET_FUN(__glewVertexPointerEXT) #define GLEW_EXT_vertex_array GLEW_GET_VAR(__GLEW_EXT_vertex_array) #endif /* GL_EXT_vertex_array */ /* ------------------------ GL_EXT_vertex_array_bgra ----------------------- */ #ifndef GL_EXT_vertex_array_bgra #define GL_EXT_vertex_array_bgra 1 #define GL_BGRA 0x80E1 #define GLEW_EXT_vertex_array_bgra GLEW_GET_VAR(__GLEW_EXT_vertex_array_bgra) #endif /* GL_EXT_vertex_array_bgra */ /* ----------------------- GL_EXT_vertex_attrib_64bit ---------------------- */ #ifndef GL_EXT_vertex_attrib_64bit #define GL_EXT_vertex_attrib_64bit 1 #define GL_DOUBLE_MAT2_EXT 0x8F46 #define GL_DOUBLE_MAT3_EXT 0x8F47 #define GL_DOUBLE_MAT4_EXT 0x8F48 #define GL_DOUBLE_MAT2x3_EXT 0x8F49 #define GL_DOUBLE_MAT2x4_EXT 0x8F4A #define GL_DOUBLE_MAT3x2_EXT 0x8F4B #define GL_DOUBLE_MAT3x4_EXT 0x8F4C #define GL_DOUBLE_MAT4x2_EXT 0x8F4D #define GL_DOUBLE_MAT4x3_EXT 0x8F4E #define GL_DOUBLE_VEC2_EXT 0x8FFC #define GL_DOUBLE_VEC3_EXT 0x8FFD #define GL_DOUBLE_VEC4_EXT 0x8FFE typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); #define glGetVertexAttribLdvEXT GLEW_GET_FUN(__glewGetVertexAttribLdvEXT) #define glVertexArrayVertexAttribLOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribLOffsetEXT) #define glVertexAttribL1dEXT GLEW_GET_FUN(__glewVertexAttribL1dEXT) #define glVertexAttribL1dvEXT GLEW_GET_FUN(__glewVertexAttribL1dvEXT) #define glVertexAttribL2dEXT GLEW_GET_FUN(__glewVertexAttribL2dEXT) #define glVertexAttribL2dvEXT GLEW_GET_FUN(__glewVertexAttribL2dvEXT) #define glVertexAttribL3dEXT GLEW_GET_FUN(__glewVertexAttribL3dEXT) #define glVertexAttribL3dvEXT GLEW_GET_FUN(__glewVertexAttribL3dvEXT) #define glVertexAttribL4dEXT GLEW_GET_FUN(__glewVertexAttribL4dEXT) #define glVertexAttribL4dvEXT GLEW_GET_FUN(__glewVertexAttribL4dvEXT) #define glVertexAttribLPointerEXT GLEW_GET_FUN(__glewVertexAttribLPointerEXT) #define GLEW_EXT_vertex_attrib_64bit GLEW_GET_VAR(__GLEW_EXT_vertex_attrib_64bit) #endif /* GL_EXT_vertex_attrib_64bit */ /* -------------------------- GL_EXT_vertex_shader ------------------------- */ #ifndef GL_EXT_vertex_shader #define GL_EXT_vertex_shader 1 #define GL_VERTEX_SHADER_EXT 0x8780 #define GL_VERTEX_SHADER_BINDING_EXT 0x8781 #define GL_OP_INDEX_EXT 0x8782 #define GL_OP_NEGATE_EXT 0x8783 #define GL_OP_DOT3_EXT 0x8784 #define GL_OP_DOT4_EXT 0x8785 #define GL_OP_MUL_EXT 0x8786 #define GL_OP_ADD_EXT 0x8787 #define GL_OP_MADD_EXT 0x8788 #define GL_OP_FRAC_EXT 0x8789 #define GL_OP_MAX_EXT 0x878A #define GL_OP_MIN_EXT 0x878B #define GL_OP_SET_GE_EXT 0x878C #define GL_OP_SET_LT_EXT 0x878D #define GL_OP_CLAMP_EXT 0x878E #define GL_OP_FLOOR_EXT 0x878F #define GL_OP_ROUND_EXT 0x8790 #define GL_OP_EXP_BASE_2_EXT 0x8791 #define GL_OP_LOG_BASE_2_EXT 0x8792 #define GL_OP_POWER_EXT 0x8793 #define GL_OP_RECIP_EXT 0x8794 #define GL_OP_RECIP_SQRT_EXT 0x8795 #define GL_OP_SUB_EXT 0x8796 #define GL_OP_CROSS_PRODUCT_EXT 0x8797 #define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 #define GL_OP_MOV_EXT 0x8799 #define GL_OUTPUT_VERTEX_EXT 0x879A #define GL_OUTPUT_COLOR0_EXT 0x879B #define GL_OUTPUT_COLOR1_EXT 0x879C #define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D #define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E #define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F #define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 #define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 #define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 #define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 #define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 #define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 #define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 #define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 #define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 #define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 #define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA #define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB #define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC #define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD #define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE #define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF #define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 #define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 #define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 #define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 #define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 #define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 #define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 #define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 #define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 #define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 #define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA #define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB #define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC #define GL_OUTPUT_FOG_EXT 0x87BD #define GL_SCALAR_EXT 0x87BE #define GL_VECTOR_EXT 0x87BF #define GL_MATRIX_EXT 0x87C0 #define GL_VARIANT_EXT 0x87C1 #define GL_INVARIANT_EXT 0x87C2 #define GL_LOCAL_CONSTANT_EXT 0x87C3 #define GL_LOCAL_EXT 0x87C4 #define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 #define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 #define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 #define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 #define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 #define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA #define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB #define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CC #define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CD #define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE #define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF #define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 #define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 #define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 #define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 #define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 #define GL_X_EXT 0x87D5 #define GL_Y_EXT 0x87D6 #define GL_Z_EXT 0x87D7 #define GL_W_EXT 0x87D8 #define GL_NEGATIVE_X_EXT 0x87D9 #define GL_NEGATIVE_Y_EXT 0x87DA #define GL_NEGATIVE_Z_EXT 0x87DB #define GL_NEGATIVE_W_EXT 0x87DC #define GL_ZERO_EXT 0x87DD #define GL_ONE_EXT 0x87DE #define GL_NEGATIVE_ONE_EXT 0x87DF #define GL_NORMALIZED_RANGE_EXT 0x87E0 #define GL_FULL_RANGE_EXT 0x87E1 #define GL_CURRENT_VERTEX_EXT 0x87E2 #define GL_MVP_MATRIX_EXT 0x87E3 #define GL_VARIANT_VALUE_EXT 0x87E4 #define GL_VARIANT_DATATYPE_EXT 0x87E5 #define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 #define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 #define GL_VARIANT_ARRAY_EXT 0x87E8 #define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 #define GL_INVARIANT_VALUE_EXT 0x87EA #define GL_INVARIANT_DATATYPE_EXT 0x87EB #define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC #define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED typedef void (GLAPIENTRY * PFNGLBEGINVERTEXSHADEREXTPROC) (void); typedef GLuint (GLAPIENTRY * PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); typedef GLuint (GLAPIENTRY * PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); typedef GLuint (GLAPIENTRY * PFNGLBINDPARAMETEREXTPROC) (GLenum value); typedef GLuint (GLAPIENTRY * PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); typedef GLuint (GLAPIENTRY * PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); typedef void (GLAPIENTRY * PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLENDVERTEXSHADEREXTPROC) (void); typedef void (GLAPIENTRY * PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); typedef GLuint (GLAPIENTRY * PFNGLGENSYMBOLSEXTPROC) (GLenum dataType, GLenum storageType, GLenum range, GLuint components); typedef GLuint (GLAPIENTRY * PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); typedef void (GLAPIENTRY * PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); typedef void (GLAPIENTRY * PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); typedef void (GLAPIENTRY * PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); typedef void (GLAPIENTRY * PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); typedef void (GLAPIENTRY * PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); typedef void (GLAPIENTRY * PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); typedef void (GLAPIENTRY * PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); typedef void (GLAPIENTRY * PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); typedef GLboolean (GLAPIENTRY * PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); typedef void (GLAPIENTRY * PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, void *addr); typedef void (GLAPIENTRY * PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, void *addr); typedef void (GLAPIENTRY * PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); typedef void (GLAPIENTRY * PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); typedef void (GLAPIENTRY * PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); typedef void (GLAPIENTRY * PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); typedef void (GLAPIENTRY * PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, void *addr); typedef void (GLAPIENTRY * PFNGLVARIANTBVEXTPROC) (GLuint id, GLbyte *addr); typedef void (GLAPIENTRY * PFNGLVARIANTDVEXTPROC) (GLuint id, GLdouble *addr); typedef void (GLAPIENTRY * PFNGLVARIANTFVEXTPROC) (GLuint id, GLfloat *addr); typedef void (GLAPIENTRY * PFNGLVARIANTIVEXTPROC) (GLuint id, GLint *addr); typedef void (GLAPIENTRY * PFNGLVARIANTSVEXTPROC) (GLuint id, GLshort *addr); typedef void (GLAPIENTRY * PFNGLVARIANTUBVEXTPROC) (GLuint id, GLubyte *addr); typedef void (GLAPIENTRY * PFNGLVARIANTUIVEXTPROC) (GLuint id, GLuint *addr); typedef void (GLAPIENTRY * PFNGLVARIANTUSVEXTPROC) (GLuint id, GLushort *addr); typedef void (GLAPIENTRY * PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); #define glBeginVertexShaderEXT GLEW_GET_FUN(__glewBeginVertexShaderEXT) #define glBindLightParameterEXT GLEW_GET_FUN(__glewBindLightParameterEXT) #define glBindMaterialParameterEXT GLEW_GET_FUN(__glewBindMaterialParameterEXT) #define glBindParameterEXT GLEW_GET_FUN(__glewBindParameterEXT) #define glBindTexGenParameterEXT GLEW_GET_FUN(__glewBindTexGenParameterEXT) #define glBindTextureUnitParameterEXT GLEW_GET_FUN(__glewBindTextureUnitParameterEXT) #define glBindVertexShaderEXT GLEW_GET_FUN(__glewBindVertexShaderEXT) #define glDeleteVertexShaderEXT GLEW_GET_FUN(__glewDeleteVertexShaderEXT) #define glDisableVariantClientStateEXT GLEW_GET_FUN(__glewDisableVariantClientStateEXT) #define glEnableVariantClientStateEXT GLEW_GET_FUN(__glewEnableVariantClientStateEXT) #define glEndVertexShaderEXT GLEW_GET_FUN(__glewEndVertexShaderEXT) #define glExtractComponentEXT GLEW_GET_FUN(__glewExtractComponentEXT) #define glGenSymbolsEXT GLEW_GET_FUN(__glewGenSymbolsEXT) #define glGenVertexShadersEXT GLEW_GET_FUN(__glewGenVertexShadersEXT) #define glGetInvariantBooleanvEXT GLEW_GET_FUN(__glewGetInvariantBooleanvEXT) #define glGetInvariantFloatvEXT GLEW_GET_FUN(__glewGetInvariantFloatvEXT) #define glGetInvariantIntegervEXT GLEW_GET_FUN(__glewGetInvariantIntegervEXT) #define glGetLocalConstantBooleanvEXT GLEW_GET_FUN(__glewGetLocalConstantBooleanvEXT) #define glGetLocalConstantFloatvEXT GLEW_GET_FUN(__glewGetLocalConstantFloatvEXT) #define glGetLocalConstantIntegervEXT GLEW_GET_FUN(__glewGetLocalConstantIntegervEXT) #define glGetVariantBooleanvEXT GLEW_GET_FUN(__glewGetVariantBooleanvEXT) #define glGetVariantFloatvEXT GLEW_GET_FUN(__glewGetVariantFloatvEXT) #define glGetVariantIntegervEXT GLEW_GET_FUN(__glewGetVariantIntegervEXT) #define glGetVariantPointervEXT GLEW_GET_FUN(__glewGetVariantPointervEXT) #define glInsertComponentEXT GLEW_GET_FUN(__glewInsertComponentEXT) #define glIsVariantEnabledEXT GLEW_GET_FUN(__glewIsVariantEnabledEXT) #define glSetInvariantEXT GLEW_GET_FUN(__glewSetInvariantEXT) #define glSetLocalConstantEXT GLEW_GET_FUN(__glewSetLocalConstantEXT) #define glShaderOp1EXT GLEW_GET_FUN(__glewShaderOp1EXT) #define glShaderOp2EXT GLEW_GET_FUN(__glewShaderOp2EXT) #define glShaderOp3EXT GLEW_GET_FUN(__glewShaderOp3EXT) #define glSwizzleEXT GLEW_GET_FUN(__glewSwizzleEXT) #define glVariantPointerEXT GLEW_GET_FUN(__glewVariantPointerEXT) #define glVariantbvEXT GLEW_GET_FUN(__glewVariantbvEXT) #define glVariantdvEXT GLEW_GET_FUN(__glewVariantdvEXT) #define glVariantfvEXT GLEW_GET_FUN(__glewVariantfvEXT) #define glVariantivEXT GLEW_GET_FUN(__glewVariantivEXT) #define glVariantsvEXT GLEW_GET_FUN(__glewVariantsvEXT) #define glVariantubvEXT GLEW_GET_FUN(__glewVariantubvEXT) #define glVariantuivEXT GLEW_GET_FUN(__glewVariantuivEXT) #define glVariantusvEXT GLEW_GET_FUN(__glewVariantusvEXT) #define glWriteMaskEXT GLEW_GET_FUN(__glewWriteMaskEXT) #define GLEW_EXT_vertex_shader GLEW_GET_VAR(__GLEW_EXT_vertex_shader) #endif /* GL_EXT_vertex_shader */ /* ------------------------ GL_EXT_vertex_weighting ------------------------ */ #ifndef GL_EXT_vertex_weighting #define GL_EXT_vertex_weighting 1 #define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 #define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 #define GL_MODELVIEW0_EXT 0x1700 #define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 #define GL_MODELVIEW1_MATRIX_EXT 0x8506 #define GL_VERTEX_WEIGHTING_EXT 0x8509 #define GL_MODELVIEW1_EXT 0x850A #define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B #define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C #define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D #define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E #define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F #define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, void *pointer); typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFVEXTPROC) (GLfloat* weight); #define glVertexWeightPointerEXT GLEW_GET_FUN(__glewVertexWeightPointerEXT) #define glVertexWeightfEXT GLEW_GET_FUN(__glewVertexWeightfEXT) #define glVertexWeightfvEXT GLEW_GET_FUN(__glewVertexWeightfvEXT) #define GLEW_EXT_vertex_weighting GLEW_GET_VAR(__GLEW_EXT_vertex_weighting) #endif /* GL_EXT_vertex_weighting */ /* ------------------------- GL_EXT_x11_sync_object ------------------------ */ #ifndef GL_EXT_x11_sync_object #define GL_EXT_x11_sync_object 1 #define GL_SYNC_X11_FENCE_EXT 0x90E1 typedef GLsync (GLAPIENTRY * PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); #define glImportSyncEXT GLEW_GET_FUN(__glewImportSyncEXT) #define GLEW_EXT_x11_sync_object GLEW_GET_VAR(__GLEW_EXT_x11_sync_object) #endif /* GL_EXT_x11_sync_object */ /* ---------------------- GL_GREMEDY_frame_terminator ---------------------- */ #ifndef GL_GREMEDY_frame_terminator #define GL_GREMEDY_frame_terminator 1 typedef void (GLAPIENTRY * PFNGLFRAMETERMINATORGREMEDYPROC) (void); #define glFrameTerminatorGREMEDY GLEW_GET_FUN(__glewFrameTerminatorGREMEDY) #define GLEW_GREMEDY_frame_terminator GLEW_GET_VAR(__GLEW_GREMEDY_frame_terminator) #endif /* GL_GREMEDY_frame_terminator */ /* ------------------------ GL_GREMEDY_string_marker ----------------------- */ #ifndef GL_GREMEDY_string_marker #define GL_GREMEDY_string_marker 1 typedef void (GLAPIENTRY * PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); #define glStringMarkerGREMEDY GLEW_GET_FUN(__glewStringMarkerGREMEDY) #define GLEW_GREMEDY_string_marker GLEW_GET_VAR(__GLEW_GREMEDY_string_marker) #endif /* GL_GREMEDY_string_marker */ /* --------------------- GL_HP_convolution_border_modes -------------------- */ #ifndef GL_HP_convolution_border_modes #define GL_HP_convolution_border_modes 1 #define GLEW_HP_convolution_border_modes GLEW_GET_VAR(__GLEW_HP_convolution_border_modes) #endif /* GL_HP_convolution_border_modes */ /* ------------------------- GL_HP_image_transform ------------------------- */ #ifndef GL_HP_image_transform #define GL_HP_image_transform 1 typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, const GLfloat param); typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, const GLint param); typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); #define glGetImageTransformParameterfvHP GLEW_GET_FUN(__glewGetImageTransformParameterfvHP) #define glGetImageTransformParameterivHP GLEW_GET_FUN(__glewGetImageTransformParameterivHP) #define glImageTransformParameterfHP GLEW_GET_FUN(__glewImageTransformParameterfHP) #define glImageTransformParameterfvHP GLEW_GET_FUN(__glewImageTransformParameterfvHP) #define glImageTransformParameteriHP GLEW_GET_FUN(__glewImageTransformParameteriHP) #define glImageTransformParameterivHP GLEW_GET_FUN(__glewImageTransformParameterivHP) #define GLEW_HP_image_transform GLEW_GET_VAR(__GLEW_HP_image_transform) #endif /* GL_HP_image_transform */ /* -------------------------- GL_HP_occlusion_test ------------------------- */ #ifndef GL_HP_occlusion_test #define GL_HP_occlusion_test 1 #define GLEW_HP_occlusion_test GLEW_GET_VAR(__GLEW_HP_occlusion_test) #endif /* GL_HP_occlusion_test */ /* ------------------------- GL_HP_texture_lighting ------------------------ */ #ifndef GL_HP_texture_lighting #define GL_HP_texture_lighting 1 #define GLEW_HP_texture_lighting GLEW_GET_VAR(__GLEW_HP_texture_lighting) #endif /* GL_HP_texture_lighting */ /* --------------------------- GL_IBM_cull_vertex -------------------------- */ #ifndef GL_IBM_cull_vertex #define GL_IBM_cull_vertex 1 #define GL_CULL_VERTEX_IBM 103050 #define GLEW_IBM_cull_vertex GLEW_GET_VAR(__GLEW_IBM_cull_vertex) #endif /* GL_IBM_cull_vertex */ /* ---------------------- GL_IBM_multimode_draw_arrays --------------------- */ #ifndef GL_IBM_multimode_draw_arrays #define GL_IBM_multimode_draw_arrays 1 typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum* mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum* mode, const GLsizei *count, GLenum type, const void *const *indices, GLsizei primcount, GLint modestride); #define glMultiModeDrawArraysIBM GLEW_GET_FUN(__glewMultiModeDrawArraysIBM) #define glMultiModeDrawElementsIBM GLEW_GET_FUN(__glewMultiModeDrawElementsIBM) #define GLEW_IBM_multimode_draw_arrays GLEW_GET_VAR(__GLEW_IBM_multimode_draw_arrays) #endif /* GL_IBM_multimode_draw_arrays */ /* ------------------------- GL_IBM_rasterpos_clip ------------------------- */ #ifndef GL_IBM_rasterpos_clip #define GL_IBM_rasterpos_clip 1 #define GL_RASTER_POSITION_UNCLIPPED_IBM 103010 #define GLEW_IBM_rasterpos_clip GLEW_GET_VAR(__GLEW_IBM_rasterpos_clip) #endif /* GL_IBM_rasterpos_clip */ /* --------------------------- GL_IBM_static_data -------------------------- */ #ifndef GL_IBM_static_data #define GL_IBM_static_data 1 #define GL_ALL_STATIC_DATA_IBM 103060 #define GL_STATIC_VERTEX_ARRAY_IBM 103061 #define GLEW_IBM_static_data GLEW_GET_VAR(__GLEW_IBM_static_data) #endif /* GL_IBM_static_data */ /* --------------------- GL_IBM_texture_mirrored_repeat -------------------- */ #ifndef GL_IBM_texture_mirrored_repeat #define GL_IBM_texture_mirrored_repeat 1 #define GL_MIRRORED_REPEAT_IBM 0x8370 #define GLEW_IBM_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_IBM_texture_mirrored_repeat) #endif /* GL_IBM_texture_mirrored_repeat */ /* ----------------------- GL_IBM_vertex_array_lists ----------------------- */ #ifndef GL_IBM_vertex_array_lists #define GL_IBM_vertex_array_lists 1 #define GL_VERTEX_ARRAY_LIST_IBM 103070 #define GL_NORMAL_ARRAY_LIST_IBM 103071 #define GL_COLOR_ARRAY_LIST_IBM 103072 #define GL_INDEX_ARRAY_LIST_IBM 103073 #define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 #define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 #define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 #define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 #define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 #define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 #define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 #define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 #define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 #define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 #define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 #define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 typedef void (GLAPIENTRY * PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void** pointer, GLint ptrstride); typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean ** pointer, GLint ptrstride); typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void** pointer, GLint ptrstride); typedef void (GLAPIENTRY * PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void** pointer, GLint ptrstride); typedef void (GLAPIENTRY * PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void** pointer, GLint ptrstride); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void** pointer, GLint ptrstride); typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void** pointer, GLint ptrstride); typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void** pointer, GLint ptrstride); #define glColorPointerListIBM GLEW_GET_FUN(__glewColorPointerListIBM) #define glEdgeFlagPointerListIBM GLEW_GET_FUN(__glewEdgeFlagPointerListIBM) #define glFogCoordPointerListIBM GLEW_GET_FUN(__glewFogCoordPointerListIBM) #define glIndexPointerListIBM GLEW_GET_FUN(__glewIndexPointerListIBM) #define glNormalPointerListIBM GLEW_GET_FUN(__glewNormalPointerListIBM) #define glSecondaryColorPointerListIBM GLEW_GET_FUN(__glewSecondaryColorPointerListIBM) #define glTexCoordPointerListIBM GLEW_GET_FUN(__glewTexCoordPointerListIBM) #define glVertexPointerListIBM GLEW_GET_FUN(__glewVertexPointerListIBM) #define GLEW_IBM_vertex_array_lists GLEW_GET_VAR(__GLEW_IBM_vertex_array_lists) #endif /* GL_IBM_vertex_array_lists */ /* -------------------------- GL_INGR_color_clamp -------------------------- */ #ifndef GL_INGR_color_clamp #define GL_INGR_color_clamp 1 #define GL_RED_MIN_CLAMP_INGR 0x8560 #define GL_GREEN_MIN_CLAMP_INGR 0x8561 #define GL_BLUE_MIN_CLAMP_INGR 0x8562 #define GL_ALPHA_MIN_CLAMP_INGR 0x8563 #define GL_RED_MAX_CLAMP_INGR 0x8564 #define GL_GREEN_MAX_CLAMP_INGR 0x8565 #define GL_BLUE_MAX_CLAMP_INGR 0x8566 #define GL_ALPHA_MAX_CLAMP_INGR 0x8567 #define GLEW_INGR_color_clamp GLEW_GET_VAR(__GLEW_INGR_color_clamp) #endif /* GL_INGR_color_clamp */ /* ------------------------- GL_INGR_interlace_read ------------------------ */ #ifndef GL_INGR_interlace_read #define GL_INGR_interlace_read 1 #define GL_INTERLACE_READ_INGR 0x8568 #define GLEW_INGR_interlace_read GLEW_GET_VAR(__GLEW_INGR_interlace_read) #endif /* GL_INGR_interlace_read */ /* ------------------- GL_INTEL_fragment_shader_ordering ------------------- */ #ifndef GL_INTEL_fragment_shader_ordering #define GL_INTEL_fragment_shader_ordering 1 #define GLEW_INTEL_fragment_shader_ordering GLEW_GET_VAR(__GLEW_INTEL_fragment_shader_ordering) #endif /* GL_INTEL_fragment_shader_ordering */ /* ----------------------- GL_INTEL_framebuffer_CMAA ----------------------- */ #ifndef GL_INTEL_framebuffer_CMAA #define GL_INTEL_framebuffer_CMAA 1 #define GLEW_INTEL_framebuffer_CMAA GLEW_GET_VAR(__GLEW_INTEL_framebuffer_CMAA) #endif /* GL_INTEL_framebuffer_CMAA */ /* -------------------------- GL_INTEL_map_texture ------------------------- */ #ifndef GL_INTEL_map_texture #define GL_INTEL_map_texture 1 #define GL_LAYOUT_DEFAULT_INTEL 0 #define GL_LAYOUT_LINEAR_INTEL 1 #define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 #define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF typedef void * (GLAPIENTRY * PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint* stride, GLenum *layout); typedef void (GLAPIENTRY * PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); typedef void (GLAPIENTRY * PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); #define glMapTexture2DINTEL GLEW_GET_FUN(__glewMapTexture2DINTEL) #define glSyncTextureINTEL GLEW_GET_FUN(__glewSyncTextureINTEL) #define glUnmapTexture2DINTEL GLEW_GET_FUN(__glewUnmapTexture2DINTEL) #define GLEW_INTEL_map_texture GLEW_GET_VAR(__GLEW_INTEL_map_texture) #endif /* GL_INTEL_map_texture */ /* ------------------------ GL_INTEL_parallel_arrays ----------------------- */ #ifndef GL_INTEL_parallel_arrays #define GL_INTEL_parallel_arrays 1 #define GL_PARALLEL_ARRAYS_INTEL 0x83F4 #define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 #define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 #define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 #define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 typedef void (GLAPIENTRY * PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); typedef void (GLAPIENTRY * PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void** pointer); typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); #define glColorPointervINTEL GLEW_GET_FUN(__glewColorPointervINTEL) #define glNormalPointervINTEL GLEW_GET_FUN(__glewNormalPointervINTEL) #define glTexCoordPointervINTEL GLEW_GET_FUN(__glewTexCoordPointervINTEL) #define glVertexPointervINTEL GLEW_GET_FUN(__glewVertexPointervINTEL) #define GLEW_INTEL_parallel_arrays GLEW_GET_VAR(__GLEW_INTEL_parallel_arrays) #endif /* GL_INTEL_parallel_arrays */ /* ----------------------- GL_INTEL_performance_query ---------------------- */ #ifndef GL_INTEL_performance_query #define GL_INTEL_performance_query 1 #define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x0000 #define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x0001 #define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 #define GL_PERFQUERY_FLUSH_INTEL 0x83FA #define GL_PERFQUERY_WAIT_INTEL 0x83FB #define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 #define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 #define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 #define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 #define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 #define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 #define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 #define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 #define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA #define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB #define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC #define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD #define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE #define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF #define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 typedef void (GLAPIENTRY * PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (GLAPIENTRY * PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint* queryHandle); typedef void (GLAPIENTRY * PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (GLAPIENTRY * PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (GLAPIENTRY * PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint* queryId); typedef void (GLAPIENTRY * PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint* nextQueryId); typedef void (GLAPIENTRY * PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar* counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); typedef void (GLAPIENTRY * PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); typedef void (GLAPIENTRY * PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar* queryName, GLuint *queryId); typedef void (GLAPIENTRY * PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar* queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #define glBeginPerfQueryINTEL GLEW_GET_FUN(__glewBeginPerfQueryINTEL) #define glCreatePerfQueryINTEL GLEW_GET_FUN(__glewCreatePerfQueryINTEL) #define glDeletePerfQueryINTEL GLEW_GET_FUN(__glewDeletePerfQueryINTEL) #define glEndPerfQueryINTEL GLEW_GET_FUN(__glewEndPerfQueryINTEL) #define glGetFirstPerfQueryIdINTEL GLEW_GET_FUN(__glewGetFirstPerfQueryIdINTEL) #define glGetNextPerfQueryIdINTEL GLEW_GET_FUN(__glewGetNextPerfQueryIdINTEL) #define glGetPerfCounterInfoINTEL GLEW_GET_FUN(__glewGetPerfCounterInfoINTEL) #define glGetPerfQueryDataINTEL GLEW_GET_FUN(__glewGetPerfQueryDataINTEL) #define glGetPerfQueryIdByNameINTEL GLEW_GET_FUN(__glewGetPerfQueryIdByNameINTEL) #define glGetPerfQueryInfoINTEL GLEW_GET_FUN(__glewGetPerfQueryInfoINTEL) #define GLEW_INTEL_performance_query GLEW_GET_VAR(__GLEW_INTEL_performance_query) #endif /* GL_INTEL_performance_query */ /* ------------------------ GL_INTEL_texture_scissor ----------------------- */ #ifndef GL_INTEL_texture_scissor #define GL_INTEL_texture_scissor 1 typedef void (GLAPIENTRY * PFNGLTEXSCISSORFUNCINTELPROC) (GLenum target, GLenum lfunc, GLenum hfunc); typedef void (GLAPIENTRY * PFNGLTEXSCISSORINTELPROC) (GLenum target, GLclampf tlow, GLclampf thigh); #define glTexScissorFuncINTEL GLEW_GET_FUN(__glewTexScissorFuncINTEL) #define glTexScissorINTEL GLEW_GET_FUN(__glewTexScissorINTEL) #define GLEW_INTEL_texture_scissor GLEW_GET_VAR(__GLEW_INTEL_texture_scissor) #endif /* GL_INTEL_texture_scissor */ /* --------------------- GL_KHR_blend_equation_advanced -------------------- */ #ifndef GL_KHR_blend_equation_advanced #define GL_KHR_blend_equation_advanced 1 #define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 #define GL_MULTIPLY_KHR 0x9294 #define GL_SCREEN_KHR 0x9295 #define GL_OVERLAY_KHR 0x9296 #define GL_DARKEN_KHR 0x9297 #define GL_LIGHTEN_KHR 0x9298 #define GL_COLORDODGE_KHR 0x9299 #define GL_COLORBURN_KHR 0x929A #define GL_HARDLIGHT_KHR 0x929B #define GL_SOFTLIGHT_KHR 0x929C #define GL_DIFFERENCE_KHR 0x929E #define GL_EXCLUSION_KHR 0x92A0 #define GL_HSL_HUE_KHR 0x92AD #define GL_HSL_SATURATION_KHR 0x92AE #define GL_HSL_COLOR_KHR 0x92AF #define GL_HSL_LUMINOSITY_KHR 0x92B0 typedef void (GLAPIENTRY * PFNGLBLENDBARRIERKHRPROC) (void); #define glBlendBarrierKHR GLEW_GET_FUN(__glewBlendBarrierKHR) #define GLEW_KHR_blend_equation_advanced GLEW_GET_VAR(__GLEW_KHR_blend_equation_advanced) #endif /* GL_KHR_blend_equation_advanced */ /* ---------------- GL_KHR_blend_equation_advanced_coherent ---------------- */ #ifndef GL_KHR_blend_equation_advanced_coherent #define GL_KHR_blend_equation_advanced_coherent 1 #define GLEW_KHR_blend_equation_advanced_coherent GLEW_GET_VAR(__GLEW_KHR_blend_equation_advanced_coherent) #endif /* GL_KHR_blend_equation_advanced_coherent */ /* ---------------------- GL_KHR_context_flush_control --------------------- */ #ifndef GL_KHR_context_flush_control #define GL_KHR_context_flush_control 1 #define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB #define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC #define GLEW_KHR_context_flush_control GLEW_GET_VAR(__GLEW_KHR_context_flush_control) #endif /* GL_KHR_context_flush_control */ /* ------------------------------ GL_KHR_debug ----------------------------- */ #ifndef GL_KHR_debug #define GL_KHR_debug 1 #define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 #define GL_STACK_OVERFLOW 0x0503 #define GL_STACK_UNDERFLOW 0x0504 #define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 #define GL_DEBUG_CALLBACK_FUNCTION 0x8244 #define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 #define GL_DEBUG_SOURCE_API 0x8246 #define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 #define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 #define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 #define GL_DEBUG_SOURCE_APPLICATION 0x824A #define GL_DEBUG_SOURCE_OTHER 0x824B #define GL_DEBUG_TYPE_ERROR 0x824C #define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D #define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E #define GL_DEBUG_TYPE_PORTABILITY 0x824F #define GL_DEBUG_TYPE_PERFORMANCE 0x8250 #define GL_DEBUG_TYPE_OTHER 0x8251 #define GL_DEBUG_TYPE_MARKER 0x8268 #define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 #define GL_DEBUG_TYPE_POP_GROUP 0x826A #define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B #define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C #define GL_DEBUG_GROUP_STACK_DEPTH 0x826D #define GL_BUFFER 0x82E0 #define GL_SHADER 0x82E1 #define GL_PROGRAM 0x82E2 #define GL_QUERY 0x82E3 #define GL_PROGRAM_PIPELINE 0x82E4 #define GL_SAMPLER 0x82E6 #define GL_DISPLAY_LIST 0x82E7 #define GL_MAX_LABEL_LENGTH 0x82E8 #define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 #define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 #define GL_DEBUG_LOGGED_MESSAGES 0x9145 #define GL_DEBUG_SEVERITY_HIGH 0x9146 #define GL_DEBUG_SEVERITY_MEDIUM 0x9147 #define GL_DEBUG_SEVERITY_LOW 0x9148 #define GL_DEBUG_OUTPUT 0x92E0 typedef void (GLAPIENTRY *GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf); typedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog); typedef void (GLAPIENTRY * PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei* length, GLchar *label); typedef void (GLAPIENTRY * PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei* length, GLchar *label); typedef void (GLAPIENTRY * PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar* label); typedef void (GLAPIENTRY * PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar* label); typedef void (GLAPIENTRY * PFNGLPOPDEBUGGROUPPROC) (void); typedef void (GLAPIENTRY * PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar * message); #define glDebugMessageCallback GLEW_GET_FUN(__glewDebugMessageCallback) #define glDebugMessageControl GLEW_GET_FUN(__glewDebugMessageControl) #define glDebugMessageInsert GLEW_GET_FUN(__glewDebugMessageInsert) #define glGetDebugMessageLog GLEW_GET_FUN(__glewGetDebugMessageLog) #define glGetObjectLabel GLEW_GET_FUN(__glewGetObjectLabel) #define glGetObjectPtrLabel GLEW_GET_FUN(__glewGetObjectPtrLabel) #define glObjectLabel GLEW_GET_FUN(__glewObjectLabel) #define glObjectPtrLabel GLEW_GET_FUN(__glewObjectPtrLabel) #define glPopDebugGroup GLEW_GET_FUN(__glewPopDebugGroup) #define glPushDebugGroup GLEW_GET_FUN(__glewPushDebugGroup) #define GLEW_KHR_debug GLEW_GET_VAR(__GLEW_KHR_debug) #endif /* GL_KHR_debug */ /* ---------------------------- GL_KHR_no_error ---------------------------- */ #ifndef GL_KHR_no_error #define GL_KHR_no_error 1 #define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 #define GLEW_KHR_no_error GLEW_GET_VAR(__GLEW_KHR_no_error) #endif /* GL_KHR_no_error */ /* ------------------ GL_KHR_robust_buffer_access_behavior ----------------- */ #ifndef GL_KHR_robust_buffer_access_behavior #define GL_KHR_robust_buffer_access_behavior 1 #define GLEW_KHR_robust_buffer_access_behavior GLEW_GET_VAR(__GLEW_KHR_robust_buffer_access_behavior) #endif /* GL_KHR_robust_buffer_access_behavior */ /* --------------------------- GL_KHR_robustness --------------------------- */ #ifndef GL_KHR_robustness #define GL_KHR_robustness 1 #define GL_CONTEXT_LOST 0x0507 #define GL_LOSE_CONTEXT_ON_RESET 0x8252 #define GL_GUILTY_CONTEXT_RESET 0x8253 #define GL_INNOCENT_CONTEXT_RESET 0x8254 #define GL_UNKNOWN_CONTEXT_RESET 0x8255 #define GL_RESET_NOTIFICATION_STRATEGY 0x8256 #define GL_NO_RESET_NOTIFICATION 0x8261 #define GL_CONTEXT_ROBUST_ACCESS 0x90F3 typedef void (GLAPIENTRY * PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint* params); typedef void (GLAPIENTRY * PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); #define glGetnUniformfv GLEW_GET_FUN(__glewGetnUniformfv) #define glGetnUniformiv GLEW_GET_FUN(__glewGetnUniformiv) #define glGetnUniformuiv GLEW_GET_FUN(__glewGetnUniformuiv) #define glReadnPixels GLEW_GET_FUN(__glewReadnPixels) #define GLEW_KHR_robustness GLEW_GET_VAR(__GLEW_KHR_robustness) #endif /* GL_KHR_robustness */ /* ------------------ GL_KHR_texture_compression_astc_hdr ------------------ */ #ifndef GL_KHR_texture_compression_astc_hdr #define GL_KHR_texture_compression_astc_hdr 1 #define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 #define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 #define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 #define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 #define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 #define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 #define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 #define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 #define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 #define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 #define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA #define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB #define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC #define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD #define GLEW_KHR_texture_compression_astc_hdr GLEW_GET_VAR(__GLEW_KHR_texture_compression_astc_hdr) #endif /* GL_KHR_texture_compression_astc_hdr */ /* ------------------ GL_KHR_texture_compression_astc_ldr ------------------ */ #ifndef GL_KHR_texture_compression_astc_ldr #define GL_KHR_texture_compression_astc_ldr 1 #define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 #define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 #define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 #define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 #define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 #define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 #define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 #define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 #define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 #define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 #define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA #define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB #define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC #define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD #define GLEW_KHR_texture_compression_astc_ldr GLEW_GET_VAR(__GLEW_KHR_texture_compression_astc_ldr) #endif /* GL_KHR_texture_compression_astc_ldr */ /* -------------------------- GL_KTX_buffer_region ------------------------- */ #ifndef GL_KTX_buffer_region #define GL_KTX_buffer_region 1 #define GL_KTX_FRONT_REGION 0x0 #define GL_KTX_BACK_REGION 0x1 #define GL_KTX_Z_REGION 0x2 #define GL_KTX_STENCIL_REGION 0x3 typedef GLuint (GLAPIENTRY * PFNGLBUFFERREGIONENABLEDPROC) (void); typedef void (GLAPIENTRY * PFNGLDELETEBUFFERREGIONPROC) (GLenum region); typedef void (GLAPIENTRY * PFNGLDRAWBUFFERREGIONPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height, GLint xDest, GLint yDest); typedef GLuint (GLAPIENTRY * PFNGLNEWBUFFERREGIONPROC) (GLenum region); typedef void (GLAPIENTRY * PFNGLREADBUFFERREGIONPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height); #define glBufferRegionEnabled GLEW_GET_FUN(__glewBufferRegionEnabled) #define glDeleteBufferRegion GLEW_GET_FUN(__glewDeleteBufferRegion) #define glDrawBufferRegion GLEW_GET_FUN(__glewDrawBufferRegion) #define glNewBufferRegion GLEW_GET_FUN(__glewNewBufferRegion) #define glReadBufferRegion GLEW_GET_FUN(__glewReadBufferRegion) #define GLEW_KTX_buffer_region GLEW_GET_VAR(__GLEW_KTX_buffer_region) #endif /* GL_KTX_buffer_region */ /* ------------------------- GL_MESAX_texture_stack ------------------------ */ #ifndef GL_MESAX_texture_stack #define GL_MESAX_texture_stack 1 #define GL_TEXTURE_1D_STACK_MESAX 0x8759 #define GL_TEXTURE_2D_STACK_MESAX 0x875A #define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B #define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C #define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D #define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E #define GLEW_MESAX_texture_stack GLEW_GET_VAR(__GLEW_MESAX_texture_stack) #endif /* GL_MESAX_texture_stack */ /* -------------------------- GL_MESA_pack_invert -------------------------- */ #ifndef GL_MESA_pack_invert #define GL_MESA_pack_invert 1 #define GL_PACK_INVERT_MESA 0x8758 #define GLEW_MESA_pack_invert GLEW_GET_VAR(__GLEW_MESA_pack_invert) #endif /* GL_MESA_pack_invert */ /* ------------------------- GL_MESA_resize_buffers ------------------------ */ #ifndef GL_MESA_resize_buffers #define GL_MESA_resize_buffers 1 typedef void (GLAPIENTRY * PFNGLRESIZEBUFFERSMESAPROC) (void); #define glResizeBuffersMESA GLEW_GET_FUN(__glewResizeBuffersMESA) #define GLEW_MESA_resize_buffers GLEW_GET_VAR(__GLEW_MESA_resize_buffers) #endif /* GL_MESA_resize_buffers */ /* --------------------------- GL_MESA_window_pos -------------------------- */ #ifndef GL_MESA_window_pos #define GL_MESA_window_pos 1 typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVMESAPROC) (const GLint* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVMESAPROC) (const GLshort* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVMESAPROC) (const GLint* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVMESAPROC) (const GLshort* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IVMESAPROC) (const GLint* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SVMESAPROC) (const GLshort* p); #define glWindowPos2dMESA GLEW_GET_FUN(__glewWindowPos2dMESA) #define glWindowPos2dvMESA GLEW_GET_FUN(__glewWindowPos2dvMESA) #define glWindowPos2fMESA GLEW_GET_FUN(__glewWindowPos2fMESA) #define glWindowPos2fvMESA GLEW_GET_FUN(__glewWindowPos2fvMESA) #define glWindowPos2iMESA GLEW_GET_FUN(__glewWindowPos2iMESA) #define glWindowPos2ivMESA GLEW_GET_FUN(__glewWindowPos2ivMESA) #define glWindowPos2sMESA GLEW_GET_FUN(__glewWindowPos2sMESA) #define glWindowPos2svMESA GLEW_GET_FUN(__glewWindowPos2svMESA) #define glWindowPos3dMESA GLEW_GET_FUN(__glewWindowPos3dMESA) #define glWindowPos3dvMESA GLEW_GET_FUN(__glewWindowPos3dvMESA) #define glWindowPos3fMESA GLEW_GET_FUN(__glewWindowPos3fMESA) #define glWindowPos3fvMESA GLEW_GET_FUN(__glewWindowPos3fvMESA) #define glWindowPos3iMESA GLEW_GET_FUN(__glewWindowPos3iMESA) #define glWindowPos3ivMESA GLEW_GET_FUN(__glewWindowPos3ivMESA) #define glWindowPos3sMESA GLEW_GET_FUN(__glewWindowPos3sMESA) #define glWindowPos3svMESA GLEW_GET_FUN(__glewWindowPos3svMESA) #define glWindowPos4dMESA GLEW_GET_FUN(__glewWindowPos4dMESA) #define glWindowPos4dvMESA GLEW_GET_FUN(__glewWindowPos4dvMESA) #define glWindowPos4fMESA GLEW_GET_FUN(__glewWindowPos4fMESA) #define glWindowPos4fvMESA GLEW_GET_FUN(__glewWindowPos4fvMESA) #define glWindowPos4iMESA GLEW_GET_FUN(__glewWindowPos4iMESA) #define glWindowPos4ivMESA GLEW_GET_FUN(__glewWindowPos4ivMESA) #define glWindowPos4sMESA GLEW_GET_FUN(__glewWindowPos4sMESA) #define glWindowPos4svMESA GLEW_GET_FUN(__glewWindowPos4svMESA) #define GLEW_MESA_window_pos GLEW_GET_VAR(__GLEW_MESA_window_pos) #endif /* GL_MESA_window_pos */ /* ------------------------- GL_MESA_ycbcr_texture ------------------------- */ #ifndef GL_MESA_ycbcr_texture #define GL_MESA_ycbcr_texture 1 #define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA #define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB #define GL_YCBCR_MESA 0x8757 #define GLEW_MESA_ycbcr_texture GLEW_GET_VAR(__GLEW_MESA_ycbcr_texture) #endif /* GL_MESA_ycbcr_texture */ /* ----------------------- GL_NVX_conditional_render ----------------------- */ #ifndef GL_NVX_conditional_render #define GL_NVX_conditional_render 1 typedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERNVXPROC) (void); #define glBeginConditionalRenderNVX GLEW_GET_FUN(__glewBeginConditionalRenderNVX) #define glEndConditionalRenderNVX GLEW_GET_FUN(__glewEndConditionalRenderNVX) #define GLEW_NVX_conditional_render GLEW_GET_VAR(__GLEW_NVX_conditional_render) #endif /* GL_NVX_conditional_render */ /* ------------------------- GL_NVX_gpu_memory_info ------------------------ */ #ifndef GL_NVX_gpu_memory_info #define GL_NVX_gpu_memory_info 1 #define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 #define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 #define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 #define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A #define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B #define GLEW_NVX_gpu_memory_info GLEW_GET_VAR(__GLEW_NVX_gpu_memory_info) #endif /* GL_NVX_gpu_memory_info */ /* ------------------- GL_NV_bindless_multi_draw_indirect ------------------ */ #ifndef GL_NV_bindless_multi_draw_indirect #define GL_NV_bindless_multi_draw_indirect 1 typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); #define glMultiDrawArraysIndirectBindlessNV GLEW_GET_FUN(__glewMultiDrawArraysIndirectBindlessNV) #define glMultiDrawElementsIndirectBindlessNV GLEW_GET_FUN(__glewMultiDrawElementsIndirectBindlessNV) #define GLEW_NV_bindless_multi_draw_indirect GLEW_GET_VAR(__GLEW_NV_bindless_multi_draw_indirect) #endif /* GL_NV_bindless_multi_draw_indirect */ /* ---------------- GL_NV_bindless_multi_draw_indirect_count --------------- */ #ifndef GL_NV_bindless_multi_draw_indirect_count #define GL_NV_bindless_multi_draw_indirect_count 1 typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLintptr drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); #define glMultiDrawArraysIndirectBindlessCountNV GLEW_GET_FUN(__glewMultiDrawArraysIndirectBindlessCountNV) #define glMultiDrawElementsIndirectBindlessCountNV GLEW_GET_FUN(__glewMultiDrawElementsIndirectBindlessCountNV) #define GLEW_NV_bindless_multi_draw_indirect_count GLEW_GET_VAR(__GLEW_NV_bindless_multi_draw_indirect_count) #endif /* GL_NV_bindless_multi_draw_indirect_count */ /* ------------------------- GL_NV_bindless_texture ------------------------ */ #ifndef GL_NV_bindless_texture #define GL_NV_bindless_texture 1 typedef GLuint64 (GLAPIENTRY * PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); typedef GLuint64 (GLAPIENTRY * PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); typedef GLuint64 (GLAPIENTRY * PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); typedef GLboolean (GLAPIENTRY * PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); typedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); typedef void (GLAPIENTRY * PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); typedef void (GLAPIENTRY * PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); typedef void (GLAPIENTRY * PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); typedef void (GLAPIENTRY * PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* values); typedef void (GLAPIENTRY * PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); typedef void (GLAPIENTRY * PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64* value); #define glGetImageHandleNV GLEW_GET_FUN(__glewGetImageHandleNV) #define glGetTextureHandleNV GLEW_GET_FUN(__glewGetTextureHandleNV) #define glGetTextureSamplerHandleNV GLEW_GET_FUN(__glewGetTextureSamplerHandleNV) #define glIsImageHandleResidentNV GLEW_GET_FUN(__glewIsImageHandleResidentNV) #define glIsTextureHandleResidentNV GLEW_GET_FUN(__glewIsTextureHandleResidentNV) #define glMakeImageHandleNonResidentNV GLEW_GET_FUN(__glewMakeImageHandleNonResidentNV) #define glMakeImageHandleResidentNV GLEW_GET_FUN(__glewMakeImageHandleResidentNV) #define glMakeTextureHandleNonResidentNV GLEW_GET_FUN(__glewMakeTextureHandleNonResidentNV) #define glMakeTextureHandleResidentNV GLEW_GET_FUN(__glewMakeTextureHandleResidentNV) #define glProgramUniformHandleui64NV GLEW_GET_FUN(__glewProgramUniformHandleui64NV) #define glProgramUniformHandleui64vNV GLEW_GET_FUN(__glewProgramUniformHandleui64vNV) #define glUniformHandleui64NV GLEW_GET_FUN(__glewUniformHandleui64NV) #define glUniformHandleui64vNV GLEW_GET_FUN(__glewUniformHandleui64vNV) #define GLEW_NV_bindless_texture GLEW_GET_VAR(__GLEW_NV_bindless_texture) #endif /* GL_NV_bindless_texture */ /* --------------------- GL_NV_blend_equation_advanced --------------------- */ #ifndef GL_NV_blend_equation_advanced #define GL_NV_blend_equation_advanced 1 #define GL_XOR_NV 0x1506 #define GL_RED_NV 0x1903 #define GL_GREEN_NV 0x1904 #define GL_BLUE_NV 0x1905 #define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 #define GL_BLEND_OVERLAP_NV 0x9281 #define GL_UNCORRELATED_NV 0x9282 #define GL_DISJOINT_NV 0x9283 #define GL_CONJOINT_NV 0x9284 #define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 #define GL_SRC_NV 0x9286 #define GL_DST_NV 0x9287 #define GL_SRC_OVER_NV 0x9288 #define GL_DST_OVER_NV 0x9289 #define GL_SRC_IN_NV 0x928A #define GL_DST_IN_NV 0x928B #define GL_SRC_OUT_NV 0x928C #define GL_DST_OUT_NV 0x928D #define GL_SRC_ATOP_NV 0x928E #define GL_DST_ATOP_NV 0x928F #define GL_PLUS_NV 0x9291 #define GL_PLUS_DARKER_NV 0x9292 #define GL_MULTIPLY_NV 0x9294 #define GL_SCREEN_NV 0x9295 #define GL_OVERLAY_NV 0x9296 #define GL_DARKEN_NV 0x9297 #define GL_LIGHTEN_NV 0x9298 #define GL_COLORDODGE_NV 0x9299 #define GL_COLORBURN_NV 0x929A #define GL_HARDLIGHT_NV 0x929B #define GL_SOFTLIGHT_NV 0x929C #define GL_DIFFERENCE_NV 0x929E #define GL_MINUS_NV 0x929F #define GL_EXCLUSION_NV 0x92A0 #define GL_CONTRAST_NV 0x92A1 #define GL_INVERT_RGB_NV 0x92A3 #define GL_LINEARDODGE_NV 0x92A4 #define GL_LINEARBURN_NV 0x92A5 #define GL_VIVIDLIGHT_NV 0x92A6 #define GL_LINEARLIGHT_NV 0x92A7 #define GL_PINLIGHT_NV 0x92A8 #define GL_HARDMIX_NV 0x92A9 #define GL_HSL_HUE_NV 0x92AD #define GL_HSL_SATURATION_NV 0x92AE #define GL_HSL_COLOR_NV 0x92AF #define GL_HSL_LUMINOSITY_NV 0x92B0 #define GL_PLUS_CLAMPED_NV 0x92B1 #define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 #define GL_MINUS_CLAMPED_NV 0x92B3 #define GL_INVERT_OVG_NV 0x92B4 typedef void (GLAPIENTRY * PFNGLBLENDBARRIERNVPROC) (void); typedef void (GLAPIENTRY * PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); #define glBlendBarrierNV GLEW_GET_FUN(__glewBlendBarrierNV) #define glBlendParameteriNV GLEW_GET_FUN(__glewBlendParameteriNV) #define GLEW_NV_blend_equation_advanced GLEW_GET_VAR(__GLEW_NV_blend_equation_advanced) #endif /* GL_NV_blend_equation_advanced */ /* ----------------- GL_NV_blend_equation_advanced_coherent ---------------- */ #ifndef GL_NV_blend_equation_advanced_coherent #define GL_NV_blend_equation_advanced_coherent 1 #define GLEW_NV_blend_equation_advanced_coherent GLEW_GET_VAR(__GLEW_NV_blend_equation_advanced_coherent) #endif /* GL_NV_blend_equation_advanced_coherent */ /* --------------------------- GL_NV_blend_square -------------------------- */ #ifndef GL_NV_blend_square #define GL_NV_blend_square 1 #define GLEW_NV_blend_square GLEW_GET_VAR(__GLEW_NV_blend_square) #endif /* GL_NV_blend_square */ /* ------------------------- GL_NV_compute_program5 ------------------------ */ #ifndef GL_NV_compute_program5 #define GL_NV_compute_program5 1 #define GL_COMPUTE_PROGRAM_NV 0x90FB #define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC #define GLEW_NV_compute_program5 GLEW_GET_VAR(__GLEW_NV_compute_program5) #endif /* GL_NV_compute_program5 */ /* ------------------------ GL_NV_conditional_render ----------------------- */ #ifndef GL_NV_conditional_render #define GL_NV_conditional_render 1 #define GL_QUERY_WAIT_NV 0x8E13 #define GL_QUERY_NO_WAIT_NV 0x8E14 #define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 #define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 typedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERNVPROC) (void); #define glBeginConditionalRenderNV GLEW_GET_FUN(__glewBeginConditionalRenderNV) #define glEndConditionalRenderNV GLEW_GET_FUN(__glewEndConditionalRenderNV) #define GLEW_NV_conditional_render GLEW_GET_VAR(__GLEW_NV_conditional_render) #endif /* GL_NV_conditional_render */ /* ----------------------- GL_NV_conservative_raster ----------------------- */ #ifndef GL_NV_conservative_raster #define GL_NV_conservative_raster 1 #define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 #define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 #define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 #define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 typedef void (GLAPIENTRY * PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); #define glSubpixelPrecisionBiasNV GLEW_GET_FUN(__glewSubpixelPrecisionBiasNV) #define GLEW_NV_conservative_raster GLEW_GET_VAR(__GLEW_NV_conservative_raster) #endif /* GL_NV_conservative_raster */ /* -------------------- GL_NV_conservative_raster_dilate ------------------- */ #ifndef GL_NV_conservative_raster_dilate #define GL_NV_conservative_raster_dilate 1 #define GL_CONSERVATIVE_RASTER_DILATE_NV 0x9379 #define GL_CONSERVATIVE_RASTER_DILATE_RANGE_NV 0x937A #define GL_CONSERVATIVE_RASTER_DILATE_GRANULARITY_NV 0x937B typedef void (GLAPIENTRY * PFNGLCONSERVATIVERASTERPARAMETERFNVPROC) (GLenum pname, GLfloat value); #define glConservativeRasterParameterfNV GLEW_GET_FUN(__glewConservativeRasterParameterfNV) #define GLEW_NV_conservative_raster_dilate GLEW_GET_VAR(__GLEW_NV_conservative_raster_dilate) #endif /* GL_NV_conservative_raster_dilate */ /* ----------------------- GL_NV_copy_depth_to_color ----------------------- */ #ifndef GL_NV_copy_depth_to_color #define GL_NV_copy_depth_to_color 1 #define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E #define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F #define GLEW_NV_copy_depth_to_color GLEW_GET_VAR(__GLEW_NV_copy_depth_to_color) #endif /* GL_NV_copy_depth_to_color */ /* ---------------------------- GL_NV_copy_image --------------------------- */ #ifndef GL_NV_copy_image #define GL_NV_copy_image 1 typedef void (GLAPIENTRY * PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); #define glCopyImageSubDataNV GLEW_GET_FUN(__glewCopyImageSubDataNV) #define GLEW_NV_copy_image GLEW_GET_VAR(__GLEW_NV_copy_image) #endif /* GL_NV_copy_image */ /* -------------------------- GL_NV_deep_texture3D ------------------------- */ #ifndef GL_NV_deep_texture3D #define GL_NV_deep_texture3D 1 #define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 #define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 #define GLEW_NV_deep_texture3D GLEW_GET_VAR(__GLEW_NV_deep_texture3D) #endif /* GL_NV_deep_texture3D */ /* ------------------------ GL_NV_depth_buffer_float ----------------------- */ #ifndef GL_NV_depth_buffer_float #define GL_NV_depth_buffer_float 1 #define GL_DEPTH_COMPONENT32F_NV 0x8DAB #define GL_DEPTH32F_STENCIL8_NV 0x8DAC #define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD #define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF typedef void (GLAPIENTRY * PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); typedef void (GLAPIENTRY * PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); #define glClearDepthdNV GLEW_GET_FUN(__glewClearDepthdNV) #define glDepthBoundsdNV GLEW_GET_FUN(__glewDepthBoundsdNV) #define glDepthRangedNV GLEW_GET_FUN(__glewDepthRangedNV) #define GLEW_NV_depth_buffer_float GLEW_GET_VAR(__GLEW_NV_depth_buffer_float) #endif /* GL_NV_depth_buffer_float */ /* --------------------------- GL_NV_depth_clamp --------------------------- */ #ifndef GL_NV_depth_clamp #define GL_NV_depth_clamp 1 #define GL_DEPTH_CLAMP_NV 0x864F #define GLEW_NV_depth_clamp GLEW_GET_VAR(__GLEW_NV_depth_clamp) #endif /* GL_NV_depth_clamp */ /* ---------------------- GL_NV_depth_range_unclamped ---------------------- */ #ifndef GL_NV_depth_range_unclamped #define GL_NV_depth_range_unclamped 1 #define GL_SAMPLE_COUNT_BITS_NV 0x8864 #define GL_CURRENT_SAMPLE_COUNT_QUERY_NV 0x8865 #define GL_QUERY_RESULT_NV 0x8866 #define GL_QUERY_RESULT_AVAILABLE_NV 0x8867 #define GL_SAMPLE_COUNT_NV 0x8914 #define GLEW_NV_depth_range_unclamped GLEW_GET_VAR(__GLEW_NV_depth_range_unclamped) #endif /* GL_NV_depth_range_unclamped */ /* --------------------------- GL_NV_draw_texture -------------------------- */ #ifndef GL_NV_draw_texture #define GL_NV_draw_texture 1 typedef void (GLAPIENTRY * PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); #define glDrawTextureNV GLEW_GET_FUN(__glewDrawTextureNV) #define GLEW_NV_draw_texture GLEW_GET_VAR(__GLEW_NV_draw_texture) #endif /* GL_NV_draw_texture */ /* ---------------------------- GL_NV_evaluators --------------------------- */ #ifndef GL_NV_evaluators #define GL_NV_evaluators 1 #define GL_EVAL_2D_NV 0x86C0 #define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 #define GL_MAP_TESSELLATION_NV 0x86C2 #define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 #define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 #define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 #define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 #define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 #define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 #define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 #define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA #define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB #define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC #define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD #define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE #define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF #define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 #define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 #define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 #define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 #define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 #define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 #define GL_MAX_MAP_TESSELLATION_NV 0x86D6 #define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 typedef void (GLAPIENTRY * PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); typedef void (GLAPIENTRY * PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint* params); #define glEvalMapsNV GLEW_GET_FUN(__glewEvalMapsNV) #define glGetMapAttribParameterfvNV GLEW_GET_FUN(__glewGetMapAttribParameterfvNV) #define glGetMapAttribParameterivNV GLEW_GET_FUN(__glewGetMapAttribParameterivNV) #define glGetMapControlPointsNV GLEW_GET_FUN(__glewGetMapControlPointsNV) #define glGetMapParameterfvNV GLEW_GET_FUN(__glewGetMapParameterfvNV) #define glGetMapParameterivNV GLEW_GET_FUN(__glewGetMapParameterivNV) #define glMapControlPointsNV GLEW_GET_FUN(__glewMapControlPointsNV) #define glMapParameterfvNV GLEW_GET_FUN(__glewMapParameterfvNV) #define glMapParameterivNV GLEW_GET_FUN(__glewMapParameterivNV) #define GLEW_NV_evaluators GLEW_GET_VAR(__GLEW_NV_evaluators) #endif /* GL_NV_evaluators */ /* ----------------------- GL_NV_explicit_multisample ---------------------- */ #ifndef GL_NV_explicit_multisample #define GL_NV_explicit_multisample 1 #define GL_SAMPLE_POSITION_NV 0x8E50 #define GL_SAMPLE_MASK_NV 0x8E51 #define GL_SAMPLE_MASK_VALUE_NV 0x8E52 #define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 #define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 #define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 #define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 #define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 #define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 #define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 typedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat* val); typedef void (GLAPIENTRY * PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); typedef void (GLAPIENTRY * PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); #define glGetMultisamplefvNV GLEW_GET_FUN(__glewGetMultisamplefvNV) #define glSampleMaskIndexedNV GLEW_GET_FUN(__glewSampleMaskIndexedNV) #define glTexRenderbufferNV GLEW_GET_FUN(__glewTexRenderbufferNV) #define GLEW_NV_explicit_multisample GLEW_GET_VAR(__GLEW_NV_explicit_multisample) #endif /* GL_NV_explicit_multisample */ /* ------------------------------ GL_NV_fence ------------------------------ */ #ifndef GL_NV_fence #define GL_NV_fence 1 #define GL_ALL_COMPLETED_NV 0x84F2 #define GL_FENCE_STATUS_NV 0x84F3 #define GL_FENCE_CONDITION_NV 0x84F4 typedef void (GLAPIENTRY * PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint* fences); typedef void (GLAPIENTRY * PFNGLFINISHFENCENVPROC) (GLuint fence); typedef void (GLAPIENTRY * PFNGLGENFENCESNVPROC) (GLsizei n, GLuint* fences); typedef void (GLAPIENTRY * PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISFENCENVPROC) (GLuint fence); typedef void (GLAPIENTRY * PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCENVPROC) (GLuint fence); #define glDeleteFencesNV GLEW_GET_FUN(__glewDeleteFencesNV) #define glFinishFenceNV GLEW_GET_FUN(__glewFinishFenceNV) #define glGenFencesNV GLEW_GET_FUN(__glewGenFencesNV) #define glGetFenceivNV GLEW_GET_FUN(__glewGetFenceivNV) #define glIsFenceNV GLEW_GET_FUN(__glewIsFenceNV) #define glSetFenceNV GLEW_GET_FUN(__glewSetFenceNV) #define glTestFenceNV GLEW_GET_FUN(__glewTestFenceNV) #define GLEW_NV_fence GLEW_GET_VAR(__GLEW_NV_fence) #endif /* GL_NV_fence */ /* -------------------------- GL_NV_fill_rectangle ------------------------- */ #ifndef GL_NV_fill_rectangle #define GL_NV_fill_rectangle 1 #define GL_FILL_RECTANGLE_NV 0x933C #define GLEW_NV_fill_rectangle GLEW_GET_VAR(__GLEW_NV_fill_rectangle) #endif /* GL_NV_fill_rectangle */ /* --------------------------- GL_NV_float_buffer -------------------------- */ #ifndef GL_NV_float_buffer #define GL_NV_float_buffer 1 #define GL_FLOAT_R_NV 0x8880 #define GL_FLOAT_RG_NV 0x8881 #define GL_FLOAT_RGB_NV 0x8882 #define GL_FLOAT_RGBA_NV 0x8883 #define GL_FLOAT_R16_NV 0x8884 #define GL_FLOAT_R32_NV 0x8885 #define GL_FLOAT_RG16_NV 0x8886 #define GL_FLOAT_RG32_NV 0x8887 #define GL_FLOAT_RGB16_NV 0x8888 #define GL_FLOAT_RGB32_NV 0x8889 #define GL_FLOAT_RGBA16_NV 0x888A #define GL_FLOAT_RGBA32_NV 0x888B #define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C #define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D #define GL_FLOAT_RGBA_MODE_NV 0x888E #define GLEW_NV_float_buffer GLEW_GET_VAR(__GLEW_NV_float_buffer) #endif /* GL_NV_float_buffer */ /* --------------------------- GL_NV_fog_distance -------------------------- */ #ifndef GL_NV_fog_distance #define GL_NV_fog_distance 1 #define GL_FOG_DISTANCE_MODE_NV 0x855A #define GL_EYE_RADIAL_NV 0x855B #define GL_EYE_PLANE_ABSOLUTE_NV 0x855C #define GLEW_NV_fog_distance GLEW_GET_VAR(__GLEW_NV_fog_distance) #endif /* GL_NV_fog_distance */ /* -------------------- GL_NV_fragment_coverage_to_color ------------------- */ #ifndef GL_NV_fragment_coverage_to_color #define GL_NV_fragment_coverage_to_color 1 #define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD #define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE typedef void (GLAPIENTRY * PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); #define glFragmentCoverageColorNV GLEW_GET_FUN(__glewFragmentCoverageColorNV) #define GLEW_NV_fragment_coverage_to_color GLEW_GET_VAR(__GLEW_NV_fragment_coverage_to_color) #endif /* GL_NV_fragment_coverage_to_color */ /* ------------------------- GL_NV_fragment_program ------------------------ */ #ifndef GL_NV_fragment_program #define GL_NV_fragment_program 1 #define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 #define GL_FRAGMENT_PROGRAM_NV 0x8870 #define GL_MAX_TEXTURE_COORDS_NV 0x8871 #define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 #define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 #define GL_PROGRAM_ERROR_STRING_NV 0x8874 typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble *params); typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat *params); typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLdouble v[]); typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLfloat v[]); #define glGetProgramNamedParameterdvNV GLEW_GET_FUN(__glewGetProgramNamedParameterdvNV) #define glGetProgramNamedParameterfvNV GLEW_GET_FUN(__glewGetProgramNamedParameterfvNV) #define glProgramNamedParameter4dNV GLEW_GET_FUN(__glewProgramNamedParameter4dNV) #define glProgramNamedParameter4dvNV GLEW_GET_FUN(__glewProgramNamedParameter4dvNV) #define glProgramNamedParameter4fNV GLEW_GET_FUN(__glewProgramNamedParameter4fNV) #define glProgramNamedParameter4fvNV GLEW_GET_FUN(__glewProgramNamedParameter4fvNV) #define GLEW_NV_fragment_program GLEW_GET_VAR(__GLEW_NV_fragment_program) #endif /* GL_NV_fragment_program */ /* ------------------------ GL_NV_fragment_program2 ------------------------ */ #ifndef GL_NV_fragment_program2 #define GL_NV_fragment_program2 1 #define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 #define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 #define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 #define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 #define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 #define GLEW_NV_fragment_program2 GLEW_GET_VAR(__GLEW_NV_fragment_program2) #endif /* GL_NV_fragment_program2 */ /* ------------------------ GL_NV_fragment_program4 ------------------------ */ #ifndef GL_NV_fragment_program4 #define GL_NV_fragment_program4 1 #define GLEW_NV_fragment_program4 GLEW_GET_VAR(__GLEW_NV_fragment_program4) #endif /* GL_NV_fragment_program4 */ /* --------------------- GL_NV_fragment_program_option --------------------- */ #ifndef GL_NV_fragment_program_option #define GL_NV_fragment_program_option 1 #define GLEW_NV_fragment_program_option GLEW_GET_VAR(__GLEW_NV_fragment_program_option) #endif /* GL_NV_fragment_program_option */ /* -------------------- GL_NV_fragment_shader_interlock -------------------- */ #ifndef GL_NV_fragment_shader_interlock #define GL_NV_fragment_shader_interlock 1 #define GLEW_NV_fragment_shader_interlock GLEW_GET_VAR(__GLEW_NV_fragment_shader_interlock) #endif /* GL_NV_fragment_shader_interlock */ /* -------------------- GL_NV_framebuffer_mixed_samples -------------------- */ #ifndef GL_NV_framebuffer_mixed_samples #define GL_NV_framebuffer_mixed_samples 1 #define GL_COLOR_SAMPLES_NV 0x8E20 #define GL_RASTER_MULTISAMPLE_EXT 0x9327 #define GL_RASTER_SAMPLES_EXT 0x9328 #define GL_MAX_RASTER_SAMPLES_EXT 0x9329 #define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A #define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B #define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C #define GL_DEPTH_SAMPLES_NV 0x932D #define GL_STENCIL_SAMPLES_NV 0x932E #define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F #define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 #define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 #define GL_COVERAGE_MODULATION_NV 0x9332 #define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 #define GLEW_NV_framebuffer_mixed_samples GLEW_GET_VAR(__GLEW_NV_framebuffer_mixed_samples) #endif /* GL_NV_framebuffer_mixed_samples */ /* ----------------- GL_NV_framebuffer_multisample_coverage ---------------- */ #ifndef GL_NV_framebuffer_multisample_coverage #define GL_NV_framebuffer_multisample_coverage 1 #define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB #define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 #define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 #define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); #define glRenderbufferStorageMultisampleCoverageNV GLEW_GET_FUN(__glewRenderbufferStorageMultisampleCoverageNV) #define GLEW_NV_framebuffer_multisample_coverage GLEW_GET_VAR(__GLEW_NV_framebuffer_multisample_coverage) #endif /* GL_NV_framebuffer_multisample_coverage */ /* ------------------------ GL_NV_geometry_program4 ------------------------ */ #ifndef GL_NV_geometry_program4 #define GL_NV_geometry_program4 1 #define GL_GEOMETRY_PROGRAM_NV 0x8C26 #define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 #define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 typedef void (GLAPIENTRY * PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); #define glProgramVertexLimitNV GLEW_GET_FUN(__glewProgramVertexLimitNV) #define GLEW_NV_geometry_program4 GLEW_GET_VAR(__GLEW_NV_geometry_program4) #endif /* GL_NV_geometry_program4 */ /* ------------------------- GL_NV_geometry_shader4 ------------------------ */ #ifndef GL_NV_geometry_shader4 #define GL_NV_geometry_shader4 1 #define GLEW_NV_geometry_shader4 GLEW_GET_VAR(__GLEW_NV_geometry_shader4) #endif /* GL_NV_geometry_shader4 */ /* ------------------- GL_NV_geometry_shader_passthrough ------------------- */ #ifndef GL_NV_geometry_shader_passthrough #define GL_NV_geometry_shader_passthrough 1 #define GLEW_NV_geometry_shader_passthrough GLEW_GET_VAR(__GLEW_NV_geometry_shader_passthrough) #endif /* GL_NV_geometry_shader_passthrough */ /* --------------------------- GL_NV_gpu_program4 -------------------------- */ #ifndef GL_NV_gpu_program4 #define GL_NV_gpu_program4 1 #define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 #define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 #define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 #define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 #define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 #define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 #define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 #define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); #define glProgramEnvParameterI4iNV GLEW_GET_FUN(__glewProgramEnvParameterI4iNV) #define glProgramEnvParameterI4ivNV GLEW_GET_FUN(__glewProgramEnvParameterI4ivNV) #define glProgramEnvParameterI4uiNV GLEW_GET_FUN(__glewProgramEnvParameterI4uiNV) #define glProgramEnvParameterI4uivNV GLEW_GET_FUN(__glewProgramEnvParameterI4uivNV) #define glProgramEnvParametersI4ivNV GLEW_GET_FUN(__glewProgramEnvParametersI4ivNV) #define glProgramEnvParametersI4uivNV GLEW_GET_FUN(__glewProgramEnvParametersI4uivNV) #define glProgramLocalParameterI4iNV GLEW_GET_FUN(__glewProgramLocalParameterI4iNV) #define glProgramLocalParameterI4ivNV GLEW_GET_FUN(__glewProgramLocalParameterI4ivNV) #define glProgramLocalParameterI4uiNV GLEW_GET_FUN(__glewProgramLocalParameterI4uiNV) #define glProgramLocalParameterI4uivNV GLEW_GET_FUN(__glewProgramLocalParameterI4uivNV) #define glProgramLocalParametersI4ivNV GLEW_GET_FUN(__glewProgramLocalParametersI4ivNV) #define glProgramLocalParametersI4uivNV GLEW_GET_FUN(__glewProgramLocalParametersI4uivNV) #define GLEW_NV_gpu_program4 GLEW_GET_VAR(__GLEW_NV_gpu_program4) #endif /* GL_NV_gpu_program4 */ /* --------------------------- GL_NV_gpu_program5 -------------------------- */ #ifndef GL_NV_gpu_program5 #define GL_NV_gpu_program5 1 #define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A #define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B #define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C #define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D #define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E #define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F #define GLEW_NV_gpu_program5 GLEW_GET_VAR(__GLEW_NV_gpu_program5) #endif /* GL_NV_gpu_program5 */ /* -------------------- GL_NV_gpu_program5_mem_extended -------------------- */ #ifndef GL_NV_gpu_program5_mem_extended #define GL_NV_gpu_program5_mem_extended 1 #define GLEW_NV_gpu_program5_mem_extended GLEW_GET_VAR(__GLEW_NV_gpu_program5_mem_extended) #endif /* GL_NV_gpu_program5_mem_extended */ /* ------------------------- GL_NV_gpu_program_fp64 ------------------------ */ #ifndef GL_NV_gpu_program_fp64 #define GL_NV_gpu_program_fp64 1 #define GLEW_NV_gpu_program_fp64 GLEW_GET_VAR(__GLEW_NV_gpu_program_fp64) #endif /* GL_NV_gpu_program_fp64 */ /* --------------------------- GL_NV_gpu_shader5 --------------------------- */ #ifndef GL_NV_gpu_shader5 #define GL_NV_gpu_shader5 1 #define GL_INT64_NV 0x140E #define GL_UNSIGNED_INT64_NV 0x140F #define GL_INT8_NV 0x8FE0 #define GL_INT8_VEC2_NV 0x8FE1 #define GL_INT8_VEC3_NV 0x8FE2 #define GL_INT8_VEC4_NV 0x8FE3 #define GL_INT16_NV 0x8FE4 #define GL_INT16_VEC2_NV 0x8FE5 #define GL_INT16_VEC3_NV 0x8FE6 #define GL_INT16_VEC4_NV 0x8FE7 #define GL_INT64_VEC2_NV 0x8FE9 #define GL_INT64_VEC3_NV 0x8FEA #define GL_INT64_VEC4_NV 0x8FEB #define GL_UNSIGNED_INT8_NV 0x8FEC #define GL_UNSIGNED_INT8_VEC2_NV 0x8FED #define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE #define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF #define GL_UNSIGNED_INT16_NV 0x8FF0 #define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 #define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 #define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 #define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 #define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 #define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 #define GL_FLOAT16_NV 0x8FF8 #define GL_FLOAT16_VEC2_NV 0x8FF9 #define GL_FLOAT16_VEC3_NV 0x8FFA #define GL_FLOAT16_VEC4_NV 0x8FFB typedef void (GLAPIENTRY * PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT* params); typedef void (GLAPIENTRY * PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT* params); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); typedef void (GLAPIENTRY * PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); typedef void (GLAPIENTRY * PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); typedef void (GLAPIENTRY * PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); typedef void (GLAPIENTRY * PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); typedef void (GLAPIENTRY * PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); typedef void (GLAPIENTRY * PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); typedef void (GLAPIENTRY * PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); typedef void (GLAPIENTRY * PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); #define glGetUniformi64vNV GLEW_GET_FUN(__glewGetUniformi64vNV) #define glGetUniformui64vNV GLEW_GET_FUN(__glewGetUniformui64vNV) #define glProgramUniform1i64NV GLEW_GET_FUN(__glewProgramUniform1i64NV) #define glProgramUniform1i64vNV GLEW_GET_FUN(__glewProgramUniform1i64vNV) #define glProgramUniform1ui64NV GLEW_GET_FUN(__glewProgramUniform1ui64NV) #define glProgramUniform1ui64vNV GLEW_GET_FUN(__glewProgramUniform1ui64vNV) #define glProgramUniform2i64NV GLEW_GET_FUN(__glewProgramUniform2i64NV) #define glProgramUniform2i64vNV GLEW_GET_FUN(__glewProgramUniform2i64vNV) #define glProgramUniform2ui64NV GLEW_GET_FUN(__glewProgramUniform2ui64NV) #define glProgramUniform2ui64vNV GLEW_GET_FUN(__glewProgramUniform2ui64vNV) #define glProgramUniform3i64NV GLEW_GET_FUN(__glewProgramUniform3i64NV) #define glProgramUniform3i64vNV GLEW_GET_FUN(__glewProgramUniform3i64vNV) #define glProgramUniform3ui64NV GLEW_GET_FUN(__glewProgramUniform3ui64NV) #define glProgramUniform3ui64vNV GLEW_GET_FUN(__glewProgramUniform3ui64vNV) #define glProgramUniform4i64NV GLEW_GET_FUN(__glewProgramUniform4i64NV) #define glProgramUniform4i64vNV GLEW_GET_FUN(__glewProgramUniform4i64vNV) #define glProgramUniform4ui64NV GLEW_GET_FUN(__glewProgramUniform4ui64NV) #define glProgramUniform4ui64vNV GLEW_GET_FUN(__glewProgramUniform4ui64vNV) #define glUniform1i64NV GLEW_GET_FUN(__glewUniform1i64NV) #define glUniform1i64vNV GLEW_GET_FUN(__glewUniform1i64vNV) #define glUniform1ui64NV GLEW_GET_FUN(__glewUniform1ui64NV) #define glUniform1ui64vNV GLEW_GET_FUN(__glewUniform1ui64vNV) #define glUniform2i64NV GLEW_GET_FUN(__glewUniform2i64NV) #define glUniform2i64vNV GLEW_GET_FUN(__glewUniform2i64vNV) #define glUniform2ui64NV GLEW_GET_FUN(__glewUniform2ui64NV) #define glUniform2ui64vNV GLEW_GET_FUN(__glewUniform2ui64vNV) #define glUniform3i64NV GLEW_GET_FUN(__glewUniform3i64NV) #define glUniform3i64vNV GLEW_GET_FUN(__glewUniform3i64vNV) #define glUniform3ui64NV GLEW_GET_FUN(__glewUniform3ui64NV) #define glUniform3ui64vNV GLEW_GET_FUN(__glewUniform3ui64vNV) #define glUniform4i64NV GLEW_GET_FUN(__glewUniform4i64NV) #define glUniform4i64vNV GLEW_GET_FUN(__glewUniform4i64vNV) #define glUniform4ui64NV GLEW_GET_FUN(__glewUniform4ui64NV) #define glUniform4ui64vNV GLEW_GET_FUN(__glewUniform4ui64vNV) #define GLEW_NV_gpu_shader5 GLEW_GET_VAR(__GLEW_NV_gpu_shader5) #endif /* GL_NV_gpu_shader5 */ /* ---------------------------- GL_NV_half_float --------------------------- */ #ifndef GL_NV_half_float #define GL_NV_half_float 1 #define GL_HALF_FLOAT_NV 0x140B typedef unsigned short GLhalf; typedef void (GLAPIENTRY * PFNGLCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); typedef void (GLAPIENTRY * PFNGLCOLOR3HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLCOLOR4HNVPROC) (GLhalf red, GLhalf green, GLhalf blue, GLhalf alpha); typedef void (GLAPIENTRY * PFNGLCOLOR4HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLFOGCOORDHNVPROC) (GLhalf fog); typedef void (GLAPIENTRY * PFNGLFOGCOORDHVNVPROC) (const GLhalf* fog); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalf s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalf s, GLhalf t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r, GLhalf q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLNORMAL3HNVPROC) (GLhalf nx, GLhalf ny, GLhalf nz); typedef void (GLAPIENTRY * PFNGLNORMAL3HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLTEXCOORD1HNVPROC) (GLhalf s); typedef void (GLAPIENTRY * PFNGLTEXCOORD1HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLTEXCOORD2HNVPROC) (GLhalf s, GLhalf t); typedef void (GLAPIENTRY * PFNGLTEXCOORD2HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLTEXCOORD3HNVPROC) (GLhalf s, GLhalf t, GLhalf r); typedef void (GLAPIENTRY * PFNGLTEXCOORD3HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLTEXCOORD4HNVPROC) (GLhalf s, GLhalf t, GLhalf r, GLhalf q); typedef void (GLAPIENTRY * PFNGLTEXCOORD4HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEX2HNVPROC) (GLhalf x, GLhalf y); typedef void (GLAPIENTRY * PFNGLVERTEX2HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEX3HNVPROC) (GLhalf x, GLhalf y, GLhalf z); typedef void (GLAPIENTRY * PFNGLVERTEX3HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEX4HNVPROC) (GLhalf x, GLhalf y, GLhalf z, GLhalf w); typedef void (GLAPIENTRY * PFNGLVERTEX4HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalf x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalf x, GLhalf y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z, GLhalf w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHNVPROC) (GLhalf weight); typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalf* weight); #define glColor3hNV GLEW_GET_FUN(__glewColor3hNV) #define glColor3hvNV GLEW_GET_FUN(__glewColor3hvNV) #define glColor4hNV GLEW_GET_FUN(__glewColor4hNV) #define glColor4hvNV GLEW_GET_FUN(__glewColor4hvNV) #define glFogCoordhNV GLEW_GET_FUN(__glewFogCoordhNV) #define glFogCoordhvNV GLEW_GET_FUN(__glewFogCoordhvNV) #define glMultiTexCoord1hNV GLEW_GET_FUN(__glewMultiTexCoord1hNV) #define glMultiTexCoord1hvNV GLEW_GET_FUN(__glewMultiTexCoord1hvNV) #define glMultiTexCoord2hNV GLEW_GET_FUN(__glewMultiTexCoord2hNV) #define glMultiTexCoord2hvNV GLEW_GET_FUN(__glewMultiTexCoord2hvNV) #define glMultiTexCoord3hNV GLEW_GET_FUN(__glewMultiTexCoord3hNV) #define glMultiTexCoord3hvNV GLEW_GET_FUN(__glewMultiTexCoord3hvNV) #define glMultiTexCoord4hNV GLEW_GET_FUN(__glewMultiTexCoord4hNV) #define glMultiTexCoord4hvNV GLEW_GET_FUN(__glewMultiTexCoord4hvNV) #define glNormal3hNV GLEW_GET_FUN(__glewNormal3hNV) #define glNormal3hvNV GLEW_GET_FUN(__glewNormal3hvNV) #define glSecondaryColor3hNV GLEW_GET_FUN(__glewSecondaryColor3hNV) #define glSecondaryColor3hvNV GLEW_GET_FUN(__glewSecondaryColor3hvNV) #define glTexCoord1hNV GLEW_GET_FUN(__glewTexCoord1hNV) #define glTexCoord1hvNV GLEW_GET_FUN(__glewTexCoord1hvNV) #define glTexCoord2hNV GLEW_GET_FUN(__glewTexCoord2hNV) #define glTexCoord2hvNV GLEW_GET_FUN(__glewTexCoord2hvNV) #define glTexCoord3hNV GLEW_GET_FUN(__glewTexCoord3hNV) #define glTexCoord3hvNV GLEW_GET_FUN(__glewTexCoord3hvNV) #define glTexCoord4hNV GLEW_GET_FUN(__glewTexCoord4hNV) #define glTexCoord4hvNV GLEW_GET_FUN(__glewTexCoord4hvNV) #define glVertex2hNV GLEW_GET_FUN(__glewVertex2hNV) #define glVertex2hvNV GLEW_GET_FUN(__glewVertex2hvNV) #define glVertex3hNV GLEW_GET_FUN(__glewVertex3hNV) #define glVertex3hvNV GLEW_GET_FUN(__glewVertex3hvNV) #define glVertex4hNV GLEW_GET_FUN(__glewVertex4hNV) #define glVertex4hvNV GLEW_GET_FUN(__glewVertex4hvNV) #define glVertexAttrib1hNV GLEW_GET_FUN(__glewVertexAttrib1hNV) #define glVertexAttrib1hvNV GLEW_GET_FUN(__glewVertexAttrib1hvNV) #define glVertexAttrib2hNV GLEW_GET_FUN(__glewVertexAttrib2hNV) #define glVertexAttrib2hvNV GLEW_GET_FUN(__glewVertexAttrib2hvNV) #define glVertexAttrib3hNV GLEW_GET_FUN(__glewVertexAttrib3hNV) #define glVertexAttrib3hvNV GLEW_GET_FUN(__glewVertexAttrib3hvNV) #define glVertexAttrib4hNV GLEW_GET_FUN(__glewVertexAttrib4hNV) #define glVertexAttrib4hvNV GLEW_GET_FUN(__glewVertexAttrib4hvNV) #define glVertexAttribs1hvNV GLEW_GET_FUN(__glewVertexAttribs1hvNV) #define glVertexAttribs2hvNV GLEW_GET_FUN(__glewVertexAttribs2hvNV) #define glVertexAttribs3hvNV GLEW_GET_FUN(__glewVertexAttribs3hvNV) #define glVertexAttribs4hvNV GLEW_GET_FUN(__glewVertexAttribs4hvNV) #define glVertexWeighthNV GLEW_GET_FUN(__glewVertexWeighthNV) #define glVertexWeighthvNV GLEW_GET_FUN(__glewVertexWeighthvNV) #define GLEW_NV_half_float GLEW_GET_VAR(__GLEW_NV_half_float) #endif /* GL_NV_half_float */ /* ------------------- GL_NV_internalformat_sample_query ------------------- */ #ifndef GL_NV_internalformat_sample_query #define GL_NV_internalformat_sample_query 1 #define GL_MULTISAMPLES_NV 0x9371 #define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 #define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 #define GL_CONFORMANT_NV 0x9374 typedef void (GLAPIENTRY * PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei bufSize, GLint* params); #define glGetInternalformatSampleivNV GLEW_GET_FUN(__glewGetInternalformatSampleivNV) #define GLEW_NV_internalformat_sample_query GLEW_GET_VAR(__GLEW_NV_internalformat_sample_query) #endif /* GL_NV_internalformat_sample_query */ /* ------------------------ GL_NV_light_max_exponent ----------------------- */ #ifndef GL_NV_light_max_exponent #define GL_NV_light_max_exponent 1 #define GL_MAX_SHININESS_NV 0x8504 #define GL_MAX_SPOT_EXPONENT_NV 0x8505 #define GLEW_NV_light_max_exponent GLEW_GET_VAR(__GLEW_NV_light_max_exponent) #endif /* GL_NV_light_max_exponent */ /* ----------------------- GL_NV_multisample_coverage ---------------------- */ #ifndef GL_NV_multisample_coverage #define GL_NV_multisample_coverage 1 #define GL_COLOR_SAMPLES_NV 0x8E20 #define GLEW_NV_multisample_coverage GLEW_GET_VAR(__GLEW_NV_multisample_coverage) #endif /* GL_NV_multisample_coverage */ /* --------------------- GL_NV_multisample_filter_hint --------------------- */ #ifndef GL_NV_multisample_filter_hint #define GL_NV_multisample_filter_hint 1 #define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 #define GLEW_NV_multisample_filter_hint GLEW_GET_VAR(__GLEW_NV_multisample_filter_hint) #endif /* GL_NV_multisample_filter_hint */ /* ------------------------- GL_NV_occlusion_query ------------------------- */ #ifndef GL_NV_occlusion_query #define GL_NV_occlusion_query 1 #define GL_PIXEL_COUNTER_BITS_NV 0x8864 #define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 #define GL_PIXEL_COUNT_NV 0x8866 #define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 typedef void (GLAPIENTRY * PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint* ids); typedef void (GLAPIENTRY * PFNGLENDOCCLUSIONQUERYNVPROC) (void); typedef void (GLAPIENTRY * PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint* ids); typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint* params); typedef GLboolean (GLAPIENTRY * PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); #define glBeginOcclusionQueryNV GLEW_GET_FUN(__glewBeginOcclusionQueryNV) #define glDeleteOcclusionQueriesNV GLEW_GET_FUN(__glewDeleteOcclusionQueriesNV) #define glEndOcclusionQueryNV GLEW_GET_FUN(__glewEndOcclusionQueryNV) #define glGenOcclusionQueriesNV GLEW_GET_FUN(__glewGenOcclusionQueriesNV) #define glGetOcclusionQueryivNV GLEW_GET_FUN(__glewGetOcclusionQueryivNV) #define glGetOcclusionQueryuivNV GLEW_GET_FUN(__glewGetOcclusionQueryuivNV) #define glIsOcclusionQueryNV GLEW_GET_FUN(__glewIsOcclusionQueryNV) #define GLEW_NV_occlusion_query GLEW_GET_VAR(__GLEW_NV_occlusion_query) #endif /* GL_NV_occlusion_query */ /* ----------------------- GL_NV_packed_depth_stencil ---------------------- */ #ifndef GL_NV_packed_depth_stencil #define GL_NV_packed_depth_stencil 1 #define GL_DEPTH_STENCIL_NV 0x84F9 #define GL_UNSIGNED_INT_24_8_NV 0x84FA #define GLEW_NV_packed_depth_stencil GLEW_GET_VAR(__GLEW_NV_packed_depth_stencil) #endif /* GL_NV_packed_depth_stencil */ /* --------------------- GL_NV_parameter_buffer_object --------------------- */ #ifndef GL_NV_parameter_buffer_object #define GL_NV_parameter_buffer_object 1 #define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 #define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 #define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 #define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 #define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); #define glProgramBufferParametersIivNV GLEW_GET_FUN(__glewProgramBufferParametersIivNV) #define glProgramBufferParametersIuivNV GLEW_GET_FUN(__glewProgramBufferParametersIuivNV) #define glProgramBufferParametersfvNV GLEW_GET_FUN(__glewProgramBufferParametersfvNV) #define GLEW_NV_parameter_buffer_object GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object) #endif /* GL_NV_parameter_buffer_object */ /* --------------------- GL_NV_parameter_buffer_object2 -------------------- */ #ifndef GL_NV_parameter_buffer_object2 #define GL_NV_parameter_buffer_object2 1 #define GLEW_NV_parameter_buffer_object2 GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object2) #endif /* GL_NV_parameter_buffer_object2 */ /* -------------------------- GL_NV_path_rendering ------------------------- */ #ifndef GL_NV_path_rendering #define GL_NV_path_rendering 1 #define GL_CLOSE_PATH_NV 0x00 #define GL_BOLD_BIT_NV 0x01 #define GL_GLYPH_WIDTH_BIT_NV 0x01 #define GL_GLYPH_HEIGHT_BIT_NV 0x02 #define GL_ITALIC_BIT_NV 0x02 #define GL_MOVE_TO_NV 0x02 #define GL_RELATIVE_MOVE_TO_NV 0x03 #define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 #define GL_LINE_TO_NV 0x04 #define GL_RELATIVE_LINE_TO_NV 0x05 #define GL_HORIZONTAL_LINE_TO_NV 0x06 #define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 #define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 #define GL_VERTICAL_LINE_TO_NV 0x08 #define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 #define GL_QUADRATIC_CURVE_TO_NV 0x0A #define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B #define GL_CUBIC_CURVE_TO_NV 0x0C #define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D #define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E #define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F #define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 #define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 #define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 #define GL_SMALL_CCW_ARC_TO_NV 0x12 #define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 #define GL_SMALL_CW_ARC_TO_NV 0x14 #define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 #define GL_LARGE_CCW_ARC_TO_NV 0x16 #define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 #define GL_LARGE_CW_ARC_TO_NV 0x18 #define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 #define GL_CONIC_CURVE_TO_NV 0x1A #define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B #define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 #define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 #define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 #define GL_ROUNDED_RECT_NV 0xE8 #define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 #define GL_ROUNDED_RECT2_NV 0xEA #define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB #define GL_ROUNDED_RECT4_NV 0xEC #define GL_RELATIVE_ROUNDED_RECT4_NV 0xED #define GL_ROUNDED_RECT8_NV 0xEE #define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF #define GL_RESTART_PATH_NV 0xF0 #define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 #define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 #define GL_RECT_NV 0xF6 #define GL_RELATIVE_RECT_NV 0xF7 #define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 #define GL_CIRCULAR_CW_ARC_TO_NV 0xFA #define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC #define GL_ARC_TO_NV 0xFE #define GL_RELATIVE_ARC_TO_NV 0xFF #define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 #define GL_PRIMARY_COLOR_NV 0x852C #define GL_SECONDARY_COLOR_NV 0x852D #define GL_PRIMARY_COLOR 0x8577 #define GL_PATH_FORMAT_SVG_NV 0x9070 #define GL_PATH_FORMAT_PS_NV 0x9071 #define GL_STANDARD_FONT_NAME_NV 0x9072 #define GL_SYSTEM_FONT_NAME_NV 0x9073 #define GL_FILE_NAME_NV 0x9074 #define GL_PATH_STROKE_WIDTH_NV 0x9075 #define GL_PATH_END_CAPS_NV 0x9076 #define GL_PATH_INITIAL_END_CAP_NV 0x9077 #define GL_PATH_TERMINAL_END_CAP_NV 0x9078 #define GL_PATH_JOIN_STYLE_NV 0x9079 #define GL_PATH_MITER_LIMIT_NV 0x907A #define GL_PATH_DASH_CAPS_NV 0x907B #define GL_PATH_INITIAL_DASH_CAP_NV 0x907C #define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D #define GL_PATH_DASH_OFFSET_NV 0x907E #define GL_PATH_CLIENT_LENGTH_NV 0x907F #define GL_PATH_FILL_MODE_NV 0x9080 #define GL_PATH_FILL_MASK_NV 0x9081 #define GL_PATH_FILL_COVER_MODE_NV 0x9082 #define GL_PATH_STROKE_COVER_MODE_NV 0x9083 #define GL_PATH_STROKE_MASK_NV 0x9084 #define GL_PATH_STROKE_BOUND_NV 0x9086 #define GL_COUNT_UP_NV 0x9088 #define GL_COUNT_DOWN_NV 0x9089 #define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A #define GL_CONVEX_HULL_NV 0x908B #define GL_BOUNDING_BOX_NV 0x908D #define GL_TRANSLATE_X_NV 0x908E #define GL_TRANSLATE_Y_NV 0x908F #define GL_TRANSLATE_2D_NV 0x9090 #define GL_TRANSLATE_3D_NV 0x9091 #define GL_AFFINE_2D_NV 0x9092 #define GL_AFFINE_3D_NV 0x9094 #define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 #define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 #define GL_UTF8_NV 0x909A #define GL_UTF16_NV 0x909B #define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C #define GL_PATH_COMMAND_COUNT_NV 0x909D #define GL_PATH_COORD_COUNT_NV 0x909E #define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F #define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 #define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 #define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 #define GL_SQUARE_NV 0x90A3 #define GL_ROUND_NV 0x90A4 #define GL_TRIANGULAR_NV 0x90A5 #define GL_BEVEL_NV 0x90A6 #define GL_MITER_REVERT_NV 0x90A7 #define GL_MITER_TRUNCATE_NV 0x90A8 #define GL_SKIP_MISSING_GLYPH_NV 0x90A9 #define GL_USE_MISSING_GLYPH_NV 0x90AA #define GL_PATH_ERROR_POSITION_NV 0x90AB #define GL_PATH_FOG_GEN_MODE_NV 0x90AC #define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD #define GL_ADJACENT_PAIRS_NV 0x90AE #define GL_FIRST_TO_REST_NV 0x90AF #define GL_PATH_GEN_MODE_NV 0x90B0 #define GL_PATH_GEN_COEFF_NV 0x90B1 #define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 #define GL_PATH_GEN_COMPONENTS_NV 0x90B3 #define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 #define GL_MOVE_TO_RESETS_NV 0x90B5 #define GL_MOVE_TO_CONTINUES_NV 0x90B6 #define GL_PATH_STENCIL_FUNC_NV 0x90B7 #define GL_PATH_STENCIL_REF_NV 0x90B8 #define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 #define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD #define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE #define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF #define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 #define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 #define GL_FONT_UNAVAILABLE_NV 0x936A #define GL_FONT_UNINTELLIGIBLE_NV 0x936B #define GL_STANDARD_FONT_FORMAT_NV 0x936C #define GL_FRAGMENT_INPUT_NV 0x936D #define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 #define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 #define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 #define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 #define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 #define GL_FONT_ASCENDER_BIT_NV 0x00200000 #define GL_FONT_DESCENDER_BIT_NV 0x00400000 #define GL_FONT_HEIGHT_BIT_NV 0x00800000 #define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 #define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 #define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 #define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 #define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 #define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 typedef void (GLAPIENTRY * PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); typedef void (GLAPIENTRY * PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); typedef void (GLAPIENTRY * PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); typedef void (GLAPIENTRY * PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); typedef void (GLAPIENTRY * PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); typedef void (GLAPIENTRY * PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); typedef GLuint (GLAPIENTRY * PFNGLGENPATHSNVPROC) (GLsizei range); typedef void (GLAPIENTRY * PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat* value); typedef void (GLAPIENTRY * PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint* value); typedef void (GLAPIENTRY * PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte* commands); typedef void (GLAPIENTRY * PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat* coords); typedef void (GLAPIENTRY * PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat* dashArray); typedef GLfloat (GLAPIENTRY * PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); typedef void (GLAPIENTRY * PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat* metrics); typedef void (GLAPIENTRY * PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); typedef void (GLAPIENTRY * PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat* value); typedef void (GLAPIENTRY * PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint* value); typedef void (GLAPIENTRY * PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); typedef void (GLAPIENTRY * PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat* value); typedef void (GLAPIENTRY * PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint* value); typedef void (GLAPIENTRY * PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum* props, GLsizei bufSize, GLsizei *length, GLfloat *params); typedef void (GLAPIENTRY * PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); typedef GLboolean (GLAPIENTRY * PFNGLISPATHNVPROC) (GLuint path); typedef GLboolean (GLAPIENTRY * PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); typedef GLboolean (GLAPIENTRY * PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat* m); typedef void (GLAPIENTRY * PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat* m); typedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat* m); typedef void (GLAPIENTRY * PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat* m); typedef void (GLAPIENTRY * PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat* m); typedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat* m); typedef void (GLAPIENTRY * PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat* coeffs); typedef void (GLAPIENTRY * PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte* commands, GLsizei numCoords, GLenum coordType, const void*coords); typedef void (GLAPIENTRY * PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); typedef void (GLAPIENTRY * PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum zfunc); typedef void (GLAPIENTRY * PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat* dashArray); typedef void (GLAPIENTRY * PFNGLPATHFOGGENNVPROC) (GLenum genMode); typedef GLenum (GLAPIENTRY * PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef GLenum (GLAPIENTRY * PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); typedef void (GLAPIENTRY * PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef void (GLAPIENTRY * PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void*charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef GLenum (GLAPIENTRY * PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef void (GLAPIENTRY * PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); typedef void (GLAPIENTRY * PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); typedef void (GLAPIENTRY * PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint* value); typedef void (GLAPIENTRY * PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); typedef void (GLAPIENTRY * PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); typedef void (GLAPIENTRY * PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); typedef void (GLAPIENTRY * PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte* commands, GLsizei numCoords, GLenum coordType, const void*coords); typedef void (GLAPIENTRY * PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); typedef void (GLAPIENTRY * PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat* coeffs); typedef GLboolean (GLAPIENTRY * PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat* x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); typedef void (GLAPIENTRY * PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat* coeffs); typedef void (GLAPIENTRY * PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); typedef void (GLAPIENTRY * PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); typedef void (GLAPIENTRY * PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); typedef void (GLAPIENTRY * PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); typedef void (GLAPIENTRY * PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); typedef void (GLAPIENTRY * PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); typedef void (GLAPIENTRY * PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); typedef void (GLAPIENTRY * PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); typedef void (GLAPIENTRY * PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat* transformValues); typedef void (GLAPIENTRY * PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint paths[], const GLfloat weights[]); #define glCopyPathNV GLEW_GET_FUN(__glewCopyPathNV) #define glCoverFillPathInstancedNV GLEW_GET_FUN(__glewCoverFillPathInstancedNV) #define glCoverFillPathNV GLEW_GET_FUN(__glewCoverFillPathNV) #define glCoverStrokePathInstancedNV GLEW_GET_FUN(__glewCoverStrokePathInstancedNV) #define glCoverStrokePathNV GLEW_GET_FUN(__glewCoverStrokePathNV) #define glDeletePathsNV GLEW_GET_FUN(__glewDeletePathsNV) #define glGenPathsNV GLEW_GET_FUN(__glewGenPathsNV) #define glGetPathColorGenfvNV GLEW_GET_FUN(__glewGetPathColorGenfvNV) #define glGetPathColorGenivNV GLEW_GET_FUN(__glewGetPathColorGenivNV) #define glGetPathCommandsNV GLEW_GET_FUN(__glewGetPathCommandsNV) #define glGetPathCoordsNV GLEW_GET_FUN(__glewGetPathCoordsNV) #define glGetPathDashArrayNV GLEW_GET_FUN(__glewGetPathDashArrayNV) #define glGetPathLengthNV GLEW_GET_FUN(__glewGetPathLengthNV) #define glGetPathMetricRangeNV GLEW_GET_FUN(__glewGetPathMetricRangeNV) #define glGetPathMetricsNV GLEW_GET_FUN(__glewGetPathMetricsNV) #define glGetPathParameterfvNV GLEW_GET_FUN(__glewGetPathParameterfvNV) #define glGetPathParameterivNV GLEW_GET_FUN(__glewGetPathParameterivNV) #define glGetPathSpacingNV GLEW_GET_FUN(__glewGetPathSpacingNV) #define glGetPathTexGenfvNV GLEW_GET_FUN(__glewGetPathTexGenfvNV) #define glGetPathTexGenivNV GLEW_GET_FUN(__glewGetPathTexGenivNV) #define glGetProgramResourcefvNV GLEW_GET_FUN(__glewGetProgramResourcefvNV) #define glInterpolatePathsNV GLEW_GET_FUN(__glewInterpolatePathsNV) #define glIsPathNV GLEW_GET_FUN(__glewIsPathNV) #define glIsPointInFillPathNV GLEW_GET_FUN(__glewIsPointInFillPathNV) #define glIsPointInStrokePathNV GLEW_GET_FUN(__glewIsPointInStrokePathNV) #define glMatrixLoad3x2fNV GLEW_GET_FUN(__glewMatrixLoad3x2fNV) #define glMatrixLoad3x3fNV GLEW_GET_FUN(__glewMatrixLoad3x3fNV) #define glMatrixLoadTranspose3x3fNV GLEW_GET_FUN(__glewMatrixLoadTranspose3x3fNV) #define glMatrixMult3x2fNV GLEW_GET_FUN(__glewMatrixMult3x2fNV) #define glMatrixMult3x3fNV GLEW_GET_FUN(__glewMatrixMult3x3fNV) #define glMatrixMultTranspose3x3fNV GLEW_GET_FUN(__glewMatrixMultTranspose3x3fNV) #define glPathColorGenNV GLEW_GET_FUN(__glewPathColorGenNV) #define glPathCommandsNV GLEW_GET_FUN(__glewPathCommandsNV) #define glPathCoordsNV GLEW_GET_FUN(__glewPathCoordsNV) #define glPathCoverDepthFuncNV GLEW_GET_FUN(__glewPathCoverDepthFuncNV) #define glPathDashArrayNV GLEW_GET_FUN(__glewPathDashArrayNV) #define glPathFogGenNV GLEW_GET_FUN(__glewPathFogGenNV) #define glPathGlyphIndexArrayNV GLEW_GET_FUN(__glewPathGlyphIndexArrayNV) #define glPathGlyphIndexRangeNV GLEW_GET_FUN(__glewPathGlyphIndexRangeNV) #define glPathGlyphRangeNV GLEW_GET_FUN(__glewPathGlyphRangeNV) #define glPathGlyphsNV GLEW_GET_FUN(__glewPathGlyphsNV) #define glPathMemoryGlyphIndexArrayNV GLEW_GET_FUN(__glewPathMemoryGlyphIndexArrayNV) #define glPathParameterfNV GLEW_GET_FUN(__glewPathParameterfNV) #define glPathParameterfvNV GLEW_GET_FUN(__glewPathParameterfvNV) #define glPathParameteriNV GLEW_GET_FUN(__glewPathParameteriNV) #define glPathParameterivNV GLEW_GET_FUN(__glewPathParameterivNV) #define glPathStencilDepthOffsetNV GLEW_GET_FUN(__glewPathStencilDepthOffsetNV) #define glPathStencilFuncNV GLEW_GET_FUN(__glewPathStencilFuncNV) #define glPathStringNV GLEW_GET_FUN(__glewPathStringNV) #define glPathSubCommandsNV GLEW_GET_FUN(__glewPathSubCommandsNV) #define glPathSubCoordsNV GLEW_GET_FUN(__glewPathSubCoordsNV) #define glPathTexGenNV GLEW_GET_FUN(__glewPathTexGenNV) #define glPointAlongPathNV GLEW_GET_FUN(__glewPointAlongPathNV) #define glProgramPathFragmentInputGenNV GLEW_GET_FUN(__glewProgramPathFragmentInputGenNV) #define glStencilFillPathInstancedNV GLEW_GET_FUN(__glewStencilFillPathInstancedNV) #define glStencilFillPathNV GLEW_GET_FUN(__glewStencilFillPathNV) #define glStencilStrokePathInstancedNV GLEW_GET_FUN(__glewStencilStrokePathInstancedNV) #define glStencilStrokePathNV GLEW_GET_FUN(__glewStencilStrokePathNV) #define glStencilThenCoverFillPathInstancedNV GLEW_GET_FUN(__glewStencilThenCoverFillPathInstancedNV) #define glStencilThenCoverFillPathNV GLEW_GET_FUN(__glewStencilThenCoverFillPathNV) #define glStencilThenCoverStrokePathInstancedNV GLEW_GET_FUN(__glewStencilThenCoverStrokePathInstancedNV) #define glStencilThenCoverStrokePathNV GLEW_GET_FUN(__glewStencilThenCoverStrokePathNV) #define glTransformPathNV GLEW_GET_FUN(__glewTransformPathNV) #define glWeightPathsNV GLEW_GET_FUN(__glewWeightPathsNV) #define GLEW_NV_path_rendering GLEW_GET_VAR(__GLEW_NV_path_rendering) #endif /* GL_NV_path_rendering */ /* -------------------- GL_NV_path_rendering_shared_edge ------------------- */ #ifndef GL_NV_path_rendering_shared_edge #define GL_NV_path_rendering_shared_edge 1 #define GL_SHARED_EDGE_NV 0xC0 #define GLEW_NV_path_rendering_shared_edge GLEW_GET_VAR(__GLEW_NV_path_rendering_shared_edge) #endif /* GL_NV_path_rendering_shared_edge */ /* ------------------------- GL_NV_pixel_data_range ------------------------ */ #ifndef GL_NV_pixel_data_range #define GL_NV_pixel_data_range 1 #define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 #define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 #define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A #define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B #define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C #define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D typedef void (GLAPIENTRY * PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, void *pointer); #define glFlushPixelDataRangeNV GLEW_GET_FUN(__glewFlushPixelDataRangeNV) #define glPixelDataRangeNV GLEW_GET_FUN(__glewPixelDataRangeNV) #define GLEW_NV_pixel_data_range GLEW_GET_VAR(__GLEW_NV_pixel_data_range) #endif /* GL_NV_pixel_data_range */ /* --------------------------- GL_NV_point_sprite -------------------------- */ #ifndef GL_NV_point_sprite #define GL_NV_point_sprite 1 #define GL_POINT_SPRITE_NV 0x8861 #define GL_COORD_REPLACE_NV 0x8862 #define GL_POINT_SPRITE_R_MODE_NV 0x8863 typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint* params); #define glPointParameteriNV GLEW_GET_FUN(__glewPointParameteriNV) #define glPointParameterivNV GLEW_GET_FUN(__glewPointParameterivNV) #define GLEW_NV_point_sprite GLEW_GET_VAR(__GLEW_NV_point_sprite) #endif /* GL_NV_point_sprite */ /* -------------------------- GL_NV_present_video -------------------------- */ #ifndef GL_NV_present_video #define GL_NV_present_video 1 #define GL_FRAME_NV 0x8E26 #define GL_FIELDS_NV 0x8E27 #define GL_CURRENT_TIME_NV 0x8E28 #define GL_NUM_FILL_STREAMS_NV 0x8E29 #define GL_PRESENT_TIME_NV 0x8E2A #define GL_PRESENT_DURATION_NV 0x8E2B typedef void (GLAPIENTRY * PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT* params); typedef void (GLAPIENTRY * PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT* params); typedef void (GLAPIENTRY * PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); typedef void (GLAPIENTRY * PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); #define glGetVideoi64vNV GLEW_GET_FUN(__glewGetVideoi64vNV) #define glGetVideoivNV GLEW_GET_FUN(__glewGetVideoivNV) #define glGetVideoui64vNV GLEW_GET_FUN(__glewGetVideoui64vNV) #define glGetVideouivNV GLEW_GET_FUN(__glewGetVideouivNV) #define glPresentFrameDualFillNV GLEW_GET_FUN(__glewPresentFrameDualFillNV) #define glPresentFrameKeyedNV GLEW_GET_FUN(__glewPresentFrameKeyedNV) #define GLEW_NV_present_video GLEW_GET_VAR(__GLEW_NV_present_video) #endif /* GL_NV_present_video */ /* ------------------------ GL_NV_primitive_restart ------------------------ */ #ifndef GL_NV_primitive_restart #define GL_NV_primitive_restart 1 #define GL_PRIMITIVE_RESTART_NV 0x8558 #define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTNVPROC) (void); #define glPrimitiveRestartIndexNV GLEW_GET_FUN(__glewPrimitiveRestartIndexNV) #define glPrimitiveRestartNV GLEW_GET_FUN(__glewPrimitiveRestartNV) #define GLEW_NV_primitive_restart GLEW_GET_VAR(__GLEW_NV_primitive_restart) #endif /* GL_NV_primitive_restart */ /* ------------------------ GL_NV_register_combiners ----------------------- */ #ifndef GL_NV_register_combiners #define GL_NV_register_combiners 1 #define GL_REGISTER_COMBINERS_NV 0x8522 #define GL_VARIABLE_A_NV 0x8523 #define GL_VARIABLE_B_NV 0x8524 #define GL_VARIABLE_C_NV 0x8525 #define GL_VARIABLE_D_NV 0x8526 #define GL_VARIABLE_E_NV 0x8527 #define GL_VARIABLE_F_NV 0x8528 #define GL_VARIABLE_G_NV 0x8529 #define GL_CONSTANT_COLOR0_NV 0x852A #define GL_CONSTANT_COLOR1_NV 0x852B #define GL_PRIMARY_COLOR_NV 0x852C #define GL_SECONDARY_COLOR_NV 0x852D #define GL_SPARE0_NV 0x852E #define GL_SPARE1_NV 0x852F #define GL_DISCARD_NV 0x8530 #define GL_E_TIMES_F_NV 0x8531 #define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 #define GL_UNSIGNED_IDENTITY_NV 0x8536 #define GL_UNSIGNED_INVERT_NV 0x8537 #define GL_EXPAND_NORMAL_NV 0x8538 #define GL_EXPAND_NEGATE_NV 0x8539 #define GL_HALF_BIAS_NORMAL_NV 0x853A #define GL_HALF_BIAS_NEGATE_NV 0x853B #define GL_SIGNED_IDENTITY_NV 0x853C #define GL_SIGNED_NEGATE_NV 0x853D #define GL_SCALE_BY_TWO_NV 0x853E #define GL_SCALE_BY_FOUR_NV 0x853F #define GL_SCALE_BY_ONE_HALF_NV 0x8540 #define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 #define GL_COMBINER_INPUT_NV 0x8542 #define GL_COMBINER_MAPPING_NV 0x8543 #define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 #define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 #define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 #define GL_COMBINER_MUX_SUM_NV 0x8547 #define GL_COMBINER_SCALE_NV 0x8548 #define GL_COMBINER_BIAS_NV 0x8549 #define GL_COMBINER_AB_OUTPUT_NV 0x854A #define GL_COMBINER_CD_OUTPUT_NV 0x854B #define GL_COMBINER_SUM_OUTPUT_NV 0x854C #define GL_MAX_GENERAL_COMBINERS_NV 0x854D #define GL_NUM_GENERAL_COMBINERS_NV 0x854E #define GL_COLOR_SUM_CLAMP_NV 0x854F #define GL_COMBINER0_NV 0x8550 #define GL_COMBINER1_NV 0x8551 #define GL_COMBINER2_NV 0x8552 #define GL_COMBINER3_NV 0x8553 #define GL_COMBINER4_NV 0x8554 #define GL_COMBINER5_NV 0x8555 #define GL_COMBINER6_NV 0x8556 #define GL_COMBINER7_NV 0x8557 typedef void (GLAPIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); typedef void (GLAPIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint* params); #define glCombinerInputNV GLEW_GET_FUN(__glewCombinerInputNV) #define glCombinerOutputNV GLEW_GET_FUN(__glewCombinerOutputNV) #define glCombinerParameterfNV GLEW_GET_FUN(__glewCombinerParameterfNV) #define glCombinerParameterfvNV GLEW_GET_FUN(__glewCombinerParameterfvNV) #define glCombinerParameteriNV GLEW_GET_FUN(__glewCombinerParameteriNV) #define glCombinerParameterivNV GLEW_GET_FUN(__glewCombinerParameterivNV) #define glFinalCombinerInputNV GLEW_GET_FUN(__glewFinalCombinerInputNV) #define glGetCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetCombinerInputParameterfvNV) #define glGetCombinerInputParameterivNV GLEW_GET_FUN(__glewGetCombinerInputParameterivNV) #define glGetCombinerOutputParameterfvNV GLEW_GET_FUN(__glewGetCombinerOutputParameterfvNV) #define glGetCombinerOutputParameterivNV GLEW_GET_FUN(__glewGetCombinerOutputParameterivNV) #define glGetFinalCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterfvNV) #define glGetFinalCombinerInputParameterivNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterivNV) #define GLEW_NV_register_combiners GLEW_GET_VAR(__GLEW_NV_register_combiners) #endif /* GL_NV_register_combiners */ /* ----------------------- GL_NV_register_combiners2 ----------------------- */ #ifndef GL_NV_register_combiners2 #define GL_NV_register_combiners2 1 #define GL_PER_STAGE_CONSTANTS_NV 0x8535 typedef void (GLAPIENTRY * PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat* params); #define glCombinerStageParameterfvNV GLEW_GET_FUN(__glewCombinerStageParameterfvNV) #define glGetCombinerStageParameterfvNV GLEW_GET_FUN(__glewGetCombinerStageParameterfvNV) #define GLEW_NV_register_combiners2 GLEW_GET_VAR(__GLEW_NV_register_combiners2) #endif /* GL_NV_register_combiners2 */ /* ------------------------- GL_NV_sample_locations ------------------------ */ #ifndef GL_NV_sample_locations #define GL_NV_sample_locations 1 #define GL_SAMPLE_LOCATION_NV 0x8E50 #define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D #define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E #define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F #define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 #define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 #define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 #define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat* v); #define glFramebufferSampleLocationsfvNV GLEW_GET_FUN(__glewFramebufferSampleLocationsfvNV) #define glNamedFramebufferSampleLocationsfvNV GLEW_GET_FUN(__glewNamedFramebufferSampleLocationsfvNV) #define GLEW_NV_sample_locations GLEW_GET_VAR(__GLEW_NV_sample_locations) #endif /* GL_NV_sample_locations */ /* ------------------ GL_NV_sample_mask_override_coverage ------------------ */ #ifndef GL_NV_sample_mask_override_coverage #define GL_NV_sample_mask_override_coverage 1 #define GLEW_NV_sample_mask_override_coverage GLEW_GET_VAR(__GLEW_NV_sample_mask_override_coverage) #endif /* GL_NV_sample_mask_override_coverage */ /* ---------------------- GL_NV_shader_atomic_counters --------------------- */ #ifndef GL_NV_shader_atomic_counters #define GL_NV_shader_atomic_counters 1 #define GLEW_NV_shader_atomic_counters GLEW_GET_VAR(__GLEW_NV_shader_atomic_counters) #endif /* GL_NV_shader_atomic_counters */ /* ----------------------- GL_NV_shader_atomic_float ----------------------- */ #ifndef GL_NV_shader_atomic_float #define GL_NV_shader_atomic_float 1 #define GLEW_NV_shader_atomic_float GLEW_GET_VAR(__GLEW_NV_shader_atomic_float) #endif /* GL_NV_shader_atomic_float */ /* -------------------- GL_NV_shader_atomic_fp16_vector -------------------- */ #ifndef GL_NV_shader_atomic_fp16_vector #define GL_NV_shader_atomic_fp16_vector 1 #define GLEW_NV_shader_atomic_fp16_vector GLEW_GET_VAR(__GLEW_NV_shader_atomic_fp16_vector) #endif /* GL_NV_shader_atomic_fp16_vector */ /* ----------------------- GL_NV_shader_atomic_int64 ----------------------- */ #ifndef GL_NV_shader_atomic_int64 #define GL_NV_shader_atomic_int64 1 #define GLEW_NV_shader_atomic_int64 GLEW_GET_VAR(__GLEW_NV_shader_atomic_int64) #endif /* GL_NV_shader_atomic_int64 */ /* ------------------------ GL_NV_shader_buffer_load ----------------------- */ #ifndef GL_NV_shader_buffer_load #define GL_NV_shader_buffer_load 1 #define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D #define GL_GPU_ADDRESS_NV 0x8F34 #define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT* params); typedef void (GLAPIENTRY * PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT* result); typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT* params); typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); typedef GLboolean (GLAPIENTRY * PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); typedef void (GLAPIENTRY * PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); typedef void (GLAPIENTRY * PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); typedef void (GLAPIENTRY * PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); typedef void (GLAPIENTRY * PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); #define glGetBufferParameterui64vNV GLEW_GET_FUN(__glewGetBufferParameterui64vNV) #define glGetIntegerui64vNV GLEW_GET_FUN(__glewGetIntegerui64vNV) #define glGetNamedBufferParameterui64vNV GLEW_GET_FUN(__glewGetNamedBufferParameterui64vNV) #define glIsBufferResidentNV GLEW_GET_FUN(__glewIsBufferResidentNV) #define glIsNamedBufferResidentNV GLEW_GET_FUN(__glewIsNamedBufferResidentNV) #define glMakeBufferNonResidentNV GLEW_GET_FUN(__glewMakeBufferNonResidentNV) #define glMakeBufferResidentNV GLEW_GET_FUN(__glewMakeBufferResidentNV) #define glMakeNamedBufferNonResidentNV GLEW_GET_FUN(__glewMakeNamedBufferNonResidentNV) #define glMakeNamedBufferResidentNV GLEW_GET_FUN(__glewMakeNamedBufferResidentNV) #define glProgramUniformui64NV GLEW_GET_FUN(__glewProgramUniformui64NV) #define glProgramUniformui64vNV GLEW_GET_FUN(__glewProgramUniformui64vNV) #define glUniformui64NV GLEW_GET_FUN(__glewUniformui64NV) #define glUniformui64vNV GLEW_GET_FUN(__glewUniformui64vNV) #define GLEW_NV_shader_buffer_load GLEW_GET_VAR(__GLEW_NV_shader_buffer_load) #endif /* GL_NV_shader_buffer_load */ /* ------------------- GL_NV_shader_storage_buffer_object ------------------ */ #ifndef GL_NV_shader_storage_buffer_object #define GL_NV_shader_storage_buffer_object 1 #define GLEW_NV_shader_storage_buffer_object GLEW_GET_VAR(__GLEW_NV_shader_storage_buffer_object) #endif /* GL_NV_shader_storage_buffer_object */ /* ----------------------- GL_NV_shader_thread_group ----------------------- */ #ifndef GL_NV_shader_thread_group #define GL_NV_shader_thread_group 1 #define GL_WARP_SIZE_NV 0x9339 #define GL_WARPS_PER_SM_NV 0x933A #define GL_SM_COUNT_NV 0x933B #define GLEW_NV_shader_thread_group GLEW_GET_VAR(__GLEW_NV_shader_thread_group) #endif /* GL_NV_shader_thread_group */ /* ---------------------- GL_NV_shader_thread_shuffle ---------------------- */ #ifndef GL_NV_shader_thread_shuffle #define GL_NV_shader_thread_shuffle 1 #define GLEW_NV_shader_thread_shuffle GLEW_GET_VAR(__GLEW_NV_shader_thread_shuffle) #endif /* GL_NV_shader_thread_shuffle */ /* ---------------------- GL_NV_tessellation_program5 ---------------------- */ #ifndef GL_NV_tessellation_program5 #define GL_NV_tessellation_program5 1 #define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 #define GL_TESS_CONTROL_PROGRAM_NV 0x891E #define GL_TESS_EVALUATION_PROGRAM_NV 0x891F #define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 #define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 #define GLEW_NV_tessellation_program5 GLEW_GET_VAR(__GLEW_NV_tessellation_program5) #endif /* GL_NV_tessellation_program5 */ /* -------------------------- GL_NV_texgen_emboss -------------------------- */ #ifndef GL_NV_texgen_emboss #define GL_NV_texgen_emboss 1 #define GL_EMBOSS_LIGHT_NV 0x855D #define GL_EMBOSS_CONSTANT_NV 0x855E #define GL_EMBOSS_MAP_NV 0x855F #define GLEW_NV_texgen_emboss GLEW_GET_VAR(__GLEW_NV_texgen_emboss) #endif /* GL_NV_texgen_emboss */ /* ------------------------ GL_NV_texgen_reflection ------------------------ */ #ifndef GL_NV_texgen_reflection #define GL_NV_texgen_reflection 1 #define GL_NORMAL_MAP_NV 0x8511 #define GL_REFLECTION_MAP_NV 0x8512 #define GLEW_NV_texgen_reflection GLEW_GET_VAR(__GLEW_NV_texgen_reflection) #endif /* GL_NV_texgen_reflection */ /* ------------------------- GL_NV_texture_barrier ------------------------- */ #ifndef GL_NV_texture_barrier #define GL_NV_texture_barrier 1 typedef void (GLAPIENTRY * PFNGLTEXTUREBARRIERNVPROC) (void); #define glTextureBarrierNV GLEW_GET_FUN(__glewTextureBarrierNV) #define GLEW_NV_texture_barrier GLEW_GET_VAR(__GLEW_NV_texture_barrier) #endif /* GL_NV_texture_barrier */ /* --------------------- GL_NV_texture_compression_vtc --------------------- */ #ifndef GL_NV_texture_compression_vtc #define GL_NV_texture_compression_vtc 1 #define GLEW_NV_texture_compression_vtc GLEW_GET_VAR(__GLEW_NV_texture_compression_vtc) #endif /* GL_NV_texture_compression_vtc */ /* ----------------------- GL_NV_texture_env_combine4 ---------------------- */ #ifndef GL_NV_texture_env_combine4 #define GL_NV_texture_env_combine4 1 #define GL_COMBINE4_NV 0x8503 #define GL_SOURCE3_RGB_NV 0x8583 #define GL_SOURCE3_ALPHA_NV 0x858B #define GL_OPERAND3_RGB_NV 0x8593 #define GL_OPERAND3_ALPHA_NV 0x859B #define GLEW_NV_texture_env_combine4 GLEW_GET_VAR(__GLEW_NV_texture_env_combine4) #endif /* GL_NV_texture_env_combine4 */ /* ---------------------- GL_NV_texture_expand_normal ---------------------- */ #ifndef GL_NV_texture_expand_normal #define GL_NV_texture_expand_normal 1 #define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F #define GLEW_NV_texture_expand_normal GLEW_GET_VAR(__GLEW_NV_texture_expand_normal) #endif /* GL_NV_texture_expand_normal */ /* ----------------------- GL_NV_texture_multisample ----------------------- */ #ifndef GL_NV_texture_multisample #define GL_NV_texture_multisample 1 #define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 #define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); #define glTexImage2DMultisampleCoverageNV GLEW_GET_FUN(__glewTexImage2DMultisampleCoverageNV) #define glTexImage3DMultisampleCoverageNV GLEW_GET_FUN(__glewTexImage3DMultisampleCoverageNV) #define glTextureImage2DMultisampleCoverageNV GLEW_GET_FUN(__glewTextureImage2DMultisampleCoverageNV) #define glTextureImage2DMultisampleNV GLEW_GET_FUN(__glewTextureImage2DMultisampleNV) #define glTextureImage3DMultisampleCoverageNV GLEW_GET_FUN(__glewTextureImage3DMultisampleCoverageNV) #define glTextureImage3DMultisampleNV GLEW_GET_FUN(__glewTextureImage3DMultisampleNV) #define GLEW_NV_texture_multisample GLEW_GET_VAR(__GLEW_NV_texture_multisample) #endif /* GL_NV_texture_multisample */ /* ------------------------ GL_NV_texture_rectangle ------------------------ */ #ifndef GL_NV_texture_rectangle #define GL_NV_texture_rectangle 1 #define GL_TEXTURE_RECTANGLE_NV 0x84F5 #define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 #define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 #define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 #define GLEW_NV_texture_rectangle GLEW_GET_VAR(__GLEW_NV_texture_rectangle) #endif /* GL_NV_texture_rectangle */ /* -------------------------- GL_NV_texture_shader ------------------------- */ #ifndef GL_NV_texture_shader #define GL_NV_texture_shader 1 #define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C #define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D #define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E #define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 #define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA #define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB #define GL_DSDT_MAG_INTENSITY_NV 0x86DC #define GL_SHADER_CONSISTENT_NV 0x86DD #define GL_TEXTURE_SHADER_NV 0x86DE #define GL_SHADER_OPERATION_NV 0x86DF #define GL_CULL_MODES_NV 0x86E0 #define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 #define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 #define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 #define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 #define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 #define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 #define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 #define GL_CONST_EYE_NV 0x86E5 #define GL_PASS_THROUGH_NV 0x86E6 #define GL_CULL_FRAGMENT_NV 0x86E7 #define GL_OFFSET_TEXTURE_2D_NV 0x86E8 #define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 #define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA #define GL_DOT_PRODUCT_NV 0x86EC #define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED #define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE #define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 #define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 #define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 #define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 #define GL_HILO_NV 0x86F4 #define GL_DSDT_NV 0x86F5 #define GL_DSDT_MAG_NV 0x86F6 #define GL_DSDT_MAG_VIB_NV 0x86F7 #define GL_HILO16_NV 0x86F8 #define GL_SIGNED_HILO_NV 0x86F9 #define GL_SIGNED_HILO16_NV 0x86FA #define GL_SIGNED_RGBA_NV 0x86FB #define GL_SIGNED_RGBA8_NV 0x86FC #define GL_SIGNED_RGB_NV 0x86FE #define GL_SIGNED_RGB8_NV 0x86FF #define GL_SIGNED_LUMINANCE_NV 0x8701 #define GL_SIGNED_LUMINANCE8_NV 0x8702 #define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 #define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 #define GL_SIGNED_ALPHA_NV 0x8705 #define GL_SIGNED_ALPHA8_NV 0x8706 #define GL_SIGNED_INTENSITY_NV 0x8707 #define GL_SIGNED_INTENSITY8_NV 0x8708 #define GL_DSDT8_NV 0x8709 #define GL_DSDT8_MAG8_NV 0x870A #define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B #define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C #define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D #define GL_HI_SCALE_NV 0x870E #define GL_LO_SCALE_NV 0x870F #define GL_DS_SCALE_NV 0x8710 #define GL_DT_SCALE_NV 0x8711 #define GL_MAGNITUDE_SCALE_NV 0x8712 #define GL_VIBRANCE_SCALE_NV 0x8713 #define GL_HI_BIAS_NV 0x8714 #define GL_LO_BIAS_NV 0x8715 #define GL_DS_BIAS_NV 0x8716 #define GL_DT_BIAS_NV 0x8717 #define GL_MAGNITUDE_BIAS_NV 0x8718 #define GL_VIBRANCE_BIAS_NV 0x8719 #define GL_TEXTURE_BORDER_VALUES_NV 0x871A #define GL_TEXTURE_HI_SIZE_NV 0x871B #define GL_TEXTURE_LO_SIZE_NV 0x871C #define GL_TEXTURE_DS_SIZE_NV 0x871D #define GL_TEXTURE_DT_SIZE_NV 0x871E #define GL_TEXTURE_MAG_SIZE_NV 0x871F #define GLEW_NV_texture_shader GLEW_GET_VAR(__GLEW_NV_texture_shader) #endif /* GL_NV_texture_shader */ /* ------------------------- GL_NV_texture_shader2 ------------------------- */ #ifndef GL_NV_texture_shader2 #define GL_NV_texture_shader2 1 #define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA #define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB #define GL_DSDT_MAG_INTENSITY_NV 0x86DC #define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF #define GL_HILO_NV 0x86F4 #define GL_DSDT_NV 0x86F5 #define GL_DSDT_MAG_NV 0x86F6 #define GL_DSDT_MAG_VIB_NV 0x86F7 #define GL_HILO16_NV 0x86F8 #define GL_SIGNED_HILO_NV 0x86F9 #define GL_SIGNED_HILO16_NV 0x86FA #define GL_SIGNED_RGBA_NV 0x86FB #define GL_SIGNED_RGBA8_NV 0x86FC #define GL_SIGNED_RGB_NV 0x86FE #define GL_SIGNED_RGB8_NV 0x86FF #define GL_SIGNED_LUMINANCE_NV 0x8701 #define GL_SIGNED_LUMINANCE8_NV 0x8702 #define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 #define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 #define GL_SIGNED_ALPHA_NV 0x8705 #define GL_SIGNED_ALPHA8_NV 0x8706 #define GL_SIGNED_INTENSITY_NV 0x8707 #define GL_SIGNED_INTENSITY8_NV 0x8708 #define GL_DSDT8_NV 0x8709 #define GL_DSDT8_MAG8_NV 0x870A #define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B #define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C #define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D #define GLEW_NV_texture_shader2 GLEW_GET_VAR(__GLEW_NV_texture_shader2) #endif /* GL_NV_texture_shader2 */ /* ------------------------- GL_NV_texture_shader3 ------------------------- */ #ifndef GL_NV_texture_shader3 #define GL_NV_texture_shader3 1 #define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 #define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 #define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 #define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 #define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 #define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 #define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 #define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 #define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 #define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 #define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A #define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B #define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C #define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D #define GL_HILO8_NV 0x885E #define GL_SIGNED_HILO8_NV 0x885F #define GL_FORCE_BLUE_TO_ONE_NV 0x8860 #define GLEW_NV_texture_shader3 GLEW_GET_VAR(__GLEW_NV_texture_shader3) #endif /* GL_NV_texture_shader3 */ /* ------------------------ GL_NV_transform_feedback ----------------------- */ #ifndef GL_NV_transform_feedback #define GL_NV_transform_feedback 1 #define GL_BACK_PRIMARY_COLOR_NV 0x8C77 #define GL_BACK_SECONDARY_COLOR_NV 0x8C78 #define GL_TEXTURE_COORD_NV 0x8C79 #define GL_CLIP_DISTANCE_NV 0x8C7A #define GL_VERTEX_ID_NV 0x8C7B #define GL_PRIMITIVE_ID_NV 0x8C7C #define GL_GENERIC_ATTRIB_NV 0x8C7D #define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E #define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 #define GL_ACTIVE_VARYINGS_NV 0x8C81 #define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 #define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 #define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 #define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 #define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 #define GL_PRIMITIVES_GENERATED_NV 0x8C87 #define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 #define GL_RASTERIZER_DISCARD_NV 0x8C89 #define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B #define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C #define GL_SEPARATE_ATTRIBS_NV 0x8C8D #define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E #define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F typedef void (GLAPIENTRY * PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); typedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); typedef void (GLAPIENTRY * PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); typedef GLint (GLAPIENTRY * PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); #define glActiveVaryingNV GLEW_GET_FUN(__glewActiveVaryingNV) #define glBeginTransformFeedbackNV GLEW_GET_FUN(__glewBeginTransformFeedbackNV) #define glBindBufferBaseNV GLEW_GET_FUN(__glewBindBufferBaseNV) #define glBindBufferOffsetNV GLEW_GET_FUN(__glewBindBufferOffsetNV) #define glBindBufferRangeNV GLEW_GET_FUN(__glewBindBufferRangeNV) #define glEndTransformFeedbackNV GLEW_GET_FUN(__glewEndTransformFeedbackNV) #define glGetActiveVaryingNV GLEW_GET_FUN(__glewGetActiveVaryingNV) #define glGetTransformFeedbackVaryingNV GLEW_GET_FUN(__glewGetTransformFeedbackVaryingNV) #define glGetVaryingLocationNV GLEW_GET_FUN(__glewGetVaryingLocationNV) #define glTransformFeedbackAttribsNV GLEW_GET_FUN(__glewTransformFeedbackAttribsNV) #define glTransformFeedbackVaryingsNV GLEW_GET_FUN(__glewTransformFeedbackVaryingsNV) #define GLEW_NV_transform_feedback GLEW_GET_VAR(__GLEW_NV_transform_feedback) #endif /* GL_NV_transform_feedback */ /* ----------------------- GL_NV_transform_feedback2 ----------------------- */ #ifndef GL_NV_transform_feedback2 #define GL_NV_transform_feedback2 1 #define GL_TRANSFORM_FEEDBACK_NV 0x8E22 #define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 #define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 #define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 typedef void (GLAPIENTRY * PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); typedef void (GLAPIENTRY * PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint* ids); typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); typedef void (GLAPIENTRY * PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint* ids); typedef GLboolean (GLAPIENTRY * PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); typedef void (GLAPIENTRY * PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); #define glBindTransformFeedbackNV GLEW_GET_FUN(__glewBindTransformFeedbackNV) #define glDeleteTransformFeedbacksNV GLEW_GET_FUN(__glewDeleteTransformFeedbacksNV) #define glDrawTransformFeedbackNV GLEW_GET_FUN(__glewDrawTransformFeedbackNV) #define glGenTransformFeedbacksNV GLEW_GET_FUN(__glewGenTransformFeedbacksNV) #define glIsTransformFeedbackNV GLEW_GET_FUN(__glewIsTransformFeedbackNV) #define glPauseTransformFeedbackNV GLEW_GET_FUN(__glewPauseTransformFeedbackNV) #define glResumeTransformFeedbackNV GLEW_GET_FUN(__glewResumeTransformFeedbackNV) #define GLEW_NV_transform_feedback2 GLEW_GET_VAR(__GLEW_NV_transform_feedback2) #endif /* GL_NV_transform_feedback2 */ /* ------------------ GL_NV_uniform_buffer_unified_memory ------------------ */ #ifndef GL_NV_uniform_buffer_unified_memory #define GL_NV_uniform_buffer_unified_memory 1 #define GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E #define GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F #define GL_UNIFORM_BUFFER_LENGTH_NV 0x9370 #define GLEW_NV_uniform_buffer_unified_memory GLEW_GET_VAR(__GLEW_NV_uniform_buffer_unified_memory) #endif /* GL_NV_uniform_buffer_unified_memory */ /* -------------------------- GL_NV_vdpau_interop -------------------------- */ #ifndef GL_NV_vdpau_interop #define GL_NV_vdpau_interop 1 #define GL_SURFACE_STATE_NV 0x86EB #define GL_SURFACE_REGISTERED_NV 0x86FD #define GL_SURFACE_MAPPED_NV 0x8700 #define GL_WRITE_DISCARD_NV 0x88BE typedef GLintptr GLvdpauSurfaceNV; typedef void (GLAPIENTRY * PFNGLVDPAUFININVPROC) (void); typedef void (GLAPIENTRY * PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei* length, GLint *values); typedef void (GLAPIENTRY * PFNGLVDPAUINITNVPROC) (const void* vdpDevice, const void*getProcAddress); typedef void (GLAPIENTRY * PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); typedef void (GLAPIENTRY * PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV* surfaces); typedef GLvdpauSurfaceNV (GLAPIENTRY * PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void* vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); typedef GLvdpauSurfaceNV (GLAPIENTRY * PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void* vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); typedef void (GLAPIENTRY * PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); typedef void (GLAPIENTRY * PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV* surfaces); typedef void (GLAPIENTRY * PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); #define glVDPAUFiniNV GLEW_GET_FUN(__glewVDPAUFiniNV) #define glVDPAUGetSurfaceivNV GLEW_GET_FUN(__glewVDPAUGetSurfaceivNV) #define glVDPAUInitNV GLEW_GET_FUN(__glewVDPAUInitNV) #define glVDPAUIsSurfaceNV GLEW_GET_FUN(__glewVDPAUIsSurfaceNV) #define glVDPAUMapSurfacesNV GLEW_GET_FUN(__glewVDPAUMapSurfacesNV) #define glVDPAURegisterOutputSurfaceNV GLEW_GET_FUN(__glewVDPAURegisterOutputSurfaceNV) #define glVDPAURegisterVideoSurfaceNV GLEW_GET_FUN(__glewVDPAURegisterVideoSurfaceNV) #define glVDPAUSurfaceAccessNV GLEW_GET_FUN(__glewVDPAUSurfaceAccessNV) #define glVDPAUUnmapSurfacesNV GLEW_GET_FUN(__glewVDPAUUnmapSurfacesNV) #define glVDPAUUnregisterSurfaceNV GLEW_GET_FUN(__glewVDPAUUnregisterSurfaceNV) #define GLEW_NV_vdpau_interop GLEW_GET_VAR(__GLEW_NV_vdpau_interop) #endif /* GL_NV_vdpau_interop */ /* ------------------------ GL_NV_vertex_array_range ----------------------- */ #ifndef GL_NV_vertex_array_range #define GL_NV_vertex_array_range 1 #define GL_VERTEX_ARRAY_RANGE_NV 0x851D #define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E #define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F #define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 #define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, void *pointer); #define glFlushVertexArrayRangeNV GLEW_GET_FUN(__glewFlushVertexArrayRangeNV) #define glVertexArrayRangeNV GLEW_GET_FUN(__glewVertexArrayRangeNV) #define GLEW_NV_vertex_array_range GLEW_GET_VAR(__GLEW_NV_vertex_array_range) #endif /* GL_NV_vertex_array_range */ /* ----------------------- GL_NV_vertex_array_range2 ----------------------- */ #ifndef GL_NV_vertex_array_range2 #define GL_NV_vertex_array_range2 1 #define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 #define GLEW_NV_vertex_array_range2 GLEW_GET_VAR(__GLEW_NV_vertex_array_range2) #endif /* GL_NV_vertex_array_range2 */ /* ------------------- GL_NV_vertex_attrib_integer_64bit ------------------- */ #ifndef GL_NV_vertex_attrib_integer_64bit #define GL_NV_vertex_attrib_integer_64bit 1 #define GL_INT64_NV 0x140E #define GL_UNSIGNED_INT64_NV 0x140F typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT* params); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); #define glGetVertexAttribLi64vNV GLEW_GET_FUN(__glewGetVertexAttribLi64vNV) #define glGetVertexAttribLui64vNV GLEW_GET_FUN(__glewGetVertexAttribLui64vNV) #define glVertexAttribL1i64NV GLEW_GET_FUN(__glewVertexAttribL1i64NV) #define glVertexAttribL1i64vNV GLEW_GET_FUN(__glewVertexAttribL1i64vNV) #define glVertexAttribL1ui64NV GLEW_GET_FUN(__glewVertexAttribL1ui64NV) #define glVertexAttribL1ui64vNV GLEW_GET_FUN(__glewVertexAttribL1ui64vNV) #define glVertexAttribL2i64NV GLEW_GET_FUN(__glewVertexAttribL2i64NV) #define glVertexAttribL2i64vNV GLEW_GET_FUN(__glewVertexAttribL2i64vNV) #define glVertexAttribL2ui64NV GLEW_GET_FUN(__glewVertexAttribL2ui64NV) #define glVertexAttribL2ui64vNV GLEW_GET_FUN(__glewVertexAttribL2ui64vNV) #define glVertexAttribL3i64NV GLEW_GET_FUN(__glewVertexAttribL3i64NV) #define glVertexAttribL3i64vNV GLEW_GET_FUN(__glewVertexAttribL3i64vNV) #define glVertexAttribL3ui64NV GLEW_GET_FUN(__glewVertexAttribL3ui64NV) #define glVertexAttribL3ui64vNV GLEW_GET_FUN(__glewVertexAttribL3ui64vNV) #define glVertexAttribL4i64NV GLEW_GET_FUN(__glewVertexAttribL4i64NV) #define glVertexAttribL4i64vNV GLEW_GET_FUN(__glewVertexAttribL4i64vNV) #define glVertexAttribL4ui64NV GLEW_GET_FUN(__glewVertexAttribL4ui64NV) #define glVertexAttribL4ui64vNV GLEW_GET_FUN(__glewVertexAttribL4ui64vNV) #define glVertexAttribLFormatNV GLEW_GET_FUN(__glewVertexAttribLFormatNV) #define GLEW_NV_vertex_attrib_integer_64bit GLEW_GET_VAR(__GLEW_NV_vertex_attrib_integer_64bit) #endif /* GL_NV_vertex_attrib_integer_64bit */ /* ------------------- GL_NV_vertex_buffer_unified_memory ------------------ */ #ifndef GL_NV_vertex_buffer_unified_memory #define GL_NV_vertex_buffer_unified_memory 1 #define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E #define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F #define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 #define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 #define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 #define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 #define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 #define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 #define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 #define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 #define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 #define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 #define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A #define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B #define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C #define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D #define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E #define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F #define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 #define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 #define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 #define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 #define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 #define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 #define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 typedef void (GLAPIENTRY * PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); typedef void (GLAPIENTRY * PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); typedef void (GLAPIENTRY * PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); typedef void (GLAPIENTRY * PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); typedef void (GLAPIENTRY * PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT result[]); typedef void (GLAPIENTRY * PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); typedef void (GLAPIENTRY * PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); typedef void (GLAPIENTRY * PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); typedef void (GLAPIENTRY * PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); #define glBufferAddressRangeNV GLEW_GET_FUN(__glewBufferAddressRangeNV) #define glColorFormatNV GLEW_GET_FUN(__glewColorFormatNV) #define glEdgeFlagFormatNV GLEW_GET_FUN(__glewEdgeFlagFormatNV) #define glFogCoordFormatNV GLEW_GET_FUN(__glewFogCoordFormatNV) #define glGetIntegerui64i_vNV GLEW_GET_FUN(__glewGetIntegerui64i_vNV) #define glIndexFormatNV GLEW_GET_FUN(__glewIndexFormatNV) #define glNormalFormatNV GLEW_GET_FUN(__glewNormalFormatNV) #define glSecondaryColorFormatNV GLEW_GET_FUN(__glewSecondaryColorFormatNV) #define glTexCoordFormatNV GLEW_GET_FUN(__glewTexCoordFormatNV) #define glVertexAttribFormatNV GLEW_GET_FUN(__glewVertexAttribFormatNV) #define glVertexAttribIFormatNV GLEW_GET_FUN(__glewVertexAttribIFormatNV) #define glVertexFormatNV GLEW_GET_FUN(__glewVertexFormatNV) #define GLEW_NV_vertex_buffer_unified_memory GLEW_GET_VAR(__GLEW_NV_vertex_buffer_unified_memory) #endif /* GL_NV_vertex_buffer_unified_memory */ /* -------------------------- GL_NV_vertex_program ------------------------- */ #ifndef GL_NV_vertex_program #define GL_NV_vertex_program 1 #define GL_VERTEX_PROGRAM_NV 0x8620 #define GL_VERTEX_STATE_PROGRAM_NV 0x8621 #define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 #define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 #define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 #define GL_CURRENT_ATTRIB_NV 0x8626 #define GL_PROGRAM_LENGTH_NV 0x8627 #define GL_PROGRAM_STRING_NV 0x8628 #define GL_MODELVIEW_PROJECTION_NV 0x8629 #define GL_IDENTITY_NV 0x862A #define GL_INVERSE_NV 0x862B #define GL_TRANSPOSE_NV 0x862C #define GL_INVERSE_TRANSPOSE_NV 0x862D #define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E #define GL_MAX_TRACK_MATRICES_NV 0x862F #define GL_MATRIX0_NV 0x8630 #define GL_MATRIX1_NV 0x8631 #define GL_MATRIX2_NV 0x8632 #define GL_MATRIX3_NV 0x8633 #define GL_MATRIX4_NV 0x8634 #define GL_MATRIX5_NV 0x8635 #define GL_MATRIX6_NV 0x8636 #define GL_MATRIX7_NV 0x8637 #define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 #define GL_CURRENT_MATRIX_NV 0x8641 #define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 #define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 #define GL_PROGRAM_PARAMETER_NV 0x8644 #define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 #define GL_PROGRAM_TARGET_NV 0x8646 #define GL_PROGRAM_RESIDENT_NV 0x8647 #define GL_TRACK_MATRIX_NV 0x8648 #define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 #define GL_VERTEX_PROGRAM_BINDING_NV 0x864A #define GL_PROGRAM_ERROR_POSITION_NV 0x864B #define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 #define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 #define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 #define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 #define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 #define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 #define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 #define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 #define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 #define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 #define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A #define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B #define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C #define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D #define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E #define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F #define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 #define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 #define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 #define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 #define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 #define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 #define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 #define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 #define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 #define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 #define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A #define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B #define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C #define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D #define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E #define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F #define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 #define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 #define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 #define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 #define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 #define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 #define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 #define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 #define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 #define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 #define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A #define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B #define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C #define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D #define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E #define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F typedef GLboolean (GLAPIENTRY * PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint* ids, GLboolean *residences); typedef void (GLAPIENTRY * PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint* ids); typedef void (GLAPIENTRY * PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint* ids); typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte* program); typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void** pointer); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMNVPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte* program); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble* params); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei num, const GLdouble* params); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei num, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, GLuint* ids); typedef void (GLAPIENTRY * PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei n, const GLubyte* v); #define glAreProgramsResidentNV GLEW_GET_FUN(__glewAreProgramsResidentNV) #define glBindProgramNV GLEW_GET_FUN(__glewBindProgramNV) #define glDeleteProgramsNV GLEW_GET_FUN(__glewDeleteProgramsNV) #define glExecuteProgramNV GLEW_GET_FUN(__glewExecuteProgramNV) #define glGenProgramsNV GLEW_GET_FUN(__glewGenProgramsNV) #define glGetProgramParameterdvNV GLEW_GET_FUN(__glewGetProgramParameterdvNV) #define glGetProgramParameterfvNV GLEW_GET_FUN(__glewGetProgramParameterfvNV) #define glGetProgramStringNV GLEW_GET_FUN(__glewGetProgramStringNV) #define glGetProgramivNV GLEW_GET_FUN(__glewGetProgramivNV) #define glGetTrackMatrixivNV GLEW_GET_FUN(__glewGetTrackMatrixivNV) #define glGetVertexAttribPointervNV GLEW_GET_FUN(__glewGetVertexAttribPointervNV) #define glGetVertexAttribdvNV GLEW_GET_FUN(__glewGetVertexAttribdvNV) #define glGetVertexAttribfvNV GLEW_GET_FUN(__glewGetVertexAttribfvNV) #define glGetVertexAttribivNV GLEW_GET_FUN(__glewGetVertexAttribivNV) #define glIsProgramNV GLEW_GET_FUN(__glewIsProgramNV) #define glLoadProgramNV GLEW_GET_FUN(__glewLoadProgramNV) #define glProgramParameter4dNV GLEW_GET_FUN(__glewProgramParameter4dNV) #define glProgramParameter4dvNV GLEW_GET_FUN(__glewProgramParameter4dvNV) #define glProgramParameter4fNV GLEW_GET_FUN(__glewProgramParameter4fNV) #define glProgramParameter4fvNV GLEW_GET_FUN(__glewProgramParameter4fvNV) #define glProgramParameters4dvNV GLEW_GET_FUN(__glewProgramParameters4dvNV) #define glProgramParameters4fvNV GLEW_GET_FUN(__glewProgramParameters4fvNV) #define glRequestResidentProgramsNV GLEW_GET_FUN(__glewRequestResidentProgramsNV) #define glTrackMatrixNV GLEW_GET_FUN(__glewTrackMatrixNV) #define glVertexAttrib1dNV GLEW_GET_FUN(__glewVertexAttrib1dNV) #define glVertexAttrib1dvNV GLEW_GET_FUN(__glewVertexAttrib1dvNV) #define glVertexAttrib1fNV GLEW_GET_FUN(__glewVertexAttrib1fNV) #define glVertexAttrib1fvNV GLEW_GET_FUN(__glewVertexAttrib1fvNV) #define glVertexAttrib1sNV GLEW_GET_FUN(__glewVertexAttrib1sNV) #define glVertexAttrib1svNV GLEW_GET_FUN(__glewVertexAttrib1svNV) #define glVertexAttrib2dNV GLEW_GET_FUN(__glewVertexAttrib2dNV) #define glVertexAttrib2dvNV GLEW_GET_FUN(__glewVertexAttrib2dvNV) #define glVertexAttrib2fNV GLEW_GET_FUN(__glewVertexAttrib2fNV) #define glVertexAttrib2fvNV GLEW_GET_FUN(__glewVertexAttrib2fvNV) #define glVertexAttrib2sNV GLEW_GET_FUN(__glewVertexAttrib2sNV) #define glVertexAttrib2svNV GLEW_GET_FUN(__glewVertexAttrib2svNV) #define glVertexAttrib3dNV GLEW_GET_FUN(__glewVertexAttrib3dNV) #define glVertexAttrib3dvNV GLEW_GET_FUN(__glewVertexAttrib3dvNV) #define glVertexAttrib3fNV GLEW_GET_FUN(__glewVertexAttrib3fNV) #define glVertexAttrib3fvNV GLEW_GET_FUN(__glewVertexAttrib3fvNV) #define glVertexAttrib3sNV GLEW_GET_FUN(__glewVertexAttrib3sNV) #define glVertexAttrib3svNV GLEW_GET_FUN(__glewVertexAttrib3svNV) #define glVertexAttrib4dNV GLEW_GET_FUN(__glewVertexAttrib4dNV) #define glVertexAttrib4dvNV GLEW_GET_FUN(__glewVertexAttrib4dvNV) #define glVertexAttrib4fNV GLEW_GET_FUN(__glewVertexAttrib4fNV) #define glVertexAttrib4fvNV GLEW_GET_FUN(__glewVertexAttrib4fvNV) #define glVertexAttrib4sNV GLEW_GET_FUN(__glewVertexAttrib4sNV) #define glVertexAttrib4svNV GLEW_GET_FUN(__glewVertexAttrib4svNV) #define glVertexAttrib4ubNV GLEW_GET_FUN(__glewVertexAttrib4ubNV) #define glVertexAttrib4ubvNV GLEW_GET_FUN(__glewVertexAttrib4ubvNV) #define glVertexAttribPointerNV GLEW_GET_FUN(__glewVertexAttribPointerNV) #define glVertexAttribs1dvNV GLEW_GET_FUN(__glewVertexAttribs1dvNV) #define glVertexAttribs1fvNV GLEW_GET_FUN(__glewVertexAttribs1fvNV) #define glVertexAttribs1svNV GLEW_GET_FUN(__glewVertexAttribs1svNV) #define glVertexAttribs2dvNV GLEW_GET_FUN(__glewVertexAttribs2dvNV) #define glVertexAttribs2fvNV GLEW_GET_FUN(__glewVertexAttribs2fvNV) #define glVertexAttribs2svNV GLEW_GET_FUN(__glewVertexAttribs2svNV) #define glVertexAttribs3dvNV GLEW_GET_FUN(__glewVertexAttribs3dvNV) #define glVertexAttribs3fvNV GLEW_GET_FUN(__glewVertexAttribs3fvNV) #define glVertexAttribs3svNV GLEW_GET_FUN(__glewVertexAttribs3svNV) #define glVertexAttribs4dvNV GLEW_GET_FUN(__glewVertexAttribs4dvNV) #define glVertexAttribs4fvNV GLEW_GET_FUN(__glewVertexAttribs4fvNV) #define glVertexAttribs4svNV GLEW_GET_FUN(__glewVertexAttribs4svNV) #define glVertexAttribs4ubvNV GLEW_GET_FUN(__glewVertexAttribs4ubvNV) #define GLEW_NV_vertex_program GLEW_GET_VAR(__GLEW_NV_vertex_program) #endif /* GL_NV_vertex_program */ /* ------------------------ GL_NV_vertex_program1_1 ------------------------ */ #ifndef GL_NV_vertex_program1_1 #define GL_NV_vertex_program1_1 1 #define GLEW_NV_vertex_program1_1 GLEW_GET_VAR(__GLEW_NV_vertex_program1_1) #endif /* GL_NV_vertex_program1_1 */ /* ------------------------- GL_NV_vertex_program2 ------------------------- */ #ifndef GL_NV_vertex_program2 #define GL_NV_vertex_program2 1 #define GLEW_NV_vertex_program2 GLEW_GET_VAR(__GLEW_NV_vertex_program2) #endif /* GL_NV_vertex_program2 */ /* ---------------------- GL_NV_vertex_program2_option --------------------- */ #ifndef GL_NV_vertex_program2_option #define GL_NV_vertex_program2_option 1 #define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 #define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 #define GLEW_NV_vertex_program2_option GLEW_GET_VAR(__GLEW_NV_vertex_program2_option) #endif /* GL_NV_vertex_program2_option */ /* ------------------------- GL_NV_vertex_program3 ------------------------- */ #ifndef GL_NV_vertex_program3 #define GL_NV_vertex_program3 1 #define MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C #define GLEW_NV_vertex_program3 GLEW_GET_VAR(__GLEW_NV_vertex_program3) #endif /* GL_NV_vertex_program3 */ /* ------------------------- GL_NV_vertex_program4 ------------------------- */ #ifndef GL_NV_vertex_program4 #define GL_NV_vertex_program4 1 #define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD #define GLEW_NV_vertex_program4 GLEW_GET_VAR(__GLEW_NV_vertex_program4) #endif /* GL_NV_vertex_program4 */ /* -------------------------- GL_NV_video_capture -------------------------- */ #ifndef GL_NV_video_capture #define GL_NV_video_capture 1 #define GL_VIDEO_BUFFER_NV 0x9020 #define GL_VIDEO_BUFFER_BINDING_NV 0x9021 #define GL_FIELD_UPPER_NV 0x9022 #define GL_FIELD_LOWER_NV 0x9023 #define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 #define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 #define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 #define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 #define GL_VIDEO_BUFFER_PITCH_NV 0x9028 #define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 #define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A #define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B #define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C #define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D #define GL_PARTIAL_SUCCESS_NV 0x902E #define GL_SUCCESS_NV 0x902F #define GL_FAILURE_NV 0x9030 #define GL_YCBYCR8_422_NV 0x9031 #define GL_YCBAYCR8A_4224_NV 0x9032 #define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 #define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 #define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 #define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 #define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 #define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 #define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 #define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A #define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B #define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C typedef void (GLAPIENTRY * PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); typedef void (GLAPIENTRY * PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); typedef void (GLAPIENTRY * PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); typedef void (GLAPIENTRY * PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); typedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint* params); typedef GLenum (GLAPIENTRY * PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint* sequence_num, GLuint64EXT *capture_time); typedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble* params); typedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint* params); #define glBeginVideoCaptureNV GLEW_GET_FUN(__glewBeginVideoCaptureNV) #define glBindVideoCaptureStreamBufferNV GLEW_GET_FUN(__glewBindVideoCaptureStreamBufferNV) #define glBindVideoCaptureStreamTextureNV GLEW_GET_FUN(__glewBindVideoCaptureStreamTextureNV) #define glEndVideoCaptureNV GLEW_GET_FUN(__glewEndVideoCaptureNV) #define glGetVideoCaptureStreamdvNV GLEW_GET_FUN(__glewGetVideoCaptureStreamdvNV) #define glGetVideoCaptureStreamfvNV GLEW_GET_FUN(__glewGetVideoCaptureStreamfvNV) #define glGetVideoCaptureStreamivNV GLEW_GET_FUN(__glewGetVideoCaptureStreamivNV) #define glGetVideoCaptureivNV GLEW_GET_FUN(__glewGetVideoCaptureivNV) #define glVideoCaptureNV GLEW_GET_FUN(__glewVideoCaptureNV) #define glVideoCaptureStreamParameterdvNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterdvNV) #define glVideoCaptureStreamParameterfvNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterfvNV) #define glVideoCaptureStreamParameterivNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterivNV) #define GLEW_NV_video_capture GLEW_GET_VAR(__GLEW_NV_video_capture) #endif /* GL_NV_video_capture */ /* ------------------------- GL_NV_viewport_array2 ------------------------- */ #ifndef GL_NV_viewport_array2 #define GL_NV_viewport_array2 1 #define GLEW_NV_viewport_array2 GLEW_GET_VAR(__GLEW_NV_viewport_array2) #endif /* GL_NV_viewport_array2 */ /* ------------------------ GL_OES_byte_coordinates ------------------------ */ #ifndef GL_OES_byte_coordinates #define GL_OES_byte_coordinates 1 #define GLEW_OES_byte_coordinates GLEW_GET_VAR(__GLEW_OES_byte_coordinates) #endif /* GL_OES_byte_coordinates */ /* ------------------- GL_OES_compressed_paletted_texture ------------------ */ #ifndef GL_OES_compressed_paletted_texture #define GL_OES_compressed_paletted_texture 1 #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 #define GLEW_OES_compressed_paletted_texture GLEW_GET_VAR(__GLEW_OES_compressed_paletted_texture) #endif /* GL_OES_compressed_paletted_texture */ /* --------------------------- GL_OES_read_format -------------------------- */ #ifndef GL_OES_read_format #define GL_OES_read_format 1 #define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A #define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B #define GLEW_OES_read_format GLEW_GET_VAR(__GLEW_OES_read_format) #endif /* GL_OES_read_format */ /* ------------------------ GL_OES_single_precision ------------------------ */ #ifndef GL_OES_single_precision #define GL_OES_single_precision 1 typedef void (GLAPIENTRY * PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); typedef void (GLAPIENTRY * PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat* equation); typedef void (GLAPIENTRY * PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); typedef void (GLAPIENTRY * PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); typedef void (GLAPIENTRY * PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat* equation); typedef void (GLAPIENTRY * PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); #define glClearDepthfOES GLEW_GET_FUN(__glewClearDepthfOES) #define glClipPlanefOES GLEW_GET_FUN(__glewClipPlanefOES) #define glDepthRangefOES GLEW_GET_FUN(__glewDepthRangefOES) #define glFrustumfOES GLEW_GET_FUN(__glewFrustumfOES) #define glGetClipPlanefOES GLEW_GET_FUN(__glewGetClipPlanefOES) #define glOrthofOES GLEW_GET_FUN(__glewOrthofOES) #define GLEW_OES_single_precision GLEW_GET_VAR(__GLEW_OES_single_precision) #endif /* GL_OES_single_precision */ /* ---------------------------- GL_OML_interlace --------------------------- */ #ifndef GL_OML_interlace #define GL_OML_interlace 1 #define GL_INTERLACE_OML 0x8980 #define GL_INTERLACE_READ_OML 0x8981 #define GLEW_OML_interlace GLEW_GET_VAR(__GLEW_OML_interlace) #endif /* GL_OML_interlace */ /* ---------------------------- GL_OML_resample ---------------------------- */ #ifndef GL_OML_resample #define GL_OML_resample 1 #define GL_PACK_RESAMPLE_OML 0x8984 #define GL_UNPACK_RESAMPLE_OML 0x8985 #define GL_RESAMPLE_REPLICATE_OML 0x8986 #define GL_RESAMPLE_ZERO_FILL_OML 0x8987 #define GL_RESAMPLE_AVERAGE_OML 0x8988 #define GL_RESAMPLE_DECIMATE_OML 0x8989 #define GLEW_OML_resample GLEW_GET_VAR(__GLEW_OML_resample) #endif /* GL_OML_resample */ /* ---------------------------- GL_OML_subsample --------------------------- */ #ifndef GL_OML_subsample #define GL_OML_subsample 1 #define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 #define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 #define GLEW_OML_subsample GLEW_GET_VAR(__GLEW_OML_subsample) #endif /* GL_OML_subsample */ /* ---------------------------- GL_OVR_multiview --------------------------- */ #ifndef GL_OVR_multiview #define GL_OVR_multiview 1 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 #define GL_MAX_VIEWS_OVR 0x9631 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 #define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); #define glFramebufferTextureMultiviewOVR GLEW_GET_FUN(__glewFramebufferTextureMultiviewOVR) #define GLEW_OVR_multiview GLEW_GET_VAR(__GLEW_OVR_multiview) #endif /* GL_OVR_multiview */ /* --------------------------- GL_OVR_multiview2 --------------------------- */ #ifndef GL_OVR_multiview2 #define GL_OVR_multiview2 1 #define GLEW_OVR_multiview2 GLEW_GET_VAR(__GLEW_OVR_multiview2) #endif /* GL_OVR_multiview2 */ /* --------------------------- GL_PGI_misc_hints --------------------------- */ #ifndef GL_PGI_misc_hints #define GL_PGI_misc_hints 1 #define GL_PREFER_DOUBLEBUFFER_HINT_PGI 107000 #define GL_CONSERVE_MEMORY_HINT_PGI 107005 #define GL_RECLAIM_MEMORY_HINT_PGI 107006 #define GL_NATIVE_GRAPHICS_HANDLE_PGI 107010 #define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 107011 #define GL_NATIVE_GRAPHICS_END_HINT_PGI 107012 #define GL_ALWAYS_FAST_HINT_PGI 107020 #define GL_ALWAYS_SOFT_HINT_PGI 107021 #define GL_ALLOW_DRAW_OBJ_HINT_PGI 107022 #define GL_ALLOW_DRAW_WIN_HINT_PGI 107023 #define GL_ALLOW_DRAW_FRG_HINT_PGI 107024 #define GL_ALLOW_DRAW_MEM_HINT_PGI 107025 #define GL_STRICT_DEPTHFUNC_HINT_PGI 107030 #define GL_STRICT_LIGHTING_HINT_PGI 107031 #define GL_STRICT_SCISSOR_HINT_PGI 107032 #define GL_FULL_STIPPLE_HINT_PGI 107033 #define GL_CLIP_NEAR_HINT_PGI 107040 #define GL_CLIP_FAR_HINT_PGI 107041 #define GL_WIDE_LINE_HINT_PGI 107042 #define GL_BACK_NORMALS_HINT_PGI 107043 #define GLEW_PGI_misc_hints GLEW_GET_VAR(__GLEW_PGI_misc_hints) #endif /* GL_PGI_misc_hints */ /* -------------------------- GL_PGI_vertex_hints -------------------------- */ #ifndef GL_PGI_vertex_hints #define GL_PGI_vertex_hints 1 #define GL_VERTEX23_BIT_PGI 0x00000004 #define GL_VERTEX4_BIT_PGI 0x00000008 #define GL_COLOR3_BIT_PGI 0x00010000 #define GL_COLOR4_BIT_PGI 0x00020000 #define GL_EDGEFLAG_BIT_PGI 0x00040000 #define GL_INDEX_BIT_PGI 0x00080000 #define GL_MAT_AMBIENT_BIT_PGI 0x00100000 #define GL_VERTEX_DATA_HINT_PGI 107050 #define GL_VERTEX_CONSISTENT_HINT_PGI 107051 #define GL_MATERIAL_SIDE_HINT_PGI 107052 #define GL_MAX_VERTEX_HINT_PGI 107053 #define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 #define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 #define GL_MAT_EMISSION_BIT_PGI 0x00800000 #define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 #define GL_MAT_SHININESS_BIT_PGI 0x02000000 #define GL_MAT_SPECULAR_BIT_PGI 0x04000000 #define GL_NORMAL_BIT_PGI 0x08000000 #define GL_TEXCOORD1_BIT_PGI 0x10000000 #define GL_TEXCOORD2_BIT_PGI 0x20000000 #define GL_TEXCOORD3_BIT_PGI 0x40000000 #define GL_TEXCOORD4_BIT_PGI 0x80000000 #define GLEW_PGI_vertex_hints GLEW_GET_VAR(__GLEW_PGI_vertex_hints) #endif /* GL_PGI_vertex_hints */ /* ---------------------- GL_REGAL_ES1_0_compatibility --------------------- */ #ifndef GL_REGAL_ES1_0_compatibility #define GL_REGAL_ES1_0_compatibility 1 typedef int GLclampx; typedef void (GLAPIENTRY * PFNGLALPHAFUNCXPROC) (GLenum func, GLclampx ref); typedef void (GLAPIENTRY * PFNGLCLEARCOLORXPROC) (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); typedef void (GLAPIENTRY * PFNGLCLEARDEPTHXPROC) (GLclampx depth); typedef void (GLAPIENTRY * PFNGLCOLOR4XPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); typedef void (GLAPIENTRY * PFNGLDEPTHRANGEXPROC) (GLclampx zNear, GLclampx zFar); typedef void (GLAPIENTRY * PFNGLFOGXPROC) (GLenum pname, GLfixed param); typedef void (GLAPIENTRY * PFNGLFOGXVPROC) (GLenum pname, const GLfixed* params); typedef void (GLAPIENTRY * PFNGLFRUSTUMFPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); typedef void (GLAPIENTRY * PFNGLFRUSTUMXPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); typedef void (GLAPIENTRY * PFNGLLIGHTMODELXPROC) (GLenum pname, GLfixed param); typedef void (GLAPIENTRY * PFNGLLIGHTMODELXVPROC) (GLenum pname, const GLfixed* params); typedef void (GLAPIENTRY * PFNGLLIGHTXPROC) (GLenum light, GLenum pname, GLfixed param); typedef void (GLAPIENTRY * PFNGLLIGHTXVPROC) (GLenum light, GLenum pname, const GLfixed* params); typedef void (GLAPIENTRY * PFNGLLINEWIDTHXPROC) (GLfixed width); typedef void (GLAPIENTRY * PFNGLLOADMATRIXXPROC) (const GLfixed* m); typedef void (GLAPIENTRY * PFNGLMATERIALXPROC) (GLenum face, GLenum pname, GLfixed param); typedef void (GLAPIENTRY * PFNGLMATERIALXVPROC) (GLenum face, GLenum pname, const GLfixed* params); typedef void (GLAPIENTRY * PFNGLMULTMATRIXXPROC) (const GLfixed* m); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4XPROC) (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); typedef void (GLAPIENTRY * PFNGLNORMAL3XPROC) (GLfixed nx, GLfixed ny, GLfixed nz); typedef void (GLAPIENTRY * PFNGLORTHOFPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); typedef void (GLAPIENTRY * PFNGLORTHOXPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); typedef void (GLAPIENTRY * PFNGLPOINTSIZEXPROC) (GLfixed size); typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETXPROC) (GLfixed factor, GLfixed units); typedef void (GLAPIENTRY * PFNGLROTATEXPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEXPROC) (GLclampx value, GLboolean invert); typedef void (GLAPIENTRY * PFNGLSCALEXPROC) (GLfixed x, GLfixed y, GLfixed z); typedef void (GLAPIENTRY * PFNGLTEXENVXPROC) (GLenum target, GLenum pname, GLfixed param); typedef void (GLAPIENTRY * PFNGLTEXENVXVPROC) (GLenum target, GLenum pname, const GLfixed* params); typedef void (GLAPIENTRY * PFNGLTEXPARAMETERXPROC) (GLenum target, GLenum pname, GLfixed param); typedef void (GLAPIENTRY * PFNGLTRANSLATEXPROC) (GLfixed x, GLfixed y, GLfixed z); #define glAlphaFuncx GLEW_GET_FUN(__glewAlphaFuncx) #define glClearColorx GLEW_GET_FUN(__glewClearColorx) #define glClearDepthx GLEW_GET_FUN(__glewClearDepthx) #define glColor4x GLEW_GET_FUN(__glewColor4x) #define glDepthRangex GLEW_GET_FUN(__glewDepthRangex) #define glFogx GLEW_GET_FUN(__glewFogx) #define glFogxv GLEW_GET_FUN(__glewFogxv) #define glFrustumf GLEW_GET_FUN(__glewFrustumf) #define glFrustumx GLEW_GET_FUN(__glewFrustumx) #define glLightModelx GLEW_GET_FUN(__glewLightModelx) #define glLightModelxv GLEW_GET_FUN(__glewLightModelxv) #define glLightx GLEW_GET_FUN(__glewLightx) #define glLightxv GLEW_GET_FUN(__glewLightxv) #define glLineWidthx GLEW_GET_FUN(__glewLineWidthx) #define glLoadMatrixx GLEW_GET_FUN(__glewLoadMatrixx) #define glMaterialx GLEW_GET_FUN(__glewMaterialx) #define glMaterialxv GLEW_GET_FUN(__glewMaterialxv) #define glMultMatrixx GLEW_GET_FUN(__glewMultMatrixx) #define glMultiTexCoord4x GLEW_GET_FUN(__glewMultiTexCoord4x) #define glNormal3x GLEW_GET_FUN(__glewNormal3x) #define glOrthof GLEW_GET_FUN(__glewOrthof) #define glOrthox GLEW_GET_FUN(__glewOrthox) #define glPointSizex GLEW_GET_FUN(__glewPointSizex) #define glPolygonOffsetx GLEW_GET_FUN(__glewPolygonOffsetx) #define glRotatex GLEW_GET_FUN(__glewRotatex) #define glSampleCoveragex GLEW_GET_FUN(__glewSampleCoveragex) #define glScalex GLEW_GET_FUN(__glewScalex) #define glTexEnvx GLEW_GET_FUN(__glewTexEnvx) #define glTexEnvxv GLEW_GET_FUN(__glewTexEnvxv) #define glTexParameterx GLEW_GET_FUN(__glewTexParameterx) #define glTranslatex GLEW_GET_FUN(__glewTranslatex) #define GLEW_REGAL_ES1_0_compatibility GLEW_GET_VAR(__GLEW_REGAL_ES1_0_compatibility) #endif /* GL_REGAL_ES1_0_compatibility */ /* ---------------------- GL_REGAL_ES1_1_compatibility --------------------- */ #ifndef GL_REGAL_ES1_1_compatibility #define GL_REGAL_ES1_1_compatibility 1 typedef void (GLAPIENTRY * PFNGLCLIPPLANEFPROC) (GLenum plane, const GLfloat* equation); typedef void (GLAPIENTRY * PFNGLCLIPPLANEXPROC) (GLenum plane, const GLfixed* equation); typedef void (GLAPIENTRY * PFNGLGETCLIPPLANEFPROC) (GLenum pname, GLfloat eqn[4]); typedef void (GLAPIENTRY * PFNGLGETCLIPPLANEXPROC) (GLenum pname, GLfixed eqn[4]); typedef void (GLAPIENTRY * PFNGLGETFIXEDVPROC) (GLenum pname, GLfixed* params); typedef void (GLAPIENTRY * PFNGLGETLIGHTXVPROC) (GLenum light, GLenum pname, GLfixed* params); typedef void (GLAPIENTRY * PFNGLGETMATERIALXVPROC) (GLenum face, GLenum pname, GLfixed* params); typedef void (GLAPIENTRY * PFNGLGETTEXENVXVPROC) (GLenum env, GLenum pname, GLfixed* params); typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERXVPROC) (GLenum target, GLenum pname, GLfixed* params); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERXPROC) (GLenum pname, GLfixed param); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERXVPROC) (GLenum pname, const GLfixed* params); typedef void (GLAPIENTRY * PFNGLPOINTSIZEPOINTEROESPROC) (GLenum type, GLsizei stride, const void *pointer); typedef void (GLAPIENTRY * PFNGLTEXPARAMETERXVPROC) (GLenum target, GLenum pname, const GLfixed* params); #define glClipPlanef GLEW_GET_FUN(__glewClipPlanef) #define glClipPlanex GLEW_GET_FUN(__glewClipPlanex) #define glGetClipPlanef GLEW_GET_FUN(__glewGetClipPlanef) #define glGetClipPlanex GLEW_GET_FUN(__glewGetClipPlanex) #define glGetFixedv GLEW_GET_FUN(__glewGetFixedv) #define glGetLightxv GLEW_GET_FUN(__glewGetLightxv) #define glGetMaterialxv GLEW_GET_FUN(__glewGetMaterialxv) #define glGetTexEnvxv GLEW_GET_FUN(__glewGetTexEnvxv) #define glGetTexParameterxv GLEW_GET_FUN(__glewGetTexParameterxv) #define glPointParameterx GLEW_GET_FUN(__glewPointParameterx) #define glPointParameterxv GLEW_GET_FUN(__glewPointParameterxv) #define glPointSizePointerOES GLEW_GET_FUN(__glewPointSizePointerOES) #define glTexParameterxv GLEW_GET_FUN(__glewTexParameterxv) #define GLEW_REGAL_ES1_1_compatibility GLEW_GET_VAR(__GLEW_REGAL_ES1_1_compatibility) #endif /* GL_REGAL_ES1_1_compatibility */ /* ---------------------------- GL_REGAL_enable ---------------------------- */ #ifndef GL_REGAL_enable #define GL_REGAL_enable 1 #define GL_ERROR_REGAL 0x9322 #define GL_DEBUG_REGAL 0x9323 #define GL_LOG_REGAL 0x9324 #define GL_EMULATION_REGAL 0x9325 #define GL_DRIVER_REGAL 0x9326 #define GL_MISSING_REGAL 0x9360 #define GL_TRACE_REGAL 0x9361 #define GL_CACHE_REGAL 0x9362 #define GL_CODE_REGAL 0x9363 #define GL_STATISTICS_REGAL 0x9364 #define GLEW_REGAL_enable GLEW_GET_VAR(__GLEW_REGAL_enable) #endif /* GL_REGAL_enable */ /* ------------------------- GL_REGAL_error_string ------------------------- */ #ifndef GL_REGAL_error_string #define GL_REGAL_error_string 1 typedef const GLchar* (GLAPIENTRY * PFNGLERRORSTRINGREGALPROC) (GLenum error); #define glErrorStringREGAL GLEW_GET_FUN(__glewErrorStringREGAL) #define GLEW_REGAL_error_string GLEW_GET_VAR(__GLEW_REGAL_error_string) #endif /* GL_REGAL_error_string */ /* ------------------------ GL_REGAL_extension_query ----------------------- */ #ifndef GL_REGAL_extension_query #define GL_REGAL_extension_query 1 typedef GLboolean (GLAPIENTRY * PFNGLGETEXTENSIONREGALPROC) (const GLchar* ext); typedef GLboolean (GLAPIENTRY * PFNGLISSUPPORTEDREGALPROC) (const GLchar* ext); #define glGetExtensionREGAL GLEW_GET_FUN(__glewGetExtensionREGAL) #define glIsSupportedREGAL GLEW_GET_FUN(__glewIsSupportedREGAL) #define GLEW_REGAL_extension_query GLEW_GET_VAR(__GLEW_REGAL_extension_query) #endif /* GL_REGAL_extension_query */ /* ------------------------------ GL_REGAL_log ----------------------------- */ #ifndef GL_REGAL_log #define GL_REGAL_log 1 #define GL_LOG_ERROR_REGAL 0x9319 #define GL_LOG_WARNING_REGAL 0x931A #define GL_LOG_INFO_REGAL 0x931B #define GL_LOG_APP_REGAL 0x931C #define GL_LOG_DRIVER_REGAL 0x931D #define GL_LOG_INTERNAL_REGAL 0x931E #define GL_LOG_DEBUG_REGAL 0x931F #define GL_LOG_STATUS_REGAL 0x9320 #define GL_LOG_HTTP_REGAL 0x9321 typedef void (APIENTRY *GLLOGPROCREGAL)(GLenum stream, GLsizei length, const GLchar *message, void *context); typedef void (GLAPIENTRY * PFNGLLOGMESSAGECALLBACKREGALPROC) (GLLOGPROCREGAL callback); #define glLogMessageCallbackREGAL GLEW_GET_FUN(__glewLogMessageCallbackREGAL) #define GLEW_REGAL_log GLEW_GET_VAR(__GLEW_REGAL_log) #endif /* GL_REGAL_log */ /* ------------------------- GL_REGAL_proc_address ------------------------- */ #ifndef GL_REGAL_proc_address #define GL_REGAL_proc_address 1 typedef void * (GLAPIENTRY * PFNGLGETPROCADDRESSREGALPROC) (const GLchar *name); #define glGetProcAddressREGAL GLEW_GET_FUN(__glewGetProcAddressREGAL) #define GLEW_REGAL_proc_address GLEW_GET_VAR(__GLEW_REGAL_proc_address) #endif /* GL_REGAL_proc_address */ /* ----------------------- GL_REND_screen_coordinates ---------------------- */ #ifndef GL_REND_screen_coordinates #define GL_REND_screen_coordinates 1 #define GL_SCREEN_COORDINATES_REND 0x8490 #define GL_INVERTED_SCREEN_W_REND 0x8491 #define GLEW_REND_screen_coordinates GLEW_GET_VAR(__GLEW_REND_screen_coordinates) #endif /* GL_REND_screen_coordinates */ /* ------------------------------- GL_S3_s3tc ------------------------------ */ #ifndef GL_S3_s3tc #define GL_S3_s3tc 1 #define GL_RGB_S3TC 0x83A0 #define GL_RGB4_S3TC 0x83A1 #define GL_RGBA_S3TC 0x83A2 #define GL_RGBA4_S3TC 0x83A3 #define GL_RGBA_DXT5_S3TC 0x83A4 #define GL_RGBA4_DXT5_S3TC 0x83A5 #define GLEW_S3_s3tc GLEW_GET_VAR(__GLEW_S3_s3tc) #endif /* GL_S3_s3tc */ /* -------------------------- GL_SGIS_color_range -------------------------- */ #ifndef GL_SGIS_color_range #define GL_SGIS_color_range 1 #define GL_EXTENDED_RANGE_SGIS 0x85A5 #define GL_MIN_RED_SGIS 0x85A6 #define GL_MAX_RED_SGIS 0x85A7 #define GL_MIN_GREEN_SGIS 0x85A8 #define GL_MAX_GREEN_SGIS 0x85A9 #define GL_MIN_BLUE_SGIS 0x85AA #define GL_MAX_BLUE_SGIS 0x85AB #define GL_MIN_ALPHA_SGIS 0x85AC #define GL_MAX_ALPHA_SGIS 0x85AD #define GLEW_SGIS_color_range GLEW_GET_VAR(__GLEW_SGIS_color_range) #endif /* GL_SGIS_color_range */ /* ------------------------- GL_SGIS_detail_texture ------------------------ */ #ifndef GL_SGIS_detail_texture #define GL_SGIS_detail_texture 1 typedef void (GLAPIENTRY * PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); typedef void (GLAPIENTRY * PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat* points); #define glDetailTexFuncSGIS GLEW_GET_FUN(__glewDetailTexFuncSGIS) #define glGetDetailTexFuncSGIS GLEW_GET_FUN(__glewGetDetailTexFuncSGIS) #define GLEW_SGIS_detail_texture GLEW_GET_VAR(__GLEW_SGIS_detail_texture) #endif /* GL_SGIS_detail_texture */ /* -------------------------- GL_SGIS_fog_function ------------------------- */ #ifndef GL_SGIS_fog_function #define GL_SGIS_fog_function 1 typedef void (GLAPIENTRY * PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat* points); typedef void (GLAPIENTRY * PFNGLGETFOGFUNCSGISPROC) (GLfloat* points); #define glFogFuncSGIS GLEW_GET_FUN(__glewFogFuncSGIS) #define glGetFogFuncSGIS GLEW_GET_FUN(__glewGetFogFuncSGIS) #define GLEW_SGIS_fog_function GLEW_GET_VAR(__GLEW_SGIS_fog_function) #endif /* GL_SGIS_fog_function */ /* ------------------------ GL_SGIS_generate_mipmap ------------------------ */ #ifndef GL_SGIS_generate_mipmap #define GL_SGIS_generate_mipmap 1 #define GL_GENERATE_MIPMAP_SGIS 0x8191 #define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 #define GLEW_SGIS_generate_mipmap GLEW_GET_VAR(__GLEW_SGIS_generate_mipmap) #endif /* GL_SGIS_generate_mipmap */ /* -------------------------- GL_SGIS_multisample -------------------------- */ #ifndef GL_SGIS_multisample #define GL_SGIS_multisample 1 #define GL_MULTISAMPLE_SGIS 0x809D #define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E #define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F #define GL_SAMPLE_MASK_SGIS 0x80A0 #define GL_1PASS_SGIS 0x80A1 #define GL_2PASS_0_SGIS 0x80A2 #define GL_2PASS_1_SGIS 0x80A3 #define GL_4PASS_0_SGIS 0x80A4 #define GL_4PASS_1_SGIS 0x80A5 #define GL_4PASS_2_SGIS 0x80A6 #define GL_4PASS_3_SGIS 0x80A7 #define GL_SAMPLE_BUFFERS_SGIS 0x80A8 #define GL_SAMPLES_SGIS 0x80A9 #define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA #define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB #define GL_SAMPLE_PATTERN_SGIS 0x80AC typedef void (GLAPIENTRY * PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); #define glSampleMaskSGIS GLEW_GET_FUN(__glewSampleMaskSGIS) #define glSamplePatternSGIS GLEW_GET_FUN(__glewSamplePatternSGIS) #define GLEW_SGIS_multisample GLEW_GET_VAR(__GLEW_SGIS_multisample) #endif /* GL_SGIS_multisample */ /* ------------------------- GL_SGIS_pixel_texture ------------------------- */ #ifndef GL_SGIS_pixel_texture #define GL_SGIS_pixel_texture 1 #define GLEW_SGIS_pixel_texture GLEW_GET_VAR(__GLEW_SGIS_pixel_texture) #endif /* GL_SGIS_pixel_texture */ /* ----------------------- GL_SGIS_point_line_texgen ----------------------- */ #ifndef GL_SGIS_point_line_texgen #define GL_SGIS_point_line_texgen 1 #define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 #define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 #define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 #define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 #define GL_EYE_POINT_SGIS 0x81F4 #define GL_OBJECT_POINT_SGIS 0x81F5 #define GL_EYE_LINE_SGIS 0x81F6 #define GL_OBJECT_LINE_SGIS 0x81F7 #define GLEW_SGIS_point_line_texgen GLEW_GET_VAR(__GLEW_SGIS_point_line_texgen) #endif /* GL_SGIS_point_line_texgen */ /* ------------------------ GL_SGIS_sharpen_texture ------------------------ */ #ifndef GL_SGIS_sharpen_texture #define GL_SGIS_sharpen_texture 1 typedef void (GLAPIENTRY * PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat* points); typedef void (GLAPIENTRY * PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); #define glGetSharpenTexFuncSGIS GLEW_GET_FUN(__glewGetSharpenTexFuncSGIS) #define glSharpenTexFuncSGIS GLEW_GET_FUN(__glewSharpenTexFuncSGIS) #define GLEW_SGIS_sharpen_texture GLEW_GET_VAR(__GLEW_SGIS_sharpen_texture) #endif /* GL_SGIS_sharpen_texture */ /* --------------------------- GL_SGIS_texture4D --------------------------- */ #ifndef GL_SGIS_texture4D #define GL_SGIS_texture4D 1 typedef void (GLAPIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLenum format, GLenum type, const void *pixels); #define glTexImage4DSGIS GLEW_GET_FUN(__glewTexImage4DSGIS) #define glTexSubImage4DSGIS GLEW_GET_FUN(__glewTexSubImage4DSGIS) #define GLEW_SGIS_texture4D GLEW_GET_VAR(__GLEW_SGIS_texture4D) #endif /* GL_SGIS_texture4D */ /* ---------------------- GL_SGIS_texture_border_clamp --------------------- */ #ifndef GL_SGIS_texture_border_clamp #define GL_SGIS_texture_border_clamp 1 #define GL_CLAMP_TO_BORDER_SGIS 0x812D #define GLEW_SGIS_texture_border_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_border_clamp) #endif /* GL_SGIS_texture_border_clamp */ /* ----------------------- GL_SGIS_texture_edge_clamp ---------------------- */ #ifndef GL_SGIS_texture_edge_clamp #define GL_SGIS_texture_edge_clamp 1 #define GL_CLAMP_TO_EDGE_SGIS 0x812F #define GLEW_SGIS_texture_edge_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_edge_clamp) #endif /* GL_SGIS_texture_edge_clamp */ /* ------------------------ GL_SGIS_texture_filter4 ------------------------ */ #ifndef GL_SGIS_texture_filter4 #define GL_SGIS_texture_filter4 1 typedef void (GLAPIENTRY * PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat* weights); typedef void (GLAPIENTRY * PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat* weights); #define glGetTexFilterFuncSGIS GLEW_GET_FUN(__glewGetTexFilterFuncSGIS) #define glTexFilterFuncSGIS GLEW_GET_FUN(__glewTexFilterFuncSGIS) #define GLEW_SGIS_texture_filter4 GLEW_GET_VAR(__GLEW_SGIS_texture_filter4) #endif /* GL_SGIS_texture_filter4 */ /* -------------------------- GL_SGIS_texture_lod -------------------------- */ #ifndef GL_SGIS_texture_lod #define GL_SGIS_texture_lod 1 #define GL_TEXTURE_MIN_LOD_SGIS 0x813A #define GL_TEXTURE_MAX_LOD_SGIS 0x813B #define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C #define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D #define GLEW_SGIS_texture_lod GLEW_GET_VAR(__GLEW_SGIS_texture_lod) #endif /* GL_SGIS_texture_lod */ /* ------------------------- GL_SGIS_texture_select ------------------------ */ #ifndef GL_SGIS_texture_select #define GL_SGIS_texture_select 1 #define GLEW_SGIS_texture_select GLEW_GET_VAR(__GLEW_SGIS_texture_select) #endif /* GL_SGIS_texture_select */ /* ----------------------------- GL_SGIX_async ----------------------------- */ #ifndef GL_SGIX_async #define GL_SGIX_async 1 #define GL_ASYNC_MARKER_SGIX 0x8329 typedef void (GLAPIENTRY * PFNGLASYNCMARKERSGIXPROC) (GLuint marker); typedef void (GLAPIENTRY * PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); typedef GLint (GLAPIENTRY * PFNGLFINISHASYNCSGIXPROC) (GLuint* markerp); typedef GLuint (GLAPIENTRY * PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); typedef GLboolean (GLAPIENTRY * PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); typedef GLint (GLAPIENTRY * PFNGLPOLLASYNCSGIXPROC) (GLuint* markerp); #define glAsyncMarkerSGIX GLEW_GET_FUN(__glewAsyncMarkerSGIX) #define glDeleteAsyncMarkersSGIX GLEW_GET_FUN(__glewDeleteAsyncMarkersSGIX) #define glFinishAsyncSGIX GLEW_GET_FUN(__glewFinishAsyncSGIX) #define glGenAsyncMarkersSGIX GLEW_GET_FUN(__glewGenAsyncMarkersSGIX) #define glIsAsyncMarkerSGIX GLEW_GET_FUN(__glewIsAsyncMarkerSGIX) #define glPollAsyncSGIX GLEW_GET_FUN(__glewPollAsyncSGIX) #define GLEW_SGIX_async GLEW_GET_VAR(__GLEW_SGIX_async) #endif /* GL_SGIX_async */ /* ------------------------ GL_SGIX_async_histogram ------------------------ */ #ifndef GL_SGIX_async_histogram #define GL_SGIX_async_histogram 1 #define GL_ASYNC_HISTOGRAM_SGIX 0x832C #define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D #define GLEW_SGIX_async_histogram GLEW_GET_VAR(__GLEW_SGIX_async_histogram) #endif /* GL_SGIX_async_histogram */ /* -------------------------- GL_SGIX_async_pixel -------------------------- */ #ifndef GL_SGIX_async_pixel #define GL_SGIX_async_pixel 1 #define GL_ASYNC_TEX_IMAGE_SGIX 0x835C #define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D #define GL_ASYNC_READ_PIXELS_SGIX 0x835E #define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F #define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 #define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 #define GLEW_SGIX_async_pixel GLEW_GET_VAR(__GLEW_SGIX_async_pixel) #endif /* GL_SGIX_async_pixel */ /* ----------------------- GL_SGIX_blend_alpha_minmax ---------------------- */ #ifndef GL_SGIX_blend_alpha_minmax #define GL_SGIX_blend_alpha_minmax 1 #define GL_ALPHA_MIN_SGIX 0x8320 #define GL_ALPHA_MAX_SGIX 0x8321 #define GLEW_SGIX_blend_alpha_minmax GLEW_GET_VAR(__GLEW_SGIX_blend_alpha_minmax) #endif /* GL_SGIX_blend_alpha_minmax */ /* ---------------------------- GL_SGIX_clipmap ---------------------------- */ #ifndef GL_SGIX_clipmap #define GL_SGIX_clipmap 1 #define GLEW_SGIX_clipmap GLEW_GET_VAR(__GLEW_SGIX_clipmap) #endif /* GL_SGIX_clipmap */ /* ---------------------- GL_SGIX_convolution_accuracy --------------------- */ #ifndef GL_SGIX_convolution_accuracy #define GL_SGIX_convolution_accuracy 1 #define GL_CONVOLUTION_HINT_SGIX 0x8316 #define GLEW_SGIX_convolution_accuracy GLEW_GET_VAR(__GLEW_SGIX_convolution_accuracy) #endif /* GL_SGIX_convolution_accuracy */ /* ------------------------- GL_SGIX_depth_texture ------------------------- */ #ifndef GL_SGIX_depth_texture #define GL_SGIX_depth_texture 1 #define GL_DEPTH_COMPONENT16_SGIX 0x81A5 #define GL_DEPTH_COMPONENT24_SGIX 0x81A6 #define GL_DEPTH_COMPONENT32_SGIX 0x81A7 #define GLEW_SGIX_depth_texture GLEW_GET_VAR(__GLEW_SGIX_depth_texture) #endif /* GL_SGIX_depth_texture */ /* -------------------------- GL_SGIX_flush_raster ------------------------- */ #ifndef GL_SGIX_flush_raster #define GL_SGIX_flush_raster 1 typedef void (GLAPIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void); #define glFlushRasterSGIX GLEW_GET_FUN(__glewFlushRasterSGIX) #define GLEW_SGIX_flush_raster GLEW_GET_VAR(__GLEW_SGIX_flush_raster) #endif /* GL_SGIX_flush_raster */ /* --------------------------- GL_SGIX_fog_offset -------------------------- */ #ifndef GL_SGIX_fog_offset #define GL_SGIX_fog_offset 1 #define GL_FOG_OFFSET_SGIX 0x8198 #define GL_FOG_OFFSET_VALUE_SGIX 0x8199 #define GLEW_SGIX_fog_offset GLEW_GET_VAR(__GLEW_SGIX_fog_offset) #endif /* GL_SGIX_fog_offset */ /* -------------------------- GL_SGIX_fog_texture -------------------------- */ #ifndef GL_SGIX_fog_texture #define GL_SGIX_fog_texture 1 #define GL_FOG_PATCHY_FACTOR_SGIX 0 #define GL_FRAGMENT_FOG_SGIX 0 #define GL_TEXTURE_FOG_SGIX 0 typedef void (GLAPIENTRY * PFNGLTEXTUREFOGSGIXPROC) (GLenum pname); #define glTextureFogSGIX GLEW_GET_FUN(__glewTextureFogSGIX) #define GLEW_SGIX_fog_texture GLEW_GET_VAR(__GLEW_SGIX_fog_texture) #endif /* GL_SGIX_fog_texture */ /* ------------------- GL_SGIX_fragment_specular_lighting ------------------ */ #ifndef GL_SGIX_fragment_specular_lighting #define GL_SGIX_fragment_specular_lighting 1 typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, const GLfloat param); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, const GLint param); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum value, GLfloat* data); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum value, GLint* data); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* data); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* data); #define glFragmentColorMaterialSGIX GLEW_GET_FUN(__glewFragmentColorMaterialSGIX) #define glFragmentLightModelfSGIX GLEW_GET_FUN(__glewFragmentLightModelfSGIX) #define glFragmentLightModelfvSGIX GLEW_GET_FUN(__glewFragmentLightModelfvSGIX) #define glFragmentLightModeliSGIX GLEW_GET_FUN(__glewFragmentLightModeliSGIX) #define glFragmentLightModelivSGIX GLEW_GET_FUN(__glewFragmentLightModelivSGIX) #define glFragmentLightfSGIX GLEW_GET_FUN(__glewFragmentLightfSGIX) #define glFragmentLightfvSGIX GLEW_GET_FUN(__glewFragmentLightfvSGIX) #define glFragmentLightiSGIX GLEW_GET_FUN(__glewFragmentLightiSGIX) #define glFragmentLightivSGIX GLEW_GET_FUN(__glewFragmentLightivSGIX) #define glFragmentMaterialfSGIX GLEW_GET_FUN(__glewFragmentMaterialfSGIX) #define glFragmentMaterialfvSGIX GLEW_GET_FUN(__glewFragmentMaterialfvSGIX) #define glFragmentMaterialiSGIX GLEW_GET_FUN(__glewFragmentMaterialiSGIX) #define glFragmentMaterialivSGIX GLEW_GET_FUN(__glewFragmentMaterialivSGIX) #define glGetFragmentLightfvSGIX GLEW_GET_FUN(__glewGetFragmentLightfvSGIX) #define glGetFragmentLightivSGIX GLEW_GET_FUN(__glewGetFragmentLightivSGIX) #define glGetFragmentMaterialfvSGIX GLEW_GET_FUN(__glewGetFragmentMaterialfvSGIX) #define glGetFragmentMaterialivSGIX GLEW_GET_FUN(__glewGetFragmentMaterialivSGIX) #define GLEW_SGIX_fragment_specular_lighting GLEW_GET_VAR(__GLEW_SGIX_fragment_specular_lighting) #endif /* GL_SGIX_fragment_specular_lighting */ /* --------------------------- GL_SGIX_framezoom --------------------------- */ #ifndef GL_SGIX_framezoom #define GL_SGIX_framezoom 1 typedef void (GLAPIENTRY * PFNGLFRAMEZOOMSGIXPROC) (GLint factor); #define glFrameZoomSGIX GLEW_GET_FUN(__glewFrameZoomSGIX) #define GLEW_SGIX_framezoom GLEW_GET_VAR(__GLEW_SGIX_framezoom) #endif /* GL_SGIX_framezoom */ /* --------------------------- GL_SGIX_interlace --------------------------- */ #ifndef GL_SGIX_interlace #define GL_SGIX_interlace 1 #define GL_INTERLACE_SGIX 0x8094 #define GLEW_SGIX_interlace GLEW_GET_VAR(__GLEW_SGIX_interlace) #endif /* GL_SGIX_interlace */ /* ------------------------- GL_SGIX_ir_instrument1 ------------------------ */ #ifndef GL_SGIX_ir_instrument1 #define GL_SGIX_ir_instrument1 1 #define GLEW_SGIX_ir_instrument1 GLEW_GET_VAR(__GLEW_SGIX_ir_instrument1) #endif /* GL_SGIX_ir_instrument1 */ /* ------------------------- GL_SGIX_list_priority ------------------------- */ #ifndef GL_SGIX_list_priority #define GL_SGIX_list_priority 1 #define GLEW_SGIX_list_priority GLEW_GET_VAR(__GLEW_SGIX_list_priority) #endif /* GL_SGIX_list_priority */ /* ------------------------- GL_SGIX_pixel_texture ------------------------- */ #ifndef GL_SGIX_pixel_texture #define GL_SGIX_pixel_texture 1 typedef void (GLAPIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); #define glPixelTexGenSGIX GLEW_GET_FUN(__glewPixelTexGenSGIX) #define GLEW_SGIX_pixel_texture GLEW_GET_VAR(__GLEW_SGIX_pixel_texture) #endif /* GL_SGIX_pixel_texture */ /* ----------------------- GL_SGIX_pixel_texture_bits ---------------------- */ #ifndef GL_SGIX_pixel_texture_bits #define GL_SGIX_pixel_texture_bits 1 #define GLEW_SGIX_pixel_texture_bits GLEW_GET_VAR(__GLEW_SGIX_pixel_texture_bits) #endif /* GL_SGIX_pixel_texture_bits */ /* ------------------------ GL_SGIX_reference_plane ------------------------ */ #ifndef GL_SGIX_reference_plane #define GL_SGIX_reference_plane 1 typedef void (GLAPIENTRY * PFNGLREFERENCEPLANESGIXPROC) (const GLdouble* equation); #define glReferencePlaneSGIX GLEW_GET_FUN(__glewReferencePlaneSGIX) #define GLEW_SGIX_reference_plane GLEW_GET_VAR(__GLEW_SGIX_reference_plane) #endif /* GL_SGIX_reference_plane */ /* ---------------------------- GL_SGIX_resample --------------------------- */ #ifndef GL_SGIX_resample #define GL_SGIX_resample 1 #define GL_PACK_RESAMPLE_SGIX 0x842E #define GL_UNPACK_RESAMPLE_SGIX 0x842F #define GL_RESAMPLE_DECIMATE_SGIX 0x8430 #define GL_RESAMPLE_REPLICATE_SGIX 0x8433 #define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 #define GLEW_SGIX_resample GLEW_GET_VAR(__GLEW_SGIX_resample) #endif /* GL_SGIX_resample */ /* ----------------------------- GL_SGIX_shadow ---------------------------- */ #ifndef GL_SGIX_shadow #define GL_SGIX_shadow 1 #define GL_TEXTURE_COMPARE_SGIX 0x819A #define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B #define GL_TEXTURE_LEQUAL_R_SGIX 0x819C #define GL_TEXTURE_GEQUAL_R_SGIX 0x819D #define GLEW_SGIX_shadow GLEW_GET_VAR(__GLEW_SGIX_shadow) #endif /* GL_SGIX_shadow */ /* ------------------------- GL_SGIX_shadow_ambient ------------------------ */ #ifndef GL_SGIX_shadow_ambient #define GL_SGIX_shadow_ambient 1 #define GL_SHADOW_AMBIENT_SGIX 0x80BF #define GLEW_SGIX_shadow_ambient GLEW_GET_VAR(__GLEW_SGIX_shadow_ambient) #endif /* GL_SGIX_shadow_ambient */ /* ----------------------------- GL_SGIX_sprite ---------------------------- */ #ifndef GL_SGIX_sprite #define GL_SGIX_sprite 1 typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, GLint* params); #define glSpriteParameterfSGIX GLEW_GET_FUN(__glewSpriteParameterfSGIX) #define glSpriteParameterfvSGIX GLEW_GET_FUN(__glewSpriteParameterfvSGIX) #define glSpriteParameteriSGIX GLEW_GET_FUN(__glewSpriteParameteriSGIX) #define glSpriteParameterivSGIX GLEW_GET_FUN(__glewSpriteParameterivSGIX) #define GLEW_SGIX_sprite GLEW_GET_VAR(__GLEW_SGIX_sprite) #endif /* GL_SGIX_sprite */ /* ----------------------- GL_SGIX_tag_sample_buffer ----------------------- */ #ifndef GL_SGIX_tag_sample_buffer #define GL_SGIX_tag_sample_buffer 1 typedef void (GLAPIENTRY * PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); #define glTagSampleBufferSGIX GLEW_GET_FUN(__glewTagSampleBufferSGIX) #define GLEW_SGIX_tag_sample_buffer GLEW_GET_VAR(__GLEW_SGIX_tag_sample_buffer) #endif /* GL_SGIX_tag_sample_buffer */ /* ------------------------ GL_SGIX_texture_add_env ------------------------ */ #ifndef GL_SGIX_texture_add_env #define GL_SGIX_texture_add_env 1 #define GLEW_SGIX_texture_add_env GLEW_GET_VAR(__GLEW_SGIX_texture_add_env) #endif /* GL_SGIX_texture_add_env */ /* -------------------- GL_SGIX_texture_coordinate_clamp ------------------- */ #ifndef GL_SGIX_texture_coordinate_clamp #define GL_SGIX_texture_coordinate_clamp 1 #define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 #define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A #define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B #define GLEW_SGIX_texture_coordinate_clamp GLEW_GET_VAR(__GLEW_SGIX_texture_coordinate_clamp) #endif /* GL_SGIX_texture_coordinate_clamp */ /* ------------------------ GL_SGIX_texture_lod_bias ----------------------- */ #ifndef GL_SGIX_texture_lod_bias #define GL_SGIX_texture_lod_bias 1 #define GLEW_SGIX_texture_lod_bias GLEW_GET_VAR(__GLEW_SGIX_texture_lod_bias) #endif /* GL_SGIX_texture_lod_bias */ /* ---------------------- GL_SGIX_texture_multi_buffer --------------------- */ #ifndef GL_SGIX_texture_multi_buffer #define GL_SGIX_texture_multi_buffer 1 #define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E #define GLEW_SGIX_texture_multi_buffer GLEW_GET_VAR(__GLEW_SGIX_texture_multi_buffer) #endif /* GL_SGIX_texture_multi_buffer */ /* ------------------------- GL_SGIX_texture_range ------------------------- */ #ifndef GL_SGIX_texture_range #define GL_SGIX_texture_range 1 #define GL_RGB_SIGNED_SGIX 0x85E0 #define GL_RGBA_SIGNED_SGIX 0x85E1 #define GL_ALPHA_SIGNED_SGIX 0x85E2 #define GL_LUMINANCE_SIGNED_SGIX 0x85E3 #define GL_INTENSITY_SIGNED_SGIX 0x85E4 #define GL_LUMINANCE_ALPHA_SIGNED_SGIX 0x85E5 #define GL_RGB16_SIGNED_SGIX 0x85E6 #define GL_RGBA16_SIGNED_SGIX 0x85E7 #define GL_ALPHA16_SIGNED_SGIX 0x85E8 #define GL_LUMINANCE16_SIGNED_SGIX 0x85E9 #define GL_INTENSITY16_SIGNED_SGIX 0x85EA #define GL_LUMINANCE16_ALPHA16_SIGNED_SGIX 0x85EB #define GL_RGB_EXTENDED_RANGE_SGIX 0x85EC #define GL_RGBA_EXTENDED_RANGE_SGIX 0x85ED #define GL_ALPHA_EXTENDED_RANGE_SGIX 0x85EE #define GL_LUMINANCE_EXTENDED_RANGE_SGIX 0x85EF #define GL_INTENSITY_EXTENDED_RANGE_SGIX 0x85F0 #define GL_LUMINANCE_ALPHA_EXTENDED_RANGE_SGIX 0x85F1 #define GL_RGB16_EXTENDED_RANGE_SGIX 0x85F2 #define GL_RGBA16_EXTENDED_RANGE_SGIX 0x85F3 #define GL_ALPHA16_EXTENDED_RANGE_SGIX 0x85F4 #define GL_LUMINANCE16_EXTENDED_RANGE_SGIX 0x85F5 #define GL_INTENSITY16_EXTENDED_RANGE_SGIX 0x85F6 #define GL_LUMINANCE16_ALPHA16_EXTENDED_RANGE_SGIX 0x85F7 #define GL_MIN_LUMINANCE_SGIS 0x85F8 #define GL_MAX_LUMINANCE_SGIS 0x85F9 #define GL_MIN_INTENSITY_SGIS 0x85FA #define GL_MAX_INTENSITY_SGIS 0x85FB #define GLEW_SGIX_texture_range GLEW_GET_VAR(__GLEW_SGIX_texture_range) #endif /* GL_SGIX_texture_range */ /* ----------------------- GL_SGIX_texture_scale_bias ---------------------- */ #ifndef GL_SGIX_texture_scale_bias #define GL_SGIX_texture_scale_bias 1 #define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 #define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A #define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B #define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C #define GLEW_SGIX_texture_scale_bias GLEW_GET_VAR(__GLEW_SGIX_texture_scale_bias) #endif /* GL_SGIX_texture_scale_bias */ /* ------------------------- GL_SGIX_vertex_preclip ------------------------ */ #ifndef GL_SGIX_vertex_preclip #define GL_SGIX_vertex_preclip 1 #define GL_VERTEX_PRECLIP_SGIX 0x83EE #define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF #define GLEW_SGIX_vertex_preclip GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip) #endif /* GL_SGIX_vertex_preclip */ /* ---------------------- GL_SGIX_vertex_preclip_hint ---------------------- */ #ifndef GL_SGIX_vertex_preclip_hint #define GL_SGIX_vertex_preclip_hint 1 #define GL_VERTEX_PRECLIP_SGIX 0x83EE #define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF #define GLEW_SGIX_vertex_preclip_hint GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip_hint) #endif /* GL_SGIX_vertex_preclip_hint */ /* ----------------------------- GL_SGIX_ycrcb ----------------------------- */ #ifndef GL_SGIX_ycrcb #define GL_SGIX_ycrcb 1 #define GLEW_SGIX_ycrcb GLEW_GET_VAR(__GLEW_SGIX_ycrcb) #endif /* GL_SGIX_ycrcb */ /* -------------------------- GL_SGI_color_matrix -------------------------- */ #ifndef GL_SGI_color_matrix #define GL_SGI_color_matrix 1 #define GL_COLOR_MATRIX_SGI 0x80B1 #define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 #define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 #define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 #define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 #define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 #define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 #define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 #define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 #define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA #define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB #define GLEW_SGI_color_matrix GLEW_GET_VAR(__GLEW_SGI_color_matrix) #endif /* GL_SGI_color_matrix */ /* --------------------------- GL_SGI_color_table -------------------------- */ #ifndef GL_SGI_color_table #define GL_SGI_color_table 1 #define GL_COLOR_TABLE_SGI 0x80D0 #define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 #define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 #define GL_PROXY_COLOR_TABLE_SGI 0x80D3 #define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 #define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 #define GL_COLOR_TABLE_SCALE_SGI 0x80D6 #define GL_COLOR_TABLE_BIAS_SGI 0x80D7 #define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 #define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 #define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA #define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB #define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC #define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD #define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE #define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); #define glColorTableParameterfvSGI GLEW_GET_FUN(__glewColorTableParameterfvSGI) #define glColorTableParameterivSGI GLEW_GET_FUN(__glewColorTableParameterivSGI) #define glColorTableSGI GLEW_GET_FUN(__glewColorTableSGI) #define glCopyColorTableSGI GLEW_GET_FUN(__glewCopyColorTableSGI) #define glGetColorTableParameterfvSGI GLEW_GET_FUN(__glewGetColorTableParameterfvSGI) #define glGetColorTableParameterivSGI GLEW_GET_FUN(__glewGetColorTableParameterivSGI) #define glGetColorTableSGI GLEW_GET_FUN(__glewGetColorTableSGI) #define GLEW_SGI_color_table GLEW_GET_VAR(__GLEW_SGI_color_table) #endif /* GL_SGI_color_table */ /* ----------------------- GL_SGI_texture_color_table ---------------------- */ #ifndef GL_SGI_texture_color_table #define GL_SGI_texture_color_table 1 #define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC #define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD #define GLEW_SGI_texture_color_table GLEW_GET_VAR(__GLEW_SGI_texture_color_table) #endif /* GL_SGI_texture_color_table */ /* ------------------------- GL_SUNX_constant_data ------------------------- */ #ifndef GL_SUNX_constant_data #define GL_SUNX_constant_data 1 #define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 #define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 typedef void (GLAPIENTRY * PFNGLFINISHTEXTURESUNXPROC) (void); #define glFinishTextureSUNX GLEW_GET_FUN(__glewFinishTextureSUNX) #define GLEW_SUNX_constant_data GLEW_GET_VAR(__GLEW_SUNX_constant_data) #endif /* GL_SUNX_constant_data */ /* -------------------- GL_SUN_convolution_border_modes -------------------- */ #ifndef GL_SUN_convolution_border_modes #define GL_SUN_convolution_border_modes 1 #define GL_WRAP_BORDER_SUN 0x81D4 #define GLEW_SUN_convolution_border_modes GLEW_GET_VAR(__GLEW_SUN_convolution_border_modes) #endif /* GL_SUN_convolution_border_modes */ /* -------------------------- GL_SUN_global_alpha -------------------------- */ #ifndef GL_SUN_global_alpha #define GL_SUN_global_alpha 1 #define GL_GLOBAL_ALPHA_SUN 0x81D9 #define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); #define glGlobalAlphaFactorbSUN GLEW_GET_FUN(__glewGlobalAlphaFactorbSUN) #define glGlobalAlphaFactordSUN GLEW_GET_FUN(__glewGlobalAlphaFactordSUN) #define glGlobalAlphaFactorfSUN GLEW_GET_FUN(__glewGlobalAlphaFactorfSUN) #define glGlobalAlphaFactoriSUN GLEW_GET_FUN(__glewGlobalAlphaFactoriSUN) #define glGlobalAlphaFactorsSUN GLEW_GET_FUN(__glewGlobalAlphaFactorsSUN) #define glGlobalAlphaFactorubSUN GLEW_GET_FUN(__glewGlobalAlphaFactorubSUN) #define glGlobalAlphaFactoruiSUN GLEW_GET_FUN(__glewGlobalAlphaFactoruiSUN) #define glGlobalAlphaFactorusSUN GLEW_GET_FUN(__glewGlobalAlphaFactorusSUN) #define GLEW_SUN_global_alpha GLEW_GET_VAR(__GLEW_SUN_global_alpha) #endif /* GL_SUN_global_alpha */ /* --------------------------- GL_SUN_mesh_array --------------------------- */ #ifndef GL_SUN_mesh_array #define GL_SUN_mesh_array 1 #define GL_QUAD_MESH_SUN 0x8614 #define GL_TRIANGLE_MESH_SUN 0x8615 #define GLEW_SUN_mesh_array GLEW_GET_VAR(__GLEW_SUN_mesh_array) #endif /* GL_SUN_mesh_array */ /* ------------------------ GL_SUN_read_video_pixels ----------------------- */ #ifndef GL_SUN_read_video_pixels #define GL_SUN_read_video_pixels 1 typedef void (GLAPIENTRY * PFNGLREADVIDEOPIXELSSUNPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels); #define glReadVideoPixelsSUN GLEW_GET_FUN(__glewReadVideoPixelsSUN) #define GLEW_SUN_read_video_pixels GLEW_GET_VAR(__GLEW_SUN_read_video_pixels) #endif /* GL_SUN_read_video_pixels */ /* --------------------------- GL_SUN_slice_accum -------------------------- */ #ifndef GL_SUN_slice_accum #define GL_SUN_slice_accum 1 #define GL_SLICE_ACCUM_SUN 0x85CC #define GLEW_SUN_slice_accum GLEW_GET_VAR(__GLEW_SUN_slice_accum) #endif /* GL_SUN_slice_accum */ /* -------------------------- GL_SUN_triangle_list ------------------------- */ #ifndef GL_SUN_triangle_list #define GL_SUN_triangle_list 1 #define GL_RESTART_SUN 0x01 #define GL_REPLACE_MIDDLE_SUN 0x02 #define GL_REPLACE_OLDEST_SUN 0x03 #define GL_TRIANGLE_LIST_SUN 0x81D7 #define GL_REPLACEMENT_CODE_SUN 0x81D8 #define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 #define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 #define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 #define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 #define GL_R1UI_V3F_SUN 0x85C4 #define GL_R1UI_C4UB_V3F_SUN 0x85C5 #define GL_R1UI_C3F_V3F_SUN 0x85C6 #define GL_R1UI_N3F_V3F_SUN 0x85C7 #define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 #define GL_R1UI_T2F_V3F_SUN 0x85C9 #define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA #define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void *pointer); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte* code); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint* code); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort* code); #define glReplacementCodePointerSUN GLEW_GET_FUN(__glewReplacementCodePointerSUN) #define glReplacementCodeubSUN GLEW_GET_FUN(__glewReplacementCodeubSUN) #define glReplacementCodeubvSUN GLEW_GET_FUN(__glewReplacementCodeubvSUN) #define glReplacementCodeuiSUN GLEW_GET_FUN(__glewReplacementCodeuiSUN) #define glReplacementCodeuivSUN GLEW_GET_FUN(__glewReplacementCodeuivSUN) #define glReplacementCodeusSUN GLEW_GET_FUN(__glewReplacementCodeusSUN) #define glReplacementCodeusvSUN GLEW_GET_FUN(__glewReplacementCodeusvSUN) #define GLEW_SUN_triangle_list GLEW_GET_VAR(__GLEW_SUN_triangle_list) #endif /* GL_SUN_triangle_list */ /* ----------------------------- GL_SUN_vertex ----------------------------- */ #ifndef GL_SUN_vertex #define GL_SUN_vertex 1 typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte* c, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte* c, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint* rc, const GLubyte *c, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat* tc, const GLubyte *c, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *v); #define glColor3fVertex3fSUN GLEW_GET_FUN(__glewColor3fVertex3fSUN) #define glColor3fVertex3fvSUN GLEW_GET_FUN(__glewColor3fVertex3fvSUN) #define glColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fSUN) #define glColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fvSUN) #define glColor4ubVertex2fSUN GLEW_GET_FUN(__glewColor4ubVertex2fSUN) #define glColor4ubVertex2fvSUN GLEW_GET_FUN(__glewColor4ubVertex2fvSUN) #define glColor4ubVertex3fSUN GLEW_GET_FUN(__glewColor4ubVertex3fSUN) #define glColor4ubVertex3fvSUN GLEW_GET_FUN(__glewColor4ubVertex3fvSUN) #define glNormal3fVertex3fSUN GLEW_GET_FUN(__glewNormal3fVertex3fSUN) #define glNormal3fVertex3fvSUN GLEW_GET_FUN(__glewNormal3fVertex3fvSUN) #define glReplacementCodeuiColor3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fSUN) #define glReplacementCodeuiColor3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fvSUN) #define glReplacementCodeuiColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fSUN) #define glReplacementCodeuiColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fvSUN) #define glReplacementCodeuiColor4ubVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fSUN) #define glReplacementCodeuiColor4ubVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fvSUN) #define glReplacementCodeuiNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fSUN) #define glReplacementCodeuiNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fvSUN) #define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN) #define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN) #define glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN) #define glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN) #define glReplacementCodeuiTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fSUN) #define glReplacementCodeuiTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fvSUN) #define glReplacementCodeuiVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fSUN) #define glReplacementCodeuiVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fvSUN) #define glTexCoord2fColor3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fSUN) #define glTexCoord2fColor3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fvSUN) #define glTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fSUN) #define glTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fvSUN) #define glTexCoord2fColor4ubVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fSUN) #define glTexCoord2fColor4ubVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fvSUN) #define glTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fSUN) #define glTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fvSUN) #define glTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fSUN) #define glTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fvSUN) #define glTexCoord4fColor4fNormal3fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fSUN) #define glTexCoord4fColor4fNormal3fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fvSUN) #define glTexCoord4fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fSUN) #define glTexCoord4fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fvSUN) #define GLEW_SUN_vertex GLEW_GET_VAR(__GLEW_SUN_vertex) #endif /* GL_SUN_vertex */ /* -------------------------- GL_WIN_phong_shading ------------------------- */ #ifndef GL_WIN_phong_shading #define GL_WIN_phong_shading 1 #define GL_PHONG_WIN 0x80EA #define GL_PHONG_HINT_WIN 0x80EB #define GLEW_WIN_phong_shading GLEW_GET_VAR(__GLEW_WIN_phong_shading) #endif /* GL_WIN_phong_shading */ /* -------------------------- GL_WIN_specular_fog -------------------------- */ #ifndef GL_WIN_specular_fog #define GL_WIN_specular_fog 1 #define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC #define GLEW_WIN_specular_fog GLEW_GET_VAR(__GLEW_WIN_specular_fog) #endif /* GL_WIN_specular_fog */ /* ---------------------------- GL_WIN_swap_hint --------------------------- */ #ifndef GL_WIN_swap_hint #define GL_WIN_swap_hint 1 typedef void (GLAPIENTRY * PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei width, GLsizei height); #define glAddSwapHintRectWIN GLEW_GET_FUN(__glewAddSwapHintRectWIN) #define GLEW_WIN_swap_hint GLEW_GET_VAR(__GLEW_WIN_swap_hint) #endif /* GL_WIN_swap_hint */ /* ------------------------------------------------------------------------- */ #if defined(GLEW_MX) && defined(_WIN32) #define GLEW_FUN_EXPORT #else #define GLEW_FUN_EXPORT GLEWAPI #endif /* GLEW_MX */ #if defined(GLEW_MX) #define GLEW_VAR_EXPORT #else #define GLEW_VAR_EXPORT GLEWAPI #endif /* GLEW_MX */ #if defined(GLEW_MX) && defined(_WIN32) struct GLEWContextStruct { #endif /* GLEW_MX */ GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D; GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSPROC __glewDrawRangeElements; GLEW_FUN_EXPORT PFNGLTEXIMAGE3DPROC __glewTexImage3D; GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DPROC __glewTexSubImage3D; GLEW_FUN_EXPORT PFNGLACTIVETEXTUREPROC __glewActiveTexture; GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DPROC __glewCompressedTexImage1D; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DPROC __glewCompressedTexImage2D; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DPROC __glewCompressedTexImage3D; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC __glewCompressedTexSubImage1D; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC __glewCompressedTexSubImage2D; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC __glewCompressedTexSubImage3D; GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEPROC __glewGetCompressedTexImage; GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd; GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf; GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd; GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv; GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEPROC __glewSampleCoverage; GLEW_FUN_EXPORT PFNGLBLENDCOLORPROC __glewBlendColor; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONPROC __glewBlendEquation; GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEPROC __glewBlendFuncSeparate; GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERPROC __glewFogCoordPointer; GLEW_FUN_EXPORT PFNGLFOGCOORDDPROC __glewFogCoordd; GLEW_FUN_EXPORT PFNGLFOGCOORDDVPROC __glewFogCoorddv; GLEW_FUN_EXPORT PFNGLFOGCOORDFPROC __glewFogCoordf; GLEW_FUN_EXPORT PFNGLFOGCOORDFVPROC __glewFogCoordfv; GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSPROC __glewMultiDrawArrays; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSPROC __glewMultiDrawElements; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFPROC __glewPointParameterf; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVPROC __glewPointParameterfv; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIPROC __glewPointParameteri; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVPROC __glewPointParameteriv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BPROC __glewSecondaryColor3b; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVPROC __glewSecondaryColor3bv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DPROC __glewSecondaryColor3d; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVPROC __glewSecondaryColor3dv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FPROC __glewSecondaryColor3f; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVPROC __glewSecondaryColor3fv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IPROC __glewSecondaryColor3i; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVPROC __glewSecondaryColor3iv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SPROC __glewSecondaryColor3s; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVPROC __glewSecondaryColor3sv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBPROC __glewSecondaryColor3ub; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVPROC __glewSecondaryColor3ubv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIPROC __glewSecondaryColor3ui; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVPROC __glewSecondaryColor3uiv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USPROC __glewSecondaryColor3us; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVPROC __glewSecondaryColor3usv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERPROC __glewSecondaryColorPointer; GLEW_FUN_EXPORT PFNGLWINDOWPOS2DPROC __glewWindowPos2d; GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVPROC __glewWindowPos2dv; GLEW_FUN_EXPORT PFNGLWINDOWPOS2FPROC __glewWindowPos2f; GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVPROC __glewWindowPos2fv; GLEW_FUN_EXPORT PFNGLWINDOWPOS2IPROC __glewWindowPos2i; GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVPROC __glewWindowPos2iv; GLEW_FUN_EXPORT PFNGLWINDOWPOS2SPROC __glewWindowPos2s; GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVPROC __glewWindowPos2sv; GLEW_FUN_EXPORT PFNGLWINDOWPOS3DPROC __glewWindowPos3d; GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVPROC __glewWindowPos3dv; GLEW_FUN_EXPORT PFNGLWINDOWPOS3FPROC __glewWindowPos3f; GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVPROC __glewWindowPos3fv; GLEW_FUN_EXPORT PFNGLWINDOWPOS3IPROC __glewWindowPos3i; GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVPROC __glewWindowPos3iv; GLEW_FUN_EXPORT PFNGLWINDOWPOS3SPROC __glewWindowPos3s; GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVPROC __glewWindowPos3sv; GLEW_FUN_EXPORT PFNGLBEGINQUERYPROC __glewBeginQuery; GLEW_FUN_EXPORT PFNGLBINDBUFFERPROC __glewBindBuffer; GLEW_FUN_EXPORT PFNGLBUFFERDATAPROC __glewBufferData; GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAPROC __glewBufferSubData; GLEW_FUN_EXPORT PFNGLDELETEBUFFERSPROC __glewDeleteBuffers; GLEW_FUN_EXPORT PFNGLDELETEQUERIESPROC __glewDeleteQueries; GLEW_FUN_EXPORT PFNGLENDQUERYPROC __glewEndQuery; GLEW_FUN_EXPORT PFNGLGENBUFFERSPROC __glewGenBuffers; GLEW_FUN_EXPORT PFNGLGENQUERIESPROC __glewGenQueries; GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVPROC __glewGetBufferParameteriv; GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVPROC __glewGetBufferPointerv; GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAPROC __glewGetBufferSubData; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVPROC __glewGetQueryObjectiv; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVPROC __glewGetQueryObjectuiv; GLEW_FUN_EXPORT PFNGLGETQUERYIVPROC __glewGetQueryiv; GLEW_FUN_EXPORT PFNGLISBUFFERPROC __glewIsBuffer; GLEW_FUN_EXPORT PFNGLISQUERYPROC __glewIsQuery; GLEW_FUN_EXPORT PFNGLMAPBUFFERPROC __glewMapBuffer; GLEW_FUN_EXPORT PFNGLUNMAPBUFFERPROC __glewUnmapBuffer; GLEW_FUN_EXPORT PFNGLATTACHSHADERPROC __glewAttachShader; GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONPROC __glewBindAttribLocation; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEPROC __glewBlendEquationSeparate; GLEW_FUN_EXPORT PFNGLCOMPILESHADERPROC __glewCompileShader; GLEW_FUN_EXPORT PFNGLCREATEPROGRAMPROC __glewCreateProgram; GLEW_FUN_EXPORT PFNGLCREATESHADERPROC __glewCreateShader; GLEW_FUN_EXPORT PFNGLDELETEPROGRAMPROC __glewDeleteProgram; GLEW_FUN_EXPORT PFNGLDELETESHADERPROC __glewDeleteShader; GLEW_FUN_EXPORT PFNGLDETACHSHADERPROC __glewDetachShader; GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYPROC __glewDisableVertexAttribArray; GLEW_FUN_EXPORT PFNGLDRAWBUFFERSPROC __glewDrawBuffers; GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYPROC __glewEnableVertexAttribArray; GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBPROC __glewGetActiveAttrib; GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMPROC __glewGetActiveUniform; GLEW_FUN_EXPORT PFNGLGETATTACHEDSHADERSPROC __glewGetAttachedShaders; GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONPROC __glewGetAttribLocation; GLEW_FUN_EXPORT PFNGLGETPROGRAMINFOLOGPROC __glewGetProgramInfoLog; GLEW_FUN_EXPORT PFNGLGETPROGRAMIVPROC __glewGetProgramiv; GLEW_FUN_EXPORT PFNGLGETSHADERINFOLOGPROC __glewGetShaderInfoLog; GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEPROC __glewGetShaderSource; GLEW_FUN_EXPORT PFNGLGETSHADERIVPROC __glewGetShaderiv; GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONPROC __glewGetUniformLocation; GLEW_FUN_EXPORT PFNGLGETUNIFORMFVPROC __glewGetUniformfv; GLEW_FUN_EXPORT PFNGLGETUNIFORMIVPROC __glewGetUniformiv; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVPROC __glewGetVertexAttribPointerv; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVPROC __glewGetVertexAttribdv; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVPROC __glewGetVertexAttribfv; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVPROC __glewGetVertexAttribiv; GLEW_FUN_EXPORT PFNGLISPROGRAMPROC __glewIsProgram; GLEW_FUN_EXPORT PFNGLISSHADERPROC __glewIsShader; GLEW_FUN_EXPORT PFNGLLINKPROGRAMPROC __glewLinkProgram; GLEW_FUN_EXPORT PFNGLSHADERSOURCEPROC __glewShaderSource; GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEPROC __glewStencilFuncSeparate; GLEW_FUN_EXPORT PFNGLSTENCILMASKSEPARATEPROC __glewStencilMaskSeparate; GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEPROC __glewStencilOpSeparate; GLEW_FUN_EXPORT PFNGLUNIFORM1FPROC __glewUniform1f; GLEW_FUN_EXPORT PFNGLUNIFORM1FVPROC __glewUniform1fv; GLEW_FUN_EXPORT PFNGLUNIFORM1IPROC __glewUniform1i; GLEW_FUN_EXPORT PFNGLUNIFORM1IVPROC __glewUniform1iv; GLEW_FUN_EXPORT PFNGLUNIFORM2FPROC __glewUniform2f; GLEW_FUN_EXPORT PFNGLUNIFORM2FVPROC __glewUniform2fv; GLEW_FUN_EXPORT PFNGLUNIFORM2IPROC __glewUniform2i; GLEW_FUN_EXPORT PFNGLUNIFORM2IVPROC __glewUniform2iv; GLEW_FUN_EXPORT PFNGLUNIFORM3FPROC __glewUniform3f; GLEW_FUN_EXPORT PFNGLUNIFORM3FVPROC __glewUniform3fv; GLEW_FUN_EXPORT PFNGLUNIFORM3IPROC __glewUniform3i; GLEW_FUN_EXPORT PFNGLUNIFORM3IVPROC __glewUniform3iv; GLEW_FUN_EXPORT PFNGLUNIFORM4FPROC __glewUniform4f; GLEW_FUN_EXPORT PFNGLUNIFORM4FVPROC __glewUniform4fv; GLEW_FUN_EXPORT PFNGLUNIFORM4IPROC __glewUniform4i; GLEW_FUN_EXPORT PFNGLUNIFORM4IVPROC __glewUniform4iv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVPROC __glewUniformMatrix2fv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVPROC __glewUniformMatrix3fv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVPROC __glewUniformMatrix4fv; GLEW_FUN_EXPORT PFNGLUSEPROGRAMPROC __glewUseProgram; GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPROC __glewValidateProgram; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DPROC __glewVertexAttrib1d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVPROC __glewVertexAttrib1dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FPROC __glewVertexAttrib1f; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVPROC __glewVertexAttrib1fv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SPROC __glewVertexAttrib1s; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVPROC __glewVertexAttrib1sv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DPROC __glewVertexAttrib2d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVPROC __glewVertexAttrib2dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FPROC __glewVertexAttrib2f; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVPROC __glewVertexAttrib2fv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SPROC __glewVertexAttrib2s; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVPROC __glewVertexAttrib2sv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DPROC __glewVertexAttrib3d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVPROC __glewVertexAttrib3dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FPROC __glewVertexAttrib3f; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVPROC __glewVertexAttrib3fv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SPROC __glewVertexAttrib3s; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVPROC __glewVertexAttrib3sv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVPROC __glewVertexAttrib4Nbv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVPROC __glewVertexAttrib4Niv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVPROC __glewVertexAttrib4Nsv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBPROC __glewVertexAttrib4Nub; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVPROC __glewVertexAttrib4Nubv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVPROC __glewVertexAttrib4Nuiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVPROC __glewVertexAttrib4Nusv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVPROC __glewVertexAttrib4bv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DPROC __glewVertexAttrib4d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVPROC __glewVertexAttrib4dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FPROC __glewVertexAttrib4f; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVPROC __glewVertexAttrib4fv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVPROC __glewVertexAttrib4iv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SPROC __glewVertexAttrib4s; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVPROC __glewVertexAttrib4sv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVPROC __glewVertexAttrib4ubv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVPROC __glewVertexAttrib4uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVPROC __glewVertexAttrib4usv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERPROC __glewVertexAttribPointer; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3FVPROC __glewUniformMatrix2x3fv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4FVPROC __glewUniformMatrix2x4fv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2FVPROC __glewUniformMatrix3x2fv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4FVPROC __glewUniformMatrix3x4fv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2FVPROC __glewUniformMatrix4x2fv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv; GLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERPROC __glewBeginConditionalRender; GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKPROC __glewBeginTransformFeedback; GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONPROC __glewBindFragDataLocation; GLEW_FUN_EXPORT PFNGLCLAMPCOLORPROC __glewClampColor; GLEW_FUN_EXPORT PFNGLCLEARBUFFERFIPROC __glewClearBufferfi; GLEW_FUN_EXPORT PFNGLCLEARBUFFERFVPROC __glewClearBufferfv; GLEW_FUN_EXPORT PFNGLCLEARBUFFERIVPROC __glewClearBufferiv; GLEW_FUN_EXPORT PFNGLCLEARBUFFERUIVPROC __glewClearBufferuiv; GLEW_FUN_EXPORT PFNGLCOLORMASKIPROC __glewColorMaski; GLEW_FUN_EXPORT PFNGLDISABLEIPROC __glewDisablei; GLEW_FUN_EXPORT PFNGLENABLEIPROC __glewEnablei; GLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERPROC __glewEndConditionalRender; GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKPROC __glewEndTransformFeedback; GLEW_FUN_EXPORT PFNGLGETBOOLEANI_VPROC __glewGetBooleani_v; GLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONPROC __glewGetFragDataLocation; GLEW_FUN_EXPORT PFNGLGETSTRINGIPROC __glewGetStringi; GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVPROC __glewGetTexParameterIiv; GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVPROC __glewGetTexParameterIuiv; GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGPROC __glewGetTransformFeedbackVarying; GLEW_FUN_EXPORT PFNGLGETUNIFORMUIVPROC __glewGetUniformuiv; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVPROC __glewGetVertexAttribIiv; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVPROC __glewGetVertexAttribIuiv; GLEW_FUN_EXPORT PFNGLISENABLEDIPROC __glewIsEnabledi; GLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVPROC __glewTexParameterIiv; GLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVPROC __glewTexParameterIuiv; GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSPROC __glewTransformFeedbackVaryings; GLEW_FUN_EXPORT PFNGLUNIFORM1UIPROC __glewUniform1ui; GLEW_FUN_EXPORT PFNGLUNIFORM1UIVPROC __glewUniform1uiv; GLEW_FUN_EXPORT PFNGLUNIFORM2UIPROC __glewUniform2ui; GLEW_FUN_EXPORT PFNGLUNIFORM2UIVPROC __glewUniform2uiv; GLEW_FUN_EXPORT PFNGLUNIFORM3UIPROC __glewUniform3ui; GLEW_FUN_EXPORT PFNGLUNIFORM3UIVPROC __glewUniform3uiv; GLEW_FUN_EXPORT PFNGLUNIFORM4UIPROC __glewUniform4ui; GLEW_FUN_EXPORT PFNGLUNIFORM4UIVPROC __glewUniform4uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IPROC __glewVertexAttribI1i; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVPROC __glewVertexAttribI1iv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIPROC __glewVertexAttribI1ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVPROC __glewVertexAttribI1uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IPROC __glewVertexAttribI2i; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVPROC __glewVertexAttribI2iv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIPROC __glewVertexAttribI2ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVPROC __glewVertexAttribI2uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IPROC __glewVertexAttribI3i; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVPROC __glewVertexAttribI3iv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIPROC __glewVertexAttribI3ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVPROC __glewVertexAttribI3uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVPROC __glewVertexAttribI4bv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IPROC __glewVertexAttribI4i; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVPROC __glewVertexAttribI4iv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVPROC __glewVertexAttribI4sv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVPROC __glewVertexAttribI4ubv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIPROC __glewVertexAttribI4ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVPROC __glewVertexAttribI4uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVPROC __glewVertexAttribI4usv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTERPROC __glewVertexAttribIPointer; GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDPROC __glewDrawArraysInstanced; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDPROC __glewDrawElementsInstanced; GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXPROC __glewPrimitiveRestartIndex; GLEW_FUN_EXPORT PFNGLTEXBUFFERPROC __glewTexBuffer; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREPROC __glewFramebufferTexture; GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERI64VPROC __glewGetBufferParameteri64v; GLEW_FUN_EXPORT PFNGLGETINTEGER64I_VPROC __glewGetInteger64i_v; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORPROC __glewVertexAttribDivisor; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEIPROC __glewBlendEquationSeparatei; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONIPROC __glewBlendEquationi; GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEIPROC __glewBlendFuncSeparatei; GLEW_FUN_EXPORT PFNGLBLENDFUNCIPROC __glewBlendFunci; GLEW_FUN_EXPORT PFNGLMINSAMPLESHADINGPROC __glewMinSampleShading; GLEW_FUN_EXPORT PFNGLGETGRAPHICSRESETSTATUSPROC __glewGetGraphicsResetStatus; GLEW_FUN_EXPORT PFNGLGETNCOMPRESSEDTEXIMAGEPROC __glewGetnCompressedTexImage; GLEW_FUN_EXPORT PFNGLGETNTEXIMAGEPROC __glewGetnTexImage; GLEW_FUN_EXPORT PFNGLGETNUNIFORMDVPROC __glewGetnUniformdv; GLEW_FUN_EXPORT PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGECALLBACKAMDPROC __glewDebugMessageCallbackAMD; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGEENABLEAMDPROC __glewDebugMessageEnableAMD; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGEINSERTAMDPROC __glewDebugMessageInsertAMD; GLEW_FUN_EXPORT PFNGLGETDEBUGMESSAGELOGAMDPROC __glewGetDebugMessageLogAMD; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONINDEXEDAMDPROC __glewBlendEquationIndexedAMD; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC __glewBlendEquationSeparateIndexedAMD; GLEW_FUN_EXPORT PFNGLBLENDFUNCINDEXEDAMDPROC __glewBlendFuncIndexedAMD; GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC __glewBlendFuncSeparateIndexedAMD; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPARAMETERIAMDPROC __glewVertexAttribParameteriAMD; GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC __glewMultiDrawArraysIndirectAMD; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC __glewMultiDrawElementsIndirectAMD; GLEW_FUN_EXPORT PFNGLDELETENAMESAMDPROC __glewDeleteNamesAMD; GLEW_FUN_EXPORT PFNGLGENNAMESAMDPROC __glewGenNamesAMD; GLEW_FUN_EXPORT PFNGLISNAMEAMDPROC __glewIsNameAMD; GLEW_FUN_EXPORT PFNGLQUERYOBJECTPARAMETERUIAMDPROC __glewQueryObjectParameteruiAMD; GLEW_FUN_EXPORT PFNGLBEGINPERFMONITORAMDPROC __glewBeginPerfMonitorAMD; GLEW_FUN_EXPORT PFNGLDELETEPERFMONITORSAMDPROC __glewDeletePerfMonitorsAMD; GLEW_FUN_EXPORT PFNGLENDPERFMONITORAMDPROC __glewEndPerfMonitorAMD; GLEW_FUN_EXPORT PFNGLGENPERFMONITORSAMDPROC __glewGenPerfMonitorsAMD; GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERDATAAMDPROC __glewGetPerfMonitorCounterDataAMD; GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERINFOAMDPROC __glewGetPerfMonitorCounterInfoAMD; GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC __glewGetPerfMonitorCounterStringAMD; GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERSAMDPROC __glewGetPerfMonitorCountersAMD; GLEW_FUN_EXPORT PFNGLGETPERFMONITORGROUPSTRINGAMDPROC __glewGetPerfMonitorGroupStringAMD; GLEW_FUN_EXPORT PFNGLGETPERFMONITORGROUPSAMDPROC __glewGetPerfMonitorGroupsAMD; GLEW_FUN_EXPORT PFNGLSELECTPERFMONITORCOUNTERSAMDPROC __glewSelectPerfMonitorCountersAMD; GLEW_FUN_EXPORT PFNGLSETMULTISAMPLEFVAMDPROC __glewSetMultisamplefvAMD; GLEW_FUN_EXPORT PFNGLTEXSTORAGESPARSEAMDPROC __glewTexStorageSparseAMD; GLEW_FUN_EXPORT PFNGLTEXTURESTORAGESPARSEAMDPROC __glewTextureStorageSparseAMD; GLEW_FUN_EXPORT PFNGLSTENCILOPVALUEAMDPROC __glewStencilOpValueAMD; GLEW_FUN_EXPORT PFNGLTESSELLATIONFACTORAMDPROC __glewTessellationFactorAMD; GLEW_FUN_EXPORT PFNGLTESSELLATIONMODEAMDPROC __glewTessellationModeAMD; GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFERANGLEPROC __glewBlitFramebufferANGLE; GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC __glewRenderbufferStorageMultisampleANGLE; GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDANGLEPROC __glewDrawArraysInstancedANGLE; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDANGLEPROC __glewDrawElementsInstancedANGLE; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORANGLEPROC __glewVertexAttribDivisorANGLE; GLEW_FUN_EXPORT PFNGLBEGINQUERYANGLEPROC __glewBeginQueryANGLE; GLEW_FUN_EXPORT PFNGLDELETEQUERIESANGLEPROC __glewDeleteQueriesANGLE; GLEW_FUN_EXPORT PFNGLENDQUERYANGLEPROC __glewEndQueryANGLE; GLEW_FUN_EXPORT PFNGLGENQUERIESANGLEPROC __glewGenQueriesANGLE; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VANGLEPROC __glewGetQueryObjecti64vANGLE; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVANGLEPROC __glewGetQueryObjectivANGLE; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VANGLEPROC __glewGetQueryObjectui64vANGLE; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVANGLEPROC __glewGetQueryObjectuivANGLE; GLEW_FUN_EXPORT PFNGLGETQUERYIVANGLEPROC __glewGetQueryivANGLE; GLEW_FUN_EXPORT PFNGLISQUERYANGLEPROC __glewIsQueryANGLE; GLEW_FUN_EXPORT PFNGLQUERYCOUNTERANGLEPROC __glewQueryCounterANGLE; GLEW_FUN_EXPORT PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC __glewGetTranslatedShaderSourceANGLE; GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE; GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE; GLEW_FUN_EXPORT PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC __glewMultiDrawElementArrayAPPLE; GLEW_FUN_EXPORT PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC __glewMultiDrawRangeElementArrayAPPLE; GLEW_FUN_EXPORT PFNGLDELETEFENCESAPPLEPROC __glewDeleteFencesAPPLE; GLEW_FUN_EXPORT PFNGLFINISHFENCEAPPLEPROC __glewFinishFenceAPPLE; GLEW_FUN_EXPORT PFNGLFINISHOBJECTAPPLEPROC __glewFinishObjectAPPLE; GLEW_FUN_EXPORT PFNGLGENFENCESAPPLEPROC __glewGenFencesAPPLE; GLEW_FUN_EXPORT PFNGLISFENCEAPPLEPROC __glewIsFenceAPPLE; GLEW_FUN_EXPORT PFNGLSETFENCEAPPLEPROC __glewSetFenceAPPLE; GLEW_FUN_EXPORT PFNGLTESTFENCEAPPLEPROC __glewTestFenceAPPLE; GLEW_FUN_EXPORT PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE; GLEW_FUN_EXPORT PFNGLBUFFERPARAMETERIAPPLEPROC __glewBufferParameteriAPPLE; GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC __glewFlushMappedBufferRangeAPPLE; GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVAPPLEPROC __glewGetObjectParameterivAPPLE; GLEW_FUN_EXPORT PFNGLOBJECTPURGEABLEAPPLEPROC __glewObjectPurgeableAPPLE; GLEW_FUN_EXPORT PFNGLOBJECTUNPURGEABLEAPPLEPROC __glewObjectUnpurgeableAPPLE; GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE; GLEW_FUN_EXPORT PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE; GLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYAPPLEPROC __glewBindVertexArrayAPPLE; GLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSAPPLEPROC __glewDeleteVertexArraysAPPLE; GLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSAPPLEPROC __glewGenVertexArraysAPPLE; GLEW_FUN_EXPORT PFNGLISVERTEXARRAYAPPLEPROC __glewIsVertexArrayAPPLE; GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE; GLEW_FUN_EXPORT PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE; GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE; GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBAPPLEPROC __glewDisableVertexAttribAPPLE; GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBAPPLEPROC __glewEnableVertexAttribAPPLE; GLEW_FUN_EXPORT PFNGLISVERTEXATTRIBENABLEDAPPLEPROC __glewIsVertexAttribEnabledAPPLE; GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1DAPPLEPROC __glewMapVertexAttrib1dAPPLE; GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1FAPPLEPROC __glewMapVertexAttrib1fAPPLE; GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2DAPPLEPROC __glewMapVertexAttrib2dAPPLE; GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2FAPPLEPROC __glewMapVertexAttrib2fAPPLE; GLEW_FUN_EXPORT PFNGLCLEARDEPTHFPROC __glewClearDepthf; GLEW_FUN_EXPORT PFNGLDEPTHRANGEFPROC __glewDepthRangef; GLEW_FUN_EXPORT PFNGLGETSHADERPRECISIONFORMATPROC __glewGetShaderPrecisionFormat; GLEW_FUN_EXPORT PFNGLRELEASESHADERCOMPILERPROC __glewReleaseShaderCompiler; GLEW_FUN_EXPORT PFNGLSHADERBINARYPROC __glewShaderBinary; GLEW_FUN_EXPORT PFNGLMEMORYBARRIERBYREGIONPROC __glewMemoryBarrierByRegion; GLEW_FUN_EXPORT PFNGLPRIMITIVEBOUNDINGBOXARBPROC __glewPrimitiveBoundingBoxARB; GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC __glewDrawArraysInstancedBaseInstance; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC __glewDrawElementsInstancedBaseInstance; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC __glewDrawElementsInstancedBaseVertexBaseInstance; GLEW_FUN_EXPORT PFNGLGETIMAGEHANDLEARBPROC __glewGetImageHandleARB; GLEW_FUN_EXPORT PFNGLGETTEXTUREHANDLEARBPROC __glewGetTextureHandleARB; GLEW_FUN_EXPORT PFNGLGETTEXTURESAMPLERHANDLEARBPROC __glewGetTextureSamplerHandleARB; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLUI64VARBPROC __glewGetVertexAttribLui64vARB; GLEW_FUN_EXPORT PFNGLISIMAGEHANDLERESIDENTARBPROC __glewIsImageHandleResidentARB; GLEW_FUN_EXPORT PFNGLISTEXTUREHANDLERESIDENTARBPROC __glewIsTextureHandleResidentARB; GLEW_FUN_EXPORT PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC __glewMakeImageHandleNonResidentARB; GLEW_FUN_EXPORT PFNGLMAKEIMAGEHANDLERESIDENTARBPROC __glewMakeImageHandleResidentARB; GLEW_FUN_EXPORT PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC __glewMakeTextureHandleNonResidentARB; GLEW_FUN_EXPORT PFNGLMAKETEXTUREHANDLERESIDENTARBPROC __glewMakeTextureHandleResidentARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC __glewProgramUniformHandleui64ARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC __glewProgramUniformHandleui64vARB; GLEW_FUN_EXPORT PFNGLUNIFORMHANDLEUI64ARBPROC __glewUniformHandleui64ARB; GLEW_FUN_EXPORT PFNGLUNIFORMHANDLEUI64VARBPROC __glewUniformHandleui64vARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64ARBPROC __glewVertexAttribL1ui64ARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64VARBPROC __glewVertexAttribL1ui64vARB; GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONINDEXEDPROC __glewBindFragDataLocationIndexed; GLEW_FUN_EXPORT PFNGLGETFRAGDATAINDEXPROC __glewGetFragDataIndex; GLEW_FUN_EXPORT PFNGLBUFFERSTORAGEPROC __glewBufferStorage; GLEW_FUN_EXPORT PFNGLNAMEDBUFFERSTORAGEEXTPROC __glewNamedBufferStorageEXT; GLEW_FUN_EXPORT PFNGLCREATESYNCFROMCLEVENTARBPROC __glewCreateSyncFromCLeventARB; GLEW_FUN_EXPORT PFNGLCLEARBUFFERDATAPROC __glewClearBufferData; GLEW_FUN_EXPORT PFNGLCLEARBUFFERSUBDATAPROC __glewClearBufferSubData; GLEW_FUN_EXPORT PFNGLCLEARNAMEDBUFFERDATAEXTPROC __glewClearNamedBufferDataEXT; GLEW_FUN_EXPORT PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC __glewClearNamedBufferSubDataEXT; GLEW_FUN_EXPORT PFNGLCLEARTEXIMAGEPROC __glewClearTexImage; GLEW_FUN_EXPORT PFNGLCLEARTEXSUBIMAGEPROC __glewClearTexSubImage; GLEW_FUN_EXPORT PFNGLCLIPCONTROLPROC __glewClipControl; GLEW_FUN_EXPORT PFNGLCLAMPCOLORARBPROC __glewClampColorARB; GLEW_FUN_EXPORT PFNGLDISPATCHCOMPUTEPROC __glewDispatchCompute; GLEW_FUN_EXPORT PFNGLDISPATCHCOMPUTEINDIRECTPROC __glewDispatchComputeIndirect; GLEW_FUN_EXPORT PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC __glewDispatchComputeGroupSizeARB; GLEW_FUN_EXPORT PFNGLCOPYBUFFERSUBDATAPROC __glewCopyBufferSubData; GLEW_FUN_EXPORT PFNGLCOPYIMAGESUBDATAPROC __glewCopyImageSubData; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGECALLBACKARBPROC __glewDebugMessageCallbackARB; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGECONTROLARBPROC __glewDebugMessageControlARB; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGEINSERTARBPROC __glewDebugMessageInsertARB; GLEW_FUN_EXPORT PFNGLGETDEBUGMESSAGELOGARBPROC __glewGetDebugMessageLogARB; GLEW_FUN_EXPORT PFNGLBINDTEXTUREUNITPROC __glewBindTextureUnit; GLEW_FUN_EXPORT PFNGLBLITNAMEDFRAMEBUFFERPROC __glewBlitNamedFramebuffer; GLEW_FUN_EXPORT PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC __glewCheckNamedFramebufferStatus; GLEW_FUN_EXPORT PFNGLCLEARNAMEDBUFFERDATAPROC __glewClearNamedBufferData; GLEW_FUN_EXPORT PFNGLCLEARNAMEDBUFFERSUBDATAPROC __glewClearNamedBufferSubData; GLEW_FUN_EXPORT PFNGLCLEARNAMEDFRAMEBUFFERFIPROC __glewClearNamedFramebufferfi; GLEW_FUN_EXPORT PFNGLCLEARNAMEDFRAMEBUFFERFVPROC __glewClearNamedFramebufferfv; GLEW_FUN_EXPORT PFNGLCLEARNAMEDFRAMEBUFFERIVPROC __glewClearNamedFramebufferiv; GLEW_FUN_EXPORT PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC __glewClearNamedFramebufferuiv; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC __glewCompressedTextureSubImage1D; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC __glewCompressedTextureSubImage2D; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC __glewCompressedTextureSubImage3D; GLEW_FUN_EXPORT PFNGLCOPYNAMEDBUFFERSUBDATAPROC __glewCopyNamedBufferSubData; GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE1DPROC __glewCopyTextureSubImage1D; GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE2DPROC __glewCopyTextureSubImage2D; GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE3DPROC __glewCopyTextureSubImage3D; GLEW_FUN_EXPORT PFNGLCREATEBUFFERSPROC __glewCreateBuffers; GLEW_FUN_EXPORT PFNGLCREATEFRAMEBUFFERSPROC __glewCreateFramebuffers; GLEW_FUN_EXPORT PFNGLCREATEPROGRAMPIPELINESPROC __glewCreateProgramPipelines; GLEW_FUN_EXPORT PFNGLCREATEQUERIESPROC __glewCreateQueries; GLEW_FUN_EXPORT PFNGLCREATERENDERBUFFERSPROC __glewCreateRenderbuffers; GLEW_FUN_EXPORT PFNGLCREATESAMPLERSPROC __glewCreateSamplers; GLEW_FUN_EXPORT PFNGLCREATETEXTURESPROC __glewCreateTextures; GLEW_FUN_EXPORT PFNGLCREATETRANSFORMFEEDBACKSPROC __glewCreateTransformFeedbacks; GLEW_FUN_EXPORT PFNGLCREATEVERTEXARRAYSPROC __glewCreateVertexArrays; GLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYATTRIBPROC __glewDisableVertexArrayAttrib; GLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYATTRIBPROC __glewEnableVertexArrayAttrib; GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC __glewFlushMappedNamedBufferRange; GLEW_FUN_EXPORT PFNGLGENERATETEXTUREMIPMAPPROC __glewGenerateTextureMipmap; GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC __glewGetCompressedTextureImage; GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERI64VPROC __glewGetNamedBufferParameteri64v; GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERIVPROC __glewGetNamedBufferParameteriv; GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPOINTERVPROC __glewGetNamedBufferPointerv; GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERSUBDATAPROC __glewGetNamedBufferSubData; GLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetNamedFramebufferAttachmentParameteriv; GLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC __glewGetNamedFramebufferParameteriv; GLEW_FUN_EXPORT PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC __glewGetNamedRenderbufferParameteriv; GLEW_FUN_EXPORT PFNGLGETQUERYBUFFEROBJECTI64VPROC __glewGetQueryBufferObjecti64v; GLEW_FUN_EXPORT PFNGLGETQUERYBUFFEROBJECTIVPROC __glewGetQueryBufferObjectiv; GLEW_FUN_EXPORT PFNGLGETQUERYBUFFEROBJECTUI64VPROC __glewGetQueryBufferObjectui64v; GLEW_FUN_EXPORT PFNGLGETQUERYBUFFEROBJECTUIVPROC __glewGetQueryBufferObjectuiv; GLEW_FUN_EXPORT PFNGLGETTEXTUREIMAGEPROC __glewGetTextureImage; GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERFVPROC __glewGetTextureLevelParameterfv; GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERIVPROC __glewGetTextureLevelParameteriv; GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIIVPROC __glewGetTextureParameterIiv; GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIUIVPROC __glewGetTextureParameterIuiv; GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERFVPROC __glewGetTextureParameterfv; GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIVPROC __glewGetTextureParameteriv; GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKI64_VPROC __glewGetTransformFeedbacki64_v; GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKI_VPROC __glewGetTransformFeedbacki_v; GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKIVPROC __glewGetTransformFeedbackiv; GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINDEXED64IVPROC __glewGetVertexArrayIndexed64iv; GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINDEXEDIVPROC __glewGetVertexArrayIndexediv; GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYIVPROC __glewGetVertexArrayiv; GLEW_FUN_EXPORT PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC __glewInvalidateNamedFramebufferData; GLEW_FUN_EXPORT PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC __glewInvalidateNamedFramebufferSubData; GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFERPROC __glewMapNamedBuffer; GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFERRANGEPROC __glewMapNamedBufferRange; GLEW_FUN_EXPORT PFNGLNAMEDBUFFERDATAPROC __glewNamedBufferData; GLEW_FUN_EXPORT PFNGLNAMEDBUFFERSTORAGEPROC __glewNamedBufferStorage; GLEW_FUN_EXPORT PFNGLNAMEDBUFFERSUBDATAPROC __glewNamedBufferSubData; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC __glewNamedFramebufferDrawBuffer; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC __glewNamedFramebufferDrawBuffers; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC __glewNamedFramebufferParameteri; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC __glewNamedFramebufferReadBuffer; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC __glewNamedFramebufferRenderbuffer; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREPROC __glewNamedFramebufferTexture; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC __glewNamedFramebufferTextureLayer; GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEPROC __glewNamedRenderbufferStorage; GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewNamedRenderbufferStorageMultisample; GLEW_FUN_EXPORT PFNGLTEXTUREBUFFERPROC __glewTextureBuffer; GLEW_FUN_EXPORT PFNGLTEXTUREBUFFERRANGEPROC __glewTextureBufferRange; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIIVPROC __glewTextureParameterIiv; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIUIVPROC __glewTextureParameterIuiv; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFPROC __glewTextureParameterf; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFVPROC __glewTextureParameterfv; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIPROC __glewTextureParameteri; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIVPROC __glewTextureParameteriv; GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE1DPROC __glewTextureStorage1D; GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DPROC __glewTextureStorage2D; GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC __glewTextureStorage2DMultisample; GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DPROC __glewTextureStorage3D; GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC __glewTextureStorage3DMultisample; GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE1DPROC __glewTextureSubImage1D; GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE2DPROC __glewTextureSubImage2D; GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE3DPROC __glewTextureSubImage3D; GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC __glewTransformFeedbackBufferBase; GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC __glewTransformFeedbackBufferRange; GLEW_FUN_EXPORT PFNGLUNMAPNAMEDBUFFERPROC __glewUnmapNamedBuffer; GLEW_FUN_EXPORT PFNGLVERTEXARRAYATTRIBBINDINGPROC __glewVertexArrayAttribBinding; GLEW_FUN_EXPORT PFNGLVERTEXARRAYATTRIBFORMATPROC __glewVertexArrayAttribFormat; GLEW_FUN_EXPORT PFNGLVERTEXARRAYATTRIBIFORMATPROC __glewVertexArrayAttribIFormat; GLEW_FUN_EXPORT PFNGLVERTEXARRAYATTRIBLFORMATPROC __glewVertexArrayAttribLFormat; GLEW_FUN_EXPORT PFNGLVERTEXARRAYBINDINGDIVISORPROC __glewVertexArrayBindingDivisor; GLEW_FUN_EXPORT PFNGLVERTEXARRAYELEMENTBUFFERPROC __glewVertexArrayElementBuffer; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXBUFFERPROC __glewVertexArrayVertexBuffer; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXBUFFERSPROC __glewVertexArrayVertexBuffers; GLEW_FUN_EXPORT PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEIARBPROC __glewBlendEquationSeparateiARB; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONIARBPROC __glewBlendEquationiARB; GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEIARBPROC __glewBlendFuncSeparateiARB; GLEW_FUN_EXPORT PFNGLBLENDFUNCIARBPROC __glewBlendFunciARB; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSBASEVERTEXPROC __glewDrawElementsBaseVertex; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC __glewDrawElementsInstancedBaseVertex; GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC __glewDrawRangeElementsBaseVertex; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC __glewMultiDrawElementsBaseVertex; GLEW_FUN_EXPORT PFNGLDRAWARRAYSINDIRECTPROC __glewDrawArraysIndirect; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINDIRECTPROC __glewDrawElementsIndirect; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERPARAMETERIPROC __glewFramebufferParameteri; GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERPARAMETERIVPROC __glewGetFramebufferParameteriv; GLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC __glewGetNamedFramebufferParameterivEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC __glewNamedFramebufferParameteriEXT; GLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFERPROC __glewBindFramebuffer; GLEW_FUN_EXPORT PFNGLBINDRENDERBUFFERPROC __glewBindRenderbuffer; GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFERPROC __glewBlitFramebuffer; GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus; GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers; GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer; GLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSPROC __glewGenFramebuffers; GLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSPROC __glewGenRenderbuffers; GLEW_FUN_EXPORT PFNGLGENERATEMIPMAPPROC __glewGenerateMipmap; GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetFramebufferAttachmentParameteriv; GLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVPROC __glewGetRenderbufferParameteriv; GLEW_FUN_EXPORT PFNGLISFRAMEBUFFERPROC __glewIsFramebuffer; GLEW_FUN_EXPORT PFNGLISRENDERBUFFERPROC __glewIsRenderbuffer; GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEPROC __glewRenderbufferStorage; GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewRenderbufferStorageMultisample; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREARBPROC __glewFramebufferTextureARB; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEARBPROC __glewFramebufferTextureFaceARB; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERARBPROC __glewFramebufferTextureLayerARB; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIARBPROC __glewProgramParameteriARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMBINARYPROC __glewGetProgramBinary; GLEW_FUN_EXPORT PFNGLPROGRAMBINARYPROC __glewProgramBinary; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIPROC __glewProgramParameteri; GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC __glewGetCompressedTextureSubImage; GLEW_FUN_EXPORT PFNGLGETTEXTURESUBIMAGEPROC __glewGetTextureSubImage; GLEW_FUN_EXPORT PFNGLGETUNIFORMDVPROC __glewGetUniformdv; GLEW_FUN_EXPORT PFNGLUNIFORM1DPROC __glewUniform1d; GLEW_FUN_EXPORT PFNGLUNIFORM1DVPROC __glewUniform1dv; GLEW_FUN_EXPORT PFNGLUNIFORM2DPROC __glewUniform2d; GLEW_FUN_EXPORT PFNGLUNIFORM2DVPROC __glewUniform2dv; GLEW_FUN_EXPORT PFNGLUNIFORM3DPROC __glewUniform3d; GLEW_FUN_EXPORT PFNGLUNIFORM3DVPROC __glewUniform3dv; GLEW_FUN_EXPORT PFNGLUNIFORM4DPROC __glewUniform4d; GLEW_FUN_EXPORT PFNGLUNIFORM4DVPROC __glewUniform4dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2DVPROC __glewUniformMatrix2dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3DVPROC __glewUniformMatrix2x3dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4DVPROC __glewUniformMatrix2x4dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3DVPROC __glewUniformMatrix3dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2DVPROC __glewUniformMatrix3x2dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4DVPROC __glewUniformMatrix3x4dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4DVPROC __glewUniformMatrix4dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2DVPROC __glewUniformMatrix4x2dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3DVPROC __glewUniformMatrix4x3dv; GLEW_FUN_EXPORT PFNGLGETUNIFORMI64VARBPROC __glewGetUniformi64vARB; GLEW_FUN_EXPORT PFNGLGETUNIFORMUI64VARBPROC __glewGetUniformui64vARB; GLEW_FUN_EXPORT PFNGLGETNUNIFORMI64VARBPROC __glewGetnUniformi64vARB; GLEW_FUN_EXPORT PFNGLGETNUNIFORMUI64VARBPROC __glewGetnUniformui64vARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64ARBPROC __glewProgramUniform1i64ARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64VARBPROC __glewProgramUniform1i64vARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64ARBPROC __glewProgramUniform1ui64ARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64VARBPROC __glewProgramUniform1ui64vARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64ARBPROC __glewProgramUniform2i64ARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64VARBPROC __glewProgramUniform2i64vARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64ARBPROC __glewProgramUniform2ui64ARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64VARBPROC __glewProgramUniform2ui64vARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64ARBPROC __glewProgramUniform3i64ARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64VARBPROC __glewProgramUniform3i64vARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64ARBPROC __glewProgramUniform3ui64ARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64VARBPROC __glewProgramUniform3ui64vARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64ARBPROC __glewProgramUniform4i64ARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64VARBPROC __glewProgramUniform4i64vARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64ARBPROC __glewProgramUniform4ui64ARB; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64VARBPROC __glewProgramUniform4ui64vARB; GLEW_FUN_EXPORT PFNGLUNIFORM1I64ARBPROC __glewUniform1i64ARB; GLEW_FUN_EXPORT PFNGLUNIFORM1I64VARBPROC __glewUniform1i64vARB; GLEW_FUN_EXPORT PFNGLUNIFORM1UI64ARBPROC __glewUniform1ui64ARB; GLEW_FUN_EXPORT PFNGLUNIFORM1UI64VARBPROC __glewUniform1ui64vARB; GLEW_FUN_EXPORT PFNGLUNIFORM2I64ARBPROC __glewUniform2i64ARB; GLEW_FUN_EXPORT PFNGLUNIFORM2I64VARBPROC __glewUniform2i64vARB; GLEW_FUN_EXPORT PFNGLUNIFORM2UI64ARBPROC __glewUniform2ui64ARB; GLEW_FUN_EXPORT PFNGLUNIFORM2UI64VARBPROC __glewUniform2ui64vARB; GLEW_FUN_EXPORT PFNGLUNIFORM3I64ARBPROC __glewUniform3i64ARB; GLEW_FUN_EXPORT PFNGLUNIFORM3I64VARBPROC __glewUniform3i64vARB; GLEW_FUN_EXPORT PFNGLUNIFORM3UI64ARBPROC __glewUniform3ui64ARB; GLEW_FUN_EXPORT PFNGLUNIFORM3UI64VARBPROC __glewUniform3ui64vARB; GLEW_FUN_EXPORT PFNGLUNIFORM4I64ARBPROC __glewUniform4i64ARB; GLEW_FUN_EXPORT PFNGLUNIFORM4I64VARBPROC __glewUniform4i64vARB; GLEW_FUN_EXPORT PFNGLUNIFORM4UI64ARBPROC __glewUniform4ui64ARB; GLEW_FUN_EXPORT PFNGLUNIFORM4UI64VARBPROC __glewUniform4ui64vARB; GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEPROC __glewColorSubTable; GLEW_FUN_EXPORT PFNGLCOLORTABLEPROC __glewColorTable; GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv; GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv; GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D; GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv; GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable; GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLEPROC __glewCopyColorTable; GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D; GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPROC __glewGetColorTable; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv; GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter; GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv; GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv; GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPROC __glewGetHistogram; GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv; GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv; GLEW_FUN_EXPORT PFNGLGETMINMAXPROC __glewGetMinmax; GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv; GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv; GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter; GLEW_FUN_EXPORT PFNGLHISTOGRAMPROC __glewHistogram; GLEW_FUN_EXPORT PFNGLMINMAXPROC __glewMinmax; GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMPROC __glewResetHistogram; GLEW_FUN_EXPORT PFNGLRESETMINMAXPROC __glewResetMinmax; GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D; GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC __glewMultiDrawArraysIndirectCountARB; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC __glewMultiDrawElementsIndirectCountARB; GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORARBPROC __glewVertexAttribDivisorARB; GLEW_FUN_EXPORT PFNGLGETINTERNALFORMATIVPROC __glewGetInternalformativ; GLEW_FUN_EXPORT PFNGLGETINTERNALFORMATI64VPROC __glewGetInternalformati64v; GLEW_FUN_EXPORT PFNGLINVALIDATEBUFFERDATAPROC __glewInvalidateBufferData; GLEW_FUN_EXPORT PFNGLINVALIDATEBUFFERSUBDATAPROC __glewInvalidateBufferSubData; GLEW_FUN_EXPORT PFNGLINVALIDATEFRAMEBUFFERPROC __glewInvalidateFramebuffer; GLEW_FUN_EXPORT PFNGLINVALIDATESUBFRAMEBUFFERPROC __glewInvalidateSubFramebuffer; GLEW_FUN_EXPORT PFNGLINVALIDATETEXIMAGEPROC __glewInvalidateTexImage; GLEW_FUN_EXPORT PFNGLINVALIDATETEXSUBIMAGEPROC __glewInvalidateTexSubImage; GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEPROC __glewFlushMappedBufferRange; GLEW_FUN_EXPORT PFNGLMAPBUFFERRANGEPROC __glewMapBufferRange; GLEW_FUN_EXPORT PFNGLCURRENTPALETTEMATRIXARBPROC __glewCurrentPaletteMatrixARB; GLEW_FUN_EXPORT PFNGLMATRIXINDEXPOINTERARBPROC __glewMatrixIndexPointerARB; GLEW_FUN_EXPORT PFNGLMATRIXINDEXUBVARBPROC __glewMatrixIndexubvARB; GLEW_FUN_EXPORT PFNGLMATRIXINDEXUIVARBPROC __glewMatrixIndexuivARB; GLEW_FUN_EXPORT PFNGLMATRIXINDEXUSVARBPROC __glewMatrixIndexusvARB; GLEW_FUN_EXPORT PFNGLBINDBUFFERSBASEPROC __glewBindBuffersBase; GLEW_FUN_EXPORT PFNGLBINDBUFFERSRANGEPROC __glewBindBuffersRange; GLEW_FUN_EXPORT PFNGLBINDIMAGETEXTURESPROC __glewBindImageTextures; GLEW_FUN_EXPORT PFNGLBINDSAMPLERSPROC __glewBindSamplers; GLEW_FUN_EXPORT PFNGLBINDTEXTURESPROC __glewBindTextures; GLEW_FUN_EXPORT PFNGLBINDVERTEXBUFFERSPROC __glewBindVertexBuffers; GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTPROC __glewMultiDrawArraysIndirect; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTPROC __glewMultiDrawElementsIndirect; GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEARBPROC __glewSampleCoverageARB; GLEW_FUN_EXPORT PFNGLACTIVETEXTUREARBPROC __glewActiveTextureARB; GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREARBPROC __glewClientActiveTextureARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DARBPROC __glewMultiTexCoord1dARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVARBPROC __glewMultiTexCoord1dvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FARBPROC __glewMultiTexCoord1fARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVARBPROC __glewMultiTexCoord1fvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IARBPROC __glewMultiTexCoord1iARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVARBPROC __glewMultiTexCoord1ivARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SARBPROC __glewMultiTexCoord1sARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVARBPROC __glewMultiTexCoord1svARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DARBPROC __glewMultiTexCoord2dARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVARBPROC __glewMultiTexCoord2dvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FARBPROC __glewMultiTexCoord2fARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVARBPROC __glewMultiTexCoord2fvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IARBPROC __glewMultiTexCoord2iARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVARBPROC __glewMultiTexCoord2ivARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SARBPROC __glewMultiTexCoord2sARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVARBPROC __glewMultiTexCoord2svARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DARBPROC __glewMultiTexCoord3dARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVARBPROC __glewMultiTexCoord3dvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FARBPROC __glewMultiTexCoord3fARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVARBPROC __glewMultiTexCoord3fvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IARBPROC __glewMultiTexCoord3iARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVARBPROC __glewMultiTexCoord3ivARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SARBPROC __glewMultiTexCoord3sARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVARBPROC __glewMultiTexCoord3svARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DARBPROC __glewMultiTexCoord4dARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVARBPROC __glewMultiTexCoord4dvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FARBPROC __glewMultiTexCoord4fARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVARBPROC __glewMultiTexCoord4fvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IARBPROC __glewMultiTexCoord4iARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVARBPROC __glewMultiTexCoord4ivARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SARBPROC __glewMultiTexCoord4sARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVARBPROC __glewMultiTexCoord4svARB; GLEW_FUN_EXPORT PFNGLBEGINQUERYARBPROC __glewBeginQueryARB; GLEW_FUN_EXPORT PFNGLDELETEQUERIESARBPROC __glewDeleteQueriesARB; GLEW_FUN_EXPORT PFNGLENDQUERYARBPROC __glewEndQueryARB; GLEW_FUN_EXPORT PFNGLGENQUERIESARBPROC __glewGenQueriesARB; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVARBPROC __glewGetQueryObjectivARB; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVARBPROC __glewGetQueryObjectuivARB; GLEW_FUN_EXPORT PFNGLGETQUERYIVARBPROC __glewGetQueryivARB; GLEW_FUN_EXPORT PFNGLISQUERYARBPROC __glewIsQueryARB; GLEW_FUN_EXPORT PFNGLMAXSHADERCOMPILERTHREADSARBPROC __glewMaxShaderCompilerThreadsARB; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMINTERFACEIVPROC __glewGetProgramInterfaceiv; GLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCEINDEXPROC __glewGetProgramResourceIndex; GLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCELOCATIONPROC __glewGetProgramResourceLocation; GLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC __glewGetProgramResourceLocationIndex; GLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCENAMEPROC __glewGetProgramResourceName; GLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCEIVPROC __glewGetProgramResourceiv; GLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXPROC __glewProvokingVertex; GLEW_FUN_EXPORT PFNGLGETGRAPHICSRESETSTATUSARBPROC __glewGetGraphicsResetStatusARB; GLEW_FUN_EXPORT PFNGLGETNCOLORTABLEARBPROC __glewGetnColorTableARB; GLEW_FUN_EXPORT PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC __glewGetnCompressedTexImageARB; GLEW_FUN_EXPORT PFNGLGETNCONVOLUTIONFILTERARBPROC __glewGetnConvolutionFilterARB; GLEW_FUN_EXPORT PFNGLGETNHISTOGRAMARBPROC __glewGetnHistogramARB; GLEW_FUN_EXPORT PFNGLGETNMAPDVARBPROC __glewGetnMapdvARB; GLEW_FUN_EXPORT PFNGLGETNMAPFVARBPROC __glewGetnMapfvARB; GLEW_FUN_EXPORT PFNGLGETNMAPIVARBPROC __glewGetnMapivARB; GLEW_FUN_EXPORT PFNGLGETNMINMAXARBPROC __glewGetnMinmaxARB; GLEW_FUN_EXPORT PFNGLGETNPIXELMAPFVARBPROC __glewGetnPixelMapfvARB; GLEW_FUN_EXPORT PFNGLGETNPIXELMAPUIVARBPROC __glewGetnPixelMapuivARB; GLEW_FUN_EXPORT PFNGLGETNPIXELMAPUSVARBPROC __glewGetnPixelMapusvARB; GLEW_FUN_EXPORT PFNGLGETNPOLYGONSTIPPLEARBPROC __glewGetnPolygonStippleARB; GLEW_FUN_EXPORT PFNGLGETNSEPARABLEFILTERARBPROC __glewGetnSeparableFilterARB; GLEW_FUN_EXPORT PFNGLGETNTEXIMAGEARBPROC __glewGetnTexImageARB; GLEW_FUN_EXPORT PFNGLGETNUNIFORMDVARBPROC __glewGetnUniformdvARB; GLEW_FUN_EXPORT PFNGLGETNUNIFORMFVARBPROC __glewGetnUniformfvARB; GLEW_FUN_EXPORT PFNGLGETNUNIFORMIVARBPROC __glewGetnUniformivARB; GLEW_FUN_EXPORT PFNGLGETNUNIFORMUIVARBPROC __glewGetnUniformuivARB; GLEW_FUN_EXPORT PFNGLREADNPIXELSARBPROC __glewReadnPixelsARB; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC __glewFramebufferSampleLocationsfvARB; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC __glewNamedFramebufferSampleLocationsfvARB; GLEW_FUN_EXPORT PFNGLMINSAMPLESHADINGARBPROC __glewMinSampleShadingARB; GLEW_FUN_EXPORT PFNGLBINDSAMPLERPROC __glewBindSampler; GLEW_FUN_EXPORT PFNGLDELETESAMPLERSPROC __glewDeleteSamplers; GLEW_FUN_EXPORT PFNGLGENSAMPLERSPROC __glewGenSamplers; GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIIVPROC __glewGetSamplerParameterIiv; GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIUIVPROC __glewGetSamplerParameterIuiv; GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERFVPROC __glewGetSamplerParameterfv; GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIVPROC __glewGetSamplerParameteriv; GLEW_FUN_EXPORT PFNGLISSAMPLERPROC __glewIsSampler; GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIIVPROC __glewSamplerParameterIiv; GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIUIVPROC __glewSamplerParameterIuiv; GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERFPROC __glewSamplerParameterf; GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERFVPROC __glewSamplerParameterfv; GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIPROC __glewSamplerParameteri; GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIVPROC __glewSamplerParameteriv; GLEW_FUN_EXPORT PFNGLACTIVESHADERPROGRAMPROC __glewActiveShaderProgram; GLEW_FUN_EXPORT PFNGLBINDPROGRAMPIPELINEPROC __glewBindProgramPipeline; GLEW_FUN_EXPORT PFNGLCREATESHADERPROGRAMVPROC __glewCreateShaderProgramv; GLEW_FUN_EXPORT PFNGLDELETEPROGRAMPIPELINESPROC __glewDeleteProgramPipelines; GLEW_FUN_EXPORT PFNGLGENPROGRAMPIPELINESPROC __glewGenProgramPipelines; GLEW_FUN_EXPORT PFNGLGETPROGRAMPIPELINEINFOLOGPROC __glewGetProgramPipelineInfoLog; GLEW_FUN_EXPORT PFNGLGETPROGRAMPIPELINEIVPROC __glewGetProgramPipelineiv; GLEW_FUN_EXPORT PFNGLISPROGRAMPIPELINEPROC __glewIsProgramPipeline; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1DPROC __glewProgramUniform1d; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1DVPROC __glewProgramUniform1dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FPROC __glewProgramUniform1f; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FVPROC __glewProgramUniform1fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IPROC __glewProgramUniform1i; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IVPROC __glewProgramUniform1iv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIPROC __glewProgramUniform1ui; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIVPROC __glewProgramUniform1uiv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2DPROC __glewProgramUniform2d; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2DVPROC __glewProgramUniform2dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FPROC __glewProgramUniform2f; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FVPROC __glewProgramUniform2fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IPROC __glewProgramUniform2i; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IVPROC __glewProgramUniform2iv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIPROC __glewProgramUniform2ui; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIVPROC __glewProgramUniform2uiv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3DPROC __glewProgramUniform3d; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3DVPROC __glewProgramUniform3dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FPROC __glewProgramUniform3f; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FVPROC __glewProgramUniform3fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IPROC __glewProgramUniform3i; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IVPROC __glewProgramUniform3iv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIPROC __glewProgramUniform3ui; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIVPROC __glewProgramUniform3uiv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4DPROC __glewProgramUniform4d; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4DVPROC __glewProgramUniform4dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FPROC __glewProgramUniform4f; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FVPROC __glewProgramUniform4fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IPROC __glewProgramUniform4i; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IVPROC __glewProgramUniform4iv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIPROC __glewProgramUniform4ui; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIVPROC __glewProgramUniform4uiv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2DVPROC __glewProgramUniformMatrix2dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2FVPROC __glewProgramUniformMatrix2fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC __glewProgramUniformMatrix2x3dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC __glewProgramUniformMatrix2x3fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC __glewProgramUniformMatrix2x4dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC __glewProgramUniformMatrix2x4fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3DVPROC __glewProgramUniformMatrix3dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3FVPROC __glewProgramUniformMatrix3fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC __glewProgramUniformMatrix3x2dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC __glewProgramUniformMatrix3x2fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC __glewProgramUniformMatrix3x4dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC __glewProgramUniformMatrix3x4fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4DVPROC __glewProgramUniformMatrix4dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4FVPROC __glewProgramUniformMatrix4fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC __glewProgramUniformMatrix4x2dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC __glewProgramUniformMatrix4x2fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC __glewProgramUniformMatrix4x3dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC __glewProgramUniformMatrix4x3fv; GLEW_FUN_EXPORT PFNGLUSEPROGRAMSTAGESPROC __glewUseProgramStages; GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPIPELINEPROC __glewValidateProgramPipeline; GLEW_FUN_EXPORT PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC __glewGetActiveAtomicCounterBufferiv; GLEW_FUN_EXPORT PFNGLBINDIMAGETEXTUREPROC __glewBindImageTexture; GLEW_FUN_EXPORT PFNGLMEMORYBARRIERPROC __glewMemoryBarrier; GLEW_FUN_EXPORT PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB; GLEW_FUN_EXPORT PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB; GLEW_FUN_EXPORT PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB; GLEW_FUN_EXPORT PFNGLCREATESHADEROBJECTARBPROC __glewCreateShaderObjectARB; GLEW_FUN_EXPORT PFNGLDELETEOBJECTARBPROC __glewDeleteObjectARB; GLEW_FUN_EXPORT PFNGLDETACHOBJECTARBPROC __glewDetachObjectARB; GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMARBPROC __glewGetActiveUniformARB; GLEW_FUN_EXPORT PFNGLGETATTACHEDOBJECTSARBPROC __glewGetAttachedObjectsARB; GLEW_FUN_EXPORT PFNGLGETHANDLEARBPROC __glewGetHandleARB; GLEW_FUN_EXPORT PFNGLGETINFOLOGARBPROC __glewGetInfoLogARB; GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERFVARBPROC __glewGetObjectParameterfvARB; GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVARBPROC __glewGetObjectParameterivARB; GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEARBPROC __glewGetShaderSourceARB; GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONARBPROC __glewGetUniformLocationARB; GLEW_FUN_EXPORT PFNGLGETUNIFORMFVARBPROC __glewGetUniformfvARB; GLEW_FUN_EXPORT PFNGLGETUNIFORMIVARBPROC __glewGetUniformivARB; GLEW_FUN_EXPORT PFNGLLINKPROGRAMARBPROC __glewLinkProgramARB; GLEW_FUN_EXPORT PFNGLSHADERSOURCEARBPROC __glewShaderSourceARB; GLEW_FUN_EXPORT PFNGLUNIFORM1FARBPROC __glewUniform1fARB; GLEW_FUN_EXPORT PFNGLUNIFORM1FVARBPROC __glewUniform1fvARB; GLEW_FUN_EXPORT PFNGLUNIFORM1IARBPROC __glewUniform1iARB; GLEW_FUN_EXPORT PFNGLUNIFORM1IVARBPROC __glewUniform1ivARB; GLEW_FUN_EXPORT PFNGLUNIFORM2FARBPROC __glewUniform2fARB; GLEW_FUN_EXPORT PFNGLUNIFORM2FVARBPROC __glewUniform2fvARB; GLEW_FUN_EXPORT PFNGLUNIFORM2IARBPROC __glewUniform2iARB; GLEW_FUN_EXPORT PFNGLUNIFORM2IVARBPROC __glewUniform2ivARB; GLEW_FUN_EXPORT PFNGLUNIFORM3FARBPROC __glewUniform3fARB; GLEW_FUN_EXPORT PFNGLUNIFORM3FVARBPROC __glewUniform3fvARB; GLEW_FUN_EXPORT PFNGLUNIFORM3IARBPROC __glewUniform3iARB; GLEW_FUN_EXPORT PFNGLUNIFORM3IVARBPROC __glewUniform3ivARB; GLEW_FUN_EXPORT PFNGLUNIFORM4FARBPROC __glewUniform4fARB; GLEW_FUN_EXPORT PFNGLUNIFORM4FVARBPROC __glewUniform4fvARB; GLEW_FUN_EXPORT PFNGLUNIFORM4IARBPROC __glewUniform4iARB; GLEW_FUN_EXPORT PFNGLUNIFORM4IVARBPROC __glewUniform4ivARB; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVARBPROC __glewUniformMatrix2fvARB; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVARBPROC __glewUniformMatrix3fvARB; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB; GLEW_FUN_EXPORT PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB; GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB; GLEW_FUN_EXPORT PFNGLSHADERSTORAGEBLOCKBINDINGPROC __glewShaderStorageBlockBinding; GLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINENAMEPROC __glewGetActiveSubroutineName; GLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC __glewGetActiveSubroutineUniformName; GLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC __glewGetActiveSubroutineUniformiv; GLEW_FUN_EXPORT PFNGLGETPROGRAMSTAGEIVPROC __glewGetProgramStageiv; GLEW_FUN_EXPORT PFNGLGETSUBROUTINEINDEXPROC __glewGetSubroutineIndex; GLEW_FUN_EXPORT PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC __glewGetSubroutineUniformLocation; GLEW_FUN_EXPORT PFNGLGETUNIFORMSUBROUTINEUIVPROC __glewGetUniformSubroutineuiv; GLEW_FUN_EXPORT PFNGLUNIFORMSUBROUTINESUIVPROC __glewUniformSubroutinesuiv; GLEW_FUN_EXPORT PFNGLCOMPILESHADERINCLUDEARBPROC __glewCompileShaderIncludeARB; GLEW_FUN_EXPORT PFNGLDELETENAMEDSTRINGARBPROC __glewDeleteNamedStringARB; GLEW_FUN_EXPORT PFNGLGETNAMEDSTRINGARBPROC __glewGetNamedStringARB; GLEW_FUN_EXPORT PFNGLGETNAMEDSTRINGIVARBPROC __glewGetNamedStringivARB; GLEW_FUN_EXPORT PFNGLISNAMEDSTRINGARBPROC __glewIsNamedStringARB; GLEW_FUN_EXPORT PFNGLNAMEDSTRINGARBPROC __glewNamedStringARB; GLEW_FUN_EXPORT PFNGLBUFFERPAGECOMMITMENTARBPROC __glewBufferPageCommitmentARB; GLEW_FUN_EXPORT PFNGLTEXPAGECOMMITMENTARBPROC __glewTexPageCommitmentARB; GLEW_FUN_EXPORT PFNGLTEXTUREPAGECOMMITMENTEXTPROC __glewTexturePageCommitmentEXT; GLEW_FUN_EXPORT PFNGLCLIENTWAITSYNCPROC __glewClientWaitSync; GLEW_FUN_EXPORT PFNGLDELETESYNCPROC __glewDeleteSync; GLEW_FUN_EXPORT PFNGLFENCESYNCPROC __glewFenceSync; GLEW_FUN_EXPORT PFNGLGETINTEGER64VPROC __glewGetInteger64v; GLEW_FUN_EXPORT PFNGLGETSYNCIVPROC __glewGetSynciv; GLEW_FUN_EXPORT PFNGLISSYNCPROC __glewIsSync; GLEW_FUN_EXPORT PFNGLWAITSYNCPROC __glewWaitSync; GLEW_FUN_EXPORT PFNGLPATCHPARAMETERFVPROC __glewPatchParameterfv; GLEW_FUN_EXPORT PFNGLPATCHPARAMETERIPROC __glewPatchParameteri; GLEW_FUN_EXPORT PFNGLTEXTUREBARRIERPROC __glewTextureBarrier; GLEW_FUN_EXPORT PFNGLTEXBUFFERARBPROC __glewTexBufferARB; GLEW_FUN_EXPORT PFNGLTEXBUFFERRANGEPROC __glewTexBufferRange; GLEW_FUN_EXPORT PFNGLTEXTUREBUFFERRANGEEXTPROC __glewTextureBufferRangeEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DARBPROC __glewCompressedTexImage2DARB; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DARBPROC __glewCompressedTexImage3DARB; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC __glewCompressedTexSubImage1DARB; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB; GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB; GLEW_FUN_EXPORT PFNGLGETMULTISAMPLEFVPROC __glewGetMultisamplefv; GLEW_FUN_EXPORT PFNGLSAMPLEMASKIPROC __glewSampleMaski; GLEW_FUN_EXPORT PFNGLTEXIMAGE2DMULTISAMPLEPROC __glewTexImage2DMultisample; GLEW_FUN_EXPORT PFNGLTEXIMAGE3DMULTISAMPLEPROC __glewTexImage3DMultisample; GLEW_FUN_EXPORT PFNGLTEXSTORAGE1DPROC __glewTexStorage1D; GLEW_FUN_EXPORT PFNGLTEXSTORAGE2DPROC __glewTexStorage2D; GLEW_FUN_EXPORT PFNGLTEXSTORAGE3DPROC __glewTexStorage3D; GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE1DEXTPROC __glewTextureStorage1DEXT; GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DEXTPROC __glewTextureStorage2DEXT; GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DEXTPROC __glewTextureStorage3DEXT; GLEW_FUN_EXPORT PFNGLTEXSTORAGE2DMULTISAMPLEPROC __glewTexStorage2DMultisample; GLEW_FUN_EXPORT PFNGLTEXSTORAGE3DMULTISAMPLEPROC __glewTexStorage3DMultisample; GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC __glewTextureStorage2DMultisampleEXT; GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC __glewTextureStorage3DMultisampleEXT; GLEW_FUN_EXPORT PFNGLTEXTUREVIEWPROC __glewTextureView; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VPROC __glewGetQueryObjecti64v; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VPROC __glewGetQueryObjectui64v; GLEW_FUN_EXPORT PFNGLQUERYCOUNTERPROC __glewQueryCounter; GLEW_FUN_EXPORT PFNGLBINDTRANSFORMFEEDBACKPROC __glewBindTransformFeedback; GLEW_FUN_EXPORT PFNGLDELETETRANSFORMFEEDBACKSPROC __glewDeleteTransformFeedbacks; GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKPROC __glewDrawTransformFeedback; GLEW_FUN_EXPORT PFNGLGENTRANSFORMFEEDBACKSPROC __glewGenTransformFeedbacks; GLEW_FUN_EXPORT PFNGLISTRANSFORMFEEDBACKPROC __glewIsTransformFeedback; GLEW_FUN_EXPORT PFNGLPAUSETRANSFORMFEEDBACKPROC __glewPauseTransformFeedback; GLEW_FUN_EXPORT PFNGLRESUMETRANSFORMFEEDBACKPROC __glewResumeTransformFeedback; GLEW_FUN_EXPORT PFNGLBEGINQUERYINDEXEDPROC __glewBeginQueryIndexed; GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC __glewDrawTransformFeedbackStream; GLEW_FUN_EXPORT PFNGLENDQUERYINDEXEDPROC __glewEndQueryIndexed; GLEW_FUN_EXPORT PFNGLGETQUERYINDEXEDIVPROC __glewGetQueryIndexediv; GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC __glewDrawTransformFeedbackInstanced; GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC __glewDrawTransformFeedbackStreamInstanced; GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB; GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB; GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB; GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB; GLEW_FUN_EXPORT PFNGLBINDBUFFERBASEPROC __glewBindBufferBase; GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEPROC __glewBindBufferRange; GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC __glewGetActiveUniformBlockName; GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMBLOCKIVPROC __glewGetActiveUniformBlockiv; GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMNAMEPROC __glewGetActiveUniformName; GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMSIVPROC __glewGetActiveUniformsiv; GLEW_FUN_EXPORT PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v; GLEW_FUN_EXPORT PFNGLGETUNIFORMBLOCKINDEXPROC __glewGetUniformBlockIndex; GLEW_FUN_EXPORT PFNGLGETUNIFORMINDICESPROC __glewGetUniformIndices; GLEW_FUN_EXPORT PFNGLUNIFORMBLOCKBINDINGPROC __glewUniformBlockBinding; GLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYPROC __glewBindVertexArray; GLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSPROC __glewDeleteVertexArrays; GLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSPROC __glewGenVertexArrays; GLEW_FUN_EXPORT PFNGLISVERTEXARRAYPROC __glewIsVertexArray; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLDVPROC __glewGetVertexAttribLdv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DPROC __glewVertexAttribL1d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DVPROC __glewVertexAttribL1dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DPROC __glewVertexAttribL2d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DVPROC __glewVertexAttribL2dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DPROC __glewVertexAttribL3d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DVPROC __glewVertexAttribL3dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DPROC __glewVertexAttribL4d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DVPROC __glewVertexAttribL4dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBLPOINTERPROC __glewVertexAttribLPointer; GLEW_FUN_EXPORT PFNGLBINDVERTEXBUFFERPROC __glewBindVertexBuffer; GLEW_FUN_EXPORT PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC __glewVertexArrayBindVertexBufferEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC __glewVertexArrayVertexAttribBindingEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC __glewVertexArrayVertexAttribFormatEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC __glewVertexArrayVertexAttribIFormatEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC __glewVertexArrayVertexAttribLFormatEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC __glewVertexArrayVertexBindingDivisorEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBBINDINGPROC __glewVertexAttribBinding; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBFORMATPROC __glewVertexAttribFormat; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIFORMATPROC __glewVertexAttribIFormat; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBLFORMATPROC __glewVertexAttribLFormat; GLEW_FUN_EXPORT PFNGLVERTEXBINDINGDIVISORPROC __glewVertexBindingDivisor; GLEW_FUN_EXPORT PFNGLVERTEXBLENDARBPROC __glewVertexBlendARB; GLEW_FUN_EXPORT PFNGLWEIGHTPOINTERARBPROC __glewWeightPointerARB; GLEW_FUN_EXPORT PFNGLWEIGHTBVARBPROC __glewWeightbvARB; GLEW_FUN_EXPORT PFNGLWEIGHTDVARBPROC __glewWeightdvARB; GLEW_FUN_EXPORT PFNGLWEIGHTFVARBPROC __glewWeightfvARB; GLEW_FUN_EXPORT PFNGLWEIGHTIVARBPROC __glewWeightivARB; GLEW_FUN_EXPORT PFNGLWEIGHTSVARBPROC __glewWeightsvARB; GLEW_FUN_EXPORT PFNGLWEIGHTUBVARBPROC __glewWeightubvARB; GLEW_FUN_EXPORT PFNGLWEIGHTUIVARBPROC __glewWeightuivARB; GLEW_FUN_EXPORT PFNGLWEIGHTUSVARBPROC __glewWeightusvARB; GLEW_FUN_EXPORT PFNGLBINDBUFFERARBPROC __glewBindBufferARB; GLEW_FUN_EXPORT PFNGLBUFFERDATAARBPROC __glewBufferDataARB; GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAARBPROC __glewBufferSubDataARB; GLEW_FUN_EXPORT PFNGLDELETEBUFFERSARBPROC __glewDeleteBuffersARB; GLEW_FUN_EXPORT PFNGLGENBUFFERSARBPROC __glewGenBuffersARB; GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVARBPROC __glewGetBufferParameterivARB; GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVARBPROC __glewGetBufferPointervARB; GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAARBPROC __glewGetBufferSubDataARB; GLEW_FUN_EXPORT PFNGLISBUFFERARBPROC __glewIsBufferARB; GLEW_FUN_EXPORT PFNGLMAPBUFFERARBPROC __glewMapBufferARB; GLEW_FUN_EXPORT PFNGLUNMAPBUFFERARBPROC __glewUnmapBufferARB; GLEW_FUN_EXPORT PFNGLBINDPROGRAMARBPROC __glewBindProgramARB; GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSARBPROC __glewDeleteProgramsARB; GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYARBPROC __glewDisableVertexAttribArrayARB; GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYARBPROC __glewEnableVertexAttribArrayARB; GLEW_FUN_EXPORT PFNGLGENPROGRAMSARBPROC __glewGenProgramsARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERDVARBPROC __glewGetProgramEnvParameterdvARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERFVARBPROC __glewGetProgramEnvParameterfvARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC __glewGetProgramLocalParameterdvARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC __glewGetProgramLocalParameterfvARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGARBPROC __glewGetProgramStringARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMIVARBPROC __glewGetProgramivARB; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVARBPROC __glewGetVertexAttribPointervARB; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVARBPROC __glewGetVertexAttribdvARB; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVARBPROC __glewGetVertexAttribfvARB; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVARBPROC __glewGetVertexAttribivARB; GLEW_FUN_EXPORT PFNGLISPROGRAMARBPROC __glewIsProgramARB; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DARBPROC __glewProgramEnvParameter4dARB; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DVARBPROC __glewProgramEnvParameter4dvARB; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FARBPROC __glewProgramEnvParameter4fARB; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FVARBPROC __glewProgramEnvParameter4fvARB; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DARBPROC __glewProgramLocalParameter4dARB; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DVARBPROC __glewProgramLocalParameter4dvARB; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FARBPROC __glewProgramLocalParameter4fARB; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FVARBPROC __glewProgramLocalParameter4fvARB; GLEW_FUN_EXPORT PFNGLPROGRAMSTRINGARBPROC __glewProgramStringARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DARBPROC __glewVertexAttrib1dARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVARBPROC __glewVertexAttrib1dvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FARBPROC __glewVertexAttrib1fARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVARBPROC __glewVertexAttrib1fvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SARBPROC __glewVertexAttrib1sARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVARBPROC __glewVertexAttrib1svARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DARBPROC __glewVertexAttrib2dARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVARBPROC __glewVertexAttrib2dvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FARBPROC __glewVertexAttrib2fARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVARBPROC __glewVertexAttrib2fvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SARBPROC __glewVertexAttrib2sARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVARBPROC __glewVertexAttrib2svARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DARBPROC __glewVertexAttrib3dARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVARBPROC __glewVertexAttrib3dvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FARBPROC __glewVertexAttrib3fARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVARBPROC __glewVertexAttrib3fvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SARBPROC __glewVertexAttrib3sARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVARBPROC __glewVertexAttrib3svARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVARBPROC __glewVertexAttrib4NbvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVARBPROC __glewVertexAttrib4NivARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVARBPROC __glewVertexAttrib4NsvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBARBPROC __glewVertexAttrib4NubARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVARBPROC __glewVertexAttrib4NubvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVARBPROC __glewVertexAttrib4NuivARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVARBPROC __glewVertexAttrib4NusvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVARBPROC __glewVertexAttrib4bvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DARBPROC __glewVertexAttrib4dARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVARBPROC __glewVertexAttrib4dvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FARBPROC __glewVertexAttrib4fARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVARBPROC __glewVertexAttrib4fvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVARBPROC __glewVertexAttrib4ivARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SARBPROC __glewVertexAttrib4sARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVARBPROC __glewVertexAttrib4svARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVARBPROC __glewVertexAttrib4ubvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVARBPROC __glewVertexAttrib4uivARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVARBPROC __glewVertexAttrib4usvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERARBPROC __glewVertexAttribPointerARB; GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB; GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB; GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB; GLEW_FUN_EXPORT PFNGLCOLORP3UIPROC __glewColorP3ui; GLEW_FUN_EXPORT PFNGLCOLORP3UIVPROC __glewColorP3uiv; GLEW_FUN_EXPORT PFNGLCOLORP4UIPROC __glewColorP4ui; GLEW_FUN_EXPORT PFNGLCOLORP4UIVPROC __glewColorP4uiv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP1UIPROC __glewMultiTexCoordP1ui; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP1UIVPROC __glewMultiTexCoordP1uiv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP2UIPROC __glewMultiTexCoordP2ui; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP2UIVPROC __glewMultiTexCoordP2uiv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP3UIPROC __glewMultiTexCoordP3ui; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP3UIVPROC __glewMultiTexCoordP3uiv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP4UIPROC __glewMultiTexCoordP4ui; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP4UIVPROC __glewMultiTexCoordP4uiv; GLEW_FUN_EXPORT PFNGLNORMALP3UIPROC __glewNormalP3ui; GLEW_FUN_EXPORT PFNGLNORMALP3UIVPROC __glewNormalP3uiv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLORP3UIPROC __glewSecondaryColorP3ui; GLEW_FUN_EXPORT PFNGLSECONDARYCOLORP3UIVPROC __glewSecondaryColorP3uiv; GLEW_FUN_EXPORT PFNGLTEXCOORDP1UIPROC __glewTexCoordP1ui; GLEW_FUN_EXPORT PFNGLTEXCOORDP1UIVPROC __glewTexCoordP1uiv; GLEW_FUN_EXPORT PFNGLTEXCOORDP2UIPROC __glewTexCoordP2ui; GLEW_FUN_EXPORT PFNGLTEXCOORDP2UIVPROC __glewTexCoordP2uiv; GLEW_FUN_EXPORT PFNGLTEXCOORDP3UIPROC __glewTexCoordP3ui; GLEW_FUN_EXPORT PFNGLTEXCOORDP3UIVPROC __glewTexCoordP3uiv; GLEW_FUN_EXPORT PFNGLTEXCOORDP4UIPROC __glewTexCoordP4ui; GLEW_FUN_EXPORT PFNGLTEXCOORDP4UIVPROC __glewTexCoordP4uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP1UIPROC __glewVertexAttribP1ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP1UIVPROC __glewVertexAttribP1uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP2UIPROC __glewVertexAttribP2ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP2UIVPROC __glewVertexAttribP2uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP3UIPROC __glewVertexAttribP3ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP3UIVPROC __glewVertexAttribP3uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP4UIPROC __glewVertexAttribP4ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP4UIVPROC __glewVertexAttribP4uiv; GLEW_FUN_EXPORT PFNGLVERTEXP2UIPROC __glewVertexP2ui; GLEW_FUN_EXPORT PFNGLVERTEXP2UIVPROC __glewVertexP2uiv; GLEW_FUN_EXPORT PFNGLVERTEXP3UIPROC __glewVertexP3ui; GLEW_FUN_EXPORT PFNGLVERTEXP3UIVPROC __glewVertexP3uiv; GLEW_FUN_EXPORT PFNGLVERTEXP4UIPROC __glewVertexP4ui; GLEW_FUN_EXPORT PFNGLVERTEXP4UIVPROC __glewVertexP4uiv; GLEW_FUN_EXPORT PFNGLDEPTHRANGEARRAYVPROC __glewDepthRangeArrayv; GLEW_FUN_EXPORT PFNGLDEPTHRANGEINDEXEDPROC __glewDepthRangeIndexed; GLEW_FUN_EXPORT PFNGLGETDOUBLEI_VPROC __glewGetDoublei_v; GLEW_FUN_EXPORT PFNGLGETFLOATI_VPROC __glewGetFloati_v; GLEW_FUN_EXPORT PFNGLSCISSORARRAYVPROC __glewScissorArrayv; GLEW_FUN_EXPORT PFNGLSCISSORINDEXEDPROC __glewScissorIndexed; GLEW_FUN_EXPORT PFNGLSCISSORINDEXEDVPROC __glewScissorIndexedv; GLEW_FUN_EXPORT PFNGLVIEWPORTARRAYVPROC __glewViewportArrayv; GLEW_FUN_EXPORT PFNGLVIEWPORTINDEXEDFPROC __glewViewportIndexedf; GLEW_FUN_EXPORT PFNGLVIEWPORTINDEXEDFVPROC __glewViewportIndexedfv; GLEW_FUN_EXPORT PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVARBPROC __glewWindowPos2fvARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2IARBPROC __glewWindowPos2iARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVARBPROC __glewWindowPos2ivARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2SARBPROC __glewWindowPos2sARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVARBPROC __glewWindowPos2svARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3DARBPROC __glewWindowPos3dARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVARBPROC __glewWindowPos3dvARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3FARBPROC __glewWindowPos3fARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVARBPROC __glewWindowPos3fvARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3IARBPROC __glewWindowPos3iARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVARBPROC __glewWindowPos3ivARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3SARBPROC __glewWindowPos3sARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVARBPROC __glewWindowPos3svARB; GLEW_FUN_EXPORT PFNGLDRAWBUFFERSATIPROC __glewDrawBuffersATI; GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYATIPROC __glewDrawElementArrayATI; GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYATIPROC __glewDrawRangeElementArrayATI; GLEW_FUN_EXPORT PFNGLELEMENTPOINTERATIPROC __glewElementPointerATI; GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERFVATIPROC __glewGetTexBumpParameterfvATI; GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERIVATIPROC __glewGetTexBumpParameterivATI; GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERFVATIPROC __glewTexBumpParameterfvATI; GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERIVATIPROC __glewTexBumpParameterivATI; GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP1ATIPROC __glewAlphaFragmentOp1ATI; GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP2ATIPROC __glewAlphaFragmentOp2ATI; GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP3ATIPROC __glewAlphaFragmentOp3ATI; GLEW_FUN_EXPORT PFNGLBEGINFRAGMENTSHADERATIPROC __glewBeginFragmentShaderATI; GLEW_FUN_EXPORT PFNGLBINDFRAGMENTSHADERATIPROC __glewBindFragmentShaderATI; GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP1ATIPROC __glewColorFragmentOp1ATI; GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP2ATIPROC __glewColorFragmentOp2ATI; GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP3ATIPROC __glewColorFragmentOp3ATI; GLEW_FUN_EXPORT PFNGLDELETEFRAGMENTSHADERATIPROC __glewDeleteFragmentShaderATI; GLEW_FUN_EXPORT PFNGLENDFRAGMENTSHADERATIPROC __glewEndFragmentShaderATI; GLEW_FUN_EXPORT PFNGLGENFRAGMENTSHADERSATIPROC __glewGenFragmentShadersATI; GLEW_FUN_EXPORT PFNGLPASSTEXCOORDATIPROC __glewPassTexCoordATI; GLEW_FUN_EXPORT PFNGLSAMPLEMAPATIPROC __glewSampleMapATI; GLEW_FUN_EXPORT PFNGLSETFRAGMENTSHADERCONSTANTATIPROC __glewSetFragmentShaderConstantATI; GLEW_FUN_EXPORT PFNGLMAPOBJECTBUFFERATIPROC __glewMapObjectBufferATI; GLEW_FUN_EXPORT PFNGLUNMAPOBJECTBUFFERATIPROC __glewUnmapObjectBufferATI; GLEW_FUN_EXPORT PFNGLPNTRIANGLESFATIPROC __glewPNTrianglesfATI; GLEW_FUN_EXPORT PFNGLPNTRIANGLESIATIPROC __glewPNTrianglesiATI; GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEATIPROC __glewStencilFuncSeparateATI; GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEATIPROC __glewStencilOpSeparateATI; GLEW_FUN_EXPORT PFNGLARRAYOBJECTATIPROC __glewArrayObjectATI; GLEW_FUN_EXPORT PFNGLFREEOBJECTBUFFERATIPROC __glewFreeObjectBufferATI; GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTFVATIPROC __glewGetArrayObjectfvATI; GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTIVATIPROC __glewGetArrayObjectivATI; GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERFVATIPROC __glewGetObjectBufferfvATI; GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERIVATIPROC __glewGetObjectBufferivATI; GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTFVATIPROC __glewGetVariantArrayObjectfvATI; GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTIVATIPROC __glewGetVariantArrayObjectivATI; GLEW_FUN_EXPORT PFNGLISOBJECTBUFFERATIPROC __glewIsObjectBufferATI; GLEW_FUN_EXPORT PFNGLNEWOBJECTBUFFERATIPROC __glewNewObjectBufferATI; GLEW_FUN_EXPORT PFNGLUPDATEOBJECTBUFFERATIPROC __glewUpdateObjectBufferATI; GLEW_FUN_EXPORT PFNGLVARIANTARRAYOBJECTATIPROC __glewVariantArrayObjectATI; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC __glewGetVertexAttribArrayObjectfvATI; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC __glewGetVertexAttribArrayObjectivATI; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBARRAYOBJECTATIPROC __glewVertexAttribArrayObjectATI; GLEW_FUN_EXPORT PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC __glewClientActiveVertexStreamATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BATIPROC __glewNormalStream3bATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BVATIPROC __glewNormalStream3bvATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DATIPROC __glewNormalStream3dATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DVATIPROC __glewNormalStream3dvATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FATIPROC __glewNormalStream3fATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FVATIPROC __glewNormalStream3fvATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IATIPROC __glewNormalStream3iATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IVATIPROC __glewNormalStream3ivATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SATIPROC __glewNormalStream3sATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SVATIPROC __glewNormalStream3svATI; GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVFATIPROC __glewVertexBlendEnvfATI; GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVIATIPROC __glewVertexBlendEnviATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1DATIPROC __glewVertexStream1dATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1DVATIPROC __glewVertexStream1dvATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1FATIPROC __glewVertexStream1fATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1FVATIPROC __glewVertexStream1fvATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1IATIPROC __glewVertexStream1iATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1IVATIPROC __glewVertexStream1ivATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1SATIPROC __glewVertexStream1sATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1SVATIPROC __glewVertexStream1svATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DATIPROC __glewVertexStream2dATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DVATIPROC __glewVertexStream2dvATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FATIPROC __glewVertexStream2fATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FVATIPROC __glewVertexStream2fvATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IATIPROC __glewVertexStream2iATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IVATIPROC __glewVertexStream2ivATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SATIPROC __glewVertexStream2sATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SVATIPROC __glewVertexStream2svATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DATIPROC __glewVertexStream3dATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DVATIPROC __glewVertexStream3dvATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FATIPROC __glewVertexStream3fATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FVATIPROC __glewVertexStream3fvATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IATIPROC __glewVertexStream3iATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IVATIPROC __glewVertexStream3ivATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SATIPROC __glewVertexStream3sATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SVATIPROC __glewVertexStream3svATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DATIPROC __glewVertexStream4dATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DVATIPROC __glewVertexStream4dvATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FATIPROC __glewVertexStream4fATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FVATIPROC __glewVertexStream4fvATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IATIPROC __glewVertexStream4iATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IVATIPROC __glewVertexStream4ivATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SATIPROC __glewVertexStream4sATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SVATIPROC __glewVertexStream4svATI; GLEW_FUN_EXPORT PFNGLGETUNIFORMBUFFERSIZEEXTPROC __glewGetUniformBufferSizeEXT; GLEW_FUN_EXPORT PFNGLGETUNIFORMOFFSETEXTPROC __glewGetUniformOffsetEXT; GLEW_FUN_EXPORT PFNGLUNIFORMBUFFEREXTPROC __glewUniformBufferEXT; GLEW_FUN_EXPORT PFNGLBLENDCOLOREXTPROC __glewBlendColorEXT; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEEXTPROC __glewBlendEquationSeparateEXT; GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEEXTPROC __glewBlendFuncSeparateEXT; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONEXTPROC __glewBlendEquationEXT; GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEEXTPROC __glewColorSubTableEXT; GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEEXTPROC __glewCopyColorSubTableEXT; GLEW_FUN_EXPORT PFNGLLOCKARRAYSEXTPROC __glewLockArraysEXT; GLEW_FUN_EXPORT PFNGLUNLOCKARRAYSEXTPROC __glewUnlockArraysEXT; GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DEXTPROC __glewConvolutionFilter1DEXT; GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DEXTPROC __glewConvolutionFilter2DEXT; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFEXTPROC __glewConvolutionParameterfEXT; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVEXTPROC __glewConvolutionParameterfvEXT; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIEXTPROC __glewConvolutionParameteriEXT; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVEXTPROC __glewConvolutionParameterivEXT; GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC __glewCopyConvolutionFilter1DEXT; GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC __glewCopyConvolutionFilter2DEXT; GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTEREXTPROC __glewGetConvolutionFilterEXT; GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC __glewGetConvolutionParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC __glewGetConvolutionParameterivEXT; GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTEREXTPROC __glewGetSeparableFilterEXT; GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DEXTPROC __glewSeparableFilter2DEXT; GLEW_FUN_EXPORT PFNGLBINORMALPOINTEREXTPROC __glewBinormalPointerEXT; GLEW_FUN_EXPORT PFNGLTANGENTPOINTEREXTPROC __glewTangentPointerEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE1DEXTPROC __glewCopyTexImage1DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE2DEXTPROC __glewCopyTexImage2DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE1DEXTPROC __glewCopyTexSubImage1DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE2DEXTPROC __glewCopyTexSubImage2DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DEXTPROC __glewCopyTexSubImage3DEXT; GLEW_FUN_EXPORT PFNGLCULLPARAMETERDVEXTPROC __glewCullParameterdvEXT; GLEW_FUN_EXPORT PFNGLCULLPARAMETERFVEXTPROC __glewCullParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETOBJECTLABELEXTPROC __glewGetObjectLabelEXT; GLEW_FUN_EXPORT PFNGLLABELOBJECTEXTPROC __glewLabelObjectEXT; GLEW_FUN_EXPORT PFNGLINSERTEVENTMARKEREXTPROC __glewInsertEventMarkerEXT; GLEW_FUN_EXPORT PFNGLPOPGROUPMARKEREXTPROC __glewPopGroupMarkerEXT; GLEW_FUN_EXPORT PFNGLPUSHGROUPMARKEREXTPROC __glewPushGroupMarkerEXT; GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSEXTPROC __glewDepthBoundsEXT; GLEW_FUN_EXPORT PFNGLBINDMULTITEXTUREEXTPROC __glewBindMultiTextureEXT; GLEW_FUN_EXPORT PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC __glewCheckNamedFramebufferStatusEXT; GLEW_FUN_EXPORT PFNGLCLIENTATTRIBDEFAULTEXTPROC __glewClientAttribDefaultEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC __glewCompressedMultiTexImage1DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC __glewCompressedMultiTexImage2DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC __glewCompressedMultiTexImage3DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC __glewCompressedMultiTexSubImage1DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC __glewCompressedMultiTexSubImage2DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC __glewCompressedMultiTexSubImage3DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC __glewCompressedTextureImage1DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC __glewCompressedTextureImage2DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC __glewCompressedTextureImage3DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC __glewCompressedTextureSubImage1DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC __glewCompressedTextureSubImage2DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC __glewCompressedTextureSubImage3DEXT; GLEW_FUN_EXPORT PFNGLCOPYMULTITEXIMAGE1DEXTPROC __glewCopyMultiTexImage1DEXT; GLEW_FUN_EXPORT PFNGLCOPYMULTITEXIMAGE2DEXTPROC __glewCopyMultiTexImage2DEXT; GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC __glewCopyMultiTexSubImage1DEXT; GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC __glewCopyMultiTexSubImage2DEXT; GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC __glewCopyMultiTexSubImage3DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXTUREIMAGE1DEXTPROC __glewCopyTextureImage1DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXTUREIMAGE2DEXTPROC __glewCopyTextureImage2DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC __glewCopyTextureSubImage1DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC __glewCopyTextureSubImage2DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC __glewCopyTextureSubImage3DEXT; GLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC __glewDisableClientStateIndexedEXT; GLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEIEXTPROC __glewDisableClientStateiEXT; GLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC __glewDisableVertexArrayAttribEXT; GLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYEXTPROC __glewDisableVertexArrayEXT; GLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEINDEXEDEXTPROC __glewEnableClientStateIndexedEXT; GLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEIEXTPROC __glewEnableClientStateiEXT; GLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYATTRIBEXTPROC __glewEnableVertexArrayAttribEXT; GLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYEXTPROC __glewEnableVertexArrayEXT; GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC __glewFlushMappedNamedBufferRangeEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC __glewFramebufferDrawBufferEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC __glewFramebufferDrawBuffersEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERREADBUFFEREXTPROC __glewFramebufferReadBufferEXT; GLEW_FUN_EXPORT PFNGLGENERATEMULTITEXMIPMAPEXTPROC __glewGenerateMultiTexMipmapEXT; GLEW_FUN_EXPORT PFNGLGENERATETEXTUREMIPMAPEXTPROC __glewGenerateTextureMipmapEXT; GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC __glewGetCompressedMultiTexImageEXT; GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC __glewGetCompressedTextureImageEXT; GLEW_FUN_EXPORT PFNGLGETDOUBLEINDEXEDVEXTPROC __glewGetDoubleIndexedvEXT; GLEW_FUN_EXPORT PFNGLGETDOUBLEI_VEXTPROC __glewGetDoublei_vEXT; GLEW_FUN_EXPORT PFNGLGETFLOATINDEXEDVEXTPROC __glewGetFloatIndexedvEXT; GLEW_FUN_EXPORT PFNGLGETFLOATI_VEXTPROC __glewGetFloati_vEXT; GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC __glewGetFramebufferParameterivEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXENVFVEXTPROC __glewGetMultiTexEnvfvEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXENVIVEXTPROC __glewGetMultiTexEnvivEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXGENDVEXTPROC __glewGetMultiTexGendvEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXGENFVEXTPROC __glewGetMultiTexGenfvEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXGENIVEXTPROC __glewGetMultiTexGenivEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXIMAGEEXTPROC __glewGetMultiTexImageEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC __glewGetMultiTexLevelParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC __glewGetMultiTexLevelParameterivEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIIVEXTPROC __glewGetMultiTexParameterIivEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIUIVEXTPROC __glewGetMultiTexParameterIuivEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERFVEXTPROC __glewGetMultiTexParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIVEXTPROC __glewGetMultiTexParameterivEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC __glewGetNamedBufferParameterivEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPOINTERVEXTPROC __glewGetNamedBufferPointervEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERSUBDATAEXTPROC __glewGetNamedBufferSubDataEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetNamedFramebufferAttachmentParameterivEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC __glewGetNamedProgramLocalParameterIivEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC __glewGetNamedProgramLocalParameterIuivEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC __glewGetNamedProgramLocalParameterdvEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC __glewGetNamedProgramLocalParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMSTRINGEXTPROC __glewGetNamedProgramStringEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMIVEXTPROC __glewGetNamedProgramivEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC __glewGetNamedRenderbufferParameterivEXT; GLEW_FUN_EXPORT PFNGLGETPOINTERINDEXEDVEXTPROC __glewGetPointerIndexedvEXT; GLEW_FUN_EXPORT PFNGLGETPOINTERI_VEXTPROC __glewGetPointeri_vEXT; GLEW_FUN_EXPORT PFNGLGETTEXTUREIMAGEEXTPROC __glewGetTextureImageEXT; GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC __glewGetTextureLevelParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC __glewGetTextureLevelParameterivEXT; GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIIVEXTPROC __glewGetTextureParameterIivEXT; GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIUIVEXTPROC __glewGetTextureParameterIuivEXT; GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERFVEXTPROC __glewGetTextureParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIVEXTPROC __glewGetTextureParameterivEXT; GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC __glewGetVertexArrayIntegeri_vEXT; GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINTEGERVEXTPROC __glewGetVertexArrayIntegervEXT; GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC __glewGetVertexArrayPointeri_vEXT; GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYPOINTERVEXTPROC __glewGetVertexArrayPointervEXT; GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFEREXTPROC __glewMapNamedBufferEXT; GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFERRANGEEXTPROC __glewMapNamedBufferRangeEXT; GLEW_FUN_EXPORT PFNGLMATRIXFRUSTUMEXTPROC __glewMatrixFrustumEXT; GLEW_FUN_EXPORT PFNGLMATRIXLOADIDENTITYEXTPROC __glewMatrixLoadIdentityEXT; GLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEDEXTPROC __glewMatrixLoadTransposedEXT; GLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEFEXTPROC __glewMatrixLoadTransposefEXT; GLEW_FUN_EXPORT PFNGLMATRIXLOADDEXTPROC __glewMatrixLoaddEXT; GLEW_FUN_EXPORT PFNGLMATRIXLOADFEXTPROC __glewMatrixLoadfEXT; GLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSEDEXTPROC __glewMatrixMultTransposedEXT; GLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSEFEXTPROC __glewMatrixMultTransposefEXT; GLEW_FUN_EXPORT PFNGLMATRIXMULTDEXTPROC __glewMatrixMultdEXT; GLEW_FUN_EXPORT PFNGLMATRIXMULTFEXTPROC __glewMatrixMultfEXT; GLEW_FUN_EXPORT PFNGLMATRIXORTHOEXTPROC __glewMatrixOrthoEXT; GLEW_FUN_EXPORT PFNGLMATRIXPOPEXTPROC __glewMatrixPopEXT; GLEW_FUN_EXPORT PFNGLMATRIXPUSHEXTPROC __glewMatrixPushEXT; GLEW_FUN_EXPORT PFNGLMATRIXROTATEDEXTPROC __glewMatrixRotatedEXT; GLEW_FUN_EXPORT PFNGLMATRIXROTATEFEXTPROC __glewMatrixRotatefEXT; GLEW_FUN_EXPORT PFNGLMATRIXSCALEDEXTPROC __glewMatrixScaledEXT; GLEW_FUN_EXPORT PFNGLMATRIXSCALEFEXTPROC __glewMatrixScalefEXT; GLEW_FUN_EXPORT PFNGLMATRIXTRANSLATEDEXTPROC __glewMatrixTranslatedEXT; GLEW_FUN_EXPORT PFNGLMATRIXTRANSLATEFEXTPROC __glewMatrixTranslatefEXT; GLEW_FUN_EXPORT PFNGLMULTITEXBUFFEREXTPROC __glewMultiTexBufferEXT; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDPOINTEREXTPROC __glewMultiTexCoordPointerEXT; GLEW_FUN_EXPORT PFNGLMULTITEXENVFEXTPROC __glewMultiTexEnvfEXT; GLEW_FUN_EXPORT PFNGLMULTITEXENVFVEXTPROC __glewMultiTexEnvfvEXT; GLEW_FUN_EXPORT PFNGLMULTITEXENVIEXTPROC __glewMultiTexEnviEXT; GLEW_FUN_EXPORT PFNGLMULTITEXENVIVEXTPROC __glewMultiTexEnvivEXT; GLEW_FUN_EXPORT PFNGLMULTITEXGENDEXTPROC __glewMultiTexGendEXT; GLEW_FUN_EXPORT PFNGLMULTITEXGENDVEXTPROC __glewMultiTexGendvEXT; GLEW_FUN_EXPORT PFNGLMULTITEXGENFEXTPROC __glewMultiTexGenfEXT; GLEW_FUN_EXPORT PFNGLMULTITEXGENFVEXTPROC __glewMultiTexGenfvEXT; GLEW_FUN_EXPORT PFNGLMULTITEXGENIEXTPROC __glewMultiTexGeniEXT; GLEW_FUN_EXPORT PFNGLMULTITEXGENIVEXTPROC __glewMultiTexGenivEXT; GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE1DEXTPROC __glewMultiTexImage1DEXT; GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE2DEXTPROC __glewMultiTexImage2DEXT; GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE3DEXTPROC __glewMultiTexImage3DEXT; GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIIVEXTPROC __glewMultiTexParameterIivEXT; GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIUIVEXTPROC __glewMultiTexParameterIuivEXT; GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERFEXTPROC __glewMultiTexParameterfEXT; GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERFVEXTPROC __glewMultiTexParameterfvEXT; GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIEXTPROC __glewMultiTexParameteriEXT; GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIVEXTPROC __glewMultiTexParameterivEXT; GLEW_FUN_EXPORT PFNGLMULTITEXRENDERBUFFEREXTPROC __glewMultiTexRenderbufferEXT; GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE1DEXTPROC __glewMultiTexSubImage1DEXT; GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE2DEXTPROC __glewMultiTexSubImage2DEXT; GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE3DEXTPROC __glewMultiTexSubImage3DEXT; GLEW_FUN_EXPORT PFNGLNAMEDBUFFERDATAEXTPROC __glewNamedBufferDataEXT; GLEW_FUN_EXPORT PFNGLNAMEDBUFFERSUBDATAEXTPROC __glewNamedBufferSubDataEXT; GLEW_FUN_EXPORT PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC __glewNamedCopyBufferSubDataEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC __glewNamedFramebufferRenderbufferEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC __glewNamedFramebufferTexture1DEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC __glewNamedFramebufferTexture2DEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC __glewNamedFramebufferTexture3DEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC __glewNamedFramebufferTextureEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC __glewNamedFramebufferTextureFaceEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC __glewNamedFramebufferTextureLayerEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC __glewNamedProgramLocalParameter4dEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC __glewNamedProgramLocalParameter4dvEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC __glewNamedProgramLocalParameter4fEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC __glewNamedProgramLocalParameter4fvEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC __glewNamedProgramLocalParameterI4iEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC __glewNamedProgramLocalParameterI4ivEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC __glewNamedProgramLocalParameterI4uiEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC __glewNamedProgramLocalParameterI4uivEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC __glewNamedProgramLocalParameters4fvEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC __glewNamedProgramLocalParametersI4ivEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC __glewNamedProgramLocalParametersI4uivEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMSTRINGEXTPROC __glewNamedProgramStringEXT; GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC __glewNamedRenderbufferStorageEXT; GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC __glewNamedRenderbufferStorageMultisampleCoverageEXT; GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewNamedRenderbufferStorageMultisampleEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FEXTPROC __glewProgramUniform1fEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FVEXTPROC __glewProgramUniform1fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IEXTPROC __glewProgramUniform1iEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IVEXTPROC __glewProgramUniform1ivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIEXTPROC __glewProgramUniform1uiEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIVEXTPROC __glewProgramUniform1uivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FEXTPROC __glewProgramUniform2fEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FVEXTPROC __glewProgramUniform2fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IEXTPROC __glewProgramUniform2iEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IVEXTPROC __glewProgramUniform2ivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIEXTPROC __glewProgramUniform2uiEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIVEXTPROC __glewProgramUniform2uivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FEXTPROC __glewProgramUniform3fEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FVEXTPROC __glewProgramUniform3fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IEXTPROC __glewProgramUniform3iEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IVEXTPROC __glewProgramUniform3ivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIEXTPROC __glewProgramUniform3uiEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIVEXTPROC __glewProgramUniform3uivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FEXTPROC __glewProgramUniform4fEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FVEXTPROC __glewProgramUniform4fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IEXTPROC __glewProgramUniform4iEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IVEXTPROC __glewProgramUniform4ivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIEXTPROC __glewProgramUniform4uiEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIVEXTPROC __glewProgramUniform4uivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC __glewProgramUniformMatrix2fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC __glewProgramUniformMatrix2x3fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC __glewProgramUniformMatrix2x4fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC __glewProgramUniformMatrix3fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC __glewProgramUniformMatrix3x2fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC __glewProgramUniformMatrix3x4fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC __glewProgramUniformMatrix4fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC __glewProgramUniformMatrix4x2fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC __glewProgramUniformMatrix4x3fvEXT; GLEW_FUN_EXPORT PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC __glewPushClientAttribDefaultEXT; GLEW_FUN_EXPORT PFNGLTEXTUREBUFFEREXTPROC __glewTextureBufferEXT; GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE1DEXTPROC __glewTextureImage1DEXT; GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DEXTPROC __glewTextureImage2DEXT; GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DEXTPROC __glewTextureImage3DEXT; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIIVEXTPROC __glewTextureParameterIivEXT; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIUIVEXTPROC __glewTextureParameterIuivEXT; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFEXTPROC __glewTextureParameterfEXT; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFVEXTPROC __glewTextureParameterfvEXT; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIEXTPROC __glewTextureParameteriEXT; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIVEXTPROC __glewTextureParameterivEXT; GLEW_FUN_EXPORT PFNGLTEXTURERENDERBUFFEREXTPROC __glewTextureRenderbufferEXT; GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE1DEXTPROC __glewTextureSubImage1DEXT; GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE2DEXTPROC __glewTextureSubImage2DEXT; GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE3DEXTPROC __glewTextureSubImage3DEXT; GLEW_FUN_EXPORT PFNGLUNMAPNAMEDBUFFEREXTPROC __glewUnmapNamedBufferEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYCOLOROFFSETEXTPROC __glewVertexArrayColorOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC __glewVertexArrayEdgeFlagOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC __glewVertexArrayFogCoordOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYINDEXOFFSETEXTPROC __glewVertexArrayIndexOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC __glewVertexArrayMultiTexCoordOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYNORMALOFFSETEXTPROC __glewVertexArrayNormalOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC __glewVertexArraySecondaryColorOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC __glewVertexArrayTexCoordOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC __glewVertexArrayVertexAttribDivisorEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC __glewVertexArrayVertexAttribIOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC __glewVertexArrayVertexAttribOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC __glewVertexArrayVertexOffsetEXT; GLEW_FUN_EXPORT PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT; GLEW_FUN_EXPORT PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT; GLEW_FUN_EXPORT PFNGLENABLEINDEXEDEXTPROC __glewEnableIndexedEXT; GLEW_FUN_EXPORT PFNGLGETBOOLEANINDEXEDVEXTPROC __glewGetBooleanIndexedvEXT; GLEW_FUN_EXPORT PFNGLGETINTEGERINDEXEDVEXTPROC __glewGetIntegerIndexedvEXT; GLEW_FUN_EXPORT PFNGLISENABLEDINDEXEDEXTPROC __glewIsEnabledIndexedEXT; GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDEXTPROC __glewDrawArraysInstancedEXT; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDEXTPROC __glewDrawElementsInstancedEXT; GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSEXTPROC __glewDrawRangeElementsEXT; GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTEREXTPROC __glewFogCoordPointerEXT; GLEW_FUN_EXPORT PFNGLFOGCOORDDEXTPROC __glewFogCoorddEXT; GLEW_FUN_EXPORT PFNGLFOGCOORDDVEXTPROC __glewFogCoorddvEXT; GLEW_FUN_EXPORT PFNGLFOGCOORDFEXTPROC __glewFogCoordfEXT; GLEW_FUN_EXPORT PFNGLFOGCOORDFVEXTPROC __glewFogCoordfvEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALEXTPROC __glewFragmentColorMaterialEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFEXTPROC __glewFragmentLightModelfEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVEXTPROC __glewFragmentLightModelfvEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIEXTPROC __glewFragmentLightModeliEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVEXTPROC __glewFragmentLightModelivEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFEXTPROC __glewFragmentLightfEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVEXTPROC __glewFragmentLightfvEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIEXTPROC __glewFragmentLightiEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVEXTPROC __glewFragmentLightivEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFEXTPROC __glewFragmentMaterialfEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVEXTPROC __glewFragmentMaterialfvEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIEXTPROC __glewFragmentMaterialiEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVEXTPROC __glewFragmentMaterialivEXT; GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVEXTPROC __glewGetFragmentLightfvEXT; GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVEXTPROC __glewGetFragmentLightivEXT; GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVEXTPROC __glewGetFragmentMaterialfvEXT; GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVEXTPROC __glewGetFragmentMaterialivEXT; GLEW_FUN_EXPORT PFNGLLIGHTENVIEXTPROC __glewLightEnviEXT; GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFEREXTPROC __glewBlitFramebufferEXT; GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewRenderbufferStorageMultisampleEXT; GLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFEREXTPROC __glewBindFramebufferEXT; GLEW_FUN_EXPORT PFNGLBINDRENDERBUFFEREXTPROC __glewBindRenderbufferEXT; GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC __glewCheckFramebufferStatusEXT; GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSEXTPROC __glewDeleteFramebuffersEXT; GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSEXTPROC __glewDeleteRenderbuffersEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC __glewFramebufferRenderbufferEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DEXTPROC __glewFramebufferTexture1DEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DEXTPROC __glewFramebufferTexture2DEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DEXTPROC __glewFramebufferTexture3DEXT; GLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSEXTPROC __glewGenFramebuffersEXT; GLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSEXTPROC __glewGenRenderbuffersEXT; GLEW_FUN_EXPORT PFNGLGENERATEMIPMAPEXTPROC __glewGenerateMipmapEXT; GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetFramebufferAttachmentParameterivEXT; GLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC __glewGetRenderbufferParameterivEXT; GLEW_FUN_EXPORT PFNGLISFRAMEBUFFEREXTPROC __glewIsFramebufferEXT; GLEW_FUN_EXPORT PFNGLISRENDERBUFFEREXTPROC __glewIsRenderbufferEXT; GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEEXTPROC __glewRenderbufferStorageEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREEXTPROC __glewFramebufferTextureEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC __glewFramebufferTextureFaceEXT; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIEXTPROC __glewProgramParameteriEXT; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERS4FVEXTPROC __glewProgramEnvParameters4fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC __glewProgramLocalParameters4fvEXT; GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONEXTPROC __glewBindFragDataLocationEXT; GLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONEXTPROC __glewGetFragDataLocationEXT; GLEW_FUN_EXPORT PFNGLGETUNIFORMUIVEXTPROC __glewGetUniformuivEXT; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVEXTPROC __glewGetVertexAttribIivEXT; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVEXTPROC __glewGetVertexAttribIuivEXT; GLEW_FUN_EXPORT PFNGLUNIFORM1UIEXTPROC __glewUniform1uiEXT; GLEW_FUN_EXPORT PFNGLUNIFORM1UIVEXTPROC __glewUniform1uivEXT; GLEW_FUN_EXPORT PFNGLUNIFORM2UIEXTPROC __glewUniform2uiEXT; GLEW_FUN_EXPORT PFNGLUNIFORM2UIVEXTPROC __glewUniform2uivEXT; GLEW_FUN_EXPORT PFNGLUNIFORM3UIEXTPROC __glewUniform3uiEXT; GLEW_FUN_EXPORT PFNGLUNIFORM3UIVEXTPROC __glewUniform3uivEXT; GLEW_FUN_EXPORT PFNGLUNIFORM4UIEXTPROC __glewUniform4uiEXT; GLEW_FUN_EXPORT PFNGLUNIFORM4UIVEXTPROC __glewUniform4uivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IEXTPROC __glewVertexAttribI1iEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVEXTPROC __glewVertexAttribI1ivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIEXTPROC __glewVertexAttribI1uiEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVEXTPROC __glewVertexAttribI1uivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IEXTPROC __glewVertexAttribI2iEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVEXTPROC __glewVertexAttribI2ivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIEXTPROC __glewVertexAttribI2uiEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVEXTPROC __glewVertexAttribI2uivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IEXTPROC __glewVertexAttribI3iEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVEXTPROC __glewVertexAttribI3ivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIEXTPROC __glewVertexAttribI3uiEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVEXTPROC __glewVertexAttribI3uivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVEXTPROC __glewVertexAttribI4bvEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IEXTPROC __glewVertexAttribI4iEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVEXTPROC __glewVertexAttribI4ivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVEXTPROC __glewVertexAttribI4svEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVEXTPROC __glewVertexAttribI4ubvEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIEXTPROC __glewVertexAttribI4uiEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVEXTPROC __glewVertexAttribI4uivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVEXTPROC __glewVertexAttribI4usvEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTEREXTPROC __glewVertexAttribIPointerEXT; GLEW_FUN_EXPORT PFNGLGETHISTOGRAMEXTPROC __glewGetHistogramEXT; GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVEXTPROC __glewGetHistogramParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVEXTPROC __glewGetHistogramParameterivEXT; GLEW_FUN_EXPORT PFNGLGETMINMAXEXTPROC __glewGetMinmaxEXT; GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVEXTPROC __glewGetMinmaxParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVEXTPROC __glewGetMinmaxParameterivEXT; GLEW_FUN_EXPORT PFNGLHISTOGRAMEXTPROC __glewHistogramEXT; GLEW_FUN_EXPORT PFNGLMINMAXEXTPROC __glewMinmaxEXT; GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMEXTPROC __glewResetHistogramEXT; GLEW_FUN_EXPORT PFNGLRESETMINMAXEXTPROC __glewResetMinmaxEXT; GLEW_FUN_EXPORT PFNGLINDEXFUNCEXTPROC __glewIndexFuncEXT; GLEW_FUN_EXPORT PFNGLINDEXMATERIALEXTPROC __glewIndexMaterialEXT; GLEW_FUN_EXPORT PFNGLAPPLYTEXTUREEXTPROC __glewApplyTextureEXT; GLEW_FUN_EXPORT PFNGLTEXTURELIGHTEXTPROC __glewTextureLightEXT; GLEW_FUN_EXPORT PFNGLTEXTUREMATERIALEXTPROC __glewTextureMaterialEXT; GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSEXTPROC __glewMultiDrawArraysEXT; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSEXTPROC __glewMultiDrawElementsEXT; GLEW_FUN_EXPORT PFNGLSAMPLEMASKEXTPROC __glewSampleMaskEXT; GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNEXTPROC __glewSamplePatternEXT; GLEW_FUN_EXPORT PFNGLCOLORTABLEEXTPROC __glewColorTableEXT; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEEXTPROC __glewGetColorTableEXT; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVEXTPROC __glewGetColorTableParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVEXTPROC __glewGetColorTableParameterivEXT; GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC __glewGetPixelTransformParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC __glewGetPixelTransformParameterivEXT; GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFEXTPROC __glewPixelTransformParameterfEXT; GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC __glewPixelTransformParameterfvEXT; GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIEXTPROC __glewPixelTransformParameteriEXT; GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC __glewPixelTransformParameterivEXT; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFEXTPROC __glewPointParameterfEXT; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT; GLEW_FUN_EXPORT PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT; GLEW_FUN_EXPORT PFNGLPOLYGONOFFSETCLAMPEXTPROC __glewPolygonOffsetClampEXT; GLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXEXTPROC __glewProvokingVertexEXT; GLEW_FUN_EXPORT PFNGLCOVERAGEMODULATIONNVPROC __glewCoverageModulationNV; GLEW_FUN_EXPORT PFNGLCOVERAGEMODULATIONTABLENVPROC __glewCoverageModulationTableNV; GLEW_FUN_EXPORT PFNGLGETCOVERAGEMODULATIONTABLENVPROC __glewGetCoverageModulationTableNV; GLEW_FUN_EXPORT PFNGLRASTERSAMPLESEXTPROC __glewRasterSamplesEXT; GLEW_FUN_EXPORT PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT; GLEW_FUN_EXPORT PFNGLENDSCENEEXTPROC __glewEndSceneEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BEXTPROC __glewSecondaryColor3bEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVEXTPROC __glewSecondaryColor3bvEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DEXTPROC __glewSecondaryColor3dEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVEXTPROC __glewSecondaryColor3dvEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FEXTPROC __glewSecondaryColor3fEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVEXTPROC __glewSecondaryColor3fvEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IEXTPROC __glewSecondaryColor3iEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVEXTPROC __glewSecondaryColor3ivEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SEXTPROC __glewSecondaryColor3sEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVEXTPROC __glewSecondaryColor3svEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBEXTPROC __glewSecondaryColor3ubEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVEXTPROC __glewSecondaryColor3ubvEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIEXTPROC __glewSecondaryColor3uiEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVEXTPROC __glewSecondaryColor3uivEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT; GLEW_FUN_EXPORT PFNGLACTIVEPROGRAMEXTPROC __glewActiveProgramEXT; GLEW_FUN_EXPORT PFNGLCREATESHADERPROGRAMEXTPROC __glewCreateShaderProgramEXT; GLEW_FUN_EXPORT PFNGLUSESHADERPROGRAMEXTPROC __glewUseShaderProgramEXT; GLEW_FUN_EXPORT PFNGLBINDIMAGETEXTUREEXTPROC __glewBindImageTextureEXT; GLEW_FUN_EXPORT PFNGLMEMORYBARRIEREXTPROC __glewMemoryBarrierEXT; GLEW_FUN_EXPORT PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT; GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT; GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE2DEXTPROC __glewTexSubImage2DEXT; GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DEXTPROC __glewTexSubImage3DEXT; GLEW_FUN_EXPORT PFNGLTEXIMAGE3DEXTPROC __glewTexImage3DEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC __glewFramebufferTextureLayerEXT; GLEW_FUN_EXPORT PFNGLTEXBUFFEREXTPROC __glewTexBufferEXT; GLEW_FUN_EXPORT PFNGLCLEARCOLORIIEXTPROC __glewClearColorIiEXT; GLEW_FUN_EXPORT PFNGLCLEARCOLORIUIEXTPROC __glewClearColorIuiEXT; GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVEXTPROC __glewGetTexParameterIivEXT; GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVEXTPROC __glewGetTexParameterIuivEXT; GLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVEXTPROC __glewTexParameterIivEXT; GLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVEXTPROC __glewTexParameterIuivEXT; GLEW_FUN_EXPORT PFNGLARETEXTURESRESIDENTEXTPROC __glewAreTexturesResidentEXT; GLEW_FUN_EXPORT PFNGLBINDTEXTUREEXTPROC __glewBindTextureEXT; GLEW_FUN_EXPORT PFNGLDELETETEXTURESEXTPROC __glewDeleteTexturesEXT; GLEW_FUN_EXPORT PFNGLGENTEXTURESEXTPROC __glewGenTexturesEXT; GLEW_FUN_EXPORT PFNGLISTEXTUREEXTPROC __glewIsTextureEXT; GLEW_FUN_EXPORT PFNGLPRIORITIZETEXTURESEXTPROC __glewPrioritizeTexturesEXT; GLEW_FUN_EXPORT PFNGLTEXTURENORMALEXTPROC __glewTextureNormalEXT; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VEXTPROC __glewGetQueryObjecti64vEXT; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VEXTPROC __glewGetQueryObjectui64vEXT; GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKEXTPROC __glewBeginTransformFeedbackEXT; GLEW_FUN_EXPORT PFNGLBINDBUFFERBASEEXTPROC __glewBindBufferBaseEXT; GLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETEXTPROC __glewBindBufferOffsetEXT; GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEEXTPROC __glewBindBufferRangeEXT; GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKEXTPROC __glewEndTransformFeedbackEXT; GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC __glewGetTransformFeedbackVaryingEXT; GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC __glewTransformFeedbackVaryingsEXT; GLEW_FUN_EXPORT PFNGLARRAYELEMENTEXTPROC __glewArrayElementEXT; GLEW_FUN_EXPORT PFNGLCOLORPOINTEREXTPROC __glewColorPointerEXT; GLEW_FUN_EXPORT PFNGLDRAWARRAYSEXTPROC __glewDrawArraysEXT; GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTEREXTPROC __glewEdgeFlagPointerEXT; GLEW_FUN_EXPORT PFNGLINDEXPOINTEREXTPROC __glewIndexPointerEXT; GLEW_FUN_EXPORT PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT; GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT; GLEW_FUN_EXPORT PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLDVEXTPROC __glewGetVertexAttribLdvEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC __glewVertexArrayVertexAttribLOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DEXTPROC __glewVertexAttribL1dEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DVEXTPROC __glewVertexAttribL1dvEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DEXTPROC __glewVertexAttribL2dEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DVEXTPROC __glewVertexAttribL2dvEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DEXTPROC __glewVertexAttribL3dEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DVEXTPROC __glewVertexAttribL3dvEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DEXTPROC __glewVertexAttribL4dEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DVEXTPROC __glewVertexAttribL4dvEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBLPOINTEREXTPROC __glewVertexAttribLPointerEXT; GLEW_FUN_EXPORT PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT; GLEW_FUN_EXPORT PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT; GLEW_FUN_EXPORT PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT; GLEW_FUN_EXPORT PFNGLBINDPARAMETEREXTPROC __glewBindParameterEXT; GLEW_FUN_EXPORT PFNGLBINDTEXGENPARAMETEREXTPROC __glewBindTexGenParameterEXT; GLEW_FUN_EXPORT PFNGLBINDTEXTUREUNITPARAMETEREXTPROC __glewBindTextureUnitParameterEXT; GLEW_FUN_EXPORT PFNGLBINDVERTEXSHADEREXTPROC __glewBindVertexShaderEXT; GLEW_FUN_EXPORT PFNGLDELETEVERTEXSHADEREXTPROC __glewDeleteVertexShaderEXT; GLEW_FUN_EXPORT PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC __glewDisableVariantClientStateEXT; GLEW_FUN_EXPORT PFNGLENABLEVARIANTCLIENTSTATEEXTPROC __glewEnableVariantClientStateEXT; GLEW_FUN_EXPORT PFNGLENDVERTEXSHADEREXTPROC __glewEndVertexShaderEXT; GLEW_FUN_EXPORT PFNGLEXTRACTCOMPONENTEXTPROC __glewExtractComponentEXT; GLEW_FUN_EXPORT PFNGLGENSYMBOLSEXTPROC __glewGenSymbolsEXT; GLEW_FUN_EXPORT PFNGLGENVERTEXSHADERSEXTPROC __glewGenVertexShadersEXT; GLEW_FUN_EXPORT PFNGLGETINVARIANTBOOLEANVEXTPROC __glewGetInvariantBooleanvEXT; GLEW_FUN_EXPORT PFNGLGETINVARIANTFLOATVEXTPROC __glewGetInvariantFloatvEXT; GLEW_FUN_EXPORT PFNGLGETINVARIANTINTEGERVEXTPROC __glewGetInvariantIntegervEXT; GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC __glewGetLocalConstantBooleanvEXT; GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTFLOATVEXTPROC __glewGetLocalConstantFloatvEXT; GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTINTEGERVEXTPROC __glewGetLocalConstantIntegervEXT; GLEW_FUN_EXPORT PFNGLGETVARIANTBOOLEANVEXTPROC __glewGetVariantBooleanvEXT; GLEW_FUN_EXPORT PFNGLGETVARIANTFLOATVEXTPROC __glewGetVariantFloatvEXT; GLEW_FUN_EXPORT PFNGLGETVARIANTINTEGERVEXTPROC __glewGetVariantIntegervEXT; GLEW_FUN_EXPORT PFNGLGETVARIANTPOINTERVEXTPROC __glewGetVariantPointervEXT; GLEW_FUN_EXPORT PFNGLINSERTCOMPONENTEXTPROC __glewInsertComponentEXT; GLEW_FUN_EXPORT PFNGLISVARIANTENABLEDEXTPROC __glewIsVariantEnabledEXT; GLEW_FUN_EXPORT PFNGLSETINVARIANTEXTPROC __glewSetInvariantEXT; GLEW_FUN_EXPORT PFNGLSETLOCALCONSTANTEXTPROC __glewSetLocalConstantEXT; GLEW_FUN_EXPORT PFNGLSHADEROP1EXTPROC __glewShaderOp1EXT; GLEW_FUN_EXPORT PFNGLSHADEROP2EXTPROC __glewShaderOp2EXT; GLEW_FUN_EXPORT PFNGLSHADEROP3EXTPROC __glewShaderOp3EXT; GLEW_FUN_EXPORT PFNGLSWIZZLEEXTPROC __glewSwizzleEXT; GLEW_FUN_EXPORT PFNGLVARIANTPOINTEREXTPROC __glewVariantPointerEXT; GLEW_FUN_EXPORT PFNGLVARIANTBVEXTPROC __glewVariantbvEXT; GLEW_FUN_EXPORT PFNGLVARIANTDVEXTPROC __glewVariantdvEXT; GLEW_FUN_EXPORT PFNGLVARIANTFVEXTPROC __glewVariantfvEXT; GLEW_FUN_EXPORT PFNGLVARIANTIVEXTPROC __glewVariantivEXT; GLEW_FUN_EXPORT PFNGLVARIANTSVEXTPROC __glewVariantsvEXT; GLEW_FUN_EXPORT PFNGLVARIANTUBVEXTPROC __glewVariantubvEXT; GLEW_FUN_EXPORT PFNGLVARIANTUIVEXTPROC __glewVariantuivEXT; GLEW_FUN_EXPORT PFNGLVARIANTUSVEXTPROC __glewVariantusvEXT; GLEW_FUN_EXPORT PFNGLWRITEMASKEXTPROC __glewWriteMaskEXT; GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTPOINTEREXTPROC __glewVertexWeightPointerEXT; GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFEXTPROC __glewVertexWeightfEXT; GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFVEXTPROC __glewVertexWeightfvEXT; GLEW_FUN_EXPORT PFNGLIMPORTSYNCEXTPROC __glewImportSyncEXT; GLEW_FUN_EXPORT PFNGLFRAMETERMINATORGREMEDYPROC __glewFrameTerminatorGREMEDY; GLEW_FUN_EXPORT PFNGLSTRINGMARKERGREMEDYPROC __glewStringMarkerGREMEDY; GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC __glewGetImageTransformParameterfvHP; GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC __glewGetImageTransformParameterivHP; GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFHPPROC __glewImageTransformParameterfHP; GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFVHPPROC __glewImageTransformParameterfvHP; GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIHPPROC __glewImageTransformParameteriHP; GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIVHPPROC __glewImageTransformParameterivHP; GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWARRAYSIBMPROC __glewMultiModeDrawArraysIBM; GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWELEMENTSIBMPROC __glewMultiModeDrawElementsIBM; GLEW_FUN_EXPORT PFNGLCOLORPOINTERLISTIBMPROC __glewColorPointerListIBM; GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTERLISTIBMPROC __glewEdgeFlagPointerListIBM; GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERLISTIBMPROC __glewFogCoordPointerListIBM; GLEW_FUN_EXPORT PFNGLINDEXPOINTERLISTIBMPROC __glewIndexPointerListIBM; GLEW_FUN_EXPORT PFNGLNORMALPOINTERLISTIBMPROC __glewNormalPointerListIBM; GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERLISTIBMPROC __glewSecondaryColorPointerListIBM; GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERLISTIBMPROC __glewTexCoordPointerListIBM; GLEW_FUN_EXPORT PFNGLVERTEXPOINTERLISTIBMPROC __glewVertexPointerListIBM; GLEW_FUN_EXPORT PFNGLMAPTEXTURE2DINTELPROC __glewMapTexture2DINTEL; GLEW_FUN_EXPORT PFNGLSYNCTEXTUREINTELPROC __glewSyncTextureINTEL; GLEW_FUN_EXPORT PFNGLUNMAPTEXTURE2DINTELPROC __glewUnmapTexture2DINTEL; GLEW_FUN_EXPORT PFNGLCOLORPOINTERVINTELPROC __glewColorPointervINTEL; GLEW_FUN_EXPORT PFNGLNORMALPOINTERVINTELPROC __glewNormalPointervINTEL; GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERVINTELPROC __glewTexCoordPointervINTEL; GLEW_FUN_EXPORT PFNGLVERTEXPOINTERVINTELPROC __glewVertexPointervINTEL; GLEW_FUN_EXPORT PFNGLBEGINPERFQUERYINTELPROC __glewBeginPerfQueryINTEL; GLEW_FUN_EXPORT PFNGLCREATEPERFQUERYINTELPROC __glewCreatePerfQueryINTEL; GLEW_FUN_EXPORT PFNGLDELETEPERFQUERYINTELPROC __glewDeletePerfQueryINTEL; GLEW_FUN_EXPORT PFNGLENDPERFQUERYINTELPROC __glewEndPerfQueryINTEL; GLEW_FUN_EXPORT PFNGLGETFIRSTPERFQUERYIDINTELPROC __glewGetFirstPerfQueryIdINTEL; GLEW_FUN_EXPORT PFNGLGETNEXTPERFQUERYIDINTELPROC __glewGetNextPerfQueryIdINTEL; GLEW_FUN_EXPORT PFNGLGETPERFCOUNTERINFOINTELPROC __glewGetPerfCounterInfoINTEL; GLEW_FUN_EXPORT PFNGLGETPERFQUERYDATAINTELPROC __glewGetPerfQueryDataINTEL; GLEW_FUN_EXPORT PFNGLGETPERFQUERYIDBYNAMEINTELPROC __glewGetPerfQueryIdByNameINTEL; GLEW_FUN_EXPORT PFNGLGETPERFQUERYINFOINTELPROC __glewGetPerfQueryInfoINTEL; GLEW_FUN_EXPORT PFNGLTEXSCISSORFUNCINTELPROC __glewTexScissorFuncINTEL; GLEW_FUN_EXPORT PFNGLTEXSCISSORINTELPROC __glewTexScissorINTEL; GLEW_FUN_EXPORT PFNGLBLENDBARRIERKHRPROC __glewBlendBarrierKHR; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGECALLBACKPROC __glewDebugMessageCallback; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGECONTROLPROC __glewDebugMessageControl; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGEINSERTPROC __glewDebugMessageInsert; GLEW_FUN_EXPORT PFNGLGETDEBUGMESSAGELOGPROC __glewGetDebugMessageLog; GLEW_FUN_EXPORT PFNGLGETOBJECTLABELPROC __glewGetObjectLabel; GLEW_FUN_EXPORT PFNGLGETOBJECTPTRLABELPROC __glewGetObjectPtrLabel; GLEW_FUN_EXPORT PFNGLOBJECTLABELPROC __glewObjectLabel; GLEW_FUN_EXPORT PFNGLOBJECTPTRLABELPROC __glewObjectPtrLabel; GLEW_FUN_EXPORT PFNGLPOPDEBUGGROUPPROC __glewPopDebugGroup; GLEW_FUN_EXPORT PFNGLPUSHDEBUGGROUPPROC __glewPushDebugGroup; GLEW_FUN_EXPORT PFNGLGETNUNIFORMFVPROC __glewGetnUniformfv; GLEW_FUN_EXPORT PFNGLGETNUNIFORMIVPROC __glewGetnUniformiv; GLEW_FUN_EXPORT PFNGLGETNUNIFORMUIVPROC __glewGetnUniformuiv; GLEW_FUN_EXPORT PFNGLREADNPIXELSPROC __glewReadnPixels; GLEW_FUN_EXPORT PFNGLBUFFERREGIONENABLEDPROC __glewBufferRegionEnabled; GLEW_FUN_EXPORT PFNGLDELETEBUFFERREGIONPROC __glewDeleteBufferRegion; GLEW_FUN_EXPORT PFNGLDRAWBUFFERREGIONPROC __glewDrawBufferRegion; GLEW_FUN_EXPORT PFNGLNEWBUFFERREGIONPROC __glewNewBufferRegion; GLEW_FUN_EXPORT PFNGLREADBUFFERREGIONPROC __glewReadBufferRegion; GLEW_FUN_EXPORT PFNGLRESIZEBUFFERSMESAPROC __glewResizeBuffersMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2DMESAPROC __glewWindowPos2dMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVMESAPROC __glewWindowPos2dvMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2FMESAPROC __glewWindowPos2fMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVMESAPROC __glewWindowPos2fvMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2IMESAPROC __glewWindowPos2iMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVMESAPROC __glewWindowPos2ivMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2SMESAPROC __glewWindowPos2sMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVMESAPROC __glewWindowPos2svMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3DMESAPROC __glewWindowPos3dMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVMESAPROC __glewWindowPos3dvMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3FMESAPROC __glewWindowPos3fMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVMESAPROC __glewWindowPos3fvMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3IMESAPROC __glewWindowPos3iMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVMESAPROC __glewWindowPos3ivMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3SMESAPROC __glewWindowPos3sMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVMESAPROC __glewWindowPos3svMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4DMESAPROC __glewWindowPos4dMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4DVMESAPROC __glewWindowPos4dvMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4FMESAPROC __glewWindowPos4fMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4FVMESAPROC __glewWindowPos4fvMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4IMESAPROC __glewWindowPos4iMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4IVMESAPROC __glewWindowPos4ivMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4SMESAPROC __glewWindowPos4sMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA; GLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERNVXPROC __glewBeginConditionalRenderNVX; GLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERNVXPROC __glewEndConditionalRenderNVX; GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC __glewMultiDrawArraysIndirectBindlessNV; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC __glewMultiDrawElementsIndirectBindlessNV; GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC __glewMultiDrawArraysIndirectBindlessCountNV; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC __glewMultiDrawElementsIndirectBindlessCountNV; GLEW_FUN_EXPORT PFNGLGETIMAGEHANDLENVPROC __glewGetImageHandleNV; GLEW_FUN_EXPORT PFNGLGETTEXTUREHANDLENVPROC __glewGetTextureHandleNV; GLEW_FUN_EXPORT PFNGLGETTEXTURESAMPLERHANDLENVPROC __glewGetTextureSamplerHandleNV; GLEW_FUN_EXPORT PFNGLISIMAGEHANDLERESIDENTNVPROC __glewIsImageHandleResidentNV; GLEW_FUN_EXPORT PFNGLISTEXTUREHANDLERESIDENTNVPROC __glewIsTextureHandleResidentNV; GLEW_FUN_EXPORT PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC __glewMakeImageHandleNonResidentNV; GLEW_FUN_EXPORT PFNGLMAKEIMAGEHANDLERESIDENTNVPROC __glewMakeImageHandleResidentNV; GLEW_FUN_EXPORT PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC __glewMakeTextureHandleNonResidentNV; GLEW_FUN_EXPORT PFNGLMAKETEXTUREHANDLERESIDENTNVPROC __glewMakeTextureHandleResidentNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC __glewProgramUniformHandleui64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC __glewProgramUniformHandleui64vNV; GLEW_FUN_EXPORT PFNGLUNIFORMHANDLEUI64NVPROC __glewUniformHandleui64NV; GLEW_FUN_EXPORT PFNGLUNIFORMHANDLEUI64VNVPROC __glewUniformHandleui64vNV; GLEW_FUN_EXPORT PFNGLBLENDBARRIERNVPROC __glewBlendBarrierNV; GLEW_FUN_EXPORT PFNGLBLENDPARAMETERINVPROC __glewBlendParameteriNV; GLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERNVPROC __glewBeginConditionalRenderNV; GLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERNVPROC __glewEndConditionalRenderNV; GLEW_FUN_EXPORT PFNGLSUBPIXELPRECISIONBIASNVPROC __glewSubpixelPrecisionBiasNV; GLEW_FUN_EXPORT PFNGLCONSERVATIVERASTERPARAMETERFNVPROC __glewConservativeRasterParameterfNV; GLEW_FUN_EXPORT PFNGLCOPYIMAGESUBDATANVPROC __glewCopyImageSubDataNV; GLEW_FUN_EXPORT PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV; GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV; GLEW_FUN_EXPORT PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV; GLEW_FUN_EXPORT PFNGLDRAWTEXTURENVPROC __glewDrawTextureNV; GLEW_FUN_EXPORT PFNGLEVALMAPSNVPROC __glewEvalMapsNV; GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERFVNVPROC __glewGetMapAttribParameterfvNV; GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERIVNVPROC __glewGetMapAttribParameterivNV; GLEW_FUN_EXPORT PFNGLGETMAPCONTROLPOINTSNVPROC __glewGetMapControlPointsNV; GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERFVNVPROC __glewGetMapParameterfvNV; GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERIVNVPROC __glewGetMapParameterivNV; GLEW_FUN_EXPORT PFNGLMAPCONTROLPOINTSNVPROC __glewMapControlPointsNV; GLEW_FUN_EXPORT PFNGLMAPPARAMETERFVNVPROC __glewMapParameterfvNV; GLEW_FUN_EXPORT PFNGLMAPPARAMETERIVNVPROC __glewMapParameterivNV; GLEW_FUN_EXPORT PFNGLGETMULTISAMPLEFVNVPROC __glewGetMultisamplefvNV; GLEW_FUN_EXPORT PFNGLSAMPLEMASKINDEXEDNVPROC __glewSampleMaskIndexedNV; GLEW_FUN_EXPORT PFNGLTEXRENDERBUFFERNVPROC __glewTexRenderbufferNV; GLEW_FUN_EXPORT PFNGLDELETEFENCESNVPROC __glewDeleteFencesNV; GLEW_FUN_EXPORT PFNGLFINISHFENCENVPROC __glewFinishFenceNV; GLEW_FUN_EXPORT PFNGLGENFENCESNVPROC __glewGenFencesNV; GLEW_FUN_EXPORT PFNGLGETFENCEIVNVPROC __glewGetFenceivNV; GLEW_FUN_EXPORT PFNGLISFENCENVPROC __glewIsFenceNV; GLEW_FUN_EXPORT PFNGLSETFENCENVPROC __glewSetFenceNV; GLEW_FUN_EXPORT PFNGLTESTFENCENVPROC __glewTestFenceNV; GLEW_FUN_EXPORT PFNGLFRAGMENTCOVERAGECOLORNVPROC __glewFragmentCoverageColorNV; GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC __glewGetProgramNamedParameterdvNV; GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC __glewGetProgramNamedParameterfvNV; GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DNVPROC __glewProgramNamedParameter4dNV; GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC __glewProgramNamedParameter4dvNV; GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FNVPROC __glewProgramNamedParameter4fNV; GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC __glewProgramNamedParameter4fvNV; GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC __glewRenderbufferStorageMultisampleCoverageNV; GLEW_FUN_EXPORT PFNGLPROGRAMVERTEXLIMITNVPROC __glewProgramVertexLimitNV; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4INVPROC __glewProgramEnvParameterI4iNV; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4IVNVPROC __glewProgramEnvParameterI4ivNV; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UINVPROC __glewProgramEnvParameterI4uiNV; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UIVNVPROC __glewProgramEnvParameterI4uivNV; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4IVNVPROC __glewProgramEnvParametersI4ivNV; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC __glewProgramEnvParametersI4uivNV; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4INVPROC __glewProgramLocalParameterI4iNV; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC __glewProgramLocalParameterI4ivNV; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UINVPROC __glewProgramLocalParameterI4uiNV; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV; GLEW_FUN_EXPORT PFNGLGETUNIFORMI64VNVPROC __glewGetUniformi64vNV; GLEW_FUN_EXPORT PFNGLGETUNIFORMUI64VNVPROC __glewGetUniformui64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64NVPROC __glewProgramUniform1i64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64VNVPROC __glewProgramUniform1i64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64NVPROC __glewProgramUniform1ui64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64VNVPROC __glewProgramUniform1ui64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64NVPROC __glewProgramUniform2i64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64VNVPROC __glewProgramUniform2i64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64NVPROC __glewProgramUniform2ui64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64VNVPROC __glewProgramUniform2ui64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64NVPROC __glewProgramUniform3i64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64VNVPROC __glewProgramUniform3i64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64NVPROC __glewProgramUniform3ui64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64VNVPROC __glewProgramUniform3ui64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64NVPROC __glewProgramUniform4i64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64VNVPROC __glewProgramUniform4i64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64NVPROC __glewProgramUniform4ui64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64VNVPROC __glewProgramUniform4ui64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM1I64NVPROC __glewUniform1i64NV; GLEW_FUN_EXPORT PFNGLUNIFORM1I64VNVPROC __glewUniform1i64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM1UI64NVPROC __glewUniform1ui64NV; GLEW_FUN_EXPORT PFNGLUNIFORM1UI64VNVPROC __glewUniform1ui64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM2I64NVPROC __glewUniform2i64NV; GLEW_FUN_EXPORT PFNGLUNIFORM2I64VNVPROC __glewUniform2i64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM2UI64NVPROC __glewUniform2ui64NV; GLEW_FUN_EXPORT PFNGLUNIFORM2UI64VNVPROC __glewUniform2ui64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM3I64NVPROC __glewUniform3i64NV; GLEW_FUN_EXPORT PFNGLUNIFORM3I64VNVPROC __glewUniform3i64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM3UI64NVPROC __glewUniform3ui64NV; GLEW_FUN_EXPORT PFNGLUNIFORM3UI64VNVPROC __glewUniform3ui64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM4I64NVPROC __glewUniform4i64NV; GLEW_FUN_EXPORT PFNGLUNIFORM4I64VNVPROC __glewUniform4i64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM4UI64NVPROC __glewUniform4ui64NV; GLEW_FUN_EXPORT PFNGLUNIFORM4UI64VNVPROC __glewUniform4ui64vNV; GLEW_FUN_EXPORT PFNGLCOLOR3HNVPROC __glewColor3hNV; GLEW_FUN_EXPORT PFNGLCOLOR3HVNVPROC __glewColor3hvNV; GLEW_FUN_EXPORT PFNGLCOLOR4HNVPROC __glewColor4hNV; GLEW_FUN_EXPORT PFNGLCOLOR4HVNVPROC __glewColor4hvNV; GLEW_FUN_EXPORT PFNGLFOGCOORDHNVPROC __glewFogCoordhNV; GLEW_FUN_EXPORT PFNGLFOGCOORDHVNVPROC __glewFogCoordhvNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HNVPROC __glewMultiTexCoord1hNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HVNVPROC __glewMultiTexCoord1hvNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HNVPROC __glewMultiTexCoord2hNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HVNVPROC __glewMultiTexCoord2hvNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HNVPROC __glewMultiTexCoord3hNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HVNVPROC __glewMultiTexCoord3hvNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HNVPROC __glewMultiTexCoord4hNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HVNVPROC __glewMultiTexCoord4hvNV; GLEW_FUN_EXPORT PFNGLNORMAL3HNVPROC __glewNormal3hNV; GLEW_FUN_EXPORT PFNGLNORMAL3HVNVPROC __glewNormal3hvNV; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HNVPROC __glewSecondaryColor3hNV; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HVNVPROC __glewSecondaryColor3hvNV; GLEW_FUN_EXPORT PFNGLTEXCOORD1HNVPROC __glewTexCoord1hNV; GLEW_FUN_EXPORT PFNGLTEXCOORD1HVNVPROC __glewTexCoord1hvNV; GLEW_FUN_EXPORT PFNGLTEXCOORD2HNVPROC __glewTexCoord2hNV; GLEW_FUN_EXPORT PFNGLTEXCOORD2HVNVPROC __glewTexCoord2hvNV; GLEW_FUN_EXPORT PFNGLTEXCOORD3HNVPROC __glewTexCoord3hNV; GLEW_FUN_EXPORT PFNGLTEXCOORD3HVNVPROC __glewTexCoord3hvNV; GLEW_FUN_EXPORT PFNGLTEXCOORD4HNVPROC __glewTexCoord4hNV; GLEW_FUN_EXPORT PFNGLTEXCOORD4HVNVPROC __glewTexCoord4hvNV; GLEW_FUN_EXPORT PFNGLVERTEX2HNVPROC __glewVertex2hNV; GLEW_FUN_EXPORT PFNGLVERTEX2HVNVPROC __glewVertex2hvNV; GLEW_FUN_EXPORT PFNGLVERTEX3HNVPROC __glewVertex3hNV; GLEW_FUN_EXPORT PFNGLVERTEX3HVNVPROC __glewVertex3hvNV; GLEW_FUN_EXPORT PFNGLVERTEX4HNVPROC __glewVertex4hNV; GLEW_FUN_EXPORT PFNGLVERTEX4HVNVPROC __glewVertex4hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HNVPROC __glewVertexAttrib1hNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HVNVPROC __glewVertexAttrib1hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HNVPROC __glewVertexAttrib2hNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HVNVPROC __glewVertexAttrib2hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HNVPROC __glewVertexAttrib3hNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HVNVPROC __glewVertexAttrib3hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HNVPROC __glewVertexAttrib4hNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HVNVPROC __glewVertexAttrib4hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1HVNVPROC __glewVertexAttribs1hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2HVNVPROC __glewVertexAttribs2hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3HVNVPROC __glewVertexAttribs3hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4HVNVPROC __glewVertexAttribs4hvNV; GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHNVPROC __glewVertexWeighthNV; GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHVNVPROC __glewVertexWeighthvNV; GLEW_FUN_EXPORT PFNGLGETINTERNALFORMATSAMPLEIVNVPROC __glewGetInternalformatSampleivNV; GLEW_FUN_EXPORT PFNGLBEGINOCCLUSIONQUERYNVPROC __glewBeginOcclusionQueryNV; GLEW_FUN_EXPORT PFNGLDELETEOCCLUSIONQUERIESNVPROC __glewDeleteOcclusionQueriesNV; GLEW_FUN_EXPORT PFNGLENDOCCLUSIONQUERYNVPROC __glewEndOcclusionQueryNV; GLEW_FUN_EXPORT PFNGLGENOCCLUSIONQUERIESNVPROC __glewGenOcclusionQueriesNV; GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYIVNVPROC __glewGetOcclusionQueryivNV; GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYUIVNVPROC __glewGetOcclusionQueryuivNV; GLEW_FUN_EXPORT PFNGLISOCCLUSIONQUERYNVPROC __glewIsOcclusionQueryNV; GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC __glewProgramBufferParametersIivNV; GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC __glewProgramBufferParametersIuivNV; GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC __glewProgramBufferParametersfvNV; GLEW_FUN_EXPORT PFNGLCOPYPATHNVPROC __glewCopyPathNV; GLEW_FUN_EXPORT PFNGLCOVERFILLPATHINSTANCEDNVPROC __glewCoverFillPathInstancedNV; GLEW_FUN_EXPORT PFNGLCOVERFILLPATHNVPROC __glewCoverFillPathNV; GLEW_FUN_EXPORT PFNGLCOVERSTROKEPATHINSTANCEDNVPROC __glewCoverStrokePathInstancedNV; GLEW_FUN_EXPORT PFNGLCOVERSTROKEPATHNVPROC __glewCoverStrokePathNV; GLEW_FUN_EXPORT PFNGLDELETEPATHSNVPROC __glewDeletePathsNV; GLEW_FUN_EXPORT PFNGLGENPATHSNVPROC __glewGenPathsNV; GLEW_FUN_EXPORT PFNGLGETPATHCOLORGENFVNVPROC __glewGetPathColorGenfvNV; GLEW_FUN_EXPORT PFNGLGETPATHCOLORGENIVNVPROC __glewGetPathColorGenivNV; GLEW_FUN_EXPORT PFNGLGETPATHCOMMANDSNVPROC __glewGetPathCommandsNV; GLEW_FUN_EXPORT PFNGLGETPATHCOORDSNVPROC __glewGetPathCoordsNV; GLEW_FUN_EXPORT PFNGLGETPATHDASHARRAYNVPROC __glewGetPathDashArrayNV; GLEW_FUN_EXPORT PFNGLGETPATHLENGTHNVPROC __glewGetPathLengthNV; GLEW_FUN_EXPORT PFNGLGETPATHMETRICRANGENVPROC __glewGetPathMetricRangeNV; GLEW_FUN_EXPORT PFNGLGETPATHMETRICSNVPROC __glewGetPathMetricsNV; GLEW_FUN_EXPORT PFNGLGETPATHPARAMETERFVNVPROC __glewGetPathParameterfvNV; GLEW_FUN_EXPORT PFNGLGETPATHPARAMETERIVNVPROC __glewGetPathParameterivNV; GLEW_FUN_EXPORT PFNGLGETPATHSPACINGNVPROC __glewGetPathSpacingNV; GLEW_FUN_EXPORT PFNGLGETPATHTEXGENFVNVPROC __glewGetPathTexGenfvNV; GLEW_FUN_EXPORT PFNGLGETPATHTEXGENIVNVPROC __glewGetPathTexGenivNV; GLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCEFVNVPROC __glewGetProgramResourcefvNV; GLEW_FUN_EXPORT PFNGLINTERPOLATEPATHSNVPROC __glewInterpolatePathsNV; GLEW_FUN_EXPORT PFNGLISPATHNVPROC __glewIsPathNV; GLEW_FUN_EXPORT PFNGLISPOINTINFILLPATHNVPROC __glewIsPointInFillPathNV; GLEW_FUN_EXPORT PFNGLISPOINTINSTROKEPATHNVPROC __glewIsPointInStrokePathNV; GLEW_FUN_EXPORT PFNGLMATRIXLOAD3X2FNVPROC __glewMatrixLoad3x2fNV; GLEW_FUN_EXPORT PFNGLMATRIXLOAD3X3FNVPROC __glewMatrixLoad3x3fNV; GLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC __glewMatrixLoadTranspose3x3fNV; GLEW_FUN_EXPORT PFNGLMATRIXMULT3X2FNVPROC __glewMatrixMult3x2fNV; GLEW_FUN_EXPORT PFNGLMATRIXMULT3X3FNVPROC __glewMatrixMult3x3fNV; GLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC __glewMatrixMultTranspose3x3fNV; GLEW_FUN_EXPORT PFNGLPATHCOLORGENNVPROC __glewPathColorGenNV; GLEW_FUN_EXPORT PFNGLPATHCOMMANDSNVPROC __glewPathCommandsNV; GLEW_FUN_EXPORT PFNGLPATHCOORDSNVPROC __glewPathCoordsNV; GLEW_FUN_EXPORT PFNGLPATHCOVERDEPTHFUNCNVPROC __glewPathCoverDepthFuncNV; GLEW_FUN_EXPORT PFNGLPATHDASHARRAYNVPROC __glewPathDashArrayNV; GLEW_FUN_EXPORT PFNGLPATHFOGGENNVPROC __glewPathFogGenNV; GLEW_FUN_EXPORT PFNGLPATHGLYPHINDEXARRAYNVPROC __glewPathGlyphIndexArrayNV; GLEW_FUN_EXPORT PFNGLPATHGLYPHINDEXRANGENVPROC __glewPathGlyphIndexRangeNV; GLEW_FUN_EXPORT PFNGLPATHGLYPHRANGENVPROC __glewPathGlyphRangeNV; GLEW_FUN_EXPORT PFNGLPATHGLYPHSNVPROC __glewPathGlyphsNV; GLEW_FUN_EXPORT PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC __glewPathMemoryGlyphIndexArrayNV; GLEW_FUN_EXPORT PFNGLPATHPARAMETERFNVPROC __glewPathParameterfNV; GLEW_FUN_EXPORT PFNGLPATHPARAMETERFVNVPROC __glewPathParameterfvNV; GLEW_FUN_EXPORT PFNGLPATHPARAMETERINVPROC __glewPathParameteriNV; GLEW_FUN_EXPORT PFNGLPATHPARAMETERIVNVPROC __glewPathParameterivNV; GLEW_FUN_EXPORT PFNGLPATHSTENCILDEPTHOFFSETNVPROC __glewPathStencilDepthOffsetNV; GLEW_FUN_EXPORT PFNGLPATHSTENCILFUNCNVPROC __glewPathStencilFuncNV; GLEW_FUN_EXPORT PFNGLPATHSTRINGNVPROC __glewPathStringNV; GLEW_FUN_EXPORT PFNGLPATHSUBCOMMANDSNVPROC __glewPathSubCommandsNV; GLEW_FUN_EXPORT PFNGLPATHSUBCOORDSNVPROC __glewPathSubCoordsNV; GLEW_FUN_EXPORT PFNGLPATHTEXGENNVPROC __glewPathTexGenNV; GLEW_FUN_EXPORT PFNGLPOINTALONGPATHNVPROC __glewPointAlongPathNV; GLEW_FUN_EXPORT PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC __glewProgramPathFragmentInputGenNV; GLEW_FUN_EXPORT PFNGLSTENCILFILLPATHINSTANCEDNVPROC __glewStencilFillPathInstancedNV; GLEW_FUN_EXPORT PFNGLSTENCILFILLPATHNVPROC __glewStencilFillPathNV; GLEW_FUN_EXPORT PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC __glewStencilStrokePathInstancedNV; GLEW_FUN_EXPORT PFNGLSTENCILSTROKEPATHNVPROC __glewStencilStrokePathNV; GLEW_FUN_EXPORT PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC __glewStencilThenCoverFillPathInstancedNV; GLEW_FUN_EXPORT PFNGLSTENCILTHENCOVERFILLPATHNVPROC __glewStencilThenCoverFillPathNV; GLEW_FUN_EXPORT PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC __glewStencilThenCoverStrokePathInstancedNV; GLEW_FUN_EXPORT PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC __glewStencilThenCoverStrokePathNV; GLEW_FUN_EXPORT PFNGLTRANSFORMPATHNVPROC __glewTransformPathNV; GLEW_FUN_EXPORT PFNGLWEIGHTPATHSNVPROC __glewWeightPathsNV; GLEW_FUN_EXPORT PFNGLFLUSHPIXELDATARANGENVPROC __glewFlushPixelDataRangeNV; GLEW_FUN_EXPORT PFNGLPIXELDATARANGENVPROC __glewPixelDataRangeNV; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERINVPROC __glewPointParameteriNV; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVNVPROC __glewPointParameterivNV; GLEW_FUN_EXPORT PFNGLGETVIDEOI64VNVPROC __glewGetVideoi64vNV; GLEW_FUN_EXPORT PFNGLGETVIDEOIVNVPROC __glewGetVideoivNV; GLEW_FUN_EXPORT PFNGLGETVIDEOUI64VNVPROC __glewGetVideoui64vNV; GLEW_FUN_EXPORT PFNGLGETVIDEOUIVNVPROC __glewGetVideouivNV; GLEW_FUN_EXPORT PFNGLPRESENTFRAMEDUALFILLNVPROC __glewPresentFrameDualFillNV; GLEW_FUN_EXPORT PFNGLPRESENTFRAMEKEYEDNVPROC __glewPresentFrameKeyedNV; GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV; GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV; GLEW_FUN_EXPORT PFNGLCOMBINERINPUTNVPROC __glewCombinerInputNV; GLEW_FUN_EXPORT PFNGLCOMBINEROUTPUTNVPROC __glewCombinerOutputNV; GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFNVPROC __glewCombinerParameterfNV; GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFVNVPROC __glewCombinerParameterfvNV; GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERINVPROC __glewCombinerParameteriNV; GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERIVNVPROC __glewCombinerParameterivNV; GLEW_FUN_EXPORT PFNGLFINALCOMBINERINPUTNVPROC __glewFinalCombinerInputNV; GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC __glewGetCombinerInputParameterfvNV; GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC __glewGetCombinerInputParameterivNV; GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC __glewGetCombinerOutputParameterfvNV; GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC __glewGetCombinerOutputParameterivNV; GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC __glewGetFinalCombinerInputParameterfvNV; GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameterivNV; GLEW_FUN_EXPORT PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV; GLEW_FUN_EXPORT PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC __glewFramebufferSampleLocationsfvNV; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC __glewNamedFramebufferSampleLocationsfvNV; GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERUI64VNVPROC __glewGetBufferParameterui64vNV; GLEW_FUN_EXPORT PFNGLGETINTEGERUI64VNVPROC __glewGetIntegerui64vNV; GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC __glewGetNamedBufferParameterui64vNV; GLEW_FUN_EXPORT PFNGLISBUFFERRESIDENTNVPROC __glewIsBufferResidentNV; GLEW_FUN_EXPORT PFNGLISNAMEDBUFFERRESIDENTNVPROC __glewIsNamedBufferResidentNV; GLEW_FUN_EXPORT PFNGLMAKEBUFFERNONRESIDENTNVPROC __glewMakeBufferNonResidentNV; GLEW_FUN_EXPORT PFNGLMAKEBUFFERRESIDENTNVPROC __glewMakeBufferResidentNV; GLEW_FUN_EXPORT PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC __glewMakeNamedBufferNonResidentNV; GLEW_FUN_EXPORT PFNGLMAKENAMEDBUFFERRESIDENTNVPROC __glewMakeNamedBufferResidentNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMUI64NVPROC __glewProgramUniformui64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMUI64VNVPROC __glewProgramUniformui64vNV; GLEW_FUN_EXPORT PFNGLUNIFORMUI64NVPROC __glewUniformui64NV; GLEW_FUN_EXPORT PFNGLUNIFORMUI64VNVPROC __glewUniformui64vNV; GLEW_FUN_EXPORT PFNGLTEXTUREBARRIERNVPROC __glewTextureBarrierNV; GLEW_FUN_EXPORT PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC __glewTexImage2DMultisampleCoverageNV; GLEW_FUN_EXPORT PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC __glewTexImage3DMultisampleCoverageNV; GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC __glewTextureImage2DMultisampleCoverageNV; GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC __glewTextureImage2DMultisampleNV; GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC __glewTextureImage3DMultisampleCoverageNV; GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC __glewTextureImage3DMultisampleNV; GLEW_FUN_EXPORT PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV; GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV; GLEW_FUN_EXPORT PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV; GLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETNVPROC __glewBindBufferOffsetNV; GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGENVPROC __glewBindBufferRangeNV; GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKNVPROC __glewEndTransformFeedbackNV; GLEW_FUN_EXPORT PFNGLGETACTIVEVARYINGNVPROC __glewGetActiveVaryingNV; GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC __glewGetTransformFeedbackVaryingNV; GLEW_FUN_EXPORT PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV; GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV; GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV; GLEW_FUN_EXPORT PFNGLBINDTRANSFORMFEEDBACKNVPROC __glewBindTransformFeedbackNV; GLEW_FUN_EXPORT PFNGLDELETETRANSFORMFEEDBACKSNVPROC __glewDeleteTransformFeedbacksNV; GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKNVPROC __glewDrawTransformFeedbackNV; GLEW_FUN_EXPORT PFNGLGENTRANSFORMFEEDBACKSNVPROC __glewGenTransformFeedbacksNV; GLEW_FUN_EXPORT PFNGLISTRANSFORMFEEDBACKNVPROC __glewIsTransformFeedbackNV; GLEW_FUN_EXPORT PFNGLPAUSETRANSFORMFEEDBACKNVPROC __glewPauseTransformFeedbackNV; GLEW_FUN_EXPORT PFNGLRESUMETRANSFORMFEEDBACKNVPROC __glewResumeTransformFeedbackNV; GLEW_FUN_EXPORT PFNGLVDPAUFININVPROC __glewVDPAUFiniNV; GLEW_FUN_EXPORT PFNGLVDPAUGETSURFACEIVNVPROC __glewVDPAUGetSurfaceivNV; GLEW_FUN_EXPORT PFNGLVDPAUINITNVPROC __glewVDPAUInitNV; GLEW_FUN_EXPORT PFNGLVDPAUISSURFACENVPROC __glewVDPAUIsSurfaceNV; GLEW_FUN_EXPORT PFNGLVDPAUMAPSURFACESNVPROC __glewVDPAUMapSurfacesNV; GLEW_FUN_EXPORT PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC __glewVDPAURegisterOutputSurfaceNV; GLEW_FUN_EXPORT PFNGLVDPAUREGISTERVIDEOSURFACENVPROC __glewVDPAURegisterVideoSurfaceNV; GLEW_FUN_EXPORT PFNGLVDPAUSURFACEACCESSNVPROC __glewVDPAUSurfaceAccessNV; GLEW_FUN_EXPORT PFNGLVDPAUUNMAPSURFACESNVPROC __glewVDPAUUnmapSurfacesNV; GLEW_FUN_EXPORT PFNGLVDPAUUNREGISTERSURFACENVPROC __glewVDPAUUnregisterSurfaceNV; GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV; GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLI64VNVPROC __glewGetVertexAttribLi64vNV; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLUI64VNVPROC __glewGetVertexAttribLui64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1I64NVPROC __glewVertexAttribL1i64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1I64VNVPROC __glewVertexAttribL1i64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64NVPROC __glewVertexAttribL1ui64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64VNVPROC __glewVertexAttribL1ui64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2I64NVPROC __glewVertexAttribL2i64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2I64VNVPROC __glewVertexAttribL2i64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2UI64NVPROC __glewVertexAttribL2ui64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2UI64VNVPROC __glewVertexAttribL2ui64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3I64NVPROC __glewVertexAttribL3i64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3I64VNVPROC __glewVertexAttribL3i64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3UI64NVPROC __glewVertexAttribL3ui64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3UI64VNVPROC __glewVertexAttribL3ui64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4I64NVPROC __glewVertexAttribL4i64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4I64VNVPROC __glewVertexAttribL4i64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4UI64NVPROC __glewVertexAttribL4ui64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4UI64VNVPROC __glewVertexAttribL4ui64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBLFORMATNVPROC __glewVertexAttribLFormatNV; GLEW_FUN_EXPORT PFNGLBUFFERADDRESSRANGENVPROC __glewBufferAddressRangeNV; GLEW_FUN_EXPORT PFNGLCOLORFORMATNVPROC __glewColorFormatNV; GLEW_FUN_EXPORT PFNGLEDGEFLAGFORMATNVPROC __glewEdgeFlagFormatNV; GLEW_FUN_EXPORT PFNGLFOGCOORDFORMATNVPROC __glewFogCoordFormatNV; GLEW_FUN_EXPORT PFNGLGETINTEGERUI64I_VNVPROC __glewGetIntegerui64i_vNV; GLEW_FUN_EXPORT PFNGLINDEXFORMATNVPROC __glewIndexFormatNV; GLEW_FUN_EXPORT PFNGLNORMALFORMATNVPROC __glewNormalFormatNV; GLEW_FUN_EXPORT PFNGLSECONDARYCOLORFORMATNVPROC __glewSecondaryColorFormatNV; GLEW_FUN_EXPORT PFNGLTEXCOORDFORMATNVPROC __glewTexCoordFormatNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBFORMATNVPROC __glewVertexAttribFormatNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIFORMATNVPROC __glewVertexAttribIFormatNV; GLEW_FUN_EXPORT PFNGLVERTEXFORMATNVPROC __glewVertexFormatNV; GLEW_FUN_EXPORT PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV; GLEW_FUN_EXPORT PFNGLBINDPROGRAMNVPROC __glewBindProgramNV; GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV; GLEW_FUN_EXPORT PFNGLEXECUTEPROGRAMNVPROC __glewExecuteProgramNV; GLEW_FUN_EXPORT PFNGLGENPROGRAMSNVPROC __glewGenProgramsNV; GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERDVNVPROC __glewGetProgramParameterdvNV; GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERFVNVPROC __glewGetProgramParameterfvNV; GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGNVPROC __glewGetProgramStringNV; GLEW_FUN_EXPORT PFNGLGETPROGRAMIVNVPROC __glewGetProgramivNV; GLEW_FUN_EXPORT PFNGLGETTRACKMATRIXIVNVPROC __glewGetTrackMatrixivNV; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVNVPROC __glewGetVertexAttribPointervNV; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVNVPROC __glewGetVertexAttribdvNV; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVNVPROC __glewGetVertexAttribfvNV; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVNVPROC __glewGetVertexAttribivNV; GLEW_FUN_EXPORT PFNGLISPROGRAMNVPROC __glewIsProgramNV; GLEW_FUN_EXPORT PFNGLLOADPROGRAMNVPROC __glewLoadProgramNV; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DNVPROC __glewProgramParameter4dNV; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DVNVPROC __glewProgramParameter4dvNV; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FNVPROC __glewProgramParameter4fNV; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FVNVPROC __glewProgramParameter4fvNV; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4DVNVPROC __glewProgramParameters4dvNV; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4FVNVPROC __glewProgramParameters4fvNV; GLEW_FUN_EXPORT PFNGLREQUESTRESIDENTPROGRAMSNVPROC __glewRequestResidentProgramsNV; GLEW_FUN_EXPORT PFNGLTRACKMATRIXNVPROC __glewTrackMatrixNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DNVPROC __glewVertexAttrib1dNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVNVPROC __glewVertexAttrib1dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FNVPROC __glewVertexAttrib1fNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVNVPROC __glewVertexAttrib1fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SNVPROC __glewVertexAttrib1sNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVNVPROC __glewVertexAttrib1svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DNVPROC __glewVertexAttrib2dNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVNVPROC __glewVertexAttrib2dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FNVPROC __glewVertexAttrib2fNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVNVPROC __glewVertexAttrib2fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SNVPROC __glewVertexAttrib2sNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVNVPROC __glewVertexAttrib2svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DNVPROC __glewVertexAttrib3dNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVNVPROC __glewVertexAttrib3dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVNVPROC __glewVertexAttrib3fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SNVPROC __glewVertexAttrib3sNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVNVPROC __glewVertexAttrib3svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DNVPROC __glewVertexAttrib4dNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVNVPROC __glewVertexAttrib4dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FNVPROC __glewVertexAttrib4fNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVNVPROC __glewVertexAttrib4fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SNVPROC __glewVertexAttrib4sNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVNVPROC __glewVertexAttrib4svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBNVPROC __glewVertexAttrib4ubNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVNVPROC __glewVertexAttrib4ubvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERNVPROC __glewVertexAttribPointerNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1DVNVPROC __glewVertexAttribs1dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1FVNVPROC __glewVertexAttribs1fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1SVNVPROC __glewVertexAttribs1svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2DVNVPROC __glewVertexAttribs2dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2FVNVPROC __glewVertexAttribs2fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2SVNVPROC __glewVertexAttribs2svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3DVNVPROC __glewVertexAttribs3dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3FVNVPROC __glewVertexAttribs3fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3SVNVPROC __glewVertexAttribs3svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4DVNVPROC __glewVertexAttribs4dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4FVNVPROC __glewVertexAttribs4fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4SVNVPROC __glewVertexAttribs4svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4UBVNVPROC __glewVertexAttribs4ubvNV; GLEW_FUN_EXPORT PFNGLBEGINVIDEOCAPTURENVPROC __glewBeginVideoCaptureNV; GLEW_FUN_EXPORT PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC __glewBindVideoCaptureStreamBufferNV; GLEW_FUN_EXPORT PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC __glewBindVideoCaptureStreamTextureNV; GLEW_FUN_EXPORT PFNGLENDVIDEOCAPTURENVPROC __glewEndVideoCaptureNV; GLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMDVNVPROC __glewGetVideoCaptureStreamdvNV; GLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMFVNVPROC __glewGetVideoCaptureStreamfvNV; GLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMIVNVPROC __glewGetVideoCaptureStreamivNV; GLEW_FUN_EXPORT PFNGLGETVIDEOCAPTUREIVNVPROC __glewGetVideoCaptureivNV; GLEW_FUN_EXPORT PFNGLVIDEOCAPTURENVPROC __glewVideoCaptureNV; GLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC __glewVideoCaptureStreamParameterdvNV; GLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC __glewVideoCaptureStreamParameterfvNV; GLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC __glewVideoCaptureStreamParameterivNV; GLEW_FUN_EXPORT PFNGLCLEARDEPTHFOESPROC __glewClearDepthfOES; GLEW_FUN_EXPORT PFNGLCLIPPLANEFOESPROC __glewClipPlanefOES; GLEW_FUN_EXPORT PFNGLDEPTHRANGEFOESPROC __glewDepthRangefOES; GLEW_FUN_EXPORT PFNGLFRUSTUMFOESPROC __glewFrustumfOES; GLEW_FUN_EXPORT PFNGLGETCLIPPLANEFOESPROC __glewGetClipPlanefOES; GLEW_FUN_EXPORT PFNGLORTHOFOESPROC __glewOrthofOES; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC __glewFramebufferTextureMultiviewOVR; GLEW_FUN_EXPORT PFNGLALPHAFUNCXPROC __glewAlphaFuncx; GLEW_FUN_EXPORT PFNGLCLEARCOLORXPROC __glewClearColorx; GLEW_FUN_EXPORT PFNGLCLEARDEPTHXPROC __glewClearDepthx; GLEW_FUN_EXPORT PFNGLCOLOR4XPROC __glewColor4x; GLEW_FUN_EXPORT PFNGLDEPTHRANGEXPROC __glewDepthRangex; GLEW_FUN_EXPORT PFNGLFOGXPROC __glewFogx; GLEW_FUN_EXPORT PFNGLFOGXVPROC __glewFogxv; GLEW_FUN_EXPORT PFNGLFRUSTUMFPROC __glewFrustumf; GLEW_FUN_EXPORT PFNGLFRUSTUMXPROC __glewFrustumx; GLEW_FUN_EXPORT PFNGLLIGHTMODELXPROC __glewLightModelx; GLEW_FUN_EXPORT PFNGLLIGHTMODELXVPROC __glewLightModelxv; GLEW_FUN_EXPORT PFNGLLIGHTXPROC __glewLightx; GLEW_FUN_EXPORT PFNGLLIGHTXVPROC __glewLightxv; GLEW_FUN_EXPORT PFNGLLINEWIDTHXPROC __glewLineWidthx; GLEW_FUN_EXPORT PFNGLLOADMATRIXXPROC __glewLoadMatrixx; GLEW_FUN_EXPORT PFNGLMATERIALXPROC __glewMaterialx; GLEW_FUN_EXPORT PFNGLMATERIALXVPROC __glewMaterialxv; GLEW_FUN_EXPORT PFNGLMULTMATRIXXPROC __glewMultMatrixx; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4XPROC __glewMultiTexCoord4x; GLEW_FUN_EXPORT PFNGLNORMAL3XPROC __glewNormal3x; GLEW_FUN_EXPORT PFNGLORTHOFPROC __glewOrthof; GLEW_FUN_EXPORT PFNGLORTHOXPROC __glewOrthox; GLEW_FUN_EXPORT PFNGLPOINTSIZEXPROC __glewPointSizex; GLEW_FUN_EXPORT PFNGLPOLYGONOFFSETXPROC __glewPolygonOffsetx; GLEW_FUN_EXPORT PFNGLROTATEXPROC __glewRotatex; GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEXPROC __glewSampleCoveragex; GLEW_FUN_EXPORT PFNGLSCALEXPROC __glewScalex; GLEW_FUN_EXPORT PFNGLTEXENVXPROC __glewTexEnvx; GLEW_FUN_EXPORT PFNGLTEXENVXVPROC __glewTexEnvxv; GLEW_FUN_EXPORT PFNGLTEXPARAMETERXPROC __glewTexParameterx; GLEW_FUN_EXPORT PFNGLTRANSLATEXPROC __glewTranslatex; GLEW_FUN_EXPORT PFNGLCLIPPLANEFPROC __glewClipPlanef; GLEW_FUN_EXPORT PFNGLCLIPPLANEXPROC __glewClipPlanex; GLEW_FUN_EXPORT PFNGLGETCLIPPLANEFPROC __glewGetClipPlanef; GLEW_FUN_EXPORT PFNGLGETCLIPPLANEXPROC __glewGetClipPlanex; GLEW_FUN_EXPORT PFNGLGETFIXEDVPROC __glewGetFixedv; GLEW_FUN_EXPORT PFNGLGETLIGHTXVPROC __glewGetLightxv; GLEW_FUN_EXPORT PFNGLGETMATERIALXVPROC __glewGetMaterialxv; GLEW_FUN_EXPORT PFNGLGETTEXENVXVPROC __glewGetTexEnvxv; GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERXVPROC __glewGetTexParameterxv; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERXPROC __glewPointParameterx; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERXVPROC __glewPointParameterxv; GLEW_FUN_EXPORT PFNGLPOINTSIZEPOINTEROESPROC __glewPointSizePointerOES; GLEW_FUN_EXPORT PFNGLTEXPARAMETERXVPROC __glewTexParameterxv; GLEW_FUN_EXPORT PFNGLERRORSTRINGREGALPROC __glewErrorStringREGAL; GLEW_FUN_EXPORT PFNGLGETEXTENSIONREGALPROC __glewGetExtensionREGAL; GLEW_FUN_EXPORT PFNGLISSUPPORTEDREGALPROC __glewIsSupportedREGAL; GLEW_FUN_EXPORT PFNGLLOGMESSAGECALLBACKREGALPROC __glewLogMessageCallbackREGAL; GLEW_FUN_EXPORT PFNGLGETPROCADDRESSREGALPROC __glewGetProcAddressREGAL; GLEW_FUN_EXPORT PFNGLDETAILTEXFUNCSGISPROC __glewDetailTexFuncSGIS; GLEW_FUN_EXPORT PFNGLGETDETAILTEXFUNCSGISPROC __glewGetDetailTexFuncSGIS; GLEW_FUN_EXPORT PFNGLFOGFUNCSGISPROC __glewFogFuncSGIS; GLEW_FUN_EXPORT PFNGLGETFOGFUNCSGISPROC __glewGetFogFuncSGIS; GLEW_FUN_EXPORT PFNGLSAMPLEMASKSGISPROC __glewSampleMaskSGIS; GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNSGISPROC __glewSamplePatternSGIS; GLEW_FUN_EXPORT PFNGLGETSHARPENTEXFUNCSGISPROC __glewGetSharpenTexFuncSGIS; GLEW_FUN_EXPORT PFNGLSHARPENTEXFUNCSGISPROC __glewSharpenTexFuncSGIS; GLEW_FUN_EXPORT PFNGLTEXIMAGE4DSGISPROC __glewTexImage4DSGIS; GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE4DSGISPROC __glewTexSubImage4DSGIS; GLEW_FUN_EXPORT PFNGLGETTEXFILTERFUNCSGISPROC __glewGetTexFilterFuncSGIS; GLEW_FUN_EXPORT PFNGLTEXFILTERFUNCSGISPROC __glewTexFilterFuncSGIS; GLEW_FUN_EXPORT PFNGLASYNCMARKERSGIXPROC __glewAsyncMarkerSGIX; GLEW_FUN_EXPORT PFNGLDELETEASYNCMARKERSSGIXPROC __glewDeleteAsyncMarkersSGIX; GLEW_FUN_EXPORT PFNGLFINISHASYNCSGIXPROC __glewFinishAsyncSGIX; GLEW_FUN_EXPORT PFNGLGENASYNCMARKERSSGIXPROC __glewGenAsyncMarkersSGIX; GLEW_FUN_EXPORT PFNGLISASYNCMARKERSGIXPROC __glewIsAsyncMarkerSGIX; GLEW_FUN_EXPORT PFNGLPOLLASYNCSGIXPROC __glewPollAsyncSGIX; GLEW_FUN_EXPORT PFNGLFLUSHRASTERSGIXPROC __glewFlushRasterSGIX; GLEW_FUN_EXPORT PFNGLTEXTUREFOGSGIXPROC __glewTextureFogSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALSGIXPROC __glewFragmentColorMaterialSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFSGIXPROC __glewFragmentLightModelfSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVSGIXPROC __glewFragmentLightModelfvSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELISGIXPROC __glewFragmentLightModeliSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVSGIXPROC __glewFragmentLightModelivSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFSGIXPROC __glewFragmentLightfSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVSGIXPROC __glewFragmentLightfvSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTISGIXPROC __glewFragmentLightiSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVSGIXPROC __glewFragmentLightivSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFSGIXPROC __glewFragmentMaterialfSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVSGIXPROC __glewFragmentMaterialfvSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALISGIXPROC __glewFragmentMaterialiSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVSGIXPROC __glewFragmentMaterialivSGIX; GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVSGIXPROC __glewGetFragmentLightfvSGIX; GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVSGIXPROC __glewGetFragmentLightivSGIX; GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVSGIXPROC __glewGetFragmentMaterialfvSGIX; GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVSGIXPROC __glewGetFragmentMaterialivSGIX; GLEW_FUN_EXPORT PFNGLFRAMEZOOMSGIXPROC __glewFrameZoomSGIX; GLEW_FUN_EXPORT PFNGLPIXELTEXGENSGIXPROC __glewPixelTexGenSGIX; GLEW_FUN_EXPORT PFNGLREFERENCEPLANESGIXPROC __glewReferencePlaneSGIX; GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFSGIXPROC __glewSpriteParameterfSGIX; GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFVSGIXPROC __glewSpriteParameterfvSGIX; GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERISGIXPROC __glewSpriteParameteriSGIX; GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERIVSGIXPROC __glewSpriteParameterivSGIX; GLEW_FUN_EXPORT PFNGLTAGSAMPLEBUFFERSGIXPROC __glewTagSampleBufferSGIX; GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVSGIPROC __glewColorTableParameterfvSGI; GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVSGIPROC __glewColorTableParameterivSGI; GLEW_FUN_EXPORT PFNGLCOLORTABLESGIPROC __glewColorTableSGI; GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLESGIPROC __glewCopyColorTableSGI; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVSGIPROC __glewGetColorTableParameterfvSGI; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVSGIPROC __glewGetColorTableParameterivSGI; GLEW_FUN_EXPORT PFNGLGETCOLORTABLESGIPROC __glewGetColorTableSGI; GLEW_FUN_EXPORT PFNGLFINISHTEXTURESUNXPROC __glewFinishTextureSUNX; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORBSUNPROC __glewGlobalAlphaFactorbSUN; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORDSUNPROC __glewGlobalAlphaFactordSUN; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORFSUNPROC __glewGlobalAlphaFactorfSUN; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORISUNPROC __glewGlobalAlphaFactoriSUN; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORSSUNPROC __glewGlobalAlphaFactorsSUN; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUBSUNPROC __glewGlobalAlphaFactorubSUN; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUISUNPROC __glewGlobalAlphaFactoruiSUN; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUSSUNPROC __glewGlobalAlphaFactorusSUN; GLEW_FUN_EXPORT PFNGLREADVIDEOPIXELSSUNPROC __glewReadVideoPixelsSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEPOINTERSUNPROC __glewReplacementCodePointerSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBSUNPROC __glewReplacementCodeubSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBVSUNPROC __glewReplacementCodeubvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUISUNPROC __glewReplacementCodeuiSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVSUNPROC __glewReplacementCodeuivSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSSUNPROC __glewReplacementCodeusSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSVSUNPROC __glewReplacementCodeusvSUN; GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FSUNPROC __glewColor3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FVSUNPROC __glewColor3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewColor4fNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewColor4fNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FSUNPROC __glewColor4ubVertex2fSUN; GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FVSUNPROC __glewColor4ubVertex2fvSUN; GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FSUNPROC __glewColor4ubVertex3fSUN; GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FVSUNPROC __glewColor4ubVertex3fvSUN; GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FSUNPROC __glewNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FVSUNPROC __glewNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC __glewReplacementCodeuiColor3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC __glewReplacementCodeuiColor4ubVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC __glewReplacementCodeuiColor4ubVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC __glewReplacementCodeuiVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC __glewReplacementCodeuiVertex3fvSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC __glewTexCoord2fColor3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC __glewTexCoord2fColor3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC __glewTexCoord2fColor4ubVertex3fSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC __glewTexCoord2fColor4ubVertex3fvSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FSUNPROC __glewTexCoord2fVertex3fSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FVSUNPROC __glewTexCoord2fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fvSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FSUNPROC __glewTexCoord4fVertex4fSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FVSUNPROC __glewTexCoord4fVertex4fvSUN; GLEW_FUN_EXPORT PFNGLADDSWAPHINTRECTWINPROC __glewAddSwapHintRectWIN; #if defined(GLEW_MX) && !defined(_WIN32) struct GLEWContextStruct { #endif /* GLEW_MX */ GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_1; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2_1; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_3; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_4; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_5; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_0; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_1; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_0; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_1; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_2; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_3; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_0; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_1; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_2; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_3; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_4; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_5; GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_tbuffer; GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_texture_compression_FXT1; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_blend_minmax_factor; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_conservative_depth; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_debug_output; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_depth_clamp_separate; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_draw_buffers_blend; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_gcn_shader; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_gpu_shader_int64; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_interleaved_elements; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_multi_draw_indirect; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_name_gen_delete; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_occlusion_query_event; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_performance_monitor; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_pinned_memory; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_query_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_sample_positions; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_seamless_cubemap_per_texture; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_atomic_counter_ops; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_stencil_export; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_stencil_value_export; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_trinary_minmax; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_sparse_texture; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_stencil_operation_extended; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_texture_texture4; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_transform_feedback3_lines_triangles; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_transform_feedback4; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_layer; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_tessellator; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_viewport_index; GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_depth_texture; GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_framebuffer_blit; GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_framebuffer_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_instanced_arrays; GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_pack_reverse_row_order; GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_program_binary; GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_texture_compression_dxt1; GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_texture_compression_dxt3; GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_texture_compression_dxt5; GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_texture_usage; GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_timer_query; GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_translated_shader_source; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_aux_depth_stencil; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_client_storage; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_element_array; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_fence; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_float_pixels; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_flush_buffer_range; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_object_purgeable; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_pixel_buffer; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_rgb_422; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_row_bytes; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_specular_vector; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_texture_range; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_transform_hint; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_object; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_range; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_program_evaluators; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_ycbcr_422; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES2_compatibility; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES3_1_compatibility; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES3_2_compatibility; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES3_compatibility; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_arrays_of_arrays; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_base_instance; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_bindless_texture; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_blend_func_extended; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_buffer_storage; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_cl_event; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_clear_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_clear_texture; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_clip_control; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_color_buffer_float; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_compatibility; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_compressed_texture_pixel_storage; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_compute_shader; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_compute_variable_group_size; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_conditional_render_inverted; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_conservative_depth; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_copy_buffer; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_copy_image; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_cull_distance; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_debug_output; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_buffer_float; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_texture; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_derivative_control; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_direct_state_access; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers_blend; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_elements_base_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_indirect; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_instanced; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_enhanced_layouts; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_explicit_attrib_location; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_explicit_uniform_location; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_coord_conventions; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_layer_viewport; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program_shadow; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader_interlock; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_no_attachments; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_sRGB; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_geometry_shader4; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_get_program_binary; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_get_texture_sub_image; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader5; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader_fp64; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader_int64; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_pixel; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_imaging; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_indirect_parameters; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_instanced_arrays; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_internalformat_query; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_internalformat_query2; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_invalidate_subdata; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_map_buffer_alignment; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_map_buffer_range; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_matrix_palette; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multi_bind; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multi_draw_indirect; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multitexture; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query2; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_parallel_shader_compile; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_pipeline_statistics_query; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_pixel_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_parameters; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_sprite; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_post_depth_coverage; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_program_interface_query; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_provoking_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_query_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_robust_buffer_access_behavior; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_robustness; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_robustness_application_isolation; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_robustness_share_group_isolation; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sample_locations; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sample_shading; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sampler_objects; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_seamless_cube_map; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_seamless_cubemap_per_texture; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_separate_shader_objects; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_atomic_counter_ops; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_atomic_counters; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_ballot; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_bit_encoding; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_clock; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_draw_parameters; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_group_vote; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_image_load_store; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_image_size; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_objects; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_precision; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_stencil_export; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_storage_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_subroutine; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_texture_image_samples; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_texture_lod; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_viewport_layer_array; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_100; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_420pack; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_include; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_packing; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow_ambient; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sparse_buffer; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sparse_texture; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sparse_texture2; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sparse_texture_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_stencil_texturing; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sync; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_tessellation_shader; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_barrier; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_border_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object_rgb32; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_range; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_bptc; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_rgtc; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map_array; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_add; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_combine; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_crossbar; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_dot3; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_filter_minmax; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_float; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_gather; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_mirror_clamp_to_edge; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_mirrored_repeat; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_non_power_of_two; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_query_levels; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_query_lod; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rectangle; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rg; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rgb10_a2ui; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_stencil8; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_storage; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_storage_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_swizzle; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_view; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_timer_query; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback2; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback3; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback_instanced; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback_overflow_query; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transpose_matrix; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_uniform_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_bgra; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_attrib_64bit; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_attrib_binding; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_blend; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_program; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_shader; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_type_10f_11f_11f_rev; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_type_2_10_10_10_rev; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_viewport_array; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_window_pos; GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_point_sprites; GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_combine3; GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_route; GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_vertex_shader_output_point_size; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_draw_buffers; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_element_array; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_envmap_bumpmap; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_fragment_shader; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_map_object_buffer; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_meminfo; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_pn_triangles; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_separate_stencil; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_shader_texture_lod; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_text_fragment_shader; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_compression_3dc; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_env_combine3; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_float; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_mirror_once; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_array_object; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_attrib_array_object; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_streams; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_422_pixels; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_Cg_shader; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_abgr; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bgra; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bindable_uniform; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_color; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_equation_separate; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_func_separate; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_logic_op; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_minmax; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_subtract; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_clip_volume_hint; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cmyka; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_color_subtable; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_compiled_vertex_array; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_convolution; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_coordinate_frame; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_copy_texture; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cull_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_debug_label; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_debug_marker; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_depth_bounds_test; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_direct_state_access; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_buffers2; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_instanced; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_range_elements; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fog_coord; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fragment_lighting; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_blit; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample_blit_scaled; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_sRGB; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_geometry_shader4; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_program_parameters; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_shader4; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_histogram; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_array_formats; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_func; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_material; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_texture; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_light_texture; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_misc_attribute; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multi_draw_arrays; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_depth_stencil; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_float; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_pixels; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_paletted_texture; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform_color_table; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_point_parameters; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_polygon_offset; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_polygon_offset_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_post_depth_coverage; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_provoking_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_raster_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_rescale_normal; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_scene_marker; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_secondary_color; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_shader_objects; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_specular_color; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shader_image_load_formatted; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shader_image_load_store; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shader_integer_mix; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shadow_funcs; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shared_texture_palette; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_sparse_texture2; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_clear_tag; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_two_side; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_wrap; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_subtexture; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture3D; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_array; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_dxt1; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_latc; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_rgtc; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_s3tc; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_cube_map; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_edge_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_add; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_combine; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_dot3; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_filter_anisotropic; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_filter_minmax; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_integer; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_lod_bias; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_mirror_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_object; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_perturb_normal; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_rectangle; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB_decode; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_shared_exponent; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_snorm; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_swizzle; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_timer_query; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_transform_feedback; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array_bgra; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_attrib_64bit; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_shader; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_weighting; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_x11_sync_object; GLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_frame_terminator; GLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_string_marker; GLEW_VAR_EXPORT GLboolean __GLEW_HP_convolution_border_modes; GLEW_VAR_EXPORT GLboolean __GLEW_HP_image_transform; GLEW_VAR_EXPORT GLboolean __GLEW_HP_occlusion_test; GLEW_VAR_EXPORT GLboolean __GLEW_HP_texture_lighting; GLEW_VAR_EXPORT GLboolean __GLEW_IBM_cull_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_IBM_multimode_draw_arrays; GLEW_VAR_EXPORT GLboolean __GLEW_IBM_rasterpos_clip; GLEW_VAR_EXPORT GLboolean __GLEW_IBM_static_data; GLEW_VAR_EXPORT GLboolean __GLEW_IBM_texture_mirrored_repeat; GLEW_VAR_EXPORT GLboolean __GLEW_IBM_vertex_array_lists; GLEW_VAR_EXPORT GLboolean __GLEW_INGR_color_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_INGR_interlace_read; GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_fragment_shader_ordering; GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_framebuffer_CMAA; GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_map_texture; GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_parallel_arrays; GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_performance_query; GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_texture_scissor; GLEW_VAR_EXPORT GLboolean __GLEW_KHR_blend_equation_advanced; GLEW_VAR_EXPORT GLboolean __GLEW_KHR_blend_equation_advanced_coherent; GLEW_VAR_EXPORT GLboolean __GLEW_KHR_context_flush_control; GLEW_VAR_EXPORT GLboolean __GLEW_KHR_debug; GLEW_VAR_EXPORT GLboolean __GLEW_KHR_no_error; GLEW_VAR_EXPORT GLboolean __GLEW_KHR_robust_buffer_access_behavior; GLEW_VAR_EXPORT GLboolean __GLEW_KHR_robustness; GLEW_VAR_EXPORT GLboolean __GLEW_KHR_texture_compression_astc_hdr; GLEW_VAR_EXPORT GLboolean __GLEW_KHR_texture_compression_astc_ldr; GLEW_VAR_EXPORT GLboolean __GLEW_KTX_buffer_region; GLEW_VAR_EXPORT GLboolean __GLEW_MESAX_texture_stack; GLEW_VAR_EXPORT GLboolean __GLEW_MESA_pack_invert; GLEW_VAR_EXPORT GLboolean __GLEW_MESA_resize_buffers; GLEW_VAR_EXPORT GLboolean __GLEW_MESA_window_pos; GLEW_VAR_EXPORT GLboolean __GLEW_MESA_ycbcr_texture; GLEW_VAR_EXPORT GLboolean __GLEW_NVX_conditional_render; GLEW_VAR_EXPORT GLboolean __GLEW_NVX_gpu_memory_info; GLEW_VAR_EXPORT GLboolean __GLEW_NV_bindless_multi_draw_indirect; GLEW_VAR_EXPORT GLboolean __GLEW_NV_bindless_multi_draw_indirect_count; GLEW_VAR_EXPORT GLboolean __GLEW_NV_bindless_texture; GLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_equation_advanced; GLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_equation_advanced_coherent; GLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_square; GLEW_VAR_EXPORT GLboolean __GLEW_NV_compute_program5; GLEW_VAR_EXPORT GLboolean __GLEW_NV_conditional_render; GLEW_VAR_EXPORT GLboolean __GLEW_NV_conservative_raster; GLEW_VAR_EXPORT GLboolean __GLEW_NV_conservative_raster_dilate; GLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_depth_to_color; GLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_image; GLEW_VAR_EXPORT GLboolean __GLEW_NV_deep_texture3D; GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_buffer_float; GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_range_unclamped; GLEW_VAR_EXPORT GLboolean __GLEW_NV_draw_texture; GLEW_VAR_EXPORT GLboolean __GLEW_NV_evaluators; GLEW_VAR_EXPORT GLboolean __GLEW_NV_explicit_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fence; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fill_rectangle; GLEW_VAR_EXPORT GLboolean __GLEW_NV_float_buffer; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fog_distance; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_coverage_to_color; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program4; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program_option; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_shader_interlock; GLEW_VAR_EXPORT GLboolean __GLEW_NV_framebuffer_mixed_samples; GLEW_VAR_EXPORT GLboolean __GLEW_NV_framebuffer_multisample_coverage; GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_program4; GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_shader4; GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_shader_passthrough; GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program4; GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program5; GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program5_mem_extended; GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program_fp64; GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_shader5; GLEW_VAR_EXPORT GLboolean __GLEW_NV_half_float; GLEW_VAR_EXPORT GLboolean __GLEW_NV_internalformat_sample_query; GLEW_VAR_EXPORT GLboolean __GLEW_NV_light_max_exponent; GLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_coverage; GLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_filter_hint; GLEW_VAR_EXPORT GLboolean __GLEW_NV_occlusion_query; GLEW_VAR_EXPORT GLboolean __GLEW_NV_packed_depth_stencil; GLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_path_rendering; GLEW_VAR_EXPORT GLboolean __GLEW_NV_path_rendering_shared_edge; GLEW_VAR_EXPORT GLboolean __GLEW_NV_pixel_data_range; GLEW_VAR_EXPORT GLboolean __GLEW_NV_point_sprite; GLEW_VAR_EXPORT GLboolean __GLEW_NV_present_video; GLEW_VAR_EXPORT GLboolean __GLEW_NV_primitive_restart; GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners; GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_sample_locations; GLEW_VAR_EXPORT GLboolean __GLEW_NV_sample_mask_override_coverage; GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_atomic_counters; GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_atomic_float; GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_atomic_fp16_vector; GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_atomic_int64; GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_buffer_load; GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_storage_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_thread_group; GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_thread_shuffle; GLEW_VAR_EXPORT GLboolean __GLEW_NV_tessellation_program5; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_emboss; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_reflection; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_barrier; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_compression_vtc; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_env_combine4; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_expand_normal; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_rectangle; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader3; GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback; GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_uniform_buffer_unified_memory; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vdpau_interop; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_attrib_integer_64bit; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_buffer_unified_memory; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program1_1; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2_option; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program3; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program4; GLEW_VAR_EXPORT GLboolean __GLEW_NV_video_capture; GLEW_VAR_EXPORT GLboolean __GLEW_NV_viewport_array2; GLEW_VAR_EXPORT GLboolean __GLEW_OES_byte_coordinates; GLEW_VAR_EXPORT GLboolean __GLEW_OES_compressed_paletted_texture; GLEW_VAR_EXPORT GLboolean __GLEW_OES_read_format; GLEW_VAR_EXPORT GLboolean __GLEW_OES_single_precision; GLEW_VAR_EXPORT GLboolean __GLEW_OML_interlace; GLEW_VAR_EXPORT GLboolean __GLEW_OML_resample; GLEW_VAR_EXPORT GLboolean __GLEW_OML_subsample; GLEW_VAR_EXPORT GLboolean __GLEW_OVR_multiview; GLEW_VAR_EXPORT GLboolean __GLEW_OVR_multiview2; GLEW_VAR_EXPORT GLboolean __GLEW_PGI_misc_hints; GLEW_VAR_EXPORT GLboolean __GLEW_PGI_vertex_hints; GLEW_VAR_EXPORT GLboolean __GLEW_REGAL_ES1_0_compatibility; GLEW_VAR_EXPORT GLboolean __GLEW_REGAL_ES1_1_compatibility; GLEW_VAR_EXPORT GLboolean __GLEW_REGAL_enable; GLEW_VAR_EXPORT GLboolean __GLEW_REGAL_error_string; GLEW_VAR_EXPORT GLboolean __GLEW_REGAL_extension_query; GLEW_VAR_EXPORT GLboolean __GLEW_REGAL_log; GLEW_VAR_EXPORT GLboolean __GLEW_REGAL_proc_address; GLEW_VAR_EXPORT GLboolean __GLEW_REND_screen_coordinates; GLEW_VAR_EXPORT GLboolean __GLEW_S3_s3tc; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_color_range; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_detail_texture; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_fog_function; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_generate_mipmap; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_pixel_texture; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_point_line_texgen; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_sharpen_texture; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture4D; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_border_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_edge_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_filter4; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_lod; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_select; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_histogram; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_pixel; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_blend_alpha_minmax; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_clipmap; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_convolution_accuracy; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_depth_texture; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_flush_raster; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_offset; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_texture; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fragment_specular_lighting; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_framezoom; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_interlace; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ir_instrument1; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_list_priority; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture_bits; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_reference_plane; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_resample; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow_ambient; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_sprite; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_tag_sample_buffer; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_add_env; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_coordinate_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_lod_bias; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_multi_buffer; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_range; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_scale_bias; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip_hint; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ycrcb; GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_matrix; GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_table; GLEW_VAR_EXPORT GLboolean __GLEW_SGI_texture_color_table; GLEW_VAR_EXPORT GLboolean __GLEW_SUNX_constant_data; GLEW_VAR_EXPORT GLboolean __GLEW_SUN_convolution_border_modes; GLEW_VAR_EXPORT GLboolean __GLEW_SUN_global_alpha; GLEW_VAR_EXPORT GLboolean __GLEW_SUN_mesh_array; GLEW_VAR_EXPORT GLboolean __GLEW_SUN_read_video_pixels; GLEW_VAR_EXPORT GLboolean __GLEW_SUN_slice_accum; GLEW_VAR_EXPORT GLboolean __GLEW_SUN_triangle_list; GLEW_VAR_EXPORT GLboolean __GLEW_SUN_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_WIN_phong_shading; GLEW_VAR_EXPORT GLboolean __GLEW_WIN_specular_fog; GLEW_VAR_EXPORT GLboolean __GLEW_WIN_swap_hint; #ifdef GLEW_MX }; /* GLEWContextStruct */ #endif /* GLEW_MX */ /* ------------------------------------------------------------------------- */ /* error codes */ #define GLEW_OK 0 #define GLEW_NO_ERROR 0 #define GLEW_ERROR_NO_GL_VERSION 1 /* missing GL version */ #define GLEW_ERROR_GL_VERSION_10_ONLY 2 /* Need at least OpenGL 1.1 */ #define GLEW_ERROR_GLX_VERSION_11_ONLY 3 /* Need at least GLX 1.2 */ /* string codes */ #define GLEW_VERSION 1 #define GLEW_VERSION_MAJOR 2 #define GLEW_VERSION_MINOR 3 #define GLEW_VERSION_MICRO 4 /* ------------------------------------------------------------------------- */ /* GLEW version info */ /* VERSION 1.13.0 VERSION_MAJOR 1 VERSION_MINOR 13 VERSION_MICRO 0 */ /* API */ #ifdef GLEW_MX typedef struct GLEWContextStruct GLEWContext; GLEWAPI GLenum GLEWAPIENTRY glewContextInit (GLEWContext *ctx); GLEWAPI GLboolean GLEWAPIENTRY glewContextIsSupported (const GLEWContext *ctx, const char *name); #define glewInit() glewContextInit(glewGetContext()) #define glewIsSupported(x) glewContextIsSupported(glewGetContext(), x) #define glewIsExtensionSupported(x) glewIsSupported(x) #define GLEW_GET_VAR(x) (*(const GLboolean*)&(glewGetContext()->x)) #ifdef _WIN32 # define GLEW_GET_FUN(x) glewGetContext()->x #else # define GLEW_GET_FUN(x) x #endif #else /* GLEW_MX */ GLEWAPI GLenum GLEWAPIENTRY glewInit (void); GLEWAPI GLboolean GLEWAPIENTRY glewIsSupported (const char *name); #define glewIsExtensionSupported(x) glewIsSupported(x) #define GLEW_GET_VAR(x) (*(const GLboolean*)&x) #define GLEW_GET_FUN(x) x #endif /* GLEW_MX */ GLEWAPI GLboolean glewExperimental; GLEWAPI GLboolean GLEWAPIENTRY glewGetExtension (const char *name); GLEWAPI const GLubyte * GLEWAPIENTRY glewGetErrorString (GLenum error); GLEWAPI const GLubyte * GLEWAPIENTRY glewGetString (GLenum name); #ifdef __cplusplus } #endif #ifdef GLEW_APIENTRY_DEFINED #undef GLEW_APIENTRY_DEFINED #undef APIENTRY #endif #ifdef GLEW_CALLBACK_DEFINED #undef GLEW_CALLBACK_DEFINED #undef CALLBACK #endif #ifdef GLEW_WINGDIAPI_DEFINED #undef GLEW_WINGDIAPI_DEFINED #undef WINGDIAPI #endif #undef GLAPI /* #undef GLEWAPI */ #endif /* __glew_h__ */ goxel-0.11.0/ext_src/glew/GL/wglew.h000066400000000000000000001765041435762723100171430ustar00rootroot00000000000000/* ** The OpenGL Extension Wrangler Library ** Copyright (C) 2008-2015, Nigel Stewart ** Copyright (C) 2002-2008, Milan Ikits ** Copyright (C) 2002-2008, Marcelo E. Magallon ** Copyright (C) 2002, Lev Povalahev ** 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. ** * The name of the author may be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** 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 OWNER 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. */ /* ** Copyright (c) 2007 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 __wglew_h__ #define __wglew_h__ #define __WGLEW_H__ #ifdef __wglext_h_ #error wglext.h included before wglew.h #endif #define __wglext_h_ #if !defined(WINAPI) # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 # endif #include # undef WIN32_LEAN_AND_MEAN #endif /* * GLEW_STATIC needs to be set when using the static version. * GLEW_BUILD is set when building the DLL version. */ #ifdef GLEW_STATIC # define GLEWAPI extern #else # ifdef GLEW_BUILD # define GLEWAPI extern __declspec(dllexport) # else # define GLEWAPI extern __declspec(dllimport) # endif #endif #ifdef __cplusplus extern "C" { #endif /* -------------------------- WGL_3DFX_multisample ------------------------- */ #ifndef WGL_3DFX_multisample #define WGL_3DFX_multisample 1 #define WGL_SAMPLE_BUFFERS_3DFX 0x2060 #define WGL_SAMPLES_3DFX 0x2061 #define WGLEW_3DFX_multisample WGLEW_GET_VAR(__WGLEW_3DFX_multisample) #endif /* WGL_3DFX_multisample */ /* ------------------------- WGL_3DL_stereo_control ------------------------ */ #ifndef WGL_3DL_stereo_control #define WGL_3DL_stereo_control 1 #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 typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); #define wglSetStereoEmitterState3DL WGLEW_GET_FUN(__wglewSetStereoEmitterState3DL) #define WGLEW_3DL_stereo_control WGLEW_GET_VAR(__WGLEW_3DL_stereo_control) #endif /* WGL_3DL_stereo_control */ /* ------------------------ WGL_AMD_gpu_association ------------------------ */ #ifndef WGL_AMD_gpu_association #define WGL_AMD_gpu_association 1 #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 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); typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int* attribList); typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT* ids); typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void* data); typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); #define wglBlitContextFramebufferAMD WGLEW_GET_FUN(__wglewBlitContextFramebufferAMD) #define wglCreateAssociatedContextAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAMD) #define wglCreateAssociatedContextAttribsAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAttribsAMD) #define wglDeleteAssociatedContextAMD WGLEW_GET_FUN(__wglewDeleteAssociatedContextAMD) #define wglGetContextGPUIDAMD WGLEW_GET_FUN(__wglewGetContextGPUIDAMD) #define wglGetCurrentAssociatedContextAMD WGLEW_GET_FUN(__wglewGetCurrentAssociatedContextAMD) #define wglGetGPUIDsAMD WGLEW_GET_FUN(__wglewGetGPUIDsAMD) #define wglGetGPUInfoAMD WGLEW_GET_FUN(__wglewGetGPUInfoAMD) #define wglMakeAssociatedContextCurrentAMD WGLEW_GET_FUN(__wglewMakeAssociatedContextCurrentAMD) #define WGLEW_AMD_gpu_association WGLEW_GET_VAR(__WGLEW_AMD_gpu_association) #endif /* WGL_AMD_gpu_association */ /* ------------------------- WGL_ARB_buffer_region ------------------------- */ #ifndef WGL_ARB_buffer_region #define WGL_ARB_buffer_region 1 #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 typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); #define wglCreateBufferRegionARB WGLEW_GET_FUN(__wglewCreateBufferRegionARB) #define wglDeleteBufferRegionARB WGLEW_GET_FUN(__wglewDeleteBufferRegionARB) #define wglRestoreBufferRegionARB WGLEW_GET_FUN(__wglewRestoreBufferRegionARB) #define wglSaveBufferRegionARB WGLEW_GET_FUN(__wglewSaveBufferRegionARB) #define WGLEW_ARB_buffer_region WGLEW_GET_VAR(__WGLEW_ARB_buffer_region) #endif /* WGL_ARB_buffer_region */ /* --------------------- WGL_ARB_context_flush_control --------------------- */ #ifndef WGL_ARB_context_flush_control #define WGL_ARB_context_flush_control 1 #define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000 #define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 #define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 #define WGLEW_ARB_context_flush_control WGLEW_GET_VAR(__WGLEW_ARB_context_flush_control) #endif /* WGL_ARB_context_flush_control */ /* ------------------------- WGL_ARB_create_context ------------------------ */ #ifndef WGL_ARB_create_context #define WGL_ARB_create_context 1 #define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 #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 #define ERROR_INVALID_PROFILE_ARB 0x2096 typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int* attribList); #define wglCreateContextAttribsARB WGLEW_GET_FUN(__wglewCreateContextAttribsARB) #define WGLEW_ARB_create_context WGLEW_GET_VAR(__WGLEW_ARB_create_context) #endif /* WGL_ARB_create_context */ /* --------------------- WGL_ARB_create_context_profile -------------------- */ #ifndef WGL_ARB_create_context_profile #define WGL_ARB_create_context_profile 1 #define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 #define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 #define WGLEW_ARB_create_context_profile WGLEW_GET_VAR(__WGLEW_ARB_create_context_profile) #endif /* WGL_ARB_create_context_profile */ /* ------------------- WGL_ARB_create_context_robustness ------------------- */ #ifndef WGL_ARB_create_context_robustness #define WGL_ARB_create_context_robustness 1 #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 #define WGLEW_ARB_create_context_robustness WGLEW_GET_VAR(__WGLEW_ARB_create_context_robustness) #endif /* WGL_ARB_create_context_robustness */ /* ----------------------- WGL_ARB_extensions_string ----------------------- */ #ifndef WGL_ARB_extensions_string #define WGL_ARB_extensions_string 1 typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); #define wglGetExtensionsStringARB WGLEW_GET_FUN(__wglewGetExtensionsStringARB) #define WGLEW_ARB_extensions_string WGLEW_GET_VAR(__WGLEW_ARB_extensions_string) #endif /* WGL_ARB_extensions_string */ /* ------------------------ WGL_ARB_framebuffer_sRGB ----------------------- */ #ifndef WGL_ARB_framebuffer_sRGB #define WGL_ARB_framebuffer_sRGB 1 #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 #define WGLEW_ARB_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_ARB_framebuffer_sRGB) #endif /* WGL_ARB_framebuffer_sRGB */ /* ----------------------- WGL_ARB_make_current_read ----------------------- */ #ifndef WGL_ARB_make_current_read #define WGL_ARB_make_current_read 1 #define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (VOID); typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); #define wglGetCurrentReadDCARB WGLEW_GET_FUN(__wglewGetCurrentReadDCARB) #define wglMakeContextCurrentARB WGLEW_GET_FUN(__wglewMakeContextCurrentARB) #define WGLEW_ARB_make_current_read WGLEW_GET_VAR(__WGLEW_ARB_make_current_read) #endif /* WGL_ARB_make_current_read */ /* -------------------------- WGL_ARB_multisample -------------------------- */ #ifndef WGL_ARB_multisample #define WGL_ARB_multisample 1 #define WGL_SAMPLE_BUFFERS_ARB 0x2041 #define WGL_SAMPLES_ARB 0x2042 #define WGLEW_ARB_multisample WGLEW_GET_VAR(__WGLEW_ARB_multisample) #endif /* WGL_ARB_multisample */ /* ---------------------------- WGL_ARB_pbuffer ---------------------------- */ #ifndef WGL_ARB_pbuffer #define WGL_ARB_pbuffer 1 #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 DECLARE_HANDLE(HPBUFFERARB); typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int* piValue); typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); #define wglCreatePbufferARB WGLEW_GET_FUN(__wglewCreatePbufferARB) #define wglDestroyPbufferARB WGLEW_GET_FUN(__wglewDestroyPbufferARB) #define wglGetPbufferDCARB WGLEW_GET_FUN(__wglewGetPbufferDCARB) #define wglQueryPbufferARB WGLEW_GET_FUN(__wglewQueryPbufferARB) #define wglReleasePbufferDCARB WGLEW_GET_FUN(__wglewReleasePbufferDCARB) #define WGLEW_ARB_pbuffer WGLEW_GET_VAR(__WGLEW_ARB_pbuffer) #endif /* WGL_ARB_pbuffer */ /* -------------------------- WGL_ARB_pixel_format ------------------------- */ #ifndef WGL_ARB_pixel_format #define WGL_ARB_pixel_format 1 #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_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 #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 typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, FLOAT *pfValues); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, int *piValues); #define wglChoosePixelFormatARB WGLEW_GET_FUN(__wglewChoosePixelFormatARB) #define wglGetPixelFormatAttribfvARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvARB) #define wglGetPixelFormatAttribivARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribivARB) #define WGLEW_ARB_pixel_format WGLEW_GET_VAR(__WGLEW_ARB_pixel_format) #endif /* WGL_ARB_pixel_format */ /* ----------------------- WGL_ARB_pixel_format_float ---------------------- */ #ifndef WGL_ARB_pixel_format_float #define WGL_ARB_pixel_format_float 1 #define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 #define WGLEW_ARB_pixel_format_float WGLEW_GET_VAR(__WGLEW_ARB_pixel_format_float) #endif /* WGL_ARB_pixel_format_float */ /* ------------------------- WGL_ARB_render_texture ------------------------ */ #ifndef WGL_ARB_render_texture #define WGL_ARB_render_texture 1 #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 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); #define wglBindTexImageARB WGLEW_GET_FUN(__wglewBindTexImageARB) #define wglReleaseTexImageARB WGLEW_GET_FUN(__wglewReleaseTexImageARB) #define wglSetPbufferAttribARB WGLEW_GET_FUN(__wglewSetPbufferAttribARB) #define WGLEW_ARB_render_texture WGLEW_GET_VAR(__WGLEW_ARB_render_texture) #endif /* WGL_ARB_render_texture */ /* ---------------- WGL_ARB_robustness_application_isolation --------------- */ #ifndef WGL_ARB_robustness_application_isolation #define WGL_ARB_robustness_application_isolation 1 #define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 #define WGLEW_ARB_robustness_application_isolation WGLEW_GET_VAR(__WGLEW_ARB_robustness_application_isolation) #endif /* WGL_ARB_robustness_application_isolation */ /* ---------------- WGL_ARB_robustness_share_group_isolation --------------- */ #ifndef WGL_ARB_robustness_share_group_isolation #define WGL_ARB_robustness_share_group_isolation 1 #define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 #define WGLEW_ARB_robustness_share_group_isolation WGLEW_GET_VAR(__WGLEW_ARB_robustness_share_group_isolation) #endif /* WGL_ARB_robustness_share_group_isolation */ /* ----------------------- WGL_ATI_pixel_format_float ---------------------- */ #ifndef WGL_ATI_pixel_format_float #define WGL_ATI_pixel_format_float 1 #define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 #define GL_RGBA_FLOAT_MODE_ATI 0x8820 #define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 #define WGLEW_ATI_pixel_format_float WGLEW_GET_VAR(__WGLEW_ATI_pixel_format_float) #endif /* WGL_ATI_pixel_format_float */ /* -------------------- WGL_ATI_render_texture_rectangle ------------------- */ #ifndef WGL_ATI_render_texture_rectangle #define WGL_ATI_render_texture_rectangle 1 #define WGL_TEXTURE_RECTANGLE_ATI 0x21A5 #define WGLEW_ATI_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_ATI_render_texture_rectangle) #endif /* WGL_ATI_render_texture_rectangle */ /* ------------------- WGL_EXT_create_context_es2_profile ------------------ */ #ifndef WGL_EXT_create_context_es2_profile #define WGL_EXT_create_context_es2_profile 1 #define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 #define WGLEW_EXT_create_context_es2_profile WGLEW_GET_VAR(__WGLEW_EXT_create_context_es2_profile) #endif /* WGL_EXT_create_context_es2_profile */ /* ------------------- WGL_EXT_create_context_es_profile ------------------- */ #ifndef WGL_EXT_create_context_es_profile #define WGL_EXT_create_context_es_profile 1 #define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 #define WGLEW_EXT_create_context_es_profile WGLEW_GET_VAR(__WGLEW_EXT_create_context_es_profile) #endif /* WGL_EXT_create_context_es_profile */ /* -------------------------- WGL_EXT_depth_float -------------------------- */ #ifndef WGL_EXT_depth_float #define WGL_EXT_depth_float 1 #define WGL_DEPTH_FLOAT_EXT 0x2040 #define WGLEW_EXT_depth_float WGLEW_GET_VAR(__WGLEW_EXT_depth_float) #endif /* WGL_EXT_depth_float */ /* ---------------------- WGL_EXT_display_color_table ---------------------- */ #ifndef WGL_EXT_display_color_table #define WGL_EXT_display_color_table 1 typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); typedef void (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (GLushort* table, GLuint length); #define wglBindDisplayColorTableEXT WGLEW_GET_FUN(__wglewBindDisplayColorTableEXT) #define wglCreateDisplayColorTableEXT WGLEW_GET_FUN(__wglewCreateDisplayColorTableEXT) #define wglDestroyDisplayColorTableEXT WGLEW_GET_FUN(__wglewDestroyDisplayColorTableEXT) #define wglLoadDisplayColorTableEXT WGLEW_GET_FUN(__wglewLoadDisplayColorTableEXT) #define WGLEW_EXT_display_color_table WGLEW_GET_VAR(__WGLEW_EXT_display_color_table) #endif /* WGL_EXT_display_color_table */ /* ----------------------- WGL_EXT_extensions_string ----------------------- */ #ifndef WGL_EXT_extensions_string #define WGL_EXT_extensions_string 1 typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); #define wglGetExtensionsStringEXT WGLEW_GET_FUN(__wglewGetExtensionsStringEXT) #define WGLEW_EXT_extensions_string WGLEW_GET_VAR(__WGLEW_EXT_extensions_string) #endif /* WGL_EXT_extensions_string */ /* ------------------------ WGL_EXT_framebuffer_sRGB ----------------------- */ #ifndef WGL_EXT_framebuffer_sRGB #define WGL_EXT_framebuffer_sRGB 1 #define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 #define WGLEW_EXT_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_EXT_framebuffer_sRGB) #endif /* WGL_EXT_framebuffer_sRGB */ /* ----------------------- WGL_EXT_make_current_read ----------------------- */ #ifndef WGL_EXT_make_current_read #define WGL_EXT_make_current_read 1 #define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (VOID); typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); #define wglGetCurrentReadDCEXT WGLEW_GET_FUN(__wglewGetCurrentReadDCEXT) #define wglMakeContextCurrentEXT WGLEW_GET_FUN(__wglewMakeContextCurrentEXT) #define WGLEW_EXT_make_current_read WGLEW_GET_VAR(__WGLEW_EXT_make_current_read) #endif /* WGL_EXT_make_current_read */ /* -------------------------- WGL_EXT_multisample -------------------------- */ #ifndef WGL_EXT_multisample #define WGL_EXT_multisample 1 #define WGL_SAMPLE_BUFFERS_EXT 0x2041 #define WGL_SAMPLES_EXT 0x2042 #define WGLEW_EXT_multisample WGLEW_GET_VAR(__WGLEW_EXT_multisample) #endif /* WGL_EXT_multisample */ /* ---------------------------- WGL_EXT_pbuffer ---------------------------- */ #ifndef WGL_EXT_pbuffer #define WGL_EXT_pbuffer 1 #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 DECLARE_HANDLE(HPBUFFEREXT); typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int* piValue); typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); #define wglCreatePbufferEXT WGLEW_GET_FUN(__wglewCreatePbufferEXT) #define wglDestroyPbufferEXT WGLEW_GET_FUN(__wglewDestroyPbufferEXT) #define wglGetPbufferDCEXT WGLEW_GET_FUN(__wglewGetPbufferDCEXT) #define wglQueryPbufferEXT WGLEW_GET_FUN(__wglewQueryPbufferEXT) #define wglReleasePbufferDCEXT WGLEW_GET_FUN(__wglewReleasePbufferDCEXT) #define WGLEW_EXT_pbuffer WGLEW_GET_VAR(__WGLEW_EXT_pbuffer) #endif /* WGL_EXT_pbuffer */ /* -------------------------- WGL_EXT_pixel_format ------------------------- */ #ifndef WGL_EXT_pixel_format #define WGL_EXT_pixel_format 1 #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 typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, FLOAT *pfValues); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues); #define wglChoosePixelFormatEXT WGLEW_GET_FUN(__wglewChoosePixelFormatEXT) #define wglGetPixelFormatAttribfvEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvEXT) #define wglGetPixelFormatAttribivEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribivEXT) #define WGLEW_EXT_pixel_format WGLEW_GET_VAR(__WGLEW_EXT_pixel_format) #endif /* WGL_EXT_pixel_format */ /* ------------------- WGL_EXT_pixel_format_packed_float ------------------- */ #ifndef WGL_EXT_pixel_format_packed_float #define WGL_EXT_pixel_format_packed_float 1 #define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 #define WGLEW_EXT_pixel_format_packed_float WGLEW_GET_VAR(__WGLEW_EXT_pixel_format_packed_float) #endif /* WGL_EXT_pixel_format_packed_float */ /* -------------------------- WGL_EXT_swap_control ------------------------- */ #ifndef WGL_EXT_swap_control #define WGL_EXT_swap_control 1 typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); #define wglGetSwapIntervalEXT WGLEW_GET_FUN(__wglewGetSwapIntervalEXT) #define wglSwapIntervalEXT WGLEW_GET_FUN(__wglewSwapIntervalEXT) #define WGLEW_EXT_swap_control WGLEW_GET_VAR(__WGLEW_EXT_swap_control) #endif /* WGL_EXT_swap_control */ /* ----------------------- WGL_EXT_swap_control_tear ----------------------- */ #ifndef WGL_EXT_swap_control_tear #define WGL_EXT_swap_control_tear 1 #define WGLEW_EXT_swap_control_tear WGLEW_GET_VAR(__WGLEW_EXT_swap_control_tear) #endif /* WGL_EXT_swap_control_tear */ /* --------------------- WGL_I3D_digital_video_control --------------------- */ #ifndef WGL_I3D_digital_video_control #define WGL_I3D_digital_video_control 1 #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 typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); #define wglGetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewGetDigitalVideoParametersI3D) #define wglSetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewSetDigitalVideoParametersI3D) #define WGLEW_I3D_digital_video_control WGLEW_GET_VAR(__WGLEW_I3D_digital_video_control) #endif /* WGL_I3D_digital_video_control */ /* ----------------------------- WGL_I3D_gamma ----------------------------- */ #ifndef WGL_I3D_gamma #define WGL_I3D_gamma 1 #define WGL_GAMMA_TABLE_SIZE_I3D 0x204E #define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT* puRed, USHORT *puGreen, USHORT *puBlue); typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT* puRed, const USHORT *puGreen, const USHORT *puBlue); typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); #define wglGetGammaTableI3D WGLEW_GET_FUN(__wglewGetGammaTableI3D) #define wglGetGammaTableParametersI3D WGLEW_GET_FUN(__wglewGetGammaTableParametersI3D) #define wglSetGammaTableI3D WGLEW_GET_FUN(__wglewSetGammaTableI3D) #define wglSetGammaTableParametersI3D WGLEW_GET_FUN(__wglewSetGammaTableParametersI3D) #define WGLEW_I3D_gamma WGLEW_GET_VAR(__WGLEW_I3D_gamma) #endif /* WGL_I3D_gamma */ /* ---------------------------- WGL_I3D_genlock ---------------------------- */ #ifndef WGL_I3D_genlock #define WGL_I3D_genlock 1 #define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 #define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 #define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 #define WGL_GENLOCK_SOURCE_EXTERNAL_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 typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT* uRate); typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT* uDelay); typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT* uEdge); typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT* uSource); typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL* pFlag); typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT* uMaxLineDelay, UINT *uMaxPixelDelay); #define wglDisableGenlockI3D WGLEW_GET_FUN(__wglewDisableGenlockI3D) #define wglEnableGenlockI3D WGLEW_GET_FUN(__wglewEnableGenlockI3D) #define wglGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGenlockSampleRateI3D) #define wglGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGenlockSourceDelayI3D) #define wglGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGenlockSourceEdgeI3D) #define wglGenlockSourceI3D WGLEW_GET_FUN(__wglewGenlockSourceI3D) #define wglGetGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGetGenlockSampleRateI3D) #define wglGetGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGetGenlockSourceDelayI3D) #define wglGetGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGetGenlockSourceEdgeI3D) #define wglGetGenlockSourceI3D WGLEW_GET_FUN(__wglewGetGenlockSourceI3D) #define wglIsEnabledGenlockI3D WGLEW_GET_FUN(__wglewIsEnabledGenlockI3D) #define wglQueryGenlockMaxSourceDelayI3D WGLEW_GET_FUN(__wglewQueryGenlockMaxSourceDelayI3D) #define WGLEW_I3D_genlock WGLEW_GET_VAR(__WGLEW_I3D_genlock) #endif /* WGL_I3D_genlock */ /* -------------------------- WGL_I3D_image_buffer ------------------------- */ #ifndef WGL_I3D_image_buffer #define WGL_I3D_image_buffer 1 #define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 #define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, HANDLE* pEvent, LPVOID *pAddress, DWORD *pSize, UINT count); typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, LPVOID* pAddress, UINT count); #define wglAssociateImageBufferEventsI3D WGLEW_GET_FUN(__wglewAssociateImageBufferEventsI3D) #define wglCreateImageBufferI3D WGLEW_GET_FUN(__wglewCreateImageBufferI3D) #define wglDestroyImageBufferI3D WGLEW_GET_FUN(__wglewDestroyImageBufferI3D) #define wglReleaseImageBufferEventsI3D WGLEW_GET_FUN(__wglewReleaseImageBufferEventsI3D) #define WGLEW_I3D_image_buffer WGLEW_GET_VAR(__WGLEW_I3D_image_buffer) #endif /* WGL_I3D_image_buffer */ /* ------------------------ WGL_I3D_swap_frame_lock ------------------------ */ #ifndef WGL_I3D_swap_frame_lock #define WGL_I3D_swap_frame_lock 1 typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (VOID); typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (VOID); typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL* pFlag); typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL* pFlag); #define wglDisableFrameLockI3D WGLEW_GET_FUN(__wglewDisableFrameLockI3D) #define wglEnableFrameLockI3D WGLEW_GET_FUN(__wglewEnableFrameLockI3D) #define wglIsEnabledFrameLockI3D WGLEW_GET_FUN(__wglewIsEnabledFrameLockI3D) #define wglQueryFrameLockMasterI3D WGLEW_GET_FUN(__wglewQueryFrameLockMasterI3D) #define WGLEW_I3D_swap_frame_lock WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_lock) #endif /* WGL_I3D_swap_frame_lock */ /* ------------------------ WGL_I3D_swap_frame_usage ----------------------- */ #ifndef WGL_I3D_swap_frame_usage #define WGL_I3D_swap_frame_usage 1 typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float* pUsage); typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD* pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); #define wglBeginFrameTrackingI3D WGLEW_GET_FUN(__wglewBeginFrameTrackingI3D) #define wglEndFrameTrackingI3D WGLEW_GET_FUN(__wglewEndFrameTrackingI3D) #define wglGetFrameUsageI3D WGLEW_GET_FUN(__wglewGetFrameUsageI3D) #define wglQueryFrameTrackingI3D WGLEW_GET_FUN(__wglewQueryFrameTrackingI3D) #define WGLEW_I3D_swap_frame_usage WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_usage) #endif /* WGL_I3D_swap_frame_usage */ /* --------------------------- WGL_NV_DX_interop --------------------------- */ #ifndef WGL_NV_DX_interop #define WGL_NV_DX_interop 1 #define WGL_ACCESS_READ_ONLY_NV 0x0000 #define WGL_ACCESS_READ_WRITE_NV 0x0001 #define WGL_ACCESS_WRITE_DISCARD_NV 0x0002 typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects); typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void* dxDevice); typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access); typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void* dxObject, HANDLE shareHandle); typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects); typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); #define wglDXCloseDeviceNV WGLEW_GET_FUN(__wglewDXCloseDeviceNV) #define wglDXLockObjectsNV WGLEW_GET_FUN(__wglewDXLockObjectsNV) #define wglDXObjectAccessNV WGLEW_GET_FUN(__wglewDXObjectAccessNV) #define wglDXOpenDeviceNV WGLEW_GET_FUN(__wglewDXOpenDeviceNV) #define wglDXRegisterObjectNV WGLEW_GET_FUN(__wglewDXRegisterObjectNV) #define wglDXSetResourceShareHandleNV WGLEW_GET_FUN(__wglewDXSetResourceShareHandleNV) #define wglDXUnlockObjectsNV WGLEW_GET_FUN(__wglewDXUnlockObjectsNV) #define wglDXUnregisterObjectNV WGLEW_GET_FUN(__wglewDXUnregisterObjectNV) #define WGLEW_NV_DX_interop WGLEW_GET_VAR(__WGLEW_NV_DX_interop) #endif /* WGL_NV_DX_interop */ /* --------------------------- WGL_NV_DX_interop2 -------------------------- */ #ifndef WGL_NV_DX_interop2 #define WGL_NV_DX_interop2 1 #define WGLEW_NV_DX_interop2 WGLEW_GET_VAR(__WGLEW_NV_DX_interop2) #endif /* WGL_NV_DX_interop2 */ /* --------------------------- WGL_NV_copy_image --------------------------- */ #ifndef WGL_NV_copy_image #define WGL_NV_copy_image 1 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); #define wglCopyImageSubDataNV WGLEW_GET_FUN(__wglewCopyImageSubDataNV) #define WGLEW_NV_copy_image WGLEW_GET_VAR(__WGLEW_NV_copy_image) #endif /* WGL_NV_copy_image */ /* ------------------------ WGL_NV_delay_before_swap ----------------------- */ #ifndef WGL_NV_delay_before_swap #define WGL_NV_delay_before_swap 1 typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds); #define wglDelayBeforeSwapNV WGLEW_GET_FUN(__wglewDelayBeforeSwapNV) #define WGLEW_NV_delay_before_swap WGLEW_GET_VAR(__WGLEW_NV_delay_before_swap) #endif /* WGL_NV_delay_before_swap */ /* -------------------------- WGL_NV_float_buffer -------------------------- */ #ifndef WGL_NV_float_buffer #define WGL_NV_float_buffer 1 #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 #define WGLEW_NV_float_buffer WGLEW_GET_VAR(__WGLEW_NV_float_buffer) #endif /* WGL_NV_float_buffer */ /* -------------------------- WGL_NV_gpu_affinity -------------------------- */ #ifndef WGL_NV_gpu_affinity #define WGL_NV_gpu_affinity 1 #define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 #define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 DECLARE_HANDLE(HGPUNV); typedef struct _GPU_DEVICE { DWORD cb; CHAR DeviceName[32]; CHAR DeviceString[128]; DWORD Flags; RECT rcVirtualScreen; } GPU_DEVICE, *PGPU_DEVICE; typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); #define wglCreateAffinityDCNV WGLEW_GET_FUN(__wglewCreateAffinityDCNV) #define wglDeleteDCNV WGLEW_GET_FUN(__wglewDeleteDCNV) #define wglEnumGpuDevicesNV WGLEW_GET_FUN(__wglewEnumGpuDevicesNV) #define wglEnumGpusFromAffinityDCNV WGLEW_GET_FUN(__wglewEnumGpusFromAffinityDCNV) #define wglEnumGpusNV WGLEW_GET_FUN(__wglewEnumGpusNV) #define WGLEW_NV_gpu_affinity WGLEW_GET_VAR(__WGLEW_NV_gpu_affinity) #endif /* WGL_NV_gpu_affinity */ /* ---------------------- WGL_NV_multisample_coverage ---------------------- */ #ifndef WGL_NV_multisample_coverage #define WGL_NV_multisample_coverage 1 #define WGL_COVERAGE_SAMPLES_NV 0x2042 #define WGL_COLOR_SAMPLES_NV 0x20B9 #define WGLEW_NV_multisample_coverage WGLEW_GET_VAR(__WGLEW_NV_multisample_coverage) #endif /* WGL_NV_multisample_coverage */ /* -------------------------- WGL_NV_present_video ------------------------- */ #ifndef WGL_NV_present_video #define WGL_NV_present_video 1 #define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int* piAttribList); typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV* phDeviceList); typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int* piValue); #define wglBindVideoDeviceNV WGLEW_GET_FUN(__wglewBindVideoDeviceNV) #define wglEnumerateVideoDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoDevicesNV) #define wglQueryCurrentContextNV WGLEW_GET_FUN(__wglewQueryCurrentContextNV) #define WGLEW_NV_present_video WGLEW_GET_VAR(__WGLEW_NV_present_video) #endif /* WGL_NV_present_video */ /* ---------------------- WGL_NV_render_depth_texture ---------------------- */ #ifndef WGL_NV_render_depth_texture #define WGL_NV_render_depth_texture 1 #define WGL_NO_TEXTURE_ARB 0x2077 #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 #define WGLEW_NV_render_depth_texture WGLEW_GET_VAR(__WGLEW_NV_render_depth_texture) #endif /* WGL_NV_render_depth_texture */ /* -------------------- WGL_NV_render_texture_rectangle -------------------- */ #ifndef WGL_NV_render_texture_rectangle #define WGL_NV_render_texture_rectangle 1 #define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 #define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 #define WGL_TEXTURE_RECTANGLE_NV 0x20A2 #define WGLEW_NV_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_NV_render_texture_rectangle) #endif /* WGL_NV_render_texture_rectangle */ /* --------------------------- WGL_NV_swap_group --------------------------- */ #ifndef WGL_NV_swap_group #define WGL_NV_swap_group 1 typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint* count); typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint* maxGroups, GLuint *maxBarriers); typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint* group, GLuint *barrier); typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); #define wglBindSwapBarrierNV WGLEW_GET_FUN(__wglewBindSwapBarrierNV) #define wglJoinSwapGroupNV WGLEW_GET_FUN(__wglewJoinSwapGroupNV) #define wglQueryFrameCountNV WGLEW_GET_FUN(__wglewQueryFrameCountNV) #define wglQueryMaxSwapGroupsNV WGLEW_GET_FUN(__wglewQueryMaxSwapGroupsNV) #define wglQuerySwapGroupNV WGLEW_GET_FUN(__wglewQuerySwapGroupNV) #define wglResetFrameCountNV WGLEW_GET_FUN(__wglewResetFrameCountNV) #define WGLEW_NV_swap_group WGLEW_GET_VAR(__WGLEW_NV_swap_group) #endif /* WGL_NV_swap_group */ /* ----------------------- WGL_NV_vertex_array_range ----------------------- */ #ifndef WGL_NV_vertex_array_range #define WGL_NV_vertex_array_range 1 typedef void * (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); #define wglAllocateMemoryNV WGLEW_GET_FUN(__wglewAllocateMemoryNV) #define wglFreeMemoryNV WGLEW_GET_FUN(__wglewFreeMemoryNV) #define WGLEW_NV_vertex_array_range WGLEW_GET_VAR(__WGLEW_NV_vertex_array_range) #endif /* WGL_NV_vertex_array_range */ /* -------------------------- WGL_NV_video_capture ------------------------- */ #ifndef WGL_NV_video_capture #define WGL_NV_video_capture 1 #define WGL_UNIQUE_ID_NV 0x20CE #define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF DECLARE_HANDLE(HVIDEOINPUTDEVICENV); 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); #define wglBindVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewBindVideoCaptureDeviceNV) #define wglEnumerateVideoCaptureDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoCaptureDevicesNV) #define wglLockVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewLockVideoCaptureDeviceNV) #define wglQueryVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewQueryVideoCaptureDeviceNV) #define wglReleaseVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoCaptureDeviceNV) #define WGLEW_NV_video_capture WGLEW_GET_VAR(__WGLEW_NV_video_capture) #endif /* WGL_NV_video_capture */ /* -------------------------- WGL_NV_video_output -------------------------- */ #ifndef WGL_NV_video_output #define WGL_NV_video_output 1 #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 DECLARE_HANDLE(HPVIDEODEV); typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV* hVideoDevice); typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long* pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long* pulCounterPbuffer, BOOL bBlock); #define wglBindVideoImageNV WGLEW_GET_FUN(__wglewBindVideoImageNV) #define wglGetVideoDeviceNV WGLEW_GET_FUN(__wglewGetVideoDeviceNV) #define wglGetVideoInfoNV WGLEW_GET_FUN(__wglewGetVideoInfoNV) #define wglReleaseVideoDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoDeviceNV) #define wglReleaseVideoImageNV WGLEW_GET_FUN(__wglewReleaseVideoImageNV) #define wglSendPbufferToVideoNV WGLEW_GET_FUN(__wglewSendPbufferToVideoNV) #define WGLEW_NV_video_output WGLEW_GET_VAR(__WGLEW_NV_video_output) #endif /* WGL_NV_video_output */ /* -------------------------- WGL_OML_sync_control ------------------------- */ #ifndef WGL_OML_sync_control #define WGL_OML_sync_control 1 typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32* numerator, INT32 *denominator); typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64* ust, INT64 *msc, INT64 *sbc); 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); #define wglGetMscRateOML WGLEW_GET_FUN(__wglewGetMscRateOML) #define wglGetSyncValuesOML WGLEW_GET_FUN(__wglewGetSyncValuesOML) #define wglSwapBuffersMscOML WGLEW_GET_FUN(__wglewSwapBuffersMscOML) #define wglSwapLayerBuffersMscOML WGLEW_GET_FUN(__wglewSwapLayerBuffersMscOML) #define wglWaitForMscOML WGLEW_GET_FUN(__wglewWaitForMscOML) #define wglWaitForSbcOML WGLEW_GET_FUN(__wglewWaitForSbcOML) #define WGLEW_OML_sync_control WGLEW_GET_VAR(__WGLEW_OML_sync_control) #endif /* WGL_OML_sync_control */ /* ------------------------------------------------------------------------- */ #ifdef GLEW_MX #define WGLEW_FUN_EXPORT #define WGLEW_VAR_EXPORT #else #define WGLEW_FUN_EXPORT GLEW_FUN_EXPORT #define WGLEW_VAR_EXPORT GLEW_VAR_EXPORT #endif /* GLEW_MX */ #ifdef GLEW_MX struct WGLEWContextStruct { #endif /* GLEW_MX */ WGLEW_FUN_EXPORT PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL; WGLEW_FUN_EXPORT PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD; WGLEW_FUN_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD; WGLEW_FUN_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD; WGLEW_FUN_EXPORT PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD; WGLEW_FUN_EXPORT PFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD; WGLEW_FUN_EXPORT PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD; WGLEW_FUN_EXPORT PFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD; WGLEW_FUN_EXPORT PFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD; WGLEW_FUN_EXPORT PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD; WGLEW_FUN_EXPORT PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB; WGLEW_FUN_EXPORT PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB; WGLEW_FUN_EXPORT PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB; WGLEW_FUN_EXPORT PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB; WGLEW_FUN_EXPORT PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB; WGLEW_FUN_EXPORT PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB; WGLEW_FUN_EXPORT PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB; WGLEW_FUN_EXPORT PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB; WGLEW_FUN_EXPORT PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB; WGLEW_FUN_EXPORT PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB; WGLEW_FUN_EXPORT PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB; WGLEW_FUN_EXPORT PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB; WGLEW_FUN_EXPORT PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB; WGLEW_FUN_EXPORT PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB; WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB; WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB; WGLEW_FUN_EXPORT PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB; WGLEW_FUN_EXPORT PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB; WGLEW_FUN_EXPORT PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB; WGLEW_FUN_EXPORT PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT; WGLEW_FUN_EXPORT PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT; WGLEW_FUN_EXPORT PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT; WGLEW_FUN_EXPORT PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT; WGLEW_FUN_EXPORT PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT; WGLEW_FUN_EXPORT PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT; WGLEW_FUN_EXPORT PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT; WGLEW_FUN_EXPORT PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT; WGLEW_FUN_EXPORT PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT; WGLEW_FUN_EXPORT PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT; WGLEW_FUN_EXPORT PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT; WGLEW_FUN_EXPORT PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT; WGLEW_FUN_EXPORT PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT; WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT; WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT; WGLEW_FUN_EXPORT PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT; WGLEW_FUN_EXPORT PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT; WGLEW_FUN_EXPORT PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D; WGLEW_FUN_EXPORT PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D; WGLEW_FUN_EXPORT PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D; WGLEW_FUN_EXPORT PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D; WGLEW_FUN_EXPORT PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D; WGLEW_FUN_EXPORT PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D; WGLEW_FUN_EXPORT PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D; WGLEW_FUN_EXPORT PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D; WGLEW_FUN_EXPORT PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D; WGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D; WGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D; WGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D; WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D; WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D; WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D; WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D; WGLEW_FUN_EXPORT PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D; WGLEW_FUN_EXPORT PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D; WGLEW_FUN_EXPORT PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D; WGLEW_FUN_EXPORT PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D; WGLEW_FUN_EXPORT PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D; WGLEW_FUN_EXPORT PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D; WGLEW_FUN_EXPORT PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D; WGLEW_FUN_EXPORT PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D; WGLEW_FUN_EXPORT PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D; WGLEW_FUN_EXPORT PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D; WGLEW_FUN_EXPORT PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D; WGLEW_FUN_EXPORT PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D; WGLEW_FUN_EXPORT PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D; WGLEW_FUN_EXPORT PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D; WGLEW_FUN_EXPORT PFNWGLDXCLOSEDEVICENVPROC __wglewDXCloseDeviceNV; WGLEW_FUN_EXPORT PFNWGLDXLOCKOBJECTSNVPROC __wglewDXLockObjectsNV; WGLEW_FUN_EXPORT PFNWGLDXOBJECTACCESSNVPROC __wglewDXObjectAccessNV; WGLEW_FUN_EXPORT PFNWGLDXOPENDEVICENVPROC __wglewDXOpenDeviceNV; WGLEW_FUN_EXPORT PFNWGLDXREGISTEROBJECTNVPROC __wglewDXRegisterObjectNV; WGLEW_FUN_EXPORT PFNWGLDXSETRESOURCESHAREHANDLENVPROC __wglewDXSetResourceShareHandleNV; WGLEW_FUN_EXPORT PFNWGLDXUNLOCKOBJECTSNVPROC __wglewDXUnlockObjectsNV; WGLEW_FUN_EXPORT PFNWGLDXUNREGISTEROBJECTNVPROC __wglewDXUnregisterObjectNV; WGLEW_FUN_EXPORT PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV; WGLEW_FUN_EXPORT PFNWGLDELAYBEFORESWAPNVPROC __wglewDelayBeforeSwapNV; WGLEW_FUN_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV; WGLEW_FUN_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV; WGLEW_FUN_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV; WGLEW_FUN_EXPORT PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV; WGLEW_FUN_EXPORT PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV; WGLEW_FUN_EXPORT PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV; WGLEW_FUN_EXPORT PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV; WGLEW_FUN_EXPORT PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV; WGLEW_FUN_EXPORT PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV; WGLEW_FUN_EXPORT PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV; WGLEW_FUN_EXPORT PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV; WGLEW_FUN_EXPORT PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV; WGLEW_FUN_EXPORT PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV; WGLEW_FUN_EXPORT PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV; WGLEW_FUN_EXPORT PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV; WGLEW_FUN_EXPORT PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV; WGLEW_FUN_EXPORT PFNWGLBINDVIDEOCAPTUREDEVICENVPROC __wglewBindVideoCaptureDeviceNV; WGLEW_FUN_EXPORT PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC __wglewEnumerateVideoCaptureDevicesNV; WGLEW_FUN_EXPORT PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC __wglewLockVideoCaptureDeviceNV; WGLEW_FUN_EXPORT PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC __wglewQueryVideoCaptureDeviceNV; WGLEW_FUN_EXPORT PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC __wglewReleaseVideoCaptureDeviceNV; WGLEW_FUN_EXPORT PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV; WGLEW_FUN_EXPORT PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV; WGLEW_FUN_EXPORT PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV; WGLEW_FUN_EXPORT PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV; WGLEW_FUN_EXPORT PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV; WGLEW_FUN_EXPORT PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV; WGLEW_FUN_EXPORT PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML; WGLEW_FUN_EXPORT PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML; WGLEW_FUN_EXPORT PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML; WGLEW_FUN_EXPORT PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML; WGLEW_FUN_EXPORT PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML; WGLEW_FUN_EXPORT PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML; WGLEW_VAR_EXPORT GLboolean __WGLEW_3DFX_multisample; WGLEW_VAR_EXPORT GLboolean __WGLEW_3DL_stereo_control; WGLEW_VAR_EXPORT GLboolean __WGLEW_AMD_gpu_association; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_buffer_region; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_context_flush_control; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_profile; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_robustness; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_extensions_string; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_framebuffer_sRGB; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_make_current_read; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_multisample; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pbuffer; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pixel_format; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pixel_format_float; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_render_texture; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_robustness_application_isolation; WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_robustness_share_group_isolation; WGLEW_VAR_EXPORT GLboolean __WGLEW_ATI_pixel_format_float; WGLEW_VAR_EXPORT GLboolean __WGLEW_ATI_render_texture_rectangle; WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_create_context_es2_profile; WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_create_context_es_profile; WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_depth_float; WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_display_color_table; WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_extensions_string; WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_framebuffer_sRGB; WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_make_current_read; WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_multisample; WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pbuffer; WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pixel_format; WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pixel_format_packed_float; WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_swap_control; WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_swap_control_tear; WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_digital_video_control; WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_gamma; WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_genlock; WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_image_buffer; WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_swap_frame_lock; WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage; WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop; WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop2; WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_copy_image; WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_delay_before_swap; WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_float_buffer; WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_gpu_affinity; WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_multisample_coverage; WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_present_video; WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_render_depth_texture; WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_render_texture_rectangle; WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_swap_group; WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_vertex_array_range; WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_video_capture; WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_video_output; WGLEW_VAR_EXPORT GLboolean __WGLEW_OML_sync_control; #ifdef GLEW_MX }; /* WGLEWContextStruct */ #endif /* GLEW_MX */ /* ------------------------------------------------------------------------- */ #ifdef GLEW_MX typedef struct WGLEWContextStruct WGLEWContext; GLEWAPI GLenum GLEWAPIENTRY wglewContextInit (WGLEWContext *ctx); GLEWAPI GLboolean GLEWAPIENTRY wglewContextIsSupported (const WGLEWContext *ctx, const char *name); #define wglewInit() wglewContextInit(wglewGetContext()) #define wglewIsSupported(x) wglewContextIsSupported(wglewGetContext(), x) #define WGLEW_GET_VAR(x) (*(const GLboolean*)&(wglewGetContext()->x)) #define WGLEW_GET_FUN(x) wglewGetContext()->x #else /* GLEW_MX */ GLEWAPI GLenum GLEWAPIENTRY wglewInit (); GLEWAPI GLboolean GLEWAPIENTRY wglewIsSupported (const char *name); #define WGLEW_GET_VAR(x) (*(const GLboolean*)&x) #define WGLEW_GET_FUN(x) x #endif /* GLEW_MX */ GLEWAPI GLboolean GLEWAPIENTRY wglewGetExtension (const char *name); #ifdef __cplusplus } #endif #undef GLEWAPI #endif /* __wglew_h__ */ goxel-0.11.0/ext_src/glew/glew.c000066400000000000000000035750431435762723100164510ustar00rootroot00000000000000/* ** The OpenGL Extension Wrangler Library ** Copyright (C) 2008-2015, Nigel Stewart ** Copyright (C) 2002-2008, Milan Ikits ** Copyright (C) 2002-2008, Marcelo E. Magallon ** Copyright (C) 2002, Lev Povalahev ** 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. ** * The name of the author may be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** 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 OWNER 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 #if defined(_WIN32) # include #elif !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX)) # include #endif #include /* For size_t */ /* * Define glewGetContext and related helper macros. */ #ifdef GLEW_MX # define glewGetContext() ctx # ifdef _WIN32 # define GLEW_CONTEXT_ARG_DEF_INIT GLEWContext* ctx # define GLEW_CONTEXT_ARG_VAR_INIT ctx # define wglewGetContext() ctx # define WGLEW_CONTEXT_ARG_DEF_INIT WGLEWContext* ctx # define WGLEW_CONTEXT_ARG_DEF_LIST WGLEWContext* ctx # else /* _WIN32 */ # define GLEW_CONTEXT_ARG_DEF_INIT void # define GLEW_CONTEXT_ARG_VAR_INIT # define glxewGetContext() ctx # define GLXEW_CONTEXT_ARG_DEF_INIT void # define GLXEW_CONTEXT_ARG_DEF_LIST GLXEWContext* ctx # endif /* _WIN32 */ # define GLEW_CONTEXT_ARG_DEF_LIST GLEWContext* ctx #else /* GLEW_MX */ # define GLEW_CONTEXT_ARG_DEF_INIT void # define GLEW_CONTEXT_ARG_VAR_INIT # define GLEW_CONTEXT_ARG_DEF_LIST void # define WGLEW_CONTEXT_ARG_DEF_INIT void # define WGLEW_CONTEXT_ARG_DEF_LIST void # define GLXEW_CONTEXT_ARG_DEF_INIT void # define GLXEW_CONTEXT_ARG_DEF_LIST void #endif /* GLEW_MX */ #if defined(GLEW_REGAL) /* In GLEW_REGAL mode we call direcly into the linked libRegal.so glGetProcAddressREGAL for looking up the GL function pointers. */ # undef glGetProcAddressREGAL # ifdef WIN32 extern void * __stdcall glGetProcAddressREGAL(const GLchar *name); static void * (__stdcall * regalGetProcAddress) (const GLchar *) = glGetProcAddressREGAL; # else extern void * glGetProcAddressREGAL(const GLchar *name); static void * (*regalGetProcAddress) (const GLchar *) = glGetProcAddressREGAL; # endif # define glGetProcAddressREGAL GLEW_GET_FUN(__glewGetProcAddressREGAL) #elif defined(__sgi) || defined (__sun) || defined(__HAIKU__) || defined(GLEW_APPLE_GLX) #include #include #include void* dlGetProcAddress (const GLubyte* name) { static void* h = NULL; static void* gpa; if (h == NULL) { if ((h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL)) == NULL) return NULL; gpa = dlsym(h, "glXGetProcAddress"); } if (gpa != NULL) return ((void*(*)(const GLubyte*))gpa)(name); else return dlsym(h, (const char*)name); } #endif /* __sgi || __sun || GLEW_APPLE_GLX */ #if defined(__APPLE__) #include #include #include #ifdef MAC_OS_X_VERSION_10_3 #include void* NSGLGetProcAddress (const GLubyte *name) { static void* image = NULL; void* addr; if (NULL == image) { image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY); } if( !image ) return NULL; addr = dlsym(image, (const char*)name); if( addr ) return addr; #ifdef GLEW_APPLE_GLX return dlGetProcAddress( name ); // try next for glx symbols #else return NULL; #endif } #else #include void* NSGLGetProcAddress (const GLubyte *name) { static const struct mach_header* image = NULL; NSSymbol symbol; char* symbolName; if (NULL == image) { image = NSAddImage("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", NSADDIMAGE_OPTION_RETURN_ON_ERROR); } /* prepend a '_' for the Unix C symbol mangling convention */ symbolName = malloc(strlen((const char*)name) + 2); strcpy(symbolName+1, (const char*)name); symbolName[0] = '_'; symbol = NULL; /* if (NSIsSymbolNameDefined(symbolName)) symbol = NSLookupAndBindSymbol(symbolName); */ symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : NULL; free(symbolName); if( symbol ) return NSAddressOfSymbol(symbol); #ifdef GLEW_APPLE_GLX return dlGetProcAddress( name ); // try next for glx symbols #else return NULL; #endif } #endif /* MAC_OS_X_VERSION_10_3 */ #endif /* __APPLE__ */ /* * Define glewGetProcAddress. */ #if defined(GLEW_REGAL) # define glewGetProcAddress(name) regalGetProcAddress((const GLchar *) name) #elif defined(_WIN32) # define glewGetProcAddress(name) wglGetProcAddress((LPCSTR)name) #elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) # define glewGetProcAddress(name) NSGLGetProcAddress(name) #elif defined(__sgi) || defined(__sun) || defined(__HAIKU__) # define glewGetProcAddress(name) dlGetProcAddress(name) #elif defined(__ANDROID__) # define glewGetProcAddress(name) NULL /* TODO */ #elif defined(__native_client__) # define glewGetProcAddress(name) NULL /* TODO */ #else /* __linux */ # define glewGetProcAddress(name) (*glXGetProcAddressARB)(name) #endif /* * Redefine GLEW_GET_VAR etc without const cast */ #undef GLEW_GET_VAR #ifdef GLEW_MX # define GLEW_GET_VAR(x) (glewGetContext()->x) #else /* GLEW_MX */ # define GLEW_GET_VAR(x) (x) #endif /* GLEW_MX */ #ifdef WGLEW_GET_VAR # undef WGLEW_GET_VAR # ifdef GLEW_MX # define WGLEW_GET_VAR(x) (wglewGetContext()->x) # else /* GLEW_MX */ # define WGLEW_GET_VAR(x) (x) # endif /* GLEW_MX */ #endif /* WGLEW_GET_VAR */ #ifdef GLXEW_GET_VAR # undef GLXEW_GET_VAR # ifdef GLEW_MX # define GLXEW_GET_VAR(x) (glxewGetContext()->x) # else /* GLEW_MX */ # define GLXEW_GET_VAR(x) (x) # endif /* GLEW_MX */ #endif /* GLXEW_GET_VAR */ /* * GLEW, just like OpenGL or GLU, does not rely on the standard C library. * These functions implement the functionality required in this file. */ static GLuint _glewStrLen (const GLubyte* s) { GLuint i=0; if (s == NULL) return 0; while (s[i] != '\0') i++; return i; } static GLuint _glewStrCLen (const GLubyte* s, GLubyte c) { GLuint i=0; if (s == NULL) return 0; while (s[i] != '\0' && s[i] != c) i++; return (s[i] == '\0' || s[i] == c) ? i : 0; } static GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n) { GLuint i=0; if(a == NULL || b == NULL) return (a == NULL && b == NULL && n == 0) ? GL_TRUE : GL_FALSE; while (i < n && a[i] != '\0' && b[i] != '\0' && a[i] == b[i]) i++; return i == n ? GL_TRUE : GL_FALSE; } static GLboolean _glewStrSame1 (const GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) { while (*na > 0 && (**a == ' ' || **a == '\n' || **a == '\r' || **a == '\t')) { (*a)++; (*na)--; } if(*na >= nb) { GLuint i=0; while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++; if(i == nb) { *a = *a + nb; *na = *na - nb; return GL_TRUE; } } return GL_FALSE; } static GLboolean _glewStrSame2 (const GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) { if(*na >= nb) { GLuint i=0; while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++; if(i == nb) { *a = *a + nb; *na = *na - nb; return GL_TRUE; } } return GL_FALSE; } static GLboolean _glewStrSame3 (const GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) { if(*na >= nb) { GLuint i=0; while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++; if (i == nb && (*na == nb || (*a)[i] == ' ' || (*a)[i] == '\n' || (*a)[i] == '\r' || (*a)[i] == '\t')) { *a = *a + nb; *na = *na - nb; return GL_TRUE; } } return GL_FALSE; } /* * Search for name in the extensions string. Use of strstr() * is not sufficient because extension names can be prefixes of * other extension names. Could use strtok() but the constant * string returned by glGetString might be in read-only memory. */ static GLboolean _glewSearchExtension (const char* name, const GLubyte *start, const GLubyte *end) { const GLubyte* p; GLuint len = _glewStrLen((const GLubyte*)name); p = start; while (p < end) { GLuint n = _glewStrCLen(p, ' '); if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE; p += n+1; } return GL_FALSE; } #if !defined(_WIN32) || !defined(GLEW_MX) PFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D = NULL; PFNGLDRAWRANGEELEMENTSPROC __glewDrawRangeElements = NULL; PFNGLTEXIMAGE3DPROC __glewTexImage3D = NULL; PFNGLTEXSUBIMAGE3DPROC __glewTexSubImage3D = NULL; PFNGLACTIVETEXTUREPROC __glewActiveTexture = NULL; PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture = NULL; PFNGLCOMPRESSEDTEXIMAGE1DPROC __glewCompressedTexImage1D = NULL; PFNGLCOMPRESSEDTEXIMAGE2DPROC __glewCompressedTexImage2D = NULL; PFNGLCOMPRESSEDTEXIMAGE3DPROC __glewCompressedTexImage3D = NULL; PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC __glewCompressedTexSubImage1D = NULL; PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC __glewCompressedTexSubImage2D = NULL; PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC __glewCompressedTexSubImage3D = NULL; PFNGLGETCOMPRESSEDTEXIMAGEPROC __glewGetCompressedTexImage = NULL; PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd = NULL; PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf = NULL; PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd = NULL; PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf = NULL; PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d = NULL; PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv = NULL; PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f = NULL; PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv = NULL; PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i = NULL; PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv = NULL; PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s = NULL; PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv = NULL; PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d = NULL; PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv = NULL; PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f = NULL; PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv = NULL; PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i = NULL; PFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv = NULL; PFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s = NULL; PFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv = NULL; PFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d = NULL; PFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv = NULL; PFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f = NULL; PFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv = NULL; PFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i = NULL; PFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv = NULL; PFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s = NULL; PFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv = NULL; PFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d = NULL; PFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv = NULL; PFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f = NULL; PFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv = NULL; PFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i = NULL; PFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv = NULL; PFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s = NULL; PFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv = NULL; PFNGLSAMPLECOVERAGEPROC __glewSampleCoverage = NULL; PFNGLBLENDCOLORPROC __glewBlendColor = NULL; PFNGLBLENDEQUATIONPROC __glewBlendEquation = NULL; PFNGLBLENDFUNCSEPARATEPROC __glewBlendFuncSeparate = NULL; PFNGLFOGCOORDPOINTERPROC __glewFogCoordPointer = NULL; PFNGLFOGCOORDDPROC __glewFogCoordd = NULL; PFNGLFOGCOORDDVPROC __glewFogCoorddv = NULL; PFNGLFOGCOORDFPROC __glewFogCoordf = NULL; PFNGLFOGCOORDFVPROC __glewFogCoordfv = NULL; PFNGLMULTIDRAWARRAYSPROC __glewMultiDrawArrays = NULL; PFNGLMULTIDRAWELEMENTSPROC __glewMultiDrawElements = NULL; PFNGLPOINTPARAMETERFPROC __glewPointParameterf = NULL; PFNGLPOINTPARAMETERFVPROC __glewPointParameterfv = NULL; PFNGLPOINTPARAMETERIPROC __glewPointParameteri = NULL; PFNGLPOINTPARAMETERIVPROC __glewPointParameteriv = NULL; PFNGLSECONDARYCOLOR3BPROC __glewSecondaryColor3b = NULL; PFNGLSECONDARYCOLOR3BVPROC __glewSecondaryColor3bv = NULL; PFNGLSECONDARYCOLOR3DPROC __glewSecondaryColor3d = NULL; PFNGLSECONDARYCOLOR3DVPROC __glewSecondaryColor3dv = NULL; PFNGLSECONDARYCOLOR3FPROC __glewSecondaryColor3f = NULL; PFNGLSECONDARYCOLOR3FVPROC __glewSecondaryColor3fv = NULL; PFNGLSECONDARYCOLOR3IPROC __glewSecondaryColor3i = NULL; PFNGLSECONDARYCOLOR3IVPROC __glewSecondaryColor3iv = NULL; PFNGLSECONDARYCOLOR3SPROC __glewSecondaryColor3s = NULL; PFNGLSECONDARYCOLOR3SVPROC __glewSecondaryColor3sv = NULL; PFNGLSECONDARYCOLOR3UBPROC __glewSecondaryColor3ub = NULL; PFNGLSECONDARYCOLOR3UBVPROC __glewSecondaryColor3ubv = NULL; PFNGLSECONDARYCOLOR3UIPROC __glewSecondaryColor3ui = NULL; PFNGLSECONDARYCOLOR3UIVPROC __glewSecondaryColor3uiv = NULL; PFNGLSECONDARYCOLOR3USPROC __glewSecondaryColor3us = NULL; PFNGLSECONDARYCOLOR3USVPROC __glewSecondaryColor3usv = NULL; PFNGLSECONDARYCOLORPOINTERPROC __glewSecondaryColorPointer = NULL; PFNGLWINDOWPOS2DPROC __glewWindowPos2d = NULL; PFNGLWINDOWPOS2DVPROC __glewWindowPos2dv = NULL; PFNGLWINDOWPOS2FPROC __glewWindowPos2f = NULL; PFNGLWINDOWPOS2FVPROC __glewWindowPos2fv = NULL; PFNGLWINDOWPOS2IPROC __glewWindowPos2i = NULL; PFNGLWINDOWPOS2IVPROC __glewWindowPos2iv = NULL; PFNGLWINDOWPOS2SPROC __glewWindowPos2s = NULL; PFNGLWINDOWPOS2SVPROC __glewWindowPos2sv = NULL; PFNGLWINDOWPOS3DPROC __glewWindowPos3d = NULL; PFNGLWINDOWPOS3DVPROC __glewWindowPos3dv = NULL; PFNGLWINDOWPOS3FPROC __glewWindowPos3f = NULL; PFNGLWINDOWPOS3FVPROC __glewWindowPos3fv = NULL; PFNGLWINDOWPOS3IPROC __glewWindowPos3i = NULL; PFNGLWINDOWPOS3IVPROC __glewWindowPos3iv = NULL; PFNGLWINDOWPOS3SPROC __glewWindowPos3s = NULL; PFNGLWINDOWPOS3SVPROC __glewWindowPos3sv = NULL; PFNGLBEGINQUERYPROC __glewBeginQuery = NULL; PFNGLBINDBUFFERPROC __glewBindBuffer = NULL; PFNGLBUFFERDATAPROC __glewBufferData = NULL; PFNGLBUFFERSUBDATAPROC __glewBufferSubData = NULL; PFNGLDELETEBUFFERSPROC __glewDeleteBuffers = NULL; PFNGLDELETEQUERIESPROC __glewDeleteQueries = NULL; PFNGLENDQUERYPROC __glewEndQuery = NULL; PFNGLGENBUFFERSPROC __glewGenBuffers = NULL; PFNGLGENQUERIESPROC __glewGenQueries = NULL; PFNGLGETBUFFERPARAMETERIVPROC __glewGetBufferParameteriv = NULL; PFNGLGETBUFFERPOINTERVPROC __glewGetBufferPointerv = NULL; PFNGLGETBUFFERSUBDATAPROC __glewGetBufferSubData = NULL; PFNGLGETQUERYOBJECTIVPROC __glewGetQueryObjectiv = NULL; PFNGLGETQUERYOBJECTUIVPROC __glewGetQueryObjectuiv = NULL; PFNGLGETQUERYIVPROC __glewGetQueryiv = NULL; PFNGLISBUFFERPROC __glewIsBuffer = NULL; PFNGLISQUERYPROC __glewIsQuery = NULL; PFNGLMAPBUFFERPROC __glewMapBuffer = NULL; PFNGLUNMAPBUFFERPROC __glewUnmapBuffer = NULL; PFNGLATTACHSHADERPROC __glewAttachShader = NULL; PFNGLBINDATTRIBLOCATIONPROC __glewBindAttribLocation = NULL; PFNGLBLENDEQUATIONSEPARATEPROC __glewBlendEquationSeparate = NULL; PFNGLCOMPILESHADERPROC __glewCompileShader = NULL; PFNGLCREATEPROGRAMPROC __glewCreateProgram = NULL; PFNGLCREATESHADERPROC __glewCreateShader = NULL; PFNGLDELETEPROGRAMPROC __glewDeleteProgram = NULL; PFNGLDELETESHADERPROC __glewDeleteShader = NULL; PFNGLDETACHSHADERPROC __glewDetachShader = NULL; PFNGLDISABLEVERTEXATTRIBARRAYPROC __glewDisableVertexAttribArray = NULL; PFNGLDRAWBUFFERSPROC __glewDrawBuffers = NULL; PFNGLENABLEVERTEXATTRIBARRAYPROC __glewEnableVertexAttribArray = NULL; PFNGLGETACTIVEATTRIBPROC __glewGetActiveAttrib = NULL; PFNGLGETACTIVEUNIFORMPROC __glewGetActiveUniform = NULL; PFNGLGETATTACHEDSHADERSPROC __glewGetAttachedShaders = NULL; PFNGLGETATTRIBLOCATIONPROC __glewGetAttribLocation = NULL; PFNGLGETPROGRAMINFOLOGPROC __glewGetProgramInfoLog = NULL; PFNGLGETPROGRAMIVPROC __glewGetProgramiv = NULL; PFNGLGETSHADERINFOLOGPROC __glewGetShaderInfoLog = NULL; PFNGLGETSHADERSOURCEPROC __glewGetShaderSource = NULL; PFNGLGETSHADERIVPROC __glewGetShaderiv = NULL; PFNGLGETUNIFORMLOCATIONPROC __glewGetUniformLocation = NULL; PFNGLGETUNIFORMFVPROC __glewGetUniformfv = NULL; PFNGLGETUNIFORMIVPROC __glewGetUniformiv = NULL; PFNGLGETVERTEXATTRIBPOINTERVPROC __glewGetVertexAttribPointerv = NULL; PFNGLGETVERTEXATTRIBDVPROC __glewGetVertexAttribdv = NULL; PFNGLGETVERTEXATTRIBFVPROC __glewGetVertexAttribfv = NULL; PFNGLGETVERTEXATTRIBIVPROC __glewGetVertexAttribiv = NULL; PFNGLISPROGRAMPROC __glewIsProgram = NULL; PFNGLISSHADERPROC __glewIsShader = NULL; PFNGLLINKPROGRAMPROC __glewLinkProgram = NULL; PFNGLSHADERSOURCEPROC __glewShaderSource = NULL; PFNGLSTENCILFUNCSEPARATEPROC __glewStencilFuncSeparate = NULL; PFNGLSTENCILMASKSEPARATEPROC __glewStencilMaskSeparate = NULL; PFNGLSTENCILOPSEPARATEPROC __glewStencilOpSeparate = NULL; PFNGLUNIFORM1FPROC __glewUniform1f = NULL; PFNGLUNIFORM1FVPROC __glewUniform1fv = NULL; PFNGLUNIFORM1IPROC __glewUniform1i = NULL; PFNGLUNIFORM1IVPROC __glewUniform1iv = NULL; PFNGLUNIFORM2FPROC __glewUniform2f = NULL; PFNGLUNIFORM2FVPROC __glewUniform2fv = NULL; PFNGLUNIFORM2IPROC __glewUniform2i = NULL; PFNGLUNIFORM2IVPROC __glewUniform2iv = NULL; PFNGLUNIFORM3FPROC __glewUniform3f = NULL; PFNGLUNIFORM3FVPROC __glewUniform3fv = NULL; PFNGLUNIFORM3IPROC __glewUniform3i = NULL; PFNGLUNIFORM3IVPROC __glewUniform3iv = NULL; PFNGLUNIFORM4FPROC __glewUniform4f = NULL; PFNGLUNIFORM4FVPROC __glewUniform4fv = NULL; PFNGLUNIFORM4IPROC __glewUniform4i = NULL; PFNGLUNIFORM4IVPROC __glewUniform4iv = NULL; PFNGLUNIFORMMATRIX2FVPROC __glewUniformMatrix2fv = NULL; PFNGLUNIFORMMATRIX3FVPROC __glewUniformMatrix3fv = NULL; PFNGLUNIFORMMATRIX4FVPROC __glewUniformMatrix4fv = NULL; PFNGLUSEPROGRAMPROC __glewUseProgram = NULL; PFNGLVALIDATEPROGRAMPROC __glewValidateProgram = NULL; PFNGLVERTEXATTRIB1DPROC __glewVertexAttrib1d = NULL; PFNGLVERTEXATTRIB1DVPROC __glewVertexAttrib1dv = NULL; PFNGLVERTEXATTRIB1FPROC __glewVertexAttrib1f = NULL; PFNGLVERTEXATTRIB1FVPROC __glewVertexAttrib1fv = NULL; PFNGLVERTEXATTRIB1SPROC __glewVertexAttrib1s = NULL; PFNGLVERTEXATTRIB1SVPROC __glewVertexAttrib1sv = NULL; PFNGLVERTEXATTRIB2DPROC __glewVertexAttrib2d = NULL; PFNGLVERTEXATTRIB2DVPROC __glewVertexAttrib2dv = NULL; PFNGLVERTEXATTRIB2FPROC __glewVertexAttrib2f = NULL; PFNGLVERTEXATTRIB2FVPROC __glewVertexAttrib2fv = NULL; PFNGLVERTEXATTRIB2SPROC __glewVertexAttrib2s = NULL; PFNGLVERTEXATTRIB2SVPROC __glewVertexAttrib2sv = NULL; PFNGLVERTEXATTRIB3DPROC __glewVertexAttrib3d = NULL; PFNGLVERTEXATTRIB3DVPROC __glewVertexAttrib3dv = NULL; PFNGLVERTEXATTRIB3FPROC __glewVertexAttrib3f = NULL; PFNGLVERTEXATTRIB3FVPROC __glewVertexAttrib3fv = NULL; PFNGLVERTEXATTRIB3SPROC __glewVertexAttrib3s = NULL; PFNGLVERTEXATTRIB3SVPROC __glewVertexAttrib3sv = NULL; PFNGLVERTEXATTRIB4NBVPROC __glewVertexAttrib4Nbv = NULL; PFNGLVERTEXATTRIB4NIVPROC __glewVertexAttrib4Niv = NULL; PFNGLVERTEXATTRIB4NSVPROC __glewVertexAttrib4Nsv = NULL; PFNGLVERTEXATTRIB4NUBPROC __glewVertexAttrib4Nub = NULL; PFNGLVERTEXATTRIB4NUBVPROC __glewVertexAttrib4Nubv = NULL; PFNGLVERTEXATTRIB4NUIVPROC __glewVertexAttrib4Nuiv = NULL; PFNGLVERTEXATTRIB4NUSVPROC __glewVertexAttrib4Nusv = NULL; PFNGLVERTEXATTRIB4BVPROC __glewVertexAttrib4bv = NULL; PFNGLVERTEXATTRIB4DPROC __glewVertexAttrib4d = NULL; PFNGLVERTEXATTRIB4DVPROC __glewVertexAttrib4dv = NULL; PFNGLVERTEXATTRIB4FPROC __glewVertexAttrib4f = NULL; PFNGLVERTEXATTRIB4FVPROC __glewVertexAttrib4fv = NULL; PFNGLVERTEXATTRIB4IVPROC __glewVertexAttrib4iv = NULL; PFNGLVERTEXATTRIB4SPROC __glewVertexAttrib4s = NULL; PFNGLVERTEXATTRIB4SVPROC __glewVertexAttrib4sv = NULL; PFNGLVERTEXATTRIB4UBVPROC __glewVertexAttrib4ubv = NULL; PFNGLVERTEXATTRIB4UIVPROC __glewVertexAttrib4uiv = NULL; PFNGLVERTEXATTRIB4USVPROC __glewVertexAttrib4usv = NULL; PFNGLVERTEXATTRIBPOINTERPROC __glewVertexAttribPointer = NULL; PFNGLUNIFORMMATRIX2X3FVPROC __glewUniformMatrix2x3fv = NULL; PFNGLUNIFORMMATRIX2X4FVPROC __glewUniformMatrix2x4fv = NULL; PFNGLUNIFORMMATRIX3X2FVPROC __glewUniformMatrix3x2fv = NULL; PFNGLUNIFORMMATRIX3X4FVPROC __glewUniformMatrix3x4fv = NULL; PFNGLUNIFORMMATRIX4X2FVPROC __glewUniformMatrix4x2fv = NULL; PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv = NULL; PFNGLBEGINCONDITIONALRENDERPROC __glewBeginConditionalRender = NULL; PFNGLBEGINTRANSFORMFEEDBACKPROC __glewBeginTransformFeedback = NULL; PFNGLBINDFRAGDATALOCATIONPROC __glewBindFragDataLocation = NULL; PFNGLCLAMPCOLORPROC __glewClampColor = NULL; PFNGLCLEARBUFFERFIPROC __glewClearBufferfi = NULL; PFNGLCLEARBUFFERFVPROC __glewClearBufferfv = NULL; PFNGLCLEARBUFFERIVPROC __glewClearBufferiv = NULL; PFNGLCLEARBUFFERUIVPROC __glewClearBufferuiv = NULL; PFNGLCOLORMASKIPROC __glewColorMaski = NULL; PFNGLDISABLEIPROC __glewDisablei = NULL; PFNGLENABLEIPROC __glewEnablei = NULL; PFNGLENDCONDITIONALRENDERPROC __glewEndConditionalRender = NULL; PFNGLENDTRANSFORMFEEDBACKPROC __glewEndTransformFeedback = NULL; PFNGLGETBOOLEANI_VPROC __glewGetBooleani_v = NULL; PFNGLGETFRAGDATALOCATIONPROC __glewGetFragDataLocation = NULL; PFNGLGETSTRINGIPROC __glewGetStringi = NULL; PFNGLGETTEXPARAMETERIIVPROC __glewGetTexParameterIiv = NULL; PFNGLGETTEXPARAMETERIUIVPROC __glewGetTexParameterIuiv = NULL; PFNGLGETTRANSFORMFEEDBACKVARYINGPROC __glewGetTransformFeedbackVarying = NULL; PFNGLGETUNIFORMUIVPROC __glewGetUniformuiv = NULL; PFNGLGETVERTEXATTRIBIIVPROC __glewGetVertexAttribIiv = NULL; PFNGLGETVERTEXATTRIBIUIVPROC __glewGetVertexAttribIuiv = NULL; PFNGLISENABLEDIPROC __glewIsEnabledi = NULL; PFNGLTEXPARAMETERIIVPROC __glewTexParameterIiv = NULL; PFNGLTEXPARAMETERIUIVPROC __glewTexParameterIuiv = NULL; PFNGLTRANSFORMFEEDBACKVARYINGSPROC __glewTransformFeedbackVaryings = NULL; PFNGLUNIFORM1UIPROC __glewUniform1ui = NULL; PFNGLUNIFORM1UIVPROC __glewUniform1uiv = NULL; PFNGLUNIFORM2UIPROC __glewUniform2ui = NULL; PFNGLUNIFORM2UIVPROC __glewUniform2uiv = NULL; PFNGLUNIFORM3UIPROC __glewUniform3ui = NULL; PFNGLUNIFORM3UIVPROC __glewUniform3uiv = NULL; PFNGLUNIFORM4UIPROC __glewUniform4ui = NULL; PFNGLUNIFORM4UIVPROC __glewUniform4uiv = NULL; PFNGLVERTEXATTRIBI1IPROC __glewVertexAttribI1i = NULL; PFNGLVERTEXATTRIBI1IVPROC __glewVertexAttribI1iv = NULL; PFNGLVERTEXATTRIBI1UIPROC __glewVertexAttribI1ui = NULL; PFNGLVERTEXATTRIBI1UIVPROC __glewVertexAttribI1uiv = NULL; PFNGLVERTEXATTRIBI2IPROC __glewVertexAttribI2i = NULL; PFNGLVERTEXATTRIBI2IVPROC __glewVertexAttribI2iv = NULL; PFNGLVERTEXATTRIBI2UIPROC __glewVertexAttribI2ui = NULL; PFNGLVERTEXATTRIBI2UIVPROC __glewVertexAttribI2uiv = NULL; PFNGLVERTEXATTRIBI3IPROC __glewVertexAttribI3i = NULL; PFNGLVERTEXATTRIBI3IVPROC __glewVertexAttribI3iv = NULL; PFNGLVERTEXATTRIBI3UIPROC __glewVertexAttribI3ui = NULL; PFNGLVERTEXATTRIBI3UIVPROC __glewVertexAttribI3uiv = NULL; PFNGLVERTEXATTRIBI4BVPROC __glewVertexAttribI4bv = NULL; PFNGLVERTEXATTRIBI4IPROC __glewVertexAttribI4i = NULL; PFNGLVERTEXATTRIBI4IVPROC __glewVertexAttribI4iv = NULL; PFNGLVERTEXATTRIBI4SVPROC __glewVertexAttribI4sv = NULL; PFNGLVERTEXATTRIBI4UBVPROC __glewVertexAttribI4ubv = NULL; PFNGLVERTEXATTRIBI4UIPROC __glewVertexAttribI4ui = NULL; PFNGLVERTEXATTRIBI4UIVPROC __glewVertexAttribI4uiv = NULL; PFNGLVERTEXATTRIBI4USVPROC __glewVertexAttribI4usv = NULL; PFNGLVERTEXATTRIBIPOINTERPROC __glewVertexAttribIPointer = NULL; PFNGLDRAWARRAYSINSTANCEDPROC __glewDrawArraysInstanced = NULL; PFNGLDRAWELEMENTSINSTANCEDPROC __glewDrawElementsInstanced = NULL; PFNGLPRIMITIVERESTARTINDEXPROC __glewPrimitiveRestartIndex = NULL; PFNGLTEXBUFFERPROC __glewTexBuffer = NULL; PFNGLFRAMEBUFFERTEXTUREPROC __glewFramebufferTexture = NULL; PFNGLGETBUFFERPARAMETERI64VPROC __glewGetBufferParameteri64v = NULL; PFNGLGETINTEGER64I_VPROC __glewGetInteger64i_v = NULL; PFNGLVERTEXATTRIBDIVISORPROC __glewVertexAttribDivisor = NULL; PFNGLBLENDEQUATIONSEPARATEIPROC __glewBlendEquationSeparatei = NULL; PFNGLBLENDEQUATIONIPROC __glewBlendEquationi = NULL; PFNGLBLENDFUNCSEPARATEIPROC __glewBlendFuncSeparatei = NULL; PFNGLBLENDFUNCIPROC __glewBlendFunci = NULL; PFNGLMINSAMPLESHADINGPROC __glewMinSampleShading = NULL; PFNGLGETGRAPHICSRESETSTATUSPROC __glewGetGraphicsResetStatus = NULL; PFNGLGETNCOMPRESSEDTEXIMAGEPROC __glewGetnCompressedTexImage = NULL; PFNGLGETNTEXIMAGEPROC __glewGetnTexImage = NULL; PFNGLGETNUNIFORMDVPROC __glewGetnUniformdv = NULL; PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX = NULL; PFNGLDEBUGMESSAGECALLBACKAMDPROC __glewDebugMessageCallbackAMD = NULL; PFNGLDEBUGMESSAGEENABLEAMDPROC __glewDebugMessageEnableAMD = NULL; PFNGLDEBUGMESSAGEINSERTAMDPROC __glewDebugMessageInsertAMD = NULL; PFNGLGETDEBUGMESSAGELOGAMDPROC __glewGetDebugMessageLogAMD = NULL; PFNGLBLENDEQUATIONINDEXEDAMDPROC __glewBlendEquationIndexedAMD = NULL; PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC __glewBlendEquationSeparateIndexedAMD = NULL; PFNGLBLENDFUNCINDEXEDAMDPROC __glewBlendFuncIndexedAMD = NULL; PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC __glewBlendFuncSeparateIndexedAMD = NULL; PFNGLVERTEXATTRIBPARAMETERIAMDPROC __glewVertexAttribParameteriAMD = NULL; PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC __glewMultiDrawArraysIndirectAMD = NULL; PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC __glewMultiDrawElementsIndirectAMD = NULL; PFNGLDELETENAMESAMDPROC __glewDeleteNamesAMD = NULL; PFNGLGENNAMESAMDPROC __glewGenNamesAMD = NULL; PFNGLISNAMEAMDPROC __glewIsNameAMD = NULL; PFNGLQUERYOBJECTPARAMETERUIAMDPROC __glewQueryObjectParameteruiAMD = NULL; PFNGLBEGINPERFMONITORAMDPROC __glewBeginPerfMonitorAMD = NULL; PFNGLDELETEPERFMONITORSAMDPROC __glewDeletePerfMonitorsAMD = NULL; PFNGLENDPERFMONITORAMDPROC __glewEndPerfMonitorAMD = NULL; PFNGLGENPERFMONITORSAMDPROC __glewGenPerfMonitorsAMD = NULL; PFNGLGETPERFMONITORCOUNTERDATAAMDPROC __glewGetPerfMonitorCounterDataAMD = NULL; PFNGLGETPERFMONITORCOUNTERINFOAMDPROC __glewGetPerfMonitorCounterInfoAMD = NULL; PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC __glewGetPerfMonitorCounterStringAMD = NULL; PFNGLGETPERFMONITORCOUNTERSAMDPROC __glewGetPerfMonitorCountersAMD = NULL; PFNGLGETPERFMONITORGROUPSTRINGAMDPROC __glewGetPerfMonitorGroupStringAMD = NULL; PFNGLGETPERFMONITORGROUPSAMDPROC __glewGetPerfMonitorGroupsAMD = NULL; PFNGLSELECTPERFMONITORCOUNTERSAMDPROC __glewSelectPerfMonitorCountersAMD = NULL; PFNGLSETMULTISAMPLEFVAMDPROC __glewSetMultisamplefvAMD = NULL; PFNGLTEXSTORAGESPARSEAMDPROC __glewTexStorageSparseAMD = NULL; PFNGLTEXTURESTORAGESPARSEAMDPROC __glewTextureStorageSparseAMD = NULL; PFNGLSTENCILOPVALUEAMDPROC __glewStencilOpValueAMD = NULL; PFNGLTESSELLATIONFACTORAMDPROC __glewTessellationFactorAMD = NULL; PFNGLTESSELLATIONMODEAMDPROC __glewTessellationModeAMD = NULL; PFNGLBLITFRAMEBUFFERANGLEPROC __glewBlitFramebufferANGLE = NULL; PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC __glewRenderbufferStorageMultisampleANGLE = NULL; PFNGLDRAWARRAYSINSTANCEDANGLEPROC __glewDrawArraysInstancedANGLE = NULL; PFNGLDRAWELEMENTSINSTANCEDANGLEPROC __glewDrawElementsInstancedANGLE = NULL; PFNGLVERTEXATTRIBDIVISORANGLEPROC __glewVertexAttribDivisorANGLE = NULL; PFNGLBEGINQUERYANGLEPROC __glewBeginQueryANGLE = NULL; PFNGLDELETEQUERIESANGLEPROC __glewDeleteQueriesANGLE = NULL; PFNGLENDQUERYANGLEPROC __glewEndQueryANGLE = NULL; PFNGLGENQUERIESANGLEPROC __glewGenQueriesANGLE = NULL; PFNGLGETQUERYOBJECTI64VANGLEPROC __glewGetQueryObjecti64vANGLE = NULL; PFNGLGETQUERYOBJECTIVANGLEPROC __glewGetQueryObjectivANGLE = NULL; PFNGLGETQUERYOBJECTUI64VANGLEPROC __glewGetQueryObjectui64vANGLE = NULL; PFNGLGETQUERYOBJECTUIVANGLEPROC __glewGetQueryObjectuivANGLE = NULL; PFNGLGETQUERYIVANGLEPROC __glewGetQueryivANGLE = NULL; PFNGLISQUERYANGLEPROC __glewIsQueryANGLE = NULL; PFNGLQUERYCOUNTERANGLEPROC __glewQueryCounterANGLE = NULL; PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC __glewGetTranslatedShaderSourceANGLE = NULL; PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE = NULL; PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE = NULL; PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE = NULL; PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC __glewMultiDrawElementArrayAPPLE = NULL; PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC __glewMultiDrawRangeElementArrayAPPLE = NULL; PFNGLDELETEFENCESAPPLEPROC __glewDeleteFencesAPPLE = NULL; PFNGLFINISHFENCEAPPLEPROC __glewFinishFenceAPPLE = NULL; PFNGLFINISHOBJECTAPPLEPROC __glewFinishObjectAPPLE = NULL; PFNGLGENFENCESAPPLEPROC __glewGenFencesAPPLE = NULL; PFNGLISFENCEAPPLEPROC __glewIsFenceAPPLE = NULL; PFNGLSETFENCEAPPLEPROC __glewSetFenceAPPLE = NULL; PFNGLTESTFENCEAPPLEPROC __glewTestFenceAPPLE = NULL; PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE = NULL; PFNGLBUFFERPARAMETERIAPPLEPROC __glewBufferParameteriAPPLE = NULL; PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC __glewFlushMappedBufferRangeAPPLE = NULL; PFNGLGETOBJECTPARAMETERIVAPPLEPROC __glewGetObjectParameterivAPPLE = NULL; PFNGLOBJECTPURGEABLEAPPLEPROC __glewObjectPurgeableAPPLE = NULL; PFNGLOBJECTUNPURGEABLEAPPLEPROC __glewObjectUnpurgeableAPPLE = NULL; PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE = NULL; PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE = NULL; PFNGLBINDVERTEXARRAYAPPLEPROC __glewBindVertexArrayAPPLE = NULL; PFNGLDELETEVERTEXARRAYSAPPLEPROC __glewDeleteVertexArraysAPPLE = NULL; PFNGLGENVERTEXARRAYSAPPLEPROC __glewGenVertexArraysAPPLE = NULL; PFNGLISVERTEXARRAYAPPLEPROC __glewIsVertexArrayAPPLE = NULL; PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE = NULL; PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE = NULL; PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE = NULL; PFNGLDISABLEVERTEXATTRIBAPPLEPROC __glewDisableVertexAttribAPPLE = NULL; PFNGLENABLEVERTEXATTRIBAPPLEPROC __glewEnableVertexAttribAPPLE = NULL; PFNGLISVERTEXATTRIBENABLEDAPPLEPROC __glewIsVertexAttribEnabledAPPLE = NULL; PFNGLMAPVERTEXATTRIB1DAPPLEPROC __glewMapVertexAttrib1dAPPLE = NULL; PFNGLMAPVERTEXATTRIB1FAPPLEPROC __glewMapVertexAttrib1fAPPLE = NULL; PFNGLMAPVERTEXATTRIB2DAPPLEPROC __glewMapVertexAttrib2dAPPLE = NULL; PFNGLMAPVERTEXATTRIB2FAPPLEPROC __glewMapVertexAttrib2fAPPLE = NULL; PFNGLCLEARDEPTHFPROC __glewClearDepthf = NULL; PFNGLDEPTHRANGEFPROC __glewDepthRangef = NULL; PFNGLGETSHADERPRECISIONFORMATPROC __glewGetShaderPrecisionFormat = NULL; PFNGLRELEASESHADERCOMPILERPROC __glewReleaseShaderCompiler = NULL; PFNGLSHADERBINARYPROC __glewShaderBinary = NULL; PFNGLMEMORYBARRIERBYREGIONPROC __glewMemoryBarrierByRegion = NULL; PFNGLPRIMITIVEBOUNDINGBOXARBPROC __glewPrimitiveBoundingBoxARB = NULL; PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC __glewDrawArraysInstancedBaseInstance = NULL; PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC __glewDrawElementsInstancedBaseInstance = NULL; PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC __glewDrawElementsInstancedBaseVertexBaseInstance = NULL; PFNGLGETIMAGEHANDLEARBPROC __glewGetImageHandleARB = NULL; PFNGLGETTEXTUREHANDLEARBPROC __glewGetTextureHandleARB = NULL; PFNGLGETTEXTURESAMPLERHANDLEARBPROC __glewGetTextureSamplerHandleARB = NULL; PFNGLGETVERTEXATTRIBLUI64VARBPROC __glewGetVertexAttribLui64vARB = NULL; PFNGLISIMAGEHANDLERESIDENTARBPROC __glewIsImageHandleResidentARB = NULL; PFNGLISTEXTUREHANDLERESIDENTARBPROC __glewIsTextureHandleResidentARB = NULL; PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC __glewMakeImageHandleNonResidentARB = NULL; PFNGLMAKEIMAGEHANDLERESIDENTARBPROC __glewMakeImageHandleResidentARB = NULL; PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC __glewMakeTextureHandleNonResidentARB = NULL; PFNGLMAKETEXTUREHANDLERESIDENTARBPROC __glewMakeTextureHandleResidentARB = NULL; PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC __glewProgramUniformHandleui64ARB = NULL; PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC __glewProgramUniformHandleui64vARB = NULL; PFNGLUNIFORMHANDLEUI64ARBPROC __glewUniformHandleui64ARB = NULL; PFNGLUNIFORMHANDLEUI64VARBPROC __glewUniformHandleui64vARB = NULL; PFNGLVERTEXATTRIBL1UI64ARBPROC __glewVertexAttribL1ui64ARB = NULL; PFNGLVERTEXATTRIBL1UI64VARBPROC __glewVertexAttribL1ui64vARB = NULL; PFNGLBINDFRAGDATALOCATIONINDEXEDPROC __glewBindFragDataLocationIndexed = NULL; PFNGLGETFRAGDATAINDEXPROC __glewGetFragDataIndex = NULL; PFNGLBUFFERSTORAGEPROC __glewBufferStorage = NULL; PFNGLNAMEDBUFFERSTORAGEEXTPROC __glewNamedBufferStorageEXT = NULL; PFNGLCREATESYNCFROMCLEVENTARBPROC __glewCreateSyncFromCLeventARB = NULL; PFNGLCLEARBUFFERDATAPROC __glewClearBufferData = NULL; PFNGLCLEARBUFFERSUBDATAPROC __glewClearBufferSubData = NULL; PFNGLCLEARNAMEDBUFFERDATAEXTPROC __glewClearNamedBufferDataEXT = NULL; PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC __glewClearNamedBufferSubDataEXT = NULL; PFNGLCLEARTEXIMAGEPROC __glewClearTexImage = NULL; PFNGLCLEARTEXSUBIMAGEPROC __glewClearTexSubImage = NULL; PFNGLCLIPCONTROLPROC __glewClipControl = NULL; PFNGLCLAMPCOLORARBPROC __glewClampColorARB = NULL; PFNGLDISPATCHCOMPUTEPROC __glewDispatchCompute = NULL; PFNGLDISPATCHCOMPUTEINDIRECTPROC __glewDispatchComputeIndirect = NULL; PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC __glewDispatchComputeGroupSizeARB = NULL; PFNGLCOPYBUFFERSUBDATAPROC __glewCopyBufferSubData = NULL; PFNGLCOPYIMAGESUBDATAPROC __glewCopyImageSubData = NULL; PFNGLDEBUGMESSAGECALLBACKARBPROC __glewDebugMessageCallbackARB = NULL; PFNGLDEBUGMESSAGECONTROLARBPROC __glewDebugMessageControlARB = NULL; PFNGLDEBUGMESSAGEINSERTARBPROC __glewDebugMessageInsertARB = NULL; PFNGLGETDEBUGMESSAGELOGARBPROC __glewGetDebugMessageLogARB = NULL; PFNGLBINDTEXTUREUNITPROC __glewBindTextureUnit = NULL; PFNGLBLITNAMEDFRAMEBUFFERPROC __glewBlitNamedFramebuffer = NULL; PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC __glewCheckNamedFramebufferStatus = NULL; PFNGLCLEARNAMEDBUFFERDATAPROC __glewClearNamedBufferData = NULL; PFNGLCLEARNAMEDBUFFERSUBDATAPROC __glewClearNamedBufferSubData = NULL; PFNGLCLEARNAMEDFRAMEBUFFERFIPROC __glewClearNamedFramebufferfi = NULL; PFNGLCLEARNAMEDFRAMEBUFFERFVPROC __glewClearNamedFramebufferfv = NULL; PFNGLCLEARNAMEDFRAMEBUFFERIVPROC __glewClearNamedFramebufferiv = NULL; PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC __glewClearNamedFramebufferuiv = NULL; PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC __glewCompressedTextureSubImage1D = NULL; PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC __glewCompressedTextureSubImage2D = NULL; PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC __glewCompressedTextureSubImage3D = NULL; PFNGLCOPYNAMEDBUFFERSUBDATAPROC __glewCopyNamedBufferSubData = NULL; PFNGLCOPYTEXTURESUBIMAGE1DPROC __glewCopyTextureSubImage1D = NULL; PFNGLCOPYTEXTURESUBIMAGE2DPROC __glewCopyTextureSubImage2D = NULL; PFNGLCOPYTEXTURESUBIMAGE3DPROC __glewCopyTextureSubImage3D = NULL; PFNGLCREATEBUFFERSPROC __glewCreateBuffers = NULL; PFNGLCREATEFRAMEBUFFERSPROC __glewCreateFramebuffers = NULL; PFNGLCREATEPROGRAMPIPELINESPROC __glewCreateProgramPipelines = NULL; PFNGLCREATEQUERIESPROC __glewCreateQueries = NULL; PFNGLCREATERENDERBUFFERSPROC __glewCreateRenderbuffers = NULL; PFNGLCREATESAMPLERSPROC __glewCreateSamplers = NULL; PFNGLCREATETEXTURESPROC __glewCreateTextures = NULL; PFNGLCREATETRANSFORMFEEDBACKSPROC __glewCreateTransformFeedbacks = NULL; PFNGLCREATEVERTEXARRAYSPROC __glewCreateVertexArrays = NULL; PFNGLDISABLEVERTEXARRAYATTRIBPROC __glewDisableVertexArrayAttrib = NULL; PFNGLENABLEVERTEXARRAYATTRIBPROC __glewEnableVertexArrayAttrib = NULL; PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC __glewFlushMappedNamedBufferRange = NULL; PFNGLGENERATETEXTUREMIPMAPPROC __glewGenerateTextureMipmap = NULL; PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC __glewGetCompressedTextureImage = NULL; PFNGLGETNAMEDBUFFERPARAMETERI64VPROC __glewGetNamedBufferParameteri64v = NULL; PFNGLGETNAMEDBUFFERPARAMETERIVPROC __glewGetNamedBufferParameteriv = NULL; PFNGLGETNAMEDBUFFERPOINTERVPROC __glewGetNamedBufferPointerv = NULL; PFNGLGETNAMEDBUFFERSUBDATAPROC __glewGetNamedBufferSubData = NULL; PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetNamedFramebufferAttachmentParameteriv = NULL; PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC __glewGetNamedFramebufferParameteriv = NULL; PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC __glewGetNamedRenderbufferParameteriv = NULL; PFNGLGETQUERYBUFFEROBJECTI64VPROC __glewGetQueryBufferObjecti64v = NULL; PFNGLGETQUERYBUFFEROBJECTIVPROC __glewGetQueryBufferObjectiv = NULL; PFNGLGETQUERYBUFFEROBJECTUI64VPROC __glewGetQueryBufferObjectui64v = NULL; PFNGLGETQUERYBUFFEROBJECTUIVPROC __glewGetQueryBufferObjectuiv = NULL; PFNGLGETTEXTUREIMAGEPROC __glewGetTextureImage = NULL; PFNGLGETTEXTURELEVELPARAMETERFVPROC __glewGetTextureLevelParameterfv = NULL; PFNGLGETTEXTURELEVELPARAMETERIVPROC __glewGetTextureLevelParameteriv = NULL; PFNGLGETTEXTUREPARAMETERIIVPROC __glewGetTextureParameterIiv = NULL; PFNGLGETTEXTUREPARAMETERIUIVPROC __glewGetTextureParameterIuiv = NULL; PFNGLGETTEXTUREPARAMETERFVPROC __glewGetTextureParameterfv = NULL; PFNGLGETTEXTUREPARAMETERIVPROC __glewGetTextureParameteriv = NULL; PFNGLGETTRANSFORMFEEDBACKI64_VPROC __glewGetTransformFeedbacki64_v = NULL; PFNGLGETTRANSFORMFEEDBACKI_VPROC __glewGetTransformFeedbacki_v = NULL; PFNGLGETTRANSFORMFEEDBACKIVPROC __glewGetTransformFeedbackiv = NULL; PFNGLGETVERTEXARRAYINDEXED64IVPROC __glewGetVertexArrayIndexed64iv = NULL; PFNGLGETVERTEXARRAYINDEXEDIVPROC __glewGetVertexArrayIndexediv = NULL; PFNGLGETVERTEXARRAYIVPROC __glewGetVertexArrayiv = NULL; PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC __glewInvalidateNamedFramebufferData = NULL; PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC __glewInvalidateNamedFramebufferSubData = NULL; PFNGLMAPNAMEDBUFFERPROC __glewMapNamedBuffer = NULL; PFNGLMAPNAMEDBUFFERRANGEPROC __glewMapNamedBufferRange = NULL; PFNGLNAMEDBUFFERDATAPROC __glewNamedBufferData = NULL; PFNGLNAMEDBUFFERSTORAGEPROC __glewNamedBufferStorage = NULL; PFNGLNAMEDBUFFERSUBDATAPROC __glewNamedBufferSubData = NULL; PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC __glewNamedFramebufferDrawBuffer = NULL; PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC __glewNamedFramebufferDrawBuffers = NULL; PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC __glewNamedFramebufferParameteri = NULL; PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC __glewNamedFramebufferReadBuffer = NULL; PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC __glewNamedFramebufferRenderbuffer = NULL; PFNGLNAMEDFRAMEBUFFERTEXTUREPROC __glewNamedFramebufferTexture = NULL; PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC __glewNamedFramebufferTextureLayer = NULL; PFNGLNAMEDRENDERBUFFERSTORAGEPROC __glewNamedRenderbufferStorage = NULL; PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewNamedRenderbufferStorageMultisample = NULL; PFNGLTEXTUREBUFFERPROC __glewTextureBuffer = NULL; PFNGLTEXTUREBUFFERRANGEPROC __glewTextureBufferRange = NULL; PFNGLTEXTUREPARAMETERIIVPROC __glewTextureParameterIiv = NULL; PFNGLTEXTUREPARAMETERIUIVPROC __glewTextureParameterIuiv = NULL; PFNGLTEXTUREPARAMETERFPROC __glewTextureParameterf = NULL; PFNGLTEXTUREPARAMETERFVPROC __glewTextureParameterfv = NULL; PFNGLTEXTUREPARAMETERIPROC __glewTextureParameteri = NULL; PFNGLTEXTUREPARAMETERIVPROC __glewTextureParameteriv = NULL; PFNGLTEXTURESTORAGE1DPROC __glewTextureStorage1D = NULL; PFNGLTEXTURESTORAGE2DPROC __glewTextureStorage2D = NULL; PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC __glewTextureStorage2DMultisample = NULL; PFNGLTEXTURESTORAGE3DPROC __glewTextureStorage3D = NULL; PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC __glewTextureStorage3DMultisample = NULL; PFNGLTEXTURESUBIMAGE1DPROC __glewTextureSubImage1D = NULL; PFNGLTEXTURESUBIMAGE2DPROC __glewTextureSubImage2D = NULL; PFNGLTEXTURESUBIMAGE3DPROC __glewTextureSubImage3D = NULL; PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC __glewTransformFeedbackBufferBase = NULL; PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC __glewTransformFeedbackBufferRange = NULL; PFNGLUNMAPNAMEDBUFFERPROC __glewUnmapNamedBuffer = NULL; PFNGLVERTEXARRAYATTRIBBINDINGPROC __glewVertexArrayAttribBinding = NULL; PFNGLVERTEXARRAYATTRIBFORMATPROC __glewVertexArrayAttribFormat = NULL; PFNGLVERTEXARRAYATTRIBIFORMATPROC __glewVertexArrayAttribIFormat = NULL; PFNGLVERTEXARRAYATTRIBLFORMATPROC __glewVertexArrayAttribLFormat = NULL; PFNGLVERTEXARRAYBINDINGDIVISORPROC __glewVertexArrayBindingDivisor = NULL; PFNGLVERTEXARRAYELEMENTBUFFERPROC __glewVertexArrayElementBuffer = NULL; PFNGLVERTEXARRAYVERTEXBUFFERPROC __glewVertexArrayVertexBuffer = NULL; PFNGLVERTEXARRAYVERTEXBUFFERSPROC __glewVertexArrayVertexBuffers = NULL; PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB = NULL; PFNGLBLENDEQUATIONSEPARATEIARBPROC __glewBlendEquationSeparateiARB = NULL; PFNGLBLENDEQUATIONIARBPROC __glewBlendEquationiARB = NULL; PFNGLBLENDFUNCSEPARATEIARBPROC __glewBlendFuncSeparateiARB = NULL; PFNGLBLENDFUNCIARBPROC __glewBlendFunciARB = NULL; PFNGLDRAWELEMENTSBASEVERTEXPROC __glewDrawElementsBaseVertex = NULL; PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC __glewDrawElementsInstancedBaseVertex = NULL; PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC __glewDrawRangeElementsBaseVertex = NULL; PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC __glewMultiDrawElementsBaseVertex = NULL; PFNGLDRAWARRAYSINDIRECTPROC __glewDrawArraysIndirect = NULL; PFNGLDRAWELEMENTSINDIRECTPROC __glewDrawElementsIndirect = NULL; PFNGLFRAMEBUFFERPARAMETERIPROC __glewFramebufferParameteri = NULL; PFNGLGETFRAMEBUFFERPARAMETERIVPROC __glewGetFramebufferParameteriv = NULL; PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC __glewGetNamedFramebufferParameterivEXT = NULL; PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC __glewNamedFramebufferParameteriEXT = NULL; PFNGLBINDFRAMEBUFFERPROC __glewBindFramebuffer = NULL; PFNGLBINDRENDERBUFFERPROC __glewBindRenderbuffer = NULL; PFNGLBLITFRAMEBUFFERPROC __glewBlitFramebuffer = NULL; PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus = NULL; PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers = NULL; PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers = NULL; PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer = NULL; PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D = NULL; PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D = NULL; PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D = NULL; PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer = NULL; PFNGLGENFRAMEBUFFERSPROC __glewGenFramebuffers = NULL; PFNGLGENRENDERBUFFERSPROC __glewGenRenderbuffers = NULL; PFNGLGENERATEMIPMAPPROC __glewGenerateMipmap = NULL; PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetFramebufferAttachmentParameteriv = NULL; PFNGLGETRENDERBUFFERPARAMETERIVPROC __glewGetRenderbufferParameteriv = NULL; PFNGLISFRAMEBUFFERPROC __glewIsFramebuffer = NULL; PFNGLISRENDERBUFFERPROC __glewIsRenderbuffer = NULL; PFNGLRENDERBUFFERSTORAGEPROC __glewRenderbufferStorage = NULL; PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewRenderbufferStorageMultisample = NULL; PFNGLFRAMEBUFFERTEXTUREARBPROC __glewFramebufferTextureARB = NULL; PFNGLFRAMEBUFFERTEXTUREFACEARBPROC __glewFramebufferTextureFaceARB = NULL; PFNGLFRAMEBUFFERTEXTURELAYERARBPROC __glewFramebufferTextureLayerARB = NULL; PFNGLPROGRAMPARAMETERIARBPROC __glewProgramParameteriARB = NULL; PFNGLGETPROGRAMBINARYPROC __glewGetProgramBinary = NULL; PFNGLPROGRAMBINARYPROC __glewProgramBinary = NULL; PFNGLPROGRAMPARAMETERIPROC __glewProgramParameteri = NULL; PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC __glewGetCompressedTextureSubImage = NULL; PFNGLGETTEXTURESUBIMAGEPROC __glewGetTextureSubImage = NULL; PFNGLGETUNIFORMDVPROC __glewGetUniformdv = NULL; PFNGLUNIFORM1DPROC __glewUniform1d = NULL; PFNGLUNIFORM1DVPROC __glewUniform1dv = NULL; PFNGLUNIFORM2DPROC __glewUniform2d = NULL; PFNGLUNIFORM2DVPROC __glewUniform2dv = NULL; PFNGLUNIFORM3DPROC __glewUniform3d = NULL; PFNGLUNIFORM3DVPROC __glewUniform3dv = NULL; PFNGLUNIFORM4DPROC __glewUniform4d = NULL; PFNGLUNIFORM4DVPROC __glewUniform4dv = NULL; PFNGLUNIFORMMATRIX2DVPROC __glewUniformMatrix2dv = NULL; PFNGLUNIFORMMATRIX2X3DVPROC __glewUniformMatrix2x3dv = NULL; PFNGLUNIFORMMATRIX2X4DVPROC __glewUniformMatrix2x4dv = NULL; PFNGLUNIFORMMATRIX3DVPROC __glewUniformMatrix3dv = NULL; PFNGLUNIFORMMATRIX3X2DVPROC __glewUniformMatrix3x2dv = NULL; PFNGLUNIFORMMATRIX3X4DVPROC __glewUniformMatrix3x4dv = NULL; PFNGLUNIFORMMATRIX4DVPROC __glewUniformMatrix4dv = NULL; PFNGLUNIFORMMATRIX4X2DVPROC __glewUniformMatrix4x2dv = NULL; PFNGLUNIFORMMATRIX4X3DVPROC __glewUniformMatrix4x3dv = NULL; PFNGLGETUNIFORMI64VARBPROC __glewGetUniformi64vARB = NULL; PFNGLGETUNIFORMUI64VARBPROC __glewGetUniformui64vARB = NULL; PFNGLGETNUNIFORMI64VARBPROC __glewGetnUniformi64vARB = NULL; PFNGLGETNUNIFORMUI64VARBPROC __glewGetnUniformui64vARB = NULL; PFNGLPROGRAMUNIFORM1I64ARBPROC __glewProgramUniform1i64ARB = NULL; PFNGLPROGRAMUNIFORM1I64VARBPROC __glewProgramUniform1i64vARB = NULL; PFNGLPROGRAMUNIFORM1UI64ARBPROC __glewProgramUniform1ui64ARB = NULL; PFNGLPROGRAMUNIFORM1UI64VARBPROC __glewProgramUniform1ui64vARB = NULL; PFNGLPROGRAMUNIFORM2I64ARBPROC __glewProgramUniform2i64ARB = NULL; PFNGLPROGRAMUNIFORM2I64VARBPROC __glewProgramUniform2i64vARB = NULL; PFNGLPROGRAMUNIFORM2UI64ARBPROC __glewProgramUniform2ui64ARB = NULL; PFNGLPROGRAMUNIFORM2UI64VARBPROC __glewProgramUniform2ui64vARB = NULL; PFNGLPROGRAMUNIFORM3I64ARBPROC __glewProgramUniform3i64ARB = NULL; PFNGLPROGRAMUNIFORM3I64VARBPROC __glewProgramUniform3i64vARB = NULL; PFNGLPROGRAMUNIFORM3UI64ARBPROC __glewProgramUniform3ui64ARB = NULL; PFNGLPROGRAMUNIFORM3UI64VARBPROC __glewProgramUniform3ui64vARB = NULL; PFNGLPROGRAMUNIFORM4I64ARBPROC __glewProgramUniform4i64ARB = NULL; PFNGLPROGRAMUNIFORM4I64VARBPROC __glewProgramUniform4i64vARB = NULL; PFNGLPROGRAMUNIFORM4UI64ARBPROC __glewProgramUniform4ui64ARB = NULL; PFNGLPROGRAMUNIFORM4UI64VARBPROC __glewProgramUniform4ui64vARB = NULL; PFNGLUNIFORM1I64ARBPROC __glewUniform1i64ARB = NULL; PFNGLUNIFORM1I64VARBPROC __glewUniform1i64vARB = NULL; PFNGLUNIFORM1UI64ARBPROC __glewUniform1ui64ARB = NULL; PFNGLUNIFORM1UI64VARBPROC __glewUniform1ui64vARB = NULL; PFNGLUNIFORM2I64ARBPROC __glewUniform2i64ARB = NULL; PFNGLUNIFORM2I64VARBPROC __glewUniform2i64vARB = NULL; PFNGLUNIFORM2UI64ARBPROC __glewUniform2ui64ARB = NULL; PFNGLUNIFORM2UI64VARBPROC __glewUniform2ui64vARB = NULL; PFNGLUNIFORM3I64ARBPROC __glewUniform3i64ARB = NULL; PFNGLUNIFORM3I64VARBPROC __glewUniform3i64vARB = NULL; PFNGLUNIFORM3UI64ARBPROC __glewUniform3ui64ARB = NULL; PFNGLUNIFORM3UI64VARBPROC __glewUniform3ui64vARB = NULL; PFNGLUNIFORM4I64ARBPROC __glewUniform4i64ARB = NULL; PFNGLUNIFORM4I64VARBPROC __glewUniform4i64vARB = NULL; PFNGLUNIFORM4UI64ARBPROC __glewUniform4ui64ARB = NULL; PFNGLUNIFORM4UI64VARBPROC __glewUniform4ui64vARB = NULL; PFNGLCOLORSUBTABLEPROC __glewColorSubTable = NULL; PFNGLCOLORTABLEPROC __glewColorTable = NULL; PFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv = NULL; PFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv = NULL; PFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D = NULL; PFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D = NULL; PFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf = NULL; PFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv = NULL; PFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri = NULL; PFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv = NULL; PFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable = NULL; PFNGLCOPYCOLORTABLEPROC __glewCopyColorTable = NULL; PFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D = NULL; PFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D = NULL; PFNGLGETCOLORTABLEPROC __glewGetColorTable = NULL; PFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv = NULL; PFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv = NULL; PFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter = NULL; PFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv = NULL; PFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv = NULL; PFNGLGETHISTOGRAMPROC __glewGetHistogram = NULL; PFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv = NULL; PFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv = NULL; PFNGLGETMINMAXPROC __glewGetMinmax = NULL; PFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv = NULL; PFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv = NULL; PFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter = NULL; PFNGLHISTOGRAMPROC __glewHistogram = NULL; PFNGLMINMAXPROC __glewMinmax = NULL; PFNGLRESETHISTOGRAMPROC __glewResetHistogram = NULL; PFNGLRESETMINMAXPROC __glewResetMinmax = NULL; PFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D = NULL; PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC __glewMultiDrawArraysIndirectCountARB = NULL; PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC __glewMultiDrawElementsIndirectCountARB = NULL; PFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB = NULL; PFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB = NULL; PFNGLVERTEXATTRIBDIVISORARBPROC __glewVertexAttribDivisorARB = NULL; PFNGLGETINTERNALFORMATIVPROC __glewGetInternalformativ = NULL; PFNGLGETINTERNALFORMATI64VPROC __glewGetInternalformati64v = NULL; PFNGLINVALIDATEBUFFERDATAPROC __glewInvalidateBufferData = NULL; PFNGLINVALIDATEBUFFERSUBDATAPROC __glewInvalidateBufferSubData = NULL; PFNGLINVALIDATEFRAMEBUFFERPROC __glewInvalidateFramebuffer = NULL; PFNGLINVALIDATESUBFRAMEBUFFERPROC __glewInvalidateSubFramebuffer = NULL; PFNGLINVALIDATETEXIMAGEPROC __glewInvalidateTexImage = NULL; PFNGLINVALIDATETEXSUBIMAGEPROC __glewInvalidateTexSubImage = NULL; PFNGLFLUSHMAPPEDBUFFERRANGEPROC __glewFlushMappedBufferRange = NULL; PFNGLMAPBUFFERRANGEPROC __glewMapBufferRange = NULL; PFNGLCURRENTPALETTEMATRIXARBPROC __glewCurrentPaletteMatrixARB = NULL; PFNGLMATRIXINDEXPOINTERARBPROC __glewMatrixIndexPointerARB = NULL; PFNGLMATRIXINDEXUBVARBPROC __glewMatrixIndexubvARB = NULL; PFNGLMATRIXINDEXUIVARBPROC __glewMatrixIndexuivARB = NULL; PFNGLMATRIXINDEXUSVARBPROC __glewMatrixIndexusvARB = NULL; PFNGLBINDBUFFERSBASEPROC __glewBindBuffersBase = NULL; PFNGLBINDBUFFERSRANGEPROC __glewBindBuffersRange = NULL; PFNGLBINDIMAGETEXTURESPROC __glewBindImageTextures = NULL; PFNGLBINDSAMPLERSPROC __glewBindSamplers = NULL; PFNGLBINDTEXTURESPROC __glewBindTextures = NULL; PFNGLBINDVERTEXBUFFERSPROC __glewBindVertexBuffers = NULL; PFNGLMULTIDRAWARRAYSINDIRECTPROC __glewMultiDrawArraysIndirect = NULL; PFNGLMULTIDRAWELEMENTSINDIRECTPROC __glewMultiDrawElementsIndirect = NULL; PFNGLSAMPLECOVERAGEARBPROC __glewSampleCoverageARB = NULL; PFNGLACTIVETEXTUREARBPROC __glewActiveTextureARB = NULL; PFNGLCLIENTACTIVETEXTUREARBPROC __glewClientActiveTextureARB = NULL; PFNGLMULTITEXCOORD1DARBPROC __glewMultiTexCoord1dARB = NULL; PFNGLMULTITEXCOORD1DVARBPROC __glewMultiTexCoord1dvARB = NULL; PFNGLMULTITEXCOORD1FARBPROC __glewMultiTexCoord1fARB = NULL; PFNGLMULTITEXCOORD1FVARBPROC __glewMultiTexCoord1fvARB = NULL; PFNGLMULTITEXCOORD1IARBPROC __glewMultiTexCoord1iARB = NULL; PFNGLMULTITEXCOORD1IVARBPROC __glewMultiTexCoord1ivARB = NULL; PFNGLMULTITEXCOORD1SARBPROC __glewMultiTexCoord1sARB = NULL; PFNGLMULTITEXCOORD1SVARBPROC __glewMultiTexCoord1svARB = NULL; PFNGLMULTITEXCOORD2DARBPROC __glewMultiTexCoord2dARB = NULL; PFNGLMULTITEXCOORD2DVARBPROC __glewMultiTexCoord2dvARB = NULL; PFNGLMULTITEXCOORD2FARBPROC __glewMultiTexCoord2fARB = NULL; PFNGLMULTITEXCOORD2FVARBPROC __glewMultiTexCoord2fvARB = NULL; PFNGLMULTITEXCOORD2IARBPROC __glewMultiTexCoord2iARB = NULL; PFNGLMULTITEXCOORD2IVARBPROC __glewMultiTexCoord2ivARB = NULL; PFNGLMULTITEXCOORD2SARBPROC __glewMultiTexCoord2sARB = NULL; PFNGLMULTITEXCOORD2SVARBPROC __glewMultiTexCoord2svARB = NULL; PFNGLMULTITEXCOORD3DARBPROC __glewMultiTexCoord3dARB = NULL; PFNGLMULTITEXCOORD3DVARBPROC __glewMultiTexCoord3dvARB = NULL; PFNGLMULTITEXCOORD3FARBPROC __glewMultiTexCoord3fARB = NULL; PFNGLMULTITEXCOORD3FVARBPROC __glewMultiTexCoord3fvARB = NULL; PFNGLMULTITEXCOORD3IARBPROC __glewMultiTexCoord3iARB = NULL; PFNGLMULTITEXCOORD3IVARBPROC __glewMultiTexCoord3ivARB = NULL; PFNGLMULTITEXCOORD3SARBPROC __glewMultiTexCoord3sARB = NULL; PFNGLMULTITEXCOORD3SVARBPROC __glewMultiTexCoord3svARB = NULL; PFNGLMULTITEXCOORD4DARBPROC __glewMultiTexCoord4dARB = NULL; PFNGLMULTITEXCOORD4DVARBPROC __glewMultiTexCoord4dvARB = NULL; PFNGLMULTITEXCOORD4FARBPROC __glewMultiTexCoord4fARB = NULL; PFNGLMULTITEXCOORD4FVARBPROC __glewMultiTexCoord4fvARB = NULL; PFNGLMULTITEXCOORD4IARBPROC __glewMultiTexCoord4iARB = NULL; PFNGLMULTITEXCOORD4IVARBPROC __glewMultiTexCoord4ivARB = NULL; PFNGLMULTITEXCOORD4SARBPROC __glewMultiTexCoord4sARB = NULL; PFNGLMULTITEXCOORD4SVARBPROC __glewMultiTexCoord4svARB = NULL; PFNGLBEGINQUERYARBPROC __glewBeginQueryARB = NULL; PFNGLDELETEQUERIESARBPROC __glewDeleteQueriesARB = NULL; PFNGLENDQUERYARBPROC __glewEndQueryARB = NULL; PFNGLGENQUERIESARBPROC __glewGenQueriesARB = NULL; PFNGLGETQUERYOBJECTIVARBPROC __glewGetQueryObjectivARB = NULL; PFNGLGETQUERYOBJECTUIVARBPROC __glewGetQueryObjectuivARB = NULL; PFNGLGETQUERYIVARBPROC __glewGetQueryivARB = NULL; PFNGLISQUERYARBPROC __glewIsQueryARB = NULL; PFNGLMAXSHADERCOMPILERTHREADSARBPROC __glewMaxShaderCompilerThreadsARB = NULL; PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB = NULL; PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB = NULL; PFNGLGETPROGRAMINTERFACEIVPROC __glewGetProgramInterfaceiv = NULL; PFNGLGETPROGRAMRESOURCEINDEXPROC __glewGetProgramResourceIndex = NULL; PFNGLGETPROGRAMRESOURCELOCATIONPROC __glewGetProgramResourceLocation = NULL; PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC __glewGetProgramResourceLocationIndex = NULL; PFNGLGETPROGRAMRESOURCENAMEPROC __glewGetProgramResourceName = NULL; PFNGLGETPROGRAMRESOURCEIVPROC __glewGetProgramResourceiv = NULL; PFNGLPROVOKINGVERTEXPROC __glewProvokingVertex = NULL; PFNGLGETGRAPHICSRESETSTATUSARBPROC __glewGetGraphicsResetStatusARB = NULL; PFNGLGETNCOLORTABLEARBPROC __glewGetnColorTableARB = NULL; PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC __glewGetnCompressedTexImageARB = NULL; PFNGLGETNCONVOLUTIONFILTERARBPROC __glewGetnConvolutionFilterARB = NULL; PFNGLGETNHISTOGRAMARBPROC __glewGetnHistogramARB = NULL; PFNGLGETNMAPDVARBPROC __glewGetnMapdvARB = NULL; PFNGLGETNMAPFVARBPROC __glewGetnMapfvARB = NULL; PFNGLGETNMAPIVARBPROC __glewGetnMapivARB = NULL; PFNGLGETNMINMAXARBPROC __glewGetnMinmaxARB = NULL; PFNGLGETNPIXELMAPFVARBPROC __glewGetnPixelMapfvARB = NULL; PFNGLGETNPIXELMAPUIVARBPROC __glewGetnPixelMapuivARB = NULL; PFNGLGETNPIXELMAPUSVARBPROC __glewGetnPixelMapusvARB = NULL; PFNGLGETNPOLYGONSTIPPLEARBPROC __glewGetnPolygonStippleARB = NULL; PFNGLGETNSEPARABLEFILTERARBPROC __glewGetnSeparableFilterARB = NULL; PFNGLGETNTEXIMAGEARBPROC __glewGetnTexImageARB = NULL; PFNGLGETNUNIFORMDVARBPROC __glewGetnUniformdvARB = NULL; PFNGLGETNUNIFORMFVARBPROC __glewGetnUniformfvARB = NULL; PFNGLGETNUNIFORMIVARBPROC __glewGetnUniformivARB = NULL; PFNGLGETNUNIFORMUIVARBPROC __glewGetnUniformuivARB = NULL; PFNGLREADNPIXELSARBPROC __glewReadnPixelsARB = NULL; PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC __glewFramebufferSampleLocationsfvARB = NULL; PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC __glewNamedFramebufferSampleLocationsfvARB = NULL; PFNGLMINSAMPLESHADINGARBPROC __glewMinSampleShadingARB = NULL; PFNGLBINDSAMPLERPROC __glewBindSampler = NULL; PFNGLDELETESAMPLERSPROC __glewDeleteSamplers = NULL; PFNGLGENSAMPLERSPROC __glewGenSamplers = NULL; PFNGLGETSAMPLERPARAMETERIIVPROC __glewGetSamplerParameterIiv = NULL; PFNGLGETSAMPLERPARAMETERIUIVPROC __glewGetSamplerParameterIuiv = NULL; PFNGLGETSAMPLERPARAMETERFVPROC __glewGetSamplerParameterfv = NULL; PFNGLGETSAMPLERPARAMETERIVPROC __glewGetSamplerParameteriv = NULL; PFNGLISSAMPLERPROC __glewIsSampler = NULL; PFNGLSAMPLERPARAMETERIIVPROC __glewSamplerParameterIiv = NULL; PFNGLSAMPLERPARAMETERIUIVPROC __glewSamplerParameterIuiv = NULL; PFNGLSAMPLERPARAMETERFPROC __glewSamplerParameterf = NULL; PFNGLSAMPLERPARAMETERFVPROC __glewSamplerParameterfv = NULL; PFNGLSAMPLERPARAMETERIPROC __glewSamplerParameteri = NULL; PFNGLSAMPLERPARAMETERIVPROC __glewSamplerParameteriv = NULL; PFNGLACTIVESHADERPROGRAMPROC __glewActiveShaderProgram = NULL; PFNGLBINDPROGRAMPIPELINEPROC __glewBindProgramPipeline = NULL; PFNGLCREATESHADERPROGRAMVPROC __glewCreateShaderProgramv = NULL; PFNGLDELETEPROGRAMPIPELINESPROC __glewDeleteProgramPipelines = NULL; PFNGLGENPROGRAMPIPELINESPROC __glewGenProgramPipelines = NULL; PFNGLGETPROGRAMPIPELINEINFOLOGPROC __glewGetProgramPipelineInfoLog = NULL; PFNGLGETPROGRAMPIPELINEIVPROC __glewGetProgramPipelineiv = NULL; PFNGLISPROGRAMPIPELINEPROC __glewIsProgramPipeline = NULL; PFNGLPROGRAMUNIFORM1DPROC __glewProgramUniform1d = NULL; PFNGLPROGRAMUNIFORM1DVPROC __glewProgramUniform1dv = NULL; PFNGLPROGRAMUNIFORM1FPROC __glewProgramUniform1f = NULL; PFNGLPROGRAMUNIFORM1FVPROC __glewProgramUniform1fv = NULL; PFNGLPROGRAMUNIFORM1IPROC __glewProgramUniform1i = NULL; PFNGLPROGRAMUNIFORM1IVPROC __glewProgramUniform1iv = NULL; PFNGLPROGRAMUNIFORM1UIPROC __glewProgramUniform1ui = NULL; PFNGLPROGRAMUNIFORM1UIVPROC __glewProgramUniform1uiv = NULL; PFNGLPROGRAMUNIFORM2DPROC __glewProgramUniform2d = NULL; PFNGLPROGRAMUNIFORM2DVPROC __glewProgramUniform2dv = NULL; PFNGLPROGRAMUNIFORM2FPROC __glewProgramUniform2f = NULL; PFNGLPROGRAMUNIFORM2FVPROC __glewProgramUniform2fv = NULL; PFNGLPROGRAMUNIFORM2IPROC __glewProgramUniform2i = NULL; PFNGLPROGRAMUNIFORM2IVPROC __glewProgramUniform2iv = NULL; PFNGLPROGRAMUNIFORM2UIPROC __glewProgramUniform2ui = NULL; PFNGLPROGRAMUNIFORM2UIVPROC __glewProgramUniform2uiv = NULL; PFNGLPROGRAMUNIFORM3DPROC __glewProgramUniform3d = NULL; PFNGLPROGRAMUNIFORM3DVPROC __glewProgramUniform3dv = NULL; PFNGLPROGRAMUNIFORM3FPROC __glewProgramUniform3f = NULL; PFNGLPROGRAMUNIFORM3FVPROC __glewProgramUniform3fv = NULL; PFNGLPROGRAMUNIFORM3IPROC __glewProgramUniform3i = NULL; PFNGLPROGRAMUNIFORM3IVPROC __glewProgramUniform3iv = NULL; PFNGLPROGRAMUNIFORM3UIPROC __glewProgramUniform3ui = NULL; PFNGLPROGRAMUNIFORM3UIVPROC __glewProgramUniform3uiv = NULL; PFNGLPROGRAMUNIFORM4DPROC __glewProgramUniform4d = NULL; PFNGLPROGRAMUNIFORM4DVPROC __glewProgramUniform4dv = NULL; PFNGLPROGRAMUNIFORM4FPROC __glewProgramUniform4f = NULL; PFNGLPROGRAMUNIFORM4FVPROC __glewProgramUniform4fv = NULL; PFNGLPROGRAMUNIFORM4IPROC __glewProgramUniform4i = NULL; PFNGLPROGRAMUNIFORM4IVPROC __glewProgramUniform4iv = NULL; PFNGLPROGRAMUNIFORM4UIPROC __glewProgramUniform4ui = NULL; PFNGLPROGRAMUNIFORM4UIVPROC __glewProgramUniform4uiv = NULL; PFNGLPROGRAMUNIFORMMATRIX2DVPROC __glewProgramUniformMatrix2dv = NULL; PFNGLPROGRAMUNIFORMMATRIX2FVPROC __glewProgramUniformMatrix2fv = NULL; PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC __glewProgramUniformMatrix2x3dv = NULL; PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC __glewProgramUniformMatrix2x3fv = NULL; PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC __glewProgramUniformMatrix2x4dv = NULL; PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC __glewProgramUniformMatrix2x4fv = NULL; PFNGLPROGRAMUNIFORMMATRIX3DVPROC __glewProgramUniformMatrix3dv = NULL; PFNGLPROGRAMUNIFORMMATRIX3FVPROC __glewProgramUniformMatrix3fv = NULL; PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC __glewProgramUniformMatrix3x2dv = NULL; PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC __glewProgramUniformMatrix3x2fv = NULL; PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC __glewProgramUniformMatrix3x4dv = NULL; PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC __glewProgramUniformMatrix3x4fv = NULL; PFNGLPROGRAMUNIFORMMATRIX4DVPROC __glewProgramUniformMatrix4dv = NULL; PFNGLPROGRAMUNIFORMMATRIX4FVPROC __glewProgramUniformMatrix4fv = NULL; PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC __glewProgramUniformMatrix4x2dv = NULL; PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC __glewProgramUniformMatrix4x2fv = NULL; PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC __glewProgramUniformMatrix4x3dv = NULL; PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC __glewProgramUniformMatrix4x3fv = NULL; PFNGLUSEPROGRAMSTAGESPROC __glewUseProgramStages = NULL; PFNGLVALIDATEPROGRAMPIPELINEPROC __glewValidateProgramPipeline = NULL; PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC __glewGetActiveAtomicCounterBufferiv = NULL; PFNGLBINDIMAGETEXTUREPROC __glewBindImageTexture = NULL; PFNGLMEMORYBARRIERPROC __glewMemoryBarrier = NULL; PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB = NULL; PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB = NULL; PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB = NULL; PFNGLCREATESHADEROBJECTARBPROC __glewCreateShaderObjectARB = NULL; PFNGLDELETEOBJECTARBPROC __glewDeleteObjectARB = NULL; PFNGLDETACHOBJECTARBPROC __glewDetachObjectARB = NULL; PFNGLGETACTIVEUNIFORMARBPROC __glewGetActiveUniformARB = NULL; PFNGLGETATTACHEDOBJECTSARBPROC __glewGetAttachedObjectsARB = NULL; PFNGLGETHANDLEARBPROC __glewGetHandleARB = NULL; PFNGLGETINFOLOGARBPROC __glewGetInfoLogARB = NULL; PFNGLGETOBJECTPARAMETERFVARBPROC __glewGetObjectParameterfvARB = NULL; PFNGLGETOBJECTPARAMETERIVARBPROC __glewGetObjectParameterivARB = NULL; PFNGLGETSHADERSOURCEARBPROC __glewGetShaderSourceARB = NULL; PFNGLGETUNIFORMLOCATIONARBPROC __glewGetUniformLocationARB = NULL; PFNGLGETUNIFORMFVARBPROC __glewGetUniformfvARB = NULL; PFNGLGETUNIFORMIVARBPROC __glewGetUniformivARB = NULL; PFNGLLINKPROGRAMARBPROC __glewLinkProgramARB = NULL; PFNGLSHADERSOURCEARBPROC __glewShaderSourceARB = NULL; PFNGLUNIFORM1FARBPROC __glewUniform1fARB = NULL; PFNGLUNIFORM1FVARBPROC __glewUniform1fvARB = NULL; PFNGLUNIFORM1IARBPROC __glewUniform1iARB = NULL; PFNGLUNIFORM1IVARBPROC __glewUniform1ivARB = NULL; PFNGLUNIFORM2FARBPROC __glewUniform2fARB = NULL; PFNGLUNIFORM2FVARBPROC __glewUniform2fvARB = NULL; PFNGLUNIFORM2IARBPROC __glewUniform2iARB = NULL; PFNGLUNIFORM2IVARBPROC __glewUniform2ivARB = NULL; PFNGLUNIFORM3FARBPROC __glewUniform3fARB = NULL; PFNGLUNIFORM3FVARBPROC __glewUniform3fvARB = NULL; PFNGLUNIFORM3IARBPROC __glewUniform3iARB = NULL; PFNGLUNIFORM3IVARBPROC __glewUniform3ivARB = NULL; PFNGLUNIFORM4FARBPROC __glewUniform4fARB = NULL; PFNGLUNIFORM4FVARBPROC __glewUniform4fvARB = NULL; PFNGLUNIFORM4IARBPROC __glewUniform4iARB = NULL; PFNGLUNIFORM4IVARBPROC __glewUniform4ivARB = NULL; PFNGLUNIFORMMATRIX2FVARBPROC __glewUniformMatrix2fvARB = NULL; PFNGLUNIFORMMATRIX3FVARBPROC __glewUniformMatrix3fvARB = NULL; PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB = NULL; PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB = NULL; PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB = NULL; PFNGLSHADERSTORAGEBLOCKBINDINGPROC __glewShaderStorageBlockBinding = NULL; PFNGLGETACTIVESUBROUTINENAMEPROC __glewGetActiveSubroutineName = NULL; PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC __glewGetActiveSubroutineUniformName = NULL; PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC __glewGetActiveSubroutineUniformiv = NULL; PFNGLGETPROGRAMSTAGEIVPROC __glewGetProgramStageiv = NULL; PFNGLGETSUBROUTINEINDEXPROC __glewGetSubroutineIndex = NULL; PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC __glewGetSubroutineUniformLocation = NULL; PFNGLGETUNIFORMSUBROUTINEUIVPROC __glewGetUniformSubroutineuiv = NULL; PFNGLUNIFORMSUBROUTINESUIVPROC __glewUniformSubroutinesuiv = NULL; PFNGLCOMPILESHADERINCLUDEARBPROC __glewCompileShaderIncludeARB = NULL; PFNGLDELETENAMEDSTRINGARBPROC __glewDeleteNamedStringARB = NULL; PFNGLGETNAMEDSTRINGARBPROC __glewGetNamedStringARB = NULL; PFNGLGETNAMEDSTRINGIVARBPROC __glewGetNamedStringivARB = NULL; PFNGLISNAMEDSTRINGARBPROC __glewIsNamedStringARB = NULL; PFNGLNAMEDSTRINGARBPROC __glewNamedStringARB = NULL; PFNGLBUFFERPAGECOMMITMENTARBPROC __glewBufferPageCommitmentARB = NULL; PFNGLTEXPAGECOMMITMENTARBPROC __glewTexPageCommitmentARB = NULL; PFNGLTEXTUREPAGECOMMITMENTEXTPROC __glewTexturePageCommitmentEXT = NULL; PFNGLCLIENTWAITSYNCPROC __glewClientWaitSync = NULL; PFNGLDELETESYNCPROC __glewDeleteSync = NULL; PFNGLFENCESYNCPROC __glewFenceSync = NULL; PFNGLGETINTEGER64VPROC __glewGetInteger64v = NULL; PFNGLGETSYNCIVPROC __glewGetSynciv = NULL; PFNGLISSYNCPROC __glewIsSync = NULL; PFNGLWAITSYNCPROC __glewWaitSync = NULL; PFNGLPATCHPARAMETERFVPROC __glewPatchParameterfv = NULL; PFNGLPATCHPARAMETERIPROC __glewPatchParameteri = NULL; PFNGLTEXTUREBARRIERPROC __glewTextureBarrier = NULL; PFNGLTEXBUFFERARBPROC __glewTexBufferARB = NULL; PFNGLTEXBUFFERRANGEPROC __glewTexBufferRange = NULL; PFNGLTEXTUREBUFFERRANGEEXTPROC __glewTextureBufferRangeEXT = NULL; PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB = NULL; PFNGLCOMPRESSEDTEXIMAGE2DARBPROC __glewCompressedTexImage2DARB = NULL; PFNGLCOMPRESSEDTEXIMAGE3DARBPROC __glewCompressedTexImage3DARB = NULL; PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC __glewCompressedTexSubImage1DARB = NULL; PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB = NULL; PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB = NULL; PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB = NULL; PFNGLGETMULTISAMPLEFVPROC __glewGetMultisamplefv = NULL; PFNGLSAMPLEMASKIPROC __glewSampleMaski = NULL; PFNGLTEXIMAGE2DMULTISAMPLEPROC __glewTexImage2DMultisample = NULL; PFNGLTEXIMAGE3DMULTISAMPLEPROC __glewTexImage3DMultisample = NULL; PFNGLTEXSTORAGE1DPROC __glewTexStorage1D = NULL; PFNGLTEXSTORAGE2DPROC __glewTexStorage2D = NULL; PFNGLTEXSTORAGE3DPROC __glewTexStorage3D = NULL; PFNGLTEXTURESTORAGE1DEXTPROC __glewTextureStorage1DEXT = NULL; PFNGLTEXTURESTORAGE2DEXTPROC __glewTextureStorage2DEXT = NULL; PFNGLTEXTURESTORAGE3DEXTPROC __glewTextureStorage3DEXT = NULL; PFNGLTEXSTORAGE2DMULTISAMPLEPROC __glewTexStorage2DMultisample = NULL; PFNGLTEXSTORAGE3DMULTISAMPLEPROC __glewTexStorage3DMultisample = NULL; PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC __glewTextureStorage2DMultisampleEXT = NULL; PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC __glewTextureStorage3DMultisampleEXT = NULL; PFNGLTEXTUREVIEWPROC __glewTextureView = NULL; PFNGLGETQUERYOBJECTI64VPROC __glewGetQueryObjecti64v = NULL; PFNGLGETQUERYOBJECTUI64VPROC __glewGetQueryObjectui64v = NULL; PFNGLQUERYCOUNTERPROC __glewQueryCounter = NULL; PFNGLBINDTRANSFORMFEEDBACKPROC __glewBindTransformFeedback = NULL; PFNGLDELETETRANSFORMFEEDBACKSPROC __glewDeleteTransformFeedbacks = NULL; PFNGLDRAWTRANSFORMFEEDBACKPROC __glewDrawTransformFeedback = NULL; PFNGLGENTRANSFORMFEEDBACKSPROC __glewGenTransformFeedbacks = NULL; PFNGLISTRANSFORMFEEDBACKPROC __glewIsTransformFeedback = NULL; PFNGLPAUSETRANSFORMFEEDBACKPROC __glewPauseTransformFeedback = NULL; PFNGLRESUMETRANSFORMFEEDBACKPROC __glewResumeTransformFeedback = NULL; PFNGLBEGINQUERYINDEXEDPROC __glewBeginQueryIndexed = NULL; PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC __glewDrawTransformFeedbackStream = NULL; PFNGLENDQUERYINDEXEDPROC __glewEndQueryIndexed = NULL; PFNGLGETQUERYINDEXEDIVPROC __glewGetQueryIndexediv = NULL; PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC __glewDrawTransformFeedbackInstanced = NULL; PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC __glewDrawTransformFeedbackStreamInstanced = NULL; PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB = NULL; PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB = NULL; PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB = NULL; PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB = NULL; PFNGLBINDBUFFERBASEPROC __glewBindBufferBase = NULL; PFNGLBINDBUFFERRANGEPROC __glewBindBufferRange = NULL; PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC __glewGetActiveUniformBlockName = NULL; PFNGLGETACTIVEUNIFORMBLOCKIVPROC __glewGetActiveUniformBlockiv = NULL; PFNGLGETACTIVEUNIFORMNAMEPROC __glewGetActiveUniformName = NULL; PFNGLGETACTIVEUNIFORMSIVPROC __glewGetActiveUniformsiv = NULL; PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v = NULL; PFNGLGETUNIFORMBLOCKINDEXPROC __glewGetUniformBlockIndex = NULL; PFNGLGETUNIFORMINDICESPROC __glewGetUniformIndices = NULL; PFNGLUNIFORMBLOCKBINDINGPROC __glewUniformBlockBinding = NULL; PFNGLBINDVERTEXARRAYPROC __glewBindVertexArray = NULL; PFNGLDELETEVERTEXARRAYSPROC __glewDeleteVertexArrays = NULL; PFNGLGENVERTEXARRAYSPROC __glewGenVertexArrays = NULL; PFNGLISVERTEXARRAYPROC __glewIsVertexArray = NULL; PFNGLGETVERTEXATTRIBLDVPROC __glewGetVertexAttribLdv = NULL; PFNGLVERTEXATTRIBL1DPROC __glewVertexAttribL1d = NULL; PFNGLVERTEXATTRIBL1DVPROC __glewVertexAttribL1dv = NULL; PFNGLVERTEXATTRIBL2DPROC __glewVertexAttribL2d = NULL; PFNGLVERTEXATTRIBL2DVPROC __glewVertexAttribL2dv = NULL; PFNGLVERTEXATTRIBL3DPROC __glewVertexAttribL3d = NULL; PFNGLVERTEXATTRIBL3DVPROC __glewVertexAttribL3dv = NULL; PFNGLVERTEXATTRIBL4DPROC __glewVertexAttribL4d = NULL; PFNGLVERTEXATTRIBL4DVPROC __glewVertexAttribL4dv = NULL; PFNGLVERTEXATTRIBLPOINTERPROC __glewVertexAttribLPointer = NULL; PFNGLBINDVERTEXBUFFERPROC __glewBindVertexBuffer = NULL; PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC __glewVertexArrayBindVertexBufferEXT = NULL; PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC __glewVertexArrayVertexAttribBindingEXT = NULL; PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC __glewVertexArrayVertexAttribFormatEXT = NULL; PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC __glewVertexArrayVertexAttribIFormatEXT = NULL; PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC __glewVertexArrayVertexAttribLFormatEXT = NULL; PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC __glewVertexArrayVertexBindingDivisorEXT = NULL; PFNGLVERTEXATTRIBBINDINGPROC __glewVertexAttribBinding = NULL; PFNGLVERTEXATTRIBFORMATPROC __glewVertexAttribFormat = NULL; PFNGLVERTEXATTRIBIFORMATPROC __glewVertexAttribIFormat = NULL; PFNGLVERTEXATTRIBLFORMATPROC __glewVertexAttribLFormat = NULL; PFNGLVERTEXBINDINGDIVISORPROC __glewVertexBindingDivisor = NULL; PFNGLVERTEXBLENDARBPROC __glewVertexBlendARB = NULL; PFNGLWEIGHTPOINTERARBPROC __glewWeightPointerARB = NULL; PFNGLWEIGHTBVARBPROC __glewWeightbvARB = NULL; PFNGLWEIGHTDVARBPROC __glewWeightdvARB = NULL; PFNGLWEIGHTFVARBPROC __glewWeightfvARB = NULL; PFNGLWEIGHTIVARBPROC __glewWeightivARB = NULL; PFNGLWEIGHTSVARBPROC __glewWeightsvARB = NULL; PFNGLWEIGHTUBVARBPROC __glewWeightubvARB = NULL; PFNGLWEIGHTUIVARBPROC __glewWeightuivARB = NULL; PFNGLWEIGHTUSVARBPROC __glewWeightusvARB = NULL; PFNGLBINDBUFFERARBPROC __glewBindBufferARB = NULL; PFNGLBUFFERDATAARBPROC __glewBufferDataARB = NULL; PFNGLBUFFERSUBDATAARBPROC __glewBufferSubDataARB = NULL; PFNGLDELETEBUFFERSARBPROC __glewDeleteBuffersARB = NULL; PFNGLGENBUFFERSARBPROC __glewGenBuffersARB = NULL; PFNGLGETBUFFERPARAMETERIVARBPROC __glewGetBufferParameterivARB = NULL; PFNGLGETBUFFERPOINTERVARBPROC __glewGetBufferPointervARB = NULL; PFNGLGETBUFFERSUBDATAARBPROC __glewGetBufferSubDataARB = NULL; PFNGLISBUFFERARBPROC __glewIsBufferARB = NULL; PFNGLMAPBUFFERARBPROC __glewMapBufferARB = NULL; PFNGLUNMAPBUFFERARBPROC __glewUnmapBufferARB = NULL; PFNGLBINDPROGRAMARBPROC __glewBindProgramARB = NULL; PFNGLDELETEPROGRAMSARBPROC __glewDeleteProgramsARB = NULL; PFNGLDISABLEVERTEXATTRIBARRAYARBPROC __glewDisableVertexAttribArrayARB = NULL; PFNGLENABLEVERTEXATTRIBARRAYARBPROC __glewEnableVertexAttribArrayARB = NULL; PFNGLGENPROGRAMSARBPROC __glewGenProgramsARB = NULL; PFNGLGETPROGRAMENVPARAMETERDVARBPROC __glewGetProgramEnvParameterdvARB = NULL; PFNGLGETPROGRAMENVPARAMETERFVARBPROC __glewGetProgramEnvParameterfvARB = NULL; PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC __glewGetProgramLocalParameterdvARB = NULL; PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC __glewGetProgramLocalParameterfvARB = NULL; PFNGLGETPROGRAMSTRINGARBPROC __glewGetProgramStringARB = NULL; PFNGLGETPROGRAMIVARBPROC __glewGetProgramivARB = NULL; PFNGLGETVERTEXATTRIBPOINTERVARBPROC __glewGetVertexAttribPointervARB = NULL; PFNGLGETVERTEXATTRIBDVARBPROC __glewGetVertexAttribdvARB = NULL; PFNGLGETVERTEXATTRIBFVARBPROC __glewGetVertexAttribfvARB = NULL; PFNGLGETVERTEXATTRIBIVARBPROC __glewGetVertexAttribivARB = NULL; PFNGLISPROGRAMARBPROC __glewIsProgramARB = NULL; PFNGLPROGRAMENVPARAMETER4DARBPROC __glewProgramEnvParameter4dARB = NULL; PFNGLPROGRAMENVPARAMETER4DVARBPROC __glewProgramEnvParameter4dvARB = NULL; PFNGLPROGRAMENVPARAMETER4FARBPROC __glewProgramEnvParameter4fARB = NULL; PFNGLPROGRAMENVPARAMETER4FVARBPROC __glewProgramEnvParameter4fvARB = NULL; PFNGLPROGRAMLOCALPARAMETER4DARBPROC __glewProgramLocalParameter4dARB = NULL; PFNGLPROGRAMLOCALPARAMETER4DVARBPROC __glewProgramLocalParameter4dvARB = NULL; PFNGLPROGRAMLOCALPARAMETER4FARBPROC __glewProgramLocalParameter4fARB = NULL; PFNGLPROGRAMLOCALPARAMETER4FVARBPROC __glewProgramLocalParameter4fvARB = NULL; PFNGLPROGRAMSTRINGARBPROC __glewProgramStringARB = NULL; PFNGLVERTEXATTRIB1DARBPROC __glewVertexAttrib1dARB = NULL; PFNGLVERTEXATTRIB1DVARBPROC __glewVertexAttrib1dvARB = NULL; PFNGLVERTEXATTRIB1FARBPROC __glewVertexAttrib1fARB = NULL; PFNGLVERTEXATTRIB1FVARBPROC __glewVertexAttrib1fvARB = NULL; PFNGLVERTEXATTRIB1SARBPROC __glewVertexAttrib1sARB = NULL; PFNGLVERTEXATTRIB1SVARBPROC __glewVertexAttrib1svARB = NULL; PFNGLVERTEXATTRIB2DARBPROC __glewVertexAttrib2dARB = NULL; PFNGLVERTEXATTRIB2DVARBPROC __glewVertexAttrib2dvARB = NULL; PFNGLVERTEXATTRIB2FARBPROC __glewVertexAttrib2fARB = NULL; PFNGLVERTEXATTRIB2FVARBPROC __glewVertexAttrib2fvARB = NULL; PFNGLVERTEXATTRIB2SARBPROC __glewVertexAttrib2sARB = NULL; PFNGLVERTEXATTRIB2SVARBPROC __glewVertexAttrib2svARB = NULL; PFNGLVERTEXATTRIB3DARBPROC __glewVertexAttrib3dARB = NULL; PFNGLVERTEXATTRIB3DVARBPROC __glewVertexAttrib3dvARB = NULL; PFNGLVERTEXATTRIB3FARBPROC __glewVertexAttrib3fARB = NULL; PFNGLVERTEXATTRIB3FVARBPROC __glewVertexAttrib3fvARB = NULL; PFNGLVERTEXATTRIB3SARBPROC __glewVertexAttrib3sARB = NULL; PFNGLVERTEXATTRIB3SVARBPROC __glewVertexAttrib3svARB = NULL; PFNGLVERTEXATTRIB4NBVARBPROC __glewVertexAttrib4NbvARB = NULL; PFNGLVERTEXATTRIB4NIVARBPROC __glewVertexAttrib4NivARB = NULL; PFNGLVERTEXATTRIB4NSVARBPROC __glewVertexAttrib4NsvARB = NULL; PFNGLVERTEXATTRIB4NUBARBPROC __glewVertexAttrib4NubARB = NULL; PFNGLVERTEXATTRIB4NUBVARBPROC __glewVertexAttrib4NubvARB = NULL; PFNGLVERTEXATTRIB4NUIVARBPROC __glewVertexAttrib4NuivARB = NULL; PFNGLVERTEXATTRIB4NUSVARBPROC __glewVertexAttrib4NusvARB = NULL; PFNGLVERTEXATTRIB4BVARBPROC __glewVertexAttrib4bvARB = NULL; PFNGLVERTEXATTRIB4DARBPROC __glewVertexAttrib4dARB = NULL; PFNGLVERTEXATTRIB4DVARBPROC __glewVertexAttrib4dvARB = NULL; PFNGLVERTEXATTRIB4FARBPROC __glewVertexAttrib4fARB = NULL; PFNGLVERTEXATTRIB4FVARBPROC __glewVertexAttrib4fvARB = NULL; PFNGLVERTEXATTRIB4IVARBPROC __glewVertexAttrib4ivARB = NULL; PFNGLVERTEXATTRIB4SARBPROC __glewVertexAttrib4sARB = NULL; PFNGLVERTEXATTRIB4SVARBPROC __glewVertexAttrib4svARB = NULL; PFNGLVERTEXATTRIB4UBVARBPROC __glewVertexAttrib4ubvARB = NULL; PFNGLVERTEXATTRIB4UIVARBPROC __glewVertexAttrib4uivARB = NULL; PFNGLVERTEXATTRIB4USVARBPROC __glewVertexAttrib4usvARB = NULL; PFNGLVERTEXATTRIBPOINTERARBPROC __glewVertexAttribPointerARB = NULL; PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB = NULL; PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB = NULL; PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB = NULL; PFNGLCOLORP3UIPROC __glewColorP3ui = NULL; PFNGLCOLORP3UIVPROC __glewColorP3uiv = NULL; PFNGLCOLORP4UIPROC __glewColorP4ui = NULL; PFNGLCOLORP4UIVPROC __glewColorP4uiv = NULL; PFNGLMULTITEXCOORDP1UIPROC __glewMultiTexCoordP1ui = NULL; PFNGLMULTITEXCOORDP1UIVPROC __glewMultiTexCoordP1uiv = NULL; PFNGLMULTITEXCOORDP2UIPROC __glewMultiTexCoordP2ui = NULL; PFNGLMULTITEXCOORDP2UIVPROC __glewMultiTexCoordP2uiv = NULL; PFNGLMULTITEXCOORDP3UIPROC __glewMultiTexCoordP3ui = NULL; PFNGLMULTITEXCOORDP3UIVPROC __glewMultiTexCoordP3uiv = NULL; PFNGLMULTITEXCOORDP4UIPROC __glewMultiTexCoordP4ui = NULL; PFNGLMULTITEXCOORDP4UIVPROC __glewMultiTexCoordP4uiv = NULL; PFNGLNORMALP3UIPROC __glewNormalP3ui = NULL; PFNGLNORMALP3UIVPROC __glewNormalP3uiv = NULL; PFNGLSECONDARYCOLORP3UIPROC __glewSecondaryColorP3ui = NULL; PFNGLSECONDARYCOLORP3UIVPROC __glewSecondaryColorP3uiv = NULL; PFNGLTEXCOORDP1UIPROC __glewTexCoordP1ui = NULL; PFNGLTEXCOORDP1UIVPROC __glewTexCoordP1uiv = NULL; PFNGLTEXCOORDP2UIPROC __glewTexCoordP2ui = NULL; PFNGLTEXCOORDP2UIVPROC __glewTexCoordP2uiv = NULL; PFNGLTEXCOORDP3UIPROC __glewTexCoordP3ui = NULL; PFNGLTEXCOORDP3UIVPROC __glewTexCoordP3uiv = NULL; PFNGLTEXCOORDP4UIPROC __glewTexCoordP4ui = NULL; PFNGLTEXCOORDP4UIVPROC __glewTexCoordP4uiv = NULL; PFNGLVERTEXATTRIBP1UIPROC __glewVertexAttribP1ui = NULL; PFNGLVERTEXATTRIBP1UIVPROC __glewVertexAttribP1uiv = NULL; PFNGLVERTEXATTRIBP2UIPROC __glewVertexAttribP2ui = NULL; PFNGLVERTEXATTRIBP2UIVPROC __glewVertexAttribP2uiv = NULL; PFNGLVERTEXATTRIBP3UIPROC __glewVertexAttribP3ui = NULL; PFNGLVERTEXATTRIBP3UIVPROC __glewVertexAttribP3uiv = NULL; PFNGLVERTEXATTRIBP4UIPROC __glewVertexAttribP4ui = NULL; PFNGLVERTEXATTRIBP4UIVPROC __glewVertexAttribP4uiv = NULL; PFNGLVERTEXP2UIPROC __glewVertexP2ui = NULL; PFNGLVERTEXP2UIVPROC __glewVertexP2uiv = NULL; PFNGLVERTEXP3UIPROC __glewVertexP3ui = NULL; PFNGLVERTEXP3UIVPROC __glewVertexP3uiv = NULL; PFNGLVERTEXP4UIPROC __glewVertexP4ui = NULL; PFNGLVERTEXP4UIVPROC __glewVertexP4uiv = NULL; PFNGLDEPTHRANGEARRAYVPROC __glewDepthRangeArrayv = NULL; PFNGLDEPTHRANGEINDEXEDPROC __glewDepthRangeIndexed = NULL; PFNGLGETDOUBLEI_VPROC __glewGetDoublei_v = NULL; PFNGLGETFLOATI_VPROC __glewGetFloati_v = NULL; PFNGLSCISSORARRAYVPROC __glewScissorArrayv = NULL; PFNGLSCISSORINDEXEDPROC __glewScissorIndexed = NULL; PFNGLSCISSORINDEXEDVPROC __glewScissorIndexedv = NULL; PFNGLVIEWPORTARRAYVPROC __glewViewportArrayv = NULL; PFNGLVIEWPORTINDEXEDFPROC __glewViewportIndexedf = NULL; PFNGLVIEWPORTINDEXEDFVPROC __glewViewportIndexedfv = NULL; PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB = NULL; PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB = NULL; PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB = NULL; PFNGLWINDOWPOS2FVARBPROC __glewWindowPos2fvARB = NULL; PFNGLWINDOWPOS2IARBPROC __glewWindowPos2iARB = NULL; PFNGLWINDOWPOS2IVARBPROC __glewWindowPos2ivARB = NULL; PFNGLWINDOWPOS2SARBPROC __glewWindowPos2sARB = NULL; PFNGLWINDOWPOS2SVARBPROC __glewWindowPos2svARB = NULL; PFNGLWINDOWPOS3DARBPROC __glewWindowPos3dARB = NULL; PFNGLWINDOWPOS3DVARBPROC __glewWindowPos3dvARB = NULL; PFNGLWINDOWPOS3FARBPROC __glewWindowPos3fARB = NULL; PFNGLWINDOWPOS3FVARBPROC __glewWindowPos3fvARB = NULL; PFNGLWINDOWPOS3IARBPROC __glewWindowPos3iARB = NULL; PFNGLWINDOWPOS3IVARBPROC __glewWindowPos3ivARB = NULL; PFNGLWINDOWPOS3SARBPROC __glewWindowPos3sARB = NULL; PFNGLWINDOWPOS3SVARBPROC __glewWindowPos3svARB = NULL; PFNGLDRAWBUFFERSATIPROC __glewDrawBuffersATI = NULL; PFNGLDRAWELEMENTARRAYATIPROC __glewDrawElementArrayATI = NULL; PFNGLDRAWRANGEELEMENTARRAYATIPROC __glewDrawRangeElementArrayATI = NULL; PFNGLELEMENTPOINTERATIPROC __glewElementPointerATI = NULL; PFNGLGETTEXBUMPPARAMETERFVATIPROC __glewGetTexBumpParameterfvATI = NULL; PFNGLGETTEXBUMPPARAMETERIVATIPROC __glewGetTexBumpParameterivATI = NULL; PFNGLTEXBUMPPARAMETERFVATIPROC __glewTexBumpParameterfvATI = NULL; PFNGLTEXBUMPPARAMETERIVATIPROC __glewTexBumpParameterivATI = NULL; PFNGLALPHAFRAGMENTOP1ATIPROC __glewAlphaFragmentOp1ATI = NULL; PFNGLALPHAFRAGMENTOP2ATIPROC __glewAlphaFragmentOp2ATI = NULL; PFNGLALPHAFRAGMENTOP3ATIPROC __glewAlphaFragmentOp3ATI = NULL; PFNGLBEGINFRAGMENTSHADERATIPROC __glewBeginFragmentShaderATI = NULL; PFNGLBINDFRAGMENTSHADERATIPROC __glewBindFragmentShaderATI = NULL; PFNGLCOLORFRAGMENTOP1ATIPROC __glewColorFragmentOp1ATI = NULL; PFNGLCOLORFRAGMENTOP2ATIPROC __glewColorFragmentOp2ATI = NULL; PFNGLCOLORFRAGMENTOP3ATIPROC __glewColorFragmentOp3ATI = NULL; PFNGLDELETEFRAGMENTSHADERATIPROC __glewDeleteFragmentShaderATI = NULL; PFNGLENDFRAGMENTSHADERATIPROC __glewEndFragmentShaderATI = NULL; PFNGLGENFRAGMENTSHADERSATIPROC __glewGenFragmentShadersATI = NULL; PFNGLPASSTEXCOORDATIPROC __glewPassTexCoordATI = NULL; PFNGLSAMPLEMAPATIPROC __glewSampleMapATI = NULL; PFNGLSETFRAGMENTSHADERCONSTANTATIPROC __glewSetFragmentShaderConstantATI = NULL; PFNGLMAPOBJECTBUFFERATIPROC __glewMapObjectBufferATI = NULL; PFNGLUNMAPOBJECTBUFFERATIPROC __glewUnmapObjectBufferATI = NULL; PFNGLPNTRIANGLESFATIPROC __glewPNTrianglesfATI = NULL; PFNGLPNTRIANGLESIATIPROC __glewPNTrianglesiATI = NULL; PFNGLSTENCILFUNCSEPARATEATIPROC __glewStencilFuncSeparateATI = NULL; PFNGLSTENCILOPSEPARATEATIPROC __glewStencilOpSeparateATI = NULL; PFNGLARRAYOBJECTATIPROC __glewArrayObjectATI = NULL; PFNGLFREEOBJECTBUFFERATIPROC __glewFreeObjectBufferATI = NULL; PFNGLGETARRAYOBJECTFVATIPROC __glewGetArrayObjectfvATI = NULL; PFNGLGETARRAYOBJECTIVATIPROC __glewGetArrayObjectivATI = NULL; PFNGLGETOBJECTBUFFERFVATIPROC __glewGetObjectBufferfvATI = NULL; PFNGLGETOBJECTBUFFERIVATIPROC __glewGetObjectBufferivATI = NULL; PFNGLGETVARIANTARRAYOBJECTFVATIPROC __glewGetVariantArrayObjectfvATI = NULL; PFNGLGETVARIANTARRAYOBJECTIVATIPROC __glewGetVariantArrayObjectivATI = NULL; PFNGLISOBJECTBUFFERATIPROC __glewIsObjectBufferATI = NULL; PFNGLNEWOBJECTBUFFERATIPROC __glewNewObjectBufferATI = NULL; PFNGLUPDATEOBJECTBUFFERATIPROC __glewUpdateObjectBufferATI = NULL; PFNGLVARIANTARRAYOBJECTATIPROC __glewVariantArrayObjectATI = NULL; PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC __glewGetVertexAttribArrayObjectfvATI = NULL; PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC __glewGetVertexAttribArrayObjectivATI = NULL; PFNGLVERTEXATTRIBARRAYOBJECTATIPROC __glewVertexAttribArrayObjectATI = NULL; PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC __glewClientActiveVertexStreamATI = NULL; PFNGLNORMALSTREAM3BATIPROC __glewNormalStream3bATI = NULL; PFNGLNORMALSTREAM3BVATIPROC __glewNormalStream3bvATI = NULL; PFNGLNORMALSTREAM3DATIPROC __glewNormalStream3dATI = NULL; PFNGLNORMALSTREAM3DVATIPROC __glewNormalStream3dvATI = NULL; PFNGLNORMALSTREAM3FATIPROC __glewNormalStream3fATI = NULL; PFNGLNORMALSTREAM3FVATIPROC __glewNormalStream3fvATI = NULL; PFNGLNORMALSTREAM3IATIPROC __glewNormalStream3iATI = NULL; PFNGLNORMALSTREAM3IVATIPROC __glewNormalStream3ivATI = NULL; PFNGLNORMALSTREAM3SATIPROC __glewNormalStream3sATI = NULL; PFNGLNORMALSTREAM3SVATIPROC __glewNormalStream3svATI = NULL; PFNGLVERTEXBLENDENVFATIPROC __glewVertexBlendEnvfATI = NULL; PFNGLVERTEXBLENDENVIATIPROC __glewVertexBlendEnviATI = NULL; PFNGLVERTEXSTREAM1DATIPROC __glewVertexStream1dATI = NULL; PFNGLVERTEXSTREAM1DVATIPROC __glewVertexStream1dvATI = NULL; PFNGLVERTEXSTREAM1FATIPROC __glewVertexStream1fATI = NULL; PFNGLVERTEXSTREAM1FVATIPROC __glewVertexStream1fvATI = NULL; PFNGLVERTEXSTREAM1IATIPROC __glewVertexStream1iATI = NULL; PFNGLVERTEXSTREAM1IVATIPROC __glewVertexStream1ivATI = NULL; PFNGLVERTEXSTREAM1SATIPROC __glewVertexStream1sATI = NULL; PFNGLVERTEXSTREAM1SVATIPROC __glewVertexStream1svATI = NULL; PFNGLVERTEXSTREAM2DATIPROC __glewVertexStream2dATI = NULL; PFNGLVERTEXSTREAM2DVATIPROC __glewVertexStream2dvATI = NULL; PFNGLVERTEXSTREAM2FATIPROC __glewVertexStream2fATI = NULL; PFNGLVERTEXSTREAM2FVATIPROC __glewVertexStream2fvATI = NULL; PFNGLVERTEXSTREAM2IATIPROC __glewVertexStream2iATI = NULL; PFNGLVERTEXSTREAM2IVATIPROC __glewVertexStream2ivATI = NULL; PFNGLVERTEXSTREAM2SATIPROC __glewVertexStream2sATI = NULL; PFNGLVERTEXSTREAM2SVATIPROC __glewVertexStream2svATI = NULL; PFNGLVERTEXSTREAM3DATIPROC __glewVertexStream3dATI = NULL; PFNGLVERTEXSTREAM3DVATIPROC __glewVertexStream3dvATI = NULL; PFNGLVERTEXSTREAM3FATIPROC __glewVertexStream3fATI = NULL; PFNGLVERTEXSTREAM3FVATIPROC __glewVertexStream3fvATI = NULL; PFNGLVERTEXSTREAM3IATIPROC __glewVertexStream3iATI = NULL; PFNGLVERTEXSTREAM3IVATIPROC __glewVertexStream3ivATI = NULL; PFNGLVERTEXSTREAM3SATIPROC __glewVertexStream3sATI = NULL; PFNGLVERTEXSTREAM3SVATIPROC __glewVertexStream3svATI = NULL; PFNGLVERTEXSTREAM4DATIPROC __glewVertexStream4dATI = NULL; PFNGLVERTEXSTREAM4DVATIPROC __glewVertexStream4dvATI = NULL; PFNGLVERTEXSTREAM4FATIPROC __glewVertexStream4fATI = NULL; PFNGLVERTEXSTREAM4FVATIPROC __glewVertexStream4fvATI = NULL; PFNGLVERTEXSTREAM4IATIPROC __glewVertexStream4iATI = NULL; PFNGLVERTEXSTREAM4IVATIPROC __glewVertexStream4ivATI = NULL; PFNGLVERTEXSTREAM4SATIPROC __glewVertexStream4sATI = NULL; PFNGLVERTEXSTREAM4SVATIPROC __glewVertexStream4svATI = NULL; PFNGLGETUNIFORMBUFFERSIZEEXTPROC __glewGetUniformBufferSizeEXT = NULL; PFNGLGETUNIFORMOFFSETEXTPROC __glewGetUniformOffsetEXT = NULL; PFNGLUNIFORMBUFFEREXTPROC __glewUniformBufferEXT = NULL; PFNGLBLENDCOLOREXTPROC __glewBlendColorEXT = NULL; PFNGLBLENDEQUATIONSEPARATEEXTPROC __glewBlendEquationSeparateEXT = NULL; PFNGLBLENDFUNCSEPARATEEXTPROC __glewBlendFuncSeparateEXT = NULL; PFNGLBLENDEQUATIONEXTPROC __glewBlendEquationEXT = NULL; PFNGLCOLORSUBTABLEEXTPROC __glewColorSubTableEXT = NULL; PFNGLCOPYCOLORSUBTABLEEXTPROC __glewCopyColorSubTableEXT = NULL; PFNGLLOCKARRAYSEXTPROC __glewLockArraysEXT = NULL; PFNGLUNLOCKARRAYSEXTPROC __glewUnlockArraysEXT = NULL; PFNGLCONVOLUTIONFILTER1DEXTPROC __glewConvolutionFilter1DEXT = NULL; PFNGLCONVOLUTIONFILTER2DEXTPROC __glewConvolutionFilter2DEXT = NULL; PFNGLCONVOLUTIONPARAMETERFEXTPROC __glewConvolutionParameterfEXT = NULL; PFNGLCONVOLUTIONPARAMETERFVEXTPROC __glewConvolutionParameterfvEXT = NULL; PFNGLCONVOLUTIONPARAMETERIEXTPROC __glewConvolutionParameteriEXT = NULL; PFNGLCONVOLUTIONPARAMETERIVEXTPROC __glewConvolutionParameterivEXT = NULL; PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC __glewCopyConvolutionFilter1DEXT = NULL; PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC __glewCopyConvolutionFilter2DEXT = NULL; PFNGLGETCONVOLUTIONFILTEREXTPROC __glewGetConvolutionFilterEXT = NULL; PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC __glewGetConvolutionParameterfvEXT = NULL; PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC __glewGetConvolutionParameterivEXT = NULL; PFNGLGETSEPARABLEFILTEREXTPROC __glewGetSeparableFilterEXT = NULL; PFNGLSEPARABLEFILTER2DEXTPROC __glewSeparableFilter2DEXT = NULL; PFNGLBINORMALPOINTEREXTPROC __glewBinormalPointerEXT = NULL; PFNGLTANGENTPOINTEREXTPROC __glewTangentPointerEXT = NULL; PFNGLCOPYTEXIMAGE1DEXTPROC __glewCopyTexImage1DEXT = NULL; PFNGLCOPYTEXIMAGE2DEXTPROC __glewCopyTexImage2DEXT = NULL; PFNGLCOPYTEXSUBIMAGE1DEXTPROC __glewCopyTexSubImage1DEXT = NULL; PFNGLCOPYTEXSUBIMAGE2DEXTPROC __glewCopyTexSubImage2DEXT = NULL; PFNGLCOPYTEXSUBIMAGE3DEXTPROC __glewCopyTexSubImage3DEXT = NULL; PFNGLCULLPARAMETERDVEXTPROC __glewCullParameterdvEXT = NULL; PFNGLCULLPARAMETERFVEXTPROC __glewCullParameterfvEXT = NULL; PFNGLGETOBJECTLABELEXTPROC __glewGetObjectLabelEXT = NULL; PFNGLLABELOBJECTEXTPROC __glewLabelObjectEXT = NULL; PFNGLINSERTEVENTMARKEREXTPROC __glewInsertEventMarkerEXT = NULL; PFNGLPOPGROUPMARKEREXTPROC __glewPopGroupMarkerEXT = NULL; PFNGLPUSHGROUPMARKEREXTPROC __glewPushGroupMarkerEXT = NULL; PFNGLDEPTHBOUNDSEXTPROC __glewDepthBoundsEXT = NULL; PFNGLBINDMULTITEXTUREEXTPROC __glewBindMultiTextureEXT = NULL; PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC __glewCheckNamedFramebufferStatusEXT = NULL; PFNGLCLIENTATTRIBDEFAULTEXTPROC __glewClientAttribDefaultEXT = NULL; PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC __glewCompressedMultiTexImage1DEXT = NULL; PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC __glewCompressedMultiTexImage2DEXT = NULL; PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC __glewCompressedMultiTexImage3DEXT = NULL; PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC __glewCompressedMultiTexSubImage1DEXT = NULL; PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC __glewCompressedMultiTexSubImage2DEXT = NULL; PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC __glewCompressedMultiTexSubImage3DEXT = NULL; PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC __glewCompressedTextureImage1DEXT = NULL; PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC __glewCompressedTextureImage2DEXT = NULL; PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC __glewCompressedTextureImage3DEXT = NULL; PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC __glewCompressedTextureSubImage1DEXT = NULL; PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC __glewCompressedTextureSubImage2DEXT = NULL; PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC __glewCompressedTextureSubImage3DEXT = NULL; PFNGLCOPYMULTITEXIMAGE1DEXTPROC __glewCopyMultiTexImage1DEXT = NULL; PFNGLCOPYMULTITEXIMAGE2DEXTPROC __glewCopyMultiTexImage2DEXT = NULL; PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC __glewCopyMultiTexSubImage1DEXT = NULL; PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC __glewCopyMultiTexSubImage2DEXT = NULL; PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC __glewCopyMultiTexSubImage3DEXT = NULL; PFNGLCOPYTEXTUREIMAGE1DEXTPROC __glewCopyTextureImage1DEXT = NULL; PFNGLCOPYTEXTUREIMAGE2DEXTPROC __glewCopyTextureImage2DEXT = NULL; PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC __glewCopyTextureSubImage1DEXT = NULL; PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC __glewCopyTextureSubImage2DEXT = NULL; PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC __glewCopyTextureSubImage3DEXT = NULL; PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC __glewDisableClientStateIndexedEXT = NULL; PFNGLDISABLECLIENTSTATEIEXTPROC __glewDisableClientStateiEXT = NULL; PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC __glewDisableVertexArrayAttribEXT = NULL; PFNGLDISABLEVERTEXARRAYEXTPROC __glewDisableVertexArrayEXT = NULL; PFNGLENABLECLIENTSTATEINDEXEDEXTPROC __glewEnableClientStateIndexedEXT = NULL; PFNGLENABLECLIENTSTATEIEXTPROC __glewEnableClientStateiEXT = NULL; PFNGLENABLEVERTEXARRAYATTRIBEXTPROC __glewEnableVertexArrayAttribEXT = NULL; PFNGLENABLEVERTEXARRAYEXTPROC __glewEnableVertexArrayEXT = NULL; PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC __glewFlushMappedNamedBufferRangeEXT = NULL; PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC __glewFramebufferDrawBufferEXT = NULL; PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC __glewFramebufferDrawBuffersEXT = NULL; PFNGLFRAMEBUFFERREADBUFFEREXTPROC __glewFramebufferReadBufferEXT = NULL; PFNGLGENERATEMULTITEXMIPMAPEXTPROC __glewGenerateMultiTexMipmapEXT = NULL; PFNGLGENERATETEXTUREMIPMAPEXTPROC __glewGenerateTextureMipmapEXT = NULL; PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC __glewGetCompressedMultiTexImageEXT = NULL; PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC __glewGetCompressedTextureImageEXT = NULL; PFNGLGETDOUBLEINDEXEDVEXTPROC __glewGetDoubleIndexedvEXT = NULL; PFNGLGETDOUBLEI_VEXTPROC __glewGetDoublei_vEXT = NULL; PFNGLGETFLOATINDEXEDVEXTPROC __glewGetFloatIndexedvEXT = NULL; PFNGLGETFLOATI_VEXTPROC __glewGetFloati_vEXT = NULL; PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC __glewGetFramebufferParameterivEXT = NULL; PFNGLGETMULTITEXENVFVEXTPROC __glewGetMultiTexEnvfvEXT = NULL; PFNGLGETMULTITEXENVIVEXTPROC __glewGetMultiTexEnvivEXT = NULL; PFNGLGETMULTITEXGENDVEXTPROC __glewGetMultiTexGendvEXT = NULL; PFNGLGETMULTITEXGENFVEXTPROC __glewGetMultiTexGenfvEXT = NULL; PFNGLGETMULTITEXGENIVEXTPROC __glewGetMultiTexGenivEXT = NULL; PFNGLGETMULTITEXIMAGEEXTPROC __glewGetMultiTexImageEXT = NULL; PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC __glewGetMultiTexLevelParameterfvEXT = NULL; PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC __glewGetMultiTexLevelParameterivEXT = NULL; PFNGLGETMULTITEXPARAMETERIIVEXTPROC __glewGetMultiTexParameterIivEXT = NULL; PFNGLGETMULTITEXPARAMETERIUIVEXTPROC __glewGetMultiTexParameterIuivEXT = NULL; PFNGLGETMULTITEXPARAMETERFVEXTPROC __glewGetMultiTexParameterfvEXT = NULL; PFNGLGETMULTITEXPARAMETERIVEXTPROC __glewGetMultiTexParameterivEXT = NULL; PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC __glewGetNamedBufferParameterivEXT = NULL; PFNGLGETNAMEDBUFFERPOINTERVEXTPROC __glewGetNamedBufferPointervEXT = NULL; PFNGLGETNAMEDBUFFERSUBDATAEXTPROC __glewGetNamedBufferSubDataEXT = NULL; PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetNamedFramebufferAttachmentParameterivEXT = NULL; PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC __glewGetNamedProgramLocalParameterIivEXT = NULL; PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC __glewGetNamedProgramLocalParameterIuivEXT = NULL; PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC __glewGetNamedProgramLocalParameterdvEXT = NULL; PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC __glewGetNamedProgramLocalParameterfvEXT = NULL; PFNGLGETNAMEDPROGRAMSTRINGEXTPROC __glewGetNamedProgramStringEXT = NULL; PFNGLGETNAMEDPROGRAMIVEXTPROC __glewGetNamedProgramivEXT = NULL; PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC __glewGetNamedRenderbufferParameterivEXT = NULL; PFNGLGETPOINTERINDEXEDVEXTPROC __glewGetPointerIndexedvEXT = NULL; PFNGLGETPOINTERI_VEXTPROC __glewGetPointeri_vEXT = NULL; PFNGLGETTEXTUREIMAGEEXTPROC __glewGetTextureImageEXT = NULL; PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC __glewGetTextureLevelParameterfvEXT = NULL; PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC __glewGetTextureLevelParameterivEXT = NULL; PFNGLGETTEXTUREPARAMETERIIVEXTPROC __glewGetTextureParameterIivEXT = NULL; PFNGLGETTEXTUREPARAMETERIUIVEXTPROC __glewGetTextureParameterIuivEXT = NULL; PFNGLGETTEXTUREPARAMETERFVEXTPROC __glewGetTextureParameterfvEXT = NULL; PFNGLGETTEXTUREPARAMETERIVEXTPROC __glewGetTextureParameterivEXT = NULL; PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC __glewGetVertexArrayIntegeri_vEXT = NULL; PFNGLGETVERTEXARRAYINTEGERVEXTPROC __glewGetVertexArrayIntegervEXT = NULL; PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC __glewGetVertexArrayPointeri_vEXT = NULL; PFNGLGETVERTEXARRAYPOINTERVEXTPROC __glewGetVertexArrayPointervEXT = NULL; PFNGLMAPNAMEDBUFFEREXTPROC __glewMapNamedBufferEXT = NULL; PFNGLMAPNAMEDBUFFERRANGEEXTPROC __glewMapNamedBufferRangeEXT = NULL; PFNGLMATRIXFRUSTUMEXTPROC __glewMatrixFrustumEXT = NULL; PFNGLMATRIXLOADIDENTITYEXTPROC __glewMatrixLoadIdentityEXT = NULL; PFNGLMATRIXLOADTRANSPOSEDEXTPROC __glewMatrixLoadTransposedEXT = NULL; PFNGLMATRIXLOADTRANSPOSEFEXTPROC __glewMatrixLoadTransposefEXT = NULL; PFNGLMATRIXLOADDEXTPROC __glewMatrixLoaddEXT = NULL; PFNGLMATRIXLOADFEXTPROC __glewMatrixLoadfEXT = NULL; PFNGLMATRIXMULTTRANSPOSEDEXTPROC __glewMatrixMultTransposedEXT = NULL; PFNGLMATRIXMULTTRANSPOSEFEXTPROC __glewMatrixMultTransposefEXT = NULL; PFNGLMATRIXMULTDEXTPROC __glewMatrixMultdEXT = NULL; PFNGLMATRIXMULTFEXTPROC __glewMatrixMultfEXT = NULL; PFNGLMATRIXORTHOEXTPROC __glewMatrixOrthoEXT = NULL; PFNGLMATRIXPOPEXTPROC __glewMatrixPopEXT = NULL; PFNGLMATRIXPUSHEXTPROC __glewMatrixPushEXT = NULL; PFNGLMATRIXROTATEDEXTPROC __glewMatrixRotatedEXT = NULL; PFNGLMATRIXROTATEFEXTPROC __glewMatrixRotatefEXT = NULL; PFNGLMATRIXSCALEDEXTPROC __glewMatrixScaledEXT = NULL; PFNGLMATRIXSCALEFEXTPROC __glewMatrixScalefEXT = NULL; PFNGLMATRIXTRANSLATEDEXTPROC __glewMatrixTranslatedEXT = NULL; PFNGLMATRIXTRANSLATEFEXTPROC __glewMatrixTranslatefEXT = NULL; PFNGLMULTITEXBUFFEREXTPROC __glewMultiTexBufferEXT = NULL; PFNGLMULTITEXCOORDPOINTEREXTPROC __glewMultiTexCoordPointerEXT = NULL; PFNGLMULTITEXENVFEXTPROC __glewMultiTexEnvfEXT = NULL; PFNGLMULTITEXENVFVEXTPROC __glewMultiTexEnvfvEXT = NULL; PFNGLMULTITEXENVIEXTPROC __glewMultiTexEnviEXT = NULL; PFNGLMULTITEXENVIVEXTPROC __glewMultiTexEnvivEXT = NULL; PFNGLMULTITEXGENDEXTPROC __glewMultiTexGendEXT = NULL; PFNGLMULTITEXGENDVEXTPROC __glewMultiTexGendvEXT = NULL; PFNGLMULTITEXGENFEXTPROC __glewMultiTexGenfEXT = NULL; PFNGLMULTITEXGENFVEXTPROC __glewMultiTexGenfvEXT = NULL; PFNGLMULTITEXGENIEXTPROC __glewMultiTexGeniEXT = NULL; PFNGLMULTITEXGENIVEXTPROC __glewMultiTexGenivEXT = NULL; PFNGLMULTITEXIMAGE1DEXTPROC __glewMultiTexImage1DEXT = NULL; PFNGLMULTITEXIMAGE2DEXTPROC __glewMultiTexImage2DEXT = NULL; PFNGLMULTITEXIMAGE3DEXTPROC __glewMultiTexImage3DEXT = NULL; PFNGLMULTITEXPARAMETERIIVEXTPROC __glewMultiTexParameterIivEXT = NULL; PFNGLMULTITEXPARAMETERIUIVEXTPROC __glewMultiTexParameterIuivEXT = NULL; PFNGLMULTITEXPARAMETERFEXTPROC __glewMultiTexParameterfEXT = NULL; PFNGLMULTITEXPARAMETERFVEXTPROC __glewMultiTexParameterfvEXT = NULL; PFNGLMULTITEXPARAMETERIEXTPROC __glewMultiTexParameteriEXT = NULL; PFNGLMULTITEXPARAMETERIVEXTPROC __glewMultiTexParameterivEXT = NULL; PFNGLMULTITEXRENDERBUFFEREXTPROC __glewMultiTexRenderbufferEXT = NULL; PFNGLMULTITEXSUBIMAGE1DEXTPROC __glewMultiTexSubImage1DEXT = NULL; PFNGLMULTITEXSUBIMAGE2DEXTPROC __glewMultiTexSubImage2DEXT = NULL; PFNGLMULTITEXSUBIMAGE3DEXTPROC __glewMultiTexSubImage3DEXT = NULL; PFNGLNAMEDBUFFERDATAEXTPROC __glewNamedBufferDataEXT = NULL; PFNGLNAMEDBUFFERSUBDATAEXTPROC __glewNamedBufferSubDataEXT = NULL; PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC __glewNamedCopyBufferSubDataEXT = NULL; PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC __glewNamedFramebufferRenderbufferEXT = NULL; PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC __glewNamedFramebufferTexture1DEXT = NULL; PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC __glewNamedFramebufferTexture2DEXT = NULL; PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC __glewNamedFramebufferTexture3DEXT = NULL; PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC __glewNamedFramebufferTextureEXT = NULL; PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC __glewNamedFramebufferTextureFaceEXT = NULL; PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC __glewNamedFramebufferTextureLayerEXT = NULL; PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC __glewNamedProgramLocalParameter4dEXT = NULL; PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC __glewNamedProgramLocalParameter4dvEXT = NULL; PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC __glewNamedProgramLocalParameter4fEXT = NULL; PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC __glewNamedProgramLocalParameter4fvEXT = NULL; PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC __glewNamedProgramLocalParameterI4iEXT = NULL; PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC __glewNamedProgramLocalParameterI4ivEXT = NULL; PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC __glewNamedProgramLocalParameterI4uiEXT = NULL; PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC __glewNamedProgramLocalParameterI4uivEXT = NULL; PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC __glewNamedProgramLocalParameters4fvEXT = NULL; PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC __glewNamedProgramLocalParametersI4ivEXT = NULL; PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC __glewNamedProgramLocalParametersI4uivEXT = NULL; PFNGLNAMEDPROGRAMSTRINGEXTPROC __glewNamedProgramStringEXT = NULL; PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC __glewNamedRenderbufferStorageEXT = NULL; PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC __glewNamedRenderbufferStorageMultisampleCoverageEXT = NULL; PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewNamedRenderbufferStorageMultisampleEXT = NULL; PFNGLPROGRAMUNIFORM1FEXTPROC __glewProgramUniform1fEXT = NULL; PFNGLPROGRAMUNIFORM1FVEXTPROC __glewProgramUniform1fvEXT = NULL; PFNGLPROGRAMUNIFORM1IEXTPROC __glewProgramUniform1iEXT = NULL; PFNGLPROGRAMUNIFORM1IVEXTPROC __glewProgramUniform1ivEXT = NULL; PFNGLPROGRAMUNIFORM1UIEXTPROC __glewProgramUniform1uiEXT = NULL; PFNGLPROGRAMUNIFORM1UIVEXTPROC __glewProgramUniform1uivEXT = NULL; PFNGLPROGRAMUNIFORM2FEXTPROC __glewProgramUniform2fEXT = NULL; PFNGLPROGRAMUNIFORM2FVEXTPROC __glewProgramUniform2fvEXT = NULL; PFNGLPROGRAMUNIFORM2IEXTPROC __glewProgramUniform2iEXT = NULL; PFNGLPROGRAMUNIFORM2IVEXTPROC __glewProgramUniform2ivEXT = NULL; PFNGLPROGRAMUNIFORM2UIEXTPROC __glewProgramUniform2uiEXT = NULL; PFNGLPROGRAMUNIFORM2UIVEXTPROC __glewProgramUniform2uivEXT = NULL; PFNGLPROGRAMUNIFORM3FEXTPROC __glewProgramUniform3fEXT = NULL; PFNGLPROGRAMUNIFORM3FVEXTPROC __glewProgramUniform3fvEXT = NULL; PFNGLPROGRAMUNIFORM3IEXTPROC __glewProgramUniform3iEXT = NULL; PFNGLPROGRAMUNIFORM3IVEXTPROC __glewProgramUniform3ivEXT = NULL; PFNGLPROGRAMUNIFORM3UIEXTPROC __glewProgramUniform3uiEXT = NULL; PFNGLPROGRAMUNIFORM3UIVEXTPROC __glewProgramUniform3uivEXT = NULL; PFNGLPROGRAMUNIFORM4FEXTPROC __glewProgramUniform4fEXT = NULL; PFNGLPROGRAMUNIFORM4FVEXTPROC __glewProgramUniform4fvEXT = NULL; PFNGLPROGRAMUNIFORM4IEXTPROC __glewProgramUniform4iEXT = NULL; PFNGLPROGRAMUNIFORM4IVEXTPROC __glewProgramUniform4ivEXT = NULL; PFNGLPROGRAMUNIFORM4UIEXTPROC __glewProgramUniform4uiEXT = NULL; PFNGLPROGRAMUNIFORM4UIVEXTPROC __glewProgramUniform4uivEXT = NULL; PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC __glewProgramUniformMatrix2fvEXT = NULL; PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC __glewProgramUniformMatrix2x3fvEXT = NULL; PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC __glewProgramUniformMatrix2x4fvEXT = NULL; PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC __glewProgramUniformMatrix3fvEXT = NULL; PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC __glewProgramUniformMatrix3x2fvEXT = NULL; PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC __glewProgramUniformMatrix3x4fvEXT = NULL; PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC __glewProgramUniformMatrix4fvEXT = NULL; PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC __glewProgramUniformMatrix4x2fvEXT = NULL; PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC __glewProgramUniformMatrix4x3fvEXT = NULL; PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC __glewPushClientAttribDefaultEXT = NULL; PFNGLTEXTUREBUFFEREXTPROC __glewTextureBufferEXT = NULL; PFNGLTEXTUREIMAGE1DEXTPROC __glewTextureImage1DEXT = NULL; PFNGLTEXTUREIMAGE2DEXTPROC __glewTextureImage2DEXT = NULL; PFNGLTEXTUREIMAGE3DEXTPROC __glewTextureImage3DEXT = NULL; PFNGLTEXTUREPARAMETERIIVEXTPROC __glewTextureParameterIivEXT = NULL; PFNGLTEXTUREPARAMETERIUIVEXTPROC __glewTextureParameterIuivEXT = NULL; PFNGLTEXTUREPARAMETERFEXTPROC __glewTextureParameterfEXT = NULL; PFNGLTEXTUREPARAMETERFVEXTPROC __glewTextureParameterfvEXT = NULL; PFNGLTEXTUREPARAMETERIEXTPROC __glewTextureParameteriEXT = NULL; PFNGLTEXTUREPARAMETERIVEXTPROC __glewTextureParameterivEXT = NULL; PFNGLTEXTURERENDERBUFFEREXTPROC __glewTextureRenderbufferEXT = NULL; PFNGLTEXTURESUBIMAGE1DEXTPROC __glewTextureSubImage1DEXT = NULL; PFNGLTEXTURESUBIMAGE2DEXTPROC __glewTextureSubImage2DEXT = NULL; PFNGLTEXTURESUBIMAGE3DEXTPROC __glewTextureSubImage3DEXT = NULL; PFNGLUNMAPNAMEDBUFFEREXTPROC __glewUnmapNamedBufferEXT = NULL; PFNGLVERTEXARRAYCOLOROFFSETEXTPROC __glewVertexArrayColorOffsetEXT = NULL; PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC __glewVertexArrayEdgeFlagOffsetEXT = NULL; PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC __glewVertexArrayFogCoordOffsetEXT = NULL; PFNGLVERTEXARRAYINDEXOFFSETEXTPROC __glewVertexArrayIndexOffsetEXT = NULL; PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC __glewVertexArrayMultiTexCoordOffsetEXT = NULL; PFNGLVERTEXARRAYNORMALOFFSETEXTPROC __glewVertexArrayNormalOffsetEXT = NULL; PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC __glewVertexArraySecondaryColorOffsetEXT = NULL; PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC __glewVertexArrayTexCoordOffsetEXT = NULL; PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC __glewVertexArrayVertexAttribDivisorEXT = NULL; PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC __glewVertexArrayVertexAttribIOffsetEXT = NULL; PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC __glewVertexArrayVertexAttribOffsetEXT = NULL; PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC __glewVertexArrayVertexOffsetEXT = NULL; PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT = NULL; PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT = NULL; PFNGLENABLEINDEXEDEXTPROC __glewEnableIndexedEXT = NULL; PFNGLGETBOOLEANINDEXEDVEXTPROC __glewGetBooleanIndexedvEXT = NULL; PFNGLGETINTEGERINDEXEDVEXTPROC __glewGetIntegerIndexedvEXT = NULL; PFNGLISENABLEDINDEXEDEXTPROC __glewIsEnabledIndexedEXT = NULL; PFNGLDRAWARRAYSINSTANCEDEXTPROC __glewDrawArraysInstancedEXT = NULL; PFNGLDRAWELEMENTSINSTANCEDEXTPROC __glewDrawElementsInstancedEXT = NULL; PFNGLDRAWRANGEELEMENTSEXTPROC __glewDrawRangeElementsEXT = NULL; PFNGLFOGCOORDPOINTEREXTPROC __glewFogCoordPointerEXT = NULL; PFNGLFOGCOORDDEXTPROC __glewFogCoorddEXT = NULL; PFNGLFOGCOORDDVEXTPROC __glewFogCoorddvEXT = NULL; PFNGLFOGCOORDFEXTPROC __glewFogCoordfEXT = NULL; PFNGLFOGCOORDFVEXTPROC __glewFogCoordfvEXT = NULL; PFNGLFRAGMENTCOLORMATERIALEXTPROC __glewFragmentColorMaterialEXT = NULL; PFNGLFRAGMENTLIGHTMODELFEXTPROC __glewFragmentLightModelfEXT = NULL; PFNGLFRAGMENTLIGHTMODELFVEXTPROC __glewFragmentLightModelfvEXT = NULL; PFNGLFRAGMENTLIGHTMODELIEXTPROC __glewFragmentLightModeliEXT = NULL; PFNGLFRAGMENTLIGHTMODELIVEXTPROC __glewFragmentLightModelivEXT = NULL; PFNGLFRAGMENTLIGHTFEXTPROC __glewFragmentLightfEXT = NULL; PFNGLFRAGMENTLIGHTFVEXTPROC __glewFragmentLightfvEXT = NULL; PFNGLFRAGMENTLIGHTIEXTPROC __glewFragmentLightiEXT = NULL; PFNGLFRAGMENTLIGHTIVEXTPROC __glewFragmentLightivEXT = NULL; PFNGLFRAGMENTMATERIALFEXTPROC __glewFragmentMaterialfEXT = NULL; PFNGLFRAGMENTMATERIALFVEXTPROC __glewFragmentMaterialfvEXT = NULL; PFNGLFRAGMENTMATERIALIEXTPROC __glewFragmentMaterialiEXT = NULL; PFNGLFRAGMENTMATERIALIVEXTPROC __glewFragmentMaterialivEXT = NULL; PFNGLGETFRAGMENTLIGHTFVEXTPROC __glewGetFragmentLightfvEXT = NULL; PFNGLGETFRAGMENTLIGHTIVEXTPROC __glewGetFragmentLightivEXT = NULL; PFNGLGETFRAGMENTMATERIALFVEXTPROC __glewGetFragmentMaterialfvEXT = NULL; PFNGLGETFRAGMENTMATERIALIVEXTPROC __glewGetFragmentMaterialivEXT = NULL; PFNGLLIGHTENVIEXTPROC __glewLightEnviEXT = NULL; PFNGLBLITFRAMEBUFFEREXTPROC __glewBlitFramebufferEXT = NULL; PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewRenderbufferStorageMultisampleEXT = NULL; PFNGLBINDFRAMEBUFFEREXTPROC __glewBindFramebufferEXT = NULL; PFNGLBINDRENDERBUFFEREXTPROC __glewBindRenderbufferEXT = NULL; PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC __glewCheckFramebufferStatusEXT = NULL; PFNGLDELETEFRAMEBUFFERSEXTPROC __glewDeleteFramebuffersEXT = NULL; PFNGLDELETERENDERBUFFERSEXTPROC __glewDeleteRenderbuffersEXT = NULL; PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC __glewFramebufferRenderbufferEXT = NULL; PFNGLFRAMEBUFFERTEXTURE1DEXTPROC __glewFramebufferTexture1DEXT = NULL; PFNGLFRAMEBUFFERTEXTURE2DEXTPROC __glewFramebufferTexture2DEXT = NULL; PFNGLFRAMEBUFFERTEXTURE3DEXTPROC __glewFramebufferTexture3DEXT = NULL; PFNGLGENFRAMEBUFFERSEXTPROC __glewGenFramebuffersEXT = NULL; PFNGLGENRENDERBUFFERSEXTPROC __glewGenRenderbuffersEXT = NULL; PFNGLGENERATEMIPMAPEXTPROC __glewGenerateMipmapEXT = NULL; PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetFramebufferAttachmentParameterivEXT = NULL; PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC __glewGetRenderbufferParameterivEXT = NULL; PFNGLISFRAMEBUFFEREXTPROC __glewIsFramebufferEXT = NULL; PFNGLISRENDERBUFFEREXTPROC __glewIsRenderbufferEXT = NULL; PFNGLRENDERBUFFERSTORAGEEXTPROC __glewRenderbufferStorageEXT = NULL; PFNGLFRAMEBUFFERTEXTUREEXTPROC __glewFramebufferTextureEXT = NULL; PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC __glewFramebufferTextureFaceEXT = NULL; PFNGLPROGRAMPARAMETERIEXTPROC __glewProgramParameteriEXT = NULL; PFNGLPROGRAMENVPARAMETERS4FVEXTPROC __glewProgramEnvParameters4fvEXT = NULL; PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC __glewProgramLocalParameters4fvEXT = NULL; PFNGLBINDFRAGDATALOCATIONEXTPROC __glewBindFragDataLocationEXT = NULL; PFNGLGETFRAGDATALOCATIONEXTPROC __glewGetFragDataLocationEXT = NULL; PFNGLGETUNIFORMUIVEXTPROC __glewGetUniformuivEXT = NULL; PFNGLGETVERTEXATTRIBIIVEXTPROC __glewGetVertexAttribIivEXT = NULL; PFNGLGETVERTEXATTRIBIUIVEXTPROC __glewGetVertexAttribIuivEXT = NULL; PFNGLUNIFORM1UIEXTPROC __glewUniform1uiEXT = NULL; PFNGLUNIFORM1UIVEXTPROC __glewUniform1uivEXT = NULL; PFNGLUNIFORM2UIEXTPROC __glewUniform2uiEXT = NULL; PFNGLUNIFORM2UIVEXTPROC __glewUniform2uivEXT = NULL; PFNGLUNIFORM3UIEXTPROC __glewUniform3uiEXT = NULL; PFNGLUNIFORM3UIVEXTPROC __glewUniform3uivEXT = NULL; PFNGLUNIFORM4UIEXTPROC __glewUniform4uiEXT = NULL; PFNGLUNIFORM4UIVEXTPROC __glewUniform4uivEXT = NULL; PFNGLVERTEXATTRIBI1IEXTPROC __glewVertexAttribI1iEXT = NULL; PFNGLVERTEXATTRIBI1IVEXTPROC __glewVertexAttribI1ivEXT = NULL; PFNGLVERTEXATTRIBI1UIEXTPROC __glewVertexAttribI1uiEXT = NULL; PFNGLVERTEXATTRIBI1UIVEXTPROC __glewVertexAttribI1uivEXT = NULL; PFNGLVERTEXATTRIBI2IEXTPROC __glewVertexAttribI2iEXT = NULL; PFNGLVERTEXATTRIBI2IVEXTPROC __glewVertexAttribI2ivEXT = NULL; PFNGLVERTEXATTRIBI2UIEXTPROC __glewVertexAttribI2uiEXT = NULL; PFNGLVERTEXATTRIBI2UIVEXTPROC __glewVertexAttribI2uivEXT = NULL; PFNGLVERTEXATTRIBI3IEXTPROC __glewVertexAttribI3iEXT = NULL; PFNGLVERTEXATTRIBI3IVEXTPROC __glewVertexAttribI3ivEXT = NULL; PFNGLVERTEXATTRIBI3UIEXTPROC __glewVertexAttribI3uiEXT = NULL; PFNGLVERTEXATTRIBI3UIVEXTPROC __glewVertexAttribI3uivEXT = NULL; PFNGLVERTEXATTRIBI4BVEXTPROC __glewVertexAttribI4bvEXT = NULL; PFNGLVERTEXATTRIBI4IEXTPROC __glewVertexAttribI4iEXT = NULL; PFNGLVERTEXATTRIBI4IVEXTPROC __glewVertexAttribI4ivEXT = NULL; PFNGLVERTEXATTRIBI4SVEXTPROC __glewVertexAttribI4svEXT = NULL; PFNGLVERTEXATTRIBI4UBVEXTPROC __glewVertexAttribI4ubvEXT = NULL; PFNGLVERTEXATTRIBI4UIEXTPROC __glewVertexAttribI4uiEXT = NULL; PFNGLVERTEXATTRIBI4UIVEXTPROC __glewVertexAttribI4uivEXT = NULL; PFNGLVERTEXATTRIBI4USVEXTPROC __glewVertexAttribI4usvEXT = NULL; PFNGLVERTEXATTRIBIPOINTEREXTPROC __glewVertexAttribIPointerEXT = NULL; PFNGLGETHISTOGRAMEXTPROC __glewGetHistogramEXT = NULL; PFNGLGETHISTOGRAMPARAMETERFVEXTPROC __glewGetHistogramParameterfvEXT = NULL; PFNGLGETHISTOGRAMPARAMETERIVEXTPROC __glewGetHistogramParameterivEXT = NULL; PFNGLGETMINMAXEXTPROC __glewGetMinmaxEXT = NULL; PFNGLGETMINMAXPARAMETERFVEXTPROC __glewGetMinmaxParameterfvEXT = NULL; PFNGLGETMINMAXPARAMETERIVEXTPROC __glewGetMinmaxParameterivEXT = NULL; PFNGLHISTOGRAMEXTPROC __glewHistogramEXT = NULL; PFNGLMINMAXEXTPROC __glewMinmaxEXT = NULL; PFNGLRESETHISTOGRAMEXTPROC __glewResetHistogramEXT = NULL; PFNGLRESETMINMAXEXTPROC __glewResetMinmaxEXT = NULL; PFNGLINDEXFUNCEXTPROC __glewIndexFuncEXT = NULL; PFNGLINDEXMATERIALEXTPROC __glewIndexMaterialEXT = NULL; PFNGLAPPLYTEXTUREEXTPROC __glewApplyTextureEXT = NULL; PFNGLTEXTURELIGHTEXTPROC __glewTextureLightEXT = NULL; PFNGLTEXTUREMATERIALEXTPROC __glewTextureMaterialEXT = NULL; PFNGLMULTIDRAWARRAYSEXTPROC __glewMultiDrawArraysEXT = NULL; PFNGLMULTIDRAWELEMENTSEXTPROC __glewMultiDrawElementsEXT = NULL; PFNGLSAMPLEMASKEXTPROC __glewSampleMaskEXT = NULL; PFNGLSAMPLEPATTERNEXTPROC __glewSamplePatternEXT = NULL; PFNGLCOLORTABLEEXTPROC __glewColorTableEXT = NULL; PFNGLGETCOLORTABLEEXTPROC __glewGetColorTableEXT = NULL; PFNGLGETCOLORTABLEPARAMETERFVEXTPROC __glewGetColorTableParameterfvEXT = NULL; PFNGLGETCOLORTABLEPARAMETERIVEXTPROC __glewGetColorTableParameterivEXT = NULL; PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC __glewGetPixelTransformParameterfvEXT = NULL; PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC __glewGetPixelTransformParameterivEXT = NULL; PFNGLPIXELTRANSFORMPARAMETERFEXTPROC __glewPixelTransformParameterfEXT = NULL; PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC __glewPixelTransformParameterfvEXT = NULL; PFNGLPIXELTRANSFORMPARAMETERIEXTPROC __glewPixelTransformParameteriEXT = NULL; PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC __glewPixelTransformParameterivEXT = NULL; PFNGLPOINTPARAMETERFEXTPROC __glewPointParameterfEXT = NULL; PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT = NULL; PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT = NULL; PFNGLPOLYGONOFFSETCLAMPEXTPROC __glewPolygonOffsetClampEXT = NULL; PFNGLPROVOKINGVERTEXEXTPROC __glewProvokingVertexEXT = NULL; PFNGLCOVERAGEMODULATIONNVPROC __glewCoverageModulationNV = NULL; PFNGLCOVERAGEMODULATIONTABLENVPROC __glewCoverageModulationTableNV = NULL; PFNGLGETCOVERAGEMODULATIONTABLENVPROC __glewGetCoverageModulationTableNV = NULL; PFNGLRASTERSAMPLESEXTPROC __glewRasterSamplesEXT = NULL; PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT = NULL; PFNGLENDSCENEEXTPROC __glewEndSceneEXT = NULL; PFNGLSECONDARYCOLOR3BEXTPROC __glewSecondaryColor3bEXT = NULL; PFNGLSECONDARYCOLOR3BVEXTPROC __glewSecondaryColor3bvEXT = NULL; PFNGLSECONDARYCOLOR3DEXTPROC __glewSecondaryColor3dEXT = NULL; PFNGLSECONDARYCOLOR3DVEXTPROC __glewSecondaryColor3dvEXT = NULL; PFNGLSECONDARYCOLOR3FEXTPROC __glewSecondaryColor3fEXT = NULL; PFNGLSECONDARYCOLOR3FVEXTPROC __glewSecondaryColor3fvEXT = NULL; PFNGLSECONDARYCOLOR3IEXTPROC __glewSecondaryColor3iEXT = NULL; PFNGLSECONDARYCOLOR3IVEXTPROC __glewSecondaryColor3ivEXT = NULL; PFNGLSECONDARYCOLOR3SEXTPROC __glewSecondaryColor3sEXT = NULL; PFNGLSECONDARYCOLOR3SVEXTPROC __glewSecondaryColor3svEXT = NULL; PFNGLSECONDARYCOLOR3UBEXTPROC __glewSecondaryColor3ubEXT = NULL; PFNGLSECONDARYCOLOR3UBVEXTPROC __glewSecondaryColor3ubvEXT = NULL; PFNGLSECONDARYCOLOR3UIEXTPROC __glewSecondaryColor3uiEXT = NULL; PFNGLSECONDARYCOLOR3UIVEXTPROC __glewSecondaryColor3uivEXT = NULL; PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT = NULL; PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT = NULL; PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT = NULL; PFNGLACTIVEPROGRAMEXTPROC __glewActiveProgramEXT = NULL; PFNGLCREATESHADERPROGRAMEXTPROC __glewCreateShaderProgramEXT = NULL; PFNGLUSESHADERPROGRAMEXTPROC __glewUseShaderProgramEXT = NULL; PFNGLBINDIMAGETEXTUREEXTPROC __glewBindImageTextureEXT = NULL; PFNGLMEMORYBARRIEREXTPROC __glewMemoryBarrierEXT = NULL; PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT = NULL; PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT = NULL; PFNGLTEXSUBIMAGE2DEXTPROC __glewTexSubImage2DEXT = NULL; PFNGLTEXSUBIMAGE3DEXTPROC __glewTexSubImage3DEXT = NULL; PFNGLTEXIMAGE3DEXTPROC __glewTexImage3DEXT = NULL; PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC __glewFramebufferTextureLayerEXT = NULL; PFNGLTEXBUFFEREXTPROC __glewTexBufferEXT = NULL; PFNGLCLEARCOLORIIEXTPROC __glewClearColorIiEXT = NULL; PFNGLCLEARCOLORIUIEXTPROC __glewClearColorIuiEXT = NULL; PFNGLGETTEXPARAMETERIIVEXTPROC __glewGetTexParameterIivEXT = NULL; PFNGLGETTEXPARAMETERIUIVEXTPROC __glewGetTexParameterIuivEXT = NULL; PFNGLTEXPARAMETERIIVEXTPROC __glewTexParameterIivEXT = NULL; PFNGLTEXPARAMETERIUIVEXTPROC __glewTexParameterIuivEXT = NULL; PFNGLARETEXTURESRESIDENTEXTPROC __glewAreTexturesResidentEXT = NULL; PFNGLBINDTEXTUREEXTPROC __glewBindTextureEXT = NULL; PFNGLDELETETEXTURESEXTPROC __glewDeleteTexturesEXT = NULL; PFNGLGENTEXTURESEXTPROC __glewGenTexturesEXT = NULL; PFNGLISTEXTUREEXTPROC __glewIsTextureEXT = NULL; PFNGLPRIORITIZETEXTURESEXTPROC __glewPrioritizeTexturesEXT = NULL; PFNGLTEXTURENORMALEXTPROC __glewTextureNormalEXT = NULL; PFNGLGETQUERYOBJECTI64VEXTPROC __glewGetQueryObjecti64vEXT = NULL; PFNGLGETQUERYOBJECTUI64VEXTPROC __glewGetQueryObjectui64vEXT = NULL; PFNGLBEGINTRANSFORMFEEDBACKEXTPROC __glewBeginTransformFeedbackEXT = NULL; PFNGLBINDBUFFERBASEEXTPROC __glewBindBufferBaseEXT = NULL; PFNGLBINDBUFFEROFFSETEXTPROC __glewBindBufferOffsetEXT = NULL; PFNGLBINDBUFFERRANGEEXTPROC __glewBindBufferRangeEXT = NULL; PFNGLENDTRANSFORMFEEDBACKEXTPROC __glewEndTransformFeedbackEXT = NULL; PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC __glewGetTransformFeedbackVaryingEXT = NULL; PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC __glewTransformFeedbackVaryingsEXT = NULL; PFNGLARRAYELEMENTEXTPROC __glewArrayElementEXT = NULL; PFNGLCOLORPOINTEREXTPROC __glewColorPointerEXT = NULL; PFNGLDRAWARRAYSEXTPROC __glewDrawArraysEXT = NULL; PFNGLEDGEFLAGPOINTEREXTPROC __glewEdgeFlagPointerEXT = NULL; PFNGLINDEXPOINTEREXTPROC __glewIndexPointerEXT = NULL; PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT = NULL; PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT = NULL; PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT = NULL; PFNGLGETVERTEXATTRIBLDVEXTPROC __glewGetVertexAttribLdvEXT = NULL; PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC __glewVertexArrayVertexAttribLOffsetEXT = NULL; PFNGLVERTEXATTRIBL1DEXTPROC __glewVertexAttribL1dEXT = NULL; PFNGLVERTEXATTRIBL1DVEXTPROC __glewVertexAttribL1dvEXT = NULL; PFNGLVERTEXATTRIBL2DEXTPROC __glewVertexAttribL2dEXT = NULL; PFNGLVERTEXATTRIBL2DVEXTPROC __glewVertexAttribL2dvEXT = NULL; PFNGLVERTEXATTRIBL3DEXTPROC __glewVertexAttribL3dEXT = NULL; PFNGLVERTEXATTRIBL3DVEXTPROC __glewVertexAttribL3dvEXT = NULL; PFNGLVERTEXATTRIBL4DEXTPROC __glewVertexAttribL4dEXT = NULL; PFNGLVERTEXATTRIBL4DVEXTPROC __glewVertexAttribL4dvEXT = NULL; PFNGLVERTEXATTRIBLPOINTEREXTPROC __glewVertexAttribLPointerEXT = NULL; PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT = NULL; PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT = NULL; PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT = NULL; PFNGLBINDPARAMETEREXTPROC __glewBindParameterEXT = NULL; PFNGLBINDTEXGENPARAMETEREXTPROC __glewBindTexGenParameterEXT = NULL; PFNGLBINDTEXTUREUNITPARAMETEREXTPROC __glewBindTextureUnitParameterEXT = NULL; PFNGLBINDVERTEXSHADEREXTPROC __glewBindVertexShaderEXT = NULL; PFNGLDELETEVERTEXSHADEREXTPROC __glewDeleteVertexShaderEXT = NULL; PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC __glewDisableVariantClientStateEXT = NULL; PFNGLENABLEVARIANTCLIENTSTATEEXTPROC __glewEnableVariantClientStateEXT = NULL; PFNGLENDVERTEXSHADEREXTPROC __glewEndVertexShaderEXT = NULL; PFNGLEXTRACTCOMPONENTEXTPROC __glewExtractComponentEXT = NULL; PFNGLGENSYMBOLSEXTPROC __glewGenSymbolsEXT = NULL; PFNGLGENVERTEXSHADERSEXTPROC __glewGenVertexShadersEXT = NULL; PFNGLGETINVARIANTBOOLEANVEXTPROC __glewGetInvariantBooleanvEXT = NULL; PFNGLGETINVARIANTFLOATVEXTPROC __glewGetInvariantFloatvEXT = NULL; PFNGLGETINVARIANTINTEGERVEXTPROC __glewGetInvariantIntegervEXT = NULL; PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC __glewGetLocalConstantBooleanvEXT = NULL; PFNGLGETLOCALCONSTANTFLOATVEXTPROC __glewGetLocalConstantFloatvEXT = NULL; PFNGLGETLOCALCONSTANTINTEGERVEXTPROC __glewGetLocalConstantIntegervEXT = NULL; PFNGLGETVARIANTBOOLEANVEXTPROC __glewGetVariantBooleanvEXT = NULL; PFNGLGETVARIANTFLOATVEXTPROC __glewGetVariantFloatvEXT = NULL; PFNGLGETVARIANTINTEGERVEXTPROC __glewGetVariantIntegervEXT = NULL; PFNGLGETVARIANTPOINTERVEXTPROC __glewGetVariantPointervEXT = NULL; PFNGLINSERTCOMPONENTEXTPROC __glewInsertComponentEXT = NULL; PFNGLISVARIANTENABLEDEXTPROC __glewIsVariantEnabledEXT = NULL; PFNGLSETINVARIANTEXTPROC __glewSetInvariantEXT = NULL; PFNGLSETLOCALCONSTANTEXTPROC __glewSetLocalConstantEXT = NULL; PFNGLSHADEROP1EXTPROC __glewShaderOp1EXT = NULL; PFNGLSHADEROP2EXTPROC __glewShaderOp2EXT = NULL; PFNGLSHADEROP3EXTPROC __glewShaderOp3EXT = NULL; PFNGLSWIZZLEEXTPROC __glewSwizzleEXT = NULL; PFNGLVARIANTPOINTEREXTPROC __glewVariantPointerEXT = NULL; PFNGLVARIANTBVEXTPROC __glewVariantbvEXT = NULL; PFNGLVARIANTDVEXTPROC __glewVariantdvEXT = NULL; PFNGLVARIANTFVEXTPROC __glewVariantfvEXT = NULL; PFNGLVARIANTIVEXTPROC __glewVariantivEXT = NULL; PFNGLVARIANTSVEXTPROC __glewVariantsvEXT = NULL; PFNGLVARIANTUBVEXTPROC __glewVariantubvEXT = NULL; PFNGLVARIANTUIVEXTPROC __glewVariantuivEXT = NULL; PFNGLVARIANTUSVEXTPROC __glewVariantusvEXT = NULL; PFNGLWRITEMASKEXTPROC __glewWriteMaskEXT = NULL; PFNGLVERTEXWEIGHTPOINTEREXTPROC __glewVertexWeightPointerEXT = NULL; PFNGLVERTEXWEIGHTFEXTPROC __glewVertexWeightfEXT = NULL; PFNGLVERTEXWEIGHTFVEXTPROC __glewVertexWeightfvEXT = NULL; PFNGLIMPORTSYNCEXTPROC __glewImportSyncEXT = NULL; PFNGLFRAMETERMINATORGREMEDYPROC __glewFrameTerminatorGREMEDY = NULL; PFNGLSTRINGMARKERGREMEDYPROC __glewStringMarkerGREMEDY = NULL; PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC __glewGetImageTransformParameterfvHP = NULL; PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC __glewGetImageTransformParameterivHP = NULL; PFNGLIMAGETRANSFORMPARAMETERFHPPROC __glewImageTransformParameterfHP = NULL; PFNGLIMAGETRANSFORMPARAMETERFVHPPROC __glewImageTransformParameterfvHP = NULL; PFNGLIMAGETRANSFORMPARAMETERIHPPROC __glewImageTransformParameteriHP = NULL; PFNGLIMAGETRANSFORMPARAMETERIVHPPROC __glewImageTransformParameterivHP = NULL; PFNGLMULTIMODEDRAWARRAYSIBMPROC __glewMultiModeDrawArraysIBM = NULL; PFNGLMULTIMODEDRAWELEMENTSIBMPROC __glewMultiModeDrawElementsIBM = NULL; PFNGLCOLORPOINTERLISTIBMPROC __glewColorPointerListIBM = NULL; PFNGLEDGEFLAGPOINTERLISTIBMPROC __glewEdgeFlagPointerListIBM = NULL; PFNGLFOGCOORDPOINTERLISTIBMPROC __glewFogCoordPointerListIBM = NULL; PFNGLINDEXPOINTERLISTIBMPROC __glewIndexPointerListIBM = NULL; PFNGLNORMALPOINTERLISTIBMPROC __glewNormalPointerListIBM = NULL; PFNGLSECONDARYCOLORPOINTERLISTIBMPROC __glewSecondaryColorPointerListIBM = NULL; PFNGLTEXCOORDPOINTERLISTIBMPROC __glewTexCoordPointerListIBM = NULL; PFNGLVERTEXPOINTERLISTIBMPROC __glewVertexPointerListIBM = NULL; PFNGLMAPTEXTURE2DINTELPROC __glewMapTexture2DINTEL = NULL; PFNGLSYNCTEXTUREINTELPROC __glewSyncTextureINTEL = NULL; PFNGLUNMAPTEXTURE2DINTELPROC __glewUnmapTexture2DINTEL = NULL; PFNGLCOLORPOINTERVINTELPROC __glewColorPointervINTEL = NULL; PFNGLNORMALPOINTERVINTELPROC __glewNormalPointervINTEL = NULL; PFNGLTEXCOORDPOINTERVINTELPROC __glewTexCoordPointervINTEL = NULL; PFNGLVERTEXPOINTERVINTELPROC __glewVertexPointervINTEL = NULL; PFNGLBEGINPERFQUERYINTELPROC __glewBeginPerfQueryINTEL = NULL; PFNGLCREATEPERFQUERYINTELPROC __glewCreatePerfQueryINTEL = NULL; PFNGLDELETEPERFQUERYINTELPROC __glewDeletePerfQueryINTEL = NULL; PFNGLENDPERFQUERYINTELPROC __glewEndPerfQueryINTEL = NULL; PFNGLGETFIRSTPERFQUERYIDINTELPROC __glewGetFirstPerfQueryIdINTEL = NULL; PFNGLGETNEXTPERFQUERYIDINTELPROC __glewGetNextPerfQueryIdINTEL = NULL; PFNGLGETPERFCOUNTERINFOINTELPROC __glewGetPerfCounterInfoINTEL = NULL; PFNGLGETPERFQUERYDATAINTELPROC __glewGetPerfQueryDataINTEL = NULL; PFNGLGETPERFQUERYIDBYNAMEINTELPROC __glewGetPerfQueryIdByNameINTEL = NULL; PFNGLGETPERFQUERYINFOINTELPROC __glewGetPerfQueryInfoINTEL = NULL; PFNGLTEXSCISSORFUNCINTELPROC __glewTexScissorFuncINTEL = NULL; PFNGLTEXSCISSORINTELPROC __glewTexScissorINTEL = NULL; PFNGLBLENDBARRIERKHRPROC __glewBlendBarrierKHR = NULL; PFNGLDEBUGMESSAGECALLBACKPROC __glewDebugMessageCallback = NULL; PFNGLDEBUGMESSAGECONTROLPROC __glewDebugMessageControl = NULL; PFNGLDEBUGMESSAGEINSERTPROC __glewDebugMessageInsert = NULL; PFNGLGETDEBUGMESSAGELOGPROC __glewGetDebugMessageLog = NULL; PFNGLGETOBJECTLABELPROC __glewGetObjectLabel = NULL; PFNGLGETOBJECTPTRLABELPROC __glewGetObjectPtrLabel = NULL; PFNGLOBJECTLABELPROC __glewObjectLabel = NULL; PFNGLOBJECTPTRLABELPROC __glewObjectPtrLabel = NULL; PFNGLPOPDEBUGGROUPPROC __glewPopDebugGroup = NULL; PFNGLPUSHDEBUGGROUPPROC __glewPushDebugGroup = NULL; PFNGLGETNUNIFORMFVPROC __glewGetnUniformfv = NULL; PFNGLGETNUNIFORMIVPROC __glewGetnUniformiv = NULL; PFNGLGETNUNIFORMUIVPROC __glewGetnUniformuiv = NULL; PFNGLREADNPIXELSPROC __glewReadnPixels = NULL; PFNGLBUFFERREGIONENABLEDPROC __glewBufferRegionEnabled = NULL; PFNGLDELETEBUFFERREGIONPROC __glewDeleteBufferRegion = NULL; PFNGLDRAWBUFFERREGIONPROC __glewDrawBufferRegion = NULL; PFNGLNEWBUFFERREGIONPROC __glewNewBufferRegion = NULL; PFNGLREADBUFFERREGIONPROC __glewReadBufferRegion = NULL; PFNGLRESIZEBUFFERSMESAPROC __glewResizeBuffersMESA = NULL; PFNGLWINDOWPOS2DMESAPROC __glewWindowPos2dMESA = NULL; PFNGLWINDOWPOS2DVMESAPROC __glewWindowPos2dvMESA = NULL; PFNGLWINDOWPOS2FMESAPROC __glewWindowPos2fMESA = NULL; PFNGLWINDOWPOS2FVMESAPROC __glewWindowPos2fvMESA = NULL; PFNGLWINDOWPOS2IMESAPROC __glewWindowPos2iMESA = NULL; PFNGLWINDOWPOS2IVMESAPROC __glewWindowPos2ivMESA = NULL; PFNGLWINDOWPOS2SMESAPROC __glewWindowPos2sMESA = NULL; PFNGLWINDOWPOS2SVMESAPROC __glewWindowPos2svMESA = NULL; PFNGLWINDOWPOS3DMESAPROC __glewWindowPos3dMESA = NULL; PFNGLWINDOWPOS3DVMESAPROC __glewWindowPos3dvMESA = NULL; PFNGLWINDOWPOS3FMESAPROC __glewWindowPos3fMESA = NULL; PFNGLWINDOWPOS3FVMESAPROC __glewWindowPos3fvMESA = NULL; PFNGLWINDOWPOS3IMESAPROC __glewWindowPos3iMESA = NULL; PFNGLWINDOWPOS3IVMESAPROC __glewWindowPos3ivMESA = NULL; PFNGLWINDOWPOS3SMESAPROC __glewWindowPos3sMESA = NULL; PFNGLWINDOWPOS3SVMESAPROC __glewWindowPos3svMESA = NULL; PFNGLWINDOWPOS4DMESAPROC __glewWindowPos4dMESA = NULL; PFNGLWINDOWPOS4DVMESAPROC __glewWindowPos4dvMESA = NULL; PFNGLWINDOWPOS4FMESAPROC __glewWindowPos4fMESA = NULL; PFNGLWINDOWPOS4FVMESAPROC __glewWindowPos4fvMESA = NULL; PFNGLWINDOWPOS4IMESAPROC __glewWindowPos4iMESA = NULL; PFNGLWINDOWPOS4IVMESAPROC __glewWindowPos4ivMESA = NULL; PFNGLWINDOWPOS4SMESAPROC __glewWindowPos4sMESA = NULL; PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA = NULL; PFNGLBEGINCONDITIONALRENDERNVXPROC __glewBeginConditionalRenderNVX = NULL; PFNGLENDCONDITIONALRENDERNVXPROC __glewEndConditionalRenderNVX = NULL; PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC __glewMultiDrawArraysIndirectBindlessNV = NULL; PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC __glewMultiDrawElementsIndirectBindlessNV = NULL; PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC __glewMultiDrawArraysIndirectBindlessCountNV = NULL; PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC __glewMultiDrawElementsIndirectBindlessCountNV = NULL; PFNGLGETIMAGEHANDLENVPROC __glewGetImageHandleNV = NULL; PFNGLGETTEXTUREHANDLENVPROC __glewGetTextureHandleNV = NULL; PFNGLGETTEXTURESAMPLERHANDLENVPROC __glewGetTextureSamplerHandleNV = NULL; PFNGLISIMAGEHANDLERESIDENTNVPROC __glewIsImageHandleResidentNV = NULL; PFNGLISTEXTUREHANDLERESIDENTNVPROC __glewIsTextureHandleResidentNV = NULL; PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC __glewMakeImageHandleNonResidentNV = NULL; PFNGLMAKEIMAGEHANDLERESIDENTNVPROC __glewMakeImageHandleResidentNV = NULL; PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC __glewMakeTextureHandleNonResidentNV = NULL; PFNGLMAKETEXTUREHANDLERESIDENTNVPROC __glewMakeTextureHandleResidentNV = NULL; PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC __glewProgramUniformHandleui64NV = NULL; PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC __glewProgramUniformHandleui64vNV = NULL; PFNGLUNIFORMHANDLEUI64NVPROC __glewUniformHandleui64NV = NULL; PFNGLUNIFORMHANDLEUI64VNVPROC __glewUniformHandleui64vNV = NULL; PFNGLBLENDBARRIERNVPROC __glewBlendBarrierNV = NULL; PFNGLBLENDPARAMETERINVPROC __glewBlendParameteriNV = NULL; PFNGLBEGINCONDITIONALRENDERNVPROC __glewBeginConditionalRenderNV = NULL; PFNGLENDCONDITIONALRENDERNVPROC __glewEndConditionalRenderNV = NULL; PFNGLSUBPIXELPRECISIONBIASNVPROC __glewSubpixelPrecisionBiasNV = NULL; PFNGLCONSERVATIVERASTERPARAMETERFNVPROC __glewConservativeRasterParameterfNV = NULL; PFNGLCOPYIMAGESUBDATANVPROC __glewCopyImageSubDataNV = NULL; PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV = NULL; PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV = NULL; PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV = NULL; PFNGLDRAWTEXTURENVPROC __glewDrawTextureNV = NULL; PFNGLEVALMAPSNVPROC __glewEvalMapsNV = NULL; PFNGLGETMAPATTRIBPARAMETERFVNVPROC __glewGetMapAttribParameterfvNV = NULL; PFNGLGETMAPATTRIBPARAMETERIVNVPROC __glewGetMapAttribParameterivNV = NULL; PFNGLGETMAPCONTROLPOINTSNVPROC __glewGetMapControlPointsNV = NULL; PFNGLGETMAPPARAMETERFVNVPROC __glewGetMapParameterfvNV = NULL; PFNGLGETMAPPARAMETERIVNVPROC __glewGetMapParameterivNV = NULL; PFNGLMAPCONTROLPOINTSNVPROC __glewMapControlPointsNV = NULL; PFNGLMAPPARAMETERFVNVPROC __glewMapParameterfvNV = NULL; PFNGLMAPPARAMETERIVNVPROC __glewMapParameterivNV = NULL; PFNGLGETMULTISAMPLEFVNVPROC __glewGetMultisamplefvNV = NULL; PFNGLSAMPLEMASKINDEXEDNVPROC __glewSampleMaskIndexedNV = NULL; PFNGLTEXRENDERBUFFERNVPROC __glewTexRenderbufferNV = NULL; PFNGLDELETEFENCESNVPROC __glewDeleteFencesNV = NULL; PFNGLFINISHFENCENVPROC __glewFinishFenceNV = NULL; PFNGLGENFENCESNVPROC __glewGenFencesNV = NULL; PFNGLGETFENCEIVNVPROC __glewGetFenceivNV = NULL; PFNGLISFENCENVPROC __glewIsFenceNV = NULL; PFNGLSETFENCENVPROC __glewSetFenceNV = NULL; PFNGLTESTFENCENVPROC __glewTestFenceNV = NULL; PFNGLFRAGMENTCOVERAGECOLORNVPROC __glewFragmentCoverageColorNV = NULL; PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC __glewGetProgramNamedParameterdvNV = NULL; PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC __glewGetProgramNamedParameterfvNV = NULL; PFNGLPROGRAMNAMEDPARAMETER4DNVPROC __glewProgramNamedParameter4dNV = NULL; PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC __glewProgramNamedParameter4dvNV = NULL; PFNGLPROGRAMNAMEDPARAMETER4FNVPROC __glewProgramNamedParameter4fNV = NULL; PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC __glewProgramNamedParameter4fvNV = NULL; PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC __glewRenderbufferStorageMultisampleCoverageNV = NULL; PFNGLPROGRAMVERTEXLIMITNVPROC __glewProgramVertexLimitNV = NULL; PFNGLPROGRAMENVPARAMETERI4INVPROC __glewProgramEnvParameterI4iNV = NULL; PFNGLPROGRAMENVPARAMETERI4IVNVPROC __glewProgramEnvParameterI4ivNV = NULL; PFNGLPROGRAMENVPARAMETERI4UINVPROC __glewProgramEnvParameterI4uiNV = NULL; PFNGLPROGRAMENVPARAMETERI4UIVNVPROC __glewProgramEnvParameterI4uivNV = NULL; PFNGLPROGRAMENVPARAMETERSI4IVNVPROC __glewProgramEnvParametersI4ivNV = NULL; PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC __glewProgramEnvParametersI4uivNV = NULL; PFNGLPROGRAMLOCALPARAMETERI4INVPROC __glewProgramLocalParameterI4iNV = NULL; PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC __glewProgramLocalParameterI4ivNV = NULL; PFNGLPROGRAMLOCALPARAMETERI4UINVPROC __glewProgramLocalParameterI4uiNV = NULL; PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV = NULL; PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV = NULL; PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV = NULL; PFNGLGETUNIFORMI64VNVPROC __glewGetUniformi64vNV = NULL; PFNGLGETUNIFORMUI64VNVPROC __glewGetUniformui64vNV = NULL; PFNGLPROGRAMUNIFORM1I64NVPROC __glewProgramUniform1i64NV = NULL; PFNGLPROGRAMUNIFORM1I64VNVPROC __glewProgramUniform1i64vNV = NULL; PFNGLPROGRAMUNIFORM1UI64NVPROC __glewProgramUniform1ui64NV = NULL; PFNGLPROGRAMUNIFORM1UI64VNVPROC __glewProgramUniform1ui64vNV = NULL; PFNGLPROGRAMUNIFORM2I64NVPROC __glewProgramUniform2i64NV = NULL; PFNGLPROGRAMUNIFORM2I64VNVPROC __glewProgramUniform2i64vNV = NULL; PFNGLPROGRAMUNIFORM2UI64NVPROC __glewProgramUniform2ui64NV = NULL; PFNGLPROGRAMUNIFORM2UI64VNVPROC __glewProgramUniform2ui64vNV = NULL; PFNGLPROGRAMUNIFORM3I64NVPROC __glewProgramUniform3i64NV = NULL; PFNGLPROGRAMUNIFORM3I64VNVPROC __glewProgramUniform3i64vNV = NULL; PFNGLPROGRAMUNIFORM3UI64NVPROC __glewProgramUniform3ui64NV = NULL; PFNGLPROGRAMUNIFORM3UI64VNVPROC __glewProgramUniform3ui64vNV = NULL; PFNGLPROGRAMUNIFORM4I64NVPROC __glewProgramUniform4i64NV = NULL; PFNGLPROGRAMUNIFORM4I64VNVPROC __glewProgramUniform4i64vNV = NULL; PFNGLPROGRAMUNIFORM4UI64NVPROC __glewProgramUniform4ui64NV = NULL; PFNGLPROGRAMUNIFORM4UI64VNVPROC __glewProgramUniform4ui64vNV = NULL; PFNGLUNIFORM1I64NVPROC __glewUniform1i64NV = NULL; PFNGLUNIFORM1I64VNVPROC __glewUniform1i64vNV = NULL; PFNGLUNIFORM1UI64NVPROC __glewUniform1ui64NV = NULL; PFNGLUNIFORM1UI64VNVPROC __glewUniform1ui64vNV = NULL; PFNGLUNIFORM2I64NVPROC __glewUniform2i64NV = NULL; PFNGLUNIFORM2I64VNVPROC __glewUniform2i64vNV = NULL; PFNGLUNIFORM2UI64NVPROC __glewUniform2ui64NV = NULL; PFNGLUNIFORM2UI64VNVPROC __glewUniform2ui64vNV = NULL; PFNGLUNIFORM3I64NVPROC __glewUniform3i64NV = NULL; PFNGLUNIFORM3I64VNVPROC __glewUniform3i64vNV = NULL; PFNGLUNIFORM3UI64NVPROC __glewUniform3ui64NV = NULL; PFNGLUNIFORM3UI64VNVPROC __glewUniform3ui64vNV = NULL; PFNGLUNIFORM4I64NVPROC __glewUniform4i64NV = NULL; PFNGLUNIFORM4I64VNVPROC __glewUniform4i64vNV = NULL; PFNGLUNIFORM4UI64NVPROC __glewUniform4ui64NV = NULL; PFNGLUNIFORM4UI64VNVPROC __glewUniform4ui64vNV = NULL; PFNGLCOLOR3HNVPROC __glewColor3hNV = NULL; PFNGLCOLOR3HVNVPROC __glewColor3hvNV = NULL; PFNGLCOLOR4HNVPROC __glewColor4hNV = NULL; PFNGLCOLOR4HVNVPROC __glewColor4hvNV = NULL; PFNGLFOGCOORDHNVPROC __glewFogCoordhNV = NULL; PFNGLFOGCOORDHVNVPROC __glewFogCoordhvNV = NULL; PFNGLMULTITEXCOORD1HNVPROC __glewMultiTexCoord1hNV = NULL; PFNGLMULTITEXCOORD1HVNVPROC __glewMultiTexCoord1hvNV = NULL; PFNGLMULTITEXCOORD2HNVPROC __glewMultiTexCoord2hNV = NULL; PFNGLMULTITEXCOORD2HVNVPROC __glewMultiTexCoord2hvNV = NULL; PFNGLMULTITEXCOORD3HNVPROC __glewMultiTexCoord3hNV = NULL; PFNGLMULTITEXCOORD3HVNVPROC __glewMultiTexCoord3hvNV = NULL; PFNGLMULTITEXCOORD4HNVPROC __glewMultiTexCoord4hNV = NULL; PFNGLMULTITEXCOORD4HVNVPROC __glewMultiTexCoord4hvNV = NULL; PFNGLNORMAL3HNVPROC __glewNormal3hNV = NULL; PFNGLNORMAL3HVNVPROC __glewNormal3hvNV = NULL; PFNGLSECONDARYCOLOR3HNVPROC __glewSecondaryColor3hNV = NULL; PFNGLSECONDARYCOLOR3HVNVPROC __glewSecondaryColor3hvNV = NULL; PFNGLTEXCOORD1HNVPROC __glewTexCoord1hNV = NULL; PFNGLTEXCOORD1HVNVPROC __glewTexCoord1hvNV = NULL; PFNGLTEXCOORD2HNVPROC __glewTexCoord2hNV = NULL; PFNGLTEXCOORD2HVNVPROC __glewTexCoord2hvNV = NULL; PFNGLTEXCOORD3HNVPROC __glewTexCoord3hNV = NULL; PFNGLTEXCOORD3HVNVPROC __glewTexCoord3hvNV = NULL; PFNGLTEXCOORD4HNVPROC __glewTexCoord4hNV = NULL; PFNGLTEXCOORD4HVNVPROC __glewTexCoord4hvNV = NULL; PFNGLVERTEX2HNVPROC __glewVertex2hNV = NULL; PFNGLVERTEX2HVNVPROC __glewVertex2hvNV = NULL; PFNGLVERTEX3HNVPROC __glewVertex3hNV = NULL; PFNGLVERTEX3HVNVPROC __glewVertex3hvNV = NULL; PFNGLVERTEX4HNVPROC __glewVertex4hNV = NULL; PFNGLVERTEX4HVNVPROC __glewVertex4hvNV = NULL; PFNGLVERTEXATTRIB1HNVPROC __glewVertexAttrib1hNV = NULL; PFNGLVERTEXATTRIB1HVNVPROC __glewVertexAttrib1hvNV = NULL; PFNGLVERTEXATTRIB2HNVPROC __glewVertexAttrib2hNV = NULL; PFNGLVERTEXATTRIB2HVNVPROC __glewVertexAttrib2hvNV = NULL; PFNGLVERTEXATTRIB3HNVPROC __glewVertexAttrib3hNV = NULL; PFNGLVERTEXATTRIB3HVNVPROC __glewVertexAttrib3hvNV = NULL; PFNGLVERTEXATTRIB4HNVPROC __glewVertexAttrib4hNV = NULL; PFNGLVERTEXATTRIB4HVNVPROC __glewVertexAttrib4hvNV = NULL; PFNGLVERTEXATTRIBS1HVNVPROC __glewVertexAttribs1hvNV = NULL; PFNGLVERTEXATTRIBS2HVNVPROC __glewVertexAttribs2hvNV = NULL; PFNGLVERTEXATTRIBS3HVNVPROC __glewVertexAttribs3hvNV = NULL; PFNGLVERTEXATTRIBS4HVNVPROC __glewVertexAttribs4hvNV = NULL; PFNGLVERTEXWEIGHTHNVPROC __glewVertexWeighthNV = NULL; PFNGLVERTEXWEIGHTHVNVPROC __glewVertexWeighthvNV = NULL; PFNGLGETINTERNALFORMATSAMPLEIVNVPROC __glewGetInternalformatSampleivNV = NULL; PFNGLBEGINOCCLUSIONQUERYNVPROC __glewBeginOcclusionQueryNV = NULL; PFNGLDELETEOCCLUSIONQUERIESNVPROC __glewDeleteOcclusionQueriesNV = NULL; PFNGLENDOCCLUSIONQUERYNVPROC __glewEndOcclusionQueryNV = NULL; PFNGLGENOCCLUSIONQUERIESNVPROC __glewGenOcclusionQueriesNV = NULL; PFNGLGETOCCLUSIONQUERYIVNVPROC __glewGetOcclusionQueryivNV = NULL; PFNGLGETOCCLUSIONQUERYUIVNVPROC __glewGetOcclusionQueryuivNV = NULL; PFNGLISOCCLUSIONQUERYNVPROC __glewIsOcclusionQueryNV = NULL; PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC __glewProgramBufferParametersIivNV = NULL; PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC __glewProgramBufferParametersIuivNV = NULL; PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC __glewProgramBufferParametersfvNV = NULL; PFNGLCOPYPATHNVPROC __glewCopyPathNV = NULL; PFNGLCOVERFILLPATHINSTANCEDNVPROC __glewCoverFillPathInstancedNV = NULL; PFNGLCOVERFILLPATHNVPROC __glewCoverFillPathNV = NULL; PFNGLCOVERSTROKEPATHINSTANCEDNVPROC __glewCoverStrokePathInstancedNV = NULL; PFNGLCOVERSTROKEPATHNVPROC __glewCoverStrokePathNV = NULL; PFNGLDELETEPATHSNVPROC __glewDeletePathsNV = NULL; PFNGLGENPATHSNVPROC __glewGenPathsNV = NULL; PFNGLGETPATHCOLORGENFVNVPROC __glewGetPathColorGenfvNV = NULL; PFNGLGETPATHCOLORGENIVNVPROC __glewGetPathColorGenivNV = NULL; PFNGLGETPATHCOMMANDSNVPROC __glewGetPathCommandsNV = NULL; PFNGLGETPATHCOORDSNVPROC __glewGetPathCoordsNV = NULL; PFNGLGETPATHDASHARRAYNVPROC __glewGetPathDashArrayNV = NULL; PFNGLGETPATHLENGTHNVPROC __glewGetPathLengthNV = NULL; PFNGLGETPATHMETRICRANGENVPROC __glewGetPathMetricRangeNV = NULL; PFNGLGETPATHMETRICSNVPROC __glewGetPathMetricsNV = NULL; PFNGLGETPATHPARAMETERFVNVPROC __glewGetPathParameterfvNV = NULL; PFNGLGETPATHPARAMETERIVNVPROC __glewGetPathParameterivNV = NULL; PFNGLGETPATHSPACINGNVPROC __glewGetPathSpacingNV = NULL; PFNGLGETPATHTEXGENFVNVPROC __glewGetPathTexGenfvNV = NULL; PFNGLGETPATHTEXGENIVNVPROC __glewGetPathTexGenivNV = NULL; PFNGLGETPROGRAMRESOURCEFVNVPROC __glewGetProgramResourcefvNV = NULL; PFNGLINTERPOLATEPATHSNVPROC __glewInterpolatePathsNV = NULL; PFNGLISPATHNVPROC __glewIsPathNV = NULL; PFNGLISPOINTINFILLPATHNVPROC __glewIsPointInFillPathNV = NULL; PFNGLISPOINTINSTROKEPATHNVPROC __glewIsPointInStrokePathNV = NULL; PFNGLMATRIXLOAD3X2FNVPROC __glewMatrixLoad3x2fNV = NULL; PFNGLMATRIXLOAD3X3FNVPROC __glewMatrixLoad3x3fNV = NULL; PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC __glewMatrixLoadTranspose3x3fNV = NULL; PFNGLMATRIXMULT3X2FNVPROC __glewMatrixMult3x2fNV = NULL; PFNGLMATRIXMULT3X3FNVPROC __glewMatrixMult3x3fNV = NULL; PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC __glewMatrixMultTranspose3x3fNV = NULL; PFNGLPATHCOLORGENNVPROC __glewPathColorGenNV = NULL; PFNGLPATHCOMMANDSNVPROC __glewPathCommandsNV = NULL; PFNGLPATHCOORDSNVPROC __glewPathCoordsNV = NULL; PFNGLPATHCOVERDEPTHFUNCNVPROC __glewPathCoverDepthFuncNV = NULL; PFNGLPATHDASHARRAYNVPROC __glewPathDashArrayNV = NULL; PFNGLPATHFOGGENNVPROC __glewPathFogGenNV = NULL; PFNGLPATHGLYPHINDEXARRAYNVPROC __glewPathGlyphIndexArrayNV = NULL; PFNGLPATHGLYPHINDEXRANGENVPROC __glewPathGlyphIndexRangeNV = NULL; PFNGLPATHGLYPHRANGENVPROC __glewPathGlyphRangeNV = NULL; PFNGLPATHGLYPHSNVPROC __glewPathGlyphsNV = NULL; PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC __glewPathMemoryGlyphIndexArrayNV = NULL; PFNGLPATHPARAMETERFNVPROC __glewPathParameterfNV = NULL; PFNGLPATHPARAMETERFVNVPROC __glewPathParameterfvNV = NULL; PFNGLPATHPARAMETERINVPROC __glewPathParameteriNV = NULL; PFNGLPATHPARAMETERIVNVPROC __glewPathParameterivNV = NULL; PFNGLPATHSTENCILDEPTHOFFSETNVPROC __glewPathStencilDepthOffsetNV = NULL; PFNGLPATHSTENCILFUNCNVPROC __glewPathStencilFuncNV = NULL; PFNGLPATHSTRINGNVPROC __glewPathStringNV = NULL; PFNGLPATHSUBCOMMANDSNVPROC __glewPathSubCommandsNV = NULL; PFNGLPATHSUBCOORDSNVPROC __glewPathSubCoordsNV = NULL; PFNGLPATHTEXGENNVPROC __glewPathTexGenNV = NULL; PFNGLPOINTALONGPATHNVPROC __glewPointAlongPathNV = NULL; PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC __glewProgramPathFragmentInputGenNV = NULL; PFNGLSTENCILFILLPATHINSTANCEDNVPROC __glewStencilFillPathInstancedNV = NULL; PFNGLSTENCILFILLPATHNVPROC __glewStencilFillPathNV = NULL; PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC __glewStencilStrokePathInstancedNV = NULL; PFNGLSTENCILSTROKEPATHNVPROC __glewStencilStrokePathNV = NULL; PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC __glewStencilThenCoverFillPathInstancedNV = NULL; PFNGLSTENCILTHENCOVERFILLPATHNVPROC __glewStencilThenCoverFillPathNV = NULL; PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC __glewStencilThenCoverStrokePathInstancedNV = NULL; PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC __glewStencilThenCoverStrokePathNV = NULL; PFNGLTRANSFORMPATHNVPROC __glewTransformPathNV = NULL; PFNGLWEIGHTPATHSNVPROC __glewWeightPathsNV = NULL; PFNGLFLUSHPIXELDATARANGENVPROC __glewFlushPixelDataRangeNV = NULL; PFNGLPIXELDATARANGENVPROC __glewPixelDataRangeNV = NULL; PFNGLPOINTPARAMETERINVPROC __glewPointParameteriNV = NULL; PFNGLPOINTPARAMETERIVNVPROC __glewPointParameterivNV = NULL; PFNGLGETVIDEOI64VNVPROC __glewGetVideoi64vNV = NULL; PFNGLGETVIDEOIVNVPROC __glewGetVideoivNV = NULL; PFNGLGETVIDEOUI64VNVPROC __glewGetVideoui64vNV = NULL; PFNGLGETVIDEOUIVNVPROC __glewGetVideouivNV = NULL; PFNGLPRESENTFRAMEDUALFILLNVPROC __glewPresentFrameDualFillNV = NULL; PFNGLPRESENTFRAMEKEYEDNVPROC __glewPresentFrameKeyedNV = NULL; PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV = NULL; PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV = NULL; PFNGLCOMBINERINPUTNVPROC __glewCombinerInputNV = NULL; PFNGLCOMBINEROUTPUTNVPROC __glewCombinerOutputNV = NULL; PFNGLCOMBINERPARAMETERFNVPROC __glewCombinerParameterfNV = NULL; PFNGLCOMBINERPARAMETERFVNVPROC __glewCombinerParameterfvNV = NULL; PFNGLCOMBINERPARAMETERINVPROC __glewCombinerParameteriNV = NULL; PFNGLCOMBINERPARAMETERIVNVPROC __glewCombinerParameterivNV = NULL; PFNGLFINALCOMBINERINPUTNVPROC __glewFinalCombinerInputNV = NULL; PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC __glewGetCombinerInputParameterfvNV = NULL; PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC __glewGetCombinerInputParameterivNV = NULL; PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC __glewGetCombinerOutputParameterfvNV = NULL; PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC __glewGetCombinerOutputParameterivNV = NULL; PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC __glewGetFinalCombinerInputParameterfvNV = NULL; PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameterivNV = NULL; PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV = NULL; PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV = NULL; PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC __glewFramebufferSampleLocationsfvNV = NULL; PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC __glewNamedFramebufferSampleLocationsfvNV = NULL; PFNGLGETBUFFERPARAMETERUI64VNVPROC __glewGetBufferParameterui64vNV = NULL; PFNGLGETINTEGERUI64VNVPROC __glewGetIntegerui64vNV = NULL; PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC __glewGetNamedBufferParameterui64vNV = NULL; PFNGLISBUFFERRESIDENTNVPROC __glewIsBufferResidentNV = NULL; PFNGLISNAMEDBUFFERRESIDENTNVPROC __glewIsNamedBufferResidentNV = NULL; PFNGLMAKEBUFFERNONRESIDENTNVPROC __glewMakeBufferNonResidentNV = NULL; PFNGLMAKEBUFFERRESIDENTNVPROC __glewMakeBufferResidentNV = NULL; PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC __glewMakeNamedBufferNonResidentNV = NULL; PFNGLMAKENAMEDBUFFERRESIDENTNVPROC __glewMakeNamedBufferResidentNV = NULL; PFNGLPROGRAMUNIFORMUI64NVPROC __glewProgramUniformui64NV = NULL; PFNGLPROGRAMUNIFORMUI64VNVPROC __glewProgramUniformui64vNV = NULL; PFNGLUNIFORMUI64NVPROC __glewUniformui64NV = NULL; PFNGLUNIFORMUI64VNVPROC __glewUniformui64vNV = NULL; PFNGLTEXTUREBARRIERNVPROC __glewTextureBarrierNV = NULL; PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC __glewTexImage2DMultisampleCoverageNV = NULL; PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC __glewTexImage3DMultisampleCoverageNV = NULL; PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC __glewTextureImage2DMultisampleCoverageNV = NULL; PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC __glewTextureImage2DMultisampleNV = NULL; PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC __glewTextureImage3DMultisampleCoverageNV = NULL; PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC __glewTextureImage3DMultisampleNV = NULL; PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV = NULL; PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV = NULL; PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV = NULL; PFNGLBINDBUFFEROFFSETNVPROC __glewBindBufferOffsetNV = NULL; PFNGLBINDBUFFERRANGENVPROC __glewBindBufferRangeNV = NULL; PFNGLENDTRANSFORMFEEDBACKNVPROC __glewEndTransformFeedbackNV = NULL; PFNGLGETACTIVEVARYINGNVPROC __glewGetActiveVaryingNV = NULL; PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC __glewGetTransformFeedbackVaryingNV = NULL; PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV = NULL; PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV = NULL; PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV = NULL; PFNGLBINDTRANSFORMFEEDBACKNVPROC __glewBindTransformFeedbackNV = NULL; PFNGLDELETETRANSFORMFEEDBACKSNVPROC __glewDeleteTransformFeedbacksNV = NULL; PFNGLDRAWTRANSFORMFEEDBACKNVPROC __glewDrawTransformFeedbackNV = NULL; PFNGLGENTRANSFORMFEEDBACKSNVPROC __glewGenTransformFeedbacksNV = NULL; PFNGLISTRANSFORMFEEDBACKNVPROC __glewIsTransformFeedbackNV = NULL; PFNGLPAUSETRANSFORMFEEDBACKNVPROC __glewPauseTransformFeedbackNV = NULL; PFNGLRESUMETRANSFORMFEEDBACKNVPROC __glewResumeTransformFeedbackNV = NULL; PFNGLVDPAUFININVPROC __glewVDPAUFiniNV = NULL; PFNGLVDPAUGETSURFACEIVNVPROC __glewVDPAUGetSurfaceivNV = NULL; PFNGLVDPAUINITNVPROC __glewVDPAUInitNV = NULL; PFNGLVDPAUISSURFACENVPROC __glewVDPAUIsSurfaceNV = NULL; PFNGLVDPAUMAPSURFACESNVPROC __glewVDPAUMapSurfacesNV = NULL; PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC __glewVDPAURegisterOutputSurfaceNV = NULL; PFNGLVDPAUREGISTERVIDEOSURFACENVPROC __glewVDPAURegisterVideoSurfaceNV = NULL; PFNGLVDPAUSURFACEACCESSNVPROC __glewVDPAUSurfaceAccessNV = NULL; PFNGLVDPAUUNMAPSURFACESNVPROC __glewVDPAUUnmapSurfacesNV = NULL; PFNGLVDPAUUNREGISTERSURFACENVPROC __glewVDPAUUnregisterSurfaceNV = NULL; PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV = NULL; PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV = NULL; PFNGLGETVERTEXATTRIBLI64VNVPROC __glewGetVertexAttribLi64vNV = NULL; PFNGLGETVERTEXATTRIBLUI64VNVPROC __glewGetVertexAttribLui64vNV = NULL; PFNGLVERTEXATTRIBL1I64NVPROC __glewVertexAttribL1i64NV = NULL; PFNGLVERTEXATTRIBL1I64VNVPROC __glewVertexAttribL1i64vNV = NULL; PFNGLVERTEXATTRIBL1UI64NVPROC __glewVertexAttribL1ui64NV = NULL; PFNGLVERTEXATTRIBL1UI64VNVPROC __glewVertexAttribL1ui64vNV = NULL; PFNGLVERTEXATTRIBL2I64NVPROC __glewVertexAttribL2i64NV = NULL; PFNGLVERTEXATTRIBL2I64VNVPROC __glewVertexAttribL2i64vNV = NULL; PFNGLVERTEXATTRIBL2UI64NVPROC __glewVertexAttribL2ui64NV = NULL; PFNGLVERTEXATTRIBL2UI64VNVPROC __glewVertexAttribL2ui64vNV = NULL; PFNGLVERTEXATTRIBL3I64NVPROC __glewVertexAttribL3i64NV = NULL; PFNGLVERTEXATTRIBL3I64VNVPROC __glewVertexAttribL3i64vNV = NULL; PFNGLVERTEXATTRIBL3UI64NVPROC __glewVertexAttribL3ui64NV = NULL; PFNGLVERTEXATTRIBL3UI64VNVPROC __glewVertexAttribL3ui64vNV = NULL; PFNGLVERTEXATTRIBL4I64NVPROC __glewVertexAttribL4i64NV = NULL; PFNGLVERTEXATTRIBL4I64VNVPROC __glewVertexAttribL4i64vNV = NULL; PFNGLVERTEXATTRIBL4UI64NVPROC __glewVertexAttribL4ui64NV = NULL; PFNGLVERTEXATTRIBL4UI64VNVPROC __glewVertexAttribL4ui64vNV = NULL; PFNGLVERTEXATTRIBLFORMATNVPROC __glewVertexAttribLFormatNV = NULL; PFNGLBUFFERADDRESSRANGENVPROC __glewBufferAddressRangeNV = NULL; PFNGLCOLORFORMATNVPROC __glewColorFormatNV = NULL; PFNGLEDGEFLAGFORMATNVPROC __glewEdgeFlagFormatNV = NULL; PFNGLFOGCOORDFORMATNVPROC __glewFogCoordFormatNV = NULL; PFNGLGETINTEGERUI64I_VNVPROC __glewGetIntegerui64i_vNV = NULL; PFNGLINDEXFORMATNVPROC __glewIndexFormatNV = NULL; PFNGLNORMALFORMATNVPROC __glewNormalFormatNV = NULL; PFNGLSECONDARYCOLORFORMATNVPROC __glewSecondaryColorFormatNV = NULL; PFNGLTEXCOORDFORMATNVPROC __glewTexCoordFormatNV = NULL; PFNGLVERTEXATTRIBFORMATNVPROC __glewVertexAttribFormatNV = NULL; PFNGLVERTEXATTRIBIFORMATNVPROC __glewVertexAttribIFormatNV = NULL; PFNGLVERTEXFORMATNVPROC __glewVertexFormatNV = NULL; PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV = NULL; PFNGLBINDPROGRAMNVPROC __glewBindProgramNV = NULL; PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV = NULL; PFNGLEXECUTEPROGRAMNVPROC __glewExecuteProgramNV = NULL; PFNGLGENPROGRAMSNVPROC __glewGenProgramsNV = NULL; PFNGLGETPROGRAMPARAMETERDVNVPROC __glewGetProgramParameterdvNV = NULL; PFNGLGETPROGRAMPARAMETERFVNVPROC __glewGetProgramParameterfvNV = NULL; PFNGLGETPROGRAMSTRINGNVPROC __glewGetProgramStringNV = NULL; PFNGLGETPROGRAMIVNVPROC __glewGetProgramivNV = NULL; PFNGLGETTRACKMATRIXIVNVPROC __glewGetTrackMatrixivNV = NULL; PFNGLGETVERTEXATTRIBPOINTERVNVPROC __glewGetVertexAttribPointervNV = NULL; PFNGLGETVERTEXATTRIBDVNVPROC __glewGetVertexAttribdvNV = NULL; PFNGLGETVERTEXATTRIBFVNVPROC __glewGetVertexAttribfvNV = NULL; PFNGLGETVERTEXATTRIBIVNVPROC __glewGetVertexAttribivNV = NULL; PFNGLISPROGRAMNVPROC __glewIsProgramNV = NULL; PFNGLLOADPROGRAMNVPROC __glewLoadProgramNV = NULL; PFNGLPROGRAMPARAMETER4DNVPROC __glewProgramParameter4dNV = NULL; PFNGLPROGRAMPARAMETER4DVNVPROC __glewProgramParameter4dvNV = NULL; PFNGLPROGRAMPARAMETER4FNVPROC __glewProgramParameter4fNV = NULL; PFNGLPROGRAMPARAMETER4FVNVPROC __glewProgramParameter4fvNV = NULL; PFNGLPROGRAMPARAMETERS4DVNVPROC __glewProgramParameters4dvNV = NULL; PFNGLPROGRAMPARAMETERS4FVNVPROC __glewProgramParameters4fvNV = NULL; PFNGLREQUESTRESIDENTPROGRAMSNVPROC __glewRequestResidentProgramsNV = NULL; PFNGLTRACKMATRIXNVPROC __glewTrackMatrixNV = NULL; PFNGLVERTEXATTRIB1DNVPROC __glewVertexAttrib1dNV = NULL; PFNGLVERTEXATTRIB1DVNVPROC __glewVertexAttrib1dvNV = NULL; PFNGLVERTEXATTRIB1FNVPROC __glewVertexAttrib1fNV = NULL; PFNGLVERTEXATTRIB1FVNVPROC __glewVertexAttrib1fvNV = NULL; PFNGLVERTEXATTRIB1SNVPROC __glewVertexAttrib1sNV = NULL; PFNGLVERTEXATTRIB1SVNVPROC __glewVertexAttrib1svNV = NULL; PFNGLVERTEXATTRIB2DNVPROC __glewVertexAttrib2dNV = NULL; PFNGLVERTEXATTRIB2DVNVPROC __glewVertexAttrib2dvNV = NULL; PFNGLVERTEXATTRIB2FNVPROC __glewVertexAttrib2fNV = NULL; PFNGLVERTEXATTRIB2FVNVPROC __glewVertexAttrib2fvNV = NULL; PFNGLVERTEXATTRIB2SNVPROC __glewVertexAttrib2sNV = NULL; PFNGLVERTEXATTRIB2SVNVPROC __glewVertexAttrib2svNV = NULL; PFNGLVERTEXATTRIB3DNVPROC __glewVertexAttrib3dNV = NULL; PFNGLVERTEXATTRIB3DVNVPROC __glewVertexAttrib3dvNV = NULL; PFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV = NULL; PFNGLVERTEXATTRIB3FVNVPROC __glewVertexAttrib3fvNV = NULL; PFNGLVERTEXATTRIB3SNVPROC __glewVertexAttrib3sNV = NULL; PFNGLVERTEXATTRIB3SVNVPROC __glewVertexAttrib3svNV = NULL; PFNGLVERTEXATTRIB4DNVPROC __glewVertexAttrib4dNV = NULL; PFNGLVERTEXATTRIB4DVNVPROC __glewVertexAttrib4dvNV = NULL; PFNGLVERTEXATTRIB4FNVPROC __glewVertexAttrib4fNV = NULL; PFNGLVERTEXATTRIB4FVNVPROC __glewVertexAttrib4fvNV = NULL; PFNGLVERTEXATTRIB4SNVPROC __glewVertexAttrib4sNV = NULL; PFNGLVERTEXATTRIB4SVNVPROC __glewVertexAttrib4svNV = NULL; PFNGLVERTEXATTRIB4UBNVPROC __glewVertexAttrib4ubNV = NULL; PFNGLVERTEXATTRIB4UBVNVPROC __glewVertexAttrib4ubvNV = NULL; PFNGLVERTEXATTRIBPOINTERNVPROC __glewVertexAttribPointerNV = NULL; PFNGLVERTEXATTRIBS1DVNVPROC __glewVertexAttribs1dvNV = NULL; PFNGLVERTEXATTRIBS1FVNVPROC __glewVertexAttribs1fvNV = NULL; PFNGLVERTEXATTRIBS1SVNVPROC __glewVertexAttribs1svNV = NULL; PFNGLVERTEXATTRIBS2DVNVPROC __glewVertexAttribs2dvNV = NULL; PFNGLVERTEXATTRIBS2FVNVPROC __glewVertexAttribs2fvNV = NULL; PFNGLVERTEXATTRIBS2SVNVPROC __glewVertexAttribs2svNV = NULL; PFNGLVERTEXATTRIBS3DVNVPROC __glewVertexAttribs3dvNV = NULL; PFNGLVERTEXATTRIBS3FVNVPROC __glewVertexAttribs3fvNV = NULL; PFNGLVERTEXATTRIBS3SVNVPROC __glewVertexAttribs3svNV = NULL; PFNGLVERTEXATTRIBS4DVNVPROC __glewVertexAttribs4dvNV = NULL; PFNGLVERTEXATTRIBS4FVNVPROC __glewVertexAttribs4fvNV = NULL; PFNGLVERTEXATTRIBS4SVNVPROC __glewVertexAttribs4svNV = NULL; PFNGLVERTEXATTRIBS4UBVNVPROC __glewVertexAttribs4ubvNV = NULL; PFNGLBEGINVIDEOCAPTURENVPROC __glewBeginVideoCaptureNV = NULL; PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC __glewBindVideoCaptureStreamBufferNV = NULL; PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC __glewBindVideoCaptureStreamTextureNV = NULL; PFNGLENDVIDEOCAPTURENVPROC __glewEndVideoCaptureNV = NULL; PFNGLGETVIDEOCAPTURESTREAMDVNVPROC __glewGetVideoCaptureStreamdvNV = NULL; PFNGLGETVIDEOCAPTURESTREAMFVNVPROC __glewGetVideoCaptureStreamfvNV = NULL; PFNGLGETVIDEOCAPTURESTREAMIVNVPROC __glewGetVideoCaptureStreamivNV = NULL; PFNGLGETVIDEOCAPTUREIVNVPROC __glewGetVideoCaptureivNV = NULL; PFNGLVIDEOCAPTURENVPROC __glewVideoCaptureNV = NULL; PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC __glewVideoCaptureStreamParameterdvNV = NULL; PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC __glewVideoCaptureStreamParameterfvNV = NULL; PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC __glewVideoCaptureStreamParameterivNV = NULL; PFNGLCLEARDEPTHFOESPROC __glewClearDepthfOES = NULL; PFNGLCLIPPLANEFOESPROC __glewClipPlanefOES = NULL; PFNGLDEPTHRANGEFOESPROC __glewDepthRangefOES = NULL; PFNGLFRUSTUMFOESPROC __glewFrustumfOES = NULL; PFNGLGETCLIPPLANEFOESPROC __glewGetClipPlanefOES = NULL; PFNGLORTHOFOESPROC __glewOrthofOES = NULL; PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC __glewFramebufferTextureMultiviewOVR = NULL; PFNGLALPHAFUNCXPROC __glewAlphaFuncx = NULL; PFNGLCLEARCOLORXPROC __glewClearColorx = NULL; PFNGLCLEARDEPTHXPROC __glewClearDepthx = NULL; PFNGLCOLOR4XPROC __glewColor4x = NULL; PFNGLDEPTHRANGEXPROC __glewDepthRangex = NULL; PFNGLFOGXPROC __glewFogx = NULL; PFNGLFOGXVPROC __glewFogxv = NULL; PFNGLFRUSTUMFPROC __glewFrustumf = NULL; PFNGLFRUSTUMXPROC __glewFrustumx = NULL; PFNGLLIGHTMODELXPROC __glewLightModelx = NULL; PFNGLLIGHTMODELXVPROC __glewLightModelxv = NULL; PFNGLLIGHTXPROC __glewLightx = NULL; PFNGLLIGHTXVPROC __glewLightxv = NULL; PFNGLLINEWIDTHXPROC __glewLineWidthx = NULL; PFNGLLOADMATRIXXPROC __glewLoadMatrixx = NULL; PFNGLMATERIALXPROC __glewMaterialx = NULL; PFNGLMATERIALXVPROC __glewMaterialxv = NULL; PFNGLMULTMATRIXXPROC __glewMultMatrixx = NULL; PFNGLMULTITEXCOORD4XPROC __glewMultiTexCoord4x = NULL; PFNGLNORMAL3XPROC __glewNormal3x = NULL; PFNGLORTHOFPROC __glewOrthof = NULL; PFNGLORTHOXPROC __glewOrthox = NULL; PFNGLPOINTSIZEXPROC __glewPointSizex = NULL; PFNGLPOLYGONOFFSETXPROC __glewPolygonOffsetx = NULL; PFNGLROTATEXPROC __glewRotatex = NULL; PFNGLSAMPLECOVERAGEXPROC __glewSampleCoveragex = NULL; PFNGLSCALEXPROC __glewScalex = NULL; PFNGLTEXENVXPROC __glewTexEnvx = NULL; PFNGLTEXENVXVPROC __glewTexEnvxv = NULL; PFNGLTEXPARAMETERXPROC __glewTexParameterx = NULL; PFNGLTRANSLATEXPROC __glewTranslatex = NULL; PFNGLCLIPPLANEFPROC __glewClipPlanef = NULL; PFNGLCLIPPLANEXPROC __glewClipPlanex = NULL; PFNGLGETCLIPPLANEFPROC __glewGetClipPlanef = NULL; PFNGLGETCLIPPLANEXPROC __glewGetClipPlanex = NULL; PFNGLGETFIXEDVPROC __glewGetFixedv = NULL; PFNGLGETLIGHTXVPROC __glewGetLightxv = NULL; PFNGLGETMATERIALXVPROC __glewGetMaterialxv = NULL; PFNGLGETTEXENVXVPROC __glewGetTexEnvxv = NULL; PFNGLGETTEXPARAMETERXVPROC __glewGetTexParameterxv = NULL; PFNGLPOINTPARAMETERXPROC __glewPointParameterx = NULL; PFNGLPOINTPARAMETERXVPROC __glewPointParameterxv = NULL; PFNGLPOINTSIZEPOINTEROESPROC __glewPointSizePointerOES = NULL; PFNGLTEXPARAMETERXVPROC __glewTexParameterxv = NULL; PFNGLERRORSTRINGREGALPROC __glewErrorStringREGAL = NULL; PFNGLGETEXTENSIONREGALPROC __glewGetExtensionREGAL = NULL; PFNGLISSUPPORTEDREGALPROC __glewIsSupportedREGAL = NULL; PFNGLLOGMESSAGECALLBACKREGALPROC __glewLogMessageCallbackREGAL = NULL; PFNGLGETPROCADDRESSREGALPROC __glewGetProcAddressREGAL = NULL; PFNGLDETAILTEXFUNCSGISPROC __glewDetailTexFuncSGIS = NULL; PFNGLGETDETAILTEXFUNCSGISPROC __glewGetDetailTexFuncSGIS = NULL; PFNGLFOGFUNCSGISPROC __glewFogFuncSGIS = NULL; PFNGLGETFOGFUNCSGISPROC __glewGetFogFuncSGIS = NULL; PFNGLSAMPLEMASKSGISPROC __glewSampleMaskSGIS = NULL; PFNGLSAMPLEPATTERNSGISPROC __glewSamplePatternSGIS = NULL; PFNGLGETSHARPENTEXFUNCSGISPROC __glewGetSharpenTexFuncSGIS = NULL; PFNGLSHARPENTEXFUNCSGISPROC __glewSharpenTexFuncSGIS = NULL; PFNGLTEXIMAGE4DSGISPROC __glewTexImage4DSGIS = NULL; PFNGLTEXSUBIMAGE4DSGISPROC __glewTexSubImage4DSGIS = NULL; PFNGLGETTEXFILTERFUNCSGISPROC __glewGetTexFilterFuncSGIS = NULL; PFNGLTEXFILTERFUNCSGISPROC __glewTexFilterFuncSGIS = NULL; PFNGLASYNCMARKERSGIXPROC __glewAsyncMarkerSGIX = NULL; PFNGLDELETEASYNCMARKERSSGIXPROC __glewDeleteAsyncMarkersSGIX = NULL; PFNGLFINISHASYNCSGIXPROC __glewFinishAsyncSGIX = NULL; PFNGLGENASYNCMARKERSSGIXPROC __glewGenAsyncMarkersSGIX = NULL; PFNGLISASYNCMARKERSGIXPROC __glewIsAsyncMarkerSGIX = NULL; PFNGLPOLLASYNCSGIXPROC __glewPollAsyncSGIX = NULL; PFNGLFLUSHRASTERSGIXPROC __glewFlushRasterSGIX = NULL; PFNGLTEXTUREFOGSGIXPROC __glewTextureFogSGIX = NULL; PFNGLFRAGMENTCOLORMATERIALSGIXPROC __glewFragmentColorMaterialSGIX = NULL; PFNGLFRAGMENTLIGHTMODELFSGIXPROC __glewFragmentLightModelfSGIX = NULL; PFNGLFRAGMENTLIGHTMODELFVSGIXPROC __glewFragmentLightModelfvSGIX = NULL; PFNGLFRAGMENTLIGHTMODELISGIXPROC __glewFragmentLightModeliSGIX = NULL; PFNGLFRAGMENTLIGHTMODELIVSGIXPROC __glewFragmentLightModelivSGIX = NULL; PFNGLFRAGMENTLIGHTFSGIXPROC __glewFragmentLightfSGIX = NULL; PFNGLFRAGMENTLIGHTFVSGIXPROC __glewFragmentLightfvSGIX = NULL; PFNGLFRAGMENTLIGHTISGIXPROC __glewFragmentLightiSGIX = NULL; PFNGLFRAGMENTLIGHTIVSGIXPROC __glewFragmentLightivSGIX = NULL; PFNGLFRAGMENTMATERIALFSGIXPROC __glewFragmentMaterialfSGIX = NULL; PFNGLFRAGMENTMATERIALFVSGIXPROC __glewFragmentMaterialfvSGIX = NULL; PFNGLFRAGMENTMATERIALISGIXPROC __glewFragmentMaterialiSGIX = NULL; PFNGLFRAGMENTMATERIALIVSGIXPROC __glewFragmentMaterialivSGIX = NULL; PFNGLGETFRAGMENTLIGHTFVSGIXPROC __glewGetFragmentLightfvSGIX = NULL; PFNGLGETFRAGMENTLIGHTIVSGIXPROC __glewGetFragmentLightivSGIX = NULL; PFNGLGETFRAGMENTMATERIALFVSGIXPROC __glewGetFragmentMaterialfvSGIX = NULL; PFNGLGETFRAGMENTMATERIALIVSGIXPROC __glewGetFragmentMaterialivSGIX = NULL; PFNGLFRAMEZOOMSGIXPROC __glewFrameZoomSGIX = NULL; PFNGLPIXELTEXGENSGIXPROC __glewPixelTexGenSGIX = NULL; PFNGLREFERENCEPLANESGIXPROC __glewReferencePlaneSGIX = NULL; PFNGLSPRITEPARAMETERFSGIXPROC __glewSpriteParameterfSGIX = NULL; PFNGLSPRITEPARAMETERFVSGIXPROC __glewSpriteParameterfvSGIX = NULL; PFNGLSPRITEPARAMETERISGIXPROC __glewSpriteParameteriSGIX = NULL; PFNGLSPRITEPARAMETERIVSGIXPROC __glewSpriteParameterivSGIX = NULL; PFNGLTAGSAMPLEBUFFERSGIXPROC __glewTagSampleBufferSGIX = NULL; PFNGLCOLORTABLEPARAMETERFVSGIPROC __glewColorTableParameterfvSGI = NULL; PFNGLCOLORTABLEPARAMETERIVSGIPROC __glewColorTableParameterivSGI = NULL; PFNGLCOLORTABLESGIPROC __glewColorTableSGI = NULL; PFNGLCOPYCOLORTABLESGIPROC __glewCopyColorTableSGI = NULL; PFNGLGETCOLORTABLEPARAMETERFVSGIPROC __glewGetColorTableParameterfvSGI = NULL; PFNGLGETCOLORTABLEPARAMETERIVSGIPROC __glewGetColorTableParameterivSGI = NULL; PFNGLGETCOLORTABLESGIPROC __glewGetColorTableSGI = NULL; PFNGLFINISHTEXTURESUNXPROC __glewFinishTextureSUNX = NULL; PFNGLGLOBALALPHAFACTORBSUNPROC __glewGlobalAlphaFactorbSUN = NULL; PFNGLGLOBALALPHAFACTORDSUNPROC __glewGlobalAlphaFactordSUN = NULL; PFNGLGLOBALALPHAFACTORFSUNPROC __glewGlobalAlphaFactorfSUN = NULL; PFNGLGLOBALALPHAFACTORISUNPROC __glewGlobalAlphaFactoriSUN = NULL; PFNGLGLOBALALPHAFACTORSSUNPROC __glewGlobalAlphaFactorsSUN = NULL; PFNGLGLOBALALPHAFACTORUBSUNPROC __glewGlobalAlphaFactorubSUN = NULL; PFNGLGLOBALALPHAFACTORUISUNPROC __glewGlobalAlphaFactoruiSUN = NULL; PFNGLGLOBALALPHAFACTORUSSUNPROC __glewGlobalAlphaFactorusSUN = NULL; PFNGLREADVIDEOPIXELSSUNPROC __glewReadVideoPixelsSUN = NULL; PFNGLREPLACEMENTCODEPOINTERSUNPROC __glewReplacementCodePointerSUN = NULL; PFNGLREPLACEMENTCODEUBSUNPROC __glewReplacementCodeubSUN = NULL; PFNGLREPLACEMENTCODEUBVSUNPROC __glewReplacementCodeubvSUN = NULL; PFNGLREPLACEMENTCODEUISUNPROC __glewReplacementCodeuiSUN = NULL; PFNGLREPLACEMENTCODEUIVSUNPROC __glewReplacementCodeuivSUN = NULL; PFNGLREPLACEMENTCODEUSSUNPROC __glewReplacementCodeusSUN = NULL; PFNGLREPLACEMENTCODEUSVSUNPROC __glewReplacementCodeusvSUN = NULL; PFNGLCOLOR3FVERTEX3FSUNPROC __glewColor3fVertex3fSUN = NULL; PFNGLCOLOR3FVERTEX3FVSUNPROC __glewColor3fVertex3fvSUN = NULL; PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewColor4fNormal3fVertex3fSUN = NULL; PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewColor4fNormal3fVertex3fvSUN = NULL; PFNGLCOLOR4UBVERTEX2FSUNPROC __glewColor4ubVertex2fSUN = NULL; PFNGLCOLOR4UBVERTEX2FVSUNPROC __glewColor4ubVertex2fvSUN = NULL; PFNGLCOLOR4UBVERTEX3FSUNPROC __glewColor4ubVertex3fSUN = NULL; PFNGLCOLOR4UBVERTEX3FVSUNPROC __glewColor4ubVertex3fvSUN = NULL; PFNGLNORMAL3FVERTEX3FSUNPROC __glewNormal3fVertex3fSUN = NULL; PFNGLNORMAL3FVERTEX3FVSUNPROC __glewNormal3fVertex3fvSUN = NULL; PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC __glewReplacementCodeuiColor3fVertex3fSUN = NULL; PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor3fVertex3fvSUN = NULL; PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fSUN = NULL; PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fvSUN = NULL; PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC __glewReplacementCodeuiColor4ubVertex3fSUN = NULL; PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC __glewReplacementCodeuiColor4ubVertex3fvSUN = NULL; PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiNormal3fVertex3fSUN = NULL; PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiNormal3fVertex3fvSUN = NULL; PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN = NULL; PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN = NULL; PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN = NULL; PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN = NULL; PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fSUN = NULL; PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fvSUN = NULL; PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC __glewReplacementCodeuiVertex3fSUN = NULL; PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC __glewReplacementCodeuiVertex3fvSUN = NULL; PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC __glewTexCoord2fColor3fVertex3fSUN = NULL; PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC __glewTexCoord2fColor3fVertex3fvSUN = NULL; PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fSUN = NULL; PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fvSUN = NULL; PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC __glewTexCoord2fColor4ubVertex3fSUN = NULL; PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC __glewTexCoord2fColor4ubVertex3fvSUN = NULL; PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fNormal3fVertex3fSUN = NULL; PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fNormal3fVertex3fvSUN = NULL; PFNGLTEXCOORD2FVERTEX3FSUNPROC __glewTexCoord2fVertex3fSUN = NULL; PFNGLTEXCOORD2FVERTEX3FVSUNPROC __glewTexCoord2fVertex3fvSUN = NULL; PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fSUN = NULL; PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fvSUN = NULL; PFNGLTEXCOORD4FVERTEX4FSUNPROC __glewTexCoord4fVertex4fSUN = NULL; PFNGLTEXCOORD4FVERTEX4FVSUNPROC __glewTexCoord4fVertex4fvSUN = NULL; PFNGLADDSWAPHINTRECTWINPROC __glewAddSwapHintRectWIN = NULL; #endif /* !WIN32 || !GLEW_MX */ #if !defined(GLEW_MX) GLboolean __GLEW_VERSION_1_1 = GL_FALSE; GLboolean __GLEW_VERSION_1_2 = GL_FALSE; GLboolean __GLEW_VERSION_1_2_1 = GL_FALSE; GLboolean __GLEW_VERSION_1_3 = GL_FALSE; GLboolean __GLEW_VERSION_1_4 = GL_FALSE; GLboolean __GLEW_VERSION_1_5 = GL_FALSE; GLboolean __GLEW_VERSION_2_0 = GL_FALSE; GLboolean __GLEW_VERSION_2_1 = GL_FALSE; GLboolean __GLEW_VERSION_3_0 = GL_FALSE; GLboolean __GLEW_VERSION_3_1 = GL_FALSE; GLboolean __GLEW_VERSION_3_2 = GL_FALSE; GLboolean __GLEW_VERSION_3_3 = GL_FALSE; GLboolean __GLEW_VERSION_4_0 = GL_FALSE; GLboolean __GLEW_VERSION_4_1 = GL_FALSE; GLboolean __GLEW_VERSION_4_2 = GL_FALSE; GLboolean __GLEW_VERSION_4_3 = GL_FALSE; GLboolean __GLEW_VERSION_4_4 = GL_FALSE; GLboolean __GLEW_VERSION_4_5 = GL_FALSE; GLboolean __GLEW_3DFX_multisample = GL_FALSE; GLboolean __GLEW_3DFX_tbuffer = GL_FALSE; GLboolean __GLEW_3DFX_texture_compression_FXT1 = GL_FALSE; GLboolean __GLEW_AMD_blend_minmax_factor = GL_FALSE; GLboolean __GLEW_AMD_conservative_depth = GL_FALSE; GLboolean __GLEW_AMD_debug_output = GL_FALSE; GLboolean __GLEW_AMD_depth_clamp_separate = GL_FALSE; GLboolean __GLEW_AMD_draw_buffers_blend = GL_FALSE; GLboolean __GLEW_AMD_gcn_shader = GL_FALSE; GLboolean __GLEW_AMD_gpu_shader_int64 = GL_FALSE; GLboolean __GLEW_AMD_interleaved_elements = GL_FALSE; GLboolean __GLEW_AMD_multi_draw_indirect = GL_FALSE; GLboolean __GLEW_AMD_name_gen_delete = GL_FALSE; GLboolean __GLEW_AMD_occlusion_query_event = GL_FALSE; GLboolean __GLEW_AMD_performance_monitor = GL_FALSE; GLboolean __GLEW_AMD_pinned_memory = GL_FALSE; GLboolean __GLEW_AMD_query_buffer_object = GL_FALSE; GLboolean __GLEW_AMD_sample_positions = GL_FALSE; GLboolean __GLEW_AMD_seamless_cubemap_per_texture = GL_FALSE; GLboolean __GLEW_AMD_shader_atomic_counter_ops = GL_FALSE; GLboolean __GLEW_AMD_shader_stencil_export = GL_FALSE; GLboolean __GLEW_AMD_shader_stencil_value_export = GL_FALSE; GLboolean __GLEW_AMD_shader_trinary_minmax = GL_FALSE; GLboolean __GLEW_AMD_sparse_texture = GL_FALSE; GLboolean __GLEW_AMD_stencil_operation_extended = GL_FALSE; GLboolean __GLEW_AMD_texture_texture4 = GL_FALSE; GLboolean __GLEW_AMD_transform_feedback3_lines_triangles = GL_FALSE; GLboolean __GLEW_AMD_transform_feedback4 = GL_FALSE; GLboolean __GLEW_AMD_vertex_shader_layer = GL_FALSE; GLboolean __GLEW_AMD_vertex_shader_tessellator = GL_FALSE; GLboolean __GLEW_AMD_vertex_shader_viewport_index = GL_FALSE; GLboolean __GLEW_ANGLE_depth_texture = GL_FALSE; GLboolean __GLEW_ANGLE_framebuffer_blit = GL_FALSE; GLboolean __GLEW_ANGLE_framebuffer_multisample = GL_FALSE; GLboolean __GLEW_ANGLE_instanced_arrays = GL_FALSE; GLboolean __GLEW_ANGLE_pack_reverse_row_order = GL_FALSE; GLboolean __GLEW_ANGLE_program_binary = GL_FALSE; GLboolean __GLEW_ANGLE_texture_compression_dxt1 = GL_FALSE; GLboolean __GLEW_ANGLE_texture_compression_dxt3 = GL_FALSE; GLboolean __GLEW_ANGLE_texture_compression_dxt5 = GL_FALSE; GLboolean __GLEW_ANGLE_texture_usage = GL_FALSE; GLboolean __GLEW_ANGLE_timer_query = GL_FALSE; GLboolean __GLEW_ANGLE_translated_shader_source = GL_FALSE; GLboolean __GLEW_APPLE_aux_depth_stencil = GL_FALSE; GLboolean __GLEW_APPLE_client_storage = GL_FALSE; GLboolean __GLEW_APPLE_element_array = GL_FALSE; GLboolean __GLEW_APPLE_fence = GL_FALSE; GLboolean __GLEW_APPLE_float_pixels = GL_FALSE; GLboolean __GLEW_APPLE_flush_buffer_range = GL_FALSE; GLboolean __GLEW_APPLE_object_purgeable = GL_FALSE; GLboolean __GLEW_APPLE_pixel_buffer = GL_FALSE; GLboolean __GLEW_APPLE_rgb_422 = GL_FALSE; GLboolean __GLEW_APPLE_row_bytes = GL_FALSE; GLboolean __GLEW_APPLE_specular_vector = GL_FALSE; GLboolean __GLEW_APPLE_texture_range = GL_FALSE; GLboolean __GLEW_APPLE_transform_hint = GL_FALSE; GLboolean __GLEW_APPLE_vertex_array_object = GL_FALSE; GLboolean __GLEW_APPLE_vertex_array_range = GL_FALSE; GLboolean __GLEW_APPLE_vertex_program_evaluators = GL_FALSE; GLboolean __GLEW_APPLE_ycbcr_422 = GL_FALSE; GLboolean __GLEW_ARB_ES2_compatibility = GL_FALSE; GLboolean __GLEW_ARB_ES3_1_compatibility = GL_FALSE; GLboolean __GLEW_ARB_ES3_2_compatibility = GL_FALSE; GLboolean __GLEW_ARB_ES3_compatibility = GL_FALSE; GLboolean __GLEW_ARB_arrays_of_arrays = GL_FALSE; GLboolean __GLEW_ARB_base_instance = GL_FALSE; GLboolean __GLEW_ARB_bindless_texture = GL_FALSE; GLboolean __GLEW_ARB_blend_func_extended = GL_FALSE; GLboolean __GLEW_ARB_buffer_storage = GL_FALSE; GLboolean __GLEW_ARB_cl_event = GL_FALSE; GLboolean __GLEW_ARB_clear_buffer_object = GL_FALSE; GLboolean __GLEW_ARB_clear_texture = GL_FALSE; GLboolean __GLEW_ARB_clip_control = GL_FALSE; GLboolean __GLEW_ARB_color_buffer_float = GL_FALSE; GLboolean __GLEW_ARB_compatibility = GL_FALSE; GLboolean __GLEW_ARB_compressed_texture_pixel_storage = GL_FALSE; GLboolean __GLEW_ARB_compute_shader = GL_FALSE; GLboolean __GLEW_ARB_compute_variable_group_size = GL_FALSE; GLboolean __GLEW_ARB_conditional_render_inverted = GL_FALSE; GLboolean __GLEW_ARB_conservative_depth = GL_FALSE; GLboolean __GLEW_ARB_copy_buffer = GL_FALSE; GLboolean __GLEW_ARB_copy_image = GL_FALSE; GLboolean __GLEW_ARB_cull_distance = GL_FALSE; GLboolean __GLEW_ARB_debug_output = GL_FALSE; GLboolean __GLEW_ARB_depth_buffer_float = GL_FALSE; GLboolean __GLEW_ARB_depth_clamp = GL_FALSE; GLboolean __GLEW_ARB_depth_texture = GL_FALSE; GLboolean __GLEW_ARB_derivative_control = GL_FALSE; GLboolean __GLEW_ARB_direct_state_access = GL_FALSE; GLboolean __GLEW_ARB_draw_buffers = GL_FALSE; GLboolean __GLEW_ARB_draw_buffers_blend = GL_FALSE; GLboolean __GLEW_ARB_draw_elements_base_vertex = GL_FALSE; GLboolean __GLEW_ARB_draw_indirect = GL_FALSE; GLboolean __GLEW_ARB_draw_instanced = GL_FALSE; GLboolean __GLEW_ARB_enhanced_layouts = GL_FALSE; GLboolean __GLEW_ARB_explicit_attrib_location = GL_FALSE; GLboolean __GLEW_ARB_explicit_uniform_location = GL_FALSE; GLboolean __GLEW_ARB_fragment_coord_conventions = GL_FALSE; GLboolean __GLEW_ARB_fragment_layer_viewport = GL_FALSE; GLboolean __GLEW_ARB_fragment_program = GL_FALSE; GLboolean __GLEW_ARB_fragment_program_shadow = GL_FALSE; GLboolean __GLEW_ARB_fragment_shader = GL_FALSE; GLboolean __GLEW_ARB_fragment_shader_interlock = GL_FALSE; GLboolean __GLEW_ARB_framebuffer_no_attachments = GL_FALSE; GLboolean __GLEW_ARB_framebuffer_object = GL_FALSE; GLboolean __GLEW_ARB_framebuffer_sRGB = GL_FALSE; GLboolean __GLEW_ARB_geometry_shader4 = GL_FALSE; GLboolean __GLEW_ARB_get_program_binary = GL_FALSE; GLboolean __GLEW_ARB_get_texture_sub_image = GL_FALSE; GLboolean __GLEW_ARB_gpu_shader5 = GL_FALSE; GLboolean __GLEW_ARB_gpu_shader_fp64 = GL_FALSE; GLboolean __GLEW_ARB_gpu_shader_int64 = GL_FALSE; GLboolean __GLEW_ARB_half_float_pixel = GL_FALSE; GLboolean __GLEW_ARB_half_float_vertex = GL_FALSE; GLboolean __GLEW_ARB_imaging = GL_FALSE; GLboolean __GLEW_ARB_indirect_parameters = GL_FALSE; GLboolean __GLEW_ARB_instanced_arrays = GL_FALSE; GLboolean __GLEW_ARB_internalformat_query = GL_FALSE; GLboolean __GLEW_ARB_internalformat_query2 = GL_FALSE; GLboolean __GLEW_ARB_invalidate_subdata = GL_FALSE; GLboolean __GLEW_ARB_map_buffer_alignment = GL_FALSE; GLboolean __GLEW_ARB_map_buffer_range = GL_FALSE; GLboolean __GLEW_ARB_matrix_palette = GL_FALSE; GLboolean __GLEW_ARB_multi_bind = GL_FALSE; GLboolean __GLEW_ARB_multi_draw_indirect = GL_FALSE; GLboolean __GLEW_ARB_multisample = GL_FALSE; GLboolean __GLEW_ARB_multitexture = GL_FALSE; GLboolean __GLEW_ARB_occlusion_query = GL_FALSE; GLboolean __GLEW_ARB_occlusion_query2 = GL_FALSE; GLboolean __GLEW_ARB_parallel_shader_compile = GL_FALSE; GLboolean __GLEW_ARB_pipeline_statistics_query = GL_FALSE; GLboolean __GLEW_ARB_pixel_buffer_object = GL_FALSE; GLboolean __GLEW_ARB_point_parameters = GL_FALSE; GLboolean __GLEW_ARB_point_sprite = GL_FALSE; GLboolean __GLEW_ARB_post_depth_coverage = GL_FALSE; GLboolean __GLEW_ARB_program_interface_query = GL_FALSE; GLboolean __GLEW_ARB_provoking_vertex = GL_FALSE; GLboolean __GLEW_ARB_query_buffer_object = GL_FALSE; GLboolean __GLEW_ARB_robust_buffer_access_behavior = GL_FALSE; GLboolean __GLEW_ARB_robustness = GL_FALSE; GLboolean __GLEW_ARB_robustness_application_isolation = GL_FALSE; GLboolean __GLEW_ARB_robustness_share_group_isolation = GL_FALSE; GLboolean __GLEW_ARB_sample_locations = GL_FALSE; GLboolean __GLEW_ARB_sample_shading = GL_FALSE; GLboolean __GLEW_ARB_sampler_objects = GL_FALSE; GLboolean __GLEW_ARB_seamless_cube_map = GL_FALSE; GLboolean __GLEW_ARB_seamless_cubemap_per_texture = GL_FALSE; GLboolean __GLEW_ARB_separate_shader_objects = GL_FALSE; GLboolean __GLEW_ARB_shader_atomic_counter_ops = GL_FALSE; GLboolean __GLEW_ARB_shader_atomic_counters = GL_FALSE; GLboolean __GLEW_ARB_shader_ballot = GL_FALSE; GLboolean __GLEW_ARB_shader_bit_encoding = GL_FALSE; GLboolean __GLEW_ARB_shader_clock = GL_FALSE; GLboolean __GLEW_ARB_shader_draw_parameters = GL_FALSE; GLboolean __GLEW_ARB_shader_group_vote = GL_FALSE; GLboolean __GLEW_ARB_shader_image_load_store = GL_FALSE; GLboolean __GLEW_ARB_shader_image_size = GL_FALSE; GLboolean __GLEW_ARB_shader_objects = GL_FALSE; GLboolean __GLEW_ARB_shader_precision = GL_FALSE; GLboolean __GLEW_ARB_shader_stencil_export = GL_FALSE; GLboolean __GLEW_ARB_shader_storage_buffer_object = GL_FALSE; GLboolean __GLEW_ARB_shader_subroutine = GL_FALSE; GLboolean __GLEW_ARB_shader_texture_image_samples = GL_FALSE; GLboolean __GLEW_ARB_shader_texture_lod = GL_FALSE; GLboolean __GLEW_ARB_shader_viewport_layer_array = GL_FALSE; GLboolean __GLEW_ARB_shading_language_100 = GL_FALSE; GLboolean __GLEW_ARB_shading_language_420pack = GL_FALSE; GLboolean __GLEW_ARB_shading_language_include = GL_FALSE; GLboolean __GLEW_ARB_shading_language_packing = GL_FALSE; GLboolean __GLEW_ARB_shadow = GL_FALSE; GLboolean __GLEW_ARB_shadow_ambient = GL_FALSE; GLboolean __GLEW_ARB_sparse_buffer = GL_FALSE; GLboolean __GLEW_ARB_sparse_texture = GL_FALSE; GLboolean __GLEW_ARB_sparse_texture2 = GL_FALSE; GLboolean __GLEW_ARB_sparse_texture_clamp = GL_FALSE; GLboolean __GLEW_ARB_stencil_texturing = GL_FALSE; GLboolean __GLEW_ARB_sync = GL_FALSE; GLboolean __GLEW_ARB_tessellation_shader = GL_FALSE; GLboolean __GLEW_ARB_texture_barrier = GL_FALSE; GLboolean __GLEW_ARB_texture_border_clamp = GL_FALSE; GLboolean __GLEW_ARB_texture_buffer_object = GL_FALSE; GLboolean __GLEW_ARB_texture_buffer_object_rgb32 = GL_FALSE; GLboolean __GLEW_ARB_texture_buffer_range = GL_FALSE; GLboolean __GLEW_ARB_texture_compression = GL_FALSE; GLboolean __GLEW_ARB_texture_compression_bptc = GL_FALSE; GLboolean __GLEW_ARB_texture_compression_rgtc = GL_FALSE; GLboolean __GLEW_ARB_texture_cube_map = GL_FALSE; GLboolean __GLEW_ARB_texture_cube_map_array = GL_FALSE; GLboolean __GLEW_ARB_texture_env_add = GL_FALSE; GLboolean __GLEW_ARB_texture_env_combine = GL_FALSE; GLboolean __GLEW_ARB_texture_env_crossbar = GL_FALSE; GLboolean __GLEW_ARB_texture_env_dot3 = GL_FALSE; GLboolean __GLEW_ARB_texture_filter_minmax = GL_FALSE; GLboolean __GLEW_ARB_texture_float = GL_FALSE; GLboolean __GLEW_ARB_texture_gather = GL_FALSE; GLboolean __GLEW_ARB_texture_mirror_clamp_to_edge = GL_FALSE; GLboolean __GLEW_ARB_texture_mirrored_repeat = GL_FALSE; GLboolean __GLEW_ARB_texture_multisample = GL_FALSE; GLboolean __GLEW_ARB_texture_non_power_of_two = GL_FALSE; GLboolean __GLEW_ARB_texture_query_levels = GL_FALSE; GLboolean __GLEW_ARB_texture_query_lod = GL_FALSE; GLboolean __GLEW_ARB_texture_rectangle = GL_FALSE; GLboolean __GLEW_ARB_texture_rg = GL_FALSE; GLboolean __GLEW_ARB_texture_rgb10_a2ui = GL_FALSE; GLboolean __GLEW_ARB_texture_stencil8 = GL_FALSE; GLboolean __GLEW_ARB_texture_storage = GL_FALSE; GLboolean __GLEW_ARB_texture_storage_multisample = GL_FALSE; GLboolean __GLEW_ARB_texture_swizzle = GL_FALSE; GLboolean __GLEW_ARB_texture_view = GL_FALSE; GLboolean __GLEW_ARB_timer_query = GL_FALSE; GLboolean __GLEW_ARB_transform_feedback2 = GL_FALSE; GLboolean __GLEW_ARB_transform_feedback3 = GL_FALSE; GLboolean __GLEW_ARB_transform_feedback_instanced = GL_FALSE; GLboolean __GLEW_ARB_transform_feedback_overflow_query = GL_FALSE; GLboolean __GLEW_ARB_transpose_matrix = GL_FALSE; GLboolean __GLEW_ARB_uniform_buffer_object = GL_FALSE; GLboolean __GLEW_ARB_vertex_array_bgra = GL_FALSE; GLboolean __GLEW_ARB_vertex_array_object = GL_FALSE; GLboolean __GLEW_ARB_vertex_attrib_64bit = GL_FALSE; GLboolean __GLEW_ARB_vertex_attrib_binding = GL_FALSE; GLboolean __GLEW_ARB_vertex_blend = GL_FALSE; GLboolean __GLEW_ARB_vertex_buffer_object = GL_FALSE; GLboolean __GLEW_ARB_vertex_program = GL_FALSE; GLboolean __GLEW_ARB_vertex_shader = GL_FALSE; GLboolean __GLEW_ARB_vertex_type_10f_11f_11f_rev = GL_FALSE; GLboolean __GLEW_ARB_vertex_type_2_10_10_10_rev = GL_FALSE; GLboolean __GLEW_ARB_viewport_array = GL_FALSE; GLboolean __GLEW_ARB_window_pos = GL_FALSE; GLboolean __GLEW_ATIX_point_sprites = GL_FALSE; GLboolean __GLEW_ATIX_texture_env_combine3 = GL_FALSE; GLboolean __GLEW_ATIX_texture_env_route = GL_FALSE; GLboolean __GLEW_ATIX_vertex_shader_output_point_size = GL_FALSE; GLboolean __GLEW_ATI_draw_buffers = GL_FALSE; GLboolean __GLEW_ATI_element_array = GL_FALSE; GLboolean __GLEW_ATI_envmap_bumpmap = GL_FALSE; GLboolean __GLEW_ATI_fragment_shader = GL_FALSE; GLboolean __GLEW_ATI_map_object_buffer = GL_FALSE; GLboolean __GLEW_ATI_meminfo = GL_FALSE; GLboolean __GLEW_ATI_pn_triangles = GL_FALSE; GLboolean __GLEW_ATI_separate_stencil = GL_FALSE; GLboolean __GLEW_ATI_shader_texture_lod = GL_FALSE; GLboolean __GLEW_ATI_text_fragment_shader = GL_FALSE; GLboolean __GLEW_ATI_texture_compression_3dc = GL_FALSE; GLboolean __GLEW_ATI_texture_env_combine3 = GL_FALSE; GLboolean __GLEW_ATI_texture_float = GL_FALSE; GLboolean __GLEW_ATI_texture_mirror_once = GL_FALSE; GLboolean __GLEW_ATI_vertex_array_object = GL_FALSE; GLboolean __GLEW_ATI_vertex_attrib_array_object = GL_FALSE; GLboolean __GLEW_ATI_vertex_streams = GL_FALSE; GLboolean __GLEW_EXT_422_pixels = GL_FALSE; GLboolean __GLEW_EXT_Cg_shader = GL_FALSE; GLboolean __GLEW_EXT_abgr = GL_FALSE; GLboolean __GLEW_EXT_bgra = GL_FALSE; GLboolean __GLEW_EXT_bindable_uniform = GL_FALSE; GLboolean __GLEW_EXT_blend_color = GL_FALSE; GLboolean __GLEW_EXT_blend_equation_separate = GL_FALSE; GLboolean __GLEW_EXT_blend_func_separate = GL_FALSE; GLboolean __GLEW_EXT_blend_logic_op = GL_FALSE; GLboolean __GLEW_EXT_blend_minmax = GL_FALSE; GLboolean __GLEW_EXT_blend_subtract = GL_FALSE; GLboolean __GLEW_EXT_clip_volume_hint = GL_FALSE; GLboolean __GLEW_EXT_cmyka = GL_FALSE; GLboolean __GLEW_EXT_color_subtable = GL_FALSE; GLboolean __GLEW_EXT_compiled_vertex_array = GL_FALSE; GLboolean __GLEW_EXT_convolution = GL_FALSE; GLboolean __GLEW_EXT_coordinate_frame = GL_FALSE; GLboolean __GLEW_EXT_copy_texture = GL_FALSE; GLboolean __GLEW_EXT_cull_vertex = GL_FALSE; GLboolean __GLEW_EXT_debug_label = GL_FALSE; GLboolean __GLEW_EXT_debug_marker = GL_FALSE; GLboolean __GLEW_EXT_depth_bounds_test = GL_FALSE; GLboolean __GLEW_EXT_direct_state_access = GL_FALSE; GLboolean __GLEW_EXT_draw_buffers2 = GL_FALSE; GLboolean __GLEW_EXT_draw_instanced = GL_FALSE; GLboolean __GLEW_EXT_draw_range_elements = GL_FALSE; GLboolean __GLEW_EXT_fog_coord = GL_FALSE; GLboolean __GLEW_EXT_fragment_lighting = GL_FALSE; GLboolean __GLEW_EXT_framebuffer_blit = GL_FALSE; GLboolean __GLEW_EXT_framebuffer_multisample = GL_FALSE; GLboolean __GLEW_EXT_framebuffer_multisample_blit_scaled = GL_FALSE; GLboolean __GLEW_EXT_framebuffer_object = GL_FALSE; GLboolean __GLEW_EXT_framebuffer_sRGB = GL_FALSE; GLboolean __GLEW_EXT_geometry_shader4 = GL_FALSE; GLboolean __GLEW_EXT_gpu_program_parameters = GL_FALSE; GLboolean __GLEW_EXT_gpu_shader4 = GL_FALSE; GLboolean __GLEW_EXT_histogram = GL_FALSE; GLboolean __GLEW_EXT_index_array_formats = GL_FALSE; GLboolean __GLEW_EXT_index_func = GL_FALSE; GLboolean __GLEW_EXT_index_material = GL_FALSE; GLboolean __GLEW_EXT_index_texture = GL_FALSE; GLboolean __GLEW_EXT_light_texture = GL_FALSE; GLboolean __GLEW_EXT_misc_attribute = GL_FALSE; GLboolean __GLEW_EXT_multi_draw_arrays = GL_FALSE; GLboolean __GLEW_EXT_multisample = GL_FALSE; GLboolean __GLEW_EXT_packed_depth_stencil = GL_FALSE; GLboolean __GLEW_EXT_packed_float = GL_FALSE; GLboolean __GLEW_EXT_packed_pixels = GL_FALSE; GLboolean __GLEW_EXT_paletted_texture = GL_FALSE; GLboolean __GLEW_EXT_pixel_buffer_object = GL_FALSE; GLboolean __GLEW_EXT_pixel_transform = GL_FALSE; GLboolean __GLEW_EXT_pixel_transform_color_table = GL_FALSE; GLboolean __GLEW_EXT_point_parameters = GL_FALSE; GLboolean __GLEW_EXT_polygon_offset = GL_FALSE; GLboolean __GLEW_EXT_polygon_offset_clamp = GL_FALSE; GLboolean __GLEW_EXT_post_depth_coverage = GL_FALSE; GLboolean __GLEW_EXT_provoking_vertex = GL_FALSE; GLboolean __GLEW_EXT_raster_multisample = GL_FALSE; GLboolean __GLEW_EXT_rescale_normal = GL_FALSE; GLboolean __GLEW_EXT_scene_marker = GL_FALSE; GLboolean __GLEW_EXT_secondary_color = GL_FALSE; GLboolean __GLEW_EXT_separate_shader_objects = GL_FALSE; GLboolean __GLEW_EXT_separate_specular_color = GL_FALSE; GLboolean __GLEW_EXT_shader_image_load_formatted = GL_FALSE; GLboolean __GLEW_EXT_shader_image_load_store = GL_FALSE; GLboolean __GLEW_EXT_shader_integer_mix = GL_FALSE; GLboolean __GLEW_EXT_shadow_funcs = GL_FALSE; GLboolean __GLEW_EXT_shared_texture_palette = GL_FALSE; GLboolean __GLEW_EXT_sparse_texture2 = GL_FALSE; GLboolean __GLEW_EXT_stencil_clear_tag = GL_FALSE; GLboolean __GLEW_EXT_stencil_two_side = GL_FALSE; GLboolean __GLEW_EXT_stencil_wrap = GL_FALSE; GLboolean __GLEW_EXT_subtexture = GL_FALSE; GLboolean __GLEW_EXT_texture = GL_FALSE; GLboolean __GLEW_EXT_texture3D = GL_FALSE; GLboolean __GLEW_EXT_texture_array = GL_FALSE; GLboolean __GLEW_EXT_texture_buffer_object = GL_FALSE; GLboolean __GLEW_EXT_texture_compression_dxt1 = GL_FALSE; GLboolean __GLEW_EXT_texture_compression_latc = GL_FALSE; GLboolean __GLEW_EXT_texture_compression_rgtc = GL_FALSE; GLboolean __GLEW_EXT_texture_compression_s3tc = GL_FALSE; GLboolean __GLEW_EXT_texture_cube_map = GL_FALSE; GLboolean __GLEW_EXT_texture_edge_clamp = GL_FALSE; GLboolean __GLEW_EXT_texture_env = GL_FALSE; GLboolean __GLEW_EXT_texture_env_add = GL_FALSE; GLboolean __GLEW_EXT_texture_env_combine = GL_FALSE; GLboolean __GLEW_EXT_texture_env_dot3 = GL_FALSE; GLboolean __GLEW_EXT_texture_filter_anisotropic = GL_FALSE; GLboolean __GLEW_EXT_texture_filter_minmax = GL_FALSE; GLboolean __GLEW_EXT_texture_integer = GL_FALSE; GLboolean __GLEW_EXT_texture_lod_bias = GL_FALSE; GLboolean __GLEW_EXT_texture_mirror_clamp = GL_FALSE; GLboolean __GLEW_EXT_texture_object = GL_FALSE; GLboolean __GLEW_EXT_texture_perturb_normal = GL_FALSE; GLboolean __GLEW_EXT_texture_rectangle = GL_FALSE; GLboolean __GLEW_EXT_texture_sRGB = GL_FALSE; GLboolean __GLEW_EXT_texture_sRGB_decode = GL_FALSE; GLboolean __GLEW_EXT_texture_shared_exponent = GL_FALSE; GLboolean __GLEW_EXT_texture_snorm = GL_FALSE; GLboolean __GLEW_EXT_texture_swizzle = GL_FALSE; GLboolean __GLEW_EXT_timer_query = GL_FALSE; GLboolean __GLEW_EXT_transform_feedback = GL_FALSE; GLboolean __GLEW_EXT_vertex_array = GL_FALSE; GLboolean __GLEW_EXT_vertex_array_bgra = GL_FALSE; GLboolean __GLEW_EXT_vertex_attrib_64bit = GL_FALSE; GLboolean __GLEW_EXT_vertex_shader = GL_FALSE; GLboolean __GLEW_EXT_vertex_weighting = GL_FALSE; GLboolean __GLEW_EXT_x11_sync_object = GL_FALSE; GLboolean __GLEW_GREMEDY_frame_terminator = GL_FALSE; GLboolean __GLEW_GREMEDY_string_marker = GL_FALSE; GLboolean __GLEW_HP_convolution_border_modes = GL_FALSE; GLboolean __GLEW_HP_image_transform = GL_FALSE; GLboolean __GLEW_HP_occlusion_test = GL_FALSE; GLboolean __GLEW_HP_texture_lighting = GL_FALSE; GLboolean __GLEW_IBM_cull_vertex = GL_FALSE; GLboolean __GLEW_IBM_multimode_draw_arrays = GL_FALSE; GLboolean __GLEW_IBM_rasterpos_clip = GL_FALSE; GLboolean __GLEW_IBM_static_data = GL_FALSE; GLboolean __GLEW_IBM_texture_mirrored_repeat = GL_FALSE; GLboolean __GLEW_IBM_vertex_array_lists = GL_FALSE; GLboolean __GLEW_INGR_color_clamp = GL_FALSE; GLboolean __GLEW_INGR_interlace_read = GL_FALSE; GLboolean __GLEW_INTEL_fragment_shader_ordering = GL_FALSE; GLboolean __GLEW_INTEL_framebuffer_CMAA = GL_FALSE; GLboolean __GLEW_INTEL_map_texture = GL_FALSE; GLboolean __GLEW_INTEL_parallel_arrays = GL_FALSE; GLboolean __GLEW_INTEL_performance_query = GL_FALSE; GLboolean __GLEW_INTEL_texture_scissor = GL_FALSE; GLboolean __GLEW_KHR_blend_equation_advanced = GL_FALSE; GLboolean __GLEW_KHR_blend_equation_advanced_coherent = GL_FALSE; GLboolean __GLEW_KHR_context_flush_control = GL_FALSE; GLboolean __GLEW_KHR_debug = GL_FALSE; GLboolean __GLEW_KHR_no_error = GL_FALSE; GLboolean __GLEW_KHR_robust_buffer_access_behavior = GL_FALSE; GLboolean __GLEW_KHR_robustness = GL_FALSE; GLboolean __GLEW_KHR_texture_compression_astc_hdr = GL_FALSE; GLboolean __GLEW_KHR_texture_compression_astc_ldr = GL_FALSE; GLboolean __GLEW_KTX_buffer_region = GL_FALSE; GLboolean __GLEW_MESAX_texture_stack = GL_FALSE; GLboolean __GLEW_MESA_pack_invert = GL_FALSE; GLboolean __GLEW_MESA_resize_buffers = GL_FALSE; GLboolean __GLEW_MESA_window_pos = GL_FALSE; GLboolean __GLEW_MESA_ycbcr_texture = GL_FALSE; GLboolean __GLEW_NVX_conditional_render = GL_FALSE; GLboolean __GLEW_NVX_gpu_memory_info = GL_FALSE; GLboolean __GLEW_NV_bindless_multi_draw_indirect = GL_FALSE; GLboolean __GLEW_NV_bindless_multi_draw_indirect_count = GL_FALSE; GLboolean __GLEW_NV_bindless_texture = GL_FALSE; GLboolean __GLEW_NV_blend_equation_advanced = GL_FALSE; GLboolean __GLEW_NV_blend_equation_advanced_coherent = GL_FALSE; GLboolean __GLEW_NV_blend_square = GL_FALSE; GLboolean __GLEW_NV_compute_program5 = GL_FALSE; GLboolean __GLEW_NV_conditional_render = GL_FALSE; GLboolean __GLEW_NV_conservative_raster = GL_FALSE; GLboolean __GLEW_NV_conservative_raster_dilate = GL_FALSE; GLboolean __GLEW_NV_copy_depth_to_color = GL_FALSE; GLboolean __GLEW_NV_copy_image = GL_FALSE; GLboolean __GLEW_NV_deep_texture3D = GL_FALSE; GLboolean __GLEW_NV_depth_buffer_float = GL_FALSE; GLboolean __GLEW_NV_depth_clamp = GL_FALSE; GLboolean __GLEW_NV_depth_range_unclamped = GL_FALSE; GLboolean __GLEW_NV_draw_texture = GL_FALSE; GLboolean __GLEW_NV_evaluators = GL_FALSE; GLboolean __GLEW_NV_explicit_multisample = GL_FALSE; GLboolean __GLEW_NV_fence = GL_FALSE; GLboolean __GLEW_NV_fill_rectangle = GL_FALSE; GLboolean __GLEW_NV_float_buffer = GL_FALSE; GLboolean __GLEW_NV_fog_distance = GL_FALSE; GLboolean __GLEW_NV_fragment_coverage_to_color = GL_FALSE; GLboolean __GLEW_NV_fragment_program = GL_FALSE; GLboolean __GLEW_NV_fragment_program2 = GL_FALSE; GLboolean __GLEW_NV_fragment_program4 = GL_FALSE; GLboolean __GLEW_NV_fragment_program_option = GL_FALSE; GLboolean __GLEW_NV_fragment_shader_interlock = GL_FALSE; GLboolean __GLEW_NV_framebuffer_mixed_samples = GL_FALSE; GLboolean __GLEW_NV_framebuffer_multisample_coverage = GL_FALSE; GLboolean __GLEW_NV_geometry_program4 = GL_FALSE; GLboolean __GLEW_NV_geometry_shader4 = GL_FALSE; GLboolean __GLEW_NV_geometry_shader_passthrough = GL_FALSE; GLboolean __GLEW_NV_gpu_program4 = GL_FALSE; GLboolean __GLEW_NV_gpu_program5 = GL_FALSE; GLboolean __GLEW_NV_gpu_program5_mem_extended = GL_FALSE; GLboolean __GLEW_NV_gpu_program_fp64 = GL_FALSE; GLboolean __GLEW_NV_gpu_shader5 = GL_FALSE; GLboolean __GLEW_NV_half_float = GL_FALSE; GLboolean __GLEW_NV_internalformat_sample_query = GL_FALSE; GLboolean __GLEW_NV_light_max_exponent = GL_FALSE; GLboolean __GLEW_NV_multisample_coverage = GL_FALSE; GLboolean __GLEW_NV_multisample_filter_hint = GL_FALSE; GLboolean __GLEW_NV_occlusion_query = GL_FALSE; GLboolean __GLEW_NV_packed_depth_stencil = GL_FALSE; GLboolean __GLEW_NV_parameter_buffer_object = GL_FALSE; GLboolean __GLEW_NV_parameter_buffer_object2 = GL_FALSE; GLboolean __GLEW_NV_path_rendering = GL_FALSE; GLboolean __GLEW_NV_path_rendering_shared_edge = GL_FALSE; GLboolean __GLEW_NV_pixel_data_range = GL_FALSE; GLboolean __GLEW_NV_point_sprite = GL_FALSE; GLboolean __GLEW_NV_present_video = GL_FALSE; GLboolean __GLEW_NV_primitive_restart = GL_FALSE; GLboolean __GLEW_NV_register_combiners = GL_FALSE; GLboolean __GLEW_NV_register_combiners2 = GL_FALSE; GLboolean __GLEW_NV_sample_locations = GL_FALSE; GLboolean __GLEW_NV_sample_mask_override_coverage = GL_FALSE; GLboolean __GLEW_NV_shader_atomic_counters = GL_FALSE; GLboolean __GLEW_NV_shader_atomic_float = GL_FALSE; GLboolean __GLEW_NV_shader_atomic_fp16_vector = GL_FALSE; GLboolean __GLEW_NV_shader_atomic_int64 = GL_FALSE; GLboolean __GLEW_NV_shader_buffer_load = GL_FALSE; GLboolean __GLEW_NV_shader_storage_buffer_object = GL_FALSE; GLboolean __GLEW_NV_shader_thread_group = GL_FALSE; GLboolean __GLEW_NV_shader_thread_shuffle = GL_FALSE; GLboolean __GLEW_NV_tessellation_program5 = GL_FALSE; GLboolean __GLEW_NV_texgen_emboss = GL_FALSE; GLboolean __GLEW_NV_texgen_reflection = GL_FALSE; GLboolean __GLEW_NV_texture_barrier = GL_FALSE; GLboolean __GLEW_NV_texture_compression_vtc = GL_FALSE; GLboolean __GLEW_NV_texture_env_combine4 = GL_FALSE; GLboolean __GLEW_NV_texture_expand_normal = GL_FALSE; GLboolean __GLEW_NV_texture_multisample = GL_FALSE; GLboolean __GLEW_NV_texture_rectangle = GL_FALSE; GLboolean __GLEW_NV_texture_shader = GL_FALSE; GLboolean __GLEW_NV_texture_shader2 = GL_FALSE; GLboolean __GLEW_NV_texture_shader3 = GL_FALSE; GLboolean __GLEW_NV_transform_feedback = GL_FALSE; GLboolean __GLEW_NV_transform_feedback2 = GL_FALSE; GLboolean __GLEW_NV_uniform_buffer_unified_memory = GL_FALSE; GLboolean __GLEW_NV_vdpau_interop = GL_FALSE; GLboolean __GLEW_NV_vertex_array_range = GL_FALSE; GLboolean __GLEW_NV_vertex_array_range2 = GL_FALSE; GLboolean __GLEW_NV_vertex_attrib_integer_64bit = GL_FALSE; GLboolean __GLEW_NV_vertex_buffer_unified_memory = GL_FALSE; GLboolean __GLEW_NV_vertex_program = GL_FALSE; GLboolean __GLEW_NV_vertex_program1_1 = GL_FALSE; GLboolean __GLEW_NV_vertex_program2 = GL_FALSE; GLboolean __GLEW_NV_vertex_program2_option = GL_FALSE; GLboolean __GLEW_NV_vertex_program3 = GL_FALSE; GLboolean __GLEW_NV_vertex_program4 = GL_FALSE; GLboolean __GLEW_NV_video_capture = GL_FALSE; GLboolean __GLEW_NV_viewport_array2 = GL_FALSE; GLboolean __GLEW_OES_byte_coordinates = GL_FALSE; GLboolean __GLEW_OES_compressed_paletted_texture = GL_FALSE; GLboolean __GLEW_OES_read_format = GL_FALSE; GLboolean __GLEW_OES_single_precision = GL_FALSE; GLboolean __GLEW_OML_interlace = GL_FALSE; GLboolean __GLEW_OML_resample = GL_FALSE; GLboolean __GLEW_OML_subsample = GL_FALSE; GLboolean __GLEW_OVR_multiview = GL_FALSE; GLboolean __GLEW_OVR_multiview2 = GL_FALSE; GLboolean __GLEW_PGI_misc_hints = GL_FALSE; GLboolean __GLEW_PGI_vertex_hints = GL_FALSE; GLboolean __GLEW_REGAL_ES1_0_compatibility = GL_FALSE; GLboolean __GLEW_REGAL_ES1_1_compatibility = GL_FALSE; GLboolean __GLEW_REGAL_enable = GL_FALSE; GLboolean __GLEW_REGAL_error_string = GL_FALSE; GLboolean __GLEW_REGAL_extension_query = GL_FALSE; GLboolean __GLEW_REGAL_log = GL_FALSE; GLboolean __GLEW_REGAL_proc_address = GL_FALSE; GLboolean __GLEW_REND_screen_coordinates = GL_FALSE; GLboolean __GLEW_S3_s3tc = GL_FALSE; GLboolean __GLEW_SGIS_color_range = GL_FALSE; GLboolean __GLEW_SGIS_detail_texture = GL_FALSE; GLboolean __GLEW_SGIS_fog_function = GL_FALSE; GLboolean __GLEW_SGIS_generate_mipmap = GL_FALSE; GLboolean __GLEW_SGIS_multisample = GL_FALSE; GLboolean __GLEW_SGIS_pixel_texture = GL_FALSE; GLboolean __GLEW_SGIS_point_line_texgen = GL_FALSE; GLboolean __GLEW_SGIS_sharpen_texture = GL_FALSE; GLboolean __GLEW_SGIS_texture4D = GL_FALSE; GLboolean __GLEW_SGIS_texture_border_clamp = GL_FALSE; GLboolean __GLEW_SGIS_texture_edge_clamp = GL_FALSE; GLboolean __GLEW_SGIS_texture_filter4 = GL_FALSE; GLboolean __GLEW_SGIS_texture_lod = GL_FALSE; GLboolean __GLEW_SGIS_texture_select = GL_FALSE; GLboolean __GLEW_SGIX_async = GL_FALSE; GLboolean __GLEW_SGIX_async_histogram = GL_FALSE; GLboolean __GLEW_SGIX_async_pixel = GL_FALSE; GLboolean __GLEW_SGIX_blend_alpha_minmax = GL_FALSE; GLboolean __GLEW_SGIX_clipmap = GL_FALSE; GLboolean __GLEW_SGIX_convolution_accuracy = GL_FALSE; GLboolean __GLEW_SGIX_depth_texture = GL_FALSE; GLboolean __GLEW_SGIX_flush_raster = GL_FALSE; GLboolean __GLEW_SGIX_fog_offset = GL_FALSE; GLboolean __GLEW_SGIX_fog_texture = GL_FALSE; GLboolean __GLEW_SGIX_fragment_specular_lighting = GL_FALSE; GLboolean __GLEW_SGIX_framezoom = GL_FALSE; GLboolean __GLEW_SGIX_interlace = GL_FALSE; GLboolean __GLEW_SGIX_ir_instrument1 = GL_FALSE; GLboolean __GLEW_SGIX_list_priority = GL_FALSE; GLboolean __GLEW_SGIX_pixel_texture = GL_FALSE; GLboolean __GLEW_SGIX_pixel_texture_bits = GL_FALSE; GLboolean __GLEW_SGIX_reference_plane = GL_FALSE; GLboolean __GLEW_SGIX_resample = GL_FALSE; GLboolean __GLEW_SGIX_shadow = GL_FALSE; GLboolean __GLEW_SGIX_shadow_ambient = GL_FALSE; GLboolean __GLEW_SGIX_sprite = GL_FALSE; GLboolean __GLEW_SGIX_tag_sample_buffer = GL_FALSE; GLboolean __GLEW_SGIX_texture_add_env = GL_FALSE; GLboolean __GLEW_SGIX_texture_coordinate_clamp = GL_FALSE; GLboolean __GLEW_SGIX_texture_lod_bias = GL_FALSE; GLboolean __GLEW_SGIX_texture_multi_buffer = GL_FALSE; GLboolean __GLEW_SGIX_texture_range = GL_FALSE; GLboolean __GLEW_SGIX_texture_scale_bias = GL_FALSE; GLboolean __GLEW_SGIX_vertex_preclip = GL_FALSE; GLboolean __GLEW_SGIX_vertex_preclip_hint = GL_FALSE; GLboolean __GLEW_SGIX_ycrcb = GL_FALSE; GLboolean __GLEW_SGI_color_matrix = GL_FALSE; GLboolean __GLEW_SGI_color_table = GL_FALSE; GLboolean __GLEW_SGI_texture_color_table = GL_FALSE; GLboolean __GLEW_SUNX_constant_data = GL_FALSE; GLboolean __GLEW_SUN_convolution_border_modes = GL_FALSE; GLboolean __GLEW_SUN_global_alpha = GL_FALSE; GLboolean __GLEW_SUN_mesh_array = GL_FALSE; GLboolean __GLEW_SUN_read_video_pixels = GL_FALSE; GLboolean __GLEW_SUN_slice_accum = GL_FALSE; GLboolean __GLEW_SUN_triangle_list = GL_FALSE; GLboolean __GLEW_SUN_vertex = GL_FALSE; GLboolean __GLEW_WIN_phong_shading = GL_FALSE; GLboolean __GLEW_WIN_specular_fog = GL_FALSE; GLboolean __GLEW_WIN_swap_hint = GL_FALSE; #endif /* !GLEW_MX */ #ifdef GL_VERSION_1_2 static GLboolean _glewInit_GL_VERSION_1_2 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glCopyTexSubImage3D")) == NULL) || r; r = ((glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)glewGetProcAddress((const GLubyte*)"glDrawRangeElements")) == NULL) || r; r = ((glTexImage3D = (PFNGLTEXIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glTexImage3D")) == NULL) || r; r = ((glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage3D")) == NULL) || r; return r; } #endif /* GL_VERSION_1_2 */ #ifdef GL_VERSION_1_3 static GLboolean _glewInit_GL_VERSION_1_3 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glActiveTexture = (PFNGLACTIVETEXTUREPROC)glewGetProcAddress((const GLubyte*)"glActiveTexture")) == NULL) || r; r = ((glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC)glewGetProcAddress((const GLubyte*)"glClientActiveTexture")) == NULL) || r; r = ((glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage1D")) == NULL) || r; r = ((glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage2D")) == NULL) || r; r = ((glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage3D")) == NULL) || r; r = ((glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage1D")) == NULL) || r; r = ((glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage2D")) == NULL) || r; r = ((glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage3D")) == NULL) || r; r = ((glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedTexImage")) == NULL) || r; r = ((glLoadTransposeMatrixd = (PFNGLLOADTRANSPOSEMATRIXDPROC)glewGetProcAddress((const GLubyte*)"glLoadTransposeMatrixd")) == NULL) || r; r = ((glLoadTransposeMatrixf = (PFNGLLOADTRANSPOSEMATRIXFPROC)glewGetProcAddress((const GLubyte*)"glLoadTransposeMatrixf")) == NULL) || r; r = ((glMultTransposeMatrixd = (PFNGLMULTTRANSPOSEMATRIXDPROC)glewGetProcAddress((const GLubyte*)"glMultTransposeMatrixd")) == NULL) || r; r = ((glMultTransposeMatrixf = (PFNGLMULTTRANSPOSEMATRIXFPROC)glewGetProcAddress((const GLubyte*)"glMultTransposeMatrixf")) == NULL) || r; r = ((glMultiTexCoord1d = (PFNGLMULTITEXCOORD1DPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1d")) == NULL) || r; r = ((glMultiTexCoord1dv = (PFNGLMULTITEXCOORD1DVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1dv")) == NULL) || r; r = ((glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1f")) == NULL) || r; r = ((glMultiTexCoord1fv = (PFNGLMULTITEXCOORD1FVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1fv")) == NULL) || r; r = ((glMultiTexCoord1i = (PFNGLMULTITEXCOORD1IPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1i")) == NULL) || r; r = ((glMultiTexCoord1iv = (PFNGLMULTITEXCOORD1IVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1iv")) == NULL) || r; r = ((glMultiTexCoord1s = (PFNGLMULTITEXCOORD1SPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1s")) == NULL) || r; r = ((glMultiTexCoord1sv = (PFNGLMULTITEXCOORD1SVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1sv")) == NULL) || r; r = ((glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2d")) == NULL) || r; r = ((glMultiTexCoord2dv = (PFNGLMULTITEXCOORD2DVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2dv")) == NULL) || r; r = ((glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2f")) == NULL) || r; r = ((glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2fv")) == NULL) || r; r = ((glMultiTexCoord2i = (PFNGLMULTITEXCOORD2IPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2i")) == NULL) || r; r = ((glMultiTexCoord2iv = (PFNGLMULTITEXCOORD2IVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2iv")) == NULL) || r; r = ((glMultiTexCoord2s = (PFNGLMULTITEXCOORD2SPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2s")) == NULL) || r; r = ((glMultiTexCoord2sv = (PFNGLMULTITEXCOORD2SVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2sv")) == NULL) || r; r = ((glMultiTexCoord3d = (PFNGLMULTITEXCOORD3DPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3d")) == NULL) || r; r = ((glMultiTexCoord3dv = (PFNGLMULTITEXCOORD3DVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3dv")) == NULL) || r; r = ((glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3f")) == NULL) || r; r = ((glMultiTexCoord3fv = (PFNGLMULTITEXCOORD3FVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3fv")) == NULL) || r; r = ((glMultiTexCoord3i = (PFNGLMULTITEXCOORD3IPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3i")) == NULL) || r; r = ((glMultiTexCoord3iv = (PFNGLMULTITEXCOORD3IVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3iv")) == NULL) || r; r = ((glMultiTexCoord3s = (PFNGLMULTITEXCOORD3SPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3s")) == NULL) || r; r = ((glMultiTexCoord3sv = (PFNGLMULTITEXCOORD3SVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3sv")) == NULL) || r; r = ((glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4d")) == NULL) || r; r = ((glMultiTexCoord4dv = (PFNGLMULTITEXCOORD4DVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4dv")) == NULL) || r; r = ((glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4f")) == NULL) || r; r = ((glMultiTexCoord4fv = (PFNGLMULTITEXCOORD4FVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4fv")) == NULL) || r; r = ((glMultiTexCoord4i = (PFNGLMULTITEXCOORD4IPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4i")) == NULL) || r; r = ((glMultiTexCoord4iv = (PFNGLMULTITEXCOORD4IVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4iv")) == NULL) || r; r = ((glMultiTexCoord4s = (PFNGLMULTITEXCOORD4SPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4s")) == NULL) || r; r = ((glMultiTexCoord4sv = (PFNGLMULTITEXCOORD4SVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4sv")) == NULL) || r; r = ((glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)glewGetProcAddress((const GLubyte*)"glSampleCoverage")) == NULL) || r; return r; } #endif /* GL_VERSION_1_3 */ #ifdef GL_VERSION_1_4 static GLboolean _glewInit_GL_VERSION_1_4 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBlendColor = (PFNGLBLENDCOLORPROC)glewGetProcAddress((const GLubyte*)"glBlendColor")) == NULL) || r; r = ((glBlendEquation = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)"glBlendEquation")) == NULL) || r; r = ((glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glBlendFuncSeparate")) == NULL) || r; r = ((glFogCoordPointer = (PFNGLFOGCOORDPOINTERPROC)glewGetProcAddress((const GLubyte*)"glFogCoordPointer")) == NULL) || r; r = ((glFogCoordd = (PFNGLFOGCOORDDPROC)glewGetProcAddress((const GLubyte*)"glFogCoordd")) == NULL) || r; r = ((glFogCoorddv = (PFNGLFOGCOORDDVPROC)glewGetProcAddress((const GLubyte*)"glFogCoorddv")) == NULL) || r; r = ((glFogCoordf = (PFNGLFOGCOORDFPROC)glewGetProcAddress((const GLubyte*)"glFogCoordf")) == NULL) || r; r = ((glFogCoordfv = (PFNGLFOGCOORDFVPROC)glewGetProcAddress((const GLubyte*)"glFogCoordfv")) == NULL) || r; r = ((glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawArrays")) == NULL) || r; r = ((glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElements")) == NULL) || r; r = ((glPointParameterf = (PFNGLPOINTPARAMETERFPROC)glewGetProcAddress((const GLubyte*)"glPointParameterf")) == NULL) || r; r = ((glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfv")) == NULL) || r; r = ((glPointParameteri = (PFNGLPOINTPARAMETERIPROC)glewGetProcAddress((const GLubyte*)"glPointParameteri")) == NULL) || r; r = ((glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glPointParameteriv")) == NULL) || r; r = ((glSecondaryColor3b = (PFNGLSECONDARYCOLOR3BPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3b")) == NULL) || r; r = ((glSecondaryColor3bv = (PFNGLSECONDARYCOLOR3BVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3bv")) == NULL) || r; r = ((glSecondaryColor3d = (PFNGLSECONDARYCOLOR3DPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3d")) == NULL) || r; r = ((glSecondaryColor3dv = (PFNGLSECONDARYCOLOR3DVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3dv")) == NULL) || r; r = ((glSecondaryColor3f = (PFNGLSECONDARYCOLOR3FPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3f")) == NULL) || r; r = ((glSecondaryColor3fv = (PFNGLSECONDARYCOLOR3FVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3fv")) == NULL) || r; r = ((glSecondaryColor3i = (PFNGLSECONDARYCOLOR3IPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3i")) == NULL) || r; r = ((glSecondaryColor3iv = (PFNGLSECONDARYCOLOR3IVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3iv")) == NULL) || r; r = ((glSecondaryColor3s = (PFNGLSECONDARYCOLOR3SPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3s")) == NULL) || r; r = ((glSecondaryColor3sv = (PFNGLSECONDARYCOLOR3SVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3sv")) == NULL) || r; r = ((glSecondaryColor3ub = (PFNGLSECONDARYCOLOR3UBPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ub")) == NULL) || r; r = ((glSecondaryColor3ubv = (PFNGLSECONDARYCOLOR3UBVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ubv")) == NULL) || r; r = ((glSecondaryColor3ui = (PFNGLSECONDARYCOLOR3UIPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ui")) == NULL) || r; r = ((glSecondaryColor3uiv = (PFNGLSECONDARYCOLOR3UIVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3uiv")) == NULL) || r; r = ((glSecondaryColor3us = (PFNGLSECONDARYCOLOR3USPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3us")) == NULL) || r; r = ((glSecondaryColor3usv = (PFNGLSECONDARYCOLOR3USVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3usv")) == NULL) || r; r = ((glSecondaryColorPointer = (PFNGLSECONDARYCOLORPOINTERPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorPointer")) == NULL) || r; r = ((glWindowPos2d = (PFNGLWINDOWPOS2DPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2d")) == NULL) || r; r = ((glWindowPos2dv = (PFNGLWINDOWPOS2DVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dv")) == NULL) || r; r = ((glWindowPos2f = (PFNGLWINDOWPOS2FPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2f")) == NULL) || r; r = ((glWindowPos2fv = (PFNGLWINDOWPOS2FVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fv")) == NULL) || r; r = ((glWindowPos2i = (PFNGLWINDOWPOS2IPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2i")) == NULL) || r; r = ((glWindowPos2iv = (PFNGLWINDOWPOS2IVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2iv")) == NULL) || r; r = ((glWindowPos2s = (PFNGLWINDOWPOS2SPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2s")) == NULL) || r; r = ((glWindowPos2sv = (PFNGLWINDOWPOS2SVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2sv")) == NULL) || r; r = ((glWindowPos3d = (PFNGLWINDOWPOS3DPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3d")) == NULL) || r; r = ((glWindowPos3dv = (PFNGLWINDOWPOS3DVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dv")) == NULL) || r; r = ((glWindowPos3f = (PFNGLWINDOWPOS3FPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3f")) == NULL) || r; r = ((glWindowPos3fv = (PFNGLWINDOWPOS3FVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fv")) == NULL) || r; r = ((glWindowPos3i = (PFNGLWINDOWPOS3IPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3i")) == NULL) || r; r = ((glWindowPos3iv = (PFNGLWINDOWPOS3IVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3iv")) == NULL) || r; r = ((glWindowPos3s = (PFNGLWINDOWPOS3SPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3s")) == NULL) || r; r = ((glWindowPos3sv = (PFNGLWINDOWPOS3SVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3sv")) == NULL) || r; return r; } #endif /* GL_VERSION_1_4 */ #ifdef GL_VERSION_1_5 static GLboolean _glewInit_GL_VERSION_1_5 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBeginQuery = (PFNGLBEGINQUERYPROC)glewGetProcAddress((const GLubyte*)"glBeginQuery")) == NULL) || r; r = ((glBindBuffer = (PFNGLBINDBUFFERPROC)glewGetProcAddress((const GLubyte*)"glBindBuffer")) == NULL) || r; r = ((glBufferData = (PFNGLBUFFERDATAPROC)glewGetProcAddress((const GLubyte*)"glBufferData")) == NULL) || r; r = ((glBufferSubData = (PFNGLBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glBufferSubData")) == NULL) || r; r = ((glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteBuffers")) == NULL) || r; r = ((glDeleteQueries = (PFNGLDELETEQUERIESPROC)glewGetProcAddress((const GLubyte*)"glDeleteQueries")) == NULL) || r; r = ((glEndQuery = (PFNGLENDQUERYPROC)glewGetProcAddress((const GLubyte*)"glEndQuery")) == NULL) || r; r = ((glGenBuffers = (PFNGLGENBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glGenBuffers")) == NULL) || r; r = ((glGenQueries = (PFNGLGENQUERIESPROC)glewGetProcAddress((const GLubyte*)"glGenQueries")) == NULL) || r; r = ((glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetBufferParameteriv")) == NULL) || r; r = ((glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)glewGetProcAddress((const GLubyte*)"glGetBufferPointerv")) == NULL) || r; r = ((glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glGetBufferSubData")) == NULL) || r; r = ((glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectiv")) == NULL) || r; r = ((glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectuiv")) == NULL) || r; r = ((glGetQueryiv = (PFNGLGETQUERYIVPROC)glewGetProcAddress((const GLubyte*)"glGetQueryiv")) == NULL) || r; r = ((glIsBuffer = (PFNGLISBUFFERPROC)glewGetProcAddress((const GLubyte*)"glIsBuffer")) == NULL) || r; r = ((glIsQuery = (PFNGLISQUERYPROC)glewGetProcAddress((const GLubyte*)"glIsQuery")) == NULL) || r; r = ((glMapBuffer = (PFNGLMAPBUFFERPROC)glewGetProcAddress((const GLubyte*)"glMapBuffer")) == NULL) || r; r = ((glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)glewGetProcAddress((const GLubyte*)"glUnmapBuffer")) == NULL) || r; return r; } #endif /* GL_VERSION_1_5 */ #ifdef GL_VERSION_2_0 static GLboolean _glewInit_GL_VERSION_2_0 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glAttachShader = (PFNGLATTACHSHADERPROC)glewGetProcAddress((const GLubyte*)"glAttachShader")) == NULL) || r; r = ((glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)glewGetProcAddress((const GLubyte*)"glBindAttribLocation")) == NULL) || r; r = ((glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationSeparate")) == NULL) || r; r = ((glCompileShader = (PFNGLCOMPILESHADERPROC)glewGetProcAddress((const GLubyte*)"glCompileShader")) == NULL) || r; r = ((glCreateProgram = (PFNGLCREATEPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glCreateProgram")) == NULL) || r; r = ((glCreateShader = (PFNGLCREATESHADERPROC)glewGetProcAddress((const GLubyte*)"glCreateShader")) == NULL) || r; r = ((glDeleteProgram = (PFNGLDELETEPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glDeleteProgram")) == NULL) || r; r = ((glDeleteShader = (PFNGLDELETESHADERPROC)glewGetProcAddress((const GLubyte*)"glDeleteShader")) == NULL) || r; r = ((glDetachShader = (PFNGLDETACHSHADERPROC)glewGetProcAddress((const GLubyte*)"glDetachShader")) == NULL) || r; r = ((glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)glewGetProcAddress((const GLubyte*)"glDisableVertexAttribArray")) == NULL) || r; r = ((glDrawBuffers = (PFNGLDRAWBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDrawBuffers")) == NULL) || r; r = ((glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)glewGetProcAddress((const GLubyte*)"glEnableVertexAttribArray")) == NULL) || r; r = ((glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)glewGetProcAddress((const GLubyte*)"glGetActiveAttrib")) == NULL) || r; r = ((glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)glewGetProcAddress((const GLubyte*)"glGetActiveUniform")) == NULL) || r; r = ((glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)glewGetProcAddress((const GLubyte*)"glGetAttachedShaders")) == NULL) || r; r = ((glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)glewGetProcAddress((const GLubyte*)"glGetAttribLocation")) == NULL) || r; r = ((glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)glewGetProcAddress((const GLubyte*)"glGetProgramInfoLog")) == NULL) || r; r = ((glGetProgramiv = (PFNGLGETPROGRAMIVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramiv")) == NULL) || r; r = ((glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)glewGetProcAddress((const GLubyte*)"glGetShaderInfoLog")) == NULL) || r; r = ((glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)glewGetProcAddress((const GLubyte*)"glGetShaderSource")) == NULL) || r; r = ((glGetShaderiv = (PFNGLGETSHADERIVPROC)glewGetProcAddress((const GLubyte*)"glGetShaderiv")) == NULL) || r; r = ((glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)glewGetProcAddress((const GLubyte*)"glGetUniformLocation")) == NULL) || r; r = ((glGetUniformfv = (PFNGLGETUNIFORMFVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformfv")) == NULL) || r; r = ((glGetUniformiv = (PFNGLGETUNIFORMIVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformiv")) == NULL) || r; r = ((glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribPointerv")) == NULL) || r; r = ((glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribdv")) == NULL) || r; r = ((glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribfv")) == NULL) || r; r = ((glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribiv")) == NULL) || r; r = ((glIsProgram = (PFNGLISPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glIsProgram")) == NULL) || r; r = ((glIsShader = (PFNGLISSHADERPROC)glewGetProcAddress((const GLubyte*)"glIsShader")) == NULL) || r; r = ((glLinkProgram = (PFNGLLINKPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glLinkProgram")) == NULL) || r; r = ((glShaderSource = (PFNGLSHADERSOURCEPROC)glewGetProcAddress((const GLubyte*)"glShaderSource")) == NULL) || r; r = ((glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glStencilFuncSeparate")) == NULL) || r; r = ((glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glStencilMaskSeparate")) == NULL) || r; r = ((glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glStencilOpSeparate")) == NULL) || r; r = ((glUniform1f = (PFNGLUNIFORM1FPROC)glewGetProcAddress((const GLubyte*)"glUniform1f")) == NULL) || r; r = ((glUniform1fv = (PFNGLUNIFORM1FVPROC)glewGetProcAddress((const GLubyte*)"glUniform1fv")) == NULL) || r; r = ((glUniform1i = (PFNGLUNIFORM1IPROC)glewGetProcAddress((const GLubyte*)"glUniform1i")) == NULL) || r; r = ((glUniform1iv = (PFNGLUNIFORM1IVPROC)glewGetProcAddress((const GLubyte*)"glUniform1iv")) == NULL) || r; r = ((glUniform2f = (PFNGLUNIFORM2FPROC)glewGetProcAddress((const GLubyte*)"glUniform2f")) == NULL) || r; r = ((glUniform2fv = (PFNGLUNIFORM2FVPROC)glewGetProcAddress((const GLubyte*)"glUniform2fv")) == NULL) || r; r = ((glUniform2i = (PFNGLUNIFORM2IPROC)glewGetProcAddress((const GLubyte*)"glUniform2i")) == NULL) || r; r = ((glUniform2iv = (PFNGLUNIFORM2IVPROC)glewGetProcAddress((const GLubyte*)"glUniform2iv")) == NULL) || r; r = ((glUniform3f = (PFNGLUNIFORM3FPROC)glewGetProcAddress((const GLubyte*)"glUniform3f")) == NULL) || r; r = ((glUniform3fv = (PFNGLUNIFORM3FVPROC)glewGetProcAddress((const GLubyte*)"glUniform3fv")) == NULL) || r; r = ((glUniform3i = (PFNGLUNIFORM3IPROC)glewGetProcAddress((const GLubyte*)"glUniform3i")) == NULL) || r; r = ((glUniform3iv = (PFNGLUNIFORM3IVPROC)glewGetProcAddress((const GLubyte*)"glUniform3iv")) == NULL) || r; r = ((glUniform4f = (PFNGLUNIFORM4FPROC)glewGetProcAddress((const GLubyte*)"glUniform4f")) == NULL) || r; r = ((glUniform4fv = (PFNGLUNIFORM4FVPROC)glewGetProcAddress((const GLubyte*)"glUniform4fv")) == NULL) || r; r = ((glUniform4i = (PFNGLUNIFORM4IPROC)glewGetProcAddress((const GLubyte*)"glUniform4i")) == NULL) || r; r = ((glUniform4iv = (PFNGLUNIFORM4IVPROC)glewGetProcAddress((const GLubyte*)"glUniform4iv")) == NULL) || r; r = ((glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2fv")) == NULL) || r; r = ((glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3fv")) == NULL) || r; r = ((glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4fv")) == NULL) || r; r = ((glUseProgram = (PFNGLUSEPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glUseProgram")) == NULL) || r; r = ((glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glValidateProgram")) == NULL) || r; r = ((glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1d")) == NULL) || r; r = ((glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dv")) == NULL) || r; r = ((glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1f")) == NULL) || r; r = ((glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fv")) == NULL) || r; r = ((glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1s")) == NULL) || r; r = ((glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1sv")) == NULL) || r; r = ((glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2d")) == NULL) || r; r = ((glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dv")) == NULL) || r; r = ((glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2f")) == NULL) || r; r = ((glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fv")) == NULL) || r; r = ((glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2s")) == NULL) || r; r = ((glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2sv")) == NULL) || r; r = ((glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3d")) == NULL) || r; r = ((glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dv")) == NULL) || r; r = ((glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3f")) == NULL) || r; r = ((glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fv")) == NULL) || r; r = ((glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3s")) == NULL) || r; r = ((glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3sv")) == NULL) || r; r = ((glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nbv")) == NULL) || r; r = ((glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Niv")) == NULL) || r; r = ((glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nsv")) == NULL) || r; r = ((glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nub")) == NULL) || r; r = ((glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nubv")) == NULL) || r; r = ((glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nuiv")) == NULL) || r; r = ((glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nusv")) == NULL) || r; r = ((glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4bv")) == NULL) || r; r = ((glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4d")) == NULL) || r; r = ((glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dv")) == NULL) || r; r = ((glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4f")) == NULL) || r; r = ((glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fv")) == NULL) || r; r = ((glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4iv")) == NULL) || r; r = ((glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4s")) == NULL) || r; r = ((glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4sv")) == NULL) || r; r = ((glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ubv")) == NULL) || r; r = ((glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4uiv")) == NULL) || r; r = ((glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4usv")) == NULL) || r; r = ((glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribPointer")) == NULL) || r; return r; } #endif /* GL_VERSION_2_0 */ #ifdef GL_VERSION_2_1 static GLboolean _glewInit_GL_VERSION_2_1 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2x3fv")) == NULL) || r; r = ((glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2x4fv")) == NULL) || r; r = ((glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3x2fv")) == NULL) || r; r = ((glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3x4fv")) == NULL) || r; r = ((glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4x2fv")) == NULL) || r; r = ((glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4x3fv")) == NULL) || r; return r; } #endif /* GL_VERSION_2_1 */ #ifdef GL_VERSION_3_0 static GLboolean _glewInit_GL_VERSION_3_0 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)glewGetProcAddress((const GLubyte*)"glBeginConditionalRender")) == NULL) || r; r = ((glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glBeginTransformFeedback")) == NULL) || r; r = ((glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)glewGetProcAddress((const GLubyte*)"glBindFragDataLocation")) == NULL) || r; r = ((glClampColor = (PFNGLCLAMPCOLORPROC)glewGetProcAddress((const GLubyte*)"glClampColor")) == NULL) || r; r = ((glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)glewGetProcAddress((const GLubyte*)"glClearBufferfi")) == NULL) || r; r = ((glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)glewGetProcAddress((const GLubyte*)"glClearBufferfv")) == NULL) || r; r = ((glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)glewGetProcAddress((const GLubyte*)"glClearBufferiv")) == NULL) || r; r = ((glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC)glewGetProcAddress((const GLubyte*)"glClearBufferuiv")) == NULL) || r; r = ((glColorMaski = (PFNGLCOLORMASKIPROC)glewGetProcAddress((const GLubyte*)"glColorMaski")) == NULL) || r; r = ((glDisablei = (PFNGLDISABLEIPROC)glewGetProcAddress((const GLubyte*)"glDisablei")) == NULL) || r; r = ((glEnablei = (PFNGLENABLEIPROC)glewGetProcAddress((const GLubyte*)"glEnablei")) == NULL) || r; r = ((glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC)glewGetProcAddress((const GLubyte*)"glEndConditionalRender")) == NULL) || r; r = ((glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glEndTransformFeedback")) == NULL) || r; r = ((glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)glewGetProcAddress((const GLubyte*)"glGetBooleani_v")) == NULL) || r; r = ((glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)glewGetProcAddress((const GLubyte*)"glGetFragDataLocation")) == NULL) || r; r = ((glGetStringi = (PFNGLGETSTRINGIPROC)glewGetProcAddress((const GLubyte*)"glGetStringi")) == NULL) || r; r = ((glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterIiv")) == NULL) || r; r = ((glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterIuiv")) == NULL) || r; r = ((glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)glewGetProcAddress((const GLubyte*)"glGetTransformFeedbackVarying")) == NULL) || r; r = ((glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformuiv")) == NULL) || r; r = ((glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribIiv")) == NULL) || r; r = ((glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribIuiv")) == NULL) || r; r = ((glIsEnabledi = (PFNGLISENABLEDIPROC)glewGetProcAddress((const GLubyte*)"glIsEnabledi")) == NULL) || r; r = ((glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)"glTexParameterIiv")) == NULL) || r; r = ((glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)"glTexParameterIuiv")) == NULL) || r; r = ((glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)glewGetProcAddress((const GLubyte*)"glTransformFeedbackVaryings")) == NULL) || r; r = ((glUniform1ui = (PFNGLUNIFORM1UIPROC)glewGetProcAddress((const GLubyte*)"glUniform1ui")) == NULL) || r; r = ((glUniform1uiv = (PFNGLUNIFORM1UIVPROC)glewGetProcAddress((const GLubyte*)"glUniform1uiv")) == NULL) || r; r = ((glUniform2ui = (PFNGLUNIFORM2UIPROC)glewGetProcAddress((const GLubyte*)"glUniform2ui")) == NULL) || r; r = ((glUniform2uiv = (PFNGLUNIFORM2UIVPROC)glewGetProcAddress((const GLubyte*)"glUniform2uiv")) == NULL) || r; r = ((glUniform3ui = (PFNGLUNIFORM3UIPROC)glewGetProcAddress((const GLubyte*)"glUniform3ui")) == NULL) || r; r = ((glUniform3uiv = (PFNGLUNIFORM3UIVPROC)glewGetProcAddress((const GLubyte*)"glUniform3uiv")) == NULL) || r; r = ((glUniform4ui = (PFNGLUNIFORM4UIPROC)glewGetProcAddress((const GLubyte*)"glUniform4ui")) == NULL) || r; r = ((glUniform4uiv = (PFNGLUNIFORM4UIVPROC)glewGetProcAddress((const GLubyte*)"glUniform4uiv")) == NULL) || r; r = ((glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1i")) == NULL) || r; r = ((glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1iv")) == NULL) || r; r = ((glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1ui")) == NULL) || r; r = ((glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1uiv")) == NULL) || r; r = ((glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2i")) == NULL) || r; r = ((glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2iv")) == NULL) || r; r = ((glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2ui")) == NULL) || r; r = ((glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2uiv")) == NULL) || r; r = ((glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3i")) == NULL) || r; r = ((glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3iv")) == NULL) || r; r = ((glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3ui")) == NULL) || r; r = ((glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3uiv")) == NULL) || r; r = ((glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4bv")) == NULL) || r; r = ((glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4i")) == NULL) || r; r = ((glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4iv")) == NULL) || r; r = ((glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4sv")) == NULL) || r; r = ((glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4ubv")) == NULL) || r; r = ((glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4ui")) == NULL) || r; r = ((glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4uiv")) == NULL) || r; r = ((glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4usv")) == NULL) || r; r = ((glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribIPointer")) == NULL) || r; return r; } #endif /* GL_VERSION_3_0 */ #ifdef GL_VERSION_3_1 static GLboolean _glewInit_GL_VERSION_3_1 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysInstanced")) == NULL) || r; r = ((glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsInstanced")) == NULL) || r; r = ((glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)glewGetProcAddress((const GLubyte*)"glPrimitiveRestartIndex")) == NULL) || r; r = ((glTexBuffer = (PFNGLTEXBUFFERPROC)glewGetProcAddress((const GLubyte*)"glTexBuffer")) == NULL) || r; return r; } #endif /* GL_VERSION_3_1 */ #ifdef GL_VERSION_3_2 static GLboolean _glewInit_GL_VERSION_3_2 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture")) == NULL) || r; r = ((glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC)glewGetProcAddress((const GLubyte*)"glGetBufferParameteri64v")) == NULL) || r; r = ((glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC)glewGetProcAddress((const GLubyte*)"glGetInteger64i_v")) == NULL) || r; return r; } #endif /* GL_VERSION_3_2 */ #ifdef GL_VERSION_3_3 static GLboolean _glewInit_GL_VERSION_3_3 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribDivisor")) == NULL) || r; return r; } #endif /* GL_VERSION_3_3 */ #ifdef GL_VERSION_4_0 static GLboolean _glewInit_GL_VERSION_4_0 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBlendEquationSeparatei = (PFNGLBLENDEQUATIONSEPARATEIPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationSeparatei")) == NULL) || r; r = ((glBlendEquationi = (PFNGLBLENDEQUATIONIPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationi")) == NULL) || r; r = ((glBlendFuncSeparatei = (PFNGLBLENDFUNCSEPARATEIPROC)glewGetProcAddress((const GLubyte*)"glBlendFuncSeparatei")) == NULL) || r; r = ((glBlendFunci = (PFNGLBLENDFUNCIPROC)glewGetProcAddress((const GLubyte*)"glBlendFunci")) == NULL) || r; r = ((glMinSampleShading = (PFNGLMINSAMPLESHADINGPROC)glewGetProcAddress((const GLubyte*)"glMinSampleShading")) == NULL) || r; return r; } #endif /* GL_VERSION_4_0 */ #ifdef GL_VERSION_4_5 static GLboolean _glewInit_GL_VERSION_4_5 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetGraphicsResetStatus = (PFNGLGETGRAPHICSRESETSTATUSPROC)glewGetProcAddress((const GLubyte*)"glGetGraphicsResetStatus")) == NULL) || r; r = ((glGetnCompressedTexImage = (PFNGLGETNCOMPRESSEDTEXIMAGEPROC)glewGetProcAddress((const GLubyte*)"glGetnCompressedTexImage")) == NULL) || r; r = ((glGetnTexImage = (PFNGLGETNTEXIMAGEPROC)glewGetProcAddress((const GLubyte*)"glGetnTexImage")) == NULL) || r; r = ((glGetnUniformdv = (PFNGLGETNUNIFORMDVPROC)glewGetProcAddress((const GLubyte*)"glGetnUniformdv")) == NULL) || r; return r; } #endif /* GL_VERSION_4_5 */ #ifdef GL_3DFX_tbuffer static GLboolean _glewInit_GL_3DFX_tbuffer (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTbufferMask3DFX = (PFNGLTBUFFERMASK3DFXPROC)glewGetProcAddress((const GLubyte*)"glTbufferMask3DFX")) == NULL) || r; return r; } #endif /* GL_3DFX_tbuffer */ #ifdef GL_AMD_debug_output static GLboolean _glewInit_GL_AMD_debug_output (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDebugMessageCallbackAMD = (PFNGLDEBUGMESSAGECALLBACKAMDPROC)glewGetProcAddress((const GLubyte*)"glDebugMessageCallbackAMD")) == NULL) || r; r = ((glDebugMessageEnableAMD = (PFNGLDEBUGMESSAGEENABLEAMDPROC)glewGetProcAddress((const GLubyte*)"glDebugMessageEnableAMD")) == NULL) || r; r = ((glDebugMessageInsertAMD = (PFNGLDEBUGMESSAGEINSERTAMDPROC)glewGetProcAddress((const GLubyte*)"glDebugMessageInsertAMD")) == NULL) || r; r = ((glGetDebugMessageLogAMD = (PFNGLGETDEBUGMESSAGELOGAMDPROC)glewGetProcAddress((const GLubyte*)"glGetDebugMessageLogAMD")) == NULL) || r; return r; } #endif /* GL_AMD_debug_output */ #ifdef GL_AMD_draw_buffers_blend static GLboolean _glewInit_GL_AMD_draw_buffers_blend (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBlendEquationIndexedAMD = (PFNGLBLENDEQUATIONINDEXEDAMDPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationIndexedAMD")) == NULL) || r; r = ((glBlendEquationSeparateIndexedAMD = (PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationSeparateIndexedAMD")) == NULL) || r; r = ((glBlendFuncIndexedAMD = (PFNGLBLENDFUNCINDEXEDAMDPROC)glewGetProcAddress((const GLubyte*)"glBlendFuncIndexedAMD")) == NULL) || r; r = ((glBlendFuncSeparateIndexedAMD = (PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC)glewGetProcAddress((const GLubyte*)"glBlendFuncSeparateIndexedAMD")) == NULL) || r; return r; } #endif /* GL_AMD_draw_buffers_blend */ #ifdef GL_AMD_interleaved_elements static GLboolean _glewInit_GL_AMD_interleaved_elements (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glVertexAttribParameteriAMD = (PFNGLVERTEXATTRIBPARAMETERIAMDPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribParameteriAMD")) == NULL) || r; return r; } #endif /* GL_AMD_interleaved_elements */ #ifdef GL_AMD_multi_draw_indirect static GLboolean _glewInit_GL_AMD_multi_draw_indirect (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glMultiDrawArraysIndirectAMD = (PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawArraysIndirectAMD")) == NULL) || r; r = ((glMultiDrawElementsIndirectAMD = (PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElementsIndirectAMD")) == NULL) || r; return r; } #endif /* GL_AMD_multi_draw_indirect */ #ifdef GL_AMD_name_gen_delete static GLboolean _glewInit_GL_AMD_name_gen_delete (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDeleteNamesAMD = (PFNGLDELETENAMESAMDPROC)glewGetProcAddress((const GLubyte*)"glDeleteNamesAMD")) == NULL) || r; r = ((glGenNamesAMD = (PFNGLGENNAMESAMDPROC)glewGetProcAddress((const GLubyte*)"glGenNamesAMD")) == NULL) || r; r = ((glIsNameAMD = (PFNGLISNAMEAMDPROC)glewGetProcAddress((const GLubyte*)"glIsNameAMD")) == NULL) || r; return r; } #endif /* GL_AMD_name_gen_delete */ #ifdef GL_AMD_occlusion_query_event static GLboolean _glewInit_GL_AMD_occlusion_query_event (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glQueryObjectParameteruiAMD = (PFNGLQUERYOBJECTPARAMETERUIAMDPROC)glewGetProcAddress((const GLubyte*)"glQueryObjectParameteruiAMD")) == NULL) || r; return r; } #endif /* GL_AMD_occlusion_query_event */ #ifdef GL_AMD_performance_monitor static GLboolean _glewInit_GL_AMD_performance_monitor (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBeginPerfMonitorAMD = (PFNGLBEGINPERFMONITORAMDPROC)glewGetProcAddress((const GLubyte*)"glBeginPerfMonitorAMD")) == NULL) || r; r = ((glDeletePerfMonitorsAMD = (PFNGLDELETEPERFMONITORSAMDPROC)glewGetProcAddress((const GLubyte*)"glDeletePerfMonitorsAMD")) == NULL) || r; r = ((glEndPerfMonitorAMD = (PFNGLENDPERFMONITORAMDPROC)glewGetProcAddress((const GLubyte*)"glEndPerfMonitorAMD")) == NULL) || r; r = ((glGenPerfMonitorsAMD = (PFNGLGENPERFMONITORSAMDPROC)glewGetProcAddress((const GLubyte*)"glGenPerfMonitorsAMD")) == NULL) || r; r = ((glGetPerfMonitorCounterDataAMD = (PFNGLGETPERFMONITORCOUNTERDATAAMDPROC)glewGetProcAddress((const GLubyte*)"glGetPerfMonitorCounterDataAMD")) == NULL) || r; r = ((glGetPerfMonitorCounterInfoAMD = (PFNGLGETPERFMONITORCOUNTERINFOAMDPROC)glewGetProcAddress((const GLubyte*)"glGetPerfMonitorCounterInfoAMD")) == NULL) || r; r = ((glGetPerfMonitorCounterStringAMD = (PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC)glewGetProcAddress((const GLubyte*)"glGetPerfMonitorCounterStringAMD")) == NULL) || r; r = ((glGetPerfMonitorCountersAMD = (PFNGLGETPERFMONITORCOUNTERSAMDPROC)glewGetProcAddress((const GLubyte*)"glGetPerfMonitorCountersAMD")) == NULL) || r; r = ((glGetPerfMonitorGroupStringAMD = (PFNGLGETPERFMONITORGROUPSTRINGAMDPROC)glewGetProcAddress((const GLubyte*)"glGetPerfMonitorGroupStringAMD")) == NULL) || r; r = ((glGetPerfMonitorGroupsAMD = (PFNGLGETPERFMONITORGROUPSAMDPROC)glewGetProcAddress((const GLubyte*)"glGetPerfMonitorGroupsAMD")) == NULL) || r; r = ((glSelectPerfMonitorCountersAMD = (PFNGLSELECTPERFMONITORCOUNTERSAMDPROC)glewGetProcAddress((const GLubyte*)"glSelectPerfMonitorCountersAMD")) == NULL) || r; return r; } #endif /* GL_AMD_performance_monitor */ #ifdef GL_AMD_sample_positions static GLboolean _glewInit_GL_AMD_sample_positions (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glSetMultisamplefvAMD = (PFNGLSETMULTISAMPLEFVAMDPROC)glewGetProcAddress((const GLubyte*)"glSetMultisamplefvAMD")) == NULL) || r; return r; } #endif /* GL_AMD_sample_positions */ #ifdef GL_AMD_sparse_texture static GLboolean _glewInit_GL_AMD_sparse_texture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTexStorageSparseAMD = (PFNGLTEXSTORAGESPARSEAMDPROC)glewGetProcAddress((const GLubyte*)"glTexStorageSparseAMD")) == NULL) || r; r = ((glTextureStorageSparseAMD = (PFNGLTEXTURESTORAGESPARSEAMDPROC)glewGetProcAddress((const GLubyte*)"glTextureStorageSparseAMD")) == NULL) || r; return r; } #endif /* GL_AMD_sparse_texture */ #ifdef GL_AMD_stencil_operation_extended static GLboolean _glewInit_GL_AMD_stencil_operation_extended (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glStencilOpValueAMD = (PFNGLSTENCILOPVALUEAMDPROC)glewGetProcAddress((const GLubyte*)"glStencilOpValueAMD")) == NULL) || r; return r; } #endif /* GL_AMD_stencil_operation_extended */ #ifdef GL_AMD_vertex_shader_tessellator static GLboolean _glewInit_GL_AMD_vertex_shader_tessellator (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTessellationFactorAMD = (PFNGLTESSELLATIONFACTORAMDPROC)glewGetProcAddress((const GLubyte*)"glTessellationFactorAMD")) == NULL) || r; r = ((glTessellationModeAMD = (PFNGLTESSELLATIONMODEAMDPROC)glewGetProcAddress((const GLubyte*)"glTessellationModeAMD")) == NULL) || r; return r; } #endif /* GL_AMD_vertex_shader_tessellator */ #ifdef GL_ANGLE_framebuffer_blit static GLboolean _glewInit_GL_ANGLE_framebuffer_blit (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBlitFramebufferANGLE = (PFNGLBLITFRAMEBUFFERANGLEPROC)glewGetProcAddress((const GLubyte*)"glBlitFramebufferANGLE")) == NULL) || r; return r; } #endif /* GL_ANGLE_framebuffer_blit */ #ifdef GL_ANGLE_framebuffer_multisample static GLboolean _glewInit_GL_ANGLE_framebuffer_multisample (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glRenderbufferStorageMultisampleANGLE = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorageMultisampleANGLE")) == NULL) || r; return r; } #endif /* GL_ANGLE_framebuffer_multisample */ #ifdef GL_ANGLE_instanced_arrays static GLboolean _glewInit_GL_ANGLE_instanced_arrays (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDrawArraysInstancedANGLE = (PFNGLDRAWARRAYSINSTANCEDANGLEPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysInstancedANGLE")) == NULL) || r; r = ((glDrawElementsInstancedANGLE = (PFNGLDRAWELEMENTSINSTANCEDANGLEPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsInstancedANGLE")) == NULL) || r; r = ((glVertexAttribDivisorANGLE = (PFNGLVERTEXATTRIBDIVISORANGLEPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribDivisorANGLE")) == NULL) || r; return r; } #endif /* GL_ANGLE_instanced_arrays */ #ifdef GL_ANGLE_timer_query static GLboolean _glewInit_GL_ANGLE_timer_query (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBeginQueryANGLE = (PFNGLBEGINQUERYANGLEPROC)glewGetProcAddress((const GLubyte*)"glBeginQueryANGLE")) == NULL) || r; r = ((glDeleteQueriesANGLE = (PFNGLDELETEQUERIESANGLEPROC)glewGetProcAddress((const GLubyte*)"glDeleteQueriesANGLE")) == NULL) || r; r = ((glEndQueryANGLE = (PFNGLENDQUERYANGLEPROC)glewGetProcAddress((const GLubyte*)"glEndQueryANGLE")) == NULL) || r; r = ((glGenQueriesANGLE = (PFNGLGENQUERIESANGLEPROC)glewGetProcAddress((const GLubyte*)"glGenQueriesANGLE")) == NULL) || r; r = ((glGetQueryObjecti64vANGLE = (PFNGLGETQUERYOBJECTI64VANGLEPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjecti64vANGLE")) == NULL) || r; r = ((glGetQueryObjectivANGLE = (PFNGLGETQUERYOBJECTIVANGLEPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectivANGLE")) == NULL) || r; r = ((glGetQueryObjectui64vANGLE = (PFNGLGETQUERYOBJECTUI64VANGLEPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectui64vANGLE")) == NULL) || r; r = ((glGetQueryObjectuivANGLE = (PFNGLGETQUERYOBJECTUIVANGLEPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectuivANGLE")) == NULL) || r; r = ((glGetQueryivANGLE = (PFNGLGETQUERYIVANGLEPROC)glewGetProcAddress((const GLubyte*)"glGetQueryivANGLE")) == NULL) || r; r = ((glIsQueryANGLE = (PFNGLISQUERYANGLEPROC)glewGetProcAddress((const GLubyte*)"glIsQueryANGLE")) == NULL) || r; r = ((glQueryCounterANGLE = (PFNGLQUERYCOUNTERANGLEPROC)glewGetProcAddress((const GLubyte*)"glQueryCounterANGLE")) == NULL) || r; return r; } #endif /* GL_ANGLE_timer_query */ #ifdef GL_ANGLE_translated_shader_source static GLboolean _glewInit_GL_ANGLE_translated_shader_source (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetTranslatedShaderSourceANGLE = (PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)glewGetProcAddress((const GLubyte*)"glGetTranslatedShaderSourceANGLE")) == NULL) || r; return r; } #endif /* GL_ANGLE_translated_shader_source */ #ifdef GL_APPLE_element_array static GLboolean _glewInit_GL_APPLE_element_array (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDrawElementArrayAPPLE = (PFNGLDRAWELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glDrawElementArrayAPPLE")) == NULL) || r; r = ((glDrawRangeElementArrayAPPLE = (PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glDrawRangeElementArrayAPPLE")) == NULL) || r; r = ((glElementPointerAPPLE = (PFNGLELEMENTPOINTERAPPLEPROC)glewGetProcAddress((const GLubyte*)"glElementPointerAPPLE")) == NULL) || r; r = ((glMultiDrawElementArrayAPPLE = (PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElementArrayAPPLE")) == NULL) || r; r = ((glMultiDrawRangeElementArrayAPPLE = (PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawRangeElementArrayAPPLE")) == NULL) || r; return r; } #endif /* GL_APPLE_element_array */ #ifdef GL_APPLE_fence static GLboolean _glewInit_GL_APPLE_fence (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDeleteFencesAPPLE = (PFNGLDELETEFENCESAPPLEPROC)glewGetProcAddress((const GLubyte*)"glDeleteFencesAPPLE")) == NULL) || r; r = ((glFinishFenceAPPLE = (PFNGLFINISHFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glFinishFenceAPPLE")) == NULL) || r; r = ((glFinishObjectAPPLE = (PFNGLFINISHOBJECTAPPLEPROC)glewGetProcAddress((const GLubyte*)"glFinishObjectAPPLE")) == NULL) || r; r = ((glGenFencesAPPLE = (PFNGLGENFENCESAPPLEPROC)glewGetProcAddress((const GLubyte*)"glGenFencesAPPLE")) == NULL) || r; r = ((glIsFenceAPPLE = (PFNGLISFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glIsFenceAPPLE")) == NULL) || r; r = ((glSetFenceAPPLE = (PFNGLSETFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glSetFenceAPPLE")) == NULL) || r; r = ((glTestFenceAPPLE = (PFNGLTESTFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glTestFenceAPPLE")) == NULL) || r; r = ((glTestObjectAPPLE = (PFNGLTESTOBJECTAPPLEPROC)glewGetProcAddress((const GLubyte*)"glTestObjectAPPLE")) == NULL) || r; return r; } #endif /* GL_APPLE_fence */ #ifdef GL_APPLE_flush_buffer_range static GLboolean _glewInit_GL_APPLE_flush_buffer_range (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBufferParameteriAPPLE = (PFNGLBUFFERPARAMETERIAPPLEPROC)glewGetProcAddress((const GLubyte*)"glBufferParameteriAPPLE")) == NULL) || r; r = ((glFlushMappedBufferRangeAPPLE = (PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glFlushMappedBufferRangeAPPLE")) == NULL) || r; return r; } #endif /* GL_APPLE_flush_buffer_range */ #ifdef GL_APPLE_object_purgeable static GLboolean _glewInit_GL_APPLE_object_purgeable (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetObjectParameterivAPPLE = (PFNGLGETOBJECTPARAMETERIVAPPLEPROC)glewGetProcAddress((const GLubyte*)"glGetObjectParameterivAPPLE")) == NULL) || r; r = ((glObjectPurgeableAPPLE = (PFNGLOBJECTPURGEABLEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glObjectPurgeableAPPLE")) == NULL) || r; r = ((glObjectUnpurgeableAPPLE = (PFNGLOBJECTUNPURGEABLEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glObjectUnpurgeableAPPLE")) == NULL) || r; return r; } #endif /* GL_APPLE_object_purgeable */ #ifdef GL_APPLE_texture_range static GLboolean _glewInit_GL_APPLE_texture_range (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetTexParameterPointervAPPLE = (PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterPointervAPPLE")) == NULL) || r; r = ((glTextureRangeAPPLE = (PFNGLTEXTURERANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glTextureRangeAPPLE")) == NULL) || r; return r; } #endif /* GL_APPLE_texture_range */ #ifdef GL_APPLE_vertex_array_object static GLboolean _glewInit_GL_APPLE_vertex_array_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindVertexArrayAPPLE = (PFNGLBINDVERTEXARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glBindVertexArrayAPPLE")) == NULL) || r; r = ((glDeleteVertexArraysAPPLE = (PFNGLDELETEVERTEXARRAYSAPPLEPROC)glewGetProcAddress((const GLubyte*)"glDeleteVertexArraysAPPLE")) == NULL) || r; r = ((glGenVertexArraysAPPLE = (PFNGLGENVERTEXARRAYSAPPLEPROC)glewGetProcAddress((const GLubyte*)"glGenVertexArraysAPPLE")) == NULL) || r; r = ((glIsVertexArrayAPPLE = (PFNGLISVERTEXARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glIsVertexArrayAPPLE")) == NULL) || r; return r; } #endif /* GL_APPLE_vertex_array_object */ #ifdef GL_APPLE_vertex_array_range static GLboolean _glewInit_GL_APPLE_vertex_array_range (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFlushVertexArrayRangeAPPLE = (PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glFlushVertexArrayRangeAPPLE")) == NULL) || r; r = ((glVertexArrayParameteriAPPLE = (PFNGLVERTEXARRAYPARAMETERIAPPLEPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayParameteriAPPLE")) == NULL) || r; r = ((glVertexArrayRangeAPPLE = (PFNGLVERTEXARRAYRANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayRangeAPPLE")) == NULL) || r; return r; } #endif /* GL_APPLE_vertex_array_range */ #ifdef GL_APPLE_vertex_program_evaluators static GLboolean _glewInit_GL_APPLE_vertex_program_evaluators (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDisableVertexAttribAPPLE = (PFNGLDISABLEVERTEXATTRIBAPPLEPROC)glewGetProcAddress((const GLubyte*)"glDisableVertexAttribAPPLE")) == NULL) || r; r = ((glEnableVertexAttribAPPLE = (PFNGLENABLEVERTEXATTRIBAPPLEPROC)glewGetProcAddress((const GLubyte*)"glEnableVertexAttribAPPLE")) == NULL) || r; r = ((glIsVertexAttribEnabledAPPLE = (PFNGLISVERTEXATTRIBENABLEDAPPLEPROC)glewGetProcAddress((const GLubyte*)"glIsVertexAttribEnabledAPPLE")) == NULL) || r; r = ((glMapVertexAttrib1dAPPLE = (PFNGLMAPVERTEXATTRIB1DAPPLEPROC)glewGetProcAddress((const GLubyte*)"glMapVertexAttrib1dAPPLE")) == NULL) || r; r = ((glMapVertexAttrib1fAPPLE = (PFNGLMAPVERTEXATTRIB1FAPPLEPROC)glewGetProcAddress((const GLubyte*)"glMapVertexAttrib1fAPPLE")) == NULL) || r; r = ((glMapVertexAttrib2dAPPLE = (PFNGLMAPVERTEXATTRIB2DAPPLEPROC)glewGetProcAddress((const GLubyte*)"glMapVertexAttrib2dAPPLE")) == NULL) || r; r = ((glMapVertexAttrib2fAPPLE = (PFNGLMAPVERTEXATTRIB2FAPPLEPROC)glewGetProcAddress((const GLubyte*)"glMapVertexAttrib2fAPPLE")) == NULL) || r; return r; } #endif /* GL_APPLE_vertex_program_evaluators */ #ifdef GL_ARB_ES2_compatibility static GLboolean _glewInit_GL_ARB_ES2_compatibility (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glClearDepthf = (PFNGLCLEARDEPTHFPROC)glewGetProcAddress((const GLubyte*)"glClearDepthf")) == NULL) || r; r = ((glDepthRangef = (PFNGLDEPTHRANGEFPROC)glewGetProcAddress((const GLubyte*)"glDepthRangef")) == NULL) || r; r = ((glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC)glewGetProcAddress((const GLubyte*)"glGetShaderPrecisionFormat")) == NULL) || r; r = ((glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC)glewGetProcAddress((const GLubyte*)"glReleaseShaderCompiler")) == NULL) || r; r = ((glShaderBinary = (PFNGLSHADERBINARYPROC)glewGetProcAddress((const GLubyte*)"glShaderBinary")) == NULL) || r; return r; } #endif /* GL_ARB_ES2_compatibility */ #ifdef GL_ARB_ES3_1_compatibility static GLboolean _glewInit_GL_ARB_ES3_1_compatibility (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glMemoryBarrierByRegion = (PFNGLMEMORYBARRIERBYREGIONPROC)glewGetProcAddress((const GLubyte*)"glMemoryBarrierByRegion")) == NULL) || r; return r; } #endif /* GL_ARB_ES3_1_compatibility */ #ifdef GL_ARB_ES3_2_compatibility static GLboolean _glewInit_GL_ARB_ES3_2_compatibility (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glPrimitiveBoundingBoxARB = (PFNGLPRIMITIVEBOUNDINGBOXARBPROC)glewGetProcAddress((const GLubyte*)"glPrimitiveBoundingBoxARB")) == NULL) || r; return r; } #endif /* GL_ARB_ES3_2_compatibility */ #ifdef GL_ARB_base_instance static GLboolean _glewInit_GL_ARB_base_instance (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDrawArraysInstancedBaseInstance = (PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysInstancedBaseInstance")) == NULL) || r; r = ((glDrawElementsInstancedBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsInstancedBaseInstance")) == NULL) || r; r = ((glDrawElementsInstancedBaseVertexBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsInstancedBaseVertexBaseInstance")) == NULL) || r; return r; } #endif /* GL_ARB_base_instance */ #ifdef GL_ARB_bindless_texture static GLboolean _glewInit_GL_ARB_bindless_texture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetImageHandleARB = (PFNGLGETIMAGEHANDLEARBPROC)glewGetProcAddress((const GLubyte*)"glGetImageHandleARB")) == NULL) || r; r = ((glGetTextureHandleARB = (PFNGLGETTEXTUREHANDLEARBPROC)glewGetProcAddress((const GLubyte*)"glGetTextureHandleARB")) == NULL) || r; r = ((glGetTextureSamplerHandleARB = (PFNGLGETTEXTURESAMPLERHANDLEARBPROC)glewGetProcAddress((const GLubyte*)"glGetTextureSamplerHandleARB")) == NULL) || r; r = ((glGetVertexAttribLui64vARB = (PFNGLGETVERTEXATTRIBLUI64VARBPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribLui64vARB")) == NULL) || r; r = ((glIsImageHandleResidentARB = (PFNGLISIMAGEHANDLERESIDENTARBPROC)glewGetProcAddress((const GLubyte*)"glIsImageHandleResidentARB")) == NULL) || r; r = ((glIsTextureHandleResidentARB = (PFNGLISTEXTUREHANDLERESIDENTARBPROC)glewGetProcAddress((const GLubyte*)"glIsTextureHandleResidentARB")) == NULL) || r; r = ((glMakeImageHandleNonResidentARB = (PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC)glewGetProcAddress((const GLubyte*)"glMakeImageHandleNonResidentARB")) == NULL) || r; r = ((glMakeImageHandleResidentARB = (PFNGLMAKEIMAGEHANDLERESIDENTARBPROC)glewGetProcAddress((const GLubyte*)"glMakeImageHandleResidentARB")) == NULL) || r; r = ((glMakeTextureHandleNonResidentARB = (PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC)glewGetProcAddress((const GLubyte*)"glMakeTextureHandleNonResidentARB")) == NULL) || r; r = ((glMakeTextureHandleResidentARB = (PFNGLMAKETEXTUREHANDLERESIDENTARBPROC)glewGetProcAddress((const GLubyte*)"glMakeTextureHandleResidentARB")) == NULL) || r; r = ((glProgramUniformHandleui64ARB = (PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformHandleui64ARB")) == NULL) || r; r = ((glProgramUniformHandleui64vARB = (PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformHandleui64vARB")) == NULL) || r; r = ((glUniformHandleui64ARB = (PFNGLUNIFORMHANDLEUI64ARBPROC)glewGetProcAddress((const GLubyte*)"glUniformHandleui64ARB")) == NULL) || r; r = ((glUniformHandleui64vARB = (PFNGLUNIFORMHANDLEUI64VARBPROC)glewGetProcAddress((const GLubyte*)"glUniformHandleui64vARB")) == NULL) || r; r = ((glVertexAttribL1ui64ARB = (PFNGLVERTEXATTRIBL1UI64ARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1ui64ARB")) == NULL) || r; r = ((glVertexAttribL1ui64vARB = (PFNGLVERTEXATTRIBL1UI64VARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1ui64vARB")) == NULL) || r; return r; } #endif /* GL_ARB_bindless_texture */ #ifdef GL_ARB_blend_func_extended static GLboolean _glewInit_GL_ARB_blend_func_extended (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)glewGetProcAddress((const GLubyte*)"glBindFragDataLocationIndexed")) == NULL) || r; r = ((glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC)glewGetProcAddress((const GLubyte*)"glGetFragDataIndex")) == NULL) || r; return r; } #endif /* GL_ARB_blend_func_extended */ #ifdef GL_ARB_buffer_storage static GLboolean _glewInit_GL_ARB_buffer_storage (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBufferStorage = (PFNGLBUFFERSTORAGEPROC)glewGetProcAddress((const GLubyte*)"glBufferStorage")) == NULL) || r; r = ((glNamedBufferStorageEXT = (PFNGLNAMEDBUFFERSTORAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedBufferStorageEXT")) == NULL) || r; return r; } #endif /* GL_ARB_buffer_storage */ #ifdef GL_ARB_cl_event static GLboolean _glewInit_GL_ARB_cl_event (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glCreateSyncFromCLeventARB = (PFNGLCREATESYNCFROMCLEVENTARBPROC)glewGetProcAddress((const GLubyte*)"glCreateSyncFromCLeventARB")) == NULL) || r; return r; } #endif /* GL_ARB_cl_event */ #ifdef GL_ARB_clear_buffer_object static GLboolean _glewInit_GL_ARB_clear_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glClearBufferData = (PFNGLCLEARBUFFERDATAPROC)glewGetProcAddress((const GLubyte*)"glClearBufferData")) == NULL) || r; r = ((glClearBufferSubData = (PFNGLCLEARBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glClearBufferSubData")) == NULL) || r; r = ((glClearNamedBufferDataEXT = (PFNGLCLEARNAMEDBUFFERDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glClearNamedBufferDataEXT")) == NULL) || r; r = ((glClearNamedBufferSubDataEXT = (PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glClearNamedBufferSubDataEXT")) == NULL) || r; return r; } #endif /* GL_ARB_clear_buffer_object */ #ifdef GL_ARB_clear_texture static GLboolean _glewInit_GL_ARB_clear_texture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glClearTexImage = (PFNGLCLEARTEXIMAGEPROC)glewGetProcAddress((const GLubyte*)"glClearTexImage")) == NULL) || r; r = ((glClearTexSubImage = (PFNGLCLEARTEXSUBIMAGEPROC)glewGetProcAddress((const GLubyte*)"glClearTexSubImage")) == NULL) || r; return r; } #endif /* GL_ARB_clear_texture */ #ifdef GL_ARB_clip_control static GLboolean _glewInit_GL_ARB_clip_control (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glClipControl = (PFNGLCLIPCONTROLPROC)glewGetProcAddress((const GLubyte*)"glClipControl")) == NULL) || r; return r; } #endif /* GL_ARB_clip_control */ #ifdef GL_ARB_color_buffer_float static GLboolean _glewInit_GL_ARB_color_buffer_float (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glClampColorARB = (PFNGLCLAMPCOLORARBPROC)glewGetProcAddress((const GLubyte*)"glClampColorARB")) == NULL) || r; return r; } #endif /* GL_ARB_color_buffer_float */ #ifdef GL_ARB_compute_shader static GLboolean _glewInit_GL_ARB_compute_shader (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDispatchCompute = (PFNGLDISPATCHCOMPUTEPROC)glewGetProcAddress((const GLubyte*)"glDispatchCompute")) == NULL) || r; r = ((glDispatchComputeIndirect = (PFNGLDISPATCHCOMPUTEINDIRECTPROC)glewGetProcAddress((const GLubyte*)"glDispatchComputeIndirect")) == NULL) || r; return r; } #endif /* GL_ARB_compute_shader */ #ifdef GL_ARB_compute_variable_group_size static GLboolean _glewInit_GL_ARB_compute_variable_group_size (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDispatchComputeGroupSizeARB = (PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC)glewGetProcAddress((const GLubyte*)"glDispatchComputeGroupSizeARB")) == NULL) || r; return r; } #endif /* GL_ARB_compute_variable_group_size */ #ifdef GL_ARB_copy_buffer static GLboolean _glewInit_GL_ARB_copy_buffer (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glCopyBufferSubData")) == NULL) || r; return r; } #endif /* GL_ARB_copy_buffer */ #ifdef GL_ARB_copy_image static GLboolean _glewInit_GL_ARB_copy_image (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glCopyImageSubData = (PFNGLCOPYIMAGESUBDATAPROC)glewGetProcAddress((const GLubyte*)"glCopyImageSubData")) == NULL) || r; return r; } #endif /* GL_ARB_copy_image */ #ifdef GL_ARB_debug_output static GLboolean _glewInit_GL_ARB_debug_output (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)glewGetProcAddress((const GLubyte*)"glDebugMessageCallbackARB")) == NULL) || r; r = ((glDebugMessageControlARB = (PFNGLDEBUGMESSAGECONTROLARBPROC)glewGetProcAddress((const GLubyte*)"glDebugMessageControlARB")) == NULL) || r; r = ((glDebugMessageInsertARB = (PFNGLDEBUGMESSAGEINSERTARBPROC)glewGetProcAddress((const GLubyte*)"glDebugMessageInsertARB")) == NULL) || r; r = ((glGetDebugMessageLogARB = (PFNGLGETDEBUGMESSAGELOGARBPROC)glewGetProcAddress((const GLubyte*)"glGetDebugMessageLogARB")) == NULL) || r; return r; } #endif /* GL_ARB_debug_output */ #ifdef GL_ARB_direct_state_access static GLboolean _glewInit_GL_ARB_direct_state_access (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindTextureUnit = (PFNGLBINDTEXTUREUNITPROC)glewGetProcAddress((const GLubyte*)"glBindTextureUnit")) == NULL) || r; r = ((glBlitNamedFramebuffer = (PFNGLBLITNAMEDFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)"glBlitNamedFramebuffer")) == NULL) || r; r = ((glCheckNamedFramebufferStatus = (PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC)glewGetProcAddress((const GLubyte*)"glCheckNamedFramebufferStatus")) == NULL) || r; r = ((glClearNamedBufferData = (PFNGLCLEARNAMEDBUFFERDATAPROC)glewGetProcAddress((const GLubyte*)"glClearNamedBufferData")) == NULL) || r; r = ((glClearNamedBufferSubData = (PFNGLCLEARNAMEDBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glClearNamedBufferSubData")) == NULL) || r; r = ((glClearNamedFramebufferfi = (PFNGLCLEARNAMEDFRAMEBUFFERFIPROC)glewGetProcAddress((const GLubyte*)"glClearNamedFramebufferfi")) == NULL) || r; r = ((glClearNamedFramebufferfv = (PFNGLCLEARNAMEDFRAMEBUFFERFVPROC)glewGetProcAddress((const GLubyte*)"glClearNamedFramebufferfv")) == NULL) || r; r = ((glClearNamedFramebufferiv = (PFNGLCLEARNAMEDFRAMEBUFFERIVPROC)glewGetProcAddress((const GLubyte*)"glClearNamedFramebufferiv")) == NULL) || r; r = ((glClearNamedFramebufferuiv = (PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC)glewGetProcAddress((const GLubyte*)"glClearNamedFramebufferuiv")) == NULL) || r; r = ((glCompressedTextureSubImage1D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureSubImage1D")) == NULL) || r; r = ((glCompressedTextureSubImage2D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureSubImage2D")) == NULL) || r; r = ((glCompressedTextureSubImage3D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureSubImage3D")) == NULL) || r; r = ((glCopyNamedBufferSubData = (PFNGLCOPYNAMEDBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glCopyNamedBufferSubData")) == NULL) || r; r = ((glCopyTextureSubImage1D = (PFNGLCOPYTEXTURESUBIMAGE1DPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureSubImage1D")) == NULL) || r; r = ((glCopyTextureSubImage2D = (PFNGLCOPYTEXTURESUBIMAGE2DPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureSubImage2D")) == NULL) || r; r = ((glCopyTextureSubImage3D = (PFNGLCOPYTEXTURESUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureSubImage3D")) == NULL) || r; r = ((glCreateBuffers = (PFNGLCREATEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glCreateBuffers")) == NULL) || r; r = ((glCreateFramebuffers = (PFNGLCREATEFRAMEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glCreateFramebuffers")) == NULL) || r; r = ((glCreateProgramPipelines = (PFNGLCREATEPROGRAMPIPELINESPROC)glewGetProcAddress((const GLubyte*)"glCreateProgramPipelines")) == NULL) || r; r = ((glCreateQueries = (PFNGLCREATEQUERIESPROC)glewGetProcAddress((const GLubyte*)"glCreateQueries")) == NULL) || r; r = ((glCreateRenderbuffers = (PFNGLCREATERENDERBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glCreateRenderbuffers")) == NULL) || r; r = ((glCreateSamplers = (PFNGLCREATESAMPLERSPROC)glewGetProcAddress((const GLubyte*)"glCreateSamplers")) == NULL) || r; r = ((glCreateTextures = (PFNGLCREATETEXTURESPROC)glewGetProcAddress((const GLubyte*)"glCreateTextures")) == NULL) || r; r = ((glCreateTransformFeedbacks = (PFNGLCREATETRANSFORMFEEDBACKSPROC)glewGetProcAddress((const GLubyte*)"glCreateTransformFeedbacks")) == NULL) || r; r = ((glCreateVertexArrays = (PFNGLCREATEVERTEXARRAYSPROC)glewGetProcAddress((const GLubyte*)"glCreateVertexArrays")) == NULL) || r; r = ((glDisableVertexArrayAttrib = (PFNGLDISABLEVERTEXARRAYATTRIBPROC)glewGetProcAddress((const GLubyte*)"glDisableVertexArrayAttrib")) == NULL) || r; r = ((glEnableVertexArrayAttrib = (PFNGLENABLEVERTEXARRAYATTRIBPROC)glewGetProcAddress((const GLubyte*)"glEnableVertexArrayAttrib")) == NULL) || r; r = ((glFlushMappedNamedBufferRange = (PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glFlushMappedNamedBufferRange")) == NULL) || r; r = ((glGenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC)glewGetProcAddress((const GLubyte*)"glGenerateTextureMipmap")) == NULL) || r; r = ((glGetCompressedTextureImage = (PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedTextureImage")) == NULL) || r; r = ((glGetNamedBufferParameteri64v = (PFNGLGETNAMEDBUFFERPARAMETERI64VPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferParameteri64v")) == NULL) || r; r = ((glGetNamedBufferParameteriv = (PFNGLGETNAMEDBUFFERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferParameteriv")) == NULL) || r; r = ((glGetNamedBufferPointerv = (PFNGLGETNAMEDBUFFERPOINTERVPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferPointerv")) == NULL) || r; r = ((glGetNamedBufferSubData = (PFNGLGETNAMEDBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferSubData")) == NULL) || r; r = ((glGetNamedFramebufferAttachmentParameteriv = (PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetNamedFramebufferAttachmentParameteriv")) == NULL) || r; r = ((glGetNamedFramebufferParameteriv = (PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetNamedFramebufferParameteriv")) == NULL) || r; r = ((glGetNamedRenderbufferParameteriv = (PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetNamedRenderbufferParameteriv")) == NULL) || r; r = ((glGetQueryBufferObjecti64v = (PFNGLGETQUERYBUFFEROBJECTI64VPROC)glewGetProcAddress((const GLubyte*)"glGetQueryBufferObjecti64v")) == NULL) || r; r = ((glGetQueryBufferObjectiv = (PFNGLGETQUERYBUFFEROBJECTIVPROC)glewGetProcAddress((const GLubyte*)"glGetQueryBufferObjectiv")) == NULL) || r; r = ((glGetQueryBufferObjectui64v = (PFNGLGETQUERYBUFFEROBJECTUI64VPROC)glewGetProcAddress((const GLubyte*)"glGetQueryBufferObjectui64v")) == NULL) || r; r = ((glGetQueryBufferObjectuiv = (PFNGLGETQUERYBUFFEROBJECTUIVPROC)glewGetProcAddress((const GLubyte*)"glGetQueryBufferObjectuiv")) == NULL) || r; r = ((glGetTextureImage = (PFNGLGETTEXTUREIMAGEPROC)glewGetProcAddress((const GLubyte*)"glGetTextureImage")) == NULL) || r; r = ((glGetTextureLevelParameterfv = (PFNGLGETTEXTURELEVELPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetTextureLevelParameterfv")) == NULL) || r; r = ((glGetTextureLevelParameteriv = (PFNGLGETTEXTURELEVELPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetTextureLevelParameteriv")) == NULL) || r; r = ((glGetTextureParameterIiv = (PFNGLGETTEXTUREPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterIiv")) == NULL) || r; r = ((glGetTextureParameterIuiv = (PFNGLGETTEXTUREPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterIuiv")) == NULL) || r; r = ((glGetTextureParameterfv = (PFNGLGETTEXTUREPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterfv")) == NULL) || r; r = ((glGetTextureParameteriv = (PFNGLGETTEXTUREPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameteriv")) == NULL) || r; r = ((glGetTransformFeedbacki64_v = (PFNGLGETTRANSFORMFEEDBACKI64_VPROC)glewGetProcAddress((const GLubyte*)"glGetTransformFeedbacki64_v")) == NULL) || r; r = ((glGetTransformFeedbacki_v = (PFNGLGETTRANSFORMFEEDBACKI_VPROC)glewGetProcAddress((const GLubyte*)"glGetTransformFeedbacki_v")) == NULL) || r; r = ((glGetTransformFeedbackiv = (PFNGLGETTRANSFORMFEEDBACKIVPROC)glewGetProcAddress((const GLubyte*)"glGetTransformFeedbackiv")) == NULL) || r; r = ((glGetVertexArrayIndexed64iv = (PFNGLGETVERTEXARRAYINDEXED64IVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexArrayIndexed64iv")) == NULL) || r; r = ((glGetVertexArrayIndexediv = (PFNGLGETVERTEXARRAYINDEXEDIVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexArrayIndexediv")) == NULL) || r; r = ((glGetVertexArrayiv = (PFNGLGETVERTEXARRAYIVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexArrayiv")) == NULL) || r; r = ((glInvalidateNamedFramebufferData = (PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC)glewGetProcAddress((const GLubyte*)"glInvalidateNamedFramebufferData")) == NULL) || r; r = ((glInvalidateNamedFramebufferSubData = (PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glInvalidateNamedFramebufferSubData")) == NULL) || r; r = ((glMapNamedBuffer = (PFNGLMAPNAMEDBUFFERPROC)glewGetProcAddress((const GLubyte*)"glMapNamedBuffer")) == NULL) || r; r = ((glMapNamedBufferRange = (PFNGLMAPNAMEDBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glMapNamedBufferRange")) == NULL) || r; r = ((glNamedBufferData = (PFNGLNAMEDBUFFERDATAPROC)glewGetProcAddress((const GLubyte*)"glNamedBufferData")) == NULL) || r; r = ((glNamedBufferStorage = (PFNGLNAMEDBUFFERSTORAGEPROC)glewGetProcAddress((const GLubyte*)"glNamedBufferStorage")) == NULL) || r; r = ((glNamedBufferSubData = (PFNGLNAMEDBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glNamedBufferSubData")) == NULL) || r; r = ((glNamedFramebufferDrawBuffer = (PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferDrawBuffer")) == NULL) || r; r = ((glNamedFramebufferDrawBuffers = (PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferDrawBuffers")) == NULL) || r; r = ((glNamedFramebufferParameteri = (PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferParameteri")) == NULL) || r; r = ((glNamedFramebufferReadBuffer = (PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferReadBuffer")) == NULL) || r; r = ((glNamedFramebufferRenderbuffer = (PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferRenderbuffer")) == NULL) || r; r = ((glNamedFramebufferTexture = (PFNGLNAMEDFRAMEBUFFERTEXTUREPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTexture")) == NULL) || r; r = ((glNamedFramebufferTextureLayer = (PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTextureLayer")) == NULL) || r; r = ((glNamedRenderbufferStorage = (PFNGLNAMEDRENDERBUFFERSTORAGEPROC)glewGetProcAddress((const GLubyte*)"glNamedRenderbufferStorage")) == NULL) || r; r = ((glNamedRenderbufferStorageMultisample = (PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)"glNamedRenderbufferStorageMultisample")) == NULL) || r; r = ((glTextureBuffer = (PFNGLTEXTUREBUFFERPROC)glewGetProcAddress((const GLubyte*)"glTextureBuffer")) == NULL) || r; r = ((glTextureBufferRange = (PFNGLTEXTUREBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glTextureBufferRange")) == NULL) || r; r = ((glTextureParameterIiv = (PFNGLTEXTUREPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterIiv")) == NULL) || r; r = ((glTextureParameterIuiv = (PFNGLTEXTUREPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterIuiv")) == NULL) || r; r = ((glTextureParameterf = (PFNGLTEXTUREPARAMETERFPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterf")) == NULL) || r; r = ((glTextureParameterfv = (PFNGLTEXTUREPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterfv")) == NULL) || r; r = ((glTextureParameteri = (PFNGLTEXTUREPARAMETERIPROC)glewGetProcAddress((const GLubyte*)"glTextureParameteri")) == NULL) || r; r = ((glTextureParameteriv = (PFNGLTEXTUREPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glTextureParameteriv")) == NULL) || r; r = ((glTextureStorage1D = (PFNGLTEXTURESTORAGE1DPROC)glewGetProcAddress((const GLubyte*)"glTextureStorage1D")) == NULL) || r; r = ((glTextureStorage2D = (PFNGLTEXTURESTORAGE2DPROC)glewGetProcAddress((const GLubyte*)"glTextureStorage2D")) == NULL) || r; r = ((glTextureStorage2DMultisample = (PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)"glTextureStorage2DMultisample")) == NULL) || r; r = ((glTextureStorage3D = (PFNGLTEXTURESTORAGE3DPROC)glewGetProcAddress((const GLubyte*)"glTextureStorage3D")) == NULL) || r; r = ((glTextureStorage3DMultisample = (PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)"glTextureStorage3DMultisample")) == NULL) || r; r = ((glTextureSubImage1D = (PFNGLTEXTURESUBIMAGE1DPROC)glewGetProcAddress((const GLubyte*)"glTextureSubImage1D")) == NULL) || r; r = ((glTextureSubImage2D = (PFNGLTEXTURESUBIMAGE2DPROC)glewGetProcAddress((const GLubyte*)"glTextureSubImage2D")) == NULL) || r; r = ((glTextureSubImage3D = (PFNGLTEXTURESUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glTextureSubImage3D")) == NULL) || r; r = ((glTransformFeedbackBufferBase = (PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC)glewGetProcAddress((const GLubyte*)"glTransformFeedbackBufferBase")) == NULL) || r; r = ((glTransformFeedbackBufferRange = (PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glTransformFeedbackBufferRange")) == NULL) || r; r = ((glUnmapNamedBuffer = (PFNGLUNMAPNAMEDBUFFERPROC)glewGetProcAddress((const GLubyte*)"glUnmapNamedBuffer")) == NULL) || r; r = ((glVertexArrayAttribBinding = (PFNGLVERTEXARRAYATTRIBBINDINGPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayAttribBinding")) == NULL) || r; r = ((glVertexArrayAttribFormat = (PFNGLVERTEXARRAYATTRIBFORMATPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayAttribFormat")) == NULL) || r; r = ((glVertexArrayAttribIFormat = (PFNGLVERTEXARRAYATTRIBIFORMATPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayAttribIFormat")) == NULL) || r; r = ((glVertexArrayAttribLFormat = (PFNGLVERTEXARRAYATTRIBLFORMATPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayAttribLFormat")) == NULL) || r; r = ((glVertexArrayBindingDivisor = (PFNGLVERTEXARRAYBINDINGDIVISORPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayBindingDivisor")) == NULL) || r; r = ((glVertexArrayElementBuffer = (PFNGLVERTEXARRAYELEMENTBUFFERPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayElementBuffer")) == NULL) || r; r = ((glVertexArrayVertexBuffer = (PFNGLVERTEXARRAYVERTEXBUFFERPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexBuffer")) == NULL) || r; r = ((glVertexArrayVertexBuffers = (PFNGLVERTEXARRAYVERTEXBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexBuffers")) == NULL) || r; return r; } #endif /* GL_ARB_direct_state_access */ #ifdef GL_ARB_draw_buffers static GLboolean _glewInit_GL_ARB_draw_buffers (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC)glewGetProcAddress((const GLubyte*)"glDrawBuffersARB")) == NULL) || r; return r; } #endif /* GL_ARB_draw_buffers */ #ifdef GL_ARB_draw_buffers_blend static GLboolean _glewInit_GL_ARB_draw_buffers_blend (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBlendEquationSeparateiARB = (PFNGLBLENDEQUATIONSEPARATEIARBPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationSeparateiARB")) == NULL) || r; r = ((glBlendEquationiARB = (PFNGLBLENDEQUATIONIARBPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationiARB")) == NULL) || r; r = ((glBlendFuncSeparateiARB = (PFNGLBLENDFUNCSEPARATEIARBPROC)glewGetProcAddress((const GLubyte*)"glBlendFuncSeparateiARB")) == NULL) || r; r = ((glBlendFunciARB = (PFNGLBLENDFUNCIARBPROC)glewGetProcAddress((const GLubyte*)"glBlendFunciARB")) == NULL) || r; return r; } #endif /* GL_ARB_draw_buffers_blend */ #ifdef GL_ARB_draw_elements_base_vertex static GLboolean _glewInit_GL_ARB_draw_elements_base_vertex (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsBaseVertex")) == NULL) || r; r = ((glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsInstancedBaseVertex")) == NULL) || r; r = ((glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)glewGetProcAddress((const GLubyte*)"glDrawRangeElementsBaseVertex")) == NULL) || r; r = ((glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElementsBaseVertex")) == NULL) || r; return r; } #endif /* GL_ARB_draw_elements_base_vertex */ #ifdef GL_ARB_draw_indirect static GLboolean _glewInit_GL_ARB_draw_indirect (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysIndirect")) == NULL) || r; r = ((glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsIndirect")) == NULL) || r; return r; } #endif /* GL_ARB_draw_indirect */ #ifdef GL_ARB_framebuffer_no_attachments static GLboolean _glewInit_GL_ARB_framebuffer_no_attachments (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFramebufferParameteri = (PFNGLFRAMEBUFFERPARAMETERIPROC)glewGetProcAddress((const GLubyte*)"glFramebufferParameteri")) == NULL) || r; r = ((glGetFramebufferParameteriv = (PFNGLGETFRAMEBUFFERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetFramebufferParameteriv")) == NULL) || r; r = ((glGetNamedFramebufferParameterivEXT = (PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedFramebufferParameterivEXT")) == NULL) || r; r = ((glNamedFramebufferParameteriEXT = (PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferParameteriEXT")) == NULL) || r; return r; } #endif /* GL_ARB_framebuffer_no_attachments */ #ifdef GL_ARB_framebuffer_object static GLboolean _glewInit_GL_ARB_framebuffer_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)"glBindFramebuffer")) == NULL) || r; r = ((glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)"glBindRenderbuffer")) == NULL) || r; r = ((glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)"glBlitFramebuffer")) == NULL) || r; r = ((glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)glewGetProcAddress((const GLubyte*)"glCheckFramebufferStatus")) == NULL) || r; r = ((glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteFramebuffers")) == NULL) || r; r = ((glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteRenderbuffers")) == NULL) || r; r = ((glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferRenderbuffer")) == NULL) || r; r = ((glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture1D")) == NULL) || r; r = ((glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture2D")) == NULL) || r; r = ((glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture3D")) == NULL) || r; r = ((glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureLayer")) == NULL) || r; r = ((glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glGenFramebuffers")) == NULL) || r; r = ((glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glGenRenderbuffers")) == NULL) || r; r = ((glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)glewGetProcAddress((const GLubyte*)"glGenerateMipmap")) == NULL) || r; r = ((glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetFramebufferAttachmentParameteriv")) == NULL) || r; r = ((glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetRenderbufferParameteriv")) == NULL) || r; r = ((glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)"glIsFramebuffer")) == NULL) || r; r = ((glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)"glIsRenderbuffer")) == NULL) || r; r = ((glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorage")) == NULL) || r; r = ((glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorageMultisample")) == NULL) || r; return r; } #endif /* GL_ARB_framebuffer_object */ #ifdef GL_ARB_geometry_shader4 static GLboolean _glewInit_GL_ARB_geometry_shader4 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFramebufferTextureARB = (PFNGLFRAMEBUFFERTEXTUREARBPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureARB")) == NULL) || r; r = ((glFramebufferTextureFaceARB = (PFNGLFRAMEBUFFERTEXTUREFACEARBPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureFaceARB")) == NULL) || r; r = ((glFramebufferTextureLayerARB = (PFNGLFRAMEBUFFERTEXTURELAYERARBPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureLayerARB")) == NULL) || r; r = ((glProgramParameteriARB = (PFNGLPROGRAMPARAMETERIARBPROC)glewGetProcAddress((const GLubyte*)"glProgramParameteriARB")) == NULL) || r; return r; } #endif /* GL_ARB_geometry_shader4 */ #ifdef GL_ARB_get_program_binary static GLboolean _glewInit_GL_ARB_get_program_binary (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetProgramBinary = (PFNGLGETPROGRAMBINARYPROC)glewGetProcAddress((const GLubyte*)"glGetProgramBinary")) == NULL) || r; r = ((glProgramBinary = (PFNGLPROGRAMBINARYPROC)glewGetProcAddress((const GLubyte*)"glProgramBinary")) == NULL) || r; r = ((glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC)glewGetProcAddress((const GLubyte*)"glProgramParameteri")) == NULL) || r; return r; } #endif /* GL_ARB_get_program_binary */ #ifdef GL_ARB_get_texture_sub_image static GLboolean _glewInit_GL_ARB_get_texture_sub_image (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetCompressedTextureSubImage = (PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedTextureSubImage")) == NULL) || r; r = ((glGetTextureSubImage = (PFNGLGETTEXTURESUBIMAGEPROC)glewGetProcAddress((const GLubyte*)"glGetTextureSubImage")) == NULL) || r; return r; } #endif /* GL_ARB_get_texture_sub_image */ #ifdef GL_ARB_gpu_shader_fp64 static GLboolean _glewInit_GL_ARB_gpu_shader_fp64 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetUniformdv = (PFNGLGETUNIFORMDVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformdv")) == NULL) || r; r = ((glUniform1d = (PFNGLUNIFORM1DPROC)glewGetProcAddress((const GLubyte*)"glUniform1d")) == NULL) || r; r = ((glUniform1dv = (PFNGLUNIFORM1DVPROC)glewGetProcAddress((const GLubyte*)"glUniform1dv")) == NULL) || r; r = ((glUniform2d = (PFNGLUNIFORM2DPROC)glewGetProcAddress((const GLubyte*)"glUniform2d")) == NULL) || r; r = ((glUniform2dv = (PFNGLUNIFORM2DVPROC)glewGetProcAddress((const GLubyte*)"glUniform2dv")) == NULL) || r; r = ((glUniform3d = (PFNGLUNIFORM3DPROC)glewGetProcAddress((const GLubyte*)"glUniform3d")) == NULL) || r; r = ((glUniform3dv = (PFNGLUNIFORM3DVPROC)glewGetProcAddress((const GLubyte*)"glUniform3dv")) == NULL) || r; r = ((glUniform4d = (PFNGLUNIFORM4DPROC)glewGetProcAddress((const GLubyte*)"glUniform4d")) == NULL) || r; r = ((glUniform4dv = (PFNGLUNIFORM4DVPROC)glewGetProcAddress((const GLubyte*)"glUniform4dv")) == NULL) || r; r = ((glUniformMatrix2dv = (PFNGLUNIFORMMATRIX2DVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2dv")) == NULL) || r; r = ((glUniformMatrix2x3dv = (PFNGLUNIFORMMATRIX2X3DVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2x3dv")) == NULL) || r; r = ((glUniformMatrix2x4dv = (PFNGLUNIFORMMATRIX2X4DVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2x4dv")) == NULL) || r; r = ((glUniformMatrix3dv = (PFNGLUNIFORMMATRIX3DVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3dv")) == NULL) || r; r = ((glUniformMatrix3x2dv = (PFNGLUNIFORMMATRIX3X2DVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3x2dv")) == NULL) || r; r = ((glUniformMatrix3x4dv = (PFNGLUNIFORMMATRIX3X4DVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3x4dv")) == NULL) || r; r = ((glUniformMatrix4dv = (PFNGLUNIFORMMATRIX4DVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4dv")) == NULL) || r; r = ((glUniformMatrix4x2dv = (PFNGLUNIFORMMATRIX4X2DVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4x2dv")) == NULL) || r; r = ((glUniformMatrix4x3dv = (PFNGLUNIFORMMATRIX4X3DVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4x3dv")) == NULL) || r; return r; } #endif /* GL_ARB_gpu_shader_fp64 */ #ifdef GL_ARB_gpu_shader_int64 static GLboolean _glewInit_GL_ARB_gpu_shader_int64 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetUniformi64vARB = (PFNGLGETUNIFORMI64VARBPROC)glewGetProcAddress((const GLubyte*)"glGetUniformi64vARB")) == NULL) || r; r = ((glGetUniformui64vARB = (PFNGLGETUNIFORMUI64VARBPROC)glewGetProcAddress((const GLubyte*)"glGetUniformui64vARB")) == NULL) || r; r = ((glGetnUniformi64vARB = (PFNGLGETNUNIFORMI64VARBPROC)glewGetProcAddress((const GLubyte*)"glGetnUniformi64vARB")) == NULL) || r; r = ((glGetnUniformui64vARB = (PFNGLGETNUNIFORMUI64VARBPROC)glewGetProcAddress((const GLubyte*)"glGetnUniformui64vARB")) == NULL) || r; r = ((glProgramUniform1i64ARB = (PFNGLPROGRAMUNIFORM1I64ARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1i64ARB")) == NULL) || r; r = ((glProgramUniform1i64vARB = (PFNGLPROGRAMUNIFORM1I64VARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1i64vARB")) == NULL) || r; r = ((glProgramUniform1ui64ARB = (PFNGLPROGRAMUNIFORM1UI64ARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1ui64ARB")) == NULL) || r; r = ((glProgramUniform1ui64vARB = (PFNGLPROGRAMUNIFORM1UI64VARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1ui64vARB")) == NULL) || r; r = ((glProgramUniform2i64ARB = (PFNGLPROGRAMUNIFORM2I64ARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2i64ARB")) == NULL) || r; r = ((glProgramUniform2i64vARB = (PFNGLPROGRAMUNIFORM2I64VARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2i64vARB")) == NULL) || r; r = ((glProgramUniform2ui64ARB = (PFNGLPROGRAMUNIFORM2UI64ARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2ui64ARB")) == NULL) || r; r = ((glProgramUniform2ui64vARB = (PFNGLPROGRAMUNIFORM2UI64VARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2ui64vARB")) == NULL) || r; r = ((glProgramUniform3i64ARB = (PFNGLPROGRAMUNIFORM3I64ARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3i64ARB")) == NULL) || r; r = ((glProgramUniform3i64vARB = (PFNGLPROGRAMUNIFORM3I64VARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3i64vARB")) == NULL) || r; r = ((glProgramUniform3ui64ARB = (PFNGLPROGRAMUNIFORM3UI64ARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3ui64ARB")) == NULL) || r; r = ((glProgramUniform3ui64vARB = (PFNGLPROGRAMUNIFORM3UI64VARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3ui64vARB")) == NULL) || r; r = ((glProgramUniform4i64ARB = (PFNGLPROGRAMUNIFORM4I64ARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4i64ARB")) == NULL) || r; r = ((glProgramUniform4i64vARB = (PFNGLPROGRAMUNIFORM4I64VARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4i64vARB")) == NULL) || r; r = ((glProgramUniform4ui64ARB = (PFNGLPROGRAMUNIFORM4UI64ARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4ui64ARB")) == NULL) || r; r = ((glProgramUniform4ui64vARB = (PFNGLPROGRAMUNIFORM4UI64VARBPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4ui64vARB")) == NULL) || r; r = ((glUniform1i64ARB = (PFNGLUNIFORM1I64ARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1i64ARB")) == NULL) || r; r = ((glUniform1i64vARB = (PFNGLUNIFORM1I64VARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1i64vARB")) == NULL) || r; r = ((glUniform1ui64ARB = (PFNGLUNIFORM1UI64ARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1ui64ARB")) == NULL) || r; r = ((glUniform1ui64vARB = (PFNGLUNIFORM1UI64VARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1ui64vARB")) == NULL) || r; r = ((glUniform2i64ARB = (PFNGLUNIFORM2I64ARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2i64ARB")) == NULL) || r; r = ((glUniform2i64vARB = (PFNGLUNIFORM2I64VARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2i64vARB")) == NULL) || r; r = ((glUniform2ui64ARB = (PFNGLUNIFORM2UI64ARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2ui64ARB")) == NULL) || r; r = ((glUniform2ui64vARB = (PFNGLUNIFORM2UI64VARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2ui64vARB")) == NULL) || r; r = ((glUniform3i64ARB = (PFNGLUNIFORM3I64ARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3i64ARB")) == NULL) || r; r = ((glUniform3i64vARB = (PFNGLUNIFORM3I64VARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3i64vARB")) == NULL) || r; r = ((glUniform3ui64ARB = (PFNGLUNIFORM3UI64ARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3ui64ARB")) == NULL) || r; r = ((glUniform3ui64vARB = (PFNGLUNIFORM3UI64VARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3ui64vARB")) == NULL) || r; r = ((glUniform4i64ARB = (PFNGLUNIFORM4I64ARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4i64ARB")) == NULL) || r; r = ((glUniform4i64vARB = (PFNGLUNIFORM4I64VARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4i64vARB")) == NULL) || r; r = ((glUniform4ui64ARB = (PFNGLUNIFORM4UI64ARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4ui64ARB")) == NULL) || r; r = ((glUniform4ui64vARB = (PFNGLUNIFORM4UI64VARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4ui64vARB")) == NULL) || r; return r; } #endif /* GL_ARB_gpu_shader_int64 */ #ifdef GL_ARB_imaging static GLboolean _glewInit_GL_ARB_imaging (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBlendEquation = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)"glBlendEquation")) == NULL) || r; r = ((glColorSubTable = (PFNGLCOLORSUBTABLEPROC)glewGetProcAddress((const GLubyte*)"glColorSubTable")) == NULL) || r; r = ((glColorTable = (PFNGLCOLORTABLEPROC)glewGetProcAddress((const GLubyte*)"glColorTable")) == NULL) || r; r = ((glColorTableParameterfv = (PFNGLCOLORTABLEPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glColorTableParameterfv")) == NULL) || r; r = ((glColorTableParameteriv = (PFNGLCOLORTABLEPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glColorTableParameteriv")) == NULL) || r; r = ((glConvolutionFilter1D = (PFNGLCONVOLUTIONFILTER1DPROC)glewGetProcAddress((const GLubyte*)"glConvolutionFilter1D")) == NULL) || r; r = ((glConvolutionFilter2D = (PFNGLCONVOLUTIONFILTER2DPROC)glewGetProcAddress((const GLubyte*)"glConvolutionFilter2D")) == NULL) || r; r = ((glConvolutionParameterf = (PFNGLCONVOLUTIONPARAMETERFPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterf")) == NULL) || r; r = ((glConvolutionParameterfv = (PFNGLCONVOLUTIONPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterfv")) == NULL) || r; r = ((glConvolutionParameteri = (PFNGLCONVOLUTIONPARAMETERIPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameteri")) == NULL) || r; r = ((glConvolutionParameteriv = (PFNGLCONVOLUTIONPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameteriv")) == NULL) || r; r = ((glCopyColorSubTable = (PFNGLCOPYCOLORSUBTABLEPROC)glewGetProcAddress((const GLubyte*)"glCopyColorSubTable")) == NULL) || r; r = ((glCopyColorTable = (PFNGLCOPYCOLORTABLEPROC)glewGetProcAddress((const GLubyte*)"glCopyColorTable")) == NULL) || r; r = ((glCopyConvolutionFilter1D = (PFNGLCOPYCONVOLUTIONFILTER1DPROC)glewGetProcAddress((const GLubyte*)"glCopyConvolutionFilter1D")) == NULL) || r; r = ((glCopyConvolutionFilter2D = (PFNGLCOPYCONVOLUTIONFILTER2DPROC)glewGetProcAddress((const GLubyte*)"glCopyConvolutionFilter2D")) == NULL) || r; r = ((glGetColorTable = (PFNGLGETCOLORTABLEPROC)glewGetProcAddress((const GLubyte*)"glGetColorTable")) == NULL) || r; r = ((glGetColorTableParameterfv = (PFNGLGETCOLORTABLEPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterfv")) == NULL) || r; r = ((glGetColorTableParameteriv = (PFNGLGETCOLORTABLEPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameteriv")) == NULL) || r; r = ((glGetConvolutionFilter = (PFNGLGETCONVOLUTIONFILTERPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionFilter")) == NULL) || r; r = ((glGetConvolutionParameterfv = (PFNGLGETCONVOLUTIONPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionParameterfv")) == NULL) || r; r = ((glGetConvolutionParameteriv = (PFNGLGETCONVOLUTIONPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionParameteriv")) == NULL) || r; r = ((glGetHistogram = (PFNGLGETHISTOGRAMPROC)glewGetProcAddress((const GLubyte*)"glGetHistogram")) == NULL) || r; r = ((glGetHistogramParameterfv = (PFNGLGETHISTOGRAMPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramParameterfv")) == NULL) || r; r = ((glGetHistogramParameteriv = (PFNGLGETHISTOGRAMPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramParameteriv")) == NULL) || r; r = ((glGetMinmax = (PFNGLGETMINMAXPROC)glewGetProcAddress((const GLubyte*)"glGetMinmax")) == NULL) || r; r = ((glGetMinmaxParameterfv = (PFNGLGETMINMAXPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxParameterfv")) == NULL) || r; r = ((glGetMinmaxParameteriv = (PFNGLGETMINMAXPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxParameteriv")) == NULL) || r; r = ((glGetSeparableFilter = (PFNGLGETSEPARABLEFILTERPROC)glewGetProcAddress((const GLubyte*)"glGetSeparableFilter")) == NULL) || r; r = ((glHistogram = (PFNGLHISTOGRAMPROC)glewGetProcAddress((const GLubyte*)"glHistogram")) == NULL) || r; r = ((glMinmax = (PFNGLMINMAXPROC)glewGetProcAddress((const GLubyte*)"glMinmax")) == NULL) || r; r = ((glResetHistogram = (PFNGLRESETHISTOGRAMPROC)glewGetProcAddress((const GLubyte*)"glResetHistogram")) == NULL) || r; r = ((glResetMinmax = (PFNGLRESETMINMAXPROC)glewGetProcAddress((const GLubyte*)"glResetMinmax")) == NULL) || r; r = ((glSeparableFilter2D = (PFNGLSEPARABLEFILTER2DPROC)glewGetProcAddress((const GLubyte*)"glSeparableFilter2D")) == NULL) || r; return r; } #endif /* GL_ARB_imaging */ #ifdef GL_ARB_indirect_parameters static GLboolean _glewInit_GL_ARB_indirect_parameters (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glMultiDrawArraysIndirectCountARB = (PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawArraysIndirectCountARB")) == NULL) || r; r = ((glMultiDrawElementsIndirectCountARB = (PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElementsIndirectCountARB")) == NULL) || r; return r; } #endif /* GL_ARB_indirect_parameters */ #ifdef GL_ARB_instanced_arrays static GLboolean _glewInit_GL_ARB_instanced_arrays (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDrawArraysInstancedARB = (PFNGLDRAWARRAYSINSTANCEDARBPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysInstancedARB")) == NULL) || r; r = ((glDrawElementsInstancedARB = (PFNGLDRAWELEMENTSINSTANCEDARBPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsInstancedARB")) == NULL) || r; r = ((glVertexAttribDivisorARB = (PFNGLVERTEXATTRIBDIVISORARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribDivisorARB")) == NULL) || r; return r; } #endif /* GL_ARB_instanced_arrays */ #ifdef GL_ARB_internalformat_query static GLboolean _glewInit_GL_ARB_internalformat_query (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetInternalformativ = (PFNGLGETINTERNALFORMATIVPROC)glewGetProcAddress((const GLubyte*)"glGetInternalformativ")) == NULL) || r; return r; } #endif /* GL_ARB_internalformat_query */ #ifdef GL_ARB_internalformat_query2 static GLboolean _glewInit_GL_ARB_internalformat_query2 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetInternalformati64v = (PFNGLGETINTERNALFORMATI64VPROC)glewGetProcAddress((const GLubyte*)"glGetInternalformati64v")) == NULL) || r; return r; } #endif /* GL_ARB_internalformat_query2 */ #ifdef GL_ARB_invalidate_subdata static GLboolean _glewInit_GL_ARB_invalidate_subdata (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glInvalidateBufferData = (PFNGLINVALIDATEBUFFERDATAPROC)glewGetProcAddress((const GLubyte*)"glInvalidateBufferData")) == NULL) || r; r = ((glInvalidateBufferSubData = (PFNGLINVALIDATEBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glInvalidateBufferSubData")) == NULL) || r; r = ((glInvalidateFramebuffer = (PFNGLINVALIDATEFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)"glInvalidateFramebuffer")) == NULL) || r; r = ((glInvalidateSubFramebuffer = (PFNGLINVALIDATESUBFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)"glInvalidateSubFramebuffer")) == NULL) || r; r = ((glInvalidateTexImage = (PFNGLINVALIDATETEXIMAGEPROC)glewGetProcAddress((const GLubyte*)"glInvalidateTexImage")) == NULL) || r; r = ((glInvalidateTexSubImage = (PFNGLINVALIDATETEXSUBIMAGEPROC)glewGetProcAddress((const GLubyte*)"glInvalidateTexSubImage")) == NULL) || r; return r; } #endif /* GL_ARB_invalidate_subdata */ #ifdef GL_ARB_map_buffer_range static GLboolean _glewInit_GL_ARB_map_buffer_range (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glFlushMappedBufferRange")) == NULL) || r; r = ((glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glMapBufferRange")) == NULL) || r; return r; } #endif /* GL_ARB_map_buffer_range */ #ifdef GL_ARB_matrix_palette static GLboolean _glewInit_GL_ARB_matrix_palette (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glCurrentPaletteMatrixARB = (PFNGLCURRENTPALETTEMATRIXARBPROC)glewGetProcAddress((const GLubyte*)"glCurrentPaletteMatrixARB")) == NULL) || r; r = ((glMatrixIndexPointerARB = (PFNGLMATRIXINDEXPOINTERARBPROC)glewGetProcAddress((const GLubyte*)"glMatrixIndexPointerARB")) == NULL) || r; r = ((glMatrixIndexubvARB = (PFNGLMATRIXINDEXUBVARBPROC)glewGetProcAddress((const GLubyte*)"glMatrixIndexubvARB")) == NULL) || r; r = ((glMatrixIndexuivARB = (PFNGLMATRIXINDEXUIVARBPROC)glewGetProcAddress((const GLubyte*)"glMatrixIndexuivARB")) == NULL) || r; r = ((glMatrixIndexusvARB = (PFNGLMATRIXINDEXUSVARBPROC)glewGetProcAddress((const GLubyte*)"glMatrixIndexusvARB")) == NULL) || r; return r; } #endif /* GL_ARB_matrix_palette */ #ifdef GL_ARB_multi_bind static GLboolean _glewInit_GL_ARB_multi_bind (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindBuffersBase = (PFNGLBINDBUFFERSBASEPROC)glewGetProcAddress((const GLubyte*)"glBindBuffersBase")) == NULL) || r; r = ((glBindBuffersRange = (PFNGLBINDBUFFERSRANGEPROC)glewGetProcAddress((const GLubyte*)"glBindBuffersRange")) == NULL) || r; r = ((glBindImageTextures = (PFNGLBINDIMAGETEXTURESPROC)glewGetProcAddress((const GLubyte*)"glBindImageTextures")) == NULL) || r; r = ((glBindSamplers = (PFNGLBINDSAMPLERSPROC)glewGetProcAddress((const GLubyte*)"glBindSamplers")) == NULL) || r; r = ((glBindTextures = (PFNGLBINDTEXTURESPROC)glewGetProcAddress((const GLubyte*)"glBindTextures")) == NULL) || r; r = ((glBindVertexBuffers = (PFNGLBINDVERTEXBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glBindVertexBuffers")) == NULL) || r; return r; } #endif /* GL_ARB_multi_bind */ #ifdef GL_ARB_multi_draw_indirect static GLboolean _glewInit_GL_ARB_multi_draw_indirect (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glMultiDrawArraysIndirect = (PFNGLMULTIDRAWARRAYSINDIRECTPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawArraysIndirect")) == NULL) || r; r = ((glMultiDrawElementsIndirect = (PFNGLMULTIDRAWELEMENTSINDIRECTPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElementsIndirect")) == NULL) || r; return r; } #endif /* GL_ARB_multi_draw_indirect */ #ifdef GL_ARB_multisample static GLboolean _glewInit_GL_ARB_multisample (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glSampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC)glewGetProcAddress((const GLubyte*)"glSampleCoverageARB")) == NULL) || r; return r; } #endif /* GL_ARB_multisample */ #ifdef GL_ARB_multitexture static GLboolean _glewInit_GL_ARB_multitexture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)glewGetProcAddress((const GLubyte*)"glActiveTextureARB")) == NULL) || r; r = ((glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)glewGetProcAddress((const GLubyte*)"glClientActiveTextureARB")) == NULL) || r; r = ((glMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1dARB")) == NULL) || r; r = ((glMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1dvARB")) == NULL) || r; r = ((glMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1fARB")) == NULL) || r; r = ((glMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1fvARB")) == NULL) || r; r = ((glMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1iARB")) == NULL) || r; r = ((glMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1ivARB")) == NULL) || r; r = ((glMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1sARB")) == NULL) || r; r = ((glMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1svARB")) == NULL) || r; r = ((glMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2dARB")) == NULL) || r; r = ((glMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2dvARB")) == NULL) || r; r = ((glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2fARB")) == NULL) || r; r = ((glMultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2fvARB")) == NULL) || r; r = ((glMultiTexCoord2iARB = (PFNGLMULTITEXCOORD2IARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2iARB")) == NULL) || r; r = ((glMultiTexCoord2ivARB = (PFNGLMULTITEXCOORD2IVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2ivARB")) == NULL) || r; r = ((glMultiTexCoord2sARB = (PFNGLMULTITEXCOORD2SARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2sARB")) == NULL) || r; r = ((glMultiTexCoord2svARB = (PFNGLMULTITEXCOORD2SVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2svARB")) == NULL) || r; r = ((glMultiTexCoord3dARB = (PFNGLMULTITEXCOORD3DARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3dARB")) == NULL) || r; r = ((glMultiTexCoord3dvARB = (PFNGLMULTITEXCOORD3DVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3dvARB")) == NULL) || r; r = ((glMultiTexCoord3fARB = (PFNGLMULTITEXCOORD3FARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3fARB")) == NULL) || r; r = ((glMultiTexCoord3fvARB = (PFNGLMULTITEXCOORD3FVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3fvARB")) == NULL) || r; r = ((glMultiTexCoord3iARB = (PFNGLMULTITEXCOORD3IARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3iARB")) == NULL) || r; r = ((glMultiTexCoord3ivARB = (PFNGLMULTITEXCOORD3IVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3ivARB")) == NULL) || r; r = ((glMultiTexCoord3sARB = (PFNGLMULTITEXCOORD3SARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3sARB")) == NULL) || r; r = ((glMultiTexCoord3svARB = (PFNGLMULTITEXCOORD3SVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3svARB")) == NULL) || r; r = ((glMultiTexCoord4dARB = (PFNGLMULTITEXCOORD4DARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4dARB")) == NULL) || r; r = ((glMultiTexCoord4dvARB = (PFNGLMULTITEXCOORD4DVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4dvARB")) == NULL) || r; r = ((glMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4fARB")) == NULL) || r; r = ((glMultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4fvARB")) == NULL) || r; r = ((glMultiTexCoord4iARB = (PFNGLMULTITEXCOORD4IARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4iARB")) == NULL) || r; r = ((glMultiTexCoord4ivARB = (PFNGLMULTITEXCOORD4IVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4ivARB")) == NULL) || r; r = ((glMultiTexCoord4sARB = (PFNGLMULTITEXCOORD4SARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4sARB")) == NULL) || r; r = ((glMultiTexCoord4svARB = (PFNGLMULTITEXCOORD4SVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4svARB")) == NULL) || r; return r; } #endif /* GL_ARB_multitexture */ #ifdef GL_ARB_occlusion_query static GLboolean _glewInit_GL_ARB_occlusion_query (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBeginQueryARB = (PFNGLBEGINQUERYARBPROC)glewGetProcAddress((const GLubyte*)"glBeginQueryARB")) == NULL) || r; r = ((glDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC)glewGetProcAddress((const GLubyte*)"glDeleteQueriesARB")) == NULL) || r; r = ((glEndQueryARB = (PFNGLENDQUERYARBPROC)glewGetProcAddress((const GLubyte*)"glEndQueryARB")) == NULL) || r; r = ((glGenQueriesARB = (PFNGLGENQUERIESARBPROC)glewGetProcAddress((const GLubyte*)"glGenQueriesARB")) == NULL) || r; r = ((glGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectivARB")) == NULL) || r; r = ((glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectuivARB")) == NULL) || r; r = ((glGetQueryivARB = (PFNGLGETQUERYIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetQueryivARB")) == NULL) || r; r = ((glIsQueryARB = (PFNGLISQUERYARBPROC)glewGetProcAddress((const GLubyte*)"glIsQueryARB")) == NULL) || r; return r; } #endif /* GL_ARB_occlusion_query */ #ifdef GL_ARB_parallel_shader_compile static GLboolean _glewInit_GL_ARB_parallel_shader_compile (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glMaxShaderCompilerThreadsARB = (PFNGLMAXSHADERCOMPILERTHREADSARBPROC)glewGetProcAddress((const GLubyte*)"glMaxShaderCompilerThreadsARB")) == NULL) || r; return r; } #endif /* GL_ARB_parallel_shader_compile */ #ifdef GL_ARB_point_parameters static GLboolean _glewInit_GL_ARB_point_parameters (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfARB")) == NULL) || r; r = ((glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfvARB")) == NULL) || r; return r; } #endif /* GL_ARB_point_parameters */ #ifdef GL_ARB_program_interface_query static GLboolean _glewInit_GL_ARB_program_interface_query (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetProgramInterfaceiv = (PFNGLGETPROGRAMINTERFACEIVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramInterfaceiv")) == NULL) || r; r = ((glGetProgramResourceIndex = (PFNGLGETPROGRAMRESOURCEINDEXPROC)glewGetProcAddress((const GLubyte*)"glGetProgramResourceIndex")) == NULL) || r; r = ((glGetProgramResourceLocation = (PFNGLGETPROGRAMRESOURCELOCATIONPROC)glewGetProcAddress((const GLubyte*)"glGetProgramResourceLocation")) == NULL) || r; r = ((glGetProgramResourceLocationIndex = (PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC)glewGetProcAddress((const GLubyte*)"glGetProgramResourceLocationIndex")) == NULL) || r; r = ((glGetProgramResourceName = (PFNGLGETPROGRAMRESOURCENAMEPROC)glewGetProcAddress((const GLubyte*)"glGetProgramResourceName")) == NULL) || r; r = ((glGetProgramResourceiv = (PFNGLGETPROGRAMRESOURCEIVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramResourceiv")) == NULL) || r; return r; } #endif /* GL_ARB_program_interface_query */ #ifdef GL_ARB_provoking_vertex static GLboolean _glewInit_GL_ARB_provoking_vertex (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC)glewGetProcAddress((const GLubyte*)"glProvokingVertex")) == NULL) || r; return r; } #endif /* GL_ARB_provoking_vertex */ #ifdef GL_ARB_robustness static GLboolean _glewInit_GL_ARB_robustness (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetGraphicsResetStatusARB = (PFNGLGETGRAPHICSRESETSTATUSARBPROC)glewGetProcAddress((const GLubyte*)"glGetGraphicsResetStatusARB")) == NULL) || r; r = ((glGetnColorTableARB = (PFNGLGETNCOLORTABLEARBPROC)glewGetProcAddress((const GLubyte*)"glGetnColorTableARB")) == NULL) || r; r = ((glGetnCompressedTexImageARB = (PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)"glGetnCompressedTexImageARB")) == NULL) || r; r = ((glGetnConvolutionFilterARB = (PFNGLGETNCONVOLUTIONFILTERARBPROC)glewGetProcAddress((const GLubyte*)"glGetnConvolutionFilterARB")) == NULL) || r; r = ((glGetnHistogramARB = (PFNGLGETNHISTOGRAMARBPROC)glewGetProcAddress((const GLubyte*)"glGetnHistogramARB")) == NULL) || r; r = ((glGetnMapdvARB = (PFNGLGETNMAPDVARBPROC)glewGetProcAddress((const GLubyte*)"glGetnMapdvARB")) == NULL) || r; r = ((glGetnMapfvARB = (PFNGLGETNMAPFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetnMapfvARB")) == NULL) || r; r = ((glGetnMapivARB = (PFNGLGETNMAPIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetnMapivARB")) == NULL) || r; r = ((glGetnMinmaxARB = (PFNGLGETNMINMAXARBPROC)glewGetProcAddress((const GLubyte*)"glGetnMinmaxARB")) == NULL) || r; r = ((glGetnPixelMapfvARB = (PFNGLGETNPIXELMAPFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetnPixelMapfvARB")) == NULL) || r; r = ((glGetnPixelMapuivARB = (PFNGLGETNPIXELMAPUIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetnPixelMapuivARB")) == NULL) || r; r = ((glGetnPixelMapusvARB = (PFNGLGETNPIXELMAPUSVARBPROC)glewGetProcAddress((const GLubyte*)"glGetnPixelMapusvARB")) == NULL) || r; r = ((glGetnPolygonStippleARB = (PFNGLGETNPOLYGONSTIPPLEARBPROC)glewGetProcAddress((const GLubyte*)"glGetnPolygonStippleARB")) == NULL) || r; r = ((glGetnSeparableFilterARB = (PFNGLGETNSEPARABLEFILTERARBPROC)glewGetProcAddress((const GLubyte*)"glGetnSeparableFilterARB")) == NULL) || r; r = ((glGetnTexImageARB = (PFNGLGETNTEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)"glGetnTexImageARB")) == NULL) || r; r = ((glGetnUniformdvARB = (PFNGLGETNUNIFORMDVARBPROC)glewGetProcAddress((const GLubyte*)"glGetnUniformdvARB")) == NULL) || r; r = ((glGetnUniformfvARB = (PFNGLGETNUNIFORMFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetnUniformfvARB")) == NULL) || r; r = ((glGetnUniformivARB = (PFNGLGETNUNIFORMIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetnUniformivARB")) == NULL) || r; r = ((glGetnUniformuivARB = (PFNGLGETNUNIFORMUIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetnUniformuivARB")) == NULL) || r; r = ((glReadnPixelsARB = (PFNGLREADNPIXELSARBPROC)glewGetProcAddress((const GLubyte*)"glReadnPixelsARB")) == NULL) || r; return r; } #endif /* GL_ARB_robustness */ #ifdef GL_ARB_sample_locations static GLboolean _glewInit_GL_ARB_sample_locations (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFramebufferSampleLocationsfvARB = (PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC)glewGetProcAddress((const GLubyte*)"glFramebufferSampleLocationsfvARB")) == NULL) || r; r = ((glNamedFramebufferSampleLocationsfvARB = (PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferSampleLocationsfvARB")) == NULL) || r; return r; } #endif /* GL_ARB_sample_locations */ #ifdef GL_ARB_sample_shading static GLboolean _glewInit_GL_ARB_sample_shading (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glMinSampleShadingARB = (PFNGLMINSAMPLESHADINGARBPROC)glewGetProcAddress((const GLubyte*)"glMinSampleShadingARB")) == NULL) || r; return r; } #endif /* GL_ARB_sample_shading */ #ifdef GL_ARB_sampler_objects static GLboolean _glewInit_GL_ARB_sampler_objects (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindSampler = (PFNGLBINDSAMPLERPROC)glewGetProcAddress((const GLubyte*)"glBindSampler")) == NULL) || r; r = ((glDeleteSamplers = (PFNGLDELETESAMPLERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteSamplers")) == NULL) || r; r = ((glGenSamplers = (PFNGLGENSAMPLERSPROC)glewGetProcAddress((const GLubyte*)"glGenSamplers")) == NULL) || r; r = ((glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)"glGetSamplerParameterIiv")) == NULL) || r; r = ((glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)"glGetSamplerParameterIuiv")) == NULL) || r; r = ((glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetSamplerParameterfv")) == NULL) || r; r = ((glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetSamplerParameteriv")) == NULL) || r; r = ((glIsSampler = (PFNGLISSAMPLERPROC)glewGetProcAddress((const GLubyte*)"glIsSampler")) == NULL) || r; r = ((glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)"glSamplerParameterIiv")) == NULL) || r; r = ((glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)"glSamplerParameterIuiv")) == NULL) || r; r = ((glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC)glewGetProcAddress((const GLubyte*)"glSamplerParameterf")) == NULL) || r; r = ((glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glSamplerParameterfv")) == NULL) || r; r = ((glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC)glewGetProcAddress((const GLubyte*)"glSamplerParameteri")) == NULL) || r; r = ((glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glSamplerParameteriv")) == NULL) || r; return r; } #endif /* GL_ARB_sampler_objects */ #ifdef GL_ARB_separate_shader_objects static GLboolean _glewInit_GL_ARB_separate_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glActiveShaderProgram = (PFNGLACTIVESHADERPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glActiveShaderProgram")) == NULL) || r; r = ((glBindProgramPipeline = (PFNGLBINDPROGRAMPIPELINEPROC)glewGetProcAddress((const GLubyte*)"glBindProgramPipeline")) == NULL) || r; r = ((glCreateShaderProgramv = (PFNGLCREATESHADERPROGRAMVPROC)glewGetProcAddress((const GLubyte*)"glCreateShaderProgramv")) == NULL) || r; r = ((glDeleteProgramPipelines = (PFNGLDELETEPROGRAMPIPELINESPROC)glewGetProcAddress((const GLubyte*)"glDeleteProgramPipelines")) == NULL) || r; r = ((glGenProgramPipelines = (PFNGLGENPROGRAMPIPELINESPROC)glewGetProcAddress((const GLubyte*)"glGenProgramPipelines")) == NULL) || r; r = ((glGetProgramPipelineInfoLog = (PFNGLGETPROGRAMPIPELINEINFOLOGPROC)glewGetProcAddress((const GLubyte*)"glGetProgramPipelineInfoLog")) == NULL) || r; r = ((glGetProgramPipelineiv = (PFNGLGETPROGRAMPIPELINEIVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramPipelineiv")) == NULL) || r; r = ((glIsProgramPipeline = (PFNGLISPROGRAMPIPELINEPROC)glewGetProcAddress((const GLubyte*)"glIsProgramPipeline")) == NULL) || r; r = ((glProgramUniform1d = (PFNGLPROGRAMUNIFORM1DPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1d")) == NULL) || r; r = ((glProgramUniform1dv = (PFNGLPROGRAMUNIFORM1DVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1dv")) == NULL) || r; r = ((glProgramUniform1f = (PFNGLPROGRAMUNIFORM1FPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1f")) == NULL) || r; r = ((glProgramUniform1fv = (PFNGLPROGRAMUNIFORM1FVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1fv")) == NULL) || r; r = ((glProgramUniform1i = (PFNGLPROGRAMUNIFORM1IPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1i")) == NULL) || r; r = ((glProgramUniform1iv = (PFNGLPROGRAMUNIFORM1IVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1iv")) == NULL) || r; r = ((glProgramUniform1ui = (PFNGLPROGRAMUNIFORM1UIPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1ui")) == NULL) || r; r = ((glProgramUniform1uiv = (PFNGLPROGRAMUNIFORM1UIVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1uiv")) == NULL) || r; r = ((glProgramUniform2d = (PFNGLPROGRAMUNIFORM2DPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2d")) == NULL) || r; r = ((glProgramUniform2dv = (PFNGLPROGRAMUNIFORM2DVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2dv")) == NULL) || r; r = ((glProgramUniform2f = (PFNGLPROGRAMUNIFORM2FPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2f")) == NULL) || r; r = ((glProgramUniform2fv = (PFNGLPROGRAMUNIFORM2FVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2fv")) == NULL) || r; r = ((glProgramUniform2i = (PFNGLPROGRAMUNIFORM2IPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2i")) == NULL) || r; r = ((glProgramUniform2iv = (PFNGLPROGRAMUNIFORM2IVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2iv")) == NULL) || r; r = ((glProgramUniform2ui = (PFNGLPROGRAMUNIFORM2UIPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2ui")) == NULL) || r; r = ((glProgramUniform2uiv = (PFNGLPROGRAMUNIFORM2UIVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2uiv")) == NULL) || r; r = ((glProgramUniform3d = (PFNGLPROGRAMUNIFORM3DPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3d")) == NULL) || r; r = ((glProgramUniform3dv = (PFNGLPROGRAMUNIFORM3DVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3dv")) == NULL) || r; r = ((glProgramUniform3f = (PFNGLPROGRAMUNIFORM3FPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3f")) == NULL) || r; r = ((glProgramUniform3fv = (PFNGLPROGRAMUNIFORM3FVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3fv")) == NULL) || r; r = ((glProgramUniform3i = (PFNGLPROGRAMUNIFORM3IPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3i")) == NULL) || r; r = ((glProgramUniform3iv = (PFNGLPROGRAMUNIFORM3IVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3iv")) == NULL) || r; r = ((glProgramUniform3ui = (PFNGLPROGRAMUNIFORM3UIPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3ui")) == NULL) || r; r = ((glProgramUniform3uiv = (PFNGLPROGRAMUNIFORM3UIVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3uiv")) == NULL) || r; r = ((glProgramUniform4d = (PFNGLPROGRAMUNIFORM4DPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4d")) == NULL) || r; r = ((glProgramUniform4dv = (PFNGLPROGRAMUNIFORM4DVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4dv")) == NULL) || r; r = ((glProgramUniform4f = (PFNGLPROGRAMUNIFORM4FPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4f")) == NULL) || r; r = ((glProgramUniform4fv = (PFNGLPROGRAMUNIFORM4FVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4fv")) == NULL) || r; r = ((glProgramUniform4i = (PFNGLPROGRAMUNIFORM4IPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4i")) == NULL) || r; r = ((glProgramUniform4iv = (PFNGLPROGRAMUNIFORM4IVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4iv")) == NULL) || r; r = ((glProgramUniform4ui = (PFNGLPROGRAMUNIFORM4UIPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4ui")) == NULL) || r; r = ((glProgramUniform4uiv = (PFNGLPROGRAMUNIFORM4UIVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4uiv")) == NULL) || r; r = ((glProgramUniformMatrix2dv = (PFNGLPROGRAMUNIFORMMATRIX2DVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2dv")) == NULL) || r; r = ((glProgramUniformMatrix2fv = (PFNGLPROGRAMUNIFORMMATRIX2FVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2fv")) == NULL) || r; r = ((glProgramUniformMatrix2x3dv = (PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2x3dv")) == NULL) || r; r = ((glProgramUniformMatrix2x3fv = (PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2x3fv")) == NULL) || r; r = ((glProgramUniformMatrix2x4dv = (PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2x4dv")) == NULL) || r; r = ((glProgramUniformMatrix2x4fv = (PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2x4fv")) == NULL) || r; r = ((glProgramUniformMatrix3dv = (PFNGLPROGRAMUNIFORMMATRIX3DVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3dv")) == NULL) || r; r = ((glProgramUniformMatrix3fv = (PFNGLPROGRAMUNIFORMMATRIX3FVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3fv")) == NULL) || r; r = ((glProgramUniformMatrix3x2dv = (PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3x2dv")) == NULL) || r; r = ((glProgramUniformMatrix3x2fv = (PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3x2fv")) == NULL) || r; r = ((glProgramUniformMatrix3x4dv = (PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3x4dv")) == NULL) || r; r = ((glProgramUniformMatrix3x4fv = (PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3x4fv")) == NULL) || r; r = ((glProgramUniformMatrix4dv = (PFNGLPROGRAMUNIFORMMATRIX4DVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4dv")) == NULL) || r; r = ((glProgramUniformMatrix4fv = (PFNGLPROGRAMUNIFORMMATRIX4FVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4fv")) == NULL) || r; r = ((glProgramUniformMatrix4x2dv = (PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4x2dv")) == NULL) || r; r = ((glProgramUniformMatrix4x2fv = (PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4x2fv")) == NULL) || r; r = ((glProgramUniformMatrix4x3dv = (PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4x3dv")) == NULL) || r; r = ((glProgramUniformMatrix4x3fv = (PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4x3fv")) == NULL) || r; r = ((glUseProgramStages = (PFNGLUSEPROGRAMSTAGESPROC)glewGetProcAddress((const GLubyte*)"glUseProgramStages")) == NULL) || r; r = ((glValidateProgramPipeline = (PFNGLVALIDATEPROGRAMPIPELINEPROC)glewGetProcAddress((const GLubyte*)"glValidateProgramPipeline")) == NULL) || r; return r; } #endif /* GL_ARB_separate_shader_objects */ #ifdef GL_ARB_shader_atomic_counters static GLboolean _glewInit_GL_ARB_shader_atomic_counters (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetActiveAtomicCounterBufferiv = (PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC)glewGetProcAddress((const GLubyte*)"glGetActiveAtomicCounterBufferiv")) == NULL) || r; return r; } #endif /* GL_ARB_shader_atomic_counters */ #ifdef GL_ARB_shader_image_load_store static GLboolean _glewInit_GL_ARB_shader_image_load_store (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC)glewGetProcAddress((const GLubyte*)"glBindImageTexture")) == NULL) || r; r = ((glMemoryBarrier = (PFNGLMEMORYBARRIERPROC)glewGetProcAddress((const GLubyte*)"glMemoryBarrier")) == NULL) || r; return r; } #endif /* GL_ARB_shader_image_load_store */ #ifdef GL_ARB_shader_objects static GLboolean _glewInit_GL_ARB_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glAttachObjectARB")) == NULL) || r; r = ((glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)glewGetProcAddress((const GLubyte*)"glCompileShaderARB")) == NULL) || r; r = ((glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glCreateProgramObjectARB")) == NULL) || r; r = ((glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glCreateShaderObjectARB")) == NULL) || r; r = ((glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glDeleteObjectARB")) == NULL) || r; r = ((glDetachObjectARB = (PFNGLDETACHOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glDetachObjectARB")) == NULL) || r; r = ((glGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC)glewGetProcAddress((const GLubyte*)"glGetActiveUniformARB")) == NULL) || r; r = ((glGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC)glewGetProcAddress((const GLubyte*)"glGetAttachedObjectsARB")) == NULL) || r; r = ((glGetHandleARB = (PFNGLGETHANDLEARBPROC)glewGetProcAddress((const GLubyte*)"glGetHandleARB")) == NULL) || r; r = ((glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)glewGetProcAddress((const GLubyte*)"glGetInfoLogARB")) == NULL) || r; r = ((glGetObjectParameterfvARB = (PFNGLGETOBJECTPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetObjectParameterfvARB")) == NULL) || r; r = ((glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetObjectParameterivARB")) == NULL) || r; r = ((glGetShaderSourceARB = (PFNGLGETSHADERSOURCEARBPROC)glewGetProcAddress((const GLubyte*)"glGetShaderSourceARB")) == NULL) || r; r = ((glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)glewGetProcAddress((const GLubyte*)"glGetUniformLocationARB")) == NULL) || r; r = ((glGetUniformfvARB = (PFNGLGETUNIFORMFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetUniformfvARB")) == NULL) || r; r = ((glGetUniformivARB = (PFNGLGETUNIFORMIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetUniformivARB")) == NULL) || r; r = ((glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)"glLinkProgramARB")) == NULL) || r; r = ((glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)glewGetProcAddress((const GLubyte*)"glShaderSourceARB")) == NULL) || r; r = ((glUniform1fARB = (PFNGLUNIFORM1FARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1fARB")) == NULL) || r; r = ((glUniform1fvARB = (PFNGLUNIFORM1FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1fvARB")) == NULL) || r; r = ((glUniform1iARB = (PFNGLUNIFORM1IARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1iARB")) == NULL) || r; r = ((glUniform1ivARB = (PFNGLUNIFORM1IVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1ivARB")) == NULL) || r; r = ((glUniform2fARB = (PFNGLUNIFORM2FARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2fARB")) == NULL) || r; r = ((glUniform2fvARB = (PFNGLUNIFORM2FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2fvARB")) == NULL) || r; r = ((glUniform2iARB = (PFNGLUNIFORM2IARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2iARB")) == NULL) || r; r = ((glUniform2ivARB = (PFNGLUNIFORM2IVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2ivARB")) == NULL) || r; r = ((glUniform3fARB = (PFNGLUNIFORM3FARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3fARB")) == NULL) || r; r = ((glUniform3fvARB = (PFNGLUNIFORM3FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3fvARB")) == NULL) || r; r = ((glUniform3iARB = (PFNGLUNIFORM3IARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3iARB")) == NULL) || r; r = ((glUniform3ivARB = (PFNGLUNIFORM3IVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3ivARB")) == NULL) || r; r = ((glUniform4fARB = (PFNGLUNIFORM4FARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4fARB")) == NULL) || r; r = ((glUniform4fvARB = (PFNGLUNIFORM4FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4fvARB")) == NULL) || r; r = ((glUniform4iARB = (PFNGLUNIFORM4IARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4iARB")) == NULL) || r; r = ((glUniform4ivARB = (PFNGLUNIFORM4IVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4ivARB")) == NULL) || r; r = ((glUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2fvARB")) == NULL) || r; r = ((glUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3fvARB")) == NULL) || r; r = ((glUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4fvARB")) == NULL) || r; r = ((glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glUseProgramObjectARB")) == NULL) || r; r = ((glValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)"glValidateProgramARB")) == NULL) || r; return r; } #endif /* GL_ARB_shader_objects */ #ifdef GL_ARB_shader_storage_buffer_object static GLboolean _glewInit_GL_ARB_shader_storage_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glShaderStorageBlockBinding = (PFNGLSHADERSTORAGEBLOCKBINDINGPROC)glewGetProcAddress((const GLubyte*)"glShaderStorageBlockBinding")) == NULL) || r; return r; } #endif /* GL_ARB_shader_storage_buffer_object */ #ifdef GL_ARB_shader_subroutine static GLboolean _glewInit_GL_ARB_shader_subroutine (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetActiveSubroutineName = (PFNGLGETACTIVESUBROUTINENAMEPROC)glewGetProcAddress((const GLubyte*)"glGetActiveSubroutineName")) == NULL) || r; r = ((glGetActiveSubroutineUniformName = (PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)glewGetProcAddress((const GLubyte*)"glGetActiveSubroutineUniformName")) == NULL) || r; r = ((glGetActiveSubroutineUniformiv = (PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC)glewGetProcAddress((const GLubyte*)"glGetActiveSubroutineUniformiv")) == NULL) || r; r = ((glGetProgramStageiv = (PFNGLGETPROGRAMSTAGEIVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramStageiv")) == NULL) || r; r = ((glGetSubroutineIndex = (PFNGLGETSUBROUTINEINDEXPROC)glewGetProcAddress((const GLubyte*)"glGetSubroutineIndex")) == NULL) || r; r = ((glGetSubroutineUniformLocation = (PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC)glewGetProcAddress((const GLubyte*)"glGetSubroutineUniformLocation")) == NULL) || r; r = ((glGetUniformSubroutineuiv = (PFNGLGETUNIFORMSUBROUTINEUIVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformSubroutineuiv")) == NULL) || r; r = ((glUniformSubroutinesuiv = (PFNGLUNIFORMSUBROUTINESUIVPROC)glewGetProcAddress((const GLubyte*)"glUniformSubroutinesuiv")) == NULL) || r; return r; } #endif /* GL_ARB_shader_subroutine */ #ifdef GL_ARB_shading_language_include static GLboolean _glewInit_GL_ARB_shading_language_include (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glCompileShaderIncludeARB = (PFNGLCOMPILESHADERINCLUDEARBPROC)glewGetProcAddress((const GLubyte*)"glCompileShaderIncludeARB")) == NULL) || r; r = ((glDeleteNamedStringARB = (PFNGLDELETENAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"glDeleteNamedStringARB")) == NULL) || r; r = ((glGetNamedStringARB = (PFNGLGETNAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"glGetNamedStringARB")) == NULL) || r; r = ((glGetNamedStringivARB = (PFNGLGETNAMEDSTRINGIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetNamedStringivARB")) == NULL) || r; r = ((glIsNamedStringARB = (PFNGLISNAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"glIsNamedStringARB")) == NULL) || r; r = ((glNamedStringARB = (PFNGLNAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"glNamedStringARB")) == NULL) || r; return r; } #endif /* GL_ARB_shading_language_include */ #ifdef GL_ARB_sparse_buffer static GLboolean _glewInit_GL_ARB_sparse_buffer (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBufferPageCommitmentARB = (PFNGLBUFFERPAGECOMMITMENTARBPROC)glewGetProcAddress((const GLubyte*)"glBufferPageCommitmentARB")) == NULL) || r; return r; } #endif /* GL_ARB_sparse_buffer */ #ifdef GL_ARB_sparse_texture static GLboolean _glewInit_GL_ARB_sparse_texture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTexPageCommitmentARB = (PFNGLTEXPAGECOMMITMENTARBPROC)glewGetProcAddress((const GLubyte*)"glTexPageCommitmentARB")) == NULL) || r; r = ((glTexturePageCommitmentEXT = (PFNGLTEXTUREPAGECOMMITMENTEXTPROC)glewGetProcAddress((const GLubyte*)"glTexturePageCommitmentEXT")) == NULL) || r; return r; } #endif /* GL_ARB_sparse_texture */ #ifdef GL_ARB_sync static GLboolean _glewInit_GL_ARB_sync (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC)glewGetProcAddress((const GLubyte*)"glClientWaitSync")) == NULL) || r; r = ((glDeleteSync = (PFNGLDELETESYNCPROC)glewGetProcAddress((const GLubyte*)"glDeleteSync")) == NULL) || r; r = ((glFenceSync = (PFNGLFENCESYNCPROC)glewGetProcAddress((const GLubyte*)"glFenceSync")) == NULL) || r; r = ((glGetInteger64v = (PFNGLGETINTEGER64VPROC)glewGetProcAddress((const GLubyte*)"glGetInteger64v")) == NULL) || r; r = ((glGetSynciv = (PFNGLGETSYNCIVPROC)glewGetProcAddress((const GLubyte*)"glGetSynciv")) == NULL) || r; r = ((glIsSync = (PFNGLISSYNCPROC)glewGetProcAddress((const GLubyte*)"glIsSync")) == NULL) || r; r = ((glWaitSync = (PFNGLWAITSYNCPROC)glewGetProcAddress((const GLubyte*)"glWaitSync")) == NULL) || r; return r; } #endif /* GL_ARB_sync */ #ifdef GL_ARB_tessellation_shader static GLboolean _glewInit_GL_ARB_tessellation_shader (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glPatchParameterfv = (PFNGLPATCHPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glPatchParameterfv")) == NULL) || r; r = ((glPatchParameteri = (PFNGLPATCHPARAMETERIPROC)glewGetProcAddress((const GLubyte*)"glPatchParameteri")) == NULL) || r; return r; } #endif /* GL_ARB_tessellation_shader */ #ifdef GL_ARB_texture_barrier static GLboolean _glewInit_GL_ARB_texture_barrier (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTextureBarrier = (PFNGLTEXTUREBARRIERPROC)glewGetProcAddress((const GLubyte*)"glTextureBarrier")) == NULL) || r; return r; } #endif /* GL_ARB_texture_barrier */ #ifdef GL_ARB_texture_buffer_object static GLboolean _glewInit_GL_ARB_texture_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTexBufferARB = (PFNGLTEXBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glTexBufferARB")) == NULL) || r; return r; } #endif /* GL_ARB_texture_buffer_object */ #ifdef GL_ARB_texture_buffer_range static GLboolean _glewInit_GL_ARB_texture_buffer_range (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTexBufferRange = (PFNGLTEXBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glTexBufferRange")) == NULL) || r; r = ((glTextureBufferRangeEXT = (PFNGLTEXTUREBUFFERRANGEEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureBufferRangeEXT")) == NULL) || r; return r; } #endif /* GL_ARB_texture_buffer_range */ #ifdef GL_ARB_texture_compression static GLboolean _glewInit_GL_ARB_texture_compression (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glCompressedTexImage1DARB = (PFNGLCOMPRESSEDTEXIMAGE1DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage1DARB")) == NULL) || r; r = ((glCompressedTexImage2DARB = (PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage2DARB")) == NULL) || r; r = ((glCompressedTexImage3DARB = (PFNGLCOMPRESSEDTEXIMAGE3DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage3DARB")) == NULL) || r; r = ((glCompressedTexSubImage1DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage1DARB")) == NULL) || r; r = ((glCompressedTexSubImage2DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage2DARB")) == NULL) || r; r = ((glCompressedTexSubImage3DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage3DARB")) == NULL) || r; r = ((glGetCompressedTexImageARB = (PFNGLGETCOMPRESSEDTEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedTexImageARB")) == NULL) || r; return r; } #endif /* GL_ARB_texture_compression */ #ifdef GL_ARB_texture_multisample static GLboolean _glewInit_GL_ARB_texture_multisample (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)glewGetProcAddress((const GLubyte*)"glGetMultisamplefv")) == NULL) || r; r = ((glSampleMaski = (PFNGLSAMPLEMASKIPROC)glewGetProcAddress((const GLubyte*)"glSampleMaski")) == NULL) || r; r = ((glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)"glTexImage2DMultisample")) == NULL) || r; r = ((glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)"glTexImage3DMultisample")) == NULL) || r; return r; } #endif /* GL_ARB_texture_multisample */ #ifdef GL_ARB_texture_storage static GLboolean _glewInit_GL_ARB_texture_storage (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTexStorage1D = (PFNGLTEXSTORAGE1DPROC)glewGetProcAddress((const GLubyte*)"glTexStorage1D")) == NULL) || r; r = ((glTexStorage2D = (PFNGLTEXSTORAGE2DPROC)glewGetProcAddress((const GLubyte*)"glTexStorage2D")) == NULL) || r; r = ((glTexStorage3D = (PFNGLTEXSTORAGE3DPROC)glewGetProcAddress((const GLubyte*)"glTexStorage3D")) == NULL) || r; r = ((glTextureStorage1DEXT = (PFNGLTEXTURESTORAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureStorage1DEXT")) == NULL) || r; r = ((glTextureStorage2DEXT = (PFNGLTEXTURESTORAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureStorage2DEXT")) == NULL) || r; r = ((glTextureStorage3DEXT = (PFNGLTEXTURESTORAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureStorage3DEXT")) == NULL) || r; return r; } #endif /* GL_ARB_texture_storage */ #ifdef GL_ARB_texture_storage_multisample static GLboolean _glewInit_GL_ARB_texture_storage_multisample (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTexStorage2DMultisample = (PFNGLTEXSTORAGE2DMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)"glTexStorage2DMultisample")) == NULL) || r; r = ((glTexStorage3DMultisample = (PFNGLTEXSTORAGE3DMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)"glTexStorage3DMultisample")) == NULL) || r; r = ((glTextureStorage2DMultisampleEXT = (PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureStorage2DMultisampleEXT")) == NULL) || r; r = ((glTextureStorage3DMultisampleEXT = (PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureStorage3DMultisampleEXT")) == NULL) || r; return r; } #endif /* GL_ARB_texture_storage_multisample */ #ifdef GL_ARB_texture_view static GLboolean _glewInit_GL_ARB_texture_view (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTextureView = (PFNGLTEXTUREVIEWPROC)glewGetProcAddress((const GLubyte*)"glTextureView")) == NULL) || r; return r; } #endif /* GL_ARB_texture_view */ #ifdef GL_ARB_timer_query static GLboolean _glewInit_GL_ARB_timer_query (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjecti64v")) == NULL) || r; r = ((glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectui64v")) == NULL) || r; r = ((glQueryCounter = (PFNGLQUERYCOUNTERPROC)glewGetProcAddress((const GLubyte*)"glQueryCounter")) == NULL) || r; return r; } #endif /* GL_ARB_timer_query */ #ifdef GL_ARB_transform_feedback2 static GLboolean _glewInit_GL_ARB_transform_feedback2 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glBindTransformFeedback")) == NULL) || r; r = ((glDeleteTransformFeedbacks = (PFNGLDELETETRANSFORMFEEDBACKSPROC)glewGetProcAddress((const GLubyte*)"glDeleteTransformFeedbacks")) == NULL) || r; r = ((glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glDrawTransformFeedback")) == NULL) || r; r = ((glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC)glewGetProcAddress((const GLubyte*)"glGenTransformFeedbacks")) == NULL) || r; r = ((glIsTransformFeedback = (PFNGLISTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glIsTransformFeedback")) == NULL) || r; r = ((glPauseTransformFeedback = (PFNGLPAUSETRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glPauseTransformFeedback")) == NULL) || r; r = ((glResumeTransformFeedback = (PFNGLRESUMETRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glResumeTransformFeedback")) == NULL) || r; return r; } #endif /* GL_ARB_transform_feedback2 */ #ifdef GL_ARB_transform_feedback3 static GLboolean _glewInit_GL_ARB_transform_feedback3 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBeginQueryIndexed = (PFNGLBEGINQUERYINDEXEDPROC)glewGetProcAddress((const GLubyte*)"glBeginQueryIndexed")) == NULL) || r; r = ((glDrawTransformFeedbackStream = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC)glewGetProcAddress((const GLubyte*)"glDrawTransformFeedbackStream")) == NULL) || r; r = ((glEndQueryIndexed = (PFNGLENDQUERYINDEXEDPROC)glewGetProcAddress((const GLubyte*)"glEndQueryIndexed")) == NULL) || r; r = ((glGetQueryIndexediv = (PFNGLGETQUERYINDEXEDIVPROC)glewGetProcAddress((const GLubyte*)"glGetQueryIndexediv")) == NULL) || r; return r; } #endif /* GL_ARB_transform_feedback3 */ #ifdef GL_ARB_transform_feedback_instanced static GLboolean _glewInit_GL_ARB_transform_feedback_instanced (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDrawTransformFeedbackInstanced = (PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC)glewGetProcAddress((const GLubyte*)"glDrawTransformFeedbackInstanced")) == NULL) || r; r = ((glDrawTransformFeedbackStreamInstanced = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC)glewGetProcAddress((const GLubyte*)"glDrawTransformFeedbackStreamInstanced")) == NULL) || r; return r; } #endif /* GL_ARB_transform_feedback_instanced */ #ifdef GL_ARB_transpose_matrix static GLboolean _glewInit_GL_ARB_transpose_matrix (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glLoadTransposeMatrixdARB = (PFNGLLOADTRANSPOSEMATRIXDARBPROC)glewGetProcAddress((const GLubyte*)"glLoadTransposeMatrixdARB")) == NULL) || r; r = ((glLoadTransposeMatrixfARB = (PFNGLLOADTRANSPOSEMATRIXFARBPROC)glewGetProcAddress((const GLubyte*)"glLoadTransposeMatrixfARB")) == NULL) || r; r = ((glMultTransposeMatrixdARB = (PFNGLMULTTRANSPOSEMATRIXDARBPROC)glewGetProcAddress((const GLubyte*)"glMultTransposeMatrixdARB")) == NULL) || r; r = ((glMultTransposeMatrixfARB = (PFNGLMULTTRANSPOSEMATRIXFARBPROC)glewGetProcAddress((const GLubyte*)"glMultTransposeMatrixfARB")) == NULL) || r; return r; } #endif /* GL_ARB_transpose_matrix */ #ifdef GL_ARB_uniform_buffer_object static GLboolean _glewInit_GL_ARB_uniform_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)glewGetProcAddress((const GLubyte*)"glBindBufferBase")) == NULL) || r; r = ((glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glBindBufferRange")) == NULL) || r; r = ((glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)glewGetProcAddress((const GLubyte*)"glGetActiveUniformBlockName")) == NULL) || r; r = ((glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)glewGetProcAddress((const GLubyte*)"glGetActiveUniformBlockiv")) == NULL) || r; r = ((glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)glewGetProcAddress((const GLubyte*)"glGetActiveUniformName")) == NULL) || r; r = ((glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)glewGetProcAddress((const GLubyte*)"glGetActiveUniformsiv")) == NULL) || r; r = ((glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)glewGetProcAddress((const GLubyte*)"glGetIntegeri_v")) == NULL) || r; r = ((glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)glewGetProcAddress((const GLubyte*)"glGetUniformBlockIndex")) == NULL) || r; r = ((glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)glewGetProcAddress((const GLubyte*)"glGetUniformIndices")) == NULL) || r; r = ((glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)glewGetProcAddress((const GLubyte*)"glUniformBlockBinding")) == NULL) || r; return r; } #endif /* GL_ARB_uniform_buffer_object */ #ifdef GL_ARB_vertex_array_object static GLboolean _glewInit_GL_ARB_vertex_array_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)glewGetProcAddress((const GLubyte*)"glBindVertexArray")) == NULL) || r; r = ((glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)glewGetProcAddress((const GLubyte*)"glDeleteVertexArrays")) == NULL) || r; r = ((glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)glewGetProcAddress((const GLubyte*)"glGenVertexArrays")) == NULL) || r; r = ((glIsVertexArray = (PFNGLISVERTEXARRAYPROC)glewGetProcAddress((const GLubyte*)"glIsVertexArray")) == NULL) || r; return r; } #endif /* GL_ARB_vertex_array_object */ #ifdef GL_ARB_vertex_attrib_64bit static GLboolean _glewInit_GL_ARB_vertex_attrib_64bit (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetVertexAttribLdv = (PFNGLGETVERTEXATTRIBLDVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribLdv")) == NULL) || r; r = ((glVertexAttribL1d = (PFNGLVERTEXATTRIBL1DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1d")) == NULL) || r; r = ((glVertexAttribL1dv = (PFNGLVERTEXATTRIBL1DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1dv")) == NULL) || r; r = ((glVertexAttribL2d = (PFNGLVERTEXATTRIBL2DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL2d")) == NULL) || r; r = ((glVertexAttribL2dv = (PFNGLVERTEXATTRIBL2DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL2dv")) == NULL) || r; r = ((glVertexAttribL3d = (PFNGLVERTEXATTRIBL3DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL3d")) == NULL) || r; r = ((glVertexAttribL3dv = (PFNGLVERTEXATTRIBL3DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL3dv")) == NULL) || r; r = ((glVertexAttribL4d = (PFNGLVERTEXATTRIBL4DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL4d")) == NULL) || r; r = ((glVertexAttribL4dv = (PFNGLVERTEXATTRIBL4DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL4dv")) == NULL) || r; r = ((glVertexAttribLPointer = (PFNGLVERTEXATTRIBLPOINTERPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribLPointer")) == NULL) || r; return r; } #endif /* GL_ARB_vertex_attrib_64bit */ #ifdef GL_ARB_vertex_attrib_binding static GLboolean _glewInit_GL_ARB_vertex_attrib_binding (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindVertexBuffer = (PFNGLBINDVERTEXBUFFERPROC)glewGetProcAddress((const GLubyte*)"glBindVertexBuffer")) == NULL) || r; r = ((glVertexArrayBindVertexBufferEXT = (PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayBindVertexBufferEXT")) == NULL) || r; r = ((glVertexArrayVertexAttribBindingEXT = (PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexAttribBindingEXT")) == NULL) || r; r = ((glVertexArrayVertexAttribFormatEXT = (PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexAttribFormatEXT")) == NULL) || r; r = ((glVertexArrayVertexAttribIFormatEXT = (PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexAttribIFormatEXT")) == NULL) || r; r = ((glVertexArrayVertexAttribLFormatEXT = (PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexAttribLFormatEXT")) == NULL) || r; r = ((glVertexArrayVertexBindingDivisorEXT = (PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexBindingDivisorEXT")) == NULL) || r; r = ((glVertexAttribBinding = (PFNGLVERTEXATTRIBBINDINGPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribBinding")) == NULL) || r; r = ((glVertexAttribFormat = (PFNGLVERTEXATTRIBFORMATPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribFormat")) == NULL) || r; r = ((glVertexAttribIFormat = (PFNGLVERTEXATTRIBIFORMATPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribIFormat")) == NULL) || r; r = ((glVertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribLFormat")) == NULL) || r; r = ((glVertexBindingDivisor = (PFNGLVERTEXBINDINGDIVISORPROC)glewGetProcAddress((const GLubyte*)"glVertexBindingDivisor")) == NULL) || r; return r; } #endif /* GL_ARB_vertex_attrib_binding */ #ifdef GL_ARB_vertex_blend static GLboolean _glewInit_GL_ARB_vertex_blend (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glVertexBlendARB = (PFNGLVERTEXBLENDARBPROC)glewGetProcAddress((const GLubyte*)"glVertexBlendARB")) == NULL) || r; r = ((glWeightPointerARB = (PFNGLWEIGHTPOINTERARBPROC)glewGetProcAddress((const GLubyte*)"glWeightPointerARB")) == NULL) || r; r = ((glWeightbvARB = (PFNGLWEIGHTBVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightbvARB")) == NULL) || r; r = ((glWeightdvARB = (PFNGLWEIGHTDVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightdvARB")) == NULL) || r; r = ((glWeightfvARB = (PFNGLWEIGHTFVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightfvARB")) == NULL) || r; r = ((glWeightivARB = (PFNGLWEIGHTIVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightivARB")) == NULL) || r; r = ((glWeightsvARB = (PFNGLWEIGHTSVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightsvARB")) == NULL) || r; r = ((glWeightubvARB = (PFNGLWEIGHTUBVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightubvARB")) == NULL) || r; r = ((glWeightuivARB = (PFNGLWEIGHTUIVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightuivARB")) == NULL) || r; r = ((glWeightusvARB = (PFNGLWEIGHTUSVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightusvARB")) == NULL) || r; return r; } #endif /* GL_ARB_vertex_blend */ #ifdef GL_ARB_vertex_buffer_object static GLboolean _glewInit_GL_ARB_vertex_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindBufferARB = (PFNGLBINDBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glBindBufferARB")) == NULL) || r; r = ((glBufferDataARB = (PFNGLBUFFERDATAARBPROC)glewGetProcAddress((const GLubyte*)"glBufferDataARB")) == NULL) || r; r = ((glBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC)glewGetProcAddress((const GLubyte*)"glBufferSubDataARB")) == NULL) || r; r = ((glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)glewGetProcAddress((const GLubyte*)"glDeleteBuffersARB")) == NULL) || r; r = ((glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)glewGetProcAddress((const GLubyte*)"glGenBuffersARB")) == NULL) || r; r = ((glGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetBufferParameterivARB")) == NULL) || r; r = ((glGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC)glewGetProcAddress((const GLubyte*)"glGetBufferPointervARB")) == NULL) || r; r = ((glGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC)glewGetProcAddress((const GLubyte*)"glGetBufferSubDataARB")) == NULL) || r; r = ((glIsBufferARB = (PFNGLISBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glIsBufferARB")) == NULL) || r; r = ((glMapBufferARB = (PFNGLMAPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glMapBufferARB")) == NULL) || r; r = ((glUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glUnmapBufferARB")) == NULL) || r; return r; } #endif /* GL_ARB_vertex_buffer_object */ #ifdef GL_ARB_vertex_program static GLboolean _glewInit_GL_ARB_vertex_program (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindProgramARB = (PFNGLBINDPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)"glBindProgramARB")) == NULL) || r; r = ((glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)glewGetProcAddress((const GLubyte*)"glDeleteProgramsARB")) == NULL) || r; r = ((glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)glewGetProcAddress((const GLubyte*)"glDisableVertexAttribArrayARB")) == NULL) || r; r = ((glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)glewGetProcAddress((const GLubyte*)"glEnableVertexAttribArrayARB")) == NULL) || r; r = ((glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)glewGetProcAddress((const GLubyte*)"glGenProgramsARB")) == NULL) || r; r = ((glGetProgramEnvParameterdvARB = (PFNGLGETPROGRAMENVPARAMETERDVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramEnvParameterdvARB")) == NULL) || r; r = ((glGetProgramEnvParameterfvARB = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramEnvParameterfvARB")) == NULL) || r; r = ((glGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramLocalParameterdvARB")) == NULL) || r; r = ((glGetProgramLocalParameterfvARB = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramLocalParameterfvARB")) == NULL) || r; r = ((glGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramStringARB")) == NULL) || r; r = ((glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramivARB")) == NULL) || r; r = ((glGetVertexAttribPointervARB = (PFNGLGETVERTEXATTRIBPOINTERVARBPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribPointervARB")) == NULL) || r; r = ((glGetVertexAttribdvARB = (PFNGLGETVERTEXATTRIBDVARBPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribdvARB")) == NULL) || r; r = ((glGetVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribfvARB")) == NULL) || r; r = ((glGetVertexAttribivARB = (PFNGLGETVERTEXATTRIBIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribivARB")) == NULL) || r; r = ((glIsProgramARB = (PFNGLISPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)"glIsProgramARB")) == NULL) || r; r = ((glProgramEnvParameter4dARB = (PFNGLPROGRAMENVPARAMETER4DARBPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameter4dARB")) == NULL) || r; r = ((glProgramEnvParameter4dvARB = (PFNGLPROGRAMENVPARAMETER4DVARBPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameter4dvARB")) == NULL) || r; r = ((glProgramEnvParameter4fARB = (PFNGLPROGRAMENVPARAMETER4FARBPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameter4fARB")) == NULL) || r; r = ((glProgramEnvParameter4fvARB = (PFNGLPROGRAMENVPARAMETER4FVARBPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameter4fvARB")) == NULL) || r; r = ((glProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameter4dARB")) == NULL) || r; r = ((glProgramLocalParameter4dvARB = (PFNGLPROGRAMLOCALPARAMETER4DVARBPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameter4dvARB")) == NULL) || r; r = ((glProgramLocalParameter4fARB = (PFNGLPROGRAMLOCALPARAMETER4FARBPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameter4fARB")) == NULL) || r; r = ((glProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameter4fvARB")) == NULL) || r; r = ((glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"glProgramStringARB")) == NULL) || r; r = ((glVertexAttrib1dARB = (PFNGLVERTEXATTRIB1DARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dARB")) == NULL) || r; r = ((glVertexAttrib1dvARB = (PFNGLVERTEXATTRIB1DVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dvARB")) == NULL) || r; r = ((glVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fARB")) == NULL) || r; r = ((glVertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fvARB")) == NULL) || r; r = ((glVertexAttrib1sARB = (PFNGLVERTEXATTRIB1SARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1sARB")) == NULL) || r; r = ((glVertexAttrib1svARB = (PFNGLVERTEXATTRIB1SVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1svARB")) == NULL) || r; r = ((glVertexAttrib2dARB = (PFNGLVERTEXATTRIB2DARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dARB")) == NULL) || r; r = ((glVertexAttrib2dvARB = (PFNGLVERTEXATTRIB2DVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dvARB")) == NULL) || r; r = ((glVertexAttrib2fARB = (PFNGLVERTEXATTRIB2FARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fARB")) == NULL) || r; r = ((glVertexAttrib2fvARB = (PFNGLVERTEXATTRIB2FVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fvARB")) == NULL) || r; r = ((glVertexAttrib2sARB = (PFNGLVERTEXATTRIB2SARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2sARB")) == NULL) || r; r = ((glVertexAttrib2svARB = (PFNGLVERTEXATTRIB2SVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2svARB")) == NULL) || r; r = ((glVertexAttrib3dARB = (PFNGLVERTEXATTRIB3DARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dARB")) == NULL) || r; r = ((glVertexAttrib3dvARB = (PFNGLVERTEXATTRIB3DVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dvARB")) == NULL) || r; r = ((glVertexAttrib3fARB = (PFNGLVERTEXATTRIB3FARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fARB")) == NULL) || r; r = ((glVertexAttrib3fvARB = (PFNGLVERTEXATTRIB3FVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fvARB")) == NULL) || r; r = ((glVertexAttrib3sARB = (PFNGLVERTEXATTRIB3SARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3sARB")) == NULL) || r; r = ((glVertexAttrib3svARB = (PFNGLVERTEXATTRIB3SVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3svARB")) == NULL) || r; r = ((glVertexAttrib4NbvARB = (PFNGLVERTEXATTRIB4NBVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NbvARB")) == NULL) || r; r = ((glVertexAttrib4NivARB = (PFNGLVERTEXATTRIB4NIVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NivARB")) == NULL) || r; r = ((glVertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NsvARB")) == NULL) || r; r = ((glVertexAttrib4NubARB = (PFNGLVERTEXATTRIB4NUBARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NubARB")) == NULL) || r; r = ((glVertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NubvARB")) == NULL) || r; r = ((glVertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NuivARB")) == NULL) || r; r = ((glVertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NusvARB")) == NULL) || r; r = ((glVertexAttrib4bvARB = (PFNGLVERTEXATTRIB4BVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4bvARB")) == NULL) || r; r = ((glVertexAttrib4dARB = (PFNGLVERTEXATTRIB4DARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dARB")) == NULL) || r; r = ((glVertexAttrib4dvARB = (PFNGLVERTEXATTRIB4DVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dvARB")) == NULL) || r; r = ((glVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fARB")) == NULL) || r; r = ((glVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fvARB")) == NULL) || r; r = ((glVertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ivARB")) == NULL) || r; r = ((glVertexAttrib4sARB = (PFNGLVERTEXATTRIB4SARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4sARB")) == NULL) || r; r = ((glVertexAttrib4svARB = (PFNGLVERTEXATTRIB4SVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4svARB")) == NULL) || r; r = ((glVertexAttrib4ubvARB = (PFNGLVERTEXATTRIB4UBVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ubvARB")) == NULL) || r; r = ((glVertexAttrib4uivARB = (PFNGLVERTEXATTRIB4UIVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4uivARB")) == NULL) || r; r = ((glVertexAttrib4usvARB = (PFNGLVERTEXATTRIB4USVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4usvARB")) == NULL) || r; r = ((glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribPointerARB")) == NULL) || r; return r; } #endif /* GL_ARB_vertex_program */ #ifdef GL_ARB_vertex_shader static GLboolean _glewInit_GL_ARB_vertex_shader (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC)glewGetProcAddress((const GLubyte*)"glBindAttribLocationARB")) == NULL) || r; r = ((glGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC)glewGetProcAddress((const GLubyte*)"glGetActiveAttribARB")) == NULL) || r; r = ((glGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC)glewGetProcAddress((const GLubyte*)"glGetAttribLocationARB")) == NULL) || r; return r; } #endif /* GL_ARB_vertex_shader */ #ifdef GL_ARB_vertex_type_2_10_10_10_rev static GLboolean _glewInit_GL_ARB_vertex_type_2_10_10_10_rev (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glColorP3ui = (PFNGLCOLORP3UIPROC)glewGetProcAddress((const GLubyte*)"glColorP3ui")) == NULL) || r; r = ((glColorP3uiv = (PFNGLCOLORP3UIVPROC)glewGetProcAddress((const GLubyte*)"glColorP3uiv")) == NULL) || r; r = ((glColorP4ui = (PFNGLCOLORP4UIPROC)glewGetProcAddress((const GLubyte*)"glColorP4ui")) == NULL) || r; r = ((glColorP4uiv = (PFNGLCOLORP4UIVPROC)glewGetProcAddress((const GLubyte*)"glColorP4uiv")) == NULL) || r; r = ((glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP1ui")) == NULL) || r; r = ((glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP1uiv")) == NULL) || r; r = ((glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP2ui")) == NULL) || r; r = ((glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP2uiv")) == NULL) || r; r = ((glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP3ui")) == NULL) || r; r = ((glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP3uiv")) == NULL) || r; r = ((glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP4ui")) == NULL) || r; r = ((glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP4uiv")) == NULL) || r; r = ((glNormalP3ui = (PFNGLNORMALP3UIPROC)glewGetProcAddress((const GLubyte*)"glNormalP3ui")) == NULL) || r; r = ((glNormalP3uiv = (PFNGLNORMALP3UIVPROC)glewGetProcAddress((const GLubyte*)"glNormalP3uiv")) == NULL) || r; r = ((glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorP3ui")) == NULL) || r; r = ((glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorP3uiv")) == NULL) || r; r = ((glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP1ui")) == NULL) || r; r = ((glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP1uiv")) == NULL) || r; r = ((glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP2ui")) == NULL) || r; r = ((glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP2uiv")) == NULL) || r; r = ((glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP3ui")) == NULL) || r; r = ((glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP3uiv")) == NULL) || r; r = ((glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP4ui")) == NULL) || r; r = ((glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP4uiv")) == NULL) || r; r = ((glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP1ui")) == NULL) || r; r = ((glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP1uiv")) == NULL) || r; r = ((glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP2ui")) == NULL) || r; r = ((glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP2uiv")) == NULL) || r; r = ((glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP3ui")) == NULL) || r; r = ((glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP3uiv")) == NULL) || r; r = ((glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP4ui")) == NULL) || r; r = ((glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP4uiv")) == NULL) || r; r = ((glVertexP2ui = (PFNGLVERTEXP2UIPROC)glewGetProcAddress((const GLubyte*)"glVertexP2ui")) == NULL) || r; r = ((glVertexP2uiv = (PFNGLVERTEXP2UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexP2uiv")) == NULL) || r; r = ((glVertexP3ui = (PFNGLVERTEXP3UIPROC)glewGetProcAddress((const GLubyte*)"glVertexP3ui")) == NULL) || r; r = ((glVertexP3uiv = (PFNGLVERTEXP3UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexP3uiv")) == NULL) || r; r = ((glVertexP4ui = (PFNGLVERTEXP4UIPROC)glewGetProcAddress((const GLubyte*)"glVertexP4ui")) == NULL) || r; r = ((glVertexP4uiv = (PFNGLVERTEXP4UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexP4uiv")) == NULL) || r; return r; } #endif /* GL_ARB_vertex_type_2_10_10_10_rev */ #ifdef GL_ARB_viewport_array static GLboolean _glewInit_GL_ARB_viewport_array (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDepthRangeArrayv = (PFNGLDEPTHRANGEARRAYVPROC)glewGetProcAddress((const GLubyte*)"glDepthRangeArrayv")) == NULL) || r; r = ((glDepthRangeIndexed = (PFNGLDEPTHRANGEINDEXEDPROC)glewGetProcAddress((const GLubyte*)"glDepthRangeIndexed")) == NULL) || r; r = ((glGetDoublei_v = (PFNGLGETDOUBLEI_VPROC)glewGetProcAddress((const GLubyte*)"glGetDoublei_v")) == NULL) || r; r = ((glGetFloati_v = (PFNGLGETFLOATI_VPROC)glewGetProcAddress((const GLubyte*)"glGetFloati_v")) == NULL) || r; r = ((glScissorArrayv = (PFNGLSCISSORARRAYVPROC)glewGetProcAddress((const GLubyte*)"glScissorArrayv")) == NULL) || r; r = ((glScissorIndexed = (PFNGLSCISSORINDEXEDPROC)glewGetProcAddress((const GLubyte*)"glScissorIndexed")) == NULL) || r; r = ((glScissorIndexedv = (PFNGLSCISSORINDEXEDVPROC)glewGetProcAddress((const GLubyte*)"glScissorIndexedv")) == NULL) || r; r = ((glViewportArrayv = (PFNGLVIEWPORTARRAYVPROC)glewGetProcAddress((const GLubyte*)"glViewportArrayv")) == NULL) || r; r = ((glViewportIndexedf = (PFNGLVIEWPORTINDEXEDFPROC)glewGetProcAddress((const GLubyte*)"glViewportIndexedf")) == NULL) || r; r = ((glViewportIndexedfv = (PFNGLVIEWPORTINDEXEDFVPROC)glewGetProcAddress((const GLubyte*)"glViewportIndexedfv")) == NULL) || r; return r; } #endif /* GL_ARB_viewport_array */ #ifdef GL_ARB_window_pos static GLboolean _glewInit_GL_ARB_window_pos (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glWindowPos2dARB = (PFNGLWINDOWPOS2DARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dARB")) == NULL) || r; r = ((glWindowPos2dvARB = (PFNGLWINDOWPOS2DVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dvARB")) == NULL) || r; r = ((glWindowPos2fARB = (PFNGLWINDOWPOS2FARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fARB")) == NULL) || r; r = ((glWindowPos2fvARB = (PFNGLWINDOWPOS2FVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fvARB")) == NULL) || r; r = ((glWindowPos2iARB = (PFNGLWINDOWPOS2IARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2iARB")) == NULL) || r; r = ((glWindowPos2ivARB = (PFNGLWINDOWPOS2IVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2ivARB")) == NULL) || r; r = ((glWindowPos2sARB = (PFNGLWINDOWPOS2SARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2sARB")) == NULL) || r; r = ((glWindowPos2svARB = (PFNGLWINDOWPOS2SVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2svARB")) == NULL) || r; r = ((glWindowPos3dARB = (PFNGLWINDOWPOS3DARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dARB")) == NULL) || r; r = ((glWindowPos3dvARB = (PFNGLWINDOWPOS3DVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dvARB")) == NULL) || r; r = ((glWindowPos3fARB = (PFNGLWINDOWPOS3FARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fARB")) == NULL) || r; r = ((glWindowPos3fvARB = (PFNGLWINDOWPOS3FVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fvARB")) == NULL) || r; r = ((glWindowPos3iARB = (PFNGLWINDOWPOS3IARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3iARB")) == NULL) || r; r = ((glWindowPos3ivARB = (PFNGLWINDOWPOS3IVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3ivARB")) == NULL) || r; r = ((glWindowPos3sARB = (PFNGLWINDOWPOS3SARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3sARB")) == NULL) || r; r = ((glWindowPos3svARB = (PFNGLWINDOWPOS3SVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3svARB")) == NULL) || r; return r; } #endif /* GL_ARB_window_pos */ #ifdef GL_ATI_draw_buffers static GLboolean _glewInit_GL_ATI_draw_buffers (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDrawBuffersATI = (PFNGLDRAWBUFFERSATIPROC)glewGetProcAddress((const GLubyte*)"glDrawBuffersATI")) == NULL) || r; return r; } #endif /* GL_ATI_draw_buffers */ #ifdef GL_ATI_element_array static GLboolean _glewInit_GL_ATI_element_array (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDrawElementArrayATI = (PFNGLDRAWELEMENTARRAYATIPROC)glewGetProcAddress((const GLubyte*)"glDrawElementArrayATI")) == NULL) || r; r = ((glDrawRangeElementArrayATI = (PFNGLDRAWRANGEELEMENTARRAYATIPROC)glewGetProcAddress((const GLubyte*)"glDrawRangeElementArrayATI")) == NULL) || r; r = ((glElementPointerATI = (PFNGLELEMENTPOINTERATIPROC)glewGetProcAddress((const GLubyte*)"glElementPointerATI")) == NULL) || r; return r; } #endif /* GL_ATI_element_array */ #ifdef GL_ATI_envmap_bumpmap static GLboolean _glewInit_GL_ATI_envmap_bumpmap (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetTexBumpParameterfvATI = (PFNGLGETTEXBUMPPARAMETERFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetTexBumpParameterfvATI")) == NULL) || r; r = ((glGetTexBumpParameterivATI = (PFNGLGETTEXBUMPPARAMETERIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetTexBumpParameterivATI")) == NULL) || r; r = ((glTexBumpParameterfvATI = (PFNGLTEXBUMPPARAMETERFVATIPROC)glewGetProcAddress((const GLubyte*)"glTexBumpParameterfvATI")) == NULL) || r; r = ((glTexBumpParameterivATI = (PFNGLTEXBUMPPARAMETERIVATIPROC)glewGetProcAddress((const GLubyte*)"glTexBumpParameterivATI")) == NULL) || r; return r; } #endif /* GL_ATI_envmap_bumpmap */ #ifdef GL_ATI_fragment_shader static GLboolean _glewInit_GL_ATI_fragment_shader (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glAlphaFragmentOp1ATI = (PFNGLALPHAFRAGMENTOP1ATIPROC)glewGetProcAddress((const GLubyte*)"glAlphaFragmentOp1ATI")) == NULL) || r; r = ((glAlphaFragmentOp2ATI = (PFNGLALPHAFRAGMENTOP2ATIPROC)glewGetProcAddress((const GLubyte*)"glAlphaFragmentOp2ATI")) == NULL) || r; r = ((glAlphaFragmentOp3ATI = (PFNGLALPHAFRAGMENTOP3ATIPROC)glewGetProcAddress((const GLubyte*)"glAlphaFragmentOp3ATI")) == NULL) || r; r = ((glBeginFragmentShaderATI = (PFNGLBEGINFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)"glBeginFragmentShaderATI")) == NULL) || r; r = ((glBindFragmentShaderATI = (PFNGLBINDFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)"glBindFragmentShaderATI")) == NULL) || r; r = ((glColorFragmentOp1ATI = (PFNGLCOLORFRAGMENTOP1ATIPROC)glewGetProcAddress((const GLubyte*)"glColorFragmentOp1ATI")) == NULL) || r; r = ((glColorFragmentOp2ATI = (PFNGLCOLORFRAGMENTOP2ATIPROC)glewGetProcAddress((const GLubyte*)"glColorFragmentOp2ATI")) == NULL) || r; r = ((glColorFragmentOp3ATI = (PFNGLCOLORFRAGMENTOP3ATIPROC)glewGetProcAddress((const GLubyte*)"glColorFragmentOp3ATI")) == NULL) || r; r = ((glDeleteFragmentShaderATI = (PFNGLDELETEFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)"glDeleteFragmentShaderATI")) == NULL) || r; r = ((glEndFragmentShaderATI = (PFNGLENDFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)"glEndFragmentShaderATI")) == NULL) || r; r = ((glGenFragmentShadersATI = (PFNGLGENFRAGMENTSHADERSATIPROC)glewGetProcAddress((const GLubyte*)"glGenFragmentShadersATI")) == NULL) || r; r = ((glPassTexCoordATI = (PFNGLPASSTEXCOORDATIPROC)glewGetProcAddress((const GLubyte*)"glPassTexCoordATI")) == NULL) || r; r = ((glSampleMapATI = (PFNGLSAMPLEMAPATIPROC)glewGetProcAddress((const GLubyte*)"glSampleMapATI")) == NULL) || r; r = ((glSetFragmentShaderConstantATI = (PFNGLSETFRAGMENTSHADERCONSTANTATIPROC)glewGetProcAddress((const GLubyte*)"glSetFragmentShaderConstantATI")) == NULL) || r; return r; } #endif /* GL_ATI_fragment_shader */ #ifdef GL_ATI_map_object_buffer static GLboolean _glewInit_GL_ATI_map_object_buffer (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glMapObjectBufferATI = (PFNGLMAPOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glMapObjectBufferATI")) == NULL) || r; r = ((glUnmapObjectBufferATI = (PFNGLUNMAPOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glUnmapObjectBufferATI")) == NULL) || r; return r; } #endif /* GL_ATI_map_object_buffer */ #ifdef GL_ATI_pn_triangles static GLboolean _glewInit_GL_ATI_pn_triangles (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glPNTrianglesfATI = (PFNGLPNTRIANGLESFATIPROC)glewGetProcAddress((const GLubyte*)"glPNTrianglesfATI")) == NULL) || r; r = ((glPNTrianglesiATI = (PFNGLPNTRIANGLESIATIPROC)glewGetProcAddress((const GLubyte*)"glPNTrianglesiATI")) == NULL) || r; return r; } #endif /* GL_ATI_pn_triangles */ #ifdef GL_ATI_separate_stencil static GLboolean _glewInit_GL_ATI_separate_stencil (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glStencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC)glewGetProcAddress((const GLubyte*)"glStencilFuncSeparateATI")) == NULL) || r; r = ((glStencilOpSeparateATI = (PFNGLSTENCILOPSEPARATEATIPROC)glewGetProcAddress((const GLubyte*)"glStencilOpSeparateATI")) == NULL) || r; return r; } #endif /* GL_ATI_separate_stencil */ #ifdef GL_ATI_vertex_array_object static GLboolean _glewInit_GL_ATI_vertex_array_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glArrayObjectATI = (PFNGLARRAYOBJECTATIPROC)glewGetProcAddress((const GLubyte*)"glArrayObjectATI")) == NULL) || r; r = ((glFreeObjectBufferATI = (PFNGLFREEOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glFreeObjectBufferATI")) == NULL) || r; r = ((glGetArrayObjectfvATI = (PFNGLGETARRAYOBJECTFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetArrayObjectfvATI")) == NULL) || r; r = ((glGetArrayObjectivATI = (PFNGLGETARRAYOBJECTIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetArrayObjectivATI")) == NULL) || r; r = ((glGetObjectBufferfvATI = (PFNGLGETOBJECTBUFFERFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetObjectBufferfvATI")) == NULL) || r; r = ((glGetObjectBufferivATI = (PFNGLGETOBJECTBUFFERIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetObjectBufferivATI")) == NULL) || r; r = ((glGetVariantArrayObjectfvATI = (PFNGLGETVARIANTARRAYOBJECTFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetVariantArrayObjectfvATI")) == NULL) || r; r = ((glGetVariantArrayObjectivATI = (PFNGLGETVARIANTARRAYOBJECTIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetVariantArrayObjectivATI")) == NULL) || r; r = ((glIsObjectBufferATI = (PFNGLISOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glIsObjectBufferATI")) == NULL) || r; r = ((glNewObjectBufferATI = (PFNGLNEWOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glNewObjectBufferATI")) == NULL) || r; r = ((glUpdateObjectBufferATI = (PFNGLUPDATEOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glUpdateObjectBufferATI")) == NULL) || r; r = ((glVariantArrayObjectATI = (PFNGLVARIANTARRAYOBJECTATIPROC)glewGetProcAddress((const GLubyte*)"glVariantArrayObjectATI")) == NULL) || r; return r; } #endif /* GL_ATI_vertex_array_object */ #ifdef GL_ATI_vertex_attrib_array_object static GLboolean _glewInit_GL_ATI_vertex_attrib_array_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetVertexAttribArrayObjectfvATI = (PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribArrayObjectfvATI")) == NULL) || r; r = ((glGetVertexAttribArrayObjectivATI = (PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribArrayObjectivATI")) == NULL) || r; r = ((glVertexAttribArrayObjectATI = (PFNGLVERTEXATTRIBARRAYOBJECTATIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribArrayObjectATI")) == NULL) || r; return r; } #endif /* GL_ATI_vertex_attrib_array_object */ #ifdef GL_ATI_vertex_streams static GLboolean _glewInit_GL_ATI_vertex_streams (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glClientActiveVertexStreamATI = (PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC)glewGetProcAddress((const GLubyte*)"glClientActiveVertexStreamATI")) == NULL) || r; r = ((glNormalStream3bATI = (PFNGLNORMALSTREAM3BATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3bATI")) == NULL) || r; r = ((glNormalStream3bvATI = (PFNGLNORMALSTREAM3BVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3bvATI")) == NULL) || r; r = ((glNormalStream3dATI = (PFNGLNORMALSTREAM3DATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3dATI")) == NULL) || r; r = ((glNormalStream3dvATI = (PFNGLNORMALSTREAM3DVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3dvATI")) == NULL) || r; r = ((glNormalStream3fATI = (PFNGLNORMALSTREAM3FATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3fATI")) == NULL) || r; r = ((glNormalStream3fvATI = (PFNGLNORMALSTREAM3FVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3fvATI")) == NULL) || r; r = ((glNormalStream3iATI = (PFNGLNORMALSTREAM3IATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3iATI")) == NULL) || r; r = ((glNormalStream3ivATI = (PFNGLNORMALSTREAM3IVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3ivATI")) == NULL) || r; r = ((glNormalStream3sATI = (PFNGLNORMALSTREAM3SATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3sATI")) == NULL) || r; r = ((glNormalStream3svATI = (PFNGLNORMALSTREAM3SVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3svATI")) == NULL) || r; r = ((glVertexBlendEnvfATI = (PFNGLVERTEXBLENDENVFATIPROC)glewGetProcAddress((const GLubyte*)"glVertexBlendEnvfATI")) == NULL) || r; r = ((glVertexBlendEnviATI = (PFNGLVERTEXBLENDENVIATIPROC)glewGetProcAddress((const GLubyte*)"glVertexBlendEnviATI")) == NULL) || r; r = ((glVertexStream1dATI = (PFNGLVERTEXSTREAM1DATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream1dATI")) == NULL) || r; r = ((glVertexStream1dvATI = (PFNGLVERTEXSTREAM1DVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream1dvATI")) == NULL) || r; r = ((glVertexStream1fATI = (PFNGLVERTEXSTREAM1FATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream1fATI")) == NULL) || r; r = ((glVertexStream1fvATI = (PFNGLVERTEXSTREAM1FVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream1fvATI")) == NULL) || r; r = ((glVertexStream1iATI = (PFNGLVERTEXSTREAM1IATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream1iATI")) == NULL) || r; r = ((glVertexStream1ivATI = (PFNGLVERTEXSTREAM1IVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream1ivATI")) == NULL) || r; r = ((glVertexStream1sATI = (PFNGLVERTEXSTREAM1SATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream1sATI")) == NULL) || r; r = ((glVertexStream1svATI = (PFNGLVERTEXSTREAM1SVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream1svATI")) == NULL) || r; r = ((glVertexStream2dATI = (PFNGLVERTEXSTREAM2DATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2dATI")) == NULL) || r; r = ((glVertexStream2dvATI = (PFNGLVERTEXSTREAM2DVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2dvATI")) == NULL) || r; r = ((glVertexStream2fATI = (PFNGLVERTEXSTREAM2FATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2fATI")) == NULL) || r; r = ((glVertexStream2fvATI = (PFNGLVERTEXSTREAM2FVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2fvATI")) == NULL) || r; r = ((glVertexStream2iATI = (PFNGLVERTEXSTREAM2IATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2iATI")) == NULL) || r; r = ((glVertexStream2ivATI = (PFNGLVERTEXSTREAM2IVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2ivATI")) == NULL) || r; r = ((glVertexStream2sATI = (PFNGLVERTEXSTREAM2SATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2sATI")) == NULL) || r; r = ((glVertexStream2svATI = (PFNGLVERTEXSTREAM2SVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2svATI")) == NULL) || r; r = ((glVertexStream3dATI = (PFNGLVERTEXSTREAM3DATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3dATI")) == NULL) || r; r = ((glVertexStream3dvATI = (PFNGLVERTEXSTREAM3DVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3dvATI")) == NULL) || r; r = ((glVertexStream3fATI = (PFNGLVERTEXSTREAM3FATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3fATI")) == NULL) || r; r = ((glVertexStream3fvATI = (PFNGLVERTEXSTREAM3FVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3fvATI")) == NULL) || r; r = ((glVertexStream3iATI = (PFNGLVERTEXSTREAM3IATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3iATI")) == NULL) || r; r = ((glVertexStream3ivATI = (PFNGLVERTEXSTREAM3IVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3ivATI")) == NULL) || r; r = ((glVertexStream3sATI = (PFNGLVERTEXSTREAM3SATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3sATI")) == NULL) || r; r = ((glVertexStream3svATI = (PFNGLVERTEXSTREAM3SVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3svATI")) == NULL) || r; r = ((glVertexStream4dATI = (PFNGLVERTEXSTREAM4DATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4dATI")) == NULL) || r; r = ((glVertexStream4dvATI = (PFNGLVERTEXSTREAM4DVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4dvATI")) == NULL) || r; r = ((glVertexStream4fATI = (PFNGLVERTEXSTREAM4FATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4fATI")) == NULL) || r; r = ((glVertexStream4fvATI = (PFNGLVERTEXSTREAM4FVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4fvATI")) == NULL) || r; r = ((glVertexStream4iATI = (PFNGLVERTEXSTREAM4IATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4iATI")) == NULL) || r; r = ((glVertexStream4ivATI = (PFNGLVERTEXSTREAM4IVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4ivATI")) == NULL) || r; r = ((glVertexStream4sATI = (PFNGLVERTEXSTREAM4SATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4sATI")) == NULL) || r; r = ((glVertexStream4svATI = (PFNGLVERTEXSTREAM4SVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4svATI")) == NULL) || r; return r; } #endif /* GL_ATI_vertex_streams */ #ifdef GL_EXT_bindable_uniform static GLboolean _glewInit_GL_EXT_bindable_uniform (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetUniformBufferSizeEXT = (PFNGLGETUNIFORMBUFFERSIZEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetUniformBufferSizeEXT")) == NULL) || r; r = ((glGetUniformOffsetEXT = (PFNGLGETUNIFORMOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glGetUniformOffsetEXT")) == NULL) || r; r = ((glUniformBufferEXT = (PFNGLUNIFORMBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glUniformBufferEXT")) == NULL) || r; return r; } #endif /* GL_EXT_bindable_uniform */ #ifdef GL_EXT_blend_color static GLboolean _glewInit_GL_EXT_blend_color (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBlendColorEXT = (PFNGLBLENDCOLOREXTPROC)glewGetProcAddress((const GLubyte*)"glBlendColorEXT")) == NULL) || r; return r; } #endif /* GL_EXT_blend_color */ #ifdef GL_EXT_blend_equation_separate static GLboolean _glewInit_GL_EXT_blend_equation_separate (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBlendEquationSeparateEXT = (PFNGLBLENDEQUATIONSEPARATEEXTPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationSeparateEXT")) == NULL) || r; return r; } #endif /* GL_EXT_blend_equation_separate */ #ifdef GL_EXT_blend_func_separate static GLboolean _glewInit_GL_EXT_blend_func_separate (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC)glewGetProcAddress((const GLubyte*)"glBlendFuncSeparateEXT")) == NULL) || r; return r; } #endif /* GL_EXT_blend_func_separate */ #ifdef GL_EXT_blend_minmax static GLboolean _glewInit_GL_EXT_blend_minmax (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBlendEquationEXT = (PFNGLBLENDEQUATIONEXTPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationEXT")) == NULL) || r; return r; } #endif /* GL_EXT_blend_minmax */ #ifdef GL_EXT_color_subtable static GLboolean _glewInit_GL_EXT_color_subtable (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glColorSubTableEXT = (PFNGLCOLORSUBTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"glColorSubTableEXT")) == NULL) || r; r = ((glCopyColorSubTableEXT = (PFNGLCOPYCOLORSUBTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyColorSubTableEXT")) == NULL) || r; return r; } #endif /* GL_EXT_color_subtable */ #ifdef GL_EXT_compiled_vertex_array static GLboolean _glewInit_GL_EXT_compiled_vertex_array (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glLockArraysEXT = (PFNGLLOCKARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)"glLockArraysEXT")) == NULL) || r; r = ((glUnlockArraysEXT = (PFNGLUNLOCKARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)"glUnlockArraysEXT")) == NULL) || r; return r; } #endif /* GL_EXT_compiled_vertex_array */ #ifdef GL_EXT_convolution static GLboolean _glewInit_GL_EXT_convolution (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glConvolutionFilter1DEXT = (PFNGLCONVOLUTIONFILTER1DEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionFilter1DEXT")) == NULL) || r; r = ((glConvolutionFilter2DEXT = (PFNGLCONVOLUTIONFILTER2DEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionFilter2DEXT")) == NULL) || r; r = ((glConvolutionParameterfEXT = (PFNGLCONVOLUTIONPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterfEXT")) == NULL) || r; r = ((glConvolutionParameterfvEXT = (PFNGLCONVOLUTIONPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterfvEXT")) == NULL) || r; r = ((glConvolutionParameteriEXT = (PFNGLCONVOLUTIONPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameteriEXT")) == NULL) || r; r = ((glConvolutionParameterivEXT = (PFNGLCONVOLUTIONPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterivEXT")) == NULL) || r; r = ((glCopyConvolutionFilter1DEXT = (PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyConvolutionFilter1DEXT")) == NULL) || r; r = ((glCopyConvolutionFilter2DEXT = (PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyConvolutionFilter2DEXT")) == NULL) || r; r = ((glGetConvolutionFilterEXT = (PFNGLGETCONVOLUTIONFILTEREXTPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionFilterEXT")) == NULL) || r; r = ((glGetConvolutionParameterfvEXT = (PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionParameterfvEXT")) == NULL) || r; r = ((glGetConvolutionParameterivEXT = (PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionParameterivEXT")) == NULL) || r; r = ((glGetSeparableFilterEXT = (PFNGLGETSEPARABLEFILTEREXTPROC)glewGetProcAddress((const GLubyte*)"glGetSeparableFilterEXT")) == NULL) || r; r = ((glSeparableFilter2DEXT = (PFNGLSEPARABLEFILTER2DEXTPROC)glewGetProcAddress((const GLubyte*)"glSeparableFilter2DEXT")) == NULL) || r; return r; } #endif /* GL_EXT_convolution */ #ifdef GL_EXT_coordinate_frame static GLboolean _glewInit_GL_EXT_coordinate_frame (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBinormalPointerEXT = (PFNGLBINORMALPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glBinormalPointerEXT")) == NULL) || r; r = ((glTangentPointerEXT = (PFNGLTANGENTPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glTangentPointerEXT")) == NULL) || r; return r; } #endif /* GL_EXT_coordinate_frame */ #ifdef GL_EXT_copy_texture static GLboolean _glewInit_GL_EXT_copy_texture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glCopyTexImage1DEXT = (PFNGLCOPYTEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexImage1DEXT")) == NULL) || r; r = ((glCopyTexImage2DEXT = (PFNGLCOPYTEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexImage2DEXT")) == NULL) || r; r = ((glCopyTexSubImage1DEXT = (PFNGLCOPYTEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexSubImage1DEXT")) == NULL) || r; r = ((glCopyTexSubImage2DEXT = (PFNGLCOPYTEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexSubImage2DEXT")) == NULL) || r; r = ((glCopyTexSubImage3DEXT = (PFNGLCOPYTEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexSubImage3DEXT")) == NULL) || r; return r; } #endif /* GL_EXT_copy_texture */ #ifdef GL_EXT_cull_vertex static GLboolean _glewInit_GL_EXT_cull_vertex (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glCullParameterdvEXT = (PFNGLCULLPARAMETERDVEXTPROC)glewGetProcAddress((const GLubyte*)"glCullParameterdvEXT")) == NULL) || r; r = ((glCullParameterfvEXT = (PFNGLCULLPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glCullParameterfvEXT")) == NULL) || r; return r; } #endif /* GL_EXT_cull_vertex */ #ifdef GL_EXT_debug_label static GLboolean _glewInit_GL_EXT_debug_label (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetObjectLabelEXT = (PFNGLGETOBJECTLABELEXTPROC)glewGetProcAddress((const GLubyte*)"glGetObjectLabelEXT")) == NULL) || r; r = ((glLabelObjectEXT = (PFNGLLABELOBJECTEXTPROC)glewGetProcAddress((const GLubyte*)"glLabelObjectEXT")) == NULL) || r; return r; } #endif /* GL_EXT_debug_label */ #ifdef GL_EXT_debug_marker static GLboolean _glewInit_GL_EXT_debug_marker (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glInsertEventMarkerEXT = (PFNGLINSERTEVENTMARKEREXTPROC)glewGetProcAddress((const GLubyte*)"glInsertEventMarkerEXT")) == NULL) || r; r = ((glPopGroupMarkerEXT = (PFNGLPOPGROUPMARKEREXTPROC)glewGetProcAddress((const GLubyte*)"glPopGroupMarkerEXT")) == NULL) || r; r = ((glPushGroupMarkerEXT = (PFNGLPUSHGROUPMARKEREXTPROC)glewGetProcAddress((const GLubyte*)"glPushGroupMarkerEXT")) == NULL) || r; return r; } #endif /* GL_EXT_debug_marker */ #ifdef GL_EXT_depth_bounds_test static GLboolean _glewInit_GL_EXT_depth_bounds_test (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDepthBoundsEXT = (PFNGLDEPTHBOUNDSEXTPROC)glewGetProcAddress((const GLubyte*)"glDepthBoundsEXT")) == NULL) || r; return r; } #endif /* GL_EXT_depth_bounds_test */ #ifdef GL_EXT_direct_state_access static GLboolean _glewInit_GL_EXT_direct_state_access (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindMultiTextureEXT = (PFNGLBINDMULTITEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glBindMultiTextureEXT")) == NULL) || r; r = ((glCheckNamedFramebufferStatusEXT = (PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC)glewGetProcAddress((const GLubyte*)"glCheckNamedFramebufferStatusEXT")) == NULL) || r; r = ((glClientAttribDefaultEXT = (PFNGLCLIENTATTRIBDEFAULTEXTPROC)glewGetProcAddress((const GLubyte*)"glClientAttribDefaultEXT")) == NULL) || r; r = ((glCompressedMultiTexImage1DEXT = (PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexImage1DEXT")) == NULL) || r; r = ((glCompressedMultiTexImage2DEXT = (PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexImage2DEXT")) == NULL) || r; r = ((glCompressedMultiTexImage3DEXT = (PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexImage3DEXT")) == NULL) || r; r = ((glCompressedMultiTexSubImage1DEXT = (PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexSubImage1DEXT")) == NULL) || r; r = ((glCompressedMultiTexSubImage2DEXT = (PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexSubImage2DEXT")) == NULL) || r; r = ((glCompressedMultiTexSubImage3DEXT = (PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexSubImage3DEXT")) == NULL) || r; r = ((glCompressedTextureImage1DEXT = (PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureImage1DEXT")) == NULL) || r; r = ((glCompressedTextureImage2DEXT = (PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureImage2DEXT")) == NULL) || r; r = ((glCompressedTextureImage3DEXT = (PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureImage3DEXT")) == NULL) || r; r = ((glCompressedTextureSubImage1DEXT = (PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureSubImage1DEXT")) == NULL) || r; r = ((glCompressedTextureSubImage2DEXT = (PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureSubImage2DEXT")) == NULL) || r; r = ((glCompressedTextureSubImage3DEXT = (PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureSubImage3DEXT")) == NULL) || r; r = ((glCopyMultiTexImage1DEXT = (PFNGLCOPYMULTITEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexImage1DEXT")) == NULL) || r; r = ((glCopyMultiTexImage2DEXT = (PFNGLCOPYMULTITEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexImage2DEXT")) == NULL) || r; r = ((glCopyMultiTexSubImage1DEXT = (PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexSubImage1DEXT")) == NULL) || r; r = ((glCopyMultiTexSubImage2DEXT = (PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexSubImage2DEXT")) == NULL) || r; r = ((glCopyMultiTexSubImage3DEXT = (PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexSubImage3DEXT")) == NULL) || r; r = ((glCopyTextureImage1DEXT = (PFNGLCOPYTEXTUREIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureImage1DEXT")) == NULL) || r; r = ((glCopyTextureImage2DEXT = (PFNGLCOPYTEXTUREIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureImage2DEXT")) == NULL) || r; r = ((glCopyTextureSubImage1DEXT = (PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureSubImage1DEXT")) == NULL) || r; r = ((glCopyTextureSubImage2DEXT = (PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureSubImage2DEXT")) == NULL) || r; r = ((glCopyTextureSubImage3DEXT = (PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureSubImage3DEXT")) == NULL) || r; r = ((glDisableClientStateIndexedEXT = (PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableClientStateIndexedEXT")) == NULL) || r; r = ((glDisableClientStateiEXT = (PFNGLDISABLECLIENTSTATEIEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableClientStateiEXT")) == NULL) || r; r = ((glDisableVertexArrayAttribEXT = (PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableVertexArrayAttribEXT")) == NULL) || r; r = ((glDisableVertexArrayEXT = (PFNGLDISABLEVERTEXARRAYEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableVertexArrayEXT")) == NULL) || r; r = ((glEnableClientStateIndexedEXT = (PFNGLENABLECLIENTSTATEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableClientStateIndexedEXT")) == NULL) || r; r = ((glEnableClientStateiEXT = (PFNGLENABLECLIENTSTATEIEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableClientStateiEXT")) == NULL) || r; r = ((glEnableVertexArrayAttribEXT = (PFNGLENABLEVERTEXARRAYATTRIBEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableVertexArrayAttribEXT")) == NULL) || r; r = ((glEnableVertexArrayEXT = (PFNGLENABLEVERTEXARRAYEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableVertexArrayEXT")) == NULL) || r; r = ((glFlushMappedNamedBufferRangeEXT = (PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC)glewGetProcAddress((const GLubyte*)"glFlushMappedNamedBufferRangeEXT")) == NULL) || r; r = ((glFramebufferDrawBufferEXT = (PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferDrawBufferEXT")) == NULL) || r; r = ((glFramebufferDrawBuffersEXT = (PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferDrawBuffersEXT")) == NULL) || r; r = ((glFramebufferReadBufferEXT = (PFNGLFRAMEBUFFERREADBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferReadBufferEXT")) == NULL) || r; r = ((glGenerateMultiTexMipmapEXT = (PFNGLGENERATEMULTITEXMIPMAPEXTPROC)glewGetProcAddress((const GLubyte*)"glGenerateMultiTexMipmapEXT")) == NULL) || r; r = ((glGenerateTextureMipmapEXT = (PFNGLGENERATETEXTUREMIPMAPEXTPROC)glewGetProcAddress((const GLubyte*)"glGenerateTextureMipmapEXT")) == NULL) || r; r = ((glGetCompressedMultiTexImageEXT = (PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedMultiTexImageEXT")) == NULL) || r; r = ((glGetCompressedTextureImageEXT = (PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedTextureImageEXT")) == NULL) || r; r = ((glGetDoubleIndexedvEXT = (PFNGLGETDOUBLEINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetDoubleIndexedvEXT")) == NULL) || r; r = ((glGetDoublei_vEXT = (PFNGLGETDOUBLEI_VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetDoublei_vEXT")) == NULL) || r; r = ((glGetFloatIndexedvEXT = (PFNGLGETFLOATINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFloatIndexedvEXT")) == NULL) || r; r = ((glGetFloati_vEXT = (PFNGLGETFLOATI_VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFloati_vEXT")) == NULL) || r; r = ((glGetFramebufferParameterivEXT = (PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFramebufferParameterivEXT")) == NULL) || r; r = ((glGetMultiTexEnvfvEXT = (PFNGLGETMULTITEXENVFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexEnvfvEXT")) == NULL) || r; r = ((glGetMultiTexEnvivEXT = (PFNGLGETMULTITEXENVIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexEnvivEXT")) == NULL) || r; r = ((glGetMultiTexGendvEXT = (PFNGLGETMULTITEXGENDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexGendvEXT")) == NULL) || r; r = ((glGetMultiTexGenfvEXT = (PFNGLGETMULTITEXGENFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexGenfvEXT")) == NULL) || r; r = ((glGetMultiTexGenivEXT = (PFNGLGETMULTITEXGENIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexGenivEXT")) == NULL) || r; r = ((glGetMultiTexImageEXT = (PFNGLGETMULTITEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexImageEXT")) == NULL) || r; r = ((glGetMultiTexLevelParameterfvEXT = (PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexLevelParameterfvEXT")) == NULL) || r; r = ((glGetMultiTexLevelParameterivEXT = (PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexLevelParameterivEXT")) == NULL) || r; r = ((glGetMultiTexParameterIivEXT = (PFNGLGETMULTITEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexParameterIivEXT")) == NULL) || r; r = ((glGetMultiTexParameterIuivEXT = (PFNGLGETMULTITEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexParameterIuivEXT")) == NULL) || r; r = ((glGetMultiTexParameterfvEXT = (PFNGLGETMULTITEXPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexParameterfvEXT")) == NULL) || r; r = ((glGetMultiTexParameterivEXT = (PFNGLGETMULTITEXPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexParameterivEXT")) == NULL) || r; r = ((glGetNamedBufferParameterivEXT = (PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferParameterivEXT")) == NULL) || r; r = ((glGetNamedBufferPointervEXT = (PFNGLGETNAMEDBUFFERPOINTERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferPointervEXT")) == NULL) || r; r = ((glGetNamedBufferSubDataEXT = (PFNGLGETNAMEDBUFFERSUBDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferSubDataEXT")) == NULL) || r; r = ((glGetNamedFramebufferAttachmentParameterivEXT = (PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedFramebufferAttachmentParameterivEXT")) == NULL) || r; r = ((glGetNamedProgramLocalParameterIivEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramLocalParameterIivEXT")) == NULL) || r; r = ((glGetNamedProgramLocalParameterIuivEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramLocalParameterIuivEXT")) == NULL) || r; r = ((glGetNamedProgramLocalParameterdvEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramLocalParameterdvEXT")) == NULL) || r; r = ((glGetNamedProgramLocalParameterfvEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramLocalParameterfvEXT")) == NULL) || r; r = ((glGetNamedProgramStringEXT = (PFNGLGETNAMEDPROGRAMSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramStringEXT")) == NULL) || r; r = ((glGetNamedProgramivEXT = (PFNGLGETNAMEDPROGRAMIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramivEXT")) == NULL) || r; r = ((glGetNamedRenderbufferParameterivEXT = (PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedRenderbufferParameterivEXT")) == NULL) || r; r = ((glGetPointerIndexedvEXT = (PFNGLGETPOINTERINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetPointerIndexedvEXT")) == NULL) || r; r = ((glGetPointeri_vEXT = (PFNGLGETPOINTERI_VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetPointeri_vEXT")) == NULL) || r; r = ((glGetTextureImageEXT = (PFNGLGETTEXTUREIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureImageEXT")) == NULL) || r; r = ((glGetTextureLevelParameterfvEXT = (PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureLevelParameterfvEXT")) == NULL) || r; r = ((glGetTextureLevelParameterivEXT = (PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureLevelParameterivEXT")) == NULL) || r; r = ((glGetTextureParameterIivEXT = (PFNGLGETTEXTUREPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterIivEXT")) == NULL) || r; r = ((glGetTextureParameterIuivEXT = (PFNGLGETTEXTUREPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterIuivEXT")) == NULL) || r; r = ((glGetTextureParameterfvEXT = (PFNGLGETTEXTUREPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterfvEXT")) == NULL) || r; r = ((glGetTextureParameterivEXT = (PFNGLGETTEXTUREPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterivEXT")) == NULL) || r; r = ((glGetVertexArrayIntegeri_vEXT = (PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexArrayIntegeri_vEXT")) == NULL) || r; r = ((glGetVertexArrayIntegervEXT = (PFNGLGETVERTEXARRAYINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexArrayIntegervEXT")) == NULL) || r; r = ((glGetVertexArrayPointeri_vEXT = (PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexArrayPointeri_vEXT")) == NULL) || r; r = ((glGetVertexArrayPointervEXT = (PFNGLGETVERTEXARRAYPOINTERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexArrayPointervEXT")) == NULL) || r; r = ((glMapNamedBufferEXT = (PFNGLMAPNAMEDBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glMapNamedBufferEXT")) == NULL) || r; r = ((glMapNamedBufferRangeEXT = (PFNGLMAPNAMEDBUFFERRANGEEXTPROC)glewGetProcAddress((const GLubyte*)"glMapNamedBufferRangeEXT")) == NULL) || r; r = ((glMatrixFrustumEXT = (PFNGLMATRIXFRUSTUMEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixFrustumEXT")) == NULL) || r; r = ((glMatrixLoadIdentityEXT = (PFNGLMATRIXLOADIDENTITYEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadIdentityEXT")) == NULL) || r; r = ((glMatrixLoadTransposedEXT = (PFNGLMATRIXLOADTRANSPOSEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadTransposedEXT")) == NULL) || r; r = ((glMatrixLoadTransposefEXT = (PFNGLMATRIXLOADTRANSPOSEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadTransposefEXT")) == NULL) || r; r = ((glMatrixLoaddEXT = (PFNGLMATRIXLOADDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoaddEXT")) == NULL) || r; r = ((glMatrixLoadfEXT = (PFNGLMATRIXLOADFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadfEXT")) == NULL) || r; r = ((glMatrixMultTransposedEXT = (PFNGLMATRIXMULTTRANSPOSEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixMultTransposedEXT")) == NULL) || r; r = ((glMatrixMultTransposefEXT = (PFNGLMATRIXMULTTRANSPOSEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixMultTransposefEXT")) == NULL) || r; r = ((glMatrixMultdEXT = (PFNGLMATRIXMULTDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixMultdEXT")) == NULL) || r; r = ((glMatrixMultfEXT = (PFNGLMATRIXMULTFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixMultfEXT")) == NULL) || r; r = ((glMatrixOrthoEXT = (PFNGLMATRIXORTHOEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixOrthoEXT")) == NULL) || r; r = ((glMatrixPopEXT = (PFNGLMATRIXPOPEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixPopEXT")) == NULL) || r; r = ((glMatrixPushEXT = (PFNGLMATRIXPUSHEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixPushEXT")) == NULL) || r; r = ((glMatrixRotatedEXT = (PFNGLMATRIXROTATEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixRotatedEXT")) == NULL) || r; r = ((glMatrixRotatefEXT = (PFNGLMATRIXROTATEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixRotatefEXT")) == NULL) || r; r = ((glMatrixScaledEXT = (PFNGLMATRIXSCALEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixScaledEXT")) == NULL) || r; r = ((glMatrixScalefEXT = (PFNGLMATRIXSCALEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixScalefEXT")) == NULL) || r; r = ((glMatrixTranslatedEXT = (PFNGLMATRIXTRANSLATEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixTranslatedEXT")) == NULL) || r; r = ((glMatrixTranslatefEXT = (PFNGLMATRIXTRANSLATEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixTranslatefEXT")) == NULL) || r; r = ((glMultiTexBufferEXT = (PFNGLMULTITEXBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexBufferEXT")) == NULL) || r; r = ((glMultiTexCoordPointerEXT = (PFNGLMULTITEXCOORDPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordPointerEXT")) == NULL) || r; r = ((glMultiTexEnvfEXT = (PFNGLMULTITEXENVFEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexEnvfEXT")) == NULL) || r; r = ((glMultiTexEnvfvEXT = (PFNGLMULTITEXENVFVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexEnvfvEXT")) == NULL) || r; r = ((glMultiTexEnviEXT = (PFNGLMULTITEXENVIEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexEnviEXT")) == NULL) || r; r = ((glMultiTexEnvivEXT = (PFNGLMULTITEXENVIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexEnvivEXT")) == NULL) || r; r = ((glMultiTexGendEXT = (PFNGLMULTITEXGENDEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGendEXT")) == NULL) || r; r = ((glMultiTexGendvEXT = (PFNGLMULTITEXGENDVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGendvEXT")) == NULL) || r; r = ((glMultiTexGenfEXT = (PFNGLMULTITEXGENFEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGenfEXT")) == NULL) || r; r = ((glMultiTexGenfvEXT = (PFNGLMULTITEXGENFVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGenfvEXT")) == NULL) || r; r = ((glMultiTexGeniEXT = (PFNGLMULTITEXGENIEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGeniEXT")) == NULL) || r; r = ((glMultiTexGenivEXT = (PFNGLMULTITEXGENIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGenivEXT")) == NULL) || r; r = ((glMultiTexImage1DEXT = (PFNGLMULTITEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexImage1DEXT")) == NULL) || r; r = ((glMultiTexImage2DEXT = (PFNGLMULTITEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexImage2DEXT")) == NULL) || r; r = ((glMultiTexImage3DEXT = (PFNGLMULTITEXIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexImage3DEXT")) == NULL) || r; r = ((glMultiTexParameterIivEXT = (PFNGLMULTITEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterIivEXT")) == NULL) || r; r = ((glMultiTexParameterIuivEXT = (PFNGLMULTITEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterIuivEXT")) == NULL) || r; r = ((glMultiTexParameterfEXT = (PFNGLMULTITEXPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterfEXT")) == NULL) || r; r = ((glMultiTexParameterfvEXT = (PFNGLMULTITEXPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterfvEXT")) == NULL) || r; r = ((glMultiTexParameteriEXT = (PFNGLMULTITEXPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameteriEXT")) == NULL) || r; r = ((glMultiTexParameterivEXT = (PFNGLMULTITEXPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterivEXT")) == NULL) || r; r = ((glMultiTexRenderbufferEXT = (PFNGLMULTITEXRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexRenderbufferEXT")) == NULL) || r; r = ((glMultiTexSubImage1DEXT = (PFNGLMULTITEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexSubImage1DEXT")) == NULL) || r; r = ((glMultiTexSubImage2DEXT = (PFNGLMULTITEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexSubImage2DEXT")) == NULL) || r; r = ((glMultiTexSubImage3DEXT = (PFNGLMULTITEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexSubImage3DEXT")) == NULL) || r; r = ((glNamedBufferDataEXT = (PFNGLNAMEDBUFFERDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedBufferDataEXT")) == NULL) || r; r = ((glNamedBufferSubDataEXT = (PFNGLNAMEDBUFFERSUBDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedBufferSubDataEXT")) == NULL) || r; r = ((glNamedCopyBufferSubDataEXT = (PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedCopyBufferSubDataEXT")) == NULL) || r; r = ((glNamedFramebufferRenderbufferEXT = (PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferRenderbufferEXT")) == NULL) || r; r = ((glNamedFramebufferTexture1DEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTexture1DEXT")) == NULL) || r; r = ((glNamedFramebufferTexture2DEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTexture2DEXT")) == NULL) || r; r = ((glNamedFramebufferTexture3DEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTexture3DEXT")) == NULL) || r; r = ((glNamedFramebufferTextureEXT = (PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTextureEXT")) == NULL) || r; r = ((glNamedFramebufferTextureFaceEXT = (PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTextureFaceEXT")) == NULL) || r; r = ((glNamedFramebufferTextureLayerEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTextureLayerEXT")) == NULL) || r; r = ((glNamedProgramLocalParameter4dEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameter4dEXT")) == NULL) || r; r = ((glNamedProgramLocalParameter4dvEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameter4dvEXT")) == NULL) || r; r = ((glNamedProgramLocalParameter4fEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameter4fEXT")) == NULL) || r; r = ((glNamedProgramLocalParameter4fvEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameter4fvEXT")) == NULL) || r; r = ((glNamedProgramLocalParameterI4iEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameterI4iEXT")) == NULL) || r; r = ((glNamedProgramLocalParameterI4ivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameterI4ivEXT")) == NULL) || r; r = ((glNamedProgramLocalParameterI4uiEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameterI4uiEXT")) == NULL) || r; r = ((glNamedProgramLocalParameterI4uivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameterI4uivEXT")) == NULL) || r; r = ((glNamedProgramLocalParameters4fvEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameters4fvEXT")) == NULL) || r; r = ((glNamedProgramLocalParametersI4ivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParametersI4ivEXT")) == NULL) || r; r = ((glNamedProgramLocalParametersI4uivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParametersI4uivEXT")) == NULL) || r; r = ((glNamedProgramStringEXT = (PFNGLNAMEDPROGRAMSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramStringEXT")) == NULL) || r; r = ((glNamedRenderbufferStorageEXT = (PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedRenderbufferStorageEXT")) == NULL) || r; r = ((glNamedRenderbufferStorageMultisampleCoverageEXT = (PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedRenderbufferStorageMultisampleCoverageEXT")) == NULL) || r; r = ((glNamedRenderbufferStorageMultisampleEXT = (PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedRenderbufferStorageMultisampleEXT")) == NULL) || r; r = ((glProgramUniform1fEXT = (PFNGLPROGRAMUNIFORM1FEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1fEXT")) == NULL) || r; r = ((glProgramUniform1fvEXT = (PFNGLPROGRAMUNIFORM1FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1fvEXT")) == NULL) || r; r = ((glProgramUniform1iEXT = (PFNGLPROGRAMUNIFORM1IEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1iEXT")) == NULL) || r; r = ((glProgramUniform1ivEXT = (PFNGLPROGRAMUNIFORM1IVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1ivEXT")) == NULL) || r; r = ((glProgramUniform1uiEXT = (PFNGLPROGRAMUNIFORM1UIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1uiEXT")) == NULL) || r; r = ((glProgramUniform1uivEXT = (PFNGLPROGRAMUNIFORM1UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1uivEXT")) == NULL) || r; r = ((glProgramUniform2fEXT = (PFNGLPROGRAMUNIFORM2FEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2fEXT")) == NULL) || r; r = ((glProgramUniform2fvEXT = (PFNGLPROGRAMUNIFORM2FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2fvEXT")) == NULL) || r; r = ((glProgramUniform2iEXT = (PFNGLPROGRAMUNIFORM2IEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2iEXT")) == NULL) || r; r = ((glProgramUniform2ivEXT = (PFNGLPROGRAMUNIFORM2IVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2ivEXT")) == NULL) || r; r = ((glProgramUniform2uiEXT = (PFNGLPROGRAMUNIFORM2UIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2uiEXT")) == NULL) || r; r = ((glProgramUniform2uivEXT = (PFNGLPROGRAMUNIFORM2UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2uivEXT")) == NULL) || r; r = ((glProgramUniform3fEXT = (PFNGLPROGRAMUNIFORM3FEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3fEXT")) == NULL) || r; r = ((glProgramUniform3fvEXT = (PFNGLPROGRAMUNIFORM3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3fvEXT")) == NULL) || r; r = ((glProgramUniform3iEXT = (PFNGLPROGRAMUNIFORM3IEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3iEXT")) == NULL) || r; r = ((glProgramUniform3ivEXT = (PFNGLPROGRAMUNIFORM3IVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3ivEXT")) == NULL) || r; r = ((glProgramUniform3uiEXT = (PFNGLPROGRAMUNIFORM3UIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3uiEXT")) == NULL) || r; r = ((glProgramUniform3uivEXT = (PFNGLPROGRAMUNIFORM3UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3uivEXT")) == NULL) || r; r = ((glProgramUniform4fEXT = (PFNGLPROGRAMUNIFORM4FEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4fEXT")) == NULL) || r; r = ((glProgramUniform4fvEXT = (PFNGLPROGRAMUNIFORM4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4fvEXT")) == NULL) || r; r = ((glProgramUniform4iEXT = (PFNGLPROGRAMUNIFORM4IEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4iEXT")) == NULL) || r; r = ((glProgramUniform4ivEXT = (PFNGLPROGRAMUNIFORM4IVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4ivEXT")) == NULL) || r; r = ((glProgramUniform4uiEXT = (PFNGLPROGRAMUNIFORM4UIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4uiEXT")) == NULL) || r; r = ((glProgramUniform4uivEXT = (PFNGLPROGRAMUNIFORM4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4uivEXT")) == NULL) || r; r = ((glProgramUniformMatrix2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2fvEXT")) == NULL) || r; r = ((glProgramUniformMatrix2x3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2x3fvEXT")) == NULL) || r; r = ((glProgramUniformMatrix2x4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2x4fvEXT")) == NULL) || r; r = ((glProgramUniformMatrix3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3fvEXT")) == NULL) || r; r = ((glProgramUniformMatrix3x2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3x2fvEXT")) == NULL) || r; r = ((glProgramUniformMatrix3x4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3x4fvEXT")) == NULL) || r; r = ((glProgramUniformMatrix4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4fvEXT")) == NULL) || r; r = ((glProgramUniformMatrix4x2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4x2fvEXT")) == NULL) || r; r = ((glProgramUniformMatrix4x3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4x3fvEXT")) == NULL) || r; r = ((glPushClientAttribDefaultEXT = (PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC)glewGetProcAddress((const GLubyte*)"glPushClientAttribDefaultEXT")) == NULL) || r; r = ((glTextureBufferEXT = (PFNGLTEXTUREBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glTextureBufferEXT")) == NULL) || r; r = ((glTextureImage1DEXT = (PFNGLTEXTUREIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureImage1DEXT")) == NULL) || r; r = ((glTextureImage2DEXT = (PFNGLTEXTUREIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureImage2DEXT")) == NULL) || r; r = ((glTextureImage3DEXT = (PFNGLTEXTUREIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureImage3DEXT")) == NULL) || r; r = ((glTextureParameterIivEXT = (PFNGLTEXTUREPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterIivEXT")) == NULL) || r; r = ((glTextureParameterIuivEXT = (PFNGLTEXTUREPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterIuivEXT")) == NULL) || r; r = ((glTextureParameterfEXT = (PFNGLTEXTUREPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterfEXT")) == NULL) || r; r = ((glTextureParameterfvEXT = (PFNGLTEXTUREPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterfvEXT")) == NULL) || r; r = ((glTextureParameteriEXT = (PFNGLTEXTUREPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameteriEXT")) == NULL) || r; r = ((glTextureParameterivEXT = (PFNGLTEXTUREPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterivEXT")) == NULL) || r; r = ((glTextureRenderbufferEXT = (PFNGLTEXTURERENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glTextureRenderbufferEXT")) == NULL) || r; r = ((glTextureSubImage1DEXT = (PFNGLTEXTURESUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureSubImage1DEXT")) == NULL) || r; r = ((glTextureSubImage2DEXT = (PFNGLTEXTURESUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureSubImage2DEXT")) == NULL) || r; r = ((glTextureSubImage3DEXT = (PFNGLTEXTURESUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureSubImage3DEXT")) == NULL) || r; r = ((glUnmapNamedBufferEXT = (PFNGLUNMAPNAMEDBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glUnmapNamedBufferEXT")) == NULL) || r; r = ((glVertexArrayColorOffsetEXT = (PFNGLVERTEXARRAYCOLOROFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayColorOffsetEXT")) == NULL) || r; r = ((glVertexArrayEdgeFlagOffsetEXT = (PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayEdgeFlagOffsetEXT")) == NULL) || r; r = ((glVertexArrayFogCoordOffsetEXT = (PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayFogCoordOffsetEXT")) == NULL) || r; r = ((glVertexArrayIndexOffsetEXT = (PFNGLVERTEXARRAYINDEXOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayIndexOffsetEXT")) == NULL) || r; r = ((glVertexArrayMultiTexCoordOffsetEXT = (PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayMultiTexCoordOffsetEXT")) == NULL) || r; r = ((glVertexArrayNormalOffsetEXT = (PFNGLVERTEXARRAYNORMALOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayNormalOffsetEXT")) == NULL) || r; r = ((glVertexArraySecondaryColorOffsetEXT = (PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArraySecondaryColorOffsetEXT")) == NULL) || r; r = ((glVertexArrayTexCoordOffsetEXT = (PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayTexCoordOffsetEXT")) == NULL) || r; r = ((glVertexArrayVertexAttribDivisorEXT = (PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexAttribDivisorEXT")) == NULL) || r; r = ((glVertexArrayVertexAttribIOffsetEXT = (PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexAttribIOffsetEXT")) == NULL) || r; r = ((glVertexArrayVertexAttribOffsetEXT = (PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexAttribOffsetEXT")) == NULL) || r; r = ((glVertexArrayVertexOffsetEXT = (PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexOffsetEXT")) == NULL) || r; return r; } #endif /* GL_EXT_direct_state_access */ #ifdef GL_EXT_draw_buffers2 static GLboolean _glewInit_GL_EXT_draw_buffers2 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glColorMaskIndexedEXT = (PFNGLCOLORMASKINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glColorMaskIndexedEXT")) == NULL) || r; r = ((glDisableIndexedEXT = (PFNGLDISABLEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableIndexedEXT")) == NULL) || r; r = ((glEnableIndexedEXT = (PFNGLENABLEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableIndexedEXT")) == NULL) || r; r = ((glGetBooleanIndexedvEXT = (PFNGLGETBOOLEANINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetBooleanIndexedvEXT")) == NULL) || r; r = ((glGetIntegerIndexedvEXT = (PFNGLGETINTEGERINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetIntegerIndexedvEXT")) == NULL) || r; r = ((glIsEnabledIndexedEXT = (PFNGLISENABLEDINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glIsEnabledIndexedEXT")) == NULL) || r; return r; } #endif /* GL_EXT_draw_buffers2 */ #ifdef GL_EXT_draw_instanced static GLboolean _glewInit_GL_EXT_draw_instanced (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDrawArraysInstancedEXT = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysInstancedEXT")) == NULL) || r; r = ((glDrawElementsInstancedEXT = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsInstancedEXT")) == NULL) || r; return r; } #endif /* GL_EXT_draw_instanced */ #ifdef GL_EXT_draw_range_elements static GLboolean _glewInit_GL_EXT_draw_range_elements (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDrawRangeElementsEXT = (PFNGLDRAWRANGEELEMENTSEXTPROC)glewGetProcAddress((const GLubyte*)"glDrawRangeElementsEXT")) == NULL) || r; return r; } #endif /* GL_EXT_draw_range_elements */ #ifdef GL_EXT_fog_coord static GLboolean _glewInit_GL_EXT_fog_coord (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFogCoordPointerEXT = (PFNGLFOGCOORDPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoordPointerEXT")) == NULL) || r; r = ((glFogCoorddEXT = (PFNGLFOGCOORDDEXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoorddEXT")) == NULL) || r; r = ((glFogCoorddvEXT = (PFNGLFOGCOORDDVEXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoorddvEXT")) == NULL) || r; r = ((glFogCoordfEXT = (PFNGLFOGCOORDFEXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoordfEXT")) == NULL) || r; r = ((glFogCoordfvEXT = (PFNGLFOGCOORDFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoordfvEXT")) == NULL) || r; return r; } #endif /* GL_EXT_fog_coord */ #ifdef GL_EXT_fragment_lighting static GLboolean _glewInit_GL_EXT_fragment_lighting (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFragmentColorMaterialEXT = (PFNGLFRAGMENTCOLORMATERIALEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentColorMaterialEXT")) == NULL) || r; r = ((glFragmentLightModelfEXT = (PFNGLFRAGMENTLIGHTMODELFEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelfEXT")) == NULL) || r; r = ((glFragmentLightModelfvEXT = (PFNGLFRAGMENTLIGHTMODELFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelfvEXT")) == NULL) || r; r = ((glFragmentLightModeliEXT = (PFNGLFRAGMENTLIGHTMODELIEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModeliEXT")) == NULL) || r; r = ((glFragmentLightModelivEXT = (PFNGLFRAGMENTLIGHTMODELIVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelivEXT")) == NULL) || r; r = ((glFragmentLightfEXT = (PFNGLFRAGMENTLIGHTFEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightfEXT")) == NULL) || r; r = ((glFragmentLightfvEXT = (PFNGLFRAGMENTLIGHTFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightfvEXT")) == NULL) || r; r = ((glFragmentLightiEXT = (PFNGLFRAGMENTLIGHTIEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightiEXT")) == NULL) || r; r = ((glFragmentLightivEXT = (PFNGLFRAGMENTLIGHTIVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightivEXT")) == NULL) || r; r = ((glFragmentMaterialfEXT = (PFNGLFRAGMENTMATERIALFEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialfEXT")) == NULL) || r; r = ((glFragmentMaterialfvEXT = (PFNGLFRAGMENTMATERIALFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialfvEXT")) == NULL) || r; r = ((glFragmentMaterialiEXT = (PFNGLFRAGMENTMATERIALIEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialiEXT")) == NULL) || r; r = ((glFragmentMaterialivEXT = (PFNGLFRAGMENTMATERIALIVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialivEXT")) == NULL) || r; r = ((glGetFragmentLightfvEXT = (PFNGLGETFRAGMENTLIGHTFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentLightfvEXT")) == NULL) || r; r = ((glGetFragmentLightivEXT = (PFNGLGETFRAGMENTLIGHTIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentLightivEXT")) == NULL) || r; r = ((glGetFragmentMaterialfvEXT = (PFNGLGETFRAGMENTMATERIALFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentMaterialfvEXT")) == NULL) || r; r = ((glGetFragmentMaterialivEXT = (PFNGLGETFRAGMENTMATERIALIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentMaterialivEXT")) == NULL) || r; r = ((glLightEnviEXT = (PFNGLLIGHTENVIEXTPROC)glewGetProcAddress((const GLubyte*)"glLightEnviEXT")) == NULL) || r; return r; } #endif /* GL_EXT_fragment_lighting */ #ifdef GL_EXT_framebuffer_blit static GLboolean _glewInit_GL_EXT_framebuffer_blit (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBlitFramebufferEXT = (PFNGLBLITFRAMEBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glBlitFramebufferEXT")) == NULL) || r; return r; } #endif /* GL_EXT_framebuffer_blit */ #ifdef GL_EXT_framebuffer_multisample static GLboolean _glewInit_GL_EXT_framebuffer_multisample (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorageMultisampleEXT")) == NULL) || r; return r; } #endif /* GL_EXT_framebuffer_multisample */ #ifdef GL_EXT_framebuffer_object static GLboolean _glewInit_GL_EXT_framebuffer_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindFramebufferEXT")) == NULL) || r; r = ((glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindRenderbufferEXT")) == NULL) || r; r = ((glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)glewGetProcAddress((const GLubyte*)"glCheckFramebufferStatusEXT")) == NULL) || r; r = ((glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glDeleteFramebuffersEXT")) == NULL) || r; r = ((glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glDeleteRenderbuffersEXT")) == NULL) || r; r = ((glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferRenderbufferEXT")) == NULL) || r; r = ((glFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture1DEXT")) == NULL) || r; r = ((glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture2DEXT")) == NULL) || r; r = ((glFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture3DEXT")) == NULL) || r; r = ((glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glGenFramebuffersEXT")) == NULL) || r; r = ((glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glGenRenderbuffersEXT")) == NULL) || r; r = ((glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)glewGetProcAddress((const GLubyte*)"glGenerateMipmapEXT")) == NULL) || r; r = ((glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFramebufferAttachmentParameterivEXT")) == NULL) || r; r = ((glGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetRenderbufferParameterivEXT")) == NULL) || r; r = ((glIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glIsFramebufferEXT")) == NULL) || r; r = ((glIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glIsRenderbufferEXT")) == NULL) || r; r = ((glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorageEXT")) == NULL) || r; return r; } #endif /* GL_EXT_framebuffer_object */ #ifdef GL_EXT_geometry_shader4 static GLboolean _glewInit_GL_EXT_geometry_shader4 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFramebufferTextureEXT = (PFNGLFRAMEBUFFERTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureEXT")) == NULL) || r; r = ((glFramebufferTextureFaceEXT = (PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureFaceEXT")) == NULL) || r; r = ((glProgramParameteriEXT = (PFNGLPROGRAMPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramParameteriEXT")) == NULL) || r; return r; } #endif /* GL_EXT_geometry_shader4 */ #ifdef GL_EXT_gpu_program_parameters static GLboolean _glewInit_GL_EXT_gpu_program_parameters (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glProgramEnvParameters4fvEXT = (PFNGLPROGRAMENVPARAMETERS4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameters4fvEXT")) == NULL) || r; r = ((glProgramLocalParameters4fvEXT = (PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameters4fvEXT")) == NULL) || r; return r; } #endif /* GL_EXT_gpu_program_parameters */ #ifdef GL_EXT_gpu_shader4 static GLboolean _glewInit_GL_EXT_gpu_shader4 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindFragDataLocationEXT = (PFNGLBINDFRAGDATALOCATIONEXTPROC)glewGetProcAddress((const GLubyte*)"glBindFragDataLocationEXT")) == NULL) || r; r = ((glGetFragDataLocationEXT = (PFNGLGETFRAGDATALOCATIONEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragDataLocationEXT")) == NULL) || r; r = ((glGetUniformuivEXT = (PFNGLGETUNIFORMUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetUniformuivEXT")) == NULL) || r; r = ((glGetVertexAttribIivEXT = (PFNGLGETVERTEXATTRIBIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribIivEXT")) == NULL) || r; r = ((glGetVertexAttribIuivEXT = (PFNGLGETVERTEXATTRIBIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribIuivEXT")) == NULL) || r; r = ((glUniform1uiEXT = (PFNGLUNIFORM1UIEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform1uiEXT")) == NULL) || r; r = ((glUniform1uivEXT = (PFNGLUNIFORM1UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform1uivEXT")) == NULL) || r; r = ((glUniform2uiEXT = (PFNGLUNIFORM2UIEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform2uiEXT")) == NULL) || r; r = ((glUniform2uivEXT = (PFNGLUNIFORM2UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform2uivEXT")) == NULL) || r; r = ((glUniform3uiEXT = (PFNGLUNIFORM3UIEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform3uiEXT")) == NULL) || r; r = ((glUniform3uivEXT = (PFNGLUNIFORM3UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform3uivEXT")) == NULL) || r; r = ((glUniform4uiEXT = (PFNGLUNIFORM4UIEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform4uiEXT")) == NULL) || r; r = ((glUniform4uivEXT = (PFNGLUNIFORM4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform4uivEXT")) == NULL) || r; r = ((glVertexAttribI1iEXT = (PFNGLVERTEXATTRIBI1IEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1iEXT")) == NULL) || r; r = ((glVertexAttribI1ivEXT = (PFNGLVERTEXATTRIBI1IVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1ivEXT")) == NULL) || r; r = ((glVertexAttribI1uiEXT = (PFNGLVERTEXATTRIBI1UIEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1uiEXT")) == NULL) || r; r = ((glVertexAttribI1uivEXT = (PFNGLVERTEXATTRIBI1UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1uivEXT")) == NULL) || r; r = ((glVertexAttribI2iEXT = (PFNGLVERTEXATTRIBI2IEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2iEXT")) == NULL) || r; r = ((glVertexAttribI2ivEXT = (PFNGLVERTEXATTRIBI2IVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2ivEXT")) == NULL) || r; r = ((glVertexAttribI2uiEXT = (PFNGLVERTEXATTRIBI2UIEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2uiEXT")) == NULL) || r; r = ((glVertexAttribI2uivEXT = (PFNGLVERTEXATTRIBI2UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2uivEXT")) == NULL) || r; r = ((glVertexAttribI3iEXT = (PFNGLVERTEXATTRIBI3IEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3iEXT")) == NULL) || r; r = ((glVertexAttribI3ivEXT = (PFNGLVERTEXATTRIBI3IVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3ivEXT")) == NULL) || r; r = ((glVertexAttribI3uiEXT = (PFNGLVERTEXATTRIBI3UIEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3uiEXT")) == NULL) || r; r = ((glVertexAttribI3uivEXT = (PFNGLVERTEXATTRIBI3UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3uivEXT")) == NULL) || r; r = ((glVertexAttribI4bvEXT = (PFNGLVERTEXATTRIBI4BVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4bvEXT")) == NULL) || r; r = ((glVertexAttribI4iEXT = (PFNGLVERTEXATTRIBI4IEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4iEXT")) == NULL) || r; r = ((glVertexAttribI4ivEXT = (PFNGLVERTEXATTRIBI4IVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4ivEXT")) == NULL) || r; r = ((glVertexAttribI4svEXT = (PFNGLVERTEXATTRIBI4SVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4svEXT")) == NULL) || r; r = ((glVertexAttribI4ubvEXT = (PFNGLVERTEXATTRIBI4UBVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4ubvEXT")) == NULL) || r; r = ((glVertexAttribI4uiEXT = (PFNGLVERTEXATTRIBI4UIEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4uiEXT")) == NULL) || r; r = ((glVertexAttribI4uivEXT = (PFNGLVERTEXATTRIBI4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4uivEXT")) == NULL) || r; r = ((glVertexAttribI4usvEXT = (PFNGLVERTEXATTRIBI4USVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4usvEXT")) == NULL) || r; r = ((glVertexAttribIPointerEXT = (PFNGLVERTEXATTRIBIPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribIPointerEXT")) == NULL) || r; return r; } #endif /* GL_EXT_gpu_shader4 */ #ifdef GL_EXT_histogram static GLboolean _glewInit_GL_EXT_histogram (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetHistogramEXT = (PFNGLGETHISTOGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramEXT")) == NULL) || r; r = ((glGetHistogramParameterfvEXT = (PFNGLGETHISTOGRAMPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramParameterfvEXT")) == NULL) || r; r = ((glGetHistogramParameterivEXT = (PFNGLGETHISTOGRAMPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramParameterivEXT")) == NULL) || r; r = ((glGetMinmaxEXT = (PFNGLGETMINMAXEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxEXT")) == NULL) || r; r = ((glGetMinmaxParameterfvEXT = (PFNGLGETMINMAXPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxParameterfvEXT")) == NULL) || r; r = ((glGetMinmaxParameterivEXT = (PFNGLGETMINMAXPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxParameterivEXT")) == NULL) || r; r = ((glHistogramEXT = (PFNGLHISTOGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glHistogramEXT")) == NULL) || r; r = ((glMinmaxEXT = (PFNGLMINMAXEXTPROC)glewGetProcAddress((const GLubyte*)"glMinmaxEXT")) == NULL) || r; r = ((glResetHistogramEXT = (PFNGLRESETHISTOGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glResetHistogramEXT")) == NULL) || r; r = ((glResetMinmaxEXT = (PFNGLRESETMINMAXEXTPROC)glewGetProcAddress((const GLubyte*)"glResetMinmaxEXT")) == NULL) || r; return r; } #endif /* GL_EXT_histogram */ #ifdef GL_EXT_index_func static GLboolean _glewInit_GL_EXT_index_func (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glIndexFuncEXT = (PFNGLINDEXFUNCEXTPROC)glewGetProcAddress((const GLubyte*)"glIndexFuncEXT")) == NULL) || r; return r; } #endif /* GL_EXT_index_func */ #ifdef GL_EXT_index_material static GLboolean _glewInit_GL_EXT_index_material (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glIndexMaterialEXT = (PFNGLINDEXMATERIALEXTPROC)glewGetProcAddress((const GLubyte*)"glIndexMaterialEXT")) == NULL) || r; return r; } #endif /* GL_EXT_index_material */ #ifdef GL_EXT_light_texture static GLboolean _glewInit_GL_EXT_light_texture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glApplyTextureEXT = (PFNGLAPPLYTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glApplyTextureEXT")) == NULL) || r; r = ((glTextureLightEXT = (PFNGLTEXTURELIGHTEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureLightEXT")) == NULL) || r; r = ((glTextureMaterialEXT = (PFNGLTEXTUREMATERIALEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureMaterialEXT")) == NULL) || r; return r; } #endif /* GL_EXT_light_texture */ #ifdef GL_EXT_multi_draw_arrays static GLboolean _glewInit_GL_EXT_multi_draw_arrays (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawArraysEXT")) == NULL) || r; r = ((glMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElementsEXT")) == NULL) || r; return r; } #endif /* GL_EXT_multi_draw_arrays */ #ifdef GL_EXT_multisample static GLboolean _glewInit_GL_EXT_multisample (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glSampleMaskEXT = (PFNGLSAMPLEMASKEXTPROC)glewGetProcAddress((const GLubyte*)"glSampleMaskEXT")) == NULL) || r; r = ((glSamplePatternEXT = (PFNGLSAMPLEPATTERNEXTPROC)glewGetProcAddress((const GLubyte*)"glSamplePatternEXT")) == NULL) || r; return r; } #endif /* GL_EXT_multisample */ #ifdef GL_EXT_paletted_texture static GLboolean _glewInit_GL_EXT_paletted_texture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glColorTableEXT = (PFNGLCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"glColorTableEXT")) == NULL) || r; r = ((glGetColorTableEXT = (PFNGLGETCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableEXT")) == NULL) || r; r = ((glGetColorTableParameterfvEXT = (PFNGLGETCOLORTABLEPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterfvEXT")) == NULL) || r; r = ((glGetColorTableParameterivEXT = (PFNGLGETCOLORTABLEPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterivEXT")) == NULL) || r; return r; } #endif /* GL_EXT_paletted_texture */ #ifdef GL_EXT_pixel_transform static GLboolean _glewInit_GL_EXT_pixel_transform (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetPixelTransformParameterfvEXT = (PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetPixelTransformParameterfvEXT")) == NULL) || r; r = ((glGetPixelTransformParameterivEXT = (PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetPixelTransformParameterivEXT")) == NULL) || r; r = ((glPixelTransformParameterfEXT = (PFNGLPIXELTRANSFORMPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glPixelTransformParameterfEXT")) == NULL) || r; r = ((glPixelTransformParameterfvEXT = (PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glPixelTransformParameterfvEXT")) == NULL) || r; r = ((glPixelTransformParameteriEXT = (PFNGLPIXELTRANSFORMPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glPixelTransformParameteriEXT")) == NULL) || r; r = ((glPixelTransformParameterivEXT = (PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glPixelTransformParameterivEXT")) == NULL) || r; return r; } #endif /* GL_EXT_pixel_transform */ #ifdef GL_EXT_point_parameters static GLboolean _glewInit_GL_EXT_point_parameters (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glPointParameterfEXT = (PFNGLPOINTPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfEXT")) == NULL) || r; r = ((glPointParameterfvEXT = (PFNGLPOINTPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfvEXT")) == NULL) || r; return r; } #endif /* GL_EXT_point_parameters */ #ifdef GL_EXT_polygon_offset static GLboolean _glewInit_GL_EXT_polygon_offset (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glPolygonOffsetEXT = (PFNGLPOLYGONOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glPolygonOffsetEXT")) == NULL) || r; return r; } #endif /* GL_EXT_polygon_offset */ #ifdef GL_EXT_polygon_offset_clamp static GLboolean _glewInit_GL_EXT_polygon_offset_clamp (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glPolygonOffsetClampEXT = (PFNGLPOLYGONOFFSETCLAMPEXTPROC)glewGetProcAddress((const GLubyte*)"glPolygonOffsetClampEXT")) == NULL) || r; return r; } #endif /* GL_EXT_polygon_offset_clamp */ #ifdef GL_EXT_provoking_vertex static GLboolean _glewInit_GL_EXT_provoking_vertex (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glProvokingVertexEXT = (PFNGLPROVOKINGVERTEXEXTPROC)glewGetProcAddress((const GLubyte*)"glProvokingVertexEXT")) == NULL) || r; return r; } #endif /* GL_EXT_provoking_vertex */ #ifdef GL_EXT_raster_multisample static GLboolean _glewInit_GL_EXT_raster_multisample (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glCoverageModulationNV = (PFNGLCOVERAGEMODULATIONNVPROC)glewGetProcAddress((const GLubyte*)"glCoverageModulationNV")) == NULL) || r; r = ((glCoverageModulationTableNV = (PFNGLCOVERAGEMODULATIONTABLENVPROC)glewGetProcAddress((const GLubyte*)"glCoverageModulationTableNV")) == NULL) || r; r = ((glGetCoverageModulationTableNV = (PFNGLGETCOVERAGEMODULATIONTABLENVPROC)glewGetProcAddress((const GLubyte*)"glGetCoverageModulationTableNV")) == NULL) || r; r = ((glRasterSamplesEXT = (PFNGLRASTERSAMPLESEXTPROC)glewGetProcAddress((const GLubyte*)"glRasterSamplesEXT")) == NULL) || r; return r; } #endif /* GL_EXT_raster_multisample */ #ifdef GL_EXT_scene_marker static GLboolean _glewInit_GL_EXT_scene_marker (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBeginSceneEXT = (PFNGLBEGINSCENEEXTPROC)glewGetProcAddress((const GLubyte*)"glBeginSceneEXT")) == NULL) || r; r = ((glEndSceneEXT = (PFNGLENDSCENEEXTPROC)glewGetProcAddress((const GLubyte*)"glEndSceneEXT")) == NULL) || r; return r; } #endif /* GL_EXT_scene_marker */ #ifdef GL_EXT_secondary_color static GLboolean _glewInit_GL_EXT_secondary_color (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glSecondaryColor3bEXT = (PFNGLSECONDARYCOLOR3BEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3bEXT")) == NULL) || r; r = ((glSecondaryColor3bvEXT = (PFNGLSECONDARYCOLOR3BVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3bvEXT")) == NULL) || r; r = ((glSecondaryColor3dEXT = (PFNGLSECONDARYCOLOR3DEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3dEXT")) == NULL) || r; r = ((glSecondaryColor3dvEXT = (PFNGLSECONDARYCOLOR3DVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3dvEXT")) == NULL) || r; r = ((glSecondaryColor3fEXT = (PFNGLSECONDARYCOLOR3FEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3fEXT")) == NULL) || r; r = ((glSecondaryColor3fvEXT = (PFNGLSECONDARYCOLOR3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3fvEXT")) == NULL) || r; r = ((glSecondaryColor3iEXT = (PFNGLSECONDARYCOLOR3IEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3iEXT")) == NULL) || r; r = ((glSecondaryColor3ivEXT = (PFNGLSECONDARYCOLOR3IVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ivEXT")) == NULL) || r; r = ((glSecondaryColor3sEXT = (PFNGLSECONDARYCOLOR3SEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3sEXT")) == NULL) || r; r = ((glSecondaryColor3svEXT = (PFNGLSECONDARYCOLOR3SVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3svEXT")) == NULL) || r; r = ((glSecondaryColor3ubEXT = (PFNGLSECONDARYCOLOR3UBEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ubEXT")) == NULL) || r; r = ((glSecondaryColor3ubvEXT = (PFNGLSECONDARYCOLOR3UBVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ubvEXT")) == NULL) || r; r = ((glSecondaryColor3uiEXT = (PFNGLSECONDARYCOLOR3UIEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3uiEXT")) == NULL) || r; r = ((glSecondaryColor3uivEXT = (PFNGLSECONDARYCOLOR3UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3uivEXT")) == NULL) || r; r = ((glSecondaryColor3usEXT = (PFNGLSECONDARYCOLOR3USEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3usEXT")) == NULL) || r; r = ((glSecondaryColor3usvEXT = (PFNGLSECONDARYCOLOR3USVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3usvEXT")) == NULL) || r; r = ((glSecondaryColorPointerEXT = (PFNGLSECONDARYCOLORPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorPointerEXT")) == NULL) || r; return r; } #endif /* GL_EXT_secondary_color */ #ifdef GL_EXT_separate_shader_objects static GLboolean _glewInit_GL_EXT_separate_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glActiveProgramEXT = (PFNGLACTIVEPROGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glActiveProgramEXT")) == NULL) || r; r = ((glCreateShaderProgramEXT = (PFNGLCREATESHADERPROGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glCreateShaderProgramEXT")) == NULL) || r; r = ((glUseShaderProgramEXT = (PFNGLUSESHADERPROGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glUseShaderProgramEXT")) == NULL) || r; return r; } #endif /* GL_EXT_separate_shader_objects */ #ifdef GL_EXT_shader_image_load_store static GLboolean _glewInit_GL_EXT_shader_image_load_store (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindImageTextureEXT = (PFNGLBINDIMAGETEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glBindImageTextureEXT")) == NULL) || r; r = ((glMemoryBarrierEXT = (PFNGLMEMORYBARRIEREXTPROC)glewGetProcAddress((const GLubyte*)"glMemoryBarrierEXT")) == NULL) || r; return r; } #endif /* GL_EXT_shader_image_load_store */ #ifdef GL_EXT_stencil_two_side static GLboolean _glewInit_GL_EXT_stencil_two_side (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glActiveStencilFaceEXT = (PFNGLACTIVESTENCILFACEEXTPROC)glewGetProcAddress((const GLubyte*)"glActiveStencilFaceEXT")) == NULL) || r; return r; } #endif /* GL_EXT_stencil_two_side */ #ifdef GL_EXT_subtexture static GLboolean _glewInit_GL_EXT_subtexture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTexSubImage1DEXT = (PFNGLTEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage1DEXT")) == NULL) || r; r = ((glTexSubImage2DEXT = (PFNGLTEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage2DEXT")) == NULL) || r; r = ((glTexSubImage3DEXT = (PFNGLTEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage3DEXT")) == NULL) || r; return r; } #endif /* GL_EXT_subtexture */ #ifdef GL_EXT_texture3D static GLboolean _glewInit_GL_EXT_texture3D (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTexImage3DEXT = (PFNGLTEXIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glTexImage3DEXT")) == NULL) || r; return r; } #endif /* GL_EXT_texture3D */ #ifdef GL_EXT_texture_array static GLboolean _glewInit_GL_EXT_texture_array (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFramebufferTextureLayerEXT = (PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureLayerEXT")) == NULL) || r; return r; } #endif /* GL_EXT_texture_array */ #ifdef GL_EXT_texture_buffer_object static GLboolean _glewInit_GL_EXT_texture_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTexBufferEXT = (PFNGLTEXBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glTexBufferEXT")) == NULL) || r; return r; } #endif /* GL_EXT_texture_buffer_object */ #ifdef GL_EXT_texture_integer static GLboolean _glewInit_GL_EXT_texture_integer (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glClearColorIiEXT = (PFNGLCLEARCOLORIIEXTPROC)glewGetProcAddress((const GLubyte*)"glClearColorIiEXT")) == NULL) || r; r = ((glClearColorIuiEXT = (PFNGLCLEARCOLORIUIEXTPROC)glewGetProcAddress((const GLubyte*)"glClearColorIuiEXT")) == NULL) || r; r = ((glGetTexParameterIivEXT = (PFNGLGETTEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterIivEXT")) == NULL) || r; r = ((glGetTexParameterIuivEXT = (PFNGLGETTEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterIuivEXT")) == NULL) || r; r = ((glTexParameterIivEXT = (PFNGLTEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTexParameterIivEXT")) == NULL) || r; r = ((glTexParameterIuivEXT = (PFNGLTEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTexParameterIuivEXT")) == NULL) || r; return r; } #endif /* GL_EXT_texture_integer */ #ifdef GL_EXT_texture_object static GLboolean _glewInit_GL_EXT_texture_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glAreTexturesResidentEXT = (PFNGLARETEXTURESRESIDENTEXTPROC)glewGetProcAddress((const GLubyte*)"glAreTexturesResidentEXT")) == NULL) || r; r = ((glBindTextureEXT = (PFNGLBINDTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glBindTextureEXT")) == NULL) || r; r = ((glDeleteTexturesEXT = (PFNGLDELETETEXTURESEXTPROC)glewGetProcAddress((const GLubyte*)"glDeleteTexturesEXT")) == NULL) || r; r = ((glGenTexturesEXT = (PFNGLGENTEXTURESEXTPROC)glewGetProcAddress((const GLubyte*)"glGenTexturesEXT")) == NULL) || r; r = ((glIsTextureEXT = (PFNGLISTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glIsTextureEXT")) == NULL) || r; r = ((glPrioritizeTexturesEXT = (PFNGLPRIORITIZETEXTURESEXTPROC)glewGetProcAddress((const GLubyte*)"glPrioritizeTexturesEXT")) == NULL) || r; return r; } #endif /* GL_EXT_texture_object */ #ifdef GL_EXT_texture_perturb_normal static GLboolean _glewInit_GL_EXT_texture_perturb_normal (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTextureNormalEXT = (PFNGLTEXTURENORMALEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureNormalEXT")) == NULL) || r; return r; } #endif /* GL_EXT_texture_perturb_normal */ #ifdef GL_EXT_timer_query static GLboolean _glewInit_GL_EXT_timer_query (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetQueryObjecti64vEXT = (PFNGLGETQUERYOBJECTI64VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjecti64vEXT")) == NULL) || r; r = ((glGetQueryObjectui64vEXT = (PFNGLGETQUERYOBJECTUI64VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectui64vEXT")) == NULL) || r; return r; } #endif /* GL_EXT_timer_query */ #ifdef GL_EXT_transform_feedback static GLboolean _glewInit_GL_EXT_transform_feedback (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBeginTransformFeedbackEXT = (PFNGLBEGINTRANSFORMFEEDBACKEXTPROC)glewGetProcAddress((const GLubyte*)"glBeginTransformFeedbackEXT")) == NULL) || r; r = ((glBindBufferBaseEXT = (PFNGLBINDBUFFERBASEEXTPROC)glewGetProcAddress((const GLubyte*)"glBindBufferBaseEXT")) == NULL) || r; r = ((glBindBufferOffsetEXT = (PFNGLBINDBUFFEROFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glBindBufferOffsetEXT")) == NULL) || r; r = ((glBindBufferRangeEXT = (PFNGLBINDBUFFERRANGEEXTPROC)glewGetProcAddress((const GLubyte*)"glBindBufferRangeEXT")) == NULL) || r; r = ((glEndTransformFeedbackEXT = (PFNGLENDTRANSFORMFEEDBACKEXTPROC)glewGetProcAddress((const GLubyte*)"glEndTransformFeedbackEXT")) == NULL) || r; r = ((glGetTransformFeedbackVaryingEXT = (PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTransformFeedbackVaryingEXT")) == NULL) || r; r = ((glTransformFeedbackVaryingsEXT = (PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC)glewGetProcAddress((const GLubyte*)"glTransformFeedbackVaryingsEXT")) == NULL) || r; return r; } #endif /* GL_EXT_transform_feedback */ #ifdef GL_EXT_vertex_array static GLboolean _glewInit_GL_EXT_vertex_array (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glArrayElementEXT = (PFNGLARRAYELEMENTEXTPROC)glewGetProcAddress((const GLubyte*)"glArrayElementEXT")) == NULL) || r; r = ((glColorPointerEXT = (PFNGLCOLORPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glColorPointerEXT")) == NULL) || r; r = ((glDrawArraysEXT = (PFNGLDRAWARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysEXT")) == NULL) || r; r = ((glEdgeFlagPointerEXT = (PFNGLEDGEFLAGPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glEdgeFlagPointerEXT")) == NULL) || r; r = ((glIndexPointerEXT = (PFNGLINDEXPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glIndexPointerEXT")) == NULL) || r; r = ((glNormalPointerEXT = (PFNGLNORMALPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glNormalPointerEXT")) == NULL) || r; r = ((glTexCoordPointerEXT = (PFNGLTEXCOORDPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glTexCoordPointerEXT")) == NULL) || r; r = ((glVertexPointerEXT = (PFNGLVERTEXPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glVertexPointerEXT")) == NULL) || r; return r; } #endif /* GL_EXT_vertex_array */ #ifdef GL_EXT_vertex_attrib_64bit static GLboolean _glewInit_GL_EXT_vertex_attrib_64bit (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetVertexAttribLdvEXT = (PFNGLGETVERTEXATTRIBLDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribLdvEXT")) == NULL) || r; r = ((glVertexArrayVertexAttribLOffsetEXT = (PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexAttribLOffsetEXT")) == NULL) || r; r = ((glVertexAttribL1dEXT = (PFNGLVERTEXATTRIBL1DEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1dEXT")) == NULL) || r; r = ((glVertexAttribL1dvEXT = (PFNGLVERTEXATTRIBL1DVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1dvEXT")) == NULL) || r; r = ((glVertexAttribL2dEXT = (PFNGLVERTEXATTRIBL2DEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL2dEXT")) == NULL) || r; r = ((glVertexAttribL2dvEXT = (PFNGLVERTEXATTRIBL2DVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL2dvEXT")) == NULL) || r; r = ((glVertexAttribL3dEXT = (PFNGLVERTEXATTRIBL3DEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL3dEXT")) == NULL) || r; r = ((glVertexAttribL3dvEXT = (PFNGLVERTEXATTRIBL3DVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL3dvEXT")) == NULL) || r; r = ((glVertexAttribL4dEXT = (PFNGLVERTEXATTRIBL4DEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL4dEXT")) == NULL) || r; r = ((glVertexAttribL4dvEXT = (PFNGLVERTEXATTRIBL4DVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL4dvEXT")) == NULL) || r; r = ((glVertexAttribLPointerEXT = (PFNGLVERTEXATTRIBLPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribLPointerEXT")) == NULL) || r; return r; } #endif /* GL_EXT_vertex_attrib_64bit */ #ifdef GL_EXT_vertex_shader static GLboolean _glewInit_GL_EXT_vertex_shader (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBeginVertexShaderEXT = (PFNGLBEGINVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)"glBeginVertexShaderEXT")) == NULL) || r; r = ((glBindLightParameterEXT = (PFNGLBINDLIGHTPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindLightParameterEXT")) == NULL) || r; r = ((glBindMaterialParameterEXT = (PFNGLBINDMATERIALPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindMaterialParameterEXT")) == NULL) || r; r = ((glBindParameterEXT = (PFNGLBINDPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindParameterEXT")) == NULL) || r; r = ((glBindTexGenParameterEXT = (PFNGLBINDTEXGENPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindTexGenParameterEXT")) == NULL) || r; r = ((glBindTextureUnitParameterEXT = (PFNGLBINDTEXTUREUNITPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindTextureUnitParameterEXT")) == NULL) || r; r = ((glBindVertexShaderEXT = (PFNGLBINDVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindVertexShaderEXT")) == NULL) || r; r = ((glDeleteVertexShaderEXT = (PFNGLDELETEVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)"glDeleteVertexShaderEXT")) == NULL) || r; r = ((glDisableVariantClientStateEXT = (PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableVariantClientStateEXT")) == NULL) || r; r = ((glEnableVariantClientStateEXT = (PFNGLENABLEVARIANTCLIENTSTATEEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableVariantClientStateEXT")) == NULL) || r; r = ((glEndVertexShaderEXT = (PFNGLENDVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)"glEndVertexShaderEXT")) == NULL) || r; r = ((glExtractComponentEXT = (PFNGLEXTRACTCOMPONENTEXTPROC)glewGetProcAddress((const GLubyte*)"glExtractComponentEXT")) == NULL) || r; r = ((glGenSymbolsEXT = (PFNGLGENSYMBOLSEXTPROC)glewGetProcAddress((const GLubyte*)"glGenSymbolsEXT")) == NULL) || r; r = ((glGenVertexShadersEXT = (PFNGLGENVERTEXSHADERSEXTPROC)glewGetProcAddress((const GLubyte*)"glGenVertexShadersEXT")) == NULL) || r; r = ((glGetInvariantBooleanvEXT = (PFNGLGETINVARIANTBOOLEANVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetInvariantBooleanvEXT")) == NULL) || r; r = ((glGetInvariantFloatvEXT = (PFNGLGETINVARIANTFLOATVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetInvariantFloatvEXT")) == NULL) || r; r = ((glGetInvariantIntegervEXT = (PFNGLGETINVARIANTINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetInvariantIntegervEXT")) == NULL) || r; r = ((glGetLocalConstantBooleanvEXT = (PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetLocalConstantBooleanvEXT")) == NULL) || r; r = ((glGetLocalConstantFloatvEXT = (PFNGLGETLOCALCONSTANTFLOATVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetLocalConstantFloatvEXT")) == NULL) || r; r = ((glGetLocalConstantIntegervEXT = (PFNGLGETLOCALCONSTANTINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetLocalConstantIntegervEXT")) == NULL) || r; r = ((glGetVariantBooleanvEXT = (PFNGLGETVARIANTBOOLEANVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVariantBooleanvEXT")) == NULL) || r; r = ((glGetVariantFloatvEXT = (PFNGLGETVARIANTFLOATVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVariantFloatvEXT")) == NULL) || r; r = ((glGetVariantIntegervEXT = (PFNGLGETVARIANTINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVariantIntegervEXT")) == NULL) || r; r = ((glGetVariantPointervEXT = (PFNGLGETVARIANTPOINTERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVariantPointervEXT")) == NULL) || r; r = ((glInsertComponentEXT = (PFNGLINSERTCOMPONENTEXTPROC)glewGetProcAddress((const GLubyte*)"glInsertComponentEXT")) == NULL) || r; r = ((glIsVariantEnabledEXT = (PFNGLISVARIANTENABLEDEXTPROC)glewGetProcAddress((const GLubyte*)"glIsVariantEnabledEXT")) == NULL) || r; r = ((glSetInvariantEXT = (PFNGLSETINVARIANTEXTPROC)glewGetProcAddress((const GLubyte*)"glSetInvariantEXT")) == NULL) || r; r = ((glSetLocalConstantEXT = (PFNGLSETLOCALCONSTANTEXTPROC)glewGetProcAddress((const GLubyte*)"glSetLocalConstantEXT")) == NULL) || r; r = ((glShaderOp1EXT = (PFNGLSHADEROP1EXTPROC)glewGetProcAddress((const GLubyte*)"glShaderOp1EXT")) == NULL) || r; r = ((glShaderOp2EXT = (PFNGLSHADEROP2EXTPROC)glewGetProcAddress((const GLubyte*)"glShaderOp2EXT")) == NULL) || r; r = ((glShaderOp3EXT = (PFNGLSHADEROP3EXTPROC)glewGetProcAddress((const GLubyte*)"glShaderOp3EXT")) == NULL) || r; r = ((glSwizzleEXT = (PFNGLSWIZZLEEXTPROC)glewGetProcAddress((const GLubyte*)"glSwizzleEXT")) == NULL) || r; r = ((glVariantPointerEXT = (PFNGLVARIANTPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glVariantPointerEXT")) == NULL) || r; r = ((glVariantbvEXT = (PFNGLVARIANTBVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantbvEXT")) == NULL) || r; r = ((glVariantdvEXT = (PFNGLVARIANTDVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantdvEXT")) == NULL) || r; r = ((glVariantfvEXT = (PFNGLVARIANTFVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantfvEXT")) == NULL) || r; r = ((glVariantivEXT = (PFNGLVARIANTIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantivEXT")) == NULL) || r; r = ((glVariantsvEXT = (PFNGLVARIANTSVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantsvEXT")) == NULL) || r; r = ((glVariantubvEXT = (PFNGLVARIANTUBVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantubvEXT")) == NULL) || r; r = ((glVariantuivEXT = (PFNGLVARIANTUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantuivEXT")) == NULL) || r; r = ((glVariantusvEXT = (PFNGLVARIANTUSVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantusvEXT")) == NULL) || r; r = ((glWriteMaskEXT = (PFNGLWRITEMASKEXTPROC)glewGetProcAddress((const GLubyte*)"glWriteMaskEXT")) == NULL) || r; return r; } #endif /* GL_EXT_vertex_shader */ #ifdef GL_EXT_vertex_weighting static GLboolean _glewInit_GL_EXT_vertex_weighting (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glVertexWeightPointerEXT = (PFNGLVERTEXWEIGHTPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glVertexWeightPointerEXT")) == NULL) || r; r = ((glVertexWeightfEXT = (PFNGLVERTEXWEIGHTFEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexWeightfEXT")) == NULL) || r; r = ((glVertexWeightfvEXT = (PFNGLVERTEXWEIGHTFVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexWeightfvEXT")) == NULL) || r; return r; } #endif /* GL_EXT_vertex_weighting */ #ifdef GL_EXT_x11_sync_object static GLboolean _glewInit_GL_EXT_x11_sync_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glImportSyncEXT = (PFNGLIMPORTSYNCEXTPROC)glewGetProcAddress((const GLubyte*)"glImportSyncEXT")) == NULL) || r; return r; } #endif /* GL_EXT_x11_sync_object */ #ifdef GL_GREMEDY_frame_terminator static GLboolean _glewInit_GL_GREMEDY_frame_terminator (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFrameTerminatorGREMEDY = (PFNGLFRAMETERMINATORGREMEDYPROC)glewGetProcAddress((const GLubyte*)"glFrameTerminatorGREMEDY")) == NULL) || r; return r; } #endif /* GL_GREMEDY_frame_terminator */ #ifdef GL_GREMEDY_string_marker static GLboolean _glewInit_GL_GREMEDY_string_marker (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glStringMarkerGREMEDY = (PFNGLSTRINGMARKERGREMEDYPROC)glewGetProcAddress((const GLubyte*)"glStringMarkerGREMEDY")) == NULL) || r; return r; } #endif /* GL_GREMEDY_string_marker */ #ifdef GL_HP_image_transform static GLboolean _glewInit_GL_HP_image_transform (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetImageTransformParameterfvHP = (PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC)glewGetProcAddress((const GLubyte*)"glGetImageTransformParameterfvHP")) == NULL) || r; r = ((glGetImageTransformParameterivHP = (PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC)glewGetProcAddress((const GLubyte*)"glGetImageTransformParameterivHP")) == NULL) || r; r = ((glImageTransformParameterfHP = (PFNGLIMAGETRANSFORMPARAMETERFHPPROC)glewGetProcAddress((const GLubyte*)"glImageTransformParameterfHP")) == NULL) || r; r = ((glImageTransformParameterfvHP = (PFNGLIMAGETRANSFORMPARAMETERFVHPPROC)glewGetProcAddress((const GLubyte*)"glImageTransformParameterfvHP")) == NULL) || r; r = ((glImageTransformParameteriHP = (PFNGLIMAGETRANSFORMPARAMETERIHPPROC)glewGetProcAddress((const GLubyte*)"glImageTransformParameteriHP")) == NULL) || r; r = ((glImageTransformParameterivHP = (PFNGLIMAGETRANSFORMPARAMETERIVHPPROC)glewGetProcAddress((const GLubyte*)"glImageTransformParameterivHP")) == NULL) || r; return r; } #endif /* GL_HP_image_transform */ #ifdef GL_IBM_multimode_draw_arrays static GLboolean _glewInit_GL_IBM_multimode_draw_arrays (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glMultiModeDrawArraysIBM = (PFNGLMULTIMODEDRAWARRAYSIBMPROC)glewGetProcAddress((const GLubyte*)"glMultiModeDrawArraysIBM")) == NULL) || r; r = ((glMultiModeDrawElementsIBM = (PFNGLMULTIMODEDRAWELEMENTSIBMPROC)glewGetProcAddress((const GLubyte*)"glMultiModeDrawElementsIBM")) == NULL) || r; return r; } #endif /* GL_IBM_multimode_draw_arrays */ #ifdef GL_IBM_vertex_array_lists static GLboolean _glewInit_GL_IBM_vertex_array_lists (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glColorPointerListIBM = (PFNGLCOLORPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glColorPointerListIBM")) == NULL) || r; r = ((glEdgeFlagPointerListIBM = (PFNGLEDGEFLAGPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glEdgeFlagPointerListIBM")) == NULL) || r; r = ((glFogCoordPointerListIBM = (PFNGLFOGCOORDPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glFogCoordPointerListIBM")) == NULL) || r; r = ((glIndexPointerListIBM = (PFNGLINDEXPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glIndexPointerListIBM")) == NULL) || r; r = ((glNormalPointerListIBM = (PFNGLNORMALPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glNormalPointerListIBM")) == NULL) || r; r = ((glSecondaryColorPointerListIBM = (PFNGLSECONDARYCOLORPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorPointerListIBM")) == NULL) || r; r = ((glTexCoordPointerListIBM = (PFNGLTEXCOORDPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glTexCoordPointerListIBM")) == NULL) || r; r = ((glVertexPointerListIBM = (PFNGLVERTEXPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glVertexPointerListIBM")) == NULL) || r; return r; } #endif /* GL_IBM_vertex_array_lists */ #ifdef GL_INTEL_map_texture static GLboolean _glewInit_GL_INTEL_map_texture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glMapTexture2DINTEL = (PFNGLMAPTEXTURE2DINTELPROC)glewGetProcAddress((const GLubyte*)"glMapTexture2DINTEL")) == NULL) || r; r = ((glSyncTextureINTEL = (PFNGLSYNCTEXTUREINTELPROC)glewGetProcAddress((const GLubyte*)"glSyncTextureINTEL")) == NULL) || r; r = ((glUnmapTexture2DINTEL = (PFNGLUNMAPTEXTURE2DINTELPROC)glewGetProcAddress((const GLubyte*)"glUnmapTexture2DINTEL")) == NULL) || r; return r; } #endif /* GL_INTEL_map_texture */ #ifdef GL_INTEL_parallel_arrays static GLboolean _glewInit_GL_INTEL_parallel_arrays (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glColorPointervINTEL = (PFNGLCOLORPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)"glColorPointervINTEL")) == NULL) || r; r = ((glNormalPointervINTEL = (PFNGLNORMALPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)"glNormalPointervINTEL")) == NULL) || r; r = ((glTexCoordPointervINTEL = (PFNGLTEXCOORDPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)"glTexCoordPointervINTEL")) == NULL) || r; r = ((glVertexPointervINTEL = (PFNGLVERTEXPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)"glVertexPointervINTEL")) == NULL) || r; return r; } #endif /* GL_INTEL_parallel_arrays */ #ifdef GL_INTEL_performance_query static GLboolean _glewInit_GL_INTEL_performance_query (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBeginPerfQueryINTEL = (PFNGLBEGINPERFQUERYINTELPROC)glewGetProcAddress((const GLubyte*)"glBeginPerfQueryINTEL")) == NULL) || r; r = ((glCreatePerfQueryINTEL = (PFNGLCREATEPERFQUERYINTELPROC)glewGetProcAddress((const GLubyte*)"glCreatePerfQueryINTEL")) == NULL) || r; r = ((glDeletePerfQueryINTEL = (PFNGLDELETEPERFQUERYINTELPROC)glewGetProcAddress((const GLubyte*)"glDeletePerfQueryINTEL")) == NULL) || r; r = ((glEndPerfQueryINTEL = (PFNGLENDPERFQUERYINTELPROC)glewGetProcAddress((const GLubyte*)"glEndPerfQueryINTEL")) == NULL) || r; r = ((glGetFirstPerfQueryIdINTEL = (PFNGLGETFIRSTPERFQUERYIDINTELPROC)glewGetProcAddress((const GLubyte*)"glGetFirstPerfQueryIdINTEL")) == NULL) || r; r = ((glGetNextPerfQueryIdINTEL = (PFNGLGETNEXTPERFQUERYIDINTELPROC)glewGetProcAddress((const GLubyte*)"glGetNextPerfQueryIdINTEL")) == NULL) || r; r = ((glGetPerfCounterInfoINTEL = (PFNGLGETPERFCOUNTERINFOINTELPROC)glewGetProcAddress((const GLubyte*)"glGetPerfCounterInfoINTEL")) == NULL) || r; r = ((glGetPerfQueryDataINTEL = (PFNGLGETPERFQUERYDATAINTELPROC)glewGetProcAddress((const GLubyte*)"glGetPerfQueryDataINTEL")) == NULL) || r; r = ((glGetPerfQueryIdByNameINTEL = (PFNGLGETPERFQUERYIDBYNAMEINTELPROC)glewGetProcAddress((const GLubyte*)"glGetPerfQueryIdByNameINTEL")) == NULL) || r; r = ((glGetPerfQueryInfoINTEL = (PFNGLGETPERFQUERYINFOINTELPROC)glewGetProcAddress((const GLubyte*)"glGetPerfQueryInfoINTEL")) == NULL) || r; return r; } #endif /* GL_INTEL_performance_query */ #ifdef GL_INTEL_texture_scissor static GLboolean _glewInit_GL_INTEL_texture_scissor (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTexScissorFuncINTEL = (PFNGLTEXSCISSORFUNCINTELPROC)glewGetProcAddress((const GLubyte*)"glTexScissorFuncINTEL")) == NULL) || r; r = ((glTexScissorINTEL = (PFNGLTEXSCISSORINTELPROC)glewGetProcAddress((const GLubyte*)"glTexScissorINTEL")) == NULL) || r; return r; } #endif /* GL_INTEL_texture_scissor */ #ifdef GL_KHR_blend_equation_advanced static GLboolean _glewInit_GL_KHR_blend_equation_advanced (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBlendBarrierKHR = (PFNGLBLENDBARRIERKHRPROC)glewGetProcAddress((const GLubyte*)"glBlendBarrierKHR")) == NULL) || r; return r; } #endif /* GL_KHR_blend_equation_advanced */ #ifdef GL_KHR_debug static GLboolean _glewInit_GL_KHR_debug (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC)glewGetProcAddress((const GLubyte*)"glDebugMessageCallback")) == NULL) || r; r = ((glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC)glewGetProcAddress((const GLubyte*)"glDebugMessageControl")) == NULL) || r; r = ((glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC)glewGetProcAddress((const GLubyte*)"glDebugMessageInsert")) == NULL) || r; r = ((glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC)glewGetProcAddress((const GLubyte*)"glGetDebugMessageLog")) == NULL) || r; r = ((glGetObjectLabel = (PFNGLGETOBJECTLABELPROC)glewGetProcAddress((const GLubyte*)"glGetObjectLabel")) == NULL) || r; r = ((glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC)glewGetProcAddress((const GLubyte*)"glGetObjectPtrLabel")) == NULL) || r; r = ((glObjectLabel = (PFNGLOBJECTLABELPROC)glewGetProcAddress((const GLubyte*)"glObjectLabel")) == NULL) || r; r = ((glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC)glewGetProcAddress((const GLubyte*)"glObjectPtrLabel")) == NULL) || r; r = ((glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC)glewGetProcAddress((const GLubyte*)"glPopDebugGroup")) == NULL) || r; r = ((glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC)glewGetProcAddress((const GLubyte*)"glPushDebugGroup")) == NULL) || r; return r; } #endif /* GL_KHR_debug */ #ifdef GL_KHR_robustness static GLboolean _glewInit_GL_KHR_robustness (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetnUniformfv = (PFNGLGETNUNIFORMFVPROC)glewGetProcAddress((const GLubyte*)"glGetnUniformfv")) == NULL) || r; r = ((glGetnUniformiv = (PFNGLGETNUNIFORMIVPROC)glewGetProcAddress((const GLubyte*)"glGetnUniformiv")) == NULL) || r; r = ((glGetnUniformuiv = (PFNGLGETNUNIFORMUIVPROC)glewGetProcAddress((const GLubyte*)"glGetnUniformuiv")) == NULL) || r; r = ((glReadnPixels = (PFNGLREADNPIXELSPROC)glewGetProcAddress((const GLubyte*)"glReadnPixels")) == NULL) || r; return r; } #endif /* GL_KHR_robustness */ #ifdef GL_KTX_buffer_region static GLboolean _glewInit_GL_KTX_buffer_region (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBufferRegionEnabled = (PFNGLBUFFERREGIONENABLEDPROC)glewGetProcAddress((const GLubyte*)"glBufferRegionEnabled")) == NULL) || r; r = ((glDeleteBufferRegion = (PFNGLDELETEBUFFERREGIONPROC)glewGetProcAddress((const GLubyte*)"glDeleteBufferRegion")) == NULL) || r; r = ((glDrawBufferRegion = (PFNGLDRAWBUFFERREGIONPROC)glewGetProcAddress((const GLubyte*)"glDrawBufferRegion")) == NULL) || r; r = ((glNewBufferRegion = (PFNGLNEWBUFFERREGIONPROC)glewGetProcAddress((const GLubyte*)"glNewBufferRegion")) == NULL) || r; r = ((glReadBufferRegion = (PFNGLREADBUFFERREGIONPROC)glewGetProcAddress((const GLubyte*)"glReadBufferRegion")) == NULL) || r; return r; } #endif /* GL_KTX_buffer_region */ #ifdef GL_MESA_resize_buffers static GLboolean _glewInit_GL_MESA_resize_buffers (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glResizeBuffersMESA = (PFNGLRESIZEBUFFERSMESAPROC)glewGetProcAddress((const GLubyte*)"glResizeBuffersMESA")) == NULL) || r; return r; } #endif /* GL_MESA_resize_buffers */ #ifdef GL_MESA_window_pos static GLboolean _glewInit_GL_MESA_window_pos (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glWindowPos2dMESA = (PFNGLWINDOWPOS2DMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dMESA")) == NULL) || r; r = ((glWindowPos2dvMESA = (PFNGLWINDOWPOS2DVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dvMESA")) == NULL) || r; r = ((glWindowPos2fMESA = (PFNGLWINDOWPOS2FMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fMESA")) == NULL) || r; r = ((glWindowPos2fvMESA = (PFNGLWINDOWPOS2FVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fvMESA")) == NULL) || r; r = ((glWindowPos2iMESA = (PFNGLWINDOWPOS2IMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2iMESA")) == NULL) || r; r = ((glWindowPos2ivMESA = (PFNGLWINDOWPOS2IVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2ivMESA")) == NULL) || r; r = ((glWindowPos2sMESA = (PFNGLWINDOWPOS2SMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2sMESA")) == NULL) || r; r = ((glWindowPos2svMESA = (PFNGLWINDOWPOS2SVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2svMESA")) == NULL) || r; r = ((glWindowPos3dMESA = (PFNGLWINDOWPOS3DMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dMESA")) == NULL) || r; r = ((glWindowPos3dvMESA = (PFNGLWINDOWPOS3DVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dvMESA")) == NULL) || r; r = ((glWindowPos3fMESA = (PFNGLWINDOWPOS3FMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fMESA")) == NULL) || r; r = ((glWindowPos3fvMESA = (PFNGLWINDOWPOS3FVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fvMESA")) == NULL) || r; r = ((glWindowPos3iMESA = (PFNGLWINDOWPOS3IMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3iMESA")) == NULL) || r; r = ((glWindowPos3ivMESA = (PFNGLWINDOWPOS3IVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3ivMESA")) == NULL) || r; r = ((glWindowPos3sMESA = (PFNGLWINDOWPOS3SMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3sMESA")) == NULL) || r; r = ((glWindowPos3svMESA = (PFNGLWINDOWPOS3SVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3svMESA")) == NULL) || r; r = ((glWindowPos4dMESA = (PFNGLWINDOWPOS4DMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4dMESA")) == NULL) || r; r = ((glWindowPos4dvMESA = (PFNGLWINDOWPOS4DVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4dvMESA")) == NULL) || r; r = ((glWindowPos4fMESA = (PFNGLWINDOWPOS4FMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4fMESA")) == NULL) || r; r = ((glWindowPos4fvMESA = (PFNGLWINDOWPOS4FVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4fvMESA")) == NULL) || r; r = ((glWindowPos4iMESA = (PFNGLWINDOWPOS4IMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4iMESA")) == NULL) || r; r = ((glWindowPos4ivMESA = (PFNGLWINDOWPOS4IVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4ivMESA")) == NULL) || r; r = ((glWindowPos4sMESA = (PFNGLWINDOWPOS4SMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4sMESA")) == NULL) || r; r = ((glWindowPos4svMESA = (PFNGLWINDOWPOS4SVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4svMESA")) == NULL) || r; return r; } #endif /* GL_MESA_window_pos */ #ifdef GL_NVX_conditional_render static GLboolean _glewInit_GL_NVX_conditional_render (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBeginConditionalRenderNVX = (PFNGLBEGINCONDITIONALRENDERNVXPROC)glewGetProcAddress((const GLubyte*)"glBeginConditionalRenderNVX")) == NULL) || r; r = ((glEndConditionalRenderNVX = (PFNGLENDCONDITIONALRENDERNVXPROC)glewGetProcAddress((const GLubyte*)"glEndConditionalRenderNVX")) == NULL) || r; return r; } #endif /* GL_NVX_conditional_render */ #ifdef GL_NV_bindless_multi_draw_indirect static GLboolean _glewInit_GL_NV_bindless_multi_draw_indirect (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glMultiDrawArraysIndirectBindlessNV = (PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawArraysIndirectBindlessNV")) == NULL) || r; r = ((glMultiDrawElementsIndirectBindlessNV = (PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElementsIndirectBindlessNV")) == NULL) || r; return r; } #endif /* GL_NV_bindless_multi_draw_indirect */ #ifdef GL_NV_bindless_multi_draw_indirect_count static GLboolean _glewInit_GL_NV_bindless_multi_draw_indirect_count (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glMultiDrawArraysIndirectBindlessCountNV = (PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawArraysIndirectBindlessCountNV")) == NULL) || r; r = ((glMultiDrawElementsIndirectBindlessCountNV = (PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElementsIndirectBindlessCountNV")) == NULL) || r; return r; } #endif /* GL_NV_bindless_multi_draw_indirect_count */ #ifdef GL_NV_bindless_texture static GLboolean _glewInit_GL_NV_bindless_texture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetImageHandleNV = (PFNGLGETIMAGEHANDLENVPROC)glewGetProcAddress((const GLubyte*)"glGetImageHandleNV")) == NULL) || r; r = ((glGetTextureHandleNV = (PFNGLGETTEXTUREHANDLENVPROC)glewGetProcAddress((const GLubyte*)"glGetTextureHandleNV")) == NULL) || r; r = ((glGetTextureSamplerHandleNV = (PFNGLGETTEXTURESAMPLERHANDLENVPROC)glewGetProcAddress((const GLubyte*)"glGetTextureSamplerHandleNV")) == NULL) || r; r = ((glIsImageHandleResidentNV = (PFNGLISIMAGEHANDLERESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glIsImageHandleResidentNV")) == NULL) || r; r = ((glIsTextureHandleResidentNV = (PFNGLISTEXTUREHANDLERESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glIsTextureHandleResidentNV")) == NULL) || r; r = ((glMakeImageHandleNonResidentNV = (PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glMakeImageHandleNonResidentNV")) == NULL) || r; r = ((glMakeImageHandleResidentNV = (PFNGLMAKEIMAGEHANDLERESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glMakeImageHandleResidentNV")) == NULL) || r; r = ((glMakeTextureHandleNonResidentNV = (PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glMakeTextureHandleNonResidentNV")) == NULL) || r; r = ((glMakeTextureHandleResidentNV = (PFNGLMAKETEXTUREHANDLERESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glMakeTextureHandleResidentNV")) == NULL) || r; r = ((glProgramUniformHandleui64NV = (PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformHandleui64NV")) == NULL) || r; r = ((glProgramUniformHandleui64vNV = (PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformHandleui64vNV")) == NULL) || r; r = ((glUniformHandleui64NV = (PFNGLUNIFORMHANDLEUI64NVPROC)glewGetProcAddress((const GLubyte*)"glUniformHandleui64NV")) == NULL) || r; r = ((glUniformHandleui64vNV = (PFNGLUNIFORMHANDLEUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniformHandleui64vNV")) == NULL) || r; return r; } #endif /* GL_NV_bindless_texture */ #ifdef GL_NV_blend_equation_advanced static GLboolean _glewInit_GL_NV_blend_equation_advanced (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBlendBarrierNV = (PFNGLBLENDBARRIERNVPROC)glewGetProcAddress((const GLubyte*)"glBlendBarrierNV")) == NULL) || r; r = ((glBlendParameteriNV = (PFNGLBLENDPARAMETERINVPROC)glewGetProcAddress((const GLubyte*)"glBlendParameteriNV")) == NULL) || r; return r; } #endif /* GL_NV_blend_equation_advanced */ #ifdef GL_NV_conditional_render static GLboolean _glewInit_GL_NV_conditional_render (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBeginConditionalRenderNV = (PFNGLBEGINCONDITIONALRENDERNVPROC)glewGetProcAddress((const GLubyte*)"glBeginConditionalRenderNV")) == NULL) || r; r = ((glEndConditionalRenderNV = (PFNGLENDCONDITIONALRENDERNVPROC)glewGetProcAddress((const GLubyte*)"glEndConditionalRenderNV")) == NULL) || r; return r; } #endif /* GL_NV_conditional_render */ #ifdef GL_NV_conservative_raster static GLboolean _glewInit_GL_NV_conservative_raster (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glSubpixelPrecisionBiasNV = (PFNGLSUBPIXELPRECISIONBIASNVPROC)glewGetProcAddress((const GLubyte*)"glSubpixelPrecisionBiasNV")) == NULL) || r; return r; } #endif /* GL_NV_conservative_raster */ #ifdef GL_NV_conservative_raster_dilate static GLboolean _glewInit_GL_NV_conservative_raster_dilate (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glConservativeRasterParameterfNV = (PFNGLCONSERVATIVERASTERPARAMETERFNVPROC)glewGetProcAddress((const GLubyte*)"glConservativeRasterParameterfNV")) == NULL) || r; return r; } #endif /* GL_NV_conservative_raster_dilate */ #ifdef GL_NV_copy_image static GLboolean _glewInit_GL_NV_copy_image (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glCopyImageSubDataNV = (PFNGLCOPYIMAGESUBDATANVPROC)glewGetProcAddress((const GLubyte*)"glCopyImageSubDataNV")) == NULL) || r; return r; } #endif /* GL_NV_copy_image */ #ifdef GL_NV_depth_buffer_float static GLboolean _glewInit_GL_NV_depth_buffer_float (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glClearDepthdNV = (PFNGLCLEARDEPTHDNVPROC)glewGetProcAddress((const GLubyte*)"glClearDepthdNV")) == NULL) || r; r = ((glDepthBoundsdNV = (PFNGLDEPTHBOUNDSDNVPROC)glewGetProcAddress((const GLubyte*)"glDepthBoundsdNV")) == NULL) || r; r = ((glDepthRangedNV = (PFNGLDEPTHRANGEDNVPROC)glewGetProcAddress((const GLubyte*)"glDepthRangedNV")) == NULL) || r; return r; } #endif /* GL_NV_depth_buffer_float */ #ifdef GL_NV_draw_texture static GLboolean _glewInit_GL_NV_draw_texture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDrawTextureNV = (PFNGLDRAWTEXTURENVPROC)glewGetProcAddress((const GLubyte*)"glDrawTextureNV")) == NULL) || r; return r; } #endif /* GL_NV_draw_texture */ #ifdef GL_NV_evaluators static GLboolean _glewInit_GL_NV_evaluators (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glEvalMapsNV = (PFNGLEVALMAPSNVPROC)glewGetProcAddress((const GLubyte*)"glEvalMapsNV")) == NULL) || r; r = ((glGetMapAttribParameterfvNV = (PFNGLGETMAPATTRIBPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapAttribParameterfvNV")) == NULL) || r; r = ((glGetMapAttribParameterivNV = (PFNGLGETMAPATTRIBPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapAttribParameterivNV")) == NULL) || r; r = ((glGetMapControlPointsNV = (PFNGLGETMAPCONTROLPOINTSNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapControlPointsNV")) == NULL) || r; r = ((glGetMapParameterfvNV = (PFNGLGETMAPPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapParameterfvNV")) == NULL) || r; r = ((glGetMapParameterivNV = (PFNGLGETMAPPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapParameterivNV")) == NULL) || r; r = ((glMapControlPointsNV = (PFNGLMAPCONTROLPOINTSNVPROC)glewGetProcAddress((const GLubyte*)"glMapControlPointsNV")) == NULL) || r; r = ((glMapParameterfvNV = (PFNGLMAPPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glMapParameterfvNV")) == NULL) || r; r = ((glMapParameterivNV = (PFNGLMAPPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glMapParameterivNV")) == NULL) || r; return r; } #endif /* GL_NV_evaluators */ #ifdef GL_NV_explicit_multisample static GLboolean _glewInit_GL_NV_explicit_multisample (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetMultisamplefvNV = (PFNGLGETMULTISAMPLEFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMultisamplefvNV")) == NULL) || r; r = ((glSampleMaskIndexedNV = (PFNGLSAMPLEMASKINDEXEDNVPROC)glewGetProcAddress((const GLubyte*)"glSampleMaskIndexedNV")) == NULL) || r; r = ((glTexRenderbufferNV = (PFNGLTEXRENDERBUFFERNVPROC)glewGetProcAddress((const GLubyte*)"glTexRenderbufferNV")) == NULL) || r; return r; } #endif /* GL_NV_explicit_multisample */ #ifdef GL_NV_fence static GLboolean _glewInit_GL_NV_fence (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDeleteFencesNV = (PFNGLDELETEFENCESNVPROC)glewGetProcAddress((const GLubyte*)"glDeleteFencesNV")) == NULL) || r; r = ((glFinishFenceNV = (PFNGLFINISHFENCENVPROC)glewGetProcAddress((const GLubyte*)"glFinishFenceNV")) == NULL) || r; r = ((glGenFencesNV = (PFNGLGENFENCESNVPROC)glewGetProcAddress((const GLubyte*)"glGenFencesNV")) == NULL) || r; r = ((glGetFenceivNV = (PFNGLGETFENCEIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetFenceivNV")) == NULL) || r; r = ((glIsFenceNV = (PFNGLISFENCENVPROC)glewGetProcAddress((const GLubyte*)"glIsFenceNV")) == NULL) || r; r = ((glSetFenceNV = (PFNGLSETFENCENVPROC)glewGetProcAddress((const GLubyte*)"glSetFenceNV")) == NULL) || r; r = ((glTestFenceNV = (PFNGLTESTFENCENVPROC)glewGetProcAddress((const GLubyte*)"glTestFenceNV")) == NULL) || r; return r; } #endif /* GL_NV_fence */ #ifdef GL_NV_fragment_coverage_to_color static GLboolean _glewInit_GL_NV_fragment_coverage_to_color (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFragmentCoverageColorNV = (PFNGLFRAGMENTCOVERAGECOLORNVPROC)glewGetProcAddress((const GLubyte*)"glFragmentCoverageColorNV")) == NULL) || r; return r; } #endif /* GL_NV_fragment_coverage_to_color */ #ifdef GL_NV_fragment_program static GLboolean _glewInit_GL_NV_fragment_program (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetProgramNamedParameterdvNV = (PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramNamedParameterdvNV")) == NULL) || r; r = ((glGetProgramNamedParameterfvNV = (PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramNamedParameterfvNV")) == NULL) || r; r = ((glProgramNamedParameter4dNV = (PFNGLPROGRAMNAMEDPARAMETER4DNVPROC)glewGetProcAddress((const GLubyte*)"glProgramNamedParameter4dNV")) == NULL) || r; r = ((glProgramNamedParameter4dvNV = (PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramNamedParameter4dvNV")) == NULL) || r; r = ((glProgramNamedParameter4fNV = (PFNGLPROGRAMNAMEDPARAMETER4FNVPROC)glewGetProcAddress((const GLubyte*)"glProgramNamedParameter4fNV")) == NULL) || r; r = ((glProgramNamedParameter4fvNV = (PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramNamedParameter4fvNV")) == NULL) || r; return r; } #endif /* GL_NV_fragment_program */ #ifdef GL_NV_framebuffer_multisample_coverage static GLboolean _glewInit_GL_NV_framebuffer_multisample_coverage (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glRenderbufferStorageMultisampleCoverageNV = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorageMultisampleCoverageNV")) == NULL) || r; return r; } #endif /* GL_NV_framebuffer_multisample_coverage */ #ifdef GL_NV_geometry_program4 static GLboolean _glewInit_GL_NV_geometry_program4 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glProgramVertexLimitNV = (PFNGLPROGRAMVERTEXLIMITNVPROC)glewGetProcAddress((const GLubyte*)"glProgramVertexLimitNV")) == NULL) || r; return r; } #endif /* GL_NV_geometry_program4 */ #ifdef GL_NV_gpu_program4 static GLboolean _glewInit_GL_NV_gpu_program4 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glProgramEnvParameterI4iNV = (PFNGLPROGRAMENVPARAMETERI4INVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameterI4iNV")) == NULL) || r; r = ((glProgramEnvParameterI4ivNV = (PFNGLPROGRAMENVPARAMETERI4IVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameterI4ivNV")) == NULL) || r; r = ((glProgramEnvParameterI4uiNV = (PFNGLPROGRAMENVPARAMETERI4UINVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameterI4uiNV")) == NULL) || r; r = ((glProgramEnvParameterI4uivNV = (PFNGLPROGRAMENVPARAMETERI4UIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameterI4uivNV")) == NULL) || r; r = ((glProgramEnvParametersI4ivNV = (PFNGLPROGRAMENVPARAMETERSI4IVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParametersI4ivNV")) == NULL) || r; r = ((glProgramEnvParametersI4uivNV = (PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParametersI4uivNV")) == NULL) || r; r = ((glProgramLocalParameterI4iNV = (PFNGLPROGRAMLOCALPARAMETERI4INVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameterI4iNV")) == NULL) || r; r = ((glProgramLocalParameterI4ivNV = (PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameterI4ivNV")) == NULL) || r; r = ((glProgramLocalParameterI4uiNV = (PFNGLPROGRAMLOCALPARAMETERI4UINVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameterI4uiNV")) == NULL) || r; r = ((glProgramLocalParameterI4uivNV = (PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameterI4uivNV")) == NULL) || r; r = ((glProgramLocalParametersI4ivNV = (PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParametersI4ivNV")) == NULL) || r; r = ((glProgramLocalParametersI4uivNV = (PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParametersI4uivNV")) == NULL) || r; return r; } #endif /* GL_NV_gpu_program4 */ #ifdef GL_NV_gpu_shader5 static GLboolean _glewInit_GL_NV_gpu_shader5 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetUniformi64vNV = (PFNGLGETUNIFORMI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformi64vNV")) == NULL) || r; r = ((glGetUniformui64vNV = (PFNGLGETUNIFORMUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformui64vNV")) == NULL) || r; r = ((glProgramUniform1i64NV = (PFNGLPROGRAMUNIFORM1I64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1i64NV")) == NULL) || r; r = ((glProgramUniform1i64vNV = (PFNGLPROGRAMUNIFORM1I64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1i64vNV")) == NULL) || r; r = ((glProgramUniform1ui64NV = (PFNGLPROGRAMUNIFORM1UI64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1ui64NV")) == NULL) || r; r = ((glProgramUniform1ui64vNV = (PFNGLPROGRAMUNIFORM1UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1ui64vNV")) == NULL) || r; r = ((glProgramUniform2i64NV = (PFNGLPROGRAMUNIFORM2I64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2i64NV")) == NULL) || r; r = ((glProgramUniform2i64vNV = (PFNGLPROGRAMUNIFORM2I64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2i64vNV")) == NULL) || r; r = ((glProgramUniform2ui64NV = (PFNGLPROGRAMUNIFORM2UI64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2ui64NV")) == NULL) || r; r = ((glProgramUniform2ui64vNV = (PFNGLPROGRAMUNIFORM2UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2ui64vNV")) == NULL) || r; r = ((glProgramUniform3i64NV = (PFNGLPROGRAMUNIFORM3I64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3i64NV")) == NULL) || r; r = ((glProgramUniform3i64vNV = (PFNGLPROGRAMUNIFORM3I64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3i64vNV")) == NULL) || r; r = ((glProgramUniform3ui64NV = (PFNGLPROGRAMUNIFORM3UI64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3ui64NV")) == NULL) || r; r = ((glProgramUniform3ui64vNV = (PFNGLPROGRAMUNIFORM3UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3ui64vNV")) == NULL) || r; r = ((glProgramUniform4i64NV = (PFNGLPROGRAMUNIFORM4I64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4i64NV")) == NULL) || r; r = ((glProgramUniform4i64vNV = (PFNGLPROGRAMUNIFORM4I64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4i64vNV")) == NULL) || r; r = ((glProgramUniform4ui64NV = (PFNGLPROGRAMUNIFORM4UI64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4ui64NV")) == NULL) || r; r = ((glProgramUniform4ui64vNV = (PFNGLPROGRAMUNIFORM4UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4ui64vNV")) == NULL) || r; r = ((glUniform1i64NV = (PFNGLUNIFORM1I64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform1i64NV")) == NULL) || r; r = ((glUniform1i64vNV = (PFNGLUNIFORM1I64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform1i64vNV")) == NULL) || r; r = ((glUniform1ui64NV = (PFNGLUNIFORM1UI64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform1ui64NV")) == NULL) || r; r = ((glUniform1ui64vNV = (PFNGLUNIFORM1UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform1ui64vNV")) == NULL) || r; r = ((glUniform2i64NV = (PFNGLUNIFORM2I64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform2i64NV")) == NULL) || r; r = ((glUniform2i64vNV = (PFNGLUNIFORM2I64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform2i64vNV")) == NULL) || r; r = ((glUniform2ui64NV = (PFNGLUNIFORM2UI64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform2ui64NV")) == NULL) || r; r = ((glUniform2ui64vNV = (PFNGLUNIFORM2UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform2ui64vNV")) == NULL) || r; r = ((glUniform3i64NV = (PFNGLUNIFORM3I64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform3i64NV")) == NULL) || r; r = ((glUniform3i64vNV = (PFNGLUNIFORM3I64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform3i64vNV")) == NULL) || r; r = ((glUniform3ui64NV = (PFNGLUNIFORM3UI64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform3ui64NV")) == NULL) || r; r = ((glUniform3ui64vNV = (PFNGLUNIFORM3UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform3ui64vNV")) == NULL) || r; r = ((glUniform4i64NV = (PFNGLUNIFORM4I64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform4i64NV")) == NULL) || r; r = ((glUniform4i64vNV = (PFNGLUNIFORM4I64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform4i64vNV")) == NULL) || r; r = ((glUniform4ui64NV = (PFNGLUNIFORM4UI64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform4ui64NV")) == NULL) || r; r = ((glUniform4ui64vNV = (PFNGLUNIFORM4UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform4ui64vNV")) == NULL) || r; return r; } #endif /* GL_NV_gpu_shader5 */ #ifdef GL_NV_half_float static GLboolean _glewInit_GL_NV_half_float (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glColor3hNV = (PFNGLCOLOR3HNVPROC)glewGetProcAddress((const GLubyte*)"glColor3hNV")) == NULL) || r; r = ((glColor3hvNV = (PFNGLCOLOR3HVNVPROC)glewGetProcAddress((const GLubyte*)"glColor3hvNV")) == NULL) || r; r = ((glColor4hNV = (PFNGLCOLOR4HNVPROC)glewGetProcAddress((const GLubyte*)"glColor4hNV")) == NULL) || r; r = ((glColor4hvNV = (PFNGLCOLOR4HVNVPROC)glewGetProcAddress((const GLubyte*)"glColor4hvNV")) == NULL) || r; r = ((glFogCoordhNV = (PFNGLFOGCOORDHNVPROC)glewGetProcAddress((const GLubyte*)"glFogCoordhNV")) == NULL) || r; r = ((glFogCoordhvNV = (PFNGLFOGCOORDHVNVPROC)glewGetProcAddress((const GLubyte*)"glFogCoordhvNV")) == NULL) || r; r = ((glMultiTexCoord1hNV = (PFNGLMULTITEXCOORD1HNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1hNV")) == NULL) || r; r = ((glMultiTexCoord1hvNV = (PFNGLMULTITEXCOORD1HVNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1hvNV")) == NULL) || r; r = ((glMultiTexCoord2hNV = (PFNGLMULTITEXCOORD2HNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2hNV")) == NULL) || r; r = ((glMultiTexCoord2hvNV = (PFNGLMULTITEXCOORD2HVNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2hvNV")) == NULL) || r; r = ((glMultiTexCoord3hNV = (PFNGLMULTITEXCOORD3HNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3hNV")) == NULL) || r; r = ((glMultiTexCoord3hvNV = (PFNGLMULTITEXCOORD3HVNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3hvNV")) == NULL) || r; r = ((glMultiTexCoord4hNV = (PFNGLMULTITEXCOORD4HNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4hNV")) == NULL) || r; r = ((glMultiTexCoord4hvNV = (PFNGLMULTITEXCOORD4HVNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4hvNV")) == NULL) || r; r = ((glNormal3hNV = (PFNGLNORMAL3HNVPROC)glewGetProcAddress((const GLubyte*)"glNormal3hNV")) == NULL) || r; r = ((glNormal3hvNV = (PFNGLNORMAL3HVNVPROC)glewGetProcAddress((const GLubyte*)"glNormal3hvNV")) == NULL) || r; r = ((glSecondaryColor3hNV = (PFNGLSECONDARYCOLOR3HNVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3hNV")) == NULL) || r; r = ((glSecondaryColor3hvNV = (PFNGLSECONDARYCOLOR3HVNVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3hvNV")) == NULL) || r; r = ((glTexCoord1hNV = (PFNGLTEXCOORD1HNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord1hNV")) == NULL) || r; r = ((glTexCoord1hvNV = (PFNGLTEXCOORD1HVNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord1hvNV")) == NULL) || r; r = ((glTexCoord2hNV = (PFNGLTEXCOORD2HNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2hNV")) == NULL) || r; r = ((glTexCoord2hvNV = (PFNGLTEXCOORD2HVNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2hvNV")) == NULL) || r; r = ((glTexCoord3hNV = (PFNGLTEXCOORD3HNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord3hNV")) == NULL) || r; r = ((glTexCoord3hvNV = (PFNGLTEXCOORD3HVNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord3hvNV")) == NULL) || r; r = ((glTexCoord4hNV = (PFNGLTEXCOORD4HNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4hNV")) == NULL) || r; r = ((glTexCoord4hvNV = (PFNGLTEXCOORD4HVNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4hvNV")) == NULL) || r; r = ((glVertex2hNV = (PFNGLVERTEX2HNVPROC)glewGetProcAddress((const GLubyte*)"glVertex2hNV")) == NULL) || r; r = ((glVertex2hvNV = (PFNGLVERTEX2HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertex2hvNV")) == NULL) || r; r = ((glVertex3hNV = (PFNGLVERTEX3HNVPROC)glewGetProcAddress((const GLubyte*)"glVertex3hNV")) == NULL) || r; r = ((glVertex3hvNV = (PFNGLVERTEX3HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertex3hvNV")) == NULL) || r; r = ((glVertex4hNV = (PFNGLVERTEX4HNVPROC)glewGetProcAddress((const GLubyte*)"glVertex4hNV")) == NULL) || r; r = ((glVertex4hvNV = (PFNGLVERTEX4HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertex4hvNV")) == NULL) || r; r = ((glVertexAttrib1hNV = (PFNGLVERTEXATTRIB1HNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1hNV")) == NULL) || r; r = ((glVertexAttrib1hvNV = (PFNGLVERTEXATTRIB1HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1hvNV")) == NULL) || r; r = ((glVertexAttrib2hNV = (PFNGLVERTEXATTRIB2HNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2hNV")) == NULL) || r; r = ((glVertexAttrib2hvNV = (PFNGLVERTEXATTRIB2HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2hvNV")) == NULL) || r; r = ((glVertexAttrib3hNV = (PFNGLVERTEXATTRIB3HNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3hNV")) == NULL) || r; r = ((glVertexAttrib3hvNV = (PFNGLVERTEXATTRIB3HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3hvNV")) == NULL) || r; r = ((glVertexAttrib4hNV = (PFNGLVERTEXATTRIB4HNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4hNV")) == NULL) || r; r = ((glVertexAttrib4hvNV = (PFNGLVERTEXATTRIB4HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4hvNV")) == NULL) || r; r = ((glVertexAttribs1hvNV = (PFNGLVERTEXATTRIBS1HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs1hvNV")) == NULL) || r; r = ((glVertexAttribs2hvNV = (PFNGLVERTEXATTRIBS2HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs2hvNV")) == NULL) || r; r = ((glVertexAttribs3hvNV = (PFNGLVERTEXATTRIBS3HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs3hvNV")) == NULL) || r; r = ((glVertexAttribs4hvNV = (PFNGLVERTEXATTRIBS4HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4hvNV")) == NULL) || r; r = ((glVertexWeighthNV = (PFNGLVERTEXWEIGHTHNVPROC)glewGetProcAddress((const GLubyte*)"glVertexWeighthNV")) == NULL) || r; r = ((glVertexWeighthvNV = (PFNGLVERTEXWEIGHTHVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexWeighthvNV")) == NULL) || r; return r; } #endif /* GL_NV_half_float */ #ifdef GL_NV_internalformat_sample_query static GLboolean _glewInit_GL_NV_internalformat_sample_query (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetInternalformatSampleivNV = (PFNGLGETINTERNALFORMATSAMPLEIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetInternalformatSampleivNV")) == NULL) || r; return r; } #endif /* GL_NV_internalformat_sample_query */ #ifdef GL_NV_occlusion_query static GLboolean _glewInit_GL_NV_occlusion_query (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBeginOcclusionQueryNV = (PFNGLBEGINOCCLUSIONQUERYNVPROC)glewGetProcAddress((const GLubyte*)"glBeginOcclusionQueryNV")) == NULL) || r; r = ((glDeleteOcclusionQueriesNV = (PFNGLDELETEOCCLUSIONQUERIESNVPROC)glewGetProcAddress((const GLubyte*)"glDeleteOcclusionQueriesNV")) == NULL) || r; r = ((glEndOcclusionQueryNV = (PFNGLENDOCCLUSIONQUERYNVPROC)glewGetProcAddress((const GLubyte*)"glEndOcclusionQueryNV")) == NULL) || r; r = ((glGenOcclusionQueriesNV = (PFNGLGENOCCLUSIONQUERIESNVPROC)glewGetProcAddress((const GLubyte*)"glGenOcclusionQueriesNV")) == NULL) || r; r = ((glGetOcclusionQueryivNV = (PFNGLGETOCCLUSIONQUERYIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetOcclusionQueryivNV")) == NULL) || r; r = ((glGetOcclusionQueryuivNV = (PFNGLGETOCCLUSIONQUERYUIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetOcclusionQueryuivNV")) == NULL) || r; r = ((glIsOcclusionQueryNV = (PFNGLISOCCLUSIONQUERYNVPROC)glewGetProcAddress((const GLubyte*)"glIsOcclusionQueryNV")) == NULL) || r; return r; } #endif /* GL_NV_occlusion_query */ #ifdef GL_NV_parameter_buffer_object static GLboolean _glewInit_GL_NV_parameter_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glProgramBufferParametersIivNV = (PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramBufferParametersIivNV")) == NULL) || r; r = ((glProgramBufferParametersIuivNV = (PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramBufferParametersIuivNV")) == NULL) || r; r = ((glProgramBufferParametersfvNV = (PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramBufferParametersfvNV")) == NULL) || r; return r; } #endif /* GL_NV_parameter_buffer_object */ #ifdef GL_NV_path_rendering static GLboolean _glewInit_GL_NV_path_rendering (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glCopyPathNV = (PFNGLCOPYPATHNVPROC)glewGetProcAddress((const GLubyte*)"glCopyPathNV")) == NULL) || r; r = ((glCoverFillPathInstancedNV = (PFNGLCOVERFILLPATHINSTANCEDNVPROC)glewGetProcAddress((const GLubyte*)"glCoverFillPathInstancedNV")) == NULL) || r; r = ((glCoverFillPathNV = (PFNGLCOVERFILLPATHNVPROC)glewGetProcAddress((const GLubyte*)"glCoverFillPathNV")) == NULL) || r; r = ((glCoverStrokePathInstancedNV = (PFNGLCOVERSTROKEPATHINSTANCEDNVPROC)glewGetProcAddress((const GLubyte*)"glCoverStrokePathInstancedNV")) == NULL) || r; r = ((glCoverStrokePathNV = (PFNGLCOVERSTROKEPATHNVPROC)glewGetProcAddress((const GLubyte*)"glCoverStrokePathNV")) == NULL) || r; r = ((glDeletePathsNV = (PFNGLDELETEPATHSNVPROC)glewGetProcAddress((const GLubyte*)"glDeletePathsNV")) == NULL) || r; r = ((glGenPathsNV = (PFNGLGENPATHSNVPROC)glewGetProcAddress((const GLubyte*)"glGenPathsNV")) == NULL) || r; r = ((glGetPathColorGenfvNV = (PFNGLGETPATHCOLORGENFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetPathColorGenfvNV")) == NULL) || r; r = ((glGetPathColorGenivNV = (PFNGLGETPATHCOLORGENIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetPathColorGenivNV")) == NULL) || r; r = ((glGetPathCommandsNV = (PFNGLGETPATHCOMMANDSNVPROC)glewGetProcAddress((const GLubyte*)"glGetPathCommandsNV")) == NULL) || r; r = ((glGetPathCoordsNV = (PFNGLGETPATHCOORDSNVPROC)glewGetProcAddress((const GLubyte*)"glGetPathCoordsNV")) == NULL) || r; r = ((glGetPathDashArrayNV = (PFNGLGETPATHDASHARRAYNVPROC)glewGetProcAddress((const GLubyte*)"glGetPathDashArrayNV")) == NULL) || r; r = ((glGetPathLengthNV = (PFNGLGETPATHLENGTHNVPROC)glewGetProcAddress((const GLubyte*)"glGetPathLengthNV")) == NULL) || r; r = ((glGetPathMetricRangeNV = (PFNGLGETPATHMETRICRANGENVPROC)glewGetProcAddress((const GLubyte*)"glGetPathMetricRangeNV")) == NULL) || r; r = ((glGetPathMetricsNV = (PFNGLGETPATHMETRICSNVPROC)glewGetProcAddress((const GLubyte*)"glGetPathMetricsNV")) == NULL) || r; r = ((glGetPathParameterfvNV = (PFNGLGETPATHPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetPathParameterfvNV")) == NULL) || r; r = ((glGetPathParameterivNV = (PFNGLGETPATHPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetPathParameterivNV")) == NULL) || r; r = ((glGetPathSpacingNV = (PFNGLGETPATHSPACINGNVPROC)glewGetProcAddress((const GLubyte*)"glGetPathSpacingNV")) == NULL) || r; r = ((glGetPathTexGenfvNV = (PFNGLGETPATHTEXGENFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetPathTexGenfvNV")) == NULL) || r; r = ((glGetPathTexGenivNV = (PFNGLGETPATHTEXGENIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetPathTexGenivNV")) == NULL) || r; r = ((glGetProgramResourcefvNV = (PFNGLGETPROGRAMRESOURCEFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramResourcefvNV")) == NULL) || r; r = ((glInterpolatePathsNV = (PFNGLINTERPOLATEPATHSNVPROC)glewGetProcAddress((const GLubyte*)"glInterpolatePathsNV")) == NULL) || r; r = ((glIsPathNV = (PFNGLISPATHNVPROC)glewGetProcAddress((const GLubyte*)"glIsPathNV")) == NULL) || r; r = ((glIsPointInFillPathNV = (PFNGLISPOINTINFILLPATHNVPROC)glewGetProcAddress((const GLubyte*)"glIsPointInFillPathNV")) == NULL) || r; r = ((glIsPointInStrokePathNV = (PFNGLISPOINTINSTROKEPATHNVPROC)glewGetProcAddress((const GLubyte*)"glIsPointInStrokePathNV")) == NULL) || r; r = ((glMatrixLoad3x2fNV = (PFNGLMATRIXLOAD3X2FNVPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoad3x2fNV")) == NULL) || r; r = ((glMatrixLoad3x3fNV = (PFNGLMATRIXLOAD3X3FNVPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoad3x3fNV")) == NULL) || r; r = ((glMatrixLoadTranspose3x3fNV = (PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadTranspose3x3fNV")) == NULL) || r; r = ((glMatrixMult3x2fNV = (PFNGLMATRIXMULT3X2FNVPROC)glewGetProcAddress((const GLubyte*)"glMatrixMult3x2fNV")) == NULL) || r; r = ((glMatrixMult3x3fNV = (PFNGLMATRIXMULT3X3FNVPROC)glewGetProcAddress((const GLubyte*)"glMatrixMult3x3fNV")) == NULL) || r; r = ((glMatrixMultTranspose3x3fNV = (PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC)glewGetProcAddress((const GLubyte*)"glMatrixMultTranspose3x3fNV")) == NULL) || r; r = ((glPathColorGenNV = (PFNGLPATHCOLORGENNVPROC)glewGetProcAddress((const GLubyte*)"glPathColorGenNV")) == NULL) || r; r = ((glPathCommandsNV = (PFNGLPATHCOMMANDSNVPROC)glewGetProcAddress((const GLubyte*)"glPathCommandsNV")) == NULL) || r; r = ((glPathCoordsNV = (PFNGLPATHCOORDSNVPROC)glewGetProcAddress((const GLubyte*)"glPathCoordsNV")) == NULL) || r; r = ((glPathCoverDepthFuncNV = (PFNGLPATHCOVERDEPTHFUNCNVPROC)glewGetProcAddress((const GLubyte*)"glPathCoverDepthFuncNV")) == NULL) || r; r = ((glPathDashArrayNV = (PFNGLPATHDASHARRAYNVPROC)glewGetProcAddress((const GLubyte*)"glPathDashArrayNV")) == NULL) || r; r = ((glPathFogGenNV = (PFNGLPATHFOGGENNVPROC)glewGetProcAddress((const GLubyte*)"glPathFogGenNV")) == NULL) || r; r = ((glPathGlyphIndexArrayNV = (PFNGLPATHGLYPHINDEXARRAYNVPROC)glewGetProcAddress((const GLubyte*)"glPathGlyphIndexArrayNV")) == NULL) || r; r = ((glPathGlyphIndexRangeNV = (PFNGLPATHGLYPHINDEXRANGENVPROC)glewGetProcAddress((const GLubyte*)"glPathGlyphIndexRangeNV")) == NULL) || r; r = ((glPathGlyphRangeNV = (PFNGLPATHGLYPHRANGENVPROC)glewGetProcAddress((const GLubyte*)"glPathGlyphRangeNV")) == NULL) || r; r = ((glPathGlyphsNV = (PFNGLPATHGLYPHSNVPROC)glewGetProcAddress((const GLubyte*)"glPathGlyphsNV")) == NULL) || r; r = ((glPathMemoryGlyphIndexArrayNV = (PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC)glewGetProcAddress((const GLubyte*)"glPathMemoryGlyphIndexArrayNV")) == NULL) || r; r = ((glPathParameterfNV = (PFNGLPATHPARAMETERFNVPROC)glewGetProcAddress((const GLubyte*)"glPathParameterfNV")) == NULL) || r; r = ((glPathParameterfvNV = (PFNGLPATHPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glPathParameterfvNV")) == NULL) || r; r = ((glPathParameteriNV = (PFNGLPATHPARAMETERINVPROC)glewGetProcAddress((const GLubyte*)"glPathParameteriNV")) == NULL) || r; r = ((glPathParameterivNV = (PFNGLPATHPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glPathParameterivNV")) == NULL) || r; r = ((glPathStencilDepthOffsetNV = (PFNGLPATHSTENCILDEPTHOFFSETNVPROC)glewGetProcAddress((const GLubyte*)"glPathStencilDepthOffsetNV")) == NULL) || r; r = ((glPathStencilFuncNV = (PFNGLPATHSTENCILFUNCNVPROC)glewGetProcAddress((const GLubyte*)"glPathStencilFuncNV")) == NULL) || r; r = ((glPathStringNV = (PFNGLPATHSTRINGNVPROC)glewGetProcAddress((const GLubyte*)"glPathStringNV")) == NULL) || r; r = ((glPathSubCommandsNV = (PFNGLPATHSUBCOMMANDSNVPROC)glewGetProcAddress((const GLubyte*)"glPathSubCommandsNV")) == NULL) || r; r = ((glPathSubCoordsNV = (PFNGLPATHSUBCOORDSNVPROC)glewGetProcAddress((const GLubyte*)"glPathSubCoordsNV")) == NULL) || r; r = ((glPathTexGenNV = (PFNGLPATHTEXGENNVPROC)glewGetProcAddress((const GLubyte*)"glPathTexGenNV")) == NULL) || r; r = ((glPointAlongPathNV = (PFNGLPOINTALONGPATHNVPROC)glewGetProcAddress((const GLubyte*)"glPointAlongPathNV")) == NULL) || r; r = ((glProgramPathFragmentInputGenNV = (PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC)glewGetProcAddress((const GLubyte*)"glProgramPathFragmentInputGenNV")) == NULL) || r; r = ((glStencilFillPathInstancedNV = (PFNGLSTENCILFILLPATHINSTANCEDNVPROC)glewGetProcAddress((const GLubyte*)"glStencilFillPathInstancedNV")) == NULL) || r; r = ((glStencilFillPathNV = (PFNGLSTENCILFILLPATHNVPROC)glewGetProcAddress((const GLubyte*)"glStencilFillPathNV")) == NULL) || r; r = ((glStencilStrokePathInstancedNV = (PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC)glewGetProcAddress((const GLubyte*)"glStencilStrokePathInstancedNV")) == NULL) || r; r = ((glStencilStrokePathNV = (PFNGLSTENCILSTROKEPATHNVPROC)glewGetProcAddress((const GLubyte*)"glStencilStrokePathNV")) == NULL) || r; r = ((glStencilThenCoverFillPathInstancedNV = (PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC)glewGetProcAddress((const GLubyte*)"glStencilThenCoverFillPathInstancedNV")) == NULL) || r; r = ((glStencilThenCoverFillPathNV = (PFNGLSTENCILTHENCOVERFILLPATHNVPROC)glewGetProcAddress((const GLubyte*)"glStencilThenCoverFillPathNV")) == NULL) || r; r = ((glStencilThenCoverStrokePathInstancedNV = (PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC)glewGetProcAddress((const GLubyte*)"glStencilThenCoverStrokePathInstancedNV")) == NULL) || r; r = ((glStencilThenCoverStrokePathNV = (PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC)glewGetProcAddress((const GLubyte*)"glStencilThenCoverStrokePathNV")) == NULL) || r; r = ((glTransformPathNV = (PFNGLTRANSFORMPATHNVPROC)glewGetProcAddress((const GLubyte*)"glTransformPathNV")) == NULL) || r; r = ((glWeightPathsNV = (PFNGLWEIGHTPATHSNVPROC)glewGetProcAddress((const GLubyte*)"glWeightPathsNV")) == NULL) || r; return r; } #endif /* GL_NV_path_rendering */ #ifdef GL_NV_pixel_data_range static GLboolean _glewInit_GL_NV_pixel_data_range (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFlushPixelDataRangeNV = (PFNGLFLUSHPIXELDATARANGENVPROC)glewGetProcAddress((const GLubyte*)"glFlushPixelDataRangeNV")) == NULL) || r; r = ((glPixelDataRangeNV = (PFNGLPIXELDATARANGENVPROC)glewGetProcAddress((const GLubyte*)"glPixelDataRangeNV")) == NULL) || r; return r; } #endif /* GL_NV_pixel_data_range */ #ifdef GL_NV_point_sprite static GLboolean _glewInit_GL_NV_point_sprite (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glPointParameteriNV = (PFNGLPOINTPARAMETERINVPROC)glewGetProcAddress((const GLubyte*)"glPointParameteriNV")) == NULL) || r; r = ((glPointParameterivNV = (PFNGLPOINTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glPointParameterivNV")) == NULL) || r; return r; } #endif /* GL_NV_point_sprite */ #ifdef GL_NV_present_video static GLboolean _glewInit_GL_NV_present_video (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetVideoi64vNV = (PFNGLGETVIDEOI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideoi64vNV")) == NULL) || r; r = ((glGetVideoivNV = (PFNGLGETVIDEOIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideoivNV")) == NULL) || r; r = ((glGetVideoui64vNV = (PFNGLGETVIDEOUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideoui64vNV")) == NULL) || r; r = ((glGetVideouivNV = (PFNGLGETVIDEOUIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideouivNV")) == NULL) || r; r = ((glPresentFrameDualFillNV = (PFNGLPRESENTFRAMEDUALFILLNVPROC)glewGetProcAddress((const GLubyte*)"glPresentFrameDualFillNV")) == NULL) || r; r = ((glPresentFrameKeyedNV = (PFNGLPRESENTFRAMEKEYEDNVPROC)glewGetProcAddress((const GLubyte*)"glPresentFrameKeyedNV")) == NULL) || r; return r; } #endif /* GL_NV_present_video */ #ifdef GL_NV_primitive_restart static GLboolean _glewInit_GL_NV_primitive_restart (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glPrimitiveRestartIndexNV = (PFNGLPRIMITIVERESTARTINDEXNVPROC)glewGetProcAddress((const GLubyte*)"glPrimitiveRestartIndexNV")) == NULL) || r; r = ((glPrimitiveRestartNV = (PFNGLPRIMITIVERESTARTNVPROC)glewGetProcAddress((const GLubyte*)"glPrimitiveRestartNV")) == NULL) || r; return r; } #endif /* GL_NV_primitive_restart */ #ifdef GL_NV_register_combiners static GLboolean _glewInit_GL_NV_register_combiners (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glCombinerInputNV = (PFNGLCOMBINERINPUTNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerInputNV")) == NULL) || r; r = ((glCombinerOutputNV = (PFNGLCOMBINEROUTPUTNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerOutputNV")) == NULL) || r; r = ((glCombinerParameterfNV = (PFNGLCOMBINERPARAMETERFNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerParameterfNV")) == NULL) || r; r = ((glCombinerParameterfvNV = (PFNGLCOMBINERPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerParameterfvNV")) == NULL) || r; r = ((glCombinerParameteriNV = (PFNGLCOMBINERPARAMETERINVPROC)glewGetProcAddress((const GLubyte*)"glCombinerParameteriNV")) == NULL) || r; r = ((glCombinerParameterivNV = (PFNGLCOMBINERPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerParameterivNV")) == NULL) || r; r = ((glFinalCombinerInputNV = (PFNGLFINALCOMBINERINPUTNVPROC)glewGetProcAddress((const GLubyte*)"glFinalCombinerInputNV")) == NULL) || r; r = ((glGetCombinerInputParameterfvNV = (PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerInputParameterfvNV")) == NULL) || r; r = ((glGetCombinerInputParameterivNV = (PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerInputParameterivNV")) == NULL) || r; r = ((glGetCombinerOutputParameterfvNV = (PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerOutputParameterfvNV")) == NULL) || r; r = ((glGetCombinerOutputParameterivNV = (PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerOutputParameterivNV")) == NULL) || r; r = ((glGetFinalCombinerInputParameterfvNV = (PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetFinalCombinerInputParameterfvNV")) == NULL) || r; r = ((glGetFinalCombinerInputParameterivNV = (PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetFinalCombinerInputParameterivNV")) == NULL) || r; return r; } #endif /* GL_NV_register_combiners */ #ifdef GL_NV_register_combiners2 static GLboolean _glewInit_GL_NV_register_combiners2 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glCombinerStageParameterfvNV = (PFNGLCOMBINERSTAGEPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerStageParameterfvNV")) == NULL) || r; r = ((glGetCombinerStageParameterfvNV = (PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerStageParameterfvNV")) == NULL) || r; return r; } #endif /* GL_NV_register_combiners2 */ #ifdef GL_NV_sample_locations static GLboolean _glewInit_GL_NV_sample_locations (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFramebufferSampleLocationsfvNV = (PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC)glewGetProcAddress((const GLubyte*)"glFramebufferSampleLocationsfvNV")) == NULL) || r; r = ((glNamedFramebufferSampleLocationsfvNV = (PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferSampleLocationsfvNV")) == NULL) || r; return r; } #endif /* GL_NV_sample_locations */ #ifdef GL_NV_shader_buffer_load static GLboolean _glewInit_GL_NV_shader_buffer_load (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetBufferParameterui64vNV = (PFNGLGETBUFFERPARAMETERUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetBufferParameterui64vNV")) == NULL) || r; r = ((glGetIntegerui64vNV = (PFNGLGETINTEGERUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetIntegerui64vNV")) == NULL) || r; r = ((glGetNamedBufferParameterui64vNV = (PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferParameterui64vNV")) == NULL) || r; r = ((glIsBufferResidentNV = (PFNGLISBUFFERRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glIsBufferResidentNV")) == NULL) || r; r = ((glIsNamedBufferResidentNV = (PFNGLISNAMEDBUFFERRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glIsNamedBufferResidentNV")) == NULL) || r; r = ((glMakeBufferNonResidentNV = (PFNGLMAKEBUFFERNONRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glMakeBufferNonResidentNV")) == NULL) || r; r = ((glMakeBufferResidentNV = (PFNGLMAKEBUFFERRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glMakeBufferResidentNV")) == NULL) || r; r = ((glMakeNamedBufferNonResidentNV = (PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glMakeNamedBufferNonResidentNV")) == NULL) || r; r = ((glMakeNamedBufferResidentNV = (PFNGLMAKENAMEDBUFFERRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glMakeNamedBufferResidentNV")) == NULL) || r; r = ((glProgramUniformui64NV = (PFNGLPROGRAMUNIFORMUI64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformui64NV")) == NULL) || r; r = ((glProgramUniformui64vNV = (PFNGLPROGRAMUNIFORMUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformui64vNV")) == NULL) || r; r = ((glUniformui64NV = (PFNGLUNIFORMUI64NVPROC)glewGetProcAddress((const GLubyte*)"glUniformui64NV")) == NULL) || r; r = ((glUniformui64vNV = (PFNGLUNIFORMUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniformui64vNV")) == NULL) || r; return r; } #endif /* GL_NV_shader_buffer_load */ #ifdef GL_NV_texture_barrier static GLboolean _glewInit_GL_NV_texture_barrier (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTextureBarrierNV = (PFNGLTEXTUREBARRIERNVPROC)glewGetProcAddress((const GLubyte*)"glTextureBarrierNV")) == NULL) || r; return r; } #endif /* GL_NV_texture_barrier */ #ifdef GL_NV_texture_multisample static GLboolean _glewInit_GL_NV_texture_multisample (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTexImage2DMultisampleCoverageNV = (PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC)glewGetProcAddress((const GLubyte*)"glTexImage2DMultisampleCoverageNV")) == NULL) || r; r = ((glTexImage3DMultisampleCoverageNV = (PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC)glewGetProcAddress((const GLubyte*)"glTexImage3DMultisampleCoverageNV")) == NULL) || r; r = ((glTextureImage2DMultisampleCoverageNV = (PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC)glewGetProcAddress((const GLubyte*)"glTextureImage2DMultisampleCoverageNV")) == NULL) || r; r = ((glTextureImage2DMultisampleNV = (PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC)glewGetProcAddress((const GLubyte*)"glTextureImage2DMultisampleNV")) == NULL) || r; r = ((glTextureImage3DMultisampleCoverageNV = (PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC)glewGetProcAddress((const GLubyte*)"glTextureImage3DMultisampleCoverageNV")) == NULL) || r; r = ((glTextureImage3DMultisampleNV = (PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC)glewGetProcAddress((const GLubyte*)"glTextureImage3DMultisampleNV")) == NULL) || r; return r; } #endif /* GL_NV_texture_multisample */ #ifdef GL_NV_transform_feedback static GLboolean _glewInit_GL_NV_transform_feedback (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glActiveVaryingNV = (PFNGLACTIVEVARYINGNVPROC)glewGetProcAddress((const GLubyte*)"glActiveVaryingNV")) == NULL) || r; r = ((glBeginTransformFeedbackNV = (PFNGLBEGINTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glBeginTransformFeedbackNV")) == NULL) || r; r = ((glBindBufferBaseNV = (PFNGLBINDBUFFERBASENVPROC)glewGetProcAddress((const GLubyte*)"glBindBufferBaseNV")) == NULL) || r; r = ((glBindBufferOffsetNV = (PFNGLBINDBUFFEROFFSETNVPROC)glewGetProcAddress((const GLubyte*)"glBindBufferOffsetNV")) == NULL) || r; r = ((glBindBufferRangeNV = (PFNGLBINDBUFFERRANGENVPROC)glewGetProcAddress((const GLubyte*)"glBindBufferRangeNV")) == NULL) || r; r = ((glEndTransformFeedbackNV = (PFNGLENDTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glEndTransformFeedbackNV")) == NULL) || r; r = ((glGetActiveVaryingNV = (PFNGLGETACTIVEVARYINGNVPROC)glewGetProcAddress((const GLubyte*)"glGetActiveVaryingNV")) == NULL) || r; r = ((glGetTransformFeedbackVaryingNV = (PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC)glewGetProcAddress((const GLubyte*)"glGetTransformFeedbackVaryingNV")) == NULL) || r; r = ((glGetVaryingLocationNV = (PFNGLGETVARYINGLOCATIONNVPROC)glewGetProcAddress((const GLubyte*)"glGetVaryingLocationNV")) == NULL) || r; r = ((glTransformFeedbackAttribsNV = (PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC)glewGetProcAddress((const GLubyte*)"glTransformFeedbackAttribsNV")) == NULL) || r; r = ((glTransformFeedbackVaryingsNV = (PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC)glewGetProcAddress((const GLubyte*)"glTransformFeedbackVaryingsNV")) == NULL) || r; return r; } #endif /* GL_NV_transform_feedback */ #ifdef GL_NV_transform_feedback2 static GLboolean _glewInit_GL_NV_transform_feedback2 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBindTransformFeedbackNV = (PFNGLBINDTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glBindTransformFeedbackNV")) == NULL) || r; r = ((glDeleteTransformFeedbacksNV = (PFNGLDELETETRANSFORMFEEDBACKSNVPROC)glewGetProcAddress((const GLubyte*)"glDeleteTransformFeedbacksNV")) == NULL) || r; r = ((glDrawTransformFeedbackNV = (PFNGLDRAWTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glDrawTransformFeedbackNV")) == NULL) || r; r = ((glGenTransformFeedbacksNV = (PFNGLGENTRANSFORMFEEDBACKSNVPROC)glewGetProcAddress((const GLubyte*)"glGenTransformFeedbacksNV")) == NULL) || r; r = ((glIsTransformFeedbackNV = (PFNGLISTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glIsTransformFeedbackNV")) == NULL) || r; r = ((glPauseTransformFeedbackNV = (PFNGLPAUSETRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glPauseTransformFeedbackNV")) == NULL) || r; r = ((glResumeTransformFeedbackNV = (PFNGLRESUMETRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glResumeTransformFeedbackNV")) == NULL) || r; return r; } #endif /* GL_NV_transform_feedback2 */ #ifdef GL_NV_vdpau_interop static GLboolean _glewInit_GL_NV_vdpau_interop (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glVDPAUFiniNV = (PFNGLVDPAUFININVPROC)glewGetProcAddress((const GLubyte*)"glVDPAUFiniNV")) == NULL) || r; r = ((glVDPAUGetSurfaceivNV = (PFNGLVDPAUGETSURFACEIVNVPROC)glewGetProcAddress((const GLubyte*)"glVDPAUGetSurfaceivNV")) == NULL) || r; r = ((glVDPAUInitNV = (PFNGLVDPAUINITNVPROC)glewGetProcAddress((const GLubyte*)"glVDPAUInitNV")) == NULL) || r; r = ((glVDPAUIsSurfaceNV = (PFNGLVDPAUISSURFACENVPROC)glewGetProcAddress((const GLubyte*)"glVDPAUIsSurfaceNV")) == NULL) || r; r = ((glVDPAUMapSurfacesNV = (PFNGLVDPAUMAPSURFACESNVPROC)glewGetProcAddress((const GLubyte*)"glVDPAUMapSurfacesNV")) == NULL) || r; r = ((glVDPAURegisterOutputSurfaceNV = (PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC)glewGetProcAddress((const GLubyte*)"glVDPAURegisterOutputSurfaceNV")) == NULL) || r; r = ((glVDPAURegisterVideoSurfaceNV = (PFNGLVDPAUREGISTERVIDEOSURFACENVPROC)glewGetProcAddress((const GLubyte*)"glVDPAURegisterVideoSurfaceNV")) == NULL) || r; r = ((glVDPAUSurfaceAccessNV = (PFNGLVDPAUSURFACEACCESSNVPROC)glewGetProcAddress((const GLubyte*)"glVDPAUSurfaceAccessNV")) == NULL) || r; r = ((glVDPAUUnmapSurfacesNV = (PFNGLVDPAUUNMAPSURFACESNVPROC)glewGetProcAddress((const GLubyte*)"glVDPAUUnmapSurfacesNV")) == NULL) || r; r = ((glVDPAUUnregisterSurfaceNV = (PFNGLVDPAUUNREGISTERSURFACENVPROC)glewGetProcAddress((const GLubyte*)"glVDPAUUnregisterSurfaceNV")) == NULL) || r; return r; } #endif /* GL_NV_vdpau_interop */ #ifdef GL_NV_vertex_array_range static GLboolean _glewInit_GL_NV_vertex_array_range (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFlushVertexArrayRangeNV = (PFNGLFLUSHVERTEXARRAYRANGENVPROC)glewGetProcAddress((const GLubyte*)"glFlushVertexArrayRangeNV")) == NULL) || r; r = ((glVertexArrayRangeNV = (PFNGLVERTEXARRAYRANGENVPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayRangeNV")) == NULL) || r; return r; } #endif /* GL_NV_vertex_array_range */ #ifdef GL_NV_vertex_attrib_integer_64bit static GLboolean _glewInit_GL_NV_vertex_attrib_integer_64bit (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetVertexAttribLi64vNV = (PFNGLGETVERTEXATTRIBLI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribLi64vNV")) == NULL) || r; r = ((glGetVertexAttribLui64vNV = (PFNGLGETVERTEXATTRIBLUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribLui64vNV")) == NULL) || r; r = ((glVertexAttribL1i64NV = (PFNGLVERTEXATTRIBL1I64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1i64NV")) == NULL) || r; r = ((glVertexAttribL1i64vNV = (PFNGLVERTEXATTRIBL1I64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1i64vNV")) == NULL) || r; r = ((glVertexAttribL1ui64NV = (PFNGLVERTEXATTRIBL1UI64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1ui64NV")) == NULL) || r; r = ((glVertexAttribL1ui64vNV = (PFNGLVERTEXATTRIBL1UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1ui64vNV")) == NULL) || r; r = ((glVertexAttribL2i64NV = (PFNGLVERTEXATTRIBL2I64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL2i64NV")) == NULL) || r; r = ((glVertexAttribL2i64vNV = (PFNGLVERTEXATTRIBL2I64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL2i64vNV")) == NULL) || r; r = ((glVertexAttribL2ui64NV = (PFNGLVERTEXATTRIBL2UI64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL2ui64NV")) == NULL) || r; r = ((glVertexAttribL2ui64vNV = (PFNGLVERTEXATTRIBL2UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL2ui64vNV")) == NULL) || r; r = ((glVertexAttribL3i64NV = (PFNGLVERTEXATTRIBL3I64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL3i64NV")) == NULL) || r; r = ((glVertexAttribL3i64vNV = (PFNGLVERTEXATTRIBL3I64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL3i64vNV")) == NULL) || r; r = ((glVertexAttribL3ui64NV = (PFNGLVERTEXATTRIBL3UI64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL3ui64NV")) == NULL) || r; r = ((glVertexAttribL3ui64vNV = (PFNGLVERTEXATTRIBL3UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL3ui64vNV")) == NULL) || r; r = ((glVertexAttribL4i64NV = (PFNGLVERTEXATTRIBL4I64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL4i64NV")) == NULL) || r; r = ((glVertexAttribL4i64vNV = (PFNGLVERTEXATTRIBL4I64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL4i64vNV")) == NULL) || r; r = ((glVertexAttribL4ui64NV = (PFNGLVERTEXATTRIBL4UI64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL4ui64NV")) == NULL) || r; r = ((glVertexAttribL4ui64vNV = (PFNGLVERTEXATTRIBL4UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL4ui64vNV")) == NULL) || r; r = ((glVertexAttribLFormatNV = (PFNGLVERTEXATTRIBLFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribLFormatNV")) == NULL) || r; return r; } #endif /* GL_NV_vertex_attrib_integer_64bit */ #ifdef GL_NV_vertex_buffer_unified_memory static GLboolean _glewInit_GL_NV_vertex_buffer_unified_memory (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBufferAddressRangeNV = (PFNGLBUFFERADDRESSRANGENVPROC)glewGetProcAddress((const GLubyte*)"glBufferAddressRangeNV")) == NULL) || r; r = ((glColorFormatNV = (PFNGLCOLORFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glColorFormatNV")) == NULL) || r; r = ((glEdgeFlagFormatNV = (PFNGLEDGEFLAGFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glEdgeFlagFormatNV")) == NULL) || r; r = ((glFogCoordFormatNV = (PFNGLFOGCOORDFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glFogCoordFormatNV")) == NULL) || r; r = ((glGetIntegerui64i_vNV = (PFNGLGETINTEGERUI64I_VNVPROC)glewGetProcAddress((const GLubyte*)"glGetIntegerui64i_vNV")) == NULL) || r; r = ((glIndexFormatNV = (PFNGLINDEXFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glIndexFormatNV")) == NULL) || r; r = ((glNormalFormatNV = (PFNGLNORMALFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glNormalFormatNV")) == NULL) || r; r = ((glSecondaryColorFormatNV = (PFNGLSECONDARYCOLORFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorFormatNV")) == NULL) || r; r = ((glTexCoordFormatNV = (PFNGLTEXCOORDFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoordFormatNV")) == NULL) || r; r = ((glVertexAttribFormatNV = (PFNGLVERTEXATTRIBFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribFormatNV")) == NULL) || r; r = ((glVertexAttribIFormatNV = (PFNGLVERTEXATTRIBIFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribIFormatNV")) == NULL) || r; r = ((glVertexFormatNV = (PFNGLVERTEXFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glVertexFormatNV")) == NULL) || r; return r; } #endif /* GL_NV_vertex_buffer_unified_memory */ #ifdef GL_NV_vertex_program static GLboolean _glewInit_GL_NV_vertex_program (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glAreProgramsResidentNV = (PFNGLAREPROGRAMSRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glAreProgramsResidentNV")) == NULL) || r; r = ((glBindProgramNV = (PFNGLBINDPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)"glBindProgramNV")) == NULL) || r; r = ((glDeleteProgramsNV = (PFNGLDELETEPROGRAMSNVPROC)glewGetProcAddress((const GLubyte*)"glDeleteProgramsNV")) == NULL) || r; r = ((glExecuteProgramNV = (PFNGLEXECUTEPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)"glExecuteProgramNV")) == NULL) || r; r = ((glGenProgramsNV = (PFNGLGENPROGRAMSNVPROC)glewGetProcAddress((const GLubyte*)"glGenProgramsNV")) == NULL) || r; r = ((glGetProgramParameterdvNV = (PFNGLGETPROGRAMPARAMETERDVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramParameterdvNV")) == NULL) || r; r = ((glGetProgramParameterfvNV = (PFNGLGETPROGRAMPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramParameterfvNV")) == NULL) || r; r = ((glGetProgramStringNV = (PFNGLGETPROGRAMSTRINGNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramStringNV")) == NULL) || r; r = ((glGetProgramivNV = (PFNGLGETPROGRAMIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramivNV")) == NULL) || r; r = ((glGetTrackMatrixivNV = (PFNGLGETTRACKMATRIXIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetTrackMatrixivNV")) == NULL) || r; r = ((glGetVertexAttribPointervNV = (PFNGLGETVERTEXATTRIBPOINTERVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribPointervNV")) == NULL) || r; r = ((glGetVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribdvNV")) == NULL) || r; r = ((glGetVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribfvNV")) == NULL) || r; r = ((glGetVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribivNV")) == NULL) || r; r = ((glIsProgramNV = (PFNGLISPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)"glIsProgramNV")) == NULL) || r; r = ((glLoadProgramNV = (PFNGLLOADPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)"glLoadProgramNV")) == NULL) || r; r = ((glProgramParameter4dNV = (PFNGLPROGRAMPARAMETER4DNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameter4dNV")) == NULL) || r; r = ((glProgramParameter4dvNV = (PFNGLPROGRAMPARAMETER4DVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameter4dvNV")) == NULL) || r; r = ((glProgramParameter4fNV = (PFNGLPROGRAMPARAMETER4FNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameter4fNV")) == NULL) || r; r = ((glProgramParameter4fvNV = (PFNGLPROGRAMPARAMETER4FVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameter4fvNV")) == NULL) || r; r = ((glProgramParameters4dvNV = (PFNGLPROGRAMPARAMETERS4DVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameters4dvNV")) == NULL) || r; r = ((glProgramParameters4fvNV = (PFNGLPROGRAMPARAMETERS4FVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameters4fvNV")) == NULL) || r; r = ((glRequestResidentProgramsNV = (PFNGLREQUESTRESIDENTPROGRAMSNVPROC)glewGetProcAddress((const GLubyte*)"glRequestResidentProgramsNV")) == NULL) || r; r = ((glTrackMatrixNV = (PFNGLTRACKMATRIXNVPROC)glewGetProcAddress((const GLubyte*)"glTrackMatrixNV")) == NULL) || r; r = ((glVertexAttrib1dNV = (PFNGLVERTEXATTRIB1DNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dNV")) == NULL) || r; r = ((glVertexAttrib1dvNV = (PFNGLVERTEXATTRIB1DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dvNV")) == NULL) || r; r = ((glVertexAttrib1fNV = (PFNGLVERTEXATTRIB1FNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fNV")) == NULL) || r; r = ((glVertexAttrib1fvNV = (PFNGLVERTEXATTRIB1FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fvNV")) == NULL) || r; r = ((glVertexAttrib1sNV = (PFNGLVERTEXATTRIB1SNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1sNV")) == NULL) || r; r = ((glVertexAttrib1svNV = (PFNGLVERTEXATTRIB1SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1svNV")) == NULL) || r; r = ((glVertexAttrib2dNV = (PFNGLVERTEXATTRIB2DNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dNV")) == NULL) || r; r = ((glVertexAttrib2dvNV = (PFNGLVERTEXATTRIB2DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dvNV")) == NULL) || r; r = ((glVertexAttrib2fNV = (PFNGLVERTEXATTRIB2FNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fNV")) == NULL) || r; r = ((glVertexAttrib2fvNV = (PFNGLVERTEXATTRIB2FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fvNV")) == NULL) || r; r = ((glVertexAttrib2sNV = (PFNGLVERTEXATTRIB2SNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2sNV")) == NULL) || r; r = ((glVertexAttrib2svNV = (PFNGLVERTEXATTRIB2SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2svNV")) == NULL) || r; r = ((glVertexAttrib3dNV = (PFNGLVERTEXATTRIB3DNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dNV")) == NULL) || r; r = ((glVertexAttrib3dvNV = (PFNGLVERTEXATTRIB3DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dvNV")) == NULL) || r; r = ((glVertexAttrib3fNV = (PFNGLVERTEXATTRIB3FNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fNV")) == NULL) || r; r = ((glVertexAttrib3fvNV = (PFNGLVERTEXATTRIB3FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fvNV")) == NULL) || r; r = ((glVertexAttrib3sNV = (PFNGLVERTEXATTRIB3SNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3sNV")) == NULL) || r; r = ((glVertexAttrib3svNV = (PFNGLVERTEXATTRIB3SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3svNV")) == NULL) || r; r = ((glVertexAttrib4dNV = (PFNGLVERTEXATTRIB4DNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dNV")) == NULL) || r; r = ((glVertexAttrib4dvNV = (PFNGLVERTEXATTRIB4DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dvNV")) == NULL) || r; r = ((glVertexAttrib4fNV = (PFNGLVERTEXATTRIB4FNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fNV")) == NULL) || r; r = ((glVertexAttrib4fvNV = (PFNGLVERTEXATTRIB4FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fvNV")) == NULL) || r; r = ((glVertexAttrib4sNV = (PFNGLVERTEXATTRIB4SNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4sNV")) == NULL) || r; r = ((glVertexAttrib4svNV = (PFNGLVERTEXATTRIB4SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4svNV")) == NULL) || r; r = ((glVertexAttrib4ubNV = (PFNGLVERTEXATTRIB4UBNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ubNV")) == NULL) || r; r = ((glVertexAttrib4ubvNV = (PFNGLVERTEXATTRIB4UBVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ubvNV")) == NULL) || r; r = ((glVertexAttribPointerNV = (PFNGLVERTEXATTRIBPOINTERNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribPointerNV")) == NULL) || r; r = ((glVertexAttribs1dvNV = (PFNGLVERTEXATTRIBS1DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs1dvNV")) == NULL) || r; r = ((glVertexAttribs1fvNV = (PFNGLVERTEXATTRIBS1FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs1fvNV")) == NULL) || r; r = ((glVertexAttribs1svNV = (PFNGLVERTEXATTRIBS1SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs1svNV")) == NULL) || r; r = ((glVertexAttribs2dvNV = (PFNGLVERTEXATTRIBS2DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs2dvNV")) == NULL) || r; r = ((glVertexAttribs2fvNV = (PFNGLVERTEXATTRIBS2FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs2fvNV")) == NULL) || r; r = ((glVertexAttribs2svNV = (PFNGLVERTEXATTRIBS2SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs2svNV")) == NULL) || r; r = ((glVertexAttribs3dvNV = (PFNGLVERTEXATTRIBS3DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs3dvNV")) == NULL) || r; r = ((glVertexAttribs3fvNV = (PFNGLVERTEXATTRIBS3FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs3fvNV")) == NULL) || r; r = ((glVertexAttribs3svNV = (PFNGLVERTEXATTRIBS3SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs3svNV")) == NULL) || r; r = ((glVertexAttribs4dvNV = (PFNGLVERTEXATTRIBS4DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4dvNV")) == NULL) || r; r = ((glVertexAttribs4fvNV = (PFNGLVERTEXATTRIBS4FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4fvNV")) == NULL) || r; r = ((glVertexAttribs4svNV = (PFNGLVERTEXATTRIBS4SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4svNV")) == NULL) || r; r = ((glVertexAttribs4ubvNV = (PFNGLVERTEXATTRIBS4UBVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4ubvNV")) == NULL) || r; return r; } #endif /* GL_NV_vertex_program */ #ifdef GL_NV_video_capture static GLboolean _glewInit_GL_NV_video_capture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glBeginVideoCaptureNV = (PFNGLBEGINVIDEOCAPTURENVPROC)glewGetProcAddress((const GLubyte*)"glBeginVideoCaptureNV")) == NULL) || r; r = ((glBindVideoCaptureStreamBufferNV = (PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC)glewGetProcAddress((const GLubyte*)"glBindVideoCaptureStreamBufferNV")) == NULL) || r; r = ((glBindVideoCaptureStreamTextureNV = (PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC)glewGetProcAddress((const GLubyte*)"glBindVideoCaptureStreamTextureNV")) == NULL) || r; r = ((glEndVideoCaptureNV = (PFNGLENDVIDEOCAPTURENVPROC)glewGetProcAddress((const GLubyte*)"glEndVideoCaptureNV")) == NULL) || r; r = ((glGetVideoCaptureStreamdvNV = (PFNGLGETVIDEOCAPTURESTREAMDVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideoCaptureStreamdvNV")) == NULL) || r; r = ((glGetVideoCaptureStreamfvNV = (PFNGLGETVIDEOCAPTURESTREAMFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideoCaptureStreamfvNV")) == NULL) || r; r = ((glGetVideoCaptureStreamivNV = (PFNGLGETVIDEOCAPTURESTREAMIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideoCaptureStreamivNV")) == NULL) || r; r = ((glGetVideoCaptureivNV = (PFNGLGETVIDEOCAPTUREIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideoCaptureivNV")) == NULL) || r; r = ((glVideoCaptureNV = (PFNGLVIDEOCAPTURENVPROC)glewGetProcAddress((const GLubyte*)"glVideoCaptureNV")) == NULL) || r; r = ((glVideoCaptureStreamParameterdvNV = (PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC)glewGetProcAddress((const GLubyte*)"glVideoCaptureStreamParameterdvNV")) == NULL) || r; r = ((glVideoCaptureStreamParameterfvNV = (PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glVideoCaptureStreamParameterfvNV")) == NULL) || r; r = ((glVideoCaptureStreamParameterivNV = (PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glVideoCaptureStreamParameterivNV")) == NULL) || r; return r; } #endif /* GL_NV_video_capture */ #ifdef GL_OES_single_precision static GLboolean _glewInit_GL_OES_single_precision (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glClearDepthfOES = (PFNGLCLEARDEPTHFOESPROC)glewGetProcAddress((const GLubyte*)"glClearDepthfOES")) == NULL) || r; r = ((glClipPlanefOES = (PFNGLCLIPPLANEFOESPROC)glewGetProcAddress((const GLubyte*)"glClipPlanefOES")) == NULL) || r; r = ((glDepthRangefOES = (PFNGLDEPTHRANGEFOESPROC)glewGetProcAddress((const GLubyte*)"glDepthRangefOES")) == NULL) || r; r = ((glFrustumfOES = (PFNGLFRUSTUMFOESPROC)glewGetProcAddress((const GLubyte*)"glFrustumfOES")) == NULL) || r; r = ((glGetClipPlanefOES = (PFNGLGETCLIPPLANEFOESPROC)glewGetProcAddress((const GLubyte*)"glGetClipPlanefOES")) == NULL) || r; r = ((glOrthofOES = (PFNGLORTHOFOESPROC)glewGetProcAddress((const GLubyte*)"glOrthofOES")) == NULL) || r; return r; } #endif /* GL_OES_single_precision */ #ifdef GL_OVR_multiview static GLboolean _glewInit_GL_OVR_multiview (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFramebufferTextureMultiviewOVR = (PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureMultiviewOVR")) == NULL) || r; return r; } #endif /* GL_OVR_multiview */ #ifdef GL_REGAL_ES1_0_compatibility static GLboolean _glewInit_GL_REGAL_ES1_0_compatibility (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glAlphaFuncx = (PFNGLALPHAFUNCXPROC)glewGetProcAddress((const GLubyte*)"glAlphaFuncx")) == NULL) || r; r = ((glClearColorx = (PFNGLCLEARCOLORXPROC)glewGetProcAddress((const GLubyte*)"glClearColorx")) == NULL) || r; r = ((glClearDepthx = (PFNGLCLEARDEPTHXPROC)glewGetProcAddress((const GLubyte*)"glClearDepthx")) == NULL) || r; r = ((glColor4x = (PFNGLCOLOR4XPROC)glewGetProcAddress((const GLubyte*)"glColor4x")) == NULL) || r; r = ((glDepthRangex = (PFNGLDEPTHRANGEXPROC)glewGetProcAddress((const GLubyte*)"glDepthRangex")) == NULL) || r; r = ((glFogx = (PFNGLFOGXPROC)glewGetProcAddress((const GLubyte*)"glFogx")) == NULL) || r; r = ((glFogxv = (PFNGLFOGXVPROC)glewGetProcAddress((const GLubyte*)"glFogxv")) == NULL) || r; r = ((glFrustumf = (PFNGLFRUSTUMFPROC)glewGetProcAddress((const GLubyte*)"glFrustumf")) == NULL) || r; r = ((glFrustumx = (PFNGLFRUSTUMXPROC)glewGetProcAddress((const GLubyte*)"glFrustumx")) == NULL) || r; r = ((glLightModelx = (PFNGLLIGHTMODELXPROC)glewGetProcAddress((const GLubyte*)"glLightModelx")) == NULL) || r; r = ((glLightModelxv = (PFNGLLIGHTMODELXVPROC)glewGetProcAddress((const GLubyte*)"glLightModelxv")) == NULL) || r; r = ((glLightx = (PFNGLLIGHTXPROC)glewGetProcAddress((const GLubyte*)"glLightx")) == NULL) || r; r = ((glLightxv = (PFNGLLIGHTXVPROC)glewGetProcAddress((const GLubyte*)"glLightxv")) == NULL) || r; r = ((glLineWidthx = (PFNGLLINEWIDTHXPROC)glewGetProcAddress((const GLubyte*)"glLineWidthx")) == NULL) || r; r = ((glLoadMatrixx = (PFNGLLOADMATRIXXPROC)glewGetProcAddress((const GLubyte*)"glLoadMatrixx")) == NULL) || r; r = ((glMaterialx = (PFNGLMATERIALXPROC)glewGetProcAddress((const GLubyte*)"glMaterialx")) == NULL) || r; r = ((glMaterialxv = (PFNGLMATERIALXVPROC)glewGetProcAddress((const GLubyte*)"glMaterialxv")) == NULL) || r; r = ((glMultMatrixx = (PFNGLMULTMATRIXXPROC)glewGetProcAddress((const GLubyte*)"glMultMatrixx")) == NULL) || r; r = ((glMultiTexCoord4x = (PFNGLMULTITEXCOORD4XPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4x")) == NULL) || r; r = ((glNormal3x = (PFNGLNORMAL3XPROC)glewGetProcAddress((const GLubyte*)"glNormal3x")) == NULL) || r; r = ((glOrthof = (PFNGLORTHOFPROC)glewGetProcAddress((const GLubyte*)"glOrthof")) == NULL) || r; r = ((glOrthox = (PFNGLORTHOXPROC)glewGetProcAddress((const GLubyte*)"glOrthox")) == NULL) || r; r = ((glPointSizex = (PFNGLPOINTSIZEXPROC)glewGetProcAddress((const GLubyte*)"glPointSizex")) == NULL) || r; r = ((glPolygonOffsetx = (PFNGLPOLYGONOFFSETXPROC)glewGetProcAddress((const GLubyte*)"glPolygonOffsetx")) == NULL) || r; r = ((glRotatex = (PFNGLROTATEXPROC)glewGetProcAddress((const GLubyte*)"glRotatex")) == NULL) || r; r = ((glSampleCoveragex = (PFNGLSAMPLECOVERAGEXPROC)glewGetProcAddress((const GLubyte*)"glSampleCoveragex")) == NULL) || r; r = ((glScalex = (PFNGLSCALEXPROC)glewGetProcAddress((const GLubyte*)"glScalex")) == NULL) || r; r = ((glTexEnvx = (PFNGLTEXENVXPROC)glewGetProcAddress((const GLubyte*)"glTexEnvx")) == NULL) || r; r = ((glTexEnvxv = (PFNGLTEXENVXVPROC)glewGetProcAddress((const GLubyte*)"glTexEnvxv")) == NULL) || r; r = ((glTexParameterx = (PFNGLTEXPARAMETERXPROC)glewGetProcAddress((const GLubyte*)"glTexParameterx")) == NULL) || r; r = ((glTranslatex = (PFNGLTRANSLATEXPROC)glewGetProcAddress((const GLubyte*)"glTranslatex")) == NULL) || r; return r; } #endif /* GL_REGAL_ES1_0_compatibility */ #ifdef GL_REGAL_ES1_1_compatibility static GLboolean _glewInit_GL_REGAL_ES1_1_compatibility (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glClipPlanef = (PFNGLCLIPPLANEFPROC)glewGetProcAddress((const GLubyte*)"glClipPlanef")) == NULL) || r; r = ((glClipPlanex = (PFNGLCLIPPLANEXPROC)glewGetProcAddress((const GLubyte*)"glClipPlanex")) == NULL) || r; r = ((glGetClipPlanef = (PFNGLGETCLIPPLANEFPROC)glewGetProcAddress((const GLubyte*)"glGetClipPlanef")) == NULL) || r; r = ((glGetClipPlanex = (PFNGLGETCLIPPLANEXPROC)glewGetProcAddress((const GLubyte*)"glGetClipPlanex")) == NULL) || r; r = ((glGetFixedv = (PFNGLGETFIXEDVPROC)glewGetProcAddress((const GLubyte*)"glGetFixedv")) == NULL) || r; r = ((glGetLightxv = (PFNGLGETLIGHTXVPROC)glewGetProcAddress((const GLubyte*)"glGetLightxv")) == NULL) || r; r = ((glGetMaterialxv = (PFNGLGETMATERIALXVPROC)glewGetProcAddress((const GLubyte*)"glGetMaterialxv")) == NULL) || r; r = ((glGetTexEnvxv = (PFNGLGETTEXENVXVPROC)glewGetProcAddress((const GLubyte*)"glGetTexEnvxv")) == NULL) || r; r = ((glGetTexParameterxv = (PFNGLGETTEXPARAMETERXVPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterxv")) == NULL) || r; r = ((glPointParameterx = (PFNGLPOINTPARAMETERXPROC)glewGetProcAddress((const GLubyte*)"glPointParameterx")) == NULL) || r; r = ((glPointParameterxv = (PFNGLPOINTPARAMETERXVPROC)glewGetProcAddress((const GLubyte*)"glPointParameterxv")) == NULL) || r; r = ((glPointSizePointerOES = (PFNGLPOINTSIZEPOINTEROESPROC)glewGetProcAddress((const GLubyte*)"glPointSizePointerOES")) == NULL) || r; r = ((glTexParameterxv = (PFNGLTEXPARAMETERXVPROC)glewGetProcAddress((const GLubyte*)"glTexParameterxv")) == NULL) || r; return r; } #endif /* GL_REGAL_ES1_1_compatibility */ #ifdef GL_REGAL_error_string static GLboolean _glewInit_GL_REGAL_error_string (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glErrorStringREGAL = (PFNGLERRORSTRINGREGALPROC)glewGetProcAddress((const GLubyte*)"glErrorStringREGAL")) == NULL) || r; return r; } #endif /* GL_REGAL_error_string */ #ifdef GL_REGAL_extension_query static GLboolean _glewInit_GL_REGAL_extension_query (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetExtensionREGAL = (PFNGLGETEXTENSIONREGALPROC)glewGetProcAddress((const GLubyte*)"glGetExtensionREGAL")) == NULL) || r; r = ((glIsSupportedREGAL = (PFNGLISSUPPORTEDREGALPROC)glewGetProcAddress((const GLubyte*)"glIsSupportedREGAL")) == NULL) || r; return r; } #endif /* GL_REGAL_extension_query */ #ifdef GL_REGAL_log static GLboolean _glewInit_GL_REGAL_log (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glLogMessageCallbackREGAL = (PFNGLLOGMESSAGECALLBACKREGALPROC)glewGetProcAddress((const GLubyte*)"glLogMessageCallbackREGAL")) == NULL) || r; return r; } #endif /* GL_REGAL_log */ #ifdef GL_REGAL_proc_address static GLboolean _glewInit_GL_REGAL_proc_address (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetProcAddressREGAL = (PFNGLGETPROCADDRESSREGALPROC)glewGetProcAddress((const GLubyte*)"glGetProcAddressREGAL")) == NULL) || r; return r; } #endif /* GL_REGAL_proc_address */ #ifdef GL_SGIS_detail_texture static GLboolean _glewInit_GL_SGIS_detail_texture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glDetailTexFuncSGIS = (PFNGLDETAILTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glDetailTexFuncSGIS")) == NULL) || r; r = ((glGetDetailTexFuncSGIS = (PFNGLGETDETAILTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glGetDetailTexFuncSGIS")) == NULL) || r; return r; } #endif /* GL_SGIS_detail_texture */ #ifdef GL_SGIS_fog_function static GLboolean _glewInit_GL_SGIS_fog_function (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFogFuncSGIS = (PFNGLFOGFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glFogFuncSGIS")) == NULL) || r; r = ((glGetFogFuncSGIS = (PFNGLGETFOGFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glGetFogFuncSGIS")) == NULL) || r; return r; } #endif /* GL_SGIS_fog_function */ #ifdef GL_SGIS_multisample static GLboolean _glewInit_GL_SGIS_multisample (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glSampleMaskSGIS = (PFNGLSAMPLEMASKSGISPROC)glewGetProcAddress((const GLubyte*)"glSampleMaskSGIS")) == NULL) || r; r = ((glSamplePatternSGIS = (PFNGLSAMPLEPATTERNSGISPROC)glewGetProcAddress((const GLubyte*)"glSamplePatternSGIS")) == NULL) || r; return r; } #endif /* GL_SGIS_multisample */ #ifdef GL_SGIS_sharpen_texture static GLboolean _glewInit_GL_SGIS_sharpen_texture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetSharpenTexFuncSGIS = (PFNGLGETSHARPENTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glGetSharpenTexFuncSGIS")) == NULL) || r; r = ((glSharpenTexFuncSGIS = (PFNGLSHARPENTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glSharpenTexFuncSGIS")) == NULL) || r; return r; } #endif /* GL_SGIS_sharpen_texture */ #ifdef GL_SGIS_texture4D static GLboolean _glewInit_GL_SGIS_texture4D (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTexImage4DSGIS = (PFNGLTEXIMAGE4DSGISPROC)glewGetProcAddress((const GLubyte*)"glTexImage4DSGIS")) == NULL) || r; r = ((glTexSubImage4DSGIS = (PFNGLTEXSUBIMAGE4DSGISPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage4DSGIS")) == NULL) || r; return r; } #endif /* GL_SGIS_texture4D */ #ifdef GL_SGIS_texture_filter4 static GLboolean _glewInit_GL_SGIS_texture_filter4 (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGetTexFilterFuncSGIS = (PFNGLGETTEXFILTERFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glGetTexFilterFuncSGIS")) == NULL) || r; r = ((glTexFilterFuncSGIS = (PFNGLTEXFILTERFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glTexFilterFuncSGIS")) == NULL) || r; return r; } #endif /* GL_SGIS_texture_filter4 */ #ifdef GL_SGIX_async static GLboolean _glewInit_GL_SGIX_async (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glAsyncMarkerSGIX = (PFNGLASYNCMARKERSGIXPROC)glewGetProcAddress((const GLubyte*)"glAsyncMarkerSGIX")) == NULL) || r; r = ((glDeleteAsyncMarkersSGIX = (PFNGLDELETEASYNCMARKERSSGIXPROC)glewGetProcAddress((const GLubyte*)"glDeleteAsyncMarkersSGIX")) == NULL) || r; r = ((glFinishAsyncSGIX = (PFNGLFINISHASYNCSGIXPROC)glewGetProcAddress((const GLubyte*)"glFinishAsyncSGIX")) == NULL) || r; r = ((glGenAsyncMarkersSGIX = (PFNGLGENASYNCMARKERSSGIXPROC)glewGetProcAddress((const GLubyte*)"glGenAsyncMarkersSGIX")) == NULL) || r; r = ((glIsAsyncMarkerSGIX = (PFNGLISASYNCMARKERSGIXPROC)glewGetProcAddress((const GLubyte*)"glIsAsyncMarkerSGIX")) == NULL) || r; r = ((glPollAsyncSGIX = (PFNGLPOLLASYNCSGIXPROC)glewGetProcAddress((const GLubyte*)"glPollAsyncSGIX")) == NULL) || r; return r; } #endif /* GL_SGIX_async */ #ifdef GL_SGIX_flush_raster static GLboolean _glewInit_GL_SGIX_flush_raster (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFlushRasterSGIX = (PFNGLFLUSHRASTERSGIXPROC)glewGetProcAddress((const GLubyte*)"glFlushRasterSGIX")) == NULL) || r; return r; } #endif /* GL_SGIX_flush_raster */ #ifdef GL_SGIX_fog_texture static GLboolean _glewInit_GL_SGIX_fog_texture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTextureFogSGIX = (PFNGLTEXTUREFOGSGIXPROC)glewGetProcAddress((const GLubyte*)"glTextureFogSGIX")) == NULL) || r; return r; } #endif /* GL_SGIX_fog_texture */ #ifdef GL_SGIX_fragment_specular_lighting static GLboolean _glewInit_GL_SGIX_fragment_specular_lighting (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFragmentColorMaterialSGIX = (PFNGLFRAGMENTCOLORMATERIALSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentColorMaterialSGIX")) == NULL) || r; r = ((glFragmentLightModelfSGIX = (PFNGLFRAGMENTLIGHTMODELFSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelfSGIX")) == NULL) || r; r = ((glFragmentLightModelfvSGIX = (PFNGLFRAGMENTLIGHTMODELFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelfvSGIX")) == NULL) || r; r = ((glFragmentLightModeliSGIX = (PFNGLFRAGMENTLIGHTMODELISGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModeliSGIX")) == NULL) || r; r = ((glFragmentLightModelivSGIX = (PFNGLFRAGMENTLIGHTMODELIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelivSGIX")) == NULL) || r; r = ((glFragmentLightfSGIX = (PFNGLFRAGMENTLIGHTFSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightfSGIX")) == NULL) || r; r = ((glFragmentLightfvSGIX = (PFNGLFRAGMENTLIGHTFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightfvSGIX")) == NULL) || r; r = ((glFragmentLightiSGIX = (PFNGLFRAGMENTLIGHTISGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightiSGIX")) == NULL) || r; r = ((glFragmentLightivSGIX = (PFNGLFRAGMENTLIGHTIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightivSGIX")) == NULL) || r; r = ((glFragmentMaterialfSGIX = (PFNGLFRAGMENTMATERIALFSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialfSGIX")) == NULL) || r; r = ((glFragmentMaterialfvSGIX = (PFNGLFRAGMENTMATERIALFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialfvSGIX")) == NULL) || r; r = ((glFragmentMaterialiSGIX = (PFNGLFRAGMENTMATERIALISGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialiSGIX")) == NULL) || r; r = ((glFragmentMaterialivSGIX = (PFNGLFRAGMENTMATERIALIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialivSGIX")) == NULL) || r; r = ((glGetFragmentLightfvSGIX = (PFNGLGETFRAGMENTLIGHTFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentLightfvSGIX")) == NULL) || r; r = ((glGetFragmentLightivSGIX = (PFNGLGETFRAGMENTLIGHTIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentLightivSGIX")) == NULL) || r; r = ((glGetFragmentMaterialfvSGIX = (PFNGLGETFRAGMENTMATERIALFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentMaterialfvSGIX")) == NULL) || r; r = ((glGetFragmentMaterialivSGIX = (PFNGLGETFRAGMENTMATERIALIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentMaterialivSGIX")) == NULL) || r; return r; } #endif /* GL_SGIX_fragment_specular_lighting */ #ifdef GL_SGIX_framezoom static GLboolean _glewInit_GL_SGIX_framezoom (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFrameZoomSGIX = (PFNGLFRAMEZOOMSGIXPROC)glewGetProcAddress((const GLubyte*)"glFrameZoomSGIX")) == NULL) || r; return r; } #endif /* GL_SGIX_framezoom */ #ifdef GL_SGIX_pixel_texture static GLboolean _glewInit_GL_SGIX_pixel_texture (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glPixelTexGenSGIX = (PFNGLPIXELTEXGENSGIXPROC)glewGetProcAddress((const GLubyte*)"glPixelTexGenSGIX")) == NULL) || r; return r; } #endif /* GL_SGIX_pixel_texture */ #ifdef GL_SGIX_reference_plane static GLboolean _glewInit_GL_SGIX_reference_plane (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glReferencePlaneSGIX = (PFNGLREFERENCEPLANESGIXPROC)glewGetProcAddress((const GLubyte*)"glReferencePlaneSGIX")) == NULL) || r; return r; } #endif /* GL_SGIX_reference_plane */ #ifdef GL_SGIX_sprite static GLboolean _glewInit_GL_SGIX_sprite (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glSpriteParameterfSGIX = (PFNGLSPRITEPARAMETERFSGIXPROC)glewGetProcAddress((const GLubyte*)"glSpriteParameterfSGIX")) == NULL) || r; r = ((glSpriteParameterfvSGIX = (PFNGLSPRITEPARAMETERFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glSpriteParameterfvSGIX")) == NULL) || r; r = ((glSpriteParameteriSGIX = (PFNGLSPRITEPARAMETERISGIXPROC)glewGetProcAddress((const GLubyte*)"glSpriteParameteriSGIX")) == NULL) || r; r = ((glSpriteParameterivSGIX = (PFNGLSPRITEPARAMETERIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glSpriteParameterivSGIX")) == NULL) || r; return r; } #endif /* GL_SGIX_sprite */ #ifdef GL_SGIX_tag_sample_buffer static GLboolean _glewInit_GL_SGIX_tag_sample_buffer (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glTagSampleBufferSGIX = (PFNGLTAGSAMPLEBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)"glTagSampleBufferSGIX")) == NULL) || r; return r; } #endif /* GL_SGIX_tag_sample_buffer */ #ifdef GL_SGI_color_table static GLboolean _glewInit_GL_SGI_color_table (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glColorTableParameterfvSGI = (PFNGLCOLORTABLEPARAMETERFVSGIPROC)glewGetProcAddress((const GLubyte*)"glColorTableParameterfvSGI")) == NULL) || r; r = ((glColorTableParameterivSGI = (PFNGLCOLORTABLEPARAMETERIVSGIPROC)glewGetProcAddress((const GLubyte*)"glColorTableParameterivSGI")) == NULL) || r; r = ((glColorTableSGI = (PFNGLCOLORTABLESGIPROC)glewGetProcAddress((const GLubyte*)"glColorTableSGI")) == NULL) || r; r = ((glCopyColorTableSGI = (PFNGLCOPYCOLORTABLESGIPROC)glewGetProcAddress((const GLubyte*)"glCopyColorTableSGI")) == NULL) || r; r = ((glGetColorTableParameterfvSGI = (PFNGLGETCOLORTABLEPARAMETERFVSGIPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterfvSGI")) == NULL) || r; r = ((glGetColorTableParameterivSGI = (PFNGLGETCOLORTABLEPARAMETERIVSGIPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterivSGI")) == NULL) || r; r = ((glGetColorTableSGI = (PFNGLGETCOLORTABLESGIPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableSGI")) == NULL) || r; return r; } #endif /* GL_SGI_color_table */ #ifdef GL_SUNX_constant_data static GLboolean _glewInit_GL_SUNX_constant_data (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glFinishTextureSUNX = (PFNGLFINISHTEXTURESUNXPROC)glewGetProcAddress((const GLubyte*)"glFinishTextureSUNX")) == NULL) || r; return r; } #endif /* GL_SUNX_constant_data */ #ifdef GL_SUN_global_alpha static GLboolean _glewInit_GL_SUN_global_alpha (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glGlobalAlphaFactorbSUN = (PFNGLGLOBALALPHAFACTORBSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorbSUN")) == NULL) || r; r = ((glGlobalAlphaFactordSUN = (PFNGLGLOBALALPHAFACTORDSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactordSUN")) == NULL) || r; r = ((glGlobalAlphaFactorfSUN = (PFNGLGLOBALALPHAFACTORFSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorfSUN")) == NULL) || r; r = ((glGlobalAlphaFactoriSUN = (PFNGLGLOBALALPHAFACTORISUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactoriSUN")) == NULL) || r; r = ((glGlobalAlphaFactorsSUN = (PFNGLGLOBALALPHAFACTORSSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorsSUN")) == NULL) || r; r = ((glGlobalAlphaFactorubSUN = (PFNGLGLOBALALPHAFACTORUBSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorubSUN")) == NULL) || r; r = ((glGlobalAlphaFactoruiSUN = (PFNGLGLOBALALPHAFACTORUISUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactoruiSUN")) == NULL) || r; r = ((glGlobalAlphaFactorusSUN = (PFNGLGLOBALALPHAFACTORUSSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorusSUN")) == NULL) || r; return r; } #endif /* GL_SUN_global_alpha */ #ifdef GL_SUN_read_video_pixels static GLboolean _glewInit_GL_SUN_read_video_pixels (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glReadVideoPixelsSUN = (PFNGLREADVIDEOPIXELSSUNPROC)glewGetProcAddress((const GLubyte*)"glReadVideoPixelsSUN")) == NULL) || r; return r; } #endif /* GL_SUN_read_video_pixels */ #ifdef GL_SUN_triangle_list static GLboolean _glewInit_GL_SUN_triangle_list (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glReplacementCodePointerSUN = (PFNGLREPLACEMENTCODEPOINTERSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodePointerSUN")) == NULL) || r; r = ((glReplacementCodeubSUN = (PFNGLREPLACEMENTCODEUBSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeubSUN")) == NULL) || r; r = ((glReplacementCodeubvSUN = (PFNGLREPLACEMENTCODEUBVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeubvSUN")) == NULL) || r; r = ((glReplacementCodeuiSUN = (PFNGLREPLACEMENTCODEUISUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiSUN")) == NULL) || r; r = ((glReplacementCodeuivSUN = (PFNGLREPLACEMENTCODEUIVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuivSUN")) == NULL) || r; r = ((glReplacementCodeusSUN = (PFNGLREPLACEMENTCODEUSSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeusSUN")) == NULL) || r; r = ((glReplacementCodeusvSUN = (PFNGLREPLACEMENTCODEUSVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeusvSUN")) == NULL) || r; return r; } #endif /* GL_SUN_triangle_list */ #ifdef GL_SUN_vertex static GLboolean _glewInit_GL_SUN_vertex (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glColor3fVertex3fSUN = (PFNGLCOLOR3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glColor3fVertex3fSUN")) == NULL) || r; r = ((glColor3fVertex3fvSUN = (PFNGLCOLOR3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glColor3fVertex3fvSUN")) == NULL) || r; r = ((glColor4fNormal3fVertex3fSUN = (PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4fNormal3fVertex3fSUN")) == NULL) || r; r = ((glColor4fNormal3fVertex3fvSUN = (PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4fNormal3fVertex3fvSUN")) == NULL) || r; r = ((glColor4ubVertex2fSUN = (PFNGLCOLOR4UBVERTEX2FSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4ubVertex2fSUN")) == NULL) || r; r = ((glColor4ubVertex2fvSUN = (PFNGLCOLOR4UBVERTEX2FVSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4ubVertex2fvSUN")) == NULL) || r; r = ((glColor4ubVertex3fSUN = (PFNGLCOLOR4UBVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4ubVertex3fSUN")) == NULL) || r; r = ((glColor4ubVertex3fvSUN = (PFNGLCOLOR4UBVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4ubVertex3fvSUN")) == NULL) || r; r = ((glNormal3fVertex3fSUN = (PFNGLNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glNormal3fVertex3fSUN")) == NULL) || r; r = ((glNormal3fVertex3fvSUN = (PFNGLNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glNormal3fVertex3fvSUN")) == NULL) || r; r = ((glReplacementCodeuiColor3fVertex3fSUN = (PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor3fVertex3fSUN")) == NULL) || r; r = ((glReplacementCodeuiColor3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor3fVertex3fvSUN")) == NULL) || r; r = ((glReplacementCodeuiColor4fNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor4fNormal3fVertex3fSUN")) == NULL) || r; r = ((glReplacementCodeuiColor4fNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor4fNormal3fVertex3fvSUN")) == NULL) || r; r = ((glReplacementCodeuiColor4ubVertex3fSUN = (PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor4ubVertex3fSUN")) == NULL) || r; r = ((glReplacementCodeuiColor4ubVertex3fvSUN = (PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor4ubVertex3fvSUN")) == NULL) || r; r = ((glReplacementCodeuiNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiNormal3fVertex3fSUN")) == NULL) || r; r = ((glReplacementCodeuiNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiNormal3fVertex3fvSUN")) == NULL) || r; r = ((glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN")) == NULL) || r; r = ((glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN")) == NULL) || r; r = ((glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN")) == NULL) || r; r = ((glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN")) == NULL) || r; r = ((glReplacementCodeuiTexCoord2fVertex3fSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fVertex3fSUN")) == NULL) || r; r = ((glReplacementCodeuiTexCoord2fVertex3fvSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fVertex3fvSUN")) == NULL) || r; r = ((glReplacementCodeuiVertex3fSUN = (PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiVertex3fSUN")) == NULL) || r; r = ((glReplacementCodeuiVertex3fvSUN = (PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiVertex3fvSUN")) == NULL) || r; r = ((glTexCoord2fColor3fVertex3fSUN = (PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor3fVertex3fSUN")) == NULL) || r; r = ((glTexCoord2fColor3fVertex3fvSUN = (PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor3fVertex3fvSUN")) == NULL) || r; r = ((glTexCoord2fColor4fNormal3fVertex3fSUN = (PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor4fNormal3fVertex3fSUN")) == NULL) || r; r = ((glTexCoord2fColor4fNormal3fVertex3fvSUN = (PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor4fNormal3fVertex3fvSUN")) == NULL) || r; r = ((glTexCoord2fColor4ubVertex3fSUN = (PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor4ubVertex3fSUN")) == NULL) || r; r = ((glTexCoord2fColor4ubVertex3fvSUN = (PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor4ubVertex3fvSUN")) == NULL) || r; r = ((glTexCoord2fNormal3fVertex3fSUN = (PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fNormal3fVertex3fSUN")) == NULL) || r; r = ((glTexCoord2fNormal3fVertex3fvSUN = (PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fNormal3fVertex3fvSUN")) == NULL) || r; r = ((glTexCoord2fVertex3fSUN = (PFNGLTEXCOORD2FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fVertex3fSUN")) == NULL) || r; r = ((glTexCoord2fVertex3fvSUN = (PFNGLTEXCOORD2FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fVertex3fvSUN")) == NULL) || r; r = ((glTexCoord4fColor4fNormal3fVertex4fSUN = (PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4fColor4fNormal3fVertex4fSUN")) == NULL) || r; r = ((glTexCoord4fColor4fNormal3fVertex4fvSUN = (PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4fColor4fNormal3fVertex4fvSUN")) == NULL) || r; r = ((glTexCoord4fVertex4fSUN = (PFNGLTEXCOORD4FVERTEX4FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4fVertex4fSUN")) == NULL) || r; r = ((glTexCoord4fVertex4fvSUN = (PFNGLTEXCOORD4FVERTEX4FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4fVertex4fvSUN")) == NULL) || r; return r; } #endif /* GL_SUN_vertex */ #ifdef GL_WIN_swap_hint static GLboolean _glewInit_GL_WIN_swap_hint (GLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glAddSwapHintRectWIN = (PFNGLADDSWAPHINTRECTWINPROC)glewGetProcAddress((const GLubyte*)"glAddSwapHintRectWIN")) == NULL) || r; return r; } #endif /* GL_WIN_swap_hint */ /* ------------------------------------------------------------------------- */ GLboolean GLEWAPIENTRY glewGetExtension (const char* name) { const GLubyte* start; const GLubyte* end; start = (const GLubyte*)glGetString(GL_EXTENSIONS); if (start == 0) return GL_FALSE; end = start + _glewStrLen(start); return _glewSearchExtension(name, start, end); } /* ------------------------------------------------------------------------- */ #ifndef GLEW_MX static #endif GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) { const GLubyte* s; GLuint dot; GLint major, minor; const GLubyte* extStart; const GLubyte* extEnd; /* query opengl version */ s = glGetString(GL_VERSION); dot = _glewStrCLen(s, '.'); if (dot == 0) return GLEW_ERROR_NO_GL_VERSION; major = s[dot-1]-'0'; minor = s[dot+1]-'0'; if (minor < 0 || minor > 9) minor = 0; if (major<0 || major>9) return GLEW_ERROR_NO_GL_VERSION; if (major == 1 && minor == 0) { return GLEW_ERROR_GL_VERSION_10_ONLY; } else { GLEW_VERSION_4_5 = ( major > 4 ) || ( major == 4 && minor >= 5 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_4_4 = GLEW_VERSION_4_5 == GL_TRUE || ( major == 4 && minor >= 4 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_4_3 = GLEW_VERSION_4_4 == GL_TRUE || ( major == 4 && minor >= 3 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_4_2 = GLEW_VERSION_4_3 == GL_TRUE || ( major == 4 && minor >= 2 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_4_1 = GLEW_VERSION_4_2 == GL_TRUE || ( major == 4 && minor >= 1 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_4_0 = GLEW_VERSION_4_1 == GL_TRUE || ( major == 4 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_3_3 = GLEW_VERSION_4_0 == GL_TRUE || ( major == 3 && minor >= 3 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_3_2 = GLEW_VERSION_3_3 == GL_TRUE || ( major == 3 && minor >= 2 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_3_1 = GLEW_VERSION_3_2 == GL_TRUE || ( major == 3 && minor >= 1 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_3_0 = GLEW_VERSION_3_1 == GL_TRUE || ( major == 3 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_2_1 = GLEW_VERSION_3_0 == GL_TRUE || ( major == 2 && minor >= 1 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_2_0 = GLEW_VERSION_2_1 == GL_TRUE || ( major == 2 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_1_5 = GLEW_VERSION_2_0 == GL_TRUE || ( major == 1 && minor >= 5 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_1_4 = GLEW_VERSION_1_5 == GL_TRUE || ( major == 1 && minor >= 4 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_1_3 = GLEW_VERSION_1_4 == GL_TRUE || ( major == 1 && minor >= 3 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_1_2_1 = GLEW_VERSION_1_3 == GL_TRUE ? GL_TRUE : GL_FALSE; GLEW_VERSION_1_2 = GLEW_VERSION_1_2_1 == GL_TRUE || ( major == 1 && minor >= 2 ) ? GL_TRUE : GL_FALSE; GLEW_VERSION_1_1 = GLEW_VERSION_1_2 == GL_TRUE || ( major == 1 && minor >= 1 ) ? GL_TRUE : GL_FALSE; } /* query opengl extensions string */ extStart = glGetString(GL_EXTENSIONS); if (extStart == 0) extStart = (const GLubyte*)""; extEnd = extStart + _glewStrLen(extStart); /* initialize extensions */ #ifdef GL_VERSION_1_2 if (glewExperimental || GLEW_VERSION_1_2) GLEW_VERSION_1_2 = !_glewInit_GL_VERSION_1_2(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_VERSION_1_2 */ #ifdef GL_VERSION_1_2_1 #endif /* GL_VERSION_1_2_1 */ #ifdef GL_VERSION_1_3 if (glewExperimental || GLEW_VERSION_1_3) GLEW_VERSION_1_3 = !_glewInit_GL_VERSION_1_3(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_VERSION_1_3 */ #ifdef GL_VERSION_1_4 if (glewExperimental || GLEW_VERSION_1_4) GLEW_VERSION_1_4 = !_glewInit_GL_VERSION_1_4(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_VERSION_1_4 */ #ifdef GL_VERSION_1_5 if (glewExperimental || GLEW_VERSION_1_5) GLEW_VERSION_1_5 = !_glewInit_GL_VERSION_1_5(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_VERSION_1_5 */ #ifdef GL_VERSION_2_0 if (glewExperimental || GLEW_VERSION_2_0) GLEW_VERSION_2_0 = !_glewInit_GL_VERSION_2_0(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_VERSION_2_0 */ #ifdef GL_VERSION_2_1 if (glewExperimental || GLEW_VERSION_2_1) GLEW_VERSION_2_1 = !_glewInit_GL_VERSION_2_1(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_VERSION_2_1 */ #ifdef GL_VERSION_3_0 if (glewExperimental || GLEW_VERSION_3_0) GLEW_VERSION_3_0 = !_glewInit_GL_VERSION_3_0(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_VERSION_3_0 */ #ifdef GL_VERSION_3_1 if (glewExperimental || GLEW_VERSION_3_1) GLEW_VERSION_3_1 = !_glewInit_GL_VERSION_3_1(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_VERSION_3_1 */ #ifdef GL_VERSION_3_2 if (glewExperimental || GLEW_VERSION_3_2) GLEW_VERSION_3_2 = !_glewInit_GL_VERSION_3_2(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_VERSION_3_2 */ #ifdef GL_VERSION_3_3 if (glewExperimental || GLEW_VERSION_3_3) GLEW_VERSION_3_3 = !_glewInit_GL_VERSION_3_3(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_VERSION_3_3 */ #ifdef GL_VERSION_4_0 if (glewExperimental || GLEW_VERSION_4_0) GLEW_VERSION_4_0 = !_glewInit_GL_VERSION_4_0(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_VERSION_4_0 */ #ifdef GL_VERSION_4_1 #endif /* GL_VERSION_4_1 */ #ifdef GL_VERSION_4_2 #endif /* GL_VERSION_4_2 */ #ifdef GL_VERSION_4_3 #endif /* GL_VERSION_4_3 */ #ifdef GL_VERSION_4_4 #endif /* GL_VERSION_4_4 */ #ifdef GL_VERSION_4_5 if (glewExperimental || GLEW_VERSION_4_5) GLEW_VERSION_4_5 = !_glewInit_GL_VERSION_4_5(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_VERSION_4_5 */ #ifdef GL_3DFX_multisample GLEW_3DFX_multisample = _glewSearchExtension("GL_3DFX_multisample", extStart, extEnd); #endif /* GL_3DFX_multisample */ #ifdef GL_3DFX_tbuffer GLEW_3DFX_tbuffer = _glewSearchExtension("GL_3DFX_tbuffer", extStart, extEnd); if (glewExperimental || GLEW_3DFX_tbuffer) GLEW_3DFX_tbuffer = !_glewInit_GL_3DFX_tbuffer(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_3DFX_tbuffer */ #ifdef GL_3DFX_texture_compression_FXT1 GLEW_3DFX_texture_compression_FXT1 = _glewSearchExtension("GL_3DFX_texture_compression_FXT1", extStart, extEnd); #endif /* GL_3DFX_texture_compression_FXT1 */ #ifdef GL_AMD_blend_minmax_factor GLEW_AMD_blend_minmax_factor = _glewSearchExtension("GL_AMD_blend_minmax_factor", extStart, extEnd); #endif /* GL_AMD_blend_minmax_factor */ #ifdef GL_AMD_conservative_depth GLEW_AMD_conservative_depth = _glewSearchExtension("GL_AMD_conservative_depth", extStart, extEnd); #endif /* GL_AMD_conservative_depth */ #ifdef GL_AMD_debug_output GLEW_AMD_debug_output = _glewSearchExtension("GL_AMD_debug_output", extStart, extEnd); if (glewExperimental || GLEW_AMD_debug_output) GLEW_AMD_debug_output = !_glewInit_GL_AMD_debug_output(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_AMD_debug_output */ #ifdef GL_AMD_depth_clamp_separate GLEW_AMD_depth_clamp_separate = _glewSearchExtension("GL_AMD_depth_clamp_separate", extStart, extEnd); #endif /* GL_AMD_depth_clamp_separate */ #ifdef GL_AMD_draw_buffers_blend GLEW_AMD_draw_buffers_blend = _glewSearchExtension("GL_AMD_draw_buffers_blend", extStart, extEnd); if (glewExperimental || GLEW_AMD_draw_buffers_blend) GLEW_AMD_draw_buffers_blend = !_glewInit_GL_AMD_draw_buffers_blend(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_AMD_draw_buffers_blend */ #ifdef GL_AMD_gcn_shader GLEW_AMD_gcn_shader = _glewSearchExtension("GL_AMD_gcn_shader", extStart, extEnd); #endif /* GL_AMD_gcn_shader */ #ifdef GL_AMD_gpu_shader_int64 GLEW_AMD_gpu_shader_int64 = _glewSearchExtension("GL_AMD_gpu_shader_int64", extStart, extEnd); #endif /* GL_AMD_gpu_shader_int64 */ #ifdef GL_AMD_interleaved_elements GLEW_AMD_interleaved_elements = _glewSearchExtension("GL_AMD_interleaved_elements", extStart, extEnd); if (glewExperimental || GLEW_AMD_interleaved_elements) GLEW_AMD_interleaved_elements = !_glewInit_GL_AMD_interleaved_elements(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_AMD_interleaved_elements */ #ifdef GL_AMD_multi_draw_indirect GLEW_AMD_multi_draw_indirect = _glewSearchExtension("GL_AMD_multi_draw_indirect", extStart, extEnd); if (glewExperimental || GLEW_AMD_multi_draw_indirect) GLEW_AMD_multi_draw_indirect = !_glewInit_GL_AMD_multi_draw_indirect(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_AMD_multi_draw_indirect */ #ifdef GL_AMD_name_gen_delete GLEW_AMD_name_gen_delete = _glewSearchExtension("GL_AMD_name_gen_delete", extStart, extEnd); if (glewExperimental || GLEW_AMD_name_gen_delete) GLEW_AMD_name_gen_delete = !_glewInit_GL_AMD_name_gen_delete(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_AMD_name_gen_delete */ #ifdef GL_AMD_occlusion_query_event GLEW_AMD_occlusion_query_event = _glewSearchExtension("GL_AMD_occlusion_query_event", extStart, extEnd); if (glewExperimental || GLEW_AMD_occlusion_query_event) GLEW_AMD_occlusion_query_event = !_glewInit_GL_AMD_occlusion_query_event(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_AMD_occlusion_query_event */ #ifdef GL_AMD_performance_monitor GLEW_AMD_performance_monitor = _glewSearchExtension("GL_AMD_performance_monitor", extStart, extEnd); if (glewExperimental || GLEW_AMD_performance_monitor) GLEW_AMD_performance_monitor = !_glewInit_GL_AMD_performance_monitor(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_AMD_performance_monitor */ #ifdef GL_AMD_pinned_memory GLEW_AMD_pinned_memory = _glewSearchExtension("GL_AMD_pinned_memory", extStart, extEnd); #endif /* GL_AMD_pinned_memory */ #ifdef GL_AMD_query_buffer_object GLEW_AMD_query_buffer_object = _glewSearchExtension("GL_AMD_query_buffer_object", extStart, extEnd); #endif /* GL_AMD_query_buffer_object */ #ifdef GL_AMD_sample_positions GLEW_AMD_sample_positions = _glewSearchExtension("GL_AMD_sample_positions", extStart, extEnd); if (glewExperimental || GLEW_AMD_sample_positions) GLEW_AMD_sample_positions = !_glewInit_GL_AMD_sample_positions(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_AMD_sample_positions */ #ifdef GL_AMD_seamless_cubemap_per_texture GLEW_AMD_seamless_cubemap_per_texture = _glewSearchExtension("GL_AMD_seamless_cubemap_per_texture", extStart, extEnd); #endif /* GL_AMD_seamless_cubemap_per_texture */ #ifdef GL_AMD_shader_atomic_counter_ops GLEW_AMD_shader_atomic_counter_ops = _glewSearchExtension("GL_AMD_shader_atomic_counter_ops", extStart, extEnd); #endif /* GL_AMD_shader_atomic_counter_ops */ #ifdef GL_AMD_shader_stencil_export GLEW_AMD_shader_stencil_export = _glewSearchExtension("GL_AMD_shader_stencil_export", extStart, extEnd); #endif /* GL_AMD_shader_stencil_export */ #ifdef GL_AMD_shader_stencil_value_export GLEW_AMD_shader_stencil_value_export = _glewSearchExtension("GL_AMD_shader_stencil_value_export", extStart, extEnd); #endif /* GL_AMD_shader_stencil_value_export */ #ifdef GL_AMD_shader_trinary_minmax GLEW_AMD_shader_trinary_minmax = _glewSearchExtension("GL_AMD_shader_trinary_minmax", extStart, extEnd); #endif /* GL_AMD_shader_trinary_minmax */ #ifdef GL_AMD_sparse_texture GLEW_AMD_sparse_texture = _glewSearchExtension("GL_AMD_sparse_texture", extStart, extEnd); if (glewExperimental || GLEW_AMD_sparse_texture) GLEW_AMD_sparse_texture = !_glewInit_GL_AMD_sparse_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_AMD_sparse_texture */ #ifdef GL_AMD_stencil_operation_extended GLEW_AMD_stencil_operation_extended = _glewSearchExtension("GL_AMD_stencil_operation_extended", extStart, extEnd); if (glewExperimental || GLEW_AMD_stencil_operation_extended) GLEW_AMD_stencil_operation_extended = !_glewInit_GL_AMD_stencil_operation_extended(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_AMD_stencil_operation_extended */ #ifdef GL_AMD_texture_texture4 GLEW_AMD_texture_texture4 = _glewSearchExtension("GL_AMD_texture_texture4", extStart, extEnd); #endif /* GL_AMD_texture_texture4 */ #ifdef GL_AMD_transform_feedback3_lines_triangles GLEW_AMD_transform_feedback3_lines_triangles = _glewSearchExtension("GL_AMD_transform_feedback3_lines_triangles", extStart, extEnd); #endif /* GL_AMD_transform_feedback3_lines_triangles */ #ifdef GL_AMD_transform_feedback4 GLEW_AMD_transform_feedback4 = _glewSearchExtension("GL_AMD_transform_feedback4", extStart, extEnd); #endif /* GL_AMD_transform_feedback4 */ #ifdef GL_AMD_vertex_shader_layer GLEW_AMD_vertex_shader_layer = _glewSearchExtension("GL_AMD_vertex_shader_layer", extStart, extEnd); #endif /* GL_AMD_vertex_shader_layer */ #ifdef GL_AMD_vertex_shader_tessellator GLEW_AMD_vertex_shader_tessellator = _glewSearchExtension("GL_AMD_vertex_shader_tessellator", extStart, extEnd); if (glewExperimental || GLEW_AMD_vertex_shader_tessellator) GLEW_AMD_vertex_shader_tessellator = !_glewInit_GL_AMD_vertex_shader_tessellator(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_AMD_vertex_shader_tessellator */ #ifdef GL_AMD_vertex_shader_viewport_index GLEW_AMD_vertex_shader_viewport_index = _glewSearchExtension("GL_AMD_vertex_shader_viewport_index", extStart, extEnd); #endif /* GL_AMD_vertex_shader_viewport_index */ #ifdef GL_ANGLE_depth_texture GLEW_ANGLE_depth_texture = _glewSearchExtension("GL_ANGLE_depth_texture", extStart, extEnd); #endif /* GL_ANGLE_depth_texture */ #ifdef GL_ANGLE_framebuffer_blit GLEW_ANGLE_framebuffer_blit = _glewSearchExtension("GL_ANGLE_framebuffer_blit", extStart, extEnd); if (glewExperimental || GLEW_ANGLE_framebuffer_blit) GLEW_ANGLE_framebuffer_blit = !_glewInit_GL_ANGLE_framebuffer_blit(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ANGLE_framebuffer_blit */ #ifdef GL_ANGLE_framebuffer_multisample GLEW_ANGLE_framebuffer_multisample = _glewSearchExtension("GL_ANGLE_framebuffer_multisample", extStart, extEnd); if (glewExperimental || GLEW_ANGLE_framebuffer_multisample) GLEW_ANGLE_framebuffer_multisample = !_glewInit_GL_ANGLE_framebuffer_multisample(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ANGLE_framebuffer_multisample */ #ifdef GL_ANGLE_instanced_arrays GLEW_ANGLE_instanced_arrays = _glewSearchExtension("GL_ANGLE_instanced_arrays", extStart, extEnd); if (glewExperimental || GLEW_ANGLE_instanced_arrays) GLEW_ANGLE_instanced_arrays = !_glewInit_GL_ANGLE_instanced_arrays(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ANGLE_instanced_arrays */ #ifdef GL_ANGLE_pack_reverse_row_order GLEW_ANGLE_pack_reverse_row_order = _glewSearchExtension("GL_ANGLE_pack_reverse_row_order", extStart, extEnd); #endif /* GL_ANGLE_pack_reverse_row_order */ #ifdef GL_ANGLE_program_binary GLEW_ANGLE_program_binary = _glewSearchExtension("GL_ANGLE_program_binary", extStart, extEnd); #endif /* GL_ANGLE_program_binary */ #ifdef GL_ANGLE_texture_compression_dxt1 GLEW_ANGLE_texture_compression_dxt1 = _glewSearchExtension("GL_ANGLE_texture_compression_dxt1", extStart, extEnd); #endif /* GL_ANGLE_texture_compression_dxt1 */ #ifdef GL_ANGLE_texture_compression_dxt3 GLEW_ANGLE_texture_compression_dxt3 = _glewSearchExtension("GL_ANGLE_texture_compression_dxt3", extStart, extEnd); #endif /* GL_ANGLE_texture_compression_dxt3 */ #ifdef GL_ANGLE_texture_compression_dxt5 GLEW_ANGLE_texture_compression_dxt5 = _glewSearchExtension("GL_ANGLE_texture_compression_dxt5", extStart, extEnd); #endif /* GL_ANGLE_texture_compression_dxt5 */ #ifdef GL_ANGLE_texture_usage GLEW_ANGLE_texture_usage = _glewSearchExtension("GL_ANGLE_texture_usage", extStart, extEnd); #endif /* GL_ANGLE_texture_usage */ #ifdef GL_ANGLE_timer_query GLEW_ANGLE_timer_query = _glewSearchExtension("GL_ANGLE_timer_query", extStart, extEnd); if (glewExperimental || GLEW_ANGLE_timer_query) GLEW_ANGLE_timer_query = !_glewInit_GL_ANGLE_timer_query(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ANGLE_timer_query */ #ifdef GL_ANGLE_translated_shader_source GLEW_ANGLE_translated_shader_source = _glewSearchExtension("GL_ANGLE_translated_shader_source", extStart, extEnd); if (glewExperimental || GLEW_ANGLE_translated_shader_source) GLEW_ANGLE_translated_shader_source = !_glewInit_GL_ANGLE_translated_shader_source(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ANGLE_translated_shader_source */ #ifdef GL_APPLE_aux_depth_stencil GLEW_APPLE_aux_depth_stencil = _glewSearchExtension("GL_APPLE_aux_depth_stencil", extStart, extEnd); #endif /* GL_APPLE_aux_depth_stencil */ #ifdef GL_APPLE_client_storage GLEW_APPLE_client_storage = _glewSearchExtension("GL_APPLE_client_storage", extStart, extEnd); #endif /* GL_APPLE_client_storage */ #ifdef GL_APPLE_element_array GLEW_APPLE_element_array = _glewSearchExtension("GL_APPLE_element_array", extStart, extEnd); if (glewExperimental || GLEW_APPLE_element_array) GLEW_APPLE_element_array = !_glewInit_GL_APPLE_element_array(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_APPLE_element_array */ #ifdef GL_APPLE_fence GLEW_APPLE_fence = _glewSearchExtension("GL_APPLE_fence", extStart, extEnd); if (glewExperimental || GLEW_APPLE_fence) GLEW_APPLE_fence = !_glewInit_GL_APPLE_fence(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_APPLE_fence */ #ifdef GL_APPLE_float_pixels GLEW_APPLE_float_pixels = _glewSearchExtension("GL_APPLE_float_pixels", extStart, extEnd); #endif /* GL_APPLE_float_pixels */ #ifdef GL_APPLE_flush_buffer_range GLEW_APPLE_flush_buffer_range = _glewSearchExtension("GL_APPLE_flush_buffer_range", extStart, extEnd); if (glewExperimental || GLEW_APPLE_flush_buffer_range) GLEW_APPLE_flush_buffer_range = !_glewInit_GL_APPLE_flush_buffer_range(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_APPLE_flush_buffer_range */ #ifdef GL_APPLE_object_purgeable GLEW_APPLE_object_purgeable = _glewSearchExtension("GL_APPLE_object_purgeable", extStart, extEnd); if (glewExperimental || GLEW_APPLE_object_purgeable) GLEW_APPLE_object_purgeable = !_glewInit_GL_APPLE_object_purgeable(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_APPLE_object_purgeable */ #ifdef GL_APPLE_pixel_buffer GLEW_APPLE_pixel_buffer = _glewSearchExtension("GL_APPLE_pixel_buffer", extStart, extEnd); #endif /* GL_APPLE_pixel_buffer */ #ifdef GL_APPLE_rgb_422 GLEW_APPLE_rgb_422 = _glewSearchExtension("GL_APPLE_rgb_422", extStart, extEnd); #endif /* GL_APPLE_rgb_422 */ #ifdef GL_APPLE_row_bytes GLEW_APPLE_row_bytes = _glewSearchExtension("GL_APPLE_row_bytes", extStart, extEnd); #endif /* GL_APPLE_row_bytes */ #ifdef GL_APPLE_specular_vector GLEW_APPLE_specular_vector = _glewSearchExtension("GL_APPLE_specular_vector", extStart, extEnd); #endif /* GL_APPLE_specular_vector */ #ifdef GL_APPLE_texture_range GLEW_APPLE_texture_range = _glewSearchExtension("GL_APPLE_texture_range", extStart, extEnd); if (glewExperimental || GLEW_APPLE_texture_range) GLEW_APPLE_texture_range = !_glewInit_GL_APPLE_texture_range(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_APPLE_texture_range */ #ifdef GL_APPLE_transform_hint GLEW_APPLE_transform_hint = _glewSearchExtension("GL_APPLE_transform_hint", extStart, extEnd); #endif /* GL_APPLE_transform_hint */ #ifdef GL_APPLE_vertex_array_object GLEW_APPLE_vertex_array_object = _glewSearchExtension("GL_APPLE_vertex_array_object", extStart, extEnd); if (glewExperimental || GLEW_APPLE_vertex_array_object) GLEW_APPLE_vertex_array_object = !_glewInit_GL_APPLE_vertex_array_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_APPLE_vertex_array_object */ #ifdef GL_APPLE_vertex_array_range GLEW_APPLE_vertex_array_range = _glewSearchExtension("GL_APPLE_vertex_array_range", extStart, extEnd); if (glewExperimental || GLEW_APPLE_vertex_array_range) GLEW_APPLE_vertex_array_range = !_glewInit_GL_APPLE_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_APPLE_vertex_array_range */ #ifdef GL_APPLE_vertex_program_evaluators GLEW_APPLE_vertex_program_evaluators = _glewSearchExtension("GL_APPLE_vertex_program_evaluators", extStart, extEnd); if (glewExperimental || GLEW_APPLE_vertex_program_evaluators) GLEW_APPLE_vertex_program_evaluators = !_glewInit_GL_APPLE_vertex_program_evaluators(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_APPLE_vertex_program_evaluators */ #ifdef GL_APPLE_ycbcr_422 GLEW_APPLE_ycbcr_422 = _glewSearchExtension("GL_APPLE_ycbcr_422", extStart, extEnd); #endif /* GL_APPLE_ycbcr_422 */ #ifdef GL_ARB_ES2_compatibility GLEW_ARB_ES2_compatibility = _glewSearchExtension("GL_ARB_ES2_compatibility", extStart, extEnd); if (glewExperimental || GLEW_ARB_ES2_compatibility) GLEW_ARB_ES2_compatibility = !_glewInit_GL_ARB_ES2_compatibility(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_ES2_compatibility */ #ifdef GL_ARB_ES3_1_compatibility GLEW_ARB_ES3_1_compatibility = _glewSearchExtension("GL_ARB_ES3_1_compatibility", extStart, extEnd); if (glewExperimental || GLEW_ARB_ES3_1_compatibility) GLEW_ARB_ES3_1_compatibility = !_glewInit_GL_ARB_ES3_1_compatibility(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_ES3_1_compatibility */ #ifdef GL_ARB_ES3_2_compatibility GLEW_ARB_ES3_2_compatibility = _glewSearchExtension("GL_ARB_ES3_2_compatibility", extStart, extEnd); if (glewExperimental || GLEW_ARB_ES3_2_compatibility) GLEW_ARB_ES3_2_compatibility = !_glewInit_GL_ARB_ES3_2_compatibility(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_ES3_2_compatibility */ #ifdef GL_ARB_ES3_compatibility GLEW_ARB_ES3_compatibility = _glewSearchExtension("GL_ARB_ES3_compatibility", extStart, extEnd); #endif /* GL_ARB_ES3_compatibility */ #ifdef GL_ARB_arrays_of_arrays GLEW_ARB_arrays_of_arrays = _glewSearchExtension("GL_ARB_arrays_of_arrays", extStart, extEnd); #endif /* GL_ARB_arrays_of_arrays */ #ifdef GL_ARB_base_instance GLEW_ARB_base_instance = _glewSearchExtension("GL_ARB_base_instance", extStart, extEnd); if (glewExperimental || GLEW_ARB_base_instance) GLEW_ARB_base_instance = !_glewInit_GL_ARB_base_instance(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_base_instance */ #ifdef GL_ARB_bindless_texture GLEW_ARB_bindless_texture = _glewSearchExtension("GL_ARB_bindless_texture", extStart, extEnd); if (glewExperimental || GLEW_ARB_bindless_texture) GLEW_ARB_bindless_texture = !_glewInit_GL_ARB_bindless_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_bindless_texture */ #ifdef GL_ARB_blend_func_extended GLEW_ARB_blend_func_extended = _glewSearchExtension("GL_ARB_blend_func_extended", extStart, extEnd); if (glewExperimental || GLEW_ARB_blend_func_extended) GLEW_ARB_blend_func_extended = !_glewInit_GL_ARB_blend_func_extended(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_blend_func_extended */ #ifdef GL_ARB_buffer_storage GLEW_ARB_buffer_storage = _glewSearchExtension("GL_ARB_buffer_storage", extStart, extEnd); if (glewExperimental || GLEW_ARB_buffer_storage) GLEW_ARB_buffer_storage = !_glewInit_GL_ARB_buffer_storage(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_buffer_storage */ #ifdef GL_ARB_cl_event GLEW_ARB_cl_event = _glewSearchExtension("GL_ARB_cl_event", extStart, extEnd); if (glewExperimental || GLEW_ARB_cl_event) GLEW_ARB_cl_event = !_glewInit_GL_ARB_cl_event(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_cl_event */ #ifdef GL_ARB_clear_buffer_object GLEW_ARB_clear_buffer_object = _glewSearchExtension("GL_ARB_clear_buffer_object", extStart, extEnd); if (glewExperimental || GLEW_ARB_clear_buffer_object) GLEW_ARB_clear_buffer_object = !_glewInit_GL_ARB_clear_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_clear_buffer_object */ #ifdef GL_ARB_clear_texture GLEW_ARB_clear_texture = _glewSearchExtension("GL_ARB_clear_texture", extStart, extEnd); if (glewExperimental || GLEW_ARB_clear_texture) GLEW_ARB_clear_texture = !_glewInit_GL_ARB_clear_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_clear_texture */ #ifdef GL_ARB_clip_control GLEW_ARB_clip_control = _glewSearchExtension("GL_ARB_clip_control", extStart, extEnd); if (glewExperimental || GLEW_ARB_clip_control) GLEW_ARB_clip_control = !_glewInit_GL_ARB_clip_control(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_clip_control */ #ifdef GL_ARB_color_buffer_float GLEW_ARB_color_buffer_float = _glewSearchExtension("GL_ARB_color_buffer_float", extStart, extEnd); if (glewExperimental || GLEW_ARB_color_buffer_float) GLEW_ARB_color_buffer_float = !_glewInit_GL_ARB_color_buffer_float(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_color_buffer_float */ #ifdef GL_ARB_compatibility GLEW_ARB_compatibility = _glewSearchExtension("GL_ARB_compatibility", extStart, extEnd); #endif /* GL_ARB_compatibility */ #ifdef GL_ARB_compressed_texture_pixel_storage GLEW_ARB_compressed_texture_pixel_storage = _glewSearchExtension("GL_ARB_compressed_texture_pixel_storage", extStart, extEnd); #endif /* GL_ARB_compressed_texture_pixel_storage */ #ifdef GL_ARB_compute_shader GLEW_ARB_compute_shader = _glewSearchExtension("GL_ARB_compute_shader", extStart, extEnd); if (glewExperimental || GLEW_ARB_compute_shader) GLEW_ARB_compute_shader = !_glewInit_GL_ARB_compute_shader(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_compute_shader */ #ifdef GL_ARB_compute_variable_group_size GLEW_ARB_compute_variable_group_size = _glewSearchExtension("GL_ARB_compute_variable_group_size", extStart, extEnd); if (glewExperimental || GLEW_ARB_compute_variable_group_size) GLEW_ARB_compute_variable_group_size = !_glewInit_GL_ARB_compute_variable_group_size(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_compute_variable_group_size */ #ifdef GL_ARB_conditional_render_inverted GLEW_ARB_conditional_render_inverted = _glewSearchExtension("GL_ARB_conditional_render_inverted", extStart, extEnd); #endif /* GL_ARB_conditional_render_inverted */ #ifdef GL_ARB_conservative_depth GLEW_ARB_conservative_depth = _glewSearchExtension("GL_ARB_conservative_depth", extStart, extEnd); #endif /* GL_ARB_conservative_depth */ #ifdef GL_ARB_copy_buffer GLEW_ARB_copy_buffer = _glewSearchExtension("GL_ARB_copy_buffer", extStart, extEnd); if (glewExperimental || GLEW_ARB_copy_buffer) GLEW_ARB_copy_buffer = !_glewInit_GL_ARB_copy_buffer(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_copy_buffer */ #ifdef GL_ARB_copy_image GLEW_ARB_copy_image = _glewSearchExtension("GL_ARB_copy_image", extStart, extEnd); if (glewExperimental || GLEW_ARB_copy_image) GLEW_ARB_copy_image = !_glewInit_GL_ARB_copy_image(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_copy_image */ #ifdef GL_ARB_cull_distance GLEW_ARB_cull_distance = _glewSearchExtension("GL_ARB_cull_distance", extStart, extEnd); #endif /* GL_ARB_cull_distance */ #ifdef GL_ARB_debug_output GLEW_ARB_debug_output = _glewSearchExtension("GL_ARB_debug_output", extStart, extEnd); if (glewExperimental || GLEW_ARB_debug_output) GLEW_ARB_debug_output = !_glewInit_GL_ARB_debug_output(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_debug_output */ #ifdef GL_ARB_depth_buffer_float GLEW_ARB_depth_buffer_float = _glewSearchExtension("GL_ARB_depth_buffer_float", extStart, extEnd); #endif /* GL_ARB_depth_buffer_float */ #ifdef GL_ARB_depth_clamp GLEW_ARB_depth_clamp = _glewSearchExtension("GL_ARB_depth_clamp", extStart, extEnd); #endif /* GL_ARB_depth_clamp */ #ifdef GL_ARB_depth_texture GLEW_ARB_depth_texture = _glewSearchExtension("GL_ARB_depth_texture", extStart, extEnd); #endif /* GL_ARB_depth_texture */ #ifdef GL_ARB_derivative_control GLEW_ARB_derivative_control = _glewSearchExtension("GL_ARB_derivative_control", extStart, extEnd); #endif /* GL_ARB_derivative_control */ #ifdef GL_ARB_direct_state_access GLEW_ARB_direct_state_access = _glewSearchExtension("GL_ARB_direct_state_access", extStart, extEnd); if (glewExperimental || GLEW_ARB_direct_state_access) GLEW_ARB_direct_state_access = !_glewInit_GL_ARB_direct_state_access(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_direct_state_access */ #ifdef GL_ARB_draw_buffers GLEW_ARB_draw_buffers = _glewSearchExtension("GL_ARB_draw_buffers", extStart, extEnd); if (glewExperimental || GLEW_ARB_draw_buffers) GLEW_ARB_draw_buffers = !_glewInit_GL_ARB_draw_buffers(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_draw_buffers */ #ifdef GL_ARB_draw_buffers_blend GLEW_ARB_draw_buffers_blend = _glewSearchExtension("GL_ARB_draw_buffers_blend", extStart, extEnd); if (glewExperimental || GLEW_ARB_draw_buffers_blend) GLEW_ARB_draw_buffers_blend = !_glewInit_GL_ARB_draw_buffers_blend(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_draw_buffers_blend */ #ifdef GL_ARB_draw_elements_base_vertex GLEW_ARB_draw_elements_base_vertex = _glewSearchExtension("GL_ARB_draw_elements_base_vertex", extStart, extEnd); if (glewExperimental || GLEW_ARB_draw_elements_base_vertex) GLEW_ARB_draw_elements_base_vertex = !_glewInit_GL_ARB_draw_elements_base_vertex(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_draw_elements_base_vertex */ #ifdef GL_ARB_draw_indirect GLEW_ARB_draw_indirect = _glewSearchExtension("GL_ARB_draw_indirect", extStart, extEnd); if (glewExperimental || GLEW_ARB_draw_indirect) GLEW_ARB_draw_indirect = !_glewInit_GL_ARB_draw_indirect(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_draw_indirect */ #ifdef GL_ARB_draw_instanced GLEW_ARB_draw_instanced = _glewSearchExtension("GL_ARB_draw_instanced", extStart, extEnd); #endif /* GL_ARB_draw_instanced */ #ifdef GL_ARB_enhanced_layouts GLEW_ARB_enhanced_layouts = _glewSearchExtension("GL_ARB_enhanced_layouts", extStart, extEnd); #endif /* GL_ARB_enhanced_layouts */ #ifdef GL_ARB_explicit_attrib_location GLEW_ARB_explicit_attrib_location = _glewSearchExtension("GL_ARB_explicit_attrib_location", extStart, extEnd); #endif /* GL_ARB_explicit_attrib_location */ #ifdef GL_ARB_explicit_uniform_location GLEW_ARB_explicit_uniform_location = _glewSearchExtension("GL_ARB_explicit_uniform_location", extStart, extEnd); #endif /* GL_ARB_explicit_uniform_location */ #ifdef GL_ARB_fragment_coord_conventions GLEW_ARB_fragment_coord_conventions = _glewSearchExtension("GL_ARB_fragment_coord_conventions", extStart, extEnd); #endif /* GL_ARB_fragment_coord_conventions */ #ifdef GL_ARB_fragment_layer_viewport GLEW_ARB_fragment_layer_viewport = _glewSearchExtension("GL_ARB_fragment_layer_viewport", extStart, extEnd); #endif /* GL_ARB_fragment_layer_viewport */ #ifdef GL_ARB_fragment_program GLEW_ARB_fragment_program = _glewSearchExtension("GL_ARB_fragment_program", extStart, extEnd); #endif /* GL_ARB_fragment_program */ #ifdef GL_ARB_fragment_program_shadow GLEW_ARB_fragment_program_shadow = _glewSearchExtension("GL_ARB_fragment_program_shadow", extStart, extEnd); #endif /* GL_ARB_fragment_program_shadow */ #ifdef GL_ARB_fragment_shader GLEW_ARB_fragment_shader = _glewSearchExtension("GL_ARB_fragment_shader", extStart, extEnd); #endif /* GL_ARB_fragment_shader */ #ifdef GL_ARB_fragment_shader_interlock GLEW_ARB_fragment_shader_interlock = _glewSearchExtension("GL_ARB_fragment_shader_interlock", extStart, extEnd); #endif /* GL_ARB_fragment_shader_interlock */ #ifdef GL_ARB_framebuffer_no_attachments GLEW_ARB_framebuffer_no_attachments = _glewSearchExtension("GL_ARB_framebuffer_no_attachments", extStart, extEnd); if (glewExperimental || GLEW_ARB_framebuffer_no_attachments) GLEW_ARB_framebuffer_no_attachments = !_glewInit_GL_ARB_framebuffer_no_attachments(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_framebuffer_no_attachments */ #ifdef GL_ARB_framebuffer_object GLEW_ARB_framebuffer_object = _glewSearchExtension("GL_ARB_framebuffer_object", extStart, extEnd); if (glewExperimental || GLEW_ARB_framebuffer_object) GLEW_ARB_framebuffer_object = !_glewInit_GL_ARB_framebuffer_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_framebuffer_object */ #ifdef GL_ARB_framebuffer_sRGB GLEW_ARB_framebuffer_sRGB = _glewSearchExtension("GL_ARB_framebuffer_sRGB", extStart, extEnd); #endif /* GL_ARB_framebuffer_sRGB */ #ifdef GL_ARB_geometry_shader4 GLEW_ARB_geometry_shader4 = _glewSearchExtension("GL_ARB_geometry_shader4", extStart, extEnd); if (glewExperimental || GLEW_ARB_geometry_shader4) GLEW_ARB_geometry_shader4 = !_glewInit_GL_ARB_geometry_shader4(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_geometry_shader4 */ #ifdef GL_ARB_get_program_binary GLEW_ARB_get_program_binary = _glewSearchExtension("GL_ARB_get_program_binary", extStart, extEnd); if (glewExperimental || GLEW_ARB_get_program_binary) GLEW_ARB_get_program_binary = !_glewInit_GL_ARB_get_program_binary(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_get_program_binary */ #ifdef GL_ARB_get_texture_sub_image GLEW_ARB_get_texture_sub_image = _glewSearchExtension("GL_ARB_get_texture_sub_image", extStart, extEnd); if (glewExperimental || GLEW_ARB_get_texture_sub_image) GLEW_ARB_get_texture_sub_image = !_glewInit_GL_ARB_get_texture_sub_image(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_get_texture_sub_image */ #ifdef GL_ARB_gpu_shader5 GLEW_ARB_gpu_shader5 = _glewSearchExtension("GL_ARB_gpu_shader5", extStart, extEnd); #endif /* GL_ARB_gpu_shader5 */ #ifdef GL_ARB_gpu_shader_fp64 GLEW_ARB_gpu_shader_fp64 = _glewSearchExtension("GL_ARB_gpu_shader_fp64", extStart, extEnd); if (glewExperimental || GLEW_ARB_gpu_shader_fp64) GLEW_ARB_gpu_shader_fp64 = !_glewInit_GL_ARB_gpu_shader_fp64(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_gpu_shader_fp64 */ #ifdef GL_ARB_gpu_shader_int64 GLEW_ARB_gpu_shader_int64 = _glewSearchExtension("GL_ARB_gpu_shader_int64", extStart, extEnd); if (glewExperimental || GLEW_ARB_gpu_shader_int64) GLEW_ARB_gpu_shader_int64 = !_glewInit_GL_ARB_gpu_shader_int64(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_gpu_shader_int64 */ #ifdef GL_ARB_half_float_pixel GLEW_ARB_half_float_pixel = _glewSearchExtension("GL_ARB_half_float_pixel", extStart, extEnd); #endif /* GL_ARB_half_float_pixel */ #ifdef GL_ARB_half_float_vertex GLEW_ARB_half_float_vertex = _glewSearchExtension("GL_ARB_half_float_vertex", extStart, extEnd); #endif /* GL_ARB_half_float_vertex */ #ifdef GL_ARB_imaging GLEW_ARB_imaging = _glewSearchExtension("GL_ARB_imaging", extStart, extEnd); if (glewExperimental || GLEW_ARB_imaging) GLEW_ARB_imaging = !_glewInit_GL_ARB_imaging(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_imaging */ #ifdef GL_ARB_indirect_parameters GLEW_ARB_indirect_parameters = _glewSearchExtension("GL_ARB_indirect_parameters", extStart, extEnd); if (glewExperimental || GLEW_ARB_indirect_parameters) GLEW_ARB_indirect_parameters = !_glewInit_GL_ARB_indirect_parameters(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_indirect_parameters */ #ifdef GL_ARB_instanced_arrays GLEW_ARB_instanced_arrays = _glewSearchExtension("GL_ARB_instanced_arrays", extStart, extEnd); if (glewExperimental || GLEW_ARB_instanced_arrays) GLEW_ARB_instanced_arrays = !_glewInit_GL_ARB_instanced_arrays(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_instanced_arrays */ #ifdef GL_ARB_internalformat_query GLEW_ARB_internalformat_query = _glewSearchExtension("GL_ARB_internalformat_query", extStart, extEnd); if (glewExperimental || GLEW_ARB_internalformat_query) GLEW_ARB_internalformat_query = !_glewInit_GL_ARB_internalformat_query(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_internalformat_query */ #ifdef GL_ARB_internalformat_query2 GLEW_ARB_internalformat_query2 = _glewSearchExtension("GL_ARB_internalformat_query2", extStart, extEnd); if (glewExperimental || GLEW_ARB_internalformat_query2) GLEW_ARB_internalformat_query2 = !_glewInit_GL_ARB_internalformat_query2(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_internalformat_query2 */ #ifdef GL_ARB_invalidate_subdata GLEW_ARB_invalidate_subdata = _glewSearchExtension("GL_ARB_invalidate_subdata", extStart, extEnd); if (glewExperimental || GLEW_ARB_invalidate_subdata) GLEW_ARB_invalidate_subdata = !_glewInit_GL_ARB_invalidate_subdata(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_invalidate_subdata */ #ifdef GL_ARB_map_buffer_alignment GLEW_ARB_map_buffer_alignment = _glewSearchExtension("GL_ARB_map_buffer_alignment", extStart, extEnd); #endif /* GL_ARB_map_buffer_alignment */ #ifdef GL_ARB_map_buffer_range GLEW_ARB_map_buffer_range = _glewSearchExtension("GL_ARB_map_buffer_range", extStart, extEnd); if (glewExperimental || GLEW_ARB_map_buffer_range) GLEW_ARB_map_buffer_range = !_glewInit_GL_ARB_map_buffer_range(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_map_buffer_range */ #ifdef GL_ARB_matrix_palette GLEW_ARB_matrix_palette = _glewSearchExtension("GL_ARB_matrix_palette", extStart, extEnd); if (glewExperimental || GLEW_ARB_matrix_palette) GLEW_ARB_matrix_palette = !_glewInit_GL_ARB_matrix_palette(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_matrix_palette */ #ifdef GL_ARB_multi_bind GLEW_ARB_multi_bind = _glewSearchExtension("GL_ARB_multi_bind", extStart, extEnd); if (glewExperimental || GLEW_ARB_multi_bind) GLEW_ARB_multi_bind = !_glewInit_GL_ARB_multi_bind(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_multi_bind */ #ifdef GL_ARB_multi_draw_indirect GLEW_ARB_multi_draw_indirect = _glewSearchExtension("GL_ARB_multi_draw_indirect", extStart, extEnd); if (glewExperimental || GLEW_ARB_multi_draw_indirect) GLEW_ARB_multi_draw_indirect = !_glewInit_GL_ARB_multi_draw_indirect(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_multi_draw_indirect */ #ifdef GL_ARB_multisample GLEW_ARB_multisample = _glewSearchExtension("GL_ARB_multisample", extStart, extEnd); if (glewExperimental || GLEW_ARB_multisample) GLEW_ARB_multisample = !_glewInit_GL_ARB_multisample(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_multisample */ #ifdef GL_ARB_multitexture GLEW_ARB_multitexture = _glewSearchExtension("GL_ARB_multitexture", extStart, extEnd); if (glewExperimental || GLEW_ARB_multitexture) GLEW_ARB_multitexture = !_glewInit_GL_ARB_multitexture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_multitexture */ #ifdef GL_ARB_occlusion_query GLEW_ARB_occlusion_query = _glewSearchExtension("GL_ARB_occlusion_query", extStart, extEnd); if (glewExperimental || GLEW_ARB_occlusion_query) GLEW_ARB_occlusion_query = !_glewInit_GL_ARB_occlusion_query(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_occlusion_query */ #ifdef GL_ARB_occlusion_query2 GLEW_ARB_occlusion_query2 = _glewSearchExtension("GL_ARB_occlusion_query2", extStart, extEnd); #endif /* GL_ARB_occlusion_query2 */ #ifdef GL_ARB_parallel_shader_compile GLEW_ARB_parallel_shader_compile = _glewSearchExtension("GL_ARB_parallel_shader_compile", extStart, extEnd); if (glewExperimental || GLEW_ARB_parallel_shader_compile) GLEW_ARB_parallel_shader_compile = !_glewInit_GL_ARB_parallel_shader_compile(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_parallel_shader_compile */ #ifdef GL_ARB_pipeline_statistics_query GLEW_ARB_pipeline_statistics_query = _glewSearchExtension("GL_ARB_pipeline_statistics_query", extStart, extEnd); #endif /* GL_ARB_pipeline_statistics_query */ #ifdef GL_ARB_pixel_buffer_object GLEW_ARB_pixel_buffer_object = _glewSearchExtension("GL_ARB_pixel_buffer_object", extStart, extEnd); #endif /* GL_ARB_pixel_buffer_object */ #ifdef GL_ARB_point_parameters GLEW_ARB_point_parameters = _glewSearchExtension("GL_ARB_point_parameters", extStart, extEnd); if (glewExperimental || GLEW_ARB_point_parameters) GLEW_ARB_point_parameters = !_glewInit_GL_ARB_point_parameters(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_point_parameters */ #ifdef GL_ARB_point_sprite GLEW_ARB_point_sprite = _glewSearchExtension("GL_ARB_point_sprite", extStart, extEnd); #endif /* GL_ARB_point_sprite */ #ifdef GL_ARB_post_depth_coverage GLEW_ARB_post_depth_coverage = _glewSearchExtension("GL_ARB_post_depth_coverage", extStart, extEnd); #endif /* GL_ARB_post_depth_coverage */ #ifdef GL_ARB_program_interface_query GLEW_ARB_program_interface_query = _glewSearchExtension("GL_ARB_program_interface_query", extStart, extEnd); if (glewExperimental || GLEW_ARB_program_interface_query) GLEW_ARB_program_interface_query = !_glewInit_GL_ARB_program_interface_query(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_program_interface_query */ #ifdef GL_ARB_provoking_vertex GLEW_ARB_provoking_vertex = _glewSearchExtension("GL_ARB_provoking_vertex", extStart, extEnd); if (glewExperimental || GLEW_ARB_provoking_vertex) GLEW_ARB_provoking_vertex = !_glewInit_GL_ARB_provoking_vertex(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_provoking_vertex */ #ifdef GL_ARB_query_buffer_object GLEW_ARB_query_buffer_object = _glewSearchExtension("GL_ARB_query_buffer_object", extStart, extEnd); #endif /* GL_ARB_query_buffer_object */ #ifdef GL_ARB_robust_buffer_access_behavior GLEW_ARB_robust_buffer_access_behavior = _glewSearchExtension("GL_ARB_robust_buffer_access_behavior", extStart, extEnd); #endif /* GL_ARB_robust_buffer_access_behavior */ #ifdef GL_ARB_robustness GLEW_ARB_robustness = _glewSearchExtension("GL_ARB_robustness", extStart, extEnd); if (glewExperimental || GLEW_ARB_robustness) GLEW_ARB_robustness = !_glewInit_GL_ARB_robustness(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_robustness */ #ifdef GL_ARB_robustness_application_isolation GLEW_ARB_robustness_application_isolation = _glewSearchExtension("GL_ARB_robustness_application_isolation", extStart, extEnd); #endif /* GL_ARB_robustness_application_isolation */ #ifdef GL_ARB_robustness_share_group_isolation GLEW_ARB_robustness_share_group_isolation = _glewSearchExtension("GL_ARB_robustness_share_group_isolation", extStart, extEnd); #endif /* GL_ARB_robustness_share_group_isolation */ #ifdef GL_ARB_sample_locations GLEW_ARB_sample_locations = _glewSearchExtension("GL_ARB_sample_locations", extStart, extEnd); if (glewExperimental || GLEW_ARB_sample_locations) GLEW_ARB_sample_locations = !_glewInit_GL_ARB_sample_locations(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_sample_locations */ #ifdef GL_ARB_sample_shading GLEW_ARB_sample_shading = _glewSearchExtension("GL_ARB_sample_shading", extStart, extEnd); if (glewExperimental || GLEW_ARB_sample_shading) GLEW_ARB_sample_shading = !_glewInit_GL_ARB_sample_shading(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_sample_shading */ #ifdef GL_ARB_sampler_objects GLEW_ARB_sampler_objects = _glewSearchExtension("GL_ARB_sampler_objects", extStart, extEnd); if (glewExperimental || GLEW_ARB_sampler_objects) GLEW_ARB_sampler_objects = !_glewInit_GL_ARB_sampler_objects(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_sampler_objects */ #ifdef GL_ARB_seamless_cube_map GLEW_ARB_seamless_cube_map = _glewSearchExtension("GL_ARB_seamless_cube_map", extStart, extEnd); #endif /* GL_ARB_seamless_cube_map */ #ifdef GL_ARB_seamless_cubemap_per_texture GLEW_ARB_seamless_cubemap_per_texture = _glewSearchExtension("GL_ARB_seamless_cubemap_per_texture", extStart, extEnd); #endif /* GL_ARB_seamless_cubemap_per_texture */ #ifdef GL_ARB_separate_shader_objects GLEW_ARB_separate_shader_objects = _glewSearchExtension("GL_ARB_separate_shader_objects", extStart, extEnd); if (glewExperimental || GLEW_ARB_separate_shader_objects) GLEW_ARB_separate_shader_objects = !_glewInit_GL_ARB_separate_shader_objects(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_separate_shader_objects */ #ifdef GL_ARB_shader_atomic_counter_ops GLEW_ARB_shader_atomic_counter_ops = _glewSearchExtension("GL_ARB_shader_atomic_counter_ops", extStart, extEnd); #endif /* GL_ARB_shader_atomic_counter_ops */ #ifdef GL_ARB_shader_atomic_counters GLEW_ARB_shader_atomic_counters = _glewSearchExtension("GL_ARB_shader_atomic_counters", extStart, extEnd); if (glewExperimental || GLEW_ARB_shader_atomic_counters) GLEW_ARB_shader_atomic_counters = !_glewInit_GL_ARB_shader_atomic_counters(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_shader_atomic_counters */ #ifdef GL_ARB_shader_ballot GLEW_ARB_shader_ballot = _glewSearchExtension("GL_ARB_shader_ballot", extStart, extEnd); #endif /* GL_ARB_shader_ballot */ #ifdef GL_ARB_shader_bit_encoding GLEW_ARB_shader_bit_encoding = _glewSearchExtension("GL_ARB_shader_bit_encoding", extStart, extEnd); #endif /* GL_ARB_shader_bit_encoding */ #ifdef GL_ARB_shader_clock GLEW_ARB_shader_clock = _glewSearchExtension("GL_ARB_shader_clock", extStart, extEnd); #endif /* GL_ARB_shader_clock */ #ifdef GL_ARB_shader_draw_parameters GLEW_ARB_shader_draw_parameters = _glewSearchExtension("GL_ARB_shader_draw_parameters", extStart, extEnd); #endif /* GL_ARB_shader_draw_parameters */ #ifdef GL_ARB_shader_group_vote GLEW_ARB_shader_group_vote = _glewSearchExtension("GL_ARB_shader_group_vote", extStart, extEnd); #endif /* GL_ARB_shader_group_vote */ #ifdef GL_ARB_shader_image_load_store GLEW_ARB_shader_image_load_store = _glewSearchExtension("GL_ARB_shader_image_load_store", extStart, extEnd); if (glewExperimental || GLEW_ARB_shader_image_load_store) GLEW_ARB_shader_image_load_store = !_glewInit_GL_ARB_shader_image_load_store(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_shader_image_load_store */ #ifdef GL_ARB_shader_image_size GLEW_ARB_shader_image_size = _glewSearchExtension("GL_ARB_shader_image_size", extStart, extEnd); #endif /* GL_ARB_shader_image_size */ #ifdef GL_ARB_shader_objects GLEW_ARB_shader_objects = _glewSearchExtension("GL_ARB_shader_objects", extStart, extEnd); if (glewExperimental || GLEW_ARB_shader_objects) GLEW_ARB_shader_objects = !_glewInit_GL_ARB_shader_objects(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_shader_objects */ #ifdef GL_ARB_shader_precision GLEW_ARB_shader_precision = _glewSearchExtension("GL_ARB_shader_precision", extStart, extEnd); #endif /* GL_ARB_shader_precision */ #ifdef GL_ARB_shader_stencil_export GLEW_ARB_shader_stencil_export = _glewSearchExtension("GL_ARB_shader_stencil_export", extStart, extEnd); #endif /* GL_ARB_shader_stencil_export */ #ifdef GL_ARB_shader_storage_buffer_object GLEW_ARB_shader_storage_buffer_object = _glewSearchExtension("GL_ARB_shader_storage_buffer_object", extStart, extEnd); if (glewExperimental || GLEW_ARB_shader_storage_buffer_object) GLEW_ARB_shader_storage_buffer_object = !_glewInit_GL_ARB_shader_storage_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_shader_storage_buffer_object */ #ifdef GL_ARB_shader_subroutine GLEW_ARB_shader_subroutine = _glewSearchExtension("GL_ARB_shader_subroutine", extStart, extEnd); if (glewExperimental || GLEW_ARB_shader_subroutine) GLEW_ARB_shader_subroutine = !_glewInit_GL_ARB_shader_subroutine(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_shader_subroutine */ #ifdef GL_ARB_shader_texture_image_samples GLEW_ARB_shader_texture_image_samples = _glewSearchExtension("GL_ARB_shader_texture_image_samples", extStart, extEnd); #endif /* GL_ARB_shader_texture_image_samples */ #ifdef GL_ARB_shader_texture_lod GLEW_ARB_shader_texture_lod = _glewSearchExtension("GL_ARB_shader_texture_lod", extStart, extEnd); #endif /* GL_ARB_shader_texture_lod */ #ifdef GL_ARB_shader_viewport_layer_array GLEW_ARB_shader_viewport_layer_array = _glewSearchExtension("GL_ARB_shader_viewport_layer_array", extStart, extEnd); #endif /* GL_ARB_shader_viewport_layer_array */ #ifdef GL_ARB_shading_language_100 GLEW_ARB_shading_language_100 = _glewSearchExtension("GL_ARB_shading_language_100", extStart, extEnd); #endif /* GL_ARB_shading_language_100 */ #ifdef GL_ARB_shading_language_420pack GLEW_ARB_shading_language_420pack = _glewSearchExtension("GL_ARB_shading_language_420pack", extStart, extEnd); #endif /* GL_ARB_shading_language_420pack */ #ifdef GL_ARB_shading_language_include GLEW_ARB_shading_language_include = _glewSearchExtension("GL_ARB_shading_language_include", extStart, extEnd); if (glewExperimental || GLEW_ARB_shading_language_include) GLEW_ARB_shading_language_include = !_glewInit_GL_ARB_shading_language_include(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_shading_language_include */ #ifdef GL_ARB_shading_language_packing GLEW_ARB_shading_language_packing = _glewSearchExtension("GL_ARB_shading_language_packing", extStart, extEnd); #endif /* GL_ARB_shading_language_packing */ #ifdef GL_ARB_shadow GLEW_ARB_shadow = _glewSearchExtension("GL_ARB_shadow", extStart, extEnd); #endif /* GL_ARB_shadow */ #ifdef GL_ARB_shadow_ambient GLEW_ARB_shadow_ambient = _glewSearchExtension("GL_ARB_shadow_ambient", extStart, extEnd); #endif /* GL_ARB_shadow_ambient */ #ifdef GL_ARB_sparse_buffer GLEW_ARB_sparse_buffer = _glewSearchExtension("GL_ARB_sparse_buffer", extStart, extEnd); if (glewExperimental || GLEW_ARB_sparse_buffer) GLEW_ARB_sparse_buffer = !_glewInit_GL_ARB_sparse_buffer(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_sparse_buffer */ #ifdef GL_ARB_sparse_texture GLEW_ARB_sparse_texture = _glewSearchExtension("GL_ARB_sparse_texture", extStart, extEnd); if (glewExperimental || GLEW_ARB_sparse_texture) GLEW_ARB_sparse_texture = !_glewInit_GL_ARB_sparse_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_sparse_texture */ #ifdef GL_ARB_sparse_texture2 GLEW_ARB_sparse_texture2 = _glewSearchExtension("GL_ARB_sparse_texture2", extStart, extEnd); #endif /* GL_ARB_sparse_texture2 */ #ifdef GL_ARB_sparse_texture_clamp GLEW_ARB_sparse_texture_clamp = _glewSearchExtension("GL_ARB_sparse_texture_clamp", extStart, extEnd); #endif /* GL_ARB_sparse_texture_clamp */ #ifdef GL_ARB_stencil_texturing GLEW_ARB_stencil_texturing = _glewSearchExtension("GL_ARB_stencil_texturing", extStart, extEnd); #endif /* GL_ARB_stencil_texturing */ #ifdef GL_ARB_sync GLEW_ARB_sync = _glewSearchExtension("GL_ARB_sync", extStart, extEnd); if (glewExperimental || GLEW_ARB_sync) GLEW_ARB_sync = !_glewInit_GL_ARB_sync(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_sync */ #ifdef GL_ARB_tessellation_shader GLEW_ARB_tessellation_shader = _glewSearchExtension("GL_ARB_tessellation_shader", extStart, extEnd); if (glewExperimental || GLEW_ARB_tessellation_shader) GLEW_ARB_tessellation_shader = !_glewInit_GL_ARB_tessellation_shader(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_tessellation_shader */ #ifdef GL_ARB_texture_barrier GLEW_ARB_texture_barrier = _glewSearchExtension("GL_ARB_texture_barrier", extStart, extEnd); if (glewExperimental || GLEW_ARB_texture_barrier) GLEW_ARB_texture_barrier = !_glewInit_GL_ARB_texture_barrier(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_texture_barrier */ #ifdef GL_ARB_texture_border_clamp GLEW_ARB_texture_border_clamp = _glewSearchExtension("GL_ARB_texture_border_clamp", extStart, extEnd); #endif /* GL_ARB_texture_border_clamp */ #ifdef GL_ARB_texture_buffer_object GLEW_ARB_texture_buffer_object = _glewSearchExtension("GL_ARB_texture_buffer_object", extStart, extEnd); if (glewExperimental || GLEW_ARB_texture_buffer_object) GLEW_ARB_texture_buffer_object = !_glewInit_GL_ARB_texture_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_texture_buffer_object */ #ifdef GL_ARB_texture_buffer_object_rgb32 GLEW_ARB_texture_buffer_object_rgb32 = _glewSearchExtension("GL_ARB_texture_buffer_object_rgb32", extStart, extEnd); #endif /* GL_ARB_texture_buffer_object_rgb32 */ #ifdef GL_ARB_texture_buffer_range GLEW_ARB_texture_buffer_range = _glewSearchExtension("GL_ARB_texture_buffer_range", extStart, extEnd); if (glewExperimental || GLEW_ARB_texture_buffer_range) GLEW_ARB_texture_buffer_range = !_glewInit_GL_ARB_texture_buffer_range(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_texture_buffer_range */ #ifdef GL_ARB_texture_compression GLEW_ARB_texture_compression = _glewSearchExtension("GL_ARB_texture_compression", extStart, extEnd); if (glewExperimental || GLEW_ARB_texture_compression) GLEW_ARB_texture_compression = !_glewInit_GL_ARB_texture_compression(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_texture_compression */ #ifdef GL_ARB_texture_compression_bptc GLEW_ARB_texture_compression_bptc = _glewSearchExtension("GL_ARB_texture_compression_bptc", extStart, extEnd); #endif /* GL_ARB_texture_compression_bptc */ #ifdef GL_ARB_texture_compression_rgtc GLEW_ARB_texture_compression_rgtc = _glewSearchExtension("GL_ARB_texture_compression_rgtc", extStart, extEnd); #endif /* GL_ARB_texture_compression_rgtc */ #ifdef GL_ARB_texture_cube_map GLEW_ARB_texture_cube_map = _glewSearchExtension("GL_ARB_texture_cube_map", extStart, extEnd); #endif /* GL_ARB_texture_cube_map */ #ifdef GL_ARB_texture_cube_map_array GLEW_ARB_texture_cube_map_array = _glewSearchExtension("GL_ARB_texture_cube_map_array", extStart, extEnd); #endif /* GL_ARB_texture_cube_map_array */ #ifdef GL_ARB_texture_env_add GLEW_ARB_texture_env_add = _glewSearchExtension("GL_ARB_texture_env_add", extStart, extEnd); #endif /* GL_ARB_texture_env_add */ #ifdef GL_ARB_texture_env_combine GLEW_ARB_texture_env_combine = _glewSearchExtension("GL_ARB_texture_env_combine", extStart, extEnd); #endif /* GL_ARB_texture_env_combine */ #ifdef GL_ARB_texture_env_crossbar GLEW_ARB_texture_env_crossbar = _glewSearchExtension("GL_ARB_texture_env_crossbar", extStart, extEnd); #endif /* GL_ARB_texture_env_crossbar */ #ifdef GL_ARB_texture_env_dot3 GLEW_ARB_texture_env_dot3 = _glewSearchExtension("GL_ARB_texture_env_dot3", extStart, extEnd); #endif /* GL_ARB_texture_env_dot3 */ #ifdef GL_ARB_texture_filter_minmax GLEW_ARB_texture_filter_minmax = _glewSearchExtension("GL_ARB_texture_filter_minmax", extStart, extEnd); #endif /* GL_ARB_texture_filter_minmax */ #ifdef GL_ARB_texture_float GLEW_ARB_texture_float = _glewSearchExtension("GL_ARB_texture_float", extStart, extEnd); #endif /* GL_ARB_texture_float */ #ifdef GL_ARB_texture_gather GLEW_ARB_texture_gather = _glewSearchExtension("GL_ARB_texture_gather", extStart, extEnd); #endif /* GL_ARB_texture_gather */ #ifdef GL_ARB_texture_mirror_clamp_to_edge GLEW_ARB_texture_mirror_clamp_to_edge = _glewSearchExtension("GL_ARB_texture_mirror_clamp_to_edge", extStart, extEnd); #endif /* GL_ARB_texture_mirror_clamp_to_edge */ #ifdef GL_ARB_texture_mirrored_repeat GLEW_ARB_texture_mirrored_repeat = _glewSearchExtension("GL_ARB_texture_mirrored_repeat", extStart, extEnd); #endif /* GL_ARB_texture_mirrored_repeat */ #ifdef GL_ARB_texture_multisample GLEW_ARB_texture_multisample = _glewSearchExtension("GL_ARB_texture_multisample", extStart, extEnd); if (glewExperimental || GLEW_ARB_texture_multisample) GLEW_ARB_texture_multisample = !_glewInit_GL_ARB_texture_multisample(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_texture_multisample */ #ifdef GL_ARB_texture_non_power_of_two GLEW_ARB_texture_non_power_of_two = _glewSearchExtension("GL_ARB_texture_non_power_of_two", extStart, extEnd); #endif /* GL_ARB_texture_non_power_of_two */ #ifdef GL_ARB_texture_query_levels GLEW_ARB_texture_query_levels = _glewSearchExtension("GL_ARB_texture_query_levels", extStart, extEnd); #endif /* GL_ARB_texture_query_levels */ #ifdef GL_ARB_texture_query_lod GLEW_ARB_texture_query_lod = _glewSearchExtension("GL_ARB_texture_query_lod", extStart, extEnd); #endif /* GL_ARB_texture_query_lod */ #ifdef GL_ARB_texture_rectangle GLEW_ARB_texture_rectangle = _glewSearchExtension("GL_ARB_texture_rectangle", extStart, extEnd); #endif /* GL_ARB_texture_rectangle */ #ifdef GL_ARB_texture_rg GLEW_ARB_texture_rg = _glewSearchExtension("GL_ARB_texture_rg", extStart, extEnd); #endif /* GL_ARB_texture_rg */ #ifdef GL_ARB_texture_rgb10_a2ui GLEW_ARB_texture_rgb10_a2ui = _glewSearchExtension("GL_ARB_texture_rgb10_a2ui", extStart, extEnd); #endif /* GL_ARB_texture_rgb10_a2ui */ #ifdef GL_ARB_texture_stencil8 GLEW_ARB_texture_stencil8 = _glewSearchExtension("GL_ARB_texture_stencil8", extStart, extEnd); #endif /* GL_ARB_texture_stencil8 */ #ifdef GL_ARB_texture_storage GLEW_ARB_texture_storage = _glewSearchExtension("GL_ARB_texture_storage", extStart, extEnd); if (glewExperimental || GLEW_ARB_texture_storage) GLEW_ARB_texture_storage = !_glewInit_GL_ARB_texture_storage(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_texture_storage */ #ifdef GL_ARB_texture_storage_multisample GLEW_ARB_texture_storage_multisample = _glewSearchExtension("GL_ARB_texture_storage_multisample", extStart, extEnd); if (glewExperimental || GLEW_ARB_texture_storage_multisample) GLEW_ARB_texture_storage_multisample = !_glewInit_GL_ARB_texture_storage_multisample(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_texture_storage_multisample */ #ifdef GL_ARB_texture_swizzle GLEW_ARB_texture_swizzle = _glewSearchExtension("GL_ARB_texture_swizzle", extStart, extEnd); #endif /* GL_ARB_texture_swizzle */ #ifdef GL_ARB_texture_view GLEW_ARB_texture_view = _glewSearchExtension("GL_ARB_texture_view", extStart, extEnd); if (glewExperimental || GLEW_ARB_texture_view) GLEW_ARB_texture_view = !_glewInit_GL_ARB_texture_view(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_texture_view */ #ifdef GL_ARB_timer_query GLEW_ARB_timer_query = _glewSearchExtension("GL_ARB_timer_query", extStart, extEnd); if (glewExperimental || GLEW_ARB_timer_query) GLEW_ARB_timer_query = !_glewInit_GL_ARB_timer_query(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_timer_query */ #ifdef GL_ARB_transform_feedback2 GLEW_ARB_transform_feedback2 = _glewSearchExtension("GL_ARB_transform_feedback2", extStart, extEnd); if (glewExperimental || GLEW_ARB_transform_feedback2) GLEW_ARB_transform_feedback2 = !_glewInit_GL_ARB_transform_feedback2(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_transform_feedback2 */ #ifdef GL_ARB_transform_feedback3 GLEW_ARB_transform_feedback3 = _glewSearchExtension("GL_ARB_transform_feedback3", extStart, extEnd); if (glewExperimental || GLEW_ARB_transform_feedback3) GLEW_ARB_transform_feedback3 = !_glewInit_GL_ARB_transform_feedback3(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_transform_feedback3 */ #ifdef GL_ARB_transform_feedback_instanced GLEW_ARB_transform_feedback_instanced = _glewSearchExtension("GL_ARB_transform_feedback_instanced", extStart, extEnd); if (glewExperimental || GLEW_ARB_transform_feedback_instanced) GLEW_ARB_transform_feedback_instanced = !_glewInit_GL_ARB_transform_feedback_instanced(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_transform_feedback_instanced */ #ifdef GL_ARB_transform_feedback_overflow_query GLEW_ARB_transform_feedback_overflow_query = _glewSearchExtension("GL_ARB_transform_feedback_overflow_query", extStart, extEnd); #endif /* GL_ARB_transform_feedback_overflow_query */ #ifdef GL_ARB_transpose_matrix GLEW_ARB_transpose_matrix = _glewSearchExtension("GL_ARB_transpose_matrix", extStart, extEnd); if (glewExperimental || GLEW_ARB_transpose_matrix) GLEW_ARB_transpose_matrix = !_glewInit_GL_ARB_transpose_matrix(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_transpose_matrix */ #ifdef GL_ARB_uniform_buffer_object GLEW_ARB_uniform_buffer_object = _glewSearchExtension("GL_ARB_uniform_buffer_object", extStart, extEnd); if (glewExperimental || GLEW_ARB_uniform_buffer_object) GLEW_ARB_uniform_buffer_object = !_glewInit_GL_ARB_uniform_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_uniform_buffer_object */ #ifdef GL_ARB_vertex_array_bgra GLEW_ARB_vertex_array_bgra = _glewSearchExtension("GL_ARB_vertex_array_bgra", extStart, extEnd); #endif /* GL_ARB_vertex_array_bgra */ #ifdef GL_ARB_vertex_array_object GLEW_ARB_vertex_array_object = _glewSearchExtension("GL_ARB_vertex_array_object", extStart, extEnd); if (glewExperimental || GLEW_ARB_vertex_array_object) GLEW_ARB_vertex_array_object = !_glewInit_GL_ARB_vertex_array_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_vertex_array_object */ #ifdef GL_ARB_vertex_attrib_64bit GLEW_ARB_vertex_attrib_64bit = _glewSearchExtension("GL_ARB_vertex_attrib_64bit", extStart, extEnd); if (glewExperimental || GLEW_ARB_vertex_attrib_64bit) GLEW_ARB_vertex_attrib_64bit = !_glewInit_GL_ARB_vertex_attrib_64bit(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_vertex_attrib_64bit */ #ifdef GL_ARB_vertex_attrib_binding GLEW_ARB_vertex_attrib_binding = _glewSearchExtension("GL_ARB_vertex_attrib_binding", extStart, extEnd); if (glewExperimental || GLEW_ARB_vertex_attrib_binding) GLEW_ARB_vertex_attrib_binding = !_glewInit_GL_ARB_vertex_attrib_binding(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_vertex_attrib_binding */ #ifdef GL_ARB_vertex_blend GLEW_ARB_vertex_blend = _glewSearchExtension("GL_ARB_vertex_blend", extStart, extEnd); if (glewExperimental || GLEW_ARB_vertex_blend) GLEW_ARB_vertex_blend = !_glewInit_GL_ARB_vertex_blend(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_vertex_blend */ #ifdef GL_ARB_vertex_buffer_object GLEW_ARB_vertex_buffer_object = _glewSearchExtension("GL_ARB_vertex_buffer_object", extStart, extEnd); if (glewExperimental || GLEW_ARB_vertex_buffer_object) GLEW_ARB_vertex_buffer_object = !_glewInit_GL_ARB_vertex_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_vertex_buffer_object */ #ifdef GL_ARB_vertex_program GLEW_ARB_vertex_program = _glewSearchExtension("GL_ARB_vertex_program", extStart, extEnd); if (glewExperimental || GLEW_ARB_vertex_program) GLEW_ARB_vertex_program = !_glewInit_GL_ARB_vertex_program(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_vertex_program */ #ifdef GL_ARB_vertex_shader GLEW_ARB_vertex_shader = _glewSearchExtension("GL_ARB_vertex_shader", extStart, extEnd); if (glewExperimental || GLEW_ARB_vertex_shader) { GLEW_ARB_vertex_shader = !_glewInit_GL_ARB_vertex_shader(GLEW_CONTEXT_ARG_VAR_INIT); _glewInit_GL_ARB_vertex_program(GLEW_CONTEXT_ARG_VAR_INIT); } #endif /* GL_ARB_vertex_shader */ #ifdef GL_ARB_vertex_type_10f_11f_11f_rev GLEW_ARB_vertex_type_10f_11f_11f_rev = _glewSearchExtension("GL_ARB_vertex_type_10f_11f_11f_rev", extStart, extEnd); #endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ #ifdef GL_ARB_vertex_type_2_10_10_10_rev GLEW_ARB_vertex_type_2_10_10_10_rev = _glewSearchExtension("GL_ARB_vertex_type_2_10_10_10_rev", extStart, extEnd); if (glewExperimental || GLEW_ARB_vertex_type_2_10_10_10_rev) GLEW_ARB_vertex_type_2_10_10_10_rev = !_glewInit_GL_ARB_vertex_type_2_10_10_10_rev(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_vertex_type_2_10_10_10_rev */ #ifdef GL_ARB_viewport_array GLEW_ARB_viewport_array = _glewSearchExtension("GL_ARB_viewport_array", extStart, extEnd); if (glewExperimental || GLEW_ARB_viewport_array) GLEW_ARB_viewport_array = !_glewInit_GL_ARB_viewport_array(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_viewport_array */ #ifdef GL_ARB_window_pos GLEW_ARB_window_pos = _glewSearchExtension("GL_ARB_window_pos", extStart, extEnd); if (glewExperimental || GLEW_ARB_window_pos) GLEW_ARB_window_pos = !_glewInit_GL_ARB_window_pos(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_window_pos */ #ifdef GL_ATIX_point_sprites GLEW_ATIX_point_sprites = _glewSearchExtension("GL_ATIX_point_sprites", extStart, extEnd); #endif /* GL_ATIX_point_sprites */ #ifdef GL_ATIX_texture_env_combine3 GLEW_ATIX_texture_env_combine3 = _glewSearchExtension("GL_ATIX_texture_env_combine3", extStart, extEnd); #endif /* GL_ATIX_texture_env_combine3 */ #ifdef GL_ATIX_texture_env_route GLEW_ATIX_texture_env_route = _glewSearchExtension("GL_ATIX_texture_env_route", extStart, extEnd); #endif /* GL_ATIX_texture_env_route */ #ifdef GL_ATIX_vertex_shader_output_point_size GLEW_ATIX_vertex_shader_output_point_size = _glewSearchExtension("GL_ATIX_vertex_shader_output_point_size", extStart, extEnd); #endif /* GL_ATIX_vertex_shader_output_point_size */ #ifdef GL_ATI_draw_buffers GLEW_ATI_draw_buffers = _glewSearchExtension("GL_ATI_draw_buffers", extStart, extEnd); if (glewExperimental || GLEW_ATI_draw_buffers) GLEW_ATI_draw_buffers = !_glewInit_GL_ATI_draw_buffers(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ATI_draw_buffers */ #ifdef GL_ATI_element_array GLEW_ATI_element_array = _glewSearchExtension("GL_ATI_element_array", extStart, extEnd); if (glewExperimental || GLEW_ATI_element_array) GLEW_ATI_element_array = !_glewInit_GL_ATI_element_array(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ATI_element_array */ #ifdef GL_ATI_envmap_bumpmap GLEW_ATI_envmap_bumpmap = _glewSearchExtension("GL_ATI_envmap_bumpmap", extStart, extEnd); if (glewExperimental || GLEW_ATI_envmap_bumpmap) GLEW_ATI_envmap_bumpmap = !_glewInit_GL_ATI_envmap_bumpmap(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ATI_envmap_bumpmap */ #ifdef GL_ATI_fragment_shader GLEW_ATI_fragment_shader = _glewSearchExtension("GL_ATI_fragment_shader", extStart, extEnd); if (glewExperimental || GLEW_ATI_fragment_shader) GLEW_ATI_fragment_shader = !_glewInit_GL_ATI_fragment_shader(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ATI_fragment_shader */ #ifdef GL_ATI_map_object_buffer GLEW_ATI_map_object_buffer = _glewSearchExtension("GL_ATI_map_object_buffer", extStart, extEnd); if (glewExperimental || GLEW_ATI_map_object_buffer) GLEW_ATI_map_object_buffer = !_glewInit_GL_ATI_map_object_buffer(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ATI_map_object_buffer */ #ifdef GL_ATI_meminfo GLEW_ATI_meminfo = _glewSearchExtension("GL_ATI_meminfo", extStart, extEnd); #endif /* GL_ATI_meminfo */ #ifdef GL_ATI_pn_triangles GLEW_ATI_pn_triangles = _glewSearchExtension("GL_ATI_pn_triangles", extStart, extEnd); if (glewExperimental || GLEW_ATI_pn_triangles) GLEW_ATI_pn_triangles = !_glewInit_GL_ATI_pn_triangles(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ATI_pn_triangles */ #ifdef GL_ATI_separate_stencil GLEW_ATI_separate_stencil = _glewSearchExtension("GL_ATI_separate_stencil", extStart, extEnd); if (glewExperimental || GLEW_ATI_separate_stencil) GLEW_ATI_separate_stencil = !_glewInit_GL_ATI_separate_stencil(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ATI_separate_stencil */ #ifdef GL_ATI_shader_texture_lod GLEW_ATI_shader_texture_lod = _glewSearchExtension("GL_ATI_shader_texture_lod", extStart, extEnd); #endif /* GL_ATI_shader_texture_lod */ #ifdef GL_ATI_text_fragment_shader GLEW_ATI_text_fragment_shader = _glewSearchExtension("GL_ATI_text_fragment_shader", extStart, extEnd); #endif /* GL_ATI_text_fragment_shader */ #ifdef GL_ATI_texture_compression_3dc GLEW_ATI_texture_compression_3dc = _glewSearchExtension("GL_ATI_texture_compression_3dc", extStart, extEnd); #endif /* GL_ATI_texture_compression_3dc */ #ifdef GL_ATI_texture_env_combine3 GLEW_ATI_texture_env_combine3 = _glewSearchExtension("GL_ATI_texture_env_combine3", extStart, extEnd); #endif /* GL_ATI_texture_env_combine3 */ #ifdef GL_ATI_texture_float GLEW_ATI_texture_float = _glewSearchExtension("GL_ATI_texture_float", extStart, extEnd); #endif /* GL_ATI_texture_float */ #ifdef GL_ATI_texture_mirror_once GLEW_ATI_texture_mirror_once = _glewSearchExtension("GL_ATI_texture_mirror_once", extStart, extEnd); #endif /* GL_ATI_texture_mirror_once */ #ifdef GL_ATI_vertex_array_object GLEW_ATI_vertex_array_object = _glewSearchExtension("GL_ATI_vertex_array_object", extStart, extEnd); if (glewExperimental || GLEW_ATI_vertex_array_object) GLEW_ATI_vertex_array_object = !_glewInit_GL_ATI_vertex_array_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ATI_vertex_array_object */ #ifdef GL_ATI_vertex_attrib_array_object GLEW_ATI_vertex_attrib_array_object = _glewSearchExtension("GL_ATI_vertex_attrib_array_object", extStart, extEnd); if (glewExperimental || GLEW_ATI_vertex_attrib_array_object) GLEW_ATI_vertex_attrib_array_object = !_glewInit_GL_ATI_vertex_attrib_array_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ATI_vertex_attrib_array_object */ #ifdef GL_ATI_vertex_streams GLEW_ATI_vertex_streams = _glewSearchExtension("GL_ATI_vertex_streams", extStart, extEnd); if (glewExperimental || GLEW_ATI_vertex_streams) GLEW_ATI_vertex_streams = !_glewInit_GL_ATI_vertex_streams(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ATI_vertex_streams */ #ifdef GL_EXT_422_pixels GLEW_EXT_422_pixels = _glewSearchExtension("GL_EXT_422_pixels", extStart, extEnd); #endif /* GL_EXT_422_pixels */ #ifdef GL_EXT_Cg_shader GLEW_EXT_Cg_shader = _glewSearchExtension("GL_EXT_Cg_shader", extStart, extEnd); #endif /* GL_EXT_Cg_shader */ #ifdef GL_EXT_abgr GLEW_EXT_abgr = _glewSearchExtension("GL_EXT_abgr", extStart, extEnd); #endif /* GL_EXT_abgr */ #ifdef GL_EXT_bgra GLEW_EXT_bgra = _glewSearchExtension("GL_EXT_bgra", extStart, extEnd); #endif /* GL_EXT_bgra */ #ifdef GL_EXT_bindable_uniform GLEW_EXT_bindable_uniform = _glewSearchExtension("GL_EXT_bindable_uniform", extStart, extEnd); if (glewExperimental || GLEW_EXT_bindable_uniform) GLEW_EXT_bindable_uniform = !_glewInit_GL_EXT_bindable_uniform(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_bindable_uniform */ #ifdef GL_EXT_blend_color GLEW_EXT_blend_color = _glewSearchExtension("GL_EXT_blend_color", extStart, extEnd); if (glewExperimental || GLEW_EXT_blend_color) GLEW_EXT_blend_color = !_glewInit_GL_EXT_blend_color(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_blend_color */ #ifdef GL_EXT_blend_equation_separate GLEW_EXT_blend_equation_separate = _glewSearchExtension("GL_EXT_blend_equation_separate", extStart, extEnd); if (glewExperimental || GLEW_EXT_blend_equation_separate) GLEW_EXT_blend_equation_separate = !_glewInit_GL_EXT_blend_equation_separate(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_blend_equation_separate */ #ifdef GL_EXT_blend_func_separate GLEW_EXT_blend_func_separate = _glewSearchExtension("GL_EXT_blend_func_separate", extStart, extEnd); if (glewExperimental || GLEW_EXT_blend_func_separate) GLEW_EXT_blend_func_separate = !_glewInit_GL_EXT_blend_func_separate(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_blend_func_separate */ #ifdef GL_EXT_blend_logic_op GLEW_EXT_blend_logic_op = _glewSearchExtension("GL_EXT_blend_logic_op", extStart, extEnd); #endif /* GL_EXT_blend_logic_op */ #ifdef GL_EXT_blend_minmax GLEW_EXT_blend_minmax = _glewSearchExtension("GL_EXT_blend_minmax", extStart, extEnd); if (glewExperimental || GLEW_EXT_blend_minmax) GLEW_EXT_blend_minmax = !_glewInit_GL_EXT_blend_minmax(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_blend_minmax */ #ifdef GL_EXT_blend_subtract GLEW_EXT_blend_subtract = _glewSearchExtension("GL_EXT_blend_subtract", extStart, extEnd); #endif /* GL_EXT_blend_subtract */ #ifdef GL_EXT_clip_volume_hint GLEW_EXT_clip_volume_hint = _glewSearchExtension("GL_EXT_clip_volume_hint", extStart, extEnd); #endif /* GL_EXT_clip_volume_hint */ #ifdef GL_EXT_cmyka GLEW_EXT_cmyka = _glewSearchExtension("GL_EXT_cmyka", extStart, extEnd); #endif /* GL_EXT_cmyka */ #ifdef GL_EXT_color_subtable GLEW_EXT_color_subtable = _glewSearchExtension("GL_EXT_color_subtable", extStart, extEnd); if (glewExperimental || GLEW_EXT_color_subtable) GLEW_EXT_color_subtable = !_glewInit_GL_EXT_color_subtable(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_color_subtable */ #ifdef GL_EXT_compiled_vertex_array GLEW_EXT_compiled_vertex_array = _glewSearchExtension("GL_EXT_compiled_vertex_array", extStart, extEnd); if (glewExperimental || GLEW_EXT_compiled_vertex_array) GLEW_EXT_compiled_vertex_array = !_glewInit_GL_EXT_compiled_vertex_array(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_compiled_vertex_array */ #ifdef GL_EXT_convolution GLEW_EXT_convolution = _glewSearchExtension("GL_EXT_convolution", extStart, extEnd); if (glewExperimental || GLEW_EXT_convolution) GLEW_EXT_convolution = !_glewInit_GL_EXT_convolution(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_convolution */ #ifdef GL_EXT_coordinate_frame GLEW_EXT_coordinate_frame = _glewSearchExtension("GL_EXT_coordinate_frame", extStart, extEnd); if (glewExperimental || GLEW_EXT_coordinate_frame) GLEW_EXT_coordinate_frame = !_glewInit_GL_EXT_coordinate_frame(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_coordinate_frame */ #ifdef GL_EXT_copy_texture GLEW_EXT_copy_texture = _glewSearchExtension("GL_EXT_copy_texture", extStart, extEnd); if (glewExperimental || GLEW_EXT_copy_texture) GLEW_EXT_copy_texture = !_glewInit_GL_EXT_copy_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_copy_texture */ #ifdef GL_EXT_cull_vertex GLEW_EXT_cull_vertex = _glewSearchExtension("GL_EXT_cull_vertex", extStart, extEnd); if (glewExperimental || GLEW_EXT_cull_vertex) GLEW_EXT_cull_vertex = !_glewInit_GL_EXT_cull_vertex(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_cull_vertex */ #ifdef GL_EXT_debug_label GLEW_EXT_debug_label = _glewSearchExtension("GL_EXT_debug_label", extStart, extEnd); if (glewExperimental || GLEW_EXT_debug_label) GLEW_EXT_debug_label = !_glewInit_GL_EXT_debug_label(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_debug_label */ #ifdef GL_EXT_debug_marker GLEW_EXT_debug_marker = _glewSearchExtension("GL_EXT_debug_marker", extStart, extEnd); if (glewExperimental || GLEW_EXT_debug_marker) GLEW_EXT_debug_marker = !_glewInit_GL_EXT_debug_marker(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_debug_marker */ #ifdef GL_EXT_depth_bounds_test GLEW_EXT_depth_bounds_test = _glewSearchExtension("GL_EXT_depth_bounds_test", extStart, extEnd); if (glewExperimental || GLEW_EXT_depth_bounds_test) GLEW_EXT_depth_bounds_test = !_glewInit_GL_EXT_depth_bounds_test(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_depth_bounds_test */ #ifdef GL_EXT_direct_state_access GLEW_EXT_direct_state_access = _glewSearchExtension("GL_EXT_direct_state_access", extStart, extEnd); if (glewExperimental || GLEW_EXT_direct_state_access) GLEW_EXT_direct_state_access = !_glewInit_GL_EXT_direct_state_access(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_direct_state_access */ #ifdef GL_EXT_draw_buffers2 GLEW_EXT_draw_buffers2 = _glewSearchExtension("GL_EXT_draw_buffers2", extStart, extEnd); if (glewExperimental || GLEW_EXT_draw_buffers2) GLEW_EXT_draw_buffers2 = !_glewInit_GL_EXT_draw_buffers2(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_draw_buffers2 */ #ifdef GL_EXT_draw_instanced GLEW_EXT_draw_instanced = _glewSearchExtension("GL_EXT_draw_instanced", extStart, extEnd); if (glewExperimental || GLEW_EXT_draw_instanced) GLEW_EXT_draw_instanced = !_glewInit_GL_EXT_draw_instanced(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_draw_instanced */ #ifdef GL_EXT_draw_range_elements GLEW_EXT_draw_range_elements = _glewSearchExtension("GL_EXT_draw_range_elements", extStart, extEnd); if (glewExperimental || GLEW_EXT_draw_range_elements) GLEW_EXT_draw_range_elements = !_glewInit_GL_EXT_draw_range_elements(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_draw_range_elements */ #ifdef GL_EXT_fog_coord GLEW_EXT_fog_coord = _glewSearchExtension("GL_EXT_fog_coord", extStart, extEnd); if (glewExperimental || GLEW_EXT_fog_coord) GLEW_EXT_fog_coord = !_glewInit_GL_EXT_fog_coord(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_fog_coord */ #ifdef GL_EXT_fragment_lighting GLEW_EXT_fragment_lighting = _glewSearchExtension("GL_EXT_fragment_lighting", extStart, extEnd); if (glewExperimental || GLEW_EXT_fragment_lighting) GLEW_EXT_fragment_lighting = !_glewInit_GL_EXT_fragment_lighting(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_fragment_lighting */ #ifdef GL_EXT_framebuffer_blit GLEW_EXT_framebuffer_blit = _glewSearchExtension("GL_EXT_framebuffer_blit", extStart, extEnd); if (glewExperimental || GLEW_EXT_framebuffer_blit) GLEW_EXT_framebuffer_blit = !_glewInit_GL_EXT_framebuffer_blit(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_framebuffer_blit */ #ifdef GL_EXT_framebuffer_multisample GLEW_EXT_framebuffer_multisample = _glewSearchExtension("GL_EXT_framebuffer_multisample", extStart, extEnd); if (glewExperimental || GLEW_EXT_framebuffer_multisample) GLEW_EXT_framebuffer_multisample = !_glewInit_GL_EXT_framebuffer_multisample(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_framebuffer_multisample */ #ifdef GL_EXT_framebuffer_multisample_blit_scaled GLEW_EXT_framebuffer_multisample_blit_scaled = _glewSearchExtension("GL_EXT_framebuffer_multisample_blit_scaled", extStart, extEnd); #endif /* GL_EXT_framebuffer_multisample_blit_scaled */ #ifdef GL_EXT_framebuffer_object GLEW_EXT_framebuffer_object = _glewSearchExtension("GL_EXT_framebuffer_object", extStart, extEnd); if (glewExperimental || GLEW_EXT_framebuffer_object) GLEW_EXT_framebuffer_object = !_glewInit_GL_EXT_framebuffer_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_framebuffer_object */ #ifdef GL_EXT_framebuffer_sRGB GLEW_EXT_framebuffer_sRGB = _glewSearchExtension("GL_EXT_framebuffer_sRGB", extStart, extEnd); #endif /* GL_EXT_framebuffer_sRGB */ #ifdef GL_EXT_geometry_shader4 GLEW_EXT_geometry_shader4 = _glewSearchExtension("GL_EXT_geometry_shader4", extStart, extEnd); if (glewExperimental || GLEW_EXT_geometry_shader4) GLEW_EXT_geometry_shader4 = !_glewInit_GL_EXT_geometry_shader4(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_geometry_shader4 */ #ifdef GL_EXT_gpu_program_parameters GLEW_EXT_gpu_program_parameters = _glewSearchExtension("GL_EXT_gpu_program_parameters", extStart, extEnd); if (glewExperimental || GLEW_EXT_gpu_program_parameters) GLEW_EXT_gpu_program_parameters = !_glewInit_GL_EXT_gpu_program_parameters(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_gpu_program_parameters */ #ifdef GL_EXT_gpu_shader4 GLEW_EXT_gpu_shader4 = _glewSearchExtension("GL_EXT_gpu_shader4", extStart, extEnd); if (glewExperimental || GLEW_EXT_gpu_shader4) GLEW_EXT_gpu_shader4 = !_glewInit_GL_EXT_gpu_shader4(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_gpu_shader4 */ #ifdef GL_EXT_histogram GLEW_EXT_histogram = _glewSearchExtension("GL_EXT_histogram", extStart, extEnd); if (glewExperimental || GLEW_EXT_histogram) GLEW_EXT_histogram = !_glewInit_GL_EXT_histogram(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_histogram */ #ifdef GL_EXT_index_array_formats GLEW_EXT_index_array_formats = _glewSearchExtension("GL_EXT_index_array_formats", extStart, extEnd); #endif /* GL_EXT_index_array_formats */ #ifdef GL_EXT_index_func GLEW_EXT_index_func = _glewSearchExtension("GL_EXT_index_func", extStart, extEnd); if (glewExperimental || GLEW_EXT_index_func) GLEW_EXT_index_func = !_glewInit_GL_EXT_index_func(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_index_func */ #ifdef GL_EXT_index_material GLEW_EXT_index_material = _glewSearchExtension("GL_EXT_index_material", extStart, extEnd); if (glewExperimental || GLEW_EXT_index_material) GLEW_EXT_index_material = !_glewInit_GL_EXT_index_material(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_index_material */ #ifdef GL_EXT_index_texture GLEW_EXT_index_texture = _glewSearchExtension("GL_EXT_index_texture", extStart, extEnd); #endif /* GL_EXT_index_texture */ #ifdef GL_EXT_light_texture GLEW_EXT_light_texture = _glewSearchExtension("GL_EXT_light_texture", extStart, extEnd); if (glewExperimental || GLEW_EXT_light_texture) GLEW_EXT_light_texture = !_glewInit_GL_EXT_light_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_light_texture */ #ifdef GL_EXT_misc_attribute GLEW_EXT_misc_attribute = _glewSearchExtension("GL_EXT_misc_attribute", extStart, extEnd); #endif /* GL_EXT_misc_attribute */ #ifdef GL_EXT_multi_draw_arrays GLEW_EXT_multi_draw_arrays = _glewSearchExtension("GL_EXT_multi_draw_arrays", extStart, extEnd); if (glewExperimental || GLEW_EXT_multi_draw_arrays) GLEW_EXT_multi_draw_arrays = !_glewInit_GL_EXT_multi_draw_arrays(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_multi_draw_arrays */ #ifdef GL_EXT_multisample GLEW_EXT_multisample = _glewSearchExtension("GL_EXT_multisample", extStart, extEnd); if (glewExperimental || GLEW_EXT_multisample) GLEW_EXT_multisample = !_glewInit_GL_EXT_multisample(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_multisample */ #ifdef GL_EXT_packed_depth_stencil GLEW_EXT_packed_depth_stencil = _glewSearchExtension("GL_EXT_packed_depth_stencil", extStart, extEnd); #endif /* GL_EXT_packed_depth_stencil */ #ifdef GL_EXT_packed_float GLEW_EXT_packed_float = _glewSearchExtension("GL_EXT_packed_float", extStart, extEnd); #endif /* GL_EXT_packed_float */ #ifdef GL_EXT_packed_pixels GLEW_EXT_packed_pixels = _glewSearchExtension("GL_EXT_packed_pixels", extStart, extEnd); #endif /* GL_EXT_packed_pixels */ #ifdef GL_EXT_paletted_texture GLEW_EXT_paletted_texture = _glewSearchExtension("GL_EXT_paletted_texture", extStart, extEnd); if (glewExperimental || GLEW_EXT_paletted_texture) GLEW_EXT_paletted_texture = !_glewInit_GL_EXT_paletted_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_paletted_texture */ #ifdef GL_EXT_pixel_buffer_object GLEW_EXT_pixel_buffer_object = _glewSearchExtension("GL_EXT_pixel_buffer_object", extStart, extEnd); #endif /* GL_EXT_pixel_buffer_object */ #ifdef GL_EXT_pixel_transform GLEW_EXT_pixel_transform = _glewSearchExtension("GL_EXT_pixel_transform", extStart, extEnd); if (glewExperimental || GLEW_EXT_pixel_transform) GLEW_EXT_pixel_transform = !_glewInit_GL_EXT_pixel_transform(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_pixel_transform */ #ifdef GL_EXT_pixel_transform_color_table GLEW_EXT_pixel_transform_color_table = _glewSearchExtension("GL_EXT_pixel_transform_color_table", extStart, extEnd); #endif /* GL_EXT_pixel_transform_color_table */ #ifdef GL_EXT_point_parameters GLEW_EXT_point_parameters = _glewSearchExtension("GL_EXT_point_parameters", extStart, extEnd); if (glewExperimental || GLEW_EXT_point_parameters) GLEW_EXT_point_parameters = !_glewInit_GL_EXT_point_parameters(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_point_parameters */ #ifdef GL_EXT_polygon_offset GLEW_EXT_polygon_offset = _glewSearchExtension("GL_EXT_polygon_offset", extStart, extEnd); if (glewExperimental || GLEW_EXT_polygon_offset) GLEW_EXT_polygon_offset = !_glewInit_GL_EXT_polygon_offset(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_polygon_offset */ #ifdef GL_EXT_polygon_offset_clamp GLEW_EXT_polygon_offset_clamp = _glewSearchExtension("GL_EXT_polygon_offset_clamp", extStart, extEnd); if (glewExperimental || GLEW_EXT_polygon_offset_clamp) GLEW_EXT_polygon_offset_clamp = !_glewInit_GL_EXT_polygon_offset_clamp(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_polygon_offset_clamp */ #ifdef GL_EXT_post_depth_coverage GLEW_EXT_post_depth_coverage = _glewSearchExtension("GL_EXT_post_depth_coverage", extStart, extEnd); #endif /* GL_EXT_post_depth_coverage */ #ifdef GL_EXT_provoking_vertex GLEW_EXT_provoking_vertex = _glewSearchExtension("GL_EXT_provoking_vertex", extStart, extEnd); if (glewExperimental || GLEW_EXT_provoking_vertex) GLEW_EXT_provoking_vertex = !_glewInit_GL_EXT_provoking_vertex(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_provoking_vertex */ #ifdef GL_EXT_raster_multisample GLEW_EXT_raster_multisample = _glewSearchExtension("GL_EXT_raster_multisample", extStart, extEnd); if (glewExperimental || GLEW_EXT_raster_multisample) GLEW_EXT_raster_multisample = !_glewInit_GL_EXT_raster_multisample(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_raster_multisample */ #ifdef GL_EXT_rescale_normal GLEW_EXT_rescale_normal = _glewSearchExtension("GL_EXT_rescale_normal", extStart, extEnd); #endif /* GL_EXT_rescale_normal */ #ifdef GL_EXT_scene_marker GLEW_EXT_scene_marker = _glewSearchExtension("GL_EXT_scene_marker", extStart, extEnd); if (glewExperimental || GLEW_EXT_scene_marker) GLEW_EXT_scene_marker = !_glewInit_GL_EXT_scene_marker(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_scene_marker */ #ifdef GL_EXT_secondary_color GLEW_EXT_secondary_color = _glewSearchExtension("GL_EXT_secondary_color", extStart, extEnd); if (glewExperimental || GLEW_EXT_secondary_color) GLEW_EXT_secondary_color = !_glewInit_GL_EXT_secondary_color(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_secondary_color */ #ifdef GL_EXT_separate_shader_objects GLEW_EXT_separate_shader_objects = _glewSearchExtension("GL_EXT_separate_shader_objects", extStart, extEnd); if (glewExperimental || GLEW_EXT_separate_shader_objects) GLEW_EXT_separate_shader_objects = !_glewInit_GL_EXT_separate_shader_objects(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_separate_shader_objects */ #ifdef GL_EXT_separate_specular_color GLEW_EXT_separate_specular_color = _glewSearchExtension("GL_EXT_separate_specular_color", extStart, extEnd); #endif /* GL_EXT_separate_specular_color */ #ifdef GL_EXT_shader_image_load_formatted GLEW_EXT_shader_image_load_formatted = _glewSearchExtension("GL_EXT_shader_image_load_formatted", extStart, extEnd); #endif /* GL_EXT_shader_image_load_formatted */ #ifdef GL_EXT_shader_image_load_store GLEW_EXT_shader_image_load_store = _glewSearchExtension("GL_EXT_shader_image_load_store", extStart, extEnd); if (glewExperimental || GLEW_EXT_shader_image_load_store) GLEW_EXT_shader_image_load_store = !_glewInit_GL_EXT_shader_image_load_store(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_shader_image_load_store */ #ifdef GL_EXT_shader_integer_mix GLEW_EXT_shader_integer_mix = _glewSearchExtension("GL_EXT_shader_integer_mix", extStart, extEnd); #endif /* GL_EXT_shader_integer_mix */ #ifdef GL_EXT_shadow_funcs GLEW_EXT_shadow_funcs = _glewSearchExtension("GL_EXT_shadow_funcs", extStart, extEnd); #endif /* GL_EXT_shadow_funcs */ #ifdef GL_EXT_shared_texture_palette GLEW_EXT_shared_texture_palette = _glewSearchExtension("GL_EXT_shared_texture_palette", extStart, extEnd); #endif /* GL_EXT_shared_texture_palette */ #ifdef GL_EXT_sparse_texture2 GLEW_EXT_sparse_texture2 = _glewSearchExtension("GL_EXT_sparse_texture2", extStart, extEnd); #endif /* GL_EXT_sparse_texture2 */ #ifdef GL_EXT_stencil_clear_tag GLEW_EXT_stencil_clear_tag = _glewSearchExtension("GL_EXT_stencil_clear_tag", extStart, extEnd); #endif /* GL_EXT_stencil_clear_tag */ #ifdef GL_EXT_stencil_two_side GLEW_EXT_stencil_two_side = _glewSearchExtension("GL_EXT_stencil_two_side", extStart, extEnd); if (glewExperimental || GLEW_EXT_stencil_two_side) GLEW_EXT_stencil_two_side = !_glewInit_GL_EXT_stencil_two_side(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_stencil_two_side */ #ifdef GL_EXT_stencil_wrap GLEW_EXT_stencil_wrap = _glewSearchExtension("GL_EXT_stencil_wrap", extStart, extEnd); #endif /* GL_EXT_stencil_wrap */ #ifdef GL_EXT_subtexture GLEW_EXT_subtexture = _glewSearchExtension("GL_EXT_subtexture", extStart, extEnd); if (glewExperimental || GLEW_EXT_subtexture) GLEW_EXT_subtexture = !_glewInit_GL_EXT_subtexture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_subtexture */ #ifdef GL_EXT_texture GLEW_EXT_texture = _glewSearchExtension("GL_EXT_texture", extStart, extEnd); #endif /* GL_EXT_texture */ #ifdef GL_EXT_texture3D GLEW_EXT_texture3D = _glewSearchExtension("GL_EXT_texture3D", extStart, extEnd); if (glewExperimental || GLEW_EXT_texture3D) GLEW_EXT_texture3D = !_glewInit_GL_EXT_texture3D(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_texture3D */ #ifdef GL_EXT_texture_array GLEW_EXT_texture_array = _glewSearchExtension("GL_EXT_texture_array", extStart, extEnd); if (glewExperimental || GLEW_EXT_texture_array) GLEW_EXT_texture_array = !_glewInit_GL_EXT_texture_array(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_texture_array */ #ifdef GL_EXT_texture_buffer_object GLEW_EXT_texture_buffer_object = _glewSearchExtension("GL_EXT_texture_buffer_object", extStart, extEnd); if (glewExperimental || GLEW_EXT_texture_buffer_object) GLEW_EXT_texture_buffer_object = !_glewInit_GL_EXT_texture_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_texture_buffer_object */ #ifdef GL_EXT_texture_compression_dxt1 GLEW_EXT_texture_compression_dxt1 = _glewSearchExtension("GL_EXT_texture_compression_dxt1", extStart, extEnd); #endif /* GL_EXT_texture_compression_dxt1 */ #ifdef GL_EXT_texture_compression_latc GLEW_EXT_texture_compression_latc = _glewSearchExtension("GL_EXT_texture_compression_latc", extStart, extEnd); #endif /* GL_EXT_texture_compression_latc */ #ifdef GL_EXT_texture_compression_rgtc GLEW_EXT_texture_compression_rgtc = _glewSearchExtension("GL_EXT_texture_compression_rgtc", extStart, extEnd); #endif /* GL_EXT_texture_compression_rgtc */ #ifdef GL_EXT_texture_compression_s3tc GLEW_EXT_texture_compression_s3tc = _glewSearchExtension("GL_EXT_texture_compression_s3tc", extStart, extEnd); #endif /* GL_EXT_texture_compression_s3tc */ #ifdef GL_EXT_texture_cube_map GLEW_EXT_texture_cube_map = _glewSearchExtension("GL_EXT_texture_cube_map", extStart, extEnd); #endif /* GL_EXT_texture_cube_map */ #ifdef GL_EXT_texture_edge_clamp GLEW_EXT_texture_edge_clamp = _glewSearchExtension("GL_EXT_texture_edge_clamp", extStart, extEnd); #endif /* GL_EXT_texture_edge_clamp */ #ifdef GL_EXT_texture_env GLEW_EXT_texture_env = _glewSearchExtension("GL_EXT_texture_env", extStart, extEnd); #endif /* GL_EXT_texture_env */ #ifdef GL_EXT_texture_env_add GLEW_EXT_texture_env_add = _glewSearchExtension("GL_EXT_texture_env_add", extStart, extEnd); #endif /* GL_EXT_texture_env_add */ #ifdef GL_EXT_texture_env_combine GLEW_EXT_texture_env_combine = _glewSearchExtension("GL_EXT_texture_env_combine", extStart, extEnd); #endif /* GL_EXT_texture_env_combine */ #ifdef GL_EXT_texture_env_dot3 GLEW_EXT_texture_env_dot3 = _glewSearchExtension("GL_EXT_texture_env_dot3", extStart, extEnd); #endif /* GL_EXT_texture_env_dot3 */ #ifdef GL_EXT_texture_filter_anisotropic GLEW_EXT_texture_filter_anisotropic = _glewSearchExtension("GL_EXT_texture_filter_anisotropic", extStart, extEnd); #endif /* GL_EXT_texture_filter_anisotropic */ #ifdef GL_EXT_texture_filter_minmax GLEW_EXT_texture_filter_minmax = _glewSearchExtension("GL_EXT_texture_filter_minmax", extStart, extEnd); #endif /* GL_EXT_texture_filter_minmax */ #ifdef GL_EXT_texture_integer GLEW_EXT_texture_integer = _glewSearchExtension("GL_EXT_texture_integer", extStart, extEnd); if (glewExperimental || GLEW_EXT_texture_integer) GLEW_EXT_texture_integer = !_glewInit_GL_EXT_texture_integer(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_texture_integer */ #ifdef GL_EXT_texture_lod_bias GLEW_EXT_texture_lod_bias = _glewSearchExtension("GL_EXT_texture_lod_bias", extStart, extEnd); #endif /* GL_EXT_texture_lod_bias */ #ifdef GL_EXT_texture_mirror_clamp GLEW_EXT_texture_mirror_clamp = _glewSearchExtension("GL_EXT_texture_mirror_clamp", extStart, extEnd); #endif /* GL_EXT_texture_mirror_clamp */ #ifdef GL_EXT_texture_object GLEW_EXT_texture_object = _glewSearchExtension("GL_EXT_texture_object", extStart, extEnd); if (glewExperimental || GLEW_EXT_texture_object) GLEW_EXT_texture_object = !_glewInit_GL_EXT_texture_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_texture_object */ #ifdef GL_EXT_texture_perturb_normal GLEW_EXT_texture_perturb_normal = _glewSearchExtension("GL_EXT_texture_perturb_normal", extStart, extEnd); if (glewExperimental || GLEW_EXT_texture_perturb_normal) GLEW_EXT_texture_perturb_normal = !_glewInit_GL_EXT_texture_perturb_normal(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_texture_perturb_normal */ #ifdef GL_EXT_texture_rectangle GLEW_EXT_texture_rectangle = _glewSearchExtension("GL_EXT_texture_rectangle", extStart, extEnd); #endif /* GL_EXT_texture_rectangle */ #ifdef GL_EXT_texture_sRGB GLEW_EXT_texture_sRGB = _glewSearchExtension("GL_EXT_texture_sRGB", extStart, extEnd); #endif /* GL_EXT_texture_sRGB */ #ifdef GL_EXT_texture_sRGB_decode GLEW_EXT_texture_sRGB_decode = _glewSearchExtension("GL_EXT_texture_sRGB_decode", extStart, extEnd); #endif /* GL_EXT_texture_sRGB_decode */ #ifdef GL_EXT_texture_shared_exponent GLEW_EXT_texture_shared_exponent = _glewSearchExtension("GL_EXT_texture_shared_exponent", extStart, extEnd); #endif /* GL_EXT_texture_shared_exponent */ #ifdef GL_EXT_texture_snorm GLEW_EXT_texture_snorm = _glewSearchExtension("GL_EXT_texture_snorm", extStart, extEnd); #endif /* GL_EXT_texture_snorm */ #ifdef GL_EXT_texture_swizzle GLEW_EXT_texture_swizzle = _glewSearchExtension("GL_EXT_texture_swizzle", extStart, extEnd); #endif /* GL_EXT_texture_swizzle */ #ifdef GL_EXT_timer_query GLEW_EXT_timer_query = _glewSearchExtension("GL_EXT_timer_query", extStart, extEnd); if (glewExperimental || GLEW_EXT_timer_query) GLEW_EXT_timer_query = !_glewInit_GL_EXT_timer_query(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_timer_query */ #ifdef GL_EXT_transform_feedback GLEW_EXT_transform_feedback = _glewSearchExtension("GL_EXT_transform_feedback", extStart, extEnd); if (glewExperimental || GLEW_EXT_transform_feedback) GLEW_EXT_transform_feedback = !_glewInit_GL_EXT_transform_feedback(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_transform_feedback */ #ifdef GL_EXT_vertex_array GLEW_EXT_vertex_array = _glewSearchExtension("GL_EXT_vertex_array", extStart, extEnd); if (glewExperimental || GLEW_EXT_vertex_array) GLEW_EXT_vertex_array = !_glewInit_GL_EXT_vertex_array(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_vertex_array */ #ifdef GL_EXT_vertex_array_bgra GLEW_EXT_vertex_array_bgra = _glewSearchExtension("GL_EXT_vertex_array_bgra", extStart, extEnd); #endif /* GL_EXT_vertex_array_bgra */ #ifdef GL_EXT_vertex_attrib_64bit GLEW_EXT_vertex_attrib_64bit = _glewSearchExtension("GL_EXT_vertex_attrib_64bit", extStart, extEnd); if (glewExperimental || GLEW_EXT_vertex_attrib_64bit) GLEW_EXT_vertex_attrib_64bit = !_glewInit_GL_EXT_vertex_attrib_64bit(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_vertex_attrib_64bit */ #ifdef GL_EXT_vertex_shader GLEW_EXT_vertex_shader = _glewSearchExtension("GL_EXT_vertex_shader", extStart, extEnd); if (glewExperimental || GLEW_EXT_vertex_shader) GLEW_EXT_vertex_shader = !_glewInit_GL_EXT_vertex_shader(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_vertex_shader */ #ifdef GL_EXT_vertex_weighting GLEW_EXT_vertex_weighting = _glewSearchExtension("GL_EXT_vertex_weighting", extStart, extEnd); if (glewExperimental || GLEW_EXT_vertex_weighting) GLEW_EXT_vertex_weighting = !_glewInit_GL_EXT_vertex_weighting(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_vertex_weighting */ #ifdef GL_EXT_x11_sync_object GLEW_EXT_x11_sync_object = _glewSearchExtension("GL_EXT_x11_sync_object", extStart, extEnd); if (glewExperimental || GLEW_EXT_x11_sync_object) GLEW_EXT_x11_sync_object = !_glewInit_GL_EXT_x11_sync_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_EXT_x11_sync_object */ #ifdef GL_GREMEDY_frame_terminator GLEW_GREMEDY_frame_terminator = _glewSearchExtension("GL_GREMEDY_frame_terminator", extStart, extEnd); if (glewExperimental || GLEW_GREMEDY_frame_terminator) GLEW_GREMEDY_frame_terminator = !_glewInit_GL_GREMEDY_frame_terminator(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_GREMEDY_frame_terminator */ #ifdef GL_GREMEDY_string_marker GLEW_GREMEDY_string_marker = _glewSearchExtension("GL_GREMEDY_string_marker", extStart, extEnd); if (glewExperimental || GLEW_GREMEDY_string_marker) GLEW_GREMEDY_string_marker = !_glewInit_GL_GREMEDY_string_marker(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_GREMEDY_string_marker */ #ifdef GL_HP_convolution_border_modes GLEW_HP_convolution_border_modes = _glewSearchExtension("GL_HP_convolution_border_modes", extStart, extEnd); #endif /* GL_HP_convolution_border_modes */ #ifdef GL_HP_image_transform GLEW_HP_image_transform = _glewSearchExtension("GL_HP_image_transform", extStart, extEnd); if (glewExperimental || GLEW_HP_image_transform) GLEW_HP_image_transform = !_glewInit_GL_HP_image_transform(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_HP_image_transform */ #ifdef GL_HP_occlusion_test GLEW_HP_occlusion_test = _glewSearchExtension("GL_HP_occlusion_test", extStart, extEnd); #endif /* GL_HP_occlusion_test */ #ifdef GL_HP_texture_lighting GLEW_HP_texture_lighting = _glewSearchExtension("GL_HP_texture_lighting", extStart, extEnd); #endif /* GL_HP_texture_lighting */ #ifdef GL_IBM_cull_vertex GLEW_IBM_cull_vertex = _glewSearchExtension("GL_IBM_cull_vertex", extStart, extEnd); #endif /* GL_IBM_cull_vertex */ #ifdef GL_IBM_multimode_draw_arrays GLEW_IBM_multimode_draw_arrays = _glewSearchExtension("GL_IBM_multimode_draw_arrays", extStart, extEnd); if (glewExperimental || GLEW_IBM_multimode_draw_arrays) GLEW_IBM_multimode_draw_arrays = !_glewInit_GL_IBM_multimode_draw_arrays(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_IBM_multimode_draw_arrays */ #ifdef GL_IBM_rasterpos_clip GLEW_IBM_rasterpos_clip = _glewSearchExtension("GL_IBM_rasterpos_clip", extStart, extEnd); #endif /* GL_IBM_rasterpos_clip */ #ifdef GL_IBM_static_data GLEW_IBM_static_data = _glewSearchExtension("GL_IBM_static_data", extStart, extEnd); #endif /* GL_IBM_static_data */ #ifdef GL_IBM_texture_mirrored_repeat GLEW_IBM_texture_mirrored_repeat = _glewSearchExtension("GL_IBM_texture_mirrored_repeat", extStart, extEnd); #endif /* GL_IBM_texture_mirrored_repeat */ #ifdef GL_IBM_vertex_array_lists GLEW_IBM_vertex_array_lists = _glewSearchExtension("GL_IBM_vertex_array_lists", extStart, extEnd); if (glewExperimental || GLEW_IBM_vertex_array_lists) GLEW_IBM_vertex_array_lists = !_glewInit_GL_IBM_vertex_array_lists(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_IBM_vertex_array_lists */ #ifdef GL_INGR_color_clamp GLEW_INGR_color_clamp = _glewSearchExtension("GL_INGR_color_clamp", extStart, extEnd); #endif /* GL_INGR_color_clamp */ #ifdef GL_INGR_interlace_read GLEW_INGR_interlace_read = _glewSearchExtension("GL_INGR_interlace_read", extStart, extEnd); #endif /* GL_INGR_interlace_read */ #ifdef GL_INTEL_fragment_shader_ordering GLEW_INTEL_fragment_shader_ordering = _glewSearchExtension("GL_INTEL_fragment_shader_ordering", extStart, extEnd); #endif /* GL_INTEL_fragment_shader_ordering */ #ifdef GL_INTEL_framebuffer_CMAA GLEW_INTEL_framebuffer_CMAA = _glewSearchExtension("GL_INTEL_framebuffer_CMAA", extStart, extEnd); #endif /* GL_INTEL_framebuffer_CMAA */ #ifdef GL_INTEL_map_texture GLEW_INTEL_map_texture = _glewSearchExtension("GL_INTEL_map_texture", extStart, extEnd); if (glewExperimental || GLEW_INTEL_map_texture) GLEW_INTEL_map_texture = !_glewInit_GL_INTEL_map_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_INTEL_map_texture */ #ifdef GL_INTEL_parallel_arrays GLEW_INTEL_parallel_arrays = _glewSearchExtension("GL_INTEL_parallel_arrays", extStart, extEnd); if (glewExperimental || GLEW_INTEL_parallel_arrays) GLEW_INTEL_parallel_arrays = !_glewInit_GL_INTEL_parallel_arrays(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_INTEL_parallel_arrays */ #ifdef GL_INTEL_performance_query GLEW_INTEL_performance_query = _glewSearchExtension("GL_INTEL_performance_query", extStart, extEnd); if (glewExperimental || GLEW_INTEL_performance_query) GLEW_INTEL_performance_query = !_glewInit_GL_INTEL_performance_query(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_INTEL_performance_query */ #ifdef GL_INTEL_texture_scissor GLEW_INTEL_texture_scissor = _glewSearchExtension("GL_INTEL_texture_scissor", extStart, extEnd); if (glewExperimental || GLEW_INTEL_texture_scissor) GLEW_INTEL_texture_scissor = !_glewInit_GL_INTEL_texture_scissor(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_INTEL_texture_scissor */ #ifdef GL_KHR_blend_equation_advanced GLEW_KHR_blend_equation_advanced = _glewSearchExtension("GL_KHR_blend_equation_advanced", extStart, extEnd); if (glewExperimental || GLEW_KHR_blend_equation_advanced) GLEW_KHR_blend_equation_advanced = !_glewInit_GL_KHR_blend_equation_advanced(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_KHR_blend_equation_advanced */ #ifdef GL_KHR_blend_equation_advanced_coherent GLEW_KHR_blend_equation_advanced_coherent = _glewSearchExtension("GL_KHR_blend_equation_advanced_coherent", extStart, extEnd); #endif /* GL_KHR_blend_equation_advanced_coherent */ #ifdef GL_KHR_context_flush_control GLEW_KHR_context_flush_control = _glewSearchExtension("GL_KHR_context_flush_control", extStart, extEnd); #endif /* GL_KHR_context_flush_control */ #ifdef GL_KHR_debug GLEW_KHR_debug = _glewSearchExtension("GL_KHR_debug", extStart, extEnd); if (glewExperimental || GLEW_KHR_debug) GLEW_KHR_debug = !_glewInit_GL_KHR_debug(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_KHR_debug */ #ifdef GL_KHR_no_error GLEW_KHR_no_error = _glewSearchExtension("GL_KHR_no_error", extStart, extEnd); #endif /* GL_KHR_no_error */ #ifdef GL_KHR_robust_buffer_access_behavior GLEW_KHR_robust_buffer_access_behavior = _glewSearchExtension("GL_KHR_robust_buffer_access_behavior", extStart, extEnd); #endif /* GL_KHR_robust_buffer_access_behavior */ #ifdef GL_KHR_robustness GLEW_KHR_robustness = _glewSearchExtension("GL_KHR_robustness", extStart, extEnd); if (glewExperimental || GLEW_KHR_robustness) GLEW_KHR_robustness = !_glewInit_GL_KHR_robustness(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_KHR_robustness */ #ifdef GL_KHR_texture_compression_astc_hdr GLEW_KHR_texture_compression_astc_hdr = _glewSearchExtension("GL_KHR_texture_compression_astc_hdr", extStart, extEnd); #endif /* GL_KHR_texture_compression_astc_hdr */ #ifdef GL_KHR_texture_compression_astc_ldr GLEW_KHR_texture_compression_astc_ldr = _glewSearchExtension("GL_KHR_texture_compression_astc_ldr", extStart, extEnd); #endif /* GL_KHR_texture_compression_astc_ldr */ #ifdef GL_KTX_buffer_region GLEW_KTX_buffer_region = _glewSearchExtension("GL_KTX_buffer_region", extStart, extEnd); if (glewExperimental || GLEW_KTX_buffer_region) GLEW_KTX_buffer_region = !_glewInit_GL_KTX_buffer_region(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_KTX_buffer_region */ #ifdef GL_MESAX_texture_stack GLEW_MESAX_texture_stack = _glewSearchExtension("GL_MESAX_texture_stack", extStart, extEnd); #endif /* GL_MESAX_texture_stack */ #ifdef GL_MESA_pack_invert GLEW_MESA_pack_invert = _glewSearchExtension("GL_MESA_pack_invert", extStart, extEnd); #endif /* GL_MESA_pack_invert */ #ifdef GL_MESA_resize_buffers GLEW_MESA_resize_buffers = _glewSearchExtension("GL_MESA_resize_buffers", extStart, extEnd); if (glewExperimental || GLEW_MESA_resize_buffers) GLEW_MESA_resize_buffers = !_glewInit_GL_MESA_resize_buffers(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_MESA_resize_buffers */ #ifdef GL_MESA_window_pos GLEW_MESA_window_pos = _glewSearchExtension("GL_MESA_window_pos", extStart, extEnd); if (glewExperimental || GLEW_MESA_window_pos) GLEW_MESA_window_pos = !_glewInit_GL_MESA_window_pos(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_MESA_window_pos */ #ifdef GL_MESA_ycbcr_texture GLEW_MESA_ycbcr_texture = _glewSearchExtension("GL_MESA_ycbcr_texture", extStart, extEnd); #endif /* GL_MESA_ycbcr_texture */ #ifdef GL_NVX_conditional_render GLEW_NVX_conditional_render = _glewSearchExtension("GL_NVX_conditional_render", extStart, extEnd); if (glewExperimental || GLEW_NVX_conditional_render) GLEW_NVX_conditional_render = !_glewInit_GL_NVX_conditional_render(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NVX_conditional_render */ #ifdef GL_NVX_gpu_memory_info GLEW_NVX_gpu_memory_info = _glewSearchExtension("GL_NVX_gpu_memory_info", extStart, extEnd); #endif /* GL_NVX_gpu_memory_info */ #ifdef GL_NV_bindless_multi_draw_indirect GLEW_NV_bindless_multi_draw_indirect = _glewSearchExtension("GL_NV_bindless_multi_draw_indirect", extStart, extEnd); if (glewExperimental || GLEW_NV_bindless_multi_draw_indirect) GLEW_NV_bindless_multi_draw_indirect = !_glewInit_GL_NV_bindless_multi_draw_indirect(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_bindless_multi_draw_indirect */ #ifdef GL_NV_bindless_multi_draw_indirect_count GLEW_NV_bindless_multi_draw_indirect_count = _glewSearchExtension("GL_NV_bindless_multi_draw_indirect_count", extStart, extEnd); if (glewExperimental || GLEW_NV_bindless_multi_draw_indirect_count) GLEW_NV_bindless_multi_draw_indirect_count = !_glewInit_GL_NV_bindless_multi_draw_indirect_count(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_bindless_multi_draw_indirect_count */ #ifdef GL_NV_bindless_texture GLEW_NV_bindless_texture = _glewSearchExtension("GL_NV_bindless_texture", extStart, extEnd); if (glewExperimental || GLEW_NV_bindless_texture) GLEW_NV_bindless_texture = !_glewInit_GL_NV_bindless_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_bindless_texture */ #ifdef GL_NV_blend_equation_advanced GLEW_NV_blend_equation_advanced = _glewSearchExtension("GL_NV_blend_equation_advanced", extStart, extEnd); if (glewExperimental || GLEW_NV_blend_equation_advanced) GLEW_NV_blend_equation_advanced = !_glewInit_GL_NV_blend_equation_advanced(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_blend_equation_advanced */ #ifdef GL_NV_blend_equation_advanced_coherent GLEW_NV_blend_equation_advanced_coherent = _glewSearchExtension("GL_NV_blend_equation_advanced_coherent", extStart, extEnd); #endif /* GL_NV_blend_equation_advanced_coherent */ #ifdef GL_NV_blend_square GLEW_NV_blend_square = _glewSearchExtension("GL_NV_blend_square", extStart, extEnd); #endif /* GL_NV_blend_square */ #ifdef GL_NV_compute_program5 GLEW_NV_compute_program5 = _glewSearchExtension("GL_NV_compute_program5", extStart, extEnd); #endif /* GL_NV_compute_program5 */ #ifdef GL_NV_conditional_render GLEW_NV_conditional_render = _glewSearchExtension("GL_NV_conditional_render", extStart, extEnd); if (glewExperimental || GLEW_NV_conditional_render) GLEW_NV_conditional_render = !_glewInit_GL_NV_conditional_render(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_conditional_render */ #ifdef GL_NV_conservative_raster GLEW_NV_conservative_raster = _glewSearchExtension("GL_NV_conservative_raster", extStart, extEnd); if (glewExperimental || GLEW_NV_conservative_raster) GLEW_NV_conservative_raster = !_glewInit_GL_NV_conservative_raster(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_conservative_raster */ #ifdef GL_NV_conservative_raster_dilate GLEW_NV_conservative_raster_dilate = _glewSearchExtension("GL_NV_conservative_raster_dilate", extStart, extEnd); if (glewExperimental || GLEW_NV_conservative_raster_dilate) GLEW_NV_conservative_raster_dilate = !_glewInit_GL_NV_conservative_raster_dilate(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_conservative_raster_dilate */ #ifdef GL_NV_copy_depth_to_color GLEW_NV_copy_depth_to_color = _glewSearchExtension("GL_NV_copy_depth_to_color", extStart, extEnd); #endif /* GL_NV_copy_depth_to_color */ #ifdef GL_NV_copy_image GLEW_NV_copy_image = _glewSearchExtension("GL_NV_copy_image", extStart, extEnd); if (glewExperimental || GLEW_NV_copy_image) GLEW_NV_copy_image = !_glewInit_GL_NV_copy_image(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_copy_image */ #ifdef GL_NV_deep_texture3D GLEW_NV_deep_texture3D = _glewSearchExtension("GL_NV_deep_texture3D", extStart, extEnd); #endif /* GL_NV_deep_texture3D */ #ifdef GL_NV_depth_buffer_float GLEW_NV_depth_buffer_float = _glewSearchExtension("GL_NV_depth_buffer_float", extStart, extEnd); if (glewExperimental || GLEW_NV_depth_buffer_float) GLEW_NV_depth_buffer_float = !_glewInit_GL_NV_depth_buffer_float(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_depth_buffer_float */ #ifdef GL_NV_depth_clamp GLEW_NV_depth_clamp = _glewSearchExtension("GL_NV_depth_clamp", extStart, extEnd); #endif /* GL_NV_depth_clamp */ #ifdef GL_NV_depth_range_unclamped GLEW_NV_depth_range_unclamped = _glewSearchExtension("GL_NV_depth_range_unclamped", extStart, extEnd); #endif /* GL_NV_depth_range_unclamped */ #ifdef GL_NV_draw_texture GLEW_NV_draw_texture = _glewSearchExtension("GL_NV_draw_texture", extStart, extEnd); if (glewExperimental || GLEW_NV_draw_texture) GLEW_NV_draw_texture = !_glewInit_GL_NV_draw_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_draw_texture */ #ifdef GL_NV_evaluators GLEW_NV_evaluators = _glewSearchExtension("GL_NV_evaluators", extStart, extEnd); if (glewExperimental || GLEW_NV_evaluators) GLEW_NV_evaluators = !_glewInit_GL_NV_evaluators(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_evaluators */ #ifdef GL_NV_explicit_multisample GLEW_NV_explicit_multisample = _glewSearchExtension("GL_NV_explicit_multisample", extStart, extEnd); if (glewExperimental || GLEW_NV_explicit_multisample) GLEW_NV_explicit_multisample = !_glewInit_GL_NV_explicit_multisample(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_explicit_multisample */ #ifdef GL_NV_fence GLEW_NV_fence = _glewSearchExtension("GL_NV_fence", extStart, extEnd); if (glewExperimental || GLEW_NV_fence) GLEW_NV_fence = !_glewInit_GL_NV_fence(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_fence */ #ifdef GL_NV_fill_rectangle GLEW_NV_fill_rectangle = _glewSearchExtension("GL_NV_fill_rectangle", extStart, extEnd); #endif /* GL_NV_fill_rectangle */ #ifdef GL_NV_float_buffer GLEW_NV_float_buffer = _glewSearchExtension("GL_NV_float_buffer", extStart, extEnd); #endif /* GL_NV_float_buffer */ #ifdef GL_NV_fog_distance GLEW_NV_fog_distance = _glewSearchExtension("GL_NV_fog_distance", extStart, extEnd); #endif /* GL_NV_fog_distance */ #ifdef GL_NV_fragment_coverage_to_color GLEW_NV_fragment_coverage_to_color = _glewSearchExtension("GL_NV_fragment_coverage_to_color", extStart, extEnd); if (glewExperimental || GLEW_NV_fragment_coverage_to_color) GLEW_NV_fragment_coverage_to_color = !_glewInit_GL_NV_fragment_coverage_to_color(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_fragment_coverage_to_color */ #ifdef GL_NV_fragment_program GLEW_NV_fragment_program = _glewSearchExtension("GL_NV_fragment_program", extStart, extEnd); if (glewExperimental || GLEW_NV_fragment_program) GLEW_NV_fragment_program = !_glewInit_GL_NV_fragment_program(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_fragment_program */ #ifdef GL_NV_fragment_program2 GLEW_NV_fragment_program2 = _glewSearchExtension("GL_NV_fragment_program2", extStart, extEnd); #endif /* GL_NV_fragment_program2 */ #ifdef GL_NV_fragment_program4 GLEW_NV_fragment_program4 = _glewSearchExtension("GL_NV_gpu_program4", extStart, extEnd); #endif /* GL_NV_fragment_program4 */ #ifdef GL_NV_fragment_program_option GLEW_NV_fragment_program_option = _glewSearchExtension("GL_NV_fragment_program_option", extStart, extEnd); #endif /* GL_NV_fragment_program_option */ #ifdef GL_NV_fragment_shader_interlock GLEW_NV_fragment_shader_interlock = _glewSearchExtension("GL_NV_fragment_shader_interlock", extStart, extEnd); #endif /* GL_NV_fragment_shader_interlock */ #ifdef GL_NV_framebuffer_mixed_samples GLEW_NV_framebuffer_mixed_samples = _glewSearchExtension("GL_NV_framebuffer_mixed_samples", extStart, extEnd); #endif /* GL_NV_framebuffer_mixed_samples */ #ifdef GL_NV_framebuffer_multisample_coverage GLEW_NV_framebuffer_multisample_coverage = _glewSearchExtension("GL_NV_framebuffer_multisample_coverage", extStart, extEnd); if (glewExperimental || GLEW_NV_framebuffer_multisample_coverage) GLEW_NV_framebuffer_multisample_coverage = !_glewInit_GL_NV_framebuffer_multisample_coverage(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_framebuffer_multisample_coverage */ #ifdef GL_NV_geometry_program4 GLEW_NV_geometry_program4 = _glewSearchExtension("GL_NV_gpu_program4", extStart, extEnd); if (glewExperimental || GLEW_NV_geometry_program4) GLEW_NV_geometry_program4 = !_glewInit_GL_NV_geometry_program4(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_geometry_program4 */ #ifdef GL_NV_geometry_shader4 GLEW_NV_geometry_shader4 = _glewSearchExtension("GL_NV_geometry_shader4", extStart, extEnd); #endif /* GL_NV_geometry_shader4 */ #ifdef GL_NV_geometry_shader_passthrough GLEW_NV_geometry_shader_passthrough = _glewSearchExtension("GL_NV_geometry_shader_passthrough", extStart, extEnd); #endif /* GL_NV_geometry_shader_passthrough */ #ifdef GL_NV_gpu_program4 GLEW_NV_gpu_program4 = _glewSearchExtension("GL_NV_gpu_program4", extStart, extEnd); if (glewExperimental || GLEW_NV_gpu_program4) GLEW_NV_gpu_program4 = !_glewInit_GL_NV_gpu_program4(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_gpu_program4 */ #ifdef GL_NV_gpu_program5 GLEW_NV_gpu_program5 = _glewSearchExtension("GL_NV_gpu_program5", extStart, extEnd); #endif /* GL_NV_gpu_program5 */ #ifdef GL_NV_gpu_program5_mem_extended GLEW_NV_gpu_program5_mem_extended = _glewSearchExtension("GL_NV_gpu_program5_mem_extended", extStart, extEnd); #endif /* GL_NV_gpu_program5_mem_extended */ #ifdef GL_NV_gpu_program_fp64 GLEW_NV_gpu_program_fp64 = _glewSearchExtension("GL_NV_gpu_program_fp64", extStart, extEnd); #endif /* GL_NV_gpu_program_fp64 */ #ifdef GL_NV_gpu_shader5 GLEW_NV_gpu_shader5 = _glewSearchExtension("GL_NV_gpu_shader5", extStart, extEnd); if (glewExperimental || GLEW_NV_gpu_shader5) GLEW_NV_gpu_shader5 = !_glewInit_GL_NV_gpu_shader5(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_gpu_shader5 */ #ifdef GL_NV_half_float GLEW_NV_half_float = _glewSearchExtension("GL_NV_half_float", extStart, extEnd); if (glewExperimental || GLEW_NV_half_float) GLEW_NV_half_float = !_glewInit_GL_NV_half_float(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_half_float */ #ifdef GL_NV_internalformat_sample_query GLEW_NV_internalformat_sample_query = _glewSearchExtension("GL_NV_internalformat_sample_query", extStart, extEnd); if (glewExperimental || GLEW_NV_internalformat_sample_query) GLEW_NV_internalformat_sample_query = !_glewInit_GL_NV_internalformat_sample_query(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_internalformat_sample_query */ #ifdef GL_NV_light_max_exponent GLEW_NV_light_max_exponent = _glewSearchExtension("GL_NV_light_max_exponent", extStart, extEnd); #endif /* GL_NV_light_max_exponent */ #ifdef GL_NV_multisample_coverage GLEW_NV_multisample_coverage = _glewSearchExtension("GL_NV_multisample_coverage", extStart, extEnd); #endif /* GL_NV_multisample_coverage */ #ifdef GL_NV_multisample_filter_hint GLEW_NV_multisample_filter_hint = _glewSearchExtension("GL_NV_multisample_filter_hint", extStart, extEnd); #endif /* GL_NV_multisample_filter_hint */ #ifdef GL_NV_occlusion_query GLEW_NV_occlusion_query = _glewSearchExtension("GL_NV_occlusion_query", extStart, extEnd); if (glewExperimental || GLEW_NV_occlusion_query) GLEW_NV_occlusion_query = !_glewInit_GL_NV_occlusion_query(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_occlusion_query */ #ifdef GL_NV_packed_depth_stencil GLEW_NV_packed_depth_stencil = _glewSearchExtension("GL_NV_packed_depth_stencil", extStart, extEnd); #endif /* GL_NV_packed_depth_stencil */ #ifdef GL_NV_parameter_buffer_object GLEW_NV_parameter_buffer_object = _glewSearchExtension("GL_NV_parameter_buffer_object", extStart, extEnd); if (glewExperimental || GLEW_NV_parameter_buffer_object) GLEW_NV_parameter_buffer_object = !_glewInit_GL_NV_parameter_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_parameter_buffer_object */ #ifdef GL_NV_parameter_buffer_object2 GLEW_NV_parameter_buffer_object2 = _glewSearchExtension("GL_NV_parameter_buffer_object2", extStart, extEnd); #endif /* GL_NV_parameter_buffer_object2 */ #ifdef GL_NV_path_rendering GLEW_NV_path_rendering = _glewSearchExtension("GL_NV_path_rendering", extStart, extEnd); if (glewExperimental || GLEW_NV_path_rendering) GLEW_NV_path_rendering = !_glewInit_GL_NV_path_rendering(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_path_rendering */ #ifdef GL_NV_path_rendering_shared_edge GLEW_NV_path_rendering_shared_edge = _glewSearchExtension("GL_NV_path_rendering_shared_edge", extStart, extEnd); #endif /* GL_NV_path_rendering_shared_edge */ #ifdef GL_NV_pixel_data_range GLEW_NV_pixel_data_range = _glewSearchExtension("GL_NV_pixel_data_range", extStart, extEnd); if (glewExperimental || GLEW_NV_pixel_data_range) GLEW_NV_pixel_data_range = !_glewInit_GL_NV_pixel_data_range(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_pixel_data_range */ #ifdef GL_NV_point_sprite GLEW_NV_point_sprite = _glewSearchExtension("GL_NV_point_sprite", extStart, extEnd); if (glewExperimental || GLEW_NV_point_sprite) GLEW_NV_point_sprite = !_glewInit_GL_NV_point_sprite(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_point_sprite */ #ifdef GL_NV_present_video GLEW_NV_present_video = _glewSearchExtension("GL_NV_present_video", extStart, extEnd); if (glewExperimental || GLEW_NV_present_video) GLEW_NV_present_video = !_glewInit_GL_NV_present_video(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_present_video */ #ifdef GL_NV_primitive_restart GLEW_NV_primitive_restart = _glewSearchExtension("GL_NV_primitive_restart", extStart, extEnd); if (glewExperimental || GLEW_NV_primitive_restart) GLEW_NV_primitive_restart = !_glewInit_GL_NV_primitive_restart(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_primitive_restart */ #ifdef GL_NV_register_combiners GLEW_NV_register_combiners = _glewSearchExtension("GL_NV_register_combiners", extStart, extEnd); if (glewExperimental || GLEW_NV_register_combiners) GLEW_NV_register_combiners = !_glewInit_GL_NV_register_combiners(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_register_combiners */ #ifdef GL_NV_register_combiners2 GLEW_NV_register_combiners2 = _glewSearchExtension("GL_NV_register_combiners2", extStart, extEnd); if (glewExperimental || GLEW_NV_register_combiners2) GLEW_NV_register_combiners2 = !_glewInit_GL_NV_register_combiners2(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_register_combiners2 */ #ifdef GL_NV_sample_locations GLEW_NV_sample_locations = _glewSearchExtension("GL_NV_sample_locations", extStart, extEnd); if (glewExperimental || GLEW_NV_sample_locations) GLEW_NV_sample_locations = !_glewInit_GL_NV_sample_locations(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_sample_locations */ #ifdef GL_NV_sample_mask_override_coverage GLEW_NV_sample_mask_override_coverage = _glewSearchExtension("GL_NV_sample_mask_override_coverage", extStart, extEnd); #endif /* GL_NV_sample_mask_override_coverage */ #ifdef GL_NV_shader_atomic_counters GLEW_NV_shader_atomic_counters = _glewSearchExtension("GL_NV_shader_atomic_counters", extStart, extEnd); #endif /* GL_NV_shader_atomic_counters */ #ifdef GL_NV_shader_atomic_float GLEW_NV_shader_atomic_float = _glewSearchExtension("GL_NV_shader_atomic_float", extStart, extEnd); #endif /* GL_NV_shader_atomic_float */ #ifdef GL_NV_shader_atomic_fp16_vector GLEW_NV_shader_atomic_fp16_vector = _glewSearchExtension("GL_NV_shader_atomic_fp16_vector", extStart, extEnd); #endif /* GL_NV_shader_atomic_fp16_vector */ #ifdef GL_NV_shader_atomic_int64 GLEW_NV_shader_atomic_int64 = _glewSearchExtension("GL_NV_shader_atomic_int64", extStart, extEnd); #endif /* GL_NV_shader_atomic_int64 */ #ifdef GL_NV_shader_buffer_load GLEW_NV_shader_buffer_load = _glewSearchExtension("GL_NV_shader_buffer_load", extStart, extEnd); if (glewExperimental || GLEW_NV_shader_buffer_load) GLEW_NV_shader_buffer_load = !_glewInit_GL_NV_shader_buffer_load(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_shader_buffer_load */ #ifdef GL_NV_shader_storage_buffer_object GLEW_NV_shader_storage_buffer_object = _glewSearchExtension("GL_NV_shader_storage_buffer_object", extStart, extEnd); #endif /* GL_NV_shader_storage_buffer_object */ #ifdef GL_NV_shader_thread_group GLEW_NV_shader_thread_group = _glewSearchExtension("GL_NV_shader_thread_group", extStart, extEnd); #endif /* GL_NV_shader_thread_group */ #ifdef GL_NV_shader_thread_shuffle GLEW_NV_shader_thread_shuffle = _glewSearchExtension("GL_NV_shader_thread_shuffle", extStart, extEnd); #endif /* GL_NV_shader_thread_shuffle */ #ifdef GL_NV_tessellation_program5 GLEW_NV_tessellation_program5 = _glewSearchExtension("GL_NV_gpu_program5", extStart, extEnd); #endif /* GL_NV_tessellation_program5 */ #ifdef GL_NV_texgen_emboss GLEW_NV_texgen_emboss = _glewSearchExtension("GL_NV_texgen_emboss", extStart, extEnd); #endif /* GL_NV_texgen_emboss */ #ifdef GL_NV_texgen_reflection GLEW_NV_texgen_reflection = _glewSearchExtension("GL_NV_texgen_reflection", extStart, extEnd); #endif /* GL_NV_texgen_reflection */ #ifdef GL_NV_texture_barrier GLEW_NV_texture_barrier = _glewSearchExtension("GL_NV_texture_barrier", extStart, extEnd); if (glewExperimental || GLEW_NV_texture_barrier) GLEW_NV_texture_barrier = !_glewInit_GL_NV_texture_barrier(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_texture_barrier */ #ifdef GL_NV_texture_compression_vtc GLEW_NV_texture_compression_vtc = _glewSearchExtension("GL_NV_texture_compression_vtc", extStart, extEnd); #endif /* GL_NV_texture_compression_vtc */ #ifdef GL_NV_texture_env_combine4 GLEW_NV_texture_env_combine4 = _glewSearchExtension("GL_NV_texture_env_combine4", extStart, extEnd); #endif /* GL_NV_texture_env_combine4 */ #ifdef GL_NV_texture_expand_normal GLEW_NV_texture_expand_normal = _glewSearchExtension("GL_NV_texture_expand_normal", extStart, extEnd); #endif /* GL_NV_texture_expand_normal */ #ifdef GL_NV_texture_multisample GLEW_NV_texture_multisample = _glewSearchExtension("GL_NV_texture_multisample", extStart, extEnd); if (glewExperimental || GLEW_NV_texture_multisample) GLEW_NV_texture_multisample = !_glewInit_GL_NV_texture_multisample(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_texture_multisample */ #ifdef GL_NV_texture_rectangle GLEW_NV_texture_rectangle = _glewSearchExtension("GL_NV_texture_rectangle", extStart, extEnd); #endif /* GL_NV_texture_rectangle */ #ifdef GL_NV_texture_shader GLEW_NV_texture_shader = _glewSearchExtension("GL_NV_texture_shader", extStart, extEnd); #endif /* GL_NV_texture_shader */ #ifdef GL_NV_texture_shader2 GLEW_NV_texture_shader2 = _glewSearchExtension("GL_NV_texture_shader2", extStart, extEnd); #endif /* GL_NV_texture_shader2 */ #ifdef GL_NV_texture_shader3 GLEW_NV_texture_shader3 = _glewSearchExtension("GL_NV_texture_shader3", extStart, extEnd); #endif /* GL_NV_texture_shader3 */ #ifdef GL_NV_transform_feedback GLEW_NV_transform_feedback = _glewSearchExtension("GL_NV_transform_feedback", extStart, extEnd); if (glewExperimental || GLEW_NV_transform_feedback) GLEW_NV_transform_feedback = !_glewInit_GL_NV_transform_feedback(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_transform_feedback */ #ifdef GL_NV_transform_feedback2 GLEW_NV_transform_feedback2 = _glewSearchExtension("GL_NV_transform_feedback2", extStart, extEnd); if (glewExperimental || GLEW_NV_transform_feedback2) GLEW_NV_transform_feedback2 = !_glewInit_GL_NV_transform_feedback2(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_transform_feedback2 */ #ifdef GL_NV_uniform_buffer_unified_memory GLEW_NV_uniform_buffer_unified_memory = _glewSearchExtension("GL_NV_uniform_buffer_unified_memory", extStart, extEnd); #endif /* GL_NV_uniform_buffer_unified_memory */ #ifdef GL_NV_vdpau_interop GLEW_NV_vdpau_interop = _glewSearchExtension("GL_NV_vdpau_interop", extStart, extEnd); if (glewExperimental || GLEW_NV_vdpau_interop) GLEW_NV_vdpau_interop = !_glewInit_GL_NV_vdpau_interop(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_vdpau_interop */ #ifdef GL_NV_vertex_array_range GLEW_NV_vertex_array_range = _glewSearchExtension("GL_NV_vertex_array_range", extStart, extEnd); if (glewExperimental || GLEW_NV_vertex_array_range) GLEW_NV_vertex_array_range = !_glewInit_GL_NV_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_vertex_array_range */ #ifdef GL_NV_vertex_array_range2 GLEW_NV_vertex_array_range2 = _glewSearchExtension("GL_NV_vertex_array_range2", extStart, extEnd); #endif /* GL_NV_vertex_array_range2 */ #ifdef GL_NV_vertex_attrib_integer_64bit GLEW_NV_vertex_attrib_integer_64bit = _glewSearchExtension("GL_NV_vertex_attrib_integer_64bit", extStart, extEnd); if (glewExperimental || GLEW_NV_vertex_attrib_integer_64bit) GLEW_NV_vertex_attrib_integer_64bit = !_glewInit_GL_NV_vertex_attrib_integer_64bit(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_vertex_attrib_integer_64bit */ #ifdef GL_NV_vertex_buffer_unified_memory GLEW_NV_vertex_buffer_unified_memory = _glewSearchExtension("GL_NV_vertex_buffer_unified_memory", extStart, extEnd); if (glewExperimental || GLEW_NV_vertex_buffer_unified_memory) GLEW_NV_vertex_buffer_unified_memory = !_glewInit_GL_NV_vertex_buffer_unified_memory(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_vertex_buffer_unified_memory */ #ifdef GL_NV_vertex_program GLEW_NV_vertex_program = _glewSearchExtension("GL_NV_vertex_program", extStart, extEnd); if (glewExperimental || GLEW_NV_vertex_program) GLEW_NV_vertex_program = !_glewInit_GL_NV_vertex_program(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_vertex_program */ #ifdef GL_NV_vertex_program1_1 GLEW_NV_vertex_program1_1 = _glewSearchExtension("GL_NV_vertex_program1_1", extStart, extEnd); #endif /* GL_NV_vertex_program1_1 */ #ifdef GL_NV_vertex_program2 GLEW_NV_vertex_program2 = _glewSearchExtension("GL_NV_vertex_program2", extStart, extEnd); #endif /* GL_NV_vertex_program2 */ #ifdef GL_NV_vertex_program2_option GLEW_NV_vertex_program2_option = _glewSearchExtension("GL_NV_vertex_program2_option", extStart, extEnd); #endif /* GL_NV_vertex_program2_option */ #ifdef GL_NV_vertex_program3 GLEW_NV_vertex_program3 = _glewSearchExtension("GL_NV_vertex_program3", extStart, extEnd); #endif /* GL_NV_vertex_program3 */ #ifdef GL_NV_vertex_program4 GLEW_NV_vertex_program4 = _glewSearchExtension("GL_NV_gpu_program4", extStart, extEnd); #endif /* GL_NV_vertex_program4 */ #ifdef GL_NV_video_capture GLEW_NV_video_capture = _glewSearchExtension("GL_NV_video_capture", extStart, extEnd); if (glewExperimental || GLEW_NV_video_capture) GLEW_NV_video_capture = !_glewInit_GL_NV_video_capture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_video_capture */ #ifdef GL_NV_viewport_array2 GLEW_NV_viewport_array2 = _glewSearchExtension("GL_NV_viewport_array2", extStart, extEnd); #endif /* GL_NV_viewport_array2 */ #ifdef GL_OES_byte_coordinates GLEW_OES_byte_coordinates = _glewSearchExtension("GL_OES_byte_coordinates", extStart, extEnd); #endif /* GL_OES_byte_coordinates */ #ifdef GL_OES_compressed_paletted_texture GLEW_OES_compressed_paletted_texture = _glewSearchExtension("GL_OES_compressed_paletted_texture", extStart, extEnd); #endif /* GL_OES_compressed_paletted_texture */ #ifdef GL_OES_read_format GLEW_OES_read_format = _glewSearchExtension("GL_OES_read_format", extStart, extEnd); #endif /* GL_OES_read_format */ #ifdef GL_OES_single_precision GLEW_OES_single_precision = _glewSearchExtension("GL_OES_single_precision", extStart, extEnd); if (glewExperimental || GLEW_OES_single_precision) GLEW_OES_single_precision = !_glewInit_GL_OES_single_precision(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_OES_single_precision */ #ifdef GL_OML_interlace GLEW_OML_interlace = _glewSearchExtension("GL_OML_interlace", extStart, extEnd); #endif /* GL_OML_interlace */ #ifdef GL_OML_resample GLEW_OML_resample = _glewSearchExtension("GL_OML_resample", extStart, extEnd); #endif /* GL_OML_resample */ #ifdef GL_OML_subsample GLEW_OML_subsample = _glewSearchExtension("GL_OML_subsample", extStart, extEnd); #endif /* GL_OML_subsample */ #ifdef GL_OVR_multiview GLEW_OVR_multiview = _glewSearchExtension("GL_OVR_multiview", extStart, extEnd); if (glewExperimental || GLEW_OVR_multiview) GLEW_OVR_multiview = !_glewInit_GL_OVR_multiview(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_OVR_multiview */ #ifdef GL_OVR_multiview2 GLEW_OVR_multiview2 = _glewSearchExtension("GL_OVR_multiview2", extStart, extEnd); #endif /* GL_OVR_multiview2 */ #ifdef GL_PGI_misc_hints GLEW_PGI_misc_hints = _glewSearchExtension("GL_PGI_misc_hints", extStart, extEnd); #endif /* GL_PGI_misc_hints */ #ifdef GL_PGI_vertex_hints GLEW_PGI_vertex_hints = _glewSearchExtension("GL_PGI_vertex_hints", extStart, extEnd); #endif /* GL_PGI_vertex_hints */ #ifdef GL_REGAL_ES1_0_compatibility GLEW_REGAL_ES1_0_compatibility = _glewSearchExtension("GL_REGAL_ES1_0_compatibility", extStart, extEnd); if (glewExperimental || GLEW_REGAL_ES1_0_compatibility) GLEW_REGAL_ES1_0_compatibility = !_glewInit_GL_REGAL_ES1_0_compatibility(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_REGAL_ES1_0_compatibility */ #ifdef GL_REGAL_ES1_1_compatibility GLEW_REGAL_ES1_1_compatibility = _glewSearchExtension("GL_REGAL_ES1_1_compatibility", extStart, extEnd); if (glewExperimental || GLEW_REGAL_ES1_1_compatibility) GLEW_REGAL_ES1_1_compatibility = !_glewInit_GL_REGAL_ES1_1_compatibility(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_REGAL_ES1_1_compatibility */ #ifdef GL_REGAL_enable GLEW_REGAL_enable = _glewSearchExtension("GL_REGAL_enable", extStart, extEnd); #endif /* GL_REGAL_enable */ #ifdef GL_REGAL_error_string GLEW_REGAL_error_string = _glewSearchExtension("GL_REGAL_error_string", extStart, extEnd); if (glewExperimental || GLEW_REGAL_error_string) GLEW_REGAL_error_string = !_glewInit_GL_REGAL_error_string(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_REGAL_error_string */ #ifdef GL_REGAL_extension_query GLEW_REGAL_extension_query = _glewSearchExtension("GL_REGAL_extension_query", extStart, extEnd); if (glewExperimental || GLEW_REGAL_extension_query) GLEW_REGAL_extension_query = !_glewInit_GL_REGAL_extension_query(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_REGAL_extension_query */ #ifdef GL_REGAL_log GLEW_REGAL_log = _glewSearchExtension("GL_REGAL_log", extStart, extEnd); if (glewExperimental || GLEW_REGAL_log) GLEW_REGAL_log = !_glewInit_GL_REGAL_log(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_REGAL_log */ #ifdef GL_REGAL_proc_address GLEW_REGAL_proc_address = _glewSearchExtension("GL_REGAL_proc_address", extStart, extEnd); if (glewExperimental || GLEW_REGAL_proc_address) GLEW_REGAL_proc_address = !_glewInit_GL_REGAL_proc_address(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_REGAL_proc_address */ #ifdef GL_REND_screen_coordinates GLEW_REND_screen_coordinates = _glewSearchExtension("GL_REND_screen_coordinates", extStart, extEnd); #endif /* GL_REND_screen_coordinates */ #ifdef GL_S3_s3tc GLEW_S3_s3tc = _glewSearchExtension("GL_S3_s3tc", extStart, extEnd); #endif /* GL_S3_s3tc */ #ifdef GL_SGIS_color_range GLEW_SGIS_color_range = _glewSearchExtension("GL_SGIS_color_range", extStart, extEnd); #endif /* GL_SGIS_color_range */ #ifdef GL_SGIS_detail_texture GLEW_SGIS_detail_texture = _glewSearchExtension("GL_SGIS_detail_texture", extStart, extEnd); if (glewExperimental || GLEW_SGIS_detail_texture) GLEW_SGIS_detail_texture = !_glewInit_GL_SGIS_detail_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIS_detail_texture */ #ifdef GL_SGIS_fog_function GLEW_SGIS_fog_function = _glewSearchExtension("GL_SGIS_fog_function", extStart, extEnd); if (glewExperimental || GLEW_SGIS_fog_function) GLEW_SGIS_fog_function = !_glewInit_GL_SGIS_fog_function(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIS_fog_function */ #ifdef GL_SGIS_generate_mipmap GLEW_SGIS_generate_mipmap = _glewSearchExtension("GL_SGIS_generate_mipmap", extStart, extEnd); #endif /* GL_SGIS_generate_mipmap */ #ifdef GL_SGIS_multisample GLEW_SGIS_multisample = _glewSearchExtension("GL_SGIS_multisample", extStart, extEnd); if (glewExperimental || GLEW_SGIS_multisample) GLEW_SGIS_multisample = !_glewInit_GL_SGIS_multisample(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIS_multisample */ #ifdef GL_SGIS_pixel_texture GLEW_SGIS_pixel_texture = _glewSearchExtension("GL_SGIS_pixel_texture", extStart, extEnd); #endif /* GL_SGIS_pixel_texture */ #ifdef GL_SGIS_point_line_texgen GLEW_SGIS_point_line_texgen = _glewSearchExtension("GL_SGIS_point_line_texgen", extStart, extEnd); #endif /* GL_SGIS_point_line_texgen */ #ifdef GL_SGIS_sharpen_texture GLEW_SGIS_sharpen_texture = _glewSearchExtension("GL_SGIS_sharpen_texture", extStart, extEnd); if (glewExperimental || GLEW_SGIS_sharpen_texture) GLEW_SGIS_sharpen_texture = !_glewInit_GL_SGIS_sharpen_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIS_sharpen_texture */ #ifdef GL_SGIS_texture4D GLEW_SGIS_texture4D = _glewSearchExtension("GL_SGIS_texture4D", extStart, extEnd); if (glewExperimental || GLEW_SGIS_texture4D) GLEW_SGIS_texture4D = !_glewInit_GL_SGIS_texture4D(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIS_texture4D */ #ifdef GL_SGIS_texture_border_clamp GLEW_SGIS_texture_border_clamp = _glewSearchExtension("GL_SGIS_texture_border_clamp", extStart, extEnd); #endif /* GL_SGIS_texture_border_clamp */ #ifdef GL_SGIS_texture_edge_clamp GLEW_SGIS_texture_edge_clamp = _glewSearchExtension("GL_SGIS_texture_edge_clamp", extStart, extEnd); #endif /* GL_SGIS_texture_edge_clamp */ #ifdef GL_SGIS_texture_filter4 GLEW_SGIS_texture_filter4 = _glewSearchExtension("GL_SGIS_texture_filter4", extStart, extEnd); if (glewExperimental || GLEW_SGIS_texture_filter4) GLEW_SGIS_texture_filter4 = !_glewInit_GL_SGIS_texture_filter4(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIS_texture_filter4 */ #ifdef GL_SGIS_texture_lod GLEW_SGIS_texture_lod = _glewSearchExtension("GL_SGIS_texture_lod", extStart, extEnd); #endif /* GL_SGIS_texture_lod */ #ifdef GL_SGIS_texture_select GLEW_SGIS_texture_select = _glewSearchExtension("GL_SGIS_texture_select", extStart, extEnd); #endif /* GL_SGIS_texture_select */ #ifdef GL_SGIX_async GLEW_SGIX_async = _glewSearchExtension("GL_SGIX_async", extStart, extEnd); if (glewExperimental || GLEW_SGIX_async) GLEW_SGIX_async = !_glewInit_GL_SGIX_async(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIX_async */ #ifdef GL_SGIX_async_histogram GLEW_SGIX_async_histogram = _glewSearchExtension("GL_SGIX_async_histogram", extStart, extEnd); #endif /* GL_SGIX_async_histogram */ #ifdef GL_SGIX_async_pixel GLEW_SGIX_async_pixel = _glewSearchExtension("GL_SGIX_async_pixel", extStart, extEnd); #endif /* GL_SGIX_async_pixel */ #ifdef GL_SGIX_blend_alpha_minmax GLEW_SGIX_blend_alpha_minmax = _glewSearchExtension("GL_SGIX_blend_alpha_minmax", extStart, extEnd); #endif /* GL_SGIX_blend_alpha_minmax */ #ifdef GL_SGIX_clipmap GLEW_SGIX_clipmap = _glewSearchExtension("GL_SGIX_clipmap", extStart, extEnd); #endif /* GL_SGIX_clipmap */ #ifdef GL_SGIX_convolution_accuracy GLEW_SGIX_convolution_accuracy = _glewSearchExtension("GL_SGIX_convolution_accuracy", extStart, extEnd); #endif /* GL_SGIX_convolution_accuracy */ #ifdef GL_SGIX_depth_texture GLEW_SGIX_depth_texture = _glewSearchExtension("GL_SGIX_depth_texture", extStart, extEnd); #endif /* GL_SGIX_depth_texture */ #ifdef GL_SGIX_flush_raster GLEW_SGIX_flush_raster = _glewSearchExtension("GL_SGIX_flush_raster", extStart, extEnd); if (glewExperimental || GLEW_SGIX_flush_raster) GLEW_SGIX_flush_raster = !_glewInit_GL_SGIX_flush_raster(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIX_flush_raster */ #ifdef GL_SGIX_fog_offset GLEW_SGIX_fog_offset = _glewSearchExtension("GL_SGIX_fog_offset", extStart, extEnd); #endif /* GL_SGIX_fog_offset */ #ifdef GL_SGIX_fog_texture GLEW_SGIX_fog_texture = _glewSearchExtension("GL_SGIX_fog_texture", extStart, extEnd); if (glewExperimental || GLEW_SGIX_fog_texture) GLEW_SGIX_fog_texture = !_glewInit_GL_SGIX_fog_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIX_fog_texture */ #ifdef GL_SGIX_fragment_specular_lighting GLEW_SGIX_fragment_specular_lighting = _glewSearchExtension("GL_SGIX_fragment_specular_lighting", extStart, extEnd); if (glewExperimental || GLEW_SGIX_fragment_specular_lighting) GLEW_SGIX_fragment_specular_lighting = !_glewInit_GL_SGIX_fragment_specular_lighting(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIX_fragment_specular_lighting */ #ifdef GL_SGIX_framezoom GLEW_SGIX_framezoom = _glewSearchExtension("GL_SGIX_framezoom", extStart, extEnd); if (glewExperimental || GLEW_SGIX_framezoom) GLEW_SGIX_framezoom = !_glewInit_GL_SGIX_framezoom(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIX_framezoom */ #ifdef GL_SGIX_interlace GLEW_SGIX_interlace = _glewSearchExtension("GL_SGIX_interlace", extStart, extEnd); #endif /* GL_SGIX_interlace */ #ifdef GL_SGIX_ir_instrument1 GLEW_SGIX_ir_instrument1 = _glewSearchExtension("GL_SGIX_ir_instrument1", extStart, extEnd); #endif /* GL_SGIX_ir_instrument1 */ #ifdef GL_SGIX_list_priority GLEW_SGIX_list_priority = _glewSearchExtension("GL_SGIX_list_priority", extStart, extEnd); #endif /* GL_SGIX_list_priority */ #ifdef GL_SGIX_pixel_texture GLEW_SGIX_pixel_texture = _glewSearchExtension("GL_SGIX_pixel_texture", extStart, extEnd); if (glewExperimental || GLEW_SGIX_pixel_texture) GLEW_SGIX_pixel_texture = !_glewInit_GL_SGIX_pixel_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIX_pixel_texture */ #ifdef GL_SGIX_pixel_texture_bits GLEW_SGIX_pixel_texture_bits = _glewSearchExtension("GL_SGIX_pixel_texture_bits", extStart, extEnd); #endif /* GL_SGIX_pixel_texture_bits */ #ifdef GL_SGIX_reference_plane GLEW_SGIX_reference_plane = _glewSearchExtension("GL_SGIX_reference_plane", extStart, extEnd); if (glewExperimental || GLEW_SGIX_reference_plane) GLEW_SGIX_reference_plane = !_glewInit_GL_SGIX_reference_plane(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIX_reference_plane */ #ifdef GL_SGIX_resample GLEW_SGIX_resample = _glewSearchExtension("GL_SGIX_resample", extStart, extEnd); #endif /* GL_SGIX_resample */ #ifdef GL_SGIX_shadow GLEW_SGIX_shadow = _glewSearchExtension("GL_SGIX_shadow", extStart, extEnd); #endif /* GL_SGIX_shadow */ #ifdef GL_SGIX_shadow_ambient GLEW_SGIX_shadow_ambient = _glewSearchExtension("GL_SGIX_shadow_ambient", extStart, extEnd); #endif /* GL_SGIX_shadow_ambient */ #ifdef GL_SGIX_sprite GLEW_SGIX_sprite = _glewSearchExtension("GL_SGIX_sprite", extStart, extEnd); if (glewExperimental || GLEW_SGIX_sprite) GLEW_SGIX_sprite = !_glewInit_GL_SGIX_sprite(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIX_sprite */ #ifdef GL_SGIX_tag_sample_buffer GLEW_SGIX_tag_sample_buffer = _glewSearchExtension("GL_SGIX_tag_sample_buffer", extStart, extEnd); if (glewExperimental || GLEW_SGIX_tag_sample_buffer) GLEW_SGIX_tag_sample_buffer = !_glewInit_GL_SGIX_tag_sample_buffer(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGIX_tag_sample_buffer */ #ifdef GL_SGIX_texture_add_env GLEW_SGIX_texture_add_env = _glewSearchExtension("GL_SGIX_texture_add_env", extStart, extEnd); #endif /* GL_SGIX_texture_add_env */ #ifdef GL_SGIX_texture_coordinate_clamp GLEW_SGIX_texture_coordinate_clamp = _glewSearchExtension("GL_SGIX_texture_coordinate_clamp", extStart, extEnd); #endif /* GL_SGIX_texture_coordinate_clamp */ #ifdef GL_SGIX_texture_lod_bias GLEW_SGIX_texture_lod_bias = _glewSearchExtension("GL_SGIX_texture_lod_bias", extStart, extEnd); #endif /* GL_SGIX_texture_lod_bias */ #ifdef GL_SGIX_texture_multi_buffer GLEW_SGIX_texture_multi_buffer = _glewSearchExtension("GL_SGIX_texture_multi_buffer", extStart, extEnd); #endif /* GL_SGIX_texture_multi_buffer */ #ifdef GL_SGIX_texture_range GLEW_SGIX_texture_range = _glewSearchExtension("GL_SGIX_texture_range", extStart, extEnd); #endif /* GL_SGIX_texture_range */ #ifdef GL_SGIX_texture_scale_bias GLEW_SGIX_texture_scale_bias = _glewSearchExtension("GL_SGIX_texture_scale_bias", extStart, extEnd); #endif /* GL_SGIX_texture_scale_bias */ #ifdef GL_SGIX_vertex_preclip GLEW_SGIX_vertex_preclip = _glewSearchExtension("GL_SGIX_vertex_preclip", extStart, extEnd); #endif /* GL_SGIX_vertex_preclip */ #ifdef GL_SGIX_vertex_preclip_hint GLEW_SGIX_vertex_preclip_hint = _glewSearchExtension("GL_SGIX_vertex_preclip_hint", extStart, extEnd); #endif /* GL_SGIX_vertex_preclip_hint */ #ifdef GL_SGIX_ycrcb GLEW_SGIX_ycrcb = _glewSearchExtension("GL_SGIX_ycrcb", extStart, extEnd); #endif /* GL_SGIX_ycrcb */ #ifdef GL_SGI_color_matrix GLEW_SGI_color_matrix = _glewSearchExtension("GL_SGI_color_matrix", extStart, extEnd); #endif /* GL_SGI_color_matrix */ #ifdef GL_SGI_color_table GLEW_SGI_color_table = _glewSearchExtension("GL_SGI_color_table", extStart, extEnd); if (glewExperimental || GLEW_SGI_color_table) GLEW_SGI_color_table = !_glewInit_GL_SGI_color_table(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SGI_color_table */ #ifdef GL_SGI_texture_color_table GLEW_SGI_texture_color_table = _glewSearchExtension("GL_SGI_texture_color_table", extStart, extEnd); #endif /* GL_SGI_texture_color_table */ #ifdef GL_SUNX_constant_data GLEW_SUNX_constant_data = _glewSearchExtension("GL_SUNX_constant_data", extStart, extEnd); if (glewExperimental || GLEW_SUNX_constant_data) GLEW_SUNX_constant_data = !_glewInit_GL_SUNX_constant_data(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SUNX_constant_data */ #ifdef GL_SUN_convolution_border_modes GLEW_SUN_convolution_border_modes = _glewSearchExtension("GL_SUN_convolution_border_modes", extStart, extEnd); #endif /* GL_SUN_convolution_border_modes */ #ifdef GL_SUN_global_alpha GLEW_SUN_global_alpha = _glewSearchExtension("GL_SUN_global_alpha", extStart, extEnd); if (glewExperimental || GLEW_SUN_global_alpha) GLEW_SUN_global_alpha = !_glewInit_GL_SUN_global_alpha(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SUN_global_alpha */ #ifdef GL_SUN_mesh_array GLEW_SUN_mesh_array = _glewSearchExtension("GL_SUN_mesh_array", extStart, extEnd); #endif /* GL_SUN_mesh_array */ #ifdef GL_SUN_read_video_pixels GLEW_SUN_read_video_pixels = _glewSearchExtension("GL_SUN_read_video_pixels", extStart, extEnd); if (glewExperimental || GLEW_SUN_read_video_pixels) GLEW_SUN_read_video_pixels = !_glewInit_GL_SUN_read_video_pixels(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SUN_read_video_pixels */ #ifdef GL_SUN_slice_accum GLEW_SUN_slice_accum = _glewSearchExtension("GL_SUN_slice_accum", extStart, extEnd); #endif /* GL_SUN_slice_accum */ #ifdef GL_SUN_triangle_list GLEW_SUN_triangle_list = _glewSearchExtension("GL_SUN_triangle_list", extStart, extEnd); if (glewExperimental || GLEW_SUN_triangle_list) GLEW_SUN_triangle_list = !_glewInit_GL_SUN_triangle_list(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SUN_triangle_list */ #ifdef GL_SUN_vertex GLEW_SUN_vertex = _glewSearchExtension("GL_SUN_vertex", extStart, extEnd); if (glewExperimental || GLEW_SUN_vertex) GLEW_SUN_vertex = !_glewInit_GL_SUN_vertex(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_SUN_vertex */ #ifdef GL_WIN_phong_shading GLEW_WIN_phong_shading = _glewSearchExtension("GL_WIN_phong_shading", extStart, extEnd); #endif /* GL_WIN_phong_shading */ #ifdef GL_WIN_specular_fog GLEW_WIN_specular_fog = _glewSearchExtension("GL_WIN_specular_fog", extStart, extEnd); #endif /* GL_WIN_specular_fog */ #ifdef GL_WIN_swap_hint GLEW_WIN_swap_hint = _glewSearchExtension("GL_WIN_swap_hint", extStart, extEnd); if (glewExperimental || GLEW_WIN_swap_hint) GLEW_WIN_swap_hint = !_glewInit_GL_WIN_swap_hint(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_WIN_swap_hint */ return GLEW_OK; } #if defined(_WIN32) #if !defined(GLEW_MX) PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL = NULL; PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD = NULL; PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD = NULL; PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD = NULL; PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD = NULL; PFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD = NULL; PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD = NULL; PFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD = NULL; PFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD = NULL; PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD = NULL; PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB = NULL; PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB = NULL; PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB = NULL; PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB = NULL; PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB = NULL; PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB = NULL; PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB = NULL; PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB = NULL; PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB = NULL; PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB = NULL; PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB = NULL; PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB = NULL; PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB = NULL; PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB = NULL; PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB = NULL; PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB = NULL; PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB = NULL; PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB = NULL; PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB = NULL; PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT = NULL; PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT = NULL; PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT = NULL; PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT = NULL; PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT = NULL; PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT = NULL; PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT = NULL; PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT = NULL; PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT = NULL; PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT = NULL; PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT = NULL; PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT = NULL; PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT = NULL; PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT = NULL; PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT = NULL; PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT = NULL; PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT = NULL; PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D = NULL; PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D = NULL; PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D = NULL; PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D = NULL; PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D = NULL; PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D = NULL; PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D = NULL; PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D = NULL; PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D = NULL; PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D = NULL; PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D = NULL; PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D = NULL; PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D = NULL; PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D = NULL; PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D = NULL; PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D = NULL; PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D = NULL; PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D = NULL; PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D = NULL; PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D = NULL; PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D = NULL; PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D = NULL; PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D = NULL; PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D = NULL; PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D = NULL; PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D = NULL; PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D = NULL; PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D = NULL; PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D = NULL; PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D = NULL; PFNWGLDXCLOSEDEVICENVPROC __wglewDXCloseDeviceNV = NULL; PFNWGLDXLOCKOBJECTSNVPROC __wglewDXLockObjectsNV = NULL; PFNWGLDXOBJECTACCESSNVPROC __wglewDXObjectAccessNV = NULL; PFNWGLDXOPENDEVICENVPROC __wglewDXOpenDeviceNV = NULL; PFNWGLDXREGISTEROBJECTNVPROC __wglewDXRegisterObjectNV = NULL; PFNWGLDXSETRESOURCESHAREHANDLENVPROC __wglewDXSetResourceShareHandleNV = NULL; PFNWGLDXUNLOCKOBJECTSNVPROC __wglewDXUnlockObjectsNV = NULL; PFNWGLDXUNREGISTEROBJECTNVPROC __wglewDXUnregisterObjectNV = NULL; PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV = NULL; PFNWGLDELAYBEFORESWAPNVPROC __wglewDelayBeforeSwapNV = NULL; PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV = NULL; PFNWGLDELETEDCNVPROC __wglewDeleteDCNV = NULL; PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV = NULL; PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV = NULL; PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV = NULL; PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV = NULL; PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV = NULL; PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV = NULL; PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV = NULL; PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV = NULL; PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV = NULL; PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV = NULL; PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV = NULL; PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV = NULL; PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV = NULL; PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV = NULL; PFNWGLBINDVIDEOCAPTUREDEVICENVPROC __wglewBindVideoCaptureDeviceNV = NULL; PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC __wglewEnumerateVideoCaptureDevicesNV = NULL; PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC __wglewLockVideoCaptureDeviceNV = NULL; PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC __wglewQueryVideoCaptureDeviceNV = NULL; PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC __wglewReleaseVideoCaptureDeviceNV = NULL; PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV = NULL; PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV = NULL; PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV = NULL; PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV = NULL; PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV = NULL; PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV = NULL; PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML = NULL; PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML = NULL; PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML = NULL; PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML = NULL; PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML = NULL; PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML = NULL; GLboolean __WGLEW_3DFX_multisample = GL_FALSE; GLboolean __WGLEW_3DL_stereo_control = GL_FALSE; GLboolean __WGLEW_AMD_gpu_association = GL_FALSE; GLboolean __WGLEW_ARB_buffer_region = GL_FALSE; GLboolean __WGLEW_ARB_context_flush_control = GL_FALSE; GLboolean __WGLEW_ARB_create_context = GL_FALSE; GLboolean __WGLEW_ARB_create_context_profile = GL_FALSE; GLboolean __WGLEW_ARB_create_context_robustness = GL_FALSE; GLboolean __WGLEW_ARB_extensions_string = GL_FALSE; GLboolean __WGLEW_ARB_framebuffer_sRGB = GL_FALSE; GLboolean __WGLEW_ARB_make_current_read = GL_FALSE; GLboolean __WGLEW_ARB_multisample = GL_FALSE; GLboolean __WGLEW_ARB_pbuffer = GL_FALSE; GLboolean __WGLEW_ARB_pixel_format = GL_FALSE; GLboolean __WGLEW_ARB_pixel_format_float = GL_FALSE; GLboolean __WGLEW_ARB_render_texture = GL_FALSE; GLboolean __WGLEW_ARB_robustness_application_isolation = GL_FALSE; GLboolean __WGLEW_ARB_robustness_share_group_isolation = GL_FALSE; GLboolean __WGLEW_ATI_pixel_format_float = GL_FALSE; GLboolean __WGLEW_ATI_render_texture_rectangle = GL_FALSE; GLboolean __WGLEW_EXT_create_context_es2_profile = GL_FALSE; GLboolean __WGLEW_EXT_create_context_es_profile = GL_FALSE; GLboolean __WGLEW_EXT_depth_float = GL_FALSE; GLboolean __WGLEW_EXT_display_color_table = GL_FALSE; GLboolean __WGLEW_EXT_extensions_string = GL_FALSE; GLboolean __WGLEW_EXT_framebuffer_sRGB = GL_FALSE; GLboolean __WGLEW_EXT_make_current_read = GL_FALSE; GLboolean __WGLEW_EXT_multisample = GL_FALSE; GLboolean __WGLEW_EXT_pbuffer = GL_FALSE; GLboolean __WGLEW_EXT_pixel_format = GL_FALSE; GLboolean __WGLEW_EXT_pixel_format_packed_float = GL_FALSE; GLboolean __WGLEW_EXT_swap_control = GL_FALSE; GLboolean __WGLEW_EXT_swap_control_tear = GL_FALSE; GLboolean __WGLEW_I3D_digital_video_control = GL_FALSE; GLboolean __WGLEW_I3D_gamma = GL_FALSE; GLboolean __WGLEW_I3D_genlock = GL_FALSE; GLboolean __WGLEW_I3D_image_buffer = GL_FALSE; GLboolean __WGLEW_I3D_swap_frame_lock = GL_FALSE; GLboolean __WGLEW_I3D_swap_frame_usage = GL_FALSE; GLboolean __WGLEW_NV_DX_interop = GL_FALSE; GLboolean __WGLEW_NV_DX_interop2 = GL_FALSE; GLboolean __WGLEW_NV_copy_image = GL_FALSE; GLboolean __WGLEW_NV_delay_before_swap = GL_FALSE; GLboolean __WGLEW_NV_float_buffer = GL_FALSE; GLboolean __WGLEW_NV_gpu_affinity = GL_FALSE; GLboolean __WGLEW_NV_multisample_coverage = GL_FALSE; GLboolean __WGLEW_NV_present_video = GL_FALSE; GLboolean __WGLEW_NV_render_depth_texture = GL_FALSE; GLboolean __WGLEW_NV_render_texture_rectangle = GL_FALSE; GLboolean __WGLEW_NV_swap_group = GL_FALSE; GLboolean __WGLEW_NV_vertex_array_range = GL_FALSE; GLboolean __WGLEW_NV_video_capture = GL_FALSE; GLboolean __WGLEW_NV_video_output = GL_FALSE; GLboolean __WGLEW_OML_sync_control = GL_FALSE; #endif /* !GLEW_MX */ #ifdef WGL_3DL_stereo_control static GLboolean _glewInit_WGL_3DL_stereo_control (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglSetStereoEmitterState3DL = (PFNWGLSETSTEREOEMITTERSTATE3DLPROC)glewGetProcAddress((const GLubyte*)"wglSetStereoEmitterState3DL")) == NULL) || r; return r; } #endif /* WGL_3DL_stereo_control */ #ifdef WGL_AMD_gpu_association static GLboolean _glewInit_WGL_AMD_gpu_association (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglBlitContextFramebufferAMD = (PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC)glewGetProcAddress((const GLubyte*)"wglBlitContextFramebufferAMD")) == NULL) || r; r = ((wglCreateAssociatedContextAMD = (PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC)glewGetProcAddress((const GLubyte*)"wglCreateAssociatedContextAMD")) == NULL) || r; r = ((wglCreateAssociatedContextAttribsAMD = (PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC)glewGetProcAddress((const GLubyte*)"wglCreateAssociatedContextAttribsAMD")) == NULL) || r; r = ((wglDeleteAssociatedContextAMD = (PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC)glewGetProcAddress((const GLubyte*)"wglDeleteAssociatedContextAMD")) == NULL) || r; r = ((wglGetContextGPUIDAMD = (PFNWGLGETCONTEXTGPUIDAMDPROC)glewGetProcAddress((const GLubyte*)"wglGetContextGPUIDAMD")) == NULL) || r; r = ((wglGetCurrentAssociatedContextAMD = (PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC)glewGetProcAddress((const GLubyte*)"wglGetCurrentAssociatedContextAMD")) == NULL) || r; r = ((wglGetGPUIDsAMD = (PFNWGLGETGPUIDSAMDPROC)glewGetProcAddress((const GLubyte*)"wglGetGPUIDsAMD")) == NULL) || r; r = ((wglGetGPUInfoAMD = (PFNWGLGETGPUINFOAMDPROC)glewGetProcAddress((const GLubyte*)"wglGetGPUInfoAMD")) == NULL) || r; r = ((wglMakeAssociatedContextCurrentAMD = (PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC)glewGetProcAddress((const GLubyte*)"wglMakeAssociatedContextCurrentAMD")) == NULL) || r; return r; } #endif /* WGL_AMD_gpu_association */ #ifdef WGL_ARB_buffer_region static GLboolean _glewInit_WGL_ARB_buffer_region (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglCreateBufferRegionARB = (PFNWGLCREATEBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)"wglCreateBufferRegionARB")) == NULL) || r; r = ((wglDeleteBufferRegionARB = (PFNWGLDELETEBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)"wglDeleteBufferRegionARB")) == NULL) || r; r = ((wglRestoreBufferRegionARB = (PFNWGLRESTOREBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)"wglRestoreBufferRegionARB")) == NULL) || r; r = ((wglSaveBufferRegionARB = (PFNWGLSAVEBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)"wglSaveBufferRegionARB")) == NULL) || r; return r; } #endif /* WGL_ARB_buffer_region */ #ifdef WGL_ARB_create_context static GLboolean _glewInit_WGL_ARB_create_context (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)glewGetProcAddress((const GLubyte*)"wglCreateContextAttribsARB")) == NULL) || r; return r; } #endif /* WGL_ARB_create_context */ #ifdef WGL_ARB_extensions_string static GLboolean _glewInit_WGL_ARB_extensions_string (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringARB")) == NULL) || r; return r; } #endif /* WGL_ARB_extensions_string */ #ifdef WGL_ARB_make_current_read static GLboolean _glewInit_WGL_ARB_make_current_read (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglGetCurrentReadDCARB = (PFNWGLGETCURRENTREADDCARBPROC)glewGetProcAddress((const GLubyte*)"wglGetCurrentReadDCARB")) == NULL) || r; r = ((wglMakeContextCurrentARB = (PFNWGLMAKECONTEXTCURRENTARBPROC)glewGetProcAddress((const GLubyte*)"wglMakeContextCurrentARB")) == NULL) || r; return r; } #endif /* WGL_ARB_make_current_read */ #ifdef WGL_ARB_pbuffer static GLboolean _glewInit_WGL_ARB_pbuffer (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"wglCreatePbufferARB")) == NULL) || r; r = ((wglDestroyPbufferARB = (PFNWGLDESTROYPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"wglDestroyPbufferARB")) == NULL) || r; r = ((wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC)glewGetProcAddress((const GLubyte*)"wglGetPbufferDCARB")) == NULL) || r; r = ((wglQueryPbufferARB = (PFNWGLQUERYPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"wglQueryPbufferARB")) == NULL) || r; r = ((wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)glewGetProcAddress((const GLubyte*)"wglReleasePbufferDCARB")) == NULL) || r; return r; } #endif /* WGL_ARB_pbuffer */ #ifdef WGL_ARB_pixel_format static GLboolean _glewInit_WGL_ARB_pixel_format (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)glewGetProcAddress((const GLubyte*)"wglChoosePixelFormatARB")) == NULL) || r; r = ((wglGetPixelFormatAttribfvARB = (PFNWGLGETPIXELFORMATATTRIBFVARBPROC)glewGetProcAddress((const GLubyte*)"wglGetPixelFormatAttribfvARB")) == NULL) || r; r = ((wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)glewGetProcAddress((const GLubyte*)"wglGetPixelFormatAttribivARB")) == NULL) || r; return r; } #endif /* WGL_ARB_pixel_format */ #ifdef WGL_ARB_render_texture static GLboolean _glewInit_WGL_ARB_render_texture (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglBindTexImageARB = (PFNWGLBINDTEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)"wglBindTexImageARB")) == NULL) || r; r = ((wglReleaseTexImageARB = (PFNWGLRELEASETEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)"wglReleaseTexImageARB")) == NULL) || r; r = ((wglSetPbufferAttribARB = (PFNWGLSETPBUFFERATTRIBARBPROC)glewGetProcAddress((const GLubyte*)"wglSetPbufferAttribARB")) == NULL) || r; return r; } #endif /* WGL_ARB_render_texture */ #ifdef WGL_EXT_display_color_table static GLboolean _glewInit_WGL_EXT_display_color_table (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglBindDisplayColorTableEXT = (PFNWGLBINDDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"wglBindDisplayColorTableEXT")) == NULL) || r; r = ((wglCreateDisplayColorTableEXT = (PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"wglCreateDisplayColorTableEXT")) == NULL) || r; r = ((wglDestroyDisplayColorTableEXT = (PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"wglDestroyDisplayColorTableEXT")) == NULL) || r; r = ((wglLoadDisplayColorTableEXT = (PFNWGLLOADDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"wglLoadDisplayColorTableEXT")) == NULL) || r; return r; } #endif /* WGL_EXT_display_color_table */ #ifdef WGL_EXT_extensions_string static GLboolean _glewInit_WGL_EXT_extensions_string (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringEXT")) == NULL) || r; return r; } #endif /* WGL_EXT_extensions_string */ #ifdef WGL_EXT_make_current_read static GLboolean _glewInit_WGL_EXT_make_current_read (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglGetCurrentReadDCEXT = (PFNWGLGETCURRENTREADDCEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetCurrentReadDCEXT")) == NULL) || r; r = ((wglMakeContextCurrentEXT = (PFNWGLMAKECONTEXTCURRENTEXTPROC)glewGetProcAddress((const GLubyte*)"wglMakeContextCurrentEXT")) == NULL) || r; return r; } #endif /* WGL_EXT_make_current_read */ #ifdef WGL_EXT_pbuffer static GLboolean _glewInit_WGL_EXT_pbuffer (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglCreatePbufferEXT = (PFNWGLCREATEPBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"wglCreatePbufferEXT")) == NULL) || r; r = ((wglDestroyPbufferEXT = (PFNWGLDESTROYPBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"wglDestroyPbufferEXT")) == NULL) || r; r = ((wglGetPbufferDCEXT = (PFNWGLGETPBUFFERDCEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetPbufferDCEXT")) == NULL) || r; r = ((wglQueryPbufferEXT = (PFNWGLQUERYPBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"wglQueryPbufferEXT")) == NULL) || r; r = ((wglReleasePbufferDCEXT = (PFNWGLRELEASEPBUFFERDCEXTPROC)glewGetProcAddress((const GLubyte*)"wglReleasePbufferDCEXT")) == NULL) || r; return r; } #endif /* WGL_EXT_pbuffer */ #ifdef WGL_EXT_pixel_format static GLboolean _glewInit_WGL_EXT_pixel_format (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglChoosePixelFormatEXT = (PFNWGLCHOOSEPIXELFORMATEXTPROC)glewGetProcAddress((const GLubyte*)"wglChoosePixelFormatEXT")) == NULL) || r; r = ((wglGetPixelFormatAttribfvEXT = (PFNWGLGETPIXELFORMATATTRIBFVEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetPixelFormatAttribfvEXT")) == NULL) || r; r = ((wglGetPixelFormatAttribivEXT = (PFNWGLGETPIXELFORMATATTRIBIVEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetPixelFormatAttribivEXT")) == NULL) || r; return r; } #endif /* WGL_EXT_pixel_format */ #ifdef WGL_EXT_swap_control static GLboolean _glewInit_WGL_EXT_swap_control (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetSwapIntervalEXT")) == NULL) || r; r = ((wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)glewGetProcAddress((const GLubyte*)"wglSwapIntervalEXT")) == NULL) || r; return r; } #endif /* WGL_EXT_swap_control */ #ifdef WGL_I3D_digital_video_control static GLboolean _glewInit_WGL_I3D_digital_video_control (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglGetDigitalVideoParametersI3D = (PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetDigitalVideoParametersI3D")) == NULL) || r; r = ((wglSetDigitalVideoParametersI3D = (PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)"wglSetDigitalVideoParametersI3D")) == NULL) || r; return r; } #endif /* WGL_I3D_digital_video_control */ #ifdef WGL_I3D_gamma static GLboolean _glewInit_WGL_I3D_gamma (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglGetGammaTableI3D = (PFNWGLGETGAMMATABLEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGammaTableI3D")) == NULL) || r; r = ((wglGetGammaTableParametersI3D = (PFNWGLGETGAMMATABLEPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGammaTableParametersI3D")) == NULL) || r; r = ((wglSetGammaTableI3D = (PFNWGLSETGAMMATABLEI3DPROC)glewGetProcAddress((const GLubyte*)"wglSetGammaTableI3D")) == NULL) || r; r = ((wglSetGammaTableParametersI3D = (PFNWGLSETGAMMATABLEPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)"wglSetGammaTableParametersI3D")) == NULL) || r; return r; } #endif /* WGL_I3D_gamma */ #ifdef WGL_I3D_genlock static GLboolean _glewInit_WGL_I3D_genlock (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglDisableGenlockI3D = (PFNWGLDISABLEGENLOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglDisableGenlockI3D")) == NULL) || r; r = ((wglEnableGenlockI3D = (PFNWGLENABLEGENLOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglEnableGenlockI3D")) == NULL) || r; r = ((wglGenlockSampleRateI3D = (PFNWGLGENLOCKSAMPLERATEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGenlockSampleRateI3D")) == NULL) || r; r = ((wglGenlockSourceDelayI3D = (PFNWGLGENLOCKSOURCEDELAYI3DPROC)glewGetProcAddress((const GLubyte*)"wglGenlockSourceDelayI3D")) == NULL) || r; r = ((wglGenlockSourceEdgeI3D = (PFNWGLGENLOCKSOURCEEDGEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGenlockSourceEdgeI3D")) == NULL) || r; r = ((wglGenlockSourceI3D = (PFNWGLGENLOCKSOURCEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGenlockSourceI3D")) == NULL) || r; r = ((wglGetGenlockSampleRateI3D = (PFNWGLGETGENLOCKSAMPLERATEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGenlockSampleRateI3D")) == NULL) || r; r = ((wglGetGenlockSourceDelayI3D = (PFNWGLGETGENLOCKSOURCEDELAYI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGenlockSourceDelayI3D")) == NULL) || r; r = ((wglGetGenlockSourceEdgeI3D = (PFNWGLGETGENLOCKSOURCEEDGEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGenlockSourceEdgeI3D")) == NULL) || r; r = ((wglGetGenlockSourceI3D = (PFNWGLGETGENLOCKSOURCEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGenlockSourceI3D")) == NULL) || r; r = ((wglIsEnabledGenlockI3D = (PFNWGLISENABLEDGENLOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglIsEnabledGenlockI3D")) == NULL) || r; r = ((wglQueryGenlockMaxSourceDelayI3D = (PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC)glewGetProcAddress((const GLubyte*)"wglQueryGenlockMaxSourceDelayI3D")) == NULL) || r; return r; } #endif /* WGL_I3D_genlock */ #ifdef WGL_I3D_image_buffer static GLboolean _glewInit_WGL_I3D_image_buffer (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglAssociateImageBufferEventsI3D = (PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC)glewGetProcAddress((const GLubyte*)"wglAssociateImageBufferEventsI3D")) == NULL) || r; r = ((wglCreateImageBufferI3D = (PFNWGLCREATEIMAGEBUFFERI3DPROC)glewGetProcAddress((const GLubyte*)"wglCreateImageBufferI3D")) == NULL) || r; r = ((wglDestroyImageBufferI3D = (PFNWGLDESTROYIMAGEBUFFERI3DPROC)glewGetProcAddress((const GLubyte*)"wglDestroyImageBufferI3D")) == NULL) || r; r = ((wglReleaseImageBufferEventsI3D = (PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC)glewGetProcAddress((const GLubyte*)"wglReleaseImageBufferEventsI3D")) == NULL) || r; return r; } #endif /* WGL_I3D_image_buffer */ #ifdef WGL_I3D_swap_frame_lock static GLboolean _glewInit_WGL_I3D_swap_frame_lock (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglDisableFrameLockI3D = (PFNWGLDISABLEFRAMELOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglDisableFrameLockI3D")) == NULL) || r; r = ((wglEnableFrameLockI3D = (PFNWGLENABLEFRAMELOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglEnableFrameLockI3D")) == NULL) || r; r = ((wglIsEnabledFrameLockI3D = (PFNWGLISENABLEDFRAMELOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglIsEnabledFrameLockI3D")) == NULL) || r; r = ((wglQueryFrameLockMasterI3D = (PFNWGLQUERYFRAMELOCKMASTERI3DPROC)glewGetProcAddress((const GLubyte*)"wglQueryFrameLockMasterI3D")) == NULL) || r; return r; } #endif /* WGL_I3D_swap_frame_lock */ #ifdef WGL_I3D_swap_frame_usage static GLboolean _glewInit_WGL_I3D_swap_frame_usage (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglBeginFrameTrackingI3D = (PFNWGLBEGINFRAMETRACKINGI3DPROC)glewGetProcAddress((const GLubyte*)"wglBeginFrameTrackingI3D")) == NULL) || r; r = ((wglEndFrameTrackingI3D = (PFNWGLENDFRAMETRACKINGI3DPROC)glewGetProcAddress((const GLubyte*)"wglEndFrameTrackingI3D")) == NULL) || r; r = ((wglGetFrameUsageI3D = (PFNWGLGETFRAMEUSAGEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetFrameUsageI3D")) == NULL) || r; r = ((wglQueryFrameTrackingI3D = (PFNWGLQUERYFRAMETRACKINGI3DPROC)glewGetProcAddress((const GLubyte*)"wglQueryFrameTrackingI3D")) == NULL) || r; return r; } #endif /* WGL_I3D_swap_frame_usage */ #ifdef WGL_NV_DX_interop static GLboolean _glewInit_WGL_NV_DX_interop (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglDXCloseDeviceNV = (PFNWGLDXCLOSEDEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglDXCloseDeviceNV")) == NULL) || r; r = ((wglDXLockObjectsNV = (PFNWGLDXLOCKOBJECTSNVPROC)glewGetProcAddress((const GLubyte*)"wglDXLockObjectsNV")) == NULL) || r; r = ((wglDXObjectAccessNV = (PFNWGLDXOBJECTACCESSNVPROC)glewGetProcAddress((const GLubyte*)"wglDXObjectAccessNV")) == NULL) || r; r = ((wglDXOpenDeviceNV = (PFNWGLDXOPENDEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglDXOpenDeviceNV")) == NULL) || r; r = ((wglDXRegisterObjectNV = (PFNWGLDXREGISTEROBJECTNVPROC)glewGetProcAddress((const GLubyte*)"wglDXRegisterObjectNV")) == NULL) || r; r = ((wglDXSetResourceShareHandleNV = (PFNWGLDXSETRESOURCESHAREHANDLENVPROC)glewGetProcAddress((const GLubyte*)"wglDXSetResourceShareHandleNV")) == NULL) || r; r = ((wglDXUnlockObjectsNV = (PFNWGLDXUNLOCKOBJECTSNVPROC)glewGetProcAddress((const GLubyte*)"wglDXUnlockObjectsNV")) == NULL) || r; r = ((wglDXUnregisterObjectNV = (PFNWGLDXUNREGISTEROBJECTNVPROC)glewGetProcAddress((const GLubyte*)"wglDXUnregisterObjectNV")) == NULL) || r; return r; } #endif /* WGL_NV_DX_interop */ #ifdef WGL_NV_copy_image static GLboolean _glewInit_WGL_NV_copy_image (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglCopyImageSubDataNV = (PFNWGLCOPYIMAGESUBDATANVPROC)glewGetProcAddress((const GLubyte*)"wglCopyImageSubDataNV")) == NULL) || r; return r; } #endif /* WGL_NV_copy_image */ #ifdef WGL_NV_delay_before_swap static GLboolean _glewInit_WGL_NV_delay_before_swap (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglDelayBeforeSwapNV = (PFNWGLDELAYBEFORESWAPNVPROC)glewGetProcAddress((const GLubyte*)"wglDelayBeforeSwapNV")) == NULL) || r; return r; } #endif /* WGL_NV_delay_before_swap */ #ifdef WGL_NV_gpu_affinity static GLboolean _glewInit_WGL_NV_gpu_affinity (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglCreateAffinityDCNV = (PFNWGLCREATEAFFINITYDCNVPROC)glewGetProcAddress((const GLubyte*)"wglCreateAffinityDCNV")) == NULL) || r; r = ((wglDeleteDCNV = (PFNWGLDELETEDCNVPROC)glewGetProcAddress((const GLubyte*)"wglDeleteDCNV")) == NULL) || r; r = ((wglEnumGpuDevicesNV = (PFNWGLENUMGPUDEVICESNVPROC)glewGetProcAddress((const GLubyte*)"wglEnumGpuDevicesNV")) == NULL) || r; r = ((wglEnumGpusFromAffinityDCNV = (PFNWGLENUMGPUSFROMAFFINITYDCNVPROC)glewGetProcAddress((const GLubyte*)"wglEnumGpusFromAffinityDCNV")) == NULL) || r; r = ((wglEnumGpusNV = (PFNWGLENUMGPUSNVPROC)glewGetProcAddress((const GLubyte*)"wglEnumGpusNV")) == NULL) || r; return r; } #endif /* WGL_NV_gpu_affinity */ #ifdef WGL_NV_present_video static GLboolean _glewInit_WGL_NV_present_video (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglBindVideoDeviceNV = (PFNWGLBINDVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglBindVideoDeviceNV")) == NULL) || r; r = ((wglEnumerateVideoDevicesNV = (PFNWGLENUMERATEVIDEODEVICESNVPROC)glewGetProcAddress((const GLubyte*)"wglEnumerateVideoDevicesNV")) == NULL) || r; r = ((wglQueryCurrentContextNV = (PFNWGLQUERYCURRENTCONTEXTNVPROC)glewGetProcAddress((const GLubyte*)"wglQueryCurrentContextNV")) == NULL) || r; return r; } #endif /* WGL_NV_present_video */ #ifdef WGL_NV_swap_group static GLboolean _glewInit_WGL_NV_swap_group (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglBindSwapBarrierNV = (PFNWGLBINDSWAPBARRIERNVPROC)glewGetProcAddress((const GLubyte*)"wglBindSwapBarrierNV")) == NULL) || r; r = ((wglJoinSwapGroupNV = (PFNWGLJOINSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)"wglJoinSwapGroupNV")) == NULL) || r; r = ((wglQueryFrameCountNV = (PFNWGLQUERYFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)"wglQueryFrameCountNV")) == NULL) || r; r = ((wglQueryMaxSwapGroupsNV = (PFNWGLQUERYMAXSWAPGROUPSNVPROC)glewGetProcAddress((const GLubyte*)"wglQueryMaxSwapGroupsNV")) == NULL) || r; r = ((wglQuerySwapGroupNV = (PFNWGLQUERYSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)"wglQuerySwapGroupNV")) == NULL) || r; r = ((wglResetFrameCountNV = (PFNWGLRESETFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)"wglResetFrameCountNV")) == NULL) || r; return r; } #endif /* WGL_NV_swap_group */ #ifdef WGL_NV_vertex_array_range static GLboolean _glewInit_WGL_NV_vertex_array_range (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglAllocateMemoryNV = (PFNWGLALLOCATEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)"wglAllocateMemoryNV")) == NULL) || r; r = ((wglFreeMemoryNV = (PFNWGLFREEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)"wglFreeMemoryNV")) == NULL) || r; return r; } #endif /* WGL_NV_vertex_array_range */ #ifdef WGL_NV_video_capture static GLboolean _glewInit_WGL_NV_video_capture (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglBindVideoCaptureDeviceNV = (PFNWGLBINDVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglBindVideoCaptureDeviceNV")) == NULL) || r; r = ((wglEnumerateVideoCaptureDevicesNV = (PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC)glewGetProcAddress((const GLubyte*)"wglEnumerateVideoCaptureDevicesNV")) == NULL) || r; r = ((wglLockVideoCaptureDeviceNV = (PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglLockVideoCaptureDeviceNV")) == NULL) || r; r = ((wglQueryVideoCaptureDeviceNV = (PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglQueryVideoCaptureDeviceNV")) == NULL) || r; r = ((wglReleaseVideoCaptureDeviceNV = (PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglReleaseVideoCaptureDeviceNV")) == NULL) || r; return r; } #endif /* WGL_NV_video_capture */ #ifdef WGL_NV_video_output static GLboolean _glewInit_WGL_NV_video_output (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglBindVideoImageNV = (PFNWGLBINDVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)"wglBindVideoImageNV")) == NULL) || r; r = ((wglGetVideoDeviceNV = (PFNWGLGETVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglGetVideoDeviceNV")) == NULL) || r; r = ((wglGetVideoInfoNV = (PFNWGLGETVIDEOINFONVPROC)glewGetProcAddress((const GLubyte*)"wglGetVideoInfoNV")) == NULL) || r; r = ((wglReleaseVideoDeviceNV = (PFNWGLRELEASEVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglReleaseVideoDeviceNV")) == NULL) || r; r = ((wglReleaseVideoImageNV = (PFNWGLRELEASEVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)"wglReleaseVideoImageNV")) == NULL) || r; r = ((wglSendPbufferToVideoNV = (PFNWGLSENDPBUFFERTOVIDEONVPROC)glewGetProcAddress((const GLubyte*)"wglSendPbufferToVideoNV")) == NULL) || r; return r; } #endif /* WGL_NV_video_output */ #ifdef WGL_OML_sync_control static GLboolean _glewInit_WGL_OML_sync_control (WGLEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((wglGetMscRateOML = (PFNWGLGETMSCRATEOMLPROC)glewGetProcAddress((const GLubyte*)"wglGetMscRateOML")) == NULL) || r; r = ((wglGetSyncValuesOML = (PFNWGLGETSYNCVALUESOMLPROC)glewGetProcAddress((const GLubyte*)"wglGetSyncValuesOML")) == NULL) || r; r = ((wglSwapBuffersMscOML = (PFNWGLSWAPBUFFERSMSCOMLPROC)glewGetProcAddress((const GLubyte*)"wglSwapBuffersMscOML")) == NULL) || r; r = ((wglSwapLayerBuffersMscOML = (PFNWGLSWAPLAYERBUFFERSMSCOMLPROC)glewGetProcAddress((const GLubyte*)"wglSwapLayerBuffersMscOML")) == NULL) || r; r = ((wglWaitForMscOML = (PFNWGLWAITFORMSCOMLPROC)glewGetProcAddress((const GLubyte*)"wglWaitForMscOML")) == NULL) || r; r = ((wglWaitForSbcOML = (PFNWGLWAITFORSBCOMLPROC)glewGetProcAddress((const GLubyte*)"wglWaitForSbcOML")) == NULL) || r; return r; } #endif /* WGL_OML_sync_control */ /* ------------------------------------------------------------------------- */ static PFNWGLGETEXTENSIONSSTRINGARBPROC _wglewGetExtensionsStringARB = NULL; static PFNWGLGETEXTENSIONSSTRINGEXTPROC _wglewGetExtensionsStringEXT = NULL; GLboolean GLEWAPIENTRY wglewGetExtension (const char* name) { const GLubyte* start; const GLubyte* end; if (_wglewGetExtensionsStringARB == NULL) if (_wglewGetExtensionsStringEXT == NULL) return GL_FALSE; else start = (const GLubyte*)_wglewGetExtensionsStringEXT(); else start = (const GLubyte*)_wglewGetExtensionsStringARB(wglGetCurrentDC()); if (start == 0) return GL_FALSE; end = start + _glewStrLen(start); return _glewSearchExtension(name, start, end); } #ifdef GLEW_MX GLenum GLEWAPIENTRY wglewContextInit (WGLEW_CONTEXT_ARG_DEF_LIST) #else GLenum GLEWAPIENTRY wglewInit (WGLEW_CONTEXT_ARG_DEF_LIST) #endif { GLboolean crippled; const GLubyte* extStart; const GLubyte* extEnd; /* find wgl extension string query functions */ _wglewGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringARB"); _wglewGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringEXT"); /* query wgl extension string */ if (_wglewGetExtensionsStringARB == NULL) if (_wglewGetExtensionsStringEXT == NULL) extStart = (const GLubyte*)""; else extStart = (const GLubyte*)_wglewGetExtensionsStringEXT(); else extStart = (const GLubyte*)_wglewGetExtensionsStringARB(wglGetCurrentDC()); extEnd = extStart + _glewStrLen(extStart); /* initialize extensions */ crippled = _wglewGetExtensionsStringARB == NULL && _wglewGetExtensionsStringEXT == NULL; #ifdef WGL_3DFX_multisample WGLEW_3DFX_multisample = _glewSearchExtension("WGL_3DFX_multisample", extStart, extEnd); #endif /* WGL_3DFX_multisample */ #ifdef WGL_3DL_stereo_control WGLEW_3DL_stereo_control = _glewSearchExtension("WGL_3DL_stereo_control", extStart, extEnd); if (glewExperimental || WGLEW_3DL_stereo_control|| crippled) WGLEW_3DL_stereo_control= !_glewInit_WGL_3DL_stereo_control(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_3DL_stereo_control */ #ifdef WGL_AMD_gpu_association WGLEW_AMD_gpu_association = _glewSearchExtension("WGL_AMD_gpu_association", extStart, extEnd); if (glewExperimental || WGLEW_AMD_gpu_association|| crippled) WGLEW_AMD_gpu_association= !_glewInit_WGL_AMD_gpu_association(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_AMD_gpu_association */ #ifdef WGL_ARB_buffer_region WGLEW_ARB_buffer_region = _glewSearchExtension("WGL_ARB_buffer_region", extStart, extEnd); if (glewExperimental || WGLEW_ARB_buffer_region|| crippled) WGLEW_ARB_buffer_region= !_glewInit_WGL_ARB_buffer_region(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_ARB_buffer_region */ #ifdef WGL_ARB_context_flush_control WGLEW_ARB_context_flush_control = _glewSearchExtension("WGL_ARB_context_flush_control", extStart, extEnd); #endif /* WGL_ARB_context_flush_control */ #ifdef WGL_ARB_create_context WGLEW_ARB_create_context = _glewSearchExtension("WGL_ARB_create_context", extStart, extEnd); if (glewExperimental || WGLEW_ARB_create_context|| crippled) WGLEW_ARB_create_context= !_glewInit_WGL_ARB_create_context(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_ARB_create_context */ #ifdef WGL_ARB_create_context_profile WGLEW_ARB_create_context_profile = _glewSearchExtension("WGL_ARB_create_context_profile", extStart, extEnd); #endif /* WGL_ARB_create_context_profile */ #ifdef WGL_ARB_create_context_robustness WGLEW_ARB_create_context_robustness = _glewSearchExtension("WGL_ARB_create_context_robustness", extStart, extEnd); #endif /* WGL_ARB_create_context_robustness */ #ifdef WGL_ARB_extensions_string WGLEW_ARB_extensions_string = _glewSearchExtension("WGL_ARB_extensions_string", extStart, extEnd); if (glewExperimental || WGLEW_ARB_extensions_string|| crippled) WGLEW_ARB_extensions_string= !_glewInit_WGL_ARB_extensions_string(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_ARB_extensions_string */ #ifdef WGL_ARB_framebuffer_sRGB WGLEW_ARB_framebuffer_sRGB = _glewSearchExtension("WGL_ARB_framebuffer_sRGB", extStart, extEnd); #endif /* WGL_ARB_framebuffer_sRGB */ #ifdef WGL_ARB_make_current_read WGLEW_ARB_make_current_read = _glewSearchExtension("WGL_ARB_make_current_read", extStart, extEnd); if (glewExperimental || WGLEW_ARB_make_current_read|| crippled) WGLEW_ARB_make_current_read= !_glewInit_WGL_ARB_make_current_read(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_ARB_make_current_read */ #ifdef WGL_ARB_multisample WGLEW_ARB_multisample = _glewSearchExtension("WGL_ARB_multisample", extStart, extEnd); #endif /* WGL_ARB_multisample */ #ifdef WGL_ARB_pbuffer WGLEW_ARB_pbuffer = _glewSearchExtension("WGL_ARB_pbuffer", extStart, extEnd); if (glewExperimental || WGLEW_ARB_pbuffer|| crippled) WGLEW_ARB_pbuffer= !_glewInit_WGL_ARB_pbuffer(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_ARB_pbuffer */ #ifdef WGL_ARB_pixel_format WGLEW_ARB_pixel_format = _glewSearchExtension("WGL_ARB_pixel_format", extStart, extEnd); if (glewExperimental || WGLEW_ARB_pixel_format|| crippled) WGLEW_ARB_pixel_format= !_glewInit_WGL_ARB_pixel_format(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_ARB_pixel_format */ #ifdef WGL_ARB_pixel_format_float WGLEW_ARB_pixel_format_float = _glewSearchExtension("WGL_ARB_pixel_format_float", extStart, extEnd); #endif /* WGL_ARB_pixel_format_float */ #ifdef WGL_ARB_render_texture WGLEW_ARB_render_texture = _glewSearchExtension("WGL_ARB_render_texture", extStart, extEnd); if (glewExperimental || WGLEW_ARB_render_texture|| crippled) WGLEW_ARB_render_texture= !_glewInit_WGL_ARB_render_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_ARB_render_texture */ #ifdef WGL_ARB_robustness_application_isolation WGLEW_ARB_robustness_application_isolation = _glewSearchExtension("WGL_ARB_robustness_application_isolation", extStart, extEnd); #endif /* WGL_ARB_robustness_application_isolation */ #ifdef WGL_ARB_robustness_share_group_isolation WGLEW_ARB_robustness_share_group_isolation = _glewSearchExtension("WGL_ARB_robustness_share_group_isolation", extStart, extEnd); #endif /* WGL_ARB_robustness_share_group_isolation */ #ifdef WGL_ATI_pixel_format_float WGLEW_ATI_pixel_format_float = _glewSearchExtension("WGL_ATI_pixel_format_float", extStart, extEnd); #endif /* WGL_ATI_pixel_format_float */ #ifdef WGL_ATI_render_texture_rectangle WGLEW_ATI_render_texture_rectangle = _glewSearchExtension("WGL_ATI_render_texture_rectangle", extStart, extEnd); #endif /* WGL_ATI_render_texture_rectangle */ #ifdef WGL_EXT_create_context_es2_profile WGLEW_EXT_create_context_es2_profile = _glewSearchExtension("WGL_EXT_create_context_es2_profile", extStart, extEnd); #endif /* WGL_EXT_create_context_es2_profile */ #ifdef WGL_EXT_create_context_es_profile WGLEW_EXT_create_context_es_profile = _glewSearchExtension("WGL_EXT_create_context_es_profile", extStart, extEnd); #endif /* WGL_EXT_create_context_es_profile */ #ifdef WGL_EXT_depth_float WGLEW_EXT_depth_float = _glewSearchExtension("WGL_EXT_depth_float", extStart, extEnd); #endif /* WGL_EXT_depth_float */ #ifdef WGL_EXT_display_color_table WGLEW_EXT_display_color_table = _glewSearchExtension("WGL_EXT_display_color_table", extStart, extEnd); if (glewExperimental || WGLEW_EXT_display_color_table|| crippled) WGLEW_EXT_display_color_table= !_glewInit_WGL_EXT_display_color_table(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_EXT_display_color_table */ #ifdef WGL_EXT_extensions_string WGLEW_EXT_extensions_string = _glewSearchExtension("WGL_EXT_extensions_string", extStart, extEnd); if (glewExperimental || WGLEW_EXT_extensions_string|| crippled) WGLEW_EXT_extensions_string= !_glewInit_WGL_EXT_extensions_string(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_EXT_extensions_string */ #ifdef WGL_EXT_framebuffer_sRGB WGLEW_EXT_framebuffer_sRGB = _glewSearchExtension("WGL_EXT_framebuffer_sRGB", extStart, extEnd); #endif /* WGL_EXT_framebuffer_sRGB */ #ifdef WGL_EXT_make_current_read WGLEW_EXT_make_current_read = _glewSearchExtension("WGL_EXT_make_current_read", extStart, extEnd); if (glewExperimental || WGLEW_EXT_make_current_read|| crippled) WGLEW_EXT_make_current_read= !_glewInit_WGL_EXT_make_current_read(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_EXT_make_current_read */ #ifdef WGL_EXT_multisample WGLEW_EXT_multisample = _glewSearchExtension("WGL_EXT_multisample", extStart, extEnd); #endif /* WGL_EXT_multisample */ #ifdef WGL_EXT_pbuffer WGLEW_EXT_pbuffer = _glewSearchExtension("WGL_EXT_pbuffer", extStart, extEnd); if (glewExperimental || WGLEW_EXT_pbuffer|| crippled) WGLEW_EXT_pbuffer= !_glewInit_WGL_EXT_pbuffer(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_EXT_pbuffer */ #ifdef WGL_EXT_pixel_format WGLEW_EXT_pixel_format = _glewSearchExtension("WGL_EXT_pixel_format", extStart, extEnd); if (glewExperimental || WGLEW_EXT_pixel_format|| crippled) WGLEW_EXT_pixel_format= !_glewInit_WGL_EXT_pixel_format(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_EXT_pixel_format */ #ifdef WGL_EXT_pixel_format_packed_float WGLEW_EXT_pixel_format_packed_float = _glewSearchExtension("WGL_EXT_pixel_format_packed_float", extStart, extEnd); #endif /* WGL_EXT_pixel_format_packed_float */ #ifdef WGL_EXT_swap_control WGLEW_EXT_swap_control = _glewSearchExtension("WGL_EXT_swap_control", extStart, extEnd); if (glewExperimental || WGLEW_EXT_swap_control|| crippled) WGLEW_EXT_swap_control= !_glewInit_WGL_EXT_swap_control(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_EXT_swap_control */ #ifdef WGL_EXT_swap_control_tear WGLEW_EXT_swap_control_tear = _glewSearchExtension("WGL_EXT_swap_control_tear", extStart, extEnd); #endif /* WGL_EXT_swap_control_tear */ #ifdef WGL_I3D_digital_video_control WGLEW_I3D_digital_video_control = _glewSearchExtension("WGL_I3D_digital_video_control", extStart, extEnd); if (glewExperimental || WGLEW_I3D_digital_video_control|| crippled) WGLEW_I3D_digital_video_control= !_glewInit_WGL_I3D_digital_video_control(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_I3D_digital_video_control */ #ifdef WGL_I3D_gamma WGLEW_I3D_gamma = _glewSearchExtension("WGL_I3D_gamma", extStart, extEnd); if (glewExperimental || WGLEW_I3D_gamma|| crippled) WGLEW_I3D_gamma= !_glewInit_WGL_I3D_gamma(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_I3D_gamma */ #ifdef WGL_I3D_genlock WGLEW_I3D_genlock = _glewSearchExtension("WGL_I3D_genlock", extStart, extEnd); if (glewExperimental || WGLEW_I3D_genlock|| crippled) WGLEW_I3D_genlock= !_glewInit_WGL_I3D_genlock(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_I3D_genlock */ #ifdef WGL_I3D_image_buffer WGLEW_I3D_image_buffer = _glewSearchExtension("WGL_I3D_image_buffer", extStart, extEnd); if (glewExperimental || WGLEW_I3D_image_buffer|| crippled) WGLEW_I3D_image_buffer= !_glewInit_WGL_I3D_image_buffer(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_I3D_image_buffer */ #ifdef WGL_I3D_swap_frame_lock WGLEW_I3D_swap_frame_lock = _glewSearchExtension("WGL_I3D_swap_frame_lock", extStart, extEnd); if (glewExperimental || WGLEW_I3D_swap_frame_lock|| crippled) WGLEW_I3D_swap_frame_lock= !_glewInit_WGL_I3D_swap_frame_lock(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_I3D_swap_frame_lock */ #ifdef WGL_I3D_swap_frame_usage WGLEW_I3D_swap_frame_usage = _glewSearchExtension("WGL_I3D_swap_frame_usage", extStart, extEnd); if (glewExperimental || WGLEW_I3D_swap_frame_usage|| crippled) WGLEW_I3D_swap_frame_usage= !_glewInit_WGL_I3D_swap_frame_usage(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_I3D_swap_frame_usage */ #ifdef WGL_NV_DX_interop WGLEW_NV_DX_interop = _glewSearchExtension("WGL_NV_DX_interop", extStart, extEnd); if (glewExperimental || WGLEW_NV_DX_interop|| crippled) WGLEW_NV_DX_interop= !_glewInit_WGL_NV_DX_interop(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_NV_DX_interop */ #ifdef WGL_NV_DX_interop2 WGLEW_NV_DX_interop2 = _glewSearchExtension("WGL_NV_DX_interop2", extStart, extEnd); #endif /* WGL_NV_DX_interop2 */ #ifdef WGL_NV_copy_image WGLEW_NV_copy_image = _glewSearchExtension("WGL_NV_copy_image", extStart, extEnd); if (glewExperimental || WGLEW_NV_copy_image|| crippled) WGLEW_NV_copy_image= !_glewInit_WGL_NV_copy_image(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_NV_copy_image */ #ifdef WGL_NV_delay_before_swap WGLEW_NV_delay_before_swap = _glewSearchExtension("WGL_NV_delay_before_swap", extStart, extEnd); if (glewExperimental || WGLEW_NV_delay_before_swap|| crippled) WGLEW_NV_delay_before_swap= !_glewInit_WGL_NV_delay_before_swap(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_NV_delay_before_swap */ #ifdef WGL_NV_float_buffer WGLEW_NV_float_buffer = _glewSearchExtension("WGL_NV_float_buffer", extStart, extEnd); #endif /* WGL_NV_float_buffer */ #ifdef WGL_NV_gpu_affinity WGLEW_NV_gpu_affinity = _glewSearchExtension("WGL_NV_gpu_affinity", extStart, extEnd); if (glewExperimental || WGLEW_NV_gpu_affinity|| crippled) WGLEW_NV_gpu_affinity= !_glewInit_WGL_NV_gpu_affinity(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_NV_gpu_affinity */ #ifdef WGL_NV_multisample_coverage WGLEW_NV_multisample_coverage = _glewSearchExtension("WGL_NV_multisample_coverage", extStart, extEnd); #endif /* WGL_NV_multisample_coverage */ #ifdef WGL_NV_present_video WGLEW_NV_present_video = _glewSearchExtension("WGL_NV_present_video", extStart, extEnd); if (glewExperimental || WGLEW_NV_present_video|| crippled) WGLEW_NV_present_video= !_glewInit_WGL_NV_present_video(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_NV_present_video */ #ifdef WGL_NV_render_depth_texture WGLEW_NV_render_depth_texture = _glewSearchExtension("WGL_NV_render_depth_texture", extStart, extEnd); #endif /* WGL_NV_render_depth_texture */ #ifdef WGL_NV_render_texture_rectangle WGLEW_NV_render_texture_rectangle = _glewSearchExtension("WGL_NV_render_texture_rectangle", extStart, extEnd); #endif /* WGL_NV_render_texture_rectangle */ #ifdef WGL_NV_swap_group WGLEW_NV_swap_group = _glewSearchExtension("WGL_NV_swap_group", extStart, extEnd); if (glewExperimental || WGLEW_NV_swap_group|| crippled) WGLEW_NV_swap_group= !_glewInit_WGL_NV_swap_group(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_NV_swap_group */ #ifdef WGL_NV_vertex_array_range WGLEW_NV_vertex_array_range = _glewSearchExtension("WGL_NV_vertex_array_range", extStart, extEnd); if (glewExperimental || WGLEW_NV_vertex_array_range|| crippled) WGLEW_NV_vertex_array_range= !_glewInit_WGL_NV_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_NV_vertex_array_range */ #ifdef WGL_NV_video_capture WGLEW_NV_video_capture = _glewSearchExtension("WGL_NV_video_capture", extStart, extEnd); if (glewExperimental || WGLEW_NV_video_capture|| crippled) WGLEW_NV_video_capture= !_glewInit_WGL_NV_video_capture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_NV_video_capture */ #ifdef WGL_NV_video_output WGLEW_NV_video_output = _glewSearchExtension("WGL_NV_video_output", extStart, extEnd); if (glewExperimental || WGLEW_NV_video_output|| crippled) WGLEW_NV_video_output= !_glewInit_WGL_NV_video_output(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_NV_video_output */ #ifdef WGL_OML_sync_control WGLEW_OML_sync_control = _glewSearchExtension("WGL_OML_sync_control", extStart, extEnd); if (glewExperimental || WGLEW_OML_sync_control|| crippled) WGLEW_OML_sync_control= !_glewInit_WGL_OML_sync_control(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* WGL_OML_sync_control */ return GLEW_OK; } #elif !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX)) PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay = NULL; PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig = NULL; PFNGLXCREATENEWCONTEXTPROC __glewXCreateNewContext = NULL; PFNGLXCREATEPBUFFERPROC __glewXCreatePbuffer = NULL; PFNGLXCREATEPIXMAPPROC __glewXCreatePixmap = NULL; PFNGLXCREATEWINDOWPROC __glewXCreateWindow = NULL; PFNGLXDESTROYPBUFFERPROC __glewXDestroyPbuffer = NULL; PFNGLXDESTROYPIXMAPPROC __glewXDestroyPixmap = NULL; PFNGLXDESTROYWINDOWPROC __glewXDestroyWindow = NULL; PFNGLXGETCURRENTREADDRAWABLEPROC __glewXGetCurrentReadDrawable = NULL; PFNGLXGETFBCONFIGATTRIBPROC __glewXGetFBConfigAttrib = NULL; PFNGLXGETFBCONFIGSPROC __glewXGetFBConfigs = NULL; PFNGLXGETSELECTEDEVENTPROC __glewXGetSelectedEvent = NULL; PFNGLXGETVISUALFROMFBCONFIGPROC __glewXGetVisualFromFBConfig = NULL; PFNGLXMAKECONTEXTCURRENTPROC __glewXMakeContextCurrent = NULL; PFNGLXQUERYCONTEXTPROC __glewXQueryContext = NULL; PFNGLXQUERYDRAWABLEPROC __glewXQueryDrawable = NULL; PFNGLXSELECTEVENTPROC __glewXSelectEvent = NULL; PFNGLXBLITCONTEXTFRAMEBUFFERAMDPROC __glewXBlitContextFramebufferAMD = NULL; PFNGLXCREATEASSOCIATEDCONTEXTAMDPROC __glewXCreateAssociatedContextAMD = NULL; PFNGLXCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __glewXCreateAssociatedContextAttribsAMD = NULL; PFNGLXDELETEASSOCIATEDCONTEXTAMDPROC __glewXDeleteAssociatedContextAMD = NULL; PFNGLXGETCONTEXTGPUIDAMDPROC __glewXGetContextGPUIDAMD = NULL; PFNGLXGETCURRENTASSOCIATEDCONTEXTAMDPROC __glewXGetCurrentAssociatedContextAMD = NULL; PFNGLXGETGPUIDSAMDPROC __glewXGetGPUIDsAMD = NULL; PFNGLXGETGPUINFOAMDPROC __glewXGetGPUInfoAMD = NULL; PFNGLXMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __glewXMakeAssociatedContextCurrentAMD = NULL; PFNGLXCREATECONTEXTATTRIBSARBPROC __glewXCreateContextAttribsARB = NULL; PFNGLXBINDTEXIMAGEATIPROC __glewXBindTexImageATI = NULL; PFNGLXDRAWABLEATTRIBATIPROC __glewXDrawableAttribATI = NULL; PFNGLXRELEASETEXIMAGEATIPROC __glewXReleaseTexImageATI = NULL; PFNGLXFREECONTEXTEXTPROC __glewXFreeContextEXT = NULL; PFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT = NULL; PFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT = NULL; PFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT = NULL; PFNGLXSWAPINTERVALEXTPROC __glewXSwapIntervalEXT = NULL; PFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT = NULL; PFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT = NULL; PFNGLXGETAGPOFFSETMESAPROC __glewXGetAGPOffsetMESA = NULL; PFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA = NULL; PFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA = NULL; PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC __glewXQueryCurrentRendererIntegerMESA = NULL; PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC __glewXQueryCurrentRendererStringMESA = NULL; PFNGLXQUERYRENDERERINTEGERMESAPROC __glewXQueryRendererIntegerMESA = NULL; PFNGLXQUERYRENDERERSTRINGMESAPROC __glewXQueryRendererStringMESA = NULL; PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA = NULL; PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA = NULL; PFNGLXGETSWAPINTERVALMESAPROC __glewXGetSwapIntervalMESA = NULL; PFNGLXSWAPINTERVALMESAPROC __glewXSwapIntervalMESA = NULL; PFNGLXCOPYBUFFERSUBDATANVPROC __glewXCopyBufferSubDataNV = NULL; PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC __glewXNamedCopyBufferSubDataNV = NULL; PFNGLXCOPYIMAGESUBDATANVPROC __glewXCopyImageSubDataNV = NULL; PFNGLXDELAYBEFORESWAPNVPROC __glewXDelayBeforeSwapNV = NULL; PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV = NULL; PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV = NULL; PFNGLXBINDSWAPBARRIERNVPROC __glewXBindSwapBarrierNV = NULL; PFNGLXJOINSWAPGROUPNVPROC __glewXJoinSwapGroupNV = NULL; PFNGLXQUERYFRAMECOUNTNVPROC __glewXQueryFrameCountNV = NULL; PFNGLXQUERYMAXSWAPGROUPSNVPROC __glewXQueryMaxSwapGroupsNV = NULL; PFNGLXQUERYSWAPGROUPNVPROC __glewXQuerySwapGroupNV = NULL; PFNGLXRESETFRAMECOUNTNVPROC __glewXResetFrameCountNV = NULL; PFNGLXALLOCATEMEMORYNVPROC __glewXAllocateMemoryNV = NULL; PFNGLXFREEMEMORYNVPROC __glewXFreeMemoryNV = NULL; PFNGLXBINDVIDEOCAPTUREDEVICENVPROC __glewXBindVideoCaptureDeviceNV = NULL; PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC __glewXEnumerateVideoCaptureDevicesNV = NULL; PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC __glewXLockVideoCaptureDeviceNV = NULL; PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC __glewXQueryVideoCaptureDeviceNV = NULL; PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC __glewXReleaseVideoCaptureDeviceNV = NULL; PFNGLXBINDVIDEOIMAGENVPROC __glewXBindVideoImageNV = NULL; PFNGLXGETVIDEODEVICENVPROC __glewXGetVideoDeviceNV = NULL; PFNGLXGETVIDEOINFONVPROC __glewXGetVideoInfoNV = NULL; PFNGLXRELEASEVIDEODEVICENVPROC __glewXReleaseVideoDeviceNV = NULL; PFNGLXRELEASEVIDEOIMAGENVPROC __glewXReleaseVideoImageNV = NULL; PFNGLXSENDPBUFFERTOVIDEONVPROC __glewXSendPbufferToVideoNV = NULL; PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML = NULL; PFNGLXGETSYNCVALUESOMLPROC __glewXGetSyncValuesOML = NULL; PFNGLXSWAPBUFFERSMSCOMLPROC __glewXSwapBuffersMscOML = NULL; PFNGLXWAITFORMSCOMLPROC __glewXWaitForMscOML = NULL; PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML = NULL; PFNGLXCHOOSEFBCONFIGSGIXPROC __glewXChooseFBConfigSGIX = NULL; PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC __glewXCreateContextWithConfigSGIX = NULL; PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC __glewXCreateGLXPixmapWithConfigSGIX = NULL; PFNGLXGETFBCONFIGATTRIBSGIXPROC __glewXGetFBConfigAttribSGIX = NULL; PFNGLXGETFBCONFIGFROMVISUALSGIXPROC __glewXGetFBConfigFromVisualSGIX = NULL; PFNGLXGETVISUALFROMFBCONFIGSGIXPROC __glewXGetVisualFromFBConfigSGIX = NULL; PFNGLXBINDHYPERPIPESGIXPROC __glewXBindHyperpipeSGIX = NULL; PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC __glewXDestroyHyperpipeConfigSGIX = NULL; PFNGLXHYPERPIPEATTRIBSGIXPROC __glewXHyperpipeAttribSGIX = NULL; PFNGLXHYPERPIPECONFIGSGIXPROC __glewXHyperpipeConfigSGIX = NULL; PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC __glewXQueryHyperpipeAttribSGIX = NULL; PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC __glewXQueryHyperpipeBestAttribSGIX = NULL; PFNGLXQUERYHYPERPIPECONFIGSGIXPROC __glewXQueryHyperpipeConfigSGIX = NULL; PFNGLXQUERYHYPERPIPENETWORKSGIXPROC __glewXQueryHyperpipeNetworkSGIX = NULL; PFNGLXCREATEGLXPBUFFERSGIXPROC __glewXCreateGLXPbufferSGIX = NULL; PFNGLXDESTROYGLXPBUFFERSGIXPROC __glewXDestroyGLXPbufferSGIX = NULL; PFNGLXGETSELECTEDEVENTSGIXPROC __glewXGetSelectedEventSGIX = NULL; PFNGLXQUERYGLXPBUFFERSGIXPROC __glewXQueryGLXPbufferSGIX = NULL; PFNGLXSELECTEVENTSGIXPROC __glewXSelectEventSGIX = NULL; PFNGLXBINDSWAPBARRIERSGIXPROC __glewXBindSwapBarrierSGIX = NULL; PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC __glewXQueryMaxSwapBarriersSGIX = NULL; PFNGLXJOINSWAPGROUPSGIXPROC __glewXJoinSwapGroupSGIX = NULL; PFNGLXBINDCHANNELTOWINDOWSGIXPROC __glewXBindChannelToWindowSGIX = NULL; PFNGLXCHANNELRECTSGIXPROC __glewXChannelRectSGIX = NULL; PFNGLXCHANNELRECTSYNCSGIXPROC __glewXChannelRectSyncSGIX = NULL; PFNGLXQUERYCHANNELDELTASSGIXPROC __glewXQueryChannelDeltasSGIX = NULL; PFNGLXQUERYCHANNELRECTSGIXPROC __glewXQueryChannelRectSGIX = NULL; PFNGLXCUSHIONSGIPROC __glewXCushionSGI = NULL; PFNGLXGETCURRENTREADDRAWABLESGIPROC __glewXGetCurrentReadDrawableSGI = NULL; PFNGLXMAKECURRENTREADSGIPROC __glewXMakeCurrentReadSGI = NULL; PFNGLXSWAPINTERVALSGIPROC __glewXSwapIntervalSGI = NULL; PFNGLXGETVIDEOSYNCSGIPROC __glewXGetVideoSyncSGI = NULL; PFNGLXWAITVIDEOSYNCSGIPROC __glewXWaitVideoSyncSGI = NULL; PFNGLXGETTRANSPARENTINDEXSUNPROC __glewXGetTransparentIndexSUN = NULL; PFNGLXGETVIDEORESIZESUNPROC __glewXGetVideoResizeSUN = NULL; PFNGLXVIDEORESIZESUNPROC __glewXVideoResizeSUN = NULL; #if !defined(GLEW_MX) GLboolean __GLXEW_VERSION_1_0 = GL_FALSE; GLboolean __GLXEW_VERSION_1_1 = GL_FALSE; GLboolean __GLXEW_VERSION_1_2 = GL_FALSE; GLboolean __GLXEW_VERSION_1_3 = GL_FALSE; GLboolean __GLXEW_VERSION_1_4 = GL_FALSE; GLboolean __GLXEW_3DFX_multisample = GL_FALSE; GLboolean __GLXEW_AMD_gpu_association = GL_FALSE; GLboolean __GLXEW_ARB_context_flush_control = GL_FALSE; GLboolean __GLXEW_ARB_create_context = GL_FALSE; GLboolean __GLXEW_ARB_create_context_profile = GL_FALSE; GLboolean __GLXEW_ARB_create_context_robustness = GL_FALSE; GLboolean __GLXEW_ARB_fbconfig_float = GL_FALSE; GLboolean __GLXEW_ARB_framebuffer_sRGB = GL_FALSE; GLboolean __GLXEW_ARB_get_proc_address = GL_FALSE; GLboolean __GLXEW_ARB_multisample = GL_FALSE; GLboolean __GLXEW_ARB_robustness_application_isolation = GL_FALSE; GLboolean __GLXEW_ARB_robustness_share_group_isolation = GL_FALSE; GLboolean __GLXEW_ARB_vertex_buffer_object = GL_FALSE; GLboolean __GLXEW_ATI_pixel_format_float = GL_FALSE; GLboolean __GLXEW_ATI_render_texture = GL_FALSE; GLboolean __GLXEW_EXT_buffer_age = GL_FALSE; GLboolean __GLXEW_EXT_create_context_es2_profile = GL_FALSE; GLboolean __GLXEW_EXT_create_context_es_profile = GL_FALSE; GLboolean __GLXEW_EXT_fbconfig_packed_float = GL_FALSE; GLboolean __GLXEW_EXT_framebuffer_sRGB = GL_FALSE; GLboolean __GLXEW_EXT_import_context = GL_FALSE; GLboolean __GLXEW_EXT_scene_marker = GL_FALSE; GLboolean __GLXEW_EXT_stereo_tree = GL_FALSE; GLboolean __GLXEW_EXT_swap_control = GL_FALSE; GLboolean __GLXEW_EXT_swap_control_tear = GL_FALSE; GLboolean __GLXEW_EXT_texture_from_pixmap = GL_FALSE; GLboolean __GLXEW_EXT_visual_info = GL_FALSE; GLboolean __GLXEW_EXT_visual_rating = GL_FALSE; GLboolean __GLXEW_INTEL_swap_event = GL_FALSE; GLboolean __GLXEW_MESA_agp_offset = GL_FALSE; GLboolean __GLXEW_MESA_copy_sub_buffer = GL_FALSE; GLboolean __GLXEW_MESA_pixmap_colormap = GL_FALSE; GLboolean __GLXEW_MESA_query_renderer = GL_FALSE; GLboolean __GLXEW_MESA_release_buffers = GL_FALSE; GLboolean __GLXEW_MESA_set_3dfx_mode = GL_FALSE; GLboolean __GLXEW_MESA_swap_control = GL_FALSE; GLboolean __GLXEW_NV_copy_buffer = GL_FALSE; GLboolean __GLXEW_NV_copy_image = GL_FALSE; GLboolean __GLXEW_NV_delay_before_swap = GL_FALSE; GLboolean __GLXEW_NV_float_buffer = GL_FALSE; GLboolean __GLXEW_NV_multisample_coverage = GL_FALSE; GLboolean __GLXEW_NV_present_video = GL_FALSE; GLboolean __GLXEW_NV_swap_group = GL_FALSE; GLboolean __GLXEW_NV_vertex_array_range = GL_FALSE; GLboolean __GLXEW_NV_video_capture = GL_FALSE; GLboolean __GLXEW_NV_video_out = GL_FALSE; GLboolean __GLXEW_OML_swap_method = GL_FALSE; GLboolean __GLXEW_OML_sync_control = GL_FALSE; GLboolean __GLXEW_SGIS_blended_overlay = GL_FALSE; GLboolean __GLXEW_SGIS_color_range = GL_FALSE; GLboolean __GLXEW_SGIS_multisample = GL_FALSE; GLboolean __GLXEW_SGIS_shared_multisample = GL_FALSE; GLboolean __GLXEW_SGIX_fbconfig = GL_FALSE; GLboolean __GLXEW_SGIX_hyperpipe = GL_FALSE; GLboolean __GLXEW_SGIX_pbuffer = GL_FALSE; GLboolean __GLXEW_SGIX_swap_barrier = GL_FALSE; GLboolean __GLXEW_SGIX_swap_group = GL_FALSE; GLboolean __GLXEW_SGIX_video_resize = GL_FALSE; GLboolean __GLXEW_SGIX_visual_select_group = GL_FALSE; GLboolean __GLXEW_SGI_cushion = GL_FALSE; GLboolean __GLXEW_SGI_make_current_read = GL_FALSE; GLboolean __GLXEW_SGI_swap_control = GL_FALSE; GLboolean __GLXEW_SGI_video_sync = GL_FALSE; GLboolean __GLXEW_SUN_get_transparent_index = GL_FALSE; GLboolean __GLXEW_SUN_video_resize = GL_FALSE; #endif /* !GLEW_MX */ #ifdef GLX_VERSION_1_2 static GLboolean _glewInit_GLX_VERSION_1_2 (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXGetCurrentDisplay = (PFNGLXGETCURRENTDISPLAYPROC)glewGetProcAddress((const GLubyte*)"glXGetCurrentDisplay")) == NULL) || r; return r; } #endif /* GLX_VERSION_1_2 */ #ifdef GLX_VERSION_1_3 static GLboolean _glewInit_GLX_VERSION_1_3 (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glewGetProcAddress((const GLubyte*)"glXChooseFBConfig")) == NULL) || r; r = ((glXCreateNewContext = (PFNGLXCREATENEWCONTEXTPROC)glewGetProcAddress((const GLubyte*)"glXCreateNewContext")) == NULL) || r; r = ((glXCreatePbuffer = (PFNGLXCREATEPBUFFERPROC)glewGetProcAddress((const GLubyte*)"glXCreatePbuffer")) == NULL) || r; r = ((glXCreatePixmap = (PFNGLXCREATEPIXMAPPROC)glewGetProcAddress((const GLubyte*)"glXCreatePixmap")) == NULL) || r; r = ((glXCreateWindow = (PFNGLXCREATEWINDOWPROC)glewGetProcAddress((const GLubyte*)"glXCreateWindow")) == NULL) || r; r = ((glXDestroyPbuffer = (PFNGLXDESTROYPBUFFERPROC)glewGetProcAddress((const GLubyte*)"glXDestroyPbuffer")) == NULL) || r; r = ((glXDestroyPixmap = (PFNGLXDESTROYPIXMAPPROC)glewGetProcAddress((const GLubyte*)"glXDestroyPixmap")) == NULL) || r; r = ((glXDestroyWindow = (PFNGLXDESTROYWINDOWPROC)glewGetProcAddress((const GLubyte*)"glXDestroyWindow")) == NULL) || r; r = ((glXGetCurrentReadDrawable = (PFNGLXGETCURRENTREADDRAWABLEPROC)glewGetProcAddress((const GLubyte*)"glXGetCurrentReadDrawable")) == NULL) || r; r = ((glXGetFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC)glewGetProcAddress((const GLubyte*)"glXGetFBConfigAttrib")) == NULL) || r; r = ((glXGetFBConfigs = (PFNGLXGETFBCONFIGSPROC)glewGetProcAddress((const GLubyte*)"glXGetFBConfigs")) == NULL) || r; r = ((glXGetSelectedEvent = (PFNGLXGETSELECTEDEVENTPROC)glewGetProcAddress((const GLubyte*)"glXGetSelectedEvent")) == NULL) || r; r = ((glXGetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)glewGetProcAddress((const GLubyte*)"glXGetVisualFromFBConfig")) == NULL) || r; r = ((glXMakeContextCurrent = (PFNGLXMAKECONTEXTCURRENTPROC)glewGetProcAddress((const GLubyte*)"glXMakeContextCurrent")) == NULL) || r; r = ((glXQueryContext = (PFNGLXQUERYCONTEXTPROC)glewGetProcAddress((const GLubyte*)"glXQueryContext")) == NULL) || r; r = ((glXQueryDrawable = (PFNGLXQUERYDRAWABLEPROC)glewGetProcAddress((const GLubyte*)"glXQueryDrawable")) == NULL) || r; r = ((glXSelectEvent = (PFNGLXSELECTEVENTPROC)glewGetProcAddress((const GLubyte*)"glXSelectEvent")) == NULL) || r; return r; } #endif /* GLX_VERSION_1_3 */ #ifdef GLX_AMD_gpu_association static GLboolean _glewInit_GLX_AMD_gpu_association (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXBlitContextFramebufferAMD = (PFNGLXBLITCONTEXTFRAMEBUFFERAMDPROC)glewGetProcAddress((const GLubyte*)"glXBlitContextFramebufferAMD")) == NULL) || r; r = ((glXCreateAssociatedContextAMD = (PFNGLXCREATEASSOCIATEDCONTEXTAMDPROC)glewGetProcAddress((const GLubyte*)"glXCreateAssociatedContextAMD")) == NULL) || r; r = ((glXCreateAssociatedContextAttribsAMD = (PFNGLXCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC)glewGetProcAddress((const GLubyte*)"glXCreateAssociatedContextAttribsAMD")) == NULL) || r; r = ((glXDeleteAssociatedContextAMD = (PFNGLXDELETEASSOCIATEDCONTEXTAMDPROC)glewGetProcAddress((const GLubyte*)"glXDeleteAssociatedContextAMD")) == NULL) || r; r = ((glXGetContextGPUIDAMD = (PFNGLXGETCONTEXTGPUIDAMDPROC)glewGetProcAddress((const GLubyte*)"glXGetContextGPUIDAMD")) == NULL) || r; r = ((glXGetCurrentAssociatedContextAMD = (PFNGLXGETCURRENTASSOCIATEDCONTEXTAMDPROC)glewGetProcAddress((const GLubyte*)"glXGetCurrentAssociatedContextAMD")) == NULL) || r; r = ((glXGetGPUIDsAMD = (PFNGLXGETGPUIDSAMDPROC)glewGetProcAddress((const GLubyte*)"glXGetGPUIDsAMD")) == NULL) || r; r = ((glXGetGPUInfoAMD = (PFNGLXGETGPUINFOAMDPROC)glewGetProcAddress((const GLubyte*)"glXGetGPUInfoAMD")) == NULL) || r; r = ((glXMakeAssociatedContextCurrentAMD = (PFNGLXMAKEASSOCIATEDCONTEXTCURRENTAMDPROC)glewGetProcAddress((const GLubyte*)"glXMakeAssociatedContextCurrentAMD")) == NULL) || r; return r; } #endif /* GLX_AMD_gpu_association */ #ifdef GLX_ARB_create_context static GLboolean _glewInit_GLX_ARB_create_context (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glewGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB")) == NULL) || r; return r; } #endif /* GLX_ARB_create_context */ #ifdef GLX_ATI_render_texture static GLboolean _glewInit_GLX_ATI_render_texture (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXBindTexImageATI = (PFNGLXBINDTEXIMAGEATIPROC)glewGetProcAddress((const GLubyte*)"glXBindTexImageATI")) == NULL) || r; r = ((glXDrawableAttribATI = (PFNGLXDRAWABLEATTRIBATIPROC)glewGetProcAddress((const GLubyte*)"glXDrawableAttribATI")) == NULL) || r; r = ((glXReleaseTexImageATI = (PFNGLXRELEASETEXIMAGEATIPROC)glewGetProcAddress((const GLubyte*)"glXReleaseTexImageATI")) == NULL) || r; return r; } #endif /* GLX_ATI_render_texture */ #ifdef GLX_EXT_import_context static GLboolean _glewInit_GLX_EXT_import_context (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXFreeContextEXT = (PFNGLXFREECONTEXTEXTPROC)glewGetProcAddress((const GLubyte*)"glXFreeContextEXT")) == NULL) || r; r = ((glXGetContextIDEXT = (PFNGLXGETCONTEXTIDEXTPROC)glewGetProcAddress((const GLubyte*)"glXGetContextIDEXT")) == NULL) || r; r = ((glXImportContextEXT = (PFNGLXIMPORTCONTEXTEXTPROC)glewGetProcAddress((const GLubyte*)"glXImportContextEXT")) == NULL) || r; r = ((glXQueryContextInfoEXT = (PFNGLXQUERYCONTEXTINFOEXTPROC)glewGetProcAddress((const GLubyte*)"glXQueryContextInfoEXT")) == NULL) || r; return r; } #endif /* GLX_EXT_import_context */ #ifdef GLX_EXT_swap_control static GLboolean _glewInit_GLX_EXT_swap_control (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glewGetProcAddress((const GLubyte*)"glXSwapIntervalEXT")) == NULL) || r; return r; } #endif /* GLX_EXT_swap_control */ #ifdef GLX_EXT_texture_from_pixmap static GLboolean _glewInit_GLX_EXT_texture_from_pixmap (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glXBindTexImageEXT")) == NULL) || r; r = ((glXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glXReleaseTexImageEXT")) == NULL) || r; return r; } #endif /* GLX_EXT_texture_from_pixmap */ #ifdef GLX_MESA_agp_offset static GLboolean _glewInit_GLX_MESA_agp_offset (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXGetAGPOffsetMESA = (PFNGLXGETAGPOFFSETMESAPROC)glewGetProcAddress((const GLubyte*)"glXGetAGPOffsetMESA")) == NULL) || r; return r; } #endif /* GLX_MESA_agp_offset */ #ifdef GLX_MESA_copy_sub_buffer static GLboolean _glewInit_GLX_MESA_copy_sub_buffer (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXCopySubBufferMESA = (PFNGLXCOPYSUBBUFFERMESAPROC)glewGetProcAddress((const GLubyte*)"glXCopySubBufferMESA")) == NULL) || r; return r; } #endif /* GLX_MESA_copy_sub_buffer */ #ifdef GLX_MESA_pixmap_colormap static GLboolean _glewInit_GLX_MESA_pixmap_colormap (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXCreateGLXPixmapMESA = (PFNGLXCREATEGLXPIXMAPMESAPROC)glewGetProcAddress((const GLubyte*)"glXCreateGLXPixmapMESA")) == NULL) || r; return r; } #endif /* GLX_MESA_pixmap_colormap */ #ifdef GLX_MESA_query_renderer static GLboolean _glewInit_GLX_MESA_query_renderer (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXQueryCurrentRendererIntegerMESA = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)glewGetProcAddress((const GLubyte*)"glXQueryCurrentRendererIntegerMESA")) == NULL) || r; r = ((glXQueryCurrentRendererStringMESA = (PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC)glewGetProcAddress((const GLubyte*)"glXQueryCurrentRendererStringMESA")) == NULL) || r; r = ((glXQueryRendererIntegerMESA = (PFNGLXQUERYRENDERERINTEGERMESAPROC)glewGetProcAddress((const GLubyte*)"glXQueryRendererIntegerMESA")) == NULL) || r; r = ((glXQueryRendererStringMESA = (PFNGLXQUERYRENDERERSTRINGMESAPROC)glewGetProcAddress((const GLubyte*)"glXQueryRendererStringMESA")) == NULL) || r; return r; } #endif /* GLX_MESA_query_renderer */ #ifdef GLX_MESA_release_buffers static GLboolean _glewInit_GLX_MESA_release_buffers (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXReleaseBuffersMESA = (PFNGLXRELEASEBUFFERSMESAPROC)glewGetProcAddress((const GLubyte*)"glXReleaseBuffersMESA")) == NULL) || r; return r; } #endif /* GLX_MESA_release_buffers */ #ifdef GLX_MESA_set_3dfx_mode static GLboolean _glewInit_GLX_MESA_set_3dfx_mode (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXSet3DfxModeMESA = (PFNGLXSET3DFXMODEMESAPROC)glewGetProcAddress((const GLubyte*)"glXSet3DfxModeMESA")) == NULL) || r; return r; } #endif /* GLX_MESA_set_3dfx_mode */ #ifdef GLX_MESA_swap_control static GLboolean _glewInit_GLX_MESA_swap_control (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXGetSwapIntervalMESA = (PFNGLXGETSWAPINTERVALMESAPROC)glewGetProcAddress((const GLubyte*)"glXGetSwapIntervalMESA")) == NULL) || r; r = ((glXSwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)glewGetProcAddress((const GLubyte*)"glXSwapIntervalMESA")) == NULL) || r; return r; } #endif /* GLX_MESA_swap_control */ #ifdef GLX_NV_copy_buffer static GLboolean _glewInit_GLX_NV_copy_buffer (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXCopyBufferSubDataNV = (PFNGLXCOPYBUFFERSUBDATANVPROC)glewGetProcAddress((const GLubyte*)"glXCopyBufferSubDataNV")) == NULL) || r; r = ((glXNamedCopyBufferSubDataNV = (PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC)glewGetProcAddress((const GLubyte*)"glXNamedCopyBufferSubDataNV")) == NULL) || r; return r; } #endif /* GLX_NV_copy_buffer */ #ifdef GLX_NV_copy_image static GLboolean _glewInit_GLX_NV_copy_image (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXCopyImageSubDataNV = (PFNGLXCOPYIMAGESUBDATANVPROC)glewGetProcAddress((const GLubyte*)"glXCopyImageSubDataNV")) == NULL) || r; return r; } #endif /* GLX_NV_copy_image */ #ifdef GLX_NV_delay_before_swap static GLboolean _glewInit_GLX_NV_delay_before_swap (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXDelayBeforeSwapNV = (PFNGLXDELAYBEFORESWAPNVPROC)glewGetProcAddress((const GLubyte*)"glXDelayBeforeSwapNV")) == NULL) || r; return r; } #endif /* GLX_NV_delay_before_swap */ #ifdef GLX_NV_present_video static GLboolean _glewInit_GLX_NV_present_video (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXBindVideoDeviceNV = (PFNGLXBINDVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"glXBindVideoDeviceNV")) == NULL) || r; r = ((glXEnumerateVideoDevicesNV = (PFNGLXENUMERATEVIDEODEVICESNVPROC)glewGetProcAddress((const GLubyte*)"glXEnumerateVideoDevicesNV")) == NULL) || r; return r; } #endif /* GLX_NV_present_video */ #ifdef GLX_NV_swap_group static GLboolean _glewInit_GLX_NV_swap_group (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXBindSwapBarrierNV = (PFNGLXBINDSWAPBARRIERNVPROC)glewGetProcAddress((const GLubyte*)"glXBindSwapBarrierNV")) == NULL) || r; r = ((glXJoinSwapGroupNV = (PFNGLXJOINSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)"glXJoinSwapGroupNV")) == NULL) || r; r = ((glXQueryFrameCountNV = (PFNGLXQUERYFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)"glXQueryFrameCountNV")) == NULL) || r; r = ((glXQueryMaxSwapGroupsNV = (PFNGLXQUERYMAXSWAPGROUPSNVPROC)glewGetProcAddress((const GLubyte*)"glXQueryMaxSwapGroupsNV")) == NULL) || r; r = ((glXQuerySwapGroupNV = (PFNGLXQUERYSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)"glXQuerySwapGroupNV")) == NULL) || r; r = ((glXResetFrameCountNV = (PFNGLXRESETFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)"glXResetFrameCountNV")) == NULL) || r; return r; } #endif /* GLX_NV_swap_group */ #ifdef GLX_NV_vertex_array_range static GLboolean _glewInit_GLX_NV_vertex_array_range (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXAllocateMemoryNV = (PFNGLXALLOCATEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)"glXAllocateMemoryNV")) == NULL) || r; r = ((glXFreeMemoryNV = (PFNGLXFREEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)"glXFreeMemoryNV")) == NULL) || r; return r; } #endif /* GLX_NV_vertex_array_range */ #ifdef GLX_NV_video_capture static GLboolean _glewInit_GLX_NV_video_capture (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXBindVideoCaptureDeviceNV = (PFNGLXBINDVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)"glXBindVideoCaptureDeviceNV")) == NULL) || r; r = ((glXEnumerateVideoCaptureDevicesNV = (PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC)glewGetProcAddress((const GLubyte*)"glXEnumerateVideoCaptureDevicesNV")) == NULL) || r; r = ((glXLockVideoCaptureDeviceNV = (PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)"glXLockVideoCaptureDeviceNV")) == NULL) || r; r = ((glXQueryVideoCaptureDeviceNV = (PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)"glXQueryVideoCaptureDeviceNV")) == NULL) || r; r = ((glXReleaseVideoCaptureDeviceNV = (PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)"glXReleaseVideoCaptureDeviceNV")) == NULL) || r; return r; } #endif /* GLX_NV_video_capture */ #ifdef GLX_NV_video_out static GLboolean _glewInit_GLX_NV_video_out (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXBindVideoImageNV = (PFNGLXBINDVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)"glXBindVideoImageNV")) == NULL) || r; r = ((glXGetVideoDeviceNV = (PFNGLXGETVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"glXGetVideoDeviceNV")) == NULL) || r; r = ((glXGetVideoInfoNV = (PFNGLXGETVIDEOINFONVPROC)glewGetProcAddress((const GLubyte*)"glXGetVideoInfoNV")) == NULL) || r; r = ((glXReleaseVideoDeviceNV = (PFNGLXRELEASEVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"glXReleaseVideoDeviceNV")) == NULL) || r; r = ((glXReleaseVideoImageNV = (PFNGLXRELEASEVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)"glXReleaseVideoImageNV")) == NULL) || r; r = ((glXSendPbufferToVideoNV = (PFNGLXSENDPBUFFERTOVIDEONVPROC)glewGetProcAddress((const GLubyte*)"glXSendPbufferToVideoNV")) == NULL) || r; return r; } #endif /* GLX_NV_video_out */ #ifdef GLX_OML_sync_control static GLboolean _glewInit_GLX_OML_sync_control (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXGetMscRateOML = (PFNGLXGETMSCRATEOMLPROC)glewGetProcAddress((const GLubyte*)"glXGetMscRateOML")) == NULL) || r; r = ((glXGetSyncValuesOML = (PFNGLXGETSYNCVALUESOMLPROC)glewGetProcAddress((const GLubyte*)"glXGetSyncValuesOML")) == NULL) || r; r = ((glXSwapBuffersMscOML = (PFNGLXSWAPBUFFERSMSCOMLPROC)glewGetProcAddress((const GLubyte*)"glXSwapBuffersMscOML")) == NULL) || r; r = ((glXWaitForMscOML = (PFNGLXWAITFORMSCOMLPROC)glewGetProcAddress((const GLubyte*)"glXWaitForMscOML")) == NULL) || r; r = ((glXWaitForSbcOML = (PFNGLXWAITFORSBCOMLPROC)glewGetProcAddress((const GLubyte*)"glXWaitForSbcOML")) == NULL) || r; return r; } #endif /* GLX_OML_sync_control */ #ifdef GLX_SGIX_fbconfig static GLboolean _glewInit_GLX_SGIX_fbconfig (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXChooseFBConfigSGIX = (PFNGLXCHOOSEFBCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXChooseFBConfigSGIX")) == NULL) || r; r = ((glXCreateContextWithConfigSGIX = (PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXCreateContextWithConfigSGIX")) == NULL) || r; r = ((glXCreateGLXPixmapWithConfigSGIX = (PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXCreateGLXPixmapWithConfigSGIX")) == NULL) || r; r = ((glXGetFBConfigAttribSGIX = (PFNGLXGETFBCONFIGATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)"glXGetFBConfigAttribSGIX")) == NULL) || r; r = ((glXGetFBConfigFromVisualSGIX = (PFNGLXGETFBCONFIGFROMVISUALSGIXPROC)glewGetProcAddress((const GLubyte*)"glXGetFBConfigFromVisualSGIX")) == NULL) || r; r = ((glXGetVisualFromFBConfigSGIX = (PFNGLXGETVISUALFROMFBCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXGetVisualFromFBConfigSGIX")) == NULL) || r; return r; } #endif /* GLX_SGIX_fbconfig */ #ifdef GLX_SGIX_hyperpipe static GLboolean _glewInit_GLX_SGIX_hyperpipe (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXBindHyperpipeSGIX = (PFNGLXBINDHYPERPIPESGIXPROC)glewGetProcAddress((const GLubyte*)"glXBindHyperpipeSGIX")) == NULL) || r; r = ((glXDestroyHyperpipeConfigSGIX = (PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXDestroyHyperpipeConfigSGIX")) == NULL) || r; r = ((glXHyperpipeAttribSGIX = (PFNGLXHYPERPIPEATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)"glXHyperpipeAttribSGIX")) == NULL) || r; r = ((glXHyperpipeConfigSGIX = (PFNGLXHYPERPIPECONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXHyperpipeConfigSGIX")) == NULL) || r; r = ((glXQueryHyperpipeAttribSGIX = (PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryHyperpipeAttribSGIX")) == NULL) || r; r = ((glXQueryHyperpipeBestAttribSGIX = (PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryHyperpipeBestAttribSGIX")) == NULL) || r; r = ((glXQueryHyperpipeConfigSGIX = (PFNGLXQUERYHYPERPIPECONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryHyperpipeConfigSGIX")) == NULL) || r; r = ((glXQueryHyperpipeNetworkSGIX = (PFNGLXQUERYHYPERPIPENETWORKSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryHyperpipeNetworkSGIX")) == NULL) || r; return r; } #endif /* GLX_SGIX_hyperpipe */ #ifdef GLX_SGIX_pbuffer static GLboolean _glewInit_GLX_SGIX_pbuffer (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXCreateGLXPbufferSGIX = (PFNGLXCREATEGLXPBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)"glXCreateGLXPbufferSGIX")) == NULL) || r; r = ((glXDestroyGLXPbufferSGIX = (PFNGLXDESTROYGLXPBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)"glXDestroyGLXPbufferSGIX")) == NULL) || r; r = ((glXGetSelectedEventSGIX = (PFNGLXGETSELECTEDEVENTSGIXPROC)glewGetProcAddress((const GLubyte*)"glXGetSelectedEventSGIX")) == NULL) || r; r = ((glXQueryGLXPbufferSGIX = (PFNGLXQUERYGLXPBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryGLXPbufferSGIX")) == NULL) || r; r = ((glXSelectEventSGIX = (PFNGLXSELECTEVENTSGIXPROC)glewGetProcAddress((const GLubyte*)"glXSelectEventSGIX")) == NULL) || r; return r; } #endif /* GLX_SGIX_pbuffer */ #ifdef GLX_SGIX_swap_barrier static GLboolean _glewInit_GLX_SGIX_swap_barrier (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXBindSwapBarrierSGIX = (PFNGLXBINDSWAPBARRIERSGIXPROC)glewGetProcAddress((const GLubyte*)"glXBindSwapBarrierSGIX")) == NULL) || r; r = ((glXQueryMaxSwapBarriersSGIX = (PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryMaxSwapBarriersSGIX")) == NULL) || r; return r; } #endif /* GLX_SGIX_swap_barrier */ #ifdef GLX_SGIX_swap_group static GLboolean _glewInit_GLX_SGIX_swap_group (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXJoinSwapGroupSGIX = (PFNGLXJOINSWAPGROUPSGIXPROC)glewGetProcAddress((const GLubyte*)"glXJoinSwapGroupSGIX")) == NULL) || r; return r; } #endif /* GLX_SGIX_swap_group */ #ifdef GLX_SGIX_video_resize static GLboolean _glewInit_GLX_SGIX_video_resize (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXBindChannelToWindowSGIX = (PFNGLXBINDCHANNELTOWINDOWSGIXPROC)glewGetProcAddress((const GLubyte*)"glXBindChannelToWindowSGIX")) == NULL) || r; r = ((glXChannelRectSGIX = (PFNGLXCHANNELRECTSGIXPROC)glewGetProcAddress((const GLubyte*)"glXChannelRectSGIX")) == NULL) || r; r = ((glXChannelRectSyncSGIX = (PFNGLXCHANNELRECTSYNCSGIXPROC)glewGetProcAddress((const GLubyte*)"glXChannelRectSyncSGIX")) == NULL) || r; r = ((glXQueryChannelDeltasSGIX = (PFNGLXQUERYCHANNELDELTASSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryChannelDeltasSGIX")) == NULL) || r; r = ((glXQueryChannelRectSGIX = (PFNGLXQUERYCHANNELRECTSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryChannelRectSGIX")) == NULL) || r; return r; } #endif /* GLX_SGIX_video_resize */ #ifdef GLX_SGI_cushion static GLboolean _glewInit_GLX_SGI_cushion (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXCushionSGI = (PFNGLXCUSHIONSGIPROC)glewGetProcAddress((const GLubyte*)"glXCushionSGI")) == NULL) || r; return r; } #endif /* GLX_SGI_cushion */ #ifdef GLX_SGI_make_current_read static GLboolean _glewInit_GLX_SGI_make_current_read (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXGetCurrentReadDrawableSGI = (PFNGLXGETCURRENTREADDRAWABLESGIPROC)glewGetProcAddress((const GLubyte*)"glXGetCurrentReadDrawableSGI")) == NULL) || r; r = ((glXMakeCurrentReadSGI = (PFNGLXMAKECURRENTREADSGIPROC)glewGetProcAddress((const GLubyte*)"glXMakeCurrentReadSGI")) == NULL) || r; return r; } #endif /* GLX_SGI_make_current_read */ #ifdef GLX_SGI_swap_control static GLboolean _glewInit_GLX_SGI_swap_control (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)glewGetProcAddress((const GLubyte*)"glXSwapIntervalSGI")) == NULL) || r; return r; } #endif /* GLX_SGI_swap_control */ #ifdef GLX_SGI_video_sync static GLboolean _glewInit_GLX_SGI_video_sync (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXGetVideoSyncSGI = (PFNGLXGETVIDEOSYNCSGIPROC)glewGetProcAddress((const GLubyte*)"glXGetVideoSyncSGI")) == NULL) || r; r = ((glXWaitVideoSyncSGI = (PFNGLXWAITVIDEOSYNCSGIPROC)glewGetProcAddress((const GLubyte*)"glXWaitVideoSyncSGI")) == NULL) || r; return r; } #endif /* GLX_SGI_video_sync */ #ifdef GLX_SUN_get_transparent_index static GLboolean _glewInit_GLX_SUN_get_transparent_index (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXGetTransparentIndexSUN = (PFNGLXGETTRANSPARENTINDEXSUNPROC)glewGetProcAddress((const GLubyte*)"glXGetTransparentIndexSUN")) == NULL) || r; return r; } #endif /* GLX_SUN_get_transparent_index */ #ifdef GLX_SUN_video_resize static GLboolean _glewInit_GLX_SUN_video_resize (GLXEW_CONTEXT_ARG_DEF_INIT) { GLboolean r = GL_FALSE; r = ((glXGetVideoResizeSUN = (PFNGLXGETVIDEORESIZESUNPROC)glewGetProcAddress((const GLubyte*)"glXGetVideoResizeSUN")) == NULL) || r; r = ((glXVideoResizeSUN = (PFNGLXVIDEORESIZESUNPROC)glewGetProcAddress((const GLubyte*)"glXVideoResizeSUN")) == NULL) || r; return r; } #endif /* GLX_SUN_video_resize */ /* ------------------------------------------------------------------------ */ GLboolean glxewGetExtension (const char* name) { const GLubyte* start; const GLubyte* end; if (glXGetCurrentDisplay == NULL) return GL_FALSE; start = (const GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS); if (0 == start) return GL_FALSE; end = start + _glewStrLen(start); return _glewSearchExtension(name, start, end); } #ifdef GLEW_MX GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST) #else GLenum glxewInit (GLXEW_CONTEXT_ARG_DEF_LIST) #endif { int major, minor; const GLubyte* extStart; const GLubyte* extEnd; /* initialize core GLX 1.2 */ if (_glewInit_GLX_VERSION_1_2(GLEW_CONTEXT_ARG_VAR_INIT)) return GLEW_ERROR_GLX_VERSION_11_ONLY; /* initialize flags */ GLXEW_VERSION_1_0 = GL_TRUE; GLXEW_VERSION_1_1 = GL_TRUE; GLXEW_VERSION_1_2 = GL_TRUE; GLXEW_VERSION_1_3 = GL_TRUE; GLXEW_VERSION_1_4 = GL_TRUE; /* query GLX version */ glXQueryVersion(glXGetCurrentDisplay(), &major, &minor); if (major == 1 && minor <= 3) { switch (minor) { case 3: GLXEW_VERSION_1_4 = GL_FALSE; break; case 2: GLXEW_VERSION_1_4 = GL_FALSE; GLXEW_VERSION_1_3 = GL_FALSE; break; default: return GLEW_ERROR_GLX_VERSION_11_ONLY; break; } } /* query GLX extension string */ extStart = 0; if (glXGetCurrentDisplay != NULL) extStart = (const GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS); if (extStart == 0) extStart = (const GLubyte *)""; extEnd = extStart + _glewStrLen(extStart); /* initialize extensions */ #ifdef GLX_VERSION_1_3 if (glewExperimental || GLXEW_VERSION_1_3) GLXEW_VERSION_1_3 = !_glewInit_GLX_VERSION_1_3(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_VERSION_1_3 */ #ifdef GLX_3DFX_multisample GLXEW_3DFX_multisample = _glewSearchExtension("GLX_3DFX_multisample", extStart, extEnd); #endif /* GLX_3DFX_multisample */ #ifdef GLX_AMD_gpu_association GLXEW_AMD_gpu_association = _glewSearchExtension("GLX_AMD_gpu_association", extStart, extEnd); if (glewExperimental || GLXEW_AMD_gpu_association) GLXEW_AMD_gpu_association = !_glewInit_GLX_AMD_gpu_association(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_AMD_gpu_association */ #ifdef GLX_ARB_context_flush_control GLXEW_ARB_context_flush_control = _glewSearchExtension("GLX_ARB_context_flush_control", extStart, extEnd); #endif /* GLX_ARB_context_flush_control */ #ifdef GLX_ARB_create_context GLXEW_ARB_create_context = _glewSearchExtension("GLX_ARB_create_context", extStart, extEnd); if (glewExperimental || GLXEW_ARB_create_context) GLXEW_ARB_create_context = !_glewInit_GLX_ARB_create_context(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_ARB_create_context */ #ifdef GLX_ARB_create_context_profile GLXEW_ARB_create_context_profile = _glewSearchExtension("GLX_ARB_create_context_profile", extStart, extEnd); #endif /* GLX_ARB_create_context_profile */ #ifdef GLX_ARB_create_context_robustness GLXEW_ARB_create_context_robustness = _glewSearchExtension("GLX_ARB_create_context_robustness", extStart, extEnd); #endif /* GLX_ARB_create_context_robustness */ #ifdef GLX_ARB_fbconfig_float GLXEW_ARB_fbconfig_float = _glewSearchExtension("GLX_ARB_fbconfig_float", extStart, extEnd); #endif /* GLX_ARB_fbconfig_float */ #ifdef GLX_ARB_framebuffer_sRGB GLXEW_ARB_framebuffer_sRGB = _glewSearchExtension("GLX_ARB_framebuffer_sRGB", extStart, extEnd); #endif /* GLX_ARB_framebuffer_sRGB */ #ifdef GLX_ARB_get_proc_address GLXEW_ARB_get_proc_address = _glewSearchExtension("GLX_ARB_get_proc_address", extStart, extEnd); #endif /* GLX_ARB_get_proc_address */ #ifdef GLX_ARB_multisample GLXEW_ARB_multisample = _glewSearchExtension("GLX_ARB_multisample", extStart, extEnd); #endif /* GLX_ARB_multisample */ #ifdef GLX_ARB_robustness_application_isolation GLXEW_ARB_robustness_application_isolation = _glewSearchExtension("GLX_ARB_robustness_application_isolation", extStart, extEnd); #endif /* GLX_ARB_robustness_application_isolation */ #ifdef GLX_ARB_robustness_share_group_isolation GLXEW_ARB_robustness_share_group_isolation = _glewSearchExtension("GLX_ARB_robustness_share_group_isolation", extStart, extEnd); #endif /* GLX_ARB_robustness_share_group_isolation */ #ifdef GLX_ARB_vertex_buffer_object GLXEW_ARB_vertex_buffer_object = _glewSearchExtension("GLX_ARB_vertex_buffer_object", extStart, extEnd); #endif /* GLX_ARB_vertex_buffer_object */ #ifdef GLX_ATI_pixel_format_float GLXEW_ATI_pixel_format_float = _glewSearchExtension("GLX_ATI_pixel_format_float", extStart, extEnd); #endif /* GLX_ATI_pixel_format_float */ #ifdef GLX_ATI_render_texture GLXEW_ATI_render_texture = _glewSearchExtension("GLX_ATI_render_texture", extStart, extEnd); if (glewExperimental || GLXEW_ATI_render_texture) GLXEW_ATI_render_texture = !_glewInit_GLX_ATI_render_texture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_ATI_render_texture */ #ifdef GLX_EXT_buffer_age GLXEW_EXT_buffer_age = _glewSearchExtension("GLX_EXT_buffer_age", extStart, extEnd); #endif /* GLX_EXT_buffer_age */ #ifdef GLX_EXT_create_context_es2_profile GLXEW_EXT_create_context_es2_profile = _glewSearchExtension("GLX_EXT_create_context_es2_profile", extStart, extEnd); #endif /* GLX_EXT_create_context_es2_profile */ #ifdef GLX_EXT_create_context_es_profile GLXEW_EXT_create_context_es_profile = _glewSearchExtension("GLX_EXT_create_context_es_profile", extStart, extEnd); #endif /* GLX_EXT_create_context_es_profile */ #ifdef GLX_EXT_fbconfig_packed_float GLXEW_EXT_fbconfig_packed_float = _glewSearchExtension("GLX_EXT_fbconfig_packed_float", extStart, extEnd); #endif /* GLX_EXT_fbconfig_packed_float */ #ifdef GLX_EXT_framebuffer_sRGB GLXEW_EXT_framebuffer_sRGB = _glewSearchExtension("GLX_EXT_framebuffer_sRGB", extStart, extEnd); #endif /* GLX_EXT_framebuffer_sRGB */ #ifdef GLX_EXT_import_context GLXEW_EXT_import_context = _glewSearchExtension("GLX_EXT_import_context", extStart, extEnd); if (glewExperimental || GLXEW_EXT_import_context) GLXEW_EXT_import_context = !_glewInit_GLX_EXT_import_context(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_EXT_import_context */ #ifdef GLX_EXT_scene_marker GLXEW_EXT_scene_marker = _glewSearchExtension("GLX_EXT_scene_marker", extStart, extEnd); #endif /* GLX_EXT_scene_marker */ #ifdef GLX_EXT_stereo_tree GLXEW_EXT_stereo_tree = _glewSearchExtension("GLX_EXT_stereo_tree", extStart, extEnd); #endif /* GLX_EXT_stereo_tree */ #ifdef GLX_EXT_swap_control GLXEW_EXT_swap_control = _glewSearchExtension("GLX_EXT_swap_control", extStart, extEnd); if (glewExperimental || GLXEW_EXT_swap_control) GLXEW_EXT_swap_control = !_glewInit_GLX_EXT_swap_control(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_EXT_swap_control */ #ifdef GLX_EXT_swap_control_tear GLXEW_EXT_swap_control_tear = _glewSearchExtension("GLX_EXT_swap_control_tear", extStart, extEnd); #endif /* GLX_EXT_swap_control_tear */ #ifdef GLX_EXT_texture_from_pixmap GLXEW_EXT_texture_from_pixmap = _glewSearchExtension("GLX_EXT_texture_from_pixmap", extStart, extEnd); if (glewExperimental || GLXEW_EXT_texture_from_pixmap) GLXEW_EXT_texture_from_pixmap = !_glewInit_GLX_EXT_texture_from_pixmap(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_EXT_texture_from_pixmap */ #ifdef GLX_EXT_visual_info GLXEW_EXT_visual_info = _glewSearchExtension("GLX_EXT_visual_info", extStart, extEnd); #endif /* GLX_EXT_visual_info */ #ifdef GLX_EXT_visual_rating GLXEW_EXT_visual_rating = _glewSearchExtension("GLX_EXT_visual_rating", extStart, extEnd); #endif /* GLX_EXT_visual_rating */ #ifdef GLX_INTEL_swap_event GLXEW_INTEL_swap_event = _glewSearchExtension("GLX_INTEL_swap_event", extStart, extEnd); #endif /* GLX_INTEL_swap_event */ #ifdef GLX_MESA_agp_offset GLXEW_MESA_agp_offset = _glewSearchExtension("GLX_MESA_agp_offset", extStart, extEnd); if (glewExperimental || GLXEW_MESA_agp_offset) GLXEW_MESA_agp_offset = !_glewInit_GLX_MESA_agp_offset(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_MESA_agp_offset */ #ifdef GLX_MESA_copy_sub_buffer GLXEW_MESA_copy_sub_buffer = _glewSearchExtension("GLX_MESA_copy_sub_buffer", extStart, extEnd); if (glewExperimental || GLXEW_MESA_copy_sub_buffer) GLXEW_MESA_copy_sub_buffer = !_glewInit_GLX_MESA_copy_sub_buffer(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_MESA_copy_sub_buffer */ #ifdef GLX_MESA_pixmap_colormap GLXEW_MESA_pixmap_colormap = _glewSearchExtension("GLX_MESA_pixmap_colormap", extStart, extEnd); if (glewExperimental || GLXEW_MESA_pixmap_colormap) GLXEW_MESA_pixmap_colormap = !_glewInit_GLX_MESA_pixmap_colormap(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_MESA_pixmap_colormap */ #ifdef GLX_MESA_query_renderer GLXEW_MESA_query_renderer = _glewSearchExtension("GLX_MESA_query_renderer", extStart, extEnd); if (glewExperimental || GLXEW_MESA_query_renderer) GLXEW_MESA_query_renderer = !_glewInit_GLX_MESA_query_renderer(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_MESA_query_renderer */ #ifdef GLX_MESA_release_buffers GLXEW_MESA_release_buffers = _glewSearchExtension("GLX_MESA_release_buffers", extStart, extEnd); if (glewExperimental || GLXEW_MESA_release_buffers) GLXEW_MESA_release_buffers = !_glewInit_GLX_MESA_release_buffers(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_MESA_release_buffers */ #ifdef GLX_MESA_set_3dfx_mode GLXEW_MESA_set_3dfx_mode = _glewSearchExtension("GLX_MESA_set_3dfx_mode", extStart, extEnd); if (glewExperimental || GLXEW_MESA_set_3dfx_mode) GLXEW_MESA_set_3dfx_mode = !_glewInit_GLX_MESA_set_3dfx_mode(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_MESA_set_3dfx_mode */ #ifdef GLX_MESA_swap_control GLXEW_MESA_swap_control = _glewSearchExtension("GLX_MESA_swap_control", extStart, extEnd); if (glewExperimental || GLXEW_MESA_swap_control) GLXEW_MESA_swap_control = !_glewInit_GLX_MESA_swap_control(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_MESA_swap_control */ #ifdef GLX_NV_copy_buffer GLXEW_NV_copy_buffer = _glewSearchExtension("GLX_NV_copy_buffer", extStart, extEnd); if (glewExperimental || GLXEW_NV_copy_buffer) GLXEW_NV_copy_buffer = !_glewInit_GLX_NV_copy_buffer(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_NV_copy_buffer */ #ifdef GLX_NV_copy_image GLXEW_NV_copy_image = _glewSearchExtension("GLX_NV_copy_image", extStart, extEnd); if (glewExperimental || GLXEW_NV_copy_image) GLXEW_NV_copy_image = !_glewInit_GLX_NV_copy_image(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_NV_copy_image */ #ifdef GLX_NV_delay_before_swap GLXEW_NV_delay_before_swap = _glewSearchExtension("GLX_NV_delay_before_swap", extStart, extEnd); if (glewExperimental || GLXEW_NV_delay_before_swap) GLXEW_NV_delay_before_swap = !_glewInit_GLX_NV_delay_before_swap(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_NV_delay_before_swap */ #ifdef GLX_NV_float_buffer GLXEW_NV_float_buffer = _glewSearchExtension("GLX_NV_float_buffer", extStart, extEnd); #endif /* GLX_NV_float_buffer */ #ifdef GLX_NV_multisample_coverage GLXEW_NV_multisample_coverage = _glewSearchExtension("GLX_NV_multisample_coverage", extStart, extEnd); #endif /* GLX_NV_multisample_coverage */ #ifdef GLX_NV_present_video GLXEW_NV_present_video = _glewSearchExtension("GLX_NV_present_video", extStart, extEnd); if (glewExperimental || GLXEW_NV_present_video) GLXEW_NV_present_video = !_glewInit_GLX_NV_present_video(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_NV_present_video */ #ifdef GLX_NV_swap_group GLXEW_NV_swap_group = _glewSearchExtension("GLX_NV_swap_group", extStart, extEnd); if (glewExperimental || GLXEW_NV_swap_group) GLXEW_NV_swap_group = !_glewInit_GLX_NV_swap_group(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_NV_swap_group */ #ifdef GLX_NV_vertex_array_range GLXEW_NV_vertex_array_range = _glewSearchExtension("GLX_NV_vertex_array_range", extStart, extEnd); if (glewExperimental || GLXEW_NV_vertex_array_range) GLXEW_NV_vertex_array_range = !_glewInit_GLX_NV_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_NV_vertex_array_range */ #ifdef GLX_NV_video_capture GLXEW_NV_video_capture = _glewSearchExtension("GLX_NV_video_capture", extStart, extEnd); if (glewExperimental || GLXEW_NV_video_capture) GLXEW_NV_video_capture = !_glewInit_GLX_NV_video_capture(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_NV_video_capture */ #ifdef GLX_NV_video_out GLXEW_NV_video_out = _glewSearchExtension("GLX_NV_video_out", extStart, extEnd); if (glewExperimental || GLXEW_NV_video_out) GLXEW_NV_video_out = !_glewInit_GLX_NV_video_out(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_NV_video_out */ #ifdef GLX_OML_swap_method GLXEW_OML_swap_method = _glewSearchExtension("GLX_OML_swap_method", extStart, extEnd); #endif /* GLX_OML_swap_method */ #ifdef GLX_OML_sync_control GLXEW_OML_sync_control = _glewSearchExtension("GLX_OML_sync_control", extStart, extEnd); if (glewExperimental || GLXEW_OML_sync_control) GLXEW_OML_sync_control = !_glewInit_GLX_OML_sync_control(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_OML_sync_control */ #ifdef GLX_SGIS_blended_overlay GLXEW_SGIS_blended_overlay = _glewSearchExtension("GLX_SGIS_blended_overlay", extStart, extEnd); #endif /* GLX_SGIS_blended_overlay */ #ifdef GLX_SGIS_color_range GLXEW_SGIS_color_range = _glewSearchExtension("GLX_SGIS_color_range", extStart, extEnd); #endif /* GLX_SGIS_color_range */ #ifdef GLX_SGIS_multisample GLXEW_SGIS_multisample = _glewSearchExtension("GLX_SGIS_multisample", extStart, extEnd); #endif /* GLX_SGIS_multisample */ #ifdef GLX_SGIS_shared_multisample GLXEW_SGIS_shared_multisample = _glewSearchExtension("GLX_SGIS_shared_multisample", extStart, extEnd); #endif /* GLX_SGIS_shared_multisample */ #ifdef GLX_SGIX_fbconfig GLXEW_SGIX_fbconfig = _glewSearchExtension("GLX_SGIX_fbconfig", extStart, extEnd); if (glewExperimental || GLXEW_SGIX_fbconfig) GLXEW_SGIX_fbconfig = !_glewInit_GLX_SGIX_fbconfig(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_SGIX_fbconfig */ #ifdef GLX_SGIX_hyperpipe GLXEW_SGIX_hyperpipe = _glewSearchExtension("GLX_SGIX_hyperpipe", extStart, extEnd); if (glewExperimental || GLXEW_SGIX_hyperpipe) GLXEW_SGIX_hyperpipe = !_glewInit_GLX_SGIX_hyperpipe(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_SGIX_hyperpipe */ #ifdef GLX_SGIX_pbuffer GLXEW_SGIX_pbuffer = _glewSearchExtension("GLX_SGIX_pbuffer", extStart, extEnd); if (glewExperimental || GLXEW_SGIX_pbuffer) GLXEW_SGIX_pbuffer = !_glewInit_GLX_SGIX_pbuffer(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_SGIX_pbuffer */ #ifdef GLX_SGIX_swap_barrier GLXEW_SGIX_swap_barrier = _glewSearchExtension("GLX_SGIX_swap_barrier", extStart, extEnd); if (glewExperimental || GLXEW_SGIX_swap_barrier) GLXEW_SGIX_swap_barrier = !_glewInit_GLX_SGIX_swap_barrier(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_SGIX_swap_barrier */ #ifdef GLX_SGIX_swap_group GLXEW_SGIX_swap_group = _glewSearchExtension("GLX_SGIX_swap_group", extStart, extEnd); if (glewExperimental || GLXEW_SGIX_swap_group) GLXEW_SGIX_swap_group = !_glewInit_GLX_SGIX_swap_group(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_SGIX_swap_group */ #ifdef GLX_SGIX_video_resize GLXEW_SGIX_video_resize = _glewSearchExtension("GLX_SGIX_video_resize", extStart, extEnd); if (glewExperimental || GLXEW_SGIX_video_resize) GLXEW_SGIX_video_resize = !_glewInit_GLX_SGIX_video_resize(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_SGIX_video_resize */ #ifdef GLX_SGIX_visual_select_group GLXEW_SGIX_visual_select_group = _glewSearchExtension("GLX_SGIX_visual_select_group", extStart, extEnd); #endif /* GLX_SGIX_visual_select_group */ #ifdef GLX_SGI_cushion GLXEW_SGI_cushion = _glewSearchExtension("GLX_SGI_cushion", extStart, extEnd); if (glewExperimental || GLXEW_SGI_cushion) GLXEW_SGI_cushion = !_glewInit_GLX_SGI_cushion(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_SGI_cushion */ #ifdef GLX_SGI_make_current_read GLXEW_SGI_make_current_read = _glewSearchExtension("GLX_SGI_make_current_read", extStart, extEnd); if (glewExperimental || GLXEW_SGI_make_current_read) GLXEW_SGI_make_current_read = !_glewInit_GLX_SGI_make_current_read(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_SGI_make_current_read */ #ifdef GLX_SGI_swap_control GLXEW_SGI_swap_control = _glewSearchExtension("GLX_SGI_swap_control", extStart, extEnd); if (glewExperimental || GLXEW_SGI_swap_control) GLXEW_SGI_swap_control = !_glewInit_GLX_SGI_swap_control(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_SGI_swap_control */ #ifdef GLX_SGI_video_sync GLXEW_SGI_video_sync = _glewSearchExtension("GLX_SGI_video_sync", extStart, extEnd); if (glewExperimental || GLXEW_SGI_video_sync) GLXEW_SGI_video_sync = !_glewInit_GLX_SGI_video_sync(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_SGI_video_sync */ #ifdef GLX_SUN_get_transparent_index GLXEW_SUN_get_transparent_index = _glewSearchExtension("GLX_SUN_get_transparent_index", extStart, extEnd); if (glewExperimental || GLXEW_SUN_get_transparent_index) GLXEW_SUN_get_transparent_index = !_glewInit_GLX_SUN_get_transparent_index(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_SUN_get_transparent_index */ #ifdef GLX_SUN_video_resize GLXEW_SUN_video_resize = _glewSearchExtension("GLX_SUN_video_resize", extStart, extEnd); if (glewExperimental || GLXEW_SUN_video_resize) GLXEW_SUN_video_resize = !_glewInit_GLX_SUN_video_resize(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GLX_SUN_video_resize */ return GLEW_OK; } #endif /* !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX)) */ /* ------------------------------------------------------------------------ */ const GLubyte * GLEWAPIENTRY glewGetErrorString (GLenum error) { static const GLubyte* _glewErrorString[] = { (const GLubyte*)"No error", (const GLubyte*)"Missing GL version", (const GLubyte*)"GL 1.1 and up are not supported", (const GLubyte*)"GLX 1.2 and up are not supported", (const GLubyte*)"Unknown error" }; const size_t max_error = sizeof(_glewErrorString)/sizeof(*_glewErrorString) - 1; return _glewErrorString[(size_t)error > max_error ? max_error : (size_t)error]; } const GLubyte * GLEWAPIENTRY glewGetString (GLenum name) { static const GLubyte* _glewString[] = { (const GLubyte*)NULL, (const GLubyte*)"1.13.0", (const GLubyte*)"1", (const GLubyte*)"13", (const GLubyte*)"0" }; const size_t max_string = sizeof(_glewString)/sizeof(*_glewString) - 1; return _glewString[(size_t)name > max_string ? 0 : (size_t)name]; } /* ------------------------------------------------------------------------ */ GLboolean glewExperimental = GL_FALSE; #if !defined(GLEW_MX) GLenum GLEWAPIENTRY glewInit (void) { GLenum r; r = glewContextInit(); if ( r != 0 ) return r; #if defined(_WIN32) return wglewInit(); #elif !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX)) /* _UNIX */ return glxewInit(); #else return r; #endif /* _WIN32 */ } #endif /* !GLEW_MX */ #ifdef GLEW_MX GLboolean GLEWAPIENTRY glewContextIsSupported (const GLEWContext* ctx, const char* name) #else GLboolean GLEWAPIENTRY glewIsSupported (const char* name) #endif { const GLubyte* pos = (const GLubyte*)name; GLuint len = _glewStrLen(pos); GLboolean ret = GL_TRUE; while (ret && len > 0) { if (_glewStrSame1(&pos, &len, (const GLubyte*)"GL_", 3)) { if (_glewStrSame2(&pos, &len, (const GLubyte*)"VERSION_", 8)) { #ifdef GL_VERSION_1_2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_2", 3)) { ret = GLEW_VERSION_1_2; continue; } #endif #ifdef GL_VERSION_1_2_1 if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_2_1", 5)) { ret = GLEW_VERSION_1_2_1; continue; } #endif #ifdef GL_VERSION_1_3 if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_3", 3)) { ret = GLEW_VERSION_1_3; continue; } #endif #ifdef GL_VERSION_1_4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_4", 3)) { ret = GLEW_VERSION_1_4; continue; } #endif #ifdef GL_VERSION_1_5 if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_5", 3)) { ret = GLEW_VERSION_1_5; continue; } #endif #ifdef GL_VERSION_2_0 if (_glewStrSame3(&pos, &len, (const GLubyte*)"2_0", 3)) { ret = GLEW_VERSION_2_0; continue; } #endif #ifdef GL_VERSION_2_1 if (_glewStrSame3(&pos, &len, (const GLubyte*)"2_1", 3)) { ret = GLEW_VERSION_2_1; continue; } #endif #ifdef GL_VERSION_3_0 if (_glewStrSame3(&pos, &len, (const GLubyte*)"3_0", 3)) { ret = GLEW_VERSION_3_0; continue; } #endif #ifdef GL_VERSION_3_1 if (_glewStrSame3(&pos, &len, (const GLubyte*)"3_1", 3)) { ret = GLEW_VERSION_3_1; continue; } #endif #ifdef GL_VERSION_3_2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"3_2", 3)) { ret = GLEW_VERSION_3_2; continue; } #endif #ifdef GL_VERSION_3_3 if (_glewStrSame3(&pos, &len, (const GLubyte*)"3_3", 3)) { ret = GLEW_VERSION_3_3; continue; } #endif #ifdef GL_VERSION_4_0 if (_glewStrSame3(&pos, &len, (const GLubyte*)"4_0", 3)) { ret = GLEW_VERSION_4_0; continue; } #endif #ifdef GL_VERSION_4_1 if (_glewStrSame3(&pos, &len, (const GLubyte*)"4_1", 3)) { ret = GLEW_VERSION_4_1; continue; } #endif #ifdef GL_VERSION_4_2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"4_2", 3)) { ret = GLEW_VERSION_4_2; continue; } #endif #ifdef GL_VERSION_4_3 if (_glewStrSame3(&pos, &len, (const GLubyte*)"4_3", 3)) { ret = GLEW_VERSION_4_3; continue; } #endif #ifdef GL_VERSION_4_4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"4_4", 3)) { ret = GLEW_VERSION_4_4; continue; } #endif #ifdef GL_VERSION_4_5 if (_glewStrSame3(&pos, &len, (const GLubyte*)"4_5", 3)) { ret = GLEW_VERSION_4_5; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"3DFX_", 5)) { #ifdef GL_3DFX_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) { ret = GLEW_3DFX_multisample; continue; } #endif #ifdef GL_3DFX_tbuffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"tbuffer", 7)) { ret = GLEW_3DFX_tbuffer; continue; } #endif #ifdef GL_3DFX_texture_compression_FXT1 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_FXT1", 24)) { ret = GLEW_3DFX_texture_compression_FXT1; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"AMD_", 4)) { #ifdef GL_AMD_blend_minmax_factor if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_minmax_factor", 19)) { ret = GLEW_AMD_blend_minmax_factor; continue; } #endif #ifdef GL_AMD_conservative_depth if (_glewStrSame3(&pos, &len, (const GLubyte*)"conservative_depth", 18)) { ret = GLEW_AMD_conservative_depth; continue; } #endif #ifdef GL_AMD_debug_output if (_glewStrSame3(&pos, &len, (const GLubyte*)"debug_output", 12)) { ret = GLEW_AMD_debug_output; continue; } #endif #ifdef GL_AMD_depth_clamp_separate if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_clamp_separate", 20)) { ret = GLEW_AMD_depth_clamp_separate; continue; } #endif #ifdef GL_AMD_draw_buffers_blend if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_buffers_blend", 18)) { ret = GLEW_AMD_draw_buffers_blend; continue; } #endif #ifdef GL_AMD_gcn_shader if (_glewStrSame3(&pos, &len, (const GLubyte*)"gcn_shader", 10)) { ret = GLEW_AMD_gcn_shader; continue; } #endif #ifdef GL_AMD_gpu_shader_int64 if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_shader_int64", 16)) { ret = GLEW_AMD_gpu_shader_int64; continue; } #endif #ifdef GL_AMD_interleaved_elements if (_glewStrSame3(&pos, &len, (const GLubyte*)"interleaved_elements", 20)) { ret = GLEW_AMD_interleaved_elements; continue; } #endif #ifdef GL_AMD_multi_draw_indirect if (_glewStrSame3(&pos, &len, (const GLubyte*)"multi_draw_indirect", 19)) { ret = GLEW_AMD_multi_draw_indirect; continue; } #endif #ifdef GL_AMD_name_gen_delete if (_glewStrSame3(&pos, &len, (const GLubyte*)"name_gen_delete", 15)) { ret = GLEW_AMD_name_gen_delete; continue; } #endif #ifdef GL_AMD_occlusion_query_event if (_glewStrSame3(&pos, &len, (const GLubyte*)"occlusion_query_event", 21)) { ret = GLEW_AMD_occlusion_query_event; continue; } #endif #ifdef GL_AMD_performance_monitor if (_glewStrSame3(&pos, &len, (const GLubyte*)"performance_monitor", 19)) { ret = GLEW_AMD_performance_monitor; continue; } #endif #ifdef GL_AMD_pinned_memory if (_glewStrSame3(&pos, &len, (const GLubyte*)"pinned_memory", 13)) { ret = GLEW_AMD_pinned_memory; continue; } #endif #ifdef GL_AMD_query_buffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"query_buffer_object", 19)) { ret = GLEW_AMD_query_buffer_object; continue; } #endif #ifdef GL_AMD_sample_positions if (_glewStrSame3(&pos, &len, (const GLubyte*)"sample_positions", 16)) { ret = GLEW_AMD_sample_positions; continue; } #endif #ifdef GL_AMD_seamless_cubemap_per_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"seamless_cubemap_per_texture", 28)) { ret = GLEW_AMD_seamless_cubemap_per_texture; continue; } #endif #ifdef GL_AMD_shader_atomic_counter_ops if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_atomic_counter_ops", 25)) { ret = GLEW_AMD_shader_atomic_counter_ops; continue; } #endif #ifdef GL_AMD_shader_stencil_export if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_stencil_export", 21)) { ret = GLEW_AMD_shader_stencil_export; continue; } #endif #ifdef GL_AMD_shader_stencil_value_export if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_stencil_value_export", 27)) { ret = GLEW_AMD_shader_stencil_value_export; continue; } #endif #ifdef GL_AMD_shader_trinary_minmax if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_trinary_minmax", 21)) { ret = GLEW_AMD_shader_trinary_minmax; continue; } #endif #ifdef GL_AMD_sparse_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"sparse_texture", 14)) { ret = GLEW_AMD_sparse_texture; continue; } #endif #ifdef GL_AMD_stencil_operation_extended if (_glewStrSame3(&pos, &len, (const GLubyte*)"stencil_operation_extended", 26)) { ret = GLEW_AMD_stencil_operation_extended; continue; } #endif #ifdef GL_AMD_texture_texture4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_texture4", 16)) { ret = GLEW_AMD_texture_texture4; continue; } #endif #ifdef GL_AMD_transform_feedback3_lines_triangles if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback3_lines_triangles", 35)) { ret = GLEW_AMD_transform_feedback3_lines_triangles; continue; } #endif #ifdef GL_AMD_transform_feedback4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback4", 19)) { ret = GLEW_AMD_transform_feedback4; continue; } #endif #ifdef GL_AMD_vertex_shader_layer if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_shader_layer", 19)) { ret = GLEW_AMD_vertex_shader_layer; continue; } #endif #ifdef GL_AMD_vertex_shader_tessellator if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_shader_tessellator", 25)) { ret = GLEW_AMD_vertex_shader_tessellator; continue; } #endif #ifdef GL_AMD_vertex_shader_viewport_index if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_shader_viewport_index", 28)) { ret = GLEW_AMD_vertex_shader_viewport_index; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"ANGLE_", 6)) { #ifdef GL_ANGLE_depth_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_texture", 13)) { ret = GLEW_ANGLE_depth_texture; continue; } #endif #ifdef GL_ANGLE_framebuffer_blit if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_blit", 16)) { ret = GLEW_ANGLE_framebuffer_blit; continue; } #endif #ifdef GL_ANGLE_framebuffer_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_multisample", 23)) { ret = GLEW_ANGLE_framebuffer_multisample; continue; } #endif #ifdef GL_ANGLE_instanced_arrays if (_glewStrSame3(&pos, &len, (const GLubyte*)"instanced_arrays", 16)) { ret = GLEW_ANGLE_instanced_arrays; continue; } #endif #ifdef GL_ANGLE_pack_reverse_row_order if (_glewStrSame3(&pos, &len, (const GLubyte*)"pack_reverse_row_order", 22)) { ret = GLEW_ANGLE_pack_reverse_row_order; continue; } #endif #ifdef GL_ANGLE_program_binary if (_glewStrSame3(&pos, &len, (const GLubyte*)"program_binary", 14)) { ret = GLEW_ANGLE_program_binary; continue; } #endif #ifdef GL_ANGLE_texture_compression_dxt1 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_dxt1", 24)) { ret = GLEW_ANGLE_texture_compression_dxt1; continue; } #endif #ifdef GL_ANGLE_texture_compression_dxt3 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_dxt3", 24)) { ret = GLEW_ANGLE_texture_compression_dxt3; continue; } #endif #ifdef GL_ANGLE_texture_compression_dxt5 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_dxt5", 24)) { ret = GLEW_ANGLE_texture_compression_dxt5; continue; } #endif #ifdef GL_ANGLE_texture_usage if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_usage", 13)) { ret = GLEW_ANGLE_texture_usage; continue; } #endif #ifdef GL_ANGLE_timer_query if (_glewStrSame3(&pos, &len, (const GLubyte*)"timer_query", 11)) { ret = GLEW_ANGLE_timer_query; continue; } #endif #ifdef GL_ANGLE_translated_shader_source if (_glewStrSame3(&pos, &len, (const GLubyte*)"translated_shader_source", 24)) { ret = GLEW_ANGLE_translated_shader_source; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"APPLE_", 6)) { #ifdef GL_APPLE_aux_depth_stencil if (_glewStrSame3(&pos, &len, (const GLubyte*)"aux_depth_stencil", 17)) { ret = GLEW_APPLE_aux_depth_stencil; continue; } #endif #ifdef GL_APPLE_client_storage if (_glewStrSame3(&pos, &len, (const GLubyte*)"client_storage", 14)) { ret = GLEW_APPLE_client_storage; continue; } #endif #ifdef GL_APPLE_element_array if (_glewStrSame3(&pos, &len, (const GLubyte*)"element_array", 13)) { ret = GLEW_APPLE_element_array; continue; } #endif #ifdef GL_APPLE_fence if (_glewStrSame3(&pos, &len, (const GLubyte*)"fence", 5)) { ret = GLEW_APPLE_fence; continue; } #endif #ifdef GL_APPLE_float_pixels if (_glewStrSame3(&pos, &len, (const GLubyte*)"float_pixels", 12)) { ret = GLEW_APPLE_float_pixels; continue; } #endif #ifdef GL_APPLE_flush_buffer_range if (_glewStrSame3(&pos, &len, (const GLubyte*)"flush_buffer_range", 18)) { ret = GLEW_APPLE_flush_buffer_range; continue; } #endif #ifdef GL_APPLE_object_purgeable if (_glewStrSame3(&pos, &len, (const GLubyte*)"object_purgeable", 16)) { ret = GLEW_APPLE_object_purgeable; continue; } #endif #ifdef GL_APPLE_pixel_buffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_buffer", 12)) { ret = GLEW_APPLE_pixel_buffer; continue; } #endif #ifdef GL_APPLE_rgb_422 if (_glewStrSame3(&pos, &len, (const GLubyte*)"rgb_422", 7)) { ret = GLEW_APPLE_rgb_422; continue; } #endif #ifdef GL_APPLE_row_bytes if (_glewStrSame3(&pos, &len, (const GLubyte*)"row_bytes", 9)) { ret = GLEW_APPLE_row_bytes; continue; } #endif #ifdef GL_APPLE_specular_vector if (_glewStrSame3(&pos, &len, (const GLubyte*)"specular_vector", 15)) { ret = GLEW_APPLE_specular_vector; continue; } #endif #ifdef GL_APPLE_texture_range if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_range", 13)) { ret = GLEW_APPLE_texture_range; continue; } #endif #ifdef GL_APPLE_transform_hint if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_hint", 14)) { ret = GLEW_APPLE_transform_hint; continue; } #endif #ifdef GL_APPLE_vertex_array_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_object", 19)) { ret = GLEW_APPLE_vertex_array_object; continue; } #endif #ifdef GL_APPLE_vertex_array_range if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range", 18)) { ret = GLEW_APPLE_vertex_array_range; continue; } #endif #ifdef GL_APPLE_vertex_program_evaluators if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program_evaluators", 25)) { ret = GLEW_APPLE_vertex_program_evaluators; continue; } #endif #ifdef GL_APPLE_ycbcr_422 if (_glewStrSame3(&pos, &len, (const GLubyte*)"ycbcr_422", 9)) { ret = GLEW_APPLE_ycbcr_422; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"ARB_", 4)) { #ifdef GL_ARB_ES2_compatibility if (_glewStrSame3(&pos, &len, (const GLubyte*)"ES2_compatibility", 17)) { ret = GLEW_ARB_ES2_compatibility; continue; } #endif #ifdef GL_ARB_ES3_1_compatibility if (_glewStrSame3(&pos, &len, (const GLubyte*)"ES3_1_compatibility", 19)) { ret = GLEW_ARB_ES3_1_compatibility; continue; } #endif #ifdef GL_ARB_ES3_2_compatibility if (_glewStrSame3(&pos, &len, (const GLubyte*)"ES3_2_compatibility", 19)) { ret = GLEW_ARB_ES3_2_compatibility; continue; } #endif #ifdef GL_ARB_ES3_compatibility if (_glewStrSame3(&pos, &len, (const GLubyte*)"ES3_compatibility", 17)) { ret = GLEW_ARB_ES3_compatibility; continue; } #endif #ifdef GL_ARB_arrays_of_arrays if (_glewStrSame3(&pos, &len, (const GLubyte*)"arrays_of_arrays", 16)) { ret = GLEW_ARB_arrays_of_arrays; continue; } #endif #ifdef GL_ARB_base_instance if (_glewStrSame3(&pos, &len, (const GLubyte*)"base_instance", 13)) { ret = GLEW_ARB_base_instance; continue; } #endif #ifdef GL_ARB_bindless_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"bindless_texture", 16)) { ret = GLEW_ARB_bindless_texture; continue; } #endif #ifdef GL_ARB_blend_func_extended if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_func_extended", 19)) { ret = GLEW_ARB_blend_func_extended; continue; } #endif #ifdef GL_ARB_buffer_storage if (_glewStrSame3(&pos, &len, (const GLubyte*)"buffer_storage", 14)) { ret = GLEW_ARB_buffer_storage; continue; } #endif #ifdef GL_ARB_cl_event if (_glewStrSame3(&pos, &len, (const GLubyte*)"cl_event", 8)) { ret = GLEW_ARB_cl_event; continue; } #endif #ifdef GL_ARB_clear_buffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"clear_buffer_object", 19)) { ret = GLEW_ARB_clear_buffer_object; continue; } #endif #ifdef GL_ARB_clear_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"clear_texture", 13)) { ret = GLEW_ARB_clear_texture; continue; } #endif #ifdef GL_ARB_clip_control if (_glewStrSame3(&pos, &len, (const GLubyte*)"clip_control", 12)) { ret = GLEW_ARB_clip_control; continue; } #endif #ifdef GL_ARB_color_buffer_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_buffer_float", 18)) { ret = GLEW_ARB_color_buffer_float; continue; } #endif #ifdef GL_ARB_compatibility if (_glewStrSame3(&pos, &len, (const GLubyte*)"compatibility", 13)) { ret = GLEW_ARB_compatibility; continue; } #endif #ifdef GL_ARB_compressed_texture_pixel_storage if (_glewStrSame3(&pos, &len, (const GLubyte*)"compressed_texture_pixel_storage", 32)) { ret = GLEW_ARB_compressed_texture_pixel_storage; continue; } #endif #ifdef GL_ARB_compute_shader if (_glewStrSame3(&pos, &len, (const GLubyte*)"compute_shader", 14)) { ret = GLEW_ARB_compute_shader; continue; } #endif #ifdef GL_ARB_compute_variable_group_size if (_glewStrSame3(&pos, &len, (const GLubyte*)"compute_variable_group_size", 27)) { ret = GLEW_ARB_compute_variable_group_size; continue; } #endif #ifdef GL_ARB_conditional_render_inverted if (_glewStrSame3(&pos, &len, (const GLubyte*)"conditional_render_inverted", 27)) { ret = GLEW_ARB_conditional_render_inverted; continue; } #endif #ifdef GL_ARB_conservative_depth if (_glewStrSame3(&pos, &len, (const GLubyte*)"conservative_depth", 18)) { ret = GLEW_ARB_conservative_depth; continue; } #endif #ifdef GL_ARB_copy_buffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_buffer", 11)) { ret = GLEW_ARB_copy_buffer; continue; } #endif #ifdef GL_ARB_copy_image if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_image", 10)) { ret = GLEW_ARB_copy_image; continue; } #endif #ifdef GL_ARB_cull_distance if (_glewStrSame3(&pos, &len, (const GLubyte*)"cull_distance", 13)) { ret = GLEW_ARB_cull_distance; continue; } #endif #ifdef GL_ARB_debug_output if (_glewStrSame3(&pos, &len, (const GLubyte*)"debug_output", 12)) { ret = GLEW_ARB_debug_output; continue; } #endif #ifdef GL_ARB_depth_buffer_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_buffer_float", 18)) { ret = GLEW_ARB_depth_buffer_float; continue; } #endif #ifdef GL_ARB_depth_clamp if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_clamp", 11)) { ret = GLEW_ARB_depth_clamp; continue; } #endif #ifdef GL_ARB_depth_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_texture", 13)) { ret = GLEW_ARB_depth_texture; continue; } #endif #ifdef GL_ARB_derivative_control if (_glewStrSame3(&pos, &len, (const GLubyte*)"derivative_control", 18)) { ret = GLEW_ARB_derivative_control; continue; } #endif #ifdef GL_ARB_direct_state_access if (_glewStrSame3(&pos, &len, (const GLubyte*)"direct_state_access", 19)) { ret = GLEW_ARB_direct_state_access; continue; } #endif #ifdef GL_ARB_draw_buffers if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_buffers", 12)) { ret = GLEW_ARB_draw_buffers; continue; } #endif #ifdef GL_ARB_draw_buffers_blend if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_buffers_blend", 18)) { ret = GLEW_ARB_draw_buffers_blend; continue; } #endif #ifdef GL_ARB_draw_elements_base_vertex if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_elements_base_vertex", 25)) { ret = GLEW_ARB_draw_elements_base_vertex; continue; } #endif #ifdef GL_ARB_draw_indirect if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_indirect", 13)) { ret = GLEW_ARB_draw_indirect; continue; } #endif #ifdef GL_ARB_draw_instanced if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_instanced", 14)) { ret = GLEW_ARB_draw_instanced; continue; } #endif #ifdef GL_ARB_enhanced_layouts if (_glewStrSame3(&pos, &len, (const GLubyte*)"enhanced_layouts", 16)) { ret = GLEW_ARB_enhanced_layouts; continue; } #endif #ifdef GL_ARB_explicit_attrib_location if (_glewStrSame3(&pos, &len, (const GLubyte*)"explicit_attrib_location", 24)) { ret = GLEW_ARB_explicit_attrib_location; continue; } #endif #ifdef GL_ARB_explicit_uniform_location if (_glewStrSame3(&pos, &len, (const GLubyte*)"explicit_uniform_location", 25)) { ret = GLEW_ARB_explicit_uniform_location; continue; } #endif #ifdef GL_ARB_fragment_coord_conventions if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_coord_conventions", 26)) { ret = GLEW_ARB_fragment_coord_conventions; continue; } #endif #ifdef GL_ARB_fragment_layer_viewport if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_layer_viewport", 23)) { ret = GLEW_ARB_fragment_layer_viewport; continue; } #endif #ifdef GL_ARB_fragment_program if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program", 16)) { ret = GLEW_ARB_fragment_program; continue; } #endif #ifdef GL_ARB_fragment_program_shadow if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program_shadow", 23)) { ret = GLEW_ARB_fragment_program_shadow; continue; } #endif #ifdef GL_ARB_fragment_shader if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_shader", 15)) { ret = GLEW_ARB_fragment_shader; continue; } #endif #ifdef GL_ARB_fragment_shader_interlock if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_shader_interlock", 25)) { ret = GLEW_ARB_fragment_shader_interlock; continue; } #endif #ifdef GL_ARB_framebuffer_no_attachments if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_no_attachments", 26)) { ret = GLEW_ARB_framebuffer_no_attachments; continue; } #endif #ifdef GL_ARB_framebuffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_object", 18)) { ret = GLEW_ARB_framebuffer_object; continue; } #endif #ifdef GL_ARB_framebuffer_sRGB if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) { ret = GLEW_ARB_framebuffer_sRGB; continue; } #endif #ifdef GL_ARB_geometry_shader4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"geometry_shader4", 16)) { ret = GLEW_ARB_geometry_shader4; continue; } #endif #ifdef GL_ARB_get_program_binary if (_glewStrSame3(&pos, &len, (const GLubyte*)"get_program_binary", 18)) { ret = GLEW_ARB_get_program_binary; continue; } #endif #ifdef GL_ARB_get_texture_sub_image if (_glewStrSame3(&pos, &len, (const GLubyte*)"get_texture_sub_image", 21)) { ret = GLEW_ARB_get_texture_sub_image; continue; } #endif #ifdef GL_ARB_gpu_shader5 if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_shader5", 11)) { ret = GLEW_ARB_gpu_shader5; continue; } #endif #ifdef GL_ARB_gpu_shader_fp64 if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_shader_fp64", 15)) { ret = GLEW_ARB_gpu_shader_fp64; continue; } #endif #ifdef GL_ARB_gpu_shader_int64 if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_shader_int64", 16)) { ret = GLEW_ARB_gpu_shader_int64; continue; } #endif #ifdef GL_ARB_half_float_pixel if (_glewStrSame3(&pos, &len, (const GLubyte*)"half_float_pixel", 16)) { ret = GLEW_ARB_half_float_pixel; continue; } #endif #ifdef GL_ARB_half_float_vertex if (_glewStrSame3(&pos, &len, (const GLubyte*)"half_float_vertex", 17)) { ret = GLEW_ARB_half_float_vertex; continue; } #endif #ifdef GL_ARB_imaging if (_glewStrSame3(&pos, &len, (const GLubyte*)"imaging", 7)) { ret = GLEW_ARB_imaging; continue; } #endif #ifdef GL_ARB_indirect_parameters if (_glewStrSame3(&pos, &len, (const GLubyte*)"indirect_parameters", 19)) { ret = GLEW_ARB_indirect_parameters; continue; } #endif #ifdef GL_ARB_instanced_arrays if (_glewStrSame3(&pos, &len, (const GLubyte*)"instanced_arrays", 16)) { ret = GLEW_ARB_instanced_arrays; continue; } #endif #ifdef GL_ARB_internalformat_query if (_glewStrSame3(&pos, &len, (const GLubyte*)"internalformat_query", 20)) { ret = GLEW_ARB_internalformat_query; continue; } #endif #ifdef GL_ARB_internalformat_query2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"internalformat_query2", 21)) { ret = GLEW_ARB_internalformat_query2; continue; } #endif #ifdef GL_ARB_invalidate_subdata if (_glewStrSame3(&pos, &len, (const GLubyte*)"invalidate_subdata", 18)) { ret = GLEW_ARB_invalidate_subdata; continue; } #endif #ifdef GL_ARB_map_buffer_alignment if (_glewStrSame3(&pos, &len, (const GLubyte*)"map_buffer_alignment", 20)) { ret = GLEW_ARB_map_buffer_alignment; continue; } #endif #ifdef GL_ARB_map_buffer_range if (_glewStrSame3(&pos, &len, (const GLubyte*)"map_buffer_range", 16)) { ret = GLEW_ARB_map_buffer_range; continue; } #endif #ifdef GL_ARB_matrix_palette if (_glewStrSame3(&pos, &len, (const GLubyte*)"matrix_palette", 14)) { ret = GLEW_ARB_matrix_palette; continue; } #endif #ifdef GL_ARB_multi_bind if (_glewStrSame3(&pos, &len, (const GLubyte*)"multi_bind", 10)) { ret = GLEW_ARB_multi_bind; continue; } #endif #ifdef GL_ARB_multi_draw_indirect if (_glewStrSame3(&pos, &len, (const GLubyte*)"multi_draw_indirect", 19)) { ret = GLEW_ARB_multi_draw_indirect; continue; } #endif #ifdef GL_ARB_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) { ret = GLEW_ARB_multisample; continue; } #endif #ifdef GL_ARB_multitexture if (_glewStrSame3(&pos, &len, (const GLubyte*)"multitexture", 12)) { ret = GLEW_ARB_multitexture; continue; } #endif #ifdef GL_ARB_occlusion_query if (_glewStrSame3(&pos, &len, (const GLubyte*)"occlusion_query", 15)) { ret = GLEW_ARB_occlusion_query; continue; } #endif #ifdef GL_ARB_occlusion_query2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"occlusion_query2", 16)) { ret = GLEW_ARB_occlusion_query2; continue; } #endif #ifdef GL_ARB_parallel_shader_compile if (_glewStrSame3(&pos, &len, (const GLubyte*)"parallel_shader_compile", 23)) { ret = GLEW_ARB_parallel_shader_compile; continue; } #endif #ifdef GL_ARB_pipeline_statistics_query if (_glewStrSame3(&pos, &len, (const GLubyte*)"pipeline_statistics_query", 25)) { ret = GLEW_ARB_pipeline_statistics_query; continue; } #endif #ifdef GL_ARB_pixel_buffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_buffer_object", 19)) { ret = GLEW_ARB_pixel_buffer_object; continue; } #endif #ifdef GL_ARB_point_parameters if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_parameters", 16)) { ret = GLEW_ARB_point_parameters; continue; } #endif #ifdef GL_ARB_point_sprite if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_sprite", 12)) { ret = GLEW_ARB_point_sprite; continue; } #endif #ifdef GL_ARB_post_depth_coverage if (_glewStrSame3(&pos, &len, (const GLubyte*)"post_depth_coverage", 19)) { ret = GLEW_ARB_post_depth_coverage; continue; } #endif #ifdef GL_ARB_program_interface_query if (_glewStrSame3(&pos, &len, (const GLubyte*)"program_interface_query", 23)) { ret = GLEW_ARB_program_interface_query; continue; } #endif #ifdef GL_ARB_provoking_vertex if (_glewStrSame3(&pos, &len, (const GLubyte*)"provoking_vertex", 16)) { ret = GLEW_ARB_provoking_vertex; continue; } #endif #ifdef GL_ARB_query_buffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"query_buffer_object", 19)) { ret = GLEW_ARB_query_buffer_object; continue; } #endif #ifdef GL_ARB_robust_buffer_access_behavior if (_glewStrSame3(&pos, &len, (const GLubyte*)"robust_buffer_access_behavior", 29)) { ret = GLEW_ARB_robust_buffer_access_behavior; continue; } #endif #ifdef GL_ARB_robustness if (_glewStrSame3(&pos, &len, (const GLubyte*)"robustness", 10)) { ret = GLEW_ARB_robustness; continue; } #endif #ifdef GL_ARB_robustness_application_isolation if (_glewStrSame3(&pos, &len, (const GLubyte*)"robustness_application_isolation", 32)) { ret = GLEW_ARB_robustness_application_isolation; continue; } #endif #ifdef GL_ARB_robustness_share_group_isolation if (_glewStrSame3(&pos, &len, (const GLubyte*)"robustness_share_group_isolation", 32)) { ret = GLEW_ARB_robustness_share_group_isolation; continue; } #endif #ifdef GL_ARB_sample_locations if (_glewStrSame3(&pos, &len, (const GLubyte*)"sample_locations", 16)) { ret = GLEW_ARB_sample_locations; continue; } #endif #ifdef GL_ARB_sample_shading if (_glewStrSame3(&pos, &len, (const GLubyte*)"sample_shading", 14)) { ret = GLEW_ARB_sample_shading; continue; } #endif #ifdef GL_ARB_sampler_objects if (_glewStrSame3(&pos, &len, (const GLubyte*)"sampler_objects", 15)) { ret = GLEW_ARB_sampler_objects; continue; } #endif #ifdef GL_ARB_seamless_cube_map if (_glewStrSame3(&pos, &len, (const GLubyte*)"seamless_cube_map", 17)) { ret = GLEW_ARB_seamless_cube_map; continue; } #endif #ifdef GL_ARB_seamless_cubemap_per_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"seamless_cubemap_per_texture", 28)) { ret = GLEW_ARB_seamless_cubemap_per_texture; continue; } #endif #ifdef GL_ARB_separate_shader_objects if (_glewStrSame3(&pos, &len, (const GLubyte*)"separate_shader_objects", 23)) { ret = GLEW_ARB_separate_shader_objects; continue; } #endif #ifdef GL_ARB_shader_atomic_counter_ops if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_atomic_counter_ops", 25)) { ret = GLEW_ARB_shader_atomic_counter_ops; continue; } #endif #ifdef GL_ARB_shader_atomic_counters if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_atomic_counters", 22)) { ret = GLEW_ARB_shader_atomic_counters; continue; } #endif #ifdef GL_ARB_shader_ballot if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_ballot", 13)) { ret = GLEW_ARB_shader_ballot; continue; } #endif #ifdef GL_ARB_shader_bit_encoding if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_bit_encoding", 19)) { ret = GLEW_ARB_shader_bit_encoding; continue; } #endif #ifdef GL_ARB_shader_clock if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_clock", 12)) { ret = GLEW_ARB_shader_clock; continue; } #endif #ifdef GL_ARB_shader_draw_parameters if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_draw_parameters", 22)) { ret = GLEW_ARB_shader_draw_parameters; continue; } #endif #ifdef GL_ARB_shader_group_vote if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_group_vote", 17)) { ret = GLEW_ARB_shader_group_vote; continue; } #endif #ifdef GL_ARB_shader_image_load_store if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_image_load_store", 23)) { ret = GLEW_ARB_shader_image_load_store; continue; } #endif #ifdef GL_ARB_shader_image_size if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_image_size", 17)) { ret = GLEW_ARB_shader_image_size; continue; } #endif #ifdef GL_ARB_shader_objects if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_objects", 14)) { ret = GLEW_ARB_shader_objects; continue; } #endif #ifdef GL_ARB_shader_precision if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_precision", 16)) { ret = GLEW_ARB_shader_precision; continue; } #endif #ifdef GL_ARB_shader_stencil_export if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_stencil_export", 21)) { ret = GLEW_ARB_shader_stencil_export; continue; } #endif #ifdef GL_ARB_shader_storage_buffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_storage_buffer_object", 28)) { ret = GLEW_ARB_shader_storage_buffer_object; continue; } #endif #ifdef GL_ARB_shader_subroutine if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_subroutine", 17)) { ret = GLEW_ARB_shader_subroutine; continue; } #endif #ifdef GL_ARB_shader_texture_image_samples if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_texture_image_samples", 28)) { ret = GLEW_ARB_shader_texture_image_samples; continue; } #endif #ifdef GL_ARB_shader_texture_lod if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_texture_lod", 18)) { ret = GLEW_ARB_shader_texture_lod; continue; } #endif #ifdef GL_ARB_shader_viewport_layer_array if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_viewport_layer_array", 27)) { ret = GLEW_ARB_shader_viewport_layer_array; continue; } #endif #ifdef GL_ARB_shading_language_100 if (_glewStrSame3(&pos, &len, (const GLubyte*)"shading_language_100", 20)) { ret = GLEW_ARB_shading_language_100; continue; } #endif #ifdef GL_ARB_shading_language_420pack if (_glewStrSame3(&pos, &len, (const GLubyte*)"shading_language_420pack", 24)) { ret = GLEW_ARB_shading_language_420pack; continue; } #endif #ifdef GL_ARB_shading_language_include if (_glewStrSame3(&pos, &len, (const GLubyte*)"shading_language_include", 24)) { ret = GLEW_ARB_shading_language_include; continue; } #endif #ifdef GL_ARB_shading_language_packing if (_glewStrSame3(&pos, &len, (const GLubyte*)"shading_language_packing", 24)) { ret = GLEW_ARB_shading_language_packing; continue; } #endif #ifdef GL_ARB_shadow if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow", 6)) { ret = GLEW_ARB_shadow; continue; } #endif #ifdef GL_ARB_shadow_ambient if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow_ambient", 14)) { ret = GLEW_ARB_shadow_ambient; continue; } #endif #ifdef GL_ARB_sparse_buffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"sparse_buffer", 13)) { ret = GLEW_ARB_sparse_buffer; continue; } #endif #ifdef GL_ARB_sparse_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"sparse_texture", 14)) { ret = GLEW_ARB_sparse_texture; continue; } #endif #ifdef GL_ARB_sparse_texture2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"sparse_texture2", 15)) { ret = GLEW_ARB_sparse_texture2; continue; } #endif #ifdef GL_ARB_sparse_texture_clamp if (_glewStrSame3(&pos, &len, (const GLubyte*)"sparse_texture_clamp", 20)) { ret = GLEW_ARB_sparse_texture_clamp; continue; } #endif #ifdef GL_ARB_stencil_texturing if (_glewStrSame3(&pos, &len, (const GLubyte*)"stencil_texturing", 17)) { ret = GLEW_ARB_stencil_texturing; continue; } #endif #ifdef GL_ARB_sync if (_glewStrSame3(&pos, &len, (const GLubyte*)"sync", 4)) { ret = GLEW_ARB_sync; continue; } #endif #ifdef GL_ARB_tessellation_shader if (_glewStrSame3(&pos, &len, (const GLubyte*)"tessellation_shader", 19)) { ret = GLEW_ARB_tessellation_shader; continue; } #endif #ifdef GL_ARB_texture_barrier if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_barrier", 15)) { ret = GLEW_ARB_texture_barrier; continue; } #endif #ifdef GL_ARB_texture_border_clamp if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_border_clamp", 20)) { ret = GLEW_ARB_texture_border_clamp; continue; } #endif #ifdef GL_ARB_texture_buffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_buffer_object", 21)) { ret = GLEW_ARB_texture_buffer_object; continue; } #endif #ifdef GL_ARB_texture_buffer_object_rgb32 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_buffer_object_rgb32", 27)) { ret = GLEW_ARB_texture_buffer_object_rgb32; continue; } #endif #ifdef GL_ARB_texture_buffer_range if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_buffer_range", 20)) { ret = GLEW_ARB_texture_buffer_range; continue; } #endif #ifdef GL_ARB_texture_compression if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression", 19)) { ret = GLEW_ARB_texture_compression; continue; } #endif #ifdef GL_ARB_texture_compression_bptc if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_bptc", 24)) { ret = GLEW_ARB_texture_compression_bptc; continue; } #endif #ifdef GL_ARB_texture_compression_rgtc if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_rgtc", 24)) { ret = GLEW_ARB_texture_compression_rgtc; continue; } #endif #ifdef GL_ARB_texture_cube_map if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_cube_map", 16)) { ret = GLEW_ARB_texture_cube_map; continue; } #endif #ifdef GL_ARB_texture_cube_map_array if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_cube_map_array", 22)) { ret = GLEW_ARB_texture_cube_map_array; continue; } #endif #ifdef GL_ARB_texture_env_add if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_add", 15)) { ret = GLEW_ARB_texture_env_add; continue; } #endif #ifdef GL_ARB_texture_env_combine if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine", 19)) { ret = GLEW_ARB_texture_env_combine; continue; } #endif #ifdef GL_ARB_texture_env_crossbar if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_crossbar", 20)) { ret = GLEW_ARB_texture_env_crossbar; continue; } #endif #ifdef GL_ARB_texture_env_dot3 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_dot3", 16)) { ret = GLEW_ARB_texture_env_dot3; continue; } #endif #ifdef GL_ARB_texture_filter_minmax if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_filter_minmax", 21)) { ret = GLEW_ARB_texture_filter_minmax; continue; } #endif #ifdef GL_ARB_texture_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_float", 13)) { ret = GLEW_ARB_texture_float; continue; } #endif #ifdef GL_ARB_texture_gather if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_gather", 14)) { ret = GLEW_ARB_texture_gather; continue; } #endif #ifdef GL_ARB_texture_mirror_clamp_to_edge if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_mirror_clamp_to_edge", 28)) { ret = GLEW_ARB_texture_mirror_clamp_to_edge; continue; } #endif #ifdef GL_ARB_texture_mirrored_repeat if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_mirrored_repeat", 23)) { ret = GLEW_ARB_texture_mirrored_repeat; continue; } #endif #ifdef GL_ARB_texture_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_multisample", 19)) { ret = GLEW_ARB_texture_multisample; continue; } #endif #ifdef GL_ARB_texture_non_power_of_two if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_non_power_of_two", 24)) { ret = GLEW_ARB_texture_non_power_of_two; continue; } #endif #ifdef GL_ARB_texture_query_levels if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_query_levels", 20)) { ret = GLEW_ARB_texture_query_levels; continue; } #endif #ifdef GL_ARB_texture_query_lod if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_query_lod", 17)) { ret = GLEW_ARB_texture_query_lod; continue; } #endif #ifdef GL_ARB_texture_rectangle if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rectangle", 17)) { ret = GLEW_ARB_texture_rectangle; continue; } #endif #ifdef GL_ARB_texture_rg if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rg", 10)) { ret = GLEW_ARB_texture_rg; continue; } #endif #ifdef GL_ARB_texture_rgb10_a2ui if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rgb10_a2ui", 18)) { ret = GLEW_ARB_texture_rgb10_a2ui; continue; } #endif #ifdef GL_ARB_texture_stencil8 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_stencil8", 16)) { ret = GLEW_ARB_texture_stencil8; continue; } #endif #ifdef GL_ARB_texture_storage if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_storage", 15)) { ret = GLEW_ARB_texture_storage; continue; } #endif #ifdef GL_ARB_texture_storage_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_storage_multisample", 27)) { ret = GLEW_ARB_texture_storage_multisample; continue; } #endif #ifdef GL_ARB_texture_swizzle if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_swizzle", 15)) { ret = GLEW_ARB_texture_swizzle; continue; } #endif #ifdef GL_ARB_texture_view if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_view", 12)) { ret = GLEW_ARB_texture_view; continue; } #endif #ifdef GL_ARB_timer_query if (_glewStrSame3(&pos, &len, (const GLubyte*)"timer_query", 11)) { ret = GLEW_ARB_timer_query; continue; } #endif #ifdef GL_ARB_transform_feedback2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback2", 19)) { ret = GLEW_ARB_transform_feedback2; continue; } #endif #ifdef GL_ARB_transform_feedback3 if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback3", 19)) { ret = GLEW_ARB_transform_feedback3; continue; } #endif #ifdef GL_ARB_transform_feedback_instanced if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback_instanced", 28)) { ret = GLEW_ARB_transform_feedback_instanced; continue; } #endif #ifdef GL_ARB_transform_feedback_overflow_query if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback_overflow_query", 33)) { ret = GLEW_ARB_transform_feedback_overflow_query; continue; } #endif #ifdef GL_ARB_transpose_matrix if (_glewStrSame3(&pos, &len, (const GLubyte*)"transpose_matrix", 16)) { ret = GLEW_ARB_transpose_matrix; continue; } #endif #ifdef GL_ARB_uniform_buffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"uniform_buffer_object", 21)) { ret = GLEW_ARB_uniform_buffer_object; continue; } #endif #ifdef GL_ARB_vertex_array_bgra if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_bgra", 17)) { ret = GLEW_ARB_vertex_array_bgra; continue; } #endif #ifdef GL_ARB_vertex_array_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_object", 19)) { ret = GLEW_ARB_vertex_array_object; continue; } #endif #ifdef GL_ARB_vertex_attrib_64bit if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_attrib_64bit", 19)) { ret = GLEW_ARB_vertex_attrib_64bit; continue; } #endif #ifdef GL_ARB_vertex_attrib_binding if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_attrib_binding", 21)) { ret = GLEW_ARB_vertex_attrib_binding; continue; } #endif #ifdef GL_ARB_vertex_blend if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_blend", 12)) { ret = GLEW_ARB_vertex_blend; continue; } #endif #ifdef GL_ARB_vertex_buffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_buffer_object", 20)) { ret = GLEW_ARB_vertex_buffer_object; continue; } #endif #ifdef GL_ARB_vertex_program if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program", 14)) { ret = GLEW_ARB_vertex_program; continue; } #endif #ifdef GL_ARB_vertex_shader if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_shader", 13)) { ret = GLEW_ARB_vertex_shader; continue; } #endif #ifdef GL_ARB_vertex_type_10f_11f_11f_rev if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_type_10f_11f_11f_rev", 27)) { ret = GLEW_ARB_vertex_type_10f_11f_11f_rev; continue; } #endif #ifdef GL_ARB_vertex_type_2_10_10_10_rev if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_type_2_10_10_10_rev", 26)) { ret = GLEW_ARB_vertex_type_2_10_10_10_rev; continue; } #endif #ifdef GL_ARB_viewport_array if (_glewStrSame3(&pos, &len, (const GLubyte*)"viewport_array", 14)) { ret = GLEW_ARB_viewport_array; continue; } #endif #ifdef GL_ARB_window_pos if (_glewStrSame3(&pos, &len, (const GLubyte*)"window_pos", 10)) { ret = GLEW_ARB_window_pos; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"ATIX_", 5)) { #ifdef GL_ATIX_point_sprites if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_sprites", 13)) { ret = GLEW_ATIX_point_sprites; continue; } #endif #ifdef GL_ATIX_texture_env_combine3 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine3", 20)) { ret = GLEW_ATIX_texture_env_combine3; continue; } #endif #ifdef GL_ATIX_texture_env_route if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_route", 17)) { ret = GLEW_ATIX_texture_env_route; continue; } #endif #ifdef GL_ATIX_vertex_shader_output_point_size if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_shader_output_point_size", 31)) { ret = GLEW_ATIX_vertex_shader_output_point_size; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"ATI_", 4)) { #ifdef GL_ATI_draw_buffers if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_buffers", 12)) { ret = GLEW_ATI_draw_buffers; continue; } #endif #ifdef GL_ATI_element_array if (_glewStrSame3(&pos, &len, (const GLubyte*)"element_array", 13)) { ret = GLEW_ATI_element_array; continue; } #endif #ifdef GL_ATI_envmap_bumpmap if (_glewStrSame3(&pos, &len, (const GLubyte*)"envmap_bumpmap", 14)) { ret = GLEW_ATI_envmap_bumpmap; continue; } #endif #ifdef GL_ATI_fragment_shader if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_shader", 15)) { ret = GLEW_ATI_fragment_shader; continue; } #endif #ifdef GL_ATI_map_object_buffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"map_object_buffer", 17)) { ret = GLEW_ATI_map_object_buffer; continue; } #endif #ifdef GL_ATI_meminfo if (_glewStrSame3(&pos, &len, (const GLubyte*)"meminfo", 7)) { ret = GLEW_ATI_meminfo; continue; } #endif #ifdef GL_ATI_pn_triangles if (_glewStrSame3(&pos, &len, (const GLubyte*)"pn_triangles", 12)) { ret = GLEW_ATI_pn_triangles; continue; } #endif #ifdef GL_ATI_separate_stencil if (_glewStrSame3(&pos, &len, (const GLubyte*)"separate_stencil", 16)) { ret = GLEW_ATI_separate_stencil; continue; } #endif #ifdef GL_ATI_shader_texture_lod if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_texture_lod", 18)) { ret = GLEW_ATI_shader_texture_lod; continue; } #endif #ifdef GL_ATI_text_fragment_shader if (_glewStrSame3(&pos, &len, (const GLubyte*)"text_fragment_shader", 20)) { ret = GLEW_ATI_text_fragment_shader; continue; } #endif #ifdef GL_ATI_texture_compression_3dc if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_3dc", 23)) { ret = GLEW_ATI_texture_compression_3dc; continue; } #endif #ifdef GL_ATI_texture_env_combine3 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine3", 20)) { ret = GLEW_ATI_texture_env_combine3; continue; } #endif #ifdef GL_ATI_texture_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_float", 13)) { ret = GLEW_ATI_texture_float; continue; } #endif #ifdef GL_ATI_texture_mirror_once if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_mirror_once", 19)) { ret = GLEW_ATI_texture_mirror_once; continue; } #endif #ifdef GL_ATI_vertex_array_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_object", 19)) { ret = GLEW_ATI_vertex_array_object; continue; } #endif #ifdef GL_ATI_vertex_attrib_array_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_attrib_array_object", 26)) { ret = GLEW_ATI_vertex_attrib_array_object; continue; } #endif #ifdef GL_ATI_vertex_streams if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_streams", 14)) { ret = GLEW_ATI_vertex_streams; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"EXT_", 4)) { #ifdef GL_EXT_422_pixels if (_glewStrSame3(&pos, &len, (const GLubyte*)"422_pixels", 10)) { ret = GLEW_EXT_422_pixels; continue; } #endif #ifdef GL_EXT_Cg_shader if (_glewStrSame3(&pos, &len, (const GLubyte*)"Cg_shader", 9)) { ret = GLEW_EXT_Cg_shader; continue; } #endif #ifdef GL_EXT_abgr if (_glewStrSame3(&pos, &len, (const GLubyte*)"abgr", 4)) { ret = GLEW_EXT_abgr; continue; } #endif #ifdef GL_EXT_bgra if (_glewStrSame3(&pos, &len, (const GLubyte*)"bgra", 4)) { ret = GLEW_EXT_bgra; continue; } #endif #ifdef GL_EXT_bindable_uniform if (_glewStrSame3(&pos, &len, (const GLubyte*)"bindable_uniform", 16)) { ret = GLEW_EXT_bindable_uniform; continue; } #endif #ifdef GL_EXT_blend_color if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_color", 11)) { ret = GLEW_EXT_blend_color; continue; } #endif #ifdef GL_EXT_blend_equation_separate if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_equation_separate", 23)) { ret = GLEW_EXT_blend_equation_separate; continue; } #endif #ifdef GL_EXT_blend_func_separate if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_func_separate", 19)) { ret = GLEW_EXT_blend_func_separate; continue; } #endif #ifdef GL_EXT_blend_logic_op if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_logic_op", 14)) { ret = GLEW_EXT_blend_logic_op; continue; } #endif #ifdef GL_EXT_blend_minmax if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_minmax", 12)) { ret = GLEW_EXT_blend_minmax; continue; } #endif #ifdef GL_EXT_blend_subtract if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_subtract", 14)) { ret = GLEW_EXT_blend_subtract; continue; } #endif #ifdef GL_EXT_clip_volume_hint if (_glewStrSame3(&pos, &len, (const GLubyte*)"clip_volume_hint", 16)) { ret = GLEW_EXT_clip_volume_hint; continue; } #endif #ifdef GL_EXT_cmyka if (_glewStrSame3(&pos, &len, (const GLubyte*)"cmyka", 5)) { ret = GLEW_EXT_cmyka; continue; } #endif #ifdef GL_EXT_color_subtable if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_subtable", 14)) { ret = GLEW_EXT_color_subtable; continue; } #endif #ifdef GL_EXT_compiled_vertex_array if (_glewStrSame3(&pos, &len, (const GLubyte*)"compiled_vertex_array", 21)) { ret = GLEW_EXT_compiled_vertex_array; continue; } #endif #ifdef GL_EXT_convolution if (_glewStrSame3(&pos, &len, (const GLubyte*)"convolution", 11)) { ret = GLEW_EXT_convolution; continue; } #endif #ifdef GL_EXT_coordinate_frame if (_glewStrSame3(&pos, &len, (const GLubyte*)"coordinate_frame", 16)) { ret = GLEW_EXT_coordinate_frame; continue; } #endif #ifdef GL_EXT_copy_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_texture", 12)) { ret = GLEW_EXT_copy_texture; continue; } #endif #ifdef GL_EXT_cull_vertex if (_glewStrSame3(&pos, &len, (const GLubyte*)"cull_vertex", 11)) { ret = GLEW_EXT_cull_vertex; continue; } #endif #ifdef GL_EXT_debug_label if (_glewStrSame3(&pos, &len, (const GLubyte*)"debug_label", 11)) { ret = GLEW_EXT_debug_label; continue; } #endif #ifdef GL_EXT_debug_marker if (_glewStrSame3(&pos, &len, (const GLubyte*)"debug_marker", 12)) { ret = GLEW_EXT_debug_marker; continue; } #endif #ifdef GL_EXT_depth_bounds_test if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_bounds_test", 17)) { ret = GLEW_EXT_depth_bounds_test; continue; } #endif #ifdef GL_EXT_direct_state_access if (_glewStrSame3(&pos, &len, (const GLubyte*)"direct_state_access", 19)) { ret = GLEW_EXT_direct_state_access; continue; } #endif #ifdef GL_EXT_draw_buffers2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_buffers2", 13)) { ret = GLEW_EXT_draw_buffers2; continue; } #endif #ifdef GL_EXT_draw_instanced if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_instanced", 14)) { ret = GLEW_EXT_draw_instanced; continue; } #endif #ifdef GL_EXT_draw_range_elements if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_range_elements", 19)) { ret = GLEW_EXT_draw_range_elements; continue; } #endif #ifdef GL_EXT_fog_coord if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_coord", 9)) { ret = GLEW_EXT_fog_coord; continue; } #endif #ifdef GL_EXT_fragment_lighting if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_lighting", 17)) { ret = GLEW_EXT_fragment_lighting; continue; } #endif #ifdef GL_EXT_framebuffer_blit if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_blit", 16)) { ret = GLEW_EXT_framebuffer_blit; continue; } #endif #ifdef GL_EXT_framebuffer_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_multisample", 23)) { ret = GLEW_EXT_framebuffer_multisample; continue; } #endif #ifdef GL_EXT_framebuffer_multisample_blit_scaled if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_multisample_blit_scaled", 35)) { ret = GLEW_EXT_framebuffer_multisample_blit_scaled; continue; } #endif #ifdef GL_EXT_framebuffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_object", 18)) { ret = GLEW_EXT_framebuffer_object; continue; } #endif #ifdef GL_EXT_framebuffer_sRGB if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) { ret = GLEW_EXT_framebuffer_sRGB; continue; } #endif #ifdef GL_EXT_geometry_shader4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"geometry_shader4", 16)) { ret = GLEW_EXT_geometry_shader4; continue; } #endif #ifdef GL_EXT_gpu_program_parameters if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_program_parameters", 22)) { ret = GLEW_EXT_gpu_program_parameters; continue; } #endif #ifdef GL_EXT_gpu_shader4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_shader4", 11)) { ret = GLEW_EXT_gpu_shader4; continue; } #endif #ifdef GL_EXT_histogram if (_glewStrSame3(&pos, &len, (const GLubyte*)"histogram", 9)) { ret = GLEW_EXT_histogram; continue; } #endif #ifdef GL_EXT_index_array_formats if (_glewStrSame3(&pos, &len, (const GLubyte*)"index_array_formats", 19)) { ret = GLEW_EXT_index_array_formats; continue; } #endif #ifdef GL_EXT_index_func if (_glewStrSame3(&pos, &len, (const GLubyte*)"index_func", 10)) { ret = GLEW_EXT_index_func; continue; } #endif #ifdef GL_EXT_index_material if (_glewStrSame3(&pos, &len, (const GLubyte*)"index_material", 14)) { ret = GLEW_EXT_index_material; continue; } #endif #ifdef GL_EXT_index_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"index_texture", 13)) { ret = GLEW_EXT_index_texture; continue; } #endif #ifdef GL_EXT_light_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"light_texture", 13)) { ret = GLEW_EXT_light_texture; continue; } #endif #ifdef GL_EXT_misc_attribute if (_glewStrSame3(&pos, &len, (const GLubyte*)"misc_attribute", 14)) { ret = GLEW_EXT_misc_attribute; continue; } #endif #ifdef GL_EXT_multi_draw_arrays if (_glewStrSame3(&pos, &len, (const GLubyte*)"multi_draw_arrays", 17)) { ret = GLEW_EXT_multi_draw_arrays; continue; } #endif #ifdef GL_EXT_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) { ret = GLEW_EXT_multisample; continue; } #endif #ifdef GL_EXT_packed_depth_stencil if (_glewStrSame3(&pos, &len, (const GLubyte*)"packed_depth_stencil", 20)) { ret = GLEW_EXT_packed_depth_stencil; continue; } #endif #ifdef GL_EXT_packed_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"packed_float", 12)) { ret = GLEW_EXT_packed_float; continue; } #endif #ifdef GL_EXT_packed_pixels if (_glewStrSame3(&pos, &len, (const GLubyte*)"packed_pixels", 13)) { ret = GLEW_EXT_packed_pixels; continue; } #endif #ifdef GL_EXT_paletted_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"paletted_texture", 16)) { ret = GLEW_EXT_paletted_texture; continue; } #endif #ifdef GL_EXT_pixel_buffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_buffer_object", 19)) { ret = GLEW_EXT_pixel_buffer_object; continue; } #endif #ifdef GL_EXT_pixel_transform if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_transform", 15)) { ret = GLEW_EXT_pixel_transform; continue; } #endif #ifdef GL_EXT_pixel_transform_color_table if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_transform_color_table", 27)) { ret = GLEW_EXT_pixel_transform_color_table; continue; } #endif #ifdef GL_EXT_point_parameters if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_parameters", 16)) { ret = GLEW_EXT_point_parameters; continue; } #endif #ifdef GL_EXT_polygon_offset if (_glewStrSame3(&pos, &len, (const GLubyte*)"polygon_offset", 14)) { ret = GLEW_EXT_polygon_offset; continue; } #endif #ifdef GL_EXT_polygon_offset_clamp if (_glewStrSame3(&pos, &len, (const GLubyte*)"polygon_offset_clamp", 20)) { ret = GLEW_EXT_polygon_offset_clamp; continue; } #endif #ifdef GL_EXT_post_depth_coverage if (_glewStrSame3(&pos, &len, (const GLubyte*)"post_depth_coverage", 19)) { ret = GLEW_EXT_post_depth_coverage; continue; } #endif #ifdef GL_EXT_provoking_vertex if (_glewStrSame3(&pos, &len, (const GLubyte*)"provoking_vertex", 16)) { ret = GLEW_EXT_provoking_vertex; continue; } #endif #ifdef GL_EXT_raster_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"raster_multisample", 18)) { ret = GLEW_EXT_raster_multisample; continue; } #endif #ifdef GL_EXT_rescale_normal if (_glewStrSame3(&pos, &len, (const GLubyte*)"rescale_normal", 14)) { ret = GLEW_EXT_rescale_normal; continue; } #endif #ifdef GL_EXT_scene_marker if (_glewStrSame3(&pos, &len, (const GLubyte*)"scene_marker", 12)) { ret = GLEW_EXT_scene_marker; continue; } #endif #ifdef GL_EXT_secondary_color if (_glewStrSame3(&pos, &len, (const GLubyte*)"secondary_color", 15)) { ret = GLEW_EXT_secondary_color; continue; } #endif #ifdef GL_EXT_separate_shader_objects if (_glewStrSame3(&pos, &len, (const GLubyte*)"separate_shader_objects", 23)) { ret = GLEW_EXT_separate_shader_objects; continue; } #endif #ifdef GL_EXT_separate_specular_color if (_glewStrSame3(&pos, &len, (const GLubyte*)"separate_specular_color", 23)) { ret = GLEW_EXT_separate_specular_color; continue; } #endif #ifdef GL_EXT_shader_image_load_formatted if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_image_load_formatted", 27)) { ret = GLEW_EXT_shader_image_load_formatted; continue; } #endif #ifdef GL_EXT_shader_image_load_store if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_image_load_store", 23)) { ret = GLEW_EXT_shader_image_load_store; continue; } #endif #ifdef GL_EXT_shader_integer_mix if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_integer_mix", 18)) { ret = GLEW_EXT_shader_integer_mix; continue; } #endif #ifdef GL_EXT_shadow_funcs if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow_funcs", 12)) { ret = GLEW_EXT_shadow_funcs; continue; } #endif #ifdef GL_EXT_shared_texture_palette if (_glewStrSame3(&pos, &len, (const GLubyte*)"shared_texture_palette", 22)) { ret = GLEW_EXT_shared_texture_palette; continue; } #endif #ifdef GL_EXT_sparse_texture2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"sparse_texture2", 15)) { ret = GLEW_EXT_sparse_texture2; continue; } #endif #ifdef GL_EXT_stencil_clear_tag if (_glewStrSame3(&pos, &len, (const GLubyte*)"stencil_clear_tag", 17)) { ret = GLEW_EXT_stencil_clear_tag; continue; } #endif #ifdef GL_EXT_stencil_two_side if (_glewStrSame3(&pos, &len, (const GLubyte*)"stencil_two_side", 16)) { ret = GLEW_EXT_stencil_two_side; continue; } #endif #ifdef GL_EXT_stencil_wrap if (_glewStrSame3(&pos, &len, (const GLubyte*)"stencil_wrap", 12)) { ret = GLEW_EXT_stencil_wrap; continue; } #endif #ifdef GL_EXT_subtexture if (_glewStrSame3(&pos, &len, (const GLubyte*)"subtexture", 10)) { ret = GLEW_EXT_subtexture; continue; } #endif #ifdef GL_EXT_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture", 7)) { ret = GLEW_EXT_texture; continue; } #endif #ifdef GL_EXT_texture3D if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture3D", 9)) { ret = GLEW_EXT_texture3D; continue; } #endif #ifdef GL_EXT_texture_array if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_array", 13)) { ret = GLEW_EXT_texture_array; continue; } #endif #ifdef GL_EXT_texture_buffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_buffer_object", 21)) { ret = GLEW_EXT_texture_buffer_object; continue; } #endif #ifdef GL_EXT_texture_compression_dxt1 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_dxt1", 24)) { ret = GLEW_EXT_texture_compression_dxt1; continue; } #endif #ifdef GL_EXT_texture_compression_latc if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_latc", 24)) { ret = GLEW_EXT_texture_compression_latc; continue; } #endif #ifdef GL_EXT_texture_compression_rgtc if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_rgtc", 24)) { ret = GLEW_EXT_texture_compression_rgtc; continue; } #endif #ifdef GL_EXT_texture_compression_s3tc if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_s3tc", 24)) { ret = GLEW_EXT_texture_compression_s3tc; continue; } #endif #ifdef GL_EXT_texture_cube_map if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_cube_map", 16)) { ret = GLEW_EXT_texture_cube_map; continue; } #endif #ifdef GL_EXT_texture_edge_clamp if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_edge_clamp", 18)) { ret = GLEW_EXT_texture_edge_clamp; continue; } #endif #ifdef GL_EXT_texture_env if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env", 11)) { ret = GLEW_EXT_texture_env; continue; } #endif #ifdef GL_EXT_texture_env_add if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_add", 15)) { ret = GLEW_EXT_texture_env_add; continue; } #endif #ifdef GL_EXT_texture_env_combine if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine", 19)) { ret = GLEW_EXT_texture_env_combine; continue; } #endif #ifdef GL_EXT_texture_env_dot3 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_dot3", 16)) { ret = GLEW_EXT_texture_env_dot3; continue; } #endif #ifdef GL_EXT_texture_filter_anisotropic if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_filter_anisotropic", 26)) { ret = GLEW_EXT_texture_filter_anisotropic; continue; } #endif #ifdef GL_EXT_texture_filter_minmax if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_filter_minmax", 21)) { ret = GLEW_EXT_texture_filter_minmax; continue; } #endif #ifdef GL_EXT_texture_integer if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_integer", 15)) { ret = GLEW_EXT_texture_integer; continue; } #endif #ifdef GL_EXT_texture_lod_bias if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_lod_bias", 16)) { ret = GLEW_EXT_texture_lod_bias; continue; } #endif #ifdef GL_EXT_texture_mirror_clamp if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_mirror_clamp", 20)) { ret = GLEW_EXT_texture_mirror_clamp; continue; } #endif #ifdef GL_EXT_texture_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_object", 14)) { ret = GLEW_EXT_texture_object; continue; } #endif #ifdef GL_EXT_texture_perturb_normal if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_perturb_normal", 22)) { ret = GLEW_EXT_texture_perturb_normal; continue; } #endif #ifdef GL_EXT_texture_rectangle if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rectangle", 17)) { ret = GLEW_EXT_texture_rectangle; continue; } #endif #ifdef GL_EXT_texture_sRGB if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_sRGB", 12)) { ret = GLEW_EXT_texture_sRGB; continue; } #endif #ifdef GL_EXT_texture_sRGB_decode if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_sRGB_decode", 19)) { ret = GLEW_EXT_texture_sRGB_decode; continue; } #endif #ifdef GL_EXT_texture_shared_exponent if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_shared_exponent", 23)) { ret = GLEW_EXT_texture_shared_exponent; continue; } #endif #ifdef GL_EXT_texture_snorm if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_snorm", 13)) { ret = GLEW_EXT_texture_snorm; continue; } #endif #ifdef GL_EXT_texture_swizzle if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_swizzle", 15)) { ret = GLEW_EXT_texture_swizzle; continue; } #endif #ifdef GL_EXT_timer_query if (_glewStrSame3(&pos, &len, (const GLubyte*)"timer_query", 11)) { ret = GLEW_EXT_timer_query; continue; } #endif #ifdef GL_EXT_transform_feedback if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback", 18)) { ret = GLEW_EXT_transform_feedback; continue; } #endif #ifdef GL_EXT_vertex_array if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array", 12)) { ret = GLEW_EXT_vertex_array; continue; } #endif #ifdef GL_EXT_vertex_array_bgra if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_bgra", 17)) { ret = GLEW_EXT_vertex_array_bgra; continue; } #endif #ifdef GL_EXT_vertex_attrib_64bit if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_attrib_64bit", 19)) { ret = GLEW_EXT_vertex_attrib_64bit; continue; } #endif #ifdef GL_EXT_vertex_shader if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_shader", 13)) { ret = GLEW_EXT_vertex_shader; continue; } #endif #ifdef GL_EXT_vertex_weighting if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_weighting", 16)) { ret = GLEW_EXT_vertex_weighting; continue; } #endif #ifdef GL_EXT_x11_sync_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"x11_sync_object", 15)) { ret = GLEW_EXT_x11_sync_object; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"GREMEDY_", 8)) { #ifdef GL_GREMEDY_frame_terminator if (_glewStrSame3(&pos, &len, (const GLubyte*)"frame_terminator", 16)) { ret = GLEW_GREMEDY_frame_terminator; continue; } #endif #ifdef GL_GREMEDY_string_marker if (_glewStrSame3(&pos, &len, (const GLubyte*)"string_marker", 13)) { ret = GLEW_GREMEDY_string_marker; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"HP_", 3)) { #ifdef GL_HP_convolution_border_modes if (_glewStrSame3(&pos, &len, (const GLubyte*)"convolution_border_modes", 24)) { ret = GLEW_HP_convolution_border_modes; continue; } #endif #ifdef GL_HP_image_transform if (_glewStrSame3(&pos, &len, (const GLubyte*)"image_transform", 15)) { ret = GLEW_HP_image_transform; continue; } #endif #ifdef GL_HP_occlusion_test if (_glewStrSame3(&pos, &len, (const GLubyte*)"occlusion_test", 14)) { ret = GLEW_HP_occlusion_test; continue; } #endif #ifdef GL_HP_texture_lighting if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_lighting", 16)) { ret = GLEW_HP_texture_lighting; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"IBM_", 4)) { #ifdef GL_IBM_cull_vertex if (_glewStrSame3(&pos, &len, (const GLubyte*)"cull_vertex", 11)) { ret = GLEW_IBM_cull_vertex; continue; } #endif #ifdef GL_IBM_multimode_draw_arrays if (_glewStrSame3(&pos, &len, (const GLubyte*)"multimode_draw_arrays", 21)) { ret = GLEW_IBM_multimode_draw_arrays; continue; } #endif #ifdef GL_IBM_rasterpos_clip if (_glewStrSame3(&pos, &len, (const GLubyte*)"rasterpos_clip", 14)) { ret = GLEW_IBM_rasterpos_clip; continue; } #endif #ifdef GL_IBM_static_data if (_glewStrSame3(&pos, &len, (const GLubyte*)"static_data", 11)) { ret = GLEW_IBM_static_data; continue; } #endif #ifdef GL_IBM_texture_mirrored_repeat if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_mirrored_repeat", 23)) { ret = GLEW_IBM_texture_mirrored_repeat; continue; } #endif #ifdef GL_IBM_vertex_array_lists if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_lists", 18)) { ret = GLEW_IBM_vertex_array_lists; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"INGR_", 5)) { #ifdef GL_INGR_color_clamp if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_clamp", 11)) { ret = GLEW_INGR_color_clamp; continue; } #endif #ifdef GL_INGR_interlace_read if (_glewStrSame3(&pos, &len, (const GLubyte*)"interlace_read", 14)) { ret = GLEW_INGR_interlace_read; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"INTEL_", 6)) { #ifdef GL_INTEL_fragment_shader_ordering if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_shader_ordering", 24)) { ret = GLEW_INTEL_fragment_shader_ordering; continue; } #endif #ifdef GL_INTEL_framebuffer_CMAA if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_CMAA", 16)) { ret = GLEW_INTEL_framebuffer_CMAA; continue; } #endif #ifdef GL_INTEL_map_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"map_texture", 11)) { ret = GLEW_INTEL_map_texture; continue; } #endif #ifdef GL_INTEL_parallel_arrays if (_glewStrSame3(&pos, &len, (const GLubyte*)"parallel_arrays", 15)) { ret = GLEW_INTEL_parallel_arrays; continue; } #endif #ifdef GL_INTEL_performance_query if (_glewStrSame3(&pos, &len, (const GLubyte*)"performance_query", 17)) { ret = GLEW_INTEL_performance_query; continue; } #endif #ifdef GL_INTEL_texture_scissor if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_scissor", 15)) { ret = GLEW_INTEL_texture_scissor; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"KHR_", 4)) { #ifdef GL_KHR_blend_equation_advanced if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_equation_advanced", 23)) { ret = GLEW_KHR_blend_equation_advanced; continue; } #endif #ifdef GL_KHR_blend_equation_advanced_coherent if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_equation_advanced_coherent", 32)) { ret = GLEW_KHR_blend_equation_advanced_coherent; continue; } #endif #ifdef GL_KHR_context_flush_control if (_glewStrSame3(&pos, &len, (const GLubyte*)"context_flush_control", 21)) { ret = GLEW_KHR_context_flush_control; continue; } #endif #ifdef GL_KHR_debug if (_glewStrSame3(&pos, &len, (const GLubyte*)"debug", 5)) { ret = GLEW_KHR_debug; continue; } #endif #ifdef GL_KHR_no_error if (_glewStrSame3(&pos, &len, (const GLubyte*)"no_error", 8)) { ret = GLEW_KHR_no_error; continue; } #endif #ifdef GL_KHR_robust_buffer_access_behavior if (_glewStrSame3(&pos, &len, (const GLubyte*)"robust_buffer_access_behavior", 29)) { ret = GLEW_KHR_robust_buffer_access_behavior; continue; } #endif #ifdef GL_KHR_robustness if (_glewStrSame3(&pos, &len, (const GLubyte*)"robustness", 10)) { ret = GLEW_KHR_robustness; continue; } #endif #ifdef GL_KHR_texture_compression_astc_hdr if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_astc_hdr", 28)) { ret = GLEW_KHR_texture_compression_astc_hdr; continue; } #endif #ifdef GL_KHR_texture_compression_astc_ldr if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_astc_ldr", 28)) { ret = GLEW_KHR_texture_compression_astc_ldr; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"KTX_", 4)) { #ifdef GL_KTX_buffer_region if (_glewStrSame3(&pos, &len, (const GLubyte*)"buffer_region", 13)) { ret = GLEW_KTX_buffer_region; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"MESAX_", 6)) { #ifdef GL_MESAX_texture_stack if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_stack", 13)) { ret = GLEW_MESAX_texture_stack; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"MESA_", 5)) { #ifdef GL_MESA_pack_invert if (_glewStrSame3(&pos, &len, (const GLubyte*)"pack_invert", 11)) { ret = GLEW_MESA_pack_invert; continue; } #endif #ifdef GL_MESA_resize_buffers if (_glewStrSame3(&pos, &len, (const GLubyte*)"resize_buffers", 14)) { ret = GLEW_MESA_resize_buffers; continue; } #endif #ifdef GL_MESA_window_pos if (_glewStrSame3(&pos, &len, (const GLubyte*)"window_pos", 10)) { ret = GLEW_MESA_window_pos; continue; } #endif #ifdef GL_MESA_ycbcr_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"ycbcr_texture", 13)) { ret = GLEW_MESA_ycbcr_texture; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"NVX_", 4)) { #ifdef GL_NVX_conditional_render if (_glewStrSame3(&pos, &len, (const GLubyte*)"conditional_render", 18)) { ret = GLEW_NVX_conditional_render; continue; } #endif #ifdef GL_NVX_gpu_memory_info if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_memory_info", 15)) { ret = GLEW_NVX_gpu_memory_info; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"NV_", 3)) { #ifdef GL_NV_bindless_multi_draw_indirect if (_glewStrSame3(&pos, &len, (const GLubyte*)"bindless_multi_draw_indirect", 28)) { ret = GLEW_NV_bindless_multi_draw_indirect; continue; } #endif #ifdef GL_NV_bindless_multi_draw_indirect_count if (_glewStrSame3(&pos, &len, (const GLubyte*)"bindless_multi_draw_indirect_count", 34)) { ret = GLEW_NV_bindless_multi_draw_indirect_count; continue; } #endif #ifdef GL_NV_bindless_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"bindless_texture", 16)) { ret = GLEW_NV_bindless_texture; continue; } #endif #ifdef GL_NV_blend_equation_advanced if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_equation_advanced", 23)) { ret = GLEW_NV_blend_equation_advanced; continue; } #endif #ifdef GL_NV_blend_equation_advanced_coherent if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_equation_advanced_coherent", 32)) { ret = GLEW_NV_blend_equation_advanced_coherent; continue; } #endif #ifdef GL_NV_blend_square if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_square", 12)) { ret = GLEW_NV_blend_square; continue; } #endif #ifdef GL_NV_compute_program5 if (_glewStrSame3(&pos, &len, (const GLubyte*)"compute_program5", 16)) { ret = GLEW_NV_compute_program5; continue; } #endif #ifdef GL_NV_conditional_render if (_glewStrSame3(&pos, &len, (const GLubyte*)"conditional_render", 18)) { ret = GLEW_NV_conditional_render; continue; } #endif #ifdef GL_NV_conservative_raster if (_glewStrSame3(&pos, &len, (const GLubyte*)"conservative_raster", 19)) { ret = GLEW_NV_conservative_raster; continue; } #endif #ifdef GL_NV_conservative_raster_dilate if (_glewStrSame3(&pos, &len, (const GLubyte*)"conservative_raster_dilate", 26)) { ret = GLEW_NV_conservative_raster_dilate; continue; } #endif #ifdef GL_NV_copy_depth_to_color if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_depth_to_color", 19)) { ret = GLEW_NV_copy_depth_to_color; continue; } #endif #ifdef GL_NV_copy_image if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_image", 10)) { ret = GLEW_NV_copy_image; continue; } #endif #ifdef GL_NV_deep_texture3D if (_glewStrSame3(&pos, &len, (const GLubyte*)"deep_texture3D", 14)) { ret = GLEW_NV_deep_texture3D; continue; } #endif #ifdef GL_NV_depth_buffer_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_buffer_float", 18)) { ret = GLEW_NV_depth_buffer_float; continue; } #endif #ifdef GL_NV_depth_clamp if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_clamp", 11)) { ret = GLEW_NV_depth_clamp; continue; } #endif #ifdef GL_NV_depth_range_unclamped if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_range_unclamped", 21)) { ret = GLEW_NV_depth_range_unclamped; continue; } #endif #ifdef GL_NV_draw_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_texture", 12)) { ret = GLEW_NV_draw_texture; continue; } #endif #ifdef GL_NV_evaluators if (_glewStrSame3(&pos, &len, (const GLubyte*)"evaluators", 10)) { ret = GLEW_NV_evaluators; continue; } #endif #ifdef GL_NV_explicit_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"explicit_multisample", 20)) { ret = GLEW_NV_explicit_multisample; continue; } #endif #ifdef GL_NV_fence if (_glewStrSame3(&pos, &len, (const GLubyte*)"fence", 5)) { ret = GLEW_NV_fence; continue; } #endif #ifdef GL_NV_fill_rectangle if (_glewStrSame3(&pos, &len, (const GLubyte*)"fill_rectangle", 14)) { ret = GLEW_NV_fill_rectangle; continue; } #endif #ifdef GL_NV_float_buffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"float_buffer", 12)) { ret = GLEW_NV_float_buffer; continue; } #endif #ifdef GL_NV_fog_distance if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_distance", 12)) { ret = GLEW_NV_fog_distance; continue; } #endif #ifdef GL_NV_fragment_coverage_to_color if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_coverage_to_color", 26)) { ret = GLEW_NV_fragment_coverage_to_color; continue; } #endif #ifdef GL_NV_fragment_program if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program", 16)) { ret = GLEW_NV_fragment_program; continue; } #endif #ifdef GL_NV_fragment_program2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program2", 17)) { ret = GLEW_NV_fragment_program2; continue; } #endif #ifdef GL_NV_fragment_program4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program4", 17)) { ret = GLEW_NV_fragment_program4; continue; } #endif #ifdef GL_NV_fragment_program_option if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program_option", 23)) { ret = GLEW_NV_fragment_program_option; continue; } #endif #ifdef GL_NV_fragment_shader_interlock if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_shader_interlock", 25)) { ret = GLEW_NV_fragment_shader_interlock; continue; } #endif #ifdef GL_NV_framebuffer_mixed_samples if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_mixed_samples", 25)) { ret = GLEW_NV_framebuffer_mixed_samples; continue; } #endif #ifdef GL_NV_framebuffer_multisample_coverage if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_multisample_coverage", 32)) { ret = GLEW_NV_framebuffer_multisample_coverage; continue; } #endif #ifdef GL_NV_geometry_program4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"geometry_program4", 17)) { ret = GLEW_NV_geometry_program4; continue; } #endif #ifdef GL_NV_geometry_shader4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"geometry_shader4", 16)) { ret = GLEW_NV_geometry_shader4; continue; } #endif #ifdef GL_NV_geometry_shader_passthrough if (_glewStrSame3(&pos, &len, (const GLubyte*)"geometry_shader_passthrough", 27)) { ret = GLEW_NV_geometry_shader_passthrough; continue; } #endif #ifdef GL_NV_gpu_program4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_program4", 12)) { ret = GLEW_NV_gpu_program4; continue; } #endif #ifdef GL_NV_gpu_program5 if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_program5", 12)) { ret = GLEW_NV_gpu_program5; continue; } #endif #ifdef GL_NV_gpu_program5_mem_extended if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_program5_mem_extended", 25)) { ret = GLEW_NV_gpu_program5_mem_extended; continue; } #endif #ifdef GL_NV_gpu_program_fp64 if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_program_fp64", 16)) { ret = GLEW_NV_gpu_program_fp64; continue; } #endif #ifdef GL_NV_gpu_shader5 if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_shader5", 11)) { ret = GLEW_NV_gpu_shader5; continue; } #endif #ifdef GL_NV_half_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"half_float", 10)) { ret = GLEW_NV_half_float; continue; } #endif #ifdef GL_NV_internalformat_sample_query if (_glewStrSame3(&pos, &len, (const GLubyte*)"internalformat_sample_query", 27)) { ret = GLEW_NV_internalformat_sample_query; continue; } #endif #ifdef GL_NV_light_max_exponent if (_glewStrSame3(&pos, &len, (const GLubyte*)"light_max_exponent", 18)) { ret = GLEW_NV_light_max_exponent; continue; } #endif #ifdef GL_NV_multisample_coverage if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample_coverage", 20)) { ret = GLEW_NV_multisample_coverage; continue; } #endif #ifdef GL_NV_multisample_filter_hint if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample_filter_hint", 23)) { ret = GLEW_NV_multisample_filter_hint; continue; } #endif #ifdef GL_NV_occlusion_query if (_glewStrSame3(&pos, &len, (const GLubyte*)"occlusion_query", 15)) { ret = GLEW_NV_occlusion_query; continue; } #endif #ifdef GL_NV_packed_depth_stencil if (_glewStrSame3(&pos, &len, (const GLubyte*)"packed_depth_stencil", 20)) { ret = GLEW_NV_packed_depth_stencil; continue; } #endif #ifdef GL_NV_parameter_buffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"parameter_buffer_object", 23)) { ret = GLEW_NV_parameter_buffer_object; continue; } #endif #ifdef GL_NV_parameter_buffer_object2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"parameter_buffer_object2", 24)) { ret = GLEW_NV_parameter_buffer_object2; continue; } #endif #ifdef GL_NV_path_rendering if (_glewStrSame3(&pos, &len, (const GLubyte*)"path_rendering", 14)) { ret = GLEW_NV_path_rendering; continue; } #endif #ifdef GL_NV_path_rendering_shared_edge if (_glewStrSame3(&pos, &len, (const GLubyte*)"path_rendering_shared_edge", 26)) { ret = GLEW_NV_path_rendering_shared_edge; continue; } #endif #ifdef GL_NV_pixel_data_range if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_data_range", 16)) { ret = GLEW_NV_pixel_data_range; continue; } #endif #ifdef GL_NV_point_sprite if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_sprite", 12)) { ret = GLEW_NV_point_sprite; continue; } #endif #ifdef GL_NV_present_video if (_glewStrSame3(&pos, &len, (const GLubyte*)"present_video", 13)) { ret = GLEW_NV_present_video; continue; } #endif #ifdef GL_NV_primitive_restart if (_glewStrSame3(&pos, &len, (const GLubyte*)"primitive_restart", 17)) { ret = GLEW_NV_primitive_restart; continue; } #endif #ifdef GL_NV_register_combiners if (_glewStrSame3(&pos, &len, (const GLubyte*)"register_combiners", 18)) { ret = GLEW_NV_register_combiners; continue; } #endif #ifdef GL_NV_register_combiners2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"register_combiners2", 19)) { ret = GLEW_NV_register_combiners2; continue; } #endif #ifdef GL_NV_sample_locations if (_glewStrSame3(&pos, &len, (const GLubyte*)"sample_locations", 16)) { ret = GLEW_NV_sample_locations; continue; } #endif #ifdef GL_NV_sample_mask_override_coverage if (_glewStrSame3(&pos, &len, (const GLubyte*)"sample_mask_override_coverage", 29)) { ret = GLEW_NV_sample_mask_override_coverage; continue; } #endif #ifdef GL_NV_shader_atomic_counters if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_atomic_counters", 22)) { ret = GLEW_NV_shader_atomic_counters; continue; } #endif #ifdef GL_NV_shader_atomic_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_atomic_float", 19)) { ret = GLEW_NV_shader_atomic_float; continue; } #endif #ifdef GL_NV_shader_atomic_fp16_vector if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_atomic_fp16_vector", 25)) { ret = GLEW_NV_shader_atomic_fp16_vector; continue; } #endif #ifdef GL_NV_shader_atomic_int64 if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_atomic_int64", 19)) { ret = GLEW_NV_shader_atomic_int64; continue; } #endif #ifdef GL_NV_shader_buffer_load if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_buffer_load", 18)) { ret = GLEW_NV_shader_buffer_load; continue; } #endif #ifdef GL_NV_shader_storage_buffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_storage_buffer_object", 28)) { ret = GLEW_NV_shader_storage_buffer_object; continue; } #endif #ifdef GL_NV_shader_thread_group if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_thread_group", 19)) { ret = GLEW_NV_shader_thread_group; continue; } #endif #ifdef GL_NV_shader_thread_shuffle if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_thread_shuffle", 21)) { ret = GLEW_NV_shader_thread_shuffle; continue; } #endif #ifdef GL_NV_tessellation_program5 if (_glewStrSame3(&pos, &len, (const GLubyte*)"tessellation_program5", 21)) { ret = GLEW_NV_tessellation_program5; continue; } #endif #ifdef GL_NV_texgen_emboss if (_glewStrSame3(&pos, &len, (const GLubyte*)"texgen_emboss", 13)) { ret = GLEW_NV_texgen_emboss; continue; } #endif #ifdef GL_NV_texgen_reflection if (_glewStrSame3(&pos, &len, (const GLubyte*)"texgen_reflection", 17)) { ret = GLEW_NV_texgen_reflection; continue; } #endif #ifdef GL_NV_texture_barrier if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_barrier", 15)) { ret = GLEW_NV_texture_barrier; continue; } #endif #ifdef GL_NV_texture_compression_vtc if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_vtc", 23)) { ret = GLEW_NV_texture_compression_vtc; continue; } #endif #ifdef GL_NV_texture_env_combine4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine4", 20)) { ret = GLEW_NV_texture_env_combine4; continue; } #endif #ifdef GL_NV_texture_expand_normal if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_expand_normal", 21)) { ret = GLEW_NV_texture_expand_normal; continue; } #endif #ifdef GL_NV_texture_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_multisample", 19)) { ret = GLEW_NV_texture_multisample; continue; } #endif #ifdef GL_NV_texture_rectangle if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rectangle", 17)) { ret = GLEW_NV_texture_rectangle; continue; } #endif #ifdef GL_NV_texture_shader if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_shader", 14)) { ret = GLEW_NV_texture_shader; continue; } #endif #ifdef GL_NV_texture_shader2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_shader2", 15)) { ret = GLEW_NV_texture_shader2; continue; } #endif #ifdef GL_NV_texture_shader3 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_shader3", 15)) { ret = GLEW_NV_texture_shader3; continue; } #endif #ifdef GL_NV_transform_feedback if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback", 18)) { ret = GLEW_NV_transform_feedback; continue; } #endif #ifdef GL_NV_transform_feedback2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback2", 19)) { ret = GLEW_NV_transform_feedback2; continue; } #endif #ifdef GL_NV_uniform_buffer_unified_memory if (_glewStrSame3(&pos, &len, (const GLubyte*)"uniform_buffer_unified_memory", 29)) { ret = GLEW_NV_uniform_buffer_unified_memory; continue; } #endif #ifdef GL_NV_vdpau_interop if (_glewStrSame3(&pos, &len, (const GLubyte*)"vdpau_interop", 13)) { ret = GLEW_NV_vdpau_interop; continue; } #endif #ifdef GL_NV_vertex_array_range if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range", 18)) { ret = GLEW_NV_vertex_array_range; continue; } #endif #ifdef GL_NV_vertex_array_range2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range2", 19)) { ret = GLEW_NV_vertex_array_range2; continue; } #endif #ifdef GL_NV_vertex_attrib_integer_64bit if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_attrib_integer_64bit", 27)) { ret = GLEW_NV_vertex_attrib_integer_64bit; continue; } #endif #ifdef GL_NV_vertex_buffer_unified_memory if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_buffer_unified_memory", 28)) { ret = GLEW_NV_vertex_buffer_unified_memory; continue; } #endif #ifdef GL_NV_vertex_program if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program", 14)) { ret = GLEW_NV_vertex_program; continue; } #endif #ifdef GL_NV_vertex_program1_1 if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program1_1", 17)) { ret = GLEW_NV_vertex_program1_1; continue; } #endif #ifdef GL_NV_vertex_program2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program2", 15)) { ret = GLEW_NV_vertex_program2; continue; } #endif #ifdef GL_NV_vertex_program2_option if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program2_option", 22)) { ret = GLEW_NV_vertex_program2_option; continue; } #endif #ifdef GL_NV_vertex_program3 if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program3", 15)) { ret = GLEW_NV_vertex_program3; continue; } #endif #ifdef GL_NV_vertex_program4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program4", 15)) { ret = GLEW_NV_vertex_program4; continue; } #endif #ifdef GL_NV_video_capture if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_capture", 13)) { ret = GLEW_NV_video_capture; continue; } #endif #ifdef GL_NV_viewport_array2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"viewport_array2", 15)) { ret = GLEW_NV_viewport_array2; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"OES_", 4)) { #ifdef GL_OES_byte_coordinates if (_glewStrSame3(&pos, &len, (const GLubyte*)"byte_coordinates", 16)) { ret = GLEW_OES_byte_coordinates; continue; } #endif #ifdef GL_OES_compressed_paletted_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"compressed_paletted_texture", 27)) { ret = GLEW_OES_compressed_paletted_texture; continue; } #endif #ifdef GL_OES_read_format if (_glewStrSame3(&pos, &len, (const GLubyte*)"read_format", 11)) { ret = GLEW_OES_read_format; continue; } #endif #ifdef GL_OES_single_precision if (_glewStrSame3(&pos, &len, (const GLubyte*)"single_precision", 16)) { ret = GLEW_OES_single_precision; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"OML_", 4)) { #ifdef GL_OML_interlace if (_glewStrSame3(&pos, &len, (const GLubyte*)"interlace", 9)) { ret = GLEW_OML_interlace; continue; } #endif #ifdef GL_OML_resample if (_glewStrSame3(&pos, &len, (const GLubyte*)"resample", 8)) { ret = GLEW_OML_resample; continue; } #endif #ifdef GL_OML_subsample if (_glewStrSame3(&pos, &len, (const GLubyte*)"subsample", 9)) { ret = GLEW_OML_subsample; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"OVR_", 4)) { #ifdef GL_OVR_multiview if (_glewStrSame3(&pos, &len, (const GLubyte*)"multiview", 9)) { ret = GLEW_OVR_multiview; continue; } #endif #ifdef GL_OVR_multiview2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"multiview2", 10)) { ret = GLEW_OVR_multiview2; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"PGI_", 4)) { #ifdef GL_PGI_misc_hints if (_glewStrSame3(&pos, &len, (const GLubyte*)"misc_hints", 10)) { ret = GLEW_PGI_misc_hints; continue; } #endif #ifdef GL_PGI_vertex_hints if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_hints", 12)) { ret = GLEW_PGI_vertex_hints; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"REGAL_", 6)) { #ifdef GL_REGAL_ES1_0_compatibility if (_glewStrSame3(&pos, &len, (const GLubyte*)"ES1_0_compatibility", 19)) { ret = GLEW_REGAL_ES1_0_compatibility; continue; } #endif #ifdef GL_REGAL_ES1_1_compatibility if (_glewStrSame3(&pos, &len, (const GLubyte*)"ES1_1_compatibility", 19)) { ret = GLEW_REGAL_ES1_1_compatibility; continue; } #endif #ifdef GL_REGAL_enable if (_glewStrSame3(&pos, &len, (const GLubyte*)"enable", 6)) { ret = GLEW_REGAL_enable; continue; } #endif #ifdef GL_REGAL_error_string if (_glewStrSame3(&pos, &len, (const GLubyte*)"error_string", 12)) { ret = GLEW_REGAL_error_string; continue; } #endif #ifdef GL_REGAL_extension_query if (_glewStrSame3(&pos, &len, (const GLubyte*)"extension_query", 15)) { ret = GLEW_REGAL_extension_query; continue; } #endif #ifdef GL_REGAL_log if (_glewStrSame3(&pos, &len, (const GLubyte*)"log", 3)) { ret = GLEW_REGAL_log; continue; } #endif #ifdef GL_REGAL_proc_address if (_glewStrSame3(&pos, &len, (const GLubyte*)"proc_address", 12)) { ret = GLEW_REGAL_proc_address; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"REND_", 5)) { #ifdef GL_REND_screen_coordinates if (_glewStrSame3(&pos, &len, (const GLubyte*)"screen_coordinates", 18)) { ret = GLEW_REND_screen_coordinates; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"S3_", 3)) { #ifdef GL_S3_s3tc if (_glewStrSame3(&pos, &len, (const GLubyte*)"s3tc", 4)) { ret = GLEW_S3_s3tc; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGIS_", 5)) { #ifdef GL_SGIS_color_range if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_range", 11)) { ret = GLEW_SGIS_color_range; continue; } #endif #ifdef GL_SGIS_detail_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"detail_texture", 14)) { ret = GLEW_SGIS_detail_texture; continue; } #endif #ifdef GL_SGIS_fog_function if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_function", 12)) { ret = GLEW_SGIS_fog_function; continue; } #endif #ifdef GL_SGIS_generate_mipmap if (_glewStrSame3(&pos, &len, (const GLubyte*)"generate_mipmap", 15)) { ret = GLEW_SGIS_generate_mipmap; continue; } #endif #ifdef GL_SGIS_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) { ret = GLEW_SGIS_multisample; continue; } #endif #ifdef GL_SGIS_pixel_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_texture", 13)) { ret = GLEW_SGIS_pixel_texture; continue; } #endif #ifdef GL_SGIS_point_line_texgen if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_line_texgen", 17)) { ret = GLEW_SGIS_point_line_texgen; continue; } #endif #ifdef GL_SGIS_sharpen_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"sharpen_texture", 15)) { ret = GLEW_SGIS_sharpen_texture; continue; } #endif #ifdef GL_SGIS_texture4D if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture4D", 9)) { ret = GLEW_SGIS_texture4D; continue; } #endif #ifdef GL_SGIS_texture_border_clamp if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_border_clamp", 20)) { ret = GLEW_SGIS_texture_border_clamp; continue; } #endif #ifdef GL_SGIS_texture_edge_clamp if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_edge_clamp", 18)) { ret = GLEW_SGIS_texture_edge_clamp; continue; } #endif #ifdef GL_SGIS_texture_filter4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_filter4", 15)) { ret = GLEW_SGIS_texture_filter4; continue; } #endif #ifdef GL_SGIS_texture_lod if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_lod", 11)) { ret = GLEW_SGIS_texture_lod; continue; } #endif #ifdef GL_SGIS_texture_select if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_select", 14)) { ret = GLEW_SGIS_texture_select; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGIX_", 5)) { #ifdef GL_SGIX_async if (_glewStrSame3(&pos, &len, (const GLubyte*)"async", 5)) { ret = GLEW_SGIX_async; continue; } #endif #ifdef GL_SGIX_async_histogram if (_glewStrSame3(&pos, &len, (const GLubyte*)"async_histogram", 15)) { ret = GLEW_SGIX_async_histogram; continue; } #endif #ifdef GL_SGIX_async_pixel if (_glewStrSame3(&pos, &len, (const GLubyte*)"async_pixel", 11)) { ret = GLEW_SGIX_async_pixel; continue; } #endif #ifdef GL_SGIX_blend_alpha_minmax if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_alpha_minmax", 18)) { ret = GLEW_SGIX_blend_alpha_minmax; continue; } #endif #ifdef GL_SGIX_clipmap if (_glewStrSame3(&pos, &len, (const GLubyte*)"clipmap", 7)) { ret = GLEW_SGIX_clipmap; continue; } #endif #ifdef GL_SGIX_convolution_accuracy if (_glewStrSame3(&pos, &len, (const GLubyte*)"convolution_accuracy", 20)) { ret = GLEW_SGIX_convolution_accuracy; continue; } #endif #ifdef GL_SGIX_depth_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_texture", 13)) { ret = GLEW_SGIX_depth_texture; continue; } #endif #ifdef GL_SGIX_flush_raster if (_glewStrSame3(&pos, &len, (const GLubyte*)"flush_raster", 12)) { ret = GLEW_SGIX_flush_raster; continue; } #endif #ifdef GL_SGIX_fog_offset if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_offset", 10)) { ret = GLEW_SGIX_fog_offset; continue; } #endif #ifdef GL_SGIX_fog_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_texture", 11)) { ret = GLEW_SGIX_fog_texture; continue; } #endif #ifdef GL_SGIX_fragment_specular_lighting if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_specular_lighting", 26)) { ret = GLEW_SGIX_fragment_specular_lighting; continue; } #endif #ifdef GL_SGIX_framezoom if (_glewStrSame3(&pos, &len, (const GLubyte*)"framezoom", 9)) { ret = GLEW_SGIX_framezoom; continue; } #endif #ifdef GL_SGIX_interlace if (_glewStrSame3(&pos, &len, (const GLubyte*)"interlace", 9)) { ret = GLEW_SGIX_interlace; continue; } #endif #ifdef GL_SGIX_ir_instrument1 if (_glewStrSame3(&pos, &len, (const GLubyte*)"ir_instrument1", 14)) { ret = GLEW_SGIX_ir_instrument1; continue; } #endif #ifdef GL_SGIX_list_priority if (_glewStrSame3(&pos, &len, (const GLubyte*)"list_priority", 13)) { ret = GLEW_SGIX_list_priority; continue; } #endif #ifdef GL_SGIX_pixel_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_texture", 13)) { ret = GLEW_SGIX_pixel_texture; continue; } #endif #ifdef GL_SGIX_pixel_texture_bits if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_texture_bits", 18)) { ret = GLEW_SGIX_pixel_texture_bits; continue; } #endif #ifdef GL_SGIX_reference_plane if (_glewStrSame3(&pos, &len, (const GLubyte*)"reference_plane", 15)) { ret = GLEW_SGIX_reference_plane; continue; } #endif #ifdef GL_SGIX_resample if (_glewStrSame3(&pos, &len, (const GLubyte*)"resample", 8)) { ret = GLEW_SGIX_resample; continue; } #endif #ifdef GL_SGIX_shadow if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow", 6)) { ret = GLEW_SGIX_shadow; continue; } #endif #ifdef GL_SGIX_shadow_ambient if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow_ambient", 14)) { ret = GLEW_SGIX_shadow_ambient; continue; } #endif #ifdef GL_SGIX_sprite if (_glewStrSame3(&pos, &len, (const GLubyte*)"sprite", 6)) { ret = GLEW_SGIX_sprite; continue; } #endif #ifdef GL_SGIX_tag_sample_buffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"tag_sample_buffer", 17)) { ret = GLEW_SGIX_tag_sample_buffer; continue; } #endif #ifdef GL_SGIX_texture_add_env if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_add_env", 15)) { ret = GLEW_SGIX_texture_add_env; continue; } #endif #ifdef GL_SGIX_texture_coordinate_clamp if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_coordinate_clamp", 24)) { ret = GLEW_SGIX_texture_coordinate_clamp; continue; } #endif #ifdef GL_SGIX_texture_lod_bias if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_lod_bias", 16)) { ret = GLEW_SGIX_texture_lod_bias; continue; } #endif #ifdef GL_SGIX_texture_multi_buffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_multi_buffer", 20)) { ret = GLEW_SGIX_texture_multi_buffer; continue; } #endif #ifdef GL_SGIX_texture_range if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_range", 13)) { ret = GLEW_SGIX_texture_range; continue; } #endif #ifdef GL_SGIX_texture_scale_bias if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_scale_bias", 18)) { ret = GLEW_SGIX_texture_scale_bias; continue; } #endif #ifdef GL_SGIX_vertex_preclip if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_preclip", 14)) { ret = GLEW_SGIX_vertex_preclip; continue; } #endif #ifdef GL_SGIX_vertex_preclip_hint if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_preclip_hint", 19)) { ret = GLEW_SGIX_vertex_preclip_hint; continue; } #endif #ifdef GL_SGIX_ycrcb if (_glewStrSame3(&pos, &len, (const GLubyte*)"ycrcb", 5)) { ret = GLEW_SGIX_ycrcb; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGI_", 4)) { #ifdef GL_SGI_color_matrix if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_matrix", 12)) { ret = GLEW_SGI_color_matrix; continue; } #endif #ifdef GL_SGI_color_table if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_table", 11)) { ret = GLEW_SGI_color_table; continue; } #endif #ifdef GL_SGI_texture_color_table if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_color_table", 19)) { ret = GLEW_SGI_texture_color_table; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"SUNX_", 5)) { #ifdef GL_SUNX_constant_data if (_glewStrSame3(&pos, &len, (const GLubyte*)"constant_data", 13)) { ret = GLEW_SUNX_constant_data; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"SUN_", 4)) { #ifdef GL_SUN_convolution_border_modes if (_glewStrSame3(&pos, &len, (const GLubyte*)"convolution_border_modes", 24)) { ret = GLEW_SUN_convolution_border_modes; continue; } #endif #ifdef GL_SUN_global_alpha if (_glewStrSame3(&pos, &len, (const GLubyte*)"global_alpha", 12)) { ret = GLEW_SUN_global_alpha; continue; } #endif #ifdef GL_SUN_mesh_array if (_glewStrSame3(&pos, &len, (const GLubyte*)"mesh_array", 10)) { ret = GLEW_SUN_mesh_array; continue; } #endif #ifdef GL_SUN_read_video_pixels if (_glewStrSame3(&pos, &len, (const GLubyte*)"read_video_pixels", 17)) { ret = GLEW_SUN_read_video_pixels; continue; } #endif #ifdef GL_SUN_slice_accum if (_glewStrSame3(&pos, &len, (const GLubyte*)"slice_accum", 11)) { ret = GLEW_SUN_slice_accum; continue; } #endif #ifdef GL_SUN_triangle_list if (_glewStrSame3(&pos, &len, (const GLubyte*)"triangle_list", 13)) { ret = GLEW_SUN_triangle_list; continue; } #endif #ifdef GL_SUN_vertex if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex", 6)) { ret = GLEW_SUN_vertex; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"WIN_", 4)) { #ifdef GL_WIN_phong_shading if (_glewStrSame3(&pos, &len, (const GLubyte*)"phong_shading", 13)) { ret = GLEW_WIN_phong_shading; continue; } #endif #ifdef GL_WIN_specular_fog if (_glewStrSame3(&pos, &len, (const GLubyte*)"specular_fog", 12)) { ret = GLEW_WIN_specular_fog; continue; } #endif #ifdef GL_WIN_swap_hint if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_hint", 9)) { ret = GLEW_WIN_swap_hint; continue; } #endif } } ret = (len == 0); } return ret; } #if defined(_WIN32) #if defined(GLEW_MX) GLboolean GLEWAPIENTRY wglewContextIsSupported (const WGLEWContext* ctx, const char* name) #else GLboolean GLEWAPIENTRY wglewIsSupported (const char* name) #endif { const GLubyte* pos = (const GLubyte*)name; GLuint len = _glewStrLen(pos); GLboolean ret = GL_TRUE; while (ret && len > 0) { if (_glewStrSame1(&pos, &len, (const GLubyte*)"WGL_", 4)) { if (_glewStrSame2(&pos, &len, (const GLubyte*)"3DFX_", 5)) { #ifdef WGL_3DFX_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) { ret = WGLEW_3DFX_multisample; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"3DL_", 4)) { #ifdef WGL_3DL_stereo_control if (_glewStrSame3(&pos, &len, (const GLubyte*)"stereo_control", 14)) { ret = WGLEW_3DL_stereo_control; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"AMD_", 4)) { #ifdef WGL_AMD_gpu_association if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_association", 15)) { ret = WGLEW_AMD_gpu_association; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"ARB_", 4)) { #ifdef WGL_ARB_buffer_region if (_glewStrSame3(&pos, &len, (const GLubyte*)"buffer_region", 13)) { ret = WGLEW_ARB_buffer_region; continue; } #endif #ifdef WGL_ARB_context_flush_control if (_glewStrSame3(&pos, &len, (const GLubyte*)"context_flush_control", 21)) { ret = WGLEW_ARB_context_flush_control; continue; } #endif #ifdef WGL_ARB_create_context if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context", 14)) { ret = WGLEW_ARB_create_context; continue; } #endif #ifdef WGL_ARB_create_context_profile if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context_profile", 22)) { ret = WGLEW_ARB_create_context_profile; continue; } #endif #ifdef WGL_ARB_create_context_robustness if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context_robustness", 25)) { ret = WGLEW_ARB_create_context_robustness; continue; } #endif #ifdef WGL_ARB_extensions_string if (_glewStrSame3(&pos, &len, (const GLubyte*)"extensions_string", 17)) { ret = WGLEW_ARB_extensions_string; continue; } #endif #ifdef WGL_ARB_framebuffer_sRGB if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) { ret = WGLEW_ARB_framebuffer_sRGB; continue; } #endif #ifdef WGL_ARB_make_current_read if (_glewStrSame3(&pos, &len, (const GLubyte*)"make_current_read", 17)) { ret = WGLEW_ARB_make_current_read; continue; } #endif #ifdef WGL_ARB_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) { ret = WGLEW_ARB_multisample; continue; } #endif #ifdef WGL_ARB_pbuffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"pbuffer", 7)) { ret = WGLEW_ARB_pbuffer; continue; } #endif #ifdef WGL_ARB_pixel_format if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format", 12)) { ret = WGLEW_ARB_pixel_format; continue; } #endif #ifdef WGL_ARB_pixel_format_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format_float", 18)) { ret = WGLEW_ARB_pixel_format_float; continue; } #endif #ifdef WGL_ARB_render_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_texture", 14)) { ret = WGLEW_ARB_render_texture; continue; } #endif #ifdef WGL_ARB_robustness_application_isolation if (_glewStrSame3(&pos, &len, (const GLubyte*)"robustness_application_isolation", 32)) { ret = WGLEW_ARB_robustness_application_isolation; continue; } #endif #ifdef WGL_ARB_robustness_share_group_isolation if (_glewStrSame3(&pos, &len, (const GLubyte*)"robustness_share_group_isolation", 32)) { ret = WGLEW_ARB_robustness_share_group_isolation; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"ATI_", 4)) { #ifdef WGL_ATI_pixel_format_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format_float", 18)) { ret = WGLEW_ATI_pixel_format_float; continue; } #endif #ifdef WGL_ATI_render_texture_rectangle if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_texture_rectangle", 24)) { ret = WGLEW_ATI_render_texture_rectangle; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"EXT_", 4)) { #ifdef WGL_EXT_create_context_es2_profile if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context_es2_profile", 26)) { ret = WGLEW_EXT_create_context_es2_profile; continue; } #endif #ifdef WGL_EXT_create_context_es_profile if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context_es_profile", 25)) { ret = WGLEW_EXT_create_context_es_profile; continue; } #endif #ifdef WGL_EXT_depth_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_float", 11)) { ret = WGLEW_EXT_depth_float; continue; } #endif #ifdef WGL_EXT_display_color_table if (_glewStrSame3(&pos, &len, (const GLubyte*)"display_color_table", 19)) { ret = WGLEW_EXT_display_color_table; continue; } #endif #ifdef WGL_EXT_extensions_string if (_glewStrSame3(&pos, &len, (const GLubyte*)"extensions_string", 17)) { ret = WGLEW_EXT_extensions_string; continue; } #endif #ifdef WGL_EXT_framebuffer_sRGB if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) { ret = WGLEW_EXT_framebuffer_sRGB; continue; } #endif #ifdef WGL_EXT_make_current_read if (_glewStrSame3(&pos, &len, (const GLubyte*)"make_current_read", 17)) { ret = WGLEW_EXT_make_current_read; continue; } #endif #ifdef WGL_EXT_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) { ret = WGLEW_EXT_multisample; continue; } #endif #ifdef WGL_EXT_pbuffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"pbuffer", 7)) { ret = WGLEW_EXT_pbuffer; continue; } #endif #ifdef WGL_EXT_pixel_format if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format", 12)) { ret = WGLEW_EXT_pixel_format; continue; } #endif #ifdef WGL_EXT_pixel_format_packed_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format_packed_float", 25)) { ret = WGLEW_EXT_pixel_format_packed_float; continue; } #endif #ifdef WGL_EXT_swap_control if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_control", 12)) { ret = WGLEW_EXT_swap_control; continue; } #endif #ifdef WGL_EXT_swap_control_tear if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_control_tear", 17)) { ret = WGLEW_EXT_swap_control_tear; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"I3D_", 4)) { #ifdef WGL_I3D_digital_video_control if (_glewStrSame3(&pos, &len, (const GLubyte*)"digital_video_control", 21)) { ret = WGLEW_I3D_digital_video_control; continue; } #endif #ifdef WGL_I3D_gamma if (_glewStrSame3(&pos, &len, (const GLubyte*)"gamma", 5)) { ret = WGLEW_I3D_gamma; continue; } #endif #ifdef WGL_I3D_genlock if (_glewStrSame3(&pos, &len, (const GLubyte*)"genlock", 7)) { ret = WGLEW_I3D_genlock; continue; } #endif #ifdef WGL_I3D_image_buffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"image_buffer", 12)) { ret = WGLEW_I3D_image_buffer; continue; } #endif #ifdef WGL_I3D_swap_frame_lock if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_frame_lock", 15)) { ret = WGLEW_I3D_swap_frame_lock; continue; } #endif #ifdef WGL_I3D_swap_frame_usage if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_frame_usage", 16)) { ret = WGLEW_I3D_swap_frame_usage; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"NV_", 3)) { #ifdef WGL_NV_DX_interop if (_glewStrSame3(&pos, &len, (const GLubyte*)"DX_interop", 10)) { ret = WGLEW_NV_DX_interop; continue; } #endif #ifdef WGL_NV_DX_interop2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"DX_interop2", 11)) { ret = WGLEW_NV_DX_interop2; continue; } #endif #ifdef WGL_NV_copy_image if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_image", 10)) { ret = WGLEW_NV_copy_image; continue; } #endif #ifdef WGL_NV_delay_before_swap if (_glewStrSame3(&pos, &len, (const GLubyte*)"delay_before_swap", 17)) { ret = WGLEW_NV_delay_before_swap; continue; } #endif #ifdef WGL_NV_float_buffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"float_buffer", 12)) { ret = WGLEW_NV_float_buffer; continue; } #endif #ifdef WGL_NV_gpu_affinity if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_affinity", 12)) { ret = WGLEW_NV_gpu_affinity; continue; } #endif #ifdef WGL_NV_multisample_coverage if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample_coverage", 20)) { ret = WGLEW_NV_multisample_coverage; continue; } #endif #ifdef WGL_NV_present_video if (_glewStrSame3(&pos, &len, (const GLubyte*)"present_video", 13)) { ret = WGLEW_NV_present_video; continue; } #endif #ifdef WGL_NV_render_depth_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_depth_texture", 20)) { ret = WGLEW_NV_render_depth_texture; continue; } #endif #ifdef WGL_NV_render_texture_rectangle if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_texture_rectangle", 24)) { ret = WGLEW_NV_render_texture_rectangle; continue; } #endif #ifdef WGL_NV_swap_group if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_group", 10)) { ret = WGLEW_NV_swap_group; continue; } #endif #ifdef WGL_NV_vertex_array_range if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range", 18)) { ret = WGLEW_NV_vertex_array_range; continue; } #endif #ifdef WGL_NV_video_capture if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_capture", 13)) { ret = WGLEW_NV_video_capture; continue; } #endif #ifdef WGL_NV_video_output if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_output", 12)) { ret = WGLEW_NV_video_output; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"OML_", 4)) { #ifdef WGL_OML_sync_control if (_glewStrSame3(&pos, &len, (const GLubyte*)"sync_control", 12)) { ret = WGLEW_OML_sync_control; continue; } #endif } } ret = (len == 0); } return ret; } #elif !defined(__ANDROID__) && !defined(__native_client__) && !defined(__HAIKU__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX) #if defined(GLEW_MX) GLboolean glxewContextIsSupported (const GLXEWContext* ctx, const char* name) #else GLboolean glxewIsSupported (const char* name) #endif { const GLubyte* pos = (const GLubyte*)name; GLuint len = _glewStrLen(pos); GLboolean ret = GL_TRUE; while (ret && len > 0) { if(_glewStrSame1(&pos, &len, (const GLubyte*)"GLX_", 4)) { if (_glewStrSame2(&pos, &len, (const GLubyte*)"VERSION_", 8)) { #ifdef GLX_VERSION_1_2 if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_2", 3)) { ret = GLXEW_VERSION_1_2; continue; } #endif #ifdef GLX_VERSION_1_3 if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_3", 3)) { ret = GLXEW_VERSION_1_3; continue; } #endif #ifdef GLX_VERSION_1_4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_4", 3)) { ret = GLXEW_VERSION_1_4; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"3DFX_", 5)) { #ifdef GLX_3DFX_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) { ret = GLXEW_3DFX_multisample; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"AMD_", 4)) { #ifdef GLX_AMD_gpu_association if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_association", 15)) { ret = GLXEW_AMD_gpu_association; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"ARB_", 4)) { #ifdef GLX_ARB_context_flush_control if (_glewStrSame3(&pos, &len, (const GLubyte*)"context_flush_control", 21)) { ret = GLXEW_ARB_context_flush_control; continue; } #endif #ifdef GLX_ARB_create_context if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context", 14)) { ret = GLXEW_ARB_create_context; continue; } #endif #ifdef GLX_ARB_create_context_profile if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context_profile", 22)) { ret = GLXEW_ARB_create_context_profile; continue; } #endif #ifdef GLX_ARB_create_context_robustness if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context_robustness", 25)) { ret = GLXEW_ARB_create_context_robustness; continue; } #endif #ifdef GLX_ARB_fbconfig_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"fbconfig_float", 14)) { ret = GLXEW_ARB_fbconfig_float; continue; } #endif #ifdef GLX_ARB_framebuffer_sRGB if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) { ret = GLXEW_ARB_framebuffer_sRGB; continue; } #endif #ifdef GLX_ARB_get_proc_address if (_glewStrSame3(&pos, &len, (const GLubyte*)"get_proc_address", 16)) { ret = GLXEW_ARB_get_proc_address; continue; } #endif #ifdef GLX_ARB_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) { ret = GLXEW_ARB_multisample; continue; } #endif #ifdef GLX_ARB_robustness_application_isolation if (_glewStrSame3(&pos, &len, (const GLubyte*)"robustness_application_isolation", 32)) { ret = GLXEW_ARB_robustness_application_isolation; continue; } #endif #ifdef GLX_ARB_robustness_share_group_isolation if (_glewStrSame3(&pos, &len, (const GLubyte*)"robustness_share_group_isolation", 32)) { ret = GLXEW_ARB_robustness_share_group_isolation; continue; } #endif #ifdef GLX_ARB_vertex_buffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_buffer_object", 20)) { ret = GLXEW_ARB_vertex_buffer_object; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"ATI_", 4)) { #ifdef GLX_ATI_pixel_format_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format_float", 18)) { ret = GLXEW_ATI_pixel_format_float; continue; } #endif #ifdef GLX_ATI_render_texture if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_texture", 14)) { ret = GLXEW_ATI_render_texture; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"EXT_", 4)) { #ifdef GLX_EXT_buffer_age if (_glewStrSame3(&pos, &len, (const GLubyte*)"buffer_age", 10)) { ret = GLXEW_EXT_buffer_age; continue; } #endif #ifdef GLX_EXT_create_context_es2_profile if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context_es2_profile", 26)) { ret = GLXEW_EXT_create_context_es2_profile; continue; } #endif #ifdef GLX_EXT_create_context_es_profile if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context_es_profile", 25)) { ret = GLXEW_EXT_create_context_es_profile; continue; } #endif #ifdef GLX_EXT_fbconfig_packed_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"fbconfig_packed_float", 21)) { ret = GLXEW_EXT_fbconfig_packed_float; continue; } #endif #ifdef GLX_EXT_framebuffer_sRGB if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) { ret = GLXEW_EXT_framebuffer_sRGB; continue; } #endif #ifdef GLX_EXT_import_context if (_glewStrSame3(&pos, &len, (const GLubyte*)"import_context", 14)) { ret = GLXEW_EXT_import_context; continue; } #endif #ifdef GLX_EXT_scene_marker if (_glewStrSame3(&pos, &len, (const GLubyte*)"scene_marker", 12)) { ret = GLXEW_EXT_scene_marker; continue; } #endif #ifdef GLX_EXT_stereo_tree if (_glewStrSame3(&pos, &len, (const GLubyte*)"stereo_tree", 11)) { ret = GLXEW_EXT_stereo_tree; continue; } #endif #ifdef GLX_EXT_swap_control if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_control", 12)) { ret = GLXEW_EXT_swap_control; continue; } #endif #ifdef GLX_EXT_swap_control_tear if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_control_tear", 17)) { ret = GLXEW_EXT_swap_control_tear; continue; } #endif #ifdef GLX_EXT_texture_from_pixmap if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_from_pixmap", 19)) { ret = GLXEW_EXT_texture_from_pixmap; continue; } #endif #ifdef GLX_EXT_visual_info if (_glewStrSame3(&pos, &len, (const GLubyte*)"visual_info", 11)) { ret = GLXEW_EXT_visual_info; continue; } #endif #ifdef GLX_EXT_visual_rating if (_glewStrSame3(&pos, &len, (const GLubyte*)"visual_rating", 13)) { ret = GLXEW_EXT_visual_rating; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"INTEL_", 6)) { #ifdef GLX_INTEL_swap_event if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_event", 10)) { ret = GLXEW_INTEL_swap_event; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"MESA_", 5)) { #ifdef GLX_MESA_agp_offset if (_glewStrSame3(&pos, &len, (const GLubyte*)"agp_offset", 10)) { ret = GLXEW_MESA_agp_offset; continue; } #endif #ifdef GLX_MESA_copy_sub_buffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_sub_buffer", 15)) { ret = GLXEW_MESA_copy_sub_buffer; continue; } #endif #ifdef GLX_MESA_pixmap_colormap if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixmap_colormap", 15)) { ret = GLXEW_MESA_pixmap_colormap; continue; } #endif #ifdef GLX_MESA_query_renderer if (_glewStrSame3(&pos, &len, (const GLubyte*)"query_renderer", 14)) { ret = GLXEW_MESA_query_renderer; continue; } #endif #ifdef GLX_MESA_release_buffers if (_glewStrSame3(&pos, &len, (const GLubyte*)"release_buffers", 15)) { ret = GLXEW_MESA_release_buffers; continue; } #endif #ifdef GLX_MESA_set_3dfx_mode if (_glewStrSame3(&pos, &len, (const GLubyte*)"set_3dfx_mode", 13)) { ret = GLXEW_MESA_set_3dfx_mode; continue; } #endif #ifdef GLX_MESA_swap_control if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_control", 12)) { ret = GLXEW_MESA_swap_control; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"NV_", 3)) { #ifdef GLX_NV_copy_buffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_buffer", 11)) { ret = GLXEW_NV_copy_buffer; continue; } #endif #ifdef GLX_NV_copy_image if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_image", 10)) { ret = GLXEW_NV_copy_image; continue; } #endif #ifdef GLX_NV_delay_before_swap if (_glewStrSame3(&pos, &len, (const GLubyte*)"delay_before_swap", 17)) { ret = GLXEW_NV_delay_before_swap; continue; } #endif #ifdef GLX_NV_float_buffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"float_buffer", 12)) { ret = GLXEW_NV_float_buffer; continue; } #endif #ifdef GLX_NV_multisample_coverage if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample_coverage", 20)) { ret = GLXEW_NV_multisample_coverage; continue; } #endif #ifdef GLX_NV_present_video if (_glewStrSame3(&pos, &len, (const GLubyte*)"present_video", 13)) { ret = GLXEW_NV_present_video; continue; } #endif #ifdef GLX_NV_swap_group if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_group", 10)) { ret = GLXEW_NV_swap_group; continue; } #endif #ifdef GLX_NV_vertex_array_range if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range", 18)) { ret = GLXEW_NV_vertex_array_range; continue; } #endif #ifdef GLX_NV_video_capture if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_capture", 13)) { ret = GLXEW_NV_video_capture; continue; } #endif #ifdef GLX_NV_video_out if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_out", 9)) { ret = GLXEW_NV_video_out; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"OML_", 4)) { #ifdef GLX_OML_swap_method if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_method", 11)) { ret = GLXEW_OML_swap_method; continue; } #endif #ifdef GLX_OML_sync_control if (_glewStrSame3(&pos, &len, (const GLubyte*)"sync_control", 12)) { ret = GLXEW_OML_sync_control; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGIS_", 5)) { #ifdef GLX_SGIS_blended_overlay if (_glewStrSame3(&pos, &len, (const GLubyte*)"blended_overlay", 15)) { ret = GLXEW_SGIS_blended_overlay; continue; } #endif #ifdef GLX_SGIS_color_range if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_range", 11)) { ret = GLXEW_SGIS_color_range; continue; } #endif #ifdef GLX_SGIS_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) { ret = GLXEW_SGIS_multisample; continue; } #endif #ifdef GLX_SGIS_shared_multisample if (_glewStrSame3(&pos, &len, (const GLubyte*)"shared_multisample", 18)) { ret = GLXEW_SGIS_shared_multisample; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGIX_", 5)) { #ifdef GLX_SGIX_fbconfig if (_glewStrSame3(&pos, &len, (const GLubyte*)"fbconfig", 8)) { ret = GLXEW_SGIX_fbconfig; continue; } #endif #ifdef GLX_SGIX_hyperpipe if (_glewStrSame3(&pos, &len, (const GLubyte*)"hyperpipe", 9)) { ret = GLXEW_SGIX_hyperpipe; continue; } #endif #ifdef GLX_SGIX_pbuffer if (_glewStrSame3(&pos, &len, (const GLubyte*)"pbuffer", 7)) { ret = GLXEW_SGIX_pbuffer; continue; } #endif #ifdef GLX_SGIX_swap_barrier if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_barrier", 12)) { ret = GLXEW_SGIX_swap_barrier; continue; } #endif #ifdef GLX_SGIX_swap_group if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_group", 10)) { ret = GLXEW_SGIX_swap_group; continue; } #endif #ifdef GLX_SGIX_video_resize if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_resize", 12)) { ret = GLXEW_SGIX_video_resize; continue; } #endif #ifdef GLX_SGIX_visual_select_group if (_glewStrSame3(&pos, &len, (const GLubyte*)"visual_select_group", 19)) { ret = GLXEW_SGIX_visual_select_group; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGI_", 4)) { #ifdef GLX_SGI_cushion if (_glewStrSame3(&pos, &len, (const GLubyte*)"cushion", 7)) { ret = GLXEW_SGI_cushion; continue; } #endif #ifdef GLX_SGI_make_current_read if (_glewStrSame3(&pos, &len, (const GLubyte*)"make_current_read", 17)) { ret = GLXEW_SGI_make_current_read; continue; } #endif #ifdef GLX_SGI_swap_control if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_control", 12)) { ret = GLXEW_SGI_swap_control; continue; } #endif #ifdef GLX_SGI_video_sync if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_sync", 10)) { ret = GLXEW_SGI_video_sync; continue; } #endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"SUN_", 4)) { #ifdef GLX_SUN_get_transparent_index if (_glewStrSame3(&pos, &len, (const GLubyte*)"get_transparent_index", 21)) { ret = GLXEW_SUN_get_transparent_index; continue; } #endif #ifdef GLX_SUN_video_resize if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_resize", 12)) { ret = GLXEW_SUN_video_resize; continue; } #endif } } ret = (len == 0); } return ret; } #endif /* _WIN32 */ goxel-0.11.0/ext_src/imgui/000077500000000000000000000000001435762723100155025ustar00rootroot00000000000000goxel-0.11.0/ext_src/imgui/imconfig.h000066400000000000000000000171711435762723100174550ustar00rootroot00000000000000//----------------------------------------------------------------------------- // COMPILE-TIME OPTIONS FOR DEAR IMGUI // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. //----------------------------------------------------------------------------- // A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/branch with your modifications to imconfig.h) // B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h" // If you do so you need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include // the imgui*.cpp files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures. // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. // Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using. //----------------------------------------------------------------------------- #pragma once //---- Define assertion handler. Defaults to calling assert(). // If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement. //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows // Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. //#define IMGUI_API __declspec( dllexport ) //#define IMGUI_API __declspec( dllimport ) //---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names. //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS //---- Disable all of Dear ImGui or don't implement standard windows. // It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp. //#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty. //#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended. //#define IMGUI_DISABLE_METRICS_WINDOW // Disable debug/metrics window: ShowMetricsWindow() will be empty. //---- Don't implement some functions to reduce linkage requirements. //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. //#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime). //#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default). //#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf) //#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself. //#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function. //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). //---- Include imgui_user.h at the end of imgui.h as a convenience //#define IMGUI_INCLUDE_IMGUI_USER_H //---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another) //#define IMGUI_USE_BGRA_PACKED_COLOR //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version // By default the embedded implementations are declared static and not available outside of imgui cpp files. //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION //---- Unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined, use the much faster STB sprintf library implementation of vsnprintf instead of the one from the default C library. // Note that stb_sprintf.h is meant to be provided by the user and available in the include path at compile time. Also, the compatibility checks of the arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf. // #define IMGUI_USE_STB_SPRINTF //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. // This will be inlined as part of ImVec2 and ImVec4 class declarations. /* #define IM_VEC2_CLASS_EXTRA \ ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ operator MyVec2() const { return MyVec2(x,y); } #define IM_VEC4_CLASS_EXTRA \ ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ operator MyVec4() const { return MyVec4(x,y,z,w); } */ //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. // Your renderer back-end will need to support it (most example renderer back-ends support both 16/32-bit indices). // Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. // Read about ImGuiBackendFlags_RendererHasVtxOffset for details. //#define ImDrawIdx unsigned int //---- Override ImDrawCallback signature (will need to modify renderer back-ends accordingly) //struct ImDrawList; //struct ImDrawCmd; //typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data); //#define ImDrawCallback MyImDrawCallback //---- Debug Tools: Macro to break in Debugger // (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.) //#define IM_DEBUG_BREAK IM_ASSERT(0) //#define IM_DEBUG_BREAK __debugbreak() //---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(), // (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.) // This adds a small runtime cost which is why it is not enabled by default. //#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX //---- Debug Tools: Enable slower asserts //#define IMGUI_DEBUG_PARANOID //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. /* namespace ImGui { void MyFunction(const char* name, const MyMatrix44& v); } */ goxel-0.11.0/ext_src/imgui/imgui.cpp000066400000000000000000017220531435762723100173320ustar00rootroot00000000000000// dear imgui, v1.75 // (main code and documentation) // Help: // - Read FAQ at http://dearimgui.org/faq // - Newcomers, read 'Programmer guide' below for notes on how to setup Dear ImGui in your codebase. // - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code. All applications in examples/ are doing that. // Resources: // - FAQ http://dearimgui.org/faq // - Homepage & latest https://github.com/ocornut/imgui // - Releases & changelog https://github.com/ocornut/imgui/releases // - Gallery https://github.com/ocornut/imgui/issues/2847 (please post your screenshots/video there!) // - Glossary https://github.com/ocornut/imgui/wiki/Glossary // - Wiki https://github.com/ocornut/imgui/wiki // - Issues & support https://github.com/ocornut/imgui/issues // Developed by Omar Cornut and every direct or indirect contributors to the GitHub. // See LICENSE.txt for copyright and licensing details (standard MIT License). // This library is free but I need your support to sustain development and maintenance. // Businesses: you can support continued development via invoiced technical support, maintenance and sponsoring contracts. Please reach out to "contact AT dearimgui.org". // Individuals: you can support continued development via donations. See docs/README or web page. // It is recommended that you don't modify imgui.cpp! It will become difficult for you to update the library. // Note that 'ImGui::' being a namespace, you can add functions into the namespace from your own source files, without // modifying imgui.h or imgui.cpp. You may include imgui_internal.h to access internal data structures, but it doesn't // come with any guarantee of forward compatibility. Discussing your changes on the GitHub Issue Tracker may lead you // to a better solution or official support for them. /* Index of this file: DOCUMENTATION - MISSION STATEMENT - END-USER GUIDE - PROGRAMMER GUIDE - READ FIRST - HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI - GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE - HOW A SIMPLE APPLICATION MAY LOOK LIKE (2 variations) - HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE - USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS - API BREAKING CHANGES (read me when you update!) - FREQUENTLY ASKED QUESTIONS (FAQ) - Read all answers online: https://www.dearimgui.org/faq, or in docs/FAQ.md (with a Markdown viewer) CODE (search for "[SECTION]" in the code to find them) // [SECTION] FORWARD DECLARATIONS // [SECTION] CONTEXT AND MEMORY ALLOCATORS // [SECTION] MAIN USER FACING STRUCTURES (ImGuiStyle, ImGuiIO) // [SECTION] MISC HELPERS/UTILITIES (Geometry functions) // [SECTION] MISC HELPERS/UTILITIES (String, Format, Hash functions) // [SECTION] MISC HELPERS/UTILITIES (File functions) // [SECTION] MISC HELPERS/UTILITIES (ImText* functions) // [SECTION] MISC HELPERS/UTILITIES (Color functions) // [SECTION] ImGuiStorage // [SECTION] ImGuiTextFilter // [SECTION] ImGuiTextBuffer // [SECTION] ImGuiListClipper // [SECTION] RENDER HELPERS // [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!) // [SECTION] ERROR CHECKING // [SECTION] SCROLLING // [SECTION] TOOLTIPS // [SECTION] POPUPS // [SECTION] KEYBOARD/GAMEPAD NAVIGATION // [SECTION] DRAG AND DROP // [SECTION] LOGGING/CAPTURING // [SECTION] SETTINGS // [SECTION] PLATFORM DEPENDENT HELPERS // [SECTION] METRICS/DEBUG WINDOW */ //----------------------------------------------------------------------------- // DOCUMENTATION //----------------------------------------------------------------------------- /* MISSION STATEMENT ================= - Easy to use to create code-driven and data-driven tools. - Easy to use to create ad hoc short-lived tools and long-lived, more elaborate tools. - Easy to hack and improve. - Minimize screen real-estate usage. - Minimize setup and maintenance. - Minimize state storage on user side. - Portable, minimize dependencies, run on target (consoles, phones, etc.). - Efficient runtime and memory consumption (NB- we do allocate when "growing" content e.g. creating a window,. opening a tree node for the first time, etc. but a typical frame should not allocate anything). Designed for developers and content-creators, not the typical end-user! Some of the weaknesses includes: - Doesn't look fancy, doesn't animate. - Limited layout features, intricate layouts are typically crafted in code. END-USER GUIDE ============== - Double-click on title bar to collapse window. - Click upper right corner to close a window, available when 'bool* p_open' is passed to ImGui::Begin(). - Click and drag on lower right corner to resize window (double-click to auto fit window to its contents). - Click and drag on any empty space to move window. - TAB/SHIFT+TAB to cycle through keyboard editable fields. - CTRL+Click on a slider or drag box to input value as text. - Use mouse wheel to scroll. - Text editor: - Hold SHIFT or use mouse to select text. - CTRL+Left/Right to word jump. - CTRL+Shift+Left/Right to select words. - CTRL+A our Double-Click to select all. - CTRL+X,CTRL+C,CTRL+V to use OS clipboard/ - CTRL+Z,CTRL+Y to undo/redo. - ESCAPE to revert text to its original value. - You can apply arithmetic operators +,*,/ on numerical values. Use +- to subtract (because - would set a negative value!) - Controls are automatically adjusted for OSX to match standard OSX text editing operations. - General Keyboard controls: enable with ImGuiConfigFlags_NavEnableKeyboard. - General Gamepad controls: enable with ImGuiConfigFlags_NavEnableGamepad. See suggested mappings in imgui.h ImGuiNavInput_ + download PNG/PSD at http://goo.gl/9LgVZW PROGRAMMER GUIDE ================ READ FIRST ---------- - Remember to read the FAQ (https://www.dearimgui.org/faq) - Your code creates the UI, if your code doesn't run the UI is gone! The UI can be highly dynamic, there are no construction or destruction steps, less superfluous data retention on your side, less state duplication, less state synchronization, less bugs. - Call and read ImGui::ShowDemoWindow() for demo code demonstrating most features. - The library is designed to be built from sources. Avoid pre-compiled binaries and packaged versions. See imconfig.h to configure your build. - Dear ImGui is an implementation of the IMGUI paradigm (immediate-mode graphical user interface, a term coined by Casey Muratori). You can learn about IMGUI principles at http://www.johno.se/book/imgui.html, http://mollyrocket.com/861 & more links docs/README.md. - Dear ImGui is a "single pass" rasterizing implementation of the IMGUI paradigm, aimed at ease of use and high-performances. For every application frame your UI code will be called only once. This is in contrast to e.g. Unity's own implementation of an IMGUI, where the UI code is called multiple times ("multiple passes") from a single entry point. There are pros and cons to both approaches. - Our origin are on the top-left. In axis aligned bounding boxes, Min = top-left, Max = bottom-right. - This codebase is also optimized to yield decent performances with typical "Debug" builds settings. - Please make sure you have asserts enabled (IM_ASSERT redirects to assert() by default, but can be redirected). If you get an assert, read the messages and comments around the assert. - C++: this is a very C-ish codebase: we don't rely on C++11, we don't include any C++ headers, and ImGui:: is a namespace. - C++: ImVec2/ImVec4 do not expose math operators by default, because it is expected that you use your own math types. See FAQ "How can I use my own math types instead of ImVec2/ImVec4?" for details about setting up imconfig.h for that. However, imgui_internal.h can optionally export math operators for ImVec2/ImVec4, which we use in this codebase. - C++: pay attention that ImVector<> manipulates plain-old-data and does not honor construction/destruction (avoid using it in your code!). HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI ---------------------------------------------- - Overwrite all the sources files except for imconfig.h (if you have made modification to your copy of imconfig.h) - Or maintain your own branch where you have imconfig.h modified. - Read the "API BREAKING CHANGES" section (below). This is where we list occasional API breaking changes. If a function/type has been renamed / or marked obsolete, try to fix the name in your code before it is permanently removed from the public API. If you have a problem with a missing function/symbols, search for its name in the code, there will likely be a comment about it. Please report any issue to the GitHub page! - Try to keep your copy of dear imgui reasonably up to date. GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE --------------------------------------------------------------- - Run and study the examples and demo in imgui_demo.cpp to get acquainted with the library. - In the majority of cases you should be able to use unmodified back-ends files available in the examples/ folder. - Add the Dear ImGui source files to your projects or using your preferred build system. It is recommended you build and statically link the .cpp files as part of your project and NOT as shared library (DLL). - You can later customize the imconfig.h file to tweak some compile-time behavior, such as integrating Dear ImGui types with your own maths types. - When using Dear ImGui, your programming IDE is your friend: follow the declaration of variables, functions and types to find comments about them. - Dear ImGui never touches or knows about your GPU state. The only function that knows about GPU is the draw function that you provide. Effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" phases of your own application. All rendering information are stored into command-lists that you will retrieve after calling ImGui::Render(). - Refer to the bindings and demo applications in the examples/ folder for instruction on how to setup your code. - If you are running over a standard OS with a common graphics API, you should be able to use unmodified imgui_impl_*** files from the examples/ folder. HOW A SIMPLE APPLICATION MAY LOOK LIKE -------------------------------------- EXHIBIT 1: USING THE EXAMPLE BINDINGS (imgui_impl_XXX.cpp files from the examples/ folder). // Application init: create a dear imgui context, setup some options, load fonts ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); // TODO: Set optional io.ConfigFlags values, e.g. 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard' to enable keyboard controls. // TODO: Fill optional fields of the io structure later. // TODO: Load TTF/OTF fonts if you don't want to use the default font. // Initialize helper Platform and Renderer bindings (here we are using imgui_impl_win32.cpp and imgui_impl_dx11.cpp) ImGui_ImplWin32_Init(hwnd); ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); // Application main loop while (true) { // Feed inputs to dear imgui, start new frame ImGui_ImplDX11_NewFrame(); ImGui_ImplWin32_NewFrame(); ImGui::NewFrame(); // Any application code here ImGui::Text("Hello, world!"); // Render dear imgui into screen ImGui::Render(); ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); g_pSwapChain->Present(1, 0); } // Shutdown ImGui_ImplDX11_Shutdown(); ImGui_ImplWin32_Shutdown(); ImGui::DestroyContext(); EXHIBIT 2: IMPLEMENTING CUSTOM BINDING / CUSTOM ENGINE // Application init: create a dear imgui context, setup some options, load fonts ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); // TODO: Set optional io.ConfigFlags values, e.g. 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard' to enable keyboard controls. // TODO: Fill optional fields of the io structure later. // TODO: Load TTF/OTF fonts if you don't want to use the default font. // Build and load the texture atlas into a texture // (In the examples/ app this is usually done within the ImGui_ImplXXX_Init() function from one of the demo Renderer) int width, height; unsigned char* pixels = NULL; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // At this point you've got the texture data and you need to upload that your your graphic system: // After we have created the texture, store its pointer/identifier (_in whichever format your engine uses_) in 'io.Fonts->TexID'. // This will be passed back to your via the renderer. Basically ImTextureID == void*. Read FAQ for details about ImTextureID. MyTexture* texture = MyEngine::CreateTextureFromMemoryPixels(pixels, width, height, TEXTURE_TYPE_RGBA32) io.Fonts->TexID = (void*)texture; // Application main loop while (true) { // Setup low-level inputs, e.g. on Win32: calling GetKeyboardState(), or write to those fields from your Windows message handlers, etc. // (In the examples/ app this is usually done within the ImGui_ImplXXX_NewFrame() function from one of the demo Platform bindings) io.DeltaTime = 1.0f/60.0f; // set the time elapsed since the previous frame (in seconds) io.DisplaySize.x = 1920.0f; // set the current display width io.DisplaySize.y = 1280.0f; // set the current display height here io.MousePos = my_mouse_pos; // set the mouse position io.MouseDown[0] = my_mouse_buttons[0]; // set the mouse button states io.MouseDown[1] = my_mouse_buttons[1]; // Call NewFrame(), after this point you can use ImGui::* functions anytime // (So you want to try calling NewFrame() as early as you can in your mainloop to be able to use Dear ImGui everywhere) ImGui::NewFrame(); // Most of your application code here ImGui::Text("Hello, world!"); MyGameUpdate(); // may use any Dear ImGui functions, e.g. ImGui::Begin("My window"); ImGui::Text("Hello, world!"); ImGui::End(); MyGameRender(); // may use any Dear ImGui functions as well! // Render dear imgui, swap buffers // (You want to try calling EndFrame/Render as late as you can, to be able to use Dear ImGui in your own game rendering code) ImGui::EndFrame(); ImGui::Render(); ImDrawData* draw_data = ImGui::GetDrawData(); MyImGuiRenderFunction(draw_data); SwapBuffers(); } // Shutdown ImGui::DestroyContext(); HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE --------------------------------------------- void void MyImGuiRenderFunction(ImDrawData* draw_data) { // TODO: Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled // TODO: Setup viewport covering draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize // TODO: Setup orthographic projection matrix cover draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize // TODO: Setup shader: vertex { float2 pos, float2 uv, u32 color }, fragment shader sample color from 1 texture, multiply by vertex color. for (int n = 0; n < draw_data->CmdListsCount; n++) { const ImDrawList* cmd_list = draw_data->CmdLists[n]; const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; // vertex buffer generated by Dear ImGui const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; // index buffer generated by Dear ImGui for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) { const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; if (pcmd->UserCallback) { pcmd->UserCallback(cmd_list, pcmd); } else { // The texture for the draw call is specified by pcmd->TextureId. // The vast majority of draw calls will use the Dear ImGui texture atlas, which value you have set yourself during initialization. MyEngineBindTexture((MyTexture*)pcmd->TextureId); // We are using scissoring to clip some objects. All low-level graphics API should supports it. // - If your engine doesn't support scissoring yet, you may ignore this at first. You will get some small glitches // (some elements visible outside their bounds) but you can fix that once everything else works! // - Clipping coordinates are provided in imgui coordinates space (from draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize) // In a single viewport application, draw_data->DisplayPos will always be (0,0) and draw_data->DisplaySize will always be == io.DisplaySize. // However, in the interest of supporting multi-viewport applications in the future (see 'viewport' branch on github), // always subtract draw_data->DisplayPos from clipping bounds to convert them to your viewport space. // - Note that pcmd->ClipRect contains Min+Max bounds. Some graphics API may use Min+Max, other may use Min+Size (size being Max-Min) ImVec2 pos = draw_data->DisplayPos; MyEngineScissor((int)(pcmd->ClipRect.x - pos.x), (int)(pcmd->ClipRect.y - pos.y), (int)(pcmd->ClipRect.z - pos.x), (int)(pcmd->ClipRect.w - pos.y)); // Render 'pcmd->ElemCount/3' indexed triangles. // By default the indices ImDrawIdx are 16-bit, you can change them to 32-bit in imconfig.h if your engine doesn't support 16-bit indices. MyEngineDrawIndexedTriangles(pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer, vtx_buffer); } idx_buffer += pcmd->ElemCount; } } } - The examples/ folders contains many actual implementation of the pseudo-codes above. - When calling NewFrame(), the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags are updated. They tell you if Dear ImGui intends to use your inputs. When a flag is set you want to hide the corresponding inputs from the rest of your application. In every cases you need to pass on the inputs to Dear ImGui. - Refer to the FAQ for more information. Amusingly, it is called a FAQ because people frequently run into the same issues! USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS ------------------------------------------ - The gamepad/keyboard navigation is fairly functional and keeps being improved. - Gamepad support is particularly useful to use Dear ImGui on a console system (e.g. PS4, Switch, XB1) without a mouse! - You can ask questions and report issues at https://github.com/ocornut/imgui/issues/787 - The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable. - Keyboard: - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays. - When keyboard navigation is active (io.NavActive + ImGuiConfigFlags_NavEnableKeyboard), the io.WantCaptureKeyboard flag will be set. For more advanced uses, you may want to read from: - io.NavActive: true when a window is focused and it doesn't have the ImGuiWindowFlags_NoNavInputs flag set. - io.NavVisible: true when the navigation cursor is visible (and usually goes false when mouse is used). - or query focus information with e.g. IsWindowFocused(ImGuiFocusedFlags_AnyWindow), IsItemFocused() etc. functions. Please reach out if you think the game vs navigation input sharing could be improved. - Gamepad: - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. - Backend: Set io.BackendFlags |= ImGuiBackendFlags_HasGamepad + fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame(). - See 'enum ImGuiNavInput_' in imgui.h for a description of inputs. For each entry of io.NavInputs[], set the following values: 0.0f= not held. 1.0f= fully held. Pass intermediate 0.0f..1.0f values for analog triggers/sticks. - We uses a simple >0.0f test for activation testing, and won't attempt to test for a dead-zone. Your code will probably need to transform your raw inputs (such as e.g. remapping your 0.2..0.9 raw input range to 0.0..1.0 imgui range, etc.). - You can download PNG/PSD files depicting the gamepad controls for common controllers at: http://goo.gl/9LgVZW. - If you need to share inputs between your game and the imgui parts, the easiest approach is to go all-or-nothing, with a buttons combo to toggle the target. Please reach out if you think the game vs navigation input sharing could be improved. - Mouse: - PS4 users: Consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse-emulation fallback. - Consoles/Tablet/Phone users: Consider using a Synergy 1.x server (on your PC) + uSynergy.c (on your console/tablet/phone app) to share your PC mouse/keyboard. - On a TV/console system where readability may be lower or mouse inputs may be awkward, you may want to set the ImGuiConfigFlags_NavEnableSetMousePos flag. Enabling ImGuiConfigFlags_NavEnableSetMousePos + ImGuiBackendFlags_HasSetMousePos instructs dear imgui to move your mouse cursor along with navigation movements. When enabled, the NewFrame() function may alter 'io.MousePos' and set 'io.WantSetMousePos' to notify you that it wants the mouse cursor to be moved. When that happens your back-end NEEDS to move the OS or underlying mouse cursor on the next frame. Some of the binding in examples/ do that. (If you set the NavEnableSetMousePos flag but don't honor 'io.WantSetMousePos' properly, imgui will misbehave as it will see your mouse as moving back and forth!) (In a setup when you may not have easy control over the mouse cursor, e.g. uSynergy.c doesn't expose moving remote mouse cursor, you may want to set a boolean to ignore your other external mouse positions until the external source is moved again.) API BREAKING CHANGES ==================== Occasionally introducing changes that are breaking the API. We try to make the breakage minor and easy to fix. Below is a change-log of API breaking changes only. If you are using one of the functions listed, expect to have to fix some code. When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files. You can read releases logs https://github.com/ocornut/imgui/releases for more details. - 2020/01/22 (1.75) - ImDrawList::AddCircle()/AddCircleFilled() functions don't accept negative radius any more. - 2019/12/17 (1.75) - made Columns() limited to 64 columns by asserting above that limit. While the current code technically supports it, future code may not so we're putting the restriction ahead. - 2019/12/13 (1.75) - [imgui_internal.h] changed ImRect() default constructor initializes all fields to 0.0f instead of (FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX). If you used ImRect::Add() to create bounding boxes by adding multiple points into it, you may need to fix your initial value. - 2019/12/08 (1.75) - removed redirecting functions/enums that were marked obsolete in 1.53 (December 2017): - ShowTestWindow() -> use ShowDemoWindow() - IsRootWindowFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootWindow) - IsRootWindowOrAnyChildFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) - SetNextWindowContentWidth(w) -> use SetNextWindowContentSize(ImVec2(w, 0.0f) - GetItemsLineHeightWithSpacing() -> use GetFrameHeightWithSpacing() - ImGuiCol_ChildWindowBg -> use ImGuiCol_ChildBg - ImGuiStyleVar_ChildWindowRounding -> use ImGuiStyleVar_ChildRounding - ImGuiTreeNodeFlags_AllowOverlapMode -> use ImGuiTreeNodeFlags_AllowItemOverlap - IMGUI_DISABLE_TEST_WINDOWS -> use IMGUI_DISABLE_DEMO_WINDOWS - 2019/12/08 (1.75) - obsoleted calling ImDrawList::PrimReserve() with a negative count (which was the vaguely documented and rarely if ever used). Instead we added an explicit PrimUnreserve() API. - 2019/12/06 (1.75) - removed implicit default parameter to IsMouseDragging(int button = 0) to be consistent with other mouse functions (none of the other functions have it). - 2019/11/21 (1.74) - ImFontAtlas::AddCustomRectRegular() now requires an ID larger than 0x110000 (instead of 0x10000) to conform with supporting Unicode planes 1-16 in a future update. ID below 0x110000 will now assert. - 2019/11/19 (1.74) - renamed IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS to IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS for consistency. - 2019/11/19 (1.74) - renamed IMGUI_DISABLE_MATH_FUNCTIONS to IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS for consistency. - 2019/10/22 (1.74) - removed redirecting functions/enums that were marked obsolete in 1.52 (October 2017): - Begin() [old 5 args version] -> use Begin() [3 args], use SetNextWindowSize() SetNextWindowBgAlpha() if needed - IsRootWindowOrAnyChildHovered() -> use IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows) - AlignFirstTextHeightToWidgets() -> use AlignTextToFramePadding() - SetNextWindowPosCenter() -> use SetNextWindowPos() with a pivot of (0.5f, 0.5f) - ImFont::Glyph -> use ImFontGlyph - 2019/10/14 (1.74) - inputs: Fixed a miscalculation in the keyboard/mouse "typematic" repeat delay/rate calculation, used by keys and e.g. repeating mouse buttons as well as the GetKeyPressedAmount() function. if you were using a non-default value for io.KeyRepeatRate (previous default was 0.250), you can add +io.KeyRepeatDelay to it to compensate for the fix. The function was triggering on: 0.0 and (delay+rate*N) where (N>=1). Fixed formula responds to (N>=0). Effectively it made io.KeyRepeatRate behave like it was set to (io.KeyRepeatRate + io.KeyRepeatDelay). If you never altered io.KeyRepeatRate nor used GetKeyPressedAmount() this won't affect you. - 2019/07/15 (1.72) - removed TreeAdvanceToLabelPos() which is rarely used and only does SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()). Kept redirection function (will obsolete). - 2019/07/12 (1.72) - renamed ImFontAtlas::CustomRect to ImFontAtlasCustomRect. Kept redirection typedef (will obsolete). - 2019/06/14 (1.72) - removed redirecting functions/enums names that were marked obsolete in 1.51 (June 2017): ImGuiCol_Column*, ImGuiSetCond_*, IsItemHoveredRect(), IsPosHoveringAnyWindow(), IsMouseHoveringAnyWindow(), IsMouseHoveringWindow(), IMGUI_ONCE_UPON_A_FRAME. Grep this log for details and new names, or see how they were implemented until 1.71. - 2019/06/07 (1.71) - rendering of child window outer decorations (bg color, border, scrollbars) is now performed as part of the parent window. If you have overlapping child windows in a same parent, and relied on their relative z-order to be mapped to their submission order, this will affect your rendering. This optimization is disabled if the parent window has no visual output, because it appears to be the most common situation leading to the creation of overlapping child windows. Please reach out if you are affected. - 2019/05/13 (1.71) - renamed SetNextTreeNodeOpen() to SetNextItemOpen(). Kept inline redirection function (will obsolete). - 2019/05/11 (1.71) - changed io.AddInputCharacter(unsigned short c) signature to io.AddInputCharacter(unsigned int c). - 2019/04/29 (1.70) - improved ImDrawList thick strokes (>1.0f) preserving correct thickness up to 90 degrees angles (e.g. rectangles). If you have custom rendering using thick lines, they will appear thicker now. - 2019/04/29 (1.70) - removed GetContentRegionAvailWidth(), use GetContentRegionAvail().x instead. Kept inline redirection function (will obsolete). - 2019/03/04 (1.69) - renamed GetOverlayDrawList() to GetForegroundDrawList(). Kept redirection function (will obsolete). - 2019/02/26 (1.69) - renamed ImGuiColorEditFlags_RGB/ImGuiColorEditFlags_HSV/ImGuiColorEditFlags_HEX to ImGuiColorEditFlags_DisplayRGB/ImGuiColorEditFlags_DisplayHSV/ImGuiColorEditFlags_DisplayHex. Kept redirection enums (will obsolete). - 2019/02/14 (1.68) - made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame). If for some reason your time step calculation gives you a zero value, replace it with a dummy small value! - 2019/02/01 (1.68) - removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already). - 2019/01/06 (1.67) - renamed io.InputCharacters[], marked internal as was always intended. Please don't access directly, and use AddInputCharacter() instead! - 2019/01/06 (1.67) - renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete). - 2018/12/20 (1.67) - made it illegal to call Begin("") with an empty string. This somehow half-worked before but had various undesirable side-effects. - 2018/12/10 (1.67) - renamed io.ConfigResizeWindowsFromEdges to io.ConfigWindowsResizeFromEdges as we are doing a large pass on configuration flags. - 2018/10/12 (1.66) - renamed misc/stl/imgui_stl.* to misc/cpp/imgui_stdlib.* in prevision for other C++ helper files. - 2018/09/28 (1.66) - renamed SetScrollHere() to SetScrollHereY(). Kept redirection function (will obsolete). - 2018/09/06 (1.65) - renamed stb_truetype.h to imstb_truetype.h, stb_textedit.h to imstb_textedit.h, and stb_rect_pack.h to imstb_rectpack.h. If you were conveniently using the imgui copy of those STB headers in your project you will have to update your include paths. - 2018/09/05 (1.65) - renamed io.OptCursorBlink/io.ConfigCursorBlink to io.ConfigInputTextCursorBlink. (#1427) - 2018/08/31 (1.64) - added imgui_widgets.cpp file, extracted and moved widgets code out of imgui.cpp into imgui_widgets.cpp. Re-ordered some of the code remaining in imgui.cpp. NONE OF THE FUNCTIONS HAVE CHANGED. THE CODE IS SEMANTICALLY 100% IDENTICAL, BUT _EVERY_ FUNCTION HAS BEEN MOVED. Because of this, any local modifications to imgui.cpp will likely conflict when you update. Read docs/CHANGELOG.txt for suggestions. - 2018/08/22 (1.63) - renamed IsItemDeactivatedAfterChange() to IsItemDeactivatedAfterEdit() for consistency with new IsItemEdited() API. Kept redirection function (will obsolete soonish as IsItemDeactivatedAfterChange() is very recent). - 2018/08/21 (1.63) - renamed ImGuiTextEditCallback to ImGuiInputTextCallback, ImGuiTextEditCallbackData to ImGuiInputTextCallbackData for consistency. Kept redirection types (will obsolete). - 2018/08/21 (1.63) - removed ImGuiInputTextCallbackData::ReadOnly since it is a duplication of (ImGuiInputTextCallbackData::Flags & ImGuiInputTextFlags_ReadOnly). - 2018/08/01 (1.63) - removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor of a global io.ConfigResizeWindowsFromEdges [update 1.67 renamed to ConfigWindowsResizeFromEdges] to enable the feature. - 2018/08/01 (1.63) - renamed io.OptCursorBlink to io.ConfigCursorBlink [-> io.ConfigInputTextCursorBlink in 1.65], io.OptMacOSXBehaviors to ConfigMacOSXBehaviors for consistency. - 2018/07/22 (1.63) - changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecisions over time. - 2018/07/08 (1.63) - style: renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. Kept redirection enum (will obsolete). - 2018/06/08 (1.62) - examples: the imgui_impl_xxx files have been split to separate platform (Win32, Glfw, SDL2, etc.) from renderer (DX11, OpenGL, Vulkan, etc.). old bindings will still work as is, however prefer using the separated bindings as they will be updated to support multi-viewports. when adopting new bindings follow the main.cpp code of your preferred examples/ folder to know which functions to call. in particular, note that old bindings called ImGui::NewFrame() at the end of their ImGui_ImplXXXX_NewFrame() function. - 2018/06/06 (1.62) - renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish other variants and discourage using the full set. - 2018/06/06 (1.62) - TreeNodeEx()/TreeNodeBehavior(): the ImGuiTreeNodeFlags_CollapsingHeader helper now include the ImGuiTreeNodeFlags_NoTreePushOnOpen flag. See Changelog for details. - 2018/05/03 (1.61) - DragInt(): the default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally any more. If you used DragInt() with custom format strings, make sure you change them to use %d or an integer-compatible format. To honor backward-compatibility, the DragInt() code will currently parse and modify format strings to replace %*f with %d, giving time to users to upgrade their code. If you have IMGUI_DISABLE_OBSOLETE_FUNCTIONS enabled, the code will instead assert! You may run a reg-exp search on your codebase for e.g. "DragInt.*%f" to help you find them. - 2018/04/28 (1.61) - obsoleted InputFloat() functions taking an optional "int decimal_precision" in favor of an equivalent and more flexible "const char* format", consistent with other functions. Kept redirection functions (will obsolete). - 2018/04/09 (1.61) - IM_DELETE() helper function added in 1.60 doesn't clear the input _pointer_ reference, more consistent with expectation and allows passing r-value. - 2018/03/20 (1.60) - renamed io.WantMoveMouse to io.WantSetMousePos for consistency and ease of understanding (was added in 1.52, _not_ used by core and only honored by some binding ahead of merging the Nav branch). - 2018/03/12 (1.60) - removed ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered as the closing cross uses regular button colors now. - 2018/03/08 (1.60) - changed ImFont::DisplayOffset.y to default to 0 instead of +1. Fixed rounding of Ascent/Descent to match TrueType renderer. If you were adding or subtracting to ImFont::DisplayOffset check if your fonts are correctly aligned vertically. - 2018/03/03 (1.60) - renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums. - 2018/02/18 (1.60) - BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment. - 2018/02/16 (1.60) - obsoleted the io.RenderDrawListsFn callback, you can call your graphics engine render function after ImGui::Render(). Use ImGui::GetDrawData() to retrieve the ImDrawData* to display. - 2018/02/07 (1.60) - reorganized context handling to be more explicit, - YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END. - removed Shutdown() function, as DestroyContext() serve this purpose. - you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwise CreateContext() will create its own font atlas instance. - removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts. - removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts. - 2018/01/31 (1.60) - moved sample TTF files from extra_fonts/ to misc/fonts/. If you loaded files directly from the imgui repo you may need to update your paths. - 2018/01/11 (1.60) - obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete). - 2018/01/11 (1.60) - obsoleted IsAnyWindowFocused() in favor of IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Kept redirection function (will obsolete). - 2018/01/03 (1.60) - renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData. - 2017/12/29 (1.60) - removed CalcItemRectClosestPoint() which was weird and not really used by anyone except demo code. If you need it it's easy to replicate on your side. - 2017/12/24 (1.53) - renamed the emblematic ShowTestWindow() function to ShowDemoWindow(). Kept redirection function (will obsolete). - 2017/12/21 (1.53) - ImDrawList: renamed style.AntiAliasedShapes to style.AntiAliasedFill for consistency and as a way to explicitly break code that manipulate those flag at runtime. You can now manipulate ImDrawList::Flags - 2017/12/21 (1.53) - ImDrawList: removed 'bool anti_aliased = true' final parameter of ImDrawList::AddPolyline() and ImDrawList::AddConvexPolyFilled(). Prefer manipulating ImDrawList::Flags if you need to toggle them during the frame. - 2017/12/14 (1.53) - using the ImGuiWindowFlags_NoScrollWithMouse flag on a child window forwards the mouse wheel event to the parent window, unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set. - 2017/12/13 (1.53) - renamed GetItemsLineHeightWithSpacing() to GetFrameHeightWithSpacing(). Kept redirection function (will obsolete). - 2017/12/13 (1.53) - obsoleted IsRootWindowFocused() in favor of using IsWindowFocused(ImGuiFocusedFlags_RootWindow). Kept redirection function (will obsolete). - obsoleted IsRootWindowOrAnyChildFocused() in favor of using IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows). Kept redirection function (will obsolete). - 2017/12/12 (1.53) - renamed ImGuiTreeNodeFlags_AllowOverlapMode to ImGuiTreeNodeFlags_AllowItemOverlap. Kept redirection enum (will obsolete). - 2017/12/10 (1.53) - removed SetNextWindowContentWidth(), prefer using SetNextWindowContentSize(). Kept redirection function (will obsolete). - 2017/11/27 (1.53) - renamed ImGuiTextBuffer::append() helper to appendf(), appendv() to appendfv(). If you copied the 'Log' demo in your code, it uses appendv() so that needs to be renamed. - 2017/11/18 (1.53) - Style, Begin: removed ImGuiWindowFlags_ShowBorders window flag. Borders are now fully set up in the ImGuiStyle structure (see e.g. style.FrameBorderSize, style.WindowBorderSize). Use ImGui::ShowStyleEditor() to look them up. Please note that the style system will keep evolving (hopefully stabilizing in Q1 2018), and so custom styles will probably subtly break over time. It is recommended you use the StyleColorsClassic(), StyleColorsDark(), StyleColorsLight() functions. - 2017/11/18 (1.53) - Style: removed ImGuiCol_ComboBg in favor of combo boxes using ImGuiCol_PopupBg for consistency. - 2017/11/18 (1.53) - Style: renamed ImGuiCol_ChildWindowBg to ImGuiCol_ChildBg. - 2017/11/18 (1.53) - Style: renamed style.ChildWindowRounding to style.ChildRounding, ImGuiStyleVar_ChildWindowRounding to ImGuiStyleVar_ChildRounding. - 2017/11/02 (1.53) - obsoleted IsRootWindowOrAnyChildHovered() in favor of using IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows); - 2017/10/24 (1.52) - renamed IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS to IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS for consistency. - 2017/10/20 (1.52) - changed IsWindowHovered() default parameters behavior to return false if an item is active in another window (e.g. click-dragging item from another window to this window). You can use the newly introduced IsWindowHovered() flags to requests this specific behavior if you need it. - 2017/10/20 (1.52) - marked IsItemHoveredRect()/IsMouseHoveringWindow() as obsolete, in favor of using the newly introduced flags for IsItemHovered() and IsWindowHovered(). See https://github.com/ocornut/imgui/issues/1382 for details. removed the IsItemRectHovered()/IsWindowRectHovered() names introduced in 1.51 since they were merely more consistent names for the two functions we are now obsoleting. IsItemHoveredRect() --> IsItemHovered(ImGuiHoveredFlags_RectOnly) IsMouseHoveringAnyWindow() --> IsWindowHovered(ImGuiHoveredFlags_AnyWindow) IsMouseHoveringWindow() --> IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) [weird, old behavior] - 2017/10/17 (1.52) - marked the old 5-parameters version of Begin() as obsolete (still available). Use SetNextWindowSize()+Begin() instead! - 2017/10/11 (1.52) - renamed AlignFirstTextHeightToWidgets() to AlignTextToFramePadding(). Kept inline redirection function (will obsolete). - 2017/09/26 (1.52) - renamed ImFont::Glyph to ImFontGlyph. Kept redirection typedef (will obsolete). - 2017/09/25 (1.52) - removed SetNextWindowPosCenter() because SetNextWindowPos() now has the optional pivot information to do the same and more. Kept redirection function (will obsolete). - 2017/08/25 (1.52) - io.MousePos needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing. Previously ImVec2(-1,-1) was enough but we now accept negative mouse coordinates. In your binding if you need to support unavailable mouse, make sure to replace "io.MousePos = ImVec2(-1,-1)" with "io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX)". - 2017/08/22 (1.51) - renamed IsItemHoveredRect() to IsItemRectHovered(). Kept inline redirection function (will obsolete). -> (1.52) use IsItemHovered(ImGuiHoveredFlags_RectOnly)! - renamed IsMouseHoveringAnyWindow() to IsAnyWindowHovered() for consistency. Kept inline redirection function (will obsolete). - renamed IsMouseHoveringWindow() to IsWindowRectHovered() for consistency. Kept inline redirection function (will obsolete). - 2017/08/20 (1.51) - renamed GetStyleColName() to GetStyleColorName() for consistency. - 2017/08/20 (1.51) - added PushStyleColor(ImGuiCol idx, ImU32 col) overload, which _might_ cause an "ambiguous call" compilation error if you are using ImColor() with implicit cast. Cast to ImU32 or ImVec4 explicily to fix. - 2017/08/15 (1.51) - marked the weird IMGUI_ONCE_UPON_A_FRAME helper macro as obsolete. prefer using the more explicit ImGuiOnceUponAFrame type. - 2017/08/15 (1.51) - changed parameter order for BeginPopupContextWindow() from (const char*,int buttons,bool also_over_items) to (const char*,int buttons,bool also_over_items). Note that most calls relied on default parameters completely. - 2017/08/13 (1.51) - renamed ImGuiCol_Column to ImGuiCol_Separator, ImGuiCol_ColumnHovered to ImGuiCol_SeparatorHovered, ImGuiCol_ColumnActive to ImGuiCol_SeparatorActive. Kept redirection enums (will obsolete). - 2017/08/11 (1.51) - renamed ImGuiSetCond_Always to ImGuiCond_Always, ImGuiSetCond_Once to ImGuiCond_Once, ImGuiSetCond_FirstUseEver to ImGuiCond_FirstUseEver, ImGuiSetCond_Appearing to ImGuiCond_Appearing. Kept redirection enums (will obsolete). - 2017/08/09 (1.51) - removed ValueColor() helpers, they are equivalent to calling Text(label) + SameLine() + ColorButton(). - 2017/08/08 (1.51) - removed ColorEditMode() and ImGuiColorEditMode in favor of ImGuiColorEditFlags and parameters to the various Color*() functions. The SetColorEditOptions() allows to initialize default but the user can still change them with right-click context menu. - changed prototype of 'ColorEdit4(const char* label, float col[4], bool show_alpha = true)' to 'ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0)', where passing flags = 0x01 is a safe no-op (hello dodgy backward compatibility!). - check and run the demo window, under "Color/Picker Widgets", to understand the various new options. - changed prototype of rarely used 'ColorButton(ImVec4 col, bool small_height = false, bool outline_border = true)' to 'ColorButton(const char* desc_id, ImVec4 col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0))' - 2017/07/20 (1.51) - removed IsPosHoveringAnyWindow(ImVec2), which was partly broken and misleading. ASSERT + redirect user to io.WantCaptureMouse - 2017/05/26 (1.50) - removed ImFontConfig::MergeGlyphCenterV in favor of a more multipurpose ImFontConfig::GlyphOffset. - 2017/05/01 (1.50) - renamed ImDrawList::PathFill() (rarely used directly) to ImDrawList::PathFillConvex() for clarity. - 2016/11/06 (1.50) - BeginChild(const char*) now applies the stack id to the provided label, consistently with other functions as it should always have been. It shouldn't affect you unless (extremely unlikely) you were appending multiple times to a same child from different locations of the stack id. If that's the case, generate an id with GetId() and use it instead of passing string to BeginChild(). - 2016/10/15 (1.50) - avoid 'void* user_data' parameter to io.SetClipboardTextFn/io.GetClipboardTextFn pointers. We pass io.ClipboardUserData to it. - 2016/09/25 (1.50) - style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc. - 2016/07/30 (1.50) - SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully breakage should be minimal. - 2016/05/12 (1.49) - title bar (using ImGuiCol_TitleBg/ImGuiCol_TitleBgActive colors) isn't rendered over a window background (ImGuiCol_WindowBg color) anymore. If your TitleBg/TitleBgActive alpha was 1.0f or you are using the default theme it will not affect you, otherwise if <1.0f you need tweak your custom theme to readjust for the fact that we don't draw a WindowBg background behind the title bar. This helper function will convert an old TitleBg/TitleBgActive color into a new one with the same visual output, given the OLD color and the OLD WindowBg color: ImVec4 ConvertTitleBgCol(const ImVec4& win_bg_col, const ImVec4& title_bg_col) { float new_a = 1.0f - ((1.0f - win_bg_col.w) * (1.0f - title_bg_col.w)), k = title_bg_col.w / new_a; return ImVec4((win_bg_col.x * win_bg_col.w + title_bg_col.x) * k, (win_bg_col.y * win_bg_col.w + title_bg_col.y) * k, (win_bg_col.z * win_bg_col.w + title_bg_col.z) * k, new_a); } If this is confusing, pick the RGB value from title bar from an old screenshot and apply this as TitleBg/TitleBgActive. Or you may just create TitleBgActive from a tweaked TitleBg color. - 2016/05/07 (1.49) - removed confusing set of GetInternalState(), GetInternalStateSize(), SetInternalState() functions. Now using CreateContext(), DestroyContext(), GetCurrentContext(), SetCurrentContext(). - 2016/05/02 (1.49) - renamed SetNextTreeNodeOpened() to SetNextTreeNodeOpen(), no redirection. - 2016/05/01 (1.49) - obsoleted old signature of CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false) as extra parameters were badly designed and rarely used. You can replace the "default_open = true" flag in new API with CollapsingHeader(label, ImGuiTreeNodeFlags_DefaultOpen). - 2016/04/26 (1.49) - changed ImDrawList::PushClipRect(ImVec4 rect) to ImDrawList::PushClipRect(Imvec2 min,ImVec2 max,bool intersect_with_current_clip_rect=false). Note that higher-level ImGui::PushClipRect() is preferable because it will clip at logic/widget level, whereas ImDrawList::PushClipRect() only affect your renderer. - 2016/04/03 (1.48) - removed style.WindowFillAlphaDefault setting which was redundant. Bake default BG alpha inside style.Colors[ImGuiCol_WindowBg] and all other Bg color values. (ref github issue #337). - 2016/04/03 (1.48) - renamed ImGuiCol_TooltipBg to ImGuiCol_PopupBg, used by popups/menus and tooltips. popups/menus were previously using ImGuiCol_WindowBg. (ref github issue #337) - 2016/03/21 (1.48) - renamed GetWindowFont() to GetFont(), GetWindowFontSize() to GetFontSize(). Kept inline redirection function (will obsolete). - 2016/03/02 (1.48) - InputText() completion/history/always callbacks: if you modify the text buffer manually (without using DeleteChars()/InsertChars() helper) you need to maintain the BufTextLen field. added an assert. - 2016/01/23 (1.48) - fixed not honoring exact width passed to PushItemWidth(), previously it would add extra FramePadding.x*2 over that width. if you had manual pixel-perfect alignment in place it might affect you. - 2015/12/27 (1.48) - fixed ImDrawList::AddRect() which used to render a rectangle 1 px too large on each axis. - 2015/12/04 (1.47) - renamed Color() helpers to ValueColor() - dangerously named, rarely used and probably to be made obsolete. - 2015/08/29 (1.45) - with the addition of horizontal scrollbar we made various fixes to inconsistencies with dealing with cursor position. GetCursorPos()/SetCursorPos() functions now include the scrolled amount. It shouldn't affect the majority of users, but take note that SetCursorPosX(100.0f) puts you at +100 from the starting x position which may include scrolling, not at +100 from the window left side. GetContentRegionMax()/GetWindowContentRegionMin()/GetWindowContentRegionMax() functions allow include the scrolled amount. Typically those were used in cases where no scrolling would happen so it may not be a problem, but watch out! - 2015/08/29 (1.45) - renamed style.ScrollbarWidth to style.ScrollbarSize - 2015/08/05 (1.44) - split imgui.cpp into extra files: imgui_demo.cpp imgui_draw.cpp imgui_internal.h that you need to add to your project. - 2015/07/18 (1.44) - fixed angles in ImDrawList::PathArcTo(), PathArcToFast() (introduced in 1.43) being off by an extra PI for no justifiable reason - 2015/07/14 (1.43) - add new ImFontAtlas::AddFont() API. For the old AddFont***, moved the 'font_no' parameter of ImFontAtlas::AddFont** functions to the ImFontConfig structure. you need to render your textured triangles with bilinear filtering to benefit from sub-pixel positioning of text. - 2015/07/08 (1.43) - switched rendering data to use indexed rendering. this is saving a fair amount of CPU/GPU and enables us to get anti-aliasing for a marginal cost. this necessary change will break your rendering function! the fix should be very easy. sorry for that :( - if you are using a vanilla copy of one of the imgui_impl_XXXX.cpp provided in the example, you just need to update your copy and you can ignore the rest. - the signature of the io.RenderDrawListsFn handler has changed! old: ImGui_XXXX_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count) new: ImGui_XXXX_RenderDrawLists(ImDrawData* draw_data). parameters: 'cmd_lists' becomes 'draw_data->CmdLists', 'cmd_lists_count' becomes 'draw_data->CmdListsCount' ImDrawList: 'commands' becomes 'CmdBuffer', 'vtx_buffer' becomes 'VtxBuffer', 'IdxBuffer' is new. ImDrawCmd: 'vtx_count' becomes 'ElemCount', 'clip_rect' becomes 'ClipRect', 'user_callback' becomes 'UserCallback', 'texture_id' becomes 'TextureId'. - each ImDrawList now contains both a vertex buffer and an index buffer. For each command, render ElemCount/3 triangles using indices from the index buffer. - if you REALLY cannot render indexed primitives, you can call the draw_data->DeIndexAllBuffers() method to de-index the buffers. This is slow and a waste of CPU/GPU. Prefer using indexed rendering! - refer to code in the examples/ folder or ask on the GitHub if you are unsure of how to upgrade. please upgrade! - 2015/07/10 (1.43) - changed SameLine() parameters from int to float. - 2015/07/02 (1.42) - renamed SetScrollPosHere() to SetScrollFromCursorPos(). Kept inline redirection function (will obsolete). - 2015/07/02 (1.42) - renamed GetScrollPosY() to GetScrollY(). Necessary to reduce confusion along with other scrolling functions, because positions (e.g. cursor position) are not equivalent to scrolling amount. - 2015/06/14 (1.41) - changed ImageButton() default bg_col parameter from (0,0,0,1) (black) to (0,0,0,0) (transparent) - makes a difference when texture have transparence - 2015/06/14 (1.41) - changed Selectable() API from (label, selected, size) to (label, selected, flags, size). Size override should have been rarely be used. Sorry! - 2015/05/31 (1.40) - renamed GetWindowCollapsed() to IsWindowCollapsed() for consistency. Kept inline redirection function (will obsolete). - 2015/05/31 (1.40) - renamed IsRectClipped() to IsRectVisible() for consistency. Note that return value is opposite! Kept inline redirection function (will obsolete). - 2015/05/27 (1.40) - removed the third 'repeat_if_held' parameter from Button() - sorry! it was rarely used and inconsistent. Use PushButtonRepeat(true) / PopButtonRepeat() to enable repeat on desired buttons. - 2015/05/11 (1.40) - changed BeginPopup() API, takes a string identifier instead of a bool. ImGui needs to manage the open/closed state of popups. Call OpenPopup() to actually set the "open" state of a popup. BeginPopup() returns true if the popup is opened. - 2015/05/03 (1.40) - removed style.AutoFitPadding, using style.WindowPadding makes more sense (the default values were already the same). - 2015/04/13 (1.38) - renamed IsClipped() to IsRectClipped(). Kept inline redirection function until 1.50. - 2015/04/09 (1.38) - renamed ImDrawList::AddArc() to ImDrawList::AddArcFast() for compatibility with future API - 2015/04/03 (1.38) - removed ImGuiCol_CheckHovered, ImGuiCol_CheckActive, replaced with the more general ImGuiCol_FrameBgHovered, ImGuiCol_FrameBgActive. - 2014/04/03 (1.38) - removed support for passing -FLT_MAX..+FLT_MAX as the range for a SliderFloat(). Use DragFloat() or Inputfloat() instead. - 2015/03/17 (1.36) - renamed GetItemBoxMin()/GetItemBoxMax()/IsMouseHoveringBox() to GetItemRectMin()/GetItemRectMax()/IsMouseHoveringRect(). Kept inline redirection function until 1.50. - 2015/03/15 (1.36) - renamed style.TreeNodeSpacing to style.IndentSpacing, ImGuiStyleVar_TreeNodeSpacing to ImGuiStyleVar_IndentSpacing - 2015/03/13 (1.36) - renamed GetWindowIsFocused() to IsWindowFocused(). Kept inline redirection function until 1.50. - 2015/03/08 (1.35) - renamed style.ScrollBarWidth to style.ScrollbarWidth (casing) - 2015/02/27 (1.34) - renamed OpenNextNode(bool) to SetNextTreeNodeOpened(bool, ImGuiSetCond). Kept inline redirection function until 1.50. - 2015/02/27 (1.34) - renamed ImGuiSetCondition_*** to ImGuiSetCond_***, and _FirstUseThisSession becomes _Once. - 2015/02/11 (1.32) - changed text input callback ImGuiTextEditCallback return type from void-->int. reserved for future use, return 0 for now. - 2015/02/10 (1.32) - renamed GetItemWidth() to CalcItemWidth() to clarify its evolving behavior - 2015/02/08 (1.31) - renamed GetTextLineSpacing() to GetTextLineHeightWithSpacing() - 2015/02/01 (1.31) - removed IO.MemReallocFn (unused) - 2015/01/19 (1.30) - renamed ImGuiStorage::GetIntPtr()/GetFloatPtr() to GetIntRef()/GetIntRef() because Ptr was conflicting with actual pointer storage functions. - 2015/01/11 (1.30) - big font/image API change! now loads TTF file. allow for multiple fonts. no need for a PNG loader. - 2015/01/11 (1.30) - removed GetDefaultFontData(). uses io.Fonts->GetTextureData*() API to retrieve uncompressed pixels. - old: const void* png_data; unsigned int png_size; ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size); [..Upload texture to GPU..]; - new: unsigned char* pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); [..Upload texture to GPU..]; io.Fonts->TexId = YourTexIdentifier; you now have more flexibility to load multiple TTF fonts and manage the texture buffer for internal needs. It is now recommended that you sample the font texture with bilinear interpolation. - 2015/01/11 (1.30) - added texture identifier in ImDrawCmd passed to your render function (we can now render images). make sure to set io.Fonts->TexID. - 2015/01/11 (1.30) - removed IO.PixelCenterOffset (unnecessary, can be handled in user projection matrix) - 2015/01/11 (1.30) - removed ImGui::IsItemFocused() in favor of ImGui::IsItemActive() which handles all widgets - 2014/12/10 (1.18) - removed SetNewWindowDefaultPos() in favor of new generic API SetNextWindowPos(pos, ImGuiSetCondition_FirstUseEver) - 2014/11/28 (1.17) - moved IO.Font*** options to inside the IO.Font-> structure (FontYOffset, FontTexUvForWhite, FontBaseScale, FontFallbackGlyph) - 2014/11/26 (1.17) - reworked syntax of IMGUI_ONCE_UPON_A_FRAME helper macro to increase compiler compatibility - 2014/11/07 (1.15) - renamed IsHovered() to IsItemHovered() - 2014/10/02 (1.14) - renamed IMGUI_INCLUDE_IMGUI_USER_CPP to IMGUI_INCLUDE_IMGUI_USER_INL and imgui_user.cpp to imgui_user.inl (more IDE friendly) - 2014/09/25 (1.13) - removed 'text_end' parameter from IO.SetClipboardTextFn (the string is now always zero-terminated for simplicity) - 2014/09/24 (1.12) - renamed SetFontScale() to SetWindowFontScale() - 2014/09/24 (1.12) - moved IM_MALLOC/IM_REALLOC/IM_FREE preprocessor defines to IO.MemAllocFn/IO.MemReallocFn/IO.MemFreeFn - 2014/08/30 (1.09) - removed IO.FontHeight (now computed automatically) - 2014/08/30 (1.09) - moved IMGUI_FONT_TEX_UV_FOR_WHITE preprocessor define to IO.FontTexUvForWhite - 2014/08/28 (1.09) - changed the behavior of IO.PixelCenterOffset following various rendering fixes FREQUENTLY ASKED QUESTIONS (FAQ) ================================ Read all answers online: https://www.dearimgui.org/faq, or in docs/FAQ.md (with a Markdown viewer) Some answers are copied down here to facilitate searching in code. Q&A: Basics =========== Q: Where is the documentation? A: This library is poorly documented at the moment and expects of the user to be acquainted with C/C++. - Run the examples/ and explore them. - See demo code in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function. - The demo covers most features of Dear ImGui, so you can read the code and see its output. - See documentation and comments at the top of imgui.cpp + effectively imgui.h. - Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the examples/ folder to explain how to integrate Dear ImGui with your own engine/application. - The Wiki (https://github.com/ocornut/imgui/wiki) has many resources and links. - The Glossary (https://github.com/ocornut/imgui/wiki/Glossary) page also may be useful. - Your programming IDE is your friend, find the type or function declaration to find comments associated to it. Q: What is this library called? Q: Which version should I get? >> This library is called "Dear ImGui", please don't call it "ImGui" :) >> See https://www.dearimgui.org/faq Q&A: Integration ================ Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or to my application? A: You should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags! >> See https://www.dearimgui.org/faq for fully detailed answer. You really want to read this. Q. How can I enable keyboard controls? Q: How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display) Q: I integrated Dear ImGui in my engine and the text or lines are blurry.. Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around.. >> See https://www.dearimgui.org/faq Q&A: Usage ---------- Q: Why are multiple widgets reacting when I interact with a single one? Q: How can I have multiple widgets with the same label or with an empty label? A: A primer on labels and the ID Stack... Dear ImGui internally need to uniquely identify UI elements. Elements that are typically not clickable (such as calls to the Text functions) don't need an ID. Interactive widgets (such as calls to Button buttons) need a unique ID. Unique ID are used internally to track active widgets and occasionally associate state to widgets. Unique ID are implicitly built from the hash of multiple elements that identify the "path" to the UI element. - Unique ID are often derived from a string label: Button("OK"); // Label = "OK", ID = hash of (..., "OK") Button("Cancel"); // Label = "Cancel", ID = hash of (..., "Cancel") - ID are uniquely scoped within windows, tree nodes, etc. which all pushes to the ID stack. Having two buttons labeled "OK" in different windows or different tree locations is fine. We used "..." above to signify whatever was already pushed to the ID stack previously: Begin("MyWindow"); Button("OK"); // Label = "OK", ID = hash of ("MyWindow", "OK") End(); Begin("MyOtherWindow"); Button("OK"); // Label = "OK", ID = hash of ("MyOtherWindow", "OK") End(); - If you have a same ID twice in the same location, you'll have a conflict: Button("OK"); Button("OK"); // ID collision! Interacting with either button will trigger the first one. Fear not! this is easy to solve and there are many ways to solve it! - Solving ID conflict in a simple/local context: When passing a label you can optionally specify extra ID information within string itself. Use "##" to pass a complement to the ID that won't be visible to the end-user. This helps solving the simple collision cases when you know e.g. at compilation time which items are going to be created: Begin("MyWindow"); Button("Play"); // Label = "Play", ID = hash of ("MyWindow", "Play") Button("Play##foo1"); // Label = "Play", ID = hash of ("MyWindow", "Play##foo1") // Different from above Button("Play##foo2"); // Label = "Play", ID = hash of ("MyWindow", "Play##foo2") // Different from above End(); - If you want to completely hide the label, but still need an ID: Checkbox("##On", &b); // Label = "", ID = hash of (..., "##On") // No visible label, just a checkbox! - Occasionally/rarely you might want change a label while preserving a constant ID. This allows you to animate labels. For example you may want to include varying information in a window title bar, but windows are uniquely identified by their ID. Use "###" to pass a label that isn't part of ID: Button("Hello###ID"); // Label = "Hello", ID = hash of (..., "###ID") Button("World###ID"); // Label = "World", ID = hash of (..., "###ID") // Same as above, even though the label looks different sprintf(buf, "My game (%f FPS)###MyGame", fps); Begin(buf); // Variable title, ID = hash of "MyGame" - Solving ID conflict in a more general manner: Use PushID() / PopID() to create scopes and manipulate the ID stack, as to avoid ID conflicts within the same window. This is the most convenient way of distinguishing ID when iterating and creating many UI elements programmatically. You can push a pointer, a string or an integer value into the ID stack. Remember that ID are formed from the concatenation of _everything_ pushed into the ID stack. At each level of the stack we store the seed used for items at this level of the ID stack. Begin("Window"); for (int i = 0; i < 100; i++) { PushID(i); // Push i to the id tack Button("Click"); // Label = "Click", ID = hash of ("Window", i, "Click") PopID(); } for (int i = 0; i < 100; i++) { MyObject* obj = Objects[i]; PushID(obj); Button("Click"); // Label = "Click", ID = hash of ("Window", obj pointer, "Click") PopID(); } for (int i = 0; i < 100; i++) { MyObject* obj = Objects[i]; PushID(obj->Name); Button("Click"); // Label = "Click", ID = hash of ("Window", obj->Name, "Click") PopID(); } End(); - You can stack multiple prefixes into the ID stack: Button("Click"); // Label = "Click", ID = hash of (..., "Click") PushID("node"); Button("Click"); // Label = "Click", ID = hash of (..., "node", "Click") PushID(my_ptr); Button("Click"); // Label = "Click", ID = hash of (..., "node", my_ptr, "Click") PopID(); PopID(); - Tree nodes implicitly creates a scope for you by calling PushID(). Button("Click"); // Label = "Click", ID = hash of (..., "Click") if (TreeNode("node")) // <-- this function call will do a PushID() for you (unless instructed not to, with a special flag) { Button("Click"); // Label = "Click", ID = hash of (..., "node", "Click") TreePop(); } - When working with trees, ID are used to preserve the open/close state of each tree node. Depending on your use cases you may want to use strings, indices or pointers as ID. e.g. when following a single pointer that may change over time, using a static string as ID will preserve your node open/closed state when the targeted object change. e.g. when displaying a list of objects, using indices or pointers as ID will preserve the node open/closed state differently. See what makes more sense in your situation! Q: How can I display an image? What is ImTextureID, how does it works? >> See https://www.dearimgui.org/faq and https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples Q: How can I use my own math types instead of ImVec2/ImVec4? Q: How can I interact with standard C++ types (such as std::string and std::vector)? Q: How can I display custom shapes? (using low-level ImDrawList API) >> See https://www.dearimgui.org/faq Q&A: Fonts, Text ================ Q: How can I load a different font than the default? Q: How can I easily use icons in my application? Q: How can I load multiple fonts? Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic? >> See https://www.dearimgui.org/faq and docs/FONTS.txt Q&A: Concerns ============= Q: Who uses Dear ImGui? Q: Can you create elaborate/serious tools with Dear ImGui? Q: Can you reskin the look of Dear ImGui? Q: Why using C++ (as opposed to C)? >> See https://www.dearimgui.org/faq Q&A: Community ============== Q: How can I help? A: - Businesses: please reach out to "contact AT dearimgui.org" if you work in a place using Dear ImGui! We can discuss ways for your company to fund development via invoiced technical support, maintenance or sponsoring contacts. This is among the most useful thing you can do for Dear ImGui. With increased funding we can hire more people working on this project. - Individuals: you can support continued development via PayPal donations. See README. - If you are experienced with Dear ImGui and C++, look at the github issues, look at the Wiki, read docs/TODO.txt and see how you want to help and can help! - Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc. You may post screenshot or links in the gallery threads (github.com/ocornut/imgui/issues/2847). Visuals are ideal as they inspire other programmers. But even without visuals, disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions. - If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues (on github or privately). */ #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) #define _CRT_SECURE_NO_WARNINGS #endif #include "imgui.h" #ifndef IMGUI_DISABLE #ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS #endif #include "imgui_internal.h" #include // toupper #include // vsnprintf, sscanf, printf #if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier #include // intptr_t #else #include // intptr_t #endif // Debug options #define IMGUI_DEBUG_NAV_SCORING 0 // Display navigation scoring preview when hovering items. Display last moving direction matches when holding CTRL #define IMGUI_DEBUG_NAV_RECTS 0 // Display the reference navigation rectangle for each window #define IMGUI_DEBUG_INI_SETTINGS 0 // Save additional comments in .ini file (particularly helps for Docking, but makes saving slower) // Visual Studio warnings #ifdef _MSC_VER #pragma warning (disable: 4127) // condition expression is constant #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen #if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later #pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types #endif #endif // Clang/GCC warnings with -Weverything #if defined(__clang__) #pragma clang diagnostic ignored "-Wunknown-pragmas" // warning : unknown warning group '-Wformat-pedantic *' // not all warnings are known by all clang versions.. so ignoring warnings triggers new warnings on some configuration. great! #pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse. #pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok. #pragma clang diagnostic ignored "-Wformat-nonliteral" // warning : format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code. #pragma clang diagnostic ignored "-Wexit-time-destructors" // warning : declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals. #pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference is. #pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness // #pragma clang diagnostic ignored "-Wformat-pedantic" // warning : format specifies type 'void *' but the argument has type 'xxxx *' // unreasonable, would lead to casting every %p arg to void*. probably enabled by -pedantic. #pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int' #if __has_warning("-Wzero-as-null-pointer-constant") #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning : zero as null pointer constant // some standard header variations use #define NULL 0 #endif #if __has_warning("-Wdouble-promotion") #pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. #endif #elif defined(__GNUC__) // We disable -Wpragmas because GCC doesn't provide an has_warning equivalent and some forks/patches may not following the warning/version association. #pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind #pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used #pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size #pragma GCC diagnostic ignored "-Wformat" // warning: format '%p' expects argument of type 'void*', but argument 6 has type 'ImGuiWindow*' #pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function #pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value #pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked #pragma GCC diagnostic ignored "-Wstrict-overflow" // warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false #pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead #endif // When using CTRL+TAB (or Gamepad Square+L/R) we delay the visual a little in order to reduce visual noise doing a fast switch. static const float NAV_WINDOWING_HIGHLIGHT_DELAY = 0.20f; // Time before the highlight and screen dimming starts fading in static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time before the window list starts to appear // Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by back-end) static const float WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS = 4.0f; // Extend outside and inside windows. Affect FindHoveredWindow(). static const float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time. static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certaint time, unless mouse moved. //------------------------------------------------------------------------- // [SECTION] FORWARD DECLARATIONS //------------------------------------------------------------------------- static void SetCurrentWindow(ImGuiWindow* window); static void FindHoveredWindow(); static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags); static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges); static void AddDrawListToDrawData(ImVector* out_list, ImDrawList* draw_list); static void AddWindowToSortBuffer(ImVector* out_sorted_windows, ImGuiWindow* window); static ImRect GetViewportRect(); // Settings static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name); static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line); static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSettingsHandler*, ImGuiTextBuffer* buf); // Platform Dependents default implementation for IO functions static const char* GetClipboardTextFn_DefaultImpl(void* user_data); static void SetClipboardTextFn_DefaultImpl(void* user_data, const char* text); static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y); namespace ImGui { // Navigation static void NavUpdate(); static void NavUpdateWindowing(); static void NavUpdateWindowingOverlay(); static void NavUpdateMoveResult(); static float NavUpdatePageUpPageDown(); static inline void NavUpdateAnyRequestFlag(); static bool NavScoreItem(ImGuiNavMoveResult* result, ImRect cand); static void NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, ImGuiID id); static ImVec2 NavCalcPreferredRefPos(); static void NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window); static ImGuiWindow* NavRestoreLastChildNavWindow(ImGuiWindow* window); static int FindWindowFocusIndex(ImGuiWindow* window); // Error Checking static void ErrorCheckEndFrame(); static void ErrorCheckBeginEndCompareStacksSize(ImGuiWindow* window, bool write); // Misc static void UpdateMouseInputs(); static void UpdateMouseWheel(); static bool UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]); static void UpdateDebugToolItemPicker(); static void RenderWindowOuterBorders(ImGuiWindow* window); static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size); static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open); } //----------------------------------------------------------------------------- // [SECTION] CONTEXT AND MEMORY ALLOCATORS //----------------------------------------------------------------------------- // Current context pointer. Implicitly used by all Dear ImGui functions. Always assumed to be != NULL. // ImGui::CreateContext() will automatically set this pointer if it is NULL. Change to a different context by calling ImGui::SetCurrentContext(). // 1) Important: globals are not shared across DLL boundaries! If you use DLLs or any form of hot-reloading: you will need to call // SetCurrentContext() (with the pointer you got from CreateContext) from each unique static/DLL boundary, and after each hot-reloading. // In your debugger, add GImGui to your watch window and notice how its value changes depending on which location you are currently stepping into. // 2) Important: Dear ImGui functions are not thread-safe because of this pointer. // If you want thread-safety to allow N threads to access N different contexts, you can: // - Change this variable to use thread local storage so each thread can refer to a different context, in imconfig.h: // struct ImGuiContext; // extern thread_local ImGuiContext* MyImGuiTLS; // #define GImGui MyImGuiTLS // And then define MyImGuiTLS in one of your cpp file. Note that thread_local is a C++11 keyword, earlier C++ uses compiler-specific keyword. // - Future development aim to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586 // - If you need a finite number of contexts, you may compile and use multiple instances of the ImGui code from different namespace. #ifndef GImGui ImGuiContext* GImGui = NULL; #endif // Memory Allocator functions. Use SetAllocatorFunctions() to change them. // If you use DLL hotreloading you might need to call SetAllocatorFunctions() after reloading code from this file. // Otherwise, you probably don't want to modify them mid-program, and if you use global/static e.g. ImVector<> instances you may need to keep them accessible during program destruction. #ifndef IMGUI_DISABLE_DEFAULT_ALLOCATORS static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); return malloc(size); } static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); free(ptr); } #else static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(size); IM_ASSERT(0); return NULL; } static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(ptr); IM_ASSERT(0); } #endif static void* (*GImAllocatorAllocFunc)(size_t size, void* user_data) = MallocWrapper; static void (*GImAllocatorFreeFunc)(void* ptr, void* user_data) = FreeWrapper; static void* GImAllocatorUserData = NULL; //----------------------------------------------------------------------------- // [SECTION] MAIN USER FACING STRUCTURES (ImGuiStyle, ImGuiIO) //----------------------------------------------------------------------------- ImGuiStyle::ImGuiStyle() { Alpha = 1.0f; // Global alpha applies to everything in ImGui WindowPadding = ImVec2(8,8); // Padding within a window WindowRounding = 7.0f; // Radius of window corners rounding. Set to 0.0f to have rectangular windows WindowBorderSize = 1.0f; // Thickness of border around windows. Generally set to 0.0f or 1.0f. Other values not well tested. WindowMinSize = ImVec2(32,32); // Minimum window size WindowTitleAlign = ImVec2(0.0f,0.5f);// Alignment for title bar text WindowMenuButtonPosition= ImGuiDir_Left; // Position of the collapsing/docking button in the title bar (left/right). Defaults to ImGuiDir_Left. ChildRounding = 0.0f; // Radius of child window corners rounding. Set to 0.0f to have rectangular child windows ChildBorderSize = 1.0f; // Thickness of border around child windows. Generally set to 0.0f or 1.0f. Other values not well tested. PopupRounding = 0.0f; // Radius of popup window corners rounding. Set to 0.0f to have rectangular child windows PopupBorderSize = 1.0f; // Thickness of border around popup or tooltip windows. Generally set to 0.0f or 1.0f. Other values not well tested. FramePadding = ImVec2(4,3); // Padding within a framed rectangle (used by most widgets) FrameRounding = 0.0f; // Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most widgets). FrameBorderSize = 0.0f; // Thickness of border around frames. Generally set to 0.0f or 1.0f. Other values not well tested. ItemSpacing = ImVec2(8,4); // Horizontal and vertical spacing between widgets/lines ItemInnerSpacing = ImVec2(4,4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label) TouchExtraPadding = ImVec2(0,0); // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much! IndentSpacing = 21.0f; // Horizontal spacing when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2). ColumnsMinSpacing = 6.0f; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1). ScrollbarSize = 14.0f; // Width of the vertical scrollbar, Height of the horizontal scrollbar ScrollbarRounding = 9.0f; // Radius of grab corners rounding for scrollbar GrabMinSize = 10.0f; // Minimum width/height of a grab box for slider/scrollbar GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs. TabRounding = 4.0f; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs. TabBorderSize = 0.0f; // Thickness of border around tabs. ColorButtonPosition = ImGuiDir_Right; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right. ButtonTextAlign = ImVec2(0.5f,0.5f);// Alignment of button text when button is larger than text. SelectableTextAlign = ImVec2(0.0f,0.0f);// Alignment of selectable text when button is larger than text. DisplayWindowPadding = ImVec2(19,19); // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows. DisplaySafeAreaPadding = ImVec2(3,3); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows. MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later. AntiAliasedLines = true; // Enable anti-aliasing on lines/borders. Disable if you are really short on CPU/GPU. AntiAliasedFill = true; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.) CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. CircleSegmentMaxError = 1.60f; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry. // Default theme ImGui::StyleColorsDark(this); } // To scale your entire UI (e.g. if you want your app to use High DPI or generally be DPI aware) you may use this helper function. Scaling the fonts is done separately and is up to you. // Important: This operation is lossy because we round all sizes to integer. If you need to change your scale multiples, call this over a freshly initialized ImGuiStyle structure rather than scaling multiple times. void ImGuiStyle::ScaleAllSizes(float scale_factor) { WindowPadding = ImFloor(WindowPadding * scale_factor); WindowRounding = ImFloor(WindowRounding * scale_factor); WindowMinSize = ImFloor(WindowMinSize * scale_factor); ChildRounding = ImFloor(ChildRounding * scale_factor); PopupRounding = ImFloor(PopupRounding * scale_factor); FramePadding = ImFloor(FramePadding * scale_factor); FrameRounding = ImFloor(FrameRounding * scale_factor); ItemSpacing = ImFloor(ItemSpacing * scale_factor); ItemInnerSpacing = ImFloor(ItemInnerSpacing * scale_factor); TouchExtraPadding = ImFloor(TouchExtraPadding * scale_factor); IndentSpacing = ImFloor(IndentSpacing * scale_factor); ColumnsMinSpacing = ImFloor(ColumnsMinSpacing * scale_factor); ScrollbarSize = ImFloor(ScrollbarSize * scale_factor); ScrollbarRounding = ImFloor(ScrollbarRounding * scale_factor); GrabMinSize = ImFloor(GrabMinSize * scale_factor); GrabRounding = ImFloor(GrabRounding * scale_factor); TabRounding = ImFloor(TabRounding * scale_factor); DisplayWindowPadding = ImFloor(DisplayWindowPadding * scale_factor); DisplaySafeAreaPadding = ImFloor(DisplaySafeAreaPadding * scale_factor); MouseCursorScale = ImFloor(MouseCursorScale * scale_factor); } ImGuiIO::ImGuiIO() { // Most fields are initialized with zero memset(this, 0, sizeof(*this)); IM_ASSERT(IM_ARRAYSIZE(ImGuiIO::MouseDown) == ImGuiMouseButton_COUNT && IM_ARRAYSIZE(ImGuiIO::MouseClicked) == ImGuiMouseButton_COUNT); // Our pre-C++11 IM_STATIC_ASSERT() macros triggers warning on modern compilers so we don't use it here. // Settings ConfigFlags = ImGuiConfigFlags_None; BackendFlags = ImGuiBackendFlags_None; DisplaySize = ImVec2(-1.0f, -1.0f); DeltaTime = 1.0f/60.0f; IniSavingRate = 5.0f; IniFilename = "imgui.ini"; LogFilename = "imgui_log.txt"; MouseDoubleClickTime = 0.30f; MouseDoubleClickMaxDist = 6.0f; for (int i = 0; i < ImGuiKey_COUNT; i++) KeyMap[i] = -1; KeyRepeatDelay = 0.275f; KeyRepeatRate = 0.050f; UserData = NULL; Fonts = NULL; FontGlobalScale = 1.0f; FontDefault = NULL; FontAllowUserScaling = false; DisplayFramebufferScale = ImVec2(1.0f, 1.0f); // Miscellaneous options MouseDrawCursor = false; #ifdef __APPLE__ ConfigMacOSXBehaviors = true; // Set Mac OS X style defaults based on __APPLE__ compile time flag #else ConfigMacOSXBehaviors = false; #endif ConfigInputTextCursorBlink = true; ConfigWindowsResizeFromEdges = true; ConfigWindowsMoveFromTitleBarOnly = false; ConfigWindowsMemoryCompactTimer = 60.0f; // Platform Functions BackendPlatformName = BackendRendererName = NULL; BackendPlatformUserData = BackendRendererUserData = BackendLanguageUserData = NULL; GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations SetClipboardTextFn = SetClipboardTextFn_DefaultImpl; ClipboardUserData = NULL; ImeSetInputScreenPosFn = ImeSetInputScreenPosFn_DefaultImpl; ImeWindowHandle = NULL; #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS RenderDrawListsFn = NULL; #endif // Input (NB: we already have memset zero the entire structure!) MousePos = ImVec2(-FLT_MAX, -FLT_MAX); MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX); MouseDragThreshold = 6.0f; for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f; for (int i = 0; i < IM_ARRAYSIZE(KeysDownDuration); i++) KeysDownDuration[i] = KeysDownDurationPrev[i] = -1.0f; for (int i = 0; i < IM_ARRAYSIZE(NavInputsDownDuration); i++) NavInputsDownDuration[i] = -1.0f; } // Pass in translated ASCII characters for text input. // - with glfw you can get those from the callback set in glfwSetCharCallback() // - on Windows you can get those using ToAscii+keyboard state, or via the WM_CHAR message void ImGuiIO::AddInputCharacter(unsigned int c) { if (c > 0 && c <= IM_UNICODE_CODEPOINT_MAX) InputQueueCharacters.push_back((ImWchar)c); } void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars) { while (*utf8_chars != 0) { unsigned int c = 0; utf8_chars += ImTextCharFromUtf8(&c, utf8_chars, NULL); if (c > 0 && c <= IM_UNICODE_CODEPOINT_MAX) InputQueueCharacters.push_back((ImWchar)c); } } void ImGuiIO::ClearInputCharacters() { InputQueueCharacters.resize(0); } //----------------------------------------------------------------------------- // [SECTION] MISC HELPERS/UTILITIES (Geometry functions) //----------------------------------------------------------------------------- ImVec2 ImBezierClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments) { IM_ASSERT(num_segments > 0); // Use ImBezierClosestPointCasteljau() ImVec2 p_last = p1; ImVec2 p_closest; float p_closest_dist2 = FLT_MAX; float t_step = 1.0f / (float)num_segments; for (int i_step = 1; i_step <= num_segments; i_step++) { ImVec2 p_current = ImBezierCalc(p1, p2, p3, p4, t_step * i_step); ImVec2 p_line = ImLineClosestPoint(p_last, p_current, p); float dist2 = ImLengthSqr(p - p_line); if (dist2 < p_closest_dist2) { p_closest = p_line; p_closest_dist2 = dist2; } p_last = p_current; } return p_closest; } // Closely mimics PathBezierToCasteljau() in imgui_draw.cpp static void BezierClosestPointCasteljauStep(const ImVec2& p, ImVec2& p_closest, ImVec2& p_last, float& p_closest_dist2, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level) { float dx = x4 - x1; float dy = y4 - y1; float d2 = ((x2 - x4) * dy - (y2 - y4) * dx); float d3 = ((x3 - x4) * dy - (y3 - y4) * dx); d2 = (d2 >= 0) ? d2 : -d2; d3 = (d3 >= 0) ? d3 : -d3; if ((d2+d3) * (d2+d3) < tess_tol * (dx*dx + dy*dy)) { ImVec2 p_current(x4, y4); ImVec2 p_line = ImLineClosestPoint(p_last, p_current, p); float dist2 = ImLengthSqr(p - p_line); if (dist2 < p_closest_dist2) { p_closest = p_line; p_closest_dist2 = dist2; } p_last = p_current; } else if (level < 10) { float x12 = (x1+x2)*0.5f, y12 = (y1+y2)*0.5f; float x23 = (x2+x3)*0.5f, y23 = (y2+y3)*0.5f; float x34 = (x3+x4)*0.5f, y34 = (y3+y4)*0.5f; float x123 = (x12+x23)*0.5f, y123 = (y12+y23)*0.5f; float x234 = (x23+x34)*0.5f, y234 = (y23+y34)*0.5f; float x1234 = (x123+x234)*0.5f, y1234 = (y123+y234)*0.5f; BezierClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1); BezierClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1); } } // tess_tol is generally the same value you would find in ImGui::GetStyle().CurveTessellationTol // Because those ImXXX functions are lower-level than ImGui:: we cannot access this value automatically. ImVec2 ImBezierClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float tess_tol) { IM_ASSERT(tess_tol > 0.0f); ImVec2 p_last = p1; ImVec2 p_closest; float p_closest_dist2 = FLT_MAX; BezierClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, tess_tol, 0); return p_closest; } ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p) { ImVec2 ap = p - a; ImVec2 ab_dir = b - a; float dot = ap.x * ab_dir.x + ap.y * ab_dir.y; if (dot < 0.0f) return a; float ab_len_sqr = ab_dir.x * ab_dir.x + ab_dir.y * ab_dir.y; if (dot > ab_len_sqr) return b; return a + ab_dir * dot / ab_len_sqr; } bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p) { bool b1 = ((p.x - b.x) * (a.y - b.y) - (p.y - b.y) * (a.x - b.x)) < 0.0f; bool b2 = ((p.x - c.x) * (b.y - c.y) - (p.y - c.y) * (b.x - c.x)) < 0.0f; bool b3 = ((p.x - a.x) * (c.y - a.y) - (p.y - a.y) * (c.x - a.x)) < 0.0f; return ((b1 == b2) && (b2 == b3)); } void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w) { ImVec2 v0 = b - a; ImVec2 v1 = c - a; ImVec2 v2 = p - a; const float denom = v0.x * v1.y - v1.x * v0.y; out_v = (v2.x * v1.y - v1.x * v2.y) / denom; out_w = (v0.x * v2.y - v2.x * v0.y) / denom; out_u = 1.0f - out_v - out_w; } ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p) { ImVec2 proj_ab = ImLineClosestPoint(a, b, p); ImVec2 proj_bc = ImLineClosestPoint(b, c, p); ImVec2 proj_ca = ImLineClosestPoint(c, a, p); float dist2_ab = ImLengthSqr(p - proj_ab); float dist2_bc = ImLengthSqr(p - proj_bc); float dist2_ca = ImLengthSqr(p - proj_ca); float m = ImMin(dist2_ab, ImMin(dist2_bc, dist2_ca)); if (m == dist2_ab) return proj_ab; if (m == dist2_bc) return proj_bc; return proj_ca; } //----------------------------------------------------------------------------- // [SECTION] MISC HELPERS/UTILITIES (String, Format, Hash functions) //----------------------------------------------------------------------------- // Consider using _stricmp/_strnicmp under Windows or strcasecmp/strncasecmp. We don't actually use either ImStricmp/ImStrnicmp in the codebase any more. int ImStricmp(const char* str1, const char* str2) { int d; while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; } return d; } int ImStrnicmp(const char* str1, const char* str2, size_t count) { int d = 0; while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; } return d; } void ImStrncpy(char* dst, const char* src, size_t count) { if (count < 1) return; if (count > 1) strncpy(dst, src, count - 1); dst[count - 1] = 0; } char* ImStrdup(const char* str) { size_t len = strlen(str); void* buf = IM_ALLOC(len + 1); return (char*)memcpy(buf, (const void*)str, len + 1); } char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* src) { size_t dst_buf_size = p_dst_size ? *p_dst_size : strlen(dst) + 1; size_t src_size = strlen(src) + 1; if (dst_buf_size < src_size) { IM_FREE(dst); dst = (char*)IM_ALLOC(src_size); if (p_dst_size) *p_dst_size = src_size; } return (char*)memcpy(dst, (const void*)src, src_size); } const char* ImStrchrRange(const char* str, const char* str_end, char c) { const char* p = (const char*)memchr(str, (int)c, str_end - str); return p; } int ImStrlenW(const ImWchar* str) { //return (int)wcslen((const wchar_t*)str); // FIXME-OPT: Could use this when wchar_t are 16-bit int n = 0; while (*str++) n++; return n; } // Find end-of-line. Return pointer will point to either first \n, either str_end. const char* ImStreolRange(const char* str, const char* str_end) { const char* p = (const char*)memchr(str, '\n', str_end - str); return p ? p : str_end; } const ImWchar* ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin) // find beginning-of-line { while (buf_mid_line > buf_begin && buf_mid_line[-1] != '\n') buf_mid_line--; return buf_mid_line; } const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end) { if (!needle_end) needle_end = needle + strlen(needle); const char un0 = (char)toupper(*needle); while ((!haystack_end && *haystack) || (haystack_end && haystack < haystack_end)) { if (toupper(*haystack) == un0) { const char* b = needle + 1; for (const char* a = haystack + 1; b < needle_end; a++, b++) if (toupper(*a) != toupper(*b)) break; if (b == needle_end) return haystack; } haystack++; } return NULL; } // Trim str by offsetting contents when there's leading data + writing a \0 at the trailing position. We use this in situation where the cost is negligible. void ImStrTrimBlanks(char* buf) { char* p = buf; while (p[0] == ' ' || p[0] == '\t') // Leading blanks p++; char* p_start = p; while (*p != 0) // Find end of string p++; while (p > p_start && (p[-1] == ' ' || p[-1] == '\t')) // Trailing blanks p--; if (p_start != buf) // Copy memory if we had leading blanks memmove(buf, p_start, p - p_start); buf[p - p_start] = 0; // Zero terminate } const char* ImStrSkipBlank(const char* str) { while (str[0] == ' ' || str[0] == '\t') str++; return str; } // A) MSVC version appears to return -1 on overflow, whereas glibc appears to return total count (which may be >= buf_size). // Ideally we would test for only one of those limits at runtime depending on the behavior the vsnprintf(), but trying to deduct it at compile time sounds like a pandora can of worm. // B) When buf==NULL vsnprintf() will return the output size. #ifndef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // We support stb_sprintf which is much faster (see: https://github.com/nothings/stb/blob/master/stb_sprintf.h) // You may set IMGUI_USE_STB_SPRINTF to use our default wrapper, or set IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // and setup the wrapper yourself. (FIXME-OPT: Some of our high-level operations such as ImGuiTextBuffer::appendfv() are // designed using two-passes worst case, which probably could be improved using the stbsp_vsprintfcb() function.) #ifdef IMGUI_USE_STB_SPRINTF #define STB_SPRINTF_IMPLEMENTATION #include "stb_sprintf.h" #endif #if defined(_MSC_VER) && !defined(vsnprintf) #define vsnprintf _vsnprintf #endif int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) { va_list args; va_start(args, fmt); #ifdef IMGUI_USE_STB_SPRINTF int w = stbsp_vsnprintf(buf, (int)buf_size, fmt, args); #else int w = vsnprintf(buf, buf_size, fmt, args); #endif va_end(args); if (buf == NULL) return w; if (w == -1 || w >= (int)buf_size) w = (int)buf_size - 1; buf[w] = 0; return w; } int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) { #ifdef IMGUI_USE_STB_SPRINTF int w = stbsp_vsnprintf(buf, (int)buf_size, fmt, args); #else int w = vsnprintf(buf, buf_size, fmt, args); #endif if (buf == NULL) return w; if (w == -1 || w >= (int)buf_size) w = (int)buf_size - 1; buf[w] = 0; return w; } #endif // #ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // CRC32 needs a 1KB lookup table (not cache friendly) // Although the code to generate the table is simple and shorter than the table itself, using a const table allows us to easily: // - avoid an unnecessary branch/memory tap, - keep the ImHashXXX functions usable by static constructors, - make it thread-safe. static const ImU32 GCrc32LookupTable[256] = { 0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,0xE963A535,0x9E6495A3,0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988,0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91, 0x1DB71064,0x6AB020F2,0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7,0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9,0xFA0F3D63,0x8D080DF5, 0x3B6E20C8,0x4C69105E,0xD56041E4,0xA2677172,0x3C03E4D1,0x4B04D447,0xD20D85FD,0xA50AB56B,0x35B5A8FA,0x42B2986C,0xDBBBC9D6,0xACBCF940,0x32D86CE3,0x45DF5C75,0xDCD60DCF,0xABD13D59, 0x26D930AC,0x51DE003A,0xC8D75180,0xBFD06116,0x21B4F4B5,0x56B3C423,0xCFBA9599,0xB8BDA50F,0x2802B89E,0x5F058808,0xC60CD9B2,0xB10BE924,0x2F6F7C87,0x58684C11,0xC1611DAB,0xB6662D3D, 0x76DC4190,0x01DB7106,0x98D220BC,0xEFD5102A,0x71B18589,0x06B6B51F,0x9FBFE4A5,0xE8B8D433,0x7807C9A2,0x0F00F934,0x9609A88E,0xE10E9818,0x7F6A0DBB,0x086D3D2D,0x91646C97,0xE6635C01, 0x6B6B51F4,0x1C6C6162,0x856530D8,0xF262004E,0x6C0695ED,0x1B01A57B,0x8208F4C1,0xF50FC457,0x65B0D9C6,0x12B7E950,0x8BBEB8EA,0xFCB9887C,0x62DD1DDF,0x15DA2D49,0x8CD37CF3,0xFBD44C65, 0x4DB26158,0x3AB551CE,0xA3BC0074,0xD4BB30E2,0x4ADFA541,0x3DD895D7,0xA4D1C46D,0xD3D6F4FB,0x4369E96A,0x346ED9FC,0xAD678846,0xDA60B8D0,0x44042D73,0x33031DE5,0xAA0A4C5F,0xDD0D7CC9, 0x5005713C,0x270241AA,0xBE0B1010,0xC90C2086,0x5768B525,0x206F85B3,0xB966D409,0xCE61E49F,0x5EDEF90E,0x29D9C998,0xB0D09822,0xC7D7A8B4,0x59B33D17,0x2EB40D81,0xB7BD5C3B,0xC0BA6CAD, 0xEDB88320,0x9ABFB3B6,0x03B6E20C,0x74B1D29A,0xEAD54739,0x9DD277AF,0x04DB2615,0x73DC1683,0xE3630B12,0x94643B84,0x0D6D6A3E,0x7A6A5AA8,0xE40ECF0B,0x9309FF9D,0x0A00AE27,0x7D079EB1, 0xF00F9344,0x8708A3D2,0x1E01F268,0x6906C2FE,0xF762575D,0x806567CB,0x196C3671,0x6E6B06E7,0xFED41B76,0x89D32BE0,0x10DA7A5A,0x67DD4ACC,0xF9B9DF6F,0x8EBEEFF9,0x17B7BE43,0x60B08ED5, 0xD6D6A3E8,0xA1D1937E,0x38D8C2C4,0x4FDFF252,0xD1BB67F1,0xA6BC5767,0x3FB506DD,0x48B2364B,0xD80D2BDA,0xAF0A1B4C,0x36034AF6,0x41047A60,0xDF60EFC3,0xA867DF55,0x316E8EEF,0x4669BE79, 0xCB61B38C,0xBC66831A,0x256FD2A0,0x5268E236,0xCC0C7795,0xBB0B4703,0x220216B9,0x5505262F,0xC5BA3BBE,0xB2BD0B28,0x2BB45A92,0x5CB36A04,0xC2D7FFA7,0xB5D0CF31,0x2CD99E8B,0x5BDEAE1D, 0x9B64C2B0,0xEC63F226,0x756AA39C,0x026D930A,0x9C0906A9,0xEB0E363F,0x72076785,0x05005713,0x95BF4A82,0xE2B87A14,0x7BB12BAE,0x0CB61B38,0x92D28E9B,0xE5D5BE0D,0x7CDCEFB7,0x0BDBDF21, 0x86D3D2D4,0xF1D4E242,0x68DDB3F8,0x1FDA836E,0x81BE16CD,0xF6B9265B,0x6FB077E1,0x18B74777,0x88085AE6,0xFF0F6A70,0x66063BCA,0x11010B5C,0x8F659EFF,0xF862AE69,0x616BFFD3,0x166CCF45, 0xA00AE278,0xD70DD2EE,0x4E048354,0x3903B3C2,0xA7672661,0xD06016F7,0x4969474D,0x3E6E77DB,0xAED16A4A,0xD9D65ADC,0x40DF0B66,0x37D83BF0,0xA9BCAE53,0xDEBB9EC5,0x47B2CF7F,0x30B5FFE9, 0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,0xCDD70693,0x54DE5729,0x23D967BF,0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94,0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D, }; // Known size hash // It is ok to call ImHashData on a string with known length but the ### operator won't be supported. // FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements. ImU32 ImHashData(const void* data_p, size_t data_size, ImU32 seed) { ImU32 crc = ~seed; const unsigned char* data = (const unsigned char*)data_p; const ImU32* crc32_lut = GCrc32LookupTable; while (data_size-- != 0) crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *data++]; return ~crc; } // Zero-terminated string hash, with support for ### to reset back to seed value // We support a syntax of "label###id" where only "###id" is included in the hash, and only "label" gets displayed. // Because this syntax is rarely used we are optimizing for the common case. // - If we reach ### in the string we discard the hash so far and reset to the seed. // - We don't do 'current += 2; continue;' after handling ### to keep the code smaller/faster (measured ~10% diff in Debug build) // FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements. ImU32 ImHashStr(const char* data_p, size_t data_size, ImU32 seed) { seed = ~seed; ImU32 crc = seed; const unsigned char* data = (const unsigned char*)data_p; const ImU32* crc32_lut = GCrc32LookupTable; if (data_size != 0) { while (data_size-- != 0) { unsigned char c = *data++; if (c == '#' && data_size >= 2 && data[0] == '#' && data[1] == '#') crc = seed; crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c]; } } else { while (unsigned char c = *data++) { if (c == '#' && data[0] == '#' && data[1] == '#') crc = seed; crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c]; } } return ~crc; } //----------------------------------------------------------------------------- // [SECTION] MISC HELPERS/UTILITIES (File functions) //----------------------------------------------------------------------------- // Default file functions #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS ImFileHandle ImFileOpen(const char* filename, const char* mode) { #if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(__CYGWIN__) && !defined(__GNUC__) // We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames. const int filename_wsize = ImTextCountCharsFromUtf8(filename, NULL) + 1; const int mode_wsize = ImTextCountCharsFromUtf8(mode, NULL) + 1; ImVector buf; buf.resize(filename_wsize + mode_wsize); ImTextStrFromUtf8(&buf[0], filename_wsize, filename, NULL); ImTextStrFromUtf8(&buf[filename_wsize], mode_wsize, mode, NULL); return _wfopen((wchar_t*)&buf[0], (wchar_t*)&buf[filename_wsize]); #else return fopen(filename, mode); #endif } // We should in theory be using fseeko()/ftello() with off_t and _fseeki64()/_ftelli64() with __int64, waiting for the PR that does that in a very portable pre-C++11 zero-warnings way. bool ImFileClose(ImFileHandle f) { return fclose(f) == 0; } ImU64 ImFileGetSize(ImFileHandle f) { long off = 0, sz = 0; return ((off = ftell(f)) != -1 && !fseek(f, 0, SEEK_END) && (sz = ftell(f)) != -1 && !fseek(f, off, SEEK_SET)) ? (ImU64)sz : (ImU64)-1; } ImU64 ImFileRead(void* data, ImU64 sz, ImU64 count, ImFileHandle f) { return fread(data, (size_t)sz, (size_t)count, f); } ImU64 ImFileWrite(const void* data, ImU64 sz, ImU64 count, ImFileHandle f) { return fwrite(data, (size_t)sz, (size_t)count, f); } #endif // #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Helper: Load file content into memory // Memory allocated with IM_ALLOC(), must be freed by user using IM_FREE() == ImGui::MemFree() void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size, int padding_bytes) { IM_ASSERT(filename && mode); if (out_file_size) *out_file_size = 0; ImFileHandle f; if ((f = ImFileOpen(filename, mode)) == NULL) return NULL; size_t file_size = (size_t)ImFileGetSize(f); if (file_size == (size_t)-1) { ImFileClose(f); return NULL; } void* file_data = IM_ALLOC(file_size + padding_bytes); if (file_data == NULL) { ImFileClose(f); return NULL; } if (ImFileRead(file_data, 1, file_size, f) != file_size) { ImFileClose(f); IM_FREE(file_data); return NULL; } if (padding_bytes > 0) memset((void*)(((char*)file_data) + file_size), 0, (size_t)padding_bytes); ImFileClose(f); if (out_file_size) *out_file_size = file_size; return file_data; } //----------------------------------------------------------------------------- // [SECTION] MISC HELPERS/UTILITIES (ImText* functions) //----------------------------------------------------------------------------- // Convert UTF-8 to 32-bit character, process single character input. // Based on stb_from_utf8() from github.com/nothings/stb/ // We handle UTF-8 decoding error by skipping forward. int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end) { unsigned int c = (unsigned int)-1; const unsigned char* str = (const unsigned char*)in_text; if (!(*str & 0x80)) { c = (unsigned int)(*str++); *out_char = c; return 1; } if ((*str & 0xe0) == 0xc0) { *out_char = IM_UNICODE_CODEPOINT_INVALID; // will be invalid but not end of string if (in_text_end && in_text_end - (const char*)str < 2) return 1; if (*str < 0xc2) return 2; c = (unsigned int)((*str++ & 0x1f) << 6); if ((*str & 0xc0) != 0x80) return 2; c += (*str++ & 0x3f); *out_char = c; return 2; } if ((*str & 0xf0) == 0xe0) { *out_char = IM_UNICODE_CODEPOINT_INVALID; // will be invalid but not end of string if (in_text_end && in_text_end - (const char*)str < 3) return 1; if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return 3; if (*str == 0xed && str[1] > 0x9f) return 3; // str[1] < 0x80 is checked below c = (unsigned int)((*str++ & 0x0f) << 12); if ((*str & 0xc0) != 0x80) return 3; c += (unsigned int)((*str++ & 0x3f) << 6); if ((*str & 0xc0) != 0x80) return 3; c += (*str++ & 0x3f); *out_char = c; return 3; } if ((*str & 0xf8) == 0xf0) { *out_char = IM_UNICODE_CODEPOINT_INVALID; // will be invalid but not end of string if (in_text_end && in_text_end - (const char*)str < 4) return 1; if (*str > 0xf4) return 4; if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return 4; if (*str == 0xf4 && str[1] > 0x8f) return 4; // str[1] < 0x80 is checked below c = (unsigned int)((*str++ & 0x07) << 18); if ((*str & 0xc0) != 0x80) return 4; c += (unsigned int)((*str++ & 0x3f) << 12); if ((*str & 0xc0) != 0x80) return 4; c += (unsigned int)((*str++ & 0x3f) << 6); if ((*str & 0xc0) != 0x80) return 4; c += (*str++ & 0x3f); // utf-8 encodings of values used in surrogate pairs are invalid if ((c & 0xFFFFF800) == 0xD800) return 4; *out_char = c; return 4; } *out_char = 0; return 0; } int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_text_remaining) { ImWchar* buf_out = buf; ImWchar* buf_end = buf + buf_size; while (buf_out < buf_end-1 && (!in_text_end || in_text < in_text_end) && *in_text) { unsigned int c; in_text += ImTextCharFromUtf8(&c, in_text, in_text_end); if (c == 0) break; if (c <= IM_UNICODE_CODEPOINT_MAX) // FIXME: Losing characters that don't fit in 2 bytes *buf_out++ = (ImWchar)c; } *buf_out = 0; if (in_text_remaining) *in_text_remaining = in_text; return (int)(buf_out - buf); } int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end) { int char_count = 0; while ((!in_text_end || in_text < in_text_end) && *in_text) { unsigned int c; in_text += ImTextCharFromUtf8(&c, in_text, in_text_end); if (c == 0) break; if (c <= IM_UNICODE_CODEPOINT_MAX) char_count++; } return char_count; } // Based on stb_to_utf8() from github.com/nothings/stb/ static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c) { if (c < 0x80) { buf[0] = (char)c; return 1; } if (c < 0x800) { if (buf_size < 2) return 0; buf[0] = (char)(0xc0 + (c >> 6)); buf[1] = (char)(0x80 + (c & 0x3f)); return 2; } if (c >= 0xdc00 && c < 0xe000) { return 0; } if (c >= 0xd800 && c < 0xdc00) { if (buf_size < 4) return 0; buf[0] = (char)(0xf0 + (c >> 18)); buf[1] = (char)(0x80 + ((c >> 12) & 0x3f)); buf[2] = (char)(0x80 + ((c >> 6) & 0x3f)); buf[3] = (char)(0x80 + ((c ) & 0x3f)); return 4; } //else if (c < 0x10000) { if (buf_size < 3) return 0; buf[0] = (char)(0xe0 + (c >> 12)); buf[1] = (char)(0x80 + ((c>> 6) & 0x3f)); buf[2] = (char)(0x80 + ((c ) & 0x3f)); return 3; } } // Not optimal but we very rarely use this function. int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end) { unsigned int dummy = 0; return ImTextCharFromUtf8(&dummy, in_text, in_text_end); } static inline int ImTextCountUtf8BytesFromChar(unsigned int c) { if (c < 0x80) return 1; if (c < 0x800) return 2; if (c >= 0xdc00 && c < 0xe000) return 0; if (c >= 0xd800 && c < 0xdc00) return 4; return 3; } int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end) { char* buf_out = buf; const char* buf_end = buf + buf_size; while (buf_out < buf_end-1 && (!in_text_end || in_text < in_text_end) && *in_text) { unsigned int c = (unsigned int)(*in_text++); if (c < 0x80) *buf_out++ = (char)c; else buf_out += ImTextCharToUtf8(buf_out, (int)(buf_end-buf_out-1), c); } *buf_out = 0; return (int)(buf_out - buf); } int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end) { int bytes_count = 0; while ((!in_text_end || in_text < in_text_end) && *in_text) { unsigned int c = (unsigned int)(*in_text++); if (c < 0x80) bytes_count++; else bytes_count += ImTextCountUtf8BytesFromChar(c); } return bytes_count; } //----------------------------------------------------------------------------- // [SECTION] MISC HELPERS/UTILTIES (Color functions) // Note: The Convert functions are early design which are not consistent with other API. //----------------------------------------------------------------------------- ImVec4 ImGui::ColorConvertU32ToFloat4(ImU32 in) { float s = 1.0f/255.0f; return ImVec4( ((in >> IM_COL32_R_SHIFT) & 0xFF) * s, ((in >> IM_COL32_G_SHIFT) & 0xFF) * s, ((in >> IM_COL32_B_SHIFT) & 0xFF) * s, ((in >> IM_COL32_A_SHIFT) & 0xFF) * s); } ImU32 ImGui::ColorConvertFloat4ToU32(const ImVec4& in) { ImU32 out; out = ((ImU32)IM_F32_TO_INT8_SAT(in.x)) << IM_COL32_R_SHIFT; out |= ((ImU32)IM_F32_TO_INT8_SAT(in.y)) << IM_COL32_G_SHIFT; out |= ((ImU32)IM_F32_TO_INT8_SAT(in.z)) << IM_COL32_B_SHIFT; out |= ((ImU32)IM_F32_TO_INT8_SAT(in.w)) << IM_COL32_A_SHIFT; return out; } // Convert rgb floats ([0-1],[0-1],[0-1]) to hsv floats ([0-1],[0-1],[0-1]), from Foley & van Dam p592 // Optimized http://lolengine.net/blog/2013/01/13/fast-rgb-to-hsv void ImGui::ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v) { float K = 0.f; if (g < b) { ImSwap(g, b); K = -1.f; } if (r < g) { ImSwap(r, g); K = -2.f / 6.f - K; } const float chroma = r - (g < b ? g : b); out_h = ImFabs(K + (g - b) / (6.f * chroma + 1e-20f)); out_s = chroma / (r + 1e-20f); out_v = r; } // Convert hsv floats ([0-1],[0-1],[0-1]) to rgb floats ([0-1],[0-1],[0-1]), from Foley & van Dam p593 // also http://en.wikipedia.org/wiki/HSL_and_HSV void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b) { if (s == 0.0f) { // gray out_r = out_g = out_b = v; return; } h = ImFmod(h, 1.0f) / (60.0f/360.0f); int i = (int)h; float f = h - (float)i; float p = v * (1.0f - s); float q = v * (1.0f - s * f); float t = v * (1.0f - s * (1.0f - f)); switch (i) { case 0: out_r = v; out_g = t; out_b = p; break; case 1: out_r = q; out_g = v; out_b = p; break; case 2: out_r = p; out_g = v; out_b = t; break; case 3: out_r = p; out_g = q; out_b = v; break; case 4: out_r = t; out_g = p; out_b = v; break; case 5: default: out_r = v; out_g = p; out_b = q; break; } } //----------------------------------------------------------------------------- // [SECTION] ImGuiStorage // Helper: Key->value storage //----------------------------------------------------------------------------- // std::lower_bound but without the bullshit static ImGuiStorage::ImGuiStoragePair* LowerBound(ImVector& data, ImGuiID key) { ImGuiStorage::ImGuiStoragePair* first = data.Data; ImGuiStorage::ImGuiStoragePair* last = data.Data + data.Size; size_t count = (size_t)(last - first); while (count > 0) { size_t count2 = count >> 1; ImGuiStorage::ImGuiStoragePair* mid = first + count2; if (mid->key < key) { first = ++mid; count -= count2 + 1; } else { count = count2; } } return first; } // For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once. void ImGuiStorage::BuildSortByKey() { struct StaticFunc { static int IMGUI_CDECL PairCompareByID(const void* lhs, const void* rhs) { // We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that. if (((const ImGuiStoragePair*)lhs)->key > ((const ImGuiStoragePair*)rhs)->key) return +1; if (((const ImGuiStoragePair*)lhs)->key < ((const ImGuiStoragePair*)rhs)->key) return -1; return 0; } }; if (Data.Size > 1) ImQsort(Data.Data, (size_t)Data.Size, sizeof(ImGuiStoragePair), StaticFunc::PairCompareByID); } int ImGuiStorage::GetInt(ImGuiID key, int default_val) const { ImGuiStoragePair* it = LowerBound(const_cast&>(Data), key); if (it == Data.end() || it->key != key) return default_val; return it->val_i; } bool ImGuiStorage::GetBool(ImGuiID key, bool default_val) const { return GetInt(key, default_val ? 1 : 0) != 0; } float ImGuiStorage::GetFloat(ImGuiID key, float default_val) const { ImGuiStoragePair* it = LowerBound(const_cast&>(Data), key); if (it == Data.end() || it->key != key) return default_val; return it->val_f; } void* ImGuiStorage::GetVoidPtr(ImGuiID key) const { ImGuiStoragePair* it = LowerBound(const_cast&>(Data), key); if (it == Data.end() || it->key != key) return NULL; return it->val_p; } // References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer. int* ImGuiStorage::GetIntRef(ImGuiID key, int default_val) { ImGuiStoragePair* it = LowerBound(Data, key); if (it == Data.end() || it->key != key) it = Data.insert(it, ImGuiStoragePair(key, default_val)); return &it->val_i; } bool* ImGuiStorage::GetBoolRef(ImGuiID key, bool default_val) { return (bool*)GetIntRef(key, default_val ? 1 : 0); } float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val) { ImGuiStoragePair* it = LowerBound(Data, key); if (it == Data.end() || it->key != key) it = Data.insert(it, ImGuiStoragePair(key, default_val)); return &it->val_f; } void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val) { ImGuiStoragePair* it = LowerBound(Data, key); if (it == Data.end() || it->key != key) it = Data.insert(it, ImGuiStoragePair(key, default_val)); return &it->val_p; } // FIXME-OPT: Need a way to reuse the result of lower_bound when doing GetInt()/SetInt() - not too bad because it only happens on explicit interaction (maximum one a frame) void ImGuiStorage::SetInt(ImGuiID key, int val) { ImGuiStoragePair* it = LowerBound(Data, key); if (it == Data.end() || it->key != key) { Data.insert(it, ImGuiStoragePair(key, val)); return; } it->val_i = val; } void ImGuiStorage::SetBool(ImGuiID key, bool val) { SetInt(key, val ? 1 : 0); } void ImGuiStorage::SetFloat(ImGuiID key, float val) { ImGuiStoragePair* it = LowerBound(Data, key); if (it == Data.end() || it->key != key) { Data.insert(it, ImGuiStoragePair(key, val)); return; } it->val_f = val; } void ImGuiStorage::SetVoidPtr(ImGuiID key, void* val) { ImGuiStoragePair* it = LowerBound(Data, key); if (it == Data.end() || it->key != key) { Data.insert(it, ImGuiStoragePair(key, val)); return; } it->val_p = val; } void ImGuiStorage::SetAllInt(int v) { for (int i = 0; i < Data.Size; i++) Data[i].val_i = v; } //----------------------------------------------------------------------------- // [SECTION] ImGuiTextFilter //----------------------------------------------------------------------------- // Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]" ImGuiTextFilter::ImGuiTextFilter(const char* default_filter) { if (default_filter) { ImStrncpy(InputBuf, default_filter, IM_ARRAYSIZE(InputBuf)); Build(); } else { InputBuf[0] = 0; CountGrep = 0; } } bool ImGuiTextFilter::Draw(const char* label, float width) { if (width != 0.0f) ImGui::SetNextItemWidth(width); bool value_changed = ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf)); if (value_changed) Build(); return value_changed; } void ImGuiTextFilter::ImGuiTextRange::split(char separator, ImVector* out) const { out->resize(0); const char* wb = b; const char* we = wb; while (we < e) { if (*we == separator) { out->push_back(ImGuiTextRange(wb, we)); wb = we + 1; } we++; } if (wb != we) out->push_back(ImGuiTextRange(wb, we)); } void ImGuiTextFilter::Build() { Filters.resize(0); ImGuiTextRange input_range(InputBuf, InputBuf+strlen(InputBuf)); input_range.split(',', &Filters); CountGrep = 0; for (int i = 0; i != Filters.Size; i++) { ImGuiTextRange& f = Filters[i]; while (f.b < f.e && ImCharIsBlankA(f.b[0])) f.b++; while (f.e > f.b && ImCharIsBlankA(f.e[-1])) f.e--; if (f.empty()) continue; if (Filters[i].b[0] != '-') CountGrep += 1; } } bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const { if (Filters.empty()) return true; if (text == NULL) text = ""; for (int i = 0; i != Filters.Size; i++) { const ImGuiTextRange& f = Filters[i]; if (f.empty()) continue; if (f.b[0] == '-') { // Subtract if (ImStristr(text, text_end, f.b + 1, f.e) != NULL) return false; } else { // Grep if (ImStristr(text, text_end, f.b, f.e) != NULL) return true; } } // Implicit * grep if (CountGrep == 0) return true; return false; } //----------------------------------------------------------------------------- // [SECTION] ImGuiTextBuffer //----------------------------------------------------------------------------- // On some platform vsnprintf() takes va_list by reference and modifies it. // va_copy is the 'correct' way to copy a va_list but Visual Studio prior to 2013 doesn't have it. #ifndef va_copy #if defined(__GNUC__) || defined(__clang__) #define va_copy(dest, src) __builtin_va_copy(dest, src) #else #define va_copy(dest, src) (dest = src) #endif #endif char ImGuiTextBuffer::EmptyString[1] = { 0 }; void ImGuiTextBuffer::append(const char* str, const char* str_end) { int len = str_end ? (int)(str_end - str) : (int)strlen(str); // Add zero-terminator the first time const int write_off = (Buf.Size != 0) ? Buf.Size : 1; const int needed_sz = write_off + len; if (write_off + len >= Buf.Capacity) { int new_capacity = Buf.Capacity * 2; Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity); } Buf.resize(needed_sz); memcpy(&Buf[write_off - 1], str, (size_t)len); Buf[write_off - 1 + len] = 0; } void ImGuiTextBuffer::appendf(const char* fmt, ...) { va_list args; va_start(args, fmt); appendfv(fmt, args); va_end(args); } // Helper: Text buffer for logging/accumulating text void ImGuiTextBuffer::appendfv(const char* fmt, va_list args) { va_list args_copy; va_copy(args_copy, args); int len = ImFormatStringV(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass. if (len <= 0) { va_end(args_copy); return; } // Add zero-terminator the first time const int write_off = (Buf.Size != 0) ? Buf.Size : 1; const int needed_sz = write_off + len; if (write_off + len >= Buf.Capacity) { int new_capacity = Buf.Capacity * 2; Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity); } Buf.resize(needed_sz); ImFormatStringV(&Buf[write_off - 1], (size_t)len + 1, fmt, args_copy); va_end(args_copy); } //----------------------------------------------------------------------------- // [SECTION] ImGuiListClipper // This is currently not as flexible/powerful as it should be and really confusing/spaghetti, mostly because we changed // the API mid-way through development and support two ways to using the clipper, needs some rework (see TODO) //----------------------------------------------------------------------------- // Helper to calculate coarse clipping of large list of evenly sized items. // NB: Prefer using the ImGuiListClipper higher-level helper if you can! Read comments and instructions there on how those use this sort of pattern. // NB: 'items_count' is only used to clamp the result, if you don't know your count you can use INT_MAX void ImGui::CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (g.LogEnabled) { // If logging is active, do not perform any clipping *out_items_display_start = 0; *out_items_display_end = items_count; return; } if (window->SkipItems) { *out_items_display_start = *out_items_display_end = 0; return; } // We create the union of the ClipRect and the NavScoringRect which at worst should be 1 page away from ClipRect ImRect unclipped_rect = window->ClipRect; if (g.NavMoveRequest) unclipped_rect.Add(g.NavScoringRectScreen); const ImVec2 pos = window->DC.CursorPos; int start = (int)((unclipped_rect.Min.y - pos.y) / items_height); int end = (int)((unclipped_rect.Max.y - pos.y) / items_height); // When performing a navigation request, ensure we have one item extra in the direction we are moving to if (g.NavMoveRequest && g.NavMoveClipDir == ImGuiDir_Up) start--; if (g.NavMoveRequest && g.NavMoveClipDir == ImGuiDir_Down) end++; start = ImClamp(start, 0, items_count); end = ImClamp(end + 1, start, items_count); *out_items_display_start = start; *out_items_display_end = end; } static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height) { // Set cursor position and a few other things so that SetScrollHereY() and Columns() can work when seeking cursor. // FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue. // The clipper should probably have a 4th step to display the last item in a regular manner. ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; window->DC.CursorPos.y = pos_y; window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, pos_y); window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHereY() can properly function after the end of our clipper usage. window->DC.PrevLineSize.y = (line_height - g.Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list. if (ImGuiColumns* columns = window->DC.CurrentColumns) columns->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly } // Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1 // Use case B: Begin() called from constructor with items_height>0 // FIXME-LEGACY: Ideally we should remove the Begin/End functions but they are part of the legacy API we still support. This is why some of the code in Step() calling Begin() and reassign some fields, spaghetti style. void ImGuiListClipper::Begin(int count, float items_height) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; StartPosY = window->DC.CursorPos.y; ItemsHeight = items_height; ItemsCount = count; StepNo = 0; DisplayEnd = DisplayStart = -1; if (ItemsHeight > 0.0f) { ImGui::CalcListClipping(ItemsCount, ItemsHeight, &DisplayStart, &DisplayEnd); // calculate how many to clip/display if (DisplayStart > 0) SetCursorPosYAndSetupDummyPrevLine(StartPosY + DisplayStart * ItemsHeight, ItemsHeight); // advance cursor StepNo = 2; } } void ImGuiListClipper::End() { if (ItemsCount < 0) return; // In theory here we should assert that ImGui::GetCursorPosY() == StartPosY + DisplayEnd * ItemsHeight, but it feels saner to just seek at the end and not assert/crash the user. if (ItemsCount < INT_MAX) SetCursorPosYAndSetupDummyPrevLine(StartPosY + ItemsCount * ItemsHeight, ItemsHeight); // advance cursor ItemsCount = -1; StepNo = 3; } bool ImGuiListClipper::Step() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (ItemsCount == 0 || window->SkipItems) { ItemsCount = -1; return false; } if (StepNo == 0) // Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height. { DisplayStart = 0; DisplayEnd = 1; StartPosY = window->DC.CursorPos.y; StepNo = 1; return true; } if (StepNo == 1) // Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element. { if (ItemsCount == 1) { ItemsCount = -1; return false; } float items_height = window->DC.CursorPos.y - StartPosY; IM_ASSERT(items_height > 0.0f); // If this triggers, it means Item 0 hasn't moved the cursor vertically Begin(ItemsCount - 1, items_height); DisplayStart++; DisplayEnd++; StepNo = 3; return true; } if (StepNo == 2) // Step 2: dummy step only required if an explicit items_height was passed to constructor or Begin() and user still call Step(). Does nothing and switch to Step 3. { IM_ASSERT(DisplayStart >= 0 && DisplayEnd >= 0); StepNo = 3; return true; } if (StepNo == 3) // Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), advance the cursor to the end of the list and then returns 'false' to end the loop. End(); return false; } //----------------------------------------------------------------------------- // [SECTION] RENDER HELPERS // Some of those (internal) functions are currently quite a legacy mess - their signature and behavior will change. // Also see imgui_draw.cpp for some more which have been reworked to not rely on ImGui:: state. //----------------------------------------------------------------------------- ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul) { ImGuiStyle& style = GImGui->Style; ImVec4 c = style.Colors[idx]; c.w *= style.Alpha * alpha_mul; return ColorConvertFloat4ToU32(c); } ImU32 ImGui::GetColorU32(const ImVec4& col) { ImGuiStyle& style = GImGui->Style; ImVec4 c = col; c.w *= style.Alpha; return ColorConvertFloat4ToU32(c); } const ImVec4& ImGui::GetStyleColorVec4(ImGuiCol idx) { ImGuiStyle& style = GImGui->Style; return style.Colors[idx]; } ImU32 ImGui::GetColorU32(ImU32 col) { ImGuiStyle& style = GImGui->Style; if (style.Alpha >= 1.0f) return col; ImU32 a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT; a = (ImU32)(a * style.Alpha); // We don't need to clamp 0..255 because Style.Alpha is in 0..1 range. return (col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT); } const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end) { const char* text_display_end = text; if (!text_end) text_end = (const char*)-1; while (text_display_end < text_end && *text_display_end != '\0' && (text_display_end[0] != '#' || text_display_end[1] != '#')) text_display_end++; return text_display_end; } // Internal ImGui functions to render text // RenderText***() functions calls ImDrawList::AddText() calls ImBitmapFont::RenderText() void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; // Hide anything after a '##' string const char* text_display_end; if (hide_text_after_hash) { text_display_end = FindRenderedTextEnd(text, text_end); } else { if (!text_end) text_end = text + strlen(text); // FIXME-OPT text_display_end = text_end; } if (text != text_display_end) { window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end); if (g.LogEnabled) LogRenderedText(&pos, text, text_display_end); } } void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (!text_end) text_end = text + strlen(text); // FIXME-OPT if (text != text_end) { window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_end, wrap_width); if (g.LogEnabled) LogRenderedText(&pos, text, text_end); } } // Default clip_rect uses (pos_min,pos_max) // Handle clipping on CPU immediately (vs typically let the GPU clip the triangles that are overlapping the clipping rectangle edges) void ImGui::RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_display_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect) { // Perform CPU side clipping for single clipped element to avoid using scissor state ImVec2 pos = pos_min; const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_display_end, false, 0.0f); const ImVec2* clip_min = clip_rect ? &clip_rect->Min : &pos_min; const ImVec2* clip_max = clip_rect ? &clip_rect->Max : &pos_max; bool need_clipping = (pos.x + text_size.x >= clip_max->x) || (pos.y + text_size.y >= clip_max->y); if (clip_rect) // If we had no explicit clipping rectangle then pos==clip_min need_clipping |= (pos.x < clip_min->x) || (pos.y < clip_min->y); // Align whole block. We should defer that to the better rendering function when we'll have support for individual line alignment. if (align.x > 0.0f) pos.x = ImMax(pos.x, pos.x + (pos_max.x - pos.x - text_size.x) * align.x); if (align.y > 0.0f) pos.y = ImMax(pos.y, pos.y + (pos_max.y - pos.y - text_size.y) * align.y); // Render if (need_clipping) { ImVec4 fine_clip_rect(clip_min->x, clip_min->y, clip_max->x, clip_max->y); draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, &fine_clip_rect); } else { draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, NULL); } } void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect) { // Hide anything after a '##' string const char* text_display_end = FindRenderedTextEnd(text, text_end); const int text_len = (int)(text_display_end - text); if (text_len == 0) return; ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; RenderTextClippedEx(window->DrawList, pos_min, pos_max, text, text_display_end, text_size_if_known, align, clip_rect); if (g.LogEnabled) LogRenderedText(&pos_min, text, text_display_end); } // Another overly complex function until we reorganize everything into a nice all-in-one helper. // This is made more complex because we have dissociated the layout rectangle (pos_min..pos_max) which define _where_ the ellipsis is, from actual clipping of text and limit of the ellipsis display. // This is because in the context of tabs we selectively hide part of the text when the Close Button appears, but we don't want the ellipsis to move. void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end_full, const ImVec2* text_size_if_known) { ImGuiContext& g = *GImGui; if (text_end_full == NULL) text_end_full = FindRenderedTextEnd(text); const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_end_full, false, 0.0f); //draw_list->AddLine(ImVec2(pos_max.x, pos_min.y - 4), ImVec2(pos_max.x, pos_max.y + 4), IM_COL32(0, 0, 255, 255)); //draw_list->AddLine(ImVec2(ellipsis_max_x, pos_min.y-2), ImVec2(ellipsis_max_x, pos_max.y+2), IM_COL32(0, 255, 0, 255)); //draw_list->AddLine(ImVec2(clip_max_x, pos_min.y), ImVec2(clip_max_x, pos_max.y), IM_COL32(255, 0, 0, 255)); // FIXME: We could technically remove (last_glyph->AdvanceX - last_glyph->X1) from text_size.x here and save a few pixels. if (text_size.x > pos_max.x - pos_min.x) { // Hello wo... // | | | // min max ellipsis_max // <-> this is generally some padding value const ImFont* font = draw_list->_Data->Font; const float font_size = draw_list->_Data->FontSize; const char* text_end_ellipsis = NULL; ImWchar ellipsis_char = font->EllipsisChar; int ellipsis_char_count = 1; if (ellipsis_char == (ImWchar)-1) { ellipsis_char = (ImWchar)'.'; ellipsis_char_count = 3; } const ImFontGlyph* glyph = font->FindGlyph(ellipsis_char); float ellipsis_glyph_width = glyph->X1; // Width of the glyph with no padding on either side float ellipsis_total_width = ellipsis_glyph_width; // Full width of entire ellipsis if (ellipsis_char_count > 1) { // Full ellipsis size without free spacing after it. const float spacing_between_dots = 1.0f * (draw_list->_Data->FontSize / font->FontSize); ellipsis_glyph_width = glyph->X1 - glyph->X0 + spacing_between_dots; ellipsis_total_width = ellipsis_glyph_width * (float)ellipsis_char_count - spacing_between_dots; } // We can now claim the space between pos_max.x and ellipsis_max.x const float text_avail_width = ImMax((ImMax(pos_max.x, ellipsis_max_x) - ellipsis_total_width) - pos_min.x, 1.0f); float text_size_clipped_x = font->CalcTextSizeA(font_size, text_avail_width, 0.0f, text, text_end_full, &text_end_ellipsis).x; if (text == text_end_ellipsis && text_end_ellipsis < text_end_full) { // Always display at least 1 character if there's no room for character + ellipsis text_end_ellipsis = text + ImTextCountUtf8BytesFromChar(text, text_end_full); text_size_clipped_x = font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text, text_end_ellipsis).x; } while (text_end_ellipsis > text && ImCharIsBlankA(text_end_ellipsis[-1])) { // Trim trailing space before ellipsis (FIXME: Supporting non-ascii blanks would be nice, for this we need a function to backtrack in UTF-8 text) text_end_ellipsis--; text_size_clipped_x -= font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text_end_ellipsis, text_end_ellipsis + 1).x; // Ascii blanks are always 1 byte } // Render text, render ellipsis RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, text_end_ellipsis, &text_size, ImVec2(0.0f, 0.0f)); float ellipsis_x = pos_min.x + text_size_clipped_x; if (ellipsis_x + ellipsis_total_width <= ellipsis_max_x) for (int i = 0; i < ellipsis_char_count; i++) { font->RenderChar(draw_list, font_size, ImVec2(ellipsis_x, pos_min.y), GetColorU32(ImGuiCol_Text), ellipsis_char); ellipsis_x += ellipsis_glyph_width; } } else { RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, text_end_full, &text_size, ImVec2(0.0f, 0.0f)); } if (g.LogEnabled) LogRenderedText(&pos_min, text, text_end_full); } // Render a rectangle shaped with optional rounding and borders void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border, float rounding) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; window->DrawList->AddRectFilled(p_min, p_max, fill_col, rounding); const float border_size = g.Style.FrameBorderSize; if (border && border_size > 0.0f) { window->DrawList->AddRect(p_min+ImVec2(1,1), p_max+ImVec2(1,1), GetColorU32(ImGuiCol_BorderShadow), rounding, ImDrawCornerFlags_All, border_size); window->DrawList->AddRect(p_min, p_max, GetColorU32(ImGuiCol_Border), rounding, ImDrawCornerFlags_All, border_size); } } void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; const float border_size = g.Style.FrameBorderSize; if (border_size > 0.0f) { window->DrawList->AddRect(p_min+ImVec2(1,1), p_max+ImVec2(1,1), GetColorU32(ImGuiCol_BorderShadow), rounding, ImDrawCornerFlags_All, border_size); window->DrawList->AddRect(p_min, p_max, GetColorU32(ImGuiCol_Border), rounding, ImDrawCornerFlags_All, border_size); } } // Render an arrow aimed to be aligned with text (p_min is a position in the same space text would be positioned). To e.g. denote expanded/collapsed state void ImGui::RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale) { const float h = draw_list->_Data->FontSize * 1.00f; float r = h * 0.40f * scale; ImVec2 center = pos + ImVec2(h * 0.50f, h * 0.50f * scale); ImVec2 a, b, c; switch (dir) { case ImGuiDir_Up: case ImGuiDir_Down: if (dir == ImGuiDir_Up) r = -r; a = ImVec2(+0.000f,+0.750f) * r; b = ImVec2(-0.866f,-0.750f) * r; c = ImVec2(+0.866f,-0.750f) * r; break; case ImGuiDir_Left: case ImGuiDir_Right: if (dir == ImGuiDir_Left) r = -r; a = ImVec2(+0.750f,+0.000f) * r; b = ImVec2(-0.750f,+0.866f) * r; c = ImVec2(-0.750f,-0.866f) * r; break; case ImGuiDir_None: case ImGuiDir_COUNT: IM_ASSERT(0); break; } draw_list->AddTriangleFilled(center + a, center + b, center + c, col); } void ImGui::RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col) { draw_list->AddCircleFilled(pos, draw_list->_Data->FontSize * 0.20f, col, 8); } void ImGui::RenderCheckMark(ImVec2 pos, ImU32 col, float sz) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; float thickness = ImMax(sz / 5.0f, 1.0f); sz -= thickness*0.5f; pos += ImVec2(thickness*0.25f, thickness*0.25f); float third = sz / 3.0f; float bx = pos.x + third; float by = pos.y + sz - third*0.5f; window->DrawList->PathLineTo(ImVec2(bx - third, by - third)); window->DrawList->PathLineTo(ImVec2(bx, by)); window->DrawList->PathLineTo(ImVec2(bx + third*2, by - third*2)); window->DrawList->PathStroke(col, false, thickness); } void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags) { ImGuiContext& g = *GImGui; if (id != g.NavId) return; if (g.NavDisableHighlight && !(flags & ImGuiNavHighlightFlags_AlwaysDraw)) return; ImGuiWindow* window = g.CurrentWindow; if (window->DC.NavHideHighlightOneFrame) return; float rounding = (flags & ImGuiNavHighlightFlags_NoRounding) ? 0.0f : g.Style.FrameRounding; ImRect display_rect = bb; display_rect.ClipWith(window->ClipRect); if (flags & ImGuiNavHighlightFlags_TypeDefault) { const float THICKNESS = 2.0f; const float DISTANCE = 3.0f + THICKNESS * 0.5f; display_rect.Expand(ImVec2(DISTANCE,DISTANCE)); bool fully_visible = window->ClipRect.Contains(display_rect); if (!fully_visible) window->DrawList->PushClipRect(display_rect.Min, display_rect.Max); window->DrawList->AddRect(display_rect.Min + ImVec2(THICKNESS*0.5f,THICKNESS*0.5f), display_rect.Max - ImVec2(THICKNESS*0.5f,THICKNESS*0.5f), GetColorU32(ImGuiCol_NavHighlight), rounding, ImDrawCornerFlags_All, THICKNESS); if (!fully_visible) window->DrawList->PopClipRect(); } if (flags & ImGuiNavHighlightFlags_TypeThin) { window->DrawList->AddRect(display_rect.Min, display_rect.Max, GetColorU32(ImGuiCol_NavHighlight), rounding, ~0, 1.0f); } } //----------------------------------------------------------------------------- // [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!) //----------------------------------------------------------------------------- // ImGuiWindow is mostly a dumb struct. It merely has a constructor and a few helper methods ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name) : DrawListInst(&context->DrawListSharedData) { Name = ImStrdup(name); ID = ImHashStr(name); IDStack.push_back(ID); Flags = ImGuiWindowFlags_None; Pos = ImVec2(0.0f, 0.0f); Size = SizeFull = ImVec2(0.0f, 0.0f); ContentSize = ContentSizeExplicit = ImVec2(0.0f, 0.0f); WindowPadding = ImVec2(0.0f, 0.0f); WindowRounding = 0.0f; WindowBorderSize = 0.0f; NameBufLen = (int)strlen(name) + 1; MoveId = GetID("#MOVE"); ChildId = 0; Scroll = ImVec2(0.0f, 0.0f); ScrollTarget = ImVec2(FLT_MAX, FLT_MAX); ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f); ScrollbarSizes = ImVec2(0.0f, 0.0f); ScrollbarX = ScrollbarY = false; Active = WasActive = false; WriteAccessed = false; Collapsed = false; WantCollapseToggle = false; SkipItems = false; Appearing = false; Hidden = false; IsFallbackWindow = false; HasCloseButton = false; ResizeBorderHeld = -1; BeginCount = 0; BeginOrderWithinParent = -1; BeginOrderWithinContext = -1; PopupId = 0; AutoFitFramesX = AutoFitFramesY = -1; AutoFitChildAxises = 0x00; AutoFitOnlyGrows = false; AutoPosLastDirection = ImGuiDir_None; HiddenFramesCanSkipItems = HiddenFramesCannotSkipItems = 0; SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiCond_Always | ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing; SetWindowPosVal = SetWindowPosPivot = ImVec2(FLT_MAX, FLT_MAX); InnerRect = ImRect(0.0f, 0.0f, 0.0f, 0.0f); // Clear so the InnerRect.GetSize() code in Begin() doesn't lead to overflow even if the result isn't used. LastFrameActive = -1; LastTimeActive = -1.0f; ItemWidthDefault = 0.0f; FontWindowScale = 1.0f; SettingsOffset = -1; DrawList = &DrawListInst; DrawList->_OwnerName = Name; ParentWindow = NULL; RootWindow = NULL; RootWindowForTitleBarHighlight = NULL; RootWindowForNav = NULL; NavLastIds[0] = NavLastIds[1] = 0; NavRectRel[0] = NavRectRel[1] = ImRect(); NavLastChildNavWindow = NULL; MemoryCompacted = false; MemoryDrawListIdxCapacity = MemoryDrawListVtxCapacity = 0; } ImGuiWindow::~ImGuiWindow() { IM_ASSERT(DrawList == &DrawListInst); IM_DELETE(Name); for (int i = 0; i != ColumnsStorage.Size; i++) ColumnsStorage[i].~ImGuiColumns(); } ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end) { ImGuiID seed = IDStack.back(); ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); ImGui::KeepAliveID(id); return id; } ImGuiID ImGuiWindow::GetID(const void* ptr) { ImGuiID seed = IDStack.back(); ImGuiID id = ImHashData(&ptr, sizeof(void*), seed); ImGui::KeepAliveID(id); return id; } ImGuiID ImGuiWindow::GetID(int n) { ImGuiID seed = IDStack.back(); ImGuiID id = ImHashData(&n, sizeof(n), seed); ImGui::KeepAliveID(id); return id; } ImGuiID ImGuiWindow::GetIDNoKeepAlive(const char* str, const char* str_end) { ImGuiID seed = IDStack.back(); return ImHashStr(str, str_end ? (str_end - str) : 0, seed); } ImGuiID ImGuiWindow::GetIDNoKeepAlive(const void* ptr) { ImGuiID seed = IDStack.back(); return ImHashData(&ptr, sizeof(void*), seed); } ImGuiID ImGuiWindow::GetIDNoKeepAlive(int n) { ImGuiID seed = IDStack.back(); return ImHashData(&n, sizeof(n), seed); } // This is only used in rare/specific situations to manufacture an ID out of nowhere. ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs) { ImGuiID seed = IDStack.back(); const int r_rel[4] = { (int)(r_abs.Min.x - Pos.x), (int)(r_abs.Min.y - Pos.y), (int)(r_abs.Max.x - Pos.x), (int)(r_abs.Max.y - Pos.y) }; ImGuiID id = ImHashData(&r_rel, sizeof(r_rel), seed); ImGui::KeepAliveID(id); return id; } static void SetCurrentWindow(ImGuiWindow* window) { ImGuiContext& g = *GImGui; g.CurrentWindow = window; if (window) g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize(); } // Free up/compact internal window buffers, we can use this when a window becomes unused. // This is currently unused by the library, but you may call this yourself for easy GC. // Not freed: // - ImGuiWindow, ImGuiWindowSettings, Name // - StateStorage, ColumnsStorage (may hold useful data) // This should have no noticeable visual effect. When the window reappear however, expect new allocation/buffer growth/copy cost. void ImGui::GcCompactTransientWindowBuffers(ImGuiWindow* window) { window->MemoryCompacted = true; window->MemoryDrawListIdxCapacity = window->DrawList->IdxBuffer.Capacity; window->MemoryDrawListVtxCapacity = window->DrawList->VtxBuffer.Capacity; window->IDStack.clear(); window->DrawList->ClearFreeMemory(); window->DC.ChildWindows.clear(); window->DC.ItemFlagsStack.clear(); window->DC.ItemWidthStack.clear(); window->DC.TextWrapPosStack.clear(); window->DC.GroupStack.clear(); } void ImGui::GcAwakeTransientWindowBuffers(ImGuiWindow* window) { // We stored capacity of the ImDrawList buffer to reduce growth-caused allocation/copy when awakening. // The other buffers tends to amortize much faster. window->MemoryCompacted = false; window->DrawList->IdxBuffer.reserve(window->MemoryDrawListIdxCapacity); window->DrawList->VtxBuffer.reserve(window->MemoryDrawListVtxCapacity); window->MemoryDrawListIdxCapacity = window->MemoryDrawListVtxCapacity = 0; } void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window) { ImGuiContext& g = *GImGui; g.ActiveIdIsJustActivated = (g.ActiveId != id); if (g.ActiveIdIsJustActivated) { g.ActiveIdTimer = 0.0f; g.ActiveIdHasBeenPressedBefore = false; g.ActiveIdHasBeenEditedBefore = false; if (id != 0) { g.LastActiveId = id; g.LastActiveIdTimer = 0.0f; } } g.ActiveId = id; g.ActiveIdAllowOverlap = false; g.ActiveIdWindow = window; g.ActiveIdHasBeenEditedThisFrame = false; if (id) { g.ActiveIdIsAlive = id; g.ActiveIdSource = (g.NavActivateId == id || g.NavInputId == id || g.NavJustTabbedId == id || g.NavJustMovedToId == id) ? ImGuiInputSource_Nav : ImGuiInputSource_Mouse; } // Clear declaration of inputs claimed by the widget // (Please note that this is WIP and not all keys/inputs are thoroughly declared by all widgets yet) g.ActiveIdUsingNavDirMask = 0x00; g.ActiveIdUsingNavInputMask = 0x00; g.ActiveIdUsingKeyInputMask = 0x00; } void ImGui::ClearActiveID() { SetActiveID(0, NULL); } void ImGui::SetHoveredID(ImGuiID id) { ImGuiContext& g = *GImGui; g.HoveredId = id; g.HoveredIdAllowOverlap = false; if (id != 0 && g.HoveredIdPreviousFrame != id) g.HoveredIdTimer = g.HoveredIdNotActiveTimer = 0.0f; } ImGuiID ImGui::GetHoveredID() { ImGuiContext& g = *GImGui; return g.HoveredId ? g.HoveredId : g.HoveredIdPreviousFrame; } void ImGui::KeepAliveID(ImGuiID id) { ImGuiContext& g = *GImGui; if (g.ActiveId == id) g.ActiveIdIsAlive = id; if (g.ActiveIdPreviousFrame == id) g.ActiveIdPreviousFrameIsAlive = true; } void ImGui::MarkItemEdited(ImGuiID id) { // This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit(). // ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need need to fill the data. ImGuiContext& g = *GImGui; IM_ASSERT(g.ActiveId == id || g.ActiveId == 0 || g.DragDropActive); IM_UNUSED(id); // Avoid unused variable warnings when asserts are compiled out. //IM_ASSERT(g.CurrentWindow->DC.LastItemId == id); g.ActiveIdHasBeenEditedThisFrame = true; g.ActiveIdHasBeenEditedBefore = true; g.CurrentWindow->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Edited; } static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flags) { // An active popup disable hovering on other windows (apart from its own children) // FIXME-OPT: This could be cached/stored within the window. ImGuiContext& g = *GImGui; if (g.NavWindow) if (ImGuiWindow* focused_root_window = g.NavWindow->RootWindow) if (focused_root_window->WasActive && focused_root_window != window->RootWindow) { // For the purpose of those flags we differentiate "standard popup" from "modal popup" // NB: The order of those two tests is important because Modal windows are also Popups. if (focused_root_window->Flags & ImGuiWindowFlags_Modal) return false; if ((focused_root_window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiHoveredFlags_AllowWhenBlockedByPopup)) return false; } return true; } // Advance cursor given item size for layout. void ImGui::ItemSize(const ImVec2& size, float text_baseline_y) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (window->SkipItems) return; // We increase the height in this function to accommodate for baseline offset. // In theory we should be offsetting the starting position (window->DC.CursorPos), that will be the topic of a larger refactor, // but since ItemSize() is not yet an API that moves the cursor (to handle e.g. wrapping) enlarging the height has the same effect. const float offset_to_match_baseline_y = (text_baseline_y >= 0) ? ImMax(0.0f, window->DC.CurrLineTextBaseOffset - text_baseline_y) : 0.0f; const float line_height = ImMax(window->DC.CurrLineSize.y, size.y + offset_to_match_baseline_y); // Always align ourselves on pixel boundaries //if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG] window->DC.CursorPosPrevLine.x = window->DC.CursorPos.x + size.x; window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y; window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); // Next line window->DC.CursorPos.y = IM_FLOOR(window->DC.CursorPos.y + line_height + g.Style.ItemSpacing.y); // Next line window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPosPrevLine.x); window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y - g.Style.ItemSpacing.y); //if (g.IO.KeyAlt) window->DrawList->AddCircle(window->DC.CursorMaxPos, 3.0f, IM_COL32(255,0,0,255), 4); // [DEBUG] window->DC.PrevLineSize.y = line_height; window->DC.CurrLineSize.y = 0.0f; window->DC.PrevLineTextBaseOffset = ImMax(window->DC.CurrLineTextBaseOffset, text_baseline_y); window->DC.CurrLineTextBaseOffset = 0.0f; // Horizontal layout mode if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) SameLine(); } void ImGui::ItemSize(const ImRect& bb, float text_baseline_y) { ItemSize(bb.GetSize(), text_baseline_y); } // Declare item bounding box for clipping and interaction. // Note that the size can be different than the one provided to ItemSize(). Typically, widgets that spread over available surface // declare their minimum size requirement to ItemSize() and then use a larger region for drawing/interaction, which is passed to ItemAdd(). bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (id != 0) { // Navigation processing runs prior to clipping early-out // (a) So that NavInitRequest can be honored, for newly opened windows to select a default widget // (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests // unfortunately, but it is still limited to one window. It may not scale very well for windows with ten of // thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame. // We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able // to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick). // We intentionally don't check if g.NavWindow != NULL because g.NavAnyRequest should only be set when it is non null. // If we crash on a NULL g.NavWindow we need to fix the bug elsewhere. window->DC.NavLayerActiveMaskNext |= window->DC.NavLayerCurrentMask; if (g.NavId == id || g.NavAnyRequest) if (g.NavWindow->RootWindowForNav == window->RootWindowForNav) if (window == g.NavWindow || ((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened)) NavProcessItem(window, nav_bb_arg ? *nav_bb_arg : bb, id); // [DEBUG] Item Picker tool, when enabling the "extended" version we perform the check in ItemAdd() #ifdef IMGUI_DEBUG_TOOL_ITEM_PICKER_EX if (id == g.DebugItemPickerBreakId) { IM_DEBUG_BREAK(); g.DebugItemPickerBreakId = 0; } #endif } window->DC.LastItemId = id; window->DC.LastItemRect = bb; window->DC.LastItemStatusFlags = ImGuiItemStatusFlags_None; g.NextItemData.Flags = ImGuiNextItemDataFlags_None; #ifdef IMGUI_ENABLE_TEST_ENGINE if (id != 0) IMGUI_TEST_ENGINE_ITEM_ADD(nav_bb_arg ? *nav_bb_arg : bb, id); #endif // Clipping test const bool is_clipped = IsClippedEx(bb, id, false); if (is_clipped) return false; //if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG] // We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them) if (IsMouseHoveringRect(bb.Min, bb.Max)) window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HoveredRect; return true; } // This is roughly matching the behavior of internal-facing ItemHoverable() // - we allow hovering to be true when ActiveId==window->MoveID, so that clicking on non-interactive items such as a Text() item still returns true with IsItemHovered() // - this should work even for non-interactive items that have no ID, so we cannot use LastItemId bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (g.NavDisableMouseHover && !g.NavDisableHighlight) return IsItemFocused(); // Test for bounding box overlap, as updated as ItemAdd() if (!(window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect)) return false; IM_ASSERT((flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows)) == 0); // Flags not supported by this function // Test if we are hovering the right window (our window could be behind another window) // [2017/10/16] Reverted commit 344d48be3 and testing RootWindow instead. I believe it is correct to NOT test for RootWindow but this leaves us unable to use IsItemHovered() after EndChild() itself. // Until a solution is found I believe reverting to the test from 2017/09/27 is safe since this was the test that has been running for a long while. //if (g.HoveredWindow != window) // return false; if (g.HoveredRootWindow != window->RootWindow && !(flags & ImGuiHoveredFlags_AllowWhenOverlapped)) return false; // Test if another item is active (e.g. being dragged) if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) if (g.ActiveId != 0 && g.ActiveId != window->DC.LastItemId && !g.ActiveIdAllowOverlap && g.ActiveId != window->MoveId) return false; // Test if interactions on this window are blocked by an active popup or modal. // The ImGuiHoveredFlags_AllowWhenBlockedByPopup flag will be tested here. if (!IsWindowContentHoverable(window, flags)) return false; // Test if the item is disabled if ((window->DC.ItemFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled)) return false; // Special handling for the dummy item after Begin() which represent the title bar or tab. // When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect the case. if (window->DC.LastItemId == window->MoveId && window->WriteAccessed) return false; return true; } // Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered(). bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id) { ImGuiContext& g = *GImGui; if (g.HoveredId != 0 && g.HoveredId != id && !g.HoveredIdAllowOverlap) return false; ImGuiWindow* window = g.CurrentWindow; if (g.HoveredWindow != window) return false; if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap) return false; if (!IsMouseHoveringRect(bb.Min, bb.Max)) return false; if (g.NavDisableMouseHover || !IsWindowContentHoverable(window, ImGuiHoveredFlags_None)) return false; if (window->DC.ItemFlags & ImGuiItemFlags_Disabled) return false; SetHoveredID(id); // [DEBUG] Item Picker tool! // We perform the check here because SetHoveredID() is not frequently called (1~ time a frame), making // the cost of this tool near-zero. We can get slightly better call-stack and support picking non-hovered // items if we perform the test in ItemAdd(), but that would incur a small runtime cost. // #define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX in imconfig.h if you want this check to also be performed in ItemAdd(). if (g.DebugItemPickerActive && g.HoveredIdPreviousFrame == id) GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255)); if (g.DebugItemPickerBreakId == id) IM_DEBUG_BREAK(); return true; } bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (!bb.Overlaps(window->ClipRect)) if (id == 0 || id != g.ActiveId) if (clip_even_when_logged || !g.LogEnabled) return true; return false; } // Process TAB/Shift+TAB. Be mindful that this function may _clear_ the ActiveID when tabbing out. bool ImGui::FocusableItemRegister(ImGuiWindow* window, ImGuiID id) { ImGuiContext& g = *GImGui; // Increment counters const bool is_tab_stop = (window->DC.ItemFlags & (ImGuiItemFlags_NoTabStop | ImGuiItemFlags_Disabled)) == 0; window->DC.FocusCounterRegular++; if (is_tab_stop) window->DC.FocusCounterTabStop++; // Process TAB/Shift-TAB to tab *OUT* of the currently focused item. // (Note that we can always TAB out of a widget that doesn't allow tabbing in) if (g.ActiveId == id && g.FocusTabPressed && !IsActiveIdUsingKey(ImGuiKey_Tab) && g.FocusRequestNextWindow == NULL) { g.FocusRequestNextWindow = window; g.FocusRequestNextCounterTabStop = window->DC.FocusCounterTabStop + (g.IO.KeyShift ? (is_tab_stop ? -1 : 0) : +1); // Modulo on index will be applied at the end of frame once we've got the total counter of items. } // Handle focus requests if (g.FocusRequestCurrWindow == window) { if (window->DC.FocusCounterRegular == g.FocusRequestCurrCounterRegular) return true; if (is_tab_stop && window->DC.FocusCounterTabStop == g.FocusRequestCurrCounterTabStop) { g.NavJustTabbedId = id; return true; } // If another item is about to be focused, we clear our own active id if (g.ActiveId == id) ClearActiveID(); } return false; } void ImGui::FocusableItemUnregister(ImGuiWindow* window) { window->DC.FocusCounterRegular--; window->DC.FocusCounterTabStop--; } float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x) { if (wrap_pos_x < 0.0f) return 0.0f; ImGuiWindow* window = GImGui->CurrentWindow; if (wrap_pos_x == 0.0f) wrap_pos_x = window->WorkRect.Max.x; else if (wrap_pos_x > 0.0f) wrap_pos_x += window->Pos.x - window->Scroll.x; // wrap_pos_x is provided is window local space return ImMax(wrap_pos_x - pos.x, 1.0f); } // IM_ALLOC() == ImGui::MemAlloc() void* ImGui::MemAlloc(size_t size) { if (ImGuiContext* ctx = GImGui) ctx->IO.MetricsActiveAllocations++; return GImAllocatorAllocFunc(size, GImAllocatorUserData); } // IM_FREE() == ImGui::MemFree() void ImGui::MemFree(void* ptr) { if (ptr) if (ImGuiContext* ctx = GImGui) ctx->IO.MetricsActiveAllocations--; return GImAllocatorFreeFunc(ptr, GImAllocatorUserData); } const char* ImGui::GetClipboardText() { ImGuiContext& g = *GImGui; return g.IO.GetClipboardTextFn ? g.IO.GetClipboardTextFn(g.IO.ClipboardUserData) : ""; } void ImGui::SetClipboardText(const char* text) { ImGuiContext& g = *GImGui; if (g.IO.SetClipboardTextFn) g.IO.SetClipboardTextFn(g.IO.ClipboardUserData, text); } const char* ImGui::GetVersion() { return IMGUI_VERSION; } // Internal state access - if you want to share Dear ImGui state between modules (e.g. DLL) or allocate it yourself // Note that we still point to some static data and members (such as GFontAtlas), so the state instance you end up using will point to the static data within its module ImGuiContext* ImGui::GetCurrentContext() { return GImGui; } void ImGui::SetCurrentContext(ImGuiContext* ctx) { #ifdef IMGUI_SET_CURRENT_CONTEXT_FUNC IMGUI_SET_CURRENT_CONTEXT_FUNC(ctx); // For custom thread-based hackery you may want to have control over this. #else GImGui = ctx; #endif } // Helper function to verify ABI compatibility between caller code and compiled version of Dear ImGui. // Verify that the type sizes are matching between the calling file's compilation unit and imgui.cpp's compilation unit // If the user has inconsistent compilation settings, imgui configuration #define, packing pragma, etc. your user code // may see different structures than what imgui.cpp sees, which is problematic. // We usually require settings to be in imconfig.h to make sure that they are accessible to all compilation units involved with Dear ImGui. bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert, size_t sz_idx) { bool error = false; if (strcmp(version, IMGUI_VERSION)!=0) { error = true; IM_ASSERT(strcmp(version,IMGUI_VERSION)==0 && "Mismatched version string!"); } if (sz_io != sizeof(ImGuiIO)) { error = true; IM_ASSERT(sz_io == sizeof(ImGuiIO) && "Mismatched struct layout!"); } if (sz_style != sizeof(ImGuiStyle)) { error = true; IM_ASSERT(sz_style == sizeof(ImGuiStyle) && "Mismatched struct layout!"); } if (sz_vec2 != sizeof(ImVec2)) { error = true; IM_ASSERT(sz_vec2 == sizeof(ImVec2) && "Mismatched struct layout!"); } if (sz_vec4 != sizeof(ImVec4)) { error = true; IM_ASSERT(sz_vec4 == sizeof(ImVec4) && "Mismatched struct layout!"); } if (sz_vert != sizeof(ImDrawVert)) { error = true; IM_ASSERT(sz_vert == sizeof(ImDrawVert) && "Mismatched struct layout!"); } if (sz_idx != sizeof(ImDrawIdx)) { error = true; IM_ASSERT(sz_idx == sizeof(ImDrawIdx) && "Mismatched struct layout!"); } return !error; } void ImGui::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data) { GImAllocatorAllocFunc = alloc_func; GImAllocatorFreeFunc = free_func; GImAllocatorUserData = user_data; } ImGuiContext* ImGui::CreateContext(ImFontAtlas* shared_font_atlas) { ImGuiContext* ctx = IM_NEW(ImGuiContext)(shared_font_atlas); if (GImGui == NULL) SetCurrentContext(ctx); Initialize(ctx); return ctx; } void ImGui::DestroyContext(ImGuiContext* ctx) { if (ctx == NULL) ctx = GImGui; Shutdown(ctx); if (GImGui == ctx) SetCurrentContext(NULL); IM_DELETE(ctx); } ImGuiIO& ImGui::GetIO() { IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); return GImGui->IO; } ImGuiStyle& ImGui::GetStyle() { IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); return GImGui->Style; } // Same value as passed to the old io.RenderDrawListsFn function. Valid after Render() and until the next call to NewFrame() ImDrawData* ImGui::GetDrawData() { ImGuiContext& g = *GImGui; return g.DrawData.Valid ? &g.DrawData : NULL; } double ImGui::GetTime() { return GImGui->Time; } int ImGui::GetFrameCount() { return GImGui->FrameCount; } ImDrawList* ImGui::GetBackgroundDrawList() { return &GImGui->BackgroundDrawList; } ImDrawList* ImGui::GetForegroundDrawList() { return &GImGui->ForegroundDrawList; } ImDrawListSharedData* ImGui::GetDrawListSharedData() { return &GImGui->DrawListSharedData; } void ImGui::StartMouseMovingWindow(ImGuiWindow* window) { // Set ActiveId even if the _NoMove flag is set. Without it, dragging away from a window with _NoMove would activate hover on other windows. // We _also_ call this when clicking in a window empty space when io.ConfigWindowsMoveFromTitleBarOnly is set, but clear g.MovingWindow afterward. // This is because we want ActiveId to be set even when the window is not permitted to move. ImGuiContext& g = *GImGui; FocusWindow(window); SetActiveID(window->MoveId, window); g.NavDisableHighlight = true; g.ActiveIdClickOffset = g.IO.MousePos - window->RootWindow->Pos; bool can_move_window = true; if ((window->Flags & ImGuiWindowFlags_NoMove) || (window->RootWindow->Flags & ImGuiWindowFlags_NoMove)) can_move_window = false; if (can_move_window) g.MovingWindow = window; } // Handle mouse moving window // Note: moving window with the navigation keys (Square + d-pad / CTRL+TAB + Arrows) are processed in NavUpdateWindowing() void ImGui::UpdateMouseMovingWindowNewFrame() { ImGuiContext& g = *GImGui; if (g.MovingWindow != NULL) { // We actually want to move the root window. g.MovingWindow == window we clicked on (could be a child window). // We track it to preserve Focus and so that generally ActiveIdWindow == MovingWindow and ActiveId == MovingWindow->MoveId for consistency. KeepAliveID(g.ActiveId); IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow); ImGuiWindow* moving_window = g.MovingWindow->RootWindow; if (g.IO.MouseDown[0] && IsMousePosValid(&g.IO.MousePos)) { ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset; if (moving_window->Pos.x != pos.x || moving_window->Pos.y != pos.y) { MarkIniSettingsDirty(moving_window); SetWindowPos(moving_window, pos, ImGuiCond_Always); } FocusWindow(g.MovingWindow); } else { ClearActiveID(); g.MovingWindow = NULL; } } else { // When clicking/dragging from a window that has the _NoMove flag, we still set the ActiveId in order to prevent hovering others. if (g.ActiveIdWindow && g.ActiveIdWindow->MoveId == g.ActiveId) { KeepAliveID(g.ActiveId); if (!g.IO.MouseDown[0]) ClearActiveID(); } } } // Initiate moving window when clicking on empty space or title bar. // Handle left-click and right-click focus. void ImGui::UpdateMouseMovingWindowEndFrame() { ImGuiContext& g = *GImGui; if (g.ActiveId != 0 || g.HoveredId != 0) return; // Unless we just made a window/popup appear if (g.NavWindow && g.NavWindow->Appearing) return; // Click to focus window and start moving (after we're done with all our widgets) if (g.IO.MouseClicked[0]) { if (g.HoveredRootWindow != NULL) { StartMouseMovingWindow(g.HoveredWindow); if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoTitleBar)) if (!g.HoveredRootWindow->TitleBarRect().Contains(g.IO.MouseClickedPos[0])) g.MovingWindow = NULL; } else if (g.NavWindow != NULL && GetTopMostPopupModal() == NULL) { // Clicking on void disable focus FocusWindow(NULL); } } // With right mouse button we close popups without changing focus based on where the mouse is aimed // Instead, focus will be restored to the window under the bottom-most closed popup. // (The left mouse button path calls FocusWindow on the hovered window, which will lead NewFrame->ClosePopupsOverWindow to trigger) if (g.IO.MouseClicked[1]) { // Find the top-most window between HoveredWindow and the top-most Modal Window. // This is where we can trim the popup stack. ImGuiWindow* modal = GetTopMostPopupModal(); bool hovered_window_above_modal = false; if (modal == NULL) hovered_window_above_modal = true; for (int i = g.Windows.Size - 1; i >= 0 && hovered_window_above_modal == false; i--) { ImGuiWindow* window = g.Windows[i]; if (window == modal) break; if (window == g.HoveredWindow) hovered_window_above_modal = true; } ClosePopupsOverWindow(hovered_window_above_modal ? g.HoveredWindow : modal, true); } } static bool IsWindowActiveAndVisible(ImGuiWindow* window) { return (window->Active) && (!window->Hidden); } static void ImGui::UpdateMouseInputs() { ImGuiContext& g = *GImGui; // Round mouse position to avoid spreading non-rounded position (e.g. UpdateManualResize doesn't support them well) if (IsMousePosValid(&g.IO.MousePos)) g.IO.MousePos = g.LastValidMousePos = ImFloor(g.IO.MousePos); // If mouse just appeared or disappeared (usually denoted by -FLT_MAX components) we cancel out movement in MouseDelta if (IsMousePosValid(&g.IO.MousePos) && IsMousePosValid(&g.IO.MousePosPrev)) g.IO.MouseDelta = g.IO.MousePos - g.IO.MousePosPrev; else g.IO.MouseDelta = ImVec2(0.0f, 0.0f); if (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f) g.NavDisableMouseHover = false; g.IO.MousePosPrev = g.IO.MousePos; for (int i = 0; i < IM_ARRAYSIZE(g.IO.MouseDown); i++) { g.IO.MouseClicked[i] = g.IO.MouseDown[i] && g.IO.MouseDownDuration[i] < 0.0f; g.IO.MouseReleased[i] = !g.IO.MouseDown[i] && g.IO.MouseDownDuration[i] >= 0.0f; g.IO.MouseDownDurationPrev[i] = g.IO.MouseDownDuration[i]; g.IO.MouseDownDuration[i] = g.IO.MouseDown[i] ? (g.IO.MouseDownDuration[i] < 0.0f ? 0.0f : g.IO.MouseDownDuration[i] + g.IO.DeltaTime) : -1.0f; g.IO.MouseDoubleClicked[i] = false; if (g.IO.MouseClicked[i]) { if ((float)(g.Time - g.IO.MouseClickedTime[i]) < g.IO.MouseDoubleClickTime) { ImVec2 delta_from_click_pos = IsMousePosValid(&g.IO.MousePos) ? (g.IO.MousePos - g.IO.MouseClickedPos[i]) : ImVec2(0.0f, 0.0f); if (ImLengthSqr(delta_from_click_pos) < g.IO.MouseDoubleClickMaxDist * g.IO.MouseDoubleClickMaxDist) g.IO.MouseDoubleClicked[i] = true; g.IO.MouseClickedTime[i] = -FLT_MAX; // so the third click isn't turned into a double-click } else { g.IO.MouseClickedTime[i] = g.Time; } g.IO.MouseClickedPos[i] = g.IO.MousePos; g.IO.MouseDownWasDoubleClick[i] = g.IO.MouseDoubleClicked[i]; g.IO.MouseDragMaxDistanceAbs[i] = ImVec2(0.0f, 0.0f); g.IO.MouseDragMaxDistanceSqr[i] = 0.0f; } else if (g.IO.MouseDown[i]) { // Maintain the maximum distance we reaching from the initial click position, which is used with dragging threshold ImVec2 delta_from_click_pos = IsMousePosValid(&g.IO.MousePos) ? (g.IO.MousePos - g.IO.MouseClickedPos[i]) : ImVec2(0.0f, 0.0f); g.IO.MouseDragMaxDistanceSqr[i] = ImMax(g.IO.MouseDragMaxDistanceSqr[i], ImLengthSqr(delta_from_click_pos)); g.IO.MouseDragMaxDistanceAbs[i].x = ImMax(g.IO.MouseDragMaxDistanceAbs[i].x, delta_from_click_pos.x < 0.0f ? -delta_from_click_pos.x : delta_from_click_pos.x); g.IO.MouseDragMaxDistanceAbs[i].y = ImMax(g.IO.MouseDragMaxDistanceAbs[i].y, delta_from_click_pos.y < 0.0f ? -delta_from_click_pos.y : delta_from_click_pos.y); } if (!g.IO.MouseDown[i] && !g.IO.MouseReleased[i]) g.IO.MouseDownWasDoubleClick[i] = false; if (g.IO.MouseClicked[i]) // Clicking any mouse button reactivate mouse hovering which may have been deactivated by gamepad/keyboard navigation g.NavDisableMouseHover = false; } } static void StartLockWheelingWindow(ImGuiWindow* window) { ImGuiContext& g = *GImGui; if (g.WheelingWindow == window) return; g.WheelingWindow = window; g.WheelingWindowRefMousePos = g.IO.MousePos; g.WheelingWindowTimer = WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER; } void ImGui::UpdateMouseWheel() { ImGuiContext& g = *GImGui; // Reset the locked window if we move the mouse or after the timer elapses if (g.WheelingWindow != NULL) { g.WheelingWindowTimer -= g.IO.DeltaTime; if (IsMousePosValid() && ImLengthSqr(g.IO.MousePos - g.WheelingWindowRefMousePos) > g.IO.MouseDragThreshold * g.IO.MouseDragThreshold) g.WheelingWindowTimer = 0.0f; if (g.WheelingWindowTimer <= 0.0f) { g.WheelingWindow = NULL; g.WheelingWindowTimer = 0.0f; } } if (g.IO.MouseWheel == 0.0f && g.IO.MouseWheelH == 0.0f) return; ImGuiWindow* window = g.WheelingWindow ? g.WheelingWindow : g.HoveredWindow; if (!window || window->Collapsed) return; // Zoom / Scale window // FIXME-OBSOLETE: This is an old feature, it still works but pretty much nobody is using it and may be best redesigned. if (g.IO.MouseWheel != 0.0f && g.IO.KeyCtrl && g.IO.FontAllowUserScaling) { StartLockWheelingWindow(window); const float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f); const float scale = new_font_scale / window->FontWindowScale; window->FontWindowScale = new_font_scale; if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) { const ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size; SetWindowPos(window, window->Pos + offset, 0); window->Size = ImFloor(window->Size * scale); window->SizeFull = ImFloor(window->SizeFull * scale); } return; } // Mouse wheel scrolling // If a child window has the ImGuiWindowFlags_NoScrollWithMouse flag, we give a chance to scroll its parent // Vertical Mouse Wheel scrolling const float wheel_y = (g.IO.MouseWheel != 0.0f && !g.IO.KeyShift) ? g.IO.MouseWheel : 0.0f; if (wheel_y != 0.0f && !g.IO.KeyCtrl) { StartLockWheelingWindow(window); while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.y == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs)))) window = window->ParentWindow; if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs)) { float max_step = window->InnerRect.GetHeight() * 0.67f; float scroll_step = ImFloor(ImMin(5 * window->CalcFontSize(), max_step)); SetScrollY(window, window->Scroll.y - wheel_y * scroll_step); } } // Horizontal Mouse Wheel scrolling, or Vertical Mouse Wheel w/ Shift held const float wheel_x = (g.IO.MouseWheelH != 0.0f && !g.IO.KeyShift) ? g.IO.MouseWheelH : (g.IO.MouseWheel != 0.0f && g.IO.KeyShift) ? g.IO.MouseWheel : 0.0f; if (wheel_x != 0.0f && !g.IO.KeyCtrl) { StartLockWheelingWindow(window); while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.x == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs)))) window = window->ParentWindow; if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs)) { float max_step = window->InnerRect.GetWidth() * 0.67f; float scroll_step = ImFloor(ImMin(2 * window->CalcFontSize(), max_step)); SetScrollX(window, window->Scroll.x - wheel_x * scroll_step); } } } // The reason this is exposed in imgui_internal.h is: on touch-based system that don't have hovering, we want to dispatch inputs to the right target (imgui vs imgui+app) void ImGui::UpdateHoveredWindowAndCaptureFlags() { ImGuiContext& g = *GImGui; // Find the window hovered by mouse: // - Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow. // - When moving a window we can skip the search, which also conveniently bypasses the fact that window->WindowRectClipped is lagging as this point of the frame. // - We also support the moved window toggling the NoInputs flag after moving has started in order to be able to detect windows below it, which is useful for e.g. docking mechanisms. FindHoveredWindow(); // Modal windows prevents cursor from hovering behind them. ImGuiWindow* modal_window = GetTopMostPopupModal(); if (modal_window) if (g.HoveredRootWindow && !IsWindowChildOf(g.HoveredRootWindow, modal_window)) g.HoveredRootWindow = g.HoveredWindow = NULL; // Disabled mouse? if (g.IO.ConfigFlags & ImGuiConfigFlags_NoMouse) g.HoveredWindow = g.HoveredRootWindow = NULL; // We track click ownership. When clicked outside of a window the click is owned by the application and won't report hovering nor request capture even while dragging over our windows afterward. int mouse_earliest_button_down = -1; bool mouse_any_down = false; for (int i = 0; i < IM_ARRAYSIZE(g.IO.MouseDown); i++) { if (g.IO.MouseClicked[i]) g.IO.MouseDownOwned[i] = (g.HoveredWindow != NULL) || (!g.OpenPopupStack.empty()); mouse_any_down |= g.IO.MouseDown[i]; if (g.IO.MouseDown[i]) if (mouse_earliest_button_down == -1 || g.IO.MouseClickedTime[i] < g.IO.MouseClickedTime[mouse_earliest_button_down]) mouse_earliest_button_down = i; } const bool mouse_avail_to_imgui = (mouse_earliest_button_down == -1) || g.IO.MouseDownOwned[mouse_earliest_button_down]; // If mouse was first clicked outside of ImGui bounds we also cancel out hovering. // FIXME: For patterns of drag and drop across OS windows, we may need to rework/remove this test (first committed 311c0ca9 on 2015/02) const bool mouse_dragging_extern_payload = g.DragDropActive && (g.DragDropSourceFlags & ImGuiDragDropFlags_SourceExtern) != 0; if (!mouse_avail_to_imgui && !mouse_dragging_extern_payload) g.HoveredWindow = g.HoveredRootWindow = NULL; // Update io.WantCaptureMouse for the user application (true = dispatch mouse info to imgui, false = dispatch mouse info to Dear ImGui + app) if (g.WantCaptureMouseNextFrame != -1) g.IO.WantCaptureMouse = (g.WantCaptureMouseNextFrame != 0); else g.IO.WantCaptureMouse = (mouse_avail_to_imgui && (g.HoveredWindow != NULL || mouse_any_down)) || (!g.OpenPopupStack.empty()); // Update io.WantCaptureKeyboard for the user application (true = dispatch keyboard info to imgui, false = dispatch keyboard info to Dear ImGui + app) if (g.WantCaptureKeyboardNextFrame != -1) g.IO.WantCaptureKeyboard = (g.WantCaptureKeyboardNextFrame != 0); else g.IO.WantCaptureKeyboard = (g.ActiveId != 0) || (modal_window != NULL); if (g.IO.NavActive && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard)) g.IO.WantCaptureKeyboard = true; // Update io.WantTextInput flag, this is to allow systems without a keyboard (e.g. mobile, hand-held) to show a software keyboard if possible g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false; } static void NewFrameSanityChecks() { ImGuiContext& g = *GImGui; // Check user data // (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument) IM_ASSERT(g.Initialized); IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!"); IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?"); IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!"); IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?"); IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?"); IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!"); IM_ASSERT(g.Style.CircleSegmentMaxError > 0.0f && "Invalid style setting!"); IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)!"); IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting."); IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_None || g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right); for (int n = 0; n < ImGuiKey_COUNT; n++) IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)"); // Perform simple check: required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was only recently added in 1.60 WIP) if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation."); // Perform simple check: the beta io.ConfigWindowsResizeFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly. if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors)) g.IO.ConfigWindowsResizeFromEdges = false; } void ImGui::NewFrame() { IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); ImGuiContext& g = *GImGui; #ifdef IMGUI_ENABLE_TEST_ENGINE ImGuiTestEngineHook_PreNewFrame(&g); #endif // Check and assert for various common IO and Configuration mistakes NewFrameSanityChecks(); // Load settings on first frame (if not explicitly loaded manually before) if (!g.SettingsLoaded) { IM_ASSERT(g.SettingsWindows.empty()); if (g.IO.IniFilename) LoadIniSettingsFromDisk(g.IO.IniFilename); g.SettingsLoaded = true; } // Save settings (with a delay after the last modification, so we don't spam disk too much) if (g.SettingsDirtyTimer > 0.0f) { g.SettingsDirtyTimer -= g.IO.DeltaTime; if (g.SettingsDirtyTimer <= 0.0f) { if (g.IO.IniFilename != NULL) SaveIniSettingsToDisk(g.IO.IniFilename); else g.IO.WantSaveIniSettings = true; // Let user know they can call SaveIniSettingsToMemory(). user will need to clear io.WantSaveIniSettings themselves. g.SettingsDirtyTimer = 0.0f; } } g.Time += g.IO.DeltaTime; g.WithinFrameScope = true; g.FrameCount += 1; g.TooltipOverrideCount = 0; g.WindowsActiveCount = 0; // Setup current font and draw list shared data g.IO.Fonts->Locked = true; SetCurrentFont(GetDefaultFont()); IM_ASSERT(g.Font->IsLoaded()); g.DrawListSharedData.ClipRectFullscreen = ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y); g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol; g.DrawListSharedData.SetCircleSegmentMaxError(g.Style.CircleSegmentMaxError); g.DrawListSharedData.InitialFlags = ImDrawListFlags_None; if (g.Style.AntiAliasedLines) g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLines; if (g.Style.AntiAliasedFill) g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedFill; if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset; g.BackgroundDrawList.Clear(); g.BackgroundDrawList.PushTextureID(g.IO.Fonts->TexID); g.BackgroundDrawList.PushClipRectFullScreen(); g.ForegroundDrawList.Clear(); g.ForegroundDrawList.PushTextureID(g.IO.Fonts->TexID); g.ForegroundDrawList.PushClipRectFullScreen(); // Mark rendering data as invalid to prevent user who may have a handle on it to use it. g.DrawData.Clear(); // Drag and drop keep the source ID alive so even if the source disappear our state is consistent if (g.DragDropActive && g.DragDropPayload.SourceId == g.ActiveId) KeepAliveID(g.DragDropPayload.SourceId); // Clear reference to active widget if the widget isn't alive anymore if (!g.HoveredIdPreviousFrame) g.HoveredIdTimer = 0.0f; if (!g.HoveredIdPreviousFrame || (g.HoveredId && g.ActiveId == g.HoveredId)) g.HoveredIdNotActiveTimer = 0.0f; if (g.HoveredId) g.HoveredIdTimer += g.IO.DeltaTime; if (g.HoveredId && g.ActiveId != g.HoveredId) g.HoveredIdNotActiveTimer += g.IO.DeltaTime; g.HoveredIdPreviousFrame = g.HoveredId; g.HoveredId = 0; g.HoveredIdAllowOverlap = false; if (g.ActiveIdIsAlive != g.ActiveId && g.ActiveIdPreviousFrame == g.ActiveId && g.ActiveId != 0) ClearActiveID(); if (g.ActiveId) g.ActiveIdTimer += g.IO.DeltaTime; g.LastActiveIdTimer += g.IO.DeltaTime; g.ActiveIdPreviousFrame = g.ActiveId; g.ActiveIdPreviousFrameWindow = g.ActiveIdWindow; g.ActiveIdPreviousFrameHasBeenEditedBefore = g.ActiveIdHasBeenEditedBefore; g.ActiveIdIsAlive = 0; g.ActiveIdHasBeenEditedThisFrame = false; g.ActiveIdPreviousFrameIsAlive = false; g.ActiveIdIsJustActivated = false; if (g.TempInputTextId != 0 && g.ActiveId != g.TempInputTextId) g.TempInputTextId = 0; if (g.ActiveId == 0) { g.ActiveIdUsingNavDirMask = g.ActiveIdUsingNavInputMask = 0; g.ActiveIdUsingKeyInputMask = 0; } // Drag and drop g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr; g.DragDropAcceptIdCurr = 0; g.DragDropAcceptIdCurrRectSurface = FLT_MAX; g.DragDropWithinSourceOrTarget = false; // Update keyboard input state memcpy(g.IO.KeysDownDurationPrev, g.IO.KeysDownDuration, sizeof(g.IO.KeysDownDuration)); for (int i = 0; i < IM_ARRAYSIZE(g.IO.KeysDown); i++) g.IO.KeysDownDuration[i] = g.IO.KeysDown[i] ? (g.IO.KeysDownDuration[i] < 0.0f ? 0.0f : g.IO.KeysDownDuration[i] + g.IO.DeltaTime) : -1.0f; // Update gamepad/keyboard directional navigation NavUpdate(); // Update mouse input state UpdateMouseInputs(); // Calculate frame-rate for the user, as a purely luxurious feature g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx]; g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime; g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame); g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame))) : FLT_MAX; // Find hovered window // (needs to be before UpdateMouseMovingWindowNewFrame so we fill g.HoveredWindowUnderMovingWindow on the mouse release frame) UpdateHoveredWindowAndCaptureFlags(); // Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering) UpdateMouseMovingWindowNewFrame(); // Background darkening/whitening if (GetTopMostPopupModal() != NULL || (g.NavWindowingTarget != NULL && g.NavWindowingHighlightAlpha > 0.0f)) g.DimBgRatio = ImMin(g.DimBgRatio + g.IO.DeltaTime * 6.0f, 1.0f); else g.DimBgRatio = ImMax(g.DimBgRatio - g.IO.DeltaTime * 10.0f, 0.0f); g.MouseCursor = ImGuiMouseCursor_Arrow; g.WantCaptureMouseNextFrame = g.WantCaptureKeyboardNextFrame = g.WantTextInputNextFrame = -1; g.PlatformImePos = ImVec2(1.0f, 1.0f); // OS Input Method Editor showing on top-left of our window by default // Mouse wheel scrolling, scale UpdateMouseWheel(); // Pressing TAB activate widget focus g.FocusTabPressed = (g.NavWindow && g.NavWindow->Active && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab)); if (g.ActiveId == 0 && g.FocusTabPressed) { // Note that SetKeyboardFocusHere() sets the Next fields mid-frame. To be consistent we also // manipulate the Next fields even, even though they will be turned into Curr fields by the code below. g.FocusRequestNextWindow = g.NavWindow; g.FocusRequestNextCounterRegular = INT_MAX; if (g.NavId != 0 && g.NavIdTabCounter != INT_MAX) g.FocusRequestNextCounterTabStop = g.NavIdTabCounter + 1 + (g.IO.KeyShift ? -1 : 1); else g.FocusRequestNextCounterTabStop = g.IO.KeyShift ? -1 : 0; } // Turn queued focus request into current one g.FocusRequestCurrWindow = NULL; g.FocusRequestCurrCounterRegular = g.FocusRequestCurrCounterTabStop = INT_MAX; if (g.FocusRequestNextWindow != NULL) { ImGuiWindow* window = g.FocusRequestNextWindow; g.FocusRequestCurrWindow = window; if (g.FocusRequestNextCounterRegular != INT_MAX && window->DC.FocusCounterRegular != -1) g.FocusRequestCurrCounterRegular = ImModPositive(g.FocusRequestNextCounterRegular, window->DC.FocusCounterRegular + 1); if (g.FocusRequestNextCounterTabStop != INT_MAX && window->DC.FocusCounterTabStop != -1) g.FocusRequestCurrCounterTabStop = ImModPositive(g.FocusRequestNextCounterTabStop, window->DC.FocusCounterTabStop + 1); g.FocusRequestNextWindow = NULL; g.FocusRequestNextCounterRegular = g.FocusRequestNextCounterTabStop = INT_MAX; } g.NavIdTabCounter = INT_MAX; // Mark all windows as not visible and compact unused memory. IM_ASSERT(g.WindowsFocusOrder.Size == g.Windows.Size); const float memory_compact_start_time = (g.IO.ConfigWindowsMemoryCompactTimer >= 0.0f) ? (float)g.Time - g.IO.ConfigWindowsMemoryCompactTimer : FLT_MAX; for (int i = 0; i != g.Windows.Size; i++) { ImGuiWindow* window = g.Windows[i]; window->WasActive = window->Active; window->BeginCount = 0; window->Active = false; window->WriteAccessed = false; // Garbage collect transient buffers of recently unused windows if (!window->WasActive && !window->MemoryCompacted && window->LastTimeActive < memory_compact_start_time) GcCompactTransientWindowBuffers(window); } // Closing the focused window restore focus to the first active root window in descending z-order if (g.NavWindow && !g.NavWindow->WasActive) FocusTopMostWindowUnderOne(NULL, NULL); // No window should be open at the beginning of the frame. // But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear. g.CurrentWindowStack.resize(0); g.BeginPopupStack.resize(0); ClosePopupsOverWindow(g.NavWindow, false); // [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack. UpdateDebugToolItemPicker(); // Create implicit/fallback window - which we will only render it if the user has added something to it. // We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags. // This fallback is particularly important as it avoid ImGui:: calls from crashing. g.WithinFrameScopeWithImplicitWindow = true; SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver); Begin("Debug##Default"); IM_ASSERT(g.CurrentWindow->IsFallbackWindow == true); #ifdef IMGUI_ENABLE_TEST_ENGINE ImGuiTestEngineHook_PostNewFrame(&g); #endif } // [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack. void ImGui::UpdateDebugToolItemPicker() { ImGuiContext& g = *GImGui; g.DebugItemPickerBreakId = 0; if (g.DebugItemPickerActive) { const ImGuiID hovered_id = g.HoveredIdPreviousFrame; ImGui::SetMouseCursor(ImGuiMouseCursor_Hand); if (ImGui::IsKeyPressedMap(ImGuiKey_Escape)) g.DebugItemPickerActive = false; if (ImGui::IsMouseClicked(0) && hovered_id) { g.DebugItemPickerBreakId = hovered_id; g.DebugItemPickerActive = false; } ImGui::SetNextWindowBgAlpha(0.60f); ImGui::BeginTooltip(); ImGui::Text("HoveredId: 0x%08X", hovered_id); ImGui::Text("Press ESC to abort picking."); ImGui::TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!"); ImGui::EndTooltip(); } } void ImGui::Initialize(ImGuiContext* context) { ImGuiContext& g = *context; IM_ASSERT(!g.Initialized && !g.SettingsLoaded); // Add .ini handle for ImGuiWindow type { ImGuiSettingsHandler ini_handler; ini_handler.TypeName = "Window"; ini_handler.TypeHash = ImHashStr("Window"); ini_handler.ReadOpenFn = WindowSettingsHandler_ReadOpen; ini_handler.ReadLineFn = WindowSettingsHandler_ReadLine; ini_handler.WriteAllFn = WindowSettingsHandler_WriteAll; g.SettingsHandlers.push_back(ini_handler); } #ifdef IMGUI_HAS_TABLE // Add .ini handle for ImGuiTable type { ImGuiSettingsHandler ini_handler; ini_handler.TypeName = "Table"; ini_handler.TypeHash = ImHashStr("Table"); ini_handler.ReadOpenFn = TableSettingsHandler_ReadOpen; ini_handler.ReadLineFn = TableSettingsHandler_ReadLine; ini_handler.WriteAllFn = TableSettingsHandler_WriteAll; g.SettingsHandlers.push_back(ini_handler); } #endif // #ifdef IMGUI_HAS_TABLE #ifdef IMGUI_HAS_DOCK #endif // #ifdef IMGUI_HAS_DOCK g.Initialized = true; } // This function is merely here to free heap allocations. void ImGui::Shutdown(ImGuiContext* context) { // The fonts atlas can be used prior to calling NewFrame(), so we clear it even if g.Initialized is FALSE (which would happen if we never called NewFrame) ImGuiContext& g = *context; if (g.IO.Fonts && g.FontAtlasOwnedByContext) { g.IO.Fonts->Locked = false; IM_DELETE(g.IO.Fonts); } g.IO.Fonts = NULL; // Cleanup of other data are conditional on actually having initialized Dear ImGui. if (!g.Initialized) return; // Save settings (unless we haven't attempted to load them: CreateContext/DestroyContext without a call to NewFrame shouldn't save an empty file) if (g.SettingsLoaded && g.IO.IniFilename != NULL) { ImGuiContext* backup_context = GImGui; SetCurrentContext(context); SaveIniSettingsToDisk(g.IO.IniFilename); SetCurrentContext(backup_context); } // Clear everything else for (int i = 0; i < g.Windows.Size; i++) IM_DELETE(g.Windows[i]); g.Windows.clear(); g.WindowsFocusOrder.clear(); g.WindowsTempSortBuffer.clear(); g.CurrentWindow = NULL; g.CurrentWindowStack.clear(); g.WindowsById.Clear(); g.NavWindow = NULL; g.HoveredWindow = g.HoveredRootWindow = NULL; g.ActiveIdWindow = g.ActiveIdPreviousFrameWindow = NULL; g.MovingWindow = NULL; g.ColorModifiers.clear(); g.StyleModifiers.clear(); g.FontStack.clear(); g.OpenPopupStack.clear(); g.BeginPopupStack.clear(); g.DrawDataBuilder.ClearFreeMemory(); g.BackgroundDrawList.ClearFreeMemory(); g.ForegroundDrawList.ClearFreeMemory(); g.TabBars.Clear(); g.CurrentTabBarStack.clear(); g.ShrinkWidthBuffer.clear(); g.PrivateClipboard.clear(); g.InputTextState.ClearFreeMemory(); g.SettingsWindows.clear(); g.SettingsHandlers.clear(); if (g.LogFile) { #ifndef IMGUI_DISABLE_TTY_FUNCTIONS if (g.LogFile != stdout) #endif ImFileClose(g.LogFile); g.LogFile = NULL; } g.LogBuffer.clear(); g.Initialized = false; } // FIXME: Add a more explicit sort order in the window structure. static int IMGUI_CDECL ChildWindowComparer(const void* lhs, const void* rhs) { const ImGuiWindow* const a = *(const ImGuiWindow* const *)lhs; const ImGuiWindow* const b = *(const ImGuiWindow* const *)rhs; if (int d = (a->Flags & ImGuiWindowFlags_Popup) - (b->Flags & ImGuiWindowFlags_Popup)) return d; if (int d = (a->Flags & ImGuiWindowFlags_Tooltip) - (b->Flags & ImGuiWindowFlags_Tooltip)) return d; return (a->BeginOrderWithinParent - b->BeginOrderWithinParent); } static void AddWindowToSortBuffer(ImVector* out_sorted_windows, ImGuiWindow* window) { out_sorted_windows->push_back(window); if (window->Active) { int count = window->DC.ChildWindows.Size; if (count > 1) ImQsort(window->DC.ChildWindows.Data, (size_t)count, sizeof(ImGuiWindow*), ChildWindowComparer); for (int i = 0; i < count; i++) { ImGuiWindow* child = window->DC.ChildWindows[i]; if (child->Active) AddWindowToSortBuffer(out_sorted_windows, child); } } } static void AddDrawListToDrawData(ImVector* out_list, ImDrawList* draw_list) { if (draw_list->CmdBuffer.empty()) return; // Remove trailing command if unused ImDrawCmd& last_cmd = draw_list->CmdBuffer.back(); if (last_cmd.ElemCount == 0 && last_cmd.UserCallback == NULL) { draw_list->CmdBuffer.pop_back(); if (draw_list->CmdBuffer.empty()) return; } // Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc. // May trigger for you if you are using PrimXXX functions incorrectly. IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size); IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size); if (!(draw_list->Flags & ImDrawListFlags_AllowVtxOffset)) IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size); // Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window) // If this assert triggers because you are drawing lots of stuff manually: // - First, make sure you are coarse clipping yourself and not trying to draw many things outside visible bounds. // Be mindful that the ImDrawList API doesn't filter vertices. Use the Metrics window to inspect draw list contents. // - If you want large meshes with more than 64K vertices, you can either: // (A) Handle the ImDrawCmd::VtxOffset value in your renderer back-end, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'. // Most example back-ends already support this from 1.71. Pre-1.71 back-ends won't. // Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them. // (B) Or handle 32-bit indices in your renderer back-end, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h. // Most example back-ends already support this. For example, the OpenGL example code detect index size at compile-time: // glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset); // Your own engine or render API may use different parameters or function calls to specify index sizes. // 2 and 4 bytes indices are generally supported by most graphics API. // - If for some reason neither of those solutions works for you, a workaround is to call BeginChild()/EndChild() before reaching // the 64K limit to split your draw commands in multiple draw lists. if (sizeof(ImDrawIdx) == 2) IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above"); out_list->push_back(draw_list); } static void AddWindowToDrawData(ImVector* out_render_list, ImGuiWindow* window) { ImGuiContext& g = *GImGui; g.IO.MetricsRenderWindows++; AddDrawListToDrawData(out_render_list, window->DrawList); for (int i = 0; i < window->DC.ChildWindows.Size; i++) { ImGuiWindow* child = window->DC.ChildWindows[i]; if (IsWindowActiveAndVisible(child)) // clipped children may have been marked not active AddWindowToDrawData(out_render_list, child); } } // Layer is locked for the root window, however child windows may use a different viewport (e.g. extruding menu) static void AddRootWindowToDrawData(ImGuiWindow* window) { ImGuiContext& g = *GImGui; int layer = (window->Flags & ImGuiWindowFlags_Tooltip) ? 1 : 0; AddWindowToDrawData(&g.DrawDataBuilder.Layers[layer], window); } void ImDrawDataBuilder::FlattenIntoSingleLayer() { int n = Layers[0].Size; int size = n; for (int i = 1; i < IM_ARRAYSIZE(Layers); i++) size += Layers[i].Size; Layers[0].resize(size); for (int layer_n = 1; layer_n < IM_ARRAYSIZE(Layers); layer_n++) { ImVector& layer = Layers[layer_n]; if (layer.empty()) continue; memcpy(&Layers[0][n], &layer[0], layer.Size * sizeof(ImDrawList*)); n += layer.Size; layer.resize(0); } } static void SetupDrawData(ImVector* draw_lists, ImDrawData* draw_data) { ImGuiIO& io = ImGui::GetIO(); draw_data->Valid = true; draw_data->CmdLists = (draw_lists->Size > 0) ? draw_lists->Data : NULL; draw_data->CmdListsCount = draw_lists->Size; draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0; draw_data->DisplayPos = ImVec2(0.0f, 0.0f); draw_data->DisplaySize = io.DisplaySize; draw_data->FramebufferScale = io.DisplayFramebufferScale; for (int n = 0; n < draw_lists->Size; n++) { draw_data->TotalVtxCount += draw_lists->Data[n]->VtxBuffer.Size; draw_data->TotalIdxCount += draw_lists->Data[n]->IdxBuffer.Size; } } // When using this function it is sane to ensure that float are perfectly rounded to integer values, to that e.g. (int)(max.x-min.x) in user's render produce correct result. void ImGui::PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect) { ImGuiWindow* window = GetCurrentWindow(); window->DrawList->PushClipRect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect); window->ClipRect = window->DrawList->_ClipRectStack.back(); } void ImGui::PopClipRect() { ImGuiWindow* window = GetCurrentWindow(); window->DrawList->PopClipRect(); window->ClipRect = window->DrawList->_ClipRectStack.back(); } // This is normally called by Render(). You may want to call it directly if you want to avoid calling Render() but the gain will be very minimal. void ImGui::EndFrame() { ImGuiContext& g = *GImGui; IM_ASSERT(g.Initialized); if (g.FrameCountEnded == g.FrameCount) // Don't process EndFrame() multiple times. return; IM_ASSERT(g.WithinFrameScope && "Forgot to call ImGui::NewFrame()?"); // Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME) if (g.IO.ImeSetInputScreenPosFn && (g.PlatformImeLastPos.x == FLT_MAX || ImLengthSqr(g.PlatformImeLastPos - g.PlatformImePos) > 0.0001f)) { g.IO.ImeSetInputScreenPosFn((int)g.PlatformImePos.x, (int)g.PlatformImePos.y); g.PlatformImeLastPos = g.PlatformImePos; } ErrorCheckEndFrame(); // Hide implicit/fallback "Debug" window if it hasn't been used g.WithinFrameScopeWithImplicitWindow = false; if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed) g.CurrentWindow->Active = false; End(); // Show CTRL+TAB list window if (g.NavWindowingTarget != NULL) NavUpdateWindowingOverlay(); // Drag and Drop: Elapse payload (if delivered, or if source stops being submitted) if (g.DragDropActive) { bool is_delivered = g.DragDropPayload.Delivery; bool is_elapsed = (g.DragDropPayload.DataFrameCount + 1 < g.FrameCount) && ((g.DragDropSourceFlags & ImGuiDragDropFlags_SourceAutoExpirePayload) || !IsMouseDown(g.DragDropMouseButton)); if (is_delivered || is_elapsed) ClearDragDrop(); } // Drag and Drop: Fallback for source tooltip. This is not ideal but better than nothing. if (g.DragDropActive && g.DragDropSourceFrameCount < g.FrameCount) { g.DragDropWithinSourceOrTarget = true; SetTooltip("..."); g.DragDropWithinSourceOrTarget = false; } // End frame g.WithinFrameScope = false; g.FrameCountEnded = g.FrameCount; // Initiate moving window + handle left-click and right-click focus UpdateMouseMovingWindowEndFrame(); // Sort the window list so that all child windows are after their parent // We cannot do that on FocusWindow() because childs may not exist yet g.WindowsTempSortBuffer.resize(0); g.WindowsTempSortBuffer.reserve(g.Windows.Size); for (int i = 0; i != g.Windows.Size; i++) { ImGuiWindow* window = g.Windows[i]; if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it continue; AddWindowToSortBuffer(&g.WindowsTempSortBuffer, window); } // This usually assert if there is a mismatch between the ImGuiWindowFlags_ChildWindow / ParentWindow values and DC.ChildWindows[] in parents, aka we've done something wrong. IM_ASSERT(g.Windows.Size == g.WindowsTempSortBuffer.Size); g.Windows.swap(g.WindowsTempSortBuffer); g.IO.MetricsActiveWindows = g.WindowsActiveCount; // Unlock font atlas g.IO.Fonts->Locked = false; // Clear Input data for next frame g.IO.MouseWheel = g.IO.MouseWheelH = 0.0f; g.IO.InputQueueCharacters.resize(0); memset(g.IO.NavInputs, 0, sizeof(g.IO.NavInputs)); } void ImGui::Render() { ImGuiContext& g = *GImGui; IM_ASSERT(g.Initialized); if (g.FrameCountEnded != g.FrameCount) EndFrame(); g.FrameCountRendered = g.FrameCount; g.IO.MetricsRenderWindows = 0; g.DrawDataBuilder.Clear(); // Add background ImDrawList if (!g.BackgroundDrawList.VtxBuffer.empty()) AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.BackgroundDrawList); // Add ImDrawList to render ImGuiWindow* windows_to_render_top_most[2]; windows_to_render_top_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL; windows_to_render_top_most[1] = (g.NavWindowingTarget ? g.NavWindowingList : NULL); for (int n = 0; n != g.Windows.Size; n++) { ImGuiWindow* window = g.Windows[n]; if (IsWindowActiveAndVisible(window) && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0 && window != windows_to_render_top_most[0] && window != windows_to_render_top_most[1]) AddRootWindowToDrawData(window); } for (int n = 0; n < IM_ARRAYSIZE(windows_to_render_top_most); n++) if (windows_to_render_top_most[n] && IsWindowActiveAndVisible(windows_to_render_top_most[n])) // NavWindowingTarget is always temporarily displayed as the top-most window AddRootWindowToDrawData(windows_to_render_top_most[n]); g.DrawDataBuilder.FlattenIntoSingleLayer(); // Draw software mouse cursor if requested if (g.IO.MouseDrawCursor) RenderMouseCursor(&g.ForegroundDrawList, g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48)); // Add foreground ImDrawList if (!g.ForegroundDrawList.VtxBuffer.empty()) AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.ForegroundDrawList); // Setup ImDrawData structure for end-user SetupDrawData(&g.DrawDataBuilder.Layers[0], &g.DrawData); g.IO.MetricsRenderVertices = g.DrawData.TotalVtxCount; g.IO.MetricsRenderIndices = g.DrawData.TotalIdxCount; // (Legacy) Call the Render callback function. The current prefer way is to let the user retrieve GetDrawData() and call the render function themselves. #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS if (g.DrawData.CmdListsCount > 0 && g.IO.RenderDrawListsFn != NULL) g.IO.RenderDrawListsFn(&g.DrawData); #endif } // Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. // CalcTextSize("") should return ImVec2(0.0f, g.FontSize) ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) { ImGuiContext& g = *GImGui; const char* text_display_end; if (hide_text_after_double_hash) text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string else text_display_end = text_end; ImFont* font = g.Font; const float font_size = g.FontSize; if (text == text_display_end) return ImVec2(0.0f, font_size); ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL); // Round text_size.x = IM_FLOOR(text_size.x + 0.95f); return text_size; } // Find window given position, search front-to-back // FIXME: Note that we have an inconsequential lag here: OuterRectClipped is updated in Begin(), so windows moved programatically // with SetWindowPos() and not SetNextWindowPos() will have that rectangle lagging by a frame at the time FindHoveredWindow() is // called, aka before the next Begin(). Moving window isn't affected. static void FindHoveredWindow() { ImGuiContext& g = *GImGui; ImGuiWindow* hovered_window = NULL; if (g.MovingWindow && !(g.MovingWindow->Flags & ImGuiWindowFlags_NoMouseInputs)) hovered_window = g.MovingWindow; ImVec2 padding_regular = g.Style.TouchExtraPadding; ImVec2 padding_for_resize_from_edges = g.IO.ConfigWindowsResizeFromEdges ? ImMax(g.Style.TouchExtraPadding, ImVec2(WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS, WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS)) : padding_regular; for (int i = g.Windows.Size - 1; i >= 0; i--) { ImGuiWindow* window = g.Windows[i]; if (!window->Active || window->Hidden) continue; if (window->Flags & ImGuiWindowFlags_NoMouseInputs) continue; // Using the clipped AABB, a child window will typically be clipped by its parent (not always) ImRect bb(window->OuterRectClipped); if (window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize)) bb.Expand(padding_regular); else bb.Expand(padding_for_resize_from_edges); if (!bb.Contains(g.IO.MousePos)) continue; // Those seemingly unnecessary extra tests are because the code here is a little different in viewport/docking branches. if (hovered_window == NULL) hovered_window = window; if (hovered_window) break; } g.HoveredWindow = hovered_window; g.HoveredRootWindow = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL; } // Test if mouse cursor is hovering given rectangle // NB- Rectangle is clipped by our current clip setting // NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding) bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip) { ImGuiContext& g = *GImGui; // Clip ImRect rect_clipped(r_min, r_max); if (clip) rect_clipped.ClipWith(g.CurrentWindow->ClipRect); // Expand for touch input const ImRect rect_for_touch(rect_clipped.Min - g.Style.TouchExtraPadding, rect_clipped.Max + g.Style.TouchExtraPadding); if (!rect_for_touch.Contains(g.IO.MousePos)) return false; return true; } int ImGui::GetKeyIndex(ImGuiKey imgui_key) { IM_ASSERT(imgui_key >= 0 && imgui_key < ImGuiKey_COUNT); ImGuiContext& g = *GImGui; return g.IO.KeyMap[imgui_key]; } // Note that dear imgui doesn't know the semantic of each entry of io.KeysDown[]! // Use your own indices/enums according to how your back-end/engine stored them into io.KeysDown[]! bool ImGui::IsKeyDown(int user_key_index) { if (user_key_index < 0) return false; ImGuiContext& g = *GImGui; IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown)); return g.IO.KeysDown[user_key_index]; } // t0 = previous time (e.g.: g.Time - g.IO.DeltaTime) // t1 = current time (e.g.: g.Time) // An event is triggered at: // t = 0.0f t = repeat_delay, t = repeat_delay + repeat_rate*N int ImGui::CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, float repeat_rate) { if (t1 == 0.0f) return 1; if (t0 >= t1) return 0; if (repeat_rate <= 0.0f) return (t0 < repeat_delay) && (t1 >= repeat_delay); const int count_t0 = (t0 < repeat_delay) ? -1 : (int)((t0 - repeat_delay) / repeat_rate); const int count_t1 = (t1 < repeat_delay) ? -1 : (int)((t1 - repeat_delay) / repeat_rate); const int count = count_t1 - count_t0; return count; } int ImGui::GetKeyPressedAmount(int key_index, float repeat_delay, float repeat_rate) { ImGuiContext& g = *GImGui; if (key_index < 0) return 0; IM_ASSERT(key_index >= 0 && key_index < IM_ARRAYSIZE(g.IO.KeysDown)); const float t = g.IO.KeysDownDuration[key_index]; return CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, repeat_delay, repeat_rate); } bool ImGui::IsKeyPressed(int user_key_index, bool repeat) { ImGuiContext& g = *GImGui; if (user_key_index < 0) return false; IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown)); const float t = g.IO.KeysDownDuration[user_key_index]; if (t == 0.0f) return true; if (repeat && t > g.IO.KeyRepeatDelay) return GetKeyPressedAmount(user_key_index, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate) > 0; return false; } bool ImGui::IsKeyReleased(int user_key_index) { ImGuiContext& g = *GImGui; if (user_key_index < 0) return false; IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown)); return g.IO.KeysDownDurationPrev[user_key_index] >= 0.0f && !g.IO.KeysDown[user_key_index]; } bool ImGui::IsMouseDown(ImGuiMouseButton button) { ImGuiContext& g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); return g.IO.MouseDown[button]; } bool ImGui::IsMouseClicked(ImGuiMouseButton button, bool repeat) { ImGuiContext& g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); const float t = g.IO.MouseDownDuration[button]; if (t == 0.0f) return true; if (repeat && t > g.IO.KeyRepeatDelay) { // FIXME: 2019/05/03: Our old repeat code was wrong here and led to doubling the repeat rate, which made it an ok rate for repeat on mouse hold. int amount = CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate * 0.50f); if (amount > 0) return true; } return false; } bool ImGui::IsMouseReleased(ImGuiMouseButton button) { ImGuiContext& g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); return g.IO.MouseReleased[button]; } bool ImGui::IsMouseDoubleClicked(ImGuiMouseButton button) { ImGuiContext& g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); return g.IO.MouseDoubleClicked[button]; } // [Internal] This doesn't test if the button is pressed bool ImGui::IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold) { ImGuiContext& g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); if (lock_threshold < 0.0f) lock_threshold = g.IO.MouseDragThreshold; return g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold; } bool ImGui::IsMouseDragging(ImGuiMouseButton button, float lock_threshold) { ImGuiContext& g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); if (!g.IO.MouseDown[button]) return false; return IsMouseDragPastThreshold(button, lock_threshold); } ImVec2 ImGui::GetMousePos() { ImGuiContext& g = *GImGui; return g.IO.MousePos; } // NB: prefer to call right after BeginPopup(). At the time Selectable/MenuItem is activated, the popup is already closed! ImVec2 ImGui::GetMousePosOnOpeningCurrentPopup() { ImGuiContext& g = *GImGui; if (g.BeginPopupStack.Size > 0) return g.OpenPopupStack[g.BeginPopupStack.Size-1].OpenMousePos; return g.IO.MousePos; } // We typically use ImVec2(-FLT_MAX,-FLT_MAX) to denote an invalid mouse position. bool ImGui::IsMousePosValid(const ImVec2* mouse_pos) { // The assert is only to silence a false-positive in XCode Static Analysis. // Because GImGui is not dereferenced in every code path, the static analyzer assume that it may be NULL (which it doesn't for other functions). IM_ASSERT(GImGui != NULL); const float MOUSE_INVALID = -256000.0f; ImVec2 p = mouse_pos ? *mouse_pos : GImGui->IO.MousePos; return p.x >= MOUSE_INVALID && p.y >= MOUSE_INVALID; } bool ImGui::IsAnyMouseDown() { ImGuiContext& g = *GImGui; for (int n = 0; n < IM_ARRAYSIZE(g.IO.MouseDown); n++) if (g.IO.MouseDown[n]) return true; return false; } // Return the delta from the initial clicking position while the mouse button is clicked or was just released. // This is locked and return 0.0f until the mouse moves past a distance threshold at least once. // NB: This is only valid if IsMousePosValid(). Back-ends in theory should always keep mouse position valid when dragging even outside the client window. ImVec2 ImGui::GetMouseDragDelta(ImGuiMouseButton button, float lock_threshold) { ImGuiContext& g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); if (lock_threshold < 0.0f) lock_threshold = g.IO.MouseDragThreshold; if (g.IO.MouseDown[button] || g.IO.MouseReleased[button]) if (g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold) if (IsMousePosValid(&g.IO.MousePos) && IsMousePosValid(&g.IO.MouseClickedPos[button])) return g.IO.MousePos - g.IO.MouseClickedPos[button]; return ImVec2(0.0f, 0.0f); } void ImGui::ResetMouseDragDelta(ImGuiMouseButton button) { ImGuiContext& g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); // NB: We don't need to reset g.IO.MouseDragMaxDistanceSqr g.IO.MouseClickedPos[button] = g.IO.MousePos; } ImGuiMouseCursor ImGui::GetMouseCursor() { return GImGui->MouseCursor; } void ImGui::SetMouseCursor(ImGuiMouseCursor cursor_type) { GImGui->MouseCursor = cursor_type; } void ImGui::CaptureKeyboardFromApp(bool capture) { GImGui->WantCaptureKeyboardNextFrame = capture ? 1 : 0; } void ImGui::CaptureMouseFromApp(bool capture) { GImGui->WantCaptureMouseNextFrame = capture ? 1 : 0; } bool ImGui::IsItemActive() { ImGuiContext& g = *GImGui; if (g.ActiveId) { ImGuiWindow* window = g.CurrentWindow; return g.ActiveId == window->DC.LastItemId; } return false; } bool ImGui::IsItemActivated() { ImGuiContext& g = *GImGui; if (g.ActiveId) { ImGuiWindow* window = g.CurrentWindow; if (g.ActiveId == window->DC.LastItemId && g.ActiveIdPreviousFrame != window->DC.LastItemId) return true; } return false; } bool ImGui::IsItemDeactivated() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HasDeactivated) return (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_Deactivated) != 0; return (g.ActiveIdPreviousFrame == window->DC.LastItemId && g.ActiveIdPreviousFrame != 0 && g.ActiveId != window->DC.LastItemId); } bool ImGui::IsItemDeactivatedAfterEdit() { ImGuiContext& g = *GImGui; return IsItemDeactivated() && (g.ActiveIdPreviousFrameHasBeenEditedBefore || (g.ActiveId == 0 && g.ActiveIdHasBeenEditedBefore)); } bool ImGui::IsItemFocused() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (g.NavId == 0 || g.NavDisableHighlight || g.NavId != window->DC.LastItemId) return false; return true; } bool ImGui::IsItemClicked(ImGuiMouseButton mouse_button) { return IsMouseClicked(mouse_button) && IsItemHovered(ImGuiHoveredFlags_None); } bool ImGui::IsItemToggledOpen() { ImGuiContext& g = *GImGui; return (g.CurrentWindow->DC.LastItemStatusFlags & ImGuiItemStatusFlags_ToggledOpen) ? true : false; } bool ImGui::IsItemToggledSelection() { ImGuiContext& g = *GImGui; return (g.CurrentWindow->DC.LastItemStatusFlags & ImGuiItemStatusFlags_ToggledSelection) ? true : false; } bool ImGui::IsAnyItemHovered() { ImGuiContext& g = *GImGui; return g.HoveredId != 0 || g.HoveredIdPreviousFrame != 0; } bool ImGui::IsAnyItemActive() { ImGuiContext& g = *GImGui; return g.ActiveId != 0; } bool ImGui::IsAnyItemFocused() { ImGuiContext& g = *GImGui; return g.NavId != 0 && !g.NavDisableHighlight; } bool ImGui::IsItemVisible() { ImGuiWindow* window = GetCurrentWindowRead(); return window->ClipRect.Overlaps(window->DC.LastItemRect); } bool ImGui::IsItemEdited() { ImGuiWindow* window = GetCurrentWindowRead(); return (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_Edited) != 0; } // Allow last item to be overlapped by a subsequent item. Both may be activated during the same frame before the later one takes priority. void ImGui::SetItemAllowOverlap() { ImGuiContext& g = *GImGui; if (g.HoveredId == g.CurrentWindow->DC.LastItemId) g.HoveredIdAllowOverlap = true; if (g.ActiveId == g.CurrentWindow->DC.LastItemId) g.ActiveIdAllowOverlap = true; } ImVec2 ImGui::GetItemRectMin() { ImGuiWindow* window = GetCurrentWindowRead(); return window->DC.LastItemRect.Min; } ImVec2 ImGui::GetItemRectMax() { ImGuiWindow* window = GetCurrentWindowRead(); return window->DC.LastItemRect.Max; } ImVec2 ImGui::GetItemRectSize() { ImGuiWindow* window = GetCurrentWindowRead(); return window->DC.LastItemRect.GetSize(); } static ImRect GetViewportRect() { ImGuiContext& g = *GImGui; return ImRect(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y); } bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* parent_window = g.CurrentWindow; flags |= ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_ChildWindow; flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag // Size const ImVec2 content_avail = GetContentRegionAvail(); ImVec2 size = ImFloor(size_arg); const int auto_fit_axises = ((size.x == 0.0f) ? (1 << ImGuiAxis_X) : 0x00) | ((size.y == 0.0f) ? (1 << ImGuiAxis_Y) : 0x00); if (size.x <= 0.0f) size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too much issues) if (size.y <= 0.0f) size.y = ImMax(content_avail.y + size.y, 4.0f); SetNextWindowSize(size); // Build up name. If you need to append to a same child from multiple location in the ID stack, use BeginChild(ImGuiID id) with a stable value. char title[256]; if (name) ImFormatString(title, IM_ARRAYSIZE(title), "%s/%s_%08X", parent_window->Name, name, id); else ImFormatString(title, IM_ARRAYSIZE(title), "%s/%08X", parent_window->Name, id); const float backup_border_size = g.Style.ChildBorderSize; if (!border) g.Style.ChildBorderSize = 0.0f; bool ret = Begin(title, NULL, flags); g.Style.ChildBorderSize = backup_border_size; ImGuiWindow* child_window = g.CurrentWindow; child_window->ChildId = id; child_window->AutoFitChildAxises = (ImS8)auto_fit_axises; // Set the cursor to handle case where the user called SetNextWindowPos()+BeginChild() manually. // While this is not really documented/defined, it seems that the expected thing to do. if (child_window->BeginCount == 1) parent_window->DC.CursorPos = child_window->Pos; // Process navigation-in immediately so NavInit can run on first frame if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayerActiveMask != 0 || child_window->DC.NavHasScroll)) { FocusWindow(child_window); NavInitWindow(child_window, false); SetActiveID(id+1, child_window); // Steal ActiveId with a dummy id so that key-press won't activate child item g.ActiveIdSource = ImGuiInputSource_Nav; } return ret; } bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) { ImGuiWindow* window = GetCurrentWindow(); return BeginChildEx(str_id, window->GetID(str_id), size_arg, border, extra_flags); } bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) { IM_ASSERT(id != 0); return BeginChildEx(NULL, id, size_arg, border, extra_flags); } void ImGui::EndChild() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; IM_ASSERT(g.WithinEndChild == false); IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() calls g.WithinEndChild = true; if (window->BeginCount > 1) { End(); } else { ImVec2 sz = window->Size; if (window->AutoFitChildAxises & (1 << ImGuiAxis_X)) // Arbitrary minimum zero-ish child size of 4.0f causes less trouble than a 0.0f sz.x = ImMax(4.0f, sz.x); if (window->AutoFitChildAxises & (1 << ImGuiAxis_Y)) sz.y = ImMax(4.0f, sz.y); End(); ImGuiWindow* parent_window = g.CurrentWindow; ImRect bb(parent_window->DC.CursorPos, parent_window->DC.CursorPos + sz); ItemSize(sz); if ((window->DC.NavLayerActiveMask != 0 || window->DC.NavHasScroll) && !(window->Flags & ImGuiWindowFlags_NavFlattened)) { ItemAdd(bb, window->ChildId); RenderNavHighlight(bb, window->ChildId); // When browsing a window that has no activable items (scroll only) we keep a highlight on the child if (window->DC.NavLayerActiveMask == 0 && window == g.NavWindow) RenderNavHighlight(ImRect(bb.Min - ImVec2(2,2), bb.Max + ImVec2(2,2)), g.NavId, ImGuiNavHighlightFlags_TypeThin); } else { // Not navigable into ItemAdd(bb, 0); } } g.WithinEndChild = false; } // Helper to create a child window / scrolling region that looks like a normal widget frame. bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags) { ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]); PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding); PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize); PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding); bool ret = BeginChild(id, size, true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysUseWindowPadding | extra_flags); PopStyleVar(3); PopStyleColor(); return ret; } void ImGui::EndChildFrame() { EndChild(); } static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled) { window->SetWindowPosAllowFlags = enabled ? (window->SetWindowPosAllowFlags | flags) : (window->SetWindowPosAllowFlags & ~flags); window->SetWindowSizeAllowFlags = enabled ? (window->SetWindowSizeAllowFlags | flags) : (window->SetWindowSizeAllowFlags & ~flags); window->SetWindowCollapsedAllowFlags = enabled ? (window->SetWindowCollapsedAllowFlags | flags) : (window->SetWindowCollapsedAllowFlags & ~flags); } ImGuiWindow* ImGui::FindWindowByID(ImGuiID id) { ImGuiContext& g = *GImGui; return (ImGuiWindow*)g.WindowsById.GetVoidPtr(id); } ImGuiWindow* ImGui::FindWindowByName(const char* name) { ImGuiID id = ImHashStr(name); return FindWindowByID(id); } static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags) { ImGuiContext& g = *GImGui; //IMGUI_DEBUG_LOG("CreateNewWindow '%s', flags = 0x%08X\n", name, flags); // Create window the first time ImGuiWindow* window = IM_NEW(ImGuiWindow)(&g, name); window->Flags = flags; g.WindowsById.SetVoidPtr(window->ID, window); // Default/arbitrary window position. Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window. window->Pos = ImVec2(60, 60); // User can disable loading and saving of settings. Tooltip and child windows also don't store settings. if (!(flags & ImGuiWindowFlags_NoSavedSettings)) if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID)) { // Retrieve settings from .ini file window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings); SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false); window->Pos = ImVec2(settings->Pos.x, settings->Pos.y); window->Collapsed = settings->Collapsed; if (settings->Size.x > 0 && settings->Size.y > 0) size = ImVec2(settings->Size.x, settings->Size.y); } window->Size = window->SizeFull = ImFloor(size); window->DC.CursorStartPos = window->DC.CursorMaxPos = window->Pos; // So first call to CalcContentSize() doesn't return crazy values if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0) { window->AutoFitFramesX = window->AutoFitFramesY = 2; window->AutoFitOnlyGrows = false; } else { if (window->Size.x <= 0.0f) window->AutoFitFramesX = 2; if (window->Size.y <= 0.0f) window->AutoFitFramesY = 2; window->AutoFitOnlyGrows = (window->AutoFitFramesX > 0) || (window->AutoFitFramesY > 0); } g.WindowsFocusOrder.push_back(window); if (flags & ImGuiWindowFlags_NoBringToFrontOnFocus) g.Windows.push_front(window); // Quite slow but rare and only once else g.Windows.push_back(window); return window; } static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size) { ImGuiContext& g = *GImGui; if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint) { // Using -1,-1 on either X/Y axis to preserve the current size. ImRect cr = g.NextWindowData.SizeConstraintRect; new_size.x = (cr.Min.x >= 0 && cr.Max.x >= 0) ? ImClamp(new_size.x, cr.Min.x, cr.Max.x) : window->SizeFull.x; new_size.y = (cr.Min.y >= 0 && cr.Max.y >= 0) ? ImClamp(new_size.y, cr.Min.y, cr.Max.y) : window->SizeFull.y; if (g.NextWindowData.SizeCallback) { ImGuiSizeCallbackData data; data.UserData = g.NextWindowData.SizeCallbackUserData; data.Pos = window->Pos; data.CurrentSize = window->SizeFull; data.DesiredSize = new_size; g.NextWindowData.SizeCallback(&data); new_size = data.DesiredSize; } new_size.x = IM_FLOOR(new_size.x); new_size.y = IM_FLOOR(new_size.y); } // Minimum size if (!(window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize))) { ImGuiWindow* window_for_height = window; new_size = ImMax(new_size, g.Style.WindowMinSize); new_size.y = ImMax(new_size.y, window_for_height->TitleBarHeight() + window_for_height->MenuBarHeight() + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows } return new_size; } static ImVec2 CalcWindowContentSize(ImGuiWindow* window) { if (window->Collapsed) if (window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0) return window->ContentSize; if (window->Hidden && window->HiddenFramesCannotSkipItems == 0 && window->HiddenFramesCanSkipItems > 0) return window->ContentSize; ImVec2 sz; sz.x = IM_FLOOR((window->ContentSizeExplicit.x != 0.0f) ? window->ContentSizeExplicit.x : window->DC.CursorMaxPos.x - window->DC.CursorStartPos.x); sz.y = IM_FLOOR((window->ContentSizeExplicit.y != 0.0f) ? window->ContentSizeExplicit.y : window->DC.CursorMaxPos.y - window->DC.CursorStartPos.y); return sz; } static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_contents) { ImGuiContext& g = *GImGui; ImGuiStyle& style = g.Style; ImVec2 size_decorations = ImVec2(0.0f, window->TitleBarHeight() + window->MenuBarHeight()); ImVec2 size_pad = window->WindowPadding * 2.0f; ImVec2 size_desired = size_contents + size_pad + size_decorations; if (window->Flags & ImGuiWindowFlags_Tooltip) { // Tooltip always resize return size_desired; } else { // Maximum window size is determined by the viewport size or monitor size const bool is_popup = (window->Flags & ImGuiWindowFlags_Popup) != 0; const bool is_menu = (window->Flags & ImGuiWindowFlags_ChildMenu) != 0; ImVec2 size_min = style.WindowMinSize; if (is_popup || is_menu) // Popups and menus bypass style.WindowMinSize by default, but we give then a non-zero minimum size to facilitate understanding problematic cases (e.g. empty popups) size_min = ImMin(size_min, ImVec2(4.0f, 4.0f)); ImVec2 size_auto_fit = ImClamp(size_desired, size_min, ImMax(size_min, g.IO.DisplaySize - style.DisplaySafeAreaPadding * 2.0f)); // When the window cannot fit all contents (either because of constraints, either because screen is too small), // we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than ViewportSize-WindowPadding. ImVec2 size_auto_fit_after_constraint = CalcWindowSizeAfterConstraint(window, size_auto_fit); bool will_have_scrollbar_x = (size_auto_fit_after_constraint.x - size_pad.x - size_decorations.x < size_contents.x && !(window->Flags & ImGuiWindowFlags_NoScrollbar) && (window->Flags & ImGuiWindowFlags_HorizontalScrollbar)) || (window->Flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar); bool will_have_scrollbar_y = (size_auto_fit_after_constraint.y - size_pad.y - size_decorations.y < size_contents.y && !(window->Flags & ImGuiWindowFlags_NoScrollbar)) || (window->Flags & ImGuiWindowFlags_AlwaysVerticalScrollbar); if (will_have_scrollbar_x) size_auto_fit.y += style.ScrollbarSize; if (will_have_scrollbar_y) size_auto_fit.x += style.ScrollbarSize; return size_auto_fit; } } ImVec2 ImGui::CalcWindowExpectedSize(ImGuiWindow* window) { ImVec2 size_contents = CalcWindowContentSize(window); ImVec2 size_auto_fit = CalcWindowAutoFitSize(window, size_contents); ImVec2 size_final = CalcWindowSizeAfterConstraint(window, size_auto_fit); return size_final; } static ImGuiCol GetWindowBgColorIdxFromFlags(ImGuiWindowFlags flags) { if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) return ImGuiCol_PopupBg; if (flags & ImGuiWindowFlags_ChildWindow) return ImGuiCol_ChildBg; return ImGuiCol_WindowBg; } static void CalcResizePosSizeFromAnyCorner(ImGuiWindow* window, const ImVec2& corner_target, const ImVec2& corner_norm, ImVec2* out_pos, ImVec2* out_size) { ImVec2 pos_min = ImLerp(corner_target, window->Pos, corner_norm); // Expected window upper-left ImVec2 pos_max = ImLerp(window->Pos + window->Size, corner_target, corner_norm); // Expected window lower-right ImVec2 size_expected = pos_max - pos_min; ImVec2 size_constrained = CalcWindowSizeAfterConstraint(window, size_expected); *out_pos = pos_min; if (corner_norm.x == 0.0f) out_pos->x -= (size_constrained.x - size_expected.x); if (corner_norm.y == 0.0f) out_pos->y -= (size_constrained.y - size_expected.y); *out_size = size_constrained; } struct ImGuiResizeGripDef { ImVec2 CornerPosN; ImVec2 InnerDir; int AngleMin12, AngleMax12; }; static const ImGuiResizeGripDef resize_grip_def[4] = { { ImVec2(1,1), ImVec2(-1,-1), 0, 3 }, // Lower-right { ImVec2(0,1), ImVec2(+1,-1), 3, 6 }, // Lower-left { ImVec2(0,0), ImVec2(+1,+1), 6, 9 }, // Upper-left (Unused) { ImVec2(1,0), ImVec2(-1,+1), 9,12 }, // Upper-right (Unused) }; static ImRect GetResizeBorderRect(ImGuiWindow* window, int border_n, float perp_padding, float thickness) { ImRect rect = window->Rect(); if (thickness == 0.0f) rect.Max -= ImVec2(1,1); if (border_n == 0) return ImRect(rect.Min.x + perp_padding, rect.Min.y - thickness, rect.Max.x - perp_padding, rect.Min.y + thickness); // Top if (border_n == 1) return ImRect(rect.Max.x - thickness, rect.Min.y + perp_padding, rect.Max.x + thickness, rect.Max.y - perp_padding); // Right if (border_n == 2) return ImRect(rect.Min.x + perp_padding, rect.Max.y - thickness, rect.Max.x - perp_padding, rect.Max.y + thickness); // Bottom if (border_n == 3) return ImRect(rect.Min.x - thickness, rect.Min.y + perp_padding, rect.Min.x + thickness, rect.Max.y - perp_padding); // Left IM_ASSERT(0); return ImRect(); } // 0..3: corners (Lower-right, Lower-left, Unused, Unused) // 4..7: borders (Top, Right, Bottom, Left) ImGuiID ImGui::GetWindowResizeID(ImGuiWindow* window, int n) { IM_ASSERT(n >= 0 && n <= 7); ImGuiID id = window->ID; id = ImHashStr("#RESIZE", 0, id); id = ImHashData(&n, sizeof(int), id); return id; } // Handle resize for: Resize Grips, Borders, Gamepad // Return true when using auto-fit (double click on resize grip) static bool ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]) { ImGuiContext& g = *GImGui; ImGuiWindowFlags flags = window->Flags; if ((flags & ImGuiWindowFlags_NoResize) || (flags & ImGuiWindowFlags_AlwaysAutoResize) || window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) return false; if (window->WasActive == false) // Early out to avoid running this code for e.g. an hidden implicit/fallback Debug window. return false; bool ret_auto_fit = false; const int resize_border_count = g.IO.ConfigWindowsResizeFromEdges ? 4 : 0; const float grip_draw_size = IM_FLOOR(ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f)); const float grip_hover_inner_size = IM_FLOOR(grip_draw_size * 0.75f); const float grip_hover_outer_size = g.IO.ConfigWindowsResizeFromEdges ? WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS : 0.0f; ImVec2 pos_target(FLT_MAX, FLT_MAX); ImVec2 size_target(FLT_MAX, FLT_MAX); // Resize grips and borders are on layer 1 window->DC.NavLayerCurrent = ImGuiNavLayer_Menu; window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Menu); // Manual resize grips PushID("#RESIZE"); for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++) { const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n]; const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPosN); // Using the FlattenChilds button flag we make the resize button accessible even if we are hovering over a child window ImRect resize_rect(corner - grip.InnerDir * grip_hover_outer_size, corner + grip.InnerDir * grip_hover_inner_size); if (resize_rect.Min.x > resize_rect.Max.x) ImSwap(resize_rect.Min.x, resize_rect.Max.x); if (resize_rect.Min.y > resize_rect.Max.y) ImSwap(resize_rect.Min.y, resize_rect.Max.y); bool hovered, held; ButtonBehavior(resize_rect, window->GetID(resize_grip_n), &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus); //GetForegroundDrawList(window)->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255)); if (hovered || held) g.MouseCursor = (resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE; if (held && g.IO.MouseDoubleClicked[0] && resize_grip_n == 0) { // Manual auto-fit when double-clicking size_target = CalcWindowSizeAfterConstraint(window, size_auto_fit); ret_auto_fit = true; ClearActiveID(); } else if (held) { // Resize from any of the four corners // We don't use an incremental MouseDelta but rather compute an absolute target size based on mouse position ImVec2 corner_target = g.IO.MousePos - g.ActiveIdClickOffset + ImLerp(grip.InnerDir * grip_hover_outer_size, grip.InnerDir * -grip_hover_inner_size, grip.CornerPosN); // Corner of the window corresponding to our corner grip CalcResizePosSizeFromAnyCorner(window, corner_target, grip.CornerPosN, &pos_target, &size_target); } if (resize_grip_n == 0 || held || hovered) resize_grip_col[resize_grip_n] = GetColorU32(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip); } for (int border_n = 0; border_n < resize_border_count; border_n++) { bool hovered, held; ImRect border_rect = GetResizeBorderRect(window, border_n, grip_hover_inner_size, WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); ButtonBehavior(border_rect, window->GetID(border_n + 4), &hovered, &held, ImGuiButtonFlags_FlattenChildren); //GetForegroundDrawLists(window)->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255)); if ((hovered && g.HoveredIdTimer > WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER) || held) { g.MouseCursor = (border_n & 1) ? ImGuiMouseCursor_ResizeEW : ImGuiMouseCursor_ResizeNS; if (held) *border_held = border_n; } if (held) { ImVec2 border_target = window->Pos; ImVec2 border_posn; if (border_n == 0) { border_posn = ImVec2(0, 0); border_target.y = (g.IO.MousePos.y - g.ActiveIdClickOffset.y + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Top if (border_n == 1) { border_posn = ImVec2(1, 0); border_target.x = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Right if (border_n == 2) { border_posn = ImVec2(0, 1); border_target.y = (g.IO.MousePos.y - g.ActiveIdClickOffset.y + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Bottom if (border_n == 3) { border_posn = ImVec2(0, 0); border_target.x = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Left CalcResizePosSizeFromAnyCorner(window, border_target, border_posn, &pos_target, &size_target); } } PopID(); // Restore nav layer window->DC.NavLayerCurrent = ImGuiNavLayer_Main; window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main); // Navigation resize (keyboard/gamepad) if (g.NavWindowingTarget && g.NavWindowingTarget->RootWindow == window) { ImVec2 nav_resize_delta; if (g.NavInputSource == ImGuiInputSource_NavKeyboard && g.IO.KeyShift) nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down); if (g.NavInputSource == ImGuiInputSource_NavGamepad) nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_Down); if (nav_resize_delta.x != 0.0f || nav_resize_delta.y != 0.0f) { const float NAV_RESIZE_SPEED = 600.0f; nav_resize_delta *= ImFloor(NAV_RESIZE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y)); g.NavWindowingToggleLayer = false; g.NavDisableMouseHover = true; resize_grip_col[0] = GetColorU32(ImGuiCol_ResizeGripActive); // FIXME-NAV: Should store and accumulate into a separate size buffer to handle sizing constraints properly, right now a constraint will make us stuck. size_target = CalcWindowSizeAfterConstraint(window, window->SizeFull + nav_resize_delta); } } // Apply back modified position/size to window if (size_target.x != FLT_MAX) { window->SizeFull = size_target; MarkIniSettingsDirty(window); } if (pos_target.x != FLT_MAX) { window->Pos = ImFloor(pos_target); MarkIniSettingsDirty(window); } window->Size = window->SizeFull; return ret_auto_fit; } static inline void ClampWindowRect(ImGuiWindow* window, const ImRect& rect, const ImVec2& padding) { ImGuiContext& g = *GImGui; ImVec2 size_for_clamping = (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(window->Flags & ImGuiWindowFlags_NoTitleBar)) ? ImVec2(window->Size.x, window->TitleBarHeight()) : window->Size; window->Pos = ImMin(rect.Max - padding, ImMax(window->Pos + size_for_clamping, rect.Min + padding) - size_for_clamping); } static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window) { ImGuiContext& g = *GImGui; float rounding = window->WindowRounding; float border_size = window->WindowBorderSize; if (border_size > 0.0f && !(window->Flags & ImGuiWindowFlags_NoBackground)) window->DrawList->AddRect(window->Pos, window->Pos + window->Size, GetColorU32(ImGuiCol_Border), rounding, ImDrawCornerFlags_All, border_size); int border_held = window->ResizeBorderHeld; if (border_held != -1) { struct ImGuiResizeBorderDef { ImVec2 InnerDir; ImVec2 CornerPosN1, CornerPosN2; float OuterAngle; }; static const ImGuiResizeBorderDef resize_border_def[4] = { { ImVec2(0,+1), ImVec2(0,0), ImVec2(1,0), IM_PI*1.50f }, // Top { ImVec2(-1,0), ImVec2(1,0), ImVec2(1,1), IM_PI*0.00f }, // Right { ImVec2(0,-1), ImVec2(1,1), ImVec2(0,1), IM_PI*0.50f }, // Bottom { ImVec2(+1,0), ImVec2(0,1), ImVec2(0,0), IM_PI*1.00f } // Left }; const ImGuiResizeBorderDef& def = resize_border_def[border_held]; ImRect border_r = GetResizeBorderRect(window, border_held, rounding, 0.0f); window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.CornerPosN1) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle - IM_PI*0.25f, def.OuterAngle); window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.CornerPosN2) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle, def.OuterAngle + IM_PI*0.25f); window->DrawList->PathStroke(GetColorU32(ImGuiCol_SeparatorActive), false, ImMax(2.0f, border_size)); // Thicker than usual } if (g.Style.FrameBorderSize > 0 && !(window->Flags & ImGuiWindowFlags_NoTitleBar)) { float y = window->Pos.y + window->TitleBarHeight() - 1; window->DrawList->AddLine(ImVec2(window->Pos.x + border_size, y), ImVec2(window->Pos.x + window->Size.x - border_size, y), GetColorU32(ImGuiCol_Border), g.Style.FrameBorderSize); } } // Draw background and borders // Draw and handle scrollbars void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size) { ImGuiContext& g = *GImGui; ImGuiStyle& style = g.Style; ImGuiWindowFlags flags = window->Flags; // Ensure that ScrollBar doesn't read last frame's SkipItems window->SkipItems = false; // Draw window + handle manual resize // As we highlight the title bar when want_focus is set, multiple reappearing windows will have have their title bar highlighted on their reappearing frame. const float window_rounding = window->WindowRounding; const float window_border_size = window->WindowBorderSize; if (window->Collapsed) { // Title bar only float backup_border_size = style.FrameBorderSize; g.Style.FrameBorderSize = window->WindowBorderSize; ImU32 title_bar_col = GetColorU32((title_bar_is_highlight && !g.NavDisableHighlight) ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBgCollapsed); RenderFrame(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, true, window_rounding); g.Style.FrameBorderSize = backup_border_size; } else { // Window background if (!(flags & ImGuiWindowFlags_NoBackground)) { ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags)); bool override_alpha = false; float alpha = 1.0f; if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasBgAlpha) { alpha = g.NextWindowData.BgAlphaVal; override_alpha = true; } if (override_alpha) bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(alpha) << IM_COL32_A_SHIFT); window->DrawList->AddRectFilled(window->Pos + ImVec2(0, window->TitleBarHeight()), window->Pos + window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot); } // Title bar if (!(flags & ImGuiWindowFlags_NoTitleBar)) { ImU32 title_bar_col = GetColorU32(title_bar_is_highlight ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg); window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, window_rounding, ImDrawCornerFlags_Top); } // Menu bar if (flags & ImGuiWindowFlags_MenuBar) { ImRect menu_bar_rect = window->MenuBarRect(); menu_bar_rect.ClipWith(window->Rect()); // Soft clipping, in particular child window don't have minimum size covering the menu bar so this is useful for them. window->DrawList->AddRectFilled(menu_bar_rect.Min + ImVec2(window_border_size, 0), menu_bar_rect.Max - ImVec2(window_border_size, 0), GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, ImDrawCornerFlags_Top); if (style.FrameBorderSize > 0.0f && menu_bar_rect.Max.y < window->Pos.y + window->Size.y) window->DrawList->AddLine(menu_bar_rect.GetBL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_Border), style.FrameBorderSize); } // Scrollbars if (window->ScrollbarX) Scrollbar(ImGuiAxis_X); if (window->ScrollbarY) Scrollbar(ImGuiAxis_Y); // Render resize grips (after their input handling so we don't have a frame of latency) if (!(flags & ImGuiWindowFlags_NoResize)) { for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++) { const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n]; const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPosN); window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(window_border_size, resize_grip_draw_size) : ImVec2(resize_grip_draw_size, window_border_size))); window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(resize_grip_draw_size, window_border_size) : ImVec2(window_border_size, resize_grip_draw_size))); window->DrawList->PathArcToFast(ImVec2(corner.x + grip.InnerDir.x * (window_rounding + window_border_size), corner.y + grip.InnerDir.y * (window_rounding + window_border_size)), window_rounding, grip.AngleMin12, grip.AngleMax12); window->DrawList->PathFillConvex(resize_grip_col[resize_grip_n]); } } // Borders RenderWindowOuterBorders(window); } } // Render title text, collapse button, close button void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open) { ImGuiContext& g = *GImGui; ImGuiStyle& style = g.Style; ImGuiWindowFlags flags = window->Flags; const bool has_close_button = (p_open != NULL); const bool has_collapse_button = !(flags & ImGuiWindowFlags_NoCollapse) && (style.WindowMenuButtonPosition != ImGuiDir_None); // Close & Collapse button are on the Menu NavLayer and don't default focus (unless there's nothing else on that layer) const ImGuiItemFlags item_flags_backup = window->DC.ItemFlags; window->DC.ItemFlags |= ImGuiItemFlags_NoNavDefaultFocus; window->DC.NavLayerCurrent = ImGuiNavLayer_Menu; window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Menu); // Layout buttons // FIXME: Would be nice to generalize the subtleties expressed here into reusable code. float pad_l = style.FramePadding.x; float pad_r = style.FramePadding.x; float button_sz = g.FontSize; ImVec2 close_button_pos; ImVec2 collapse_button_pos; if (has_close_button) { pad_r += button_sz; close_button_pos = ImVec2(title_bar_rect.Max.x - pad_r - style.FramePadding.x, title_bar_rect.Min.y); } if (has_collapse_button && style.WindowMenuButtonPosition == ImGuiDir_Right) { pad_r += button_sz; collapse_button_pos = ImVec2(title_bar_rect.Max.x - pad_r - style.FramePadding.x, title_bar_rect.Min.y); } if (has_collapse_button && style.WindowMenuButtonPosition == ImGuiDir_Left) { collapse_button_pos = ImVec2(title_bar_rect.Min.x + pad_l - style.FramePadding.x, title_bar_rect.Min.y); pad_l += button_sz; } // Collapse button (submitting first so it gets priority when choosing a navigation init fallback) if (has_collapse_button) if (CollapseButton(window->GetID("#COLLAPSE"), collapse_button_pos)) window->WantCollapseToggle = true; // Defer actual collapsing to next frame as we are too far in the Begin() function // Close button if (has_close_button) if (CloseButton(window->GetID("#CLOSE"), close_button_pos)) *p_open = false; window->DC.NavLayerCurrent = ImGuiNavLayer_Main; window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main); window->DC.ItemFlags = item_flags_backup; // Title bar text (with: horizontal alignment, avoiding collapse/close button, optional "unsaved document" marker) // FIXME: Refactor text alignment facilities along with RenderText helpers, this is WAY too much messy code.. const char* UNSAVED_DOCUMENT_MARKER = "*"; const float marker_size_x = (flags & ImGuiWindowFlags_UnsavedDocument) ? CalcTextSize(UNSAVED_DOCUMENT_MARKER, NULL, false).x : 0.0f; const ImVec2 text_size = CalcTextSize(name, NULL, true) + ImVec2(marker_size_x, 0.0f); // As a nice touch we try to ensure that centered title text doesn't get affected by visibility of Close/Collapse button, // while uncentered title text will still reach edges correct. if (pad_l > style.FramePadding.x) pad_l += g.Style.ItemInnerSpacing.x; if (pad_r > style.FramePadding.x) pad_r += g.Style.ItemInnerSpacing.x; if (style.WindowTitleAlign.x > 0.0f && style.WindowTitleAlign.x < 1.0f) { float centerness = ImSaturate(1.0f - ImFabs(style.WindowTitleAlign.x - 0.5f) * 2.0f); // 0.0f on either edges, 1.0f on center float pad_extend = ImMin(ImMax(pad_l, pad_r), title_bar_rect.GetWidth() - pad_l - pad_r - text_size.x); pad_l = ImMax(pad_l, pad_extend * centerness); pad_r = ImMax(pad_r, pad_extend * centerness); } ImRect layout_r(title_bar_rect.Min.x + pad_l, title_bar_rect.Min.y, title_bar_rect.Max.x - pad_r, title_bar_rect.Max.y); ImRect clip_r(layout_r.Min.x, layout_r.Min.y, layout_r.Max.x + g.Style.ItemInnerSpacing.x, layout_r.Max.y); //if (g.IO.KeyCtrl) window->DrawList->AddRect(layout_r.Min, layout_r.Max, IM_COL32(255, 128, 0, 255)); // [DEBUG] RenderTextClipped(layout_r.Min, layout_r.Max, name, NULL, &text_size, style.WindowTitleAlign, &clip_r); if (flags & ImGuiWindowFlags_UnsavedDocument) { ImVec2 marker_pos = ImVec2(ImMax(layout_r.Min.x, layout_r.Min.x + (layout_r.GetWidth() - text_size.x) * style.WindowTitleAlign.x) + text_size.x, layout_r.Min.y) + ImVec2(2 - marker_size_x, 0.0f); ImVec2 off = ImVec2(0.0f, IM_FLOOR(-g.FontSize * 0.25f)); RenderTextClipped(marker_pos + off, layout_r.Max + off, UNSAVED_DOCUMENT_MARKER, NULL, NULL, ImVec2(0, style.WindowTitleAlign.y), &clip_r); } } void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window) { window->ParentWindow = parent_window; window->RootWindow = window->RootWindowForTitleBarHighlight = window->RootWindowForNav = window; if (parent_window && (flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Tooltip)) window->RootWindow = parent_window->RootWindow; if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup))) window->RootWindowForTitleBarHighlight = parent_window->RootWindowForTitleBarHighlight; while (window->RootWindowForNav->Flags & ImGuiWindowFlags_NavFlattened) { IM_ASSERT(window->RootWindowForNav->ParentWindow != NULL); window->RootWindowForNav = window->RootWindowForNav->ParentWindow; } } // Push a new Dear ImGui window to add widgets to. // - A default window called "Debug" is automatically stacked at the beginning of every frame so you can use widgets without explicitly calling a Begin/End pair. // - Begin/End can be called multiple times during the frame with the same window name to append content. // - The window name is used as a unique identifier to preserve window information across frames (and save rudimentary information to the .ini file). // You can use the "##" or "###" markers to use the same label with different id, or same id with different label. See documentation at the top of this file. // - Return false when window is collapsed, so you can early out in your code. You always need to call ImGui::End() even if false is returned. // - Passing 'bool* p_open' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed. bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) { ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; IM_ASSERT(name != NULL && name[0] != '\0'); // Window name required IM_ASSERT(g.WithinFrameScope); // Forgot to call ImGui::NewFrame() IM_ASSERT(g.FrameCountEnded != g.FrameCount); // Called ImGui::Render() or ImGui::EndFrame() and haven't called ImGui::NewFrame() again yet // Find or create ImGuiWindow* window = FindWindowByName(name); const bool window_just_created = (window == NULL); if (window_just_created) { ImVec2 size_on_first_use = (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize) ? g.NextWindowData.SizeVal : ImVec2(0.0f, 0.0f); // Any condition flag will do since we are creating a new window here. window = CreateNewWindow(name, size_on_first_use, flags); } // Automatically disable manual moving/resizing when NoInputs is set if ((flags & ImGuiWindowFlags_NoInputs) == ImGuiWindowFlags_NoInputs) flags |= ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize; if (flags & ImGuiWindowFlags_NavFlattened) IM_ASSERT(flags & ImGuiWindowFlags_ChildWindow); const int current_frame = g.FrameCount; const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame); window->IsFallbackWindow = (g.CurrentWindowStack.Size == 0 && g.WithinFrameScopeWithImplicitWindow); // Update the Appearing flag bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on const bool window_just_appearing_after_hidden_for_resize = (window->HiddenFramesCannotSkipItems > 0); if (flags & ImGuiWindowFlags_Popup) { ImGuiPopupData& popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size]; window_just_activated_by_user |= (window->PopupId != popup_ref.PopupId); // We recycle popups so treat window as activated if popup id changed window_just_activated_by_user |= (window != popup_ref.Window); } window->Appearing = (window_just_activated_by_user || window_just_appearing_after_hidden_for_resize); if (window->Appearing) SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, true); // Update Flags, LastFrameActive, BeginOrderXXX fields if (first_begin_of_the_frame) { window->Flags = (ImGuiWindowFlags)flags; window->LastFrameActive = current_frame; window->LastTimeActive = (float)g.Time; window->BeginOrderWithinParent = 0; window->BeginOrderWithinContext = (short)(g.WindowsActiveCount++); } else { flags = window->Flags; } // Parent window is latched only on the first call to Begin() of the frame, so further append-calls can be done from a different window stack ImGuiWindow* parent_window_in_stack = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back(); ImGuiWindow* parent_window = first_begin_of_the_frame ? ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)) ? parent_window_in_stack : NULL) : window->ParentWindow; IM_ASSERT(parent_window != NULL || !(flags & ImGuiWindowFlags_ChildWindow)); // We allow window memory to be compacted so recreate the base stack when needed. if (window->IDStack.Size == 0) window->IDStack.push_back(window->ID); // Add to stack // We intentionally set g.CurrentWindow to NULL to prevent usage until when the viewport is set, then will call SetCurrentWindow() g.CurrentWindowStack.push_back(window); g.CurrentWindow = NULL; ErrorCheckBeginEndCompareStacksSize(window, true); if (flags & ImGuiWindowFlags_Popup) { ImGuiPopupData& popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size]; popup_ref.Window = window; g.BeginPopupStack.push_back(popup_ref); window->PopupId = popup_ref.PopupId; } if (window_just_appearing_after_hidden_for_resize && !(flags & ImGuiWindowFlags_ChildWindow)) window->NavLastIds[0] = 0; // Update ->RootWindow and others pointers (before any possible call to FocusWindow) if (first_begin_of_the_frame) UpdateWindowParentAndRootLinks(window, flags, parent_window); // Process SetNextWindow***() calls bool window_pos_set_by_api = false; bool window_size_x_set_by_api = false, window_size_y_set_by_api = false; if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) { window_pos_set_by_api = (window->SetWindowPosAllowFlags & g.NextWindowData.PosCond) != 0; if (window_pos_set_by_api && ImLengthSqr(g.NextWindowData.PosPivotVal) > 0.00001f) { // May be processed on the next frame if this is our first frame and we are measuring size // FIXME: Look into removing the branch so everything can go through this same code path for consistency. window->SetWindowPosVal = g.NextWindowData.PosVal; window->SetWindowPosPivot = g.NextWindowData.PosPivotVal; window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); } else { SetWindowPos(window, g.NextWindowData.PosVal, g.NextWindowData.PosCond); } } if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize) { window_size_x_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.x > 0.0f); window_size_y_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.y > 0.0f); SetWindowSize(window, g.NextWindowData.SizeVal, g.NextWindowData.SizeCond); } if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasContentSize) window->ContentSizeExplicit = g.NextWindowData.ContentSizeVal; else if (first_begin_of_the_frame) window->ContentSizeExplicit = ImVec2(0.0f, 0.0f); if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasCollapsed) SetWindowCollapsed(window, g.NextWindowData.CollapsedVal, g.NextWindowData.CollapsedCond); if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasFocus) FocusWindow(window); if (window->Appearing) SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false); // When reusing window again multiple times a frame, just append content (don't need to setup again) if (first_begin_of_the_frame) { // Initialize const bool window_is_child_tooltip = (flags & ImGuiWindowFlags_ChildWindow) && (flags & ImGuiWindowFlags_Tooltip); // FIXME-WIP: Undocumented behavior of Child+Tooltip for pinned tooltip (#1345) window->Active = true; window->HasCloseButton = (p_open != NULL); window->ClipRect = ImVec4(-FLT_MAX,-FLT_MAX,+FLT_MAX,+FLT_MAX); window->IDStack.resize(1); // Restore buffer capacity when woken from a compacted state, to avoid if (window->MemoryCompacted) GcAwakeTransientWindowBuffers(window); // Update stored window name when it changes (which can _only_ happen with the "###" operator, so the ID would stay unchanged). // The title bar always display the 'name' parameter, so we only update the string storage if it needs to be visible to the end-user elsewhere. bool window_title_visible_elsewhere = false; if (g.NavWindowingList != NULL && (window->Flags & ImGuiWindowFlags_NoNavFocus) == 0) // Window titles visible when using CTRL+TAB window_title_visible_elsewhere = true; if (window_title_visible_elsewhere && !window_just_created && strcmp(name, window->Name) != 0) { size_t buf_len = (size_t)window->NameBufLen; window->Name = ImStrdupcpy(window->Name, &buf_len, name); window->NameBufLen = (int)buf_len; } // UPDATE CONTENTS SIZE, UPDATE HIDDEN STATUS // Update contents size from last frame for auto-fitting (or use explicit size) window->ContentSize = CalcWindowContentSize(window); if (window->HiddenFramesCanSkipItems > 0) window->HiddenFramesCanSkipItems--; if (window->HiddenFramesCannotSkipItems > 0) window->HiddenFramesCannotSkipItems--; // Hide new windows for one frame until they calculate their size if (window_just_created && (!window_size_x_set_by_api || !window_size_y_set_by_api)) window->HiddenFramesCannotSkipItems = 1; // Hide popup/tooltip window when re-opening while we measure size (because we recycle the windows) // We reset Size/ContentSize for reappearing popups/tooltips early in this function, so further code won't be tempted to use the old size. if (window_just_activated_by_user && (flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) != 0) { window->HiddenFramesCannotSkipItems = 1; if (flags & ImGuiWindowFlags_AlwaysAutoResize) { if (!window_size_x_set_by_api) window->Size.x = window->SizeFull.x = 0.f; if (!window_size_y_set_by_api) window->Size.y = window->SizeFull.y = 0.f; window->ContentSize = ImVec2(0.f, 0.f); } } // SELECT VIEWPORT // FIXME-VIEWPORT: In the docking/viewport branch, this is the point where we select the current viewport (which may affect the style) SetCurrentWindow(window); // LOCK BORDER SIZE AND PADDING FOR THE FRAME (so that altering them doesn't cause inconsistencies) if (flags & ImGuiWindowFlags_ChildWindow) window->WindowBorderSize = style.ChildBorderSize; else window->WindowBorderSize = ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupBorderSize : style.WindowBorderSize; window->WindowPadding = style.WindowPadding; if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f) window->WindowPadding = ImVec2(0.0f, (flags & ImGuiWindowFlags_MenuBar) ? style.WindowPadding.y : 0.0f); // Collapse window by double-clicking on title bar // At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing if (!(flags & ImGuiWindowFlags_NoTitleBar) && !(flags & ImGuiWindowFlags_NoCollapse)) { // We don't use a regular button+id to test for double-click on title bar (mostly due to legacy reason, could be fixed), so verify that we don't have items over the title bar. ImRect title_bar_rect = window->TitleBarRect(); if (g.HoveredWindow == window && g.HoveredId == 0 && g.HoveredIdPreviousFrame == 0 && IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max) && g.IO.MouseDoubleClicked[0]) window->WantCollapseToggle = true; if (window->WantCollapseToggle) { window->Collapsed = !window->Collapsed; MarkIniSettingsDirty(window); FocusWindow(window); } } else { window->Collapsed = false; } window->WantCollapseToggle = false; // SIZE // Calculate auto-fit size, handle automatic resize const ImVec2 size_auto_fit = CalcWindowAutoFitSize(window, window->ContentSize); bool use_current_size_for_scrollbar_x = window_just_created; bool use_current_size_for_scrollbar_y = window_just_created; if ((flags & ImGuiWindowFlags_AlwaysAutoResize) && !window->Collapsed) { // Using SetNextWindowSize() overrides ImGuiWindowFlags_AlwaysAutoResize, so it can be used on tooltips/popups, etc. if (!window_size_x_set_by_api) { window->SizeFull.x = size_auto_fit.x; use_current_size_for_scrollbar_x = true; } if (!window_size_y_set_by_api) { window->SizeFull.y = size_auto_fit.y; use_current_size_for_scrollbar_y = true; } } else if (window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) { // Auto-fit may only grow window during the first few frames // We still process initial auto-fit on collapsed windows to get a window width, but otherwise don't honor ImGuiWindowFlags_AlwaysAutoResize when collapsed. if (!window_size_x_set_by_api && window->AutoFitFramesX > 0) { window->SizeFull.x = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.x, size_auto_fit.x) : size_auto_fit.x; use_current_size_for_scrollbar_x = true; } if (!window_size_y_set_by_api && window->AutoFitFramesY > 0) { window->SizeFull.y = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.y, size_auto_fit.y) : size_auto_fit.y; use_current_size_for_scrollbar_y = true; } if (!window->Collapsed) MarkIniSettingsDirty(window); } // Apply minimum/maximum window size constraints and final size window->SizeFull = CalcWindowSizeAfterConstraint(window, window->SizeFull); window->Size = window->Collapsed && !(flags & ImGuiWindowFlags_ChildWindow) ? window->TitleBarRect().GetSize() : window->SizeFull; // Decoration size const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight(); // POSITION // Popup latch its initial position, will position itself when it appears next frame if (window_just_activated_by_user) { window->AutoPosLastDirection = ImGuiDir_None; if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api) window->Pos = g.BeginPopupStack.back().OpenPopupPos; } // Position child window if (flags & ImGuiWindowFlags_ChildWindow) { IM_ASSERT(parent_window && parent_window->Active); window->BeginOrderWithinParent = (short)parent_window->DC.ChildWindows.Size; parent_window->DC.ChildWindows.push_back(window); if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api && !window_is_child_tooltip) window->Pos = parent_window->DC.CursorPos; } const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFramesCannotSkipItems == 0); if (window_pos_with_pivot) SetWindowPos(window, window->SetWindowPosVal - window->SizeFull * window->SetWindowPosPivot, 0); // Position given a pivot (e.g. for centering) else if ((flags & ImGuiWindowFlags_ChildMenu) != 0) window->Pos = FindBestWindowPosForPopup(window); else if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api && window_just_appearing_after_hidden_for_resize) window->Pos = FindBestWindowPosForPopup(window); else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip) window->Pos = FindBestWindowPosForPopup(window); // Clamp position/size so window stays visible within its viewport or monitor // Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing. ImRect viewport_rect(GetViewportRect()); if (!window_pos_set_by_api && !(flags & ImGuiWindowFlags_ChildWindow) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0) { ImVec2 clamp_padding = ImMax(style.DisplayWindowPadding, style.DisplaySafeAreaPadding); if (viewport_rect.GetWidth() > 0 && viewport_rect.GetHeight() > 0.0f) { ClampWindowRect(window, viewport_rect, clamp_padding); } } window->Pos = ImFloor(window->Pos); // Lock window rounding for the frame (so that altering them doesn't cause inconsistencies) window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding; // Apply window focus (new and reactivated windows are moved to front) bool want_focus = false; if (window_just_activated_by_user && !(flags & ImGuiWindowFlags_NoFocusOnAppearing)) { if (flags & ImGuiWindowFlags_Popup) want_focus = true; else if ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Tooltip)) == 0) want_focus = true; } // Handle manual resize: Resize Grips, Borders, Gamepad int border_held = -1; ImU32 resize_grip_col[4] = {}; const int resize_grip_count = g.IO.ConfigWindowsResizeFromEdges ? 2 : 1; // Allow resize from lower-left if we have the mouse cursor feedback for it. const float resize_grip_draw_size = IM_FLOOR(ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f)); if (!window->Collapsed) if (UpdateManualResize(window, size_auto_fit, &border_held, resize_grip_count, &resize_grip_col[0])) use_current_size_for_scrollbar_x = use_current_size_for_scrollbar_y = true; window->ResizeBorderHeld = (signed char)border_held; // SCROLLBAR VISIBILITY // Update scrollbar visibility (based on the Size that was effective during last frame or the auto-resized Size). if (!window->Collapsed) { // When reading the current size we need to read it after size constraints have been applied. // When we use InnerRect here we are intentionally reading last frame size, same for ScrollbarSizes values before we set them again. ImVec2 avail_size_from_current_frame = ImVec2(window->SizeFull.x, window->SizeFull.y - decoration_up_height); ImVec2 avail_size_from_last_frame = window->InnerRect.GetSize() + window->ScrollbarSizes; ImVec2 needed_size_from_last_frame = window_just_created ? ImVec2(0, 0) : window->ContentSize + window->WindowPadding * 2.0f; float size_x_for_scrollbars = use_current_size_for_scrollbar_x ? avail_size_from_current_frame.x : avail_size_from_last_frame.x; float size_y_for_scrollbars = use_current_size_for_scrollbar_y ? avail_size_from_current_frame.y : avail_size_from_last_frame.y; //bool scrollbar_y_from_last_frame = window->ScrollbarY; // FIXME: May want to use that in the ScrollbarX expression? How many pros vs cons? window->ScrollbarY = (flags & ImGuiWindowFlags_AlwaysVerticalScrollbar) || ((needed_size_from_last_frame.y > size_y_for_scrollbars) && !(flags & ImGuiWindowFlags_NoScrollbar)); window->ScrollbarX = (flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar) || ((needed_size_from_last_frame.x > size_x_for_scrollbars - (window->ScrollbarY ? style.ScrollbarSize : 0.0f)) && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar)); if (window->ScrollbarX && !window->ScrollbarY) window->ScrollbarY = (needed_size_from_last_frame.y > size_y_for_scrollbars) && !(flags & ImGuiWindowFlags_NoScrollbar); window->ScrollbarSizes = ImVec2(window->ScrollbarY ? style.ScrollbarSize : 0.0f, window->ScrollbarX ? style.ScrollbarSize : 0.0f); } // UPDATE RECTANGLES (1- THOSE NOT AFFECTED BY SCROLLING) // Update various regions. Variables they depends on should be set above in this function. // We set this up after processing the resize grip so that our rectangles doesn't lag by a frame. // Outer rectangle // Not affected by window border size. Used by: // - FindHoveredWindow() (w/ extra padding when border resize is enabled) // - Begin() initial clipping rect for drawing window background and borders. // - Begin() clipping whole child const ImRect host_rect = ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_is_child_tooltip) ? parent_window->ClipRect : viewport_rect; const ImRect outer_rect = window->Rect(); const ImRect title_bar_rect = window->TitleBarRect(); window->OuterRectClipped = outer_rect; window->OuterRectClipped.ClipWith(host_rect); // Inner rectangle // Not affected by window border size. Used by: // - InnerClipRect // - ScrollToBringRectIntoView() // - NavUpdatePageUpPageDown() // - Scrollbar() window->InnerRect.Min.x = window->Pos.x; window->InnerRect.Min.y = window->Pos.y + decoration_up_height; window->InnerRect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x; window->InnerRect.Max.y = window->Pos.y + window->Size.y - window->ScrollbarSizes.y; // Inner clipping rectangle. // Will extend a little bit outside the normal work region. // This is to allow e.g. Selectable or CollapsingHeader or some separators to cover that space. // Force round operator last to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result. // Note that if our window is collapsed we will end up with an inverted (~null) clipping rectangle which is the correct behavior. // Affected by window/frame border size. Used by: // - Begin() initial clip rect float top_border_size = (((flags & ImGuiWindowFlags_MenuBar) || !(flags & ImGuiWindowFlags_NoTitleBar)) ? style.FrameBorderSize : window->WindowBorderSize); window->InnerClipRect.Min.x = ImFloor(0.5f + window->InnerRect.Min.x + ImMax(ImFloor(window->WindowPadding.x * 0.5f), window->WindowBorderSize)); window->InnerClipRect.Min.y = ImFloor(0.5f + window->InnerRect.Min.y + top_border_size); window->InnerClipRect.Max.x = ImFloor(0.5f + window->InnerRect.Max.x - ImMax(ImFloor(window->WindowPadding.x * 0.5f), window->WindowBorderSize)); window->InnerClipRect.Max.y = ImFloor(0.5f + window->InnerRect.Max.y - window->WindowBorderSize); window->InnerClipRect.ClipWithFull(host_rect); // Default item width. Make it proportional to window size if window manually resizes if (window->Size.x > 0.0f && !(flags & ImGuiWindowFlags_Tooltip) && !(flags & ImGuiWindowFlags_AlwaysAutoResize)) window->ItemWidthDefault = ImFloor(window->Size.x * 0.65f); else window->ItemWidthDefault = ImFloor(g.FontSize * 16.0f); // SCROLLING // Lock down maximum scrolling // The value of ScrollMax are ahead from ScrollbarX/ScrollbarY which is intentionally using InnerRect from previous rect in order to accommodate // for right/bottom aligned items without creating a scrollbar. window->ScrollMax.x = ImMax(0.0f, window->ContentSize.x + window->WindowPadding.x * 2.0f - window->InnerRect.GetWidth()); window->ScrollMax.y = ImMax(0.0f, window->ContentSize.y + window->WindowPadding.y * 2.0f - window->InnerRect.GetHeight()); // Apply scrolling window->Scroll = CalcNextScrollFromScrollTargetAndClamp(window, true); window->ScrollTarget = ImVec2(FLT_MAX, FLT_MAX); // DRAWING // Setup draw list and outer clipping rectangle window->DrawList->Clear(); window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID); PushClipRect(host_rect.Min, host_rect.Max, false); // Draw modal window background (darkens what is behind them, all viewports) const bool dim_bg_for_modal = (flags & ImGuiWindowFlags_Modal) && window == GetTopMostPopupModal() && window->HiddenFramesCannotSkipItems <= 0; const bool dim_bg_for_window_list = g.NavWindowingTargetAnim && (window == g.NavWindowingTargetAnim->RootWindow); if (dim_bg_for_modal || dim_bg_for_window_list) { const ImU32 dim_bg_col = GetColorU32(dim_bg_for_modal ? ImGuiCol_ModalWindowDimBg : ImGuiCol_NavWindowingDimBg, g.DimBgRatio); window->DrawList->AddRectFilled(viewport_rect.Min, viewport_rect.Max, dim_bg_col); } // Draw navigation selection/windowing rectangle background if (dim_bg_for_window_list && window == g.NavWindowingTargetAnim) { ImRect bb = window->Rect(); bb.Expand(g.FontSize); if (!bb.Contains(viewport_rect)) // Avoid drawing if the window covers all the viewport anyway window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha * 0.25f), g.Style.WindowRounding); } // Since 1.71, child window can render their decoration (bg color, border, scrollbars, etc.) within their parent to save a draw call. // When using overlapping child windows, this will break the assumption that child z-order is mapped to submission order. // We disable this when the parent window has zero vertices, which is a common pattern leading to laying out multiple overlapping child. // We also disabled this when we have dimming overlay behind this specific one child. // FIXME: More code may rely on explicit sorting of overlapping child window and would need to disable this somehow. Please get in contact if you are affected. { bool render_decorations_in_parent = false; if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_is_child_tooltip) if (window->DrawList->CmdBuffer.back().ElemCount == 0 && parent_window->DrawList->VtxBuffer.Size > 0) render_decorations_in_parent = true; if (render_decorations_in_parent) window->DrawList = parent_window->DrawList; // Handle title bar, scrollbar, resize grips and resize borders const ImGuiWindow* window_to_highlight = g.NavWindowingTarget ? g.NavWindowingTarget : g.NavWindow; const bool title_bar_is_highlight = want_focus || (window_to_highlight && window->RootWindowForTitleBarHighlight == window_to_highlight->RootWindowForTitleBarHighlight); RenderWindowDecorations(window, title_bar_rect, title_bar_is_highlight, resize_grip_count, resize_grip_col, resize_grip_draw_size); if (render_decorations_in_parent) window->DrawList = &window->DrawListInst; } // Draw navigation selection/windowing rectangle border if (g.NavWindowingTargetAnim == window) { float rounding = ImMax(window->WindowRounding, g.Style.WindowRounding); ImRect bb = window->Rect(); bb.Expand(g.FontSize); if (bb.Contains(viewport_rect)) // If a window fits the entire viewport, adjust its highlight inward { bb.Expand(-g.FontSize - 1.0f); rounding = window->WindowRounding; } window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), rounding, ~0, 3.0f); } // UPDATE RECTANGLES (2- THOSE AFFECTED BY SCROLLING) // Work rectangle. // Affected by window padding and border size. Used by: // - Columns() for right-most edge // - TreeNode(), CollapsingHeader() for right-most edge // - BeginTabBar() for right-most edge const bool allow_scrollbar_x = !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar); const bool allow_scrollbar_y = !(flags & ImGuiWindowFlags_NoScrollbar); const float work_rect_size_x = (window->ContentSizeExplicit.x != 0.0f ? window->ContentSizeExplicit.x : ImMax(allow_scrollbar_x ? window->ContentSize.x : 0.0f, window->Size.x - window->WindowPadding.x * 2.0f - window->ScrollbarSizes.x)); const float work_rect_size_y = (window->ContentSizeExplicit.y != 0.0f ? window->ContentSizeExplicit.y : ImMax(allow_scrollbar_y ? window->ContentSize.y : 0.0f, window->Size.y - window->WindowPadding.y * 2.0f - decoration_up_height - window->ScrollbarSizes.y)); window->WorkRect.Min.x = ImFloor(window->InnerRect.Min.x - window->Scroll.x + ImMax(window->WindowPadding.x, window->WindowBorderSize)); window->WorkRect.Min.y = ImFloor(window->InnerRect.Min.y - window->Scroll.y + ImMax(window->WindowPadding.y, window->WindowBorderSize)); window->WorkRect.Max.x = window->WorkRect.Min.x + work_rect_size_x; window->WorkRect.Max.y = window->WorkRect.Min.y + work_rect_size_y; // [LEGACY] Content Region // FIXME-OBSOLETE: window->ContentRegionRect.Max is currently very misleading / partly faulty, but some BeginChild() patterns relies on it. // Used by: // - Mouse wheel scrolling + many other things window->ContentRegionRect.Min.x = window->Pos.x - window->Scroll.x + window->WindowPadding.x; window->ContentRegionRect.Min.y = window->Pos.y - window->Scroll.y + window->WindowPadding.y + decoration_up_height; window->ContentRegionRect.Max.x = window->ContentRegionRect.Min.x + (window->ContentSizeExplicit.x != 0.0f ? window->ContentSizeExplicit.x : (window->Size.x - window->WindowPadding.x * 2.0f - window->ScrollbarSizes.x)); window->ContentRegionRect.Max.y = window->ContentRegionRect.Min.y + (window->ContentSizeExplicit.y != 0.0f ? window->ContentSizeExplicit.y : (window->Size.y - window->WindowPadding.y * 2.0f - decoration_up_height - window->ScrollbarSizes.y)); // Setup drawing context // (NB: That term "drawing context / DC" lost its meaning a long time ago. Initially was meant to hold transient data only. Nowadays difference between window-> and window->DC-> is dubious.) window->DC.Indent.x = 0.0f + window->WindowPadding.x - window->Scroll.x; window->DC.GroupOffset.x = 0.0f; window->DC.ColumnsOffset.x = 0.0f; window->DC.CursorStartPos = window->Pos + ImVec2(window->DC.Indent.x + window->DC.ColumnsOffset.x, decoration_up_height + window->WindowPadding.y - window->Scroll.y); window->DC.CursorPos = window->DC.CursorStartPos; window->DC.CursorPosPrevLine = window->DC.CursorPos; window->DC.CursorMaxPos = window->DC.CursorStartPos; window->DC.CurrLineSize = window->DC.PrevLineSize = ImVec2(0.0f, 0.0f); window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset = 0.0f; window->DC.NavLayerCurrent = ImGuiNavLayer_Main; window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main); window->DC.NavLayerActiveMask = window->DC.NavLayerActiveMaskNext; window->DC.NavLayerActiveMaskNext = 0x00; window->DC.NavFocusScopeIdCurrent = 0; window->DC.NavHideHighlightOneFrame = false; window->DC.NavHasScroll = (window->ScrollMax.y > 0.0f); window->DC.MenuBarAppending = false; window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x); window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y; window->DC.MenuColumns.Update(3, style.ItemSpacing.x, window_just_activated_by_user); window->DC.TreeDepth = 0; window->DC.TreeJumpToParentOnPopMask = 0x00; window->DC.ChildWindows.resize(0); window->DC.StateStorage = &window->StateStorage; window->DC.CurrentColumns = NULL; window->DC.LayoutType = ImGuiLayoutType_Vertical; window->DC.ParentLayoutType = parent_window ? parent_window->DC.LayoutType : ImGuiLayoutType_Vertical; window->DC.FocusCounterRegular = window->DC.FocusCounterTabStop = -1; window->DC.ItemFlags = parent_window ? parent_window->DC.ItemFlags : ImGuiItemFlags_Default_; window->DC.ItemWidth = window->ItemWidthDefault; window->DC.TextWrapPos = -1.0f; // disabled window->DC.ItemFlagsStack.resize(0); window->DC.ItemWidthStack.resize(0); window->DC.TextWrapPosStack.resize(0); window->DC.GroupStack.resize(0); if ((flags & ImGuiWindowFlags_ChildWindow) && (window->DC.ItemFlags != parent_window->DC.ItemFlags)) { window->DC.ItemFlags = parent_window->DC.ItemFlags; window->DC.ItemFlagsStack.push_back(window->DC.ItemFlags); } if (window->AutoFitFramesX > 0) window->AutoFitFramesX--; if (window->AutoFitFramesY > 0) window->AutoFitFramesY--; // Apply focus (we need to call FocusWindow() AFTER setting DC.CursorStartPos so our initial navigation reference rectangle can start around there) if (want_focus) { FocusWindow(window); NavInitWindow(window, false); } // Title bar if (!(flags & ImGuiWindowFlags_NoTitleBar)) RenderWindowTitleBarContents(window, title_bar_rect, name, p_open); // Pressing CTRL+C while holding on a window copy its content to the clipboard // This works but 1. doesn't handle multiple Begin/End pairs, 2. recursing into another Begin/End pair - so we need to work that out and add better logging scope. // Maybe we can support CTRL+C on every element? /* if (g.ActiveId == move_id) if (g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_C)) LogToClipboard(); */ // We fill last item data based on Title Bar/Tab, in order for IsItemHovered() and IsItemActive() to be usable after Begin(). // This is useful to allow creating context menus on title bar only, etc. window->DC.LastItemId = window->MoveId; window->DC.LastItemStatusFlags = IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0; window->DC.LastItemRect = title_bar_rect; #ifdef IMGUI_ENABLE_TEST_ENGINE if (!(window->Flags & ImGuiWindowFlags_NoTitleBar)) IMGUI_TEST_ENGINE_ITEM_ADD(window->DC.LastItemRect, window->DC.LastItemId); #endif } else { // Append SetCurrentWindow(window); } PushClipRect(window->InnerClipRect.Min, window->InnerClipRect.Max, true); // Clear 'accessed' flag last thing (After PushClipRect which will set the flag. We want the flag to stay false when the default "Debug" window is unused) if (first_begin_of_the_frame) window->WriteAccessed = false; window->BeginCount++; g.NextWindowData.ClearFlags(); if (flags & ImGuiWindowFlags_ChildWindow) { // Child window can be out of sight and have "negative" clip windows. // Mark them as collapsed so commands are skipped earlier (we can't manually collapse them because they have no title bar). IM_ASSERT((flags & ImGuiWindowFlags_NoTitleBar) != 0); if (!(flags & ImGuiWindowFlags_AlwaysAutoResize) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0) if (window->OuterRectClipped.Min.x >= window->OuterRectClipped.Max.x || window->OuterRectClipped.Min.y >= window->OuterRectClipped.Max.y) window->HiddenFramesCanSkipItems = 1; // Hide along with parent or if parent is collapsed if (parent_window && (parent_window->Collapsed || parent_window->HiddenFramesCanSkipItems > 0)) window->HiddenFramesCanSkipItems = 1; if (parent_window && (parent_window->Collapsed || parent_window->HiddenFramesCannotSkipItems > 0)) window->HiddenFramesCannotSkipItems = 1; } // Don't render if style alpha is 0.0 at the time of Begin(). This is arbitrary and inconsistent but has been there for a long while (may remove at some point) if (style.Alpha <= 0.0f) window->HiddenFramesCanSkipItems = 1; // Update the Hidden flag window->Hidden = (window->HiddenFramesCanSkipItems > 0) || (window->HiddenFramesCannotSkipItems > 0); // Update the SkipItems flag, used to early out of all items functions (no layout required) bool skip_items = false; if (window->Collapsed || !window->Active || window->Hidden) if (window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0 && window->HiddenFramesCannotSkipItems <= 0) skip_items = true; window->SkipItems = skip_items; return !skip_items; } void ImGui::End() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; // Error checking: verify that user hasn't called End() too many times! if (g.CurrentWindowStack.Size <= 1 && g.WithinFrameScopeWithImplicitWindow) { IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size > 1, "Calling End() too many times!"); return; } IM_ASSERT(g.CurrentWindowStack.Size > 0); // Error checking: verify that user doesn't directly call End() on a child window. if (window->Flags & ImGuiWindowFlags_ChildWindow) IM_ASSERT_USER_ERROR(g.WithinEndChild, "Must call EndChild() and not End()!"); // Close anything that is open if (window->DC.CurrentColumns) EndColumns(); PopClipRect(); // Inner window clip rectangle // Stop logging if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME: add more options for scope of logging LogFinish(); // Pop from window stack g.CurrentWindowStack.pop_back(); if (window->Flags & ImGuiWindowFlags_Popup) g.BeginPopupStack.pop_back(); ErrorCheckBeginEndCompareStacksSize(window, false); SetCurrentWindow(g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back()); } void ImGui::BringWindowToFocusFront(ImGuiWindow* window) { ImGuiContext& g = *GImGui; if (g.WindowsFocusOrder.back() == window) return; for (int i = g.WindowsFocusOrder.Size - 2; i >= 0; i--) // We can ignore the top-most window if (g.WindowsFocusOrder[i] == window) { memmove(&g.WindowsFocusOrder[i], &g.WindowsFocusOrder[i + 1], (size_t)(g.WindowsFocusOrder.Size - i - 1) * sizeof(ImGuiWindow*)); g.WindowsFocusOrder[g.WindowsFocusOrder.Size - 1] = window; break; } } void ImGui::BringWindowToDisplayFront(ImGuiWindow* window) { ImGuiContext& g = *GImGui; ImGuiWindow* current_front_window = g.Windows.back(); if (current_front_window == window || current_front_window->RootWindow == window) return; for (int i = g.Windows.Size - 2; i >= 0; i--) // We can ignore the top-most window if (g.Windows[i] == window) { memmove(&g.Windows[i], &g.Windows[i + 1], (size_t)(g.Windows.Size - i - 1) * sizeof(ImGuiWindow*)); g.Windows[g.Windows.Size - 1] = window; break; } } void ImGui::BringWindowToDisplayBack(ImGuiWindow* window) { ImGuiContext& g = *GImGui; if (g.Windows[0] == window) return; for (int i = 0; i < g.Windows.Size; i++) if (g.Windows[i] == window) { memmove(&g.Windows[1], &g.Windows[0], (size_t)i * sizeof(ImGuiWindow*)); g.Windows[0] = window; break; } } // Moving window to front of display and set focus (which happens to be back of our sorted list) void ImGui::FocusWindow(ImGuiWindow* window) { ImGuiContext& g = *GImGui; if (g.NavWindow != window) { g.NavWindow = window; if (window && g.NavDisableMouseHover) g.NavMousePosDirty = true; g.NavInitRequest = false; g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId g.NavFocusScopeId = 0; g.NavIdIsAlive = false; g.NavLayer = ImGuiNavLayer_Main; //IMGUI_DEBUG_LOG("FocusWindow(\"%s\")\n", window ? window->Name : NULL); } // Close popups if any ClosePopupsOverWindow(window, false); // Passing NULL allow to disable keyboard focus if (!window) return; // Move the root window to the top of the pile IM_ASSERT(window->RootWindow != NULL); ImGuiWindow* focus_front_window = window->RootWindow; // NB: In docking branch this is window->RootWindowDockStop ImGuiWindow* display_front_window = window->RootWindow; // Steal focus on active widgets if (focus_front_window->Flags & ImGuiWindowFlags_Popup) // FIXME: This statement may be unnecessary? Need further testing before removing it.. if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindow != focus_front_window) ClearActiveID(); // Bring to front BringWindowToFocusFront(focus_front_window); if (((window->Flags | display_front_window->Flags) & ImGuiWindowFlags_NoBringToFrontOnFocus) == 0) BringWindowToDisplayFront(display_front_window); } void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window) { ImGuiContext& g = *GImGui; int start_idx = g.WindowsFocusOrder.Size - 1; if (under_this_window != NULL) { int under_this_window_idx = FindWindowFocusIndex(under_this_window); if (under_this_window_idx != -1) start_idx = under_this_window_idx - 1; } for (int i = start_idx; i >= 0; i--) { // We may later decide to test for different NoXXXInputs based on the active navigation input (mouse vs nav) but that may feel more confusing to the user. ImGuiWindow* window = g.WindowsFocusOrder[i]; if (window != ignore_window && window->WasActive && !(window->Flags & ImGuiWindowFlags_ChildWindow)) if ((window->Flags & (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) != (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) { ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(window); FocusWindow(focus_window); return; } } FocusWindow(NULL); } void ImGui::SetNextItemWidth(float item_width) { ImGuiContext& g = *GImGui; g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasWidth; g.NextItemData.Width = item_width; } void ImGui::PushItemWidth(float item_width) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; window->DC.ItemWidth = (item_width == 0.0f ? window->ItemWidthDefault : item_width); window->DC.ItemWidthStack.push_back(window->DC.ItemWidth); g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth; } void ImGui::PushMultiItemsWidths(int components, float w_full) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; const ImGuiStyle& style = g.Style; const float w_item_one = ImMax(1.0f, IM_FLOOR((w_full - (style.ItemInnerSpacing.x) * (components-1)) / (float)components)); const float w_item_last = ImMax(1.0f, IM_FLOOR(w_full - (w_item_one + style.ItemInnerSpacing.x) * (components-1))); window->DC.ItemWidthStack.push_back(w_item_last); for (int i = 0; i < components-1; i++) window->DC.ItemWidthStack.push_back(w_item_one); window->DC.ItemWidth = window->DC.ItemWidthStack.back(); g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth; } void ImGui::PopItemWidth() { ImGuiWindow* window = GetCurrentWindow(); window->DC.ItemWidthStack.pop_back(); window->DC.ItemWidth = window->DC.ItemWidthStack.empty() ? window->ItemWidthDefault : window->DC.ItemWidthStack.back(); } // Calculate default item width given value passed to PushItemWidth() or SetNextItemWidth(). // The SetNextItemWidth() data is generally cleared/consumed by ItemAdd() or NextItemData.ClearFlags() float ImGui::CalcItemWidth() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; float w; if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasWidth) w = g.NextItemData.Width; else w = window->DC.ItemWidth; if (w < 0.0f) { float region_max_x = GetContentRegionMaxAbs().x; w = ImMax(1.0f, region_max_x - window->DC.CursorPos.x + w); } w = IM_FLOOR(w); return w; } // [Internal] Calculate full item size given user provided 'size' parameter and default width/height. Default width is often == CalcItemWidth(). // Those two functions CalcItemWidth vs CalcItemSize are awkwardly named because they are not fully symmetrical. // Note that only CalcItemWidth() is publicly exposed. // The 4.0f here may be changed to match CalcItemWidth() and/or BeginChild() (right now we have a mismatch which is harmless but undesirable) ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_w, float default_h) { ImGuiWindow* window = GImGui->CurrentWindow; ImVec2 region_max; if (size.x < 0.0f || size.y < 0.0f) region_max = GetContentRegionMaxAbs(); if (size.x == 0.0f) size.x = default_w; else if (size.x < 0.0f) size.x = ImMax(4.0f, region_max.x - window->DC.CursorPos.x + size.x); if (size.y == 0.0f) size.y = default_h; else if (size.y < 0.0f) size.y = ImMax(4.0f, region_max.y - window->DC.CursorPos.y + size.y); return size; } void ImGui::SetCurrentFont(ImFont* font) { ImGuiContext& g = *GImGui; IM_ASSERT(font && font->IsLoaded()); // Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ? IM_ASSERT(font->Scale > 0.0f); g.Font = font; g.FontBaseSize = ImMax(1.0f, g.IO.FontGlobalScale * g.Font->FontSize * g.Font->Scale); g.FontSize = g.CurrentWindow ? g.CurrentWindow->CalcFontSize() : 0.0f; ImFontAtlas* atlas = g.Font->ContainerAtlas; g.DrawListSharedData.TexUvWhitePixel = atlas->TexUvWhitePixel; g.DrawListSharedData.Font = g.Font; g.DrawListSharedData.FontSize = g.FontSize; } void ImGui::PushFont(ImFont* font) { ImGuiContext& g = *GImGui; if (!font) font = GetDefaultFont(); SetCurrentFont(font); g.FontStack.push_back(font); g.CurrentWindow->DrawList->PushTextureID(font->ContainerAtlas->TexID); } void ImGui::PopFont() { ImGuiContext& g = *GImGui; g.CurrentWindow->DrawList->PopTextureID(); g.FontStack.pop_back(); SetCurrentFont(g.FontStack.empty() ? GetDefaultFont() : g.FontStack.back()); } void ImGui::PushItemFlag(ImGuiItemFlags option, bool enabled) { ImGuiWindow* window = GetCurrentWindow(); if (enabled) window->DC.ItemFlags |= option; else window->DC.ItemFlags &= ~option; window->DC.ItemFlagsStack.push_back(window->DC.ItemFlags); } void ImGui::PopItemFlag() { ImGuiWindow* window = GetCurrentWindow(); window->DC.ItemFlagsStack.pop_back(); window->DC.ItemFlags = window->DC.ItemFlagsStack.empty() ? ImGuiItemFlags_Default_ : window->DC.ItemFlagsStack.back(); } // FIXME: Look into renaming this once we have settled the new Focus/Activation/TabStop system. void ImGui::PushAllowKeyboardFocus(bool allow_keyboard_focus) { PushItemFlag(ImGuiItemFlags_NoTabStop, !allow_keyboard_focus); } void ImGui::PopAllowKeyboardFocus() { PopItemFlag(); } void ImGui::PushButtonRepeat(bool repeat) { PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat); } void ImGui::PopButtonRepeat() { PopItemFlag(); } void ImGui::PushTextWrapPos(float wrap_pos_x) { ImGuiWindow* window = GetCurrentWindow(); window->DC.TextWrapPos = wrap_pos_x; window->DC.TextWrapPosStack.push_back(wrap_pos_x); } void ImGui::PopTextWrapPos() { ImGuiWindow* window = GetCurrentWindow(); window->DC.TextWrapPosStack.pop_back(); window->DC.TextWrapPos = window->DC.TextWrapPosStack.empty() ? -1.0f : window->DC.TextWrapPosStack.back(); } // FIXME: This may incur a round-trip (if the end user got their data from a float4) but eventually we aim to store the in-flight colors as ImU32 void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col) { ImGuiContext& g = *GImGui; ImGuiColorMod backup; backup.Col = idx; backup.BackupValue = g.Style.Colors[idx]; g.ColorModifiers.push_back(backup); g.Style.Colors[idx] = ColorConvertU32ToFloat4(col); } void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col) { ImGuiContext& g = *GImGui; ImGuiColorMod backup; backup.Col = idx; backup.BackupValue = g.Style.Colors[idx]; g.ColorModifiers.push_back(backup); g.Style.Colors[idx] = col; } void ImGui::PopStyleColor(int count) { ImGuiContext& g = *GImGui; while (count > 0) { ImGuiColorMod& backup = g.ColorModifiers.back(); g.Style.Colors[backup.Col] = backup.BackupValue; g.ColorModifiers.pop_back(); count--; } } struct ImGuiStyleVarInfo { ImGuiDataType Type; ImU32 Count; ImU32 Offset; void* GetVarPtr(ImGuiStyle* style) const { return (void*)((unsigned char*)style + Offset); } }; static const ImGuiStyleVarInfo GStyleVarInfo[] = { { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowTitleAlign) }, // ImGuiStyleVar_WindowTitleAlign { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SelectableTextAlign) }, // ImGuiStyleVar_SelectableTextAlign }; static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx) { IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_COUNT); IM_ASSERT(IM_ARRAYSIZE(GStyleVarInfo) == ImGuiStyleVar_COUNT); return &GStyleVarInfo[idx]; } void ImGui::PushStyleVar(ImGuiStyleVar idx, float val) { const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx); if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1) { ImGuiContext& g = *GImGui; float* pvar = (float*)var_info->GetVarPtr(&g.Style); g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar)); *pvar = val; return; } IM_ASSERT(0 && "Called PushStyleVar() float variant but variable is not a float!"); } void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val) { const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx); if (var_info->Type == ImGuiDataType_Float && var_info->Count == 2) { ImGuiContext& g = *GImGui; ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style); g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar)); *pvar = val; return; } IM_ASSERT(0 && "Called PushStyleVar() ImVec2 variant but variable is not a ImVec2!"); } void ImGui::PopStyleVar(int count) { ImGuiContext& g = *GImGui; while (count > 0) { // We avoid a generic memcpy(data, &backup.Backup.., GDataTypeSize[info->Type] * info->Count), the overhead in Debug is not worth it. ImGuiStyleMod& backup = g.StyleModifiers.back(); const ImGuiStyleVarInfo* info = GetStyleVarInfo(backup.VarIdx); void* data = info->GetVarPtr(&g.Style); if (info->Type == ImGuiDataType_Float && info->Count == 1) { ((float*)data)[0] = backup.BackupFloat[0]; } else if (info->Type == ImGuiDataType_Float && info->Count == 2) { ((float*)data)[0] = backup.BackupFloat[0]; ((float*)data)[1] = backup.BackupFloat[1]; } g.StyleModifiers.pop_back(); count--; } } const char* ImGui::GetStyleColorName(ImGuiCol idx) { // Create switch-case from enum with regexp: ImGuiCol_{.*}, --> case ImGuiCol_\1: return "\1"; switch (idx) { case ImGuiCol_Text: return "Text"; case ImGuiCol_TextDisabled: return "TextDisabled"; case ImGuiCol_WindowBg: return "WindowBg"; case ImGuiCol_ChildBg: return "ChildBg"; case ImGuiCol_PopupBg: return "PopupBg"; case ImGuiCol_Border: return "Border"; case ImGuiCol_BorderShadow: return "BorderShadow"; case ImGuiCol_FrameBg: return "FrameBg"; case ImGuiCol_FrameBgHovered: return "FrameBgHovered"; case ImGuiCol_FrameBgActive: return "FrameBgActive"; case ImGuiCol_TitleBg: return "TitleBg"; case ImGuiCol_TitleBgActive: return "TitleBgActive"; case ImGuiCol_TitleBgCollapsed: return "TitleBgCollapsed"; case ImGuiCol_MenuBarBg: return "MenuBarBg"; case ImGuiCol_ScrollbarBg: return "ScrollbarBg"; case ImGuiCol_ScrollbarGrab: return "ScrollbarGrab"; case ImGuiCol_ScrollbarGrabHovered: return "ScrollbarGrabHovered"; case ImGuiCol_ScrollbarGrabActive: return "ScrollbarGrabActive"; case ImGuiCol_CheckMark: return "CheckMark"; case ImGuiCol_SliderGrab: return "SliderGrab"; case ImGuiCol_SliderGrabActive: return "SliderGrabActive"; case ImGuiCol_Button: return "Button"; case ImGuiCol_ButtonHovered: return "ButtonHovered"; case ImGuiCol_ButtonActive: return "ButtonActive"; case ImGuiCol_Header: return "Header"; case ImGuiCol_HeaderHovered: return "HeaderHovered"; case ImGuiCol_HeaderActive: return "HeaderActive"; case ImGuiCol_Separator: return "Separator"; case ImGuiCol_SeparatorHovered: return "SeparatorHovered"; case ImGuiCol_SeparatorActive: return "SeparatorActive"; case ImGuiCol_ResizeGrip: return "ResizeGrip"; case ImGuiCol_ResizeGripHovered: return "ResizeGripHovered"; case ImGuiCol_ResizeGripActive: return "ResizeGripActive"; case ImGuiCol_Tab: return "Tab"; case ImGuiCol_TabHovered: return "TabHovered"; case ImGuiCol_TabActive: return "TabActive"; case ImGuiCol_TabUnfocused: return "TabUnfocused"; case ImGuiCol_TabUnfocusedActive: return "TabUnfocusedActive"; case ImGuiCol_PlotLines: return "PlotLines"; case ImGuiCol_PlotLinesHovered: return "PlotLinesHovered"; case ImGuiCol_PlotHistogram: return "PlotHistogram"; case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered"; case ImGuiCol_TextSelectedBg: return "TextSelectedBg"; case ImGuiCol_DragDropTarget: return "DragDropTarget"; case ImGuiCol_NavHighlight: return "NavHighlight"; case ImGuiCol_NavWindowingHighlight: return "NavWindowingHighlight"; case ImGuiCol_NavWindowingDimBg: return "NavWindowingDimBg"; case ImGuiCol_ModalWindowDimBg: return "ModalWindowDimBg"; } IM_ASSERT(0); return "Unknown"; } bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent) { if (window->RootWindow == potential_parent) return true; while (window != NULL) { if (window == potential_parent) return true; window = window->ParentWindow; } return false; } bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags) { IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function ImGuiContext& g = *GImGui; if (flags & ImGuiHoveredFlags_AnyWindow) { if (g.HoveredWindow == NULL) return false; } else { switch (flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows)) { case ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows: if (g.HoveredRootWindow != g.CurrentWindow->RootWindow) return false; break; case ImGuiHoveredFlags_RootWindow: if (g.HoveredWindow != g.CurrentWindow->RootWindow) return false; break; case ImGuiHoveredFlags_ChildWindows: if (g.HoveredWindow == NULL || !IsWindowChildOf(g.HoveredWindow, g.CurrentWindow)) return false; break; default: if (g.HoveredWindow != g.CurrentWindow) return false; break; } } if (!IsWindowContentHoverable(g.HoveredWindow, flags)) return false; if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) if (g.ActiveId != 0 && !g.ActiveIdAllowOverlap && g.ActiveId != g.HoveredWindow->MoveId) return false; return true; } bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags) { ImGuiContext& g = *GImGui; if (flags & ImGuiFocusedFlags_AnyWindow) return g.NavWindow != NULL; IM_ASSERT(g.CurrentWindow); // Not inside a Begin()/End() switch (flags & (ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows)) { case ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows: return g.NavWindow && g.NavWindow->RootWindow == g.CurrentWindow->RootWindow; case ImGuiFocusedFlags_RootWindow: return g.NavWindow == g.CurrentWindow->RootWindow; case ImGuiFocusedFlags_ChildWindows: return g.NavWindow && IsWindowChildOf(g.NavWindow, g.CurrentWindow); default: return g.NavWindow == g.CurrentWindow; } } // Can we focus this window with CTRL+TAB (or PadMenu + PadFocusPrev/PadFocusNext) // Note that NoNavFocus makes the window not reachable with CTRL+TAB but it can still be focused with mouse or programmaticaly. // If you want a window to never be focused, you may use the e.g. NoInputs flag. bool ImGui::IsWindowNavFocusable(ImGuiWindow* window) { return window->Active && window == window->RootWindow && !(window->Flags & ImGuiWindowFlags_NoNavFocus); } float ImGui::GetWindowWidth() { ImGuiWindow* window = GImGui->CurrentWindow; return window->Size.x; } float ImGui::GetWindowHeight() { ImGuiWindow* window = GImGui->CurrentWindow; return window->Size.y; } ImVec2 ImGui::GetWindowPos() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; return window->Pos; } void ImGui::SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond) { // Test condition (NB: bit 0 is always true) and clear flags for next time if (cond && (window->SetWindowPosAllowFlags & cond) == 0) return; IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); window->SetWindowPosVal = ImVec2(FLT_MAX, FLT_MAX); // Set const ImVec2 old_pos = window->Pos; window->Pos = ImFloor(pos); ImVec2 offset = window->Pos - old_pos; window->DC.CursorPos += offset; // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor window->DC.CursorMaxPos += offset; // And more importantly we need to offset CursorMaxPos/CursorStartPos this so ContentSize calculation doesn't get affected. window->DC.CursorStartPos += offset; } void ImGui::SetWindowPos(const ImVec2& pos, ImGuiCond cond) { ImGuiWindow* window = GetCurrentWindowRead(); SetWindowPos(window, pos, cond); } void ImGui::SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond) { if (ImGuiWindow* window = FindWindowByName(name)) SetWindowPos(window, pos, cond); } ImVec2 ImGui::GetWindowSize() { ImGuiWindow* window = GetCurrentWindowRead(); return window->Size; } void ImGui::SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond) { // Test condition (NB: bit 0 is always true) and clear flags for next time if (cond && (window->SetWindowSizeAllowFlags & cond) == 0) return; IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. window->SetWindowSizeAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); // Set if (size.x > 0.0f) { window->AutoFitFramesX = 0; window->SizeFull.x = IM_FLOOR(size.x); } else { window->AutoFitFramesX = 2; window->AutoFitOnlyGrows = false; } if (size.y > 0.0f) { window->AutoFitFramesY = 0; window->SizeFull.y = IM_FLOOR(size.y); } else { window->AutoFitFramesY = 2; window->AutoFitOnlyGrows = false; } } void ImGui::SetWindowSize(const ImVec2& size, ImGuiCond cond) { SetWindowSize(GImGui->CurrentWindow, size, cond); } void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond) { if (ImGuiWindow* window = FindWindowByName(name)) SetWindowSize(window, size, cond); } void ImGui::SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond) { // Test condition (NB: bit 0 is always true) and clear flags for next time if (cond && (window->SetWindowCollapsedAllowFlags & cond) == 0) return; window->SetWindowCollapsedAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); // Set window->Collapsed = collapsed; } void ImGui::SetWindowCollapsed(bool collapsed, ImGuiCond cond) { SetWindowCollapsed(GImGui->CurrentWindow, collapsed, cond); } bool ImGui::IsWindowCollapsed() { ImGuiWindow* window = GetCurrentWindowRead(); return window->Collapsed; } bool ImGui::IsWindowAppearing() { ImGuiWindow* window = GetCurrentWindowRead(); return window->Appearing; } void ImGui::SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond) { if (ImGuiWindow* window = FindWindowByName(name)) SetWindowCollapsed(window, collapsed, cond); } void ImGui::SetWindowFocus() { FocusWindow(GImGui->CurrentWindow); } void ImGui::SetWindowFocus(const char* name) { if (name) { if (ImGuiWindow* window = FindWindowByName(name)) FocusWindow(window); } else { FocusWindow(NULL); } } void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pivot) { ImGuiContext& g = *GImGui; IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasPos; g.NextWindowData.PosVal = pos; g.NextWindowData.PosPivotVal = pivot; g.NextWindowData.PosCond = cond ? cond : ImGuiCond_Always; } void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond) { ImGuiContext& g = *GImGui; IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSize; g.NextWindowData.SizeVal = size; g.NextWindowData.SizeCond = cond ? cond : ImGuiCond_Always; } void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback, void* custom_callback_user_data) { ImGuiContext& g = *GImGui; g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSizeConstraint; g.NextWindowData.SizeConstraintRect = ImRect(size_min, size_max); g.NextWindowData.SizeCallback = custom_callback; g.NextWindowData.SizeCallbackUserData = custom_callback_user_data; } // Content size = inner scrollable rectangle, padded with WindowPadding. // SetNextWindowContentSize(ImVec2(100,100) + ImGuiWindowFlags_AlwaysAutoResize will always allow submitting a 100x100 item. void ImGui::SetNextWindowContentSize(const ImVec2& size) { ImGuiContext& g = *GImGui; g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasContentSize; g.NextWindowData.ContentSizeVal = size; } void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond) { ImGuiContext& g = *GImGui; IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasCollapsed; g.NextWindowData.CollapsedVal = collapsed; g.NextWindowData.CollapsedCond = cond ? cond : ImGuiCond_Always; } void ImGui::SetNextWindowFocus() { ImGuiContext& g = *GImGui; g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasFocus; } void ImGui::SetNextWindowBgAlpha(float alpha) { ImGuiContext& g = *GImGui; g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasBgAlpha; g.NextWindowData.BgAlphaVal = alpha; } // FIXME: This is in window space (not screen space!). We should try to obsolete all those functions. ImVec2 ImGui::GetContentRegionMax() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; ImVec2 mx = window->ContentRegionRect.Max - window->Pos; if (window->DC.CurrentColumns) mx.x = window->WorkRect.Max.x - window->Pos.x; return mx; } // [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features. ImVec2 ImGui::GetContentRegionMaxAbs() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; ImVec2 mx = window->ContentRegionRect.Max; if (window->DC.CurrentColumns) mx.x = window->WorkRect.Max.x; return mx; } ImVec2 ImGui::GetContentRegionAvail() { ImGuiWindow* window = GImGui->CurrentWindow; return GetContentRegionMaxAbs() - window->DC.CursorPos; } // In window space (not screen space!) ImVec2 ImGui::GetWindowContentRegionMin() { ImGuiWindow* window = GImGui->CurrentWindow; return window->ContentRegionRect.Min - window->Pos; } ImVec2 ImGui::GetWindowContentRegionMax() { ImGuiWindow* window = GImGui->CurrentWindow; return window->ContentRegionRect.Max - window->Pos; } float ImGui::GetWindowContentRegionWidth() { ImGuiWindow* window = GImGui->CurrentWindow; return window->ContentRegionRect.GetWidth(); } float ImGui::GetTextLineHeight() { ImGuiContext& g = *GImGui; return g.FontSize; } float ImGui::GetTextLineHeightWithSpacing() { ImGuiContext& g = *GImGui; return g.FontSize + g.Style.ItemSpacing.y; } float ImGui::GetFrameHeight() { ImGuiContext& g = *GImGui; return g.FontSize + g.Style.FramePadding.y * 2.0f; } float ImGui::GetFrameHeightWithSpacing() { ImGuiContext& g = *GImGui; return g.FontSize + g.Style.FramePadding.y * 2.0f + g.Style.ItemSpacing.y; } ImDrawList* ImGui::GetWindowDrawList() { ImGuiWindow* window = GetCurrentWindow(); return window->DrawList; } ImFont* ImGui::GetFont() { return GImGui->Font; } float ImGui::GetFontSize() { return GImGui->FontSize; } ImVec2 ImGui::GetFontTexUvWhitePixel() { return GImGui->DrawListSharedData.TexUvWhitePixel; } void ImGui::SetWindowFontScale(float scale) { ImGuiContext& g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); window->FontWindowScale = scale; g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize(); } // User generally sees positions in window coordinates. Internally we store CursorPos in absolute screen coordinates because it is more convenient. // Conversion happens as we pass the value to user, but it makes our naming convention confusing because GetCursorPos() == (DC.CursorPos - window.Pos). May want to rename 'DC.CursorPos'. ImVec2 ImGui::GetCursorPos() { ImGuiWindow* window = GetCurrentWindowRead(); return window->DC.CursorPos - window->Pos + window->Scroll; } float ImGui::GetCursorPosX() { ImGuiWindow* window = GetCurrentWindowRead(); return window->DC.CursorPos.x - window->Pos.x + window->Scroll.x; } float ImGui::GetCursorPosY() { ImGuiWindow* window = GetCurrentWindowRead(); return window->DC.CursorPos.y - window->Pos.y + window->Scroll.y; } void ImGui::SetCursorPos(const ImVec2& local_pos) { ImGuiWindow* window = GetCurrentWindow(); window->DC.CursorPos = window->Pos - window->Scroll + local_pos; window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); } void ImGui::SetCursorPosX(float x) { ImGuiWindow* window = GetCurrentWindow(); window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + x; window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPos.x); } void ImGui::SetCursorPosY(float y) { ImGuiWindow* window = GetCurrentWindow(); window->DC.CursorPos.y = window->Pos.y - window->Scroll.y + y; window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y); } ImVec2 ImGui::GetCursorStartPos() { ImGuiWindow* window = GetCurrentWindowRead(); return window->DC.CursorStartPos - window->Pos; } ImVec2 ImGui::GetCursorScreenPos() { ImGuiWindow* window = GetCurrentWindowRead(); return window->DC.CursorPos; } void ImGui::SetCursorScreenPos(const ImVec2& pos) { ImGuiWindow* window = GetCurrentWindow(); window->DC.CursorPos = pos; window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); } void ImGui::ActivateItem(ImGuiID id) { ImGuiContext& g = *GImGui; g.NavNextActivateId = id; } void ImGui::PushFocusScope(ImGuiID id) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; window->IDStack.push_back(window->DC.NavFocusScopeIdCurrent); window->DC.NavFocusScopeIdCurrent = id; } void ImGui::PopFocusScope() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; window->DC.NavFocusScopeIdCurrent = window->IDStack.back(); window->IDStack.pop_back(); } void ImGui::SetKeyboardFocusHere(int offset) { IM_ASSERT(offset >= -1); // -1 is allowed but not below ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; g.FocusRequestNextWindow = window; g.FocusRequestNextCounterRegular = window->DC.FocusCounterRegular + 1 + offset; g.FocusRequestNextCounterTabStop = INT_MAX; } void ImGui::SetItemDefaultFocus() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (!window->Appearing) return; if (g.NavWindow == window->RootWindowForNav && (g.NavInitRequest || g.NavInitResultId != 0) && g.NavLayer == g.NavWindow->DC.NavLayerCurrent) { g.NavInitRequest = false; g.NavInitResultId = g.NavWindow->DC.LastItemId; g.NavInitResultRectRel = ImRect(g.NavWindow->DC.LastItemRect.Min - g.NavWindow->Pos, g.NavWindow->DC.LastItemRect.Max - g.NavWindow->Pos); NavUpdateAnyRequestFlag(); if (!IsItemVisible()) SetScrollHereY(); } } void ImGui::SetStateStorage(ImGuiStorage* tree) { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.StateStorage = tree ? tree : &window->StateStorage; } ImGuiStorage* ImGui::GetStateStorage() { ImGuiWindow* window = GImGui->CurrentWindow; return window->DC.StateStorage; } void ImGui::PushID(const char* str_id) { ImGuiWindow* window = GImGui->CurrentWindow; window->IDStack.push_back(window->GetIDNoKeepAlive(str_id)); } void ImGui::PushID(const char* str_id_begin, const char* str_id_end) { ImGuiWindow* window = GImGui->CurrentWindow; window->IDStack.push_back(window->GetIDNoKeepAlive(str_id_begin, str_id_end)); } void ImGui::PushID(const void* ptr_id) { ImGuiWindow* window = GImGui->CurrentWindow; window->IDStack.push_back(window->GetIDNoKeepAlive(ptr_id)); } void ImGui::PushID(int int_id) { ImGuiWindow* window = GImGui->CurrentWindow; window->IDStack.push_back(window->GetIDNoKeepAlive(int_id)); } // Push a given id value ignoring the ID stack as a seed. void ImGui::PushOverrideID(ImGuiID id) { ImGuiWindow* window = GImGui->CurrentWindow; window->IDStack.push_back(id); } void ImGui::PopID() { ImGuiWindow* window = GImGui->CurrentWindow; window->IDStack.pop_back(); } ImGuiID ImGui::GetID(const char* str_id) { ImGuiWindow* window = GImGui->CurrentWindow; return window->GetID(str_id); } ImGuiID ImGui::GetID(const char* str_id_begin, const char* str_id_end) { ImGuiWindow* window = GImGui->CurrentWindow; return window->GetID(str_id_begin, str_id_end); } ImGuiID ImGui::GetID(const void* ptr_id) { ImGuiWindow* window = GImGui->CurrentWindow; return window->GetID(ptr_id); } bool ImGui::IsRectVisible(const ImVec2& size) { ImGuiWindow* window = GImGui->CurrentWindow; return window->ClipRect.Overlaps(ImRect(window->DC.CursorPos, window->DC.CursorPos + size)); } bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max) { ImGuiWindow* window = GImGui->CurrentWindow; return window->ClipRect.Overlaps(ImRect(rect_min, rect_max)); } // Lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.) void ImGui::BeginGroup() { ImGuiContext& g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); window->DC.GroupStack.resize(window->DC.GroupStack.Size + 1); ImGuiGroupData& group_data = window->DC.GroupStack.back(); group_data.BackupCursorPos = window->DC.CursorPos; group_data.BackupCursorMaxPos = window->DC.CursorMaxPos; group_data.BackupIndent = window->DC.Indent; group_data.BackupGroupOffset = window->DC.GroupOffset; group_data.BackupCurrLineSize = window->DC.CurrLineSize; group_data.BackupCurrLineTextBaseOffset = window->DC.CurrLineTextBaseOffset; group_data.BackupActiveIdIsAlive = g.ActiveIdIsAlive; group_data.BackupActiveIdPreviousFrameIsAlive = g.ActiveIdPreviousFrameIsAlive; group_data.EmitItem = true; window->DC.GroupOffset.x = window->DC.CursorPos.x - window->Pos.x - window->DC.ColumnsOffset.x; window->DC.Indent = window->DC.GroupOffset; window->DC.CursorMaxPos = window->DC.CursorPos; window->DC.CurrLineSize = ImVec2(0.0f, 0.0f); if (g.LogEnabled) g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return } void ImGui::EndGroup() { ImGuiContext& g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); IM_ASSERT(!window->DC.GroupStack.empty()); // Mismatched BeginGroup()/EndGroup() calls ImGuiGroupData& group_data = window->DC.GroupStack.back(); ImRect group_bb(group_data.BackupCursorPos, ImMax(window->DC.CursorMaxPos, group_data.BackupCursorPos)); window->DC.CursorPos = group_data.BackupCursorPos; window->DC.CursorMaxPos = ImMax(group_data.BackupCursorMaxPos, window->DC.CursorMaxPos); window->DC.Indent = group_data.BackupIndent; window->DC.GroupOffset = group_data.BackupGroupOffset; window->DC.CurrLineSize = group_data.BackupCurrLineSize; window->DC.CurrLineTextBaseOffset = group_data.BackupCurrLineTextBaseOffset; if (g.LogEnabled) g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return if (!group_data.EmitItem) { window->DC.GroupStack.pop_back(); return; } window->DC.CurrLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now. ItemSize(group_bb.GetSize()); ItemAdd(group_bb, 0); // If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive(), IsItemDeactivated() etc. will be functional on the entire group. // It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but would put a little more burden on individual widgets. // Also if you grep for LastItemId you'll notice it is only used in that context. // (The tests not symmetrical because ActiveIdIsAlive is an ID itself, in order to be able to handle ActiveId being overwritten during the frame.) const bool group_contains_curr_active_id = (group_data.BackupActiveIdIsAlive != g.ActiveId) && (g.ActiveIdIsAlive == g.ActiveId) && g.ActiveId; const bool group_contains_prev_active_id = !group_data.BackupActiveIdPreviousFrameIsAlive && g.ActiveIdPreviousFrameIsAlive; if (group_contains_curr_active_id) window->DC.LastItemId = g.ActiveId; else if (group_contains_prev_active_id) window->DC.LastItemId = g.ActiveIdPreviousFrame; window->DC.LastItemRect = group_bb; // Forward Edited flag if (group_contains_curr_active_id && g.ActiveIdHasBeenEditedThisFrame) window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Edited; // Forward Deactivated flag window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HasDeactivated; if (group_contains_prev_active_id && g.ActiveId != g.ActiveIdPreviousFrame) window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Deactivated; window->DC.GroupStack.pop_back(); //window->DrawList->AddRect(group_bb.Min, group_bb.Max, IM_COL32(255,0,255,255)); // [Debug] } // Gets back to previous line and continue with horizontal layout // offset_from_start_x == 0 : follow right after previous item // offset_from_start_x != 0 : align to specified x position (relative to window/group left) // spacing_w < 0 : use default spacing if pos_x == 0, no spacing if pos_x != 0 // spacing_w >= 0 : enforce spacing amount void ImGui::SameLine(float offset_from_start_x, float spacing_w) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; ImGuiContext& g = *GImGui; if (offset_from_start_x != 0.0f) { if (spacing_w < 0.0f) spacing_w = 0.0f; window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + offset_from_start_x + spacing_w + window->DC.GroupOffset.x + window->DC.ColumnsOffset.x; window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y; } else { if (spacing_w < 0.0f) spacing_w = g.Style.ItemSpacing.x; window->DC.CursorPos.x = window->DC.CursorPosPrevLine.x + spacing_w; window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y; } window->DC.CurrLineSize = window->DC.PrevLineSize; window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset; } void ImGui::Indent(float indent_w) { ImGuiContext& g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); window->DC.Indent.x += (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing; window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x; } void ImGui::Unindent(float indent_w) { ImGuiContext& g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); window->DC.Indent.x -= (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing; window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x; } //----------------------------------------------------------------------------- // [SECTION] ERROR CHECKING //----------------------------------------------------------------------------- static void ImGui::ErrorCheckEndFrame() { // Report when there is a mismatch of Begin/BeginChild vs End/EndChild calls. Important: Remember that the Begin/BeginChild API requires you // to always call End/EndChild even if Begin/BeginChild returns false! (this is unfortunately inconsistent with most other Begin* API). ImGuiContext& g = *GImGui; if (g.CurrentWindowStack.Size != 1) { if (g.CurrentWindowStack.Size > 1) { IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size == 1, "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?"); while (g.CurrentWindowStack.Size > 1) End(); } else { IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size == 1, "Mismatched Begin/BeginChild vs End/EndChild calls: did you call End/EndChild too much?"); } } } // Save and compare stack sizes on Begin()/End() to detect usage errors // Begin() calls this with write=true // End() calls this with write=false static void ImGui::ErrorCheckBeginEndCompareStacksSize(ImGuiWindow* window, bool write) { ImGuiContext& g = *GImGui; short* p = &window->DC.StackSizesBackup[0]; // Window stacks // NOT checking: DC.ItemWidth, DC.AllowKeyboardFocus, DC.ButtonRepeat, DC.TextWrapPos (per window) to allow user to conveniently push once and not pop (they are cleared on Begin) { int n = window->IDStack.Size; if (write) *p = (short)n; else IM_ASSERT(*p == n && "PushID/PopID or TreeNode/TreePop Mismatch!"); p++; } // Too few or too many PopID()/TreePop() { int n = window->DC.GroupStack.Size; if (write) *p = (short)n; else IM_ASSERT(*p == n && "BeginGroup/EndGroup Mismatch!"); p++; } // Too few or too many EndGroup() // Global stacks // For color, style and font stacks there is an incentive to use Push/Begin/Pop/.../End patterns, so we relax our checks a little to allow them. { int n = g.BeginPopupStack.Size; if (write) *p = (short)n; else IM_ASSERT(*p == n && "BeginMenu/EndMenu or BeginPopup/EndPopup Mismatch!"); p++; }// Too few or too many EndMenu()/EndPopup() { int n = g.ColorModifiers.Size; if (write) *p = (short)n; else IM_ASSERT(*p >= n && "PushStyleColor/PopStyleColor Mismatch!"); p++; } // Too few or too many PopStyleColor() { int n = g.StyleModifiers.Size; if (write) *p = (short)n; else IM_ASSERT(*p >= n && "PushStyleVar/PopStyleVar Mismatch!"); p++; } // Too few or too many PopStyleVar() { int n = g.FontStack.Size; if (write) *p = (short)n; else IM_ASSERT(*p >= n && "PushFont/PopFont Mismatch!"); p++; } // Too few or too many PopFont() IM_ASSERT(p == window->DC.StackSizesBackup + IM_ARRAYSIZE(window->DC.StackSizesBackup)); } //----------------------------------------------------------------------------- // [SECTION] SCROLLING //----------------------------------------------------------------------------- static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges) { ImGuiContext& g = *GImGui; ImVec2 scroll = window->Scroll; if (window->ScrollTarget.x < FLT_MAX) { float cr_x = window->ScrollTargetCenterRatio.x; float target_x = window->ScrollTarget.x; if (snap_on_edges && cr_x <= 0.0f && target_x <= window->WindowPadding.x) target_x = 0.0f; else if (snap_on_edges && cr_x >= 1.0f && target_x >= window->ContentSize.x + window->WindowPadding.x + g.Style.ItemSpacing.x) target_x = window->ContentSize.x + window->WindowPadding.x * 2.0f; scroll.x = target_x - cr_x * (window->SizeFull.x - window->ScrollbarSizes.x); } if (window->ScrollTarget.y < FLT_MAX) { // 'snap_on_edges' allows for a discontinuity at the edge of scrolling limits to take account of WindowPadding so that scrolling to make the last item visible scroll far enough to see the padding. float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight(); float cr_y = window->ScrollTargetCenterRatio.y; float target_y = window->ScrollTarget.y; if (snap_on_edges && cr_y <= 0.0f && target_y <= window->WindowPadding.y) target_y = 0.0f; if (snap_on_edges && cr_y >= 1.0f && target_y >= window->ContentSize.y + window->WindowPadding.y + g.Style.ItemSpacing.y) target_y = window->ContentSize.y + window->WindowPadding.y * 2.0f; scroll.y = target_y - cr_y * (window->SizeFull.y - window->ScrollbarSizes.y - decoration_up_height); } scroll = ImMax(scroll, ImVec2(0.0f, 0.0f)); if (!window->Collapsed && !window->SkipItems) { scroll.x = ImMin(scroll.x, window->ScrollMax.x); scroll.y = ImMin(scroll.y, window->ScrollMax.y); } return scroll; } // Scroll to keep newly navigated item fully into view ImVec2 ImGui::ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect) { ImGuiContext& g = *GImGui; ImRect window_rect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1)); //GetForegroundDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG] ImVec2 delta_scroll; if (!window_rect.Contains(item_rect)) { if (window->ScrollbarX && item_rect.Min.x < window_rect.Min.x) SetScrollFromPosX(window, item_rect.Min.x - window->Pos.x + g.Style.ItemSpacing.x, 0.0f); else if (window->ScrollbarX && item_rect.Max.x >= window_rect.Max.x) SetScrollFromPosX(window, item_rect.Max.x - window->Pos.x + g.Style.ItemSpacing.x, 1.0f); if (item_rect.Min.y < window_rect.Min.y) SetScrollFromPosY(window, item_rect.Min.y - window->Pos.y - g.Style.ItemSpacing.y, 0.0f); else if (item_rect.Max.y >= window_rect.Max.y) SetScrollFromPosY(window, item_rect.Max.y - window->Pos.y + g.Style.ItemSpacing.y, 1.0f); ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(window, false); delta_scroll = next_scroll - window->Scroll; } // Also scroll parent window to keep us into view if necessary if (window->Flags & ImGuiWindowFlags_ChildWindow) delta_scroll += ScrollToBringRectIntoView(window->ParentWindow, ImRect(item_rect.Min - delta_scroll, item_rect.Max - delta_scroll)); return delta_scroll; } float ImGui::GetScrollX() { ImGuiWindow* window = GImGui->CurrentWindow; return window->Scroll.x; } float ImGui::GetScrollY() { ImGuiWindow* window = GImGui->CurrentWindow; return window->Scroll.y; } float ImGui::GetScrollMaxX() { ImGuiWindow* window = GImGui->CurrentWindow; return window->ScrollMax.x; } float ImGui::GetScrollMaxY() { ImGuiWindow* window = GImGui->CurrentWindow; return window->ScrollMax.y; } void ImGui::SetScrollX(float scroll_x) { ImGuiWindow* window = GetCurrentWindow(); window->ScrollTarget.x = scroll_x; window->ScrollTargetCenterRatio.x = 0.0f; } void ImGui::SetScrollY(float scroll_y) { ImGuiWindow* window = GetCurrentWindow(); window->ScrollTarget.y = scroll_y; window->ScrollTargetCenterRatio.y = 0.0f; } void ImGui::SetScrollX(ImGuiWindow* window, float new_scroll_x) { window->ScrollTarget.x = new_scroll_x; window->ScrollTargetCenterRatio.x = 0.0f; } void ImGui::SetScrollY(ImGuiWindow* window, float new_scroll_y) { window->ScrollTarget.y = new_scroll_y; window->ScrollTargetCenterRatio.y = 0.0f; } void ImGui::SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio) { // We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size IM_ASSERT(center_x_ratio >= 0.0f && center_x_ratio <= 1.0f); window->ScrollTarget.x = IM_FLOOR(local_x + window->Scroll.x); window->ScrollTargetCenterRatio.x = center_x_ratio; } void ImGui::SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio) { // We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f); const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight(); local_y -= decoration_up_height; window->ScrollTarget.y = IM_FLOOR(local_y + window->Scroll.y); window->ScrollTargetCenterRatio.y = center_y_ratio; } void ImGui::SetScrollFromPosX(float local_x, float center_x_ratio) { ImGuiContext& g = *GImGui; SetScrollFromPosX(g.CurrentWindow, local_x, center_x_ratio); } void ImGui::SetScrollFromPosY(float local_y, float center_y_ratio) { ImGuiContext& g = *GImGui; SetScrollFromPosY(g.CurrentWindow, local_y, center_y_ratio); } // center_x_ratio: 0.0f left of last item, 0.5f horizontal center of last item, 1.0f right of last item. void ImGui::SetScrollHereX(float center_x_ratio) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; float target_x = window->DC.LastItemRect.Min.x - window->Pos.x; // Left of last item, in window space float last_item_width = window->DC.LastItemRect.GetWidth(); target_x += (last_item_width * center_x_ratio) + (g.Style.ItemSpacing.x * (center_x_ratio - 0.5f) * 2.0f); // Precisely aim before, in the middle or after the last item. SetScrollFromPosX(target_x, center_x_ratio); } // center_y_ratio: 0.0f top of last item, 0.5f vertical center of last item, 1.0f bottom of last item. void ImGui::SetScrollHereY(float center_y_ratio) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; float target_y = window->DC.CursorPosPrevLine.y - window->Pos.y; // Top of last item, in window space target_y += (window->DC.PrevLineSize.y * center_y_ratio) + (g.Style.ItemSpacing.y * (center_y_ratio - 0.5f) * 2.0f); // Precisely aim above, in the middle or below the last line. SetScrollFromPosY(target_y, center_y_ratio); } //----------------------------------------------------------------------------- // [SECTION] TOOLTIPS //----------------------------------------------------------------------------- void ImGui::BeginTooltip() { BeginTooltipEx(ImGuiWindowFlags_None, ImGuiTooltipFlags_None); } void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags) { ImGuiContext& g = *GImGui; if (g.DragDropWithinSourceOrTarget) { // The default tooltip position is a little offset to give space to see the context menu (it's also clamped within the current viewport/monitor) // In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor. // Whatever we do we want to call SetNextWindowPos() to enforce a tooltip position and disable clipping the tooltip without our display area, like regular tooltip do. //ImVec2 tooltip_pos = g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding; ImVec2 tooltip_pos = g.IO.MousePos + ImVec2(16 * g.Style.MouseCursorScale, 8 * g.Style.MouseCursorScale); SetNextWindowPos(tooltip_pos); SetNextWindowBgAlpha(g.Style.Colors[ImGuiCol_PopupBg].w * 0.60f); //PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This would be nice but e.g ColorButton with checkboard has issue with transparent colors :( tooltip_flags |= ImGuiTooltipFlags_OverridePreviousTooltip; } char window_name[16]; ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", g.TooltipOverrideCount); if (tooltip_flags & ImGuiTooltipFlags_OverridePreviousTooltip) if (ImGuiWindow* window = FindWindowByName(window_name)) if (window->Active) { // Hide previous tooltip from being displayed. We can't easily "reset" the content of a window so we create a new one. window->Hidden = true; window->HiddenFramesCanSkipItems = 1; ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount); } ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoInputs|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize; Begin(window_name, NULL, flags | extra_flags); } void ImGui::EndTooltip() { IM_ASSERT(GetCurrentWindowRead()->Flags & ImGuiWindowFlags_Tooltip); // Mismatched BeginTooltip()/EndTooltip() calls End(); } void ImGui::SetTooltipV(const char* fmt, va_list args) { BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip); TextV(fmt, args); EndTooltip(); } void ImGui::SetTooltip(const char* fmt, ...) { va_list args; va_start(args, fmt); SetTooltipV(fmt, args); va_end(args); } //----------------------------------------------------------------------------- // [SECTION] POPUPS //----------------------------------------------------------------------------- bool ImGui::IsPopupOpen(ImGuiID id) { ImGuiContext& g = *GImGui; return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == id; } bool ImGui::IsPopupOpen(const char* str_id) { ImGuiContext& g = *GImGui; return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == g.CurrentWindow->GetID(str_id); } ImGuiWindow* ImGui::GetTopMostPopupModal() { ImGuiContext& g = *GImGui; for (int n = g.OpenPopupStack.Size-1; n >= 0; n--) if (ImGuiWindow* popup = g.OpenPopupStack.Data[n].Window) if (popup->Flags & ImGuiWindowFlags_Modal) return popup; return NULL; } void ImGui::OpenPopup(const char* str_id) { ImGuiContext& g = *GImGui; OpenPopupEx(g.CurrentWindow->GetID(str_id)); } // Mark popup as open (toggle toward open state). // Popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. // Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). // One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL) void ImGui::OpenPopupEx(ImGuiID id) { ImGuiContext& g = *GImGui; ImGuiWindow* parent_window = g.CurrentWindow; int current_stack_size = g.BeginPopupStack.Size; ImGuiPopupData popup_ref; // Tagged as new ref as Window will be set back to NULL if we write this into OpenPopupStack. popup_ref.PopupId = id; popup_ref.Window = NULL; popup_ref.SourceWindow = g.NavWindow; popup_ref.OpenFrameCount = g.FrameCount; popup_ref.OpenParentId = parent_window->IDStack.back(); popup_ref.OpenPopupPos = NavCalcPreferredRefPos(); popup_ref.OpenMousePos = IsMousePosValid(&g.IO.MousePos) ? g.IO.MousePos : popup_ref.OpenPopupPos; //IMGUI_DEBUG_LOG("OpenPopupEx(0x%08X)\n", g.FrameCount, id); if (g.OpenPopupStack.Size < current_stack_size + 1) { g.OpenPopupStack.push_back(popup_ref); } else { // Gently handle the user mistakenly calling OpenPopup() every frame. It is a programming mistake! However, if we were to run the regular code path, the ui // would become completely unusable because the popup will always be in hidden-while-calculating-size state _while_ claiming focus. Which would be a very confusing // situation for the programmer. Instead, we silently allow the popup to proceed, it will keep reappearing and the programming error will be more obvious to understand. if (g.OpenPopupStack[current_stack_size].PopupId == id && g.OpenPopupStack[current_stack_size].OpenFrameCount == g.FrameCount - 1) { g.OpenPopupStack[current_stack_size].OpenFrameCount = popup_ref.OpenFrameCount; } else { // Close child popups if any, then flag popup for open/reopen g.OpenPopupStack.resize(current_stack_size + 1); g.OpenPopupStack[current_stack_size] = popup_ref; } // When reopening a popup we first refocus its parent, otherwise if its parent is itself a popup it would get closed by ClosePopupsOverWindow(). // This is equivalent to what ClosePopupToLevel() does. //if (g.OpenPopupStack[current_stack_size].PopupId == id) // FocusWindow(parent_window); } } void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup) { ImGuiContext& g = *GImGui; if (g.OpenPopupStack.empty()) return; // When popups are stacked, clicking on a lower level popups puts focus back to it and close popups above it. // Don't close our own child popup windows. int popup_count_to_keep = 0; if (ref_window) { // Find the highest popup which is a descendant of the reference window (generally reference window = NavWindow) for (; popup_count_to_keep < g.OpenPopupStack.Size; popup_count_to_keep++) { ImGuiPopupData& popup = g.OpenPopupStack[popup_count_to_keep]; if (!popup.Window) continue; IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0); if (popup.Window->Flags & ImGuiWindowFlags_ChildWindow) continue; // Trim the stack when popups are not direct descendant of the reference window (the reference window is often the NavWindow) bool popup_or_descendent_is_ref_window = false; for (int m = popup_count_to_keep; m < g.OpenPopupStack.Size && !popup_or_descendent_is_ref_window; m++) if (ImGuiWindow* popup_window = g.OpenPopupStack[m].Window) if (popup_window->RootWindow == ref_window->RootWindow) popup_or_descendent_is_ref_window = true; if (!popup_or_descendent_is_ref_window) break; } } if (popup_count_to_keep < g.OpenPopupStack.Size) // This test is not required but it allows to set a convenient breakpoint on the statement below { //IMGUI_DEBUG_LOG("ClosePopupsOverWindow(%s) -> ClosePopupToLevel(%d)\n", ref_window->Name, popup_count_to_keep); ClosePopupToLevel(popup_count_to_keep, restore_focus_to_window_under_popup); } } void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup) { ImGuiContext& g = *GImGui; IM_ASSERT(remaining >= 0 && remaining < g.OpenPopupStack.Size); ImGuiWindow* focus_window = g.OpenPopupStack[remaining].SourceWindow; ImGuiWindow* popup_window = g.OpenPopupStack[remaining].Window; g.OpenPopupStack.resize(remaining); if (restore_focus_to_window_under_popup) { if (focus_window && !focus_window->WasActive && popup_window) { // Fallback FocusTopMostWindowUnderOne(popup_window, NULL); } else { if (g.NavLayer == 0 && focus_window) focus_window = NavRestoreLastChildNavWindow(focus_window); FocusWindow(focus_window); } } } // Close the popup we have begin-ed into. void ImGui::CloseCurrentPopup() { ImGuiContext& g = *GImGui; int popup_idx = g.BeginPopupStack.Size - 1; if (popup_idx < 0 || popup_idx >= g.OpenPopupStack.Size || g.BeginPopupStack[popup_idx].PopupId != g.OpenPopupStack[popup_idx].PopupId) return; // Closing a menu closes its top-most parent popup (unless a modal) while (popup_idx > 0) { ImGuiWindow* popup_window = g.OpenPopupStack[popup_idx].Window; ImGuiWindow* parent_popup_window = g.OpenPopupStack[popup_idx - 1].Window; bool close_parent = false; if (popup_window && (popup_window->Flags & ImGuiWindowFlags_ChildMenu)) if (parent_popup_window == NULL || !(parent_popup_window->Flags & ImGuiWindowFlags_Modal)) close_parent = true; if (!close_parent) break; popup_idx--; } //IMGUI_DEBUG_LOG("CloseCurrentPopup %d -> %d\n", g.BeginPopupStack.Size - 1, popup_idx); ClosePopupToLevel(popup_idx, true); // A common pattern is to close a popup when selecting a menu item/selectable that will open another window. // To improve this usage pattern, we avoid nav highlight for a single frame in the parent window. // Similarly, we could avoid mouse hover highlight in this window but it is less visually problematic. if (ImGuiWindow* window = g.NavWindow) window->DC.NavHideHighlightOneFrame = true; } bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags) { ImGuiContext& g = *GImGui; if (!IsPopupOpen(id)) { g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values return false; } char name[20]; if (flags & ImGuiWindowFlags_ChildMenu) ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth else ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame flags |= ImGuiWindowFlags_Popup; bool is_open = Begin(name, NULL, flags); if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display) EndPopup(); return is_open; } bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags) { ImGuiContext& g = *GImGui; if (g.OpenPopupStack.Size <= g.BeginPopupStack.Size) // Early out for performance { g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values return false; } flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings; return BeginPopupEx(g.CurrentWindow->GetID(str_id), flags); } // If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup. // Note that popup visibility status is owned by Dear ImGui (and manipulated with e.g. OpenPopup) so the actual value of *p_open is meaningless here. bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; const ImGuiID id = window->GetID(name); if (!IsPopupOpen(id)) { g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values return false; } // Center modal windows by default // FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window. if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) == 0) SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings; const bool is_open = Begin(name, p_open, flags); if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display) { EndPopup(); if (is_open) ClosePopupToLevel(g.BeginPopupStack.Size, true); return false; } return is_open; } void ImGui::EndPopup() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; IM_ASSERT(window->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls IM_ASSERT(g.BeginPopupStack.Size > 0); // Make all menus and popups wrap around for now, may need to expose that policy. NavMoveRequestTryWrapping(window, ImGuiNavMoveFlags_LoopY); // Child-popups don't need to be layed out IM_ASSERT(g.WithinEndChild == false); if (window->Flags & ImGuiWindowFlags_ChildWindow) g.WithinEndChild = true; End(); g.WithinEndChild = false; } bool ImGui::OpenPopupOnItemClick(const char* str_id, ImGuiMouseButton mouse_button) { ImGuiWindow* window = GImGui->CurrentWindow; if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) { ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) OpenPopupEx(id); return true; } return false; } // This is a helper to handle the simplest case of associating one named popup to one given widget. // You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters). // You can pass a NULL str_id to use the identifier of the last item. bool ImGui::BeginPopupContextItem(const char* str_id, ImGuiMouseButton mouse_button) { ImGuiWindow* window = GImGui->CurrentWindow; if (window->SkipItems) return false; ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) OpenPopupEx(id); return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); } bool ImGui::BeginPopupContextWindow(const char* str_id, ImGuiMouseButton mouse_button, bool also_over_items) { if (!str_id) str_id = "window_context"; ImGuiID id = GImGui->CurrentWindow->GetID(str_id); if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) if (also_over_items || !IsAnyItemHovered()) OpenPopupEx(id); return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); } bool ImGui::BeginPopupContextVoid(const char* str_id, ImGuiMouseButton mouse_button) { if (!str_id) str_id = "void_context"; ImGuiID id = GImGui->CurrentWindow->GetID(str_id); if (IsMouseReleased(mouse_button) && !IsWindowHovered(ImGuiHoveredFlags_AnyWindow)) OpenPopupEx(id); return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); } // r_avoid = the rectangle to avoid (e.g. for tooltip it is a rectangle around the mouse cursor which we want to avoid. for popups it's a small point around the cursor.) // r_outer = the visible area rectangle, minus safe area padding. If our popup size won't fit because of safe area padding we ignore it. ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy) { ImVec2 base_pos_clamped = ImClamp(ref_pos, r_outer.Min, r_outer.Max - size); //GetForegroundDrawList()->AddRect(r_avoid.Min, r_avoid.Max, IM_COL32(255,0,0,255)); //GetForegroundDrawList()->AddRect(r_outer.Min, r_outer.Max, IM_COL32(0,255,0,255)); // Combo Box policy (we want a connecting edge) if (policy == ImGuiPopupPositionPolicy_ComboBox) { const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Down, ImGuiDir_Right, ImGuiDir_Left, ImGuiDir_Up }; for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++) { const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n]; if (n != -1 && dir == *last_dir) // Already tried this direction? continue; ImVec2 pos; if (dir == ImGuiDir_Down) pos = ImVec2(r_avoid.Min.x, r_avoid.Max.y); // Below, Toward Right (default) if (dir == ImGuiDir_Right) pos = ImVec2(r_avoid.Min.x, r_avoid.Min.y - size.y); // Above, Toward Right if (dir == ImGuiDir_Left) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Max.y); // Below, Toward Left if (dir == ImGuiDir_Up) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Min.y - size.y); // Above, Toward Left if (!r_outer.Contains(ImRect(pos, pos + size))) continue; *last_dir = dir; return pos; } } // Default popup policy const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Right, ImGuiDir_Down, ImGuiDir_Up, ImGuiDir_Left }; for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++) { const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n]; if (n != -1 && dir == *last_dir) // Already tried this direction? continue; float avail_w = (dir == ImGuiDir_Left ? r_avoid.Min.x : r_outer.Max.x) - (dir == ImGuiDir_Right ? r_avoid.Max.x : r_outer.Min.x); float avail_h = (dir == ImGuiDir_Up ? r_avoid.Min.y : r_outer.Max.y) - (dir == ImGuiDir_Down ? r_avoid.Max.y : r_outer.Min.y); if (avail_w < size.x || avail_h < size.y) continue; ImVec2 pos; pos.x = (dir == ImGuiDir_Left) ? r_avoid.Min.x - size.x : (dir == ImGuiDir_Right) ? r_avoid.Max.x : base_pos_clamped.x; pos.y = (dir == ImGuiDir_Up) ? r_avoid.Min.y - size.y : (dir == ImGuiDir_Down) ? r_avoid.Max.y : base_pos_clamped.y; *last_dir = dir; return pos; } // Fallback, try to keep within display *last_dir = ImGuiDir_None; ImVec2 pos = ref_pos; pos.x = ImMax(ImMin(pos.x + size.x, r_outer.Max.x) - size.x, r_outer.Min.x); pos.y = ImMax(ImMin(pos.y + size.y, r_outer.Max.y) - size.y, r_outer.Min.y); return pos; } ImRect ImGui::GetWindowAllowedExtentRect(ImGuiWindow* window) { IM_UNUSED(window); ImVec2 padding = GImGui->Style.DisplaySafeAreaPadding; ImRect r_screen = GetViewportRect(); r_screen.Expand(ImVec2((r_screen.GetWidth() > padding.x * 2) ? -padding.x : 0.0f, (r_screen.GetHeight() > padding.y * 2) ? -padding.y : 0.0f)); return r_screen; } ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window) { ImGuiContext& g = *GImGui; ImRect r_outer = GetWindowAllowedExtentRect(window); if (window->Flags & ImGuiWindowFlags_ChildMenu) { // Child menus typically request _any_ position within the parent menu item, and then we move the new menu outside the parent bounds. // This is how we end up with child menus appearing (most-commonly) on the right of the parent menu. IM_ASSERT(g.CurrentWindow == window); ImGuiWindow* parent_window = g.CurrentWindowStack[g.CurrentWindowStack.Size - 2]; float horizontal_overlap = g.Style.ItemInnerSpacing.x; // We want some overlap to convey the relative depth of each menu (currently the amount of overlap is hard-coded to style.ItemSpacing.x). ImRect r_avoid; if (parent_window->DC.MenuBarAppending) r_avoid = ImRect(-FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight(), FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight() + parent_window->MenuBarHeight()); else r_avoid = ImRect(parent_window->Pos.x + horizontal_overlap, -FLT_MAX, parent_window->Pos.x + parent_window->Size.x - horizontal_overlap - parent_window->ScrollbarSizes.x, FLT_MAX); return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid); } if (window->Flags & ImGuiWindowFlags_Popup) { ImRect r_avoid = ImRect(window->Pos.x - 1, window->Pos.y - 1, window->Pos.x + 1, window->Pos.y + 1); return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid); } if (window->Flags & ImGuiWindowFlags_Tooltip) { // Position tooltip (always follows mouse) float sc = g.Style.MouseCursorScale; ImVec2 ref_pos = NavCalcPreferredRefPos(); ImRect r_avoid; if (!g.NavDisableHighlight && g.NavDisableMouseHover && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos)) r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 16, ref_pos.y + 8); else r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24 * sc, ref_pos.y + 24 * sc); // FIXME: Hard-coded based on mouse cursor shape expectation. Exact dimension not very important. ImVec2 pos = FindBestWindowPosForPopupEx(ref_pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid); if (window->AutoPosLastDirection == ImGuiDir_None) pos = ref_pos + ImVec2(2, 2); // If there's not enough room, for tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible. return pos; } IM_ASSERT(0); return window->Pos; } //----------------------------------------------------------------------------- // [SECTION] KEYBOARD/GAMEPAD NAVIGATION //----------------------------------------------------------------------------- // FIXME-NAV: The existence of SetNavID vs SetNavIDWithRectRel vs SetFocusID is incredibly messy and confusing, // and needs some explanation or serious refactoring. void ImGui::SetNavID(ImGuiID id, int nav_layer, ImGuiID focus_scope_id) { ImGuiContext& g = *GImGui; IM_ASSERT(g.NavWindow); IM_ASSERT(nav_layer == 0 || nav_layer == 1); g.NavId = id; g.NavFocusScopeId = focus_scope_id; g.NavWindow->NavLastIds[nav_layer] = id; } void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel) { ImGuiContext& g = *GImGui; SetNavID(id, nav_layer, focus_scope_id); g.NavWindow->NavRectRel[nav_layer] = rect_rel; g.NavMousePosDirty = true; g.NavDisableHighlight = false; g.NavDisableMouseHover = true; } void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window) { ImGuiContext& g = *GImGui; IM_ASSERT(id != 0); // Assume that SetFocusID() is called in the context where its window->DC.NavLayerCurrent and window->DC.NavFocusScopeIdCurrent are valid. // Note that window may be != g.CurrentWindow (e.g. SetFocusID call in InputTextEx for multi-line text) const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent; if (g.NavWindow != window) g.NavInitRequest = false; g.NavWindow = window; g.NavId = id; g.NavLayer = nav_layer; g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent; window->NavLastIds[nav_layer] = id; if (window->DC.LastItemId == id) window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos); if (g.ActiveIdSource == ImGuiInputSource_Nav) g.NavDisableMouseHover = true; else g.NavDisableHighlight = true; } ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy) { if (ImFabs(dx) > ImFabs(dy)) return (dx > 0.0f) ? ImGuiDir_Right : ImGuiDir_Left; return (dy > 0.0f) ? ImGuiDir_Down : ImGuiDir_Up; } static float inline NavScoreItemDistInterval(float a0, float a1, float b0, float b1) { if (a1 < b0) return a1 - b0; if (b1 < a0) return a0 - b1; return 0.0f; } static void inline NavClampRectToVisibleAreaForMoveDir(ImGuiDir move_dir, ImRect& r, const ImRect& clip_rect) { if (move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right) { r.Min.y = ImClamp(r.Min.y, clip_rect.Min.y, clip_rect.Max.y); r.Max.y = ImClamp(r.Max.y, clip_rect.Min.y, clip_rect.Max.y); } else { r.Min.x = ImClamp(r.Min.x, clip_rect.Min.x, clip_rect.Max.x); r.Max.x = ImClamp(r.Max.x, clip_rect.Min.x, clip_rect.Max.x); } } // Scoring function for directional navigation. Based on https://gist.github.com/rygorous/6981057 static bool ImGui::NavScoreItem(ImGuiNavMoveResult* result, ImRect cand) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (g.NavLayer != window->DC.NavLayerCurrent) return false; const ImRect& curr = g.NavScoringRectScreen; // Current modified source rect (NB: we've applied Max.x = Min.x in NavUpdate() to inhibit the effect of having varied item width) g.NavScoringCount++; // When entering through a NavFlattened border, we consider child window items as fully clipped for scoring if (window->ParentWindow == g.NavWindow) { IM_ASSERT((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened); if (!window->ClipRect.Overlaps(cand)) return false; cand.ClipWithFull(window->ClipRect); // This allows the scored item to not overlap other candidates in the parent window } // We perform scoring on items bounding box clipped by the current clipping rectangle on the other axis (clipping on our movement axis would give us equal scores for all clipped items) // For example, this ensure that items in one column are not reached when moving vertically from items in another column. NavClampRectToVisibleAreaForMoveDir(g.NavMoveClipDir, cand, window->ClipRect); // Compute distance between boxes // FIXME-NAV: Introducing biases for vertical navigation, needs to be removed. float dbx = NavScoreItemDistInterval(cand.Min.x, cand.Max.x, curr.Min.x, curr.Max.x); float dby = NavScoreItemDistInterval(ImLerp(cand.Min.y, cand.Max.y, 0.2f), ImLerp(cand.Min.y, cand.Max.y, 0.8f), ImLerp(curr.Min.y, curr.Max.y, 0.2f), ImLerp(curr.Min.y, curr.Max.y, 0.8f)); // Scale down on Y to keep using box-distance for vertically touching items if (dby != 0.0f && dbx != 0.0f) dbx = (dbx/1000.0f) + ((dbx > 0.0f) ? +1.0f : -1.0f); float dist_box = ImFabs(dbx) + ImFabs(dby); // Compute distance between centers (this is off by a factor of 2, but we only compare center distances with each other so it doesn't matter) float dcx = (cand.Min.x + cand.Max.x) - (curr.Min.x + curr.Max.x); float dcy = (cand.Min.y + cand.Max.y) - (curr.Min.y + curr.Max.y); float dist_center = ImFabs(dcx) + ImFabs(dcy); // L1 metric (need this for our connectedness guarantee) // Determine which quadrant of 'curr' our candidate item 'cand' lies in based on distance ImGuiDir quadrant; float dax = 0.0f, day = 0.0f, dist_axial = 0.0f; if (dbx != 0.0f || dby != 0.0f) { // For non-overlapping boxes, use distance between boxes dax = dbx; day = dby; dist_axial = dist_box; quadrant = ImGetDirQuadrantFromDelta(dbx, dby); } else if (dcx != 0.0f || dcy != 0.0f) { // For overlapping boxes with different centers, use distance between centers dax = dcx; day = dcy; dist_axial = dist_center; quadrant = ImGetDirQuadrantFromDelta(dcx, dcy); } else { // Degenerate case: two overlapping buttons with same center, break ties arbitrarily (note that LastItemId here is really the _previous_ item order, but it doesn't matter) quadrant = (window->DC.LastItemId < g.NavId) ? ImGuiDir_Left : ImGuiDir_Right; } #if IMGUI_DEBUG_NAV_SCORING char buf[128]; if (IsMouseHoveringRect(cand.Min, cand.Max)) { ImFormatString(buf, IM_ARRAYSIZE(buf), "dbox (%.2f,%.2f->%.4f)\ndcen (%.2f,%.2f->%.4f)\nd (%.2f,%.2f->%.4f)\nnav %c, quadrant %c", dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "WENS"[g.NavMoveDir], "WENS"[quadrant]); ImDrawList* draw_list = GetForegroundDrawList(window); draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255,200,0,100)); draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255,255,0,200)); draw_list->AddRectFilled(cand.Max - ImVec2(4,4), cand.Max + CalcTextSize(buf) + ImVec2(4,4), IM_COL32(40,0,0,150)); draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Max, ~0U, buf); } else if (g.IO.KeyCtrl) // Hold to preview score in matching quadrant. Press C to rotate. { if (IsKeyPressedMap(ImGuiKey_C)) { g.NavMoveDirLast = (ImGuiDir)((g.NavMoveDirLast + 1) & 3); g.IO.KeysDownDuration[g.IO.KeyMap[ImGuiKey_C]] = 0.01f; } if (quadrant == g.NavMoveDir) { ImFormatString(buf, IM_ARRAYSIZE(buf), "%.0f/%.0f", dist_box, dist_center); ImDrawList* draw_list = GetForegroundDrawList(window); draw_list->AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 200)); draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Min, IM_COL32(255, 255, 255, 255), buf); } } #endif // Is it in the quadrant we're interesting in moving to? bool new_best = false; if (quadrant == g.NavMoveDir) { // Does it beat the current best candidate? if (dist_box < result->DistBox) { result->DistBox = dist_box; result->DistCenter = dist_center; return true; } if (dist_box == result->DistBox) { // Try using distance between center points to break ties if (dist_center < result->DistCenter) { result->DistCenter = dist_center; new_best = true; } else if (dist_center == result->DistCenter) { // Still tied! we need to be extra-careful to make sure everything gets linked properly. We consistently break ties by symbolically moving "later" items // (with higher index) to the right/downwards by an infinitesimal amount since we the current "best" button already (so it must have a lower index), // this is fairly easy. This rule ensures that all buttons with dx==dy==0 will end up being linked in order of appearance along the x axis. if (((g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? dby : dbx) < 0.0f) // moving bj to the right/down decreases distance new_best = true; } } } // Axial check: if 'curr' has no link at all in some direction and 'cand' lies roughly in that direction, add a tentative link. This will only be kept if no "real" matches // are found, so it only augments the graph produced by the above method using extra links. (important, since it doesn't guarantee strong connectedness) // This is just to avoid buttons having no links in a particular direction when there's a suitable neighbor. you get good graphs without this too. // 2017/09/29: FIXME: This now currently only enabled inside menu bars, ideally we'd disable it everywhere. Menus in particular need to catch failure. For general navigation it feels awkward. // Disabling it may lead to disconnected graphs when nodes are very spaced out on different axis. Perhaps consider offering this as an option? if (result->DistBox == FLT_MAX && dist_axial < result->DistAxial) // Check axial match if (g.NavLayer == 1 && !(g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu)) if ((g.NavMoveDir == ImGuiDir_Left && dax < 0.0f) || (g.NavMoveDir == ImGuiDir_Right && dax > 0.0f) || (g.NavMoveDir == ImGuiDir_Up && day < 0.0f) || (g.NavMoveDir == ImGuiDir_Down && day > 0.0f)) { result->DistAxial = dist_axial; new_best = true; } return new_best; } // We get there when either NavId == id, or when g.NavAnyRequest is set (which is updated by NavUpdateAnyRequestFlag above) static void ImGui::NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id) { ImGuiContext& g = *GImGui; //if (!g.IO.NavActive) // [2017/10/06] Removed this possibly redundant test but I am not sure of all the side-effects yet. Some of the feature here will need to work regardless of using a _NoNavInputs flag. // return; const ImGuiItemFlags item_flags = window->DC.ItemFlags; const ImRect nav_bb_rel(nav_bb.Min - window->Pos, nav_bb.Max - window->Pos); // Process Init Request if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent) { // Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus) || g.NavInitResultId == 0) { g.NavInitResultId = id; g.NavInitResultRectRel = nav_bb_rel; } if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus)) { g.NavInitRequest = false; // Found a match, clear request NavUpdateAnyRequestFlag(); } } // Process Move Request (scoring for navigation) // FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRectScreen + scoring from a rect wrapped according to current wrapping policy) if ((g.NavId != id || (g.NavMoveRequestFlags & ImGuiNavMoveFlags_AllowCurrentNavId)) && !(item_flags & (ImGuiItemFlags_Disabled|ImGuiItemFlags_NoNav))) { ImGuiNavMoveResult* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther; #if IMGUI_DEBUG_NAV_SCORING // [DEBUG] Score all items in NavWindow at all times if (!g.NavMoveRequest) g.NavMoveDir = g.NavMoveDirLast; bool new_best = NavScoreItem(result, nav_bb) && g.NavMoveRequest; #else bool new_best = g.NavMoveRequest && NavScoreItem(result, nav_bb); #endif if (new_best) { result->Window = window; result->ID = id; result->FocusScopeId = window->DC.NavFocusScopeIdCurrent; result->RectRel = nav_bb_rel; } // Features like PageUp/PageDown need to maintain a separate score for the visible set of items. const float VISIBLE_RATIO = 0.70f; if ((g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb)) if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO) if (NavScoreItem(&g.NavMoveResultLocalVisibleSet, nav_bb)) { result = &g.NavMoveResultLocalVisibleSet; result->Window = window; result->ID = id; result->FocusScopeId = window->DC.NavFocusScopeIdCurrent; result->RectRel = nav_bb_rel; } } // Update window-relative bounding box of navigated item if (g.NavId == id) { g.NavWindow = window; // Always refresh g.NavWindow, because some operations such as FocusItem() don't have a window. g.NavLayer = window->DC.NavLayerCurrent; g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent; g.NavIdIsAlive = true; g.NavIdTabCounter = window->DC.FocusCounterTabStop; window->NavRectRel[window->DC.NavLayerCurrent] = nav_bb_rel; // Store item bounding box (relative to window position) } } bool ImGui::NavMoveRequestButNoResultYet() { ImGuiContext& g = *GImGui; return g.NavMoveRequest && g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0; } void ImGui::NavMoveRequestCancel() { ImGuiContext& g = *GImGui; g.NavMoveRequest = false; NavUpdateAnyRequestFlag(); } void ImGui::NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const ImRect& bb_rel, ImGuiNavMoveFlags move_flags) { ImGuiContext& g = *GImGui; IM_ASSERT(g.NavMoveRequestForward == ImGuiNavForward_None); NavMoveRequestCancel(); g.NavMoveDir = move_dir; g.NavMoveClipDir = clip_dir; g.NavMoveRequestForward = ImGuiNavForward_ForwardQueued; g.NavMoveRequestFlags = move_flags; g.NavWindow->NavRectRel[g.NavLayer] = bb_rel; } void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags) { ImGuiContext& g = *GImGui; if (g.NavWindow != window || !NavMoveRequestButNoResultYet() || g.NavMoveRequestForward != ImGuiNavForward_None || g.NavLayer != 0) return; IM_ASSERT(move_flags != 0); // No points calling this with no wrapping ImRect bb_rel = window->NavRectRel[0]; ImGuiDir clip_dir = g.NavMoveDir; if (g.NavMoveDir == ImGuiDir_Left && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX))) { bb_rel.Min.x = bb_rel.Max.x = ImMax(window->SizeFull.x, window->ContentSize.x + window->WindowPadding.x * 2.0f) - window->Scroll.x; if (move_flags & ImGuiNavMoveFlags_WrapX) { bb_rel.TranslateY(-bb_rel.GetHeight()); clip_dir = ImGuiDir_Up; } NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags); } if (g.NavMoveDir == ImGuiDir_Right && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX))) { bb_rel.Min.x = bb_rel.Max.x = -window->Scroll.x; if (move_flags & ImGuiNavMoveFlags_WrapX) { bb_rel.TranslateY(+bb_rel.GetHeight()); clip_dir = ImGuiDir_Down; } NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags); } if (g.NavMoveDir == ImGuiDir_Up && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY))) { bb_rel.Min.y = bb_rel.Max.y = ImMax(window->SizeFull.y, window->ContentSize.y + window->WindowPadding.y * 2.0f) - window->Scroll.y; if (move_flags & ImGuiNavMoveFlags_WrapY) { bb_rel.TranslateX(-bb_rel.GetWidth()); clip_dir = ImGuiDir_Left; } NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags); } if (g.NavMoveDir == ImGuiDir_Down && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY))) { bb_rel.Min.y = bb_rel.Max.y = -window->Scroll.y; if (move_flags & ImGuiNavMoveFlags_WrapY) { bb_rel.TranslateX(+bb_rel.GetWidth()); clip_dir = ImGuiDir_Right; } NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags); } } // FIXME: This could be replaced by updating a frame number in each window when (window == NavWindow) and (NavLayer == 0). // This way we could find the last focused window among our children. It would be much less confusing this way? static void ImGui::NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window) { ImGuiWindow* parent_window = nav_window; while (parent_window && (parent_window->Flags & ImGuiWindowFlags_ChildWindow) != 0 && (parent_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0) parent_window = parent_window->ParentWindow; if (parent_window && parent_window != nav_window) parent_window->NavLastChildNavWindow = nav_window; } // Restore the last focused child. // Call when we are expected to land on the Main Layer (0) after FocusWindow() static ImGuiWindow* ImGui::NavRestoreLastChildNavWindow(ImGuiWindow* window) { return window->NavLastChildNavWindow ? window->NavLastChildNavWindow : window; } static void NavRestoreLayer(ImGuiNavLayer layer) { ImGuiContext& g = *GImGui; g.NavLayer = layer; if (layer == 0) g.NavWindow = ImGui::NavRestoreLastChildNavWindow(g.NavWindow); ImGuiWindow* window = g.NavWindow; if (layer == 0 && window->NavLastIds[0] != 0) ImGui::SetNavIDWithRectRel(window->NavLastIds[0], layer, 0, window->NavRectRel[0]); else ImGui::NavInitWindow(window, true); } static inline void ImGui::NavUpdateAnyRequestFlag() { ImGuiContext& g = *GImGui; g.NavAnyRequest = g.NavMoveRequest || g.NavInitRequest || (IMGUI_DEBUG_NAV_SCORING && g.NavWindow != NULL); if (g.NavAnyRequest) IM_ASSERT(g.NavWindow != NULL); } // This needs to be called before we submit any widget (aka in or before Begin) void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit) { ImGuiContext& g = *GImGui; IM_ASSERT(window == g.NavWindow); bool init_for_nav = false; if (!(window->Flags & ImGuiWindowFlags_NoNavInputs)) if (!(window->Flags & ImGuiWindowFlags_ChildWindow) || (window->Flags & ImGuiWindowFlags_Popup) || (window->NavLastIds[0] == 0) || force_reinit) init_for_nav = true; //IMGUI_DEBUG_LOG("[Nav] NavInitWindow() init_for_nav=%d, window=\"%s\", layer=%d\n", init_for_nav, window->Name, g.NavLayer); if (init_for_nav) { SetNavID(0, g.NavLayer, 0); g.NavInitRequest = true; g.NavInitRequestFromMove = false; g.NavInitResultId = 0; g.NavInitResultRectRel = ImRect(); NavUpdateAnyRequestFlag(); } else { g.NavId = window->NavLastIds[0]; g.NavFocusScopeId = 0; } } static ImVec2 ImGui::NavCalcPreferredRefPos() { ImGuiContext& g = *GImGui; if (g.NavDisableHighlight || !g.NavDisableMouseHover || !g.NavWindow) { // Mouse (we need a fallback in case the mouse becomes invalid after being used) if (IsMousePosValid(&g.IO.MousePos)) return g.IO.MousePos; return g.LastValidMousePos; } else { // When navigation is active and mouse is disabled, decide on an arbitrary position around the bottom left of the currently navigated item. const ImRect& rect_rel = g.NavWindow->NavRectRel[g.NavLayer]; ImVec2 pos = g.NavWindow->Pos + ImVec2(rect_rel.Min.x + ImMin(g.Style.FramePadding.x * 4, rect_rel.GetWidth()), rect_rel.Max.y - ImMin(g.Style.FramePadding.y, rect_rel.GetHeight())); ImRect visible_rect = GetViewportRect(); return ImFloor(ImClamp(pos, visible_rect.Min, visible_rect.Max)); // ImFloor() is important because non-integer mouse position application in back-end might be lossy and result in undesirable non-zero delta. } } float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode) { ImGuiContext& g = *GImGui; if (mode == ImGuiInputReadMode_Down) return g.IO.NavInputs[n]; // Instant, read analog input (0.0f..1.0f, as provided by user) const float t = g.IO.NavInputsDownDuration[n]; if (t < 0.0f && mode == ImGuiInputReadMode_Released) // Return 1.0f when just released, no repeat, ignore analog input. return (g.IO.NavInputsDownDurationPrev[n] >= 0.0f ? 1.0f : 0.0f); if (t < 0.0f) return 0.0f; if (mode == ImGuiInputReadMode_Pressed) // Return 1.0f when just pressed, no repeat, ignore analog input. return (t == 0.0f) ? 1.0f : 0.0f; if (mode == ImGuiInputReadMode_Repeat) return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 0.72f, g.IO.KeyRepeatRate * 0.80f); if (mode == ImGuiInputReadMode_RepeatSlow) return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 1.25f, g.IO.KeyRepeatRate * 2.00f); if (mode == ImGuiInputReadMode_RepeatFast) return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 0.72f, g.IO.KeyRepeatRate * 0.30f); return 0.0f; } ImVec2 ImGui::GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor, float fast_factor) { ImVec2 delta(0.0f, 0.0f); if (dir_sources & ImGuiNavDirSourceFlags_Keyboard) delta += ImVec2(GetNavInputAmount(ImGuiNavInput_KeyRight_, mode) - GetNavInputAmount(ImGuiNavInput_KeyLeft_, mode), GetNavInputAmount(ImGuiNavInput_KeyDown_, mode) - GetNavInputAmount(ImGuiNavInput_KeyUp_, mode)); if (dir_sources & ImGuiNavDirSourceFlags_PadDPad) delta += ImVec2(GetNavInputAmount(ImGuiNavInput_DpadRight, mode) - GetNavInputAmount(ImGuiNavInput_DpadLeft, mode), GetNavInputAmount(ImGuiNavInput_DpadDown, mode) - GetNavInputAmount(ImGuiNavInput_DpadUp, mode)); if (dir_sources & ImGuiNavDirSourceFlags_PadLStick) delta += ImVec2(GetNavInputAmount(ImGuiNavInput_LStickRight, mode) - GetNavInputAmount(ImGuiNavInput_LStickLeft, mode), GetNavInputAmount(ImGuiNavInput_LStickDown, mode) - GetNavInputAmount(ImGuiNavInput_LStickUp, mode)); if (slow_factor != 0.0f && IsNavInputDown(ImGuiNavInput_TweakSlow)) delta *= slow_factor; if (fast_factor != 0.0f && IsNavInputDown(ImGuiNavInput_TweakFast)) delta *= fast_factor; return delta; } static void ImGui::NavUpdate() { ImGuiContext& g = *GImGui; g.IO.WantSetMousePos = false; #if 0 if (g.NavScoringCount > 0) IMGUI_DEBUG_LOG("NavScoringCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.FrameCount, g.NavScoringCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest); #endif // Set input source as Gamepad when buttons are pressed (as some features differs when used with Gamepad vs Keyboard) // (do it before we map Keyboard input!) bool nav_keyboard_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0; bool nav_gamepad_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (g.IO.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0; if (nav_gamepad_active) if (g.IO.NavInputs[ImGuiNavInput_Activate] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Input] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Cancel] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Menu] > 0.0f) g.NavInputSource = ImGuiInputSource_NavGamepad; // Update Keyboard->Nav inputs mapping if (nav_keyboard_active) { #define NAV_MAP_KEY(_KEY, _NAV_INPUT) do { if (IsKeyDown(g.IO.KeyMap[_KEY])) { g.IO.NavInputs[_NAV_INPUT] = 1.0f; g.NavInputSource = ImGuiInputSource_NavKeyboard; } } while (0) NAV_MAP_KEY(ImGuiKey_Space, ImGuiNavInput_Activate ); NAV_MAP_KEY(ImGuiKey_Enter, ImGuiNavInput_Input ); NAV_MAP_KEY(ImGuiKey_Escape, ImGuiNavInput_Cancel ); NAV_MAP_KEY(ImGuiKey_LeftArrow, ImGuiNavInput_KeyLeft_ ); NAV_MAP_KEY(ImGuiKey_RightArrow,ImGuiNavInput_KeyRight_); NAV_MAP_KEY(ImGuiKey_UpArrow, ImGuiNavInput_KeyUp_ ); NAV_MAP_KEY(ImGuiKey_DownArrow, ImGuiNavInput_KeyDown_ ); if (g.IO.KeyCtrl) g.IO.NavInputs[ImGuiNavInput_TweakSlow] = 1.0f; if (g.IO.KeyShift) g.IO.NavInputs[ImGuiNavInput_TweakFast] = 1.0f; if (g.IO.KeyAlt && !g.IO.KeyCtrl) // AltGR is Alt+Ctrl, also even on keyboards without AltGR we don't want Alt+Ctrl to open menu. g.IO.NavInputs[ImGuiNavInput_KeyMenu_] = 1.0f; #undef NAV_MAP_KEY } memcpy(g.IO.NavInputsDownDurationPrev, g.IO.NavInputsDownDuration, sizeof(g.IO.NavInputsDownDuration)); for (int i = 0; i < IM_ARRAYSIZE(g.IO.NavInputs); i++) g.IO.NavInputsDownDuration[i] = (g.IO.NavInputs[i] > 0.0f) ? (g.IO.NavInputsDownDuration[i] < 0.0f ? 0.0f : g.IO.NavInputsDownDuration[i] + g.IO.DeltaTime) : -1.0f; // Process navigation init request (select first/default focus) // In very rare cases g.NavWindow may be null (e.g. clearing focus after requesting an init request, which does happen when releasing Alt while clicking on void) if (g.NavInitResultId != 0 && (!g.NavDisableHighlight || g.NavInitRequestFromMove) && g.NavWindow) { // Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called) //IMGUI_DEBUG_LOG("[Nav] Apply NavInitRequest result: 0x%08X Layer %d in \"%s\"\n", g.NavInitResultId, g.NavLayer, g.NavWindow->Name); if (g.NavInitRequestFromMove) SetNavIDWithRectRel(g.NavInitResultId, g.NavLayer, 0, g.NavInitResultRectRel); else SetNavID(g.NavInitResultId, g.NavLayer, 0); g.NavWindow->NavRectRel[g.NavLayer] = g.NavInitResultRectRel; } g.NavInitRequest = false; g.NavInitRequestFromMove = false; g.NavInitResultId = 0; g.NavJustMovedToId = 0; // Process navigation move request if (g.NavMoveRequest) NavUpdateMoveResult(); // When a forwarded move request failed, we restore the highlight that we disabled during the forward frame if (g.NavMoveRequestForward == ImGuiNavForward_ForwardActive) { IM_ASSERT(g.NavMoveRequest); if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0) g.NavDisableHighlight = false; g.NavMoveRequestForward = ImGuiNavForward_None; } // Apply application mouse position movement, after we had a chance to process move request result. if (g.NavMousePosDirty && g.NavIdIsAlive) { // Set mouse position given our knowledge of the navigated item position from last frame if ((g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) && (g.IO.BackendFlags & ImGuiBackendFlags_HasSetMousePos)) { if (!g.NavDisableHighlight && g.NavDisableMouseHover && g.NavWindow) { g.IO.MousePos = g.IO.MousePosPrev = NavCalcPreferredRefPos(); g.IO.WantSetMousePos = true; } } g.NavMousePosDirty = false; } g.NavIdIsAlive = false; g.NavJustTabbedId = 0; IM_ASSERT(g.NavLayer == 0 || g.NavLayer == 1); // Store our return window (for returning from Layer 1 to Layer 0) and clear it as soon as we step back in our own Layer 0 if (g.NavWindow) NavSaveLastChildNavWindowIntoParent(g.NavWindow); if (g.NavWindow && g.NavWindow->NavLastChildNavWindow != NULL && g.NavLayer == 0) g.NavWindow->NavLastChildNavWindow = NULL; // Update CTRL+TAB and Windowing features (hold Square to move/resize/etc.) NavUpdateWindowing(); // Set output flags for user application g.IO.NavActive = (nav_keyboard_active || nav_gamepad_active) && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs); g.IO.NavVisible = (g.IO.NavActive && g.NavId != 0 && !g.NavDisableHighlight) || (g.NavWindowingTarget != NULL); // Process NavCancel input (to close a popup, get back to parent, clear focus) if (IsNavInputTest(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed)) { if (g.ActiveId != 0) { if (!IsActiveIdUsingNavInput(ImGuiNavInput_Cancel)) ClearActiveID(); } else if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow) && !(g.NavWindow->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->ParentWindow) { // Exit child window ImGuiWindow* child_window = g.NavWindow; ImGuiWindow* parent_window = g.NavWindow->ParentWindow; IM_ASSERT(child_window->ChildId != 0); FocusWindow(parent_window); SetNavID(child_window->ChildId, 0, 0); // Reassigning with same value, we're being explicit here. g.NavIdIsAlive = false; // -V1048 if (g.NavDisableMouseHover) g.NavMousePosDirty = true; } else if (g.OpenPopupStack.Size > 0) { // Close open popup/menu if (!(g.OpenPopupStack.back().Window->Flags & ImGuiWindowFlags_Modal)) ClosePopupToLevel(g.OpenPopupStack.Size - 1, true); } else if (g.NavLayer != 0) { // Leave the "menu" layer NavRestoreLayer(ImGuiNavLayer_Main); } else { // Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup) || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow))) g.NavWindow->NavLastIds[0] = 0; g.NavId = g.NavFocusScopeId = 0; } } // Process manual activation request g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavInputId = 0; if (g.NavId != 0 && !g.NavDisableHighlight && !g.NavWindowingTarget && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs)) { bool activate_down = IsNavInputDown(ImGuiNavInput_Activate); bool activate_pressed = activate_down && IsNavInputTest(ImGuiNavInput_Activate, ImGuiInputReadMode_Pressed); if (g.ActiveId == 0 && activate_pressed) g.NavActivateId = g.NavId; if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && activate_down) g.NavActivateDownId = g.NavId; if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && activate_pressed) g.NavActivatePressedId = g.NavId; if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && IsNavInputTest(ImGuiNavInput_Input, ImGuiInputReadMode_Pressed)) g.NavInputId = g.NavId; } if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs)) g.NavDisableHighlight = true; if (g.NavActivateId != 0) IM_ASSERT(g.NavActivateDownId == g.NavActivateId); g.NavMoveRequest = false; // Process programmatic activation request if (g.NavNextActivateId != 0) g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavInputId = g.NavNextActivateId; g.NavNextActivateId = 0; // Initiate directional inputs request if (g.NavMoveRequestForward == ImGuiNavForward_None) { g.NavMoveDir = ImGuiDir_None; g.NavMoveRequestFlags = ImGuiNavMoveFlags_None; if (g.NavWindow && !g.NavWindowingTarget && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs)) { const ImGuiInputReadMode read_mode = ImGuiInputReadMode_Repeat; if (!IsActiveIdUsingNavDir(ImGuiDir_Left) && (IsNavInputTest(ImGuiNavInput_DpadLeft, read_mode) || IsNavInputTest(ImGuiNavInput_KeyLeft_, read_mode))) { g.NavMoveDir = ImGuiDir_Left; } if (!IsActiveIdUsingNavDir(ImGuiDir_Right) && (IsNavInputTest(ImGuiNavInput_DpadRight, read_mode) || IsNavInputTest(ImGuiNavInput_KeyRight_, read_mode))) { g.NavMoveDir = ImGuiDir_Right; } if (!IsActiveIdUsingNavDir(ImGuiDir_Up) && (IsNavInputTest(ImGuiNavInput_DpadUp, read_mode) || IsNavInputTest(ImGuiNavInput_KeyUp_, read_mode))) { g.NavMoveDir = ImGuiDir_Up; } if (!IsActiveIdUsingNavDir(ImGuiDir_Down) && (IsNavInputTest(ImGuiNavInput_DpadDown, read_mode) || IsNavInputTest(ImGuiNavInput_KeyDown_, read_mode))) { g.NavMoveDir = ImGuiDir_Down; } } g.NavMoveClipDir = g.NavMoveDir; } else { // Forwarding previous request (which has been modified, e.g. wrap around menus rewrite the requests with a starting rectangle at the other side of the window) // (Preserve g.NavMoveRequestFlags, g.NavMoveClipDir which were set by the NavMoveRequestForward() function) IM_ASSERT(g.NavMoveDir != ImGuiDir_None && g.NavMoveClipDir != ImGuiDir_None); IM_ASSERT(g.NavMoveRequestForward == ImGuiNavForward_ForwardQueued); g.NavMoveRequestForward = ImGuiNavForward_ForwardActive; } // Update PageUp/PageDown/Home/End scroll // FIXME-NAV: Consider enabling those keys even without the master ImGuiConfigFlags_NavEnableKeyboard flag? float nav_scoring_rect_offset_y = 0.0f; if (nav_keyboard_active) nav_scoring_rect_offset_y = NavUpdatePageUpPageDown(); // If we initiate a movement request and have no current NavId, we initiate a InitDefautRequest that will be used as a fallback if the direction fails to find a match if (g.NavMoveDir != ImGuiDir_None) { g.NavMoveRequest = true; g.NavMoveDirLast = g.NavMoveDir; } if (g.NavMoveRequest && g.NavId == 0) { //IMGUI_DEBUG_LOG("[Nav] NavInitRequest from move, window \"%s\", layer=%d\n", g.NavWindow->Name, g.NavLayer); g.NavInitRequest = g.NavInitRequestFromMove = true; // Reassigning with same value, we're being explicit here. g.NavInitResultId = 0; // -V1048 g.NavDisableHighlight = false; } NavUpdateAnyRequestFlag(); // Scrolling if (g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.NavWindowingTarget) { // *Fallback* manual-scroll with Nav directional keys when window has no navigable item ImGuiWindow* window = g.NavWindow; const float scroll_speed = IM_ROUND(window->CalcFontSize() * 100 * g.IO.DeltaTime); // We need round the scrolling speed because sub-pixel scroll isn't reliably supported. if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll && g.NavMoveRequest) { if (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right) SetScrollX(window, ImFloor(window->Scroll.x + ((g.NavMoveDir == ImGuiDir_Left) ? -1.0f : +1.0f) * scroll_speed)); if (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) SetScrollY(window, ImFloor(window->Scroll.y + ((g.NavMoveDir == ImGuiDir_Up) ? -1.0f : +1.0f) * scroll_speed)); } // *Normal* Manual scroll with NavScrollXXX keys // Next movement request will clamp the NavId reference rectangle to the visible area, so navigation will resume within those bounds. ImVec2 scroll_dir = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down, 1.0f/10.0f, 10.0f); if (scroll_dir.x != 0.0f && window->ScrollbarX) { SetScrollX(window, ImFloor(window->Scroll.x + scroll_dir.x * scroll_speed)); g.NavMoveFromClampedRefRect = true; } if (scroll_dir.y != 0.0f) { SetScrollY(window, ImFloor(window->Scroll.y + scroll_dir.y * scroll_speed)); g.NavMoveFromClampedRefRect = true; } } // Reset search results g.NavMoveResultLocal.Clear(); g.NavMoveResultLocalVisibleSet.Clear(); g.NavMoveResultOther.Clear(); // When we have manually scrolled (without using navigation) and NavId becomes out of bounds, we project its bounding box to the visible area to restart navigation within visible items if (g.NavMoveRequest && g.NavMoveFromClampedRefRect && g.NavLayer == 0) { ImGuiWindow* window = g.NavWindow; ImRect window_rect_rel(window->InnerRect.Min - window->Pos - ImVec2(1,1), window->InnerRect.Max - window->Pos + ImVec2(1,1)); if (!window_rect_rel.Contains(window->NavRectRel[g.NavLayer])) { float pad = window->CalcFontSize() * 0.5f; window_rect_rel.Expand(ImVec2(-ImMin(window_rect_rel.GetWidth(), pad), -ImMin(window_rect_rel.GetHeight(), pad))); // Terrible approximation for the intent of starting navigation from first fully visible item window->NavRectRel[g.NavLayer].ClipWith(window_rect_rel); g.NavId = g.NavFocusScopeId = 0; } g.NavMoveFromClampedRefRect = false; } // For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items) ImRect nav_rect_rel = (g.NavWindow && !g.NavWindow->NavRectRel[g.NavLayer].IsInverted()) ? g.NavWindow->NavRectRel[g.NavLayer] : ImRect(0,0,0,0); g.NavScoringRectScreen = g.NavWindow ? ImRect(g.NavWindow->Pos + nav_rect_rel.Min, g.NavWindow->Pos + nav_rect_rel.Max) : GetViewportRect(); g.NavScoringRectScreen.TranslateY(nav_scoring_rect_offset_y); g.NavScoringRectScreen.Min.x = ImMin(g.NavScoringRectScreen.Min.x + 1.0f, g.NavScoringRectScreen.Max.x); g.NavScoringRectScreen.Max.x = g.NavScoringRectScreen.Min.x; IM_ASSERT(!g.NavScoringRectScreen.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allows us to remove extraneous ImFabs() calls in NavScoreItem(). //GetForegroundDrawList()->AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG] g.NavScoringCount = 0; #if IMGUI_DEBUG_NAV_RECTS if (g.NavWindow) { ImDrawList* draw_list = GetForegroundDrawList(g.NavWindow); if (1) { for (int layer = 0; layer < 2; layer++) draw_list->AddRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Max, IM_COL32(255,200,0,255)); } // [DEBUG] if (1) { ImU32 col = (!g.NavWindow->Hidden) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredRefPos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); draw_list->AddCircleFilled(p, 3.0f, col); draw_list->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); } } #endif } // Apply result from previous frame navigation directional move request static void ImGui::NavUpdateMoveResult() { ImGuiContext& g = *GImGui; if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0) { // In a situation when there is no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result) if (g.NavId != 0) { g.NavDisableHighlight = false; g.NavDisableMouseHover = true; } return; } // Select which result to use ImGuiNavMoveResult* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : &g.NavMoveResultOther; // PageUp/PageDown behavior first jumps to the bottom/top mostly visible item, _otherwise_ use the result from the previous/next page. if (g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) if (g.NavMoveResultLocalVisibleSet.ID != 0 && g.NavMoveResultLocalVisibleSet.ID != g.NavId) result = &g.NavMoveResultLocalVisibleSet; // Maybe entering a flattened child from the outside? In this case solve the tie using the regular scoring rules. if (result != &g.NavMoveResultOther && g.NavMoveResultOther.ID != 0 && g.NavMoveResultOther.Window->ParentWindow == g.NavWindow) if ((g.NavMoveResultOther.DistBox < result->DistBox) || (g.NavMoveResultOther.DistBox == result->DistBox && g.NavMoveResultOther.DistCenter < result->DistCenter)) result = &g.NavMoveResultOther; IM_ASSERT(g.NavWindow && result->Window); // Scroll to keep newly navigated item fully into view. if (g.NavLayer == 0) { ImVec2 delta_scroll; if (g.NavMoveRequestFlags & ImGuiNavMoveFlags_ScrollToEdge) { float scroll_target = (g.NavMoveDir == ImGuiDir_Up) ? result->Window->ScrollMax.y : 0.0f; delta_scroll.y = result->Window->Scroll.y - scroll_target; SetScrollY(result->Window, scroll_target); } else { ImRect rect_abs = ImRect(result->RectRel.Min + result->Window->Pos, result->RectRel.Max + result->Window->Pos); delta_scroll = ScrollToBringRectIntoView(result->Window, rect_abs); } // Offset our result position so mouse position can be applied immediately after in NavUpdate() result->RectRel.TranslateX(-delta_scroll.x); result->RectRel.TranslateY(-delta_scroll.y); } ClearActiveID(); g.NavWindow = result->Window; if (g.NavId != result->ID) { // Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId) g.NavJustMovedToId = result->ID; g.NavJustMovedToFocusScopeId = result->FocusScopeId; } SetNavIDWithRectRel(result->ID, g.NavLayer, result->FocusScopeId, result->RectRel); g.NavMoveFromClampedRefRect = false; } // Handle PageUp/PageDown/Home/End keys static float ImGui::NavUpdatePageUpPageDown() { ImGuiContext& g = *GImGui; if (g.NavMoveDir != ImGuiDir_None || g.NavWindow == NULL) return 0.0f; if ((g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) || g.NavWindowingTarget != NULL || g.NavLayer != 0) return 0.0f; ImGuiWindow* window = g.NavWindow; const bool page_up_held = IsKeyDown(g.IO.KeyMap[ImGuiKey_PageUp]) && !IsActiveIdUsingKey(ImGuiKey_PageUp); const bool page_down_held = IsKeyDown(g.IO.KeyMap[ImGuiKey_PageDown]) && !IsActiveIdUsingKey(ImGuiKey_PageDown); const bool home_pressed = IsKeyPressed(g.IO.KeyMap[ImGuiKey_Home]) && !IsActiveIdUsingKey(ImGuiKey_Home); const bool end_pressed = IsKeyPressed(g.IO.KeyMap[ImGuiKey_End]) && !IsActiveIdUsingKey(ImGuiKey_End); if (page_up_held != page_down_held || home_pressed != end_pressed) // If either (not both) are pressed { if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll) { // Fallback manual-scroll when window has no navigable item if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageUp], true)) SetScrollY(window, window->Scroll.y - window->InnerRect.GetHeight()); else if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageDown], true)) SetScrollY(window, window->Scroll.y + window->InnerRect.GetHeight()); else if (home_pressed) SetScrollY(window, 0.0f); else if (end_pressed) SetScrollY(window, window->ScrollMax.y); } else { ImRect& nav_rect_rel = window->NavRectRel[g.NavLayer]; const float page_offset_y = ImMax(0.0f, window->InnerRect.GetHeight() - window->CalcFontSize() * 1.0f + nav_rect_rel.GetHeight()); float nav_scoring_rect_offset_y = 0.0f; if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageUp], true)) { nav_scoring_rect_offset_y = -page_offset_y; g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset up, we request the down direction (so we can always land on the last item) g.NavMoveClipDir = ImGuiDir_Up; g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet; } else if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageDown], true)) { nav_scoring_rect_offset_y = +page_offset_y; g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset down, we request the up direction (so we can always land on the last item) g.NavMoveClipDir = ImGuiDir_Down; g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet; } else if (home_pressed) { // FIXME-NAV: handling of Home/End is assuming that the top/bottom most item will be visible with Scroll.y == 0/ScrollMax.y // Scrolling will be handled via the ImGuiNavMoveFlags_ScrollToEdge flag, we don't scroll immediately to avoid scrolling happening before nav result. // Preserve current horizontal position if we have any. nav_rect_rel.Min.y = nav_rect_rel.Max.y = -window->Scroll.y; if (nav_rect_rel.IsInverted()) nav_rect_rel.Min.x = nav_rect_rel.Max.x = 0.0f; g.NavMoveDir = ImGuiDir_Down; g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_ScrollToEdge; } else if (end_pressed) { nav_rect_rel.Min.y = nav_rect_rel.Max.y = window->ScrollMax.y + window->SizeFull.y - window->Scroll.y; if (nav_rect_rel.IsInverted()) nav_rect_rel.Min.x = nav_rect_rel.Max.x = 0.0f; g.NavMoveDir = ImGuiDir_Up; g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_ScrollToEdge; } return nav_scoring_rect_offset_y; } } return 0.0f; } static int ImGui::FindWindowFocusIndex(ImGuiWindow* window) // FIXME-OPT O(N) { ImGuiContext& g = *GImGui; for (int i = g.WindowsFocusOrder.Size-1; i >= 0; i--) if (g.WindowsFocusOrder[i] == window) return i; return -1; } static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) // FIXME-OPT O(N) { ImGuiContext& g = *GImGui; for (int i = i_start; i >= 0 && i < g.WindowsFocusOrder.Size && i != i_stop; i += dir) if (ImGui::IsWindowNavFocusable(g.WindowsFocusOrder[i])) return g.WindowsFocusOrder[i]; return NULL; } static void NavUpdateWindowingHighlightWindow(int focus_change_dir) { ImGuiContext& g = *GImGui; IM_ASSERT(g.NavWindowingTarget); if (g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal) return; const int i_current = ImGui::FindWindowFocusIndex(g.NavWindowingTarget); ImGuiWindow* window_target = FindWindowNavFocusable(i_current + focus_change_dir, -INT_MAX, focus_change_dir); if (!window_target) window_target = FindWindowNavFocusable((focus_change_dir < 0) ? (g.WindowsFocusOrder.Size - 1) : 0, i_current, focus_change_dir); if (window_target) // Don't reset windowing target if there's a single window in the list g.NavWindowingTarget = g.NavWindowingTargetAnim = window_target; g.NavWindowingToggleLayer = false; } // Windowing management mode // Keyboard: CTRL+Tab (change focus/move/resize), Alt (toggle menu layer) // Gamepad: Hold Menu/Square (change focus/move/resize), Tap Menu/Square (toggle menu layer) static void ImGui::NavUpdateWindowing() { ImGuiContext& g = *GImGui; ImGuiWindow* apply_focus_window = NULL; bool apply_toggle_layer = false; ImGuiWindow* modal_window = GetTopMostPopupModal(); if (modal_window != NULL) { g.NavWindowingTarget = NULL; return; } // Fade out if (g.NavWindowingTargetAnim && g.NavWindowingTarget == NULL) { g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha - g.IO.DeltaTime * 10.0f, 0.0f); if (g.DimBgRatio <= 0.0f && g.NavWindowingHighlightAlpha <= 0.0f) g.NavWindowingTargetAnim = NULL; } // Start CTRL-TAB or Square+L/R window selection bool start_windowing_with_gamepad = !g.NavWindowingTarget && IsNavInputTest(ImGuiNavInput_Menu, ImGuiInputReadMode_Pressed); bool start_windowing_with_keyboard = !g.NavWindowingTarget && g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab) && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard); if (start_windowing_with_gamepad || start_windowing_with_keyboard) if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1)) { g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow; // FIXME-DOCK: Will need to use RootWindowDockStop g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f; g.NavWindowingToggleLayer = start_windowing_with_keyboard ? false : true; g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_NavKeyboard : ImGuiInputSource_NavGamepad; } // Gamepad update g.NavWindowingTimer += g.IO.DeltaTime; if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_NavGamepad) { // Highlight only appears after a brief time holding the button, so that a fast tap on PadMenu (to toggle NavLayer) doesn't add visual noise g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); // Select window to focus const int focus_change_dir = (int)IsNavInputTest(ImGuiNavInput_FocusPrev, ImGuiInputReadMode_RepeatSlow) - (int)IsNavInputTest(ImGuiNavInput_FocusNext, ImGuiInputReadMode_RepeatSlow); if (focus_change_dir != 0) { NavUpdateWindowingHighlightWindow(focus_change_dir); g.NavWindowingHighlightAlpha = 1.0f; } // Single press toggles NavLayer, long press with L/R apply actual focus on release (until then the window was merely rendered top-most) if (!IsNavInputDown(ImGuiNavInput_Menu)) { g.NavWindowingToggleLayer &= (g.NavWindowingHighlightAlpha < 1.0f); // Once button was held long enough we don't consider it a tap-to-toggle-layer press anymore. if (g.NavWindowingToggleLayer && g.NavWindow) apply_toggle_layer = true; else if (!g.NavWindowingToggleLayer) apply_focus_window = g.NavWindowingTarget; g.NavWindowingTarget = NULL; } } // Keyboard: Focus if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_NavKeyboard) { // Visuals only appears after a brief time after pressing TAB the first time, so that a fast CTRL+TAB doesn't add visual noise g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); // 1.0f if (IsKeyPressedMap(ImGuiKey_Tab, true)) NavUpdateWindowingHighlightWindow(g.IO.KeyShift ? +1 : -1); if (!g.IO.KeyCtrl) apply_focus_window = g.NavWindowingTarget; } // Keyboard: Press and Release ALT to toggle menu layer // FIXME: We lack an explicit IO variable for "is the imgui window focused", so compare mouse validity to detect the common case of back-end clearing releases all keys on ALT-TAB if (IsNavInputTest(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Pressed)) g.NavWindowingToggleLayer = true; if ((g.ActiveId == 0 || g.ActiveIdAllowOverlap) && g.NavWindowingToggleLayer && IsNavInputTest(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Released)) if (IsMousePosValid(&g.IO.MousePos) == IsMousePosValid(&g.IO.MousePosPrev)) apply_toggle_layer = true; // Move window if (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoMove)) { ImVec2 move_delta; if (g.NavInputSource == ImGuiInputSource_NavKeyboard && !g.IO.KeyShift) move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down); if (g.NavInputSource == ImGuiInputSource_NavGamepad) move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down); if (move_delta.x != 0.0f || move_delta.y != 0.0f) { const float NAV_MOVE_SPEED = 800.0f; const float move_speed = ImFloor(NAV_MOVE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y)); // FIXME: Doesn't code variable framerate very well SetWindowPos(g.NavWindowingTarget->RootWindow, g.NavWindowingTarget->RootWindow->Pos + move_delta * move_speed, ImGuiCond_Always); g.NavDisableMouseHover = true; MarkIniSettingsDirty(g.NavWindowingTarget); } } // Apply final focus if (apply_focus_window && (g.NavWindow == NULL || apply_focus_window != g.NavWindow->RootWindow)) { ClearActiveID(); g.NavDisableHighlight = false; g.NavDisableMouseHover = true; apply_focus_window = NavRestoreLastChildNavWindow(apply_focus_window); ClosePopupsOverWindow(apply_focus_window, false); FocusWindow(apply_focus_window); if (apply_focus_window->NavLastIds[0] == 0) NavInitWindow(apply_focus_window, false); // If the window only has a menu layer, select it directly if (apply_focus_window->DC.NavLayerActiveMask == (1 << ImGuiNavLayer_Menu)) g.NavLayer = ImGuiNavLayer_Menu; } if (apply_focus_window) g.NavWindowingTarget = NULL; // Apply menu/layer toggle if (apply_toggle_layer && g.NavWindow) { // Move to parent menu if necessary ImGuiWindow* new_nav_window = g.NavWindow; while (new_nav_window->ParentWindow && (new_nav_window->DC.NavLayerActiveMask & (1 << ImGuiNavLayer_Menu)) == 0 && (new_nav_window->Flags & ImGuiWindowFlags_ChildWindow) != 0 && (new_nav_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0) new_nav_window = new_nav_window->ParentWindow; if (new_nav_window != g.NavWindow) { ImGuiWindow* old_nav_window = g.NavWindow; FocusWindow(new_nav_window); new_nav_window->NavLastChildNavWindow = old_nav_window; } g.NavDisableHighlight = false; g.NavDisableMouseHover = true; // When entering a regular menu bar with the Alt key, we always reinitialize the navigation ID. const ImGuiNavLayer new_nav_layer = (g.NavWindow->DC.NavLayerActiveMask & (1 << ImGuiNavLayer_Menu)) ? (ImGuiNavLayer)((int)g.NavLayer ^ 1) : ImGuiNavLayer_Main; NavRestoreLayer(new_nav_layer); } } // Window has already passed the IsWindowNavFocusable() static const char* GetFallbackWindowNameForWindowingList(ImGuiWindow* window) { if (window->Flags & ImGuiWindowFlags_Popup) return "(Popup)"; if ((window->Flags & ImGuiWindowFlags_MenuBar) && strcmp(window->Name, "##MainMenuBar") == 0) return "(Main menu bar)"; return "(Untitled)"; } // Overlay displayed when using CTRL+TAB. Called by EndFrame(). void ImGui::NavUpdateWindowingOverlay() { ImGuiContext& g = *GImGui; IM_ASSERT(g.NavWindowingTarget != NULL); if (g.NavWindowingTimer < NAV_WINDOWING_LIST_APPEAR_DELAY) return; if (g.NavWindowingList == NULL) g.NavWindowingList = FindWindowByName("###NavWindowingList"); SetNextWindowSizeConstraints(ImVec2(g.IO.DisplaySize.x * 0.20f, g.IO.DisplaySize.y * 0.20f), ImVec2(FLT_MAX, FLT_MAX)); SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f); Begin("###NavWindowingList", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings); for (int n = g.WindowsFocusOrder.Size - 1; n >= 0; n--) { ImGuiWindow* window = g.WindowsFocusOrder[n]; if (!IsWindowNavFocusable(window)) continue; const char* label = window->Name; if (label == FindRenderedTextEnd(label)) label = GetFallbackWindowNameForWindowingList(window); Selectable(label, g.NavWindowingTarget == window); } End(); PopStyleVar(); } //----------------------------------------------------------------------------- // [SECTION] DRAG AND DROP //----------------------------------------------------------------------------- void ImGui::ClearDragDrop() { ImGuiContext& g = *GImGui; g.DragDropActive = false; g.DragDropPayload.Clear(); g.DragDropAcceptFlags = ImGuiDragDropFlags_None; g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0; g.DragDropAcceptIdCurrRectSurface = FLT_MAX; g.DragDropAcceptFrameCount = -1; g.DragDropPayloadBufHeap.clear(); memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal)); } // Call when current ID is active. // When this returns true you need to: a) call SetDragDropPayload() exactly once, b) you may render the payload visual/description, c) call EndDragDropSource() bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; bool source_drag_active = false; ImGuiID source_id = 0; ImGuiID source_parent_id = 0; ImGuiMouseButton mouse_button = ImGuiMouseButton_Left; if (!(flags & ImGuiDragDropFlags_SourceExtern)) { source_id = window->DC.LastItemId; if (source_id != 0 && g.ActiveId != source_id) // Early out for most common case return false; if (g.IO.MouseDown[mouse_button] == false) return false; if (source_id == 0) { // If you want to use BeginDragDropSource() on an item with no unique identifier for interaction, such as Text() or Image(), you need to: // A) Read the explanation below, B) Use the ImGuiDragDropFlags_SourceAllowNullID flag, C) Swallow your programmer pride. if (!(flags & ImGuiDragDropFlags_SourceAllowNullID)) { IM_ASSERT(0); return false; } // Early out if ((window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect) == 0 && (g.ActiveId == 0 || g.ActiveIdWindow != window)) return false; // Magic fallback (=somehow reprehensible) to handle items with no assigned ID, e.g. Text(), Image() // We build a throwaway ID based on current ID stack + relative AABB of items in window. // THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING OF THE WIDGET, so if your widget moves your dragging operation will be canceled. // We don't need to maintain/call ClearActiveID() as releasing the button will early out this function and trigger !ActiveIdIsAlive. source_id = window->DC.LastItemId = window->GetIDFromRectangle(window->DC.LastItemRect); bool is_hovered = ItemHoverable(window->DC.LastItemRect, source_id); if (is_hovered && g.IO.MouseClicked[mouse_button]) { SetActiveID(source_id, window); FocusWindow(window); } if (g.ActiveId == source_id) // Allow the underlying widget to display/return hovered during the mouse release frame, else we would get a flicker. g.ActiveIdAllowOverlap = is_hovered; } else { g.ActiveIdAllowOverlap = false; } if (g.ActiveId != source_id) return false; source_parent_id = window->IDStack.back(); source_drag_active = IsMouseDragging(mouse_button); } else { window = NULL; source_id = ImHashStr("#SourceExtern"); source_drag_active = true; } if (source_drag_active) { if (!g.DragDropActive) { IM_ASSERT(source_id != 0); ClearDragDrop(); ImGuiPayload& payload = g.DragDropPayload; payload.SourceId = source_id; payload.SourceParentId = source_parent_id; g.DragDropActive = true; g.DragDropSourceFlags = flags; g.DragDropMouseButton = mouse_button; } g.DragDropSourceFrameCount = g.FrameCount; g.DragDropWithinSourceOrTarget = true; if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip)) { // Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit) // We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents. BeginTooltip(); if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip)) { ImGuiWindow* tooltip_window = g.CurrentWindow; tooltip_window->SkipItems = true; tooltip_window->HiddenFramesCanSkipItems = 1; } } if (!(flags & ImGuiDragDropFlags_SourceNoDisableHover) && !(flags & ImGuiDragDropFlags_SourceExtern)) window->DC.LastItemStatusFlags &= ~ImGuiItemStatusFlags_HoveredRect; return true; } return false; } void ImGui::EndDragDropSource() { ImGuiContext& g = *GImGui; IM_ASSERT(g.DragDropActive); IM_ASSERT(g.DragDropWithinSourceOrTarget && "Not after a BeginDragDropSource()?"); if (!(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip)) EndTooltip(); // Discard the drag if have not called SetDragDropPayload() if (g.DragDropPayload.DataFrameCount == -1) ClearDragDrop(); g.DragDropWithinSourceOrTarget = false; } // Use 'cond' to choose to submit payload on drag start or every frame bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_size, ImGuiCond cond) { ImGuiContext& g = *GImGui; ImGuiPayload& payload = g.DragDropPayload; if (cond == 0) cond = ImGuiCond_Always; IM_ASSERT(type != NULL); IM_ASSERT(strlen(type) < IM_ARRAYSIZE(payload.DataType) && "Payload type can be at most 32 characters long"); IM_ASSERT((data != NULL && data_size > 0) || (data == NULL && data_size == 0)); IM_ASSERT(cond == ImGuiCond_Always || cond == ImGuiCond_Once); IM_ASSERT(payload.SourceId != 0); // Not called between BeginDragDropSource() and EndDragDropSource() if (cond == ImGuiCond_Always || payload.DataFrameCount == -1) { // Copy payload ImStrncpy(payload.DataType, type, IM_ARRAYSIZE(payload.DataType)); g.DragDropPayloadBufHeap.resize(0); if (data_size > sizeof(g.DragDropPayloadBufLocal)) { // Store in heap g.DragDropPayloadBufHeap.resize((int)data_size); payload.Data = g.DragDropPayloadBufHeap.Data; memcpy(payload.Data, data, data_size); } else if (data_size > 0) { // Store locally memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal)); payload.Data = g.DragDropPayloadBufLocal; memcpy(payload.Data, data, data_size); } else { payload.Data = NULL; } payload.DataSize = (int)data_size; } payload.DataFrameCount = g.FrameCount; return (g.DragDropAcceptFrameCount == g.FrameCount) || (g.DragDropAcceptFrameCount == g.FrameCount - 1); } bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id) { ImGuiContext& g = *GImGui; if (!g.DragDropActive) return false; ImGuiWindow* window = g.CurrentWindow; if (g.HoveredWindow == NULL || window->RootWindow != g.HoveredWindow->RootWindow) return false; IM_ASSERT(id != 0); if (!IsMouseHoveringRect(bb.Min, bb.Max) || (id == g.DragDropPayload.SourceId)) return false; if (window->SkipItems) return false; IM_ASSERT(g.DragDropWithinSourceOrTarget == false); g.DragDropTargetRect = bb; g.DragDropTargetId = id; g.DragDropWithinSourceOrTarget = true; return true; } // We don't use BeginDragDropTargetCustom() and duplicate its code because: // 1) we use LastItemRectHoveredRect which handles items that pushes a temporarily clip rectangle in their code. Calling BeginDragDropTargetCustom(LastItemRect) would not handle them. // 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can. // Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case) bool ImGui::BeginDragDropTarget() { ImGuiContext& g = *GImGui; if (!g.DragDropActive) return false; ImGuiWindow* window = g.CurrentWindow; if (!(window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect)) return false; if (g.HoveredWindow == NULL || window->RootWindow != g.HoveredWindow->RootWindow) return false; const ImRect& display_rect = (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? window->DC.LastItemDisplayRect : window->DC.LastItemRect; ImGuiID id = window->DC.LastItemId; if (id == 0) id = window->GetIDFromRectangle(display_rect); if (g.DragDropPayload.SourceId == id) return false; IM_ASSERT(g.DragDropWithinSourceOrTarget == false); g.DragDropTargetRect = display_rect; g.DragDropTargetId = id; g.DragDropWithinSourceOrTarget = true; return true; } bool ImGui::IsDragDropPayloadBeingAccepted() { ImGuiContext& g = *GImGui; return g.DragDropActive && g.DragDropAcceptIdPrev != 0; } const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; ImGuiPayload& payload = g.DragDropPayload; IM_ASSERT(g.DragDropActive); // Not called between BeginDragDropTarget() and EndDragDropTarget() ? IM_ASSERT(payload.DataFrameCount != -1); // Forgot to call EndDragDropTarget() ? if (type != NULL && !payload.IsDataType(type)) return NULL; // Accept smallest drag target bounding box, this allows us to nest drag targets conveniently without ordering constraints. // NB: We currently accept NULL id as target. However, overlapping targets requires a unique ID to function! const bool was_accepted_previously = (g.DragDropAcceptIdPrev == g.DragDropTargetId); ImRect r = g.DragDropTargetRect; float r_surface = r.GetWidth() * r.GetHeight(); if (r_surface < g.DragDropAcceptIdCurrRectSurface) { g.DragDropAcceptFlags = flags; g.DragDropAcceptIdCurr = g.DragDropTargetId; g.DragDropAcceptIdCurrRectSurface = r_surface; } // Render default drop visuals payload.Preview = was_accepted_previously; flags |= (g.DragDropSourceFlags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect); // Source can also inhibit the preview (useful for external sources that lives for 1 frame) if (!(flags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect) && payload.Preview) { // FIXME-DRAG: Settle on a proper default visuals for drop target. r.Expand(3.5f); bool push_clip_rect = !window->ClipRect.Contains(r); if (push_clip_rect) window->DrawList->PushClipRect(r.Min-ImVec2(1,1), r.Max+ImVec2(1,1)); window->DrawList->AddRect(r.Min, r.Max, GetColorU32(ImGuiCol_DragDropTarget), 0.0f, ~0, 2.0f); if (push_clip_rect) window->DrawList->PopClipRect(); } g.DragDropAcceptFrameCount = g.FrameCount; payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting os window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased() if (!payload.Delivery && !(flags & ImGuiDragDropFlags_AcceptBeforeDelivery)) return NULL; return &payload; } const ImGuiPayload* ImGui::GetDragDropPayload() { ImGuiContext& g = *GImGui; return g.DragDropActive ? &g.DragDropPayload : NULL; } // We don't really use/need this now, but added it for the sake of consistency and because we might need it later. void ImGui::EndDragDropTarget() { ImGuiContext& g = *GImGui; IM_ASSERT(g.DragDropActive); IM_ASSERT(g.DragDropWithinSourceOrTarget); g.DragDropWithinSourceOrTarget = false; } //----------------------------------------------------------------------------- // [SECTION] LOGGING/CAPTURING //----------------------------------------------------------------------------- // All text output from the interface can be captured into tty/file/clipboard. // By default, tree nodes are automatically opened during logging. //----------------------------------------------------------------------------- // Pass text data straight to log (without being displayed) void ImGui::LogText(const char* fmt, ...) { ImGuiContext& g = *GImGui; if (!g.LogEnabled) return; va_list args; va_start(args, fmt); if (g.LogFile) { g.LogBuffer.Buf.resize(0); g.LogBuffer.appendfv(fmt, args); ImFileWrite(g.LogBuffer.c_str(), sizeof(char), (ImU64)g.LogBuffer.size(), g.LogFile); } else { g.LogBuffer.appendfv(fmt, args); } va_end(args); } // Internal version that takes a position to decide on newline placement and pad items according to their depth. // We split text into individual lines to add current tree level padding void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (!text_end) text_end = FindRenderedTextEnd(text, text_end); const bool log_new_line = ref_pos && (ref_pos->y > g.LogLinePosY + 1); if (ref_pos) g.LogLinePosY = ref_pos->y; if (log_new_line) g.LogLineFirstItem = true; const char* text_remaining = text; if (g.LogDepthRef > window->DC.TreeDepth) // Re-adjust padding if we have popped out of our starting depth g.LogDepthRef = window->DC.TreeDepth; const int tree_depth = (window->DC.TreeDepth - g.LogDepthRef); for (;;) { // Split the string. Each new line (after a '\n') is followed by spacing corresponding to the current depth of our log entry. // We don't add a trailing \n to allow a subsequent item on the same line to be captured. const char* line_start = text_remaining; const char* line_end = ImStreolRange(line_start, text_end); const bool is_first_line = (line_start == text); const bool is_last_line = (line_end == text_end); if (!is_last_line || (line_start != line_end)) { const int char_count = (int)(line_end - line_start); if (log_new_line || !is_first_line) LogText(IM_NEWLINE "%*s%.*s", tree_depth * 4, "", char_count, line_start); else if (g.LogLineFirstItem) LogText("%*s%.*s", tree_depth * 4, "", char_count, line_start); else LogText(" %.*s", char_count, line_start); g.LogLineFirstItem = false; } else if (log_new_line) { // An empty "" string at a different Y position should output a carriage return. LogText(IM_NEWLINE); break; } if (is_last_line) break; text_remaining = line_end + 1; } } // Start logging/capturing text output void ImGui::LogBegin(ImGuiLogType type, int auto_open_depth) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; IM_ASSERT(g.LogEnabled == false); IM_ASSERT(g.LogFile == NULL); IM_ASSERT(g.LogBuffer.empty()); g.LogEnabled = true; g.LogType = type; g.LogDepthRef = window->DC.TreeDepth; g.LogDepthToExpand = ((auto_open_depth >= 0) ? auto_open_depth : g.LogDepthToExpandDefault); g.LogLinePosY = FLT_MAX; g.LogLineFirstItem = true; } void ImGui::LogToTTY(int auto_open_depth) { ImGuiContext& g = *GImGui; if (g.LogEnabled) return; IM_UNUSED(auto_open_depth); #ifndef IMGUI_DISABLE_TTY_FUNCTIONS LogBegin(ImGuiLogType_TTY, auto_open_depth); g.LogFile = stdout; #endif } // Start logging/capturing text output to given file void ImGui::LogToFile(int auto_open_depth, const char* filename) { ImGuiContext& g = *GImGui; if (g.LogEnabled) return; // FIXME: We could probably open the file in text mode "at", however note that clipboard/buffer logging will still // be subject to outputting OS-incompatible carriage return if within strings the user doesn't use IM_NEWLINE. // By opening the file in binary mode "ab" we have consistent output everywhere. if (!filename) filename = g.IO.LogFilename; if (!filename || !filename[0]) return; ImFileHandle f = ImFileOpen(filename, "ab"); if (!f) { IM_ASSERT(0); return; } LogBegin(ImGuiLogType_File, auto_open_depth); g.LogFile = f; } // Start logging/capturing text output to clipboard void ImGui::LogToClipboard(int auto_open_depth) { ImGuiContext& g = *GImGui; if (g.LogEnabled) return; LogBegin(ImGuiLogType_Clipboard, auto_open_depth); } void ImGui::LogToBuffer(int auto_open_depth) { ImGuiContext& g = *GImGui; if (g.LogEnabled) return; LogBegin(ImGuiLogType_Buffer, auto_open_depth); } void ImGui::LogFinish() { ImGuiContext& g = *GImGui; if (!g.LogEnabled) return; LogText(IM_NEWLINE); switch (g.LogType) { case ImGuiLogType_TTY: #ifndef IMGUI_DISABLE_TTY_FUNCTIONS fflush(g.LogFile); #endif break; case ImGuiLogType_File: ImFileClose(g.LogFile); break; case ImGuiLogType_Buffer: break; case ImGuiLogType_Clipboard: if (!g.LogBuffer.empty()) SetClipboardText(g.LogBuffer.begin()); break; case ImGuiLogType_None: IM_ASSERT(0); break; } g.LogEnabled = false; g.LogType = ImGuiLogType_None; g.LogFile = NULL; g.LogBuffer.clear(); } // Helper to display logging buttons // FIXME-OBSOLETE: We should probably obsolete this and let the user have their own helper (this is one of the oldest function alive!) void ImGui::LogButtons() { ImGuiContext& g = *GImGui; PushID("LogButtons"); #ifndef IMGUI_DISABLE_TTY_FUNCTIONS const bool log_to_tty = Button("Log To TTY"); SameLine(); #else const bool log_to_tty = false; #endif const bool log_to_file = Button("Log To File"); SameLine(); const bool log_to_clipboard = Button("Log To Clipboard"); SameLine(); PushAllowKeyboardFocus(false); SetNextItemWidth(80.0f); SliderInt("Default Depth", &g.LogDepthToExpandDefault, 0, 9, NULL); PopAllowKeyboardFocus(); PopID(); // Start logging at the end of the function so that the buttons don't appear in the log if (log_to_tty) LogToTTY(); if (log_to_file) LogToFile(); if (log_to_clipboard) LogToClipboard(); } //----------------------------------------------------------------------------- // [SECTION] SETTINGS //----------------------------------------------------------------------------- void ImGui::MarkIniSettingsDirty() { ImGuiContext& g = *GImGui; if (g.SettingsDirtyTimer <= 0.0f) g.SettingsDirtyTimer = g.IO.IniSavingRate; } void ImGui::MarkIniSettingsDirty(ImGuiWindow* window) { ImGuiContext& g = *GImGui; if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings)) if (g.SettingsDirtyTimer <= 0.0f) g.SettingsDirtyTimer = g.IO.IniSavingRate; } ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name) { ImGuiContext& g = *GImGui; #if !IMGUI_DEBUG_INI_SETTINGS // Skip to the "###" marker if any. We don't skip past to match the behavior of GetID() // Preserve the full string when IMGUI_DEBUG_INI_SETTINGS is set to make .ini inspection easier. if (const char* p = strstr(name, "###")) name = p; #endif const size_t name_len = strlen(name); // Allocate chunk const size_t chunk_size = sizeof(ImGuiWindowSettings) + name_len + 1; ImGuiWindowSettings* settings = g.SettingsWindows.alloc_chunk(chunk_size); IM_PLACEMENT_NEW(settings) ImGuiWindowSettings(); settings->ID = ImHashStr(name, name_len); memcpy(settings->GetName(), name, name_len + 1); // Store with zero terminator return settings; } ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id) { ImGuiContext& g = *GImGui; for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) if (settings->ID == id) return settings; return NULL; } ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name) { if (ImGuiWindowSettings* settings = FindWindowSettings(ImHashStr(name))) return settings; return CreateNewWindowSettings(name); } void ImGui::LoadIniSettingsFromDisk(const char* ini_filename) { size_t file_data_size = 0; char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_data_size); if (!file_data) return; LoadIniSettingsFromMemory(file_data, (size_t)file_data_size); IM_FREE(file_data); } ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name) { ImGuiContext& g = *GImGui; const ImGuiID type_hash = ImHashStr(type_name); for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) if (g.SettingsHandlers[handler_n].TypeHash == type_hash) return &g.SettingsHandlers[handler_n]; return NULL; } // Zero-tolerance, no error reporting, cheap .ini parsing void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size) { ImGuiContext& g = *GImGui; IM_ASSERT(g.Initialized); IM_ASSERT(g.SettingsLoaded == false && g.FrameCount == 0); // For user convenience, we allow passing a non zero-terminated string (hence the ini_size parameter). // For our convenience and to make the code simpler, we'll also write zero-terminators within the buffer. So let's create a writable copy.. if (ini_size == 0) ini_size = strlen(ini_data); char* buf = (char*)IM_ALLOC(ini_size + 1); char* buf_end = buf + ini_size; memcpy(buf, ini_data, ini_size); buf[ini_size] = 0; void* entry_data = NULL; ImGuiSettingsHandler* entry_handler = NULL; char* line_end = NULL; for (char* line = buf; line < buf_end; line = line_end + 1) { // Skip new lines markers, then find end of the line while (*line == '\n' || *line == '\r') line++; line_end = line; while (line_end < buf_end && *line_end != '\n' && *line_end != '\r') line_end++; line_end[0] = 0; if (line[0] == ';') continue; if (line[0] == '[' && line_end > line && line_end[-1] == ']') { // Parse "[Type][Name]". Note that 'Name' can itself contains [] characters, which is acceptable with the current format and parsing code. line_end[-1] = 0; const char* name_end = line_end - 1; const char* type_start = line + 1; char* type_end = (char*)(void*)ImStrchrRange(type_start, name_end, ']'); const char* name_start = type_end ? ImStrchrRange(type_end + 1, name_end, '[') : NULL; if (!type_end || !name_start) continue; *type_end = 0; // Overwrite first ']' name_start++; // Skip second '[' entry_handler = FindSettingsHandler(type_start); entry_data = entry_handler ? entry_handler->ReadOpenFn(&g, entry_handler, name_start) : NULL; } else if (entry_handler != NULL && entry_data != NULL) { // Let type handler parse the line entry_handler->ReadLineFn(&g, entry_handler, entry_data, line); } } IM_FREE(buf); g.SettingsLoaded = true; } void ImGui::SaveIniSettingsToDisk(const char* ini_filename) { ImGuiContext& g = *GImGui; g.SettingsDirtyTimer = 0.0f; if (!ini_filename) return; size_t ini_data_size = 0; const char* ini_data = SaveIniSettingsToMemory(&ini_data_size); ImFileHandle f = ImFileOpen(ini_filename, "wt"); if (!f) return; ImFileWrite(ini_data, sizeof(char), ini_data_size, f); ImFileClose(f); } // Call registered handlers (e.g. SettingsHandlerWindow_WriteAll() + custom handlers) to write their stuff into a text buffer const char* ImGui::SaveIniSettingsToMemory(size_t* out_size) { ImGuiContext& g = *GImGui; g.SettingsDirtyTimer = 0.0f; g.SettingsIniData.Buf.resize(0); g.SettingsIniData.Buf.push_back(0); for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) { ImGuiSettingsHandler* handler = &g.SettingsHandlers[handler_n]; handler->WriteAllFn(&g, handler, &g.SettingsIniData); } if (out_size) *out_size = (size_t)g.SettingsIniData.size(); return g.SettingsIniData.c_str(); } static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name) { ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHashStr(name)); if (!settings) settings = ImGui::CreateNewWindowSettings(name); return (void*)settings; } static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line) { ImGuiWindowSettings* settings = (ImGuiWindowSettings*)entry; int x, y; int i; if (sscanf(line, "Pos=%i,%i", &x, &y) == 2) settings->Pos = ImVec2ih((short)x, (short)y); else if (sscanf(line, "Size=%i,%i", &x, &y) == 2) settings->Size = ImVec2ih((short)x, (short)y); else if (sscanf(line, "Collapsed=%d", &i) == 1) settings->Collapsed = (i != 0); } static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf) { // Gather data from windows that were active during this session // (if a window wasn't opened in this session we preserve its settings) ImGuiContext& g = *ctx; for (int i = 0; i != g.Windows.Size; i++) { ImGuiWindow* window = g.Windows[i]; if (window->Flags & ImGuiWindowFlags_NoSavedSettings) continue; ImGuiWindowSettings* settings = (window->SettingsOffset != -1) ? g.SettingsWindows.ptr_from_offset(window->SettingsOffset) : ImGui::FindWindowSettings(window->ID); if (!settings) { settings = ImGui::CreateNewWindowSettings(window->Name); window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings); } IM_ASSERT(settings->ID == window->ID); settings->Pos = ImVec2ih((short)window->Pos.x, (short)window->Pos.y); settings->Size = ImVec2ih((short)window->SizeFull.x, (short)window->SizeFull.y); settings->Collapsed = window->Collapsed; } // Write to text buffer buf->reserve(buf->size() + g.SettingsWindows.size() * 6); // ballpark reserve for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) { const char* settings_name = settings->GetName(); buf->appendf("[%s][%s]\n", handler->TypeName, settings_name); buf->appendf("Pos=%d,%d\n", settings->Pos.x, settings->Pos.y); buf->appendf("Size=%d,%d\n", settings->Size.x, settings->Size.y); buf->appendf("Collapsed=%d\n", settings->Collapsed); buf->append("\n"); } } //----------------------------------------------------------------------------- // [SECTION] VIEWPORTS, PLATFORM WINDOWS //----------------------------------------------------------------------------- // (this section is filled in the 'docking' branch) //----------------------------------------------------------------------------- // [SECTION] DOCKING //----------------------------------------------------------------------------- // (this section is filled in the 'docking' branch) //----------------------------------------------------------------------------- // [SECTION] PLATFORM DEPENDENT HELPERS //----------------------------------------------------------------------------- #if defined(_WIN32) && !defined(_WINDOWS_) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && (!defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) || !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #ifndef __MINGW32__ #include #else #include #endif #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) // UWP doesn't have Win32 functions #define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS #define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS #endif #elif defined(__APPLE__) #include #endif #if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) #ifdef _MSC_VER #pragma comment(lib, "user32") #endif // Win32 clipboard implementation static const char* GetClipboardTextFn_DefaultImpl(void*) { static ImVector buf_local; buf_local.clear(); if (!::OpenClipboard(NULL)) return NULL; HANDLE wbuf_handle = ::GetClipboardData(CF_UNICODETEXT); if (wbuf_handle == NULL) { ::CloseClipboard(); return NULL; } if (ImWchar* wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle)) { int buf_len = ImTextCountUtf8BytesFromStr(wbuf_global, NULL) + 1; buf_local.resize(buf_len); ImTextStrToUtf8(buf_local.Data, buf_len, wbuf_global, NULL); } ::GlobalUnlock(wbuf_handle); ::CloseClipboard(); return buf_local.Data; } static void SetClipboardTextFn_DefaultImpl(void*, const char* text) { if (!::OpenClipboard(NULL)) return; const int wbuf_length = ImTextCountCharsFromUtf8(text, NULL) + 1; HGLOBAL wbuf_handle = ::GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(ImWchar)); if (wbuf_handle == NULL) { ::CloseClipboard(); return; } ImWchar* wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle); ImTextStrFromUtf8(wbuf_global, wbuf_length, text, NULL); ::GlobalUnlock(wbuf_handle); ::EmptyClipboard(); if (::SetClipboardData(CF_UNICODETEXT, wbuf_handle) == NULL) ::GlobalFree(wbuf_handle); ::CloseClipboard(); } #elif defined(__APPLE__) && TARGET_OS_OSX && defined(IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS) #include // Use old API to avoid need for separate .mm file static PasteboardRef main_clipboard = 0; // OSX clipboard implementation // If you enable this you will need to add '-framework ApplicationServices' to your linker command-line! static void SetClipboardTextFn_DefaultImpl(void*, const char* text) { if (!main_clipboard) PasteboardCreate(kPasteboardClipboard, &main_clipboard); PasteboardClear(main_clipboard); CFDataRef cf_data = CFDataCreate(kCFAllocatorDefault, (const UInt8*)text, strlen(text)); if (cf_data) { PasteboardPutItemFlavor(main_clipboard, (PasteboardItemID)1, CFSTR("public.utf8-plain-text"), cf_data, 0); CFRelease(cf_data); } } static const char* GetClipboardTextFn_DefaultImpl(void*) { if (!main_clipboard) PasteboardCreate(kPasteboardClipboard, &main_clipboard); PasteboardSynchronize(main_clipboard); ItemCount item_count = 0; PasteboardGetItemCount(main_clipboard, &item_count); for (ItemCount i = 0; i < item_count; i++) { PasteboardItemID item_id = 0; PasteboardGetItemIdentifier(main_clipboard, i + 1, &item_id); CFArrayRef flavor_type_array = 0; PasteboardCopyItemFlavors(main_clipboard, item_id, &flavor_type_array); for (CFIndex j = 0, nj = CFArrayGetCount(flavor_type_array); j < nj; j++) { CFDataRef cf_data; if (PasteboardCopyItemFlavorData(main_clipboard, item_id, CFSTR("public.utf8-plain-text"), &cf_data) == noErr) { static ImVector clipboard_text; int length = (int)CFDataGetLength(cf_data); clipboard_text.resize(length + 1); CFDataGetBytes(cf_data, CFRangeMake(0, length), (UInt8*)clipboard_text.Data); clipboard_text[length] = 0; CFRelease(cf_data); return clipboard_text.Data; } } } return NULL; } #else // Local Dear ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers. static const char* GetClipboardTextFn_DefaultImpl(void*) { ImGuiContext& g = *GImGui; return g.PrivateClipboard.empty() ? NULL : g.PrivateClipboard.begin(); } static void SetClipboardTextFn_DefaultImpl(void*, const char* text) { ImGuiContext& g = *GImGui; g.PrivateClipboard.clear(); const char* text_end = text + strlen(text); g.PrivateClipboard.resize((int)(text_end - text) + 1); memcpy(&g.PrivateClipboard[0], text, (size_t)(text_end - text)); g.PrivateClipboard[(int)(text_end - text)] = 0; } #endif // Win32 API IME support (for Asian languages, etc.) #if defined(_WIN32) && !defined(__GNUC__) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS) #include #ifdef _MSC_VER #pragma comment(lib, "imm32") #endif static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y) { // Notify OS Input Method Editor of text input position ImGuiIO& io = ImGui::GetIO(); if (HWND hwnd = (HWND)io.ImeWindowHandle) if (HIMC himc = ::ImmGetContext(hwnd)) { COMPOSITIONFORM cf; cf.ptCurrentPos.x = x; cf.ptCurrentPos.y = y; cf.dwStyle = CFS_FORCE_POSITION; ::ImmSetCompositionWindow(himc, &cf); ::ImmReleaseContext(hwnd, himc); } } #else static void ImeSetInputScreenPosFn_DefaultImpl(int, int) {} #endif //----------------------------------------------------------------------------- // [SECTION] METRICS/DEBUG WINDOW //----------------------------------------------------------------------------- #ifndef IMGUI_DISABLE_METRICS_WINDOW // Avoid naming collision with imgui_demo.cpp's HelpMarker() for unity builds. static void MetricsHelpMarker(const char* desc) { ImGui::TextDisabled("(?)"); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f); ImGui::TextUnformatted(desc); ImGui::PopTextWrapPos(); ImGui::EndTooltip(); } } void ImGui::ShowMetricsWindow(bool* p_open) { if (!ImGui::Begin("Dear ImGui Metrics", p_open)) { ImGui::End(); return; } // Debugging enums enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Content, WRT_ContentRegionRect, WRT_Count }; // Windows Rect Type const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Content", "ContentRegionRect" }; enum { TRT_OuterRect, TRT_WorkRect, TRT_HostClipRect, TRT_InnerClipRect, TRT_BackgroundClipRect, TRT_ColumnsRect, TRT_ColumnsClipRect, TRT_ColumnsContentHeadersUsed, TRT_ColumnsContentHeadersDesired, TRT_ColumnsContentRowsFrozen, TRT_ColumnsContentRowsUnfrozen, TRT_Count }; // Tables Rect Type const char* trt_rects_names[TRT_Count] = { "OuterRect", "WorkRect", "HostClipRect", "InnerClipRect", "BackgroundClipRect", "ColumnsRect", "ColumnsClipRect", "ColumnsContentHeadersUsed", "ColumnsContentHeadersDesired", "ColumnsContentRowsFrozen", "ColumnsContentRowsUnfrozen" }; // State static bool show_windows_rects = false; static int show_windows_rect_type = WRT_WorkRect; static bool show_windows_begin_order = false; static bool show_tables_rects = false; static int show_tables_rect_type = TRT_WorkRect; static bool show_drawcmd_details = true; // Basic info ImGuiContext& g = *GImGui; ImGuiIO& io = ImGui::GetIO(); ImGui::Text("Dear ImGui %s", ImGui::GetVersion()); ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); ImGui::Text("%d vertices, %d indices (%d triangles)", io.MetricsRenderVertices, io.MetricsRenderIndices, io.MetricsRenderIndices / 3); ImGui::Text("%d active windows (%d visible)", io.MetricsActiveWindows, io.MetricsRenderWindows); ImGui::Text("%d active allocations", io.MetricsActiveAllocations); ImGui::Separator(); // Helper functions to display common structures: // - NodeDrawList() // - NodeColumns() // - NodeWindow() // - NodeWindows() // - NodeTabBar() // - NodeStorage() struct Funcs { static ImRect GetWindowRect(ImGuiWindow* window, int rect_type) { if (rect_type == WRT_OuterRect) { return window->Rect(); } else if (rect_type == WRT_OuterRectClipped) { return window->OuterRectClipped; } else if (rect_type == WRT_InnerRect) { return window->InnerRect; } else if (rect_type == WRT_InnerClipRect) { return window->InnerClipRect; } else if (rect_type == WRT_WorkRect) { return window->WorkRect; } else if (rect_type == WRT_Content) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); } else if (rect_type == WRT_ContentRegionRect) { return window->ContentRegionRect; } IM_ASSERT(0); return ImRect(); } static void NodeDrawList(ImGuiWindow* window, ImDrawList* draw_list, const char* label) { bool node_open = ImGui::TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, draw_list->CmdBuffer.Size); if (draw_list == ImGui::GetWindowDrawList()) { ImGui::SameLine(); ImGui::TextColored(ImVec4(1.0f,0.4f,0.4f,1.0f), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered) if (node_open) ImGui::TreePop(); return; } ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list if (window && IsItemHovered()) fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); if (!node_open) return; if (window && !window->WasActive) ImGui::TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!"); unsigned int elem_offset = 0; for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.begin(); pcmd < draw_list->CmdBuffer.end(); elem_offset += pcmd->ElemCount, pcmd++) { if (pcmd->UserCallback == NULL && pcmd->ElemCount == 0) continue; if (pcmd->UserCallback) { ImGui::BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); continue; } ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; char buf[300]; ImFormatString(buf, IM_ARRAYSIZE(buf), "DrawCmd: %4d triangles, Tex 0x%p, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)", pcmd->ElemCount/3, (void*)(intptr_t)pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); bool pcmd_node_open = ImGui::TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); if (show_drawcmd_details && fg_draw_list && ImGui::IsItemHovered()) { ImRect clip_rect = pcmd->ClipRect; ImRect vtxs_rect(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX); for (unsigned int i = elem_offset; i < elem_offset + (int)pcmd->ElemCount; i++) vtxs_rect.Add(draw_list->VtxBuffer[idx_buffer ? idx_buffer[i] : i].pos); fg_draw_list->AddRect(ImFloor(clip_rect.Min), ImFloor(clip_rect.Max), IM_COL32(255,0,255,255)); fg_draw_list->AddRect(ImFloor(vtxs_rect.Min), ImFloor(vtxs_rect.Max), IM_COL32(255,255,0,255)); } if (!pcmd_node_open) continue; // Calculate approximate coverage area (touched pixel count) // This will be in pixels squared as long there's no post-scaling happening to the renderer output. float total_area = 0.0f; for (unsigned int base_idx = elem_offset; base_idx < (elem_offset + pcmd->ElemCount); base_idx += 3) { ImVec2 triangle[3]; for (int n = 0; n < 3; n++) triangle[n] = draw_list->VtxBuffer[idx_buffer ? idx_buffer[base_idx + n] : (base_idx + n)].pos; total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]); } // Display vertex information summary. Hover to get all triangles drawn in wire-frame ImFormatString(buf, IM_ARRAYSIZE(buf), "Mesh: ElemCount: %d, VtxOffset: +%d, IdxOffset: +%d, Area: ~%0.f px", pcmd->ElemCount, pcmd->VtxOffset, pcmd->IdxOffset, total_area); ImGui::Selectable(buf); if (fg_draw_list && ImGui::IsItemHovered() && show_drawcmd_details) { // Draw wire-frame version of everything ImDrawListFlags backup_flags = fg_draw_list->Flags; fg_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles. ImRect clip_rect = pcmd->ClipRect; fg_draw_list->AddRect(ImFloor(clip_rect.Min), ImFloor(clip_rect.Max), IM_COL32(255, 0, 255, 255)); for (unsigned int base_idx = elem_offset; base_idx < (elem_offset + pcmd->ElemCount); base_idx += 3) { ImVec2 triangle[3]; for (int n = 0; n < 3; n++) triangle[n] = draw_list->VtxBuffer[idx_buffer ? idx_buffer[base_idx + n] : (base_idx + n)].pos; fg_draw_list->AddPolyline(triangle, 3, IM_COL32(255, 255, 0, 255), true, 1.0f); } fg_draw_list->Flags = backup_flags; } // Display individual triangles/vertices. Hover on to get the corresponding triangle highlighted. ImGuiListClipper clipper(pcmd->ElemCount/3); // Manually coarse clip our print out of individual vertices to save CPU, only items that may be visible. while (clipper.Step()) for (int prim = clipper.DisplayStart, idx_i = elem_offset + clipper.DisplayStart*3; prim < clipper.DisplayEnd; prim++) { char *buf_p = buf, *buf_end = buf + IM_ARRAYSIZE(buf); ImVec2 triangle[3]; for (int n = 0; n < 3; n++, idx_i++) { ImDrawVert& v = draw_list->VtxBuffer[idx_buffer ? idx_buffer[idx_i] : idx_i]; triangle[n] = v.pos; buf_p += ImFormatString(buf_p, buf_end - buf_p, "%s %04d: pos (%8.2f,%8.2f), uv (%.6f,%.6f), col %08X\n", (n == 0) ? "Vert:" : " ", idx_i, v.pos.x, v.pos.y, v.uv.x, v.uv.y, v.col); } ImGui::Selectable(buf, false); if (fg_draw_list && ImGui::IsItemHovered()) { ImDrawListFlags backup_flags = fg_draw_list->Flags; fg_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles. fg_draw_list->AddPolyline(triangle, 3, IM_COL32(255,255,0,255), true, 1.0f); fg_draw_list->Flags = backup_flags; } } ImGui::TreePop(); } ImGui::TreePop(); } static void NodeColumns(const ImGuiColumns* columns) { if (!ImGui::TreeNode((void*)(uintptr_t)columns->ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->ID, columns->Count, columns->Flags)) return; ImGui::BulletText("Width: %.1f (MinX: %.1f, MaxX: %.1f)", columns->OffMaxX - columns->OffMinX, columns->OffMinX, columns->OffMaxX); for (int column_n = 0; column_n < columns->Columns.Size; column_n++) ImGui::BulletText("Column %02d: OffsetNorm %.3f (= %.1f px)", column_n, columns->Columns[column_n].OffsetNorm, GetColumnOffsetFromNorm(columns, columns->Columns[column_n].OffsetNorm)); ImGui::TreePop(); } static void NodeWindows(ImVector& windows, const char* label) { if (!ImGui::TreeNode(label, "%s (%d)", label, windows.Size)) return; for (int i = 0; i < windows.Size; i++) { ImGui::PushID(windows[i]); Funcs::NodeWindow(windows[i], "Window"); ImGui::PopID(); } ImGui::TreePop(); } static void NodeWindow(ImGuiWindow* window, const char* label) { if (window == NULL) { ImGui::BulletText("%s: NULL", label); return; } bool open = ImGui::TreeNode(label, "%s '%s', %d @ 0x%p", label, window->Name, (window->Active || window->WasActive), window); if (ImGui::IsItemHovered() && window->WasActive) ImGui::GetForegroundDrawList()->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); if (!open) return; ImGuiWindowFlags flags = window->Flags; NodeDrawList(window, window->DrawList, "DrawList"); ImGui::BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), ContentSize (%.1f,%.1f)", window->Pos.x, window->Pos.y, window->Size.x, window->Size.y, window->ContentSize.x, window->ContentSize.y); ImGui::BulletText("Flags: 0x%08X (%s%s%s%s%s%s%s%s%s..)", flags, (flags & ImGuiWindowFlags_ChildWindow) ? "Child " : "", (flags & ImGuiWindowFlags_Tooltip) ? "Tooltip " : "", (flags & ImGuiWindowFlags_Popup) ? "Popup " : "", (flags & ImGuiWindowFlags_Modal) ? "Modal " : "", (flags & ImGuiWindowFlags_ChildMenu) ? "ChildMenu " : "", (flags & ImGuiWindowFlags_NoSavedSettings) ? "NoSavedSettings " : "", (flags & ImGuiWindowFlags_NoMouseInputs)? "NoMouseInputs":"", (flags & ImGuiWindowFlags_NoNavInputs) ? "NoNavInputs" : "", (flags & ImGuiWindowFlags_AlwaysAutoResize) ? "AlwaysAutoResize" : ""); ImGui::BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f) Scrollbar:%s%s", window->Scroll.x, window->ScrollMax.x, window->Scroll.y, window->ScrollMax.y, window->ScrollbarX ? "X" : "", window->ScrollbarY ? "Y" : ""); ImGui::BulletText("Active: %d/%d, WriteAccessed: %d, BeginOrderWithinContext: %d", window->Active, window->WasActive, window->WriteAccessed, (window->Active || window->WasActive) ? window->BeginOrderWithinContext : -1); ImGui::BulletText("Appearing: %d, Hidden: %d (CanSkip %d Cannot %d), SkipItems: %d", window->Appearing, window->Hidden, window->HiddenFramesCanSkipItems, window->HiddenFramesCannotSkipItems, window->SkipItems); ImGui::BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask); ImGui::BulletText("NavLastChildNavWindow: %s", window->NavLastChildNavWindow ? window->NavLastChildNavWindow->Name : "NULL"); if (!window->NavRectRel[0].IsInverted()) ImGui::BulletText("NavRectRel[0]: (%.1f,%.1f)(%.1f,%.1f)", window->NavRectRel[0].Min.x, window->NavRectRel[0].Min.y, window->NavRectRel[0].Max.x, window->NavRectRel[0].Max.y); else ImGui::BulletText("NavRectRel[0]: "); if (window->RootWindow != window) NodeWindow(window->RootWindow, "RootWindow"); if (window->ParentWindow != NULL) NodeWindow(window->ParentWindow, "ParentWindow"); if (window->DC.ChildWindows.Size > 0) NodeWindows(window->DC.ChildWindows, "ChildWindows"); if (window->ColumnsStorage.Size > 0 && ImGui::TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size)) { for (int n = 0; n < window->ColumnsStorage.Size; n++) NodeColumns(&window->ColumnsStorage[n]); ImGui::TreePop(); } NodeStorage(&window->StateStorage, "Storage"); ImGui::TreePop(); } static void NodeTabBar(ImGuiTabBar* tab_bar) { // Standalone tab bars (not associated to docking/windows functionality) currently hold no discernible strings. char buf[256]; char* p = buf; const char* buf_end = buf + IM_ARRAYSIZE(buf); p += ImFormatString(p, buf_end - p, "TabBar (%d tabs)%s", tab_bar->Tabs.Size, (tab_bar->PrevFrameVisible < ImGui::GetFrameCount() - 2) ? " *Inactive*" : ""); if (ImGui::TreeNode(tab_bar, "%s", buf)) { for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) { const ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; ImGui::PushID(tab); if (ImGui::SmallButton("<")) { TabBarQueueChangeTabOrder(tab_bar, tab, -1); } ImGui::SameLine(0, 2); if (ImGui::SmallButton(">")) { TabBarQueueChangeTabOrder(tab_bar, tab, +1); } ImGui::SameLine(); ImGui::Text("%02d%c Tab 0x%08X '%s'", tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : ""); ImGui::PopID(); } ImGui::TreePop(); } } static void NodeStorage(ImGuiStorage* storage, const char* label) { if (!ImGui::TreeNode(label, "%s: %d entries, %d bytes", label, storage->Data.Size, storage->Data.size_in_bytes())) return; for (int n = 0; n < storage->Data.Size; n++) { const ImGuiStorage::ImGuiStoragePair& p = storage->Data[n]; ImGui::BulletText("Key 0x%08X Value { i: %d }", p.key, p.val_i); // Important: we currently don't store a type, real value may not be integer. } ImGui::TreePop(); } }; Funcs::NodeWindows(g.Windows, "Windows"); //Funcs::NodeWindows(g.WindowsFocusOrder, "WindowsFocusOrder"); if (ImGui::TreeNode("DrawLists", "Active DrawLists (%d)", g.DrawDataBuilder.Layers[0].Size)) { for (int i = 0; i < g.DrawDataBuilder.Layers[0].Size; i++) Funcs::NodeDrawList(NULL, g.DrawDataBuilder.Layers[0][i], "DrawList"); ImGui::TreePop(); } // Details for Popups if (ImGui::TreeNode("Popups", "Popups (%d)", g.OpenPopupStack.Size)) { for (int i = 0; i < g.OpenPopupStack.Size; i++) { ImGuiWindow* window = g.OpenPopupStack[i].Window; ImGui::BulletText("PopupID: %08x, Window: '%s'%s%s", g.OpenPopupStack[i].PopupId, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? " ChildWindow" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? " ChildMenu" : ""); } ImGui::TreePop(); } // Details for TabBars if (ImGui::TreeNode("TabBars", "Tab Bars (%d)", g.TabBars.GetSize())) { for (int n = 0; n < g.TabBars.GetSize(); n++) Funcs::NodeTabBar(g.TabBars.GetByIndex(n)); ImGui::TreePop(); } // Details for Tables IM_UNUSED(trt_rects_names); IM_UNUSED(show_tables_rects); IM_UNUSED(show_tables_rect_type); #ifdef IMGUI_HAS_TABLE if (ImGui::TreeNode("Tables", "Tables (%d)", g.Tables.GetSize())) { for (int n = 0; n < g.Tables.GetSize(); n++) Funcs::NodeTable(g.Tables.GetByIndex(n)); ImGui::TreePop(); } #endif // #define IMGUI_HAS_TABLE // Details for Docking #ifdef IMGUI_HAS_DOCK if (ImGui::TreeNode("Docking")) { ImGui::TreePop(); } #endif // #define IMGUI_HAS_DOCK // Misc Details if (ImGui::TreeNode("Internal state")) { const char* input_source_names[] = { "None", "Mouse", "Nav", "NavKeyboard", "NavGamepad" }; IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT); ImGui::Text("HoveredWindow: '%s'", g.HoveredWindow ? g.HoveredWindow->Name : "NULL"); ImGui::Text("HoveredRootWindow: '%s'", g.HoveredRootWindow ? g.HoveredRootWindow->Name : "NULL"); ImGui::Text("HoveredId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredId, g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Data is "in-flight" so depending on when the Metrics window is called we may see current frame information or not ImGui::Text("ActiveId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d, Source: %s", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer, g.ActiveIdAllowOverlap, input_source_names[g.ActiveIdSource]); ImGui::Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL"); ImGui::Text("MovingWindow: '%s'", g.MovingWindow ? g.MovingWindow->Name : "NULL"); ImGui::Text("NavWindow: '%s'", g.NavWindow ? g.NavWindow->Name : "NULL"); ImGui::Text("NavId: 0x%08X, NavLayer: %d", g.NavId, g.NavLayer); ImGui::Text("NavInputSource: %s", input_source_names[g.NavInputSource]); ImGui::Text("NavActive: %d, NavVisible: %d", g.IO.NavActive, g.IO.NavVisible); ImGui::Text("NavActivateId: 0x%08X, NavInputId: 0x%08X", g.NavActivateId, g.NavInputId); ImGui::Text("NavDisableHighlight: %d, NavDisableMouseHover: %d", g.NavDisableHighlight, g.NavDisableMouseHover); ImGui::Text("NavWindowingTarget: '%s'", g.NavWindowingTarget ? g.NavWindowingTarget->Name : "NULL"); ImGui::Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize); ImGui::TreePop(); } // Tools if (ImGui::TreeNode("Tools")) { // The Item Picker tool is super useful to visually select an item and break into the call-stack of where it was submitted. if (ImGui::Button("Item Picker..")) ImGui::DebugStartItemPicker(); ImGui::SameLine(); MetricsHelpMarker("Will call the IM_DEBUG_BREAK() macro to break in debugger.\nWarning: If you don't have a debugger attached, this will probably crash."); ImGui::Checkbox("Show windows begin order", &show_windows_begin_order); ImGui::Checkbox("Show windows rectangles", &show_windows_rects); ImGui::SameLine(); ImGui::SetNextItemWidth(ImGui::GetFontSize() * 12); show_windows_rects |= ImGui::Combo("##show_windows_rect_type", &show_windows_rect_type, wrt_rects_names, WRT_Count, WRT_Count); if (show_windows_rects && g.NavWindow) { ImGui::BulletText("'%s':", g.NavWindow->Name); ImGui::Indent(); for (int rect_n = 0; rect_n < WRT_Count; rect_n++) { ImRect r = Funcs::GetWindowRect(g.NavWindow, rect_n); ImGui::Text("(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), wrt_rects_names[rect_n]); } ImGui::Unindent(); } ImGui::Checkbox("Show details when hovering ImDrawCmd node", &show_drawcmd_details); ImGui::TreePop(); } // Overlay: Display windows Rectangles and Begin Order if (show_windows_rects || show_windows_begin_order) { for (int n = 0; n < g.Windows.Size; n++) { ImGuiWindow* window = g.Windows[n]; if (!window->WasActive) continue; ImDrawList* draw_list = GetForegroundDrawList(window); if (show_windows_rects) { ImRect r = Funcs::GetWindowRect(window, show_windows_rect_type); draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 0, 128, 255)); } if (show_windows_begin_order && !(window->Flags & ImGuiWindowFlags_ChildWindow)) { char buf[32]; ImFormatString(buf, IM_ARRAYSIZE(buf), "%d", window->BeginOrderWithinContext); float font_size = ImGui::GetFontSize(); draw_list->AddRectFilled(window->Pos, window->Pos + ImVec2(font_size, font_size), IM_COL32(200, 100, 100, 255)); draw_list->AddText(window->Pos, IM_COL32(255, 255, 255, 255), buf); } } } #ifdef IMGUI_HAS_TABLE // Overlay: Display Tables Rectangles if (show_tables_rects) { for (int table_n = 0; table_n < g.Tables.GetSize(); table_n++) { ImGuiTable* table = g.Tables.GetByIndex(table_n); } } #endif // #define IMGUI_HAS_TABLE #ifdef IMGUI_HAS_DOCK // Overlay: Display Docking info if (show_docking_nodes && g.IO.KeyCtrl) { } #endif // #define IMGUI_HAS_DOCK ImGui::End(); } #else void ImGui::ShowMetricsWindow(bool*) { } #endif //----------------------------------------------------------------------------- // Include imgui_user.inl at the end of imgui.cpp to access private data/functions that aren't exposed. // Prefer just including imgui_internal.h from your code rather than using this define. If a declaration is missing from imgui_internal.h add it or request it on the github. #ifdef IMGUI_INCLUDE_IMGUI_USER_INL #include "imgui_user.inl" #endif //----------------------------------------------------------------------------- #endif // #ifndef IMGUI_DISABLE goxel-0.11.0/ext_src/imgui/imgui.h000066400000000000000000006542771435762723100170120ustar00rootroot00000000000000// dear imgui, v1.75 // (headers) // Help: // - Read FAQ at http://dearimgui.org/faq // - Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase. // - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code. All applications in examples/ are doing that. // Read imgui.cpp for more details, documentation and comments. // Resources: // - FAQ http://dearimgui.org/faq // - Homepage & latest https://github.com/ocornut/imgui // - Releases & changelog https://github.com/ocornut/imgui/releases // - Gallery https://github.com/ocornut/imgui/issues/2847 (please post your screenshots/video there!) // - Glossary https://github.com/ocornut/imgui/wiki/Glossary // - Wiki https://github.com/ocornut/imgui/wiki // - Issues & support https://github.com/ocornut/imgui/issues /* Index of this file: // Header mess // Forward declarations and basic types // ImGui API (Dear ImGui end-user API) // Flags & Enumerations // Memory allocations macros // ImVector<> // ImGuiStyle // ImGuiIO // Misc data structures (ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiPayload) // Obsolete functions // Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, ImColor) // Draw List API (ImDrawCallback, ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawListFlags, ImDrawList, ImDrawData) // Font API (ImFontConfig, ImFontGlyph, ImFontGlyphRangesBuilder, ImFontAtlasFlags, ImFontAtlas, ImFont) */ #pragma once // Configuration file with compile-time options (edit imconfig.h or #define IMGUI_USER_CONFIG to your own filename) #ifdef IMGUI_USER_CONFIG #include IMGUI_USER_CONFIG #endif #if !defined(IMGUI_DISABLE_INCLUDE_IMCONFIG_H) || defined(IMGUI_INCLUDE_IMCONFIG_H) #include "imconfig.h" #endif #ifndef IMGUI_DISABLE //----------------------------------------------------------------------------- // Header mess //----------------------------------------------------------------------------- // Includes #include // FLT_MIN, FLT_MAX #include // va_list, va_start, va_end #include // ptrdiff_t, NULL #include // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp // Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) #define IMGUI_VERSION "1.75" #define IMGUI_VERSION_NUM 17500 #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) // Define attributes of all API symbols declarations (e.g. for DLL under Windows) // IMGUI_API is used for core imgui functions, IMGUI_IMPL_API is used for the default bindings files (imgui_impl_xxx.h) // Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. #ifndef IMGUI_API #define IMGUI_API #endif #ifndef IMGUI_IMPL_API #define IMGUI_IMPL_API IMGUI_API #endif // Helper Macros #ifndef IM_ASSERT #include #define IM_ASSERT(_EXPR) assert(_EXPR) // You can override the default assert handler by editing imconfig.h #endif #if !defined(IMGUI_USE_STB_SPRINTF) && (defined(__clang__) || defined(__GNUC__)) #define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1))) // To apply printf-style warnings to our functions. #define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0))) #else #define IM_FMTARGS(FMT) #define IM_FMTLIST(FMT) #endif #define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*_ARR))) // Size of a static C-style array. Don't use on pointers! #define IM_UNUSED(_VAR) ((void)_VAR) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds. #if (__cplusplus >= 201100) #define IM_OFFSETOF(_TYPE,_MEMBER) offsetof(_TYPE, _MEMBER) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in C++11 #else #define IM_OFFSETOF(_TYPE,_MEMBER) ((size_t)&(((_TYPE*)0)->_MEMBER)) // Offset of _MEMBER within _TYPE. Old style macro. #endif #define IM_UNICODE_CODEPOINT_MAX 0xFFFF // Last Unicode code point supported by this build. #define IM_UNICODE_CODEPOINT_INVALID 0xFFFD // Standard invalid Unicode code point. // Warnings #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wold-style-cast" #if __has_warning("-Wzero-as-null-pointer-constant") #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" #endif #elif defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind #pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead #endif //----------------------------------------------------------------------------- // Forward declarations and basic types //----------------------------------------------------------------------------- struct ImDrawChannel; // Temporary storage to output draw commands out of order, used by ImDrawListSplitter and ImDrawList::ChannelsSplit() struct ImDrawCmd; // A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call, unless it is a callback) struct ImDrawData; // All draw command lists required to render the frame + pos/size coordinates to use for the projection matrix. struct ImDrawList; // A single draw command list (generally one per window, conceptually you may see this as a dynamic "mesh" builder) struct ImDrawListSharedData; // Data shared among multiple draw lists (typically owned by parent ImGui context, but you may create one yourself) struct ImDrawListSplitter; // Helper to split a draw list into different layers which can be drawn into out of order, then flattened back. struct ImDrawVert; // A single vertex (pos + uv + col = 20 bytes by default. Override layout with IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT) struct ImFont; // Runtime data for a single font within a parent ImFontAtlas struct ImFontAtlas; // Runtime data for multiple fonts, bake multiple fonts into a single texture, TTF/OTF font loader struct ImFontConfig; // Configuration data when adding a font or merging fonts struct ImFontGlyph; // A single font glyph (code point + coordinates within in ImFontAtlas + offset) struct ImFontGlyphRangesBuilder; // Helper to build glyph ranges from text/string data struct ImColor; // Helper functions to create a color that can be converted to either u32 or float4 (*OBSOLETE* please avoid using) struct ImGuiContext; // Dear ImGui context (opaque structure, unless including imgui_internal.h) struct ImGuiIO; // Main configuration and I/O between your application and ImGui struct ImGuiInputTextCallbackData; // Shared state of InputText() when using custom ImGuiInputTextCallback (rare/advanced use) struct ImGuiListClipper; // Helper to manually clip large list of items struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame, used by IMGUI_ONCE_UPON_A_FRAME macro struct ImGuiPayload; // User data payload for drag and drop operations struct ImGuiSizeCallbackData; // Callback data when using SetNextWindowSizeConstraints() (rare/advanced use) struct ImGuiStorage; // Helper for key->value storage struct ImGuiStyle; // Runtime data for styling/colors struct ImGuiTextBuffer; // Helper to hold and append into a text buffer (~string builder) struct ImGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbb][,ccccc]") // Typedefs and Enums/Flags (declared as int for compatibility with old C++, to allow using as flags and to not pollute the top of this file) // Use your programming IDE "Go to definition" facility on the names in the central column below to find the actual flags/enum lists. #ifndef ImTextureID typedef void* ImTextureID; // User data to identify a texture (this is whatever to you want it to be! read the FAQ about ImTextureID in imgui.cpp) #endif typedef unsigned int ImGuiID; // Unique ID used by widgets (typically hashed from a stack of string) typedef unsigned short ImWchar; // A single U16 character for keyboard input/display. We encode them as multi bytes UTF-8 when used in strings. typedef int ImGuiCol; // -> enum ImGuiCol_ // Enum: A color identifier for styling typedef int ImGuiCond; // -> enum ImGuiCond_ // Enum: A condition for many Set*() functions typedef int ImGuiDataType; // -> enum ImGuiDataType_ // Enum: A primary data type typedef int ImGuiDir; // -> enum ImGuiDir_ // Enum: A cardinal direction typedef int ImGuiKey; // -> enum ImGuiKey_ // Enum: A key identifier (ImGui-side enum) typedef int ImGuiNavInput; // -> enum ImGuiNavInput_ // Enum: An input identifier for navigation typedef int ImGuiMouseButton; // -> enum ImGuiMouseButton_ // Enum: A mouse button identifier (0=left, 1=right, 2=middle) typedef int ImGuiMouseCursor; // -> enum ImGuiMouseCursor_ // Enum: A mouse cursor identifier typedef int ImGuiStyleVar; // -> enum ImGuiStyleVar_ // Enum: A variable identifier for styling typedef int ImDrawCornerFlags; // -> enum ImDrawCornerFlags_ // Flags: for ImDrawList::AddRect(), AddRectFilled() etc. typedef int ImDrawListFlags; // -> enum ImDrawListFlags_ // Flags: for ImDrawList typedef int ImFontAtlasFlags; // -> enum ImFontAtlasFlags_ // Flags: for ImFontAtlas typedef int ImGuiBackendFlags; // -> enum ImGuiBackendFlags_ // Flags: for io.BackendFlags typedef int ImGuiColorEditFlags; // -> enum ImGuiColorEditFlags_ // Flags: for ColorEdit4(), ColorPicker4() etc. typedef int ImGuiConfigFlags; // -> enum ImGuiConfigFlags_ // Flags: for io.ConfigFlags typedef int ImGuiComboFlags; // -> enum ImGuiComboFlags_ // Flags: for BeginCombo() typedef int ImGuiDragDropFlags; // -> enum ImGuiDragDropFlags_ // Flags: for BeginDragDropSource(), AcceptDragDropPayload() typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: for IsWindowFocused() typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc. typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline() typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable() typedef int ImGuiTabBarFlags; // -> enum ImGuiTabBarFlags_ // Flags: for BeginTabBar() typedef int ImGuiTabItemFlags; // -> enum ImGuiTabItemFlags_ // Flags: for BeginTabItem() typedef int ImGuiTreeNodeFlags; // -> enum ImGuiTreeNodeFlags_ // Flags: for TreeNode(), TreeNodeEx(), CollapsingHeader() typedef int ImGuiWindowFlags; // -> enum ImGuiWindowFlags_ // Flags: for Begin(), BeginChild() typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData *data); typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data); // Scalar data types typedef signed char ImS8; // 8-bit signed integer typedef unsigned char ImU8; // 8-bit unsigned integer typedef signed short ImS16; // 16-bit signed integer typedef unsigned short ImU16; // 16-bit unsigned integer typedef signed int ImS32; // 32-bit signed integer == int typedef unsigned int ImU32; // 32-bit unsigned integer (often used to store packed colors) #if defined(_MSC_VER) && !defined(__clang__) typedef signed __int64 ImS64; // 64-bit signed integer (pre and post C++11 with Visual Studio) typedef unsigned __int64 ImU64; // 64-bit unsigned integer (pre and post C++11 with Visual Studio) #elif (defined(__clang__) || defined(__GNUC__)) && (__cplusplus < 201100) #include typedef int64_t ImS64; // 64-bit signed integer (pre C++11) typedef uint64_t ImU64; // 64-bit unsigned integer (pre C++11) #else typedef signed long long ImS64; // 64-bit signed integer (post C++11) typedef unsigned long long ImU64; // 64-bit unsigned integer (post C++11) #endif // 2D vector (often used to store positions, sizes, etc.) struct ImVec2 { float x, y; ImVec2() { x = y = 0.0f; } ImVec2(float _x, float _y) { x = _x; y = _y; } float operator[] (size_t idx) const { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine. float& operator[] (size_t idx) { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine. #ifdef IM_VEC2_CLASS_EXTRA IM_VEC2_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec2. #endif }; // 4D vector (often used to store floating-point colors) struct ImVec4 { float x, y, z, w; ImVec4() { x = y = z = w = 0.0f; } ImVec4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; } #ifdef IM_VEC4_CLASS_EXTRA IM_VEC4_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec4. #endif }; //----------------------------------------------------------------------------- // ImGui: Dear ImGui end-user API // (Inside a namespace so you can add extra functions in your own separate file. Please don't modify imgui source files!) //----------------------------------------------------------------------------- namespace ImGui { // Context creation and access // Each context create its own ImFontAtlas by default. You may instance one yourself and pass it to CreateContext() to share a font atlas between imgui contexts. // None of those functions is reliant on the current context. IMGUI_API ImGuiContext* CreateContext(ImFontAtlas* shared_font_atlas = NULL); IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = destroy current context IMGUI_API ImGuiContext* GetCurrentContext(); IMGUI_API void SetCurrentContext(ImGuiContext* ctx); IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert, size_t sz_drawidx); // Main IMGUI_API ImGuiIO& GetIO(); // access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags) IMGUI_API ImGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame. IMGUI_API void NewFrame(); // start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame(). IMGUI_API void EndFrame(); // ends the Dear ImGui frame. automatically called by Render(), you likely don't need to call that yourself directly. If you don't need to render data (skipping rendering) you may call EndFrame() but you'll have wasted CPU already! If you don't need to render, better to not create any imgui windows and not call NewFrame() at all! IMGUI_API void Render(); // ends the Dear ImGui frame, finalize the draw data. You can get call GetDrawData() to obtain it and run your rendering function. (Obsolete: this used to call io.RenderDrawListsFn(). Nowadays, we allow and prefer calling your render function yourself.) IMGUI_API ImDrawData* GetDrawData(); // valid after Render() and until the next call to NewFrame(). this is what you have to render. // Demo, Debug, Information IMGUI_API void ShowDemoWindow(bool* p_open = NULL); // create Demo window (previously called ShowTestWindow). demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application! IMGUI_API void ShowAboutWindow(bool* p_open = NULL); // create About window. display Dear ImGui version, credits and build/system information. IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create Metrics/Debug window. display Dear ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc. IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style) IMGUI_API bool ShowStyleSelector(const char* label); // add style selector block (not a window), essentially a combo listing the default styles. IMGUI_API void ShowFontSelector(const char* label); // add font selector block (not a window), essentially a combo listing the loaded fonts. IMGUI_API void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls). IMGUI_API const char* GetVersion(); // get the compiled version string e.g. "1.23" (essentially the compiled value for IMGUI_VERSION) // Styles IMGUI_API void StyleColorsDark(ImGuiStyle* dst = NULL); // new, recommended style (default) IMGUI_API void StyleColorsClassic(ImGuiStyle* dst = NULL); // classic imgui style IMGUI_API void StyleColorsLight(ImGuiStyle* dst = NULL); // best used with borders and a custom, thicker font // Windows // - Begin() = push window to the stack and start appending to it. End() = pop window from the stack. // - You may append multiple times to the same window during the same frame. // - Passing 'bool* p_open != NULL' shows a window-closing widget in the upper-right corner of the window, // which clicking will set the boolean to false when clicked. // - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting // anything to the window. Always call a matching End() for each Begin() call, regardless of its return value! // [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu, // BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function // returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.] // - Note that the bottom of window stack always contains a window called "Debug". IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); IMGUI_API void End(); // Child Windows // - Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window. Child windows can embed their own child. // - For each independent axis of 'size': ==0.0f: use remaining host window size / >0.0f: fixed size / <0.0f: use remaining window size minus abs(size) / Each axis can use a different mode, e.g. ImVec2(0,400). // - BeginChild() returns false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window. // Always call a matching EndChild() for each BeginChild() call, regardless of its return value [as with Begin: this is due to legacy reason and inconsistent with most BeginXXX functions apart from the regular Begin() which behaves like BeginChild().] IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags flags = 0); IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags flags = 0); IMGUI_API void EndChild(); // Windows Utilities // - 'current window' = the window we are appending into while inside a Begin()/End() block. 'next window' = next window we will Begin() into. IMGUI_API bool IsWindowAppearing(); IMGUI_API bool IsWindowCollapsed(); IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0); // is current window focused? or its root/child, depending on flags. see flags for options. IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags=0); // is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. NB: If you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that! Please read the FAQ! IMGUI_API ImDrawList* GetWindowDrawList(); // get draw list associated to the current window, to append your own drawing primitives IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList API) IMGUI_API ImVec2 GetWindowSize(); // get current window size IMGUI_API float GetWindowWidth(); // get current window width (shortcut for GetWindowSize().x) IMGUI_API float GetWindowHeight(); // get current window height (shortcut for GetWindowSize().y) // Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin). IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0,0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc. IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin() IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Sizes will be rounded down. Use callback to apply non-trivial programmatic constraints. IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ scrollable client area, which enforce the range of scrollbars). Not including window decorations (title bar, menu bar, etc.) nor WindowPadding. set an axis to 0.0f to leave it automatic. call before Begin() IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // set next window collapsed state. call before Begin() IMGUI_API void SetNextWindowFocus(); // set next window to be focused / top-most. call before Begin() IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground. IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects. IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects. IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed(). IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / top-most. prefer using SetNextWindowFocus(). IMGUI_API void SetWindowFontScale(float scale); // set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes(). IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond = 0); // set named window position. IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis. IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / top-most. use NULL to remove focus. // Content region // - Those functions are bound to be redesigned soon (they are confusing, incomplete and return values in local window coordinates which increases confusion) IMGUI_API ImVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos() IMGUI_API ImVec2 GetWindowContentRegionMin(); // content boundaries min (roughly (0,0)-Scroll), in window coordinates IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates IMGUI_API float GetWindowContentRegionWidth(); // // Windows Scrolling IMGUI_API float GetScrollX(); // get scrolling amount [0..GetScrollMaxX()] IMGUI_API float GetScrollY(); // get scrolling amount [0..GetScrollMaxY()] IMGUI_API float GetScrollMaxX(); // get maximum scrolling amount ~~ ContentSize.X - WindowSize.X IMGUI_API float GetScrollMaxY(); // get maximum scrolling amount ~~ ContentSize.Y - WindowSize.Y IMGUI_API void SetScrollX(float scroll_x); // set scrolling amount [0..GetScrollMaxX()] IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()] IMGUI_API void SetScrollHereX(float center_x_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_x_ratio=0.0: left, 0.5: center, 1.0: right. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead. IMGUI_API void SetScrollHereY(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead. IMGUI_API void SetScrollFromPosX(float local_x, float center_x_ratio = 0.5f); // adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position. IMGUI_API void SetScrollFromPosY(float local_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position. // Parameters stacks (shared) IMGUI_API void PushFont(ImFont* font); // use NULL as a shortcut to push default font IMGUI_API void PopFont(); IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col); IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4& col); IMGUI_API void PopStyleColor(int count = 1); IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val); IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val); IMGUI_API void PopStyleVar(int count = 1); IMGUI_API const ImVec4& GetStyleColorVec4(ImGuiCol idx); // retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), otherwise use GetColorU32() to get style color with style alpha baked in. IMGUI_API ImFont* GetFont(); // get current font IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f); // retrieve given style color with style alpha applied and optional extra alpha multiplier IMGUI_API ImU32 GetColorU32(const ImVec4& col); // retrieve given color with style alpha applied IMGUI_API ImU32 GetColorU32(ImU32 col); // retrieve given color with style alpha applied // Parameters stacks (current window) IMGUI_API void PushItemWidth(float item_width); // set width of items for common large "item+label" widgets. >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -1.0f always align width to the right side). 0.0f = default to ~2/3 of windows width, IMGUI_API void PopItemWidth(); IMGUI_API void SetNextItemWidth(float item_width); // set width of the _next_ common large "item+label" widget. >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -1.0f always align width to the right side) IMGUI_API float CalcItemWidth(); // width of item given pushed settings and current cursor position. NOT necessarily the width of last item unlike most 'Item' functions. IMGUI_API void PushTextWrapPos(float wrap_local_pos_x = 0.0f); // word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space IMGUI_API void PopTextWrapPos(); IMGUI_API void PushAllowKeyboardFocus(bool allow_keyboard_focus); // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets IMGUI_API void PopAllowKeyboardFocus(); IMGUI_API void PushButtonRepeat(bool repeat); // in 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame. IMGUI_API void PopButtonRepeat(); // Cursor / Layout // - By "cursor" we mean the current output position. // - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down. // - You can call SameLine() between widgets to undo the last carriage return and output at the right of the preceeding widget. IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator. IMGUI_API void SameLine(float offset_from_start_x=0.0f, float spacing=-1.0f); // call between widgets or groups to layout them horizontally. X position given in window coordinates. IMGUI_API void NewLine(); // undo a SameLine() or force a new line when in an horizontal-layout context. IMGUI_API void Spacing(); // add vertical spacing. IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size. unlike InvisibleButton(), Dummy() won't take the mouse click or be navigable into. IMGUI_API void Indent(float indent_w = 0.0f); // move content position toward the right, by style.IndentSpacing or indent_w if != 0 IMGUI_API void Unindent(float indent_w = 0.0f); // move content position back to the left, by style.IndentSpacing or indent_w if != 0 IMGUI_API void BeginGroup(); // lock horizontal starting position IMGUI_API void EndGroup(); // unlock horizontal starting position + capture the whole group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.) IMGUI_API ImVec2 GetCursorPos(); // cursor position in window coordinates (relative to window position) IMGUI_API float GetCursorPosX(); // (some functions are using window-relative coordinates, such as: GetCursorPos, GetCursorStartPos, GetContentRegionMax, GetWindowContentRegion* etc. IMGUI_API float GetCursorPosY(); // other functions such as GetCursorScreenPos or everything in ImDrawList:: IMGUI_API void SetCursorPos(const ImVec2& local_pos); // are using the main, absolute coordinate system. IMGUI_API void SetCursorPosX(float local_x); // GetWindowPos() + GetCursorPos() == GetCursorScreenPos() etc.) IMGUI_API void SetCursorPosY(float local_y); // IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position in window coordinates IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API) IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize] IMGUI_API void AlignTextToFramePadding(); // vertically align upcoming text baseline to FramePadding.y so that it will align properly to regularly framed items (call if you have text on a line before a framed item) IMGUI_API float GetTextLineHeight(); // ~ FontSize IMGUI_API float GetTextLineHeightWithSpacing(); // ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text) IMGUI_API float GetFrameHeight(); // ~ FontSize + style.FramePadding.y * 2 IMGUI_API float GetFrameHeightWithSpacing(); // ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets) // ID stack/scopes // - Read the FAQ for more details about how ID are handled in dear imgui. If you are creating widgets in a loop you most // likely want to push a unique identifier (e.g. object pointer, loop index) to uniquely differentiate them. // - The resulting ID are hashes of the entire stack. // - You can also use the "Label##foobar" syntax within widget label to distinguish them from each others. // - In this header file we use the "label"/"name" terminology to denote a string that will be displayed and used as an ID, // whereas "str_id" denote a string that is only used as an ID and not normally displayed. IMGUI_API void PushID(const char* str_id); // push string into the ID stack (will hash string). IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end); // push string into the ID stack (will hash string). IMGUI_API void PushID(const void* ptr_id); // push pointer into the ID stack (will hash pointer). IMGUI_API void PushID(int int_id); // push integer into the ID stack (will hash integer). IMGUI_API void PopID(); // pop from the ID stack. IMGUI_API ImGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself IMGUI_API ImGuiID GetID(const char* str_id_begin, const char* str_id_end); IMGUI_API ImGuiID GetID(const void* ptr_id); // Widgets: Text IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text. IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // formatted text IMGUI_API void TextV(const char* fmt, va_list args) IM_FMTLIST(1); IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor(); IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args) IM_FMTLIST(2); IMGUI_API void TextDisabled(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor(); IMGUI_API void TextDisabledV(const char* fmt, va_list args) IM_FMTLIST(1); IMGUI_API void TextWrapped(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize(). IMGUI_API void TextWrappedV(const char* fmt, va_list args) IM_FMTLIST(1); IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_FMTARGS(2); // display text+label aligned the same way as value+label widgets IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args) IM_FMTLIST(2); IMGUI_API void BulletText(const char* fmt, ...) IM_FMTARGS(1); // shortcut for Bullet()+Text() IMGUI_API void BulletTextV(const char* fmt, va_list args) IM_FMTLIST(1); // Widgets: Main // - Most widgets return true when the value has been changed or when pressed/selected // - You may also use one of the many IsItemXXX functions (e.g. IsItemActive, IsItemHovered, etc.) to query widget state. IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); // button IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size); // button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.) IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); // square button with an arrow shape IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0)); IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding IMGUI_API bool Checkbox(const char* label, bool* v); IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value); IMGUI_API bool RadioButton(const char* label, bool active); // use with e.g. if (RadioButton("one", my_value==1)) { my_value = 1; } IMGUI_API bool RadioButton(const char* label, int* v, int v_button); // shortcut to handle the above pattern when value is an integer IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-1,0), const char* overlay = NULL); IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses // Widgets: Combo Box // - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items. // - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0); IMGUI_API void EndCombo(); // only call EndCombo() if BeginCombo() returns true! IMGUI_API bool Combo(const char* label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items = -1); IMGUI_API bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); // Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0" IMGUI_API bool Combo(const char* label, int* current_item, bool(*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_max_height_in_items = -1); // Widgets: Drags // - CTRL+Click on any drag box to turn them into an input box. Manually input values aren't clamped and can go off-bounds. // - For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc. // - Speed are per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For gamepad/keyboard navigation, minimum speed is Max(v_speed, minimum_step_at_given_precision). // - Use v_min < v_max to clamp edits to given limits. Note that CTRL+Click manual input can override those limits. // - Use v_max = FLT_MAX / INT_MAX etc to avoid clamping to a maximum, same with v_min = -FLT_MAX / INT_MIN to avoid clamping to a minimum. // - Use v_min > v_max to lock edits. IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", float power = 1.0f); // If v_min >= v_max we have no bound IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", float power = 1.0f); IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", float power = 1.0f); IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", float power = 1.0f); IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", const char* format_max = NULL, float power = 1.0f); IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d"); // If v_min >= v_max we have no bound IMGUI_API bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d"); IMGUI_API bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d"); IMGUI_API bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d"); IMGUI_API bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", const char* format_max = NULL); IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, float power = 1.0f); IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, float power = 1.0f); // Widgets: Sliders // - CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped and can go off-bounds. // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc. IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); // adjust format to decorate the value with a prefix or a suffix for in-slider labels or unit display. Use power!=1.0 for power curve sliders IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); IMGUI_API bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); IMGUI_API bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f, const char* format = "%.0f deg"); IMGUI_API bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* format = "%d"); IMGUI_API bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format = "%d"); IMGUI_API bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format = "%d"); IMGUI_API bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format = "%d"); IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, float power = 1.0f); IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, const char* format = NULL, float power = 1.0f); IMGUI_API bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format = "%d"); IMGUI_API bool VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, float power = 1.0f); // Widgets: Input with Keyboard // - If you want to use InputText() with std::string or any custom dynamic string type, see misc/cpp/imgui_stdlib.h and comments in imgui_demo.cpp. // - Most of the ImGuiInputTextFlags flags are only useful for InputText() and not for InputFloatX, InputIntX, InputDouble etc. IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); IMGUI_API bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0,0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); IMGUI_API bool InputTextWithHint(const char* label, const char* hint, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); IMGUI_API bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", ImGuiInputTextFlags flags = 0); IMGUI_API bool InputFloat2(const char* label, float v[2], const char* format = "%.3f", ImGuiInputTextFlags flags = 0); IMGUI_API bool InputFloat3(const char* label, float v[3], const char* format = "%.3f", ImGuiInputTextFlags flags = 0); IMGUI_API bool InputFloat4(const char* label, float v[4], const char* format = "%.3f", ImGuiInputTextFlags flags = 0); IMGUI_API bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags flags = 0); IMGUI_API bool InputInt2(const char* label, int v[2], ImGuiInputTextFlags flags = 0); IMGUI_API bool InputInt3(const char* label, int v[3], ImGuiInputTextFlags flags = 0); IMGUI_API bool InputInt4(const char* label, int v[4], ImGuiInputTextFlags flags = 0); IMGUI_API bool InputDouble(const char* label, double* v, double step = 0.0, double step_fast = 0.0, const char* format = "%.6f", ImGuiInputTextFlags flags = 0); IMGUI_API bool InputScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_step = NULL, const void* p_step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags flags = 0); IMGUI_API bool InputScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_step = NULL, const void* p_step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags flags = 0); // Widgets: Color Editor/Picker (tip: the ColorEdit* functions have a little colored preview square that can be left-clicked to open a picker, and right-clicked to open an option menu.) // - Note that in C++ a 'float v[X]' function argument is the _same_ as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. // - You can pass the address of a first float element out of a contiguous structure, e.g. &myvector.x IMGUI_API bool ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags = 0); IMGUI_API bool ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0); IMGUI_API bool ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags = 0); IMGUI_API bool ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags = 0, const float* ref_col = NULL); IMGUI_API bool ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0)); // display a colored square/button, hover for details, return true when pressed. IMGUI_API void SetColorEditOptions(ImGuiColorEditFlags flags); // initialize current options (generally on application startup) if you want to select a default format, picker type, etc. User will be able to change many settings, unless you pass the _NoOptions flag to your calls. // Widgets: Trees // - TreeNode functions return true when the node is open, in which case you need to also call TreePop() when you are finished displaying the tree node contents. IMGUI_API bool TreeNode(const char* label); IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_FMTARGS(2); // helper variation to easily decorelate the id from the displayed string. Read the FAQ about why and how to use ID. to align arbitrary text at the same level as a TreeNode() you can use Bullet(). IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_FMTARGS(2); // " IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args) IM_FMTLIST(2); IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args) IM_FMTLIST(2); IMGUI_API bool TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags = 0); IMGUI_API bool TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3); IMGUI_API bool TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3); IMGUI_API bool TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3); IMGUI_API bool TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3); IMGUI_API void TreePush(const char* str_id); // ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call TreePush/TreePop yourself if desired. IMGUI_API void TreePush(const void* ptr_id = NULL); // " IMGUI_API void TreePop(); // ~ Unindent()+PopId() IMGUI_API float GetTreeNodeToLabelSpacing(); // horizontal distance preceding label when using TreeNode*() or Bullet() == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode IMGUI_API bool CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags = 0); // if returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop(). IMGUI_API bool CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags = 0); // when 'p_open' isn't NULL, display an additional small close button on upper right of the header IMGUI_API void SetNextItemOpen(bool is_open, ImGuiCond cond = 0); // set next TreeNode/CollapsingHeader open state. // Widgets: Selectables // - A selectable highlights when hovered, and can display another color when selected. // - Neighbors selectable extend their highlight bounds in order to leave no gap between them. This is so a series of selected Selectable appear contiguous. IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper. // Widgets: List Boxes // - FIXME: To be consistent with all the newer API, ListBoxHeader/ListBoxFooter should in reality be called BeginListBox/EndListBox. Will rename them. IMGUI_API bool ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items = -1); IMGUI_API bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1); IMGUI_API bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0,0)); // use if you want to reimplement ListBox() will custom data or interactions. if the function return true, you can output elements then call ListBoxFooter() afterwards. IMGUI_API bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // " IMGUI_API void ListBoxFooter(); // terminate the scrolling region. only call ListBoxFooter() if ListBoxHeader() returned true! // Widgets: Data Plotting IMGUI_API void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float)); IMGUI_API void PlotLines(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0)); IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float)); IMGUI_API void PlotHistogram(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0)); // Widgets: Value() Helpers. // - Those are merely shortcut to calling Text() with a format string. Output single value in "name: value" format (tip: freely declare more in your code to handle your types. you can add functions to the ImGui namespace) IMGUI_API void Value(const char* prefix, bool b); IMGUI_API void Value(const char* prefix, int v); IMGUI_API void Value(const char* prefix, unsigned int v); IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL); // Widgets: Menus // - Use BeginMenuBar() on a window ImGuiWindowFlags_MenuBar to append to its menu bar. // - Use BeginMainMenuBar() to create a menu bar at the top of the screen. IMGUI_API bool BeginMenuBar(); // append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window). IMGUI_API void EndMenuBar(); // only call EndMenuBar() if BeginMenuBar() returns true! IMGUI_API bool BeginMainMenuBar(); // create and append to a full screen menu-bar. IMGUI_API void EndMainMenuBar(); // only call EndMainMenuBar() if BeginMainMenuBar() returns true! IMGUI_API bool BeginMenu(const char* label, bool enabled = true); // create a sub-menu entry. only call EndMenu() if this returns true! IMGUI_API void EndMenu(); // only call EndMenu() if BeginMenu() returns true! IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL // Tooltips // - Tooltip are windows following the mouse which do not take focus away. IMGUI_API void BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of items). IMGUI_API void EndTooltip(); IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set a text-only tooltip, typically use with ImGui::IsItemHovered(). override any previous call to SetTooltip(). IMGUI_API void SetTooltipV(const char* fmt, va_list args) IM_FMTLIST(1); // Popups, Modals // The properties of popups windows are: // - They block normal mouse hovering detection outside them. (*) // - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE. // - Their visibility state (~bool) is held internally by imgui instead of being held by the programmer as we are used to with regular Begin() calls. // User can manipulate the visibility state by calling OpenPopup(). // - We default to use the right mouse (ImGuiMouseButton_Right=1) for the Popup Context functions. // (*) You can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even when normally blocked by a popup. // Those three properties are connected. The library needs to hold their visibility state because it can close popups at any time. IMGUI_API void OpenPopup(const char* str_id); // call to mark popup as open (don't call every frame!). popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. By default, Selectable()/MenuItem() are calling CloseCurrentPopup(). Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returns true! IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1); // helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp! IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1, bool also_over_items = true); // helper to open and begin popup when clicked on current window. IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1); // helper to open and begin popup when clicked in void (where there are no imgui windows). IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // modal dialog (regular window with title bar, block interactions behind the modal window, can't close the modal window by clicking outside) IMGUI_API void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true! IMGUI_API bool OpenPopupOnItemClick(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1); // helper to open popup when clicked on last item (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors). return true when just opened. IMGUI_API bool IsPopupOpen(const char* str_id); // return true if the popup is open at the current begin-ed level of the popup stack. IMGUI_API void CloseCurrentPopup(); // close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup. // Columns // - You can also use SameLine(pos_x) to mimic simplified columns. // - The columns API is work-in-progress and rather lacking (columns are arguably the worst part of dear imgui at the moment!) // - There is a maximum of 64 columns. // - Currently working on new 'Tables' api which will replace columns (see GitHub #2957) IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true); IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished IMGUI_API int GetColumnIndex(); // get current column index IMGUI_API float GetColumnWidth(int column_index = -1); // get column width (in pixels). pass -1 to use current column IMGUI_API void SetColumnWidth(int column_index, float width); // set column width (in pixels). pass -1 to use current column IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetColumnsCount() inclusive. column 0 is typically 0.0f IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column IMGUI_API int GetColumnsCount(); // Tab Bars, Tabs IMGUI_API bool BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0); // create and append into a TabBar IMGUI_API void EndTabBar(); // only call EndTabBar() if BeginTabBar() returns true! IMGUI_API bool BeginTabItem(const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0);// create a Tab. Returns true if the Tab is selected. IMGUI_API void EndTabItem(); // only call EndTabItem() if BeginTabItem() returns true! IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name. // Logging/Capture // - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging. IMGUI_API void LogToTTY(int auto_open_depth = -1); // start logging to tty (stdout) IMGUI_API void LogToFile(int auto_open_depth = -1, const char* filename = NULL); // start logging to file IMGUI_API void LogToClipboard(int auto_open_depth = -1); // start logging to OS clipboard IMGUI_API void LogFinish(); // stop logging (close file, etc.) IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard IMGUI_API void LogText(const char* fmt, ...) IM_FMTARGS(1); // pass text data straight to log (without being displayed) // Drag and Drop // [BETA API] API may evolve! IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0); // call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource() IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t sz, ImGuiCond cond = 0); // type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui. IMGUI_API void EndDragDropSource(); // only call EndDragDropSource() if BeginDragDropSource() returns true! IMGUI_API bool BeginDragDropTarget(); // call after submitting an item that may receive a payload. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget() IMGUI_API const ImGuiPayload* AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags = 0); // accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released. IMGUI_API void EndDragDropTarget(); // only call EndDragDropTarget() if BeginDragDropTarget() returns true! IMGUI_API const ImGuiPayload* GetDragDropPayload(); // peek directly into the current payload from anywhere. may return NULL. use ImGuiPayload::IsDataType() to test for the payload type. // Clipping IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect); IMGUI_API void PopClipRect(); // Focus, Activation // - Prefer using "SetItemDefaultFocus()" over "if (IsWindowAppearing()) SetScrollHereY()" when applicable to signify "this is the default item" IMGUI_API void SetItemDefaultFocus(); // make last item the default focused item of a window. IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use -1 to access previous widget. // Item/Widgets Utilities // - Most of the functions are referring to the last/previous item we submitted. // - See Demo Window under "Widgets->Querying Status" for an interactive visualization of most of those functions. IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags = 0); // is the last item hovered? (and usable, aka not blocked by a popup, etc.). See ImGuiHoveredFlags for more options. IMGUI_API bool IsItemActive(); // is the last item active? (e.g. button being held, text field being edited. This will continuously return true while holding mouse button on an item. Items that don't interact will always return false) IMGUI_API bool IsItemFocused(); // is the last item focused for keyboard/gamepad navigation? IMGUI_API bool IsItemClicked(ImGuiMouseButton mouse_button = 0); // is the last item clicked? (e.g. button/node just clicked on) == IsMouseClicked(mouse_button) && IsItemHovered() IMGUI_API bool IsItemVisible(); // is the last item visible? (items may be out of sight because of clipping/scrolling) IMGUI_API bool IsItemEdited(); // did the last item modify its underlying value this frame? or was pressed? This is generally the same as the "bool" return value of many widgets. IMGUI_API bool IsItemActivated(); // was the last item just made active (item was previously inactive). IMGUI_API bool IsItemDeactivated(); // was the last item just made inactive (item was previously active). Useful for Undo/Redo patterns with widgets that requires continuous editing. IMGUI_API bool IsItemDeactivatedAfterEdit(); // was the last item just made inactive and made a value change when it was active? (e.g. Slider/Drag moved). Useful for Undo/Redo patterns with widgets that requires continuous editing. Note that you may get false positives (some widgets such as Combo()/ListBox()/Selectable() will return true even when clicking an already selected item). IMGUI_API bool IsItemToggledOpen(); // was the last item open state toggled? set by TreeNode(). IMGUI_API bool IsAnyItemHovered(); // is any item hovered? IMGUI_API bool IsAnyItemActive(); // is any item active? IMGUI_API bool IsAnyItemFocused(); // is any item focused? IMGUI_API ImVec2 GetItemRectMin(); // get upper-left bounding rectangle of the last item (screen space) IMGUI_API ImVec2 GetItemRectMax(); // get lower-right bounding rectangle of the last item (screen space) IMGUI_API ImVec2 GetItemRectSize(); // get size of last item IMGUI_API void SetItemAllowOverlap(); // allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area. // Miscellaneous Utilities IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped. IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side. IMGUI_API double GetTime(); // get global imgui time. incremented by io.DeltaTime every frame. IMGUI_API int GetFrameCount(); // get global imgui frame count. incremented by 1 every frame. IMGUI_API ImDrawList* GetBackgroundDrawList(); // this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents. IMGUI_API ImDrawList* GetForegroundDrawList(); // this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents. IMGUI_API ImDrawListSharedData* GetDrawListSharedData(); // you may use this when creating your own ImDrawList instances. IMGUI_API const char* GetStyleColorName(ImGuiCol idx); // get a string corresponding to the enum value (for display, saving, etc.). IMGUI_API void SetStateStorage(ImGuiStorage* storage); // replace current window storage with our own (if you want to manipulate it yourself, typically clear subsection of it) IMGUI_API ImGuiStorage* GetStateStorage(); IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f); IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can. IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags flags = 0); // helper to create a child window / scrolling region that looks like a normal widget frame IMGUI_API void EndChildFrame(); // always call EndChildFrame() regardless of BeginChildFrame() return values (which indicates a collapsed/clipped window) // Color Utilities IMGUI_API ImVec4 ColorConvertU32ToFloat4(ImU32 in); IMGUI_API ImU32 ColorConvertFloat4ToU32(const ImVec4& in); IMGUI_API void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v); IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b); // Inputs Utilities: Keyboard // - For 'int user_key_index' you can use your own indices/enums according to how your backend/engine stored them in io.KeysDown[]. // - We don't know the meaning of those value. You can use GetKeyIndex() to map a ImGuiKey_ value into the user index. IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key] IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index]. IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat = true); // was key pressed (went from !Down to Down)? if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate IMGUI_API bool IsKeyReleased(int user_key_index); // was key released (went from Down to !Down)? IMGUI_API int GetKeyPressedAmount(int key_index, float repeat_delay, float rate); // uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate IMGUI_API void CaptureKeyboardFromApp(bool want_capture_keyboard_value = true); // attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard_value"; after the next NewFrame() call. // Inputs Utilities: Mouse // - To refer to a mouse button, you may use named enums in your code e.g. ImGuiMouseButton_Left, ImGuiMouseButton_Right. // - You can also use regular integer: it is forever guaranteed that 0=Left, 1=Right, 2=Middle. // - Dragging operations are only reported after mouse has moved a certain distance away from the initial clicking position (see 'lock_threshold' and 'io.MouseDraggingThreshold') IMGUI_API bool IsMouseDown(ImGuiMouseButton button); // is mouse button held? IMGUI_API bool IsMouseClicked(ImGuiMouseButton button, bool repeat = false); // did mouse button clicked? (went from !Down to Down) IMGUI_API bool IsMouseReleased(ImGuiMouseButton button); // did mouse button released? (went from Down to !Down) IMGUI_API bool IsMouseDoubleClicked(ImGuiMouseButton button); // did mouse button double-clicked? a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime. IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true);// is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block. IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // by convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse available IMGUI_API bool IsAnyMouseDown(); // is any mouse button held? IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve mouse position at the time of opening popup we have BeginPopup() into (helper to avoid user backing that value themselves) IMGUI_API bool IsMouseDragging(ImGuiMouseButton button, float lock_threshold = -1.0f); // is mouse dragging? (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold) IMGUI_API ImVec2 GetMouseDragDelta(ImGuiMouseButton button = 0, float lock_threshold = -1.0f); // return the delta from the initial clicking position while the mouse button is pressed or was just released. This is locked and return 0.0f until the mouse moves past a distance threshold at least once (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold) IMGUI_API void ResetMouseDragDelta(ImGuiMouseButton button = 0); // IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired cursor type, reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you IMGUI_API void SetMouseCursor(ImGuiMouseCursor cursor_type); // set desired cursor type IMGUI_API void CaptureMouseFromApp(bool want_capture_mouse_value = true); // attention: misleading name! manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application to handle). This is equivalent to setting "io.WantCaptureMouse = want_capture_mouse_value;" after the next NewFrame() call. // Clipboard Utilities (also see the LogToClipboard() function to capture or output text data to the clipboard) IMGUI_API const char* GetClipboardText(); IMGUI_API void SetClipboardText(const char* text); // Settings/.Ini Utilities // - The disk functions are automatically called if io.IniFilename != NULL (default is "imgui.ini"). // - Set io.IniFilename to NULL to load/save manually. Read io.WantSaveIniSettings description about handling .ini saving manually. IMGUI_API void LoadIniSettingsFromDisk(const char* ini_filename); // call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename). IMGUI_API void LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size=0); // call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source. IMGUI_API void SaveIniSettingsToDisk(const char* ini_filename); // this is automatically called (if io.IniFilename is not empty) a few seconds after any modification that should be reflected in the .ini file (and also by DestroyContext). IMGUI_API const char* SaveIniSettingsToMemory(size_t* out_ini_size = NULL); // return a zero-terminated string with the .ini data which you can save by your own mean. call when io.WantSaveIniSettings is set, then save data by your own mean and clear io.WantSaveIniSettings. // Memory Allocators // - All those functions are not reliant on the current context. // - If you reload the contents of imgui.cpp at runtime, you may need to call SetCurrentContext() + SetAllocatorFunctions() again because we use global storage for those. IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data = NULL); IMGUI_API void* MemAlloc(size_t size); IMGUI_API void MemFree(void* ptr); } // namespace ImGui //----------------------------------------------------------------------------- // Flags & Enumerations //----------------------------------------------------------------------------- // Flags for ImGui::Begin() enum ImGuiWindowFlags_ { ImGuiWindowFlags_None = 0, ImGuiWindowFlags_NoTitleBar = 1 << 0, // Disable title-bar ImGuiWindowFlags_NoResize = 1 << 1, // Disable user resizing with the lower-right grip ImGuiWindowFlags_NoMove = 1 << 2, // Disable user moving the window ImGuiWindowFlags_NoScrollbar = 1 << 3, // Disable scrollbars (window can still scroll with mouse or programmatically) ImGuiWindowFlags_NoScrollWithMouse = 1 << 4, // Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will be forwarded to the parent unless NoScrollbar is also set. ImGuiWindowFlags_NoCollapse = 1 << 5, // Disable user collapsing window by double-clicking on it ImGuiWindowFlags_AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame ImGuiWindowFlags_NoBackground = 1 << 7, // Disable drawing background color (WindowBg, etc.) and outside border. Similar as using SetNextWindowBgAlpha(0.0f). ImGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file ImGuiWindowFlags_NoMouseInputs = 1 << 9, // Disable catching mouse, hovering test with pass through. ImGuiWindowFlags_MenuBar = 1 << 10, // Has a menu-bar ImGuiWindowFlags_HorizontalScrollbar = 1 << 11, // Allow horizontal scrollbar to appear (off by default). You may use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section. ImGuiWindowFlags_NoFocusOnAppearing = 1 << 12, // Disable taking focus when transitioning from hidden to visible state ImGuiWindowFlags_NoBringToFrontOnFocus = 1 << 13, // Disable bringing window to front when taking focus (e.g. clicking on it or programmatically giving it focus) ImGuiWindowFlags_AlwaysVerticalScrollbar= 1 << 14, // Always show vertical scrollbar (even if ContentSize.y < Size.y) ImGuiWindowFlags_AlwaysHorizontalScrollbar=1<< 15, // Always show horizontal scrollbar (even if ContentSize.x < Size.x) ImGuiWindowFlags_AlwaysUseWindowPadding = 1 << 16, // Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient) ImGuiWindowFlags_NoNavInputs = 1 << 18, // No gamepad/keyboard navigation within the window ImGuiWindowFlags_NoNavFocus = 1 << 19, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB) ImGuiWindowFlags_UnsavedDocument = 1 << 20, // Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. When used in a tab/docking context, tab is selected on closure and closure is deferred by one frame to allow code to cancel the closure (with a confirmation popup, etc.) without flicker. ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus, ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse, ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus, // [Internal] ImGuiWindowFlags_NavFlattened = 1 << 23, // [BETA] Allow gamepad/keyboard navigation to cross over parent border to this child (only use on child that have no scrolling!) ImGuiWindowFlags_ChildWindow = 1 << 24, // Don't use! For internal use by BeginChild() ImGuiWindowFlags_Tooltip = 1 << 25, // Don't use! For internal use by BeginTooltip() ImGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup() ImGuiWindowFlags_Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal() ImGuiWindowFlags_ChildMenu = 1 << 28 // Don't use! For internal use by BeginMenu() // [Obsolete] //ImGuiWindowFlags_ShowBorders = 1 << 7, // --> Set style.FrameBorderSize=1.0f or style.WindowBorderSize=1.0f to enable borders around items or windows. //ImGuiWindowFlags_ResizeFromAnySide = 1 << 17, // --> Set io.ConfigWindowsResizeFromEdges=true and make sure mouse cursors are supported by back-end (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) }; // Flags for ImGui::InputText() enum ImGuiInputTextFlags_ { ImGuiInputTextFlags_None = 0, ImGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/ ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef ImGuiInputTextFlags_CharsUppercase = 1 << 2, // Turn a..z into A..Z ImGuiInputTextFlags_CharsNoBlank = 1 << 3, // Filter out spaces, tabs ImGuiInputTextFlags_AutoSelectAll = 1 << 4, // Select entire text when first taking mouse focus ImGuiInputTextFlags_EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to every time the value was modified). Consider looking at the IsItemDeactivatedAfterEdit() function. ImGuiInputTextFlags_CallbackCompletion = 1 << 6, // Callback on pressing TAB (for completion handling) ImGuiInputTextFlags_CallbackHistory = 1 << 7, // Callback on pressing Up/Down arrows (for history handling) ImGuiInputTextFlags_CallbackAlways = 1 << 8, // Callback on each iteration. User code may query cursor position, modify text buffer. ImGuiInputTextFlags_CallbackCharFilter = 1 << 9, // Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard. ImGuiInputTextFlags_AllowTabInput = 1 << 10, // Pressing TAB input a '\t' character into the text field ImGuiInputTextFlags_CtrlEnterForNewLine = 1 << 11, // In multi-line mode, unfocus with Enter, add new line with Ctrl+Enter (default is opposite: unfocus with Ctrl+Enter, add line with Enter). ImGuiInputTextFlags_NoHorizontalScroll = 1 << 12, // Disable following the cursor horizontally ImGuiInputTextFlags_AlwaysInsertMode = 1 << 13, // Insert mode ImGuiInputTextFlags_ReadOnly = 1 << 14, // Read-only mode ImGuiInputTextFlags_Password = 1 << 15, // Password mode, display all characters as '*' ImGuiInputTextFlags_NoUndoRedo = 1 << 16, // Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID(). ImGuiInputTextFlags_CharsScientific = 1 << 17, // Allow 0123456789.+-*/eE (Scientific notation input) ImGuiInputTextFlags_CallbackResize = 1 << 18, // Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this) // [Internal] ImGuiInputTextFlags_Multiline = 1 << 20, // For internal use by InputTextMultiline() ImGuiInputTextFlags_NoMarkEdited = 1 << 21 // For internal use by functions using InputText() before reformatting data }; // Flags for ImGui::TreeNodeEx(), ImGui::CollapsingHeader*() enum ImGuiTreeNodeFlags_ { ImGuiTreeNodeFlags_None = 0, ImGuiTreeNodeFlags_Selected = 1 << 0, // Draw as selected ImGuiTreeNodeFlags_Framed = 1 << 1, // Full colored frame (e.g. for CollapsingHeader) ImGuiTreeNodeFlags_AllowItemOverlap = 1 << 2, // Hit testing to allow subsequent widgets to overlap this one ImGuiTreeNodeFlags_NoTreePushOnOpen = 1 << 3, // Don't do a TreePush() when open (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack ImGuiTreeNodeFlags_NoAutoOpenOnLog = 1 << 4, // Don't automatically and temporarily open node when Logging is active (by default logging will automatically open tree nodes) ImGuiTreeNodeFlags_DefaultOpen = 1 << 5, // Default node to be open ImGuiTreeNodeFlags_OpenOnDoubleClick = 1 << 6, // Need double-click to open node ImGuiTreeNodeFlags_OpenOnArrow = 1 << 7, // Only open when clicking on the arrow part. If ImGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open. ImGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes). ImGuiTreeNodeFlags_Bullet = 1 << 9, // Display a bullet instead of arrow ImGuiTreeNodeFlags_FramePadding = 1 << 10, // Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding(). ImGuiTreeNodeFlags_SpanAvailWidth = 1 << 11, // Extend hit box to the right-most edge, even if not framed. This is not the default in order to allow adding other items on the same line. In the future we may refactor the hit system to be front-to-back, allowing natural overlaps and then this can become the default. ImGuiTreeNodeFlags_SpanFullWidth = 1 << 12, // Extend hit box to the left-most and right-most edges (bypass the indented area). ImGuiTreeNodeFlags_NavLeftJumpsBackHere = 1 << 13, // (WIP) Nav: left direction may move to this TreeNode() from any of its child (items submitted between TreeNode and TreePop) //ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 14, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog }; // Flags for ImGui::Selectable() enum ImGuiSelectableFlags_ { ImGuiSelectableFlags_None = 0, ImGuiSelectableFlags_DontClosePopups = 1 << 0, // Clicking this don't close parent popup window ImGuiSelectableFlags_SpanAllColumns = 1 << 1, // Selectable frame can span all columns (text will still fit in current column) ImGuiSelectableFlags_AllowDoubleClick = 1 << 2, // Generate press events on double clicks too ImGuiSelectableFlags_Disabled = 1 << 3, // Cannot be selected, display grayed out text ImGuiSelectableFlags_AllowItemOverlap = 1 << 4 // (WIP) Hit testing to allow subsequent widgets to overlap this one }; // Flags for ImGui::BeginCombo() enum ImGuiComboFlags_ { ImGuiComboFlags_None = 0, ImGuiComboFlags_PopupAlignLeft = 1 << 0, // Align the popup toward the left by default ImGuiComboFlags_HeightSmall = 1 << 1, // Max ~4 items visible. Tip: If you want your combo popup to be a specific size you can use SetNextWindowSizeConstraints() prior to calling BeginCombo() ImGuiComboFlags_HeightRegular = 1 << 2, // Max ~8 items visible (default) ImGuiComboFlags_HeightLarge = 1 << 3, // Max ~20 items visible ImGuiComboFlags_HeightLargest = 1 << 4, // As many fitting items as possible ImGuiComboFlags_NoArrowButton = 1 << 5, // Display on the preview box without the square arrow button ImGuiComboFlags_NoPreview = 1 << 6, // Display only a square arrow button ImGuiComboFlags_HeightMask_ = ImGuiComboFlags_HeightSmall | ImGuiComboFlags_HeightRegular | ImGuiComboFlags_HeightLarge | ImGuiComboFlags_HeightLargest }; // Flags for ImGui::BeginTabBar() enum ImGuiTabBarFlags_ { ImGuiTabBarFlags_None = 0, ImGuiTabBarFlags_Reorderable = 1 << 0, // Allow manually dragging tabs to re-order them + New tabs are appended at the end of list ImGuiTabBarFlags_AutoSelectNewTabs = 1 << 1, // Automatically select new tabs when they appear ImGuiTabBarFlags_TabListPopupButton = 1 << 2, // Disable buttons to open the tab list popup ImGuiTabBarFlags_NoCloseWithMiddleMouseButton = 1 << 3, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false. ImGuiTabBarFlags_NoTabListScrollingButtons = 1 << 4, // Disable scrolling buttons (apply when fitting policy is ImGuiTabBarFlags_FittingPolicyScroll) ImGuiTabBarFlags_NoTooltip = 1 << 5, // Disable tooltips when hovering a tab ImGuiTabBarFlags_FittingPolicyResizeDown = 1 << 6, // Resize tabs when they don't fit ImGuiTabBarFlags_FittingPolicyScroll = 1 << 7, // Add scroll buttons when tabs don't fit ImGuiTabBarFlags_FittingPolicyMask_ = ImGuiTabBarFlags_FittingPolicyResizeDown | ImGuiTabBarFlags_FittingPolicyScroll, ImGuiTabBarFlags_FittingPolicyDefault_ = ImGuiTabBarFlags_FittingPolicyResizeDown }; // Flags for ImGui::BeginTabItem() enum ImGuiTabItemFlags_ { ImGuiTabItemFlags_None = 0, ImGuiTabItemFlags_UnsavedDocument = 1 << 0, // Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. Also: tab is selected on closure and closure is deferred by one frame to allow code to undo it without flicker. ImGuiTabItemFlags_SetSelected = 1 << 1, // Trigger flag to programmatically make the tab selected when calling BeginTabItem() ImGuiTabItemFlags_NoCloseWithMiddleMouseButton = 1 << 2, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false. ImGuiTabItemFlags_NoPushId = 1 << 3 // Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem() }; // Flags for ImGui::IsWindowFocused() enum ImGuiFocusedFlags_ { ImGuiFocusedFlags_None = 0, ImGuiFocusedFlags_ChildWindows = 1 << 0, // IsWindowFocused(): Return true if any children of the window is focused ImGuiFocusedFlags_RootWindow = 1 << 1, // IsWindowFocused(): Test from root window (top most parent of the current hierarchy) ImGuiFocusedFlags_AnyWindow = 1 << 2, // IsWindowFocused(): Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use ImGui::GetIO().WantCaptureMouse instead. ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows }; // Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered() // Note: if you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that. Please read the FAQ! // Note: windows with the ImGuiWindowFlags_NoInputs flag are ignored by IsWindowHovered() calls. enum ImGuiHoveredFlags_ { ImGuiHoveredFlags_None = 0, // Return true if directly over the item/window, not obstructed by another window, not obstructed by an active popup or modal blocking inputs under them. ImGuiHoveredFlags_ChildWindows = 1 << 0, // IsWindowHovered() only: Return true if any children of the window is hovered ImGuiHoveredFlags_RootWindow = 1 << 1, // IsWindowHovered() only: Test from root window (top most parent of the current hierarchy) ImGuiHoveredFlags_AnyWindow = 1 << 2, // IsWindowHovered() only: Return true if any window is hovered ImGuiHoveredFlags_AllowWhenBlockedByPopup = 1 << 3, // Return true even if a popup window is normally blocking access to this item/window //ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 4, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet. ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 5, // Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns. ImGuiHoveredFlags_AllowWhenOverlapped = 1 << 6, // Return true even if the position is obstructed or overlapped by another window ImGuiHoveredFlags_AllowWhenDisabled = 1 << 7, // Return true even if the item is disabled ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped, ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows }; // Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload() enum ImGuiDragDropFlags_ { ImGuiDragDropFlags_None = 0, // BeginDragDropSource() flags ImGuiDragDropFlags_SourceNoPreviewTooltip = 1 << 0, // By default, a successful call to BeginDragDropSource opens a tooltip so you can display a preview or description of the source contents. This flag disable this behavior. ImGuiDragDropFlags_SourceNoDisableHover = 1 << 1, // By default, when dragging we clear data so that IsItemHovered() will return false, to avoid subsequent user code submitting tooltips. This flag disable this behavior so you can still call IsItemHovered() on the source item. ImGuiDragDropFlags_SourceNoHoldToOpenOthers = 1 << 2, // Disable the behavior that allows to open tree nodes and collapsing header by holding over them while dragging a source item. ImGuiDragDropFlags_SourceAllowNullID = 1 << 3, // Allow items such as Text(), Image() that have no unique identifier to be used as drag source, by manufacturing a temporary identifier based on their window-relative position. This is extremely unusual within the dear imgui ecosystem and so we made it explicit. ImGuiDragDropFlags_SourceExtern = 1 << 4, // External source (from outside of dear imgui), won't attempt to read current item/window info. Will always return true. Only one Extern source can be active simultaneously. ImGuiDragDropFlags_SourceAutoExpirePayload = 1 << 5, // Automatically expire the payload if the source cease to be submitted (otherwise payloads are persisting while being dragged) // AcceptDragDropPayload() flags ImGuiDragDropFlags_AcceptBeforeDelivery = 1 << 10, // AcceptDragDropPayload() will returns true even before the mouse button is released. You can then call IsDelivery() to test if the payload needs to be delivered. ImGuiDragDropFlags_AcceptNoDrawDefaultRect = 1 << 11, // Do not draw the default highlight rectangle when hovering over target. ImGuiDragDropFlags_AcceptNoPreviewTooltip = 1 << 12, // Request hiding the BeginDragDropSource tooltip from the BeginDragDropTarget site. ImGuiDragDropFlags_AcceptPeekOnly = ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect // For peeking ahead and inspecting the payload before delivery. }; // Standard Drag and Drop payload types. You can define you own payload types using short strings. Types starting with '_' are defined by Dear ImGui. #define IMGUI_PAYLOAD_TYPE_COLOR_3F "_COL3F" // float[3]: Standard type for colors, without alpha. User code may use this type. #define IMGUI_PAYLOAD_TYPE_COLOR_4F "_COL4F" // float[4]: Standard type for colors. User code may use this type. // A primary data type enum ImGuiDataType_ { ImGuiDataType_S8, // signed char / char (with sensible compilers) ImGuiDataType_U8, // unsigned char ImGuiDataType_S16, // short ImGuiDataType_U16, // unsigned short ImGuiDataType_S32, // int ImGuiDataType_U32, // unsigned int ImGuiDataType_S64, // long long / __int64 ImGuiDataType_U64, // unsigned long long / unsigned __int64 ImGuiDataType_Float, // float ImGuiDataType_Double, // double ImGuiDataType_COUNT }; // A cardinal direction enum ImGuiDir_ { ImGuiDir_None = -1, ImGuiDir_Left = 0, ImGuiDir_Right = 1, ImGuiDir_Up = 2, ImGuiDir_Down = 3, ImGuiDir_COUNT }; // User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array enum ImGuiKey_ { ImGuiKey_Tab, ImGuiKey_LeftArrow, ImGuiKey_RightArrow, ImGuiKey_UpArrow, ImGuiKey_DownArrow, ImGuiKey_PageUp, ImGuiKey_PageDown, ImGuiKey_Home, ImGuiKey_End, ImGuiKey_Insert, ImGuiKey_Delete, ImGuiKey_Backspace, ImGuiKey_Space, ImGuiKey_Enter, ImGuiKey_Escape, ImGuiKey_KeyPadEnter, ImGuiKey_A, // for text edit CTRL+A: select all ImGuiKey_C, // for text edit CTRL+C: copy ImGuiKey_V, // for text edit CTRL+V: paste ImGuiKey_X, // for text edit CTRL+X: cut ImGuiKey_Y, // for text edit CTRL+Y: redo ImGuiKey_Z, // for text edit CTRL+Z: undo ImGuiKey_COUNT }; // Gamepad/Keyboard directional navigation // Keyboard: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays. // Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Back-end: set ImGuiBackendFlags_HasGamepad and fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame(). // Read instructions in imgui.cpp for more details. Download PNG/PSD at http://goo.gl/9LgVZW. enum ImGuiNavInput_ { // Gamepad Mapping ImGuiNavInput_Activate, // activate / open / toggle / tweak value // e.g. Cross (PS4), A (Xbox), A (Switch), Space (Keyboard) ImGuiNavInput_Cancel, // cancel / close / exit // e.g. Circle (PS4), B (Xbox), B (Switch), Escape (Keyboard) ImGuiNavInput_Input, // text input / on-screen keyboard // e.g. Triang.(PS4), Y (Xbox), X (Switch), Return (Keyboard) ImGuiNavInput_Menu, // tap: toggle menu / hold: focus, move, resize // e.g. Square (PS4), X (Xbox), Y (Switch), Alt (Keyboard) ImGuiNavInput_DpadLeft, // move / tweak / resize window (w/ PadMenu) // e.g. D-pad Left/Right/Up/Down (Gamepads), Arrow keys (Keyboard) ImGuiNavInput_DpadRight, // ImGuiNavInput_DpadUp, // ImGuiNavInput_DpadDown, // ImGuiNavInput_LStickLeft, // scroll / move window (w/ PadMenu) // e.g. Left Analog Stick Left/Right/Up/Down ImGuiNavInput_LStickRight, // ImGuiNavInput_LStickUp, // ImGuiNavInput_LStickDown, // ImGuiNavInput_FocusPrev, // next window (w/ PadMenu) // e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch) ImGuiNavInput_FocusNext, // prev window (w/ PadMenu) // e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch) ImGuiNavInput_TweakSlow, // slower tweaks // e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch) ImGuiNavInput_TweakFast, // faster tweaks // e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch) // [Internal] Don't use directly! This is used internally to differentiate keyboard from gamepad inputs for behaviors that require to differentiate them. // Keyboard behavior that have no corresponding gamepad mapping (e.g. CTRL+TAB) will be directly reading from io.KeysDown[] instead of io.NavInputs[]. ImGuiNavInput_KeyMenu_, // toggle menu // = io.KeyAlt ImGuiNavInput_KeyLeft_, // move left // = Arrow keys ImGuiNavInput_KeyRight_, // move right ImGuiNavInput_KeyUp_, // move up ImGuiNavInput_KeyDown_, // move down ImGuiNavInput_COUNT, ImGuiNavInput_InternalStart_ = ImGuiNavInput_KeyMenu_ }; // Configuration flags stored in io.ConfigFlags. Set by user/application. enum ImGuiConfigFlags_ { ImGuiConfigFlags_None = 0, ImGuiConfigFlags_NavEnableKeyboard = 1 << 0, // Master keyboard navigation enable flag. NewFrame() will automatically fill io.NavInputs[] based on io.KeysDown[]. ImGuiConfigFlags_NavEnableGamepad = 1 << 1, // Master gamepad navigation enable flag. This is mostly to instruct your imgui back-end to fill io.NavInputs[]. Back-end also needs to set ImGuiBackendFlags_HasGamepad. ImGuiConfigFlags_NavEnableSetMousePos = 1 << 2, // Instruct navigation to move the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantSetMousePos=true. If enabled you MUST honor io.WantSetMousePos requests in your binding, otherwise ImGui will react as if the mouse is jumping around back and forth. ImGuiConfigFlags_NavNoCaptureKeyboard = 1 << 3, // Instruct navigation to not set the io.WantCaptureKeyboard flag when io.NavActive is set. ImGuiConfigFlags_NoMouse = 1 << 4, // Instruct imgui to clear mouse position/buttons in NewFrame(). This allows ignoring the mouse information set by the back-end. ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct back-end to not alter mouse cursor shape and visibility. Use if the back-end cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead. // User storage (to allow your back-end/engine to communicate to code that may be shared between multiple projects. Those flags are not used by core Dear ImGui) ImGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware. ImGuiConfigFlags_IsTouchScreen = 1 << 21 // Application is using a touch screen instead of a mouse. }; // Back-end capabilities flags stored in io.BackendFlags. Set by imgui_impl_xxx or custom back-end. enum ImGuiBackendFlags_ { ImGuiBackendFlags_None = 0, ImGuiBackendFlags_HasGamepad = 1 << 0, // Back-end Platform supports gamepad and currently has one connected. ImGuiBackendFlags_HasMouseCursors = 1 << 1, // Back-end Platform supports honoring GetMouseCursor() value to change the OS cursor shape. ImGuiBackendFlags_HasSetMousePos = 1 << 2, // Back-end Platform supports io.WantSetMousePos requests to reposition the OS mouse position (only used if ImGuiConfigFlags_NavEnableSetMousePos is set). ImGuiBackendFlags_RendererHasVtxOffset = 1 << 3 // Back-end Renderer supports ImDrawCmd::VtxOffset. This enables output of large meshes (64K+ vertices) while still using 16-bit indices. }; // Enumeration for PushStyleColor() / PopStyleColor() enum ImGuiCol_ { ImGuiCol_Text, ImGuiCol_TextDisabled, ImGuiCol_WindowBg, // Background of normal windows ImGuiCol_ChildBg, // Background of child windows ImGuiCol_PopupBg, // Background of popups, menus, tooltips windows ImGuiCol_Border, ImGuiCol_BorderShadow, ImGuiCol_FrameBg, // Background of checkbox, radio button, plot, slider, text input ImGuiCol_FrameBgHovered, ImGuiCol_FrameBgActive, ImGuiCol_TitleBg, ImGuiCol_TitleBgActive, ImGuiCol_TitleBgCollapsed, ImGuiCol_MenuBarBg, ImGuiCol_ScrollbarBg, ImGuiCol_ScrollbarGrab, ImGuiCol_ScrollbarGrabHovered, ImGuiCol_ScrollbarGrabActive, ImGuiCol_CheckMark, ImGuiCol_SliderGrab, ImGuiCol_SliderGrabActive, ImGuiCol_Button, ImGuiCol_ButtonHovered, ImGuiCol_ButtonActive, ImGuiCol_Header, // Header* colors are used for CollapsingHeader, TreeNode, Selectable, MenuItem ImGuiCol_HeaderHovered, ImGuiCol_HeaderActive, ImGuiCol_Separator, ImGuiCol_SeparatorHovered, ImGuiCol_SeparatorActive, ImGuiCol_ResizeGrip, ImGuiCol_ResizeGripHovered, ImGuiCol_ResizeGripActive, ImGuiCol_Tab, ImGuiCol_TabHovered, ImGuiCol_TabActive, ImGuiCol_TabUnfocused, ImGuiCol_TabUnfocusedActive, ImGuiCol_PlotLines, ImGuiCol_PlotLinesHovered, ImGuiCol_PlotHistogram, ImGuiCol_PlotHistogramHovered, ImGuiCol_TextSelectedBg, ImGuiCol_DragDropTarget, ImGuiCol_NavHighlight, // Gamepad/keyboard: current highlighted item ImGuiCol_NavWindowingHighlight, // Highlight window when using CTRL+TAB ImGuiCol_NavWindowingDimBg, // Darken/colorize entire screen behind the CTRL+TAB window list, when active ImGuiCol_ModalWindowDimBg, // Darken/colorize entire screen behind a modal window, when one is active ImGuiCol_COUNT // Obsolete names (will be removed) #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS , ImGuiCol_ModalWindowDarkening = ImGuiCol_ModalWindowDimBg // [renamed in 1.63] //, ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered// [unused since 1.60+] the close button now uses regular button colors. #endif }; // Enumeration for PushStyleVar() / PopStyleVar() to temporarily modify the ImGuiStyle structure. // NB: the enum only refers to fields of ImGuiStyle which makes sense to be pushed/popped inside UI code. During initialization, feel free to just poke into ImGuiStyle directly. // NB: if changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type. enum ImGuiStyleVar_ { // Enum name --------------------- // Member in ImGuiStyle structure (see ImGuiStyle for descriptions) ImGuiStyleVar_Alpha, // float Alpha ImGuiStyleVar_WindowPadding, // ImVec2 WindowPadding ImGuiStyleVar_WindowRounding, // float WindowRounding ImGuiStyleVar_WindowBorderSize, // float WindowBorderSize ImGuiStyleVar_WindowMinSize, // ImVec2 WindowMinSize ImGuiStyleVar_WindowTitleAlign, // ImVec2 WindowTitleAlign ImGuiStyleVar_ChildRounding, // float ChildRounding ImGuiStyleVar_ChildBorderSize, // float ChildBorderSize ImGuiStyleVar_PopupRounding, // float PopupRounding ImGuiStyleVar_PopupBorderSize, // float PopupBorderSize ImGuiStyleVar_FramePadding, // ImVec2 FramePadding ImGuiStyleVar_FrameRounding, // float FrameRounding ImGuiStyleVar_FrameBorderSize, // float FrameBorderSize ImGuiStyleVar_ItemSpacing, // ImVec2 ItemSpacing ImGuiStyleVar_ItemInnerSpacing, // ImVec2 ItemInnerSpacing ImGuiStyleVar_IndentSpacing, // float IndentSpacing ImGuiStyleVar_ScrollbarSize, // float ScrollbarSize ImGuiStyleVar_ScrollbarRounding, // float ScrollbarRounding ImGuiStyleVar_GrabMinSize, // float GrabMinSize ImGuiStyleVar_GrabRounding, // float GrabRounding ImGuiStyleVar_TabRounding, // float TabRounding ImGuiStyleVar_ButtonTextAlign, // ImVec2 ButtonTextAlign ImGuiStyleVar_SelectableTextAlign, // ImVec2 SelectableTextAlign ImGuiStyleVar_COUNT // Obsolete names (will be removed) #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS , ImGuiStyleVar_Count_ = ImGuiStyleVar_COUNT // [renamed in 1.60] #endif }; // Flags for ColorEdit3() / ColorEdit4() / ColorPicker3() / ColorPicker4() / ColorButton() enum ImGuiColorEditFlags_ { ImGuiColorEditFlags_None = 0, ImGuiColorEditFlags_NoAlpha = 1 << 1, // // ColorEdit, ColorPicker, ColorButton: ignore Alpha component (will only read 3 components from the input pointer). ImGuiColorEditFlags_NoPicker = 1 << 2, // // ColorEdit: disable picker when clicking on colored square. ImGuiColorEditFlags_NoOptions = 1 << 3, // // ColorEdit: disable toggling options menu when right-clicking on inputs/small preview. ImGuiColorEditFlags_NoSmallPreview = 1 << 4, // // ColorEdit, ColorPicker: disable colored square preview next to the inputs. (e.g. to show only the inputs) ImGuiColorEditFlags_NoInputs = 1 << 5, // // ColorEdit, ColorPicker: disable inputs sliders/text widgets (e.g. to show only the small preview colored square). ImGuiColorEditFlags_NoTooltip = 1 << 6, // // ColorEdit, ColorPicker, ColorButton: disable tooltip when hovering the preview. ImGuiColorEditFlags_NoLabel = 1 << 7, // // ColorEdit, ColorPicker: disable display of inline text label (the label is still forwarded to the tooltip and picker). ImGuiColorEditFlags_NoSidePreview = 1 << 8, // // ColorPicker: disable bigger color preview on right side of the picker, use small colored square preview instead. ImGuiColorEditFlags_NoDragDrop = 1 << 9, // // ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source. // User Options (right-click on widget to change some of them). ImGuiColorEditFlags_AlphaBar = 1 << 16, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker. ImGuiColorEditFlags_AlphaPreview = 1 << 17, // // ColorEdit, ColorPicker, ColorButton: display preview as a transparent color over a checkerboard, instead of opaque. ImGuiColorEditFlags_AlphaPreviewHalf= 1 << 18, // // ColorEdit, ColorPicker, ColorButton: display half opaque / half checkerboard, instead of opaque. ImGuiColorEditFlags_HDR = 1 << 19, // // (WIP) ColorEdit: Currently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use ImGuiColorEditFlags_Float flag as well). ImGuiColorEditFlags_DisplayRGB = 1 << 20, // [Display] // ColorEdit: override _display_ type among RGB/HSV/Hex. ColorPicker: select any combination using one or more of RGB/HSV/Hex. ImGuiColorEditFlags_DisplayHSV = 1 << 21, // [Display] // " ImGuiColorEditFlags_DisplayHex = 1 << 22, // [Display] // " ImGuiColorEditFlags_Uint8 = 1 << 23, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0..255. ImGuiColorEditFlags_Float = 1 << 24, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0.0f..1.0f floats instead of 0..255 integers. No round-trip of value via integers. ImGuiColorEditFlags_PickerHueBar = 1 << 25, // [Picker] // ColorPicker: bar for Hue, rectangle for Sat/Value. ImGuiColorEditFlags_PickerHueWheel = 1 << 26, // [Picker] // ColorPicker: wheel for Hue, triangle for Sat/Value. ImGuiColorEditFlags_InputRGB = 1 << 27, // [Input] // ColorEdit, ColorPicker: input and output data in RGB format. ImGuiColorEditFlags_InputHSV = 1 << 28, // [Input] // ColorEdit, ColorPicker: input and output data in HSV format. // Defaults Options. You can set application defaults using SetColorEditOptions(). The intent is that you probably don't want to // override them in most of your calls. Let the user choose via the option menu and/or call SetColorEditOptions() once during startup. ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_DisplayRGB|ImGuiColorEditFlags_InputRGB|ImGuiColorEditFlags_PickerHueBar, // [Internal] Masks ImGuiColorEditFlags__DisplayMask = ImGuiColorEditFlags_DisplayRGB|ImGuiColorEditFlags_DisplayHSV|ImGuiColorEditFlags_DisplayHex, ImGuiColorEditFlags__DataTypeMask = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_Float, ImGuiColorEditFlags__PickerMask = ImGuiColorEditFlags_PickerHueWheel|ImGuiColorEditFlags_PickerHueBar, ImGuiColorEditFlags__InputMask = ImGuiColorEditFlags_InputRGB|ImGuiColorEditFlags_InputHSV // Obsolete names (will be removed) #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS , ImGuiColorEditFlags_RGB = ImGuiColorEditFlags_DisplayRGB, ImGuiColorEditFlags_HSV = ImGuiColorEditFlags_DisplayHSV, ImGuiColorEditFlags_HEX = ImGuiColorEditFlags_DisplayHex // [renamed in 1.69] #endif }; // Identify a mouse button. // Those values are guaranteed to be stable and we frequently use 0/1 directly. Named enums provided for convenience. enum ImGuiMouseButton_ { ImGuiMouseButton_Left = 0, ImGuiMouseButton_Right = 1, ImGuiMouseButton_Middle = 2, ImGuiMouseButton_COUNT = 5 }; // Enumeration for GetMouseCursor() // User code may request binding to display given cursor by calling SetMouseCursor(), which is why we have some cursors that are marked unused here enum ImGuiMouseCursor_ { ImGuiMouseCursor_None = -1, ImGuiMouseCursor_Arrow = 0, ImGuiMouseCursor_TextInput, // When hovering over InputText, etc. ImGuiMouseCursor_ResizeAll, // (Unused by Dear ImGui functions) ImGuiMouseCursor_ResizeNS, // When hovering over an horizontal border ImGuiMouseCursor_ResizeEW, // When hovering over a vertical border or a column ImGuiMouseCursor_ResizeNESW, // When hovering over the bottom-left corner of a window ImGuiMouseCursor_ResizeNWSE, // When hovering over the bottom-right corner of a window ImGuiMouseCursor_Hand, // (Unused by Dear ImGui functions. Use for e.g. hyperlinks) ImGuiMouseCursor_NotAllowed, // When hovering something with disallowed interaction. Usually a crossed circle. ImGuiMouseCursor_COUNT // Obsolete names (will be removed) #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS , ImGuiMouseCursor_Count_ = ImGuiMouseCursor_COUNT // [renamed in 1.60] #endif }; // Enumeration for ImGui::SetWindow***(), SetNextWindow***(), SetNextItem***() functions // Represent a condition. // Important: Treat as a regular enum! Do NOT combine multiple values using binary operators! All the functions above treat 0 as a shortcut to ImGuiCond_Always. enum ImGuiCond_ { ImGuiCond_Always = 1 << 0, // Set the variable ImGuiCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call with succeed) ImGuiCond_FirstUseEver = 1 << 2, // Set the variable if the object/window has no persistently saved data (no entry in .ini file) ImGuiCond_Appearing = 1 << 3 // Set the variable if the object/window is appearing after being hidden/inactive (or the first time) }; //----------------------------------------------------------------------------- // Helpers: Memory allocations macros // IM_MALLOC(), IM_FREE(), IM_NEW(), IM_PLACEMENT_NEW(), IM_DELETE() // We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax. // Defining a custom placement new() with a dummy parameter allows us to bypass including which on some platforms complains when user has disabled exceptions. //----------------------------------------------------------------------------- struct ImNewDummy {}; inline void* operator new(size_t, ImNewDummy, void* ptr) { return ptr; } inline void operator delete(void*, ImNewDummy, void*) {} // This is only required so we can use the symmetrical new() #define IM_ALLOC(_SIZE) ImGui::MemAlloc(_SIZE) #define IM_FREE(_PTR) ImGui::MemFree(_PTR) #define IM_PLACEMENT_NEW(_PTR) new(ImNewDummy(), _PTR) #define IM_NEW(_TYPE) new(ImNewDummy(), ImGui::MemAlloc(sizeof(_TYPE))) _TYPE template void IM_DELETE(T* p) { if (p) { p->~T(); ImGui::MemFree(p); } } //----------------------------------------------------------------------------- // Helper: ImVector<> // Lightweight std::vector<>-like class to avoid dragging dependencies (also, some implementations of STL with debug enabled are absurdly slow, we bypass it so our code runs fast in debug). //----------------------------------------------------------------------------- // - You generally do NOT need to care or use this ever. But we need to make it available in imgui.h because some of our public structures are relying on it. // - We use std-like naming convention here, which is a little unusual for this codebase. // - Important: clear() frees memory, resize(0) keep the allocated buffer. We use resize(0) a lot to intentionally recycle allocated buffers across frames and amortize our costs. // - Important: our implementation does NOT call C++ constructors/destructors, we treat everything as raw data! This is intentional but be extra mindful of that, // Do NOT use this class as a std::vector replacement in your own code! Many of the structures used by dear imgui can be safely initialized by a zero-memset. //----------------------------------------------------------------------------- template struct ImVector { int Size; int Capacity; T* Data; // Provide standard typedefs but we don't use them ourselves. typedef T value_type; typedef value_type* iterator; typedef const value_type* const_iterator; // Constructors, destructor inline ImVector() { Size = Capacity = 0; Data = NULL; } inline ImVector(const ImVector& src) { Size = Capacity = 0; Data = NULL; operator=(src); } inline ImVector& operator=(const ImVector& src) { clear(); resize(src.Size); memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; } inline ~ImVector() { if (Data) IM_FREE(Data); } inline bool empty() const { return Size == 0; } inline int size() const { return Size; } inline int size_in_bytes() const { return Size * (int)sizeof(T); } inline int capacity() const { return Capacity; } inline T& operator[](int i) { IM_ASSERT(i < Size); return Data[i]; } inline const T& operator[](int i) const { IM_ASSERT(i < Size); return Data[i]; } inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } } inline T* begin() { return Data; } inline const T* begin() const { return Data; } inline T* end() { return Data + Size; } inline const T* end() const { return Data + Size; } inline T& front() { IM_ASSERT(Size > 0); return Data[0]; } inline const T& front() const { IM_ASSERT(Size > 0); return Data[0]; } inline T& back() { IM_ASSERT(Size > 0); return Data[Size - 1]; } inline const T& back() const { IM_ASSERT(Size > 0); return Data[Size - 1]; } inline void swap(ImVector& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; T* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; } inline int _grow_capacity(int sz) const { int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > sz ? new_capacity : sz; } inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; } inline void resize(int new_size, const T& v) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) memcpy(&Data[n], &v, sizeof(v)); Size = new_size; } inline void shrink(int new_size) { IM_ASSERT(new_size <= Size); Size = new_size; } // Resize a vector to a smaller size, guaranteed not to cause a reallocation inline void reserve(int new_capacity) { if (new_capacity <= Capacity) return; T* new_data = (T*)IM_ALLOC((size_t)new_capacity * sizeof(T)); if (Data) { memcpy(new_data, Data, (size_t)Size * sizeof(T)); IM_FREE(Data); } Data = new_data; Capacity = new_capacity; } // NB: It is illegal to call push_back/push_front/insert with a reference pointing inside the ImVector data itself! e.g. v.push_back(v[10]) is forbidden. inline void push_back(const T& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); memcpy(&Data[Size], &v, sizeof(v)); Size++; } inline void pop_back() { IM_ASSERT(Size > 0); Size--; } inline void push_front(const T& v) { if (Size == 0) push_back(v); else insert(Data, v); } inline T* erase(const T* it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(T)); Size--; return Data + off; } inline T* erase(const T* it, const T* it_last){ IM_ASSERT(it >= Data && it < Data+Size && it_last > it && it_last <= Data+Size); const ptrdiff_t count = it_last - it; const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + count, ((size_t)Size - (size_t)off - count) * sizeof(T)); Size -= (int)count; return Data + off; } inline T* erase_unsorted(const T* it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; if (it < Data+Size-1) memcpy(Data + off, Data + Size - 1, sizeof(T)); Size--; return Data + off; } inline T* insert(const T* it, const T& v) { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(T)); memcpy(&Data[off], &v, sizeof(v)); Size++; return Data + off; } inline bool contains(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; } inline T* find(const T& v) { T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; } inline const T* find(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; } inline bool find_erase(const T& v) { const T* it = find(v); if (it < Data + Size) { erase(it); return true; } return false; } inline bool find_erase_unsorted(const T& v) { const T* it = find(v); if (it < Data + Size) { erase_unsorted(it); return true; } return false; } inline int index_from_ptr(const T* it) const { IM_ASSERT(it >= Data && it < Data + Size); const ptrdiff_t off = it - Data; return (int)off; } }; //----------------------------------------------------------------------------- // ImGuiStyle // You may modify the ImGui::GetStyle() main instance during initialization and before NewFrame(). // During the frame, use ImGui::PushStyleVar(ImGuiStyleVar_XXXX)/PopStyleVar() to alter the main style values, // and ImGui::PushStyleColor(ImGuiCol_XXX)/PopStyleColor() for colors. //----------------------------------------------------------------------------- struct ImGuiStyle { float Alpha; // Global alpha applies to everything in Dear ImGui. ImVec2 WindowPadding; // Padding within a window. float WindowRounding; // Radius of window corners rounding. Set to 0.0f to have rectangular windows. float WindowBorderSize; // Thickness of border around windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). ImVec2 WindowMinSize; // Minimum window size. This is a global setting. If you want to constraint individual windows, use SetNextWindowSizeConstraints(). ImVec2 WindowTitleAlign; // Alignment for title bar text. Defaults to (0.0f,0.5f) for left-aligned,vertically centered. ImGuiDir WindowMenuButtonPosition; // Side of the collapsing/docking button in the title bar (None/Left/Right). Defaults to ImGuiDir_Left. float ChildRounding; // Radius of child window corners rounding. Set to 0.0f to have rectangular windows. float ChildBorderSize; // Thickness of border around child windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). float PopupRounding; // Radius of popup window corners rounding. (Note that tooltip windows use WindowRounding) float PopupBorderSize; // Thickness of border around popup/tooltip windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). ImVec2 FramePadding; // Padding within a framed rectangle (used by most widgets). float FrameRounding; // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets). float FrameBorderSize; // Thickness of border around frames. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines. ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label). ImVec2 TouchExtraPadding; // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much! float IndentSpacing; // Horizontal indentation when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2). float ColumnsMinSpacing; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1). float ScrollbarSize; // Width of the vertical scrollbar, Height of the horizontal scrollbar. float ScrollbarRounding; // Radius of grab corners for scrollbar. float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar. float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs. float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs. float TabBorderSize; // Thickness of border around tabs. ImGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right. ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered). ImVec2 SelectableTextAlign; // Alignment of selectable text when selectable is larger than text. Defaults to (0.0f, 0.0f) (top-left aligned). ImVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area by at least this amount. Only applies to regular windows. ImVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly! float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later. bool AntiAliasedLines; // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU. bool AntiAliasedFill; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.) float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. float CircleSegmentMaxError; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry. ImVec4 Colors[ImGuiCol_COUNT]; IMGUI_API ImGuiStyle(); IMGUI_API void ScaleAllSizes(float scale_factor); }; //----------------------------------------------------------------------------- // ImGuiIO // Communicate most settings and inputs/outputs to Dear ImGui using this structure. // Access via ImGui::GetIO(). Read 'Programmer guide' section in .cpp file for general usage. //----------------------------------------------------------------------------- struct ImGuiIO { //------------------------------------------------------------------ // Configuration (fill once) // Default value //------------------------------------------------------------------ ImGuiConfigFlags ConfigFlags; // = 0 // See ImGuiConfigFlags_ enum. Set by user/application. Gamepad/keyboard navigation options, etc. ImGuiBackendFlags BackendFlags; // = 0 // See ImGuiBackendFlags_ enum. Set by back-end (imgui_impl_xxx files or custom back-end) to communicate features supported by the back-end. ImVec2 DisplaySize; // // Main display size, in pixels. float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds. float IniSavingRate; // = 5.0f // Minimum time between saving positions/sizes to .ini file, in seconds. const char* IniFilename; // = "imgui.ini" // Path to .ini file. Set NULL to disable automatic .ini loading/saving, if e.g. you want to manually load/save from memory. const char* LogFilename; // = "imgui_log.txt"// Path to .log file (default parameter to ImGui::LogToFile when no file is specified). float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds. float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels. float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging. int KeyMap[ImGuiKey_COUNT]; // // Map of indices into the KeysDown[512] entries array which represent your "native" keyboard state. float KeyRepeatDelay; // = 0.250f // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.). float KeyRepeatRate; // = 0.050f // When holding a key/button, rate at which it repeats, in seconds. void* UserData; // = NULL // Store your own data for retrieval by callbacks. ImFontAtlas*Fonts; // // Font atlas: load, rasterize and pack one or more fonts into a single texture. float FontGlobalScale; // = 1.0f // Global scale all fonts bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel. ImFont* FontDefault; // = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0]. ImVec2 DisplayFramebufferScale; // = (1, 1) // For retina display or other situations where window coordinates are different from framebuffer coordinates. This generally ends up in ImDrawData::FramebufferScale. // Miscellaneous options bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by back-end implementations. bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl (was called io.OptMacOSXBehaviors prior to 1.63) bool ConfigInputTextCursorBlink; // = true // Set to false to disable blinking cursor, for users who consider it distracting. (was called: io.OptCursorBlink prior to 1.63) bool ConfigWindowsResizeFromEdges; // = true // Enable resizing of windows from their edges and from the lower-left corner. This requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback. (This used to be a per-window ImGuiWindowFlags_ResizeFromAnySide flag) bool ConfigWindowsMoveFromTitleBarOnly; // = false // [BETA] Set to true to only allow moving windows when clicked+dragged from the title bar. Windows without a title bar are not affected. float ConfigWindowsMemoryCompactTimer;// = 60.0f // [BETA] Compact window memory usage when unused. Set to -1.0f to disable. //------------------------------------------------------------------ // Platform Functions // (the imgui_impl_xxxx back-end files are setting those up for you) //------------------------------------------------------------------ // Optional: Platform/Renderer back-end name (informational only! will be displayed in About Window) + User data for back-end/wrappers to store their own stuff. const char* BackendPlatformName; // = NULL const char* BackendRendererName; // = NULL void* BackendPlatformUserData; // = NULL // User data for platform back-end void* BackendRendererUserData; // = NULL // User data for renderer back-end void* BackendLanguageUserData; // = NULL // User data for non C++ programming language back-end // Optional: Access OS clipboard // (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures) const char* (*GetClipboardTextFn)(void* user_data); void (*SetClipboardTextFn)(void* user_data, const char* text); void* ClipboardUserData; // Optional: Notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME on Windows) // (default to use native imm32 api on Windows) void (*ImeSetInputScreenPosFn)(int x, int y); void* ImeWindowHandle; // = NULL // (Windows) Set this to your HWND to get automatic IME cursor positioning. #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS // [OBSOLETE since 1.60+] Rendering function, will be automatically called in Render(). Please call your rendering function yourself now! // You can obtain the ImDrawData* by calling ImGui::GetDrawData() after Render(). See example applications if you are unsure of how to implement this. void (*RenderDrawListsFn)(ImDrawData* data); #else // This is only here to keep ImGuiIO the same size/layout, so that IMGUI_DISABLE_OBSOLETE_FUNCTIONS can exceptionally be used outside of imconfig.h. void* RenderDrawListsFnUnused; #endif //------------------------------------------------------------------ // Input - Fill before calling NewFrame() //------------------------------------------------------------------ ImVec2 MousePos; // Mouse position, in pixels. Set to ImVec2(-FLT_MAX,-FLT_MAX) if mouse is unavailable (on another screen, etc.) bool MouseDown[5]; // Mouse buttons: 0=left, 1=right, 2=middle + extras. ImGui itself mostly only uses left button (BeginPopupContext** are using right button). Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API. float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text. float MouseWheelH; // Mouse wheel Horizontal. Most users don't have a mouse with an horizontal wheel, may not be filled by all back-ends. bool KeyCtrl; // Keyboard modifier pressed: Control bool KeyShift; // Keyboard modifier pressed: Shift bool KeyAlt; // Keyboard modifier pressed: Alt bool KeySuper; // Keyboard modifier pressed: Cmd/Super/Windows bool KeysDown[512]; // Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys). float NavInputs[ImGuiNavInput_COUNT]; // Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame(). // Functions IMGUI_API void AddInputCharacter(unsigned int c); // Queue new character input IMGUI_API void AddInputCharactersUTF8(const char* str); // Queue new characters input from an UTF-8 string IMGUI_API void ClearInputCharacters(); // Clear the text input buffer manually //------------------------------------------------------------------ // Output - Retrieve after calling NewFrame() //------------------------------------------------------------------ bool WantCaptureMouse; // When io.WantCaptureMouse is true, imgui will use the mouse inputs, do not dispatch them to your main game/application (in both cases, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.). bool WantCaptureKeyboard; // When io.WantCaptureKeyboard is true, imgui will use the keyboard inputs, do not dispatch them to your main game/application (in both cases, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.). bool WantTextInput; // Mobile/console: when io.WantTextInput is true, you may display an on-screen keyboard. This is set by ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active). bool WantSetMousePos; // MousePos has been altered, back-end should reposition mouse on next frame. Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled. bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. IMPORTANT: You need to clear io.WantSaveIniSettings yourself. bool NavActive; // Directional navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag. bool NavVisible; // Directional navigation is visible and allowed (will handle ImGuiKey_NavXXX events). float Framerate; // Application framerate estimation, in frame per second. Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames int MetricsRenderVertices; // Vertices output during last call to Render() int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3 int MetricsRenderWindows; // Number of visible windows int MetricsActiveWindows; // Number of active windows int MetricsActiveAllocations; // Number of active allocations, updated by MemAlloc/MemFree based on current context. May be off if you have multiple imgui contexts. ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are invalid (-FLT_MAX,-FLT_MAX), so a disappearing/reappearing mouse won't have a huge delta. //------------------------------------------------------------------ // [Internal] Dear ImGui will maintain those fields. Forward compatibility not guaranteed! //------------------------------------------------------------------ ImVec2 MousePosPrev; // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid) ImVec2 MouseClickedPos[5]; // Position at time of clicking double MouseClickedTime[5]; // Time of last click (used to figure out double-click) bool MouseClicked[5]; // Mouse button went from !Down to Down bool MouseDoubleClicked[5]; // Has mouse button been double-clicked? bool MouseReleased[5]; // Mouse button went from Down to !Down bool MouseDownOwned[5]; // Track if button was clicked inside a dear imgui window. We don't request mouse capture from the application if click started outside ImGui bounds. bool MouseDownWasDoubleClick[5]; // Track if button down was a double-click float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked) float MouseDownDurationPrev[5]; // Previous time the mouse button has been down ImVec2 MouseDragMaxDistanceAbs[5]; // Maximum distance, absolute, on each axis, of how much mouse has traveled from the clicking point float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point float KeysDownDuration[512]; // Duration the keyboard key has been down (0.0f == just pressed) float KeysDownDurationPrev[512]; // Previous duration the key has been down float NavInputsDownDuration[ImGuiNavInput_COUNT]; float NavInputsDownDurationPrev[ImGuiNavInput_COUNT]; ImVector InputQueueCharacters; // Queue of _characters_ input (obtained by platform back-end). Fill using AddInputCharacter() helper. IMGUI_API ImGuiIO(); }; //----------------------------------------------------------------------------- // Misc data structures //----------------------------------------------------------------------------- // Shared state of InputText(), passed as an argument to your callback when a ImGuiInputTextFlags_Callback* flag is used. // The callback function should return 0 by default. // Callbacks (follow a flag name and see comments in ImGuiInputTextFlags_ declarations for more details) // - ImGuiInputTextFlags_CallbackCompletion: Callback on pressing TAB // - ImGuiInputTextFlags_CallbackHistory: Callback on pressing Up/Down arrows // - ImGuiInputTextFlags_CallbackAlways: Callback on each iteration // - ImGuiInputTextFlags_CallbackCharFilter: Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard. // - ImGuiInputTextFlags_CallbackResize: Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. struct ImGuiInputTextCallbackData { ImGuiInputTextFlags EventFlag; // One ImGuiInputTextFlags_Callback* // Read-only ImGuiInputTextFlags Flags; // What user passed to InputText() // Read-only void* UserData; // What user passed to InputText() // Read-only // Arguments for the different callback events // - To modify the text buffer in a callback, prefer using the InsertChars() / DeleteChars() function. InsertChars() will take care of calling the resize callback if necessary. // - If you know your edits are not going to resize the underlying buffer allocation, you may modify the contents of 'Buf[]' directly. You need to update 'BufTextLen' accordingly (0 <= BufTextLen < BufSize) and set 'BufDirty'' to true so InputText can update its internal state. ImWchar EventChar; // Character input // Read-write // [CharFilter] Replace character with another one, or set to zero to drop. return 1 is equivalent to setting EventChar=0; ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only // [Completion,History] char* Buf; // Text buffer // Read-write // [Resize] Can replace pointer / [Completion,History,Always] Only write to pointed data, don't replace the actual pointer! int BufTextLen; // Text length (in bytes) // Read-write // [Resize,Completion,History,Always] Exclude zero-terminator storage. In C land: == strlen(some_text), in C++ land: string.length() int BufSize; // Buffer size (in bytes) = capacity+1 // Read-only // [Resize,Completion,History,Always] Include zero-terminator storage. In C land == ARRAYSIZE(my_char_array), in C++ land: string.capacity()+1 bool BufDirty; // Set if you modify Buf/BufTextLen! // Write // [Completion,History,Always] int CursorPos; // // Read-write // [Completion,History,Always] int SelectionStart; // // Read-write // [Completion,History,Always] == to SelectionEnd when no selection) int SelectionEnd; // // Read-write // [Completion,History,Always] // Helper functions for text manipulation. // Use those function to benefit from the CallbackResize behaviors. Calling those function reset the selection. IMGUI_API ImGuiInputTextCallbackData(); IMGUI_API void DeleteChars(int pos, int bytes_count); IMGUI_API void InsertChars(int pos, const char* text, const char* text_end = NULL); bool HasSelection() const { return SelectionStart != SelectionEnd; } }; // Resizing callback data to apply custom constraint. As enabled by SetNextWindowSizeConstraints(). Callback is called during the next Begin(). // NB: For basic min/max size constraint on each axis you don't need to use the callback! The SetNextWindowSizeConstraints() parameters are enough. struct ImGuiSizeCallbackData { void* UserData; // Read-only. What user passed to SetNextWindowSizeConstraints() ImVec2 Pos; // Read-only. Window position, for reference. ImVec2 CurrentSize; // Read-only. Current window size. ImVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing. }; // Data payload for Drag and Drop operations: AcceptDragDropPayload(), GetDragDropPayload() struct ImGuiPayload { // Members void* Data; // Data (copied and owned by dear imgui) int DataSize; // Data size // [Internal] ImGuiID SourceId; // Source item id ImGuiID SourceParentId; // Source parent id (if available) int DataFrameCount; // Data timestamp char DataType[32+1]; // Data type tag (short user-supplied string, 32 characters max) bool Preview; // Set when AcceptDragDropPayload() was called and mouse has been hovering the target item (nb: handle overlapping drag targets) bool Delivery; // Set when AcceptDragDropPayload() was called and mouse button is released over the target item. ImGuiPayload() { Clear(); } void Clear() { SourceId = SourceParentId = 0; Data = NULL; DataSize = 0; memset(DataType, 0, sizeof(DataType)); DataFrameCount = -1; Preview = Delivery = false; } bool IsDataType(const char* type) const { return DataFrameCount != -1 && strcmp(type, DataType) == 0; } bool IsPreview() const { return Preview; } bool IsDelivery() const { return Delivery; } }; //----------------------------------------------------------------------------- // Obsolete functions (Will be removed! Read 'API BREAKING CHANGES' section in imgui.cpp for details) // Please keep your copy of dear imgui up to date! Occasionally set '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' in imconfig.h to stay ahead. //----------------------------------------------------------------------------- #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS namespace ImGui { // OBSOLETED in 1.72 (from July 2019) static inline void TreeAdvanceToLabelPos() { SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()); } // OBSOLETED in 1.71 (from June 2019) static inline void SetNextTreeNodeOpen(bool open, ImGuiCond cond = 0) { SetNextItemOpen(open, cond); } // OBSOLETED in 1.70 (from May 2019) static inline float GetContentRegionAvailWidth() { return GetContentRegionAvail().x; } // OBSOLETED in 1.69 (from Mar 2019) static inline ImDrawList* GetOverlayDrawList() { return GetForegroundDrawList(); } // OBSOLETED in 1.66 (from Sep 2018) static inline void SetScrollHere(float center_ratio=0.5f){ SetScrollHereY(center_ratio); } // OBSOLETED in 1.63 (between Aug 2018 and Sept 2018) static inline bool IsItemDeactivatedAfterChange() { return IsItemDeactivatedAfterEdit(); } // OBSOLETED in 1.61 (between Apr 2018 and Aug 2018) IMGUI_API bool InputFloat(const char* label, float* v, float step, float step_fast, int decimal_precision, ImGuiInputTextFlags flags = 0); // Use the 'const char* format' version instead of 'decimal_precision'! IMGUI_API bool InputFloat2(const char* label, float v[2], int decimal_precision, ImGuiInputTextFlags flags = 0); IMGUI_API bool InputFloat3(const char* label, float v[3], int decimal_precision, ImGuiInputTextFlags flags = 0); IMGUI_API bool InputFloat4(const char* label, float v[4], int decimal_precision, ImGuiInputTextFlags flags = 0); // OBSOLETED in 1.60 (between Dec 2017 and Apr 2018) static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); } static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); } static inline ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge = false, float outward = 0.f) { IM_UNUSED(on_edge); IM_UNUSED(outward); IM_ASSERT(0); return pos; } } typedef ImGuiInputTextCallback ImGuiTextEditCallback; // OBSOLETED in 1.63 (from Aug 2018): made the names consistent typedef ImGuiInputTextCallbackData ImGuiTextEditCallbackData; #endif //----------------------------------------------------------------------------- // Helpers //----------------------------------------------------------------------------- // Helper: Execute a block of code at maximum once a frame. Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame. // Usage: static ImGuiOnceUponAFrame oaf; if (oaf) ImGui::Text("This will be called only once per frame"); struct ImGuiOnceUponAFrame { ImGuiOnceUponAFrame() { RefFrame = -1; } mutable int RefFrame; operator bool() const { int current_frame = ImGui::GetFrameCount(); if (RefFrame == current_frame) return false; RefFrame = current_frame; return true; } }; // Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]" struct ImGuiTextFilter { IMGUI_API ImGuiTextFilter(const char* default_filter = ""); IMGUI_API bool Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build IMGUI_API bool PassFilter(const char* text, const char* text_end = NULL) const; IMGUI_API void Build(); void Clear() { InputBuf[0] = 0; Build(); } bool IsActive() const { return !Filters.empty(); } // [Internal] struct ImGuiTextRange { const char* b; const char* e; ImGuiTextRange() { b = e = NULL; } ImGuiTextRange(const char* _b, const char* _e) { b = _b; e = _e; } bool empty() const { return b == e; } IMGUI_API void split(char separator, ImVector* out) const; }; char InputBuf[256]; ImVectorFilters; int CountGrep; }; // Helper: Growable text buffer for logging/accumulating text // (this could be called 'ImGuiTextBuilder' / 'ImGuiStringBuilder') struct ImGuiTextBuffer { ImVector Buf; IMGUI_API static char EmptyString[1]; ImGuiTextBuffer() { } inline char operator[](int i) const { IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; } const char* begin() const { return Buf.Data ? &Buf.front() : EmptyString; } const char* end() const { return Buf.Data ? &Buf.back() : EmptyString; } // Buf is zero-terminated, so end() will point on the zero-terminator int size() const { return Buf.Size ? Buf.Size - 1 : 0; } bool empty() const { return Buf.Size <= 1; } void clear() { Buf.clear(); } void reserve(int capacity) { Buf.reserve(capacity); } const char* c_str() const { return Buf.Data ? Buf.Data : EmptyString; } IMGUI_API void append(const char* str, const char* str_end = NULL); IMGUI_API void appendf(const char* fmt, ...) IM_FMTARGS(2); IMGUI_API void appendfv(const char* fmt, va_list args) IM_FMTLIST(2); }; // Helper: Key->Value storage // Typically you don't have to worry about this since a storage is held within each Window. // We use it to e.g. store collapse state for a tree (Int 0/1) // This is optimized for efficient lookup (dichotomy into a contiguous buffer) and rare insertion (typically tied to user interactions aka max once a frame) // You can use it as custom user storage for temporary values. Declare your own storage if, for example: // - You want to manipulate the open/close state of a particular sub-tree in your interface (tree node uses Int 0/1 to store their state). // - You want to store custom debug data easily without adding or editing structures in your code (probably not efficient, but convenient) // Types are NOT stored, so it is up to you to make sure your Key don't collide with different types. struct ImGuiStorage { // [Internal] struct ImGuiStoragePair { ImGuiID key; union { int val_i; float val_f; void* val_p; }; ImGuiStoragePair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; } ImGuiStoragePair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; } ImGuiStoragePair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; } }; ImVector Data; // - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N) // - Set***() functions find pair, insertion on demand if missing. // - Sorted insertion is costly, paid once. A typical frame shouldn't need to insert any new pair. void Clear() { Data.clear(); } IMGUI_API int GetInt(ImGuiID key, int default_val = 0) const; IMGUI_API void SetInt(ImGuiID key, int val); IMGUI_API bool GetBool(ImGuiID key, bool default_val = false) const; IMGUI_API void SetBool(ImGuiID key, bool val); IMGUI_API float GetFloat(ImGuiID key, float default_val = 0.0f) const; IMGUI_API void SetFloat(ImGuiID key, float val); IMGUI_API void* GetVoidPtr(ImGuiID key) const; // default_val is NULL IMGUI_API void SetVoidPtr(ImGuiID key, void* val); // - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set. // - References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer. // - A typical use case where this is convenient for quick hacking (e.g. add storage during a live Edit&Continue session if you can't modify existing struct) // float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar; IMGUI_API int* GetIntRef(ImGuiID key, int default_val = 0); IMGUI_API bool* GetBoolRef(ImGuiID key, bool default_val = false); IMGUI_API float* GetFloatRef(ImGuiID key, float default_val = 0.0f); IMGUI_API void** GetVoidPtrRef(ImGuiID key, void* default_val = NULL); // Use on your own storage if you know only integer are being stored (open/close all tree nodes) IMGUI_API void SetAllInt(int val); // For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once. IMGUI_API void BuildSortByKey(); }; // Helper: Manually clip large list of items. // If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse clipping based on visibility to save yourself from processing those items at all. // The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped. // ImGui already clip items based on their bounds but it needs to measure text size to do so. Coarse clipping before submission makes this cost and your own data fetching/submission cost null. // Usage: // ImGuiListClipper clipper(1000); // we have 1000 elements, evenly spaced. // while (clipper.Step()) // for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) // ImGui::Text("line number %d", i); // - Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height (step skipped if we passed a known height as second arg to constructor). // - Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element. // - (Step 2: dummy step only required if an explicit items_height was passed to constructor or Begin() and user call Step(). Does nothing and switch to Step 3.) // - Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), advance the cursor to the end of the list and then returns 'false' to end the loop. struct ImGuiListClipper { int DisplayStart, DisplayEnd; int ItemsCount; // [Internal] int StepNo; float ItemsHeight; float StartPosY; // items_count: Use -1 to ignore (you can call Begin later). Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step). // items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing(). // If you don't specify an items_height, you NEED to call Step(). If you specify items_height you may call the old Begin()/End() api directly, but prefer calling Step(). ImGuiListClipper(int items_count = -1, float items_height = -1.0f) { Begin(items_count, items_height); } // NB: Begin() initialize every fields (as we allow user to call Begin/End multiple times on a same instance if they want). ~ImGuiListClipper() { IM_ASSERT(ItemsCount == -1); } // Assert if user forgot to call End() or Step() until false. IMGUI_API bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items. IMGUI_API void Begin(int items_count, float items_height = -1.0f); // Automatically called by constructor if you passed 'items_count' or by Step() in Step 1. IMGUI_API void End(); // Automatically called on the last call of Step() that returns false. }; // Helpers macros to generate 32-bit encoded colors #ifdef IMGUI_USE_BGRA_PACKED_COLOR #define IM_COL32_R_SHIFT 16 #define IM_COL32_G_SHIFT 8 #define IM_COL32_B_SHIFT 0 #define IM_COL32_A_SHIFT 24 #define IM_COL32_A_MASK 0xFF000000 #else #define IM_COL32_R_SHIFT 0 #define IM_COL32_G_SHIFT 8 #define IM_COL32_B_SHIFT 16 #define IM_COL32_A_SHIFT 24 #define IM_COL32_A_MASK 0xFF000000 #endif #define IM_COL32(R,G,B,A) (((ImU32)(A)<>IM_COL32_R_SHIFT)&0xFF) * sc; Value.y = (float)((rgba>>IM_COL32_G_SHIFT)&0xFF) * sc; Value.z = (float)((rgba>>IM_COL32_B_SHIFT)&0xFF) * sc; Value.w = (float)((rgba>>IM_COL32_A_SHIFT)&0xFF) * sc; } ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; } ImColor(const ImVec4& col) { Value = col; } inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); } inline operator ImVec4() const { return Value; } // FIXME-OBSOLETE: May need to obsolete/cleanup those helpers. inline void SetHSV(float h, float s, float v, float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; } static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r,g,b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r,g,b,a); } }; //----------------------------------------------------------------------------- // Draw List API (ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawListFlags, ImDrawList, ImDrawData) // Hold a series of drawing commands. The user provides a renderer for ImDrawData which essentially contains an array of ImDrawList. //----------------------------------------------------------------------------- // Draw callbacks for advanced uses. // NB: You most likely do NOT need to use draw callbacks just to create your own widget or customized UI rendering, // you can poke into the draw list for that! Draw callback may be useful for example to: // A) Change your GPU render state, // B) render a complex 3D scene inside a UI element without an intermediate texture/render target, etc. // The expected behavior from your rendering function is 'if (cmd.UserCallback != NULL) { cmd.UserCallback(parent_list, cmd); } else { RenderTriangles() }' // If you want to override the signature of ImDrawCallback, you can simply use e.g. '#define ImDrawCallback MyDrawCallback' (in imconfig.h) + update rendering back-end accordingly. #ifndef ImDrawCallback typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd); #endif // Special Draw callback value to request renderer back-end to reset the graphics/render state. // The renderer back-end needs to handle this special value, otherwise it will crash trying to call a function at this address. // This is useful for example if you submitted callbacks which you know have altered the render state and you want it to be restored. // It is not done by default because they are many perfectly useful way of altering render state for imgui contents (e.g. changing shader/blending settings before an Image call). #define ImDrawCallback_ResetRenderState (ImDrawCallback)(-1) // Typically, 1 command = 1 GPU draw call (unless command is a callback) // Pre 1.71 back-ends will typically ignore the VtxOffset/IdxOffset fields. When 'io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset' // is enabled, those fields allow us to render meshes larger than 64K vertices while keeping 16-bit indices. struct ImDrawCmd { unsigned int ElemCount; // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[]. ImVec4 ClipRect; // Clipping rectangle (x1, y1, x2, y2). Subtract ImDrawData->DisplayPos to get clipping rectangle in "viewport" coordinates ImTextureID TextureId; // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas. unsigned int VtxOffset; // Start offset in vertex buffer. Pre-1.71 or without ImGuiBackendFlags_RendererHasVtxOffset: always 0. With ImGuiBackendFlags_RendererHasVtxOffset: may be >0 to support meshes larger than 64K vertices with 16-bit indices. unsigned int IdxOffset; // Start offset in index buffer. Always equal to sum of ElemCount drawn so far. ImDrawCallback UserCallback; // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally. void* UserCallbackData; // The draw callback code can access this. ImDrawCmd() { ElemCount = 0; TextureId = (ImTextureID)NULL; VtxOffset = IdxOffset = 0; UserCallback = NULL; UserCallbackData = NULL; } }; // Vertex index // (to allow large meshes with 16-bit indices: set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' and handle ImDrawCmd::VtxOffset in the renderer back-end) // (to use 32-bit indices: override with '#define ImDrawIdx unsigned int' in imconfig.h) #ifndef ImDrawIdx typedef unsigned short ImDrawIdx; #endif // Vertex layout #ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; ImVec2 uv; ImU32 col; }; #else // You can override the vertex format layout by defining IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT in imconfig.h // The code expect ImVec2 pos (8 bytes), ImVec2 uv (8 bytes), ImU32 col (4 bytes), but you can re-order them or add other fields as needed to simplify integration in your engine. // The type has to be described within the macro (you can either declare the struct or use a typedef). This is because ImVec2/ImU32 are likely not declared a the time you'd want to set your type up. // NOTE: IMGUI DOESN'T CLEAR THE STRUCTURE AND DOESN'T CALL A CONSTRUCTOR SO ANY CUSTOM FIELD WILL BE UNINITIALIZED. IF YOU ADD EXTRA FIELDS (SUCH AS A 'Z' COORDINATES) YOU WILL NEED TO CLEAR THEM DURING RENDER OR TO IGNORE THEM. IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT; #endif // For use by ImDrawListSplitter. struct ImDrawChannel { ImVector _CmdBuffer; ImVector _IdxBuffer; }; // Split/Merge functions are used to split the draw list into different layers which can be drawn into out of order. // This is used by the Columns api, so items of each column can be batched together in a same draw call. struct ImDrawListSplitter { int _Current; // Current channel number (0) int _Count; // Number of active channels (1+) ImVector _Channels; // Draw channels (not resized down so _Count might be < Channels.Size) inline ImDrawListSplitter() { Clear(); } inline ~ImDrawListSplitter() { ClearFreeMemory(); } inline void Clear() { _Current = 0; _Count = 1; } // Do not clear Channels[] so our allocations are reused next frame IMGUI_API void ClearFreeMemory(); IMGUI_API void Split(ImDrawList* draw_list, int count); IMGUI_API void Merge(ImDrawList* draw_list); IMGUI_API void SetCurrentChannel(ImDrawList* draw_list, int channel_idx); }; enum ImDrawCornerFlags_ { ImDrawCornerFlags_None = 0, ImDrawCornerFlags_TopLeft = 1 << 0, // 0x1 ImDrawCornerFlags_TopRight = 1 << 1, // 0x2 ImDrawCornerFlags_BotLeft = 1 << 2, // 0x4 ImDrawCornerFlags_BotRight = 1 << 3, // 0x8 ImDrawCornerFlags_Top = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_TopRight, // 0x3 ImDrawCornerFlags_Bot = ImDrawCornerFlags_BotLeft | ImDrawCornerFlags_BotRight, // 0xC ImDrawCornerFlags_Left = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotLeft, // 0x5 ImDrawCornerFlags_Right = ImDrawCornerFlags_TopRight | ImDrawCornerFlags_BotRight, // 0xA ImDrawCornerFlags_All = 0xF // In your function calls you may use ~0 (= all bits sets) instead of ImDrawCornerFlags_All, as a convenience }; enum ImDrawListFlags_ { ImDrawListFlags_None = 0, ImDrawListFlags_AntiAliasedLines = 1 << 0, // Lines are anti-aliased (*2 the number of triangles for 1.0f wide line, otherwise *3 the number of triangles) ImDrawListFlags_AntiAliasedFill = 1 << 1, // Filled shapes have anti-aliased edges (*2 the number of vertices) ImDrawListFlags_AllowVtxOffset = 1 << 2 // Can emit 'VtxOffset > 0' to allow large meshes. Set when 'ImGuiBackendFlags_RendererHasVtxOffset' is enabled. }; // Draw command list // This is the low-level list of polygons that ImGui:: functions are filling. At the end of the frame, // all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering. // Each dear imgui window contains its own ImDrawList. You can use ImGui::GetWindowDrawList() to // access the current window draw list and draw custom primitives. // You can interleave normal ImGui:: calls and adding primitives to the current draw list. // All positions are generally in pixel coordinates (top-left at (0,0), bottom-right at io.DisplaySize), but you are totally free to apply whatever transformation matrix to want to the data (if you apply such transformation you'll want to apply it to ClipRect as well) // Important: Primitives are always added to the list and not culled (culling is done at higher-level by ImGui:: functions), if you use this API a lot consider coarse culling your drawn objects. struct ImDrawList { // This is what you have to render ImVector CmdBuffer; // Draw commands. Typically 1 command = 1 GPU draw call, unless the command is a callback. ImVector IdxBuffer; // Index buffer. Each command consume ImDrawCmd::ElemCount of those ImVector VtxBuffer; // Vertex buffer. ImDrawListFlags Flags; // Flags, you may poke into these to adjust anti-aliasing settings per-primitive. // [Internal, used while building lists] const ImDrawListSharedData* _Data; // Pointer to shared draw data (you can use ImGui::GetDrawListSharedData() to get the one from current ImGui context) const char* _OwnerName; // Pointer to owner window's name for debugging unsigned int _VtxCurrentOffset; // [Internal] Always 0 unless 'Flags & ImDrawListFlags_AllowVtxOffset'. unsigned int _VtxCurrentIdx; // [Internal] Generally == VtxBuffer.Size unless we are past 64K vertices, in which case this gets reset to 0. ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much) ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much) ImVector _ClipRectStack; // [Internal] ImVector _TextureIdStack; // [Internal] ImVector _Path; // [Internal] current path building ImDrawListSplitter _Splitter; // [Internal] for channels api // If you want to create ImDrawList instances, pass them ImGui::GetDrawListSharedData() or create and use your own ImDrawListSharedData (so you can use ImDrawList without ImGui) ImDrawList(const ImDrawListSharedData* shared_data) { _Data = shared_data; _OwnerName = NULL; Clear(); } ~ImDrawList() { ClearFreeMemory(); } IMGUI_API void PushClipRect(ImVec2 clip_rect_min, ImVec2 clip_rect_max, bool intersect_with_current_clip_rect = false); // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling) IMGUI_API void PushClipRectFullScreen(); IMGUI_API void PopClipRect(); IMGUI_API void PushTextureID(ImTextureID texture_id); IMGUI_API void PopTextureID(); inline ImVec2 GetClipRectMin() const { const ImVec4& cr = _ClipRectStack.back(); return ImVec2(cr.x, cr.y); } inline ImVec2 GetClipRectMax() const { const ImVec4& cr = _ClipRectStack.back(); return ImVec2(cr.z, cr.w); } // Primitives // - For rectangular primitives, "p_min" and "p_max" represent the upper-left and lower-right corners. // - For circle primitives, use "num_segments == 0" to automatically calculate tessellation (preferred). // In future versions we will use textures to provide cheaper and higher-quality circles. // Use AddNgon() and AddNgonFilled() functions if you need to guaranteed a specific number of sides. IMGUI_API void AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness = 1.0f); IMGUI_API void AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All, float thickness = 1.0f); // a: upper-left, b: lower-right (== upper-left + size), rounding_corners_flags: 4 bits corresponding to which corner to round IMGUI_API void AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All); // a: upper-left, b: lower-right (== upper-left + size) IMGUI_API void AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left); IMGUI_API void AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness = 1.0f); IMGUI_API void AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col); IMGUI_API void AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness = 1.0f); IMGUI_API void AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col); IMGUI_API void AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments = 12, float thickness = 1.0f); IMGUI_API void AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments = 12); IMGUI_API void AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness = 1.0f); IMGUI_API void AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments); IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL); IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL); IMGUI_API void AddPolyline(const ImVec2* points, int num_points, ImU32 col, bool closed, float thickness); IMGUI_API void AddConvexPolyFilled(const ImVec2* points, int num_points, ImU32 col); // Note: Anti-aliased filling requires points to be in clockwise order. IMGUI_API void AddBezierCurve(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments = 0); // Image primitives // - Read FAQ to understand what ImTextureID is. // - "p_min" and "p_max" represent the upper-left and lower-right corners of the rectangle. // - "uv_min" and "uv_max" represent the normalized texture coordinates to use for those corners. Using (0,0)->(1,1) texture coordinates will generally display the entire texture. IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min = ImVec2(0, 0), const ImVec2& uv_max = ImVec2(1, 1), ImU32 col = IM_COL32_WHITE); IMGUI_API void AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1 = ImVec2(0, 0), const ImVec2& uv2 = ImVec2(1, 0), const ImVec2& uv3 = ImVec2(1, 1), const ImVec2& uv4 = ImVec2(0, 1), ImU32 col = IM_COL32_WHITE); IMGUI_API void AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All); // Stateful path API, add points then finish with PathFillConvex() or PathStroke() inline void PathClear() { _Path.Size = 0; } inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); } inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path.Data[_Path.Size-1], &pos, 8) != 0) _Path.push_back(pos); } inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; } // Note: Anti-aliased filling requires points to be in clockwise order. inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); _Path.Size = 0; } IMGUI_API void PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments = 10); IMGUI_API void PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle IMGUI_API void PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments = 0); IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All); // Advanced IMGUI_API void AddCallback(ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles. IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible IMGUI_API ImDrawList* CloneOutput() const; // Create a clone of the CmdBuffer/IdxBuffer/VtxBuffer. // Advanced: Channels // - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit FG primitives before BG primitives) // - Use to minimize draw calls (e.g. if going back-and-forth between multiple clipping rectangles, prefer to append into separate channels then merge at the end) // - FIXME-OBSOLETE: This API shouldn't have been in ImDrawList in the first place! // Prefer using your own persistent copy of ImDrawListSplitter as you can stack them. // Using the ImDrawList::ChannelsXXXX you cannot stack a split over another. inline void ChannelsSplit(int count) { _Splitter.Split(this, count); } inline void ChannelsMerge() { _Splitter.Merge(this); } inline void ChannelsSetCurrent(int n) { _Splitter.SetCurrentChannel(this, n); } // Internal helpers // NB: all primitives needs to be reserved via PrimReserve() beforehand! IMGUI_API void Clear(); IMGUI_API void ClearFreeMemory(); IMGUI_API void PrimReserve(int idx_count, int vtx_count); IMGUI_API void PrimUnreserve(int idx_count, int vtx_count); IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col); // Axis aligned rectangle (composed of two triangles) IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col); IMGUI_API void PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col); inline void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col){ _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; } inline void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; } inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } IMGUI_API void UpdateClipRect(); IMGUI_API void UpdateTextureID(); }; // All draw data to render a Dear ImGui frame // (NB: the style and the naming convention here is a little inconsistent, we currently preserve them for backward compatibility purpose, // as this is one of the oldest structure exposed by the library! Basically, ImDrawList == CmdList) struct ImDrawData { bool Valid; // Only valid after Render() is called and before the next NewFrame() is called. ImDrawList** CmdLists; // Array of ImDrawList* to render. The ImDrawList are owned by ImGuiContext and only pointed to from here. int CmdListsCount; // Number of ImDrawList* to render int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size ImVec2 DisplayPos; // Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use) ImVec2 DisplaySize; // Size of the viewport to render (== io.DisplaySize for the main viewport) (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use) ImVec2 FramebufferScale; // Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display. // Functions ImDrawData() { Valid = false; Clear(); } ~ImDrawData() { Clear(); } void Clear() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; DisplayPos = DisplaySize = FramebufferScale = ImVec2(0.f, 0.f); } // The ImDrawList are owned by ImGuiContext! IMGUI_API void DeIndexAllBuffers(); // Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering! IMGUI_API void ScaleClipRects(const ImVec2& fb_scale); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than Dear ImGui expects, or if there is a difference between your window resolution and framebuffer resolution. }; //----------------------------------------------------------------------------- // Font API (ImFontConfig, ImFontGlyph, ImFontAtlasFlags, ImFontAtlas, ImFontGlyphRangesBuilder, ImFont) //----------------------------------------------------------------------------- struct ImFontConfig { void* FontData; // // TTF/OTF data int FontDataSize; // // TTF/OTF data size bool FontDataOwnedByAtlas; // true // TTF/OTF data ownership taken by the container ImFontAtlas (will delete memory itself). int FontNo; // 0 // Index of font within TTF/OTF file float SizePixels; // // Size in pixels for rasterizer (more or less maps to the resulting font height). int OversampleH; // 3 // Rasterize at higher quality for sub-pixel positioning. Read https://github.com/nothings/stb/blob/master/tests/oversample/README.md for details. int OversampleV; // 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis. bool PixelSnapH; // false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1. ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs. Only X axis is supported for now. ImVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input. const ImWchar* GlyphRanges; // NULL // Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE. float GlyphMinAdvanceX; // 0 // Minimum AdvanceX for glyphs, set Min to align font icons, set both Min/Max to enforce mono-space font float GlyphMaxAdvanceX; // FLT_MAX // Maximum AdvanceX for glyphs bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs). You may want to use GlyphOffset.y when merge font of different heights. unsigned int RasterizerFlags; // 0x00 // Settings for custom font rasterizer (e.g. ImGuiFreeType). Leave as zero if you aren't using one. float RasterizerMultiply; // 1.0f // Brighten (>1.0f) or darken (<1.0f) font output. Brightening small fonts may be a good workaround to make them more readable. ImWchar EllipsisChar; // -1 // Explicitly specify unicode codepoint of ellipsis character. When fonts are being merged first specified ellipsis will be used. // [Internal] char Name[40]; // Name (strictly to ease debugging) ImFont* DstFont; IMGUI_API ImFontConfig(); }; struct ImFontGlyph { ImWchar Codepoint; // 0x0000..0xFFFF float AdvanceX; // Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in) float X0, Y0, X1, Y1; // Glyph corners float U0, V0, U1, V1; // Texture coordinates }; // Helper to build glyph ranges from text/string data. Feed your application strings/characters to it then call BuildRanges(). // This is essentially a tightly packed of vector of 64k booleans = 8KB storage. struct ImFontGlyphRangesBuilder { ImVector UsedChars; // Store 1-bit per Unicode code point (0=unused, 1=used) ImFontGlyphRangesBuilder() { Clear(); } inline void Clear() { int size_in_bytes = (IM_UNICODE_CODEPOINT_MAX+1) / 8; UsedChars.resize(size_in_bytes / (int)sizeof(ImU32)); memset(UsedChars.Data, 0, (size_t)size_in_bytes); } inline bool GetBit(int n) const { int off = (n >> 5); ImU32 mask = 1u << (n & 31); return (UsedChars[off] & mask) != 0; } // Get bit n in the array inline void SetBit(int n) { int off = (n >> 5); ImU32 mask = 1u << (n & 31); UsedChars[off] |= mask; } // Set bit n in the array inline void AddChar(ImWchar c) { SetBit(c); } // Add character IMGUI_API void AddText(const char* text, const char* text_end = NULL); // Add string (each character of the UTF-8 string are added) IMGUI_API void AddRanges(const ImWchar* ranges); // Add ranges, e.g. builder.AddRanges(ImFontAtlas::GetGlyphRangesDefault()) to force add all of ASCII/Latin+Ext IMGUI_API void BuildRanges(ImVector* out_ranges); // Output new ranges }; // See ImFontAtlas::AddCustomRectXXX functions. struct ImFontAtlasCustomRect { unsigned int ID; // Input // User ID. Use < 0x110000 to map into a font glyph, >= 0x110000 for other/internal/custom texture data. unsigned short Width, Height; // Input // Desired rectangle dimension unsigned short X, Y; // Output // Packed position in Atlas float GlyphAdvanceX; // Input // For custom font glyphs only (ID < 0x110000): glyph xadvance ImVec2 GlyphOffset; // Input // For custom font glyphs only (ID < 0x110000): glyph display offset ImFont* Font; // Input // For custom font glyphs only (ID < 0x110000): target font ImFontAtlasCustomRect() { ID = 0xFFFFFFFF; Width = Height = 0; X = Y = 0xFFFF; GlyphAdvanceX = 0.0f; GlyphOffset = ImVec2(0,0); Font = NULL; } bool IsPacked() const { return X != 0xFFFF; } }; enum ImFontAtlasFlags_ { ImFontAtlasFlags_None = 0, ImFontAtlasFlags_NoPowerOfTwoHeight = 1 << 0, // Don't round the height to next power of two ImFontAtlasFlags_NoMouseCursors = 1 << 1 // Don't build software mouse cursors into the atlas }; // Load and rasterize multiple TTF/OTF fonts into a same texture. The font atlas will build a single texture holding: // - One or more fonts. // - Custom graphics data needed to render the shapes needed by Dear ImGui. // - Mouse cursor shapes for software cursor rendering (unless setting 'Flags |= ImFontAtlasFlags_NoMouseCursors' in the font atlas). // It is the user-code responsibility to setup/build the atlas, then upload the pixel data into a texture accessible by your graphics api. // - Optionally, call any of the AddFont*** functions. If you don't call any, the default font embedded in the code will be loaded for you. // - Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data. // - Upload the pixels data into a texture within your graphics system (see imgui_impl_xxxx.cpp examples) // - Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture in a format natural to your graphics API. // This value will be passed back to you during rendering to identify the texture. Read FAQ entry about ImTextureID for more details. // Common pitfalls: // - If you pass a 'glyph_ranges' array to AddFont*** functions, you need to make sure that your array persist up until the // atlas is build (when calling GetTexData*** or Build()). We only copy the pointer, not the data. // - Important: By default, AddFontFromMemoryTTF() takes ownership of the data. Even though we are not writing to it, we will free the pointer on destruction. // You can set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed, // - Even though many functions are suffixed with "TTF", OTF data is supported just as well. // - This is an old API and it is currently awkward for those and and various other reasons! We will address them in the future! struct ImFontAtlas { IMGUI_API ImFontAtlas(); IMGUI_API ~ImFontAtlas(); IMGUI_API ImFont* AddFont(const ImFontConfig* font_cfg); IMGUI_API ImFont* AddFontDefault(const ImFontConfig* font_cfg = NULL); IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); IMGUI_API ImFont* AddFontFromMemoryTTF(void* font_data, int font_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after destruction of the atlas. Set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed. IMGUI_API ImFont* AddFontFromMemoryCompressedTTF(const void* compressed_font_data, int compressed_font_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp. IMGUI_API ImFont* AddFontFromMemoryCompressedBase85TTF(const char* compressed_font_data_base85, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 parameter. IMGUI_API void ClearInputData(); // Clear input data (all ImFontConfig structures including sizes, TTF data, glyph ranges, etc.) = all the data used to build the texture and fonts. IMGUI_API void ClearTexData(); // Clear output texture data (CPU side). Saves RAM once the texture has been copied to graphics memory. IMGUI_API void ClearFonts(); // Clear output font data (glyphs storage, UV coordinates). IMGUI_API void Clear(); // Clear all input and output. // Build atlas, retrieve pixel data. // User is in charge of copying the pixels into graphics memory (e.g. create a texture with your engine). Then store your texture handle with SetTexID(). // The pitch is always = Width * BytesPerPixels (1 or 4) // Building in RGBA32 format is provided for convenience and compatibility, but note that unless you manually manipulate or copy color data into // the texture (e.g. when using the AddCustomRect*** api), then the RGB pixels emitted will always be white (~75% of memory/bandwidth waste. IMGUI_API bool Build(); // Build pixels data. This is called automatically for you by the GetTexData*** functions. IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel bool IsBuilt() const { return Fonts.Size > 0 && (TexPixelsAlpha8 != NULL || TexPixelsRGBA32 != NULL); } void SetTexID(ImTextureID id) { TexID = id; } //------------------------------------------- // Glyph Ranges //------------------------------------------- // Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list) // NB: Make sure that your string are UTF-8 and NOT in your local code page. In C++11, you can create UTF-8 string literal using the u8"Hello world" syntax. See FAQ for details. // NB: Consider using ImFontGlyphRangesBuilder to build glyph ranges from textual data. IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin IMGUI_API const ImWchar* GetGlyphRangesKorean(); // Default + Korean characters IMGUI_API const ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs IMGUI_API const ImWchar* GetGlyphRangesChineseFull(); // Default + Half-Width + Japanese Hiragana/Katakana + full set of about 21000 CJK Unified Ideographs IMGUI_API const ImWchar* GetGlyphRangesChineseSimplifiedCommon();// Default + Half-Width + Japanese Hiragana/Katakana + set of 2500 CJK Unified Ideographs for common simplified Chinese IMGUI_API const ImWchar* GetGlyphRangesCyrillic(); // Default + about 400 Cyrillic characters IMGUI_API const ImWchar* GetGlyphRangesThai(); // Default + Thai characters IMGUI_API const ImWchar* GetGlyphRangesVietnamese(); // Default + Vietnamese characters //------------------------------------------- // [BETA] Custom Rectangles/Glyphs API //------------------------------------------- // You can request arbitrary rectangles to be packed into the atlas, for your own purposes. // After calling Build(), you can query the rectangle position and render your pixels. // You can also request your rectangles to be mapped as font glyph (given a font + Unicode point), // so you can render e.g. custom colorful icons and use them as regular glyphs. // Read docs/FONTS.txt for more details about using colorful icons. IMGUI_API int AddCustomRectRegular(unsigned int id, int width, int height); // Id needs to be >= 0x110000. Id >= 0x80000000 are reserved for ImGui and ImDrawList IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0,0)); // Id needs to be < 0x110000 to register a rectangle to map into a specific font. const ImFontAtlasCustomRect*GetCustomRectByIndex(int index) const { if (index < 0) return NULL; return &CustomRects[index]; } // [Internal] IMGUI_API void CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max) const; IMGUI_API bool GetMouseCursorTexData(ImGuiMouseCursor cursor, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2]); //------------------------------------------- // Members //------------------------------------------- bool Locked; // Marked as Locked by ImGui::NewFrame() so attempt to modify the atlas will assert. ImFontAtlasFlags Flags; // Build flags (see ImFontAtlasFlags_) ImTextureID TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It is passed back to you during rendering via the ImDrawCmd structure. int TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height. int TexGlyphPadding; // Padding between glyphs within texture in pixels. Defaults to 1. If your rendering method doesn't rely on bilinear filtering you may set this to 0. // [Internal] // NB: Access texture data via GetTexData*() calls! Which will setup a default font for you. unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4 int TexWidth; // Texture width calculated during Build(). int TexHeight; // Texture height calculated during Build(). ImVec2 TexUvScale; // = (1.0f/TexWidth, 1.0f/TexHeight) ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel ImVector Fonts; // Hold all the fonts returned by AddFont*. Fonts[0] is the default font upon calling ImGui::NewFrame(), use ImGui::PushFont()/PopFont() to change the current font. ImVector CustomRects; // Rectangles for packing custom texture data into the atlas. ImVector ConfigData; // Internal data int CustomRectIds[1]; // Identifiers of custom texture rectangle used by ImFontAtlas/ImDrawList #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS typedef ImFontAtlasCustomRect CustomRect; // OBSOLETED in 1.72+ typedef ImFontGlyphRangesBuilder GlyphRangesBuilder; // OBSOLETED in 1.67+ #endif }; // Font runtime data and rendering // ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32(). struct ImFont { // Members: Hot ~20/24 bytes (for CalcTextSize) ImVector IndexAdvanceX; // 12-16 // out // // Sparse. Glyphs->AdvanceX in a directly indexable way (cache-friendly for CalcTextSize functions which only this this info, and are often bottleneck in large UI). float FallbackAdvanceX; // 4 // out // = FallbackGlyph->AdvanceX float FontSize; // 4 // in // // Height of characters/line, set during loading (don't change after loading) // Members: Hot ~36/48 bytes (for CalcTextSize + render loop) ImVector IndexLookup; // 12-16 // out // // Sparse. Index glyphs by Unicode code-point. ImVector Glyphs; // 12-16 // out // // All glyphs. const ImFontGlyph* FallbackGlyph; // 4-8 // out // = FindGlyph(FontFallbackChar) ImVec2 DisplayOffset; // 8 // in // = (0,0) // Offset font rendering by xx pixels // Members: Cold ~32/40 bytes ImFontAtlas* ContainerAtlas; // 4-8 // out // // What we has been loaded into const ImFontConfig* ConfigData; // 4-8 // in // // Pointer within ContainerAtlas->ConfigData short ConfigDataCount; // 2 // in // ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont. ImWchar FallbackChar; // 2 // in // = '?' // Replacement character if a glyph isn't found. Only set via SetFallbackChar() ImWchar EllipsisChar; // 2 // out // = -1 // Character used for ellipsis rendering. bool DirtyLookupTables; // 1 // out // float Scale; // 4 // in // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale() float Ascent, Descent; // 4+4 // out // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize] int MetricsTotalSurface;// 4 // out // // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs) // Methods IMGUI_API ImFont(); IMGUI_API ~ImFont(); IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const; IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c) const; float GetCharAdvance(ImWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; } bool IsLoaded() const { return ContainerAtlas != NULL; } const char* GetDebugName() const { return ConfigData ? ConfigData->Name : ""; } // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable. // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable. IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8 IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const; IMGUI_API void RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const; IMGUI_API void RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false) const; // [Internal] Don't use! IMGUI_API void BuildLookupTable(); IMGUI_API void ClearOutputData(); IMGUI_API void GrowIndex(int new_size); IMGUI_API void AddGlyph(ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x); IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built. IMGUI_API void SetFallbackChar(ImWchar c); }; #if defined(__clang__) #pragma clang diagnostic pop #elif defined(__GNUC__) #pragma GCC diagnostic pop #endif // Include imgui_user.h at the end of imgui.h (convenient for user to only explicitly include vanilla imgui.h) #ifdef IMGUI_INCLUDE_IMGUI_USER_H #include "imgui_user.h" #endif #endif // #ifndef IMGUI_DISABLE goxel-0.11.0/ext_src/imgui/imgui_draw.cpp000066400000000000000000005173651435762723100203560ustar00rootroot00000000000000// dear imgui, v1.75 // (drawing and font code) /* Index of this file: // [SECTION] STB libraries implementation // [SECTION] Style functions // [SECTION] ImDrawList // [SECTION] ImDrawListSplitter // [SECTION] ImDrawData // [SECTION] Helpers ShadeVertsXXX functions // [SECTION] ImFontConfig // [SECTION] ImFontAtlas // [SECTION] ImFontAtlas glyph ranges helpers // [SECTION] ImFontGlyphRangesBuilder // [SECTION] ImFont // [SECTION] Internal Render Helpers // [SECTION] Decompression code // [SECTION] Default font data (ProggyClean.ttf) */ #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) #define _CRT_SECURE_NO_WARNINGS #endif #include "imgui.h" #ifndef IMGUI_DISABLE #ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS #endif #include "imgui_internal.h" #include // vsnprintf, sscanf, printf #if !defined(alloca) #if defined(__GLIBC__) || defined(__sun) || defined(__CYGWIN__) || defined(__APPLE__) || defined(__SWITCH__) #include // alloca (glibc uses . Note that Cygwin may have _WIN32 defined, so the order matters here) #elif defined(_WIN32) #include // alloca #if !defined(alloca) #define alloca _alloca // for clang with MS Codegen #endif #else #include // alloca #endif #endif // Visual Studio warnings #ifdef _MSC_VER #pragma warning (disable: 4127) // condition expression is constant #pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff) #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen #endif // Clang/GCC warnings with -Weverything #if defined(__clang__) #pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse. #pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants ok. #pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference is. #pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness // #if __has_warning("-Wzero-as-null-pointer-constant") #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning : zero as null pointer constant // some standard header variations use #define NULL 0 #endif #if __has_warning("-Wcomma") #pragma clang diagnostic ignored "-Wcomma" // warning : possible misuse of comma operator here // #endif #if __has_warning("-Wreserved-id-macro") #pragma clang diagnostic ignored "-Wreserved-id-macro" // warning : macro name is a reserved identifier // #endif #if __has_warning("-Wdouble-promotion") #pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. #endif #elif defined(__GNUC__) #pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind #pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used #pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function #pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value #pragma GCC diagnostic ignored "-Wstack-protector" // warning: stack protector not protecting local variables: variable length buffer #pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead #endif //------------------------------------------------------------------------- // [SECTION] STB libraries implementation //------------------------------------------------------------------------- // Compile time options: //#define IMGUI_STB_NAMESPACE ImStb //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION #ifdef IMGUI_STB_NAMESPACE namespace IMGUI_STB_NAMESPACE { #endif #ifdef _MSC_VER #pragma warning (push) #pragma warning (disable: 4456) // declaration of 'xx' hides previous local declaration #endif #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-function" #pragma clang diagnostic ignored "-Wmissing-prototypes" #pragma clang diagnostic ignored "-Wimplicit-fallthrough" #pragma clang diagnostic ignored "-Wcast-qual" // warning : cast from 'const xxxx *' to 'xxx *' drops const qualifier // #endif #if defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wtype-limits" // warning: comparison is always true due to limited range of data type [-Wtype-limits] #pragma GCC diagnostic ignored "-Wcast-qual" // warning: cast from type 'const xxxx *' to type 'xxxx *' casts away qualifiers #endif #ifndef STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds) #ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION #define STBRP_STATIC #define STBRP_ASSERT(x) IM_ASSERT(x) #define STBRP_SORT ImQsort #define STB_RECT_PACK_IMPLEMENTATION #endif #ifdef IMGUI_STB_RECT_PACK_FILENAME #include IMGUI_STB_RECT_PACK_FILENAME #else #include "imstb_rectpack.h" #endif #endif #ifndef STB_TRUETYPE_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds) #ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION #define STBTT_malloc(x,u) ((void)(u), IM_ALLOC(x)) #define STBTT_free(x,u) ((void)(u), IM_FREE(x)) #define STBTT_assert(x) IM_ASSERT(x) #define STBTT_fmod(x,y) ImFmod(x,y) #define STBTT_sqrt(x) ImSqrt(x) #define STBTT_pow(x,y) ImPow(x,y) #define STBTT_fabs(x) ImFabs(x) #define STBTT_ifloor(x) ((int)ImFloorStd(x)) #define STBTT_iceil(x) ((int)ImCeil(x)) #define STBTT_STATIC #define STB_TRUETYPE_IMPLEMENTATION #else #define STBTT_DEF extern #endif #ifdef IMGUI_STB_TRUETYPE_FILENAME #include IMGUI_STB_TRUETYPE_FILENAME #else #include "imstb_truetype.h" #endif #endif #if defined(__GNUC__) #pragma GCC diagnostic pop #endif #if defined(__clang__) #pragma clang diagnostic pop #endif #if defined(_MSC_VER) #pragma warning (pop) #endif #ifdef IMGUI_STB_NAMESPACE } // namespace ImStb using namespace IMGUI_STB_NAMESPACE; #endif //----------------------------------------------------------------------------- // [SECTION] Style functions //----------------------------------------------------------------------------- void ImGui::StyleColorsDark(ImGuiStyle* dst) { ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); ImVec4* colors = style->Colors; colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f); colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.29f, 0.48f, 0.54f); colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f); colors[ImGuiCol_TitleBgActive] = ImVec4(0.16f, 0.29f, 0.48f, 1.00f); colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f); colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f); colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); colors[ImGuiCol_SliderGrab] = ImVec4(0.24f, 0.52f, 0.88f, 1.00f); colors[ImGuiCol_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f); colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); colors[ImGuiCol_Separator] = colors[ImGuiCol_Border]; colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f); colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f); colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.25f); colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f); colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered]; colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f); colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f); colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); } void ImGui::StyleColorsClassic(ImGuiStyle* dst) { ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); ImVec4* colors = style->Colors; colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.70f); colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_PopupBg] = ImVec4(0.11f, 0.11f, 0.14f, 0.92f); colors[ImGuiCol_Border] = ImVec4(0.50f, 0.50f, 0.50f, 0.50f); colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_FrameBg] = ImVec4(0.43f, 0.43f, 0.43f, 0.39f); colors[ImGuiCol_FrameBgHovered] = ImVec4(0.47f, 0.47f, 0.69f, 0.40f); colors[ImGuiCol_FrameBgActive] = ImVec4(0.42f, 0.41f, 0.64f, 0.69f); colors[ImGuiCol_TitleBg] = ImVec4(0.27f, 0.27f, 0.54f, 0.83f); colors[ImGuiCol_TitleBgActive] = ImVec4(0.32f, 0.32f, 0.63f, 0.87f); colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.40f, 0.40f, 0.80f, 0.20f); colors[ImGuiCol_MenuBarBg] = ImVec4(0.40f, 0.40f, 0.55f, 0.80f); colors[ImGuiCol_ScrollbarBg] = ImVec4(0.20f, 0.25f, 0.30f, 0.60f); colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.40f, 0.80f, 0.30f); colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.40f, 0.80f, 0.40f); colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.41f, 0.39f, 0.80f, 0.60f); colors[ImGuiCol_CheckMark] = ImVec4(0.90f, 0.90f, 0.90f, 0.50f); colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f); colors[ImGuiCol_SliderGrabActive] = ImVec4(0.41f, 0.39f, 0.80f, 0.60f); colors[ImGuiCol_Button] = ImVec4(0.35f, 0.40f, 0.61f, 0.62f); colors[ImGuiCol_ButtonHovered] = ImVec4(0.40f, 0.48f, 0.71f, 0.79f); colors[ImGuiCol_ButtonActive] = ImVec4(0.46f, 0.54f, 0.80f, 1.00f); colors[ImGuiCol_Header] = ImVec4(0.40f, 0.40f, 0.90f, 0.45f); colors[ImGuiCol_HeaderHovered] = ImVec4(0.45f, 0.45f, 0.90f, 0.80f); colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.53f, 0.87f, 0.80f); colors[ImGuiCol_Separator] = ImVec4(0.50f, 0.50f, 0.50f, 0.60f); colors[ImGuiCol_SeparatorHovered] = ImVec4(0.60f, 0.60f, 0.70f, 1.00f); colors[ImGuiCol_SeparatorActive] = ImVec4(0.70f, 0.70f, 0.90f, 1.00f); colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.16f); colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.78f, 0.82f, 1.00f, 0.60f); colors[ImGuiCol_ResizeGripActive] = ImVec4(0.78f, 0.82f, 1.00f, 0.90f); colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f); colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered]; colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f); colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f); colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f); colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); colors[ImGuiCol_NavHighlight] = colors[ImGuiCol_HeaderHovered]; colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); } // Those light colors are better suited with a thicker font than the default one + FrameBorder void ImGui::StyleColorsLight(ImGuiStyle* dst) { ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); ImVec4* colors = style->Colors; colors[ImGuiCol_Text] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); colors[ImGuiCol_WindowBg] = ImVec4(0.94f, 0.94f, 0.94f, 1.00f); colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_PopupBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.98f); colors[ImGuiCol_Border] = ImVec4(0.00f, 0.00f, 0.00f, 0.30f); colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_FrameBg] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); colors[ImGuiCol_TitleBg] = ImVec4(0.96f, 0.96f, 0.96f, 1.00f); colors[ImGuiCol_TitleBgActive] = ImVec4(0.82f, 0.82f, 0.82f, 1.00f); colors[ImGuiCol_TitleBgCollapsed] = ImVec4(1.00f, 1.00f, 1.00f, 0.51f); colors[ImGuiCol_MenuBarBg] = ImVec4(0.86f, 0.86f, 0.86f, 1.00f); colors[ImGuiCol_ScrollbarBg] = ImVec4(0.98f, 0.98f, 0.98f, 0.53f); colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.69f, 0.69f, 0.69f, 0.80f); colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.49f, 0.49f, 0.49f, 0.80f); colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.49f, 0.49f, 0.49f, 1.00f); colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); colors[ImGuiCol_SliderGrab] = ImVec4(0.26f, 0.59f, 0.98f, 0.78f); colors[ImGuiCol_SliderGrabActive] = ImVec4(0.46f, 0.54f, 0.80f, 0.60f); colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f); colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); colors[ImGuiCol_Separator] = ImVec4(0.39f, 0.39f, 0.39f, 0.62f); colors[ImGuiCol_SeparatorHovered] = ImVec4(0.14f, 0.44f, 0.80f, 0.78f); colors[ImGuiCol_SeparatorActive] = ImVec4(0.14f, 0.44f, 0.80f, 1.00f); colors[ImGuiCol_ResizeGrip] = ImVec4(0.80f, 0.80f, 0.80f, 0.56f); colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.90f); colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered]; colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f); colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f); colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f); colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.45f, 0.00f, 1.00f); colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); colors[ImGuiCol_DragDropTarget] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); colors[ImGuiCol_NavHighlight] = colors[ImGuiCol_HeaderHovered]; colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.70f, 0.70f, 0.70f, 0.70f); colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.20f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); } //----------------------------------------------------------------------------- // ImDrawList //----------------------------------------------------------------------------- ImDrawListSharedData::ImDrawListSharedData() { Font = NULL; FontSize = 0.0f; CurveTessellationTol = 0.0f; CircleSegmentMaxError = 0.0f; ClipRectFullscreen = ImVec4(-8192.0f, -8192.0f, +8192.0f, +8192.0f); InitialFlags = ImDrawListFlags_None; // Lookup tables for (int i = 0; i < IM_ARRAYSIZE(CircleVtx12); i++) { const float a = ((float)i * 2 * IM_PI) / (float)IM_ARRAYSIZE(CircleVtx12); CircleVtx12[i] = ImVec2(ImCos(a), ImSin(a)); } memset(CircleSegmentCounts, 0, sizeof(CircleSegmentCounts)); // This will be set by SetCircleSegmentMaxError() } void ImDrawListSharedData::SetCircleSegmentMaxError(float max_error) { if (CircleSegmentMaxError == max_error) return; CircleSegmentMaxError = max_error; for (int i = 0; i < IM_ARRAYSIZE(CircleSegmentCounts); i++) { const float radius = i + 1.0f; const int segment_count = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, CircleSegmentMaxError); CircleSegmentCounts[i] = (ImU8)ImMin(segment_count, 255); } } void ImDrawList::Clear() { CmdBuffer.resize(0); IdxBuffer.resize(0); VtxBuffer.resize(0); Flags = _Data ? _Data->InitialFlags : ImDrawListFlags_None; _VtxCurrentOffset = 0; _VtxCurrentIdx = 0; _VtxWritePtr = NULL; _IdxWritePtr = NULL; _ClipRectStack.resize(0); _TextureIdStack.resize(0); _Path.resize(0); _Splitter.Clear(); } void ImDrawList::ClearFreeMemory() { CmdBuffer.clear(); IdxBuffer.clear(); VtxBuffer.clear(); _VtxCurrentIdx = 0; _VtxWritePtr = NULL; _IdxWritePtr = NULL; _ClipRectStack.clear(); _TextureIdStack.clear(); _Path.clear(); _Splitter.ClearFreeMemory(); } ImDrawList* ImDrawList::CloneOutput() const { ImDrawList* dst = IM_NEW(ImDrawList(_Data)); dst->CmdBuffer = CmdBuffer; dst->IdxBuffer = IdxBuffer; dst->VtxBuffer = VtxBuffer; dst->Flags = Flags; return dst; } // Using macros because C++ is a terrible language, we want guaranteed inline, no code in header, and no overhead in Debug builds #define GetCurrentClipRect() (_ClipRectStack.Size ? _ClipRectStack.Data[_ClipRectStack.Size-1] : _Data->ClipRectFullscreen) #define GetCurrentTextureId() (_TextureIdStack.Size ? _TextureIdStack.Data[_TextureIdStack.Size-1] : (ImTextureID)NULL) void ImDrawList::AddDrawCmd() { ImDrawCmd draw_cmd; draw_cmd.ClipRect = GetCurrentClipRect(); draw_cmd.TextureId = GetCurrentTextureId(); draw_cmd.VtxOffset = _VtxCurrentOffset; draw_cmd.IdxOffset = IdxBuffer.Size; IM_ASSERT(draw_cmd.ClipRect.x <= draw_cmd.ClipRect.z && draw_cmd.ClipRect.y <= draw_cmd.ClipRect.w); CmdBuffer.push_back(draw_cmd); } void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data) { ImDrawCmd* current_cmd = CmdBuffer.Size ? &CmdBuffer.back() : NULL; if (!current_cmd || current_cmd->ElemCount != 0 || current_cmd->UserCallback != NULL) { AddDrawCmd(); current_cmd = &CmdBuffer.back(); } current_cmd->UserCallback = callback; current_cmd->UserCallbackData = callback_data; AddDrawCmd(); // Force a new command after us (see comment below) } // Our scheme may appears a bit unusual, basically we want the most-common calls AddLine AddRect etc. to not have to perform any check so we always have a command ready in the stack. // The cost of figuring out if a new command has to be added or if we can merge is paid in those Update** functions only. void ImDrawList::UpdateClipRect() { // If current command is used with different settings we need to add a new command const ImVec4 curr_clip_rect = GetCurrentClipRect(); ImDrawCmd* curr_cmd = CmdBuffer.Size > 0 ? &CmdBuffer.Data[CmdBuffer.Size-1] : NULL; if (!curr_cmd || (curr_cmd->ElemCount != 0 && memcmp(&curr_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) != 0) || curr_cmd->UserCallback != NULL) { AddDrawCmd(); return; } // Try to merge with previous command if it matches, else use current command ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL; if (curr_cmd->ElemCount == 0 && prev_cmd && memcmp(&prev_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) == 0 && prev_cmd->TextureId == GetCurrentTextureId() && prev_cmd->UserCallback == NULL) CmdBuffer.pop_back(); else curr_cmd->ClipRect = curr_clip_rect; } void ImDrawList::UpdateTextureID() { // If current command is used with different settings we need to add a new command const ImTextureID curr_texture_id = GetCurrentTextureId(); ImDrawCmd* curr_cmd = CmdBuffer.Size ? &CmdBuffer.back() : NULL; if (!curr_cmd || (curr_cmd->ElemCount != 0 && curr_cmd->TextureId != curr_texture_id) || curr_cmd->UserCallback != NULL) { AddDrawCmd(); return; } // Try to merge with previous command if it matches, else use current command ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL; if (curr_cmd->ElemCount == 0 && prev_cmd && prev_cmd->TextureId == curr_texture_id && memcmp(&prev_cmd->ClipRect, &GetCurrentClipRect(), sizeof(ImVec4)) == 0 && prev_cmd->UserCallback == NULL) CmdBuffer.pop_back(); else curr_cmd->TextureId = curr_texture_id; } #undef GetCurrentClipRect #undef GetCurrentTextureId // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling) void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_current_clip_rect) { ImVec4 cr(cr_min.x, cr_min.y, cr_max.x, cr_max.y); if (intersect_with_current_clip_rect && _ClipRectStack.Size) { ImVec4 current = _ClipRectStack.Data[_ClipRectStack.Size-1]; if (cr.x < current.x) cr.x = current.x; if (cr.y < current.y) cr.y = current.y; if (cr.z > current.z) cr.z = current.z; if (cr.w > current.w) cr.w = current.w; } cr.z = ImMax(cr.x, cr.z); cr.w = ImMax(cr.y, cr.w); _ClipRectStack.push_back(cr); UpdateClipRect(); } void ImDrawList::PushClipRectFullScreen() { PushClipRect(ImVec2(_Data->ClipRectFullscreen.x, _Data->ClipRectFullscreen.y), ImVec2(_Data->ClipRectFullscreen.z, _Data->ClipRectFullscreen.w)); } void ImDrawList::PopClipRect() { IM_ASSERT(_ClipRectStack.Size > 0); _ClipRectStack.pop_back(); UpdateClipRect(); } void ImDrawList::PushTextureID(ImTextureID texture_id) { _TextureIdStack.push_back(texture_id); UpdateTextureID(); } void ImDrawList::PopTextureID() { IM_ASSERT(_TextureIdStack.Size > 0); _TextureIdStack.pop_back(); UpdateTextureID(); } // Reserve space for a number of vertices and indices. // You must finish filling your reserved data before calling PrimReserve() again, as it may reallocate or // submit the intermediate results. PrimUnreserve() can be used to release unused allocations. void ImDrawList::PrimReserve(int idx_count, int vtx_count) { // Large mesh support (when enabled) IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0); if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset)) { _VtxCurrentOffset = VtxBuffer.Size; _VtxCurrentIdx = 0; AddDrawCmd(); } ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size - 1]; draw_cmd.ElemCount += idx_count; int vtx_buffer_old_size = VtxBuffer.Size; VtxBuffer.resize(vtx_buffer_old_size + vtx_count); _VtxWritePtr = VtxBuffer.Data + vtx_buffer_old_size; int idx_buffer_old_size = IdxBuffer.Size; IdxBuffer.resize(idx_buffer_old_size + idx_count); _IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size; } // Release the a number of reserved vertices/indices from the end of the last reservation made with PrimReserve(). void ImDrawList::PrimUnreserve(int idx_count, int vtx_count) { IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0); ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size - 1]; draw_cmd.ElemCount -= idx_count; VtxBuffer.shrink(VtxBuffer.Size - vtx_count); IdxBuffer.shrink(IdxBuffer.Size - idx_count); } // Fully unrolled with inline call to keep our debug builds decently fast. void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col) { ImVec2 b(c.x, a.y), d(a.x, c.y), uv(_Data->TexUvWhitePixel); ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2); _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3); _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col; _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col; _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col; _VtxWritePtr += 4; _VtxCurrentIdx += 4; _IdxWritePtr += 6; } void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a, const ImVec2& uv_c, ImU32 col) { ImVec2 b(c.x, a.y), d(a.x, c.y), uv_b(uv_c.x, uv_a.y), uv_d(uv_a.x, uv_c.y); ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2); _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3); _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv_a; _VtxWritePtr[0].col = col; _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv_b; _VtxWritePtr[1].col = col; _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv_c; _VtxWritePtr[2].col = col; _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv_d; _VtxWritePtr[3].col = col; _VtxWritePtr += 4; _VtxCurrentIdx += 4; _IdxWritePtr += 6; } void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col) { ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2); _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3); _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv_a; _VtxWritePtr[0].col = col; _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv_b; _VtxWritePtr[1].col = col; _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv_c; _VtxWritePtr[2].col = col; _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv_d; _VtxWritePtr[3].col = col; _VtxWritePtr += 4; _VtxCurrentIdx += 4; _IdxWritePtr += 6; } // On AddPolyline() and AddConvexPolyFilled() we intentionally avoid using ImVec2 and superflous function calls to optimize debug/non-inlined builds. // Those macros expects l-values. #define IM_NORMALIZE2F_OVER_ZERO(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = 1.0f / ImSqrt(d2); VX *= inv_len; VY *= inv_len; } } #define IM_FIXNORMAL2F(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 < 0.5f) d2 = 0.5f; float inv_lensq = 1.0f / d2; VX *= inv_lensq; VY *= inv_lensq; } // TODO: Thickness anti-aliased lines cap are missing their AA fringe. // We avoid using the ImVec2 math operators here to reduce cost to a minimum for debug/non-inlined builds. void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 col, bool closed, float thickness) { if (points_count < 2) return; const ImVec2 uv = _Data->TexUvWhitePixel; int count = points_count; if (!closed) count = points_count-1; const bool thick_line = thickness > 1.0f; if (Flags & ImDrawListFlags_AntiAliasedLines) { // Anti-aliased stroke const float AA_SIZE = 1.0f; const ImU32 col_trans = col & ~IM_COL32_A_MASK; const int idx_count = thick_line ? count*18 : count*12; const int vtx_count = thick_line ? points_count*4 : points_count*3; PrimReserve(idx_count, vtx_count); // Temporary buffer ImVec2* temp_normals = (ImVec2*)alloca(points_count * (thick_line ? 5 : 3) * sizeof(ImVec2)); //-V630 ImVec2* temp_points = temp_normals + points_count; for (int i1 = 0; i1 < count; i1++) { const int i2 = (i1+1) == points_count ? 0 : i1+1; float dx = points[i2].x - points[i1].x; float dy = points[i2].y - points[i1].y; IM_NORMALIZE2F_OVER_ZERO(dx, dy); temp_normals[i1].x = dy; temp_normals[i1].y = -dx; } if (!closed) temp_normals[points_count-1] = temp_normals[points_count-2]; if (!thick_line) { if (!closed) { temp_points[0] = points[0] + temp_normals[0] * AA_SIZE; temp_points[1] = points[0] - temp_normals[0] * AA_SIZE; temp_points[(points_count-1)*2+0] = points[points_count-1] + temp_normals[points_count-1] * AA_SIZE; temp_points[(points_count-1)*2+1] = points[points_count-1] - temp_normals[points_count-1] * AA_SIZE; } // FIXME-OPT: Merge the different loops, possibly remove the temporary buffer. unsigned int idx1 = _VtxCurrentIdx; for (int i1 = 0; i1 < count; i1++) { const int i2 = (i1+1) == points_count ? 0 : i1+1; unsigned int idx2 = (i1+1) == points_count ? _VtxCurrentIdx : idx1+3; // Average normals float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f; float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f; IM_FIXNORMAL2F(dm_x, dm_y) dm_x *= AA_SIZE; dm_y *= AA_SIZE; // Add temporary vertexes ImVec2* out_vtx = &temp_points[i2*2]; out_vtx[0].x = points[i2].x + dm_x; out_vtx[0].y = points[i2].y + dm_y; out_vtx[1].x = points[i2].x - dm_x; out_vtx[1].y = points[i2].y - dm_y; // Add indexes _IdxWritePtr[0] = (ImDrawIdx)(idx2+0); _IdxWritePtr[1] = (ImDrawIdx)(idx1+0); _IdxWritePtr[2] = (ImDrawIdx)(idx1+2); _IdxWritePtr[3] = (ImDrawIdx)(idx1+2); _IdxWritePtr[4] = (ImDrawIdx)(idx2+2); _IdxWritePtr[5] = (ImDrawIdx)(idx2+0); _IdxWritePtr[6] = (ImDrawIdx)(idx2+1); _IdxWritePtr[7] = (ImDrawIdx)(idx1+1); _IdxWritePtr[8] = (ImDrawIdx)(idx1+0); _IdxWritePtr[9] = (ImDrawIdx)(idx1+0); _IdxWritePtr[10]= (ImDrawIdx)(idx2+0); _IdxWritePtr[11]= (ImDrawIdx)(idx2+1); _IdxWritePtr += 12; idx1 = idx2; } // Add vertexes for (int i = 0; i < points_count; i++) { _VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; _VtxWritePtr[1].pos = temp_points[i*2+0]; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col_trans; _VtxWritePtr[2].pos = temp_points[i*2+1]; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col_trans; _VtxWritePtr += 3; } } else { const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f; if (!closed) { temp_points[0] = points[0] + temp_normals[0] * (half_inner_thickness + AA_SIZE); temp_points[1] = points[0] + temp_normals[0] * (half_inner_thickness); temp_points[2] = points[0] - temp_normals[0] * (half_inner_thickness); temp_points[3] = points[0] - temp_normals[0] * (half_inner_thickness + AA_SIZE); temp_points[(points_count-1)*4+0] = points[points_count-1] + temp_normals[points_count-1] * (half_inner_thickness + AA_SIZE); temp_points[(points_count-1)*4+1] = points[points_count-1] + temp_normals[points_count-1] * (half_inner_thickness); temp_points[(points_count-1)*4+2] = points[points_count-1] - temp_normals[points_count-1] * (half_inner_thickness); temp_points[(points_count-1)*4+3] = points[points_count-1] - temp_normals[points_count-1] * (half_inner_thickness + AA_SIZE); } // FIXME-OPT: Merge the different loops, possibly remove the temporary buffer. unsigned int idx1 = _VtxCurrentIdx; for (int i1 = 0; i1 < count; i1++) { const int i2 = (i1+1) == points_count ? 0 : i1+1; unsigned int idx2 = (i1+1) == points_count ? _VtxCurrentIdx : idx1+4; // Average normals float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f; float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f; IM_FIXNORMAL2F(dm_x, dm_y); float dm_out_x = dm_x * (half_inner_thickness + AA_SIZE); float dm_out_y = dm_y * (half_inner_thickness + AA_SIZE); float dm_in_x = dm_x * half_inner_thickness; float dm_in_y = dm_y * half_inner_thickness; // Add temporary vertexes ImVec2* out_vtx = &temp_points[i2*4]; out_vtx[0].x = points[i2].x + dm_out_x; out_vtx[0].y = points[i2].y + dm_out_y; out_vtx[1].x = points[i2].x + dm_in_x; out_vtx[1].y = points[i2].y + dm_in_y; out_vtx[2].x = points[i2].x - dm_in_x; out_vtx[2].y = points[i2].y - dm_in_y; out_vtx[3].x = points[i2].x - dm_out_x; out_vtx[3].y = points[i2].y - dm_out_y; // Add indexes _IdxWritePtr[0] = (ImDrawIdx)(idx2+1); _IdxWritePtr[1] = (ImDrawIdx)(idx1+1); _IdxWritePtr[2] = (ImDrawIdx)(idx1+2); _IdxWritePtr[3] = (ImDrawIdx)(idx1+2); _IdxWritePtr[4] = (ImDrawIdx)(idx2+2); _IdxWritePtr[5] = (ImDrawIdx)(idx2+1); _IdxWritePtr[6] = (ImDrawIdx)(idx2+1); _IdxWritePtr[7] = (ImDrawIdx)(idx1+1); _IdxWritePtr[8] = (ImDrawIdx)(idx1+0); _IdxWritePtr[9] = (ImDrawIdx)(idx1+0); _IdxWritePtr[10] = (ImDrawIdx)(idx2+0); _IdxWritePtr[11] = (ImDrawIdx)(idx2+1); _IdxWritePtr[12] = (ImDrawIdx)(idx2+2); _IdxWritePtr[13] = (ImDrawIdx)(idx1+2); _IdxWritePtr[14] = (ImDrawIdx)(idx1+3); _IdxWritePtr[15] = (ImDrawIdx)(idx1+3); _IdxWritePtr[16] = (ImDrawIdx)(idx2+3); _IdxWritePtr[17] = (ImDrawIdx)(idx2+2); _IdxWritePtr += 18; idx1 = idx2; } // Add vertexes for (int i = 0; i < points_count; i++) { _VtxWritePtr[0].pos = temp_points[i*4+0]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col_trans; _VtxWritePtr[1].pos = temp_points[i*4+1]; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col; _VtxWritePtr[2].pos = temp_points[i*4+2]; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col; _VtxWritePtr[3].pos = temp_points[i*4+3]; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col_trans; _VtxWritePtr += 4; } } _VtxCurrentIdx += (ImDrawIdx)vtx_count; } else { // Non Anti-aliased Stroke const int idx_count = count*6; const int vtx_count = count*4; // FIXME-OPT: Not sharing edges PrimReserve(idx_count, vtx_count); for (int i1 = 0; i1 < count; i1++) { const int i2 = (i1+1) == points_count ? 0 : i1+1; const ImVec2& p1 = points[i1]; const ImVec2& p2 = points[i2]; float dx = p2.x - p1.x; float dy = p2.y - p1.y; IM_NORMALIZE2F_OVER_ZERO(dx, dy); dx *= (thickness * 0.5f); dy *= (thickness * 0.5f); _VtxWritePtr[0].pos.x = p1.x + dy; _VtxWritePtr[0].pos.y = p1.y - dx; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; _VtxWritePtr[1].pos.x = p2.x + dy; _VtxWritePtr[1].pos.y = p2.y - dx; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col; _VtxWritePtr[2].pos.x = p2.x - dy; _VtxWritePtr[2].pos.y = p2.y + dx; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col; _VtxWritePtr[3].pos.x = p1.x - dy; _VtxWritePtr[3].pos.y = p1.y + dx; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col; _VtxWritePtr += 4; _IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+2); _IdxWritePtr[3] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[4] = (ImDrawIdx)(_VtxCurrentIdx+2); _IdxWritePtr[5] = (ImDrawIdx)(_VtxCurrentIdx+3); _IdxWritePtr += 6; _VtxCurrentIdx += 4; } } } // We intentionally avoid using ImVec2 and its math operators here to reduce cost to a minimum for debug/non-inlined builds. void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col) { if (points_count < 3) return; const ImVec2 uv = _Data->TexUvWhitePixel; if (Flags & ImDrawListFlags_AntiAliasedFill) { // Anti-aliased Fill const float AA_SIZE = 1.0f; const ImU32 col_trans = col & ~IM_COL32_A_MASK; const int idx_count = (points_count-2)*3 + points_count*6; const int vtx_count = (points_count*2); PrimReserve(idx_count, vtx_count); // Add indexes for fill unsigned int vtx_inner_idx = _VtxCurrentIdx; unsigned int vtx_outer_idx = _VtxCurrentIdx+1; for (int i = 2; i < points_count; i++) { _IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx+((i-1)<<1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_inner_idx+(i<<1)); _IdxWritePtr += 3; } // Compute normals ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2)); //-V630 for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) { const ImVec2& p0 = points[i0]; const ImVec2& p1 = points[i1]; float dx = p1.x - p0.x; float dy = p1.y - p0.y; IM_NORMALIZE2F_OVER_ZERO(dx, dy); temp_normals[i0].x = dy; temp_normals[i0].y = -dx; } for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) { // Average normals const ImVec2& n0 = temp_normals[i0]; const ImVec2& n1 = temp_normals[i1]; float dm_x = (n0.x + n1.x) * 0.5f; float dm_y = (n0.y + n1.y) * 0.5f; IM_FIXNORMAL2F(dm_x, dm_y); dm_x *= AA_SIZE * 0.5f; dm_y *= AA_SIZE * 0.5f; // Add vertices _VtxWritePtr[0].pos.x = (points[i1].x - dm_x); _VtxWritePtr[0].pos.y = (points[i1].y - dm_y); _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; // Inner _VtxWritePtr[1].pos.x = (points[i1].x + dm_x); _VtxWritePtr[1].pos.y = (points[i1].y + dm_y); _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col_trans; // Outer _VtxWritePtr += 2; // Add indexes for fringes _IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx+(i1<<1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx+(i0<<1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_outer_idx+(i0<<1)); _IdxWritePtr[3] = (ImDrawIdx)(vtx_outer_idx+(i0<<1)); _IdxWritePtr[4] = (ImDrawIdx)(vtx_outer_idx+(i1<<1)); _IdxWritePtr[5] = (ImDrawIdx)(vtx_inner_idx+(i1<<1)); _IdxWritePtr += 6; } _VtxCurrentIdx += (ImDrawIdx)vtx_count; } else { // Non Anti-aliased Fill const int idx_count = (points_count-2)*3; const int vtx_count = points_count; PrimReserve(idx_count, vtx_count); for (int i = 0; i < vtx_count; i++) { _VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; _VtxWritePtr++; } for (int i = 2; i < points_count; i++) { _IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+i-1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+i); _IdxWritePtr += 3; } _VtxCurrentIdx += (ImDrawIdx)vtx_count; } } void ImDrawList::PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12) { if (radius == 0.0f || a_min_of_12 > a_max_of_12) { _Path.push_back(center); return; } _Path.reserve(_Path.Size + (a_max_of_12 - a_min_of_12 + 1)); for (int a = a_min_of_12; a <= a_max_of_12; a++) { const ImVec2& c = _Data->CircleVtx12[a % IM_ARRAYSIZE(_Data->CircleVtx12)]; _Path.push_back(ImVec2(center.x + c.x * radius, center.y + c.y * radius)); } } void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments) { if (radius == 0.0f) { _Path.push_back(center); return; } // Note that we are adding a point at both a_min and a_max. // If you are trying to draw a full closed circle you don't want the overlapping points! _Path.reserve(_Path.Size + (num_segments + 1)); for (int i = 0; i <= num_segments; i++) { const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min); _Path.push_back(ImVec2(center.x + ImCos(a) * radius, center.y + ImSin(a) * radius)); } } ImVec2 ImBezierCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t) { float u = 1.0f - t; float w1 = u*u*u; float w2 = 3*u*u*t; float w3 = 3*u*t*t; float w4 = t*t*t; return ImVec2(w1*p1.x + w2*p2.x + w3*p3.x + w4*p4.x, w1*p1.y + w2*p2.y + w3*p3.y + w4*p4.y); } // Closely mimics BezierClosestPointCasteljauStep() in imgui.cpp static void PathBezierToCasteljau(ImVector* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level) { float dx = x4 - x1; float dy = y4 - y1; float d2 = ((x2 - x4) * dy - (y2 - y4) * dx); float d3 = ((x3 - x4) * dy - (y3 - y4) * dx); d2 = (d2 >= 0) ? d2 : -d2; d3 = (d3 >= 0) ? d3 : -d3; if ((d2+d3) * (d2+d3) < tess_tol * (dx*dx + dy*dy)) { path->push_back(ImVec2(x4, y4)); } else if (level < 10) { float x12 = (x1+x2)*0.5f, y12 = (y1+y2)*0.5f; float x23 = (x2+x3)*0.5f, y23 = (y2+y3)*0.5f; float x34 = (x3+x4)*0.5f, y34 = (y3+y4)*0.5f; float x123 = (x12+x23)*0.5f, y123 = (y12+y23)*0.5f; float x234 = (x23+x34)*0.5f, y234 = (y23+y34)*0.5f; float x1234 = (x123+x234)*0.5f, y1234 = (y123+y234)*0.5f; PathBezierToCasteljau(path, x1,y1, x12,y12, x123,y123, x1234,y1234, tess_tol, level+1); PathBezierToCasteljau(path, x1234,y1234, x234,y234, x34,y34, x4,y4, tess_tol, level+1); } } void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments) { ImVec2 p1 = _Path.back(); if (num_segments == 0) { PathBezierToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, _Data->CurveTessellationTol, 0); // Auto-tessellated } else { float t_step = 1.0f / (float)num_segments; for (int i_step = 1; i_step <= num_segments; i_step++) _Path.push_back(ImBezierCalc(p1, p2, p3, p4, t_step * i_step)); } } void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, ImDrawCornerFlags rounding_corners) { rounding = ImMin(rounding, ImFabs(b.x - a.x) * ( ((rounding_corners & ImDrawCornerFlags_Top) == ImDrawCornerFlags_Top) || ((rounding_corners & ImDrawCornerFlags_Bot) == ImDrawCornerFlags_Bot) ? 0.5f : 1.0f ) - 1.0f); rounding = ImMin(rounding, ImFabs(b.y - a.y) * ( ((rounding_corners & ImDrawCornerFlags_Left) == ImDrawCornerFlags_Left) || ((rounding_corners & ImDrawCornerFlags_Right) == ImDrawCornerFlags_Right) ? 0.5f : 1.0f ) - 1.0f); if (rounding <= 0.0f || rounding_corners == 0) { PathLineTo(a); PathLineTo(ImVec2(b.x, a.y)); PathLineTo(b); PathLineTo(ImVec2(a.x, b.y)); } else { const float rounding_tl = (rounding_corners & ImDrawCornerFlags_TopLeft) ? rounding : 0.0f; const float rounding_tr = (rounding_corners & ImDrawCornerFlags_TopRight) ? rounding : 0.0f; const float rounding_br = (rounding_corners & ImDrawCornerFlags_BotRight) ? rounding : 0.0f; const float rounding_bl = (rounding_corners & ImDrawCornerFlags_BotLeft) ? rounding : 0.0f; PathArcToFast(ImVec2(a.x + rounding_tl, a.y + rounding_tl), rounding_tl, 6, 9); PathArcToFast(ImVec2(b.x - rounding_tr, a.y + rounding_tr), rounding_tr, 9, 12); PathArcToFast(ImVec2(b.x - rounding_br, b.y - rounding_br), rounding_br, 0, 3); PathArcToFast(ImVec2(a.x + rounding_bl, b.y - rounding_bl), rounding_bl, 3, 6); } } void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness) { if ((col & IM_COL32_A_MASK) == 0) return; PathLineTo(p1 + ImVec2(0.5f, 0.5f)); PathLineTo(p2 + ImVec2(0.5f, 0.5f)); PathStroke(col, false, thickness); } // p_min = upper-left, p_max = lower-right // Note we don't render 1 pixels sized rectangles properly. void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners, float thickness) { if ((col & IM_COL32_A_MASK) == 0) return; if (Flags & ImDrawListFlags_AntiAliasedLines) PathRect(p_min + ImVec2(0.50f,0.50f), p_max - ImVec2(0.50f,0.50f), rounding, rounding_corners); else PathRect(p_min + ImVec2(0.50f,0.50f), p_max - ImVec2(0.49f,0.49f), rounding, rounding_corners); // Better looking lower-right corner and rounded non-AA shapes. PathStroke(col, true, thickness); } void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners) { if ((col & IM_COL32_A_MASK) == 0) return; if (rounding > 0.0f) { PathRect(p_min, p_max, rounding, rounding_corners); PathFillConvex(col); } else { PrimReserve(6, 4); PrimRect(p_min, p_max, col); } } // p_min = upper-left, p_max = lower-right void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left) { if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) & IM_COL32_A_MASK) == 0) return; const ImVec2 uv = _Data->TexUvWhitePixel; PrimReserve(6, 4); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+3)); PrimWriteVtx(p_min, uv, col_upr_left); PrimWriteVtx(ImVec2(p_max.x, p_min.y), uv, col_upr_right); PrimWriteVtx(p_max, uv, col_bot_right); PrimWriteVtx(ImVec2(p_min.x, p_max.y), uv, col_bot_left); } void ImDrawList::AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness) { if ((col & IM_COL32_A_MASK) == 0) return; PathLineTo(p1); PathLineTo(p2); PathLineTo(p3); PathLineTo(p4); PathStroke(col, true, thickness); } void ImDrawList::AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col) { if ((col & IM_COL32_A_MASK) == 0) return; PathLineTo(p1); PathLineTo(p2); PathLineTo(p3); PathLineTo(p4); PathFillConvex(col); } void ImDrawList::AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness) { if ((col & IM_COL32_A_MASK) == 0) return; PathLineTo(p1); PathLineTo(p2); PathLineTo(p3); PathStroke(col, true, thickness); } void ImDrawList::AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col) { if ((col & IM_COL32_A_MASK) == 0) return; PathLineTo(p1); PathLineTo(p2); PathLineTo(p3); PathFillConvex(col); } void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness) { if ((col & IM_COL32_A_MASK) == 0 || radius <= 0.0f) return; // Obtain segment count if (num_segments <= 0) { // Automatic segment count const int radius_idx = (int)radius - 1; if (radius_idx < IM_ARRAYSIZE(_Data->CircleSegmentCounts)) num_segments = _Data->CircleSegmentCounts[radius_idx]; // Use cached value else num_segments = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, _Data->CircleSegmentMaxError); } else { // Explicit segment count (still clamp to avoid drawing insanely tessellated shapes) num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX); } // Because we are filling a closed shape we remove 1 from the count of segments/points const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments; if (num_segments == 12) PathArcToFast(center, radius - 0.5f, 0, 12); else PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1); PathStroke(col, true, thickness); } void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments) { if ((col & IM_COL32_A_MASK) == 0 || radius <= 0.0f) return; // Obtain segment count if (num_segments <= 0) { // Automatic segment count const int radius_idx = (int)radius - 1; if (radius_idx < IM_ARRAYSIZE(_Data->CircleSegmentCounts)) num_segments = _Data->CircleSegmentCounts[radius_idx]; // Use cached value else num_segments = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, _Data->CircleSegmentMaxError); } else { // Explicit segment count (still clamp to avoid drawing insanely tessellated shapes) num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX); } // Because we are filling a closed shape we remove 1 from the count of segments/points const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments; if (num_segments == 12) PathArcToFast(center, radius, 0, 12); else PathArcTo(center, radius, 0.0f, a_max, num_segments - 1); PathFillConvex(col); } // Guaranteed to honor 'num_segments' void ImDrawList::AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness) { if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2) return; // Because we are filling a closed shape we remove 1 from the count of segments/points const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments; PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1); PathStroke(col, true, thickness); } // Guaranteed to honor 'num_segments' void ImDrawList::AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments) { if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2) return; // Because we are filling a closed shape we remove 1 from the count of segments/points const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments; PathArcTo(center, radius, 0.0f, a_max, num_segments - 1); PathFillConvex(col); } // Cubic Bezier takes 4 controls points void ImDrawList::AddBezierCurve(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments) { if ((col & IM_COL32_A_MASK) == 0) return; PathLineTo(p1); PathBezierCurveTo(p2, p3, p4, num_segments); PathStroke(col, false, thickness); } void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect) { if ((col & IM_COL32_A_MASK) == 0) return; if (text_end == NULL) text_end = text_begin + strlen(text_begin); if (text_begin == text_end) return; // Pull default font/size from the shared ImDrawListSharedData instance if (font == NULL) font = _Data->Font; if (font_size == 0.0f) font_size = _Data->FontSize; IM_ASSERT(font->ContainerAtlas->TexID == _TextureIdStack.back()); // Use high-level ImGui::PushFont() or low-level ImDrawList::PushTextureId() to change font. ImVec4 clip_rect = _ClipRectStack.back(); if (cpu_fine_clip_rect) { clip_rect.x = ImMax(clip_rect.x, cpu_fine_clip_rect->x); clip_rect.y = ImMax(clip_rect.y, cpu_fine_clip_rect->y); clip_rect.z = ImMin(clip_rect.z, cpu_fine_clip_rect->z); clip_rect.w = ImMin(clip_rect.w, cpu_fine_clip_rect->w); } font->RenderText(this, font_size, pos, col, clip_rect, text_begin, text_end, wrap_width, cpu_fine_clip_rect != NULL); } void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end) { AddText(NULL, 0.0f, pos, col, text_begin, text_end); } void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col) { if ((col & IM_COL32_A_MASK) == 0) return; const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back(); if (push_texture_id) PushTextureID(user_texture_id); PrimReserve(6, 4); PrimRectUV(p_min, p_max, uv_min, uv_max, col); if (push_texture_id) PopTextureID(); } void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1, const ImVec2& uv2, const ImVec2& uv3, const ImVec2& uv4, ImU32 col) { if ((col & IM_COL32_A_MASK) == 0) return; const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back(); if (push_texture_id) PushTextureID(user_texture_id); PrimReserve(6, 4); PrimQuadUV(p1, p2, p3, p4, uv1, uv2, uv3, uv4, col); if (push_texture_id) PopTextureID(); } void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners) { if ((col & IM_COL32_A_MASK) == 0) return; if (rounding <= 0.0f || (rounding_corners & ImDrawCornerFlags_All) == 0) { AddImage(user_texture_id, p_min, p_max, uv_min, uv_max, col); return; } const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back(); if (push_texture_id) PushTextureID(user_texture_id); int vert_start_idx = VtxBuffer.Size; PathRect(p_min, p_max, rounding, rounding_corners); PathFillConvex(col); int vert_end_idx = VtxBuffer.Size; ImGui::ShadeVertsLinearUV(this, vert_start_idx, vert_end_idx, p_min, p_max, uv_min, uv_max, true); if (push_texture_id) PopTextureID(); } //----------------------------------------------------------------------------- // ImDrawListSplitter //----------------------------------------------------------------------------- // FIXME: This may be a little confusing, trying to be a little too low-level/optimal instead of just doing vector swap.. //----------------------------------------------------------------------------- void ImDrawListSplitter::ClearFreeMemory() { for (int i = 0; i < _Channels.Size; i++) { if (i == _Current) memset(&_Channels[i], 0, sizeof(_Channels[i])); // Current channel is a copy of CmdBuffer/IdxBuffer, don't destruct again _Channels[i]._CmdBuffer.clear(); _Channels[i]._IdxBuffer.clear(); } _Current = 0; _Count = 1; _Channels.clear(); } void ImDrawListSplitter::Split(ImDrawList* draw_list, int channels_count) { IM_ASSERT(_Current == 0 && _Count <= 1 && "Nested channel splitting is not supported. Please use separate instances of ImDrawListSplitter."); int old_channels_count = _Channels.Size; if (old_channels_count < channels_count) _Channels.resize(channels_count); _Count = channels_count; // Channels[] (24/32 bytes each) hold storage that we'll swap with draw_list->_CmdBuffer/_IdxBuffer // The content of Channels[0] at this point doesn't matter. We clear it to make state tidy in a debugger but we don't strictly need to. // When we switch to the next channel, we'll copy draw_list->_CmdBuffer/_IdxBuffer into Channels[0] and then Channels[1] into draw_list->CmdBuffer/_IdxBuffer memset(&_Channels[0], 0, sizeof(ImDrawChannel)); for (int i = 1; i < channels_count; i++) { if (i >= old_channels_count) { IM_PLACEMENT_NEW(&_Channels[i]) ImDrawChannel(); } else { _Channels[i]._CmdBuffer.resize(0); _Channels[i]._IdxBuffer.resize(0); } if (_Channels[i]._CmdBuffer.Size == 0) { ImDrawCmd draw_cmd; draw_cmd.ClipRect = draw_list->_ClipRectStack.back(); draw_cmd.TextureId = draw_list->_TextureIdStack.back(); _Channels[i]._CmdBuffer.push_back(draw_cmd); } } } static inline bool CanMergeDrawCommands(ImDrawCmd* a, ImDrawCmd* b) { return memcmp(&a->ClipRect, &b->ClipRect, sizeof(a->ClipRect)) == 0 && a->TextureId == b->TextureId && a->VtxOffset == b->VtxOffset && !a->UserCallback && !b->UserCallback; } void ImDrawListSplitter::Merge(ImDrawList* draw_list) { // Note that we never use or rely on channels.Size because it is merely a buffer that we never shrink back to 0 to keep all sub-buffers ready for use. if (_Count <= 1) return; SetCurrentChannel(draw_list, 0); if (draw_list->CmdBuffer.Size != 0 && draw_list->CmdBuffer.back().ElemCount == 0) draw_list->CmdBuffer.pop_back(); // Calculate our final buffer sizes. Also fix the incorrect IdxOffset values in each command. int new_cmd_buffer_count = 0; int new_idx_buffer_count = 0; ImDrawCmd* last_cmd = (_Count > 0 && draw_list->CmdBuffer.Size > 0) ? &draw_list->CmdBuffer.back() : NULL; int idx_offset = last_cmd ? last_cmd->IdxOffset + last_cmd->ElemCount : 0; for (int i = 1; i < _Count; i++) { ImDrawChannel& ch = _Channels[i]; if (ch._CmdBuffer.Size > 0 && ch._CmdBuffer.back().ElemCount == 0) ch._CmdBuffer.pop_back(); if (ch._CmdBuffer.Size > 0 && last_cmd != NULL && CanMergeDrawCommands(last_cmd, &ch._CmdBuffer[0])) { // Merge previous channel last draw command with current channel first draw command if matching. last_cmd->ElemCount += ch._CmdBuffer[0].ElemCount; idx_offset += ch._CmdBuffer[0].ElemCount; ch._CmdBuffer.erase(ch._CmdBuffer.Data); // FIXME-OPT: Improve for multiple merges. } if (ch._CmdBuffer.Size > 0) last_cmd = &ch._CmdBuffer.back(); new_cmd_buffer_count += ch._CmdBuffer.Size; new_idx_buffer_count += ch._IdxBuffer.Size; for (int cmd_n = 0; cmd_n < ch._CmdBuffer.Size; cmd_n++) { ch._CmdBuffer.Data[cmd_n].IdxOffset = idx_offset; idx_offset += ch._CmdBuffer.Data[cmd_n].ElemCount; } } draw_list->CmdBuffer.resize(draw_list->CmdBuffer.Size + new_cmd_buffer_count); draw_list->IdxBuffer.resize(draw_list->IdxBuffer.Size + new_idx_buffer_count); // Write commands and indices in order (they are fairly small structures, we don't copy vertices only indices) ImDrawCmd* cmd_write = draw_list->CmdBuffer.Data + draw_list->CmdBuffer.Size - new_cmd_buffer_count; ImDrawIdx* idx_write = draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size - new_idx_buffer_count; for (int i = 1; i < _Count; i++) { ImDrawChannel& ch = _Channels[i]; if (int sz = ch._CmdBuffer.Size) { memcpy(cmd_write, ch._CmdBuffer.Data, sz * sizeof(ImDrawCmd)); cmd_write += sz; } if (int sz = ch._IdxBuffer.Size) { memcpy(idx_write, ch._IdxBuffer.Data, sz * sizeof(ImDrawIdx)); idx_write += sz; } } draw_list->_IdxWritePtr = idx_write; draw_list->UpdateClipRect(); // We call this instead of AddDrawCmd(), so that empty channels won't produce an extra draw call. draw_list->UpdateTextureID(); _Count = 1; } void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx) { IM_ASSERT(idx >= 0 && idx < _Count); if (_Current == idx) return; // Overwrite ImVector (12/16 bytes), four times. This is merely a silly optimization instead of doing .swap() memcpy(&_Channels.Data[_Current]._CmdBuffer, &draw_list->CmdBuffer, sizeof(draw_list->CmdBuffer)); memcpy(&_Channels.Data[_Current]._IdxBuffer, &draw_list->IdxBuffer, sizeof(draw_list->IdxBuffer)); _Current = idx; memcpy(&draw_list->CmdBuffer, &_Channels.Data[idx]._CmdBuffer, sizeof(draw_list->CmdBuffer)); memcpy(&draw_list->IdxBuffer, &_Channels.Data[idx]._IdxBuffer, sizeof(draw_list->IdxBuffer)); draw_list->_IdxWritePtr = draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size; } //----------------------------------------------------------------------------- // [SECTION] ImDrawData //----------------------------------------------------------------------------- // For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering! void ImDrawData::DeIndexAllBuffers() { ImVector new_vtx_buffer; TotalVtxCount = TotalIdxCount = 0; for (int i = 0; i < CmdListsCount; i++) { ImDrawList* cmd_list = CmdLists[i]; if (cmd_list->IdxBuffer.empty()) continue; new_vtx_buffer.resize(cmd_list->IdxBuffer.Size); for (int j = 0; j < cmd_list->IdxBuffer.Size; j++) new_vtx_buffer[j] = cmd_list->VtxBuffer[cmd_list->IdxBuffer[j]]; cmd_list->VtxBuffer.swap(new_vtx_buffer); cmd_list->IdxBuffer.resize(0); TotalVtxCount += cmd_list->VtxBuffer.Size; } } // Helper to scale the ClipRect field of each ImDrawCmd. // Use if your final output buffer is at a different scale than draw_data->DisplaySize, // or if there is a difference between your window resolution and framebuffer resolution. void ImDrawData::ScaleClipRects(const ImVec2& fb_scale) { for (int i = 0; i < CmdListsCount; i++) { ImDrawList* cmd_list = CmdLists[i]; for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) { ImDrawCmd* cmd = &cmd_list->CmdBuffer[cmd_i]; cmd->ClipRect = ImVec4(cmd->ClipRect.x * fb_scale.x, cmd->ClipRect.y * fb_scale.y, cmd->ClipRect.z * fb_scale.x, cmd->ClipRect.w * fb_scale.y); } } } //----------------------------------------------------------------------------- // [SECTION] Helpers ShadeVertsXXX functions //----------------------------------------------------------------------------- // Generic linear color gradient, write to RGB fields, leave A untouched. void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1) { ImVec2 gradient_extent = gradient_p1 - gradient_p0; float gradient_inv_length2 = 1.0f / ImLengthSqr(gradient_extent); ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx; ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx; for (ImDrawVert* vert = vert_start; vert < vert_end; vert++) { float d = ImDot(vert->pos - gradient_p0, gradient_extent); float t = ImClamp(d * gradient_inv_length2, 0.0f, 1.0f); int r = ImLerp((int)(col0 >> IM_COL32_R_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_R_SHIFT) & 0xFF, t); int g = ImLerp((int)(col0 >> IM_COL32_G_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_G_SHIFT) & 0xFF, t); int b = ImLerp((int)(col0 >> IM_COL32_B_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_B_SHIFT) & 0xFF, t); vert->col = (r << IM_COL32_R_SHIFT) | (g << IM_COL32_G_SHIFT) | (b << IM_COL32_B_SHIFT) | (vert->col & IM_COL32_A_MASK); } } // Distribute UV over (a, b) rectangle void ImGui::ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp) { const ImVec2 size = b - a; const ImVec2 uv_size = uv_b - uv_a; const ImVec2 scale = ImVec2( size.x != 0.0f ? (uv_size.x / size.x) : 0.0f, size.y != 0.0f ? (uv_size.y / size.y) : 0.0f); ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx; ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx; if (clamp) { const ImVec2 min = ImMin(uv_a, uv_b); const ImVec2 max = ImMax(uv_a, uv_b); for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex) vertex->uv = ImClamp(uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale), min, max); } else { for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex) vertex->uv = uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale); } } //----------------------------------------------------------------------------- // [SECTION] ImFontConfig //----------------------------------------------------------------------------- ImFontConfig::ImFontConfig() { FontData = NULL; FontDataSize = 0; FontDataOwnedByAtlas = true; FontNo = 0; SizePixels = 0.0f; OversampleH = 3; // FIXME: 2 may be a better default? OversampleV = 1; PixelSnapH = false; GlyphExtraSpacing = ImVec2(0.0f, 0.0f); GlyphOffset = ImVec2(0.0f, 0.0f); GlyphRanges = NULL; GlyphMinAdvanceX = 0.0f; GlyphMaxAdvanceX = FLT_MAX; MergeMode = false; RasterizerFlags = 0x00; RasterizerMultiply = 1.0f; EllipsisChar = (ImWchar)-1; memset(Name, 0, sizeof(Name)); DstFont = NULL; } //----------------------------------------------------------------------------- // [SECTION] ImFontAtlas //----------------------------------------------------------------------------- // A work of art lies ahead! (. = white layer, X = black layer, others are blank) // The white texels on the top left are the ones we'll use everywhere in Dear ImGui to render filled shapes. const int FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF = 108; const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27; const unsigned int FONT_ATLAS_DEFAULT_TEX_DATA_ID = 0x80000000; static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] = { "..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX- XX " "..- -X.....X- X.X - X.X -X.....X - X.....X- X..X " "--- -XXX.XXX- X...X - X...X -X....X - X....X- X..X " "X - X.X - X.....X - X.....X -X...X - X...X- X..X " "XX - X.X -X.......X- X.......X -X..X.X - X.X..X- X..X " "X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X- X..XXX " "X..X - X.X - X.X - X.X -XX X.X - X.X XX- X..X..XXX " "X...X - X.X - X.X - XX X.X XX - X.X - X.X - X..X..X..XX " "X....X - X.X - X.X - X.X X.X X.X - X.X - X.X - X..X..X..X.X " "X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X -XXX X..X..X..X..X" "X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X -X..XX........X..X" "X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X -X...X...........X" "X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X - X..............X" "X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X - X.............X" "X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X - X.............X" "X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X - X............X" "X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX - X...........X " "X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------- X..........X " "X.X X..X - -X.......X- X.......X - XX XX - - X..........X " "XX X..X - - X.....X - X.....X - X.X X.X - - X........X " " X..X - X...X - X...X - X..X X..X - - X........X " " XX - X.X - X.X - X...XXXXXXXXXXXXX...X - - XXXXXXXXXX " "------------ - X - X -X.....................X- ------------------" " ----------------------------------- X...XXXXXXXXXXXXX...X - " " - X..X X..X - " " - X.X X.X - " " - XX XX - " }; static const ImVec2 FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[ImGuiMouseCursor_COUNT][3] = { // Pos ........ Size ......... Offset ...... { ImVec2( 0,3), ImVec2(12,19), ImVec2( 0, 0) }, // ImGuiMouseCursor_Arrow { ImVec2(13,0), ImVec2( 7,16), ImVec2( 1, 8) }, // ImGuiMouseCursor_TextInput { ImVec2(31,0), ImVec2(23,23), ImVec2(11,11) }, // ImGuiMouseCursor_ResizeAll { ImVec2(21,0), ImVec2( 9,23), ImVec2( 4,11) }, // ImGuiMouseCursor_ResizeNS { ImVec2(55,18),ImVec2(23, 9), ImVec2(11, 4) }, // ImGuiMouseCursor_ResizeEW { ImVec2(73,0), ImVec2(17,17), ImVec2( 8, 8) }, // ImGuiMouseCursor_ResizeNESW { ImVec2(55,0), ImVec2(17,17), ImVec2( 8, 8) }, // ImGuiMouseCursor_ResizeNWSE { ImVec2(91,0), ImVec2(17,22), ImVec2( 5, 0) }, // ImGuiMouseCursor_Hand }; ImFontAtlas::ImFontAtlas() { Locked = false; Flags = ImFontAtlasFlags_None; TexID = (ImTextureID)NULL; TexDesiredWidth = 0; TexGlyphPadding = 1; TexPixelsAlpha8 = NULL; TexPixelsRGBA32 = NULL; TexWidth = TexHeight = 0; TexUvScale = ImVec2(0.0f, 0.0f); TexUvWhitePixel = ImVec2(0.0f, 0.0f); for (int n = 0; n < IM_ARRAYSIZE(CustomRectIds); n++) CustomRectIds[n] = -1; } ImFontAtlas::~ImFontAtlas() { IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); Clear(); } void ImFontAtlas::ClearInputData() { IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); for (int i = 0; i < ConfigData.Size; i++) if (ConfigData[i].FontData && ConfigData[i].FontDataOwnedByAtlas) { IM_FREE(ConfigData[i].FontData); ConfigData[i].FontData = NULL; } // When clearing this we lose access to the font name and other information used to build the font. for (int i = 0; i < Fonts.Size; i++) if (Fonts[i]->ConfigData >= ConfigData.Data && Fonts[i]->ConfigData < ConfigData.Data + ConfigData.Size) { Fonts[i]->ConfigData = NULL; Fonts[i]->ConfigDataCount = 0; } ConfigData.clear(); CustomRects.clear(); for (int n = 0; n < IM_ARRAYSIZE(CustomRectIds); n++) CustomRectIds[n] = -1; } void ImFontAtlas::ClearTexData() { IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); if (TexPixelsAlpha8) IM_FREE(TexPixelsAlpha8); if (TexPixelsRGBA32) IM_FREE(TexPixelsRGBA32); TexPixelsAlpha8 = NULL; TexPixelsRGBA32 = NULL; } void ImFontAtlas::ClearFonts() { IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); for (int i = 0; i < Fonts.Size; i++) IM_DELETE(Fonts[i]); Fonts.clear(); } void ImFontAtlas::Clear() { ClearInputData(); ClearTexData(); ClearFonts(); } void ImFontAtlas::GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel) { // Build atlas on demand if (TexPixelsAlpha8 == NULL) { if (ConfigData.empty()) AddFontDefault(); Build(); } *out_pixels = TexPixelsAlpha8; if (out_width) *out_width = TexWidth; if (out_height) *out_height = TexHeight; if (out_bytes_per_pixel) *out_bytes_per_pixel = 1; } void ImFontAtlas::GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel) { // Convert to RGBA32 format on demand // Although it is likely to be the most commonly used format, our font rendering is 1 channel / 8 bpp if (!TexPixelsRGBA32) { unsigned char* pixels = NULL; GetTexDataAsAlpha8(&pixels, NULL, NULL); if (pixels) { TexPixelsRGBA32 = (unsigned int*)IM_ALLOC((size_t)TexWidth * (size_t)TexHeight * 4); const unsigned char* src = pixels; unsigned int* dst = TexPixelsRGBA32; for (int n = TexWidth * TexHeight; n > 0; n--) *dst++ = IM_COL32(255, 255, 255, (unsigned int)(*src++)); } } *out_pixels = (unsigned char*)TexPixelsRGBA32; if (out_width) *out_width = TexWidth; if (out_height) *out_height = TexHeight; if (out_bytes_per_pixel) *out_bytes_per_pixel = 4; } ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg) { IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); IM_ASSERT(font_cfg->FontData != NULL && font_cfg->FontDataSize > 0); IM_ASSERT(font_cfg->SizePixels > 0.0f); // Create new font if (!font_cfg->MergeMode) Fonts.push_back(IM_NEW(ImFont)); else IM_ASSERT(!Fonts.empty() && "Cannot use MergeMode for the first font"); // When using MergeMode make sure that a font has already been added before. You can use ImGui::GetIO().Fonts->AddFontDefault() to add the default imgui font. ConfigData.push_back(*font_cfg); ImFontConfig& new_font_cfg = ConfigData.back(); if (new_font_cfg.DstFont == NULL) new_font_cfg.DstFont = Fonts.back(); if (!new_font_cfg.FontDataOwnedByAtlas) { new_font_cfg.FontData = IM_ALLOC(new_font_cfg.FontDataSize); new_font_cfg.FontDataOwnedByAtlas = true; memcpy(new_font_cfg.FontData, font_cfg->FontData, (size_t)new_font_cfg.FontDataSize); } if (new_font_cfg.DstFont->EllipsisChar == (ImWchar)-1) new_font_cfg.DstFont->EllipsisChar = font_cfg->EllipsisChar; // Invalidate texture ClearTexData(); return new_font_cfg.DstFont; } // Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder) static unsigned int stb_decompress_length(const unsigned char *input); static unsigned int stb_decompress(unsigned char *output, const unsigned char *input, unsigned int length); static const char* GetDefaultCompressedFontDataTTFBase85(); static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; } static void Decode85(const unsigned char* src, unsigned char* dst) { while (*src) { unsigned int tmp = Decode85Byte(src[0]) + 85*(Decode85Byte(src[1]) + 85*(Decode85Byte(src[2]) + 85*(Decode85Byte(src[3]) + 85*Decode85Byte(src[4])))); dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianness. src += 5; dst += 4; } } // Load embedded ProggyClean.ttf at size 13, disable oversampling ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template) { ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); if (!font_cfg_template) { font_cfg.OversampleH = font_cfg.OversampleV = 1; font_cfg.PixelSnapH = true; } if (font_cfg.SizePixels <= 0.0f) font_cfg.SizePixels = 13.0f * 1.0f; if (font_cfg.Name[0] == '\0') ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "ProggyClean.ttf, %dpx", (int)font_cfg.SizePixels); font_cfg.EllipsisChar = (ImWchar)0x0085; const char* ttf_compressed_base85 = GetDefaultCompressedFontDataTTFBase85(); const ImWchar* glyph_ranges = font_cfg.GlyphRanges != NULL ? font_cfg.GlyphRanges : GetGlyphRangesDefault(); ImFont* font = AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_cfg.SizePixels, &font_cfg, glyph_ranges); font->DisplayOffset.y = 1.0f; return font; } ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) { IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); size_t data_size = 0; void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0); if (!data) { IM_ASSERT_USER_ERROR(0, "Could not load font file!"); return NULL; } ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); if (font_cfg.Name[0] == '\0') { // Store a short copy of filename into into the font name for convenience const char* p; for (p = filename + strlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {} ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "%s, %.0fpx", p, size_pixels); } return AddFontFromMemoryTTF(data, (int)data_size, size_pixels, &font_cfg, glyph_ranges); } // NB: Transfer ownership of 'ttf_data' to ImFontAtlas, unless font_cfg_template->FontDataOwnedByAtlas == false. Owned TTF buffer will be deleted after Build(). ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) { IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); IM_ASSERT(font_cfg.FontData == NULL); font_cfg.FontData = ttf_data; font_cfg.FontDataSize = ttf_size; font_cfg.SizePixels = size_pixels; if (glyph_ranges) font_cfg.GlyphRanges = glyph_ranges; return AddFont(&font_cfg); } ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) { const unsigned int buf_decompressed_size = stb_decompress_length((const unsigned char*)compressed_ttf_data); unsigned char* buf_decompressed_data = (unsigned char *)IM_ALLOC(buf_decompressed_size); stb_decompress(buf_decompressed_data, (const unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size); ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); IM_ASSERT(font_cfg.FontData == NULL); font_cfg.FontDataOwnedByAtlas = true; return AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, size_pixels, &font_cfg, glyph_ranges); } ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges) { int compressed_ttf_size = (((int)strlen(compressed_ttf_data_base85) + 4) / 5) * 4; void* compressed_ttf = IM_ALLOC((size_t)compressed_ttf_size); Decode85((const unsigned char*)compressed_ttf_data_base85, (unsigned char*)compressed_ttf); ImFont* font = AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, font_cfg, glyph_ranges); IM_FREE(compressed_ttf); return font; } int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height) { // Breaking change on 2019/11/21 (1.74): ImFontAtlas::AddCustomRectRegular() now requires an ID >= 0x110000 (instead of >= 0x10000) IM_ASSERT(id >= 0x110000); IM_ASSERT(width > 0 && width <= 0xFFFF); IM_ASSERT(height > 0 && height <= 0xFFFF); ImFontAtlasCustomRect r; r.ID = id; r.Width = (unsigned short)width; r.Height = (unsigned short)height; CustomRects.push_back(r); return CustomRects.Size - 1; // Return index } int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset) { IM_ASSERT(font != NULL); IM_ASSERT(width > 0 && width <= 0xFFFF); IM_ASSERT(height > 0 && height <= 0xFFFF); ImFontAtlasCustomRect r; r.ID = id; r.Width = (unsigned short)width; r.Height = (unsigned short)height; r.GlyphAdvanceX = advance_x; r.GlyphOffset = offset; r.Font = font; CustomRects.push_back(r); return CustomRects.Size - 1; // Return index } void ImFontAtlas::CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max) const { IM_ASSERT(TexWidth > 0 && TexHeight > 0); // Font atlas needs to be built before we can calculate UV coordinates IM_ASSERT(rect->IsPacked()); // Make sure the rectangle has been packed *out_uv_min = ImVec2((float)rect->X * TexUvScale.x, (float)rect->Y * TexUvScale.y); *out_uv_max = ImVec2((float)(rect->X + rect->Width) * TexUvScale.x, (float)(rect->Y + rect->Height) * TexUvScale.y); } bool ImFontAtlas::GetMouseCursorTexData(ImGuiMouseCursor cursor_type, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2]) { if (cursor_type <= ImGuiMouseCursor_None || cursor_type >= ImGuiMouseCursor_COUNT) return false; if (Flags & ImFontAtlasFlags_NoMouseCursors) return false; IM_ASSERT(CustomRectIds[0] != -1); ImFontAtlasCustomRect& r = CustomRects[CustomRectIds[0]]; IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID); ImVec2 pos = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][0] + ImVec2((float)r.X, (float)r.Y); ImVec2 size = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][1]; *out_size = size; *out_offset = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][2]; out_uv_border[0] = (pos) * TexUvScale; out_uv_border[1] = (pos + size) * TexUvScale; pos.x += FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF + 1; out_uv_fill[0] = (pos) * TexUvScale; out_uv_fill[1] = (pos + size) * TexUvScale; return true; } bool ImFontAtlas::Build() { IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); return ImFontAtlasBuildWithStbTruetype(this); } void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_brighten_factor) { for (unsigned int i = 0; i < 256; i++) { unsigned int value = (unsigned int)(i * in_brighten_factor); out_table[i] = value > 255 ? 255 : (value & 0xFF); } } void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride) { unsigned char* data = pixels + x + y * stride; for (int j = h; j > 0; j--, data += stride) for (int i = 0; i < w; i++) data[i] = table[data[i]]; } // Temporary data for one source font (multiple source fonts can be merged into one destination ImFont) // (C++03 doesn't allow instancing ImVector<> with function-local types so we declare the type here.) struct ImFontBuildSrcData { stbtt_fontinfo FontInfo; stbtt_pack_range PackRange; // Hold the list of codepoints to pack (essentially points to Codepoints.Data) stbrp_rect* Rects; // Rectangle to pack. We first fill in their size and the packer will give us their position. stbtt_packedchar* PackedChars; // Output glyphs const ImWchar* SrcRanges; // Ranges as requested by user (user is allowed to request too much, e.g. 0x0020..0xFFFF) int DstIndex; // Index into atlas->Fonts[] and dst_tmp_array[] int GlyphsHighest; // Highest requested codepoint int GlyphsCount; // Glyph count (excluding missing glyphs and glyphs already set by an earlier source font) ImBoolVector GlyphsSet; // Glyph bit map (random access, 1-bit per codepoint. This will be a maximum of 8KB) ImVector GlyphsList; // Glyph codepoints list (flattened version of GlyphsMap) }; // Temporary data for one destination ImFont* (multiple source fonts can be merged into one destination ImFont) struct ImFontBuildDstData { int SrcCount; // Number of source fonts targeting this destination font. int GlyphsHighest; int GlyphsCount; ImBoolVector GlyphsSet; // This is used to resolve collision when multiple sources are merged into a same destination font. }; static void UnpackBoolVectorToFlatIndexList(const ImBoolVector* in, ImVector* out) { IM_ASSERT(sizeof(in->Storage.Data[0]) == sizeof(int)); const int* it_begin = in->Storage.begin(); const int* it_end = in->Storage.end(); for (const int* it = it_begin; it < it_end; it++) if (int entries_32 = *it) for (int bit_n = 0; bit_n < 32; bit_n++) if (entries_32 & (1u << bit_n)) out->push_back((int)((it - it_begin) << 5) + bit_n); } bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas) { IM_ASSERT(atlas->ConfigData.Size > 0); ImFontAtlasBuildRegisterDefaultCustomRects(atlas); // Clear atlas atlas->TexID = (ImTextureID)NULL; atlas->TexWidth = atlas->TexHeight = 0; atlas->TexUvScale = ImVec2(0.0f, 0.0f); atlas->TexUvWhitePixel = ImVec2(0.0f, 0.0f); atlas->ClearTexData(); // Temporary storage for building ImVector src_tmp_array; ImVector dst_tmp_array; src_tmp_array.resize(atlas->ConfigData.Size); dst_tmp_array.resize(atlas->Fonts.Size); memset(src_tmp_array.Data, 0, (size_t)src_tmp_array.size_in_bytes()); memset(dst_tmp_array.Data, 0, (size_t)dst_tmp_array.size_in_bytes()); // 1. Initialize font loading structure, check font data validity for (int src_i = 0; src_i < atlas->ConfigData.Size; src_i++) { ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; ImFontConfig& cfg = atlas->ConfigData[src_i]; IM_ASSERT(cfg.DstFont && (!cfg.DstFont->IsLoaded() || cfg.DstFont->ContainerAtlas == atlas)); // Find index from cfg.DstFont (we allow the user to set cfg.DstFont. Also it makes casual debugging nicer than when storing indices) src_tmp.DstIndex = -1; for (int output_i = 0; output_i < atlas->Fonts.Size && src_tmp.DstIndex == -1; output_i++) if (cfg.DstFont == atlas->Fonts[output_i]) src_tmp.DstIndex = output_i; IM_ASSERT(src_tmp.DstIndex != -1); // cfg.DstFont not pointing within atlas->Fonts[] array? if (src_tmp.DstIndex == -1) return false; // Initialize helper structure for font loading and verify that the TTF/OTF data is correct const int font_offset = stbtt_GetFontOffsetForIndex((unsigned char*)cfg.FontData, cfg.FontNo); IM_ASSERT(font_offset >= 0 && "FontData is incorrect, or FontNo cannot be found."); if (!stbtt_InitFont(&src_tmp.FontInfo, (unsigned char*)cfg.FontData, font_offset)) return false; // Measure highest codepoints ImFontBuildDstData& dst_tmp = dst_tmp_array[src_tmp.DstIndex]; src_tmp.SrcRanges = cfg.GlyphRanges ? cfg.GlyphRanges : atlas->GetGlyphRangesDefault(); for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2) src_tmp.GlyphsHighest = ImMax(src_tmp.GlyphsHighest, (int)src_range[1]); dst_tmp.SrcCount++; dst_tmp.GlyphsHighest = ImMax(dst_tmp.GlyphsHighest, src_tmp.GlyphsHighest); } // 2. For every requested codepoint, check for their presence in the font data, and handle redundancy or overlaps between source fonts to avoid unused glyphs. int total_glyphs_count = 0; for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) { ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; ImFontBuildDstData& dst_tmp = dst_tmp_array[src_tmp.DstIndex]; src_tmp.GlyphsSet.Resize(src_tmp.GlyphsHighest + 1); if (dst_tmp.GlyphsSet.Storage.empty()) dst_tmp.GlyphsSet.Resize(dst_tmp.GlyphsHighest + 1); for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2) for (unsigned int codepoint = src_range[0]; codepoint <= src_range[1]; codepoint++) { if (dst_tmp.GlyphsSet.GetBit(codepoint)) // Don't overwrite existing glyphs. We could make this an option for MergeMode (e.g. MergeOverwrite==true) continue; if (!stbtt_FindGlyphIndex(&src_tmp.FontInfo, codepoint)) // It is actually in the font? continue; // Add to avail set/counters src_tmp.GlyphsCount++; dst_tmp.GlyphsCount++; src_tmp.GlyphsSet.SetBit(codepoint, true); dst_tmp.GlyphsSet.SetBit(codepoint, true); total_glyphs_count++; } } // 3. Unpack our bit map into a flat list (we now have all the Unicode points that we know are requested _and_ available _and_ not overlapping another) for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) { ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; src_tmp.GlyphsList.reserve(src_tmp.GlyphsCount); UnpackBoolVectorToFlatIndexList(&src_tmp.GlyphsSet, &src_tmp.GlyphsList); src_tmp.GlyphsSet.Clear(); IM_ASSERT(src_tmp.GlyphsList.Size == src_tmp.GlyphsCount); } for (int dst_i = 0; dst_i < dst_tmp_array.Size; dst_i++) dst_tmp_array[dst_i].GlyphsSet.Clear(); dst_tmp_array.clear(); // Allocate packing character data and flag packed characters buffer as non-packed (x0=y0=x1=y1=0) // (We technically don't need to zero-clear buf_rects, but let's do it for the sake of sanity) ImVector buf_rects; ImVector buf_packedchars; buf_rects.resize(total_glyphs_count); buf_packedchars.resize(total_glyphs_count); memset(buf_rects.Data, 0, (size_t)buf_rects.size_in_bytes()); memset(buf_packedchars.Data, 0, (size_t)buf_packedchars.size_in_bytes()); // 4. Gather glyphs sizes so we can pack them in our virtual canvas. int total_surface = 0; int buf_rects_out_n = 0; int buf_packedchars_out_n = 0; for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) { ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; if (src_tmp.GlyphsCount == 0) continue; src_tmp.Rects = &buf_rects[buf_rects_out_n]; src_tmp.PackedChars = &buf_packedchars[buf_packedchars_out_n]; buf_rects_out_n += src_tmp.GlyphsCount; buf_packedchars_out_n += src_tmp.GlyphsCount; // Convert our ranges in the format stb_truetype wants ImFontConfig& cfg = atlas->ConfigData[src_i]; src_tmp.PackRange.font_size = cfg.SizePixels; src_tmp.PackRange.first_unicode_codepoint_in_range = 0; src_tmp.PackRange.array_of_unicode_codepoints = src_tmp.GlyphsList.Data; src_tmp.PackRange.num_chars = src_tmp.GlyphsList.Size; src_tmp.PackRange.chardata_for_range = src_tmp.PackedChars; src_tmp.PackRange.h_oversample = (unsigned char)cfg.OversampleH; src_tmp.PackRange.v_oversample = (unsigned char)cfg.OversampleV; // Gather the sizes of all rectangles we will need to pack (this loop is based on stbtt_PackFontRangesGatherRects) const float scale = (cfg.SizePixels > 0) ? stbtt_ScaleForPixelHeight(&src_tmp.FontInfo, cfg.SizePixels) : stbtt_ScaleForMappingEmToPixels(&src_tmp.FontInfo, -cfg.SizePixels); const int padding = atlas->TexGlyphPadding; for (int glyph_i = 0; glyph_i < src_tmp.GlyphsList.Size; glyph_i++) { int x0, y0, x1, y1; const int glyph_index_in_font = stbtt_FindGlyphIndex(&src_tmp.FontInfo, src_tmp.GlyphsList[glyph_i]); IM_ASSERT(glyph_index_in_font != 0); stbtt_GetGlyphBitmapBoxSubpixel(&src_tmp.FontInfo, glyph_index_in_font, scale * cfg.OversampleH, scale * cfg.OversampleV, 0, 0, &x0, &y0, &x1, &y1); src_tmp.Rects[glyph_i].w = (stbrp_coord)(x1 - x0 + padding + cfg.OversampleH - 1); src_tmp.Rects[glyph_i].h = (stbrp_coord)(y1 - y0 + padding + cfg.OversampleV - 1); total_surface += src_tmp.Rects[glyph_i].w * src_tmp.Rects[glyph_i].h; } } // We need a width for the skyline algorithm, any width! // The exact width doesn't really matter much, but some API/GPU have texture size limitations and increasing width can decrease height. // User can override TexDesiredWidth and TexGlyphPadding if they wish, otherwise we use a simple heuristic to select the width based on expected surface. const int surface_sqrt = (int)ImSqrt((float)total_surface) + 1; atlas->TexHeight = 0; if (atlas->TexDesiredWidth > 0) atlas->TexWidth = atlas->TexDesiredWidth; else atlas->TexWidth = (surface_sqrt >= 4096*0.7f) ? 4096 : (surface_sqrt >= 2048*0.7f) ? 2048 : (surface_sqrt >= 1024*0.7f) ? 1024 : 512; // 5. Start packing // Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values). const int TEX_HEIGHT_MAX = 1024 * 32; stbtt_pack_context spc = {}; stbtt_PackBegin(&spc, NULL, atlas->TexWidth, TEX_HEIGHT_MAX, 0, atlas->TexGlyphPadding, NULL); ImFontAtlasBuildPackCustomRects(atlas, spc.pack_info); // 6. Pack each source font. No rendering yet, we are working with rectangles in an infinitely tall texture at this point. for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) { ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; if (src_tmp.GlyphsCount == 0) continue; stbrp_pack_rects((stbrp_context*)spc.pack_info, src_tmp.Rects, src_tmp.GlyphsCount); // Extend texture height and mark missing glyphs as non-packed so we won't render them. // FIXME: We are not handling packing failure here (would happen if we got off TEX_HEIGHT_MAX or if a single if larger than TexWidth?) for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++) if (src_tmp.Rects[glyph_i].was_packed) atlas->TexHeight = ImMax(atlas->TexHeight, src_tmp.Rects[glyph_i].y + src_tmp.Rects[glyph_i].h); } // 7. Allocate texture atlas->TexHeight = (atlas->Flags & ImFontAtlasFlags_NoPowerOfTwoHeight) ? (atlas->TexHeight + 1) : ImUpperPowerOfTwo(atlas->TexHeight); atlas->TexUvScale = ImVec2(1.0f / atlas->TexWidth, 1.0f / atlas->TexHeight); atlas->TexPixelsAlpha8 = (unsigned char*)IM_ALLOC(atlas->TexWidth * atlas->TexHeight); memset(atlas->TexPixelsAlpha8, 0, atlas->TexWidth * atlas->TexHeight); spc.pixels = atlas->TexPixelsAlpha8; spc.height = atlas->TexHeight; // 8. Render/rasterize font characters into the texture for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) { ImFontConfig& cfg = atlas->ConfigData[src_i]; ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; if (src_tmp.GlyphsCount == 0) continue; stbtt_PackFontRangesRenderIntoRects(&spc, &src_tmp.FontInfo, &src_tmp.PackRange, 1, src_tmp.Rects); // Apply multiply operator if (cfg.RasterizerMultiply != 1.0f) { unsigned char multiply_table[256]; ImFontAtlasBuildMultiplyCalcLookupTable(multiply_table, cfg.RasterizerMultiply); stbrp_rect* r = &src_tmp.Rects[0]; for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++, r++) if (r->was_packed) ImFontAtlasBuildMultiplyRectAlpha8(multiply_table, atlas->TexPixelsAlpha8, r->x, r->y, r->w, r->h, atlas->TexWidth * 1); } src_tmp.Rects = NULL; } // End packing stbtt_PackEnd(&spc); buf_rects.clear(); // 9. Setup ImFont and glyphs for runtime for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) { ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; if (src_tmp.GlyphsCount == 0) continue; ImFontConfig& cfg = atlas->ConfigData[src_i]; ImFont* dst_font = cfg.DstFont; // We can have multiple input fonts writing into a same destination font (when using MergeMode=true) const float font_scale = stbtt_ScaleForPixelHeight(&src_tmp.FontInfo, cfg.SizePixels); int unscaled_ascent, unscaled_descent, unscaled_line_gap; stbtt_GetFontVMetrics(&src_tmp.FontInfo, &unscaled_ascent, &unscaled_descent, &unscaled_line_gap); const float ascent = ImFloor(unscaled_ascent * font_scale + ((unscaled_ascent > 0.0f) ? +1 : -1)); const float descent = ImFloor(unscaled_descent * font_scale + ((unscaled_descent > 0.0f) ? +1 : -1)); ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent); const float font_off_x = cfg.GlyphOffset.x; const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent); for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++) { const int codepoint = src_tmp.GlyphsList[glyph_i]; const stbtt_packedchar& pc = src_tmp.PackedChars[glyph_i]; const float char_advance_x_org = pc.xadvance; const float char_advance_x_mod = ImClamp(char_advance_x_org, cfg.GlyphMinAdvanceX, cfg.GlyphMaxAdvanceX); float char_off_x = font_off_x; if (char_advance_x_org != char_advance_x_mod) char_off_x += cfg.PixelSnapH ? ImFloor((char_advance_x_mod - char_advance_x_org) * 0.5f) : (char_advance_x_mod - char_advance_x_org) * 0.5f; // Register glyph stbtt_aligned_quad q; float dummy_x = 0.0f, dummy_y = 0.0f; stbtt_GetPackedQuad(src_tmp.PackedChars, atlas->TexWidth, atlas->TexHeight, glyph_i, &dummy_x, &dummy_y, &q, 0); dst_font->AddGlyph((ImWchar)codepoint, q.x0 + char_off_x, q.y0 + font_off_y, q.x1 + char_off_x, q.y1 + font_off_y, q.s0, q.t0, q.s1, q.t1, char_advance_x_mod); } } // Cleanup temporary (ImVector doesn't honor destructor) for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) src_tmp_array[src_i].~ImFontBuildSrcData(); ImFontAtlasBuildFinish(atlas); return true; } void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas) { if (atlas->CustomRectIds[0] >= 0) return; if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors)) atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF*2+1, FONT_ATLAS_DEFAULT_TEX_DATA_H); else atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, 2, 2); } void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent) { if (!font_config->MergeMode) { font->ClearOutputData(); font->FontSize = font_config->SizePixels; font->ConfigData = font_config; font->ContainerAtlas = atlas; font->Ascent = ascent; font->Descent = descent; } font->ConfigDataCount++; } void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque) { stbrp_context* pack_context = (stbrp_context*)stbrp_context_opaque; IM_ASSERT(pack_context != NULL); ImVector& user_rects = atlas->CustomRects; IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong. ImVector pack_rects; pack_rects.resize(user_rects.Size); memset(pack_rects.Data, 0, (size_t)pack_rects.size_in_bytes()); for (int i = 0; i < user_rects.Size; i++) { pack_rects[i].w = user_rects[i].Width; pack_rects[i].h = user_rects[i].Height; } stbrp_pack_rects(pack_context, &pack_rects[0], pack_rects.Size); for (int i = 0; i < pack_rects.Size; i++) if (pack_rects[i].was_packed) { user_rects[i].X = pack_rects[i].x; user_rects[i].Y = pack_rects[i].y; IM_ASSERT(pack_rects[i].w == user_rects[i].Width && pack_rects[i].h == user_rects[i].Height); atlas->TexHeight = ImMax(atlas->TexHeight, pack_rects[i].y + pack_rects[i].h); } } static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas) { IM_ASSERT(atlas->CustomRectIds[0] >= 0); IM_ASSERT(atlas->TexPixelsAlpha8 != NULL); ImFontAtlasCustomRect& r = atlas->CustomRects[atlas->CustomRectIds[0]]; IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID); IM_ASSERT(r.IsPacked()); const int w = atlas->TexWidth; if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors)) { // Render/copy pixels IM_ASSERT(r.Width == FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * 2 + 1 && r.Height == FONT_ATLAS_DEFAULT_TEX_DATA_H); for (int y = 0, n = 0; y < FONT_ATLAS_DEFAULT_TEX_DATA_H; y++) for (int x = 0; x < FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF; x++, n++) { const int offset0 = (int)(r.X + x) + (int)(r.Y + y) * w; const int offset1 = offset0 + FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF + 1; atlas->TexPixelsAlpha8[offset0] = FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[n] == '.' ? 0xFF : 0x00; atlas->TexPixelsAlpha8[offset1] = FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[n] == 'X' ? 0xFF : 0x00; } } else { IM_ASSERT(r.Width == 2 && r.Height == 2); const int offset = (int)(r.X) + (int)(r.Y) * w; atlas->TexPixelsAlpha8[offset] = atlas->TexPixelsAlpha8[offset + 1] = atlas->TexPixelsAlpha8[offset + w] = atlas->TexPixelsAlpha8[offset + w + 1] = 0xFF; } atlas->TexUvWhitePixel = ImVec2((r.X + 0.5f) * atlas->TexUvScale.x, (r.Y + 0.5f) * atlas->TexUvScale.y); } void ImFontAtlasBuildFinish(ImFontAtlas* atlas) { // Render into our custom data block ImFontAtlasBuildRenderDefaultTexData(atlas); // Register custom rectangle glyphs for (int i = 0; i < atlas->CustomRects.Size; i++) { const ImFontAtlasCustomRect& r = atlas->CustomRects[i]; if (r.Font == NULL || r.ID >= 0x110000) continue; IM_ASSERT(r.Font->ContainerAtlas == atlas); ImVec2 uv0, uv1; atlas->CalcCustomRectUV(&r, &uv0, &uv1); r.Font->AddGlyph((ImWchar)r.ID, r.GlyphOffset.x, r.GlyphOffset.y, r.GlyphOffset.x + r.Width, r.GlyphOffset.y + r.Height, uv0.x, uv0.y, uv1.x, uv1.y, r.GlyphAdvanceX); } // Build all fonts lookup tables for (int i = 0; i < atlas->Fonts.Size; i++) if (atlas->Fonts[i]->DirtyLookupTables) atlas->Fonts[i]->BuildLookupTable(); // Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis). // However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character. // FIXME: Also note that 0x2026 is currently seldomly included in our font ranges. Because of this we are more likely to use three individual dots. for (int i = 0; i < atlas->Fonts.size(); i++) { ImFont* font = atlas->Fonts[i]; if (font->EllipsisChar != (ImWchar)-1) continue; const ImWchar ellipsis_variants[] = { (ImWchar)0x2026, (ImWchar)0x0085 }; for (int j = 0; j < IM_ARRAYSIZE(ellipsis_variants); j++) if (font->FindGlyphNoFallback(ellipsis_variants[j]) != NULL) // Verify glyph exists { font->EllipsisChar = ellipsis_variants[j]; break; } } } // Retrieve list of range (2 int per range, values are inclusive) const ImWchar* ImFontAtlas::GetGlyphRangesDefault() { static const ImWchar ranges[] = { 0x0020, 0x00FF, // Basic Latin + Latin Supplement 0, }; return &ranges[0]; } const ImWchar* ImFontAtlas::GetGlyphRangesKorean() { static const ImWchar ranges[] = { 0x0020, 0x00FF, // Basic Latin + Latin Supplement 0x3131, 0x3163, // Korean alphabets 0xAC00, 0xD79D, // Korean characters 0, }; return &ranges[0]; } const ImWchar* ImFontAtlas::GetGlyphRangesChineseFull() { static const ImWchar ranges[] = { 0x0020, 0x00FF, // Basic Latin + Latin Supplement 0x2000, 0x206F, // General Punctuation 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana 0x31F0, 0x31FF, // Katakana Phonetic Extensions 0xFF00, 0xFFEF, // Half-width characters 0x4e00, 0x9FAF, // CJK Ideograms 0, }; return &ranges[0]; } static void UnpackAccumulativeOffsetsIntoRanges(int base_codepoint, const short* accumulative_offsets, int accumulative_offsets_count, ImWchar* out_ranges) { for (int n = 0; n < accumulative_offsets_count; n++, out_ranges += 2) { out_ranges[0] = out_ranges[1] = (ImWchar)(base_codepoint + accumulative_offsets[n]); base_codepoint += accumulative_offsets[n]; } out_ranges[0] = 0; } //------------------------------------------------------------------------- // [SECTION] ImFontAtlas glyph ranges helpers //------------------------------------------------------------------------- const ImWchar* ImFontAtlas::GetGlyphRangesChineseSimplifiedCommon() { // Store 2500 regularly used characters for Simplified Chinese. // Sourced from https://zh.wiktionary.org/wiki/%E9%99%84%E5%BD%95:%E7%8E%B0%E4%BB%A3%E6%B1%89%E8%AF%AD%E5%B8%B8%E7%94%A8%E5%AD%97%E8%A1%A8 // This table covers 97.97% of all characters used during the month in July, 1987. // You can use ImFontGlyphRangesBuilder to create your own ranges derived from this, by merging existing ranges or adding new characters. // (Stored as accumulative offsets from the initial unicode codepoint 0x4E00. This encoding is designed to helps us compact the source code size.) static const short accumulative_offsets_from_0x4E00[] = { 0,1,2,4,1,1,1,1,2,1,3,2,1,2,2,1,1,1,1,1,5,2,1,2,3,3,3,2,2,4,1,1,1,2,1,5,2,3,1,2,1,2,1,1,2,1,1,2,2,1,4,1,1,1,1,5,10,1,2,19,2,1,2,1,2,1,2,1,2, 1,5,1,6,3,2,1,2,2,1,1,1,4,8,5,1,1,4,1,1,3,1,2,1,5,1,2,1,1,1,10,1,1,5,2,4,6,1,4,2,2,2,12,2,1,1,6,1,1,1,4,1,1,4,6,5,1,4,2,2,4,10,7,1,1,4,2,4, 2,1,4,3,6,10,12,5,7,2,14,2,9,1,1,6,7,10,4,7,13,1,5,4,8,4,1,1,2,28,5,6,1,1,5,2,5,20,2,2,9,8,11,2,9,17,1,8,6,8,27,4,6,9,20,11,27,6,68,2,2,1,1, 1,2,1,2,2,7,6,11,3,3,1,1,3,1,2,1,1,1,1,1,3,1,1,8,3,4,1,5,7,2,1,4,4,8,4,2,1,2,1,1,4,5,6,3,6,2,12,3,1,3,9,2,4,3,4,1,5,3,3,1,3,7,1,5,1,1,1,1,2, 3,4,5,2,3,2,6,1,1,2,1,7,1,7,3,4,5,15,2,2,1,5,3,22,19,2,1,1,1,1,2,5,1,1,1,6,1,1,12,8,2,9,18,22,4,1,1,5,1,16,1,2,7,10,15,1,1,6,2,4,1,2,4,1,6, 1,1,3,2,4,1,6,4,5,1,2,1,1,2,1,10,3,1,3,2,1,9,3,2,5,7,2,19,4,3,6,1,1,1,1,1,4,3,2,1,1,1,2,5,3,1,1,1,2,2,1,1,2,1,1,2,1,3,1,1,1,3,7,1,4,1,1,2,1, 1,2,1,2,4,4,3,8,1,1,1,2,1,3,5,1,3,1,3,4,6,2,2,14,4,6,6,11,9,1,15,3,1,28,5,2,5,5,3,1,3,4,5,4,6,14,3,2,3,5,21,2,7,20,10,1,2,19,2,4,28,28,2,3, 2,1,14,4,1,26,28,42,12,40,3,52,79,5,14,17,3,2,2,11,3,4,6,3,1,8,2,23,4,5,8,10,4,2,7,3,5,1,1,6,3,1,2,2,2,5,28,1,1,7,7,20,5,3,29,3,17,26,1,8,4, 27,3,6,11,23,5,3,4,6,13,24,16,6,5,10,25,35,7,3,2,3,3,14,3,6,2,6,1,4,2,3,8,2,1,1,3,3,3,4,1,1,13,2,2,4,5,2,1,14,14,1,2,2,1,4,5,2,3,1,14,3,12, 3,17,2,16,5,1,2,1,8,9,3,19,4,2,2,4,17,25,21,20,28,75,1,10,29,103,4,1,2,1,1,4,2,4,1,2,3,24,2,2,2,1,1,2,1,3,8,1,1,1,2,1,1,3,1,1,1,6,1,5,3,1,1, 1,3,4,1,1,5,2,1,5,6,13,9,16,1,1,1,1,3,2,3,2,4,5,2,5,2,2,3,7,13,7,2,2,1,1,1,1,2,3,3,2,1,6,4,9,2,1,14,2,14,2,1,18,3,4,14,4,11,41,15,23,15,23, 176,1,3,4,1,1,1,1,5,3,1,2,3,7,3,1,1,2,1,2,4,4,6,2,4,1,9,7,1,10,5,8,16,29,1,1,2,2,3,1,3,5,2,4,5,4,1,1,2,2,3,3,7,1,6,10,1,17,1,44,4,6,2,1,1,6, 5,4,2,10,1,6,9,2,8,1,24,1,2,13,7,8,8,2,1,4,1,3,1,3,3,5,2,5,10,9,4,9,12,2,1,6,1,10,1,1,7,7,4,10,8,3,1,13,4,3,1,6,1,3,5,2,1,2,17,16,5,2,16,6, 1,4,2,1,3,3,6,8,5,11,11,1,3,3,2,4,6,10,9,5,7,4,7,4,7,1,1,4,2,1,3,6,8,7,1,6,11,5,5,3,24,9,4,2,7,13,5,1,8,82,16,61,1,1,1,4,2,2,16,10,3,8,1,1, 6,4,2,1,3,1,1,1,4,3,8,4,2,2,1,1,1,1,1,6,3,5,1,1,4,6,9,2,1,1,1,2,1,7,2,1,6,1,5,4,4,3,1,8,1,3,3,1,3,2,2,2,2,3,1,6,1,2,1,2,1,3,7,1,8,2,1,2,1,5, 2,5,3,5,10,1,2,1,1,3,2,5,11,3,9,3,5,1,1,5,9,1,2,1,5,7,9,9,8,1,3,3,3,6,8,2,3,2,1,1,32,6,1,2,15,9,3,7,13,1,3,10,13,2,14,1,13,10,2,1,3,10,4,15, 2,15,15,10,1,3,9,6,9,32,25,26,47,7,3,2,3,1,6,3,4,3,2,8,5,4,1,9,4,2,2,19,10,6,2,3,8,1,2,2,4,2,1,9,4,4,4,6,4,8,9,2,3,1,1,1,1,3,5,5,1,3,8,4,6, 2,1,4,12,1,5,3,7,13,2,5,8,1,6,1,2,5,14,6,1,5,2,4,8,15,5,1,23,6,62,2,10,1,1,8,1,2,2,10,4,2,2,9,2,1,1,3,2,3,1,5,3,3,2,1,3,8,1,1,1,11,3,1,1,4, 3,7,1,14,1,2,3,12,5,2,5,1,6,7,5,7,14,11,1,3,1,8,9,12,2,1,11,8,4,4,2,6,10,9,13,1,1,3,1,5,1,3,2,4,4,1,18,2,3,14,11,4,29,4,2,7,1,3,13,9,2,2,5, 3,5,20,7,16,8,5,72,34,6,4,22,12,12,28,45,36,9,7,39,9,191,1,1,1,4,11,8,4,9,2,3,22,1,1,1,1,4,17,1,7,7,1,11,31,10,2,4,8,2,3,2,1,4,2,16,4,32,2, 3,19,13,4,9,1,5,2,14,8,1,1,3,6,19,6,5,1,16,6,2,10,8,5,1,2,3,1,5,5,1,11,6,6,1,3,3,2,6,3,8,1,1,4,10,7,5,7,7,5,8,9,2,1,3,4,1,1,3,1,3,3,2,6,16, 1,4,6,3,1,10,6,1,3,15,2,9,2,10,25,13,9,16,6,2,2,10,11,4,3,9,1,2,6,6,5,4,30,40,1,10,7,12,14,33,6,3,6,7,3,1,3,1,11,14,4,9,5,12,11,49,18,51,31, 140,31,2,2,1,5,1,8,1,10,1,4,4,3,24,1,10,1,3,6,6,16,3,4,5,2,1,4,2,57,10,6,22,2,22,3,7,22,6,10,11,36,18,16,33,36,2,5,5,1,1,1,4,10,1,4,13,2,7, 5,2,9,3,4,1,7,43,3,7,3,9,14,7,9,1,11,1,1,3,7,4,18,13,1,14,1,3,6,10,73,2,2,30,6,1,11,18,19,13,22,3,46,42,37,89,7,3,16,34,2,2,3,9,1,7,1,1,1,2, 2,4,10,7,3,10,3,9,5,28,9,2,6,13,7,3,1,3,10,2,7,2,11,3,6,21,54,85,2,1,4,2,2,1,39,3,21,2,2,5,1,1,1,4,1,1,3,4,15,1,3,2,4,4,2,3,8,2,20,1,8,7,13, 4,1,26,6,2,9,34,4,21,52,10,4,4,1,5,12,2,11,1,7,2,30,12,44,2,30,1,1,3,6,16,9,17,39,82,2,2,24,7,1,7,3,16,9,14,44,2,1,2,1,2,3,5,2,4,1,6,7,5,3, 2,6,1,11,5,11,2,1,18,19,8,1,3,24,29,2,1,3,5,2,2,1,13,6,5,1,46,11,3,5,1,1,5,8,2,10,6,12,6,3,7,11,2,4,16,13,2,5,1,1,2,2,5,2,28,5,2,23,10,8,4, 4,22,39,95,38,8,14,9,5,1,13,5,4,3,13,12,11,1,9,1,27,37,2,5,4,4,63,211,95,2,2,2,1,3,5,2,1,1,2,2,1,1,1,3,2,4,1,2,1,1,5,2,2,1,1,2,3,1,3,1,1,1, 3,1,4,2,1,3,6,1,1,3,7,15,5,3,2,5,3,9,11,4,2,22,1,6,3,8,7,1,4,28,4,16,3,3,25,4,4,27,27,1,4,1,2,2,7,1,3,5,2,28,8,2,14,1,8,6,16,25,3,3,3,14,3, 3,1,1,2,1,4,6,3,8,4,1,1,1,2,3,6,10,6,2,3,18,3,2,5,5,4,3,1,5,2,5,4,23,7,6,12,6,4,17,11,9,5,1,1,10,5,12,1,1,11,26,33,7,3,6,1,17,7,1,5,12,1,11, 2,4,1,8,14,17,23,1,2,1,7,8,16,11,9,6,5,2,6,4,16,2,8,14,1,11,8,9,1,1,1,9,25,4,11,19,7,2,15,2,12,8,52,7,5,19,2,16,4,36,8,1,16,8,24,26,4,6,2,9, 5,4,36,3,28,12,25,15,37,27,17,12,59,38,5,32,127,1,2,9,17,14,4,1,2,1,1,8,11,50,4,14,2,19,16,4,17,5,4,5,26,12,45,2,23,45,104,30,12,8,3,10,2,2, 3,3,1,4,20,7,2,9,6,15,2,20,1,3,16,4,11,15,6,134,2,5,59,1,2,2,2,1,9,17,3,26,137,10,211,59,1,2,4,1,4,1,1,1,2,6,2,3,1,1,2,3,2,3,1,3,4,4,2,3,3, 1,4,3,1,7,2,2,3,1,2,1,3,3,3,2,2,3,2,1,3,14,6,1,3,2,9,6,15,27,9,34,145,1,1,2,1,1,1,1,2,1,1,1,1,2,2,2,3,1,2,1,1,1,2,3,5,8,3,5,2,4,1,3,2,2,2,12, 4,1,1,1,10,4,5,1,20,4,16,1,15,9,5,12,2,9,2,5,4,2,26,19,7,1,26,4,30,12,15,42,1,6,8,172,1,1,4,2,1,1,11,2,2,4,2,1,2,1,10,8,1,2,1,4,5,1,2,5,1,8, 4,1,3,4,2,1,6,2,1,3,4,1,2,1,1,1,1,12,5,7,2,4,3,1,1,1,3,3,6,1,2,2,3,3,3,2,1,2,12,14,11,6,6,4,12,2,8,1,7,10,1,35,7,4,13,15,4,3,23,21,28,52,5, 26,5,6,1,7,10,2,7,53,3,2,1,1,1,2,163,532,1,10,11,1,3,3,4,8,2,8,6,2,2,23,22,4,2,2,4,2,1,3,1,3,3,5,9,8,2,1,2,8,1,10,2,12,21,20,15,105,2,3,1,1, 3,2,3,1,1,2,5,1,4,15,11,19,1,1,1,1,5,4,5,1,1,2,5,3,5,12,1,2,5,1,11,1,1,15,9,1,4,5,3,26,8,2,1,3,1,1,15,19,2,12,1,2,5,2,7,2,19,2,20,6,26,7,5, 2,2,7,34,21,13,70,2,128,1,1,2,1,1,2,1,1,3,2,2,2,15,1,4,1,3,4,42,10,6,1,49,85,8,1,2,1,1,4,4,2,3,6,1,5,7,4,3,211,4,1,2,1,2,5,1,2,4,2,2,6,5,6, 10,3,4,48,100,6,2,16,296,5,27,387,2,2,3,7,16,8,5,38,15,39,21,9,10,3,7,59,13,27,21,47,5,21,6 }; static ImWchar base_ranges[] = // not zero-terminated { 0x0020, 0x00FF, // Basic Latin + Latin Supplement 0x2000, 0x206F, // General Punctuation 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana 0x31F0, 0x31FF, // Katakana Phonetic Extensions 0xFF00, 0xFFEF // Half-width characters }; static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00) * 2 + 1] = { 0 }; if (!full_ranges[0]) { memcpy(full_ranges, base_ranges, sizeof(base_ranges)); UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_ARRAYSIZE(accumulative_offsets_from_0x4E00), full_ranges + IM_ARRAYSIZE(base_ranges)); } return &full_ranges[0]; } const ImWchar* ImFontAtlas::GetGlyphRangesJapanese() { // 1946 common ideograms code points for Japanese // Sourced from http://theinstructionlimit.com/common-kanji-character-ranges-for-xna-spritefont-rendering // FIXME: Source a list of the revised 2136 Joyo Kanji list from 2010 and rebuild this. // You can use ImFontGlyphRangesBuilder to create your own ranges derived from this, by merging existing ranges or adding new characters. // (Stored as accumulative offsets from the initial unicode codepoint 0x4E00. This encoding is designed to helps us compact the source code size.) static const short accumulative_offsets_from_0x4E00[] = { 0,1,2,4,1,1,1,1,2,1,6,2,2,1,8,5,7,11,1,2,10,10,8,2,4,20,2,11,8,2,1,2,1,6,2,1,7,5,3,7,1,1,13,7,9,1,4,6,1,2,1,10,1,1,9,2,2,4,5,6,14,1,1,9,3,18, 5,4,2,2,10,7,1,1,1,3,2,4,3,23,2,10,12,2,14,2,4,13,1,6,10,3,1,7,13,6,4,13,5,2,3,17,2,2,5,7,6,4,1,7,14,16,6,13,9,15,1,1,7,16,4,7,1,19,9,2,7,15, 2,6,5,13,25,4,14,13,11,25,1,1,1,2,1,2,2,3,10,11,3,3,1,1,4,4,2,1,4,9,1,4,3,5,5,2,7,12,11,15,7,16,4,5,16,2,1,1,6,3,3,1,1,2,7,6,6,7,1,4,7,6,1,1, 2,1,12,3,3,9,5,8,1,11,1,2,3,18,20,4,1,3,6,1,7,3,5,5,7,2,2,12,3,1,4,2,3,2,3,11,8,7,4,17,1,9,25,1,1,4,2,2,4,1,2,7,1,1,1,3,1,2,6,16,1,2,1,1,3,12, 20,2,5,20,8,7,6,2,1,1,1,1,6,2,1,2,10,1,1,6,1,3,1,2,1,4,1,12,4,1,3,1,1,1,1,1,10,4,7,5,13,1,15,1,1,30,11,9,1,15,38,14,1,32,17,20,1,9,31,2,21,9, 4,49,22,2,1,13,1,11,45,35,43,55,12,19,83,1,3,2,3,13,2,1,7,3,18,3,13,8,1,8,18,5,3,7,25,24,9,24,40,3,17,24,2,1,6,2,3,16,15,6,7,3,12,1,9,7,3,3, 3,15,21,5,16,4,5,12,11,11,3,6,3,2,31,3,2,1,1,23,6,6,1,4,2,6,5,2,1,1,3,3,22,2,6,2,3,17,3,2,4,5,1,9,5,1,1,6,15,12,3,17,2,14,2,8,1,23,16,4,2,23, 8,15,23,20,12,25,19,47,11,21,65,46,4,3,1,5,6,1,2,5,26,2,1,1,3,11,1,1,1,2,1,2,3,1,1,10,2,3,1,1,1,3,6,3,2,2,6,6,9,2,2,2,6,2,5,10,2,4,1,2,1,2,2, 3,1,1,3,1,2,9,23,9,2,1,1,1,1,5,3,2,1,10,9,6,1,10,2,31,25,3,7,5,40,1,15,6,17,7,27,180,1,3,2,2,1,1,1,6,3,10,7,1,3,6,17,8,6,2,2,1,3,5,5,8,16,14, 15,1,1,4,1,2,1,1,1,3,2,7,5,6,2,5,10,1,4,2,9,1,1,11,6,1,44,1,3,7,9,5,1,3,1,1,10,7,1,10,4,2,7,21,15,7,2,5,1,8,3,4,1,3,1,6,1,4,2,1,4,10,8,1,4,5, 1,5,10,2,7,1,10,1,1,3,4,11,10,29,4,7,3,5,2,3,33,5,2,19,3,1,4,2,6,31,11,1,3,3,3,1,8,10,9,12,11,12,8,3,14,8,6,11,1,4,41,3,1,2,7,13,1,5,6,2,6,12, 12,22,5,9,4,8,9,9,34,6,24,1,1,20,9,9,3,4,1,7,2,2,2,6,2,28,5,3,6,1,4,6,7,4,2,1,4,2,13,6,4,4,3,1,8,8,3,2,1,5,1,2,2,3,1,11,11,7,3,6,10,8,6,16,16, 22,7,12,6,21,5,4,6,6,3,6,1,3,2,1,2,8,29,1,10,1,6,13,6,6,19,31,1,13,4,4,22,17,26,33,10,4,15,12,25,6,67,10,2,3,1,6,10,2,6,2,9,1,9,4,4,1,2,16,2, 5,9,2,3,8,1,8,3,9,4,8,6,4,8,11,3,2,1,1,3,26,1,7,5,1,11,1,5,3,5,2,13,6,39,5,1,5,2,11,6,10,5,1,15,5,3,6,19,21,22,2,4,1,6,1,8,1,4,8,2,4,2,2,9,2, 1,1,1,4,3,6,3,12,7,1,14,2,4,10,2,13,1,17,7,3,2,1,3,2,13,7,14,12,3,1,29,2,8,9,15,14,9,14,1,3,1,6,5,9,11,3,38,43,20,7,7,8,5,15,12,19,15,81,8,7, 1,5,73,13,37,28,8,8,1,15,18,20,165,28,1,6,11,8,4,14,7,15,1,3,3,6,4,1,7,14,1,1,11,30,1,5,1,4,14,1,4,2,7,52,2,6,29,3,1,9,1,21,3,5,1,26,3,11,14, 11,1,17,5,1,2,1,3,2,8,1,2,9,12,1,1,2,3,8,3,24,12,7,7,5,17,3,3,3,1,23,10,4,4,6,3,1,16,17,22,3,10,21,16,16,6,4,10,2,1,1,2,8,8,6,5,3,3,3,39,25, 15,1,1,16,6,7,25,15,6,6,12,1,22,13,1,4,9,5,12,2,9,1,12,28,8,3,5,10,22,60,1,2,40,4,61,63,4,1,13,12,1,4,31,12,1,14,89,5,16,6,29,14,2,5,49,18,18, 5,29,33,47,1,17,1,19,12,2,9,7,39,12,3,7,12,39,3,1,46,4,12,3,8,9,5,31,15,18,3,2,2,66,19,13,17,5,3,46,124,13,57,34,2,5,4,5,8,1,1,1,4,3,1,17,5, 3,5,3,1,8,5,6,3,27,3,26,7,12,7,2,17,3,7,18,78,16,4,36,1,2,1,6,2,1,39,17,7,4,13,4,4,4,1,10,4,2,4,6,3,10,1,19,1,26,2,4,33,2,73,47,7,3,8,2,4,15, 18,1,29,2,41,14,1,21,16,41,7,39,25,13,44,2,2,10,1,13,7,1,7,3,5,20,4,8,2,49,1,10,6,1,6,7,10,7,11,16,3,12,20,4,10,3,1,2,11,2,28,9,2,4,7,2,15,1, 27,1,28,17,4,5,10,7,3,24,10,11,6,26,3,2,7,2,2,49,16,10,16,15,4,5,27,61,30,14,38,22,2,7,5,1,3,12,23,24,17,17,3,3,2,4,1,6,2,7,5,1,1,5,1,1,9,4, 1,3,6,1,8,2,8,4,14,3,5,11,4,1,3,32,1,19,4,1,13,11,5,2,1,8,6,8,1,6,5,13,3,23,11,5,3,16,3,9,10,1,24,3,198,52,4,2,2,5,14,5,4,22,5,20,4,11,6,41, 1,5,2,2,11,5,2,28,35,8,22,3,18,3,10,7,5,3,4,1,5,3,8,9,3,6,2,16,22,4,5,5,3,3,18,23,2,6,23,5,27,8,1,33,2,12,43,16,5,2,3,6,1,20,4,2,9,7,1,11,2, 10,3,14,31,9,3,25,18,20,2,5,5,26,14,1,11,17,12,40,19,9,6,31,83,2,7,9,19,78,12,14,21,76,12,113,79,34,4,1,1,61,18,85,10,2,2,13,31,11,50,6,33,159, 179,6,6,7,4,4,2,4,2,5,8,7,20,32,22,1,3,10,6,7,28,5,10,9,2,77,19,13,2,5,1,4,4,7,4,13,3,9,31,17,3,26,2,6,6,5,4,1,7,11,3,4,2,1,6,2,20,4,1,9,2,6, 3,7,1,1,1,20,2,3,1,6,2,3,6,2,4,8,1,5,13,8,4,11,23,1,10,6,2,1,3,21,2,2,4,24,31,4,10,10,2,5,192,15,4,16,7,9,51,1,2,1,1,5,1,1,2,1,3,5,3,1,3,4,1, 3,1,3,3,9,8,1,2,2,2,4,4,18,12,92,2,10,4,3,14,5,25,16,42,4,14,4,2,21,5,126,30,31,2,1,5,13,3,22,5,6,6,20,12,1,14,12,87,3,19,1,8,2,9,9,3,3,23,2, 3,7,6,3,1,2,3,9,1,3,1,6,3,2,1,3,11,3,1,6,10,3,2,3,1,2,1,5,1,1,11,3,6,4,1,7,2,1,2,5,5,34,4,14,18,4,19,7,5,8,2,6,79,1,5,2,14,8,2,9,2,1,36,28,16, 4,1,1,1,2,12,6,42,39,16,23,7,15,15,3,2,12,7,21,64,6,9,28,8,12,3,3,41,59,24,51,55,57,294,9,9,2,6,2,15,1,2,13,38,90,9,9,9,3,11,7,1,1,1,5,6,3,2, 1,2,2,3,8,1,4,4,1,5,7,1,4,3,20,4,9,1,1,1,5,5,17,1,5,2,6,2,4,1,4,5,7,3,18,11,11,32,7,5,4,7,11,127,8,4,3,3,1,10,1,1,6,21,14,1,16,1,7,1,3,6,9,65, 51,4,3,13,3,10,1,1,12,9,21,110,3,19,24,1,1,10,62,4,1,29,42,78,28,20,18,82,6,3,15,6,84,58,253,15,155,264,15,21,9,14,7,58,40,39, }; static ImWchar base_ranges[] = // not zero-terminated { 0x0020, 0x00FF, // Basic Latin + Latin Supplement 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana 0x31F0, 0x31FF, // Katakana Phonetic Extensions 0xFF00, 0xFFEF // Half-width characters }; static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00)*2 + 1] = { 0 }; if (!full_ranges[0]) { memcpy(full_ranges, base_ranges, sizeof(base_ranges)); UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_ARRAYSIZE(accumulative_offsets_from_0x4E00), full_ranges + IM_ARRAYSIZE(base_ranges)); } return &full_ranges[0]; } const ImWchar* ImFontAtlas::GetGlyphRangesCyrillic() { static const ImWchar ranges[] = { 0x0020, 0x00FF, // Basic Latin + Latin Supplement 0x0400, 0x052F, // Cyrillic + Cyrillic Supplement 0x2DE0, 0x2DFF, // Cyrillic Extended-A 0xA640, 0xA69F, // Cyrillic Extended-B 0, }; return &ranges[0]; } const ImWchar* ImFontAtlas::GetGlyphRangesThai() { static const ImWchar ranges[] = { 0x0020, 0x00FF, // Basic Latin 0x2010, 0x205E, // Punctuations 0x0E00, 0x0E7F, // Thai 0, }; return &ranges[0]; } const ImWchar* ImFontAtlas::GetGlyphRangesVietnamese() { static const ImWchar ranges[] = { 0x0020, 0x00FF, // Basic Latin 0x0102, 0x0103, 0x0110, 0x0111, 0x0128, 0x0129, 0x0168, 0x0169, 0x01A0, 0x01A1, 0x01AF, 0x01B0, 0x1EA0, 0x1EF9, 0, }; return &ranges[0]; } //----------------------------------------------------------------------------- // [SECTION] ImFontGlyphRangesBuilder //----------------------------------------------------------------------------- void ImFontGlyphRangesBuilder::AddText(const char* text, const char* text_end) { while (text_end ? (text < text_end) : *text) { unsigned int c = 0; int c_len = ImTextCharFromUtf8(&c, text, text_end); text += c_len; if (c_len == 0) break; if (c <= IM_UNICODE_CODEPOINT_MAX) AddChar((ImWchar)c); } } void ImFontGlyphRangesBuilder::AddRanges(const ImWchar* ranges) { for (; ranges[0]; ranges += 2) for (ImWchar c = ranges[0]; c <= ranges[1]; c++) AddChar(c); } void ImFontGlyphRangesBuilder::BuildRanges(ImVector* out_ranges) { const int max_codepoint = IM_UNICODE_CODEPOINT_MAX; for (int n = 0; n <= max_codepoint; n++) if (GetBit(n)) { out_ranges->push_back((ImWchar)n); while (n < max_codepoint && GetBit(n + 1)) n++; out_ranges->push_back((ImWchar)n); } out_ranges->push_back(0); } //----------------------------------------------------------------------------- // [SECTION] ImFont //----------------------------------------------------------------------------- ImFont::ImFont() { FontSize = 0.0f; FallbackAdvanceX = 0.0f; FallbackChar = (ImWchar)'?'; EllipsisChar = (ImWchar)-1; DisplayOffset = ImVec2(0.0f, 0.0f); FallbackGlyph = NULL; ContainerAtlas = NULL; ConfigData = NULL; ConfigDataCount = 0; DirtyLookupTables = false; Scale = 1.0f; Ascent = Descent = 0.0f; MetricsTotalSurface = 0; } ImFont::~ImFont() { ClearOutputData(); } void ImFont::ClearOutputData() { FontSize = 0.0f; FallbackAdvanceX = 0.0f; Glyphs.clear(); IndexAdvanceX.clear(); IndexLookup.clear(); FallbackGlyph = NULL; ContainerAtlas = NULL; DirtyLookupTables = true; Ascent = Descent = 0.0f; MetricsTotalSurface = 0; } void ImFont::BuildLookupTable() { int max_codepoint = 0; for (int i = 0; i != Glyphs.Size; i++) max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint); IM_ASSERT(Glyphs.Size < 0xFFFF); // -1 is reserved IndexAdvanceX.clear(); IndexLookup.clear(); DirtyLookupTables = false; GrowIndex(max_codepoint + 1); for (int i = 0; i < Glyphs.Size; i++) { int codepoint = (int)Glyphs[i].Codepoint; IndexAdvanceX[codepoint] = Glyphs[i].AdvanceX; IndexLookup[codepoint] = (ImWchar)i; } // Create a glyph to handle TAB // FIXME: Needs proper TAB handling but it needs to be contextualized (or we could arbitrary say that each string starts at "column 0" ?) if (FindGlyph((ImWchar)' ')) { if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times Glyphs.resize(Glyphs.Size + 1); ImFontGlyph& tab_glyph = Glyphs.back(); tab_glyph = *FindGlyph((ImWchar)' '); tab_glyph.Codepoint = '\t'; tab_glyph.AdvanceX *= IM_TABSIZE; IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX; IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size-1); } FallbackGlyph = FindGlyphNoFallback(FallbackChar); FallbackAdvanceX = FallbackGlyph ? FallbackGlyph->AdvanceX : 0.0f; for (int i = 0; i < max_codepoint + 1; i++) if (IndexAdvanceX[i] < 0.0f) IndexAdvanceX[i] = FallbackAdvanceX; } void ImFont::SetFallbackChar(ImWchar c) { FallbackChar = c; BuildLookupTable(); } void ImFont::GrowIndex(int new_size) { IM_ASSERT(IndexAdvanceX.Size == IndexLookup.Size); if (new_size <= IndexLookup.Size) return; IndexAdvanceX.resize(new_size, -1.0f); IndexLookup.resize(new_size, (ImWchar)-1); } // x0/y0/x1/y1 are offset from the character upper-left layout position, in pixels. Therefore x0/y0 are often fairly close to zero. // Not to be mistaken with texture coordinates, which are held by u0/v0/u1/v1 in normalized format (0.0..1.0 on each texture axis). void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x) { Glyphs.resize(Glyphs.Size + 1); ImFontGlyph& glyph = Glyphs.back(); glyph.Codepoint = (ImWchar)codepoint; glyph.X0 = x0; glyph.Y0 = y0; glyph.X1 = x1; glyph.Y1 = y1; glyph.U0 = u0; glyph.V0 = v0; glyph.U1 = u1; glyph.V1 = v1; glyph.AdvanceX = advance_x + ConfigData->GlyphExtraSpacing.x; // Bake spacing into AdvanceX if (ConfigData->PixelSnapH) glyph.AdvanceX = IM_ROUND(glyph.AdvanceX); // Compute rough surface usage metrics (+1 to account for average padding, +0.99 to round) DirtyLookupTables = true; MetricsTotalSurface += (int)((glyph.U1 - glyph.U0) * ContainerAtlas->TexWidth + 1.99f) * (int)((glyph.V1 - glyph.V0) * ContainerAtlas->TexHeight + 1.99f); } void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst) { IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function. unsigned int index_size = (unsigned int)IndexLookup.Size; if (dst < index_size && IndexLookup.Data[dst] == (ImWchar)-1 && !overwrite_dst) // 'dst' already exists return; if (src >= index_size && dst >= index_size) // both 'dst' and 'src' don't exist -> no-op return; GrowIndex(dst + 1); IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (ImWchar)-1; IndexAdvanceX[dst] = (src < index_size) ? IndexAdvanceX.Data[src] : 1.0f; } const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const { if (c >= IndexLookup.Size) return FallbackGlyph; const ImWchar i = IndexLookup.Data[c]; if (i == (ImWchar)-1) return FallbackGlyph; return &Glyphs.Data[i]; } const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const { if (c >= IndexLookup.Size) return NULL; const ImWchar i = IndexLookup.Data[c]; if (i == (ImWchar)-1) return NULL; return &Glyphs.Data[i]; } const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const { // Simple word-wrapping for English, not full-featured. Please submit failing cases! // FIXME: Much possible improvements (don't cut things like "word !", "word!!!" but cut within "word,,,,", more sensible support for punctuations, support for Unicode punctuations, etc.) // For references, possible wrap point marked with ^ // "aaa bbb, ccc,ddd. eee fff. ggg!" // ^ ^ ^ ^ ^__ ^ ^ // List of hardcoded separators: .,;!?'" // Skip extra blanks after a line returns (that includes not counting them in width computation) // e.g. "Hello world" --> "Hello" "World" // Cut words that cannot possibly fit within one line. // e.g.: "The tropical fish" with ~5 characters worth of width --> "The tr" "opical" "fish" float line_width = 0.0f; float word_width = 0.0f; float blank_width = 0.0f; wrap_width /= scale; // We work with unscaled widths to avoid scaling every characters const char* word_end = text; const char* prev_word_end = NULL; bool inside_word = true; const char* s = text; while (s < text_end) { unsigned int c = (unsigned int)*s; const char* next_s; if (c < 0x80) next_s = s + 1; else next_s = s + ImTextCharFromUtf8(&c, s, text_end); if (c == 0) break; if (c < 32) { if (c == '\n') { line_width = word_width = blank_width = 0.0f; inside_word = true; s = next_s; continue; } if (c == '\r') { s = next_s; continue; } } const float char_width = ((int)c < IndexAdvanceX.Size ? IndexAdvanceX.Data[c] : FallbackAdvanceX); if (ImCharIsBlankW(c)) { if (inside_word) { line_width += blank_width; blank_width = 0.0f; word_end = s; } blank_width += char_width; inside_word = false; } else { word_width += char_width; if (inside_word) { word_end = next_s; } else { prev_word_end = word_end; line_width += word_width + blank_width; word_width = blank_width = 0.0f; } // Allow wrapping after punctuation. inside_word = !(c == '.' || c == ',' || c == ';' || c == '!' || c == '?' || c == '\"'); } // We ignore blank width at the end of the line (they can be skipped) if (line_width + word_width > wrap_width) { // Words that cannot possibly fit within an entire line will be cut anywhere. if (word_width < wrap_width) s = prev_word_end ? prev_word_end : word_end; break; } s = next_s; } return s; } ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end, const char** remaining) const { if (!text_end) text_end = text_begin + strlen(text_begin); // FIXME-OPT: Need to avoid this. const float line_height = size; const float scale = size / FontSize; ImVec2 text_size = ImVec2(0,0); float line_width = 0.0f; const bool word_wrap_enabled = (wrap_width > 0.0f); const char* word_wrap_eol = NULL; const char* s = text_begin; while (s < text_end) { if (word_wrap_enabled) { // Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature. if (!word_wrap_eol) { word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - line_width); if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity. word_wrap_eol++; // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below } if (s >= word_wrap_eol) { if (text_size.x < line_width) text_size.x = line_width; text_size.y += line_height; line_width = 0.0f; word_wrap_eol = NULL; // Wrapping skips upcoming blanks while (s < text_end) { const char c = *s; if (ImCharIsBlankA(c)) { s++; } else if (c == '\n') { s++; break; } else { break; } } continue; } } // Decode and advance source const char* prev_s = s; unsigned int c = (unsigned int)*s; if (c < 0x80) { s += 1; } else { s += ImTextCharFromUtf8(&c, s, text_end); if (c == 0) // Malformed UTF-8? break; } if (c < 32) { if (c == '\n') { text_size.x = ImMax(text_size.x, line_width); text_size.y += line_height; line_width = 0.0f; continue; } if (c == '\r') continue; } const float char_width = ((int)c < IndexAdvanceX.Size ? IndexAdvanceX.Data[c] : FallbackAdvanceX) * scale; if (line_width + char_width >= max_width) { s = prev_s; break; } line_width += char_width; } if (text_size.x < line_width) text_size.x = line_width; if (line_width > 0 || text_size.y == 0.0f) text_size.y += line_height; if (remaining) *remaining = s; return text_size; } void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const { if (c == ' ' || c == '\t' || c == '\n' || c == '\r') // Match behavior of RenderText(), those 4 codepoints are hard-coded. return; if (const ImFontGlyph* glyph = FindGlyph(c)) { float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f; pos.x = IM_FLOOR(pos.x + DisplayOffset.x); pos.y = IM_FLOOR(pos.y + DisplayOffset.y); draw_list->PrimReserve(6, 4); draw_list->PrimRectUV(ImVec2(pos.x + glyph->X0 * scale, pos.y + glyph->Y0 * scale), ImVec2(pos.x + glyph->X1 * scale, pos.y + glyph->Y1 * scale), ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V1), col); } } void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip) const { if (!text_end) text_end = text_begin + strlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls. // Align to be pixel perfect pos.x = IM_FLOOR(pos.x + DisplayOffset.x); pos.y = IM_FLOOR(pos.y + DisplayOffset.y); float x = pos.x; float y = pos.y; if (y > clip_rect.w) return; const float scale = size / FontSize; const float line_height = FontSize * scale; const bool word_wrap_enabled = (wrap_width > 0.0f); const char* word_wrap_eol = NULL; // Fast-forward to first visible line const char* s = text_begin; if (y + line_height < clip_rect.y && !word_wrap_enabled) while (y + line_height < clip_rect.y && s < text_end) { s = (const char*)memchr(s, '\n', text_end - s); s = s ? s + 1 : text_end; y += line_height; } // For large text, scan for the last visible line in order to avoid over-reserving in the call to PrimReserve() // Note that very large horizontal line will still be affected by the issue (e.g. a one megabyte string buffer without a newline will likely crash atm) if (text_end - s > 10000 && !word_wrap_enabled) { const char* s_end = s; float y_end = y; while (y_end < clip_rect.w && s_end < text_end) { s_end = (const char*)memchr(s_end, '\n', text_end - s_end); s_end = s_end ? s_end + 1 : text_end; y_end += line_height; } text_end = s_end; } if (s == text_end) return; // Reserve vertices for remaining worse case (over-reserving is useful and easily amortized) const int vtx_count_max = (int)(text_end - s) * 4; const int idx_count_max = (int)(text_end - s) * 6; const int idx_expected_size = draw_list->IdxBuffer.Size + idx_count_max; draw_list->PrimReserve(idx_count_max, vtx_count_max); ImDrawVert* vtx_write = draw_list->_VtxWritePtr; ImDrawIdx* idx_write = draw_list->_IdxWritePtr; unsigned int vtx_current_idx = draw_list->_VtxCurrentIdx; while (s < text_end) { if (word_wrap_enabled) { // Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature. if (!word_wrap_eol) { word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - (x - pos.x)); if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity. word_wrap_eol++; // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below } if (s >= word_wrap_eol) { x = pos.x; y += line_height; word_wrap_eol = NULL; // Wrapping skips upcoming blanks while (s < text_end) { const char c = *s; if (ImCharIsBlankA(c)) { s++; } else if (c == '\n') { s++; break; } else { break; } } continue; } } // Decode and advance source unsigned int c = (unsigned int)*s; if (c < 0x80) { s += 1; } else { s += ImTextCharFromUtf8(&c, s, text_end); if (c == 0) // Malformed UTF-8? break; } if (c < 32) { if (c == '\n') { x = pos.x; y += line_height; if (y > clip_rect.w) break; // break out of main loop continue; } if (c == '\r') continue; } float char_width = 0.0f; if (const ImFontGlyph* glyph = FindGlyph((ImWchar)c)) { char_width = glyph->AdvanceX * scale; // Arbitrarily assume that both space and tabs are empty glyphs as an optimization if (c != ' ' && c != '\t') { // We don't do a second finer clipping test on the Y axis as we've already skipped anything before clip_rect.y and exit once we pass clip_rect.w float x1 = x + glyph->X0 * scale; float x2 = x + glyph->X1 * scale; float y1 = y + glyph->Y0 * scale; float y2 = y + glyph->Y1 * scale; if (x1 <= clip_rect.z && x2 >= clip_rect.x) { // Render a character float u1 = glyph->U0; float v1 = glyph->V0; float u2 = glyph->U1; float v2 = glyph->V1; // CPU side clipping used to fit text in their frame when the frame is too small. Only does clipping for axis aligned quads. if (cpu_fine_clip) { if (x1 < clip_rect.x) { u1 = u1 + (1.0f - (x2 - clip_rect.x) / (x2 - x1)) * (u2 - u1); x1 = clip_rect.x; } if (y1 < clip_rect.y) { v1 = v1 + (1.0f - (y2 - clip_rect.y) / (y2 - y1)) * (v2 - v1); y1 = clip_rect.y; } if (x2 > clip_rect.z) { u2 = u1 + ((clip_rect.z - x1) / (x2 - x1)) * (u2 - u1); x2 = clip_rect.z; } if (y2 > clip_rect.w) { v2 = v1 + ((clip_rect.w - y1) / (y2 - y1)) * (v2 - v1); y2 = clip_rect.w; } if (y1 >= y2) { x += char_width; continue; } } // We are NOT calling PrimRectUV() here because non-inlined causes too much overhead in a debug builds. Inlined here: { idx_write[0] = (ImDrawIdx)(vtx_current_idx); idx_write[1] = (ImDrawIdx)(vtx_current_idx+1); idx_write[2] = (ImDrawIdx)(vtx_current_idx+2); idx_write[3] = (ImDrawIdx)(vtx_current_idx); idx_write[4] = (ImDrawIdx)(vtx_current_idx+2); idx_write[5] = (ImDrawIdx)(vtx_current_idx+3); vtx_write[0].pos.x = x1; vtx_write[0].pos.y = y1; vtx_write[0].col = col; vtx_write[0].uv.x = u1; vtx_write[0].uv.y = v1; vtx_write[1].pos.x = x2; vtx_write[1].pos.y = y1; vtx_write[1].col = col; vtx_write[1].uv.x = u2; vtx_write[1].uv.y = v1; vtx_write[2].pos.x = x2; vtx_write[2].pos.y = y2; vtx_write[2].col = col; vtx_write[2].uv.x = u2; vtx_write[2].uv.y = v2; vtx_write[3].pos.x = x1; vtx_write[3].pos.y = y2; vtx_write[3].col = col; vtx_write[3].uv.x = u1; vtx_write[3].uv.y = v2; vtx_write += 4; vtx_current_idx += 4; idx_write += 6; } } } } x += char_width; } // Give back unused vertices (clipped ones, blanks) ~ this is essentially a PrimUnreserve() action. draw_list->VtxBuffer.Size = (int)(vtx_write - draw_list->VtxBuffer.Data); // Same as calling shrink() draw_list->IdxBuffer.Size = (int)(idx_write - draw_list->IdxBuffer.Data); draw_list->CmdBuffer[draw_list->CmdBuffer.Size-1].ElemCount -= (idx_expected_size - draw_list->IdxBuffer.Size); draw_list->_VtxWritePtr = vtx_write; draw_list->_IdxWritePtr = idx_write; draw_list->_VtxCurrentIdx = vtx_current_idx; } //----------------------------------------------------------------------------- // [SECTION] Internal Render Helpers // (progressively moved from imgui.cpp to here when they are redesigned to stop accessing ImGui global state) //----------------------------------------------------------------------------- // - RenderMouseCursor() // - RenderArrowPointingAt() // - RenderRectFilledRangeH() //----------------------------------------------------------------------------- void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow) { if (mouse_cursor == ImGuiMouseCursor_None) return; IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT); ImFontAtlas* font_atlas = draw_list->_Data->Font->ContainerAtlas; ImVec2 offset, size, uv[4]; if (font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2])) { pos -= offset; const ImTextureID tex_id = font_atlas->TexID; draw_list->PushTextureID(tex_id); draw_list->AddImage(tex_id, pos + ImVec2(1,0)*scale, pos + ImVec2(1,0)*scale + size*scale, uv[2], uv[3], col_shadow); draw_list->AddImage(tex_id, pos + ImVec2(2,0)*scale, pos + ImVec2(2,0)*scale + size*scale, uv[2], uv[3], col_shadow); draw_list->AddImage(tex_id, pos, pos + size*scale, uv[2], uv[3], col_border); draw_list->AddImage(tex_id, pos, pos + size*scale, uv[0], uv[1], col_fill); draw_list->PopTextureID(); } } // Render an arrow. 'pos' is position of the arrow tip. half_sz.x is length from base to tip. half_sz.y is length on each side. void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col) { switch (direction) { case ImGuiDir_Left: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), pos, col); return; case ImGuiDir_Right: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), pos, col); return; case ImGuiDir_Up: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), pos, col); return; case ImGuiDir_Down: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), pos, col); return; case ImGuiDir_None: case ImGuiDir_COUNT: break; // Fix warnings } } static inline float ImAcos01(float x) { if (x <= 0.0f) return IM_PI * 0.5f; if (x >= 1.0f) return 0.0f; return ImAcos(x); //return (-0.69813170079773212f * x * x - 0.87266462599716477f) * x + 1.5707963267948966f; // Cheap approximation, may be enough for what we do. } // FIXME: Cleanup and move code to ImDrawList. void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding) { if (x_end_norm == x_start_norm) return; if (x_start_norm > x_end_norm) ImSwap(x_start_norm, x_end_norm); ImVec2 p0 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_start_norm), rect.Min.y); ImVec2 p1 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_end_norm), rect.Max.y); if (rounding == 0.0f) { draw_list->AddRectFilled(p0, p1, col, 0.0f); return; } rounding = ImClamp(ImMin((rect.Max.x - rect.Min.x) * 0.5f, (rect.Max.y - rect.Min.y) * 0.5f) - 1.0f, 0.0f, rounding); const float inv_rounding = 1.0f / rounding; const float arc0_b = ImAcos01(1.0f - (p0.x - rect.Min.x) * inv_rounding); const float arc0_e = ImAcos01(1.0f - (p1.x - rect.Min.x) * inv_rounding); const float half_pi = IM_PI * 0.5f; // We will == compare to this because we know this is the exact value ImAcos01 can return. const float x0 = ImMax(p0.x, rect.Min.x + rounding); if (arc0_b == arc0_e) { draw_list->PathLineTo(ImVec2(x0, p1.y)); draw_list->PathLineTo(ImVec2(x0, p0.y)); } else if (arc0_b == 0.0f && arc0_e == half_pi) { draw_list->PathArcToFast(ImVec2(x0, p1.y - rounding), rounding, 3, 6); // BL draw_list->PathArcToFast(ImVec2(x0, p0.y + rounding), rounding, 6, 9); // TR } else { draw_list->PathArcTo(ImVec2(x0, p1.y - rounding), rounding, IM_PI - arc0_e, IM_PI - arc0_b, 3); // BL draw_list->PathArcTo(ImVec2(x0, p0.y + rounding), rounding, IM_PI + arc0_b, IM_PI + arc0_e, 3); // TR } if (p1.x > rect.Min.x + rounding) { const float arc1_b = ImAcos01(1.0f - (rect.Max.x - p1.x) * inv_rounding); const float arc1_e = ImAcos01(1.0f - (rect.Max.x - p0.x) * inv_rounding); const float x1 = ImMin(p1.x, rect.Max.x - rounding); if (arc1_b == arc1_e) { draw_list->PathLineTo(ImVec2(x1, p0.y)); draw_list->PathLineTo(ImVec2(x1, p1.y)); } else if (arc1_b == 0.0f && arc1_e == half_pi) { draw_list->PathArcToFast(ImVec2(x1, p0.y + rounding), rounding, 9, 12); // TR draw_list->PathArcToFast(ImVec2(x1, p1.y - rounding), rounding, 0, 3); // BR } else { draw_list->PathArcTo(ImVec2(x1, p0.y + rounding), rounding, -arc1_e, -arc1_b, 3); // TR draw_list->PathArcTo(ImVec2(x1, p1.y - rounding), rounding, +arc1_b, +arc1_e, 3); // BR } } draw_list->PathFillConvex(col); } //----------------------------------------------------------------------------- // [SECTION] Decompression code //----------------------------------------------------------------------------- // Compressed with stb_compress() then converted to a C array and encoded as base85. // Use the program in misc/fonts/binary_to_compressed_c.cpp to create the array from a TTF file. // The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size. // Decompression from stb.h (public domain) by Sean Barrett https://github.com/nothings/stb/blob/master/stb.h //----------------------------------------------------------------------------- static unsigned int stb_decompress_length(const unsigned char *input) { return (input[8] << 24) + (input[9] << 16) + (input[10] << 8) + input[11]; } static unsigned char *stb__barrier_out_e, *stb__barrier_out_b; static const unsigned char *stb__barrier_in_b; static unsigned char *stb__dout; static void stb__match(const unsigned char *data, unsigned int length) { // INVERSE of memmove... write each byte before copying the next... IM_ASSERT(stb__dout + length <= stb__barrier_out_e); if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; } if (data < stb__barrier_out_b) { stb__dout = stb__barrier_out_e+1; return; } while (length--) *stb__dout++ = *data++; } static void stb__lit(const unsigned char *data, unsigned int length) { IM_ASSERT(stb__dout + length <= stb__barrier_out_e); if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; } if (data < stb__barrier_in_b) { stb__dout = stb__barrier_out_e+1; return; } memcpy(stb__dout, data, length); stb__dout += length; } #define stb__in2(x) ((i[x] << 8) + i[(x)+1]) #define stb__in3(x) ((i[x] << 16) + stb__in2((x)+1)) #define stb__in4(x) ((i[x] << 24) + stb__in3((x)+1)) static const unsigned char *stb_decompress_token(const unsigned char *i) { if (*i >= 0x20) { // use fewer if's for cases that expand small if (*i >= 0x80) stb__match(stb__dout-i[1]-1, i[0] - 0x80 + 1), i += 2; else if (*i >= 0x40) stb__match(stb__dout-(stb__in2(0) - 0x4000 + 1), i[2]+1), i += 3; else /* *i >= 0x20 */ stb__lit(i+1, i[0] - 0x20 + 1), i += 1 + (i[0] - 0x20 + 1); } else { // more ifs for cases that expand large, since overhead is amortized if (*i >= 0x18) stb__match(stb__dout-(stb__in3(0) - 0x180000 + 1), i[3]+1), i += 4; else if (*i >= 0x10) stb__match(stb__dout-(stb__in3(0) - 0x100000 + 1), stb__in2(3)+1), i += 5; else if (*i >= 0x08) stb__lit(i+2, stb__in2(0) - 0x0800 + 1), i += 2 + (stb__in2(0) - 0x0800 + 1); else if (*i == 0x07) stb__lit(i+3, stb__in2(1) + 1), i += 3 + (stb__in2(1) + 1); else if (*i == 0x06) stb__match(stb__dout-(stb__in3(1)+1), i[4]+1), i += 5; else if (*i == 0x04) stb__match(stb__dout-(stb__in3(1)+1), stb__in2(4)+1), i += 6; } return i; } static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, unsigned int buflen) { const unsigned long ADLER_MOD = 65521; unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16; unsigned long blocklen = buflen % 5552; unsigned long i; while (buflen) { for (i=0; i + 7 < blocklen; i += 8) { s1 += buffer[0], s2 += s1; s1 += buffer[1], s2 += s1; s1 += buffer[2], s2 += s1; s1 += buffer[3], s2 += s1; s1 += buffer[4], s2 += s1; s1 += buffer[5], s2 += s1; s1 += buffer[6], s2 += s1; s1 += buffer[7], s2 += s1; buffer += 8; } for (; i < blocklen; ++i) s1 += *buffer++, s2 += s1; s1 %= ADLER_MOD, s2 %= ADLER_MOD; buflen -= blocklen; blocklen = 5552; } return (unsigned int)(s2 << 16) + (unsigned int)s1; } static unsigned int stb_decompress(unsigned char *output, const unsigned char *i, unsigned int /*length*/) { if (stb__in4(0) != 0x57bC0000) return 0; if (stb__in4(4) != 0) return 0; // error! stream is > 4GB const unsigned int olen = stb_decompress_length(i); stb__barrier_in_b = i; stb__barrier_out_e = output + olen; stb__barrier_out_b = output; i += 16; stb__dout = output; for (;;) { const unsigned char *old_i = i; i = stb_decompress_token(i); if (i == old_i) { if (*i == 0x05 && i[1] == 0xfa) { IM_ASSERT(stb__dout == output + olen); if (stb__dout != output + olen) return 0; if (stb_adler32(1, output, olen) != (unsigned int) stb__in4(2)) return 0; return olen; } else { IM_ASSERT(0); /* NOTREACHED */ return 0; } } IM_ASSERT(stb__dout <= output + olen); if (stb__dout > output + olen) return 0; } } //----------------------------------------------------------------------------- // [SECTION] Default font data (ProggyClean.ttf) //----------------------------------------------------------------------------- // ProggyClean.ttf // Copyright (c) 2004, 2005 Tristan Grimmer // MIT license (see License.txt in http://www.upperbounds.net/download/ProggyClean.ttf.zip) // Download and more information at http://upperbounds.net //----------------------------------------------------------------------------- // File: 'ProggyClean.ttf' (41208 bytes) // Exported using misc/fonts/binary_to_compressed_c.cpp (with compression + base85 string encoding). // The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size. //----------------------------------------------------------------------------- static const char proggy_clean_ttf_compressed_data_base85[11980+1] = "7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/" "2*>]b(MC;$jPfY.;h^`IWM9Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1=Ke$$'5F%)]0^#0X@U.a$FBjVQTSDgEKnIS7EM9>ZY9w0#L;>>#Mx&4Mvt//L[MkA#W@lK.N'[0#7RL_&#w+F%HtG9M#XL`N&.,GM4Pg;--VsM.M0rJfLH2eTM`*oJMHRC`N" "kfimM2J,W-jXS:)r0wK#@Fge$U>`w'N7G#$#fB#$E^$#:9:hk+eOe--6x)F7*E%?76%^GMHePW-Z5l'&GiF#$956:rS?dA#fiK:)Yr+`�j@'DbG&#^$PG.Ll+DNa&VZ>1i%h1S9u5o@YaaW$e+bROPOpxTO7Stwi1::iB1q)C_=dV26J;2,]7op$]uQr@_V7$q^%lQwtuHY]=DX,n3L#0PHDO4f9>dC@O>HBuKPpP*E,N+b3L#lpR/MrTEH.IAQk.a>D[.e;mc." "x]Ip.PH^'/aqUO/$1WxLoW0[iLAw=4h(9.`G" "CRUxHPeR`5Mjol(dUWxZa(>STrPkrJiWx`5U7F#.g*jrohGg`cg:lSTvEY/EV_7H4Q9[Z%cnv;JQYZ5q.l7Zeas:HOIZOB?Ggv:[7MI2k).'2($5FNP&EQ(,)" "U]W]+fh18.vsai00);D3@4ku5P?DP8aJt+;qUM]=+b'8@;mViBKx0DE[-auGl8:PJ&Dj+M6OC]O^((##]`0i)drT;-7X`=-H3[igUnPG-NZlo.#k@h#=Ork$m>a>$-?Tm$UV(?#P6YY#" "'/###xe7q.73rI3*pP/$1>s9)W,JrM7SN]'/4C#v$U`0#V.[0>xQsH$fEmPMgY2u7Kh(G%siIfLSoS+MK2eTM$=5,M8p`A.;_R%#u[K#$x4AG8.kK/HSB==-'Ie/QTtG?-.*^N-4B/ZM" "_3YlQC7(p7q)&](`6_c)$/*JL(L-^(]$wIM`dPtOdGA,U3:w2M-0+WomX2u7lqM2iEumMTcsF?-aT=Z-97UEnXglEn1K-bnEO`gu" "Ft(c%=;Am_Qs@jLooI&NX;]0#j4#F14;gl8-GQpgwhrq8'=l_f-b49'UOqkLu7-##oDY2L(te+Mch&gLYtJ,MEtJfLh'x'M=$CS-ZZ%P]8bZ>#S?YY#%Q&q'3^Fw&?D)UDNrocM3A76/" "/oL?#h7gl85[qW/NDOk%16ij;+:1a'iNIdb-ou8.P*w,v5#EI$TWS>Pot-R*H'-SEpA:g)f+O$%%`kA#G=8RMmG1&O`>to8bC]T&$,n.LoO>29sp3dt-52U%VM#q7'DHpg+#Z9%H[Ket`e;)f#Km8&+DC$I46>#Kr]]u-[=99tts1.qb#q72g1WJO81q+eN'03'eM>&1XxY-caEnO" "j%2n8)),?ILR5^.Ibn<-X-Mq7[a82Lq:F&#ce+S9wsCK*x`569E8ew'He]h:sI[2LM$[guka3ZRd6:t%IG:;$%YiJ:Nq=?eAw;/:nnDq0(CYcMpG)qLN4$##&J-XTt,%OVU4)S1+R-#dg0/Nn?Ku1^0f$B*P:Rowwm-`0PKjYDDM'3]d39VZHEl4,.j']Pk-M.h^&:0FACm$maq-&sgw0t7/6(^xtk%" "LuH88Fj-ekm>GA#_>568x6(OFRl-IZp`&b,_P'$MhLbxfc$mj`,O;&%W2m`Zh:/)Uetw:aJ%]K9h:TcF]u_-Sj9,VK3M.*'&0D[Ca]J9gp8,kAW]" "%(?A%R$f<->Zts'^kn=-^@c4%-pY6qI%J%1IGxfLU9CP8cbPlXv);C=b),<2mOvP8up,UVf3839acAWAW-W?#ao/^#%KYo8fRULNd2.>%m]UK:n%r$'sw]J;5pAoO_#2mO3n,'=H5(et" "Hg*`+RLgv>=4U8guD$I%D:W>-r5V*%j*W:Kvej.Lp$'?;++O'>()jLR-^u68PHm8ZFWe+ej8h:9r6L*0//c&iH&R8pRbA#Kjm%upV1g:" "a_#Ur7FuA#(tRh#.Y5K+@?3<-8m0$PEn;J:rh6?I6uG<-`wMU'ircp0LaE_OtlMb&1#6T.#FDKu#1Lw%u%+GM+X'e?YLfjM[VO0MbuFp7;>Q&#WIo)0@F%q7c#4XAXN-U&VBpqB>0ie&jhZ[?iLR@@_AvA-iQC(=ksRZRVp7`.=+NpBC%rh&3]R:8XDmE5^V8O(x<-+k?'(^](H.aREZSi,#1:[IXaZFOm<-ui#qUq2$##Ri;u75OK#(RtaW-K-F`S+cF]uN`-KMQ%rP/Xri.LRcB##=YL3BgM/3M" "D?@f&1'BW-)Ju#bmmWCMkk&#TR`C,5d>g)F;t,4:@_l8G/5h4vUd%&%950:VXD'QdWoY-F$BtUwmfe$YqL'8(PWX(" "P?^@Po3$##`MSs?DWBZ/S>+4%>fX,VWv/w'KD`LP5IbH;rTV>n3cEK8U#bX]l-/V+^lj3;vlMb&[5YQ8#pekX9JP3XUC72L,,?+Ni&co7ApnO*5NK,((W-i:$,kp'UDAO(G0Sq7MVjJs" "bIu)'Z,*[>br5fX^:FPAWr-m2KgLQ_nN6'8uTGT5g)uLv:873UpTLgH+#FgpH'_o1780Ph8KmxQJ8#H72L4@768@Tm&Q" "h4CB/5OvmA&,Q&QbUoi$a_%3M01H)4x7I^&KQVgtFnV+;[Pc>[m4k//,]1?#`VY[Jr*3&&slRfLiVZJ:]?=K3Sw=[$=uRB?3xk48@aege0jT6'N#(q%.O=?2S]u*(m<-" "V8J'(1)G][68hW$5'q[GC&5j`TE?m'esFGNRM)j,ffZ?-qx8;->g4t*:CIP/[Qap7/9'#(1sao7w-.qNUdkJ)tCF&#B^;xGvn2r9FEPFFFcL@.iFNkTve$m%#QvQS8U@)2Z+3K:AKM5i" "sZ88+dKQ)W6>J%CL`.d*(B`-n8D9oK-XV1q['-5k'cAZ69e;D_?$ZPP&s^+7])$*$#@QYi9,5P r+$%CE=68>K8r0=dSC%%(@p7" ".m7jilQ02'0-VWAgTlGW'b)Tq7VT9q^*^$$.:&N@@" "$&)WHtPm*5_rO0&e%K&#-30j(E4#'Zb.o/(Tpm$>K'f@[PvFl,hfINTNU6u'0pao7%XUp9]5.>%h`8_=VYbxuel.NTSsJfLacFu3B'lQSu/m6-Oqem8T+oE--$0a/k]uj9EwsG>%veR*" "hv^BFpQj:K'#SJ,sB-'#](j.Lg92rTw-*n%@/;39rrJF,l#qV%OrtBeC6/,;qB3ebNW[?,Hqj2L.1NP&GjUR=1D8QaS3Up&@*9wP?+lo7b?@%'k4`p0Z$22%K3+iCZj?XJN4Nm&+YF]u" "@-W$U%VEQ/,,>>#)D#%8cY#YZ?=,`Wdxu/ae&#" "w6)R89tI#6@s'(6Bf7a&?S=^ZI_kS&ai`&=tE72L_D,;^R)7[$so8lKN%5/$(vdfq7+ebA#" "u1p]ovUKW&Y%q]'>$1@-[xfn$7ZTp7mM,G,Ko7a&Gu%G[RMxJs[0MM%wci.LFDK)(%:_i2B5CsR8&9Z&#=mPEnm0f`<&c)QL5uJ#%u%lJj+D-r;BoFDoS97h5g)E#o:&S4weDF,9^Hoe`h*L+_a*NrLW-1pG_&2UdB8" "6e%B/:=>)N4xeW.*wft-;$'58-ESqr#U`'6AQ]m&6/`Z>#S?YY#Vc;r7U2&326d=w&H####?TZ`*4?&.MK?LP8Vxg>$[QXc%QJv92.(Db*B)gb*BM9dM*hJMAo*c&#" "b0v=Pjer]$gG&JXDf->'StvU7505l9$AFvgYRI^&<^b68?j#q9QX4SM'RO#&sL1IM.rJfLUAj221]d##DW=m83u5;'bYx,*Sl0hL(W;;$doB&O/TQ:(Z^xBdLjLV#*8U_72Lh+2Q8Cj0i:6hp&$C/:p(HK>T8Y[gHQ4`4)'$Ab(Nof%V'8hL&#SfD07&6D@M.*J:;$-rv29'M]8qMv-tLp,'886iaC=Hb*YJoKJ,(j%K=H`K.v9HggqBIiZu'QvBT.#=)0ukruV&.)3=(^1`o*Pj4<-#MJ+gLq9-##@HuZPN0]u:h7.T..G:;$/Usj(T7`Q8tT72LnYl<-qx8;-HV7Q-&Xdx%1a,hC=0u+HlsV>nuIQL-5" "_>@kXQtMacfD.m-VAb8;IReM3$wf0''hra*so568'Ip&vRs849'MRYSp%:t:h5qSgwpEr$B>Q,;s(C#$)`svQuF$##-D,##,g68@2[T;.XSdN9Qe)rpt._K-#5wF)sP'##p#C0c%-Gb%" "hd+<-j'Ai*x&&HMkT]C'OSl##5RG[JXaHN;d'uA#x._U;.`PU@(Z3dt4r152@:v,'R.Sj'w#0<-;kPI)FfJ&#AYJ&#//)>-k=m=*XnK$>=)72L]0I%>.G690a:$##<,);?;72#?x9+d;" "^V'9;jY@;)br#q^YQpx:X#Te$Z^'=-=bGhLf:D6&bNwZ9-ZD#n^9HhLMr5G;']d&6'wYmTFmLq9wI>P(9mI[>kC-ekLC/R&CH+s'B;K-M6$EB%is00:" "+A4[7xks.LrNk0&E)wILYF@2L'0Nb$+pv<(2.768/FrY&h$^3i&@+G%JT'<-,v`3;_)I9M^AE]CN?Cl2AZg+%4iTpT3$U4O]GKx'm9)b@p7YsvK3w^YR-" "CdQ*:Ir<($u&)#(&?L9Rg3H)4fiEp^iI9O8KnTj,]H?D*r7'M;PwZ9K0E^k&-cpI;.p/6_vwoFMV<->#%Xi.LxVnrU(4&8/P+:hLSKj$#U%]49t'I:rgMi'FL@a:0Y-uA[39',(vbma*" "hU%<-SRF`Tt:542R_VV$p@[p8DV[A,?1839FWdFTi1O*H&#(AL8[_P%.M>v^-))qOT*F5Cq0`Ye%+$B6i:7@0IXSsDiWP,##P`%/L-" "S(qw%sf/@%#B6;/U7K]uZbi^Oc^2n%t<)'mEVE''n`WnJra$^TKvX5B>;_aSEK',(hwa0:i4G?.Bci.(X[?b*($,=-n<.Q%`(X=?+@Am*Js0&=3bh8K]mL69=Lb,OcZV/);TTm8VI;?%OtJ<(b4mq7M6:u?KRdFl*:xP?Yb.5)%w_I?7uk5JC+FS(m#i'k.'a0i)9<7b'fs'59hq$*5Uhv##pi^8+hIEBF`nvo`;'l0.^S1<-wUK2/Coh58KKhLj" "M=SO*rfO`+qC`W-On.=AJ56>>i2@2LH6A:&5q`?9I3@@'04&p2/LVa*T-4<-i3;M9UvZd+N7>b*eIwg:CC)c<>nO&#$(>.Z-I&J(Q0Hd5Q%7Co-b`-cP)hI;*_F]u`Rb[.j8_Q/<&>uu+VsH$sM9TA%?)(vmJ80),P7E>)tjD%2L=-t#fK[%`v=Q8WlA2);Sa" ">gXm8YB`1d@K#n]76-a$U,mF%Ul:#/'xoFM9QX-$.QN'>" "[%$Z$uF6pA6Ki2O5:8w*vP1<-1`[G,)-m#>0`P&#eb#.3i)rtB61(o'$?X3B2Qft^ae_5tKL9MUe9b*sLEQ95C&`=G?@Mj=wh*'3E>=-<)Gt*Iw)'QG:`@I" "wOf7&]1i'S01B+Ev/Nac#9S;=;YQpg_6U`*kVY39xK,[/6Aj7:'1Bm-_1EYfa1+o&o4hp7KN_Q(OlIo@S%;jVdn0'1h19w,WQhLI)3S#f$2(eb,jr*b;3Vw]*7NH%$c4Vs,eD9>XW8?N]o+(*pgC%/72LV-uW%iewS8W6m2rtCpo'RS1R84=@paTKt)>=%&1[)*vp'u+x,VrwN;&]kuO9JDbg=pO$J*.jVe;u'm0dr9l,<*wMK*Oe=g8lV_KEBFkO'oU]^=[-792#ok,)" "i]lR8qQ2oA8wcRCZ^7w/Njh;?.stX?Q1>S1q4Bn$)K1<-rGdO'$Wr.Lc.CG)$/*JL4tNR/,SVO3,aUw'DJN:)Ss;wGn9A32ijw%FL+Z0Fn.U9;reSq)bmI32U==5ALuG&#Vf1398/pVo" "1*c-(aY168o<`JsSbk-,1N;$>0:OUas(3:8Z972LSfF8eb=c-;>SPw7.6hn3m`9^Xkn(r.qS[0;T%&Qc=+STRxX'q1BNk3&*eu2;&8q$&x>Q#Q7^Tf+6<(d%ZVmj2bDi%.3L2n+4W'$P" "iDDG)g,r%+?,$@?uou5tSe2aN_AQU*'IAO" "URQ##V^Fv-XFbGM7Fl(N<3DhLGF%q.1rC$#:T__&Pi68%0xi_&[qFJ(77j_&JWoF.V735&T,[R*:xFR*K5>>#`bW-?4Ne_&6Ne_&6Ne_&n`kr-#GJcM6X;uM6X;uM(.a..^2TkL%oR(#" ";u.T%fAr%4tJ8&><1=GHZ_+m9/#H1F^R#SC#*N=BA9(D?v[UiFY>>^8p,KKF.W]L29uLkLlu/+4T" "w$)F./^n3+rlo+DB;5sIYGNk+i1t-69Jg--0pao7Sm#K)pdHW&;LuDNH@H>#/X-TI(;P>#,Gc>#0Su>#4`1?#8lC?#xL$#B.`$#F:r$#JF.%#NR@%#R_R%#Vke%#Zww%#_-4^Rh%Sflr-k'MS.o?.5/sWel/wpEM0%3'/1)K^f1-d>G21&v(35>V`39V7A4=onx4" "A1OY5EI0;6Ibgr6M$HS7Q<)58C5w,;WoA*#[%T*#`1g*#d=#+#hI5+#lUG+#pbY+#tnl+#x$),#&1;,#*=M,#.I`,#2Ur,#6b.-#;w[H#iQtA#m^0B#qjBB#uvTB##-hB#'9$C#+E6C#" "/QHC#3^ZC#7jmC#;v)D#?,)4kMYD4lVu`4m`:&5niUA5@(A5BA1]PBB:xlBCC=2CDLXMCEUtiCf&0g2'tN?PGT4CPGT4CPGT4CPGT4CPGT4CPGT4CPGT4CP" "GT4CPGT4CPGT4CPGT4CPGT4CPGT4CP-qekC`.9kEg^+F$kwViFJTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5o,^<-28ZI'O?;xp" "O?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xp;7q-#lLYI:xvD=#"; static const char* GetDefaultCompressedFontDataTTFBase85() { return proggy_clean_ttf_compressed_data_base85; } #endif // #ifndef IMGUI_DISABLE goxel-0.11.0/ext_src/imgui/imgui_internal.h000066400000000000000000003774631435762723100207050ustar00rootroot00000000000000// dear imgui, v1.75 // (internal structures/api) // You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility! // Set: // #define IMGUI_DEFINE_MATH_OPERATORS // To implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators) /* Index of this file: // Header mess // Forward declarations // STB libraries includes // Context pointer // Generic helpers // Misc data structures // Main imgui context // Tab bar, tab item // Internal API */ #pragma once #ifndef IMGUI_DISABLE //----------------------------------------------------------------------------- // Header mess //----------------------------------------------------------------------------- #ifndef IMGUI_VERSION #error Must include imgui.h before imgui_internal.h #endif #include // FILE*, sscanf #include // NULL, malloc, free, qsort, atoi, atof #include // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf #include // INT_MIN, INT_MAX // Visual Studio warnings #ifdef _MSC_VER #pragma warning (push) #pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport) #endif // Clang/GCC warnings with -Weverything #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-function" // for stb_textedit.h #pragma clang diagnostic ignored "-Wmissing-prototypes" // for stb_textedit.h #pragma clang diagnostic ignored "-Wold-style-cast" #if __has_warning("-Wzero-as-null-pointer-constant") #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" #endif #if __has_warning("-Wdouble-promotion") #pragma clang diagnostic ignored "-Wdouble-promotion" #endif #elif defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind #pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead #endif // Legacy defines #ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Renamed in 1.74 #error Use IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS #endif #ifdef IMGUI_DISABLE_MATH_FUNCTIONS // Renamed in 1.74 #error Use IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS #endif //----------------------------------------------------------------------------- // Forward declarations //----------------------------------------------------------------------------- struct ImBoolVector; // Store 1-bit per value struct ImRect; // An axis-aligned rectangle (2 points) struct ImDrawDataBuilder; // Helper to build a ImDrawData instance struct ImDrawListSharedData; // Data shared between all ImDrawList instances struct ImGuiColorMod; // Stacked color modifier, backup of modified data so we can restore it struct ImGuiColumnData; // Storage data for a single column struct ImGuiColumns; // Storage data for a columns set struct ImGuiContext; // Main Dear ImGui context struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup() struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box struct ImGuiItemHoveredDataBackup; // Backup and restore IsItemHovered() internal data struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only struct ImGuiNavMoveResult; // Result of a directional navigation move query result struct ImGuiNextWindowData; // Storage for SetNextWindow** functions struct ImGuiNextItemData; // Storage for SetNextItem** functions struct ImGuiPopupData; // Storage for current popup stack struct ImGuiSettingsHandler; // Storage for one type registered in the .ini file struct ImGuiStyleMod; // Stacked style modifier, backup of modified data so we can restore it struct ImGuiTabBar; // Storage for a tab bar struct ImGuiTabItem; // Storage for a tab item (within a tab bar) struct ImGuiWindow; // Storage for one window struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame) struct ImGuiWindowSettings; // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session) // Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists. typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical typedef int ImGuiButtonFlags; // -> enum ImGuiButtonFlags_ // Flags: for ButtonEx(), ButtonBehavior() typedef int ImGuiColumnsFlags; // -> enum ImGuiColumnsFlags_ // Flags: BeginColumns() typedef int ImGuiDragFlags; // -> enum ImGuiDragFlags_ // Flags: for DragBehavior() typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag() typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for DC.LastItemStatusFlags typedef int ImGuiNavHighlightFlags; // -> enum ImGuiNavHighlightFlags_ // Flags: for RenderNavHighlight() typedef int ImGuiNavDirSourceFlags; // -> enum ImGuiNavDirSourceFlags_ // Flags: for GetNavInputAmount2d() typedef int ImGuiNavMoveFlags; // -> enum ImGuiNavMoveFlags_ // Flags: for navigation requests typedef int ImGuiNextItemDataFlags; // -> enum ImGuiNextItemDataFlags_ // Flags: for SetNextItemXXX() functions typedef int ImGuiNextWindowDataFlags; // -> enum ImGuiNextWindowDataFlags_// Flags: for SetNextWindowXXX() functions typedef int ImGuiSeparatorFlags; // -> enum ImGuiSeparatorFlags_ // Flags: for SeparatorEx() typedef int ImGuiSliderFlags; // -> enum ImGuiSliderFlags_ // Flags: for SliderBehavior() typedef int ImGuiTextFlags; // -> enum ImGuiTextFlags_ // Flags: for TextEx() typedef int ImGuiTooltipFlags; // -> enum ImGuiTooltipFlags_ // Flags: for BeginTooltipEx() //------------------------------------------------------------------------- // STB libraries includes //------------------------------------------------------------------------- namespace ImStb { #undef STB_TEXTEDIT_STRING #undef STB_TEXTEDIT_CHARTYPE #define STB_TEXTEDIT_STRING ImGuiInputTextState #define STB_TEXTEDIT_CHARTYPE ImWchar #define STB_TEXTEDIT_GETWIDTH_NEWLINE -1.0f #define STB_TEXTEDIT_UNDOSTATECOUNT 99 #define STB_TEXTEDIT_UNDOCHARCOUNT 999 #include "imstb_textedit.h" } // namespace ImStb //----------------------------------------------------------------------------- // Context pointer //----------------------------------------------------------------------------- #ifndef GImGui extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer #endif //----------------------------------------------------------------------------- // Macros //----------------------------------------------------------------------------- // Debug Logging #ifndef IMGUI_DEBUG_LOG #define IMGUI_DEBUG_LOG(_FMT,...) printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__) #endif // Static Asserts #if (__cplusplus >= 201100) #define IM_STATIC_ASSERT(_COND) static_assert(_COND, "") #else #define IM_STATIC_ASSERT(_COND) typedef char static_assertion_##__line__[(_COND)?1:-1] #endif // "Paranoid" Debug Asserts are meant to only be enabled during specific debugging/work, otherwise would slow down the code too much. // We currently don't have many of those so the effect is currently negligible, but onward intent to add more aggressive ones in the code. //#define IMGUI_DEBUG_PARANOID #ifdef IMGUI_DEBUG_PARANOID #define IM_ASSERT_PARANOID(_EXPR) IM_ASSERT(_EXPR) #else #define IM_ASSERT_PARANOID(_EXPR) #endif // Error handling // Down the line in some frameworks/languages we would like to have a way to redirect those to the programmer and recover from more faults. #ifndef IM_ASSERT_USER_ERROR #define IM_ASSERT_USER_ERROR(_EXP,_MSG) IM_ASSERT((_EXP) && _MSG) // Recoverable User Error #endif // Misc Macros #define IM_PI 3.14159265358979323846f #ifdef _WIN32 #define IM_NEWLINE "\r\n" // Play it nice with Windows users (Update: since 2018-05, Notepad finally appears to support Unix-style carriage returns!) #else #define IM_NEWLINE "\n" #endif #define IM_TABSIZE (4) #define IM_F32_TO_INT8_UNBOUND(_VAL) ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f))) // Unsaturated, for display purpose #define IM_F32_TO_INT8_SAT(_VAL) ((int)(ImSaturate(_VAL) * 255.0f + 0.5f)) // Saturated, always output 0..255 #define IM_FLOOR(_VAL) ((float)(int)(_VAL)) // ImFloor() is not inlined in MSVC debug builds #define IM_ROUND(_VAL) ((float)(int)((_VAL) + 0.5f)) // // Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall #ifdef _MSC_VER #define IMGUI_CDECL __cdecl #else #define IMGUI_CDECL #endif //----------------------------------------------------------------------------- // Generic helpers // Note that the ImXXX helpers functions are lower-level than ImGui functions. // ImGui functions or the ImGui context are never called/used from other ImXXX functions. //----------------------------------------------------------------------------- // - Helpers: Misc // - Helpers: Bit manipulation // - Helpers: String, Formatting // - Helpers: UTF-8 <> wchar conversions // - Helpers: ImVec2/ImVec4 operators // - Helpers: Maths // - Helpers: Geometry // - Helper: ImBoolVector // - Helper: ImPool<> // - Helper: ImChunkStream<> //----------------------------------------------------------------------------- // Helpers: Misc #define ImQsort qsort IMGUI_API ImU32 ImHashData(const void* data, size_t data_size, ImU32 seed = 0); IMGUI_API ImU32 ImHashStr(const char* data, size_t data_size = 0, ImU32 seed = 0); #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS static inline ImU32 ImHash(const void* data, int size, ImU32 seed = 0) { return size ? ImHashData(data, (size_t)size, seed) : ImHashStr((const char*)data, 0, seed); } // [moved to ImHashStr/ImHashData in 1.68] #endif // Helpers: Bit manipulation static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; } static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; } // Helpers: String, Formatting IMGUI_API int ImStricmp(const char* str1, const char* str2); IMGUI_API int ImStrnicmp(const char* str1, const char* str2, size_t count); IMGUI_API void ImStrncpy(char* dst, const char* src, size_t count); IMGUI_API char* ImStrdup(const char* str); IMGUI_API char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* str); IMGUI_API const char* ImStrchrRange(const char* str_begin, const char* str_end, char c); IMGUI_API int ImStrlenW(const ImWchar* str); IMGUI_API const char* ImStreolRange(const char* str, const char* str_end); // End end-of-line IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end); IMGUI_API void ImStrTrimBlanks(char* str); IMGUI_API const char* ImStrSkipBlank(const char* str); IMGUI_API int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3); IMGUI_API int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3); IMGUI_API const char* ImParseFormatFindStart(const char* format); IMGUI_API const char* ImParseFormatFindEnd(const char* format); IMGUI_API const char* ImParseFormatTrimDecorations(const char* format, char* buf, size_t buf_size); IMGUI_API int ImParseFormatPrecision(const char* format, int default_value); static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; } static inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; } // Helpers: UTF-8 <> wchar conversions IMGUI_API int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // read one character. return input UTF-8 bytes count IMGUI_API int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT bytes count) IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end); // return number of bytes to express one char in UTF-8 IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8 // Helpers: ImVec2/ImVec4 operators // We are keeping those disabled by default so they don't leak in user space, to allow user enabling implicit cast operators between ImVec2 and their own types (using IM_VEC2_CLASS_EXTRA etc.) // We unfortunately don't have a unary- operator for ImVec2 because this would needs to be defined inside the class itself. #ifdef IMGUI_DEFINE_MATH_OPERATORS static inline ImVec2 operator*(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x*rhs, lhs.y*rhs); } static inline ImVec2 operator/(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x/rhs, lhs.y/rhs); } static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); } static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); } static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); } static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x/rhs.x, lhs.y/rhs.y); } static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; } static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; } static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; } static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; } static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z, lhs.w+rhs.w); } static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); } static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); } #endif // Helpers: File System #ifdef IMGUI_DISABLE_FILE_FUNCTIONS #define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS typedef void* ImFileHandle; static inline ImFileHandle ImFileOpen(const char*, const char*) { return NULL; } static inline bool ImFileClose(ImFileHandle) { return false; } static inline ImU64 ImFileGetSize(ImFileHandle) { return (ImU64)-1; } static inline ImU64 ImFileRead(void*, ImU64, ImU64, ImFileHandle) { return 0; } static inline ImU64 ImFileWrite(const void*, ImU64, ImU64, ImFileHandle) { return 0; } #endif #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS typedef FILE* ImFileHandle; IMGUI_API ImFileHandle ImFileOpen(const char* filename, const char* mode); IMGUI_API bool ImFileClose(ImFileHandle file); IMGUI_API ImU64 ImFileGetSize(ImFileHandle file); IMGUI_API ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file); IMGUI_API ImU64 ImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file); #else #define IMGUI_DISABLE_TTY_FUNCTIONS // Can't use stdout, fflush if we are not using default file functions #endif IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size = NULL, int padding_bytes = 0); // Helpers: Maths // - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy) #ifndef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS #define ImFabs(X) fabsf(X) #define ImSqrt(X) sqrtf(X) #define ImFmod(X, Y) fmodf((X), (Y)) #define ImCos(X) cosf(X) #define ImSin(X) sinf(X) #define ImAcos(X) acosf(X) #define ImAtan2(Y, X) atan2f((Y), (X)) #define ImAtof(STR) atof(STR) #define ImFloorStd(X) floorf(X) // We already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by e.g. stb_truetype) #define ImCeil(X) ceilf(X) static inline float ImPow(float x, float y) { return powf(x, y); } // DragBehaviorT/SliderBehaviorT uses ImPow with either float/double and need the precision static inline double ImPow(double x, double y) { return pow(x, y); } #endif // - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support variety of types: signed/unsigned int/long long float/double // (Exceptionally using templates here but we could also redefine them for those types) template static inline T ImMin(T lhs, T rhs) { return lhs < rhs ? lhs : rhs; } template static inline T ImMax(T lhs, T rhs) { return lhs >= rhs ? lhs : rhs; } template static inline T ImClamp(T v, T mn, T mx) { return (v < mn) ? mn : (v > mx) ? mx : v; } template static inline T ImLerp(T a, T b, float t) { return (T)(a + (b - a) * t); } template static inline void ImSwap(T& a, T& b) { T tmp = a; a = b; b = tmp; } template static inline T ImAddClampOverflow(T a, T b, T mn, T mx) { if (b < 0 && (a < mn - b)) return mn; if (b > 0 && (a > mx - b)) return mx; return a + b; } template static inline T ImSubClampOverflow(T a, T b, T mn, T mx) { if (b > 0 && (a < mn + b)) return mn; if (b < 0 && (a > mx + b)) return mx; return a - b; } // - Misc maths helpers static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); } static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); } static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2& mn, ImVec2 mx) { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); } static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); } static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); } static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); } static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; } static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; } static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; } static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / ImSqrt(d); return fail_value; } static inline float ImFloor(float f) { return (float)(int)(f); } static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)(v.x), (float)(int)(v.y)); } static inline int ImModPositive(int a, int b) { return (a + b) % b; } static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; } static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); } static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; } static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); } // Helpers: Geometry IMGUI_API ImVec2 ImBezierCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t); // Cubic Bezier IMGUI_API ImVec2 ImBezierClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments); // For curves with explicit number of segments IMGUI_API ImVec2 ImBezierClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float tess_tol);// For auto-tessellated curves you can use tess_tol = style.CurveTessellationTol IMGUI_API ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p); IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p); IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p); IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w); inline float ImTriangleArea(const ImVec2& a, const ImVec2& b, const ImVec2& c) { return ImFabs((a.x * (b.y - c.y)) + (b.x * (c.y - a.y)) + (c.x * (a.y - b.y))) * 0.5f; } IMGUI_API ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy); // Helper: ImBoolVector // Store 1-bit per value. Note that Resize() currently clears the whole vector. struct IMGUI_API ImBoolVector { ImVector Storage; ImBoolVector() { } void Resize(int sz) { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); } void Clear() { Storage.clear(); } bool GetBit(int n) const { int off = (n >> 5); int mask = 1 << (n & 31); return (Storage[off] & mask) != 0; } void SetBit(int n, bool v) { int off = (n >> 5); int mask = 1 << (n & 31); if (v) Storage[off] |= mask; else Storage[off] &= ~mask; } }; // Helper: ImPool<> // Basic keyed storage for contiguous instances, slow/amortized insertion, O(1) indexable, O(Log N) queries by ID over a dense/hot buffer, // Honor constructor/destructor. Add/remove invalidate all pointers. Indexes have the same lifetime as the associated object. typedef int ImPoolIdx; template struct IMGUI_API ImPool { ImVector Buf; // Contiguous data ImGuiStorage Map; // ID->Index ImPoolIdx FreeIdx; // Next free idx to use ImPool() { FreeIdx = 0; } ~ImPool() { Clear(); } T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Buf[idx] : NULL; } T* GetByIndex(ImPoolIdx n) { return &Buf[n]; } ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Buf.Data && p < Buf.Data + Buf.Size); return (ImPoolIdx)(p - Buf.Data); } T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Buf[*p_idx]; *p_idx = FreeIdx; return Add(); } bool Contains(const T* p) const { return (p >= Buf.Data && p < Buf.Data + Buf.Size); } void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Buf[idx].~T(); } Map.Clear(); Buf.clear(); FreeIdx = 0; } T* Add() { int idx = FreeIdx; if (idx == Buf.Size) { Buf.resize(Buf.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Buf[idx]; } IM_PLACEMENT_NEW(&Buf[idx]) T(); return &Buf[idx]; } void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); } void Remove(ImGuiID key, ImPoolIdx idx) { Buf[idx].~T(); *(int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); } void Reserve(int capacity) { Buf.reserve(capacity); Map.Data.reserve(capacity); } int GetSize() const { return Buf.Size; } }; // Helper: ImChunkStream<> // Build and iterate a contiguous stream of variable-sized structures. // This is used by Settings to store persistent data while reducing allocation count. // We store the chunk size first, and align the final size on 4 bytes boundaries (this what the '(X + 3) & ~3' statement is for) // The tedious/zealous amount of casting is to avoid -Wcast-align warnings. template struct IMGUI_API ImChunkStream { ImVector Buf; void clear() { Buf.clear(); } bool empty() const { return Buf.Size == 0; } int size() const { return Buf.Size; } T* alloc_chunk(size_t sz) { size_t HDR_SZ = 4; sz = ((HDR_SZ + sz) + 3u) & ~3u; int off = Buf.Size; Buf.resize(off + (int)sz); ((int*)(void*)(Buf.Data + off))[0] = (int)sz; return (T*)(void*)(Buf.Data + off + (int)HDR_SZ); } T* begin() { size_t HDR_SZ = 4; if (!Buf.Data) return NULL; return (T*)(void*)(Buf.Data + HDR_SZ); } T* next_chunk(T* p) { size_t HDR_SZ = 4; IM_ASSERT(p >= begin() && p < end()); p = (T*)(void*)((char*)(void*)p + chunk_size(p)); if (p == (T*)(void*)((char*)end() + HDR_SZ)) return (T*)0; IM_ASSERT(p < end()); return p; } int chunk_size(const T* p) { return ((const int*)p)[-1]; } T* end() { return (T*)(void*)(Buf.Data + Buf.Size); } int offset_from_ptr(const T* p) { IM_ASSERT(p >= begin() && p < end()); const ptrdiff_t off = (const char*)p - Buf.Data; return (int)off; } T* ptr_from_offset(int off) { IM_ASSERT(off >= 4 && off < Buf.Size); return (T*)(void*)(Buf.Data + off); } }; //----------------------------------------------------------------------------- // Misc data structures //----------------------------------------------------------------------------- enum ImGuiButtonFlags_ { ImGuiButtonFlags_None = 0, ImGuiButtonFlags_Repeat = 1 << 0, // hold to repeat ImGuiButtonFlags_PressedOnClick = 1 << 1, // return true on click (mouse down event) ImGuiButtonFlags_PressedOnClickRelease = 1 << 2, // [Default] return true on click + release on same item <-- this is what the majority of Button are using ImGuiButtonFlags_PressedOnClickReleaseAnywhere = 1 << 3, // return true on click + release even if the release event is not done while hovering the item ImGuiButtonFlags_PressedOnRelease = 1 << 4, // return true on release (default requires click+release) ImGuiButtonFlags_PressedOnDoubleClick = 1 << 5, // return true on double-click (default requires click+release) ImGuiButtonFlags_PressedOnDragDropHold = 1 << 6, // return true when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers) ImGuiButtonFlags_FlattenChildren = 1 << 7, // allow interactions even if a child window is overlapping ImGuiButtonFlags_AllowItemOverlap = 1 << 8, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap() ImGuiButtonFlags_DontClosePopups = 1 << 9, // disable automatically closing parent popup on press // [UNUSED] ImGuiButtonFlags_Disabled = 1 << 10, // disable interactions ImGuiButtonFlags_AlignTextBaseLine = 1 << 11, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine ImGuiButtonFlags_NoKeyModifiers = 1 << 12, // disable mouse interaction if a key modifier is held ImGuiButtonFlags_NoHoldingActiveId = 1 << 13, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only) ImGuiButtonFlags_NoNavFocus = 1 << 14, // don't override navigation focus when activated ImGuiButtonFlags_NoHoveredOnNav = 1 << 15, // don't report as hovered when navigated on ImGuiButtonFlags_MouseButtonLeft = 1 << 16, // [Default] react on left mouse button ImGuiButtonFlags_MouseButtonRight = 1 << 17, // react on right mouse button ImGuiButtonFlags_MouseButtonMiddle = 1 << 18, // react on center mouse button ImGuiButtonFlags_MouseButtonMask_ = ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle, ImGuiButtonFlags_MouseButtonShift_ = 16, ImGuiButtonFlags_MouseButtonDefault_ = ImGuiButtonFlags_MouseButtonLeft, ImGuiButtonFlags_PressedOnMask_ = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold, ImGuiButtonFlags_PressedOnDefault_ = ImGuiButtonFlags_PressedOnClickRelease }; enum ImGuiSliderFlags_ { ImGuiSliderFlags_None = 0, ImGuiSliderFlags_Vertical = 1 << 0 }; enum ImGuiDragFlags_ { ImGuiDragFlags_None = 0, ImGuiDragFlags_Vertical = 1 << 0 }; enum ImGuiColumnsFlags_ { // Default: 0 ImGuiColumnsFlags_None = 0, ImGuiColumnsFlags_NoBorder = 1 << 0, // Disable column dividers ImGuiColumnsFlags_NoResize = 1 << 1, // Disable resizing columns when clicking on the dividers ImGuiColumnsFlags_NoPreserveWidths = 1 << 2, // Disable column width preservation when adjusting columns ImGuiColumnsFlags_NoForceWithinWindow = 1 << 3, // Disable forcing columns to fit within window ImGuiColumnsFlags_GrowParentContentsSize= 1 << 4 // (WIP) Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove. }; // Extend ImGuiSelectableFlags_ enum ImGuiSelectableFlagsPrivate_ { // NB: need to be in sync with last value of ImGuiSelectableFlags_ ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20, ImGuiSelectableFlags_PressedOnClick = 1 << 21, ImGuiSelectableFlags_PressedOnRelease = 1 << 22, ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 23, // FIXME: We may be able to remove this (added in 6251d379 for menus) ImGuiSelectableFlags_DrawHoveredWhenHeld= 1 << 24, // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow. ImGuiSelectableFlags_SetNavIdOnHover = 1 << 25 }; // Extend ImGuiTreeNodeFlags_ enum ImGuiTreeNodeFlagsPrivate_ { ImGuiTreeNodeFlags_ClipLabelForTrailingButton = 1 << 20 }; enum ImGuiSeparatorFlags_ { ImGuiSeparatorFlags_None = 0, ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar ImGuiSeparatorFlags_Vertical = 1 << 1, ImGuiSeparatorFlags_SpanAllColumns = 1 << 2 }; // Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin(). // This is going to be exposed in imgui.h when stabilized enough. enum ImGuiItemFlags_ { ImGuiItemFlags_None = 0, ImGuiItemFlags_NoTabStop = 1 << 0, // false ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings. ImGuiItemFlags_Disabled = 1 << 2, // false // [BETA] Disable interactions but doesn't affect visuals yet. See github.com/ocornut/imgui/issues/211 ImGuiItemFlags_NoNav = 1 << 3, // false ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window ImGuiItemFlags_MixedValue = 1 << 6, // false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets) ImGuiItemFlags_Default_ = 0 }; // Storage for LastItem data enum ImGuiItemStatusFlags_ { ImGuiItemStatusFlags_None = 0, ImGuiItemStatusFlags_HoveredRect = 1 << 0, ImGuiItemStatusFlags_HasDisplayRect = 1 << 1, ImGuiItemStatusFlags_Edited = 1 << 2, // Value exposed by item was edited in the current frame (should match the bool return value of most widgets) ImGuiItemStatusFlags_ToggledSelection = 1 << 3, // Set when Selectable(), TreeNode() reports toggling a selection. We can't report "Selected" because reporting the change allows us to handle clipping with less issues. ImGuiItemStatusFlags_ToggledOpen = 1 << 4, // Set when TreeNode() reports toggling their open state. ImGuiItemStatusFlags_HasDeactivated = 1 << 5, // Set if the widget/group is able to provide data for the ImGuiItemStatusFlags_Deactivated flag. ImGuiItemStatusFlags_Deactivated = 1 << 6 // Only valid if ImGuiItemStatusFlags_HasDeactivated is set. #ifdef IMGUI_ENABLE_TEST_ENGINE , // [imgui_tests only] ImGuiItemStatusFlags_Openable = 1 << 10, // ImGuiItemStatusFlags_Opened = 1 << 11, // ImGuiItemStatusFlags_Checkable = 1 << 12, // ImGuiItemStatusFlags_Checked = 1 << 13 // #endif }; enum ImGuiTextFlags_ { ImGuiTextFlags_None = 0, ImGuiTextFlags_NoWidthForLargeClippedText = 1 << 0 }; enum ImGuiTooltipFlags_ { ImGuiTooltipFlags_None = 0, ImGuiTooltipFlags_OverridePreviousTooltip = 1 << 0 // Override will clear/ignore previously submitted tooltip (defaults to append) }; // FIXME: this is in development, not exposed/functional as a generic feature yet. // Horizontal/Vertical enums are fixed to 0/1 so they may be used to index ImVec2 enum ImGuiLayoutType_ { ImGuiLayoutType_Horizontal = 0, ImGuiLayoutType_Vertical = 1 }; enum ImGuiLogType { ImGuiLogType_None = 0, ImGuiLogType_TTY, ImGuiLogType_File, ImGuiLogType_Buffer, ImGuiLogType_Clipboard }; // X/Y enums are fixed to 0/1 so they may be used to index ImVec2 enum ImGuiAxis { ImGuiAxis_None = -1, ImGuiAxis_X = 0, ImGuiAxis_Y = 1 }; enum ImGuiPlotType { ImGuiPlotType_Lines, ImGuiPlotType_Histogram }; enum ImGuiInputSource { ImGuiInputSource_None = 0, ImGuiInputSource_Mouse, ImGuiInputSource_Nav, ImGuiInputSource_NavKeyboard, // Only used occasionally for storage, not tested/handled by most code ImGuiInputSource_NavGamepad, // " ImGuiInputSource_COUNT }; // FIXME-NAV: Clarify/expose various repeat delay/rate enum ImGuiInputReadMode { ImGuiInputReadMode_Down, ImGuiInputReadMode_Pressed, ImGuiInputReadMode_Released, ImGuiInputReadMode_Repeat, ImGuiInputReadMode_RepeatSlow, ImGuiInputReadMode_RepeatFast }; enum ImGuiNavHighlightFlags_ { ImGuiNavHighlightFlags_None = 0, ImGuiNavHighlightFlags_TypeDefault = 1 << 0, ImGuiNavHighlightFlags_TypeThin = 1 << 1, ImGuiNavHighlightFlags_AlwaysDraw = 1 << 2, // Draw rectangular highlight if (g.NavId == id) _even_ when using the mouse. ImGuiNavHighlightFlags_NoRounding = 1 << 3 }; enum ImGuiNavDirSourceFlags_ { ImGuiNavDirSourceFlags_None = 0, ImGuiNavDirSourceFlags_Keyboard = 1 << 0, ImGuiNavDirSourceFlags_PadDPad = 1 << 1, ImGuiNavDirSourceFlags_PadLStick = 1 << 2 }; enum ImGuiNavMoveFlags_ { ImGuiNavMoveFlags_None = 0, ImGuiNavMoveFlags_LoopX = 1 << 0, // On failed request, restart from opposite side ImGuiNavMoveFlags_LoopY = 1 << 1, ImGuiNavMoveFlags_WrapX = 1 << 2, // On failed request, request from opposite side one line down (when NavDir==right) or one line up (when NavDir==left) ImGuiNavMoveFlags_WrapY = 1 << 3, // This is not super useful for provided for completeness ImGuiNavMoveFlags_AllowCurrentNavId = 1 << 4, // Allow scoring and considering the current NavId as a move target candidate. This is used when the move source is offset (e.g. pressing PageDown actually needs to send a Up move request, if we are pressing PageDown from the bottom-most item we need to stay in place) ImGuiNavMoveFlags_AlsoScoreVisibleSet = 1 << 5, // Store alternate result in NavMoveResultLocalVisibleSet that only comprise elements that are already fully visible. ImGuiNavMoveFlags_ScrollToEdge = 1 << 6 }; enum ImGuiNavForward { ImGuiNavForward_None, ImGuiNavForward_ForwardQueued, ImGuiNavForward_ForwardActive }; enum ImGuiNavLayer { ImGuiNavLayer_Main = 0, // Main scrolling layer ImGuiNavLayer_Menu = 1, // Menu layer (access with Alt/ImGuiNavInput_Menu) ImGuiNavLayer_COUNT }; enum ImGuiPopupPositionPolicy { ImGuiPopupPositionPolicy_Default, ImGuiPopupPositionPolicy_ComboBox }; // 1D vector (this odd construct is used to facilitate the transition between 1D and 2D, and the maintenance of some branches/patches) struct ImVec1 { float x; ImVec1() { x = 0.0f; } ImVec1(float _x) { x = _x; } }; // 2D vector (half-size integer) struct ImVec2ih { short x, y; ImVec2ih() { x = y = 0; } ImVec2ih(short _x, short _y) { x = _x; y = _y; } explicit ImVec2ih(const ImVec2& rhs) { x = (short)rhs.x; y = (short)rhs.y; } }; // 2D axis aligned bounding-box // NB: we can't rely on ImVec2 math operators being available here struct IMGUI_API ImRect { ImVec2 Min; // Upper-left ImVec2 Max; // Lower-right ImRect() : Min(0.0f, 0.0f), Max(0.0f, 0.0f) {} ImRect(const ImVec2& min, const ImVec2& max) : Min(min), Max(max) {} ImRect(const ImVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {} ImRect(float x1, float y1, float x2, float y2) : Min(x1, y1), Max(x2, y2) {} ImVec2 GetCenter() const { return ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); } ImVec2 GetSize() const { return ImVec2(Max.x - Min.x, Max.y - Min.y); } float GetWidth() const { return Max.x - Min.x; } float GetHeight() const { return Max.y - Min.y; } ImVec2 GetTL() const { return Min; } // Top-left ImVec2 GetTR() const { return ImVec2(Max.x, Min.y); } // Top-right ImVec2 GetBL() const { return ImVec2(Min.x, Max.y); } // Bottom-left ImVec2 GetBR() const { return Max; } // Bottom-right bool Contains(const ImVec2& p) const { return p.x >= Min.x && p.y >= Min.y && p.x < Max.x && p.y < Max.y; } bool Contains(const ImRect& r) const { return r.Min.x >= Min.x && r.Min.y >= Min.y && r.Max.x <= Max.x && r.Max.y <= Max.y; } bool Overlaps(const ImRect& r) const { return r.Min.y < Max.y && r.Max.y > Min.y && r.Min.x < Max.x && r.Max.x > Min.x; } void Add(const ImVec2& p) { if (Min.x > p.x) Min.x = p.x; if (Min.y > p.y) Min.y = p.y; if (Max.x < p.x) Max.x = p.x; if (Max.y < p.y) Max.y = p.y; } void Add(const ImRect& r) { if (Min.x > r.Min.x) Min.x = r.Min.x; if (Min.y > r.Min.y) Min.y = r.Min.y; if (Max.x < r.Max.x) Max.x = r.Max.x; if (Max.y < r.Max.y) Max.y = r.Max.y; } void Expand(const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; } void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; } void Translate(const ImVec2& d) { Min.x += d.x; Min.y += d.y; Max.x += d.x; Max.y += d.y; } void TranslateX(float dx) { Min.x += dx; Max.x += dx; } void TranslateY(float dy) { Min.y += dy; Max.y += dy; } void ClipWith(const ImRect& r) { Min = ImMax(Min, r.Min); Max = ImMin(Max, r.Max); } // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display. void ClipWithFull(const ImRect& r) { Min = ImClamp(Min, r.Min, r.Max); Max = ImClamp(Max, r.Min, r.Max); } // Full version, ensure both points are fully clipped. void Floor() { Min.x = IM_FLOOR(Min.x); Min.y = IM_FLOOR(Min.y); Max.x = IM_FLOOR(Max.x); Max.y = IM_FLOOR(Max.y); } bool IsInverted() const { return Min.x > Max.x || Min.y > Max.y; } }; // Type information associated to one ImGuiDataType. Retrieve with DataTypeGetInfo(). struct ImGuiDataTypeInfo { size_t Size; // Size in byte const char* PrintFmt; // Default printf format for the type const char* ScanFmt; // Default scanf format for the type }; // Stacked color modifier, backup of modified data so we can restore it struct ImGuiColorMod { ImGuiCol Col; ImVec4 BackupValue; }; // Stacked style modifier, backup of modified data so we can restore it. Data type inferred from the variable. struct ImGuiStyleMod { ImGuiStyleVar VarIdx; union { int BackupInt[2]; float BackupFloat[2]; }; ImGuiStyleMod(ImGuiStyleVar idx, int v) { VarIdx = idx; BackupInt[0] = v; } ImGuiStyleMod(ImGuiStyleVar idx, float v) { VarIdx = idx; BackupFloat[0] = v; } ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; } }; // Stacked storage data for BeginGroup()/EndGroup() struct ImGuiGroupData { ImVec2 BackupCursorPos; ImVec2 BackupCursorMaxPos; ImVec1 BackupIndent; ImVec1 BackupGroupOffset; ImVec2 BackupCurrLineSize; float BackupCurrLineTextBaseOffset; ImGuiID BackupActiveIdIsAlive; bool BackupActiveIdPreviousFrameIsAlive; bool EmitItem; }; // Simple column measurement, currently used for MenuItem() only.. This is very short-sighted/throw-away code and NOT a generic helper. struct IMGUI_API ImGuiMenuColumns { float Spacing; float Width, NextWidth; float Pos[3], NextWidths[3]; ImGuiMenuColumns(); void Update(int count, float spacing, bool clear); float DeclColumns(float w0, float w1, float w2); float CalcExtraSpace(float avail_w) const; }; // Internal state of the currently focused/edited text input box struct IMGUI_API ImGuiInputTextState { ImGuiID ID; // widget id owning the text state int CurLenW, CurLenA; // we need to maintain our buffer length in both UTF-8 and wchar format. UTF-8 len is valid even if TextA is not. ImVector TextW; // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer. ImVector TextA; // temporary UTF8 buffer for callbacks and other operations. this is not updated in every code-path! size=capacity. ImVector InitialTextA; // backup of end-user buffer at the time of focus (in UTF-8, unaltered) bool TextAIsValid; // temporary UTF8 buffer is not initially valid before we make the widget active (until then we pull the data from user argument) int BufCapacityA; // end-user buffer capacity float ScrollX; // horizontal scrolling/offset ImStb::STB_TexteditState Stb; // state for stb_textedit.h float CursorAnim; // timer for cursor blink, reset on every user action so the cursor reappears immediately bool CursorFollow; // set when we want scrolling to follow the current cursor position (not always!) bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection ImGuiInputTextFlags UserFlags; // Temporarily set while we call user's callback ImGuiInputTextCallback UserCallback; // " void* UserCallbackData; // " ImGuiInputTextState() { memset(this, 0, sizeof(*this)); } void ClearText() { CurLenW = CurLenA = 0; TextW[0] = 0; TextA[0] = 0; CursorClamp(); } void ClearFreeMemory() { TextW.clear(); TextA.clear(); InitialTextA.clear(); } int GetUndoAvailCount() const { return Stb.undostate.undo_point; } int GetRedoAvailCount() const { return STB_TEXTEDIT_UNDOSTATECOUNT - Stb.undostate.redo_point; } void OnKeyPressed(int key); // Cannot be inline because we call in code in stb_textedit.h implementation // Cursor & Selection void CursorAnimReset() { CursorAnim = -0.30f; } // After a user-input the cursor stays on for a while without blinking void CursorClamp() { Stb.cursor = ImMin(Stb.cursor, CurLenW); Stb.select_start = ImMin(Stb.select_start, CurLenW); Stb.select_end = ImMin(Stb.select_end, CurLenW); } bool HasSelection() const { return Stb.select_start != Stb.select_end; } void ClearSelection() { Stb.select_start = Stb.select_end = Stb.cursor; } void SelectAll() { Stb.select_start = 0; Stb.cursor = Stb.select_end = CurLenW; Stb.has_preferred_x = 0; } }; // Windows data saved in imgui.ini file // Because we never destroy or rename ImGuiWindowSettings, we can store the names in a separate buffer easily. // (this is designed to be stored in a ImChunkStream buffer, with the variable-length Name following our structure) struct ImGuiWindowSettings { ImGuiID ID; ImVec2ih Pos; ImVec2ih Size; bool Collapsed; ImGuiWindowSettings() { ID = 0; Pos = Size = ImVec2ih(0, 0); Collapsed = false; } char* GetName() { return (char*)(this + 1); } }; struct ImGuiSettingsHandler { const char* TypeName; // Short description stored in .ini file. Disallowed characters: '[' ']' ImGuiID TypeHash; // == ImHashStr(TypeName) void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name); // Read: Called when entering into a new ini entry e.g. "[Window][Name]" void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf); // Write: Output every entries into 'out_buf' void* UserData; ImGuiSettingsHandler() { memset(this, 0, sizeof(*this)); } }; // Storage for current popup stack struct ImGuiPopupData { ImGuiID PopupId; // Set on OpenPopup() ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup() ImGuiWindow* SourceWindow; // Set on OpenPopup() copy of NavWindow at the time of opening the popup int OpenFrameCount; // Set on OpenPopup() ImGuiID OpenParentId; // Set on OpenPopup(), we need this to differentiate multiple menu sets from each others (e.g. inside menu bar vs loose menu items) ImVec2 OpenPopupPos; // Set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse) ImVec2 OpenMousePos; // Set on OpenPopup(), copy of mouse position at the time of opening popup ImGuiPopupData() { PopupId = 0; Window = SourceWindow = NULL; OpenFrameCount = -1; OpenParentId = 0; } }; struct ImGuiColumnData { float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right) float OffsetNormBeforeResize; ImGuiColumnsFlags Flags; // Not exposed ImRect ClipRect; ImGuiColumnData() { OffsetNorm = OffsetNormBeforeResize = 0.0f; Flags = ImGuiColumnsFlags_None; } }; struct ImGuiColumns { ImGuiID ID; ImGuiColumnsFlags Flags; bool IsFirstFrame; bool IsBeingResized; int Current; int Count; float OffMinX, OffMaxX; // Offsets from HostWorkRect.Min.x float LineMinY, LineMaxY; float HostCursorPosY; // Backup of CursorPos at the time of BeginColumns() float HostCursorMaxPosX; // Backup of CursorMaxPos at the time of BeginColumns() ImRect HostClipRect; // Backup of ClipRect at the time of BeginColumns() ImRect HostWorkRect; // Backup of WorkRect at the time of BeginColumns() ImVector Columns; ImDrawListSplitter Splitter; ImGuiColumns() { Clear(); } void Clear() { ID = 0; Flags = ImGuiColumnsFlags_None; IsFirstFrame = false; IsBeingResized = false; Current = 0; Count = 1; OffMinX = OffMaxX = 0.0f; LineMinY = LineMaxY = 0.0f; HostCursorPosY = 0.0f; HostCursorMaxPosX = 0.0f; Columns.clear(); } }; // Helper function to calculate a circle's segment count given its radius and a "maximum error" value. #define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN 12 #define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX 512 #define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(_RAD,_MAXERROR) ImClamp((int)((IM_PI * 2.0f) / ImAcos((_RAD - _MAXERROR) / _RAD)), IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX) // Data shared between all ImDrawList instances // You may want to create your own instance of this if you want to use ImDrawList completely without ImGui. In that case, watch out for future changes to this structure. struct IMGUI_API ImDrawListSharedData { ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas ImFont* Font; // Current/default font (optional, for simplified AddText overload) float FontSize; // Current/default font size (optional, for simplified AddText overload) float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() float CircleSegmentMaxError; // Number of circle segments to use per pixel of radius for AddCircle() etc ImVec4 ClipRectFullscreen; // Value for PushClipRectFullscreen() ImDrawListFlags InitialFlags; // Initial flags at the beginning of the frame (it is possible to alter flags on a per-drawlist basis afterwards) // [Internal] Lookup tables ImVec2 CircleVtx12[12]; // FIXME: Bake rounded corners fill/borders in atlas ImU8 CircleSegmentCounts[64]; // Precomputed segment count for given radius (array index + 1) before we calculate it dynamically (to avoid calculation overhead) ImDrawListSharedData(); void SetCircleSegmentMaxError(float max_error); }; struct ImDrawDataBuilder { ImVector Layers[2]; // Global layers for: regular, tooltip void Clear() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].resize(0); } void ClearFreeMemory() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].clear(); } IMGUI_API void FlattenIntoSingleLayer(); }; struct ImGuiNavMoveResult { ImGuiWindow* Window; // Best candidate window ImGuiID ID; // Best candidate ID ImGuiID FocusScopeId; // Best candidate focus scope ID float DistBox; // Best candidate box distance to current NavId float DistCenter; // Best candidate center distance to current NavId float DistAxial; ImRect RectRel; // Best candidate bounding box in window relative space ImGuiNavMoveResult() { Clear(); } void Clear() { Window = NULL; ID = FocusScopeId = 0; DistBox = DistCenter = DistAxial = FLT_MAX; RectRel = ImRect(); } }; enum ImGuiNextWindowDataFlags_ { ImGuiNextWindowDataFlags_None = 0, ImGuiNextWindowDataFlags_HasPos = 1 << 0, ImGuiNextWindowDataFlags_HasSize = 1 << 1, ImGuiNextWindowDataFlags_HasContentSize = 1 << 2, ImGuiNextWindowDataFlags_HasCollapsed = 1 << 3, ImGuiNextWindowDataFlags_HasSizeConstraint = 1 << 4, ImGuiNextWindowDataFlags_HasFocus = 1 << 5, ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6 }; // Storage for SetNexWindow** functions struct ImGuiNextWindowData { ImGuiNextWindowDataFlags Flags; ImGuiCond PosCond; ImGuiCond SizeCond; ImGuiCond CollapsedCond; ImVec2 PosVal; ImVec2 PosPivotVal; ImVec2 SizeVal; ImVec2 ContentSizeVal; bool CollapsedVal; ImRect SizeConstraintRect; ImGuiSizeCallback SizeCallback; void* SizeCallbackUserData; float BgAlphaVal; // Override background alpha ImVec2 MenuBarOffsetMinVal; // *Always on* This is not exposed publicly, so we don't clear it. ImGuiNextWindowData() { memset(this, 0, sizeof(*this)); } inline void ClearFlags() { Flags = ImGuiNextWindowDataFlags_None; } }; enum ImGuiNextItemDataFlags_ { ImGuiNextItemDataFlags_None = 0, ImGuiNextItemDataFlags_HasWidth = 1 << 0, ImGuiNextItemDataFlags_HasOpen = 1 << 1 }; struct ImGuiNextItemData { ImGuiNextItemDataFlags Flags; float Width; // Set by SetNextItemWidth() ImGuiID FocusScopeId; // Set by SetNextItemMultiSelectData() (!= 0 signify value has been set, so it's an alternate version of HasSelectionData, we don't use Flags for this because they are cleared too early. This is mostly used for debugging) ImGuiCond OpenCond; bool OpenVal; // Set by SetNextItemOpen() ImGuiNextItemData() { memset(this, 0, sizeof(*this)); } inline void ClearFlags() { Flags = ImGuiNextItemDataFlags_None; } // Also cleared manually by ItemAdd()! }; //----------------------------------------------------------------------------- // Tabs //----------------------------------------------------------------------------- struct ImGuiShrinkWidthItem { int Index; float Width; }; struct ImGuiPtrOrIndex { void* Ptr; // Either field can be set, not both. e.g. Dock node tab bars are loose while BeginTabBar() ones are in a pool. int Index; // Usually index in a main pool. ImGuiPtrOrIndex(void* ptr) { Ptr = ptr; Index = -1; } ImGuiPtrOrIndex(int index) { Ptr = NULL; Index = index; } }; //----------------------------------------------------------------------------- // Main Dear ImGui context //----------------------------------------------------------------------------- struct ImGuiContext { bool Initialized; bool FontAtlasOwnedByContext; // IO.Fonts-> is owned by the ImGuiContext and will be destructed along with it. ImGuiIO IO; ImGuiStyle Style; ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back() float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window. float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height. ImDrawListSharedData DrawListSharedData; double Time; int FrameCount; int FrameCountEnded; int FrameCountRendered; bool WithinFrameScope; // Set by NewFrame(), cleared by EndFrame() bool WithinFrameScopeWithImplicitWindow; // Set by NewFrame(), cleared by EndFrame() when the implicit debug window has been pushed bool WithinEndChild; // Set within EndChild() // Windows state ImVector Windows; // Windows, sorted in display order, back to front ImVector WindowsFocusOrder; // Windows, sorted in focus order, back to front. (FIXME: We could only store root windows here! Need to sort out the Docking equivalent which is RootWindowDockStop and is unfortunately a little more dynamic) ImVector WindowsTempSortBuffer; // Temporary buffer used in EndFrame() to reorder windows so parents are kept before their child ImVector CurrentWindowStack; ImGuiStorage WindowsById; // Map window's ImGuiID to ImGuiWindow* int WindowsActiveCount; // Number of unique windows submitted by frame ImGuiWindow* CurrentWindow; // Window being drawn into ImGuiWindow* HoveredWindow; // Will catch mouse inputs ImGuiWindow* HoveredRootWindow; // Will catch mouse inputs (for focus/move only) ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actually window that is moved is generally MovingWindow->RootWindow. ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window. ImVec2 WheelingWindowRefMousePos; float WheelingWindowTimer; // Item/widgets state and tracking information ImGuiID HoveredId; // Hovered widget bool HoveredIdAllowOverlap; ImGuiID HoveredIdPreviousFrame; float HoveredIdTimer; // Measure contiguous hovering time float HoveredIdNotActiveTimer; // Measure contiguous hovering time where the item has not been active ImGuiID ActiveId; // Active widget ImGuiID ActiveIdIsAlive; // Active widget has been seen this frame (we can't use a bool as the ActiveId may change within the frame) float ActiveIdTimer; bool ActiveIdIsJustActivated; // Set at the time of activation for one frame bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always) bool ActiveIdHasBeenPressedBefore; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch. bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state. bool ActiveIdHasBeenEditedThisFrame; ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those directional navigation requests (e.g. can activate a button and move away from it) ImU32 ActiveIdUsingNavInputMask; // Active widget will want to read those nav inputs. ImU64 ActiveIdUsingKeyInputMask; // Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array. ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior) ImGuiWindow* ActiveIdWindow; ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard) int ActiveIdMouseButton; ImGuiID ActiveIdPreviousFrame; bool ActiveIdPreviousFrameIsAlive; bool ActiveIdPreviousFrameHasBeenEditedBefore; ImGuiWindow* ActiveIdPreviousFrameWindow; ImGuiID LastActiveId; // Store the last non-zero ActiveId, useful for animation. float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation. // Next window/item data ImGuiNextWindowData NextWindowData; // Storage for SetNextWindow** functions ImGuiNextItemData NextItemData; // Storage for SetNextItem** functions // Shared stacks ImVector ColorModifiers; // Stack for PushStyleColor()/PopStyleColor() ImVector StyleModifiers; // Stack for PushStyleVar()/PopStyleVar() ImVector FontStack; // Stack for PushFont()/PopFont() ImVectorOpenPopupStack; // Which popups are open (persistent) ImVectorBeginPopupStack; // Which level of BeginPopup() we are in (reset every frame) // Gamepad/keyboard Navigation ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusWindow' ImGuiID NavId; // Focused item for navigation ImGuiID NavFocusScopeId; ImGuiID NavActivateId; // ~~ (g.ActiveId == 0) && IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0, also set when calling ActivateItem() ImGuiID NavActivateDownId; // ~~ IsNavInputDown(ImGuiNavInput_Activate) ? NavId : 0 ImGuiID NavActivatePressedId; // ~~ IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0 ImGuiID NavInputId; // ~~ IsNavInputPressed(ImGuiNavInput_Input) ? NavId : 0 ImGuiID NavJustTabbedId; // Just tabbed to this id. ImGuiID NavJustMovedToId; // Just navigated to this id (result of a successfully MoveRequest). ImGuiID NavJustMovedToFocusScopeId; // Just navigated to this focus scope id (result of a successfully MoveRequest). ImGuiID NavNextActivateId; // Set by ActivateItem(), queued until next frame. ImGuiInputSource NavInputSource; // Keyboard or Gamepad mode? THIS WILL ONLY BE None or NavGamepad or NavKeyboard. ImRect NavScoringRectScreen; // Rectangle used for scoring, in screen space. Based of window->DC.NavRefRectRel[], modified for directional navigation scoring. int NavScoringCount; // Metrics for debugging ImGuiNavLayer NavLayer; // Layer we are navigating on. For now the system is hard-coded for 0=main contents and 1=menu/title bar, may expose layers later. int NavIdTabCounter; // == NavWindow->DC.FocusIdxTabCounter at time of NavId processing bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRefRectRel is valid bool NavMousePosDirty; // When set we will update mouse position if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) if set (NB: this not enabled by default) bool NavDisableHighlight; // When user starts using mouse, we hide gamepad/keyboard highlight (NB: but they are still available, which is why NavDisableHighlight isn't always != NavDisableMouseHover) bool NavDisableMouseHover; // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again. bool NavAnyRequest; // ~~ NavMoveRequest || NavInitRequest bool NavInitRequest; // Init request for appearing window to select first item bool NavInitRequestFromMove; ImGuiID NavInitResultId; ImRect NavInitResultRectRel; bool NavMoveFromClampedRefRect; // Set by manual scrolling, if we scroll to a point where NavId isn't visible we reset navigation from visible items bool NavMoveRequest; // Move request for this frame ImGuiNavMoveFlags NavMoveRequestFlags; ImGuiNavForward NavMoveRequestForward; // None / ForwardQueued / ForwardActive (this is used to navigate sibling parent menus from a child menu) ImGuiDir NavMoveDir, NavMoveDirLast; // Direction of the move request (left/right/up/down), direction of the previous move request ImGuiDir NavMoveClipDir; // FIXME-NAV: Describe the purpose of this better. Might want to rename? ImGuiNavMoveResult NavMoveResultLocal; // Best move request candidate within NavWindow ImGuiNavMoveResult NavMoveResultLocalVisibleSet; // Best move request candidate within NavWindow that are mostly visible (when using ImGuiNavMoveFlags_AlsoScoreVisibleSet flag) ImGuiNavMoveResult NavMoveResultOther; // Best move request candidate within NavWindow's flattened hierarchy (when using ImGuiWindowFlags_NavFlattened flag) // Navigation: Windowing (CTRL+TAB, holding Menu button + directional pads to move/resize) ImGuiWindow* NavWindowingTarget; // When selecting a window (holding Menu+FocusPrev/Next, or equivalent of CTRL-TAB) this window is temporarily displayed top-most. ImGuiWindow* NavWindowingTargetAnim; // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f ImGuiWindow* NavWindowingList; float NavWindowingTimer; float NavWindowingHighlightAlpha; bool NavWindowingToggleLayer; // Legacy Focus/Tabbing system (older than Nav, active even if Nav is disabled, misnamed. FIXME-NAV: This needs a redesign!) ImGuiWindow* FocusRequestCurrWindow; // ImGuiWindow* FocusRequestNextWindow; // int FocusRequestCurrCounterRegular; // Any item being requested for focus, stored as an index (we on layout to be stable between the frame pressing TAB and the next frame, semi-ouch) int FocusRequestCurrCounterTabStop; // Tab item being requested for focus, stored as an index int FocusRequestNextCounterRegular; // Stored for next frame int FocusRequestNextCounterTabStop; // " bool FocusTabPressed; // // Render ImDrawData DrawData; // Main ImDrawData instance to pass render information to the user ImDrawDataBuilder DrawDataBuilder; float DimBgRatio; // 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list) ImDrawList BackgroundDrawList; // First draw list to be rendered. ImDrawList ForegroundDrawList; // Last draw list to be rendered. This is where we the render software mouse cursor (if io.MouseDrawCursor is set) and most debug overlays. ImGuiMouseCursor MouseCursor; // Drag and Drop bool DragDropActive; bool DragDropWithinSourceOrTarget; // Set when within a BeginDragDropXXX/EndDragDropXXX block. ImGuiDragDropFlags DragDropSourceFlags; int DragDropSourceFrameCount; int DragDropMouseButton; ImGuiPayload DragDropPayload; ImRect DragDropTargetRect; // Store rectangle of current target candidate (we favor small targets when overlapping) ImGuiID DragDropTargetId; ImGuiDragDropFlags DragDropAcceptFlags; float DragDropAcceptIdCurrRectSurface; // Target item surface (we resolve overlapping targets by prioritizing the smaller surface) ImGuiID DragDropAcceptIdCurr; // Target item id (set at the time of accepting the payload) ImGuiID DragDropAcceptIdPrev; // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets) int DragDropAcceptFrameCount; // Last time a target expressed a desire to accept the source ImVector DragDropPayloadBufHeap; // We don't expose the ImVector<> directly, ImGuiPayload only holds pointer+size unsigned char DragDropPayloadBufLocal[16]; // Local buffer for small payloads // Tab bars ImGuiTabBar* CurrentTabBar; ImPool TabBars; ImVector CurrentTabBarStack; ImVector ShrinkWidthBuffer; // Widget state ImVec2 LastValidMousePos; ImGuiInputTextState InputTextState; ImFont InputTextPasswordFont; ImGuiID TempInputTextId; // Temporary text input when CTRL+clicking on a slider, etc. ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets float ColorEditLastHue; // Backup of last Hue associated to LastColor[3], so we can restore Hue in lossy RGB<>HSV round trips float ColorEditLastSat; // Backup of last Saturation associated to LastColor[3], so we can restore Saturation in lossy RGB<>HSV round trips float ColorEditLastColor[3]; ImVec4 ColorPickerRef; // Initial/reference color at the time of opening the color picker. bool DragCurrentAccumDirty; float DragCurrentAccum; // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio float ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage? int TooltipOverrideCount; ImVector PrivateClipboard; // If no custom clipboard handler is defined // Platform support ImVec2 PlatformImePos; // Cursor position request & last passed to the OS Input Method Editor ImVec2 PlatformImeLastPos; // Settings bool SettingsLoaded; float SettingsDirtyTimer; // Save .ini Settings to memory when time reaches zero ImGuiTextBuffer SettingsIniData; // In memory .ini settings ImVector SettingsHandlers; // List of .ini settings handlers ImChunkStream SettingsWindows; // ImGuiWindow .ini settings entries // Capture/Logging bool LogEnabled; ImGuiLogType LogType; ImFileHandle LogFile; // If != NULL log to stdout/ file ImGuiTextBuffer LogBuffer; // Accumulation buffer when log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators. float LogLinePosY; bool LogLineFirstItem; int LogDepthRef; int LogDepthToExpand; int LogDepthToExpandDefault; // Default/stored value for LogDepthMaxExpand if not specified in the LogXXX function call. // Debug Tools bool DebugItemPickerActive; ImGuiID DebugItemPickerBreakId; // Will call IM_DEBUG_BREAK() when encountering this id // Misc float FramerateSecPerFrame[120]; // Calculate estimate of framerate for user over the last 2 seconds. int FramerateSecPerFrameIdx; float FramerateSecPerFrameAccum; int WantCaptureMouseNextFrame; // Explicit capture via CaptureKeyboardFromApp()/CaptureMouseFromApp() sets those flags int WantCaptureKeyboardNextFrame; int WantTextInputNextFrame; char TempBuffer[1024*3+1]; // Temporary text buffer ImGuiContext(ImFontAtlas* shared_font_atlas) : BackgroundDrawList(&DrawListSharedData), ForegroundDrawList(&DrawListSharedData) { Initialized = false; Font = NULL; FontSize = FontBaseSize = 0.0f; FontAtlasOwnedByContext = shared_font_atlas ? false : true; IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)(); Time = 0.0f; FrameCount = 0; FrameCountEnded = FrameCountRendered = -1; WithinFrameScope = WithinFrameScopeWithImplicitWindow = WithinEndChild = false; WindowsActiveCount = 0; CurrentWindow = NULL; HoveredWindow = NULL; HoveredRootWindow = NULL; MovingWindow = NULL; WheelingWindow = NULL; WheelingWindowTimer = 0.0f; HoveredId = 0; HoveredIdAllowOverlap = false; HoveredIdPreviousFrame = 0; HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f; ActiveId = 0; ActiveIdIsAlive = 0; ActiveIdTimer = 0.0f; ActiveIdIsJustActivated = false; ActiveIdAllowOverlap = false; ActiveIdHasBeenPressedBefore = false; ActiveIdHasBeenEditedBefore = false; ActiveIdHasBeenEditedThisFrame = false; ActiveIdUsingNavDirMask = 0x00; ActiveIdUsingNavInputMask = 0x00; ActiveIdUsingKeyInputMask = 0x00; ActiveIdClickOffset = ImVec2(-1,-1); ActiveIdWindow = NULL; ActiveIdSource = ImGuiInputSource_None; ActiveIdMouseButton = 0; ActiveIdPreviousFrame = 0; ActiveIdPreviousFrameIsAlive = false; ActiveIdPreviousFrameHasBeenEditedBefore = false; ActiveIdPreviousFrameWindow = NULL; LastActiveId = 0; LastActiveIdTimer = 0.0f; NavWindow = NULL; NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavInputId = 0; NavJustTabbedId = NavJustMovedToId = NavJustMovedToFocusScopeId = NavNextActivateId = 0; NavInputSource = ImGuiInputSource_None; NavScoringRectScreen = ImRect(); NavScoringCount = 0; NavLayer = ImGuiNavLayer_Main; NavIdTabCounter = INT_MAX; NavIdIsAlive = false; NavMousePosDirty = false; NavDisableHighlight = true; NavDisableMouseHover = false; NavAnyRequest = false; NavInitRequest = false; NavInitRequestFromMove = false; NavInitResultId = 0; NavMoveFromClampedRefRect = false; NavMoveRequest = false; NavMoveRequestFlags = ImGuiNavMoveFlags_None; NavMoveRequestForward = ImGuiNavForward_None; NavMoveDir = NavMoveDirLast = NavMoveClipDir = ImGuiDir_None; NavWindowingTarget = NavWindowingTargetAnim = NavWindowingList = NULL; NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f; NavWindowingToggleLayer = false; FocusRequestCurrWindow = FocusRequestNextWindow = NULL; FocusRequestCurrCounterRegular = FocusRequestCurrCounterTabStop = INT_MAX; FocusRequestNextCounterRegular = FocusRequestNextCounterTabStop = INT_MAX; FocusTabPressed = false; DimBgRatio = 0.0f; BackgroundDrawList._OwnerName = "##Background"; // Give it a name for debugging ForegroundDrawList._OwnerName = "##Foreground"; // Give it a name for debugging MouseCursor = ImGuiMouseCursor_Arrow; DragDropActive = DragDropWithinSourceOrTarget = false; DragDropSourceFlags = ImGuiDragDropFlags_None; DragDropSourceFrameCount = -1; DragDropMouseButton = -1; DragDropTargetId = 0; DragDropAcceptFlags = ImGuiDragDropFlags_None; DragDropAcceptIdCurrRectSurface = 0.0f; DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0; DragDropAcceptFrameCount = -1; memset(DragDropPayloadBufLocal, 0, sizeof(DragDropPayloadBufLocal)); CurrentTabBar = NULL; LastValidMousePos = ImVec2(0.0f, 0.0f); TempInputTextId = 0; ColorEditOptions = ImGuiColorEditFlags__OptionsDefault; ColorEditLastHue = ColorEditLastSat = 0.0f; ColorEditLastColor[0] = ColorEditLastColor[1] = ColorEditLastColor[2] = FLT_MAX; DragCurrentAccumDirty = false; DragCurrentAccum = 0.0f; DragSpeedDefaultRatio = 1.0f / 100.0f; ScrollbarClickDeltaToGrabCenter = 0.0f; TooltipOverrideCount = 0; PlatformImePos = PlatformImeLastPos = ImVec2(FLT_MAX, FLT_MAX); SettingsLoaded = false; SettingsDirtyTimer = 0.0f; LogEnabled = false; LogType = ImGuiLogType_None; LogFile = NULL; LogLinePosY = FLT_MAX; LogLineFirstItem = false; LogDepthRef = 0; LogDepthToExpand = LogDepthToExpandDefault = 2; DebugItemPickerActive = false; DebugItemPickerBreakId = 0; memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame)); FramerateSecPerFrameIdx = 0; FramerateSecPerFrameAccum = 0.0f; WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1; memset(TempBuffer, 0, sizeof(TempBuffer)); } }; //----------------------------------------------------------------------------- // ImGuiWindow //----------------------------------------------------------------------------- // Transient per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the DC variable name in ImGuiWindow. // FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered. struct IMGUI_API ImGuiWindowTempData { // Layout ImVec2 CursorPos; // Current emitting position, in absolute coordinates. ImVec2 CursorPosPrevLine; ImVec2 CursorStartPos; // Initial position after Begin(), generally ~ window position + WindowPadding. ImVec2 CursorMaxPos; // Used to implicitly calculate the size of our contents, always growing during the frame. Used to calculate window->ContentSize at the beginning of next frame ImVec2 CurrLineSize; ImVec2 PrevLineSize; float CurrLineTextBaseOffset; // Baseline offset (0.0f by default on a new line, generally == style.FramePadding.y when a framed item has been added). float PrevLineTextBaseOffset; ImVec1 Indent; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.) ImVec1 ColumnsOffset; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API. ImVec1 GroupOffset; // Last item status ImGuiID LastItemId; // ID for last item ImGuiItemStatusFlags LastItemStatusFlags; // Status flags for last item (see ImGuiItemStatusFlags_) ImRect LastItemRect; // Interaction rect for last item ImRect LastItemDisplayRect; // End-user display rect for last item (only valid if LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect) // Keyboard/Gamepad navigation ImGuiNavLayer NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1) int NavLayerCurrentMask; // = (1 << NavLayerCurrent) used by ItemAdd prior to clipping. int NavLayerActiveMask; // Which layer have been written to (result from previous frame) int NavLayerActiveMaskNext; // Which layer have been written to (buffer for current frame) ImGuiID NavFocusScopeIdCurrent; // Current focus scope ID while appending bool NavHideHighlightOneFrame; bool NavHasScroll; // Set when scrolling can be used (ScrollMax > 0.0f) // Miscellaneous bool MenuBarAppending; // FIXME: Remove this ImVec2 MenuBarOffset; // MenuBarOffset.x is sort of equivalent of a per-layer CursorPos.x, saved/restored as we switch to the menu bar. The only situation when MenuBarOffset.y is > 0 if when (SafeAreaPadding.y > FramePadding.y), often used on TVs. ImGuiMenuColumns MenuColumns; // Simplified columns storage for menu items measurement int TreeDepth; // Current tree depth. ImU32 TreeJumpToParentOnPopMask; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31.. Could be turned into a ImU64 if necessary. ImVector ChildWindows; ImGuiStorage* StateStorage; // Current persistent per-window storage (store e.g. tree node open/close state) ImGuiColumns* CurrentColumns; // Current columns set ImGuiLayoutType LayoutType; ImGuiLayoutType ParentLayoutType; // Layout type of parent window at the time of Begin() int FocusCounterRegular; // (Legacy Focus/Tabbing system) Sequential counter, start at -1 and increase as assigned via FocusableItemRegister() (FIXME-NAV: Needs redesign) int FocusCounterTabStop; // (Legacy Focus/Tabbing system) Same, but only count widgets which you can Tab through. // Local parameters stacks // We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings. ImGuiItemFlags ItemFlags; // == ItemFlagsStack.back() [empty == ImGuiItemFlags_Default] float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window float TextWrapPos; // == TextWrapPosStack.back() [empty == -1.0f] ImVectorItemFlagsStack; ImVector ItemWidthStack; ImVector TextWrapPosStack; ImVectorGroupStack; short StackSizesBackup[6]; // Store size of various stacks for asserting ImGuiWindowTempData() { CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f); CurrLineSize = PrevLineSize = ImVec2(0.0f, 0.0f); CurrLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f; Indent = ImVec1(0.0f); ColumnsOffset = ImVec1(0.0f); GroupOffset = ImVec1(0.0f); LastItemId = 0; LastItemStatusFlags = ImGuiItemStatusFlags_None; LastItemRect = LastItemDisplayRect = ImRect(); NavLayerActiveMask = NavLayerActiveMaskNext = 0x00; NavLayerCurrent = ImGuiNavLayer_Main; NavLayerCurrentMask = (1 << ImGuiNavLayer_Main); NavFocusScopeIdCurrent = 0; NavHideHighlightOneFrame = false; NavHasScroll = false; MenuBarAppending = false; MenuBarOffset = ImVec2(0.0f, 0.0f); TreeDepth = 0; TreeJumpToParentOnPopMask = 0x00; StateStorage = NULL; CurrentColumns = NULL; LayoutType = ParentLayoutType = ImGuiLayoutType_Vertical; FocusCounterRegular = FocusCounterTabStop = -1; ItemFlags = ImGuiItemFlags_Default_; ItemWidth = 0.0f; TextWrapPos = -1.0f; memset(StackSizesBackup, 0, sizeof(StackSizesBackup)); } }; // Storage for one window struct IMGUI_API ImGuiWindow { char* Name; // Window name, owned by the window. ImGuiID ID; // == ImHashStr(Name) ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_ ImVec2 Pos; // Position (always rounded-up to nearest pixel) ImVec2 Size; // Current size (==SizeFull or collapsed title bar size) ImVec2 SizeFull; // Size when non collapsed ImVec2 ContentSize; // Size of contents/scrollable client area (calculated from the extents reach of the cursor) from previous frame. Does not include window decoration or window padding. ImVec2 ContentSizeExplicit; // Size of contents/scrollable client area explicitly request by the user via SetNextWindowContentSize(). ImVec2 WindowPadding; // Window padding at the time of Begin(). float WindowRounding; // Window rounding at the time of Begin(). float WindowBorderSize; // Window border size at the time of Begin(). int NameBufLen; // Size of buffer storing Name. May be larger than strlen(Name)! ImGuiID MoveId; // == window->GetID("#MOVE") ImGuiID ChildId; // ID of corresponding item in parent window (for navigation to return from child window to parent window) ImVec2 Scroll; ImVec2 ScrollMax; ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change) ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered ImVec2 ScrollbarSizes; // Size taken by scrollbars on each axis bool ScrollbarX, ScrollbarY; // Are scrollbars visible? bool Active; // Set to true on Begin(), unless Collapsed bool WasActive; bool WriteAccessed; // Set to true when any widget access the current window bool Collapsed; // Set when collapsing window to become only title-bar bool WantCollapseToggle; bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed) bool Appearing; // Set during the frame where the window is appearing (or re-appearing) bool Hidden; // Do not display (== (HiddenFrames*** > 0)) bool IsFallbackWindow; // Set on the "Debug##Default" window. bool HasCloseButton; // Set when the window has a close button (p_open != NULL) signed char ResizeBorderHeld; // Current border being held for resize (-1: none, otherwise 0-3) short BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs) short BeginOrderWithinParent; // Order within immediate parent window, if we are a child window. Otherwise 0. short BeginOrderWithinContext; // Order within entire imgui context. This is mostly used for debugging submission order related issues. ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling) ImS8 AutoFitFramesX, AutoFitFramesY; ImS8 AutoFitChildAxises; bool AutoFitOnlyGrows; ImGuiDir AutoPosLastDirection; int HiddenFramesCanSkipItems; // Hide the window for N frames int HiddenFramesCannotSkipItems; // Hide the window for N frames while allowing items to be submitted so we can measure their size ImGuiCond SetWindowPosAllowFlags; // store acceptable condition flags for SetNextWindowPos() use. ImGuiCond SetWindowSizeAllowFlags; // store acceptable condition flags for SetNextWindowSize() use. ImGuiCond SetWindowCollapsedAllowFlags; // store acceptable condition flags for SetNextWindowCollapsed() use. ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size) ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0,0) when positioning from top-left corner; ImVec2(0.5f,0.5f) for centering; ImVec2(1,1) for bottom right. ImVector IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack. (In theory this should be in the TempData structure) ImGuiWindowTempData DC; // Temporary per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the "DC" variable name. // The best way to understand what those rectangles are is to use the 'Metrics -> Tools -> Show windows rectangles' viewer. // The main 'OuterRect', omitted as a field, is window->Rect(). ImRect OuterRectClipped; // == Window->Rect() just after setup in Begin(). == window->Rect() for root window. ImRect InnerRect; // Inner rectangle (omit title bar, menu bar, scroll bar) ImRect InnerClipRect; // == InnerRect shrunk by WindowPadding*0.5f on each side, clipped within viewport or parent clip rect. ImRect WorkRect; // Cover the whole scrolling region, shrunk by WindowPadding*1.0f on each side. This is meant to replace ContentRegionRect over time (from 1.71+ onward). ImRect ClipRect; // Current clipping/scissoring rectangle, evolve as we are using PushClipRect(), etc. == DrawList->clip_rect_stack.back(). ImRect ContentRegionRect; // FIXME: This is currently confusing/misleading. It is essentially WorkRect but not handling of scrolling. We currently rely on it as right/bottom aligned sizing operation need some size to rely on. int LastFrameActive; // Last frame number the window was Active. float LastTimeActive; // Last timestamp the window was Active (using float as we don't need high precision there) float ItemWidthDefault; ImGuiStorage StateStorage; ImVector ColumnsStorage; float FontWindowScale; // User scale multiplier per-window, via SetWindowFontScale() int SettingsOffset; // Offset into SettingsWindows[] (offsets are always valid as we only grow the array from the back) ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer) ImDrawList DrawListInst; ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL. ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window. ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active. ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag. ImGuiWindow* NavLastChildNavWindow; // When going to the menu bar, we remember the child window we came from. (This could probably be made implicit if we kept g.Windows sorted by last focused including child window.) ImGuiID NavLastIds[ImGuiNavLayer_COUNT]; // Last known NavId for this window, per layer (0/1) ImRect NavRectRel[ImGuiNavLayer_COUNT]; // Reference rectangle, in window relative space bool MemoryCompacted; int MemoryDrawListIdxCapacity; int MemoryDrawListVtxCapacity; public: ImGuiWindow(ImGuiContext* context, const char* name); ~ImGuiWindow(); ImGuiID GetID(const char* str, const char* str_end = NULL); ImGuiID GetID(const void* ptr); ImGuiID GetID(int n); ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL); ImGuiID GetIDNoKeepAlive(const void* ptr); ImGuiID GetIDNoKeepAlive(int n); ImGuiID GetIDFromRectangle(const ImRect& r_abs); // We don't use g.FontSize because the window may be != g.CurrentWidow. ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x+Size.x, Pos.y+Size.y); } float CalcFontSize() const { ImGuiContext& g = *GImGui; float scale = g.FontBaseSize * FontWindowScale; if (ParentWindow) scale *= ParentWindow->FontWindowScale; return scale; } float TitleBarHeight() const { ImGuiContext& g = *GImGui; return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + g.Style.FramePadding.y * 2.0f; } ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); } float MenuBarHeight() const { ImGuiContext& g = *GImGui; return (Flags & ImGuiWindowFlags_MenuBar) ? DC.MenuBarOffset.y + CalcFontSize() + g.Style.FramePadding.y * 2.0f : 0.0f; } ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); } }; // Backup and restore just enough data to be able to use IsItemHovered() on item A after another B in the same window has overwritten the data. struct ImGuiItemHoveredDataBackup { ImGuiID LastItemId; ImGuiItemStatusFlags LastItemStatusFlags; ImRect LastItemRect; ImRect LastItemDisplayRect; ImGuiItemHoveredDataBackup() { Backup(); } void Backup() { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemStatusFlags = window->DC.LastItemStatusFlags; LastItemRect = window->DC.LastItemRect; LastItemDisplayRect = window->DC.LastItemDisplayRect; } void Restore() const { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemStatusFlags = LastItemStatusFlags; window->DC.LastItemRect = LastItemRect; window->DC.LastItemDisplayRect = LastItemDisplayRect; } }; //----------------------------------------------------------------------------- // Tab bar, tab item //----------------------------------------------------------------------------- // Extend ImGuiTabBarFlags_ enum ImGuiTabBarFlagsPrivate_ { ImGuiTabBarFlags_DockNode = 1 << 20, // Part of a dock node [we don't use this in the master branch but it facilitate branch syncing to keep this around] ImGuiTabBarFlags_IsFocused = 1 << 21, ImGuiTabBarFlags_SaveSettings = 1 << 22 // FIXME: Settings are handled by the docking system, this only request the tab bar to mark settings dirty when reordering tabs }; // Extend ImGuiTabItemFlags_ enum ImGuiTabItemFlagsPrivate_ { ImGuiTabItemFlags_NoCloseButton = 1 << 20 // Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout) }; // Storage for one active tab item (sizeof() 26~32 bytes) struct ImGuiTabItem { ImGuiID ID; ImGuiTabItemFlags Flags; int LastFrameVisible; int LastFrameSelected; // This allows us to infer an ordered list of the last activated tabs with little maintenance int NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames float Offset; // Position relative to beginning of tab float Width; // Width currently displayed float ContentWidth; // Width of actual contents, stored during BeginTabItem() call ImGuiTabItem() { ID = 0; Flags = ImGuiTabItemFlags_None; LastFrameVisible = LastFrameSelected = -1; NameOffset = -1; Offset = Width = ContentWidth = 0.0f; } }; // Storage for a tab bar (sizeof() 92~96 bytes) struct ImGuiTabBar { ImVector Tabs; ImGuiID ID; // Zero for tab-bars used by docking ImGuiID SelectedTabId; // Selected tab/window ImGuiID NextSelectedTabId; ImGuiID VisibleTabId; // Can occasionally be != SelectedTabId (e.g. when previewing contents for CTRL+TAB preview) int CurrFrameVisible; int PrevFrameVisible; ImRect BarRect; float LastTabContentHeight; // Record the height of contents submitted below the tab bar float OffsetMax; // Distance from BarRect.Min.x, locked during layout float OffsetMaxIdeal; // Ideal offset if all tabs were visible and not clipped float OffsetNextTab; // Distance from BarRect.Min.x, incremented with each BeginTabItem() call, not used if ImGuiTabBarFlags_Reorderable if set. float ScrollingAnim; float ScrollingTarget; float ScrollingTargetDistToVisibility; float ScrollingSpeed; ImGuiTabBarFlags Flags; ImGuiID ReorderRequestTabId; ImS8 ReorderRequestDir; bool WantLayout; bool VisibleTabWasSubmitted; short LastTabItemIdx; // For BeginTabItem()/EndTabItem() ImVec2 FramePadding; // style.FramePadding locked at the time of BeginTabBar() ImGuiTextBuffer TabsNames; // For non-docking tab bar we re-append names in a contiguous buffer. ImGuiTabBar(); int GetTabOrder(const ImGuiTabItem* tab) const { return Tabs.index_from_ptr(tab); } const char* GetTabName(const ImGuiTabItem* tab) const { IM_ASSERT(tab->NameOffset != -1 && tab->NameOffset < TabsNames.Buf.Size); return TabsNames.Buf.Data + tab->NameOffset; } }; //----------------------------------------------------------------------------- // Internal API // No guarantee of forward compatibility here. //----------------------------------------------------------------------------- namespace ImGui { // Windows // We should always have a CurrentWindow in the stack (there is an implicit "Debug" window) // If this ever crash because g.CurrentWindow is NULL it means that either // - ImGui::NewFrame() has never been called, which is illegal. // - You are calling ImGui functions after ImGui::EndFrame()/ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal. inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; } inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; } IMGUI_API ImGuiWindow* FindWindowByID(ImGuiID id); IMGUI_API ImGuiWindow* FindWindowByName(const char* name); IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window); IMGUI_API ImVec2 CalcWindowExpectedSize(ImGuiWindow* window); IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent); IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window); IMGUI_API ImRect GetWindowAllowedExtentRect(ImGuiWindow* window); IMGUI_API void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond = 0); IMGUI_API void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond = 0); IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0); // Windows: Display Order and Focus Order IMGUI_API void FocusWindow(ImGuiWindow* window); IMGUI_API void FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window); IMGUI_API void BringWindowToFocusFront(ImGuiWindow* window); IMGUI_API void BringWindowToDisplayFront(ImGuiWindow* window); IMGUI_API void BringWindowToDisplayBack(ImGuiWindow* window); // Fonts, drawing IMGUI_API void SetCurrentFont(ImFont* font); inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; } inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { IM_UNUSED(window); ImGuiContext& g = *GImGui; return &g.ForegroundDrawList; } // This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'docking' branches. // Init IMGUI_API void Initialize(ImGuiContext* context); IMGUI_API void Shutdown(ImGuiContext* context); // Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext(). // NewFrame IMGUI_API void UpdateHoveredWindowAndCaptureFlags(); IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window); IMGUI_API void UpdateMouseMovingWindowNewFrame(); IMGUI_API void UpdateMouseMovingWindowEndFrame(); // Settings IMGUI_API void MarkIniSettingsDirty(); IMGUI_API void MarkIniSettingsDirty(ImGuiWindow* window); IMGUI_API ImGuiWindowSettings* CreateNewWindowSettings(const char* name); IMGUI_API ImGuiWindowSettings* FindWindowSettings(ImGuiID id); IMGUI_API ImGuiWindowSettings* FindOrCreateWindowSettings(const char* name); IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name); // Scrolling IMGUI_API void SetScrollX(ImGuiWindow* window, float new_scroll_x); IMGUI_API void SetScrollY(ImGuiWindow* window, float new_scroll_y); IMGUI_API void SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio = 0.5f); IMGUI_API void SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio = 0.5f); IMGUI_API ImVec2 ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect); // Basic Accessors inline ImGuiID GetItemID() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemId; } inline ImGuiItemStatusFlags GetItemStatusFlags() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemStatusFlags; } inline ImGuiID GetActiveID() { ImGuiContext& g = *GImGui; return g.ActiveId; } inline ImGuiID GetFocusID() { ImGuiContext& g = *GImGui; return g.NavId; } IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window); IMGUI_API void SetFocusID(ImGuiID id, ImGuiWindow* window); IMGUI_API void ClearActiveID(); IMGUI_API ImGuiID GetHoveredID(); IMGUI_API void SetHoveredID(ImGuiID id); IMGUI_API void KeepAliveID(ImGuiID id); IMGUI_API void MarkItemEdited(ImGuiID id); // Mark data associated to given item as "edited", used by IsItemDeactivatedAfterEdit() function. IMGUI_API void PushOverrideID(ImGuiID id); // Push given value at the top of the ID stack (whereas PushID combines old and new hashes) // Basic Helpers for widget code IMGUI_API void ItemSize(const ImVec2& size, float text_baseline_y = -1.0f); IMGUI_API void ItemSize(const ImRect& bb, float text_baseline_y = -1.0f); IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL); IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id); IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged); IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id); // Return true if focus is requested IMGUI_API void FocusableItemUnregister(ImGuiWindow* window); IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_w, float default_h); IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x); IMGUI_API void PushMultiItemsWidths(int components, float width_full); IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled); IMGUI_API void PopItemFlag(); IMGUI_API bool IsItemToggledSelection(); // Was the last item selection toggled? (after Selectable(), TreeNode() etc. We only returns toggle _event_ in order to handle clipping correctly) IMGUI_API ImVec2 GetContentRegionMaxAbs(); IMGUI_API void ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess); // Logging/Capture IMGUI_API void LogBegin(ImGuiLogType type, int auto_open_depth); // -> BeginCapture() when we design v2 api, for now stay under the radar by using the old name. IMGUI_API void LogToBuffer(int auto_open_depth = -1); // Start logging/capturing to internal buffer // Popups, Modals, Tooltips IMGUI_API bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags); IMGUI_API void OpenPopupEx(ImGuiID id); IMGUI_API void ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup); IMGUI_API void ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup); IMGUI_API bool IsPopupOpen(ImGuiID id); // Test for id within current popup stack level (currently begin-ed into); this doesn't scan the whole popup stack! IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags); IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags); IMGUI_API ImGuiWindow* GetTopMostPopupModal(); IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window); IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy = ImGuiPopupPositionPolicy_Default); // Navigation IMGUI_API void NavInitWindow(ImGuiWindow* window, bool force_reinit); IMGUI_API bool NavMoveRequestButNoResultYet(); IMGUI_API void NavMoveRequestCancel(); IMGUI_API void NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const ImRect& bb_rel, ImGuiNavMoveFlags move_flags); IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags); IMGUI_API float GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode); IMGUI_API ImVec2 GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor = 0.0f, float fast_factor = 0.0f); IMGUI_API int CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, float repeat_rate); IMGUI_API void ActivateItem(ImGuiID id); // Remotely activate a button, checkbox, tree node etc. given its unique ID. activation is queued and processed on the next frame when the item is encountered again. IMGUI_API void SetNavID(ImGuiID id, int nav_layer, ImGuiID focus_scope_id); IMGUI_API void SetNavIDWithRectRel(ImGuiID id, int nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel); // Focus scope (WIP) IMGUI_API void PushFocusScope(ImGuiID id); // Note: this is storing in same stack as IDStack, so Push/Pop mismatch will be reported there. IMGUI_API void PopFocusScope(); inline ImGuiID GetFocusScopeID() { ImGuiContext& g = *GImGui; return g.NavFocusScopeId; } // Inputs // FIXME: Eventually we should aim to move e.g. IsActiveIdUsingKey() into IsKeyXXX functions. inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; } inline bool IsActiveIdUsingNavInput(ImGuiNavInput input) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavInputMask & (1 << input)) != 0; } inline bool IsActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; IM_ASSERT(key < 64); return (g.ActiveIdUsingKeyInputMask & ((ImU64)1 << key)) != 0; } IMGUI_API bool IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f); inline bool IsKeyPressedMap(ImGuiKey key, bool repeat = true) { ImGuiContext& g = *GImGui; const int key_index = g.IO.KeyMap[key]; return (key_index >= 0) ? IsKeyPressed(key_index, repeat) : false; } inline bool IsNavInputDown(ImGuiNavInput n) { ImGuiContext& g = *GImGui; return g.IO.NavInputs[n] > 0.0f; } inline bool IsNavInputTest(ImGuiNavInput n, ImGuiInputReadMode rm) { return (GetNavInputAmount(n, rm) > 0.0f); } // Drag and Drop IMGUI_API bool BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id); IMGUI_API void ClearDragDrop(); IMGUI_API bool IsDragDropPayloadBeingAccepted(); // Internal Columns API (this is not exposed because we will encourage transitioning to the Tables api) IMGUI_API void BeginColumns(const char* str_id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns(). IMGUI_API void EndColumns(); // close columns IMGUI_API void PushColumnClipRect(int column_index); IMGUI_API void PushColumnsBackground(); IMGUI_API void PopColumnsBackground(); IMGUI_API ImGuiID GetColumnsID(const char* str_id, int count); IMGUI_API ImGuiColumns* FindOrCreateColumns(ImGuiWindow* window, ImGuiID id); IMGUI_API float GetColumnOffsetFromNorm(const ImGuiColumns* columns, float offset_norm); IMGUI_API float GetColumnNormFromOffset(const ImGuiColumns* columns, float offset); // Tab Bars IMGUI_API bool BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags); IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id); IMGUI_API void TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id); IMGUI_API void TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab); IMGUI_API void TabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir); IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags); IMGUI_API ImVec2 TabItemCalcSize(const char* label, bool has_close_button); IMGUI_API void TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col); IMGUI_API bool TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id); // Render helpers // AVOID USING OUTSIDE OF IMGUI.CPP! NOT FOR PUBLIC CONSUMPTION. THOSE FUNCTIONS ARE A MESS. THEIR SIGNATURE AND BEHAVIOR WILL CHANGE, THEY NEED TO BE REFACTORED INTO SOMETHING DECENT. // NB: All position are in absolute pixels coordinates (we are never using window coordinates internally) IMGUI_API void RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true); IMGUI_API void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width); IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0,0), const ImRect* clip_rect = NULL); IMGUI_API void RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0, 0), const ImRect* clip_rect = NULL); IMGUI_API void RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end, const ImVec2* text_size_if_known); IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f); IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f); IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0); IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col, float sz); IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text. IMGUI_API void LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL); // Render helpers (those functions don't access any ImGui state!) IMGUI_API void RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale = 1.0f); IMGUI_API void RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col); IMGUI_API void RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow); IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col); IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding); #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS // [1.71: 2019/06/07: Updating prototypes of some of the internal functions. Leaving those for reference for a short while] inline void RenderArrow(ImVec2 pos, ImGuiDir dir, float scale=1.0f) { ImGuiWindow* window = GetCurrentWindow(); RenderArrow(window->DrawList, pos, GetColorU32(ImGuiCol_Text), dir, scale); } inline void RenderBullet(ImVec2 pos) { ImGuiWindow* window = GetCurrentWindow(); RenderBullet(window->DrawList, pos, GetColorU32(ImGuiCol_Text)); } #endif // Widgets IMGUI_API void TextEx(const char* text, const char* text_end = NULL, ImGuiTextFlags flags = 0); IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0,0), ImGuiButtonFlags flags = 0); IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos); IMGUI_API bool CollapseButton(ImGuiID id, const ImVec2& pos); IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0); IMGUI_API void Scrollbar(ImGuiAxis axis); IMGUI_API bool ScrollbarEx(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* p_scroll_v, float avail_v, float contents_v, ImDrawCornerFlags rounding_corners); IMGUI_API ImGuiID GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis); IMGUI_API ImGuiID GetWindowResizeID(ImGuiWindow* window, int n); // 0..3: corners, 4..7: borders IMGUI_API void SeparatorEx(ImGuiSeparatorFlags flags); // Widgets low-level behaviors IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0); IMGUI_API bool DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v_speed, const void* p_min, const void* p_max, const char* format, float power, ImGuiDragFlags flags); IMGUI_API bool SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb); IMGUI_API bool SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend = 0.0f, float hover_visibility_delay = 0.0f); IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL); IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextItemOpen() data, if any. May return true when logging IMGUI_API void TreePushOverrideID(ImGuiID id); // Template functions are instantiated in imgui_widgets.cpp for a finite number of types. // To use them externally (for custom widget) you may need an "extern template" statement in your code in order to link to existing instances and silence Clang warnings (see #2036). // e.g. " extern template IMGUI_API float RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, float v); " template IMGUI_API bool DragBehaviorT(ImGuiDataType data_type, T* v, float v_speed, T v_min, T v_max, const char* format, float power, ImGuiDragFlags flags); template IMGUI_API bool SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, T* v, T v_min, T v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb); template IMGUI_API float SliderCalcRatioFromValueT(ImGuiDataType data_type, T v, T v_min, T v_max, float power, float linear_zero_pos); template IMGUI_API T RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, T v); // Data type helpers IMGUI_API const ImGuiDataTypeInfo* DataTypeGetInfo(ImGuiDataType data_type); IMGUI_API int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* p_data, const char* format); IMGUI_API void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, void* arg_1, const void* arg_2); IMGUI_API bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* p_data, const char* format); // InputText IMGUI_API bool InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); IMGUI_API bool TempInputTextScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format); inline bool TempInputTextIsActive(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.ActiveId == id && g.TempInputTextId == id); } // Color IMGUI_API void ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags); IMGUI_API void ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags); IMGUI_API void ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags); // Plot IMGUI_API void PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size); // Shade functions (write over already created vertices) IMGUI_API void ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1); IMGUI_API void ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp); // Garbage collection IMGUI_API void GcCompactTransientWindowBuffers(ImGuiWindow* window); IMGUI_API void GcAwakeTransientWindowBuffers(ImGuiWindow* window); // Debug Tools inline void DebugDrawItemRect(ImU32 col = IM_COL32(255,0,0,255)) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; GetForegroundDrawList(window)->AddRect(window->DC.LastItemRect.Min, window->DC.LastItemRect.Max, col); } inline void DebugStartItemPicker() { ImGuiContext& g = *GImGui; g.DebugItemPickerActive = true; } } // namespace ImGui // ImFontAtlas internals IMGUI_API bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas); IMGUI_API void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas); IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent); IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque); IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas); IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor); IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride); // Debug Tools // Use 'Metrics->Tools->Item Picker' to break into the call-stack of a specific item. #ifndef IM_DEBUG_BREAK #if defined(__clang__) #define IM_DEBUG_BREAK() __builtin_debugtrap() #elif defined (_MSC_VER) #define IM_DEBUG_BREAK() __debugbreak() #else #define IM_DEBUG_BREAK() IM_ASSERT(0) // It is expected that you define IM_DEBUG_BREAK() into something that will break nicely in a debugger! #endif #endif // #ifndef IM_DEBUG_BREAK // Test Engine Hooks (imgui_tests) //#define IMGUI_ENABLE_TEST_ENGINE #ifdef IMGUI_ENABLE_TEST_ENGINE extern void ImGuiTestEngineHook_PreNewFrame(ImGuiContext* ctx); extern void ImGuiTestEngineHook_PostNewFrame(ImGuiContext* ctx); extern void ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id); extern void ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, ImGuiItemStatusFlags flags); extern void ImGuiTestEngineHook_Log(ImGuiContext* ctx, const char* fmt, ...); #define IMGUI_TEST_ENGINE_ITEM_ADD(_BB, _ID) ImGuiTestEngineHook_ItemAdd(&g, _BB, _ID) // Register item bounding box #define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS) // Register item label and status flags (optional) #define IMGUI_TEST_ENGINE_LOG(_FMT, ...) ImGuiTestEngineHook_Log(&g, _FMT, __VA_ARGS__) // Custom log entry from user land into test log #else #define IMGUI_TEST_ENGINE_ITEM_ADD(_BB, _ID) do { } while (0) #define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS) do { } while (0) #define IMGUI_TEST_ENGINE_LOG(_FMT, ...) do { } while (0) #endif #if defined(__clang__) #pragma clang diagnostic pop #elif defined(__GNUC__) #pragma GCC diagnostic pop #endif #ifdef _MSC_VER #pragma warning (pop) #endif #endif // #ifndef IMGUI_DISABLE goxel-0.11.0/ext_src/imgui/imgui_widgets.cpp000066400000000000000000013127621435762723100210620ustar00rootroot00000000000000// dear imgui, v1.75 // (widgets code) /* Index of this file: // [SECTION] Forward Declarations // [SECTION] Widgets: Text, etc. // [SECTION] Widgets: Main (Button, Image, Checkbox, RadioButton, ProgressBar, Bullet, etc.) // [SECTION] Widgets: Low-level Layout helpers (Spacing, Dummy, NewLine, Separator, etc.) // [SECTION] Widgets: ComboBox // [SECTION] Data Type and Data Formatting Helpers // [SECTION] Widgets: DragScalar, DragFloat, DragInt, etc. // [SECTION] Widgets: SliderScalar, SliderFloat, SliderInt, etc. // [SECTION] Widgets: InputScalar, InputFloat, InputInt, etc. // [SECTION] Widgets: InputText, InputTextMultiline // [SECTION] Widgets: ColorEdit, ColorPicker, ColorButton, etc. // [SECTION] Widgets: TreeNode, CollapsingHeader, etc. // [SECTION] Widgets: Selectable // [SECTION] Widgets: ListBox // [SECTION] Widgets: PlotLines, PlotHistogram // [SECTION] Widgets: Value helpers // [SECTION] Widgets: MenuItem, BeginMenu, EndMenu, etc. // [SECTION] Widgets: BeginTabBar, EndTabBar, etc. // [SECTION] Widgets: BeginTabItem, EndTabItem, etc. // [SECTION] Widgets: Columns, BeginColumns, EndColumns, etc. */ #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) #define _CRT_SECURE_NO_WARNINGS #endif #include "imgui.h" #ifndef IMGUI_DISABLE #ifndef IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS #endif #include "imgui_internal.h" #include // toupper #if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier #include // intptr_t #else #include // intptr_t #endif // Visual Studio warnings #ifdef _MSC_VER #pragma warning (disable: 4127) // condition expression is constant #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen #if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later #pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types #endif #endif // Clang/GCC warnings with -Weverything #if defined(__clang__) #pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse. #pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok. #pragma clang diagnostic ignored "-Wformat-nonliteral" // warning : format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code. #pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness // #if __has_warning("-Wzero-as-null-pointer-constant") #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning : zero as null pointer constant // some standard header variations use #define NULL 0 #endif #if __has_warning("-Wdouble-promotion") #pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. #endif #elif defined(__GNUC__) #pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind #pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked #pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead #endif //------------------------------------------------------------------------- // Data //------------------------------------------------------------------------- // Those MIN/MAX values are not define because we need to point to them static const signed char IM_S8_MIN = -128; static const signed char IM_S8_MAX = 127; static const unsigned char IM_U8_MIN = 0; static const unsigned char IM_U8_MAX = 0xFF; static const signed short IM_S16_MIN = -32768; static const signed short IM_S16_MAX = 32767; static const unsigned short IM_U16_MIN = 0; static const unsigned short IM_U16_MAX = 0xFFFF; static const ImS32 IM_S32_MIN = INT_MIN; // (-2147483647 - 1), (0x80000000); static const ImS32 IM_S32_MAX = INT_MAX; // (2147483647), (0x7FFFFFFF) static const ImU32 IM_U32_MIN = 0; static const ImU32 IM_U32_MAX = UINT_MAX; // (0xFFFFFFFF) #ifdef LLONG_MIN static const ImS64 IM_S64_MIN = LLONG_MIN; // (-9223372036854775807ll - 1ll); static const ImS64 IM_S64_MAX = LLONG_MAX; // (9223372036854775807ll); #else static const ImS64 IM_S64_MIN = -9223372036854775807LL - 1; static const ImS64 IM_S64_MAX = 9223372036854775807LL; #endif static const ImU64 IM_U64_MIN = 0; #ifdef ULLONG_MAX static const ImU64 IM_U64_MAX = ULLONG_MAX; // (0xFFFFFFFFFFFFFFFFull); #else static const ImU64 IM_U64_MAX = (2ULL * 9223372036854775807LL + 1); #endif //------------------------------------------------------------------------- // [SECTION] Forward Declarations //------------------------------------------------------------------------- // For InputTextEx() static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data); static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end); static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL, ImVec2* out_offset = NULL, bool stop_on_new_line = false); //------------------------------------------------------------------------- // [SECTION] Widgets: Text, etc. //------------------------------------------------------------------------- // - TextEx() [Internal] // - TextUnformatted() // - Text() // - TextV() // - TextColored() // - TextColoredV() // - TextDisabled() // - TextDisabledV() // - TextWrapped() // - TextWrappedV() // - LabelText() // - LabelTextV() // - BulletText() // - BulletTextV() //------------------------------------------------------------------------- void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; ImGuiContext& g = *GImGui; IM_ASSERT(text != NULL); const char* text_begin = text; if (text_end == NULL) text_end = text + strlen(text); // FIXME-OPT const ImVec2 text_pos(window->DC.CursorPos.x, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset); const float wrap_pos_x = window->DC.TextWrapPos; const bool wrap_enabled = (wrap_pos_x >= 0.0f); if (text_end - text > 2000 && !wrap_enabled) { // Long text! // Perform manual coarse clipping to optimize for long multi-line text // - From this point we will only compute the width of lines that are visible. Optimization only available when word-wrapping is disabled. // - We also don't vertically center the text within the line full height, which is unlikely to matter because we are likely the biggest and only item on the line. // - We use memchr(), pay attention that well optimized versions of those str/mem functions are much faster than a casually written loop. const char* line = text; const float line_height = GetTextLineHeight(); ImVec2 text_size(0,0); // Lines to skip (can't skip when logging text) ImVec2 pos = text_pos; if (!g.LogEnabled) { int lines_skippable = (int)((window->ClipRect.Min.y - text_pos.y) / line_height); if (lines_skippable > 0) { int lines_skipped = 0; while (line < text_end && lines_skipped < lines_skippable) { const char* line_end = (const char*)memchr(line, '\n', text_end - line); if (!line_end) line_end = text_end; if ((flags & ImGuiTextFlags_NoWidthForLargeClippedText) == 0) text_size.x = ImMax(text_size.x, CalcTextSize(line, line_end).x); line = line_end + 1; lines_skipped++; } pos.y += lines_skipped * line_height; } } // Lines to render if (line < text_end) { ImRect line_rect(pos, pos + ImVec2(FLT_MAX, line_height)); while (line < text_end) { if (IsClippedEx(line_rect, 0, false)) break; const char* line_end = (const char*)memchr(line, '\n', text_end - line); if (!line_end) line_end = text_end; text_size.x = ImMax(text_size.x, CalcTextSize(line, line_end).x); RenderText(pos, line, line_end, false); line = line_end + 1; line_rect.Min.y += line_height; line_rect.Max.y += line_height; pos.y += line_height; } // Count remaining lines int lines_skipped = 0; while (line < text_end) { const char* line_end = (const char*)memchr(line, '\n', text_end - line); if (!line_end) line_end = text_end; if ((flags & ImGuiTextFlags_NoWidthForLargeClippedText) == 0) text_size.x = ImMax(text_size.x, CalcTextSize(line, line_end).x); line = line_end + 1; lines_skipped++; } pos.y += lines_skipped * line_height; } text_size.y = (pos - text_pos).y; ImRect bb(text_pos, text_pos + text_size); ItemSize(text_size, 0.0f); ItemAdd(bb, 0); } else { const float wrap_width = wrap_enabled ? CalcWrapWidthForPos(window->DC.CursorPos, wrap_pos_x) : 0.0f; const ImVec2 text_size = CalcTextSize(text_begin, text_end, false, wrap_width); ImRect bb(text_pos, text_pos + text_size); ItemSize(text_size, 0.0f); if (!ItemAdd(bb, 0)) return; // Render (we don't hide text after ## in this end-user function) RenderTextWrapped(bb.Min, text_begin, text_end, wrap_width); } } void ImGui::TextUnformatted(const char* text, const char* text_end) { TextEx(text, text_end, ImGuiTextFlags_NoWidthForLargeClippedText); } void ImGui::Text(const char* fmt, ...) { va_list args; va_start(args, fmt); TextV(fmt, args); va_end(args); } void ImGui::TextV(const char* fmt, va_list args) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; ImGuiContext& g = *GImGui; const char* text_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); TextEx(g.TempBuffer, text_end, ImGuiTextFlags_NoWidthForLargeClippedText); } void ImGui::TextColored(const ImVec4& col, const char* fmt, ...) { va_list args; va_start(args, fmt); TextColoredV(col, fmt, args); va_end(args); } void ImGui::TextColoredV(const ImVec4& col, const char* fmt, va_list args) { PushStyleColor(ImGuiCol_Text, col); TextV(fmt, args); PopStyleColor(); } void ImGui::TextDisabled(const char* fmt, ...) { va_list args; va_start(args, fmt); TextDisabledV(fmt, args); va_end(args); } void ImGui::TextDisabledV(const char* fmt, va_list args) { PushStyleColor(ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled]); TextV(fmt, args); PopStyleColor(); } void ImGui::TextWrapped(const char* fmt, ...) { va_list args; va_start(args, fmt); TextWrappedV(fmt, args); va_end(args); } void ImGui::TextWrappedV(const char* fmt, va_list args) { ImGuiWindow* window = GetCurrentWindow(); bool need_backup = (window->DC.TextWrapPos < 0.0f); // Keep existing wrap position if one is already set if (need_backup) PushTextWrapPos(0.0f); TextV(fmt, args); if (need_backup) PopTextWrapPos(); } void ImGui::LabelText(const char* label, const char* fmt, ...) { va_list args; va_start(args, fmt); LabelTextV(label, fmt, args); va_end(args); } // Add a label+text combo aligned to other label+value widgets void ImGui::LabelTextV(const char* label, const char* fmt, va_list args) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const float w = CalcItemWidth(); const ImVec2 label_size = CalcTextSize(label, NULL, true); const ImRect value_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2)); const ImRect total_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w + (label_size.x > 0.0f ? style.ItemInnerSpacing.x : 0.0f), style.FramePadding.y*2) + label_size); ItemSize(total_bb, style.FramePadding.y); if (!ItemAdd(total_bb, 0)) return; // Render const char* value_text_begin = &g.TempBuffer[0]; const char* value_text_end = value_text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); RenderTextClipped(value_bb.Min, value_bb.Max, value_text_begin, value_text_end, NULL, ImVec2(0.0f,0.5f)); if (label_size.x > 0.0f) RenderText(ImVec2(value_bb.Max.x + style.ItemInnerSpacing.x, value_bb.Min.y + style.FramePadding.y), label); } void ImGui::BulletText(const char* fmt, ...) { va_list args; va_start(args, fmt); BulletTextV(fmt, args); va_end(args); } // Text with a little bullet aligned to the typical tree node. void ImGui::BulletTextV(const char* fmt, va_list args) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const char* text_begin = g.TempBuffer; const char* text_end = text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); const ImVec2 label_size = CalcTextSize(text_begin, text_end, false); const ImVec2 total_size = ImVec2(g.FontSize + (label_size.x > 0.0f ? (label_size.x + style.FramePadding.x * 2) : 0.0f), label_size.y); // Empty text doesn't add padding ImVec2 pos = window->DC.CursorPos; pos.y += window->DC.CurrLineTextBaseOffset; ItemSize(total_size, 0.0f); const ImRect bb(pos, pos + total_size); if (!ItemAdd(bb, 0)) return; // Render ImU32 text_col = GetColorU32(ImGuiCol_Text); RenderBullet(window->DrawList, bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, g.FontSize*0.5f), text_col); RenderText(bb.Min + ImVec2(g.FontSize + style.FramePadding.x * 2, 0.0f), text_begin, text_end, false); } //------------------------------------------------------------------------- // [SECTION] Widgets: Main //------------------------------------------------------------------------- // - ButtonBehavior() [Internal] // - Button() // - SmallButton() // - InvisibleButton() // - ArrowButton() // - CloseButton() [Internal] // - CollapseButton() [Internal] // - ScrollbarEx() [Internal] // - Scrollbar() [Internal] // - Image() // - ImageButton() // - Checkbox() // - CheckboxFlags() // - RadioButton() // - ProgressBar() // - Bullet() //------------------------------------------------------------------------- // The ButtonBehavior() function is key to many interactions and used by many/most widgets. // Because we handle so many cases (keyboard/gamepad navigation, drag and drop) and many specific behavior (via ImGuiButtonFlags_), // this code is a little complex. // By far the most common path is interacting with the Mouse using the default ImGuiButtonFlags_PressedOnClickRelease button behavior. // See the series of events below and the corresponding state reported by dear imgui: //------------------------------------------------------------------------------------------------------------------------------------------------ // with PressedOnClickRelease: return-value IsItemHovered() IsItemActive() IsItemActivated() IsItemDeactivated() IsItemClicked() // Frame N+0 (mouse is outside bb) - - - - - - // Frame N+1 (mouse moves inside bb) - true - - - - // Frame N+2 (mouse button is down) - true true true - true // Frame N+3 (mouse button is down) - true true - - - // Frame N+4 (mouse moves outside bb) - - true - - - // Frame N+5 (mouse moves inside bb) - true true - - - // Frame N+6 (mouse button is released) true true - - true - // Frame N+7 (mouse button is released) - true - - - - // Frame N+8 (mouse moves outside bb) - - - - - - //------------------------------------------------------------------------------------------------------------------------------------------------ // with PressedOnClick: return-value IsItemHovered() IsItemActive() IsItemActivated() IsItemDeactivated() IsItemClicked() // Frame N+2 (mouse button is down) true true true true - true // Frame N+3 (mouse button is down) - true true - - - // Frame N+6 (mouse button is released) - true - - true - // Frame N+7 (mouse button is released) - true - - - - //------------------------------------------------------------------------------------------------------------------------------------------------ // with PressedOnRelease: return-value IsItemHovered() IsItemActive() IsItemActivated() IsItemDeactivated() IsItemClicked() // Frame N+2 (mouse button is down) - true - - - true // Frame N+3 (mouse button is down) - true - - - - // Frame N+6 (mouse button is released) true true - - - - // Frame N+7 (mouse button is released) - true - - - - //------------------------------------------------------------------------------------------------------------------------------------------------ // with PressedOnDoubleClick: return-value IsItemHovered() IsItemActive() IsItemActivated() IsItemDeactivated() IsItemClicked() // Frame N+0 (mouse button is down) - true - - - true // Frame N+1 (mouse button is down) - true - - - - // Frame N+2 (mouse button is released) - true - - - - // Frame N+3 (mouse button is released) - true - - - - // Frame N+4 (mouse button is down) true true true true - true // Frame N+5 (mouse button is down) - true true - - - // Frame N+6 (mouse button is released) - true - - true - // Frame N+7 (mouse button is released) - true - - - - //------------------------------------------------------------------------------------------------------------------------------------------------ // Note that some combinations are supported, // - PressedOnDragDropHold can generally be associated with any flag. // - PressedOnDoubleClick can be associated by PressedOnClickRelease/PressedOnRelease, in which case the second release event won't be reported. //------------------------------------------------------------------------------------------------------------------------------------------------ // The behavior of the return-value changes when ImGuiButtonFlags_Repeat is set: // Repeat+ Repeat+ Repeat+ Repeat+ // PressedOnClickRelease PressedOnClick PressedOnRelease PressedOnDoubleClick //------------------------------------------------------------------------------------------------------------------------------------------------- // Frame N+0 (mouse button is down) - true - true // ... - - - - // Frame N + RepeatDelay true true - true // ... - - - - // Frame N + RepeatDelay + RepeatRate*N true true - true //------------------------------------------------------------------------------------------------------------------------------------------------- bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); if (flags & ImGuiButtonFlags_Disabled) { if (out_hovered) *out_hovered = false; if (out_held) *out_held = false; if (g.ActiveId == id) ClearActiveID(); return false; } // Default only reacts to left mouse button if ((flags & ImGuiButtonFlags_MouseButtonMask_) == 0) flags |= ImGuiButtonFlags_MouseButtonDefault_; // Default behavior requires click + release inside bounding box if ((flags & ImGuiButtonFlags_PressedOnMask_) == 0) flags |= ImGuiButtonFlags_PressedOnDefault_; ImGuiWindow* backup_hovered_window = g.HoveredWindow; const bool flatten_hovered_children = (flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredRootWindow == window; if (flatten_hovered_children) g.HoveredWindow = window; #ifdef IMGUI_ENABLE_TEST_ENGINE if (id != 0 && window->DC.LastItemId != id) ImGuiTestEngineHook_ItemAdd(&g, bb, id); #endif bool pressed = false; bool hovered = ItemHoverable(bb, id); // Drag source doesn't report as hovered if (hovered && g.DragDropActive && g.DragDropPayload.SourceId == id && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoDisableHover)) hovered = false; // Special mode for Drag and Drop where holding button pressed for a long time while dragging another item triggers the button if (g.DragDropActive && (flags & ImGuiButtonFlags_PressedOnDragDropHold) && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoHoldToOpenOthers)) if (IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) { hovered = true; SetHoveredID(id); if (CalcTypematicRepeatAmount(g.HoveredIdTimer + 0.0001f - g.IO.DeltaTime, g.HoveredIdTimer + 0.0001f, 0.70f, 0.00f)) { pressed = true; FocusWindow(window); } } if (flatten_hovered_children) g.HoveredWindow = backup_hovered_window; // AllowOverlap mode (rarely used) requires previous frame HoveredId to be null or to match. This allows using patterns where a later submitted widget overlaps a previous one. if (hovered && (flags & ImGuiButtonFlags_AllowItemOverlap) && (g.HoveredIdPreviousFrame != id && g.HoveredIdPreviousFrame != 0)) hovered = false; // Mouse handling if (hovered) { if (!(flags & ImGuiButtonFlags_NoKeyModifiers) || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt)) { // Poll buttons int mouse_button_clicked = -1; int mouse_button_released = -1; if ((flags & ImGuiButtonFlags_MouseButtonLeft) && g.IO.MouseClicked[0]) { mouse_button_clicked = 0; } else if ((flags & ImGuiButtonFlags_MouseButtonRight) && g.IO.MouseClicked[1]) { mouse_button_clicked = 1; } else if ((flags & ImGuiButtonFlags_MouseButtonMiddle) && g.IO.MouseClicked[2]) { mouse_button_clicked = 2; } if ((flags & ImGuiButtonFlags_MouseButtonLeft) && g.IO.MouseReleased[0]) { mouse_button_released = 0; } else if ((flags & ImGuiButtonFlags_MouseButtonRight) && g.IO.MouseReleased[1]) { mouse_button_released = 1; } else if ((flags & ImGuiButtonFlags_MouseButtonMiddle) && g.IO.MouseReleased[2]) { mouse_button_released = 2; } if (mouse_button_clicked != -1 && g.ActiveId != id) { if (flags & (ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere)) { SetActiveID(id, window); g.ActiveIdMouseButton = mouse_button_clicked; if (!(flags & ImGuiButtonFlags_NoNavFocus)) SetFocusID(id, window); FocusWindow(window); } if ((flags & ImGuiButtonFlags_PressedOnClick) || ((flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDoubleClicked[mouse_button_clicked])) { pressed = true; if (flags & ImGuiButtonFlags_NoHoldingActiveId) ClearActiveID(); else SetActiveID(id, window); // Hold on ID g.ActiveIdMouseButton = mouse_button_clicked; FocusWindow(window); } } if ((flags & ImGuiButtonFlags_PressedOnRelease) && mouse_button_released != -1) { // Repeat mode trumps on release behavior if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[mouse_button_released] >= g.IO.KeyRepeatDelay)) pressed = true; ClearActiveID(); } // 'Repeat' mode acts when held regardless of _PressedOn flags (see table above). // Relies on repeat logic of IsMouseClicked() but we may as well do it ourselves if we end up exposing finer RepeatDelay/RepeatRate settings. if (g.ActiveId == id && (flags & ImGuiButtonFlags_Repeat)) if (g.IO.MouseDownDuration[g.ActiveIdMouseButton] > 0.0f && IsMouseClicked(g.ActiveIdMouseButton, true)) pressed = true; } if (pressed) g.NavDisableHighlight = true; } // Gamepad/Keyboard navigation // We report navigated item as hovered but we don't set g.HoveredId to not interfere with mouse. if (g.NavId == id && !g.NavDisableHighlight && g.NavDisableMouseHover && (g.ActiveId == 0 || g.ActiveId == id || g.ActiveId == window->MoveId)) if (!(flags & ImGuiButtonFlags_NoHoveredOnNav)) hovered = true; if (g.NavActivateDownId == id) { bool nav_activated_by_code = (g.NavActivateId == id); bool nav_activated_by_inputs = IsNavInputTest(ImGuiNavInput_Activate, (flags & ImGuiButtonFlags_Repeat) ? ImGuiInputReadMode_Repeat : ImGuiInputReadMode_Pressed); if (nav_activated_by_code || nav_activated_by_inputs) pressed = true; if (nav_activated_by_code || nav_activated_by_inputs || g.ActiveId == id) { // Set active id so it can be queried by user via IsItemActive(), equivalent of holding the mouse button. g.NavActivateId = id; // This is so SetActiveId assign a Nav source SetActiveID(id, window); if ((nav_activated_by_code || nav_activated_by_inputs) && !(flags & ImGuiButtonFlags_NoNavFocus)) SetFocusID(id, window); } } bool held = false; if (g.ActiveId == id) { if (g.ActiveIdSource == ImGuiInputSource_Mouse) { if (g.ActiveIdIsJustActivated) g.ActiveIdClickOffset = g.IO.MousePos - bb.Min; const int mouse_button = g.ActiveIdMouseButton; IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT); if (g.IO.MouseDown[mouse_button]) { held = true; } else { bool release_in = hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease) != 0; bool release_anywhere = (flags & ImGuiButtonFlags_PressedOnClickReleaseAnywhere) != 0; if ((release_in || release_anywhere) && !g.DragDropActive) { bool is_double_click_release = (flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDownWasDoubleClick[mouse_button]; bool is_repeating_already = (flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[mouse_button] >= g.IO.KeyRepeatDelay; // Repeat mode trumps if (!is_double_click_release && !is_repeating_already) pressed = true; } ClearActiveID(); } if (!(flags & ImGuiButtonFlags_NoNavFocus)) g.NavDisableHighlight = true; } else if (g.ActiveIdSource == ImGuiInputSource_Nav) { if (g.NavActivateDownId != id) ClearActiveID(); } if (pressed) g.ActiveIdHasBeenPressedBefore = true; } if (out_hovered) *out_hovered = hovered; if (out_held) *out_held = held; return pressed; } bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags flags) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImGuiID id = window->GetID(label); const ImVec2 label_size = CalcTextSize(label, NULL, true); ImVec2 pos = window->DC.CursorPos; if ((flags & ImGuiButtonFlags_AlignTextBaseLine) && style.FramePadding.y < window->DC.CurrLineTextBaseOffset) // Try to vertically align buttons that are smaller/have no padding so that text baseline matches (bit hacky, since it shouldn't be a flag) pos.y += window->DC.CurrLineTextBaseOffset - style.FramePadding.y; ImVec2 size = CalcItemSize(size_arg, label_size.x + style.FramePadding.x * 2.0f, label_size.y + style.FramePadding.y * 2.0f); const ImRect bb(pos, pos + size); ItemSize(size, style.FramePadding.y); if (!ItemAdd(bb, id)) return false; if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat) flags |= ImGuiButtonFlags_Repeat; bool hovered, held; bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); // Render const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); RenderNavHighlight(bb, id); RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding); RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb); // Automatically close popups //if (pressed && !(flags & ImGuiButtonFlags_DontClosePopups) && (window->Flags & ImGuiWindowFlags_Popup)) // CloseCurrentPopup(); IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.LastItemStatusFlags); return pressed; } bool ImGui::Button(const char* label, const ImVec2& size_arg) { return ButtonEx(label, size_arg, 0); } // Small buttons fits within text without additional vertical spacing. bool ImGui::SmallButton(const char* label) { ImGuiContext& g = *GImGui; float backup_padding_y = g.Style.FramePadding.y; g.Style.FramePadding.y = 0.0f; bool pressed = ButtonEx(label, ImVec2(0, 0), ImGuiButtonFlags_AlignTextBaseLine); g.Style.FramePadding.y = backup_padding_y; return pressed; } // Tip: use ImGui::PushID()/PopID() to push indices or pointers in the ID stack. // Then you can keep 'str_id' empty or the same for all your buttons (instead of creating a string based on a non-string id) bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; // Cannot use zero-size for InvisibleButton(). Unlike Button() there is not way to fallback using the label size. IM_ASSERT(size_arg.x != 0.0f && size_arg.y != 0.0f); const ImGuiID id = window->GetID(str_id); ImVec2 size = CalcItemSize(size_arg, 0.0f, 0.0f); const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); ItemSize(size); if (!ItemAdd(bb, id)) return false; bool hovered, held; bool pressed = ButtonBehavior(bb, id, &hovered, &held); return pressed; } bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiButtonFlags flags) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiID id = window->GetID(str_id); const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); const float default_size = GetFrameHeight(); ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : -1.0f); if (!ItemAdd(bb, id)) return false; if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat) flags |= ImGuiButtonFlags_Repeat; bool hovered, held; bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); // Render const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); const ImU32 text_col = GetColorU32(ImGuiCol_Text); RenderNavHighlight(bb, id); RenderFrame(bb.Min, bb.Max, bg_col, true, g.Style.FrameRounding); RenderArrow(window->DrawList, bb.Min + ImVec2(ImMax(0.0f, (size.x - g.FontSize) * 0.5f), ImMax(0.0f, (size.y - g.FontSize) * 0.5f)), text_col, dir); return pressed; } bool ImGui::ArrowButton(const char* str_id, ImGuiDir dir) { float sz = GetFrameHeight(); return ArrowButtonEx(str_id, dir, ImVec2(sz, sz), ImGuiButtonFlags_None); } // Button to close a window bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos)//, float size) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; // We intentionally allow interaction when clipped so that a mechanical Alt,Right,Validate sequence close a window. // (this isn't the regular behavior of buttons, but it doesn't affect the user much because navigation tends to keep items visible). const ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize) + g.Style.FramePadding * 2.0f); bool is_clipped = !ItemAdd(bb, id); bool hovered, held; bool pressed = ButtonBehavior(bb, id, &hovered, &held); if (is_clipped) return pressed; // Render ImU32 col = GetColorU32(held ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered); ImVec2 center = bb.GetCenter(); if (hovered) window->DrawList->AddCircleFilled(center, ImMax(2.0f, g.FontSize * 0.5f + 1.0f), col, 12); float cross_extent = g.FontSize * 0.5f * 0.7071f - 1.0f; ImU32 cross_col = GetColorU32(ImGuiCol_Text); center -= ImVec2(0.5f, 0.5f); window->DrawList->AddLine(center + ImVec2(+cross_extent,+cross_extent), center + ImVec2(-cross_extent,-cross_extent), cross_col, 1.0f); window->DrawList->AddLine(center + ImVec2(+cross_extent,-cross_extent), center + ImVec2(-cross_extent,+cross_extent), cross_col, 1.0f); return pressed; } bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize) + g.Style.FramePadding * 2.0f); ItemAdd(bb, id); bool hovered, held; bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_None); // Render ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); ImU32 text_col = GetColorU32(ImGuiCol_Text); ImVec2 center = bb.GetCenter(); if (hovered || held) window->DrawList->AddCircleFilled(center/*+ ImVec2(0.0f, -0.5f)*/, g.FontSize * 0.5f + 1.0f, bg_col, 12); RenderArrow(window->DrawList, bb.Min + g.Style.FramePadding, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f); // Switch to moving the window after mouse is moved beyond the initial drag threshold if (IsItemActive() && IsMouseDragging(0)) StartMouseMovingWindow(window); return pressed; } ImGuiID ImGui::GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis) { return window->GetIDNoKeepAlive(axis == ImGuiAxis_X ? "#SCROLLX" : "#SCROLLY"); } // Vertical/Horizontal scrollbar // The entire piece of code below is rather confusing because: // - We handle absolute seeking (when first clicking outside the grab) and relative manipulation (afterward or when clicking inside the grab) // - We store values as normalized ratio and in a form that allows the window content to change while we are holding on a scrollbar // - We handle both horizontal and vertical scrollbars, which makes the terminology not ideal. // Still, the code should probably be made simpler.. bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, float* p_scroll_v, float size_avail_v, float size_contents_v, ImDrawCornerFlags rounding_corners) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (window->SkipItems) return false; const float bb_frame_width = bb_frame.GetWidth(); const float bb_frame_height = bb_frame.GetHeight(); if (bb_frame_width <= 0.0f || bb_frame_height <= 0.0f) return false; // When we are too small, start hiding and disabling the grab (this reduce visual noise on very small window and facilitate using the resize grab) float alpha = 1.0f; if ((axis == ImGuiAxis_Y) && bb_frame_height < g.FontSize + g.Style.FramePadding.y * 2.0f) alpha = ImSaturate((bb_frame_height - g.FontSize) / (g.Style.FramePadding.y * 2.0f)); if (alpha <= 0.0f) return false; const ImGuiStyle& style = g.Style; const bool allow_interaction = (alpha >= 1.0f); const bool horizontal = (axis == ImGuiAxis_X); ImRect bb = bb_frame; bb.Expand(ImVec2(-ImClamp(IM_FLOOR((bb_frame_width - 2.0f) * 0.5f), 0.0f, 3.0f), -ImClamp(IM_FLOOR((bb_frame_height - 2.0f) * 0.5f), 0.0f, 3.0f))); // V denote the main, longer axis of the scrollbar (= height for a vertical scrollbar) const float scrollbar_size_v = horizontal ? bb.GetWidth() : bb.GetHeight(); // Calculate the height of our grabbable box. It generally represent the amount visible (vs the total scrollable amount) // But we maintain a minimum size in pixel to allow for the user to still aim inside. IM_ASSERT(ImMax(size_contents_v, size_avail_v) > 0.0f); // Adding this assert to check if the ImMax(XXX,1.0f) is still needed. PLEASE CONTACT ME if this triggers. const float win_size_v = ImMax(ImMax(size_contents_v, size_avail_v), 1.0f); const float grab_h_pixels = ImClamp(scrollbar_size_v * (size_avail_v / win_size_v), style.GrabMinSize, scrollbar_size_v); const float grab_h_norm = grab_h_pixels / scrollbar_size_v; // Handle input right away. None of the code of Begin() is relying on scrolling position before calling Scrollbar(). bool held = false; bool hovered = false; ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_NoNavFocus); float scroll_max = ImMax(1.0f, size_contents_v - size_avail_v); float scroll_ratio = ImSaturate(*p_scroll_v / scroll_max); float grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v; if (held && allow_interaction && grab_h_norm < 1.0f) { float scrollbar_pos_v = horizontal ? bb.Min.x : bb.Min.y; float mouse_pos_v = horizontal ? g.IO.MousePos.x : g.IO.MousePos.y; // Click position in scrollbar normalized space (0.0f->1.0f) const float clicked_v_norm = ImSaturate((mouse_pos_v - scrollbar_pos_v) / scrollbar_size_v); SetHoveredID(id); bool seek_absolute = false; if (g.ActiveIdIsJustActivated) { // On initial click calculate the distance between mouse and the center of the grab seek_absolute = (clicked_v_norm < grab_v_norm || clicked_v_norm > grab_v_norm + grab_h_norm); if (seek_absolute) g.ScrollbarClickDeltaToGrabCenter = 0.0f; else g.ScrollbarClickDeltaToGrabCenter = clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f; } // Apply scroll // It is ok to modify Scroll here because we are being called in Begin() after the calculation of ContentSize and before setting up our starting position const float scroll_v_norm = ImSaturate((clicked_v_norm - g.ScrollbarClickDeltaToGrabCenter - grab_h_norm * 0.5f) / (1.0f - grab_h_norm)); *p_scroll_v = IM_ROUND(scroll_v_norm * scroll_max);//(win_size_contents_v - win_size_v)); // Update values for rendering scroll_ratio = ImSaturate(*p_scroll_v / scroll_max); grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v; // Update distance to grab now that we have seeked and saturated if (seek_absolute) g.ScrollbarClickDeltaToGrabCenter = clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f; } // Render window->DrawList->AddRectFilled(bb_frame.Min, bb_frame.Max, GetColorU32(ImGuiCol_ScrollbarBg), window->WindowRounding, rounding_corners); const ImU32 grab_col = GetColorU32(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab, alpha); ImRect grab_rect; if (horizontal) grab_rect = ImRect(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm), bb.Min.y, ImLerp(bb.Min.x, bb.Max.x, grab_v_norm) + grab_h_pixels, bb.Max.y); else grab_rect = ImRect(bb.Min.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm), bb.Max.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm) + grab_h_pixels); window->DrawList->AddRectFilled(grab_rect.Min, grab_rect.Max, grab_col, style.ScrollbarRounding); return held; } void ImGui::Scrollbar(ImGuiAxis axis) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; const ImGuiID id = GetWindowScrollbarID(window, axis); KeepAliveID(id); // Calculate scrollbar bounding box const ImRect outer_rect = window->Rect(); const ImRect inner_rect = window->InnerRect; const float border_size = window->WindowBorderSize; const float scrollbar_size = window->ScrollbarSizes[axis ^ 1]; IM_ASSERT(scrollbar_size > 0.0f); const float other_scrollbar_size = window->ScrollbarSizes[axis]; ImDrawCornerFlags rounding_corners = (other_scrollbar_size <= 0.0f) ? ImDrawCornerFlags_BotRight : 0; ImRect bb; if (axis == ImGuiAxis_X) { bb.Min = ImVec2(inner_rect.Min.x, ImMax(outer_rect.Min.y, outer_rect.Max.y - border_size - scrollbar_size)); bb.Max = ImVec2(inner_rect.Max.x, outer_rect.Max.y); rounding_corners |= ImDrawCornerFlags_BotLeft; } else { bb.Min = ImVec2(ImMax(outer_rect.Min.x, outer_rect.Max.x - border_size - scrollbar_size), inner_rect.Min.y); bb.Max = ImVec2(outer_rect.Max.x, window->InnerRect.Max.y); rounding_corners |= ((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) ? ImDrawCornerFlags_TopRight : 0; } ScrollbarEx(bb, id, axis, &window->Scroll[axis], inner_rect.Max[axis] - inner_rect.Min[axis], window->ContentSize[axis] + window->WindowPadding[axis] * 2.0f, rounding_corners); } void ImGui::Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); if (border_col.w > 0.0f) bb.Max += ImVec2(2, 2); ItemSize(bb); if (!ItemAdd(bb, 0)) return; if (border_col.w > 0.0f) { window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(border_col), 0.0f); window->DrawList->AddImage(user_texture_id, bb.Min + ImVec2(1, 1), bb.Max - ImVec2(1, 1), uv0, uv1, GetColorU32(tint_col)); } else { window->DrawList->AddImage(user_texture_id, bb.Min, bb.Max, uv0, uv1, GetColorU32(tint_col)); } } // frame_padding < 0: uses FramePadding from style (default) // frame_padding = 0: no framing // frame_padding > 0: set framing size // The color used are the button colors. bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; // Default to using texture ID as ID. User can still push string/integer prefixes. // We could hash the size/uv to create a unique ID but that would prevent the user from animating UV. PushID((void*)(intptr_t)user_texture_id); const ImGuiID id = window->GetID("#image"); PopID(); const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : style.FramePadding; const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2); const ImRect image_bb(window->DC.CursorPos + padding, window->DC.CursorPos + padding + size); ItemSize(bb); if (!ItemAdd(bb, id)) return false; bool hovered, held; bool pressed = ButtonBehavior(bb, id, &hovered, &held); // Render const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); RenderNavHighlight(bb, id); RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, style.FrameRounding)); if (bg_col.w > 0.0f) window->DrawList->AddRectFilled(image_bb.Min, image_bb.Max, GetColorU32(bg_col)); window->DrawList->AddImage(user_texture_id, image_bb.Min, image_bb.Max, uv0, uv1, GetColorU32(tint_col)); return pressed; } bool ImGui::Checkbox(const char* label, bool* v) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImGuiID id = window->GetID(label); const ImVec2 label_size = CalcTextSize(label, NULL, true); const float square_sz = GetFrameHeight(); const ImVec2 pos = window->DC.CursorPos; const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f)); ItemSize(total_bb, style.FramePadding.y); if (!ItemAdd(total_bb, id)) return false; bool hovered, held; bool pressed = ButtonBehavior(total_bb, id, &hovered, &held); if (pressed) { *v = !(*v); MarkItemEdited(id); } const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz)); RenderNavHighlight(total_bb, id); RenderFrame(check_bb.Min, check_bb.Max, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding); ImU32 check_col = GetColorU32(ImGuiCol_CheckMark); if (window->DC.ItemFlags & ImGuiItemFlags_MixedValue) { // Undocumented tristate/mixed/indeterminate checkbox (#2644) ImVec2 pad(ImMax(1.0f, IM_FLOOR(square_sz / 3.6f)), ImMax(1.0f, IM_FLOOR(square_sz / 3.6f))); window->DrawList->AddRectFilled(check_bb.Min + pad, check_bb.Max - pad, check_col, style.FrameRounding); } else if (*v) { const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f)); RenderCheckMark(check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad*2.0f); } if (g.LogEnabled) LogRenderedText(&total_bb.Min, *v ? "[x]" : "[ ]"); if (label_size.x > 0.0f) RenderText(ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y), label); IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0)); return pressed; } bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value) { bool v = ((*flags & flags_value) == flags_value); bool pressed = Checkbox(label, &v); if (pressed) { if (v) *flags |= flags_value; else *flags &= ~flags_value; } return pressed; } bool ImGui::RadioButton(const char* label, bool active) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImGuiID id = window->GetID(label); const ImVec2 label_size = CalcTextSize(label, NULL, true); const float square_sz = GetFrameHeight(); const ImVec2 pos = window->DC.CursorPos; const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz)); const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f)); ItemSize(total_bb, style.FramePadding.y); if (!ItemAdd(total_bb, id)) return false; ImVec2 center = check_bb.GetCenter(); center.x = IM_ROUND(center.x); center.y = IM_ROUND(center.y); const float radius = (square_sz - 1.0f) * 0.5f; bool hovered, held; bool pressed = ButtonBehavior(total_bb, id, &hovered, &held); if (pressed) MarkItemEdited(id); RenderNavHighlight(total_bb, id); window->DrawList->AddCircleFilled(center, radius, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), 16); if (active) { const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f)); window->DrawList->AddCircleFilled(center, radius - pad, GetColorU32(ImGuiCol_CheckMark), 16); } if (style.FrameBorderSize > 0.0f) { window->DrawList->AddCircle(center + ImVec2(1,1), radius, GetColorU32(ImGuiCol_BorderShadow), 16, style.FrameBorderSize); window->DrawList->AddCircle(center, radius, GetColorU32(ImGuiCol_Border), 16, style.FrameBorderSize); } if (g.LogEnabled) LogRenderedText(&total_bb.Min, active ? "(x)" : "( )"); if (label_size.x > 0.0f) RenderText(ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y), label); return pressed; } // FIXME: This would work nicely if it was a public template, e.g. 'template RadioButton(const char* label, T* v, T v_button)', but I'm not sure how we would expose it.. bool ImGui::RadioButton(const char* label, int* v, int v_button) { const bool pressed = RadioButton(label, *v == v_button); if (pressed) *v = v_button; return pressed; } // size_arg (for each axis) < 0.0f: align to end, 0.0f: auto, > 0.0f: specified size void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* overlay) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; ImVec2 pos = window->DC.CursorPos; ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), g.FontSize + style.FramePadding.y*2.0f); ImRect bb(pos, pos + size); ItemSize(size, style.FramePadding.y); if (!ItemAdd(bb, 0)) return; // Render fraction = ImSaturate(fraction); RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize)); const ImVec2 fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction), bb.Max.y); RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), 0.0f, fraction, style.FrameRounding); // Default displaying the fraction as percentage string, but user can override it char overlay_buf[32]; if (!overlay) { ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%.0f%%", fraction*100+0.01f); overlay = overlay_buf; } ImVec2 overlay_size = CalcTextSize(overlay, NULL); if (overlay_size.x > 0.0f) RenderTextClipped(ImVec2(ImClamp(fill_br.x + style.ItemSpacing.x, bb.Min.x, bb.Max.x - overlay_size.x - style.ItemInnerSpacing.x), bb.Min.y), bb.Max, overlay, NULL, &overlay_size, ImVec2(0.0f,0.5f), &bb); } void ImGui::Bullet() { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const float line_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + g.Style.FramePadding.y*2), g.FontSize); const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize, line_height)); ItemSize(bb); if (!ItemAdd(bb, 0)) { SameLine(0, style.FramePadding.x*2); return; } // Render and stay on same line ImU32 text_col = GetColorU32(ImGuiCol_Text); RenderBullet(window->DrawList, bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f), text_col); SameLine(0, style.FramePadding.x * 2.0f); } //------------------------------------------------------------------------- // [SECTION] Widgets: Low-level Layout helpers //------------------------------------------------------------------------- // - Spacing() // - Dummy() // - NewLine() // - AlignTextToFramePadding() // - SeparatorEx() [Internal] // - Separator() // - SplitterBehavior() [Internal] // - ShrinkWidths() [Internal] //------------------------------------------------------------------------- void ImGui::Spacing() { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; ItemSize(ImVec2(0,0)); } void ImGui::Dummy(const ImVec2& size) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); ItemSize(size); ItemAdd(bb, 0); } void ImGui::NewLine() { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; ImGuiContext& g = *GImGui; const ImGuiLayoutType backup_layout_type = window->DC.LayoutType; window->DC.LayoutType = ImGuiLayoutType_Vertical; if (window->DC.CurrLineSize.y > 0.0f) // In the event that we are on a line with items that is smaller that FontSize high, we will preserve its height. ItemSize(ImVec2(0,0)); else ItemSize(ImVec2(0.0f, g.FontSize)); window->DC.LayoutType = backup_layout_type; } void ImGui::AlignTextToFramePadding() { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; ImGuiContext& g = *GImGui; window->DC.CurrLineSize.y = ImMax(window->DC.CurrLineSize.y, g.FontSize + g.Style.FramePadding.y * 2); window->DC.CurrLineTextBaseOffset = ImMax(window->DC.CurrLineTextBaseOffset, g.Style.FramePadding.y); } // Horizontal/vertical separating line void ImGui::SeparatorEx(ImGuiSeparatorFlags flags) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; ImGuiContext& g = *GImGui; IM_ASSERT(ImIsPowerOfTwo(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical))); // Check that only 1 option is selected float thickness_draw = 1.0f; float thickness_layout = 0.0f; if (flags & ImGuiSeparatorFlags_Vertical) { // Vertical separator, for menu bars (use current line height). Not exposed because it is misleading and it doesn't have an effect on regular layout. float y1 = window->DC.CursorPos.y; float y2 = window->DC.CursorPos.y + window->DC.CurrLineSize.y; const ImRect bb(ImVec2(window->DC.CursorPos.x, y1), ImVec2(window->DC.CursorPos.x + thickness_draw, y2)); ItemSize(ImVec2(thickness_layout, 0.0f)); if (!ItemAdd(bb, 0)) return; // Draw window->DrawList->AddLine(ImVec2(bb.Min.x, bb.Min.y), ImVec2(bb.Min.x, bb.Max.y), GetColorU32(ImGuiCol_Separator)); if (g.LogEnabled) LogText(" |"); } else if (flags & ImGuiSeparatorFlags_Horizontal) { // Horizontal Separator float x1 = window->Pos.x; float x2 = window->Pos.x + window->Size.x; if (!window->DC.GroupStack.empty()) x1 += window->DC.Indent.x; ImGuiColumns* columns = (flags & ImGuiSeparatorFlags_SpanAllColumns) ? window->DC.CurrentColumns : NULL; if (columns) PushColumnsBackground(); // We don't provide our width to the layout so that it doesn't get feed back into AutoFit const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y + thickness_draw)); ItemSize(ImVec2(0.0f, thickness_layout)); const bool item_visible = ItemAdd(bb, 0); if (item_visible) { // Draw window->DrawList->AddLine(bb.Min, ImVec2(bb.Max.x, bb.Min.y), GetColorU32(ImGuiCol_Separator)); if (g.LogEnabled) LogRenderedText(&bb.Min, "--------------------------------"); } if (columns) { PopColumnsBackground(); columns->LineMinY = window->DC.CursorPos.y; } } } void ImGui::Separator() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (window->SkipItems) return; // Those flags should eventually be overridable by the user ImGuiSeparatorFlags flags = (window->DC.LayoutType == ImGuiLayoutType_Horizontal) ? ImGuiSeparatorFlags_Vertical : ImGuiSeparatorFlags_Horizontal; flags |= ImGuiSeparatorFlags_SpanAllColumns; SeparatorEx(flags); } // Using 'hover_visibility_delay' allows us to hide the highlight and mouse cursor for a short time, which can be convenient to reduce visual noise. bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend, float hover_visibility_delay) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; const ImGuiItemFlags item_flags_backup = window->DC.ItemFlags; window->DC.ItemFlags |= ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus; bool item_add = ItemAdd(bb, id); window->DC.ItemFlags = item_flags_backup; if (!item_add) return false; bool hovered, held; ImRect bb_interact = bb; bb_interact.Expand(axis == ImGuiAxis_Y ? ImVec2(0.0f, hover_extend) : ImVec2(hover_extend, 0.0f)); ButtonBehavior(bb_interact, id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap); if (g.ActiveId != id) SetItemAllowOverlap(); if (held || (g.HoveredId == id && g.HoveredIdPreviousFrame == id && g.HoveredIdTimer >= hover_visibility_delay)) SetMouseCursor(axis == ImGuiAxis_Y ? ImGuiMouseCursor_ResizeNS : ImGuiMouseCursor_ResizeEW); ImRect bb_render = bb; if (held) { ImVec2 mouse_delta_2d = g.IO.MousePos - g.ActiveIdClickOffset - bb_interact.Min; float mouse_delta = (axis == ImGuiAxis_Y) ? mouse_delta_2d.y : mouse_delta_2d.x; // Minimum pane size float size_1_maximum_delta = ImMax(0.0f, *size1 - min_size1); float size_2_maximum_delta = ImMax(0.0f, *size2 - min_size2); if (mouse_delta < -size_1_maximum_delta) mouse_delta = -size_1_maximum_delta; if (mouse_delta > size_2_maximum_delta) mouse_delta = size_2_maximum_delta; // Apply resize if (mouse_delta != 0.0f) { if (mouse_delta < 0.0f) IM_ASSERT(*size1 + mouse_delta >= min_size1); if (mouse_delta > 0.0f) IM_ASSERT(*size2 - mouse_delta >= min_size2); *size1 += mouse_delta; *size2 -= mouse_delta; bb_render.Translate((axis == ImGuiAxis_X) ? ImVec2(mouse_delta, 0.0f) : ImVec2(0.0f, mouse_delta)); MarkItemEdited(id); } } // Render const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : (hovered && g.HoveredIdTimer >= hover_visibility_delay) ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator); window->DrawList->AddRectFilled(bb_render.Min, bb_render.Max, col, 0.0f); return held; } static int IMGUI_CDECL ShrinkWidthItemComparer(const void* lhs, const void* rhs) { const ImGuiShrinkWidthItem* a = (const ImGuiShrinkWidthItem*)lhs; const ImGuiShrinkWidthItem* b = (const ImGuiShrinkWidthItem*)rhs; if (int d = (int)(b->Width - a->Width)) return d; return (b->Index - a->Index); } // Shrink excess width from a set of item, by removing width from the larger items first. void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess) { if (count == 1) { items[0].Width = ImMax(items[0].Width - width_excess, 1.0f); return; } ImQsort(items, (size_t)count, sizeof(ImGuiShrinkWidthItem), ShrinkWidthItemComparer); int count_same_width = 1; while (width_excess > 0.0f && count_same_width < count) { while (count_same_width < count && items[0].Width <= items[count_same_width].Width) count_same_width++; float max_width_to_remove_per_item = (count_same_width < count) ? (items[0].Width - items[count_same_width].Width) : (items[0].Width - 1.0f); float width_to_remove_per_item = ImMin(width_excess / count_same_width, max_width_to_remove_per_item); for (int item_n = 0; item_n < count_same_width; item_n++) items[item_n].Width -= width_to_remove_per_item; width_excess -= width_to_remove_per_item * count_same_width; } // Round width and redistribute remainder left-to-right (could make it an option of the function?) // Ensure that e.g. the right-most tab of a shrunk tab-bar always reaches exactly at the same distance from the right-most edge of the tab bar separator. width_excess = 0.0f; for (int n = 0; n < count; n++) { float width_rounded = ImFloor(items[n].Width); width_excess += items[n].Width - width_rounded; items[n].Width = width_rounded; } if (width_excess > 0.0f) for (int n = 0; n < count; n++) if (items[n].Index < (int)(width_excess + 0.01f)) items[n].Width += 1.0f; } //------------------------------------------------------------------------- // [SECTION] Widgets: ComboBox //------------------------------------------------------------------------- // - BeginCombo() // - EndCombo() // - Combo() //------------------------------------------------------------------------- static float CalcMaxPopupHeightFromItemCount(int items_count) { ImGuiContext& g = *GImGui; if (items_count <= 0) return FLT_MAX; return (g.FontSize + g.Style.ItemSpacing.y) * items_count - g.Style.ItemSpacing.y + (g.Style.WindowPadding.y * 2); } bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags) { // Always consume the SetNextWindowSizeConstraint() call in our early return paths ImGuiContext& g = *GImGui; bool has_window_size_constraint = (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint) != 0; g.NextWindowData.Flags &= ~ImGuiNextWindowDataFlags_HasSizeConstraint; ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; IM_ASSERT((flags & (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)) != (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)); // Can't use both flags together const ImGuiStyle& style = g.Style; const ImGuiID id = window->GetID(label); const float arrow_size = (flags & ImGuiComboFlags_NoArrowButton) ? 0.0f : GetFrameHeight(); const ImVec2 label_size = CalcTextSize(label, NULL, true); const float expected_w = CalcItemWidth(); const float w = (flags & ImGuiComboFlags_NoPreview) ? arrow_size : expected_w; const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f)); const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); ItemSize(total_bb, style.FramePadding.y); if (!ItemAdd(total_bb, id, &frame_bb)) return false; bool hovered, held; bool pressed = ButtonBehavior(frame_bb, id, &hovered, &held); bool popup_open = IsPopupOpen(id); const ImU32 frame_col = GetColorU32(hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); const float value_x2 = ImMax(frame_bb.Min.x, frame_bb.Max.x - arrow_size); RenderNavHighlight(frame_bb, id); if (!(flags & ImGuiComboFlags_NoPreview)) window->DrawList->AddRectFilled(frame_bb.Min, ImVec2(value_x2, frame_bb.Max.y), frame_col, style.FrameRounding, (flags & ImGuiComboFlags_NoArrowButton) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Left); if (!(flags & ImGuiComboFlags_NoArrowButton)) { ImU32 bg_col = GetColorU32((popup_open || hovered) ? ImGuiCol_ButtonHovered : ImGuiCol_Button); ImU32 text_col = GetColorU32(ImGuiCol_Text); window->DrawList->AddRectFilled(ImVec2(value_x2, frame_bb.Min.y), frame_bb.Max, bg_col, style.FrameRounding, (w <= arrow_size) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Right); if (value_x2 + arrow_size - style.FramePadding.x <= frame_bb.Max.x) RenderArrow(window->DrawList, ImVec2(value_x2 + style.FramePadding.y, frame_bb.Min.y + style.FramePadding.y), text_col, ImGuiDir_Down, 1.0f); } RenderFrameBorder(frame_bb.Min, frame_bb.Max, style.FrameRounding); if (preview_value != NULL && !(flags & ImGuiComboFlags_NoPreview)) RenderTextClipped(frame_bb.Min + style.FramePadding, ImVec2(value_x2, frame_bb.Max.y), preview_value, NULL, NULL, ImVec2(0.0f,0.0f)); if (label_size.x > 0) RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); if ((pressed || g.NavActivateId == id) && !popup_open) { if (window->DC.NavLayerCurrent == 0) window->NavLastIds[0] = id; OpenPopupEx(id); popup_open = true; } if (!popup_open) return false; if (has_window_size_constraint) { g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSizeConstraint; g.NextWindowData.SizeConstraintRect.Min.x = ImMax(g.NextWindowData.SizeConstraintRect.Min.x, w); } else { if ((flags & ImGuiComboFlags_HeightMask_) == 0) flags |= ImGuiComboFlags_HeightRegular; IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiComboFlags_HeightMask_)); // Only one int popup_max_height_in_items = -1; if (flags & ImGuiComboFlags_HeightRegular) popup_max_height_in_items = 8; else if (flags & ImGuiComboFlags_HeightSmall) popup_max_height_in_items = 4; else if (flags & ImGuiComboFlags_HeightLarge) popup_max_height_in_items = 20; SetNextWindowSizeConstraints(ImVec2(w, 0.0f), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items))); } char name[16]; ImFormatString(name, IM_ARRAYSIZE(name), "##Combo_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth // Peak into expected window size so we can position it if (ImGuiWindow* popup_window = FindWindowByName(name)) if (popup_window->WasActive) { ImVec2 size_expected = CalcWindowExpectedSize(popup_window); if (flags & ImGuiComboFlags_PopupAlignLeft) popup_window->AutoPosLastDirection = ImGuiDir_Left; ImRect r_outer = GetWindowAllowedExtentRect(popup_window); ImVec2 pos = FindBestWindowPosForPopupEx(frame_bb.GetBL(), size_expected, &popup_window->AutoPosLastDirection, r_outer, frame_bb, ImGuiPopupPositionPolicy_ComboBox); SetNextWindowPos(pos); } // We don't use BeginPopupEx() solely because we have a custom name string, which we could make an argument to BeginPopupEx() ImGuiWindowFlags window_flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_Popup | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoMove; // Horizontally align ourselves with the framed text PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(style.FramePadding.x, style.WindowPadding.y)); bool ret = Begin(name, NULL, window_flags); PopStyleVar(); if (!ret) { EndPopup(); IM_ASSERT(0); // This should never happen as we tested for IsPopupOpen() above return false; } return true; } void ImGui::EndCombo() { EndPopup(); } // Getter for the old Combo() API: const char*[] static bool Items_ArrayGetter(void* data, int idx, const char** out_text) { const char* const* items = (const char* const*)data; if (out_text) *out_text = items[idx]; return true; } // Getter for the old Combo() API: "item1\0item2\0item3\0" static bool Items_SingleStringGetter(void* data, int idx, const char** out_text) { // FIXME-OPT: we could pre-compute the indices to fasten this. But only 1 active combo means the waste is limited. const char* items_separated_by_zeros = (const char*)data; int items_count = 0; const char* p = items_separated_by_zeros; while (*p) { if (idx == items_count) break; p += strlen(p) + 1; items_count++; } if (!*p) return false; if (out_text) *out_text = p; return true; } // Old API, prefer using BeginCombo() nowadays if you can. bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int popup_max_height_in_items) { ImGuiContext& g = *GImGui; // Call the getter to obtain the preview string which is a parameter to BeginCombo() const char* preview_value = NULL; if (*current_item >= 0 && *current_item < items_count) items_getter(data, *current_item, &preview_value); // The old Combo() API exposed "popup_max_height_in_items". The new more general BeginCombo() API doesn't have/need it, but we emulate it here. if (popup_max_height_in_items != -1 && !(g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint)) SetNextWindowSizeConstraints(ImVec2(0,0), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items))); if (!BeginCombo(label, preview_value, ImGuiComboFlags_None)) return false; // Display items // FIXME-OPT: Use clipper (but we need to disable it on the appearing frame to make sure our call to SetItemDefaultFocus() is processed) bool value_changed = false; for (int i = 0; i < items_count; i++) { PushID((void*)(intptr_t)i); const bool item_selected = (i == *current_item); const char* item_text; if (!items_getter(data, i, &item_text)) item_text = "*Unknown item*"; if (Selectable(item_text, item_selected)) { value_changed = true; *current_item = i; } if (item_selected) SetItemDefaultFocus(); PopID(); } EndCombo(); return value_changed; } // Combo box helper allowing to pass an array of strings. bool ImGui::Combo(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items) { const bool value_changed = Combo(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_in_items); return value_changed; } // Combo box helper allowing to pass all items in a single string literal holding multiple zero-terminated items "item1\0item2\0" bool ImGui::Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items) { int items_count = 0; const char* p = items_separated_by_zeros; // FIXME-OPT: Avoid computing this, or at least only when combo is open while (*p) { p += strlen(p) + 1; items_count++; } bool value_changed = Combo(label, current_item, Items_SingleStringGetter, (void*)items_separated_by_zeros, items_count, height_in_items); return value_changed; } //------------------------------------------------------------------------- // [SECTION] Data Type and Data Formatting Helpers [Internal] //------------------------------------------------------------------------- // - PatchFormatStringFloatToInt() // - DataTypeGetInfo() // - DataTypeFormatString() // - DataTypeApplyOp() // - DataTypeApplyOpFromText() // - GetMinimumStepAtDecimalPrecision // - RoundScalarWithFormat<>() //------------------------------------------------------------------------- static const ImGuiDataTypeInfo GDataTypeInfo[] = { { sizeof(char), "%d", "%d" }, // ImGuiDataType_S8 { sizeof(unsigned char), "%u", "%u" }, { sizeof(short), "%d", "%d" }, // ImGuiDataType_S16 { sizeof(unsigned short), "%u", "%u" }, { sizeof(int), "%d", "%d" }, // ImGuiDataType_S32 { sizeof(unsigned int), "%u", "%u" }, #ifdef _MSC_VER { sizeof(ImS64), "%I64d","%I64d" }, // ImGuiDataType_S64 { sizeof(ImU64), "%I64u","%I64u" }, #else { sizeof(ImS64), "%lld", "%lld" }, // ImGuiDataType_S64 { sizeof(ImU64), "%llu", "%llu" }, #endif { sizeof(float), "%f", "%f" }, // ImGuiDataType_Float (float are promoted to double in va_arg) { sizeof(double), "%f", "%lf" }, // ImGuiDataType_Double }; IM_STATIC_ASSERT(IM_ARRAYSIZE(GDataTypeInfo) == ImGuiDataType_COUNT); // FIXME-LEGACY: Prior to 1.61 our DragInt() function internally used floats and because of this the compile-time default value for format was "%.0f". // Even though we changed the compile-time default, we expect users to have carried %f around, which would break the display of DragInt() calls. // To honor backward compatibility we are rewriting the format string, unless IMGUI_DISABLE_OBSOLETE_FUNCTIONS is enabled. What could possibly go wrong?! static const char* PatchFormatStringFloatToInt(const char* fmt) { if (fmt[0] == '%' && fmt[1] == '.' && fmt[2] == '0' && fmt[3] == 'f' && fmt[4] == 0) // Fast legacy path for "%.0f" which is expected to be the most common case. return "%d"; const char* fmt_start = ImParseFormatFindStart(fmt); // Find % (if any, and ignore %%) const char* fmt_end = ImParseFormatFindEnd(fmt_start); // Find end of format specifier, which itself is an exercise of confidence/recklessness (because snprintf is dependent on libc or user). if (fmt_end > fmt_start && fmt_end[-1] == 'f') { #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS if (fmt_start == fmt && fmt_end[0] == 0) return "%d"; ImGuiContext& g = *GImGui; ImFormatString(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), "%.*s%%d%s", (int)(fmt_start - fmt), fmt, fmt_end); // Honor leading and trailing decorations, but lose alignment/precision. return g.TempBuffer; #else IM_ASSERT(0 && "DragInt(): Invalid format string!"); // Old versions used a default parameter of "%.0f", please replace with e.g. "%d" #endif } return fmt; } const ImGuiDataTypeInfo* ImGui::DataTypeGetInfo(ImGuiDataType data_type) { IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT); return &GDataTypeInfo[data_type]; } int ImGui::DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* p_data, const char* format) { // Signedness doesn't matter when pushing integer arguments if (data_type == ImGuiDataType_S32 || data_type == ImGuiDataType_U32) return ImFormatString(buf, buf_size, format, *(const ImU32*)p_data); if (data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64) return ImFormatString(buf, buf_size, format, *(const ImU64*)p_data); if (data_type == ImGuiDataType_Float) return ImFormatString(buf, buf_size, format, *(const float*)p_data); if (data_type == ImGuiDataType_Double) return ImFormatString(buf, buf_size, format, *(const double*)p_data); if (data_type == ImGuiDataType_S8) return ImFormatString(buf, buf_size, format, *(const ImS8*)p_data); if (data_type == ImGuiDataType_U8) return ImFormatString(buf, buf_size, format, *(const ImU8*)p_data); if (data_type == ImGuiDataType_S16) return ImFormatString(buf, buf_size, format, *(const ImS16*)p_data); if (data_type == ImGuiDataType_U16) return ImFormatString(buf, buf_size, format, *(const ImU16*)p_data); IM_ASSERT(0); return 0; } void ImGui::DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, void* arg1, const void* arg2) { IM_ASSERT(op == '+' || op == '-'); switch (data_type) { case ImGuiDataType_S8: if (op == '+') { *(ImS8*)output = ImAddClampOverflow(*(const ImS8*)arg1, *(const ImS8*)arg2, IM_S8_MIN, IM_S8_MAX); } if (op == '-') { *(ImS8*)output = ImSubClampOverflow(*(const ImS8*)arg1, *(const ImS8*)arg2, IM_S8_MIN, IM_S8_MAX); } return; case ImGuiDataType_U8: if (op == '+') { *(ImU8*)output = ImAddClampOverflow(*(const ImU8*)arg1, *(const ImU8*)arg2, IM_U8_MIN, IM_U8_MAX); } if (op == '-') { *(ImU8*)output = ImSubClampOverflow(*(const ImU8*)arg1, *(const ImU8*)arg2, IM_U8_MIN, IM_U8_MAX); } return; case ImGuiDataType_S16: if (op == '+') { *(ImS16*)output = ImAddClampOverflow(*(const ImS16*)arg1, *(const ImS16*)arg2, IM_S16_MIN, IM_S16_MAX); } if (op == '-') { *(ImS16*)output = ImSubClampOverflow(*(const ImS16*)arg1, *(const ImS16*)arg2, IM_S16_MIN, IM_S16_MAX); } return; case ImGuiDataType_U16: if (op == '+') { *(ImU16*)output = ImAddClampOverflow(*(const ImU16*)arg1, *(const ImU16*)arg2, IM_U16_MIN, IM_U16_MAX); } if (op == '-') { *(ImU16*)output = ImSubClampOverflow(*(const ImU16*)arg1, *(const ImU16*)arg2, IM_U16_MIN, IM_U16_MAX); } return; case ImGuiDataType_S32: if (op == '+') { *(ImS32*)output = ImAddClampOverflow(*(const ImS32*)arg1, *(const ImS32*)arg2, IM_S32_MIN, IM_S32_MAX); } if (op == '-') { *(ImS32*)output = ImSubClampOverflow(*(const ImS32*)arg1, *(const ImS32*)arg2, IM_S32_MIN, IM_S32_MAX); } return; case ImGuiDataType_U32: if (op == '+') { *(ImU32*)output = ImAddClampOverflow(*(const ImU32*)arg1, *(const ImU32*)arg2, IM_U32_MIN, IM_U32_MAX); } if (op == '-') { *(ImU32*)output = ImSubClampOverflow(*(const ImU32*)arg1, *(const ImU32*)arg2, IM_U32_MIN, IM_U32_MAX); } return; case ImGuiDataType_S64: if (op == '+') { *(ImS64*)output = ImAddClampOverflow(*(const ImS64*)arg1, *(const ImS64*)arg2, IM_S64_MIN, IM_S64_MAX); } if (op == '-') { *(ImS64*)output = ImSubClampOverflow(*(const ImS64*)arg1, *(const ImS64*)arg2, IM_S64_MIN, IM_S64_MAX); } return; case ImGuiDataType_U64: if (op == '+') { *(ImU64*)output = ImAddClampOverflow(*(const ImU64*)arg1, *(const ImU64*)arg2, IM_U64_MIN, IM_U64_MAX); } if (op == '-') { *(ImU64*)output = ImSubClampOverflow(*(const ImU64*)arg1, *(const ImU64*)arg2, IM_U64_MIN, IM_U64_MAX); } return; case ImGuiDataType_Float: if (op == '+') { *(float*)output = *(const float*)arg1 + *(const float*)arg2; } if (op == '-') { *(float*)output = *(const float*)arg1 - *(const float*)arg2; } return; case ImGuiDataType_Double: if (op == '+') { *(double*)output = *(const double*)arg1 + *(const double*)arg2; } if (op == '-') { *(double*)output = *(const double*)arg1 - *(const double*)arg2; } return; case ImGuiDataType_COUNT: break; } IM_ASSERT(0); } // User can input math operators (e.g. +100) to edit a numerical values. // NB: This is _not_ a full expression evaluator. We should probably add one and replace this dumb mess.. bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* p_data, const char* format) { while (ImCharIsBlankA(*buf)) buf++; // We don't support '-' op because it would conflict with inputing negative value. // Instead you can use +-100 to subtract from an existing value char op = buf[0]; if (op == '+' || op == '*' || op == '/') { buf++; while (ImCharIsBlankA(*buf)) buf++; } else { op = 0; } if (!buf[0]) return false; // Copy the value in an opaque buffer so we can compare at the end of the function if it changed at all. IM_ASSERT(data_type < ImGuiDataType_COUNT); int data_backup[2]; const ImGuiDataTypeInfo* type_info = ImGui::DataTypeGetInfo(data_type); IM_ASSERT(type_info->Size <= sizeof(data_backup)); memcpy(data_backup, p_data, type_info->Size); if (format == NULL) format = type_info->ScanFmt; // FIXME-LEGACY: The aim is to remove those operators and write a proper expression evaluator at some point.. int arg1i = 0; if (data_type == ImGuiDataType_S32) { int* v = (int*)p_data; int arg0i = *v; float arg1f = 0.0f; if (op && sscanf(initial_value_buf, format, &arg0i) < 1) return false; // Store operand in a float so we can use fractional value for multipliers (*1.1), but constant always parsed as integer so we can fit big integers (e.g. 2000000003) past float precision if (op == '+') { if (sscanf(buf, "%d", &arg1i)) *v = (int)(arg0i + arg1i); } // Add (use "+-" to subtract) else if (op == '*') { if (sscanf(buf, "%f", &arg1f)) *v = (int)(arg0i * arg1f); } // Multiply else if (op == '/') { if (sscanf(buf, "%f", &arg1f) && arg1f != 0.0f) *v = (int)(arg0i / arg1f); } // Divide else { if (sscanf(buf, format, &arg1i) == 1) *v = arg1i; } // Assign constant } else if (data_type == ImGuiDataType_Float) { // For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in format = "%f"; float* v = (float*)p_data; float arg0f = *v, arg1f = 0.0f; if (op && sscanf(initial_value_buf, format, &arg0f) < 1) return false; if (sscanf(buf, format, &arg1f) < 1) return false; if (op == '+') { *v = arg0f + arg1f; } // Add (use "+-" to subtract) else if (op == '*') { *v = arg0f * arg1f; } // Multiply else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide else { *v = arg1f; } // Assign constant } else if (data_type == ImGuiDataType_Double) { format = "%lf"; // scanf differentiate float/double unlike printf which forces everything to double because of ellipsis double* v = (double*)p_data; double arg0f = *v, arg1f = 0.0; if (op && sscanf(initial_value_buf, format, &arg0f) < 1) return false; if (sscanf(buf, format, &arg1f) < 1) return false; if (op == '+') { *v = arg0f + arg1f; } // Add (use "+-" to subtract) else if (op == '*') { *v = arg0f * arg1f; } // Multiply else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide else { *v = arg1f; } // Assign constant } else if (data_type == ImGuiDataType_U32 || data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64) { // All other types assign constant // We don't bother handling support for legacy operators since they are a little too crappy. Instead we will later implement a proper expression evaluator in the future. sscanf(buf, format, p_data); } else { // Small types need a 32-bit buffer to receive the result from scanf() int v32; sscanf(buf, format, &v32); if (data_type == ImGuiDataType_S8) *(ImS8*)p_data = (ImS8)ImClamp(v32, (int)IM_S8_MIN, (int)IM_S8_MAX); else if (data_type == ImGuiDataType_U8) *(ImU8*)p_data = (ImU8)ImClamp(v32, (int)IM_U8_MIN, (int)IM_U8_MAX); else if (data_type == ImGuiDataType_S16) *(ImS16*)p_data = (ImS16)ImClamp(v32, (int)IM_S16_MIN, (int)IM_S16_MAX); else if (data_type == ImGuiDataType_U16) *(ImU16*)p_data = (ImU16)ImClamp(v32, (int)IM_U16_MIN, (int)IM_U16_MAX); else IM_ASSERT(0); } return memcmp(data_backup, p_data, type_info->Size) != 0; } static float GetMinimumStepAtDecimalPrecision(int decimal_precision) { static const float min_steps[10] = { 1.0f, 0.1f, 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f }; if (decimal_precision < 0) return FLT_MIN; return (decimal_precision < IM_ARRAYSIZE(min_steps)) ? min_steps[decimal_precision] : ImPow(10.0f, (float)-decimal_precision); } template static const char* ImAtoi(const char* src, TYPE* output) { int negative = 0; if (*src == '-') { negative = 1; src++; } if (*src == '+') { src++; } TYPE v = 0; while (*src >= '0' && *src <= '9') v = (v * 10) + (*src++ - '0'); *output = negative ? -v : v; return src; } template TYPE ImGui::RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, TYPE v) { const char* fmt_start = ImParseFormatFindStart(format); if (fmt_start[0] != '%' || fmt_start[1] == '%') // Don't apply if the value is not visible in the format string return v; char v_str[64]; ImFormatString(v_str, IM_ARRAYSIZE(v_str), fmt_start, v); const char* p = v_str; while (*p == ' ') p++; if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) v = (TYPE)ImAtof(p); else ImAtoi(p, (SIGNEDTYPE*)&v); return v; } //------------------------------------------------------------------------- // [SECTION] Widgets: DragScalar, DragFloat, DragInt, etc. //------------------------------------------------------------------------- // - DragBehaviorT<>() [Internal] // - DragBehavior() [Internal] // - DragScalar() // - DragScalarN() // - DragFloat() // - DragFloat2() // - DragFloat3() // - DragFloat4() // - DragFloatRange2() // - DragInt() // - DragInt2() // - DragInt3() // - DragInt4() // - DragIntRange2() //------------------------------------------------------------------------- // This is called by DragBehavior() when the widget is active (held by mouse or being manipulated with Nav controls) template bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const TYPE v_min, const TYPE v_max, const char* format, float power, ImGuiDragFlags flags) { ImGuiContext& g = *GImGui; const ImGuiAxis axis = (flags & ImGuiDragFlags_Vertical) ? ImGuiAxis_Y : ImGuiAxis_X; const bool is_decimal = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double); const bool is_clamped = (v_min < v_max); const bool is_power = (power != 1.0f && is_decimal && is_clamped && (v_max - v_min < FLT_MAX)); const bool is_locked = (v_min > v_max); if (is_locked) return false; // Default tweak speed if (v_speed == 0.0f && is_clamped && (v_max - v_min < FLT_MAX)) v_speed = (float)((v_max - v_min) * g.DragSpeedDefaultRatio); // Inputs accumulates into g.DragCurrentAccum, which is flushed into the current value as soon as it makes a difference with our precision settings float adjust_delta = 0.0f; if (g.ActiveIdSource == ImGuiInputSource_Mouse && IsMousePosValid() && g.IO.MouseDragMaxDistanceSqr[0] > 1.0f*1.0f) { adjust_delta = g.IO.MouseDelta[axis]; if (g.IO.KeyAlt) adjust_delta *= 1.0f / 100.0f; if (g.IO.KeyShift) adjust_delta *= 10.0f; } else if (g.ActiveIdSource == ImGuiInputSource_Nav) { int decimal_precision = is_decimal ? ImParseFormatPrecision(format, 3) : 0; adjust_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard | ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 1.0f / 10.0f, 10.0f)[axis]; v_speed = ImMax(v_speed, GetMinimumStepAtDecimalPrecision(decimal_precision)); } adjust_delta *= v_speed; // For vertical drag we currently assume that Up=higher value (like we do with vertical sliders). This may become a parameter. if (axis == ImGuiAxis_Y) adjust_delta = -adjust_delta; // Clear current value on activation // Avoid altering values and clamping when we are _already_ past the limits and heading in the same direction, so e.g. if range is 0..255, current value is 300 and we are pushing to the right side, keep the 300. bool is_just_activated = g.ActiveIdIsJustActivated; bool is_already_past_limits_and_pushing_outward = is_clamped && ((*v >= v_max && adjust_delta > 0.0f) || (*v <= v_min && adjust_delta < 0.0f)); bool is_drag_direction_change_with_power = is_power && ((adjust_delta < 0 && g.DragCurrentAccum > 0) || (adjust_delta > 0 && g.DragCurrentAccum < 0)); if (is_just_activated || is_already_past_limits_and_pushing_outward || is_drag_direction_change_with_power) { g.DragCurrentAccum = 0.0f; g.DragCurrentAccumDirty = false; } else if (adjust_delta != 0.0f) { g.DragCurrentAccum += adjust_delta; g.DragCurrentAccumDirty = true; } if (!g.DragCurrentAccumDirty) return false; TYPE v_cur = *v; FLOATTYPE v_old_ref_for_accum_remainder = (FLOATTYPE)0.0f; if (is_power) { // Offset + round to user desired precision, with a curve on the v_min..v_max range to get more precision on one side of the range FLOATTYPE v_old_norm_curved = ImPow((FLOATTYPE)(v_cur - v_min) / (FLOATTYPE)(v_max - v_min), (FLOATTYPE)1.0f / power); FLOATTYPE v_new_norm_curved = v_old_norm_curved + (g.DragCurrentAccum / (v_max - v_min)); v_cur = v_min + (SIGNEDTYPE)ImPow(ImSaturate((float)v_new_norm_curved), power) * (v_max - v_min); v_old_ref_for_accum_remainder = v_old_norm_curved; } else { v_cur += (SIGNEDTYPE)g.DragCurrentAccum; } // Round to user desired precision based on format string v_cur = RoundScalarWithFormatT(format, data_type, v_cur); // Preserve remainder after rounding has been applied. This also allow slow tweaking of values. g.DragCurrentAccumDirty = false; if (is_power) { FLOATTYPE v_cur_norm_curved = ImPow((FLOATTYPE)(v_cur - v_min) / (FLOATTYPE)(v_max - v_min), (FLOATTYPE)1.0f / power); g.DragCurrentAccum -= (float)(v_cur_norm_curved - v_old_ref_for_accum_remainder); } else { g.DragCurrentAccum -= (float)((SIGNEDTYPE)v_cur - (SIGNEDTYPE)*v); } // Lose zero sign for float/double if (v_cur == (TYPE)-0) v_cur = (TYPE)0; // Clamp values (+ handle overflow/wrap-around for integer types) if (*v != v_cur && is_clamped) { if (v_cur < v_min || (v_cur > *v && adjust_delta < 0.0f && !is_decimal)) v_cur = v_min; if (v_cur > v_max || (v_cur < *v && adjust_delta > 0.0f && !is_decimal)) v_cur = v_max; } // Apply result if (*v == v_cur) return false; *v = v_cur; return true; } bool ImGui::DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v_speed, const void* p_min, const void* p_max, const char* format, float power, ImGuiDragFlags flags) { ImGuiContext& g = *GImGui; if (g.ActiveId == id) { if (g.ActiveIdSource == ImGuiInputSource_Mouse && !g.IO.MouseDown[0]) ClearActiveID(); else if (g.ActiveIdSource == ImGuiInputSource_Nav && g.NavActivatePressedId == id && !g.ActiveIdIsJustActivated) ClearActiveID(); } if (g.ActiveId != id) return false; switch (data_type) { case ImGuiDataType_S8: { ImS32 v32 = (ImS32)*(ImS8*)p_v; bool r = DragBehaviorT(ImGuiDataType_S32, &v32, v_speed, p_min ? *(const ImS8*) p_min : IM_S8_MIN, p_max ? *(const ImS8*)p_max : IM_S8_MAX, format, power, flags); if (r) *(ImS8*)p_v = (ImS8)v32; return r; } case ImGuiDataType_U8: { ImU32 v32 = (ImU32)*(ImU8*)p_v; bool r = DragBehaviorT(ImGuiDataType_U32, &v32, v_speed, p_min ? *(const ImU8*) p_min : IM_U8_MIN, p_max ? *(const ImU8*)p_max : IM_U8_MAX, format, power, flags); if (r) *(ImU8*)p_v = (ImU8)v32; return r; } case ImGuiDataType_S16: { ImS32 v32 = (ImS32)*(ImS16*)p_v; bool r = DragBehaviorT(ImGuiDataType_S32, &v32, v_speed, p_min ? *(const ImS16*)p_min : IM_S16_MIN, p_max ? *(const ImS16*)p_max : IM_S16_MAX, format, power, flags); if (r) *(ImS16*)p_v = (ImS16)v32; return r; } case ImGuiDataType_U16: { ImU32 v32 = (ImU32)*(ImU16*)p_v; bool r = DragBehaviorT(ImGuiDataType_U32, &v32, v_speed, p_min ? *(const ImU16*)p_min : IM_U16_MIN, p_max ? *(const ImU16*)p_max : IM_U16_MAX, format, power, flags); if (r) *(ImU16*)p_v = (ImU16)v32; return r; } case ImGuiDataType_S32: return DragBehaviorT(data_type, (ImS32*)p_v, v_speed, p_min ? *(const ImS32* )p_min : IM_S32_MIN, p_max ? *(const ImS32* )p_max : IM_S32_MAX, format, power, flags); case ImGuiDataType_U32: return DragBehaviorT(data_type, (ImU32*)p_v, v_speed, p_min ? *(const ImU32* )p_min : IM_U32_MIN, p_max ? *(const ImU32* )p_max : IM_U32_MAX, format, power, flags); case ImGuiDataType_S64: return DragBehaviorT(data_type, (ImS64*)p_v, v_speed, p_min ? *(const ImS64* )p_min : IM_S64_MIN, p_max ? *(const ImS64* )p_max : IM_S64_MAX, format, power, flags); case ImGuiDataType_U64: return DragBehaviorT(data_type, (ImU64*)p_v, v_speed, p_min ? *(const ImU64* )p_min : IM_U64_MIN, p_max ? *(const ImU64* )p_max : IM_U64_MAX, format, power, flags); case ImGuiDataType_Float: return DragBehaviorT(data_type, (float*)p_v, v_speed, p_min ? *(const float* )p_min : -FLT_MAX, p_max ? *(const float* )p_max : FLT_MAX, format, power, flags); case ImGuiDataType_Double: return DragBehaviorT(data_type, (double*)p_v, v_speed, p_min ? *(const double*)p_min : -DBL_MAX, p_max ? *(const double*)p_max : DBL_MAX, format, power, flags); case ImGuiDataType_COUNT: break; } IM_ASSERT(0); return false; } // Note: p_data, p_min and p_max are _pointers_ to a memory address holding the data. For a Drag widget, p_min and p_max are optional. // Read code of e.g. SliderFloat(), SliderInt() etc. or examples in 'Demo->Widgets->Data Types' to understand how to use this function directly. bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed, const void* p_min, const void* p_max, const char* format, float power) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; if (power != 1.0f) IM_ASSERT(p_min != NULL && p_max != NULL); // When using a power curve the drag needs to have known bounds ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImGuiID id = window->GetID(label); const float w = CalcItemWidth(); const ImVec2 label_size = CalcTextSize(label, NULL, true); const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f)); const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); ItemSize(total_bb, style.FramePadding.y); if (!ItemAdd(total_bb, id, &frame_bb)) return false; // Default format string when passing NULL if (format == NULL) format = DataTypeGetInfo(data_type)->PrintFmt; else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.) format = PatchFormatStringFloatToInt(format); // Tabbing or CTRL-clicking on Drag turns it into an input box const bool hovered = ItemHoverable(frame_bb, id); bool temp_input_is_active = TempInputTextIsActive(id); bool temp_input_start = false; if (!temp_input_is_active) { const bool focus_requested = FocusableItemRegister(window, id); const bool clicked = (hovered && g.IO.MouseClicked[0]); const bool double_clicked = (hovered && g.IO.MouseDoubleClicked[0]); if (focus_requested || clicked || double_clicked || g.NavActivateId == id || g.NavInputId == id) { SetActiveID(id, window); SetFocusID(id, window); FocusWindow(window); g.ActiveIdUsingNavDirMask = (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right); if (focus_requested || (clicked && g.IO.KeyCtrl) || double_clicked || g.NavInputId == id) { temp_input_start = true; FocusableItemUnregister(window); } } } if (temp_input_is_active || temp_input_start) return TempInputTextScalar(frame_bb, id, label, data_type, p_data, format); // Draw frame const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); RenderNavHighlight(frame_bb, id); RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, style.FrameRounding); // Drag behavior const bool value_changed = DragBehavior(id, data_type, p_data, v_speed, p_min, p_max, format, power, ImGuiDragFlags_None); if (value_changed) MarkItemEdited(id); // Display value using user-provided display format so user can add prefix/suffix/decorations to the value. char value_buf[64]; const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, p_data, format); RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.5f)); if (label_size.x > 0.0f) RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags); return value_changed; } bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, const void* p_min, const void* p_max, const char* format, float power) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; bool value_changed = false; BeginGroup(); PushID(label); PushMultiItemsWidths(components, CalcItemWidth()); size_t type_size = GDataTypeInfo[data_type].Size; for (int i = 0; i < components; i++) { PushID(i); if (i > 0) SameLine(0, g.Style.ItemInnerSpacing.x); value_changed |= DragScalar("", data_type, p_data, v_speed, p_min, p_max, format, power); PopID(); PopItemWidth(); p_data = (void*)((char*)p_data + type_size); } PopID(); const char* label_end = FindRenderedTextEnd(label); if (label != label_end) { SameLine(0, g.Style.ItemInnerSpacing.x); TextEx(label, label_end); } EndGroup(); return value_changed; } bool ImGui::DragFloat(const char* label, float* v, float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalar(label, ImGuiDataType_Float, v, v_speed, &v_min, &v_max, format, power); } bool ImGui::DragFloat2(const char* label, float v[2], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 2, v_speed, &v_min, &v_max, format, power); } bool ImGui::DragFloat3(const char* label, float v[3], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 3, v_speed, &v_min, &v_max, format, power); } bool ImGui::DragFloat4(const char* label, float v[4], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 4, v_speed, &v_min, &v_max, format, power); } bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed, float v_min, float v_max, const char* format, const char* format_max, float power) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; PushID(label); BeginGroup(); PushMultiItemsWidths(2, CalcItemWidth()); bool value_changed = DragFloat("##min", v_current_min, v_speed, (v_min >= v_max) ? -FLT_MAX : v_min, (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max), format, power); PopItemWidth(); SameLine(0, g.Style.ItemInnerSpacing.x); value_changed |= DragFloat("##max", v_current_max, v_speed, (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min), (v_min >= v_max) ? FLT_MAX : v_max, format_max ? format_max : format, power); PopItemWidth(); SameLine(0, g.Style.ItemInnerSpacing.x); TextEx(label, FindRenderedTextEnd(label)); EndGroup(); PopID(); return value_changed; } // NB: v_speed is float to allow adjusting the drag speed with more precision bool ImGui::DragInt(const char* label, int* v, float v_speed, int v_min, int v_max, const char* format) { return DragScalar(label, ImGuiDataType_S32, v, v_speed, &v_min, &v_max, format); } bool ImGui::DragInt2(const char* label, int v[2], float v_speed, int v_min, int v_max, const char* format) { return DragScalarN(label, ImGuiDataType_S32, v, 2, v_speed, &v_min, &v_max, format); } bool ImGui::DragInt3(const char* label, int v[3], float v_speed, int v_min, int v_max, const char* format) { return DragScalarN(label, ImGuiDataType_S32, v, 3, v_speed, &v_min, &v_max, format); } bool ImGui::DragInt4(const char* label, int v[4], float v_speed, int v_min, int v_max, const char* format) { return DragScalarN(label, ImGuiDataType_S32, v, 4, v_speed, &v_min, &v_max, format); } bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed, int v_min, int v_max, const char* format, const char* format_max) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; PushID(label); BeginGroup(); PushMultiItemsWidths(2, CalcItemWidth()); bool value_changed = DragInt("##min", v_current_min, v_speed, (v_min >= v_max) ? INT_MIN : v_min, (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max), format); PopItemWidth(); SameLine(0, g.Style.ItemInnerSpacing.x); value_changed |= DragInt("##max", v_current_max, v_speed, (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min), (v_min >= v_max) ? INT_MAX : v_max, format_max ? format_max : format); PopItemWidth(); SameLine(0, g.Style.ItemInnerSpacing.x); TextEx(label, FindRenderedTextEnd(label)); EndGroup(); PopID(); return value_changed; } //------------------------------------------------------------------------- // [SECTION] Widgets: SliderScalar, SliderFloat, SliderInt, etc. //------------------------------------------------------------------------- // - SliderBehaviorT<>() [Internal] // - SliderBehavior() [Internal] // - SliderScalar() // - SliderScalarN() // - SliderFloat() // - SliderFloat2() // - SliderFloat3() // - SliderFloat4() // - SliderAngle() // - SliderInt() // - SliderInt2() // - SliderInt3() // - SliderInt4() // - VSliderScalar() // - VSliderFloat() // - VSliderInt() //------------------------------------------------------------------------- template float ImGui::SliderCalcRatioFromValueT(ImGuiDataType data_type, TYPE v, TYPE v_min, TYPE v_max, float power, float linear_zero_pos) { if (v_min == v_max) return 0.0f; const bool is_power = (power != 1.0f) && (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double); const TYPE v_clamped = (v_min < v_max) ? ImClamp(v, v_min, v_max) : ImClamp(v, v_max, v_min); if (is_power) { if (v_clamped < 0.0f) { const float f = 1.0f - (float)((v_clamped - v_min) / (ImMin((TYPE)0, v_max) - v_min)); return (1.0f - ImPow(f, 1.0f/power)) * linear_zero_pos; } else { const float f = (float)((v_clamped - ImMax((TYPE)0, v_min)) / (v_max - ImMax((TYPE)0, v_min))); return linear_zero_pos + ImPow(f, 1.0f/power) * (1.0f - linear_zero_pos); } } // Linear slider return (float)((FLOATTYPE)(v_clamped - v_min) / (FLOATTYPE)(v_max - v_min)); } // FIXME: Move some of the code into SliderBehavior(). Current responsability is larger than what the equivalent DragBehaviorT<> does, we also do some rendering, etc. template bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, TYPE* v, const TYPE v_min, const TYPE v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb) { ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImGuiAxis axis = (flags & ImGuiSliderFlags_Vertical) ? ImGuiAxis_Y : ImGuiAxis_X; const bool is_decimal = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double); const bool is_power = (power != 1.0f) && is_decimal; const float grab_padding = 2.0f; const float slider_sz = (bb.Max[axis] - bb.Min[axis]) - grab_padding * 2.0f; float grab_sz = style.GrabMinSize; SIGNEDTYPE v_range = (v_min < v_max ? v_max - v_min : v_min - v_max); if (!is_decimal && v_range >= 0) // v_range < 0 may happen on integer overflows grab_sz = ImMax((float)(slider_sz / (v_range + 1)), style.GrabMinSize); // For integer sliders: if possible have the grab size represent 1 unit grab_sz = ImMin(grab_sz, slider_sz); const float slider_usable_sz = slider_sz - grab_sz; const float slider_usable_pos_min = bb.Min[axis] + grab_padding + grab_sz * 0.5f; const float slider_usable_pos_max = bb.Max[axis] - grab_padding - grab_sz * 0.5f; // For power curve sliders that cross over sign boundary we want the curve to be symmetric around 0.0f float linear_zero_pos; // 0.0->1.0f if (is_power && v_min * v_max < 0.0f) { // Different sign const FLOATTYPE linear_dist_min_to_0 = ImPow(v_min >= 0 ? (FLOATTYPE)v_min : -(FLOATTYPE)v_min, (FLOATTYPE)1.0f / power); const FLOATTYPE linear_dist_max_to_0 = ImPow(v_max >= 0 ? (FLOATTYPE)v_max : -(FLOATTYPE)v_max, (FLOATTYPE)1.0f / power); linear_zero_pos = (float)(linear_dist_min_to_0 / (linear_dist_min_to_0 + linear_dist_max_to_0)); } else { // Same sign linear_zero_pos = v_min < 0.0f ? 1.0f : 0.0f; } // Process interacting with the slider bool value_changed = false; if (g.ActiveId == id) { bool set_new_value = false; float clicked_t = 0.0f; if (g.ActiveIdSource == ImGuiInputSource_Mouse) { if (!g.IO.MouseDown[0]) { ClearActiveID(); } else { const float mouse_abs_pos = g.IO.MousePos[axis]; clicked_t = (slider_usable_sz > 0.0f) ? ImClamp((mouse_abs_pos - slider_usable_pos_min) / slider_usable_sz, 0.0f, 1.0f) : 0.0f; if (axis == ImGuiAxis_Y) clicked_t = 1.0f - clicked_t; set_new_value = true; } } else if (g.ActiveIdSource == ImGuiInputSource_Nav) { const ImVec2 delta2 = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard | ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 0.0f, 0.0f); float delta = (axis == ImGuiAxis_X) ? delta2.x : -delta2.y; if (g.NavActivatePressedId == id && !g.ActiveIdIsJustActivated) { ClearActiveID(); } else if (delta != 0.0f) { clicked_t = SliderCalcRatioFromValueT(data_type, *v, v_min, v_max, power, linear_zero_pos); const int decimal_precision = is_decimal ? ImParseFormatPrecision(format, 3) : 0; if ((decimal_precision > 0) || is_power) { delta /= 100.0f; // Gamepad/keyboard tweak speeds in % of slider bounds if (IsNavInputDown(ImGuiNavInput_TweakSlow)) delta /= 10.0f; } else { if ((v_range >= -100.0f && v_range <= 100.0f) || IsNavInputDown(ImGuiNavInput_TweakSlow)) delta = ((delta < 0.0f) ? -1.0f : +1.0f) / (float)v_range; // Gamepad/keyboard tweak speeds in integer steps else delta /= 100.0f; } if (IsNavInputDown(ImGuiNavInput_TweakFast)) delta *= 10.0f; set_new_value = true; if ((clicked_t >= 1.0f && delta > 0.0f) || (clicked_t <= 0.0f && delta < 0.0f)) // This is to avoid applying the saturation when already past the limits set_new_value = false; else clicked_t = ImSaturate(clicked_t + delta); } } if (set_new_value) { TYPE v_new; if (is_power) { // Account for power curve scale on both sides of the zero if (clicked_t < linear_zero_pos) { // Negative: rescale to the negative range before powering float a = 1.0f - (clicked_t / linear_zero_pos); a = ImPow(a, power); v_new = ImLerp(ImMin(v_max, (TYPE)0), v_min, a); } else { // Positive: rescale to the positive range before powering float a; if (ImFabs(linear_zero_pos - 1.0f) > 1.e-6f) a = (clicked_t - linear_zero_pos) / (1.0f - linear_zero_pos); else a = clicked_t; a = ImPow(a, power); v_new = ImLerp(ImMax(v_min, (TYPE)0), v_max, a); } } else { // Linear slider if (is_decimal) { v_new = ImLerp(v_min, v_max, clicked_t); } else { // For integer values we want the clicking position to match the grab box so we round above // This code is carefully tuned to work with large values (e.g. high ranges of U64) while preserving this property.. FLOATTYPE v_new_off_f = (v_max - v_min) * clicked_t; TYPE v_new_off_floor = (TYPE)(v_new_off_f); TYPE v_new_off_round = (TYPE)(v_new_off_f + (FLOATTYPE)0.5); if (v_new_off_floor < v_new_off_round) v_new = v_min + v_new_off_round; else v_new = v_min + v_new_off_floor; } } // Round to user desired precision based on format string v_new = RoundScalarWithFormatT(format, data_type, v_new); // Apply result if (*v != v_new) { *v = v_new; value_changed = true; } } } if (slider_sz < 1.0f) { *out_grab_bb = ImRect(bb.Min, bb.Min); } else { // Output grab position so it can be displayed by the caller float grab_t = SliderCalcRatioFromValueT(data_type, *v, v_min, v_max, power, linear_zero_pos); if (axis == ImGuiAxis_Y) grab_t = 1.0f - grab_t; const float grab_pos = ImLerp(slider_usable_pos_min, slider_usable_pos_max, grab_t); if (axis == ImGuiAxis_X) *out_grab_bb = ImRect(grab_pos - grab_sz * 0.5f, bb.Min.y + grab_padding, grab_pos + grab_sz * 0.5f, bb.Max.y - grab_padding); else *out_grab_bb = ImRect(bb.Min.x + grab_padding, grab_pos - grab_sz * 0.5f, bb.Max.x - grab_padding, grab_pos + grab_sz * 0.5f); } return value_changed; } // For 32-bit and larger types, slider bounds are limited to half the natural type range. // So e.g. an integer Slider between INT_MAX-10 and INT_MAX will fail, but an integer Slider between INT_MAX/2-10 and INT_MAX/2 will be ok. // It would be possible to lift that limitation with some work but it doesn't seem to be worth it for sliders. bool ImGui::SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb) { switch (data_type) { case ImGuiDataType_S8: { ImS32 v32 = (ImS32)*(ImS8*)p_v; bool r = SliderBehaviorT(bb, id, ImGuiDataType_S32, &v32, *(const ImS8*)p_min, *(const ImS8*)p_max, format, power, flags, out_grab_bb); if (r) *(ImS8*)p_v = (ImS8)v32; return r; } case ImGuiDataType_U8: { ImU32 v32 = (ImU32)*(ImU8*)p_v; bool r = SliderBehaviorT(bb, id, ImGuiDataType_U32, &v32, *(const ImU8*)p_min, *(const ImU8*)p_max, format, power, flags, out_grab_bb); if (r) *(ImU8*)p_v = (ImU8)v32; return r; } case ImGuiDataType_S16: { ImS32 v32 = (ImS32)*(ImS16*)p_v; bool r = SliderBehaviorT(bb, id, ImGuiDataType_S32, &v32, *(const ImS16*)p_min, *(const ImS16*)p_max, format, power, flags, out_grab_bb); if (r) *(ImS16*)p_v = (ImS16)v32; return r; } case ImGuiDataType_U16: { ImU32 v32 = (ImU32)*(ImU16*)p_v; bool r = SliderBehaviorT(bb, id, ImGuiDataType_U32, &v32, *(const ImU16*)p_min, *(const ImU16*)p_max, format, power, flags, out_grab_bb); if (r) *(ImU16*)p_v = (ImU16)v32; return r; } case ImGuiDataType_S32: IM_ASSERT(*(const ImS32*)p_min >= IM_S32_MIN/2 && *(const ImS32*)p_max <= IM_S32_MAX/2); return SliderBehaviorT(bb, id, data_type, (ImS32*)p_v, *(const ImS32*)p_min, *(const ImS32*)p_max, format, power, flags, out_grab_bb); case ImGuiDataType_U32: IM_ASSERT(*(const ImU32*)p_max <= IM_U32_MAX/2); return SliderBehaviorT(bb, id, data_type, (ImU32*)p_v, *(const ImU32*)p_min, *(const ImU32*)p_max, format, power, flags, out_grab_bb); case ImGuiDataType_S64: IM_ASSERT(*(const ImS64*)p_min >= IM_S64_MIN/2 && *(const ImS64*)p_max <= IM_S64_MAX/2); return SliderBehaviorT(bb, id, data_type, (ImS64*)p_v, *(const ImS64*)p_min, *(const ImS64*)p_max, format, power, flags, out_grab_bb); case ImGuiDataType_U64: IM_ASSERT(*(const ImU64*)p_max <= IM_U64_MAX/2); return SliderBehaviorT(bb, id, data_type, (ImU64*)p_v, *(const ImU64*)p_min, *(const ImU64*)p_max, format, power, flags, out_grab_bb); case ImGuiDataType_Float: IM_ASSERT(*(const float*)p_min >= -FLT_MAX/2.0f && *(const float*)p_max <= FLT_MAX/2.0f); return SliderBehaviorT(bb, id, data_type, (float*)p_v, *(const float*)p_min, *(const float*)p_max, format, power, flags, out_grab_bb); case ImGuiDataType_Double: IM_ASSERT(*(const double*)p_min >= -DBL_MAX/2.0f && *(const double*)p_max <= DBL_MAX/2.0f); return SliderBehaviorT(bb, id, data_type, (double*)p_v, *(const double*)p_min, *(const double*)p_max, format, power, flags, out_grab_bb); case ImGuiDataType_COUNT: break; } IM_ASSERT(0); return false; } // Note: p_data, p_min and p_max are _pointers_ to a memory address holding the data. For a slider, they are all required. // Read code of e.g. SliderFloat(), SliderInt() etc. or examples in 'Demo->Widgets->Data Types' to understand how to use this function directly. bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, float power) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImGuiID id = window->GetID(label); const float w = CalcItemWidth(); const ImVec2 label_size = CalcTextSize(label, NULL, true); const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f)); const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); ItemSize(total_bb, style.FramePadding.y); if (!ItemAdd(total_bb, id, &frame_bb)) return false; // Default format string when passing NULL if (format == NULL) format = DataTypeGetInfo(data_type)->PrintFmt; else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.) format = PatchFormatStringFloatToInt(format); // Tabbing or CTRL-clicking on Slider turns it into an input box const bool hovered = ItemHoverable(frame_bb, id); bool temp_input_is_active = TempInputTextIsActive(id); bool temp_input_start = false; if (!temp_input_is_active) { const bool focus_requested = FocusableItemRegister(window, id); const bool clicked = (hovered && g.IO.MouseClicked[0]); if (focus_requested || clicked || g.NavActivateId == id || g.NavInputId == id) { SetActiveID(id, window); SetFocusID(id, window); FocusWindow(window); g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right); if (focus_requested || (clicked && g.IO.KeyCtrl) || g.NavInputId == id) { temp_input_start = true; FocusableItemUnregister(window); } } } if (temp_input_is_active || temp_input_start) return TempInputTextScalar(frame_bb, id, label, data_type, p_data, format); // Draw frame const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); RenderNavHighlight(frame_bb, id); RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding); // Slider behavior ImRect grab_bb; const bool value_changed = SliderBehavior(frame_bb, id, data_type, p_data, p_min, p_max, format, power, ImGuiSliderFlags_None, &grab_bb); if (value_changed) MarkItemEdited(id); // Render grab if (grab_bb.Max.x > grab_bb.Min.x) window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding); // Display value using user-provided display format so user can add prefix/suffix/decorations to the value. char value_buf[64]; const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, p_data, format); RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f,0.5f)); if (label_size.x > 0.0f) RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags); return value_changed; } // Add multiple sliders on 1 line for compact edition of multiple components bool ImGui::SliderScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* v_min, const void* v_max, const char* format, float power) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; bool value_changed = false; BeginGroup(); PushID(label); PushMultiItemsWidths(components, CalcItemWidth()); size_t type_size = GDataTypeInfo[data_type].Size; for (int i = 0; i < components; i++) { PushID(i); if (i > 0) SameLine(0, g.Style.ItemInnerSpacing.x); value_changed |= SliderScalar("", data_type, v, v_min, v_max, format, power); PopID(); PopItemWidth(); v = (void*)((char*)v + type_size); } PopID(); const char* label_end = FindRenderedTextEnd(label); if (label != label_end) { SameLine(0, g.Style.ItemInnerSpacing.x); TextEx(label, label_end); } EndGroup(); return value_changed; } bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format, float power) { return SliderScalar(label, ImGuiDataType_Float, v, &v_min, &v_max, format, power); } bool ImGui::SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 2, &v_min, &v_max, format, power); } bool ImGui::SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 3, &v_min, &v_max, format, power); } bool ImGui::SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 4, &v_min, &v_max, format, power); } bool ImGui::SliderAngle(const char* label, float* v_rad, float v_degrees_min, float v_degrees_max, const char* format) { if (format == NULL) format = "%.0f deg"; float v_deg = (*v_rad) * 360.0f / (2*IM_PI); bool value_changed = SliderFloat(label, &v_deg, v_degrees_min, v_degrees_max, format, 1.0f); *v_rad = v_deg * (2*IM_PI) / 360.0f; return value_changed; } bool ImGui::SliderInt(const char* label, int* v, int v_min, int v_max, const char* format) { return SliderScalar(label, ImGuiDataType_S32, v, &v_min, &v_max, format); } bool ImGui::SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format) { return SliderScalarN(label, ImGuiDataType_S32, v, 2, &v_min, &v_max, format); } bool ImGui::SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format) { return SliderScalarN(label, ImGuiDataType_S32, v, 3, &v_min, &v_max, format); } bool ImGui::SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format) { return SliderScalarN(label, ImGuiDataType_S32, v, 4, &v_min, &v_max, format); } bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, float power) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImGuiID id = window->GetID(label); const ImVec2 label_size = CalcTextSize(label, NULL, true); const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size); const ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); ItemSize(bb, style.FramePadding.y); if (!ItemAdd(frame_bb, id)) return false; // Default format string when passing NULL if (format == NULL) format = DataTypeGetInfo(data_type)->PrintFmt; else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.) format = PatchFormatStringFloatToInt(format); const bool hovered = ItemHoverable(frame_bb, id); if ((hovered && g.IO.MouseClicked[0]) || g.NavActivateId == id || g.NavInputId == id) { SetActiveID(id, window); SetFocusID(id, window); FocusWindow(window); g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down); } // Draw frame const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); RenderNavHighlight(frame_bb, id); RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding); // Slider behavior ImRect grab_bb; const bool value_changed = SliderBehavior(frame_bb, id, data_type, p_data, p_min, p_max, format, power, ImGuiSliderFlags_Vertical, &grab_bb); if (value_changed) MarkItemEdited(id); // Render grab if (grab_bb.Max.y > grab_bb.Min.y) window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding); // Display value using user-provided display format so user can add prefix/suffix/decorations to the value. // For the vertical slider we allow centered text to overlap the frame padding char value_buf[64]; const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, p_data, format); RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f,0.0f)); if (label_size.x > 0.0f) RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); return value_changed; } bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format, float power) { return VSliderScalar(label, size, ImGuiDataType_Float, v, &v_min, &v_max, format, power); } bool ImGui::VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format) { return VSliderScalar(label, size, ImGuiDataType_S32, v, &v_min, &v_max, format); } //------------------------------------------------------------------------- // [SECTION] Widgets: InputScalar, InputFloat, InputInt, etc. //------------------------------------------------------------------------- // - ImParseFormatFindStart() [Internal] // - ImParseFormatFindEnd() [Internal] // - ImParseFormatTrimDecorations() [Internal] // - ImParseFormatPrecision() [Internal] // - TempInputTextScalar() [Internal] // - InputScalar() // - InputScalarN() // - InputFloat() // - InputFloat2() // - InputFloat3() // - InputFloat4() // - InputInt() // - InputInt2() // - InputInt3() // - InputInt4() // - InputDouble() //------------------------------------------------------------------------- // We don't use strchr() because our strings are usually very short and often start with '%' const char* ImParseFormatFindStart(const char* fmt) { while (char c = fmt[0]) { if (c == '%' && fmt[1] != '%') return fmt; else if (c == '%') fmt++; fmt++; } return fmt; } const char* ImParseFormatFindEnd(const char* fmt) { // Printf/scanf types modifiers: I/L/h/j/l/t/w/z. Other uppercase letters qualify as types aka end of the format. if (fmt[0] != '%') return fmt; const unsigned int ignored_uppercase_mask = (1 << ('I'-'A')) | (1 << ('L'-'A')); const unsigned int ignored_lowercase_mask = (1 << ('h'-'a')) | (1 << ('j'-'a')) | (1 << ('l'-'a')) | (1 << ('t'-'a')) | (1 << ('w'-'a')) | (1 << ('z'-'a')); for (char c; (c = *fmt) != 0; fmt++) { if (c >= 'A' && c <= 'Z' && ((1 << (c - 'A')) & ignored_uppercase_mask) == 0) return fmt + 1; if (c >= 'a' && c <= 'z' && ((1 << (c - 'a')) & ignored_lowercase_mask) == 0) return fmt + 1; } return fmt; } // Extract the format out of a format string with leading or trailing decorations // fmt = "blah blah" -> return fmt // fmt = "%.3f" -> return fmt // fmt = "hello %.3f" -> return fmt + 6 // fmt = "%.3f hello" -> return buf written with "%.3f" const char* ImParseFormatTrimDecorations(const char* fmt, char* buf, size_t buf_size) { const char* fmt_start = ImParseFormatFindStart(fmt); if (fmt_start[0] != '%') return fmt; const char* fmt_end = ImParseFormatFindEnd(fmt_start); if (fmt_end[0] == 0) // If we only have leading decoration, we don't need to copy the data. return fmt_start; ImStrncpy(buf, fmt_start, ImMin((size_t)(fmt_end - fmt_start) + 1, buf_size)); return buf; } // Parse display precision back from the display format string // FIXME: This is still used by some navigation code path to infer a minimum tweak step, but we should aim to rework widgets so it isn't needed. int ImParseFormatPrecision(const char* fmt, int default_precision) { fmt = ImParseFormatFindStart(fmt); if (fmt[0] != '%') return default_precision; fmt++; while (*fmt >= '0' && *fmt <= '9') fmt++; int precision = INT_MAX; if (*fmt == '.') { fmt = ImAtoi(fmt + 1, &precision); if (precision < 0 || precision > 99) precision = default_precision; } if (*fmt == 'e' || *fmt == 'E') // Maximum precision with scientific notation precision = -1; if ((*fmt == 'g' || *fmt == 'G') && precision == INT_MAX) precision = -1; return (precision == INT_MAX) ? default_precision : precision; } // Create text input in place of another active widget (e.g. used when doing a CTRL+Click on drag/slider widgets) // FIXME: Facilitate using this in variety of other situations. bool ImGui::TempInputTextScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format) { ImGuiContext& g = *GImGui; // On the first frame, g.TempInputTextId == 0, then on subsequent frames it becomes == id. // We clear ActiveID on the first frame to allow the InputText() taking it back. const bool init = (g.TempInputTextId != id); if (init) ClearActiveID(); char fmt_buf[32]; char data_buf[32]; format = ImParseFormatTrimDecorations(format, fmt_buf, IM_ARRAYSIZE(fmt_buf)); DataTypeFormatString(data_buf, IM_ARRAYSIZE(data_buf), data_type, p_data, format); ImStrTrimBlanks(data_buf); g.CurrentWindow->DC.CursorPos = bb.Min; ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoMarkEdited; flags |= ((data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) ? ImGuiInputTextFlags_CharsScientific : ImGuiInputTextFlags_CharsDecimal); bool value_changed = InputTextEx(label, NULL, data_buf, IM_ARRAYSIZE(data_buf), bb.GetSize(), flags); if (init) { // First frame we started displaying the InputText widget, we expect it to take the active id. IM_ASSERT(g.ActiveId == id); g.TempInputTextId = g.ActiveId; } if (value_changed) { value_changed = DataTypeApplyOpFromText(data_buf, g.InputTextState.InitialTextA.Data, data_type, p_data, NULL); if (value_changed) MarkItemEdited(id); } return value_changed; } // Note: p_data, p_step, p_step_fast are _pointers_ to a memory address holding the data. For an Input widget, p_step and p_step_fast are optional. // Read code of e.g. InputFloat(), InputInt() etc. or examples in 'Demo->Widgets->Data Types' to understand how to use this function directly. bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_step, const void* p_step_fast, const char* format, ImGuiInputTextFlags flags) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; ImGuiStyle& style = g.Style; if (format == NULL) format = DataTypeGetInfo(data_type)->PrintFmt; char buf[64]; DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format); bool value_changed = false; if ((flags & (ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsScientific)) == 0) flags |= ImGuiInputTextFlags_CharsDecimal; flags |= ImGuiInputTextFlags_AutoSelectAll; flags |= ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselve by comparing the actual data rather than the string. if (p_step != NULL) { const float button_size = GetFrameHeight(); BeginGroup(); // The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive() PushID(label); SetNextItemWidth(ImMax(1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2)); if (InputText("", buf, IM_ARRAYSIZE(buf), flags)) // PushId(label) + "" gives us the expected ID from outside point of view value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialTextA.Data, data_type, p_data, format); // Step buttons const ImVec2 backup_frame_padding = style.FramePadding; style.FramePadding.x = style.FramePadding.y; ImGuiButtonFlags button_flags = ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups; if (flags & ImGuiInputTextFlags_ReadOnly) button_flags |= ImGuiButtonFlags_Disabled; SameLine(0, style.ItemInnerSpacing.x); if (ButtonEx("-", ImVec2(button_size, button_size), button_flags)) { DataTypeApplyOp(data_type, '-', p_data, p_data, g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step); value_changed = true; } SameLine(0, style.ItemInnerSpacing.x); if (ButtonEx("+", ImVec2(button_size, button_size), button_flags)) { DataTypeApplyOp(data_type, '+', p_data, p_data, g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step); value_changed = true; } const char* label_end = FindRenderedTextEnd(label); if (label != label_end) { SameLine(0, style.ItemInnerSpacing.x); TextEx(label, label_end); } style.FramePadding = backup_frame_padding; PopID(); EndGroup(); } else { if (InputText(label, buf, IM_ARRAYSIZE(buf), flags)) value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialTextA.Data, data_type, p_data, format); } if (value_changed) MarkItemEdited(window->DC.LastItemId); return value_changed; } bool ImGui::InputScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_step, const void* p_step_fast, const char* format, ImGuiInputTextFlags flags) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; bool value_changed = false; BeginGroup(); PushID(label); PushMultiItemsWidths(components, CalcItemWidth()); size_t type_size = GDataTypeInfo[data_type].Size; for (int i = 0; i < components; i++) { PushID(i); if (i > 0) SameLine(0, g.Style.ItemInnerSpacing.x); value_changed |= InputScalar("", data_type, p_data, p_step, p_step_fast, format, flags); PopID(); PopItemWidth(); p_data = (void*)((char*)p_data + type_size); } PopID(); const char* label_end = FindRenderedTextEnd(label); if (label != label_end) { SameLine(0.0f, g.Style.ItemInnerSpacing.x); TextEx(label, label_end); } EndGroup(); return value_changed; } bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, const char* format, ImGuiInputTextFlags flags) { flags |= ImGuiInputTextFlags_CharsScientific; return InputScalar(label, ImGuiDataType_Float, (void*)v, (void*)(step>0.0f ? &step : NULL), (void*)(step_fast>0.0f ? &step_fast : NULL), format, flags); } bool ImGui::InputFloat2(const char* label, float v[2], const char* format, ImGuiInputTextFlags flags) { return InputScalarN(label, ImGuiDataType_Float, v, 2, NULL, NULL, format, flags); } bool ImGui::InputFloat3(const char* label, float v[3], const char* format, ImGuiInputTextFlags flags) { return InputScalarN(label, ImGuiDataType_Float, v, 3, NULL, NULL, format, flags); } bool ImGui::InputFloat4(const char* label, float v[4], const char* format, ImGuiInputTextFlags flags) { return InputScalarN(label, ImGuiDataType_Float, v, 4, NULL, NULL, format, flags); } // Prefer using "const char* format" directly, which is more flexible and consistent with other API. #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, int decimal_precision, ImGuiInputTextFlags flags) { char format[16] = "%f"; if (decimal_precision >= 0) ImFormatString(format, IM_ARRAYSIZE(format), "%%.%df", decimal_precision); return InputFloat(label, v, step, step_fast, format, flags); } bool ImGui::InputFloat2(const char* label, float v[2], int decimal_precision, ImGuiInputTextFlags flags) { char format[16] = "%f"; if (decimal_precision >= 0) ImFormatString(format, IM_ARRAYSIZE(format), "%%.%df", decimal_precision); return InputScalarN(label, ImGuiDataType_Float, v, 2, NULL, NULL, format, flags); } bool ImGui::InputFloat3(const char* label, float v[3], int decimal_precision, ImGuiInputTextFlags flags) { char format[16] = "%f"; if (decimal_precision >= 0) ImFormatString(format, IM_ARRAYSIZE(format), "%%.%df", decimal_precision); return InputScalarN(label, ImGuiDataType_Float, v, 3, NULL, NULL, format, flags); } bool ImGui::InputFloat4(const char* label, float v[4], int decimal_precision, ImGuiInputTextFlags flags) { char format[16] = "%f"; if (decimal_precision >= 0) ImFormatString(format, IM_ARRAYSIZE(format), "%%.%df", decimal_precision); return InputScalarN(label, ImGuiDataType_Float, v, 4, NULL, NULL, format, flags); } #endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS bool ImGui::InputInt(const char* label, int* v, int step, int step_fast, ImGuiInputTextFlags flags) { // Hexadecimal input provided as a convenience but the flag name is awkward. Typically you'd use InputText() to parse your own data, if you want to handle prefixes. const char* format = (flags & ImGuiInputTextFlags_CharsHexadecimal) ? "%08X" : "%d"; return InputScalar(label, ImGuiDataType_S32, (void*)v, (void*)(step>0 ? &step : NULL), (void*)(step_fast>0 ? &step_fast : NULL), format, flags); } bool ImGui::InputInt2(const char* label, int v[2], ImGuiInputTextFlags flags) { return InputScalarN(label, ImGuiDataType_S32, v, 2, NULL, NULL, "%d", flags); } bool ImGui::InputInt3(const char* label, int v[3], ImGuiInputTextFlags flags) { return InputScalarN(label, ImGuiDataType_S32, v, 3, NULL, NULL, "%d", flags); } bool ImGui::InputInt4(const char* label, int v[4], ImGuiInputTextFlags flags) { return InputScalarN(label, ImGuiDataType_S32, v, 4, NULL, NULL, "%d", flags); } bool ImGui::InputDouble(const char* label, double* v, double step, double step_fast, const char* format, ImGuiInputTextFlags flags) { flags |= ImGuiInputTextFlags_CharsScientific; return InputScalar(label, ImGuiDataType_Double, (void*)v, (void*)(step>0.0 ? &step : NULL), (void*)(step_fast>0.0 ? &step_fast : NULL), format, flags); } //------------------------------------------------------------------------- // [SECTION] Widgets: InputText, InputTextMultiline, InputTextWithHint //------------------------------------------------------------------------- // - InputText() // - InputTextWithHint() // - InputTextMultiline() // - InputTextEx() [Internal] //------------------------------------------------------------------------- bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) { IM_ASSERT(!(flags & ImGuiInputTextFlags_Multiline)); // call InputTextMultiline() return InputTextEx(label, NULL, buf, (int)buf_size, ImVec2(0,0), flags, callback, user_data); } bool ImGui::InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) { return InputTextEx(label, NULL, buf, (int)buf_size, size, flags | ImGuiInputTextFlags_Multiline, callback, user_data); } bool ImGui::InputTextWithHint(const char* label, const char* hint, char* buf, size_t buf_size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) { IM_ASSERT(!(flags & ImGuiInputTextFlags_Multiline)); // call InputTextMultiline() return InputTextEx(label, hint, buf, (int)buf_size, ImVec2(0, 0), flags, callback, user_data); } static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end) { int line_count = 0; const char* s = text_begin; while (char c = *s++) // We are only matching for \n so we can ignore UTF-8 decoding if (c == '\n') line_count++; s--; if (s[0] != '\n' && s[0] != '\r') line_count++; *out_text_end = s; return line_count; } static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining, ImVec2* out_offset, bool stop_on_new_line) { ImGuiContext& g = *GImGui; ImFont* font = g.Font; const float line_height = g.FontSize; const float scale = line_height / font->FontSize; ImVec2 text_size = ImVec2(0,0); float line_width = 0.0f; const ImWchar* s = text_begin; while (s < text_end) { unsigned int c = (unsigned int)(*s++); if (c == '\n') { text_size.x = ImMax(text_size.x, line_width); text_size.y += line_height; line_width = 0.0f; if (stop_on_new_line) break; continue; } if (c == '\r') continue; const float char_width = font->GetCharAdvance((ImWchar)c) * scale; line_width += char_width; } if (text_size.x < line_width) text_size.x = line_width; if (out_offset) *out_offset = ImVec2(line_width, text_size.y + line_height); // offset allow for the possibility of sitting after a trailing \n if (line_width > 0 || text_size.y == 0.0f) // whereas size.y will ignore the trailing \n text_size.y += line_height; if (remaining) *remaining = s; return text_size; } // Wrapper for stb_textedit.h to edit text (our wrapper is for: statically sized buffer, single-line, wchar characters. InputText converts between UTF-8 and wchar) namespace ImStb { static int STB_TEXTEDIT_STRINGLEN(const STB_TEXTEDIT_STRING* obj) { return obj->CurLenW; } static ImWchar STB_TEXTEDIT_GETCHAR(const STB_TEXTEDIT_STRING* obj, int idx) { return obj->TextW[idx]; } static float STB_TEXTEDIT_GETWIDTH(STB_TEXTEDIT_STRING* obj, int line_start_idx, int char_idx) { ImWchar c = obj->TextW[line_start_idx + char_idx]; if (c == '\n') return STB_TEXTEDIT_GETWIDTH_NEWLINE; ImGuiContext& g = *GImGui; return g.Font->GetCharAdvance(c) * (g.FontSize / g.Font->FontSize); } static int STB_TEXTEDIT_KEYTOTEXT(int key) { return key >= 0x200000 ? 0 : key; } static ImWchar STB_TEXTEDIT_NEWLINE = '\n'; static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, STB_TEXTEDIT_STRING* obj, int line_start_idx) { const ImWchar* text = obj->TextW.Data; const ImWchar* text_remaining = NULL; const ImVec2 size = InputTextCalcTextSizeW(text + line_start_idx, text + obj->CurLenW, &text_remaining, NULL, true); r->x0 = 0.0f; r->x1 = size.x; r->baseline_y_delta = size.y; r->ymin = 0.0f; r->ymax = size.y; r->num_chars = (int)(text_remaining - (text + line_start_idx)); } static bool is_separator(unsigned int c) { return ImCharIsBlankW(c) || c==',' || c==';' || c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' || c=='|'; } static int is_word_boundary_from_right(STB_TEXTEDIT_STRING* obj, int idx) { return idx > 0 ? (is_separator( obj->TextW[idx-1] ) && !is_separator( obj->TextW[idx] ) ) : 1; } static int STB_TEXTEDIT_MOVEWORDLEFT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { idx--; while (idx >= 0 && !is_word_boundary_from_right(obj, idx)) idx--; return idx < 0 ? 0 : idx; } #ifdef __APPLE__ // FIXME: Move setting to IO structure static int is_word_boundary_from_left(STB_TEXTEDIT_STRING* obj, int idx) { return idx > 0 ? (!is_separator( obj->TextW[idx-1] ) && is_separator( obj->TextW[idx] ) ) : 1; } static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { idx++; int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_left(obj, idx)) idx++; return idx > len ? len : idx; } #else static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { idx++; int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_right(obj, idx)) idx++; return idx > len ? len : idx; } #endif #define STB_TEXTEDIT_MOVEWORDLEFT STB_TEXTEDIT_MOVEWORDLEFT_IMPL // They need to be #define for stb_textedit.h #define STB_TEXTEDIT_MOVEWORDRIGHT STB_TEXTEDIT_MOVEWORDRIGHT_IMPL static void STB_TEXTEDIT_DELETECHARS(STB_TEXTEDIT_STRING* obj, int pos, int n) { ImWchar* dst = obj->TextW.Data + pos; // We maintain our buffer length in both UTF-8 and wchar formats obj->CurLenA -= ImTextCountUtf8BytesFromStr(dst, dst + n); obj->CurLenW -= n; // Offset remaining text (FIXME-OPT: Use memmove) const ImWchar* src = obj->TextW.Data + pos + n; while (ImWchar c = *src++) *dst++ = c; *dst = '\0'; } static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, int pos, const ImWchar* new_text, int new_text_len) { const bool is_resizable = (obj->UserFlags & ImGuiInputTextFlags_CallbackResize) != 0; const int text_len = obj->CurLenW; IM_ASSERT(pos <= text_len); const int new_text_len_utf8 = ImTextCountUtf8BytesFromStr(new_text, new_text + new_text_len); if (!is_resizable && (new_text_len_utf8 + obj->CurLenA + 1 > obj->BufCapacityA)) return false; // Grow internal buffer if needed if (new_text_len + text_len + 1 > obj->TextW.Size) { if (!is_resizable) return false; IM_ASSERT(text_len < obj->TextW.Size); obj->TextW.resize(text_len + ImClamp(new_text_len * 4, 32, ImMax(256, new_text_len)) + 1); } ImWchar* text = obj->TextW.Data; if (pos != text_len) memmove(text + pos + new_text_len, text + pos, (size_t)(text_len - pos) * sizeof(ImWchar)); memcpy(text + pos, new_text, (size_t)new_text_len * sizeof(ImWchar)); obj->CurLenW += new_text_len; obj->CurLenA += new_text_len_utf8; obj->TextW[obj->CurLenW] = '\0'; return true; } // We don't use an enum so we can build even with conflicting symbols (if another user of stb_textedit.h leak their STB_TEXTEDIT_K_* symbols) #define STB_TEXTEDIT_K_LEFT 0x200000 // keyboard input to move cursor left #define STB_TEXTEDIT_K_RIGHT 0x200001 // keyboard input to move cursor right #define STB_TEXTEDIT_K_UP 0x200002 // keyboard input to move cursor up #define STB_TEXTEDIT_K_DOWN 0x200003 // keyboard input to move cursor down #define STB_TEXTEDIT_K_LINESTART 0x200004 // keyboard input to move cursor to start of line #define STB_TEXTEDIT_K_LINEEND 0x200005 // keyboard input to move cursor to end of line #define STB_TEXTEDIT_K_TEXTSTART 0x200006 // keyboard input to move cursor to start of text #define STB_TEXTEDIT_K_TEXTEND 0x200007 // keyboard input to move cursor to end of text #define STB_TEXTEDIT_K_DELETE 0x200008 // keyboard input to delete selection or character under cursor #define STB_TEXTEDIT_K_BACKSPACE 0x200009 // keyboard input to delete selection or character left of cursor #define STB_TEXTEDIT_K_UNDO 0x20000A // keyboard input to perform undo #define STB_TEXTEDIT_K_REDO 0x20000B // keyboard input to perform redo #define STB_TEXTEDIT_K_WORDLEFT 0x20000C // keyboard input to move cursor left one word #define STB_TEXTEDIT_K_WORDRIGHT 0x20000D // keyboard input to move cursor right one word #define STB_TEXTEDIT_K_SHIFT 0x400000 #define STB_TEXTEDIT_IMPLEMENTATION #include "imstb_textedit.h" // stb_textedit internally allows for a single undo record to do addition and deletion, but somehow, calling // the stb_textedit_paste() function creates two separate records, so we perform it manually. (FIXME: Report to nothings/stb?) static void stb_textedit_replace(STB_TEXTEDIT_STRING* str, STB_TexteditState* state, const STB_TEXTEDIT_CHARTYPE* text, int text_len) { stb_text_makeundo_replace(str, state, 0, str->CurLenW, text_len); ImStb::STB_TEXTEDIT_DELETECHARS(str, 0, str->CurLenW); if (text_len <= 0) return; if (ImStb::STB_TEXTEDIT_INSERTCHARS(str, 0, text, text_len)) { state->cursor = text_len; state->has_preferred_x = 0; return; } IM_ASSERT(0); // Failed to insert character, normally shouldn't happen because of how we currently use stb_textedit_replace() } } // namespace ImStb void ImGuiInputTextState::OnKeyPressed(int key) { stb_textedit_key(this, &Stb, key); CursorFollow = true; CursorAnimReset(); } ImGuiInputTextCallbackData::ImGuiInputTextCallbackData() { memset(this, 0, sizeof(*this)); } // Public API to manipulate UTF-8 text // We expose UTF-8 to the user (unlike the STB_TEXTEDIT_* functions which are manipulating wchar) // FIXME: The existence of this rarely exercised code path is a bit of a nuisance. void ImGuiInputTextCallbackData::DeleteChars(int pos, int bytes_count) { IM_ASSERT(pos + bytes_count <= BufTextLen); char* dst = Buf + pos; const char* src = Buf + pos + bytes_count; while (char c = *src++) *dst++ = c; *dst = '\0'; if (CursorPos + bytes_count >= pos) CursorPos -= bytes_count; else if (CursorPos >= pos) CursorPos = pos; SelectionStart = SelectionEnd = CursorPos; BufDirty = true; BufTextLen -= bytes_count; } void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, const char* new_text_end) { const bool is_resizable = (Flags & ImGuiInputTextFlags_CallbackResize) != 0; const int new_text_len = new_text_end ? (int)(new_text_end - new_text) : (int)strlen(new_text); if (new_text_len + BufTextLen >= BufSize) { if (!is_resizable) return; // Contrary to STB_TEXTEDIT_INSERTCHARS() this is working in the UTF8 buffer, hence the midly similar code (until we remove the U16 buffer alltogether!) ImGuiContext& g = *GImGui; ImGuiInputTextState* edit_state = &g.InputTextState; IM_ASSERT(edit_state->ID != 0 && g.ActiveId == edit_state->ID); IM_ASSERT(Buf == edit_state->TextA.Data); int new_buf_size = BufTextLen + ImClamp(new_text_len * 4, 32, ImMax(256, new_text_len)) + 1; edit_state->TextA.reserve(new_buf_size + 1); Buf = edit_state->TextA.Data; BufSize = edit_state->BufCapacityA = new_buf_size; } if (BufTextLen != pos) memmove(Buf + pos + new_text_len, Buf + pos, (size_t)(BufTextLen - pos)); memcpy(Buf + pos, new_text, (size_t)new_text_len * sizeof(char)); Buf[BufTextLen + new_text_len] = '\0'; if (CursorPos >= pos) CursorPos += new_text_len; SelectionStart = SelectionEnd = CursorPos; BufDirty = true; BufTextLen += new_text_len; } // Return false to discard a character. static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) { unsigned int c = *p_char; // Filter non-printable (NB: isprint is unreliable! see #2467) if (c < 0x20) { bool pass = false; pass |= (c == '\n' && (flags & ImGuiInputTextFlags_Multiline)); pass |= (c == '\t' && (flags & ImGuiInputTextFlags_AllowTabInput)); if (!pass) return false; } // We ignore Ascii representation of delete (emitted from Backspace on OSX, see #2578, #2817) if (c == 127) return false; // Filter private Unicode range. GLFW on OSX seems to send private characters for special keys like arrow keys (FIXME) if (c >= 0xE000 && c <= 0xF8FF) return false; // Filter Unicode ranges we are not handling in this build. if (c > IM_UNICODE_CODEPOINT_MAX) return false; // Generic named filters if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsScientific)) { if (flags & ImGuiInputTextFlags_CharsDecimal) if (!(c >= '0' && c <= '9') && (c != '.') && (c != '-') && (c != '+') && (c != '*') && (c != '/')) return false; if (flags & ImGuiInputTextFlags_CharsScientific) if (!(c >= '0' && c <= '9') && (c != '.') && (c != '-') && (c != '+') && (c != '*') && (c != '/') && (c != 'e') && (c != 'E')) return false; if (flags & ImGuiInputTextFlags_CharsHexadecimal) if (!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f') && !(c >= 'A' && c <= 'F')) return false; if (flags & ImGuiInputTextFlags_CharsUppercase) if (c >= 'a' && c <= 'z') *p_char = (c += (unsigned int)('A'-'a')); if (flags & ImGuiInputTextFlags_CharsNoBlank) if (ImCharIsBlankW(c)) return false; } // Custom callback filter if (flags & ImGuiInputTextFlags_CallbackCharFilter) { ImGuiInputTextCallbackData callback_data; memset(&callback_data, 0, sizeof(ImGuiInputTextCallbackData)); callback_data.EventFlag = ImGuiInputTextFlags_CallbackCharFilter; callback_data.EventChar = (ImWchar)c; callback_data.Flags = flags; callback_data.UserData = user_data; if (callback(&callback_data) != 0) return false; *p_char = callback_data.EventChar; if (!callback_data.EventChar) return false; } return true; } // Edit a string of text // - buf_size account for the zero-terminator, so a buf_size of 6 can hold "Hello" but not "Hello!". // This is so we can easily call InputText() on static arrays using ARRAYSIZE() and to match // Note that in std::string world, capacity() would omit 1 byte used by the zero-terminator. // - When active, hold on a privately held copy of the text (and apply back to 'buf'). So changing 'buf' while the InputText is active has no effect. // - If you want to use ImGui::InputText() with std::string, see misc/cpp/imgui_stdlib.h // (FIXME: Rather confusing and messy function, among the worse part of our codebase, expecting to rewrite a V2 at some point.. Partly because we are // doing UTF8 > U16 > UTF8 conversions on the go to easily interface with stb_textedit. Ideally should stay in UTF-8 all the time. See https://github.com/nothings/stb/issues/188) bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* callback_user_data) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackHistory) && (flags & ImGuiInputTextFlags_Multiline))); // Can't use both together (they both use up/down keys) IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackCompletion) && (flags & ImGuiInputTextFlags_AllowTabInput))); // Can't use both together (they both use tab key) ImGuiContext& g = *GImGui; ImGuiIO& io = g.IO; const ImGuiStyle& style = g.Style; const bool RENDER_SELECTION_WHEN_INACTIVE = false; const bool is_multiline = (flags & ImGuiInputTextFlags_Multiline) != 0; const bool is_readonly = (flags & ImGuiInputTextFlags_ReadOnly) != 0; const bool is_password = (flags & ImGuiInputTextFlags_Password) != 0; const bool is_undoable = (flags & ImGuiInputTextFlags_NoUndoRedo) == 0; const bool is_resizable = (flags & ImGuiInputTextFlags_CallbackResize) != 0; if (is_resizable) IM_ASSERT(callback != NULL); // Must provide a callback if you set the ImGuiInputTextFlags_CallbackResize flag! if (is_multiline) // Open group before calling GetID() because groups tracks id created within their scope, BeginGroup(); const ImGuiID id = window->GetID(label); const ImVec2 label_size = CalcTextSize(label, NULL, true); const ImVec2 frame_size = CalcItemSize(size_arg, CalcItemWidth(), (is_multiline ? g.FontSize * 8.0f : label_size.y) + style.FramePadding.y*2.0f); // Arbitrary default of 8 lines high for multi-line const ImVec2 total_size = ImVec2(frame_size.x + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), frame_size.y); const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size); const ImRect total_bb(frame_bb.Min, frame_bb.Min + total_size); ImGuiWindow* draw_window = window; ImVec2 inner_size = frame_size; if (is_multiline) { if (!ItemAdd(total_bb, id, &frame_bb)) { ItemSize(total_bb, style.FramePadding.y); EndGroup(); return false; } // We reproduce the contents of BeginChildFrame() in order to provide 'label' so our window internal data are easier to read/debug. PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]); PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding); PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize); PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding); bool child_visible = BeginChildEx(label, id, frame_bb.GetSize(), true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysUseWindowPadding); PopStyleVar(3); PopStyleColor(); if (!child_visible) { EndChild(); EndGroup(); return false; } draw_window = g.CurrentWindow; // Child window draw_window->DC.NavLayerActiveMaskNext |= draw_window->DC.NavLayerCurrentMask; // This is to ensure that EndChild() will display a navigation highlight so we can "enter" into it. inner_size.x -= draw_window->ScrollbarSizes.x; } else { ItemSize(total_bb, style.FramePadding.y); if (!ItemAdd(total_bb, id, &frame_bb)) return false; } const bool hovered = ItemHoverable(frame_bb, id); if (hovered) g.MouseCursor = ImGuiMouseCursor_TextInput; // NB: we are only allowed to access 'edit_state' if we are the active widget. ImGuiInputTextState* state = NULL; if (g.InputTextState.ID == id) state = &g.InputTextState; const bool focus_requested = FocusableItemRegister(window, id); const bool focus_requested_by_code = focus_requested && (g.FocusRequestCurrWindow == window && g.FocusRequestCurrCounterRegular == window->DC.FocusCounterRegular); const bool focus_requested_by_tab = focus_requested && !focus_requested_by_code; const bool user_clicked = hovered && io.MouseClicked[0]; const bool user_nav_input_start = (g.ActiveId != id) && ((g.NavInputId == id) || (g.NavActivateId == id && g.NavInputSource == ImGuiInputSource_NavKeyboard)); const bool user_scroll_finish = is_multiline && state != NULL && g.ActiveId == 0 && g.ActiveIdPreviousFrame == GetWindowScrollbarID(draw_window, ImGuiAxis_Y); const bool user_scroll_active = is_multiline && state != NULL && g.ActiveId == GetWindowScrollbarID(draw_window, ImGuiAxis_Y); bool clear_active_id = false; bool select_all = (g.ActiveId != id) && ((flags & ImGuiInputTextFlags_AutoSelectAll) != 0 || user_nav_input_start) && (!is_multiline); const bool init_make_active = (focus_requested || user_clicked || user_scroll_finish || user_nav_input_start); const bool init_state = (init_make_active || user_scroll_active); if (init_state && g.ActiveId != id) { // Access state even if we don't own it yet. state = &g.InputTextState; state->CursorAnimReset(); // Take a copy of the initial buffer value (both in original UTF-8 format and converted to wchar) // From the moment we focused we are ignoring the content of 'buf' (unless we are in read-only mode) const int buf_len = (int)strlen(buf); state->InitialTextA.resize(buf_len + 1); // UTF-8. we use +1 to make sure that .Data is always pointing to at least an empty string. memcpy(state->InitialTextA.Data, buf, buf_len + 1); // Start edition const char* buf_end = NULL; state->TextW.resize(buf_size + 1); // wchar count <= UTF-8 count. we use +1 to make sure that .Data is always pointing to at least an empty string. state->TextA.resize(0); state->TextAIsValid = false; // TextA is not valid yet (we will display buf until then) state->CurLenW = ImTextStrFromUtf8(state->TextW.Data, buf_size, buf, NULL, &buf_end); state->CurLenA = (int)(buf_end - buf); // We can't get the result from ImStrncpy() above because it is not UTF-8 aware. Here we'll cut off malformed UTF-8. // Preserve cursor position and undo/redo stack if we come back to same widget // FIXME: For non-readonly widgets we might be able to require that TextAIsValid && TextA == buf ? (untested) and discard undo stack if user buffer has changed. const bool recycle_state = (state->ID == id); if (recycle_state) { // Recycle existing cursor/selection/undo stack but clamp position // Note a single mouse click will override the cursor/position immediately by calling stb_textedit_click handler. state->CursorClamp(); } else { state->ID = id; state->ScrollX = 0.0f; stb_textedit_initialize_state(&state->Stb, !is_multiline); if (!is_multiline && focus_requested_by_code) select_all = true; } if (flags & ImGuiInputTextFlags_AlwaysInsertMode) state->Stb.insert_mode = 1; if (!is_multiline && (focus_requested_by_tab || (user_clicked && io.KeyCtrl))) select_all = true; } if (g.ActiveId != id && init_make_active) { IM_ASSERT(state && state->ID == id); SetActiveID(id, window); SetFocusID(id, window); FocusWindow(window); // Declare our inputs IM_ASSERT(ImGuiNavInput_COUNT < 32); g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right); if (is_multiline || (flags & ImGuiInputTextFlags_CallbackHistory)) g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down); g.ActiveIdUsingNavInputMask |= (1 << ImGuiNavInput_Cancel); g.ActiveIdUsingKeyInputMask |= ((ImU64)1 << ImGuiKey_Home) | ((ImU64)1 << ImGuiKey_End); if (is_multiline) g.ActiveIdUsingKeyInputMask |= ((ImU64)1 << ImGuiKey_PageUp) | ((ImU64)1 << ImGuiKey_PageDown); // FIXME-NAV: Page up/down actually not supported yet by widget, but claim them ahead. if (flags & (ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_AllowTabInput)) // Disable keyboard tabbing out as we will use the \t character. g.ActiveIdUsingKeyInputMask |= ((ImU64)1 << ImGuiKey_Tab); } // We have an edge case if ActiveId was set through another widget (e.g. widget being swapped), clear id immediately (don't wait until the end of the function) if (g.ActiveId == id && state == NULL) ClearActiveID(); // Release focus when we click outside if (g.ActiveId == id && io.MouseClicked[0] && !init_state && !init_make_active) //-V560 clear_active_id = true; // Lock the decision of whether we are going to take the path displaying the cursor or selection const bool render_cursor = (g.ActiveId == id) || (state && user_scroll_active); bool render_selection = state && state->HasSelection() && (RENDER_SELECTION_WHEN_INACTIVE || render_cursor); bool value_changed = false; bool enter_pressed = false; // When read-only we always use the live data passed to the function // FIXME-OPT: Because our selection/cursor code currently needs the wide text we need to convert it when active, which is not ideal :( if (is_readonly && state != NULL && (render_cursor || render_selection)) { const char* buf_end = NULL; state->TextW.resize(buf_size + 1); state->CurLenW = ImTextStrFromUtf8(state->TextW.Data, state->TextW.Size, buf, NULL, &buf_end); state->CurLenA = (int)(buf_end - buf); state->CursorClamp(); render_selection &= state->HasSelection(); } // Select the buffer to render. const bool buf_display_from_state = (render_cursor || render_selection || g.ActiveId == id) && !is_readonly && state && state->TextAIsValid; const bool is_displaying_hint = (hint != NULL && (buf_display_from_state ? state->TextA.Data : buf)[0] == 0); // Password pushes a temporary font with only a fallback glyph if (is_password && !is_displaying_hint) { const ImFontGlyph* glyph = g.Font->FindGlyph('*'); ImFont* password_font = &g.InputTextPasswordFont; password_font->FontSize = g.Font->FontSize; password_font->Scale = g.Font->Scale; password_font->DisplayOffset = g.Font->DisplayOffset; password_font->Ascent = g.Font->Ascent; password_font->Descent = g.Font->Descent; password_font->ContainerAtlas = g.Font->ContainerAtlas; password_font->FallbackGlyph = glyph; password_font->FallbackAdvanceX = glyph->AdvanceX; IM_ASSERT(password_font->Glyphs.empty() && password_font->IndexAdvanceX.empty() && password_font->IndexLookup.empty()); PushFont(password_font); } // Process mouse inputs and character inputs int backup_current_text_length = 0; if (g.ActiveId == id) { IM_ASSERT(state != NULL); backup_current_text_length = state->CurLenA; state->BufCapacityA = buf_size; state->UserFlags = flags; state->UserCallback = callback; state->UserCallbackData = callback_user_data; // Although we are active we don't prevent mouse from hovering other elements unless we are interacting right now with the widget. // Down the line we should have a cleaner library-wide concept of Selected vs Active. g.ActiveIdAllowOverlap = !io.MouseDown[0]; g.WantTextInputNextFrame = 1; // Edit in progress const float mouse_x = (io.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + state->ScrollX; const float mouse_y = (is_multiline ? (io.MousePos.y - draw_window->DC.CursorPos.y - style.FramePadding.y) : (g.FontSize*0.5f)); const bool is_osx = io.ConfigMacOSXBehaviors; if (select_all || (hovered && !is_osx && io.MouseDoubleClicked[0])) { state->SelectAll(); state->SelectedAllMouseLock = true; } else if (hovered && is_osx && io.MouseDoubleClicked[0]) { // Double-click select a word only, OS X style (by simulating keystrokes) state->OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT); state->OnKeyPressed(STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT); } else if (io.MouseClicked[0] && !state->SelectedAllMouseLock) { if (hovered) { stb_textedit_click(state, &state->Stb, mouse_x, mouse_y); state->CursorAnimReset(); } } else if (io.MouseDown[0] && !state->SelectedAllMouseLock && (io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f)) { stb_textedit_drag(state, &state->Stb, mouse_x, mouse_y); state->CursorAnimReset(); state->CursorFollow = true; } if (state->SelectedAllMouseLock && !io.MouseDown[0]) state->SelectedAllMouseLock = false; // It is ill-defined whether the back-end needs to send a \t character when pressing the TAB keys. // Win32 and GLFW naturally do it but not SDL. const bool ignore_char_inputs = (io.KeyCtrl && !io.KeyAlt) || (is_osx && io.KeySuper); if ((flags & ImGuiInputTextFlags_AllowTabInput) && IsKeyPressedMap(ImGuiKey_Tab) && !ignore_char_inputs && !io.KeyShift && !is_readonly) if (!io.InputQueueCharacters.contains('\t')) { unsigned int c = '\t'; // Insert TAB if (InputTextFilterCharacter(&c, flags, callback, callback_user_data)) state->OnKeyPressed((int)c); } // Process regular text input (before we check for Return because using some IME will effectively send a Return?) // We ignore CTRL inputs, but need to allow ALT+CTRL as some keyboards (e.g. German) use AltGR (which _is_ Alt+Ctrl) to input certain characters. if (io.InputQueueCharacters.Size > 0) { if (!ignore_char_inputs && !is_readonly && !user_nav_input_start) for (int n = 0; n < io.InputQueueCharacters.Size; n++) { // Insert character if they pass filtering unsigned int c = (unsigned int)io.InputQueueCharacters[n]; if (c == '\t' && io.KeyShift) continue; if (InputTextFilterCharacter(&c, flags, callback, callback_user_data)) state->OnKeyPressed((int)c); } // Consume characters io.InputQueueCharacters.resize(0); } } // Process other shortcuts/key-presses bool cancel_edit = false; if (g.ActiveId == id && !g.ActiveIdIsJustActivated && !clear_active_id) { IM_ASSERT(state != NULL); const int k_mask = (io.KeyShift ? STB_TEXTEDIT_K_SHIFT : 0); const bool is_osx = io.ConfigMacOSXBehaviors; const bool is_shortcut_key = (is_osx ? (io.KeySuper && !io.KeyCtrl) : (io.KeyCtrl && !io.KeySuper)) && !io.KeyAlt && !io.KeyShift; // OS X style: Shortcuts using Cmd/Super instead of Ctrl const bool is_osx_shift_shortcut = is_osx && io.KeySuper && io.KeyShift && !io.KeyCtrl && !io.KeyAlt; const bool is_wordmove_key_down = is_osx ? io.KeyAlt : io.KeyCtrl; // OS X style: Text editing cursor movement using Alt instead of Ctrl const bool is_startend_key_down = is_osx && io.KeySuper && !io.KeyCtrl && !io.KeyAlt; // OS X style: Line/Text Start and End using Cmd+Arrows instead of Home/End const bool is_ctrl_key_only = io.KeyCtrl && !io.KeyShift && !io.KeyAlt && !io.KeySuper; const bool is_shift_key_only = io.KeyShift && !io.KeyCtrl && !io.KeyAlt && !io.KeySuper; const bool is_cut = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_X)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Delete))) && !is_readonly && !is_password && (!is_multiline || state->HasSelection()); const bool is_copy = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_C)) || (is_ctrl_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && !is_password && (!is_multiline || state->HasSelection()); const bool is_paste = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_V)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && !is_readonly; const bool is_undo = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_Z)) && !is_readonly && is_undoable); const bool is_redo = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_Y)) || (is_osx_shift_shortcut && IsKeyPressedMap(ImGuiKey_Z))) && !is_readonly && is_undoable; if (IsKeyPressedMap(ImGuiKey_LeftArrow)) { state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINESTART : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT : STB_TEXTEDIT_K_LEFT) | k_mask); } else if (IsKeyPressedMap(ImGuiKey_RightArrow)) { state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT) | k_mask); } else if (IsKeyPressedMap(ImGuiKey_UpArrow) && is_multiline) { if (io.KeyCtrl) SetScrollY(draw_window, ImMax(draw_window->Scroll.y - g.FontSize, 0.0f)); else state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTSTART : STB_TEXTEDIT_K_UP) | k_mask); } else if (IsKeyPressedMap(ImGuiKey_DownArrow) && is_multiline) { if (io.KeyCtrl) SetScrollY(draw_window, ImMin(draw_window->Scroll.y + g.FontSize, GetScrollMaxY())); else state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTEND : STB_TEXTEDIT_K_DOWN) | k_mask); } else if (IsKeyPressedMap(ImGuiKey_Home)) { state->OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTSTART | k_mask : STB_TEXTEDIT_K_LINESTART | k_mask); } else if (IsKeyPressedMap(ImGuiKey_End)) { state->OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTEND | k_mask : STB_TEXTEDIT_K_LINEEND | k_mask); } else if (IsKeyPressedMap(ImGuiKey_Delete) && !is_readonly) { state->OnKeyPressed(STB_TEXTEDIT_K_DELETE | k_mask); } else if (IsKeyPressedMap(ImGuiKey_Backspace) && !is_readonly) { if (!state->HasSelection()) { if (is_wordmove_key_down) state->OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT|STB_TEXTEDIT_K_SHIFT); else if (is_osx && io.KeySuper && !io.KeyAlt && !io.KeyCtrl) state->OnKeyPressed(STB_TEXTEDIT_K_LINESTART|STB_TEXTEDIT_K_SHIFT); } state->OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask); } else if (IsKeyPressedMap(ImGuiKey_Enter) || IsKeyPressedMap(ImGuiKey_KeyPadEnter)) { bool ctrl_enter_for_new_line = (flags & ImGuiInputTextFlags_CtrlEnterForNewLine) != 0; if (!is_multiline || (ctrl_enter_for_new_line && !io.KeyCtrl) || (!ctrl_enter_for_new_line && io.KeyCtrl)) { enter_pressed = clear_active_id = true; } else if (!is_readonly) { unsigned int c = '\n'; // Insert new line if (InputTextFilterCharacter(&c, flags, callback, callback_user_data)) state->OnKeyPressed((int)c); } } else if (IsKeyPressedMap(ImGuiKey_Escape)) { clear_active_id = cancel_edit = true; } else if (is_undo || is_redo) { state->OnKeyPressed(is_undo ? STB_TEXTEDIT_K_UNDO : STB_TEXTEDIT_K_REDO); state->ClearSelection(); } else if (is_shortcut_key && IsKeyPressedMap(ImGuiKey_A)) { state->SelectAll(); state->CursorFollow = true; } else if (is_cut || is_copy) { // Cut, Copy if (io.SetClipboardTextFn) { const int ib = state->HasSelection() ? ImMin(state->Stb.select_start, state->Stb.select_end) : 0; const int ie = state->HasSelection() ? ImMax(state->Stb.select_start, state->Stb.select_end) : state->CurLenW; const int clipboard_data_len = ImTextCountUtf8BytesFromStr(state->TextW.Data + ib, state->TextW.Data + ie) + 1; char* clipboard_data = (char*)IM_ALLOC(clipboard_data_len * sizeof(char)); ImTextStrToUtf8(clipboard_data, clipboard_data_len, state->TextW.Data + ib, state->TextW.Data + ie); SetClipboardText(clipboard_data); MemFree(clipboard_data); } if (is_cut) { if (!state->HasSelection()) state->SelectAll(); state->CursorFollow = true; stb_textedit_cut(state, &state->Stb); } } else if (is_paste) { if (const char* clipboard = GetClipboardText()) { // Filter pasted buffer const int clipboard_len = (int)strlen(clipboard); ImWchar* clipboard_filtered = (ImWchar*)IM_ALLOC((clipboard_len+1) * sizeof(ImWchar)); int clipboard_filtered_len = 0; for (const char* s = clipboard; *s; ) { unsigned int c; s += ImTextCharFromUtf8(&c, s, NULL); if (c == 0) break; if (!InputTextFilterCharacter(&c, flags, callback, callback_user_data)) continue; clipboard_filtered[clipboard_filtered_len++] = (ImWchar)c; } clipboard_filtered[clipboard_filtered_len] = 0; if (clipboard_filtered_len > 0) // If everything was filtered, ignore the pasting operation { stb_textedit_paste(state, &state->Stb, clipboard_filtered, clipboard_filtered_len); state->CursorFollow = true; } MemFree(clipboard_filtered); } } // Update render selection flag after events have been handled, so selection highlight can be displayed during the same frame. render_selection |= state->HasSelection() && (RENDER_SELECTION_WHEN_INACTIVE || render_cursor); } // Process callbacks and apply result back to user's buffer. if (g.ActiveId == id) { IM_ASSERT(state != NULL); const char* apply_new_text = NULL; int apply_new_text_length = 0; if (cancel_edit) { // Restore initial value. Only return true if restoring to the initial value changes the current buffer contents. if (!is_readonly && strcmp(buf, state->InitialTextA.Data) != 0) { // Push records into the undo stack so we can CTRL+Z the revert operation itself apply_new_text = state->InitialTextA.Data; apply_new_text_length = state->InitialTextA.Size - 1; ImVector w_text; if (apply_new_text_length > 0) { w_text.resize(ImTextCountCharsFromUtf8(apply_new_text, apply_new_text + apply_new_text_length) + 1); ImTextStrFromUtf8(w_text.Data, w_text.Size, apply_new_text, apply_new_text + apply_new_text_length); } stb_textedit_replace(state, &state->Stb, w_text.Data, (apply_new_text_length > 0) ? (w_text.Size - 1) : 0); } } // When using 'ImGuiInputTextFlags_EnterReturnsTrue' as a special case we reapply the live buffer back to the input buffer before clearing ActiveId, even though strictly speaking it wasn't modified on this frame. // If we didn't do that, code like InputInt() with ImGuiInputTextFlags_EnterReturnsTrue would fail. // This also allows the user to use InputText() with ImGuiInputTextFlags_EnterReturnsTrue without maintaining any user-side storage (please note that if you use this property along ImGuiInputTextFlags_CallbackResize you can end up with your temporary string object unnecessarily allocating once a frame, either store your string data, either if you don't then don't use ImGuiInputTextFlags_CallbackResize). bool apply_edit_back_to_user_buffer = !cancel_edit || (enter_pressed && (flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0); if (apply_edit_back_to_user_buffer) { // Apply new value immediately - copy modified buffer back // Note that as soon as the input box is active, the in-widget value gets priority over any underlying modification of the input buffer // FIXME: We actually always render 'buf' when calling DrawList->AddText, making the comment above incorrect. // FIXME-OPT: CPU waste to do this every time the widget is active, should mark dirty state from the stb_textedit callbacks. if (!is_readonly) { state->TextAIsValid = true; state->TextA.resize(state->TextW.Size * 4 + 1); ImTextStrToUtf8(state->TextA.Data, state->TextA.Size, state->TextW.Data, NULL); } // User callback if ((flags & (ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory | ImGuiInputTextFlags_CallbackAlways)) != 0) { IM_ASSERT(callback != NULL); // The reason we specify the usage semantic (Completion/History) is that Completion needs to disable keyboard TABBING at the moment. ImGuiInputTextFlags event_flag = 0; ImGuiKey event_key = ImGuiKey_COUNT; if ((flags & ImGuiInputTextFlags_CallbackCompletion) != 0 && IsKeyPressedMap(ImGuiKey_Tab)) { event_flag = ImGuiInputTextFlags_CallbackCompletion; event_key = ImGuiKey_Tab; } else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressedMap(ImGuiKey_UpArrow)) { event_flag = ImGuiInputTextFlags_CallbackHistory; event_key = ImGuiKey_UpArrow; } else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressedMap(ImGuiKey_DownArrow)) { event_flag = ImGuiInputTextFlags_CallbackHistory; event_key = ImGuiKey_DownArrow; } else if (flags & ImGuiInputTextFlags_CallbackAlways) event_flag = ImGuiInputTextFlags_CallbackAlways; if (event_flag) { ImGuiInputTextCallbackData callback_data; memset(&callback_data, 0, sizeof(ImGuiInputTextCallbackData)); callback_data.EventFlag = event_flag; callback_data.Flags = flags; callback_data.UserData = callback_user_data; callback_data.EventKey = event_key; callback_data.Buf = state->TextA.Data; callback_data.BufTextLen = state->CurLenA; callback_data.BufSize = state->BufCapacityA; callback_data.BufDirty = false; // We have to convert from wchar-positions to UTF-8-positions, which can be pretty slow (an incentive to ditch the ImWchar buffer, see https://github.com/nothings/stb/issues/188) ImWchar* text = state->TextW.Data; const int utf8_cursor_pos = callback_data.CursorPos = ImTextCountUtf8BytesFromStr(text, text + state->Stb.cursor); const int utf8_selection_start = callback_data.SelectionStart = ImTextCountUtf8BytesFromStr(text, text + state->Stb.select_start); const int utf8_selection_end = callback_data.SelectionEnd = ImTextCountUtf8BytesFromStr(text, text + state->Stb.select_end); // Call user code callback(&callback_data); // Read back what user may have modified IM_ASSERT(callback_data.Buf == state->TextA.Data); // Invalid to modify those fields IM_ASSERT(callback_data.BufSize == state->BufCapacityA); IM_ASSERT(callback_data.Flags == flags); if (callback_data.CursorPos != utf8_cursor_pos) { state->Stb.cursor = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.CursorPos); state->CursorFollow = true; } if (callback_data.SelectionStart != utf8_selection_start) { state->Stb.select_start = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionStart); } if (callback_data.SelectionEnd != utf8_selection_end) { state->Stb.select_end = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionEnd); } if (callback_data.BufDirty) { IM_ASSERT(callback_data.BufTextLen == (int)strlen(callback_data.Buf)); // You need to maintain BufTextLen if you change the text! if (callback_data.BufTextLen > backup_current_text_length && is_resizable) state->TextW.resize(state->TextW.Size + (callback_data.BufTextLen - backup_current_text_length)); state->CurLenW = ImTextStrFromUtf8(state->TextW.Data, state->TextW.Size, callback_data.Buf, NULL); state->CurLenA = callback_data.BufTextLen; // Assume correct length and valid UTF-8 from user, saves us an extra strlen() state->CursorAnimReset(); } } } // Will copy result string if modified if (!is_readonly && strcmp(state->TextA.Data, buf) != 0) { apply_new_text = state->TextA.Data; apply_new_text_length = state->CurLenA; } } // Copy result to user buffer if (apply_new_text) { // We cannot test for 'backup_current_text_length != apply_new_text_length' here because we have no guarantee that the size // of our owned buffer matches the size of the string object held by the user, and by design we allow InputText() to be used // without any storage on user's side. IM_ASSERT(apply_new_text_length >= 0); if (is_resizable) { ImGuiInputTextCallbackData callback_data; callback_data.EventFlag = ImGuiInputTextFlags_CallbackResize; callback_data.Flags = flags; callback_data.Buf = buf; callback_data.BufTextLen = apply_new_text_length; callback_data.BufSize = ImMax(buf_size, apply_new_text_length + 1); callback_data.UserData = callback_user_data; callback(&callback_data); buf = callback_data.Buf; buf_size = callback_data.BufSize; apply_new_text_length = ImMin(callback_data.BufTextLen, buf_size - 1); IM_ASSERT(apply_new_text_length <= buf_size); } //IMGUI_DEBUG_LOG("InputText(\"%s\"): apply_new_text length %d\n", label, apply_new_text_length); // If the underlying buffer resize was denied or not carried to the next frame, apply_new_text_length+1 may be >= buf_size. ImStrncpy(buf, apply_new_text, ImMin(apply_new_text_length + 1, buf_size)); value_changed = true; } // Clear temporary user storage state->UserFlags = 0; state->UserCallback = NULL; state->UserCallbackData = NULL; } // Release active ID at the end of the function (so e.g. pressing Return still does a final application of the value) if (clear_active_id && g.ActiveId == id) ClearActiveID(); // Render frame if (!is_multiline) { RenderNavHighlight(frame_bb, id); RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); } const ImVec4 clip_rect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + inner_size.x, frame_bb.Min.y + inner_size.y); // Not using frame_bb.Max because we have adjusted size ImVec2 draw_pos = is_multiline ? draw_window->DC.CursorPos : frame_bb.Min + style.FramePadding; ImVec2 text_size(0.0f, 0.0f); // Set upper limit of single-line InputTextEx() at 2 million characters strings. The current pathological worst case is a long line // without any carriage return, which would makes ImFont::RenderText() reserve too many vertices and probably crash. Avoid it altogether. // Note that we only use this limit on single-line InputText(), so a pathologically large line on a InputTextMultiline() would still crash. const int buf_display_max_length = 2 * 1024 * 1024; const char* buf_display = buf_display_from_state ? state->TextA.Data : buf; //-V595 const char* buf_display_end = NULL; // We have specialized paths below for setting the length if (is_displaying_hint) { buf_display = hint; buf_display_end = hint + strlen(hint); } // Render text. We currently only render selection when the widget is active or while scrolling. // FIXME: We could remove the '&& render_cursor' to keep rendering selection when inactive. if (render_cursor || render_selection) { IM_ASSERT(state != NULL); if (!is_displaying_hint) buf_display_end = buf_display + state->CurLenA; // Render text (with cursor and selection) // This is going to be messy. We need to: // - Display the text (this alone can be more easily clipped) // - Handle scrolling, highlight selection, display cursor (those all requires some form of 1d->2d cursor position calculation) // - Measure text height (for scrollbar) // We are attempting to do most of that in **one main pass** to minimize the computation cost (non-negligible for large amount of text) + 2nd pass for selection rendering (we could merge them by an extra refactoring effort) // FIXME: This should occur on buf_display but we'd need to maintain cursor/select_start/select_end for UTF-8. const ImWchar* text_begin = state->TextW.Data; ImVec2 cursor_offset, select_start_offset; { // Find lines numbers straddling 'cursor' (slot 0) and 'select_start' (slot 1) positions. const ImWchar* searches_input_ptr[2] = { NULL, NULL }; int searches_result_line_no[2] = { -1000, -1000 }; int searches_remaining = 0; if (render_cursor) { searches_input_ptr[0] = text_begin + state->Stb.cursor; searches_result_line_no[0] = -1; searches_remaining++; } if (render_selection) { searches_input_ptr[1] = text_begin + ImMin(state->Stb.select_start, state->Stb.select_end); searches_result_line_no[1] = -1; searches_remaining++; } // Iterate all lines to find our line numbers // In multi-line mode, we never exit the loop until all lines are counted, so add one extra to the searches_remaining counter. searches_remaining += is_multiline ? 1 : 0; int line_count = 0; //for (const ImWchar* s = text_begin; (s = (const ImWchar*)wcschr((const wchar_t*)s, (wchar_t)'\n')) != NULL; s++) // FIXME-OPT: Could use this when wchar_t are 16-bit for (const ImWchar* s = text_begin; *s != 0; s++) if (*s == '\n') { line_count++; if (searches_result_line_no[0] == -1 && s >= searches_input_ptr[0]) { searches_result_line_no[0] = line_count; if (--searches_remaining <= 0) break; } if (searches_result_line_no[1] == -1 && s >= searches_input_ptr[1]) { searches_result_line_no[1] = line_count; if (--searches_remaining <= 0) break; } } line_count++; if (searches_result_line_no[0] == -1) searches_result_line_no[0] = line_count; if (searches_result_line_no[1] == -1) searches_result_line_no[1] = line_count; // Calculate 2d position by finding the beginning of the line and measuring distance cursor_offset.x = InputTextCalcTextSizeW(ImStrbolW(searches_input_ptr[0], text_begin), searches_input_ptr[0]).x; cursor_offset.y = searches_result_line_no[0] * g.FontSize; if (searches_result_line_no[1] >= 0) { select_start_offset.x = InputTextCalcTextSizeW(ImStrbolW(searches_input_ptr[1], text_begin), searches_input_ptr[1]).x; select_start_offset.y = searches_result_line_no[1] * g.FontSize; } // Store text height (note that we haven't calculated text width at all, see GitHub issues #383, #1224) if (is_multiline) text_size = ImVec2(inner_size.x, line_count * g.FontSize); } // Scroll if (render_cursor && state->CursorFollow) { // Horizontal scroll in chunks of quarter width if (!(flags & ImGuiInputTextFlags_NoHorizontalScroll)) { const float scroll_increment_x = inner_size.x * 0.25f; if (cursor_offset.x < state->ScrollX) state->ScrollX = IM_FLOOR(ImMax(0.0f, cursor_offset.x - scroll_increment_x)); else if (cursor_offset.x - inner_size.x >= state->ScrollX) state->ScrollX = IM_FLOOR(cursor_offset.x - inner_size.x + scroll_increment_x); } else { state->ScrollX = 0.0f; } // Vertical scroll if (is_multiline) { float scroll_y = draw_window->Scroll.y; if (cursor_offset.y - g.FontSize < scroll_y) scroll_y = ImMax(0.0f, cursor_offset.y - g.FontSize); else if (cursor_offset.y - inner_size.y >= scroll_y) scroll_y = cursor_offset.y - inner_size.y; draw_pos.y += (draw_window->Scroll.y - scroll_y); // Manipulate cursor pos immediately avoid a frame of lag draw_window->Scroll.y = scroll_y; } state->CursorFollow = false; } // Draw selection const ImVec2 draw_scroll = ImVec2(state->ScrollX, 0.0f); if (render_selection) { const ImWchar* text_selected_begin = text_begin + ImMin(state->Stb.select_start, state->Stb.select_end); const ImWchar* text_selected_end = text_begin + ImMax(state->Stb.select_start, state->Stb.select_end); ImU32 bg_color = GetColorU32(ImGuiCol_TextSelectedBg, render_cursor ? 1.0f : 0.6f); // FIXME: current code flow mandate that render_cursor is always true here, we are leaving the transparent one for tests. float bg_offy_up = is_multiline ? 0.0f : -1.0f; // FIXME: those offsets should be part of the style? they don't play so well with multi-line selection. float bg_offy_dn = is_multiline ? 0.0f : 2.0f; ImVec2 rect_pos = draw_pos + select_start_offset - draw_scroll; for (const ImWchar* p = text_selected_begin; p < text_selected_end; ) { if (rect_pos.y > clip_rect.w + g.FontSize) break; if (rect_pos.y < clip_rect.y) { //p = (const ImWchar*)wmemchr((const wchar_t*)p, '\n', text_selected_end - p); // FIXME-OPT: Could use this when wchar_t are 16-bit //p = p ? p + 1 : text_selected_end; while (p < text_selected_end) if (*p++ == '\n') break; } else { ImVec2 rect_size = InputTextCalcTextSizeW(p, text_selected_end, &p, NULL, true); if (rect_size.x <= 0.0f) rect_size.x = IM_FLOOR(g.Font->GetCharAdvance((ImWchar)' ') * 0.50f); // So we can see selected empty lines ImRect rect(rect_pos + ImVec2(0.0f, bg_offy_up - g.FontSize), rect_pos +ImVec2(rect_size.x, bg_offy_dn)); rect.ClipWith(clip_rect); if (rect.Overlaps(clip_rect)) draw_window->DrawList->AddRectFilled(rect.Min, rect.Max, bg_color); } rect_pos.x = draw_pos.x - draw_scroll.x; rect_pos.y += g.FontSize; } } // We test for 'buf_display_max_length' as a way to avoid some pathological cases (e.g. single-line 1 MB string) which would make ImDrawList crash. if (is_multiline || (buf_display_end - buf_display) < buf_display_max_length) { ImU32 col = GetColorU32(is_displaying_hint ? ImGuiCol_TextDisabled : ImGuiCol_Text); draw_window->DrawList->AddText(g.Font, g.FontSize, draw_pos - draw_scroll, col, buf_display, buf_display_end, 0.0f, is_multiline ? NULL : &clip_rect); } // Draw blinking cursor if (render_cursor) { state->CursorAnim += io.DeltaTime; bool cursor_is_visible = (!g.IO.ConfigInputTextCursorBlink) || (state->CursorAnim <= 0.0f) || ImFmod(state->CursorAnim, 1.20f) <= 0.80f; ImVec2 cursor_screen_pos = draw_pos + cursor_offset - draw_scroll; ImRect cursor_screen_rect(cursor_screen_pos.x, cursor_screen_pos.y - g.FontSize + 0.5f, cursor_screen_pos.x + 1.0f, cursor_screen_pos.y - 1.5f); if (cursor_is_visible && cursor_screen_rect.Overlaps(clip_rect)) draw_window->DrawList->AddLine(cursor_screen_rect.Min, cursor_screen_rect.GetBL(), GetColorU32(ImGuiCol_Text)); // Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.) if (!is_readonly) g.PlatformImePos = ImVec2(cursor_screen_pos.x - 1.0f, cursor_screen_pos.y - g.FontSize); } } else { // Render text only (no selection, no cursor) if (is_multiline) text_size = ImVec2(inner_size.x, InputTextCalcTextLenAndLineCount(buf_display, &buf_display_end) * g.FontSize); // We don't need width else if (!is_displaying_hint && g.ActiveId == id) buf_display_end = buf_display + state->CurLenA; else if (!is_displaying_hint) buf_display_end = buf_display + strlen(buf_display); if (is_multiline || (buf_display_end - buf_display) < buf_display_max_length) { ImU32 col = GetColorU32(is_displaying_hint ? ImGuiCol_TextDisabled : ImGuiCol_Text); draw_window->DrawList->AddText(g.Font, g.FontSize, draw_pos, col, buf_display, buf_display_end, 0.0f, is_multiline ? NULL : &clip_rect); } } if (is_multiline) { Dummy(text_size + ImVec2(0.0f, g.FontSize)); // Always add room to scroll an extra line EndChild(); EndGroup(); } if (is_password && !is_displaying_hint) PopFont(); // Log as text if (g.LogEnabled && !(is_password && !is_displaying_hint)) LogRenderedText(&draw_pos, buf_display, buf_display_end); if (label_size.x > 0) RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); if (value_changed && !(flags & ImGuiInputTextFlags_NoMarkEdited)) MarkItemEdited(id); IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags); if ((flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0) return enter_pressed; else return value_changed; } //------------------------------------------------------------------------- // [SECTION] Widgets: ColorEdit, ColorPicker, ColorButton, etc. //------------------------------------------------------------------------- // - ColorEdit3() // - ColorEdit4() // - ColorPicker3() // - RenderColorRectWithAlphaCheckerboard() [Internal] // - ColorPicker4() // - ColorButton() // - SetColorEditOptions() // - ColorTooltip() [Internal] // - ColorEditOptionsPopup() [Internal] // - ColorPickerOptionsPopup() [Internal] //------------------------------------------------------------------------- bool ImGui::ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags) { return ColorEdit4(label, col, flags | ImGuiColorEditFlags_NoAlpha); } // Edit colors components (each component in 0.0f..1.0f range). // See enum ImGuiColorEditFlags_ for available options. e.g. Only access 3 floats if ImGuiColorEditFlags_NoAlpha flag is set. // With typical options: Left-click on colored square to open color picker. Right-click to open option menu. CTRL-Click over input fields to edit them and TAB to go to next item. bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const float square_sz = GetFrameHeight(); const float w_full = CalcItemWidth(); const float w_button = (flags & ImGuiColorEditFlags_NoSmallPreview) ? 0.0f : (square_sz + style.ItemInnerSpacing.x); const float w_inputs = w_full - w_button; const char* label_display_end = FindRenderedTextEnd(label); g.NextItemData.ClearFlags(); BeginGroup(); PushID(label); // If we're not showing any slider there's no point in doing any HSV conversions const ImGuiColorEditFlags flags_untouched = flags; if (flags & ImGuiColorEditFlags_NoInputs) flags = (flags & (~ImGuiColorEditFlags__DisplayMask)) | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_NoOptions; // Context menu: display and modify options (before defaults are applied) if (!(flags & ImGuiColorEditFlags_NoOptions)) ColorEditOptionsPopup(col, flags); // Read stored options if (!(flags & ImGuiColorEditFlags__DisplayMask)) flags |= (g.ColorEditOptions & ImGuiColorEditFlags__DisplayMask); if (!(flags & ImGuiColorEditFlags__DataTypeMask)) flags |= (g.ColorEditOptions & ImGuiColorEditFlags__DataTypeMask); if (!(flags & ImGuiColorEditFlags__PickerMask)) flags |= (g.ColorEditOptions & ImGuiColorEditFlags__PickerMask); if (!(flags & ImGuiColorEditFlags__InputMask)) flags |= (g.ColorEditOptions & ImGuiColorEditFlags__InputMask); flags |= (g.ColorEditOptions & ~(ImGuiColorEditFlags__DisplayMask | ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags__InputMask)); IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__DisplayMask)); // Check that only 1 is selected IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__InputMask)); // Check that only 1 is selected const bool alpha = (flags & ImGuiColorEditFlags_NoAlpha) == 0; const bool hdr = (flags & ImGuiColorEditFlags_HDR) != 0; const int components = alpha ? 4 : 3; // Convert to the formats we need float f[4] = { col[0], col[1], col[2], alpha ? col[3] : 1.0f }; if ((flags & ImGuiColorEditFlags_InputHSV) && (flags & ImGuiColorEditFlags_DisplayRGB)) ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]); else if ((flags & ImGuiColorEditFlags_InputRGB) && (flags & ImGuiColorEditFlags_DisplayHSV)) { // Hue is lost when converting from greyscale rgb (saturation=0). Restore it. ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]); if (memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0) { if (f[1] == 0) f[0] = g.ColorEditLastHue; if (f[2] == 0) f[1] = g.ColorEditLastSat; } } int i[4] = { IM_F32_TO_INT8_UNBOUND(f[0]), IM_F32_TO_INT8_UNBOUND(f[1]), IM_F32_TO_INT8_UNBOUND(f[2]), IM_F32_TO_INT8_UNBOUND(f[3]) }; bool value_changed = false; bool value_changed_as_float = false; const ImVec2 pos = window->DC.CursorPos; const float inputs_offset_x = (style.ColorButtonPosition == ImGuiDir_Left) ? w_button : 0.0f; window->DC.CursorPos.x = pos.x + inputs_offset_x; if ((flags & (ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV)) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0) { // RGB/HSV 0..255 Sliders const float w_item_one = ImMax(1.0f, IM_FLOOR((w_inputs - (style.ItemInnerSpacing.x) * (components-1)) / (float)components)); const float w_item_last = ImMax(1.0f, IM_FLOOR(w_inputs - (w_item_one + style.ItemInnerSpacing.x) * (components-1))); const bool hide_prefix = (w_item_one <= CalcTextSize((flags & ImGuiColorEditFlags_Float) ? "M:0.000" : "M:000").x); static const char* ids[4] = { "##X", "##Y", "##Z", "##W" }; static const char* fmt_table_int[3][4] = { { "%3d", "%3d", "%3d", "%3d" }, // Short display { "R:%3d", "G:%3d", "B:%3d", "A:%3d" }, // Long display for RGBA { "H:%3d", "S:%3d", "V:%3d", "A:%3d" } // Long display for HSVA }; static const char* fmt_table_float[3][4] = { { "%0.3f", "%0.3f", "%0.3f", "%0.3f" }, // Short display { "R:%0.3f", "G:%0.3f", "B:%0.3f", "A:%0.3f" }, // Long display for RGBA { "H:%0.3f", "S:%0.3f", "V:%0.3f", "A:%0.3f" } // Long display for HSVA }; const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_DisplayHSV) ? 2 : 1; for (int n = 0; n < components; n++) { if (n > 0) SameLine(0, style.ItemInnerSpacing.x); SetNextItemWidth((n + 1 < components) ? w_item_one : w_item_last); // FIXME: When ImGuiColorEditFlags_HDR flag is passed HS values snap in weird ways when SV values go below 0. if (flags & ImGuiColorEditFlags_Float) { value_changed |= DragFloat(ids[n], &f[n], 1.0f/255.0f, 0.0f, hdr ? 0.0f : 1.0f, fmt_table_float[fmt_idx][n]); value_changed_as_float |= value_changed; } else { value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n]); } if (!(flags & ImGuiColorEditFlags_NoOptions)) OpenPopupOnItemClick("context"); } } else if ((flags & ImGuiColorEditFlags_DisplayHex) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0) { // RGB Hexadecimal Input char buf[64]; if (alpha) ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", ImClamp(i[0],0,255), ImClamp(i[1],0,255), ImClamp(i[2],0,255), ImClamp(i[3],0,255)); else ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", ImClamp(i[0],0,255), ImClamp(i[1],0,255), ImClamp(i[2],0,255)); SetNextItemWidth(w_inputs); if (InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase)) { value_changed = true; char* p = buf; while (*p == '#' || ImCharIsBlankA(*p)) p++; i[0] = i[1] = i[2] = i[3] = 0; if (alpha) sscanf(p, "%02X%02X%02X%02X", (unsigned int*)&i[0], (unsigned int*)&i[1], (unsigned int*)&i[2], (unsigned int*)&i[3]); // Treat at unsigned (%X is unsigned) else sscanf(p, "%02X%02X%02X", (unsigned int*)&i[0], (unsigned int*)&i[1], (unsigned int*)&i[2]); } if (!(flags & ImGuiColorEditFlags_NoOptions)) OpenPopupOnItemClick("context"); } ImGuiWindow* picker_active_window = NULL; if (!(flags & ImGuiColorEditFlags_NoSmallPreview)) { const float button_offset_x = ((flags & ImGuiColorEditFlags_NoInputs) || (style.ColorButtonPosition == ImGuiDir_Left)) ? 0.0f : w_inputs + style.ItemInnerSpacing.x; window->DC.CursorPos = ImVec2(pos.x + button_offset_x, pos.y); const ImVec4 col_v4(col[0], col[1], col[2], alpha ? col[3] : 1.0f); if (ColorButton("##ColorButton", col_v4, flags)) { if (!(flags & ImGuiColorEditFlags_NoPicker)) { // Store current color and open a picker g.ColorPickerRef = col_v4; OpenPopup("picker"); SetNextWindowPos(window->DC.LastItemRect.GetBL() + ImVec2(-1,style.ItemSpacing.y)); } } if (!(flags & ImGuiColorEditFlags_NoOptions)) OpenPopupOnItemClick("context"); if (BeginPopup("picker")) { picker_active_window = g.CurrentWindow; if (label != label_display_end) { TextEx(label, label_display_end); Spacing(); } ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar; ImGuiColorEditFlags picker_flags = (flags_untouched & picker_flags_to_forward) | ImGuiColorEditFlags__DisplayMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf; SetNextItemWidth(square_sz * 12.0f); // Use 256 + bar sizes? value_changed |= ColorPicker4("##picker", col, picker_flags, &g.ColorPickerRef.x); EndPopup(); } } if (label != label_display_end && !(flags & ImGuiColorEditFlags_NoLabel)) { const float text_offset_x = (flags & ImGuiColorEditFlags_NoInputs) ? w_button : w_full + style.ItemInnerSpacing.x; window->DC.CursorPos = ImVec2(pos.x + text_offset_x, pos.y + style.FramePadding.y); TextEx(label, label_display_end); } // Convert back if (value_changed && picker_active_window == NULL) { if (!value_changed_as_float) for (int n = 0; n < 4; n++) f[n] = i[n] / 255.0f; if ((flags & ImGuiColorEditFlags_DisplayHSV) && (flags & ImGuiColorEditFlags_InputRGB)) { g.ColorEditLastHue = f[0]; g.ColorEditLastSat = f[1]; ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]); memcpy(g.ColorEditLastColor, f, sizeof(float) * 3); } if ((flags & ImGuiColorEditFlags_DisplayRGB) && (flags & ImGuiColorEditFlags_InputHSV)) ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]); col[0] = f[0]; col[1] = f[1]; col[2] = f[2]; if (alpha) col[3] = f[3]; } PopID(); EndGroup(); // Drag and Drop Target // NB: The flag test is merely an optional micro-optimization, BeginDragDropTarget() does the same test. if ((window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect) && !(flags & ImGuiColorEditFlags_NoDragDrop) && BeginDragDropTarget()) { bool accepted_drag_drop = false; if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F)) { memcpy((float*)col, payload->Data, sizeof(float) * 3); // Preserve alpha if any //-V512 value_changed = accepted_drag_drop = true; } if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F)) { memcpy((float*)col, payload->Data, sizeof(float) * components); value_changed = accepted_drag_drop = true; } // Drag-drop payloads are always RGB if (accepted_drag_drop && (flags & ImGuiColorEditFlags_InputHSV)) ColorConvertRGBtoHSV(col[0], col[1], col[2], col[0], col[1], col[2]); EndDragDropTarget(); } // When picker is being actively used, use its active id so IsItemActive() will function on ColorEdit4(). if (picker_active_window && g.ActiveId != 0 && g.ActiveIdWindow == picker_active_window) window->DC.LastItemId = g.ActiveId; if (value_changed) MarkItemEdited(window->DC.LastItemId); return value_changed; } bool ImGui::ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags) { float col4[4] = { col[0], col[1], col[2], 1.0f }; if (!ColorPicker4(label, col4, flags | ImGuiColorEditFlags_NoAlpha)) return false; col[0] = col4[0]; col[1] = col4[1]; col[2] = col4[2]; return true; } static inline ImU32 ImAlphaBlendColor(ImU32 col_a, ImU32 col_b) { float t = ((col_b >> IM_COL32_A_SHIFT) & 0xFF) / 255.f; int r = ImLerp((int)(col_a >> IM_COL32_R_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_R_SHIFT) & 0xFF, t); int g = ImLerp((int)(col_a >> IM_COL32_G_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_G_SHIFT) & 0xFF, t); int b = ImLerp((int)(col_a >> IM_COL32_B_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_B_SHIFT) & 0xFF, t); return IM_COL32(r, g, b, 0xFF); } // Helper for ColorPicker4() // NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that. // I spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding alltogether. void ImGui::RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 col, float grid_step, ImVec2 grid_off, float rounding, int rounding_corners_flags) { ImGuiWindow* window = GetCurrentWindow(); if (((col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT) < 0xFF) { ImU32 col_bg1 = GetColorU32(ImAlphaBlendColor(IM_COL32(204,204,204,255), col)); ImU32 col_bg2 = GetColorU32(ImAlphaBlendColor(IM_COL32(128,128,128,255), col)); window->DrawList->AddRectFilled(p_min, p_max, col_bg1, rounding, rounding_corners_flags); int yi = 0; for (float y = p_min.y + grid_off.y; y < p_max.y; y += grid_step, yi++) { float y1 = ImClamp(y, p_min.y, p_max.y), y2 = ImMin(y + grid_step, p_max.y); if (y2 <= y1) continue; for (float x = p_min.x + grid_off.x + (yi & 1) * grid_step; x < p_max.x; x += grid_step * 2.0f) { float x1 = ImClamp(x, p_min.x, p_max.x), x2 = ImMin(x + grid_step, p_max.x); if (x2 <= x1) continue; int rounding_corners_flags_cell = 0; if (y1 <= p_min.y) { if (x1 <= p_min.x) rounding_corners_flags_cell |= ImDrawCornerFlags_TopLeft; if (x2 >= p_max.x) rounding_corners_flags_cell |= ImDrawCornerFlags_TopRight; } if (y2 >= p_max.y) { if (x1 <= p_min.x) rounding_corners_flags_cell |= ImDrawCornerFlags_BotLeft; if (x2 >= p_max.x) rounding_corners_flags_cell |= ImDrawCornerFlags_BotRight; } rounding_corners_flags_cell &= rounding_corners_flags; window->DrawList->AddRectFilled(ImVec2(x1,y1), ImVec2(x2,y2), col_bg2, rounding_corners_flags_cell ? rounding : 0.0f, rounding_corners_flags_cell); } } } else { window->DrawList->AddRectFilled(p_min, p_max, col, rounding, rounding_corners_flags); } } // Helper for ColorPicker4() static void RenderArrowsForVerticalBar(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, float bar_w, float alpha) { ImU32 alpha8 = IM_F32_TO_INT8_SAT(alpha); ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x + 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Right, IM_COL32(0,0,0,alpha8)); ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x, pos.y), half_sz, ImGuiDir_Right, IM_COL32(255,255,255,alpha8)); ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x - 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Left, IM_COL32(0,0,0,alpha8)); ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x, pos.y), half_sz, ImGuiDir_Left, IM_COL32(255,255,255,alpha8)); } // Note: ColorPicker4() only accesses 3 floats if ImGuiColorEditFlags_NoAlpha flag is set. // (In C++ the 'float col[4]' notation for a function argument is equivalent to 'float* col', we only specify a size to facilitate understanding of the code.) // FIXME: we adjust the big color square height based on item width, which may cause a flickering feedback loop (if automatic height makes a vertical scrollbar appears, affecting automatic width..) // FIXME: this is trying to be aware of style.Alpha but not fully correct. Also, the color wheel will have overlapping glitches with (style.Alpha < 1.0) bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags, const float* ref_col) { ImGuiContext& g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImDrawList* draw_list = window->DrawList; ImGuiStyle& style = g.Style; ImGuiIO& io = g.IO; const float width = CalcItemWidth(); g.NextItemData.ClearFlags(); PushID(label); BeginGroup(); if (!(flags & ImGuiColorEditFlags_NoSidePreview)) flags |= ImGuiColorEditFlags_NoSmallPreview; // Context menu: display and store options. if (!(flags & ImGuiColorEditFlags_NoOptions)) ColorPickerOptionsPopup(col, flags); // Read stored options if (!(flags & ImGuiColorEditFlags__PickerMask)) flags |= ((g.ColorEditOptions & ImGuiColorEditFlags__PickerMask) ? g.ColorEditOptions : ImGuiColorEditFlags__OptionsDefault) & ImGuiColorEditFlags__PickerMask; if (!(flags & ImGuiColorEditFlags__InputMask)) flags |= ((g.ColorEditOptions & ImGuiColorEditFlags__InputMask) ? g.ColorEditOptions : ImGuiColorEditFlags__OptionsDefault) & ImGuiColorEditFlags__InputMask; IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__PickerMask)); // Check that only 1 is selected IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__InputMask)); // Check that only 1 is selected if (!(flags & ImGuiColorEditFlags_NoOptions)) flags |= (g.ColorEditOptions & ImGuiColorEditFlags_AlphaBar); // Setup int components = (flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4; bool alpha_bar = (flags & ImGuiColorEditFlags_AlphaBar) && !(flags & ImGuiColorEditFlags_NoAlpha); ImVec2 picker_pos = window->DC.CursorPos; float square_sz = GetFrameHeight(); float bars_width = square_sz; // Arbitrary smallish width of Hue/Alpha picking bars float sv_picker_size = ImMax(bars_width * 1, width - (alpha_bar ? 2 : 1) * (bars_width + style.ItemInnerSpacing.x)); // Saturation/Value picking box float bar0_pos_x = picker_pos.x + sv_picker_size + style.ItemInnerSpacing.x; float bar1_pos_x = bar0_pos_x + bars_width + style.ItemInnerSpacing.x; float bars_triangles_half_sz = IM_FLOOR(bars_width * 0.20f); float backup_initial_col[4]; memcpy(backup_initial_col, col, components * sizeof(float)); float wheel_thickness = sv_picker_size * 0.08f; float wheel_r_outer = sv_picker_size * 0.50f; float wheel_r_inner = wheel_r_outer - wheel_thickness; ImVec2 wheel_center(picker_pos.x + (sv_picker_size + bars_width)*0.5f, picker_pos.y + sv_picker_size*0.5f); // Note: the triangle is displayed rotated with triangle_pa pointing to Hue, but most coordinates stays unrotated for logic. float triangle_r = wheel_r_inner - (int)(sv_picker_size * 0.027f); ImVec2 triangle_pa = ImVec2(triangle_r, 0.0f); // Hue point. ImVec2 triangle_pb = ImVec2(triangle_r * -0.5f, triangle_r * -0.866025f); // Black point. ImVec2 triangle_pc = ImVec2(triangle_r * -0.5f, triangle_r * +0.866025f); // White point. float H = col[0], S = col[1], V = col[2]; float R = col[0], G = col[1], B = col[2]; if (flags & ImGuiColorEditFlags_InputRGB) { // Hue is lost when converting from greyscale rgb (saturation=0). Restore it. ColorConvertRGBtoHSV(R, G, B, H, S, V); if (memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0) { if (S == 0) H = g.ColorEditLastHue; if (V == 0) S = g.ColorEditLastSat; } } else if (flags & ImGuiColorEditFlags_InputHSV) { ColorConvertHSVtoRGB(H, S, V, R, G, B); } bool value_changed = false, value_changed_h = false, value_changed_sv = false; PushItemFlag(ImGuiItemFlags_NoNav, true); if (flags & ImGuiColorEditFlags_PickerHueWheel) { // Hue wheel + SV triangle logic InvisibleButton("hsv", ImVec2(sv_picker_size + style.ItemInnerSpacing.x + bars_width, sv_picker_size)); if (IsItemActive()) { ImVec2 initial_off = g.IO.MouseClickedPos[0] - wheel_center; ImVec2 current_off = g.IO.MousePos - wheel_center; float initial_dist2 = ImLengthSqr(initial_off); if (initial_dist2 >= (wheel_r_inner-1)*(wheel_r_inner-1) && initial_dist2 <= (wheel_r_outer+1)*(wheel_r_outer+1)) { // Interactive with Hue wheel H = ImAtan2(current_off.y, current_off.x) / IM_PI*0.5f; if (H < 0.0f) H += 1.0f; value_changed = value_changed_h = true; } float cos_hue_angle = ImCos(-H * 2.0f * IM_PI); float sin_hue_angle = ImSin(-H * 2.0f * IM_PI); if (ImTriangleContainsPoint(triangle_pa, triangle_pb, triangle_pc, ImRotate(initial_off, cos_hue_angle, sin_hue_angle))) { // Interacting with SV triangle ImVec2 current_off_unrotated = ImRotate(current_off, cos_hue_angle, sin_hue_angle); if (!ImTriangleContainsPoint(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated)) current_off_unrotated = ImTriangleClosestPoint(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated); float uu, vv, ww; ImTriangleBarycentricCoords(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated, uu, vv, ww); V = ImClamp(1.0f - vv, 0.0001f, 1.0f); S = ImClamp(uu / V, 0.0001f, 1.0f); value_changed = value_changed_sv = true; } } if (!(flags & ImGuiColorEditFlags_NoOptions)) OpenPopupOnItemClick("context"); } else if (flags & ImGuiColorEditFlags_PickerHueBar) { // SV rectangle logic InvisibleButton("sv", ImVec2(sv_picker_size, sv_picker_size)); if (IsItemActive()) { S = ImSaturate((io.MousePos.x - picker_pos.x) / (sv_picker_size-1)); V = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size-1)); value_changed = value_changed_sv = true; } if (!(flags & ImGuiColorEditFlags_NoOptions)) OpenPopupOnItemClick("context"); // Hue bar logic SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y)); InvisibleButton("hue", ImVec2(bars_width, sv_picker_size)); if (IsItemActive()) { H = ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size-1)); value_changed = value_changed_h = true; } } // Alpha bar logic if (alpha_bar) { SetCursorScreenPos(ImVec2(bar1_pos_x, picker_pos.y)); InvisibleButton("alpha", ImVec2(bars_width, sv_picker_size)); if (IsItemActive()) { col[3] = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size-1)); value_changed = true; } } PopItemFlag(); // ImGuiItemFlags_NoNav if (!(flags & ImGuiColorEditFlags_NoSidePreview)) { SameLine(0, style.ItemInnerSpacing.x); BeginGroup(); } if (!(flags & ImGuiColorEditFlags_NoLabel)) { const char* label_display_end = FindRenderedTextEnd(label); if (label != label_display_end) { if ((flags & ImGuiColorEditFlags_NoSidePreview)) SameLine(0, style.ItemInnerSpacing.x); TextEx(label, label_display_end); } } if (!(flags & ImGuiColorEditFlags_NoSidePreview)) { PushItemFlag(ImGuiItemFlags_NoNavDefaultFocus, true); ImVec4 col_v4(col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]); if ((flags & ImGuiColorEditFlags_NoLabel)) Text("Current"); ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf | ImGuiColorEditFlags_NoTooltip; ColorButton("##current", col_v4, (flags & sub_flags_to_forward), ImVec2(square_sz * 3, square_sz * 2)); if (ref_col != NULL) { Text("Original"); ImVec4 ref_col_v4(ref_col[0], ref_col[1], ref_col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : ref_col[3]); if (ColorButton("##original", ref_col_v4, (flags & sub_flags_to_forward), ImVec2(square_sz * 3, square_sz * 2))) { memcpy(col, ref_col, components * sizeof(float)); value_changed = true; } } PopItemFlag(); EndGroup(); } // Convert back color to RGB if (value_changed_h || value_changed_sv) { if (flags & ImGuiColorEditFlags_InputRGB) { ColorConvertHSVtoRGB(H >= 1.0f ? H - 10 * 1e-6f : H, S > 0.0f ? S : 10*1e-6f, V > 0.0f ? V : 1e-6f, col[0], col[1], col[2]); g.ColorEditLastHue = H; g.ColorEditLastSat = S; memcpy(g.ColorEditLastColor, col, sizeof(float) * 3); } else if (flags & ImGuiColorEditFlags_InputHSV) { col[0] = H; col[1] = S; col[2] = V; } } // R,G,B and H,S,V slider color editor bool value_changed_fix_hue_wrap = false; if ((flags & ImGuiColorEditFlags_NoInputs) == 0) { PushItemWidth((alpha_bar ? bar1_pos_x : bar0_pos_x) + bars_width - picker_pos.x); ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf; ImGuiColorEditFlags sub_flags = (flags & sub_flags_to_forward) | ImGuiColorEditFlags_NoPicker; if (flags & ImGuiColorEditFlags_DisplayRGB || (flags & ImGuiColorEditFlags__DisplayMask) == 0) if (ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_DisplayRGB)) { // FIXME: Hackily differenciating using the DragInt (ActiveId != 0 && !ActiveIdAllowOverlap) vs. using the InputText or DropTarget. // For the later we don't want to run the hue-wrap canceling code. If you are well versed in HSV picker please provide your input! (See #2050) value_changed_fix_hue_wrap = (g.ActiveId != 0 && !g.ActiveIdAllowOverlap); value_changed = true; } if (flags & ImGuiColorEditFlags_DisplayHSV || (flags & ImGuiColorEditFlags__DisplayMask) == 0) value_changed |= ColorEdit4("##hsv", col, sub_flags | ImGuiColorEditFlags_DisplayHSV); if (flags & ImGuiColorEditFlags_DisplayHex || (flags & ImGuiColorEditFlags__DisplayMask) == 0) value_changed |= ColorEdit4("##hex", col, sub_flags | ImGuiColorEditFlags_DisplayHex); PopItemWidth(); } // Try to cancel hue wrap (after ColorEdit4 call), if any if (value_changed_fix_hue_wrap && (flags & ImGuiColorEditFlags_InputRGB)) { float new_H, new_S, new_V; ColorConvertRGBtoHSV(col[0], col[1], col[2], new_H, new_S, new_V); if (new_H <= 0 && H > 0) { if (new_V <= 0 && V != new_V) ColorConvertHSVtoRGB(H, S, new_V <= 0 ? V * 0.5f : new_V, col[0], col[1], col[2]); else if (new_S <= 0) ColorConvertHSVtoRGB(H, new_S <= 0 ? S * 0.5f : new_S, new_V, col[0], col[1], col[2]); } } if (value_changed) { if (flags & ImGuiColorEditFlags_InputRGB) { R = col[0]; G = col[1]; B = col[2]; ColorConvertRGBtoHSV(R, G, B, H, S, V); if (memcmp(g.ColorEditLastColor, col, sizeof(float) * 3) == 0) // Fix local Hue as display below will use it immediately. { if (S == 0) H = g.ColorEditLastHue; if (V == 0) S = g.ColorEditLastSat; } } else if (flags & ImGuiColorEditFlags_InputHSV) { H = col[0]; S = col[1]; V = col[2]; ColorConvertHSVtoRGB(H, S, V, R, G, B); } } const int style_alpha8 = IM_F32_TO_INT8_SAT(style.Alpha); const ImU32 col_black = IM_COL32(0,0,0,style_alpha8); const ImU32 col_white = IM_COL32(255,255,255,style_alpha8); const ImU32 col_midgrey = IM_COL32(128,128,128,style_alpha8); const ImU32 col_hues[6 + 1] = { IM_COL32(255,0,0,style_alpha8), IM_COL32(255,255,0,style_alpha8), IM_COL32(0,255,0,style_alpha8), IM_COL32(0,255,255,style_alpha8), IM_COL32(0,0,255,style_alpha8), IM_COL32(255,0,255,style_alpha8), IM_COL32(255,0,0,style_alpha8) }; ImVec4 hue_color_f(1, 1, 1, style.Alpha); ColorConvertHSVtoRGB(H, 1, 1, hue_color_f.x, hue_color_f.y, hue_color_f.z); ImU32 hue_color32 = ColorConvertFloat4ToU32(hue_color_f); ImU32 user_col32_striped_of_alpha = ColorConvertFloat4ToU32(ImVec4(R, G, B, style.Alpha)); // Important: this is still including the main rendering/style alpha!! ImVec2 sv_cursor_pos; if (flags & ImGuiColorEditFlags_PickerHueWheel) { // Render Hue Wheel const float aeps = 0.5f / wheel_r_outer; // Half a pixel arc length in radians (2pi cancels out). const int segment_per_arc = ImMax(4, (int)wheel_r_outer / 12); for (int n = 0; n < 6; n++) { const float a0 = (n) /6.0f * 2.0f * IM_PI - aeps; const float a1 = (n+1.0f)/6.0f * 2.0f * IM_PI + aeps; const int vert_start_idx = draw_list->VtxBuffer.Size; draw_list->PathArcTo(wheel_center, (wheel_r_inner + wheel_r_outer)*0.5f, a0, a1, segment_per_arc); draw_list->PathStroke(col_white, false, wheel_thickness); const int vert_end_idx = draw_list->VtxBuffer.Size; // Paint colors over existing vertices ImVec2 gradient_p0(wheel_center.x + ImCos(a0) * wheel_r_inner, wheel_center.y + ImSin(a0) * wheel_r_inner); ImVec2 gradient_p1(wheel_center.x + ImCos(a1) * wheel_r_inner, wheel_center.y + ImSin(a1) * wheel_r_inner); ShadeVertsLinearColorGradientKeepAlpha(draw_list, vert_start_idx, vert_end_idx, gradient_p0, gradient_p1, col_hues[n], col_hues[n+1]); } // Render Cursor + preview on Hue Wheel float cos_hue_angle = ImCos(H * 2.0f * IM_PI); float sin_hue_angle = ImSin(H * 2.0f * IM_PI); ImVec2 hue_cursor_pos(wheel_center.x + cos_hue_angle * (wheel_r_inner+wheel_r_outer)*0.5f, wheel_center.y + sin_hue_angle * (wheel_r_inner+wheel_r_outer)*0.5f); float hue_cursor_rad = value_changed_h ? wheel_thickness * 0.65f : wheel_thickness * 0.55f; int hue_cursor_segments = ImClamp((int)(hue_cursor_rad / 1.4f), 9, 32); draw_list->AddCircleFilled(hue_cursor_pos, hue_cursor_rad, hue_color32, hue_cursor_segments); draw_list->AddCircle(hue_cursor_pos, hue_cursor_rad+1, col_midgrey, hue_cursor_segments); draw_list->AddCircle(hue_cursor_pos, hue_cursor_rad, col_white, hue_cursor_segments); // Render SV triangle (rotated according to hue) ImVec2 tra = wheel_center + ImRotate(triangle_pa, cos_hue_angle, sin_hue_angle); ImVec2 trb = wheel_center + ImRotate(triangle_pb, cos_hue_angle, sin_hue_angle); ImVec2 trc = wheel_center + ImRotate(triangle_pc, cos_hue_angle, sin_hue_angle); ImVec2 uv_white = GetFontTexUvWhitePixel(); draw_list->PrimReserve(6, 6); draw_list->PrimVtx(tra, uv_white, hue_color32); draw_list->PrimVtx(trb, uv_white, hue_color32); draw_list->PrimVtx(trc, uv_white, col_white); draw_list->PrimVtx(tra, uv_white, 0); draw_list->PrimVtx(trb, uv_white, col_black); draw_list->PrimVtx(trc, uv_white, 0); draw_list->AddTriangle(tra, trb, trc, col_midgrey, 1.5f); sv_cursor_pos = ImLerp(ImLerp(trc, tra, ImSaturate(S)), trb, ImSaturate(1 - V)); } else if (flags & ImGuiColorEditFlags_PickerHueBar) { // Render SV Square draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), col_white, hue_color32, hue_color32, col_white); draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), 0, 0, col_black, col_black); RenderFrameBorder(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), 0.0f); sv_cursor_pos.x = ImClamp(IM_ROUND(picker_pos.x + ImSaturate(S) * sv_picker_size), picker_pos.x + 2, picker_pos.x + sv_picker_size - 2); // Sneakily prevent the circle to stick out too much sv_cursor_pos.y = ImClamp(IM_ROUND(picker_pos.y + ImSaturate(1 - V) * sv_picker_size), picker_pos.y + 2, picker_pos.y + sv_picker_size - 2); // Render Hue Bar for (int i = 0; i < 6; ++i) draw_list->AddRectFilledMultiColor(ImVec2(bar0_pos_x, picker_pos.y + i * (sv_picker_size / 6)), ImVec2(bar0_pos_x + bars_width, picker_pos.y + (i + 1) * (sv_picker_size / 6)), col_hues[i], col_hues[i], col_hues[i + 1], col_hues[i + 1]); float bar0_line_y = IM_ROUND(picker_pos.y + H * sv_picker_size); RenderFrameBorder(ImVec2(bar0_pos_x, picker_pos.y), ImVec2(bar0_pos_x + bars_width, picker_pos.y + sv_picker_size), 0.0f); RenderArrowsForVerticalBar(draw_list, ImVec2(bar0_pos_x - 1, bar0_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0f, style.Alpha); } // Render cursor/preview circle (clamp S/V within 0..1 range because floating points colors may lead HSV values to be out of range) float sv_cursor_rad = value_changed_sv ? 10.0f : 6.0f; draw_list->AddCircleFilled(sv_cursor_pos, sv_cursor_rad, user_col32_striped_of_alpha, 12); draw_list->AddCircle(sv_cursor_pos, sv_cursor_rad+1, col_midgrey, 12); draw_list->AddCircle(sv_cursor_pos, sv_cursor_rad, col_white, 12); // Render alpha bar if (alpha_bar) { float alpha = ImSaturate(col[3]); ImRect bar1_bb(bar1_pos_x, picker_pos.y, bar1_pos_x + bars_width, picker_pos.y + sv_picker_size); RenderColorRectWithAlphaCheckerboard(bar1_bb.Min, bar1_bb.Max, 0, bar1_bb.GetWidth() / 2.0f, ImVec2(0.0f, 0.0f)); draw_list->AddRectFilledMultiColor(bar1_bb.Min, bar1_bb.Max, user_col32_striped_of_alpha, user_col32_striped_of_alpha, user_col32_striped_of_alpha & ~IM_COL32_A_MASK, user_col32_striped_of_alpha & ~IM_COL32_A_MASK); float bar1_line_y = IM_ROUND(picker_pos.y + (1.0f - alpha) * sv_picker_size); RenderFrameBorder(bar1_bb.Min, bar1_bb.Max, 0.0f); RenderArrowsForVerticalBar(draw_list, ImVec2(bar1_pos_x - 1, bar1_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0f, style.Alpha); } EndGroup(); if (value_changed && memcmp(backup_initial_col, col, components * sizeof(float)) == 0) value_changed = false; if (value_changed) MarkItemEdited(window->DC.LastItemId); PopID(); return value_changed; } // A little colored square. Return true when clicked. // FIXME: May want to display/ignore the alpha component in the color display? Yet show it in the tooltip. // 'desc_id' is not called 'label' because we don't display it next to the button, but only in the tooltip. // Note that 'col' may be encoded in HSV if ImGuiColorEditFlags_InputHSV is set. bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags, ImVec2 size) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiID id = window->GetID(desc_id); float default_size = GetFrameHeight(); if (size.x == 0.0f) size.x = default_size; if (size.y == 0.0f) size.y = default_size; const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); ItemSize(bb, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f); if (!ItemAdd(bb, id)) return false; bool hovered, held; bool pressed = ButtonBehavior(bb, id, &hovered, &held); if (flags & ImGuiColorEditFlags_NoAlpha) flags &= ~(ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf); ImVec4 col_rgb = col; if (flags & ImGuiColorEditFlags_InputHSV) ColorConvertHSVtoRGB(col_rgb.x, col_rgb.y, col_rgb.z, col_rgb.x, col_rgb.y, col_rgb.z); ImVec4 col_rgb_without_alpha(col_rgb.x, col_rgb.y, col_rgb.z, 1.0f); float grid_step = ImMin(size.x, size.y) / 2.99f; float rounding = ImMin(g.Style.FrameRounding, grid_step * 0.5f); ImRect bb_inner = bb; float off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts. bb_inner.Expand(off); if ((flags & ImGuiColorEditFlags_AlphaPreviewHalf) && col_rgb.w < 1.0f) { float mid_x = IM_ROUND((bb_inner.Min.x + bb_inner.Max.x) * 0.5f); RenderColorRectWithAlphaCheckerboard(ImVec2(bb_inner.Min.x + grid_step, bb_inner.Min.y), bb_inner.Max, GetColorU32(col_rgb), grid_step, ImVec2(-grid_step + off, off), rounding, ImDrawCornerFlags_TopRight| ImDrawCornerFlags_BotRight); window->DrawList->AddRectFilled(bb_inner.Min, ImVec2(mid_x, bb_inner.Max.y), GetColorU32(col_rgb_without_alpha), rounding, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotLeft); } else { // Because GetColorU32() multiplies by the global style Alpha and we don't want to display a checkerboard if the source code had no alpha ImVec4 col_source = (flags & ImGuiColorEditFlags_AlphaPreview) ? col_rgb : col_rgb_without_alpha; if (col_source.w < 1.0f) RenderColorRectWithAlphaCheckerboard(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), grid_step, ImVec2(off, off), rounding); else window->DrawList->AddRectFilled(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), rounding, ImDrawCornerFlags_All); } RenderNavHighlight(bb, id); if (g.Style.FrameBorderSize > 0.0f) RenderFrameBorder(bb.Min, bb.Max, rounding); else window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), rounding); // Color button are often in need of some sort of border // Drag and Drop Source // NB: The ActiveId test is merely an optional micro-optimization, BeginDragDropSource() does the same test. if (g.ActiveId == id && !(flags & ImGuiColorEditFlags_NoDragDrop) && BeginDragDropSource()) { if (flags & ImGuiColorEditFlags_NoAlpha) SetDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F, &col_rgb, sizeof(float) * 3, ImGuiCond_Once); else SetDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F, &col_rgb, sizeof(float) * 4, ImGuiCond_Once); ColorButton(desc_id, col, flags); SameLine(); TextEx("Color"); EndDragDropSource(); } // Tooltip if (!(flags & ImGuiColorEditFlags_NoTooltip) && hovered) ColorTooltip(desc_id, &col.x, flags & (ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf)); return pressed; } // Initialize/override default color options void ImGui::SetColorEditOptions(ImGuiColorEditFlags flags) { ImGuiContext& g = *GImGui; if ((flags & ImGuiColorEditFlags__DisplayMask) == 0) flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__DisplayMask; if ((flags & ImGuiColorEditFlags__DataTypeMask) == 0) flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__DataTypeMask; if ((flags & ImGuiColorEditFlags__PickerMask) == 0) flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__PickerMask; if ((flags & ImGuiColorEditFlags__InputMask) == 0) flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__InputMask; IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__DisplayMask)); // Check only 1 option is selected IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__DataTypeMask)); // Check only 1 option is selected IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__PickerMask)); // Check only 1 option is selected IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags__InputMask)); // Check only 1 option is selected g.ColorEditOptions = flags; } // Note: only access 3 floats if ImGuiColorEditFlags_NoAlpha flag is set. void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags) { ImGuiContext& g = *GImGui; BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip); const char* text_end = text ? FindRenderedTextEnd(text, NULL) : text; if (text_end > text) { TextEx(text, text_end); Separator(); } ImVec2 sz(g.FontSize * 3 + g.Style.FramePadding.y * 2, g.FontSize * 3 + g.Style.FramePadding.y * 2); ImVec4 cf(col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]); int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]); ColorButton("##preview", cf, (flags & (ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf)) | ImGuiColorEditFlags_NoTooltip, sz); SameLine(); if ((flags & ImGuiColorEditFlags_InputRGB) || !(flags & ImGuiColorEditFlags__InputMask)) { if (flags & ImGuiColorEditFlags_NoAlpha) Text("#%02X%02X%02X\nR: %d, G: %d, B: %d\n(%.3f, %.3f, %.3f)", cr, cg, cb, cr, cg, cb, col[0], col[1], col[2]); else Text("#%02X%02X%02X%02X\nR:%d, G:%d, B:%d, A:%d\n(%.3f, %.3f, %.3f, %.3f)", cr, cg, cb, ca, cr, cg, cb, ca, col[0], col[1], col[2], col[3]); } else if (flags & ImGuiColorEditFlags_InputHSV) { if (flags & ImGuiColorEditFlags_NoAlpha) Text("H: %.3f, S: %.3f, V: %.3f", col[0], col[1], col[2]); else Text("H: %.3f, S: %.3f, V: %.3f, A: %.3f", col[0], col[1], col[2], col[3]); } EndTooltip(); } void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags) { bool allow_opt_inputs = !(flags & ImGuiColorEditFlags__DisplayMask); bool allow_opt_datatype = !(flags & ImGuiColorEditFlags__DataTypeMask); if ((!allow_opt_inputs && !allow_opt_datatype) || !BeginPopup("context")) return; ImGuiContext& g = *GImGui; ImGuiColorEditFlags opts = g.ColorEditOptions; if (allow_opt_inputs) { if (RadioButton("RGB", (opts & ImGuiColorEditFlags_DisplayRGB) != 0)) opts = (opts & ~ImGuiColorEditFlags__DisplayMask) | ImGuiColorEditFlags_DisplayRGB; if (RadioButton("HSV", (opts & ImGuiColorEditFlags_DisplayHSV) != 0)) opts = (opts & ~ImGuiColorEditFlags__DisplayMask) | ImGuiColorEditFlags_DisplayHSV; if (RadioButton("Hex", (opts & ImGuiColorEditFlags_DisplayHex) != 0)) opts = (opts & ~ImGuiColorEditFlags__DisplayMask) | ImGuiColorEditFlags_DisplayHex; } if (allow_opt_datatype) { if (allow_opt_inputs) Separator(); if (RadioButton("0..255", (opts & ImGuiColorEditFlags_Uint8) != 0)) opts = (opts & ~ImGuiColorEditFlags__DataTypeMask) | ImGuiColorEditFlags_Uint8; if (RadioButton("0.00..1.00", (opts & ImGuiColorEditFlags_Float) != 0)) opts = (opts & ~ImGuiColorEditFlags__DataTypeMask) | ImGuiColorEditFlags_Float; } if (allow_opt_inputs || allow_opt_datatype) Separator(); if (Button("Copy as..", ImVec2(-1,0))) OpenPopup("Copy"); if (BeginPopup("Copy")) { int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]); char buf[64]; ImFormatString(buf, IM_ARRAYSIZE(buf), "(%.3ff, %.3ff, %.3ff, %.3ff)", col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]); if (Selectable(buf)) SetClipboardText(buf); ImFormatString(buf, IM_ARRAYSIZE(buf), "(%d,%d,%d,%d)", cr, cg, cb, ca); if (Selectable(buf)) SetClipboardText(buf); ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", cr, cg, cb); if (Selectable(buf)) SetClipboardText(buf); if (!(flags & ImGuiColorEditFlags_NoAlpha)) { ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", cr, cg, cb, ca); if (Selectable(buf)) SetClipboardText(buf); } EndPopup(); } g.ColorEditOptions = opts; EndPopup(); } void ImGui::ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags) { bool allow_opt_picker = !(flags & ImGuiColorEditFlags__PickerMask); bool allow_opt_alpha_bar = !(flags & ImGuiColorEditFlags_NoAlpha) && !(flags & ImGuiColorEditFlags_AlphaBar); if ((!allow_opt_picker && !allow_opt_alpha_bar) || !BeginPopup("context")) return; ImGuiContext& g = *GImGui; if (allow_opt_picker) { ImVec2 picker_size(g.FontSize * 8, ImMax(g.FontSize * 8 - (GetFrameHeight() + g.Style.ItemInnerSpacing.x), 1.0f)); // FIXME: Picker size copied from main picker function PushItemWidth(picker_size.x); for (int picker_type = 0; picker_type < 2; picker_type++) { // Draw small/thumbnail version of each picker type (over an invisible button for selection) if (picker_type > 0) Separator(); PushID(picker_type); ImGuiColorEditFlags picker_flags = ImGuiColorEditFlags_NoInputs|ImGuiColorEditFlags_NoOptions|ImGuiColorEditFlags_NoLabel|ImGuiColorEditFlags_NoSidePreview|(flags & ImGuiColorEditFlags_NoAlpha); if (picker_type == 0) picker_flags |= ImGuiColorEditFlags_PickerHueBar; if (picker_type == 1) picker_flags |= ImGuiColorEditFlags_PickerHueWheel; ImVec2 backup_pos = GetCursorScreenPos(); if (Selectable("##selectable", false, 0, picker_size)) // By default, Selectable() is closing popup g.ColorEditOptions = (g.ColorEditOptions & ~ImGuiColorEditFlags__PickerMask) | (picker_flags & ImGuiColorEditFlags__PickerMask); SetCursorScreenPos(backup_pos); ImVec4 dummy_ref_col; memcpy(&dummy_ref_col, ref_col, sizeof(float) * ((picker_flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4)); ColorPicker4("##dummypicker", &dummy_ref_col.x, picker_flags); PopID(); } PopItemWidth(); } if (allow_opt_alpha_bar) { if (allow_opt_picker) Separator(); CheckboxFlags("Alpha Bar", (unsigned int*)&g.ColorEditOptions, ImGuiColorEditFlags_AlphaBar); } EndPopup(); } //------------------------------------------------------------------------- // [SECTION] Widgets: TreeNode, CollapsingHeader, etc. //------------------------------------------------------------------------- // - TreeNode() // - TreeNodeV() // - TreeNodeEx() // - TreeNodeExV() // - TreeNodeBehavior() [Internal] // - TreePush() // - TreePop() // - GetTreeNodeToLabelSpacing() // - SetNextItemOpen() // - CollapsingHeader() //------------------------------------------------------------------------- bool ImGui::TreeNode(const char* str_id, const char* fmt, ...) { va_list args; va_start(args, fmt); bool is_open = TreeNodeExV(str_id, 0, fmt, args); va_end(args); return is_open; } bool ImGui::TreeNode(const void* ptr_id, const char* fmt, ...) { va_list args; va_start(args, fmt); bool is_open = TreeNodeExV(ptr_id, 0, fmt, args); va_end(args); return is_open; } bool ImGui::TreeNode(const char* label) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; return TreeNodeBehavior(window->GetID(label), 0, label, NULL); } bool ImGui::TreeNodeV(const char* str_id, const char* fmt, va_list args) { return TreeNodeExV(str_id, 0, fmt, args); } bool ImGui::TreeNodeV(const void* ptr_id, const char* fmt, va_list args) { return TreeNodeExV(ptr_id, 0, fmt, args); } bool ImGui::TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; return TreeNodeBehavior(window->GetID(label), flags, label, NULL); } bool ImGui::TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) { va_list args; va_start(args, fmt); bool is_open = TreeNodeExV(str_id, flags, fmt, args); va_end(args); return is_open; } bool ImGui::TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) { va_list args; va_start(args, fmt); bool is_open = TreeNodeExV(ptr_id, flags, fmt, args); va_end(args); return is_open; } bool ImGui::TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); return TreeNodeBehavior(window->GetID(str_id), flags, g.TempBuffer, label_end); } bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); return TreeNodeBehavior(window->GetID(ptr_id), flags, g.TempBuffer, label_end); } bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags) { if (flags & ImGuiTreeNodeFlags_Leaf) return true; // We only write to the tree storage if the user clicks (or explicitly use the SetNextItemOpen function) ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; ImGuiStorage* storage = window->DC.StateStorage; bool is_open; if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasOpen) { if (g.NextItemData.OpenCond & ImGuiCond_Always) { is_open = g.NextItemData.OpenVal; storage->SetInt(id, is_open); } else { // We treat ImGuiCond_Once and ImGuiCond_FirstUseEver the same because tree node state are not saved persistently. const int stored_value = storage->GetInt(id, -1); if (stored_value == -1) { is_open = g.NextItemData.OpenVal; storage->SetInt(id, is_open); } else { is_open = stored_value != 0; } } } else { is_open = storage->GetInt(id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0; } // When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior). // NB- If we are above max depth we still allow manually opened nodes to be logged. if (g.LogEnabled && !(flags & ImGuiTreeNodeFlags_NoAutoOpenOnLog) && (window->DC.TreeDepth - g.LogDepthRef) < g.LogDepthToExpand) is_open = true; return is_open; } bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0; const ImVec2 padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) ? style.FramePadding : ImVec2(style.FramePadding.x, ImMin(window->DC.CurrLineTextBaseOffset, style.FramePadding.y)); if (!label_end) label_end = FindRenderedTextEnd(label); const ImVec2 label_size = CalcTextSize(label, label_end, false); // We vertically grow up to current line height up the typical widget height. const float frame_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + style.FramePadding.y*2), label_size.y + padding.y*2); ImRect frame_bb; frame_bb.Min.x = (flags & ImGuiTreeNodeFlags_SpanFullWidth) ? window->WorkRect.Min.x : window->DC.CursorPos.x; frame_bb.Min.y = window->DC.CursorPos.y; frame_bb.Max.x = window->WorkRect.Max.x; frame_bb.Max.y = window->DC.CursorPos.y + frame_height; if (display_frame) { // Framed header expand a little outside the default padding, to the edge of InnerClipRect // (FIXME: May remove this at some point and make InnerClipRect align with WindowPadding.x instead of WindowPadding.x*0.5f) frame_bb.Min.x -= IM_FLOOR(window->WindowPadding.x * 0.5f - 1.0f); frame_bb.Max.x += IM_FLOOR(window->WindowPadding.x * 0.5f); } const float text_offset_x = g.FontSize + (display_frame ? padding.x*3 : padding.x*2); // Collapser arrow width + Spacing const float text_offset_y = ImMax(padding.y, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it const float text_width = g.FontSize + (label_size.x > 0.0f ? label_size.x + padding.x*2 : 0.0f); // Include collapser ImVec2 text_pos(window->DC.CursorPos.x + text_offset_x, window->DC.CursorPos.y + text_offset_y); ItemSize(ImVec2(text_width, frame_height), padding.y); // For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing ImRect interact_bb = frame_bb; if (!display_frame && (flags & (ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth)) == 0) interact_bb.Max.x = frame_bb.Min.x + text_width + style.ItemSpacing.x * 2.0f; // Store a flag for the current depth to tell if we will allow closing this node when navigating one of its child. // For this purpose we essentially compare if g.NavIdIsAlive went from 0 to 1 between TreeNode() and TreePop(). // This is currently only support 32 level deep and we are fine with (1 << Depth) overflowing into a zero. const bool is_leaf = (flags & ImGuiTreeNodeFlags_Leaf) != 0; bool is_open = TreeNodeBehaviorIsOpen(id, flags); if (is_open && !g.NavIdIsAlive && (flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) window->DC.TreeJumpToParentOnPopMask |= (1 << window->DC.TreeDepth); bool item_add = ItemAdd(interact_bb, id); window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HasDisplayRect; window->DC.LastItemDisplayRect = frame_bb; if (!item_add) { if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) TreePushOverrideID(id); IMGUI_TEST_ENGINE_ITEM_INFO(window->DC.LastItemId, label, window->DC.ItemFlags | (is_leaf ? 0 : ImGuiItemStatusFlags_Openable) | (is_open ? ImGuiItemStatusFlags_Opened : 0)); return is_open; } // Flags that affects opening behavior: // - 0 (default) .................... single-click anywhere to open // - OpenOnDoubleClick .............. double-click anywhere to open // - OpenOnArrow .................... single-click on arrow to open // - OpenOnDoubleClick|OpenOnArrow .. single-click on arrow or double-click anywhere to open ImGuiButtonFlags button_flags = 0; if (flags & ImGuiTreeNodeFlags_AllowItemOverlap) button_flags |= ImGuiButtonFlags_AllowItemOverlap; if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) button_flags |= ImGuiButtonFlags_PressedOnDoubleClick | ((flags & ImGuiTreeNodeFlags_OpenOnArrow) ? ImGuiButtonFlags_PressedOnClickRelease : 0); else button_flags |= ImGuiButtonFlags_PressedOnClickRelease; if (!is_leaf) button_flags |= ImGuiButtonFlags_PressedOnDragDropHold; // We allow clicking on the arrow section with keyboard modifiers held, in order to easily // allow browsing a tree while preserving selection with code implementing multi-selection patterns. // When clicking on the rest of the tree node we always disallow keyboard modifiers. const float hit_padding_x = style.TouchExtraPadding.x; const float arrow_hit_x1 = (text_pos.x - text_offset_x) - hit_padding_x; const float arrow_hit_x2 = (text_pos.x - text_offset_x) + (g.FontSize + padding.x * 2.0f) + hit_padding_x; if (window != g.HoveredWindow || !(g.IO.MousePos.x >= arrow_hit_x1 && g.IO.MousePos.x < arrow_hit_x2)) button_flags |= ImGuiButtonFlags_NoKeyModifiers; bool selected = (flags & ImGuiTreeNodeFlags_Selected) != 0; const bool was_selected = selected; bool hovered, held; bool pressed = ButtonBehavior(interact_bb, id, &hovered, &held, button_flags); bool toggled = false; if (!is_leaf) { if (pressed) { if ((flags & (ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) == 0 || (g.NavActivateId == id)) toggled = true; if (flags & ImGuiTreeNodeFlags_OpenOnArrow) toggled |= (g.IO.MousePos.x >= arrow_hit_x1 && g.IO.MousePos.x < arrow_hit_x2) && (!g.NavDisableMouseHover); // Lightweight equivalent of IsMouseHoveringRect() since ButtonBehavior() already did the job if ((flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) && g.IO.MouseDoubleClicked[0]) toggled = true; if (g.DragDropActive && is_open) // When using Drag and Drop "hold to open" we keep the node highlighted after opening, but never close it again. toggled = false; } if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Left && is_open) { toggled = true; NavMoveRequestCancel(); } if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Right && !is_open) // If there's something upcoming on the line we may want to give it the priority? { toggled = true; NavMoveRequestCancel(); } if (toggled) { is_open = !is_open; window->DC.StateStorage->SetInt(id, is_open); window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_ToggledOpen; } } if (flags & ImGuiTreeNodeFlags_AllowItemOverlap) SetItemAllowOverlap(); // In this branch, TreeNodeBehavior() cannot toggle the selection so this will never trigger. if (selected != was_selected) //-V547 window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_ToggledSelection; // Render const ImU32 text_col = GetColorU32(ImGuiCol_Text); ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_TypeThin; if (display_frame) { // Framed type const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, true, style.FrameRounding); RenderNavHighlight(frame_bb, id, nav_highlight_flags); if (flags & ImGuiTreeNodeFlags_Bullet) RenderBullet(window->DrawList, ImVec2(text_pos.x - text_offset_x * 0.60f, text_pos.y + g.FontSize * 0.5f), text_col); else if (!is_leaf) RenderArrow(window->DrawList, ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y), text_col, is_open ? ImGuiDir_Down : ImGuiDir_Right, 1.0f); else // Leaf without bullet, left-adjusted text text_pos.x -= text_offset_x; if (flags & ImGuiTreeNodeFlags_ClipLabelForTrailingButton) frame_bb.Max.x -= g.FontSize + style.FramePadding.x; if (g.LogEnabled) { // NB: '##' is normally used to hide text (as a library-wide feature), so we need to specify the text range to make sure the ## aren't stripped out here. const char log_prefix[] = "\n##"; const char log_suffix[] = "##"; LogRenderedText(&text_pos, log_prefix, log_prefix+3); RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size); LogRenderedText(&text_pos, log_suffix, log_suffix+2); } else { RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size); } } else { // Unframed typed for tree nodes if (hovered || selected) { const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, false); RenderNavHighlight(frame_bb, id, nav_highlight_flags); } if (flags & ImGuiTreeNodeFlags_Bullet) RenderBullet(window->DrawList, ImVec2(text_pos.x - text_offset_x * 0.5f, text_pos.y + g.FontSize * 0.5f), text_col); else if (!is_leaf) RenderArrow(window->DrawList, ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y + g.FontSize * 0.15f), text_col, is_open ? ImGuiDir_Down : ImGuiDir_Right, 0.70f); if (g.LogEnabled) LogRenderedText(&text_pos, ">"); RenderText(text_pos, label, label_end, false); } if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) TreePushOverrideID(id); IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags | (is_leaf ? 0 : ImGuiItemStatusFlags_Openable) | (is_open ? ImGuiItemStatusFlags_Opened : 0)); return is_open; } void ImGui::TreePush(const char* str_id) { ImGuiWindow* window = GetCurrentWindow(); Indent(); window->DC.TreeDepth++; PushID(str_id ? str_id : "#TreePush"); } void ImGui::TreePush(const void* ptr_id) { ImGuiWindow* window = GetCurrentWindow(); Indent(); window->DC.TreeDepth++; PushID(ptr_id ? ptr_id : (const void*)"#TreePush"); } void ImGui::TreePushOverrideID(ImGuiID id) { ImGuiWindow* window = GetCurrentWindow(); Indent(); window->DC.TreeDepth++; window->IDStack.push_back(id); } void ImGui::TreePop() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; Unindent(); window->DC.TreeDepth--; ImU32 tree_depth_mask = (1 << window->DC.TreeDepth); // Handle Left arrow to move to parent tree node (when ImGuiTreeNodeFlags_NavLeftJumpsBackHere is enabled) if (g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && NavMoveRequestButNoResultYet()) if (g.NavIdIsAlive && (window->DC.TreeJumpToParentOnPopMask & tree_depth_mask)) { SetNavID(window->IDStack.back(), g.NavLayer, 0); NavMoveRequestCancel(); } window->DC.TreeJumpToParentOnPopMask &= tree_depth_mask - 1; IM_ASSERT(window->IDStack.Size > 1); // There should always be 1 element in the IDStack (pushed during window creation). If this triggers you called TreePop/PopID too much. PopID(); } // Horizontal distance preceding label when using TreeNode() or Bullet() float ImGui::GetTreeNodeToLabelSpacing() { ImGuiContext& g = *GImGui; return g.FontSize + (g.Style.FramePadding.x * 2.0f); } // Set next TreeNode/CollapsingHeader open state. void ImGui::SetNextItemOpen(bool is_open, ImGuiCond cond) { ImGuiContext& g = *GImGui; if (g.CurrentWindow->SkipItems) return; g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasOpen; g.NextItemData.OpenVal = is_open; g.NextItemData.OpenCond = cond ? cond : ImGuiCond_Always; } // CollapsingHeader returns true when opened but do not indent nor push into the ID stack (because of the ImGuiTreeNodeFlags_NoTreePushOnOpen flag). // This is basically the same as calling TreeNodeEx(label, ImGuiTreeNodeFlags_CollapsingHeader). You can remove the _NoTreePushOnOpen flag if you want behavior closer to normal TreeNode(). bool ImGui::CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; return TreeNodeBehavior(window->GetID(label), flags | ImGuiTreeNodeFlags_CollapsingHeader, label); } bool ImGui::CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; if (p_open && !*p_open) return false; ImGuiID id = window->GetID(label); flags |= ImGuiTreeNodeFlags_CollapsingHeader | (p_open ? ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_ClipLabelForTrailingButton : 0); bool is_open = TreeNodeBehavior(id, flags, label); if (p_open) { // Create a small overlapping close button // FIXME: We can evolve this into user accessible helpers to add extra buttons on title bars, headers, etc. // FIXME: CloseButton can overlap into text, need find a way to clip the text somehow. ImGuiContext& g = *GImGui; ImGuiItemHoveredDataBackup last_item_backup; float button_size = g.FontSize; float button_x = ImMax(window->DC.LastItemRect.Min.x, window->DC.LastItemRect.Max.x - g.Style.FramePadding.x * 2.0f - button_size); float button_y = window->DC.LastItemRect.Min.y; if (CloseButton(window->GetID((void*)((intptr_t)id + 1)), ImVec2(button_x, button_y))) *p_open = false; last_item_backup.Restore(); } return is_open; } //------------------------------------------------------------------------- // [SECTION] Widgets: Selectable //------------------------------------------------------------------------- // - Selectable() //------------------------------------------------------------------------- // Tip: pass a non-visible label (e.g. "##dummy") then you can use the space to draw other text or image. // But you need to make sure the ID is unique, e.g. enclose calls in PushID/PopID or use ##unique_id. bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags flags, const ImVec2& size_arg) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.CurrentColumns) // FIXME-OPT: Avoid if vertically clipped. PushColumnsBackground(); ImGuiID id = window->GetID(label); ImVec2 label_size = CalcTextSize(label, NULL, true); ImVec2 size(size_arg.x != 0.0f ? size_arg.x : label_size.x, size_arg.y != 0.0f ? size_arg.y : label_size.y); ImVec2 pos = window->DC.CursorPos; pos.y += window->DC.CurrLineTextBaseOffset; ImRect bb_inner(pos, pos + size); ItemSize(size, 0.0f); // Fill horizontal space. ImVec2 window_padding = window->WindowPadding; float max_x = (flags & ImGuiSelectableFlags_SpanAllColumns) ? GetWindowContentRegionMax().x : GetContentRegionMax().x; float w_draw = ImMax(label_size.x, window->Pos.x + max_x - window_padding.x - pos.x); ImVec2 size_draw((size_arg.x != 0 && !(flags & ImGuiSelectableFlags_DrawFillAvailWidth)) ? size_arg.x : w_draw, size_arg.y != 0.0f ? size_arg.y : size.y); ImRect bb(pos, pos + size_draw); if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_DrawFillAvailWidth)) bb.Max.x += window_padding.x; // Selectables are tightly packed together so we extend the box to cover spacing between selectable. const float spacing_x = style.ItemSpacing.x; const float spacing_y = style.ItemSpacing.y; const float spacing_L = IM_FLOOR(spacing_x * 0.50f); const float spacing_U = IM_FLOOR(spacing_y * 0.50f); bb.Min.x -= spacing_L; bb.Min.y -= spacing_U; bb.Max.x += (spacing_x - spacing_L); bb.Max.y += (spacing_y - spacing_U); bool item_add; if (flags & ImGuiSelectableFlags_Disabled) { ImGuiItemFlags backup_item_flags = window->DC.ItemFlags; window->DC.ItemFlags |= ImGuiItemFlags_Disabled | ImGuiItemFlags_NoNavDefaultFocus; item_add = ItemAdd(bb, id); window->DC.ItemFlags = backup_item_flags; } else { item_add = ItemAdd(bb, id); } if (!item_add) { if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.CurrentColumns) PopColumnsBackground(); return false; } // We use NoHoldingActiveID on menus so user can click and _hold_ on a menu then drag to browse child entries ImGuiButtonFlags button_flags = 0; if (flags & ImGuiSelectableFlags_NoHoldingActiveID) { button_flags |= ImGuiButtonFlags_NoHoldingActiveId; } if (flags & ImGuiSelectableFlags_PressedOnClick) { button_flags |= ImGuiButtonFlags_PressedOnClick; } if (flags & ImGuiSelectableFlags_PressedOnRelease) { button_flags |= ImGuiButtonFlags_PressedOnRelease; } if (flags & ImGuiSelectableFlags_Disabled) { button_flags |= ImGuiButtonFlags_Disabled; } if (flags & ImGuiSelectableFlags_AllowDoubleClick) { button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick; } if (flags & ImGuiSelectableFlags_AllowItemOverlap) { button_flags |= ImGuiButtonFlags_AllowItemOverlap; } if (flags & ImGuiSelectableFlags_Disabled) selected = false; const bool was_selected = selected; bool hovered, held; bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags); // Update NavId when clicking or when Hovering (this doesn't happen on most widgets), so navigation can be resumed with gamepad/keyboard if (pressed || (hovered && (flags & ImGuiSelectableFlags_SetNavIdOnHover))) { if (!g.NavDisableMouseHover && g.NavWindow == window && g.NavLayer == window->DC.NavLayerCurrent) { g.NavDisableHighlight = true; SetNavID(id, window->DC.NavLayerCurrent, window->DC.NavFocusScopeIdCurrent); } } if (pressed) MarkItemEdited(id); if (flags & ImGuiSelectableFlags_AllowItemOverlap) SetItemAllowOverlap(); // In this branch, Selectable() cannot toggle the selection so this will never trigger. if (selected != was_selected) //-V547 window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_ToggledSelection; // Render if (held && (flags & ImGuiSelectableFlags_DrawHoveredWhenHeld)) hovered = true; if (hovered || selected) { const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); RenderFrame(bb.Min, bb.Max, col, false, 0.0f); RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding); } if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.CurrentColumns) { PopColumnsBackground(); bb.Max.x -= (GetContentRegionMax().x - max_x); } if (flags & ImGuiSelectableFlags_Disabled) PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); RenderTextClipped(bb_inner.Min, bb_inner.Max, label, NULL, &label_size, style.SelectableTextAlign, &bb); if (flags & ImGuiSelectableFlags_Disabled) PopStyleColor(); // Automatically close popups if (pressed && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(window->DC.ItemFlags & ImGuiItemFlags_SelectableDontClosePopup)) CloseCurrentPopup(); IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags); return pressed; } bool ImGui::Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags, const ImVec2& size_arg) { if (Selectable(label, *p_selected, flags, size_arg)) { *p_selected = !*p_selected; return true; } return false; } //------------------------------------------------------------------------- // [SECTION] Widgets: ListBox //------------------------------------------------------------------------- // - ListBox() // - ListBoxHeader() // - ListBoxFooter() //------------------------------------------------------------------------- // FIXME: This is an old API. We should redesign some of it, rename ListBoxHeader->BeginListBox, ListBoxFooter->EndListBox // and promote using them over existing ListBox() functions, similarly to change with combo boxes. //------------------------------------------------------------------------- // FIXME: In principle this function should be called BeginListBox(). We should rename it after re-evaluating if we want to keep the same signature. // Helper to calculate the size of a listbox and display a label on the right. // Tip: To have a list filling the entire window width, PushItemWidth(-1) and pass an non-visible label e.g. "##empty" bool ImGui::ListBoxHeader(const char* label, const ImVec2& size_arg) { ImGuiContext& g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; const ImGuiStyle& style = g.Style; const ImGuiID id = GetID(label); const ImVec2 label_size = CalcTextSize(label, NULL, true); // Size default to hold ~7 items. Fractional number of items helps seeing that we can scroll down/up without looking at scrollbar. ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), GetTextLineHeightWithSpacing() * 7.4f + style.ItemSpacing.y); ImVec2 frame_size = ImVec2(size.x, ImMax(size.y, label_size.y)); ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size); ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); window->DC.LastItemRect = bb; // Forward storage for ListBoxFooter.. dodgy. g.NextItemData.ClearFlags(); if (!IsRectVisible(bb.Min, bb.Max)) { ItemSize(bb.GetSize(), style.FramePadding.y); ItemAdd(bb, 0, &frame_bb); return false; } BeginGroup(); if (label_size.x > 0) RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); BeginChildFrame(id, frame_bb.GetSize()); return true; } // FIXME: In principle this function should be called EndListBox(). We should rename it after re-evaluating if we want to keep the same signature. bool ImGui::ListBoxHeader(const char* label, int items_count, int height_in_items) { // Size default to hold ~7.25 items. // We add +25% worth of item height to allow the user to see at a glance if there are more items up/down, without looking at the scrollbar. // We don't add this extra bit if items_count <= height_in_items. It is slightly dodgy, because it means a dynamic list of items will make the widget resize occasionally when it crosses that size. // I am expecting that someone will come and complain about this behavior in a remote future, then we can advise on a better solution. if (height_in_items < 0) height_in_items = ImMin(items_count, 7); const ImGuiStyle& style = GetStyle(); float height_in_items_f = (height_in_items < items_count) ? (height_in_items + 0.25f) : (height_in_items + 0.00f); // We include ItemSpacing.y so that a list sized for the exact number of items doesn't make a scrollbar appears. We could also enforce that by passing a flag to BeginChild(). ImVec2 size; size.x = 0.0f; size.y = ImFloor(GetTextLineHeightWithSpacing() * height_in_items_f + style.FramePadding.y * 2.0f); return ListBoxHeader(label, size); } // FIXME: In principle this function should be called EndListBox(). We should rename it after re-evaluating if we want to keep the same signature. void ImGui::ListBoxFooter() { ImGuiWindow* parent_window = GetCurrentWindow()->ParentWindow; const ImRect bb = parent_window->DC.LastItemRect; const ImGuiStyle& style = GetStyle(); EndChildFrame(); // Redeclare item size so that it includes the label (we have stored the full size in LastItemRect) // We call SameLine() to restore DC.CurrentLine* data SameLine(); parent_window->DC.CursorPos = bb.Min; ItemSize(bb, style.FramePadding.y); EndGroup(); } bool ImGui::ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_items) { const bool value_changed = ListBox(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_items); return value_changed; } bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int height_in_items) { if (!ListBoxHeader(label, items_count, height_in_items)) return false; // Assume all items have even height (= 1 line of text). If you need items of different or variable sizes you can create a custom version of ListBox() in your code without using the clipper. ImGuiContext& g = *GImGui; bool value_changed = false; ImGuiListClipper clipper(items_count, GetTextLineHeightWithSpacing()); // We know exactly our line height here so we pass it as a minor optimization, but generally you don't need to. while (clipper.Step()) for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { const bool item_selected = (i == *current_item); const char* item_text; if (!items_getter(data, i, &item_text)) item_text = "*Unknown item*"; PushID(i); if (Selectable(item_text, item_selected)) { *current_item = i; value_changed = true; } if (item_selected) SetItemDefaultFocus(); PopID(); } ListBoxFooter(); if (value_changed) MarkItemEdited(g.CurrentWindow->DC.LastItemId); return value_changed; } //------------------------------------------------------------------------- // [SECTION] Widgets: PlotLines, PlotHistogram //------------------------------------------------------------------------- // - PlotEx() [Internal] // - PlotLines() // - PlotHistogram() //------------------------------------------------------------------------- void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImGuiID id = window->GetID(label); const ImVec2 label_size = CalcTextSize(label, NULL, true); if (frame_size.x == 0.0f) frame_size.x = CalcItemWidth(); if (frame_size.y == 0.0f) frame_size.y = label_size.y + (style.FramePadding.y * 2); const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size); const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding); const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0)); ItemSize(total_bb, style.FramePadding.y); if (!ItemAdd(total_bb, 0, &frame_bb)) return; const bool hovered = ItemHoverable(frame_bb, id); // Determine scale from values if not specified if (scale_min == FLT_MAX || scale_max == FLT_MAX) { float v_min = FLT_MAX; float v_max = -FLT_MAX; for (int i = 0; i < values_count; i++) { const float v = values_getter(data, i); if (v != v) // Ignore NaN values continue; v_min = ImMin(v_min, v); v_max = ImMax(v_max, v); } if (scale_min == FLT_MAX) scale_min = v_min; if (scale_max == FLT_MAX) scale_max = v_max; } RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); const int values_count_min = (plot_type == ImGuiPlotType_Lines) ? 2 : 1; if (values_count >= values_count_min) { int res_w = ImMin((int)frame_size.x, values_count) + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0); int item_count = values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0); // Tooltip on hover int v_hovered = -1; if (hovered && inner_bb.Contains(g.IO.MousePos)) { const float t = ImClamp((g.IO.MousePos.x - inner_bb.Min.x) / (inner_bb.Max.x - inner_bb.Min.x), 0.0f, 0.9999f); const int v_idx = (int)(t * item_count); IM_ASSERT(v_idx >= 0 && v_idx < values_count); const float v0 = values_getter(data, (v_idx + values_offset) % values_count); const float v1 = values_getter(data, (v_idx + 1 + values_offset) % values_count); if (plot_type == ImGuiPlotType_Lines) SetTooltip("%d: %8.4g\n%d: %8.4g", v_idx, v0, v_idx+1, v1); else if (plot_type == ImGuiPlotType_Histogram) SetTooltip("%d: %8.4g", v_idx, v0); v_hovered = v_idx; } const float t_step = 1.0f / (float)res_w; const float inv_scale = (scale_min == scale_max) ? 0.0f : (1.0f / (scale_max - scale_min)); float v0 = values_getter(data, (0 + values_offset) % values_count); float t0 = 0.0f; ImVec2 tp0 = ImVec2( t0, 1.0f - ImSaturate((v0 - scale_min) * inv_scale) ); // Point in the normalized space of our target rectangle float histogram_zero_line_t = (scale_min * scale_max < 0.0f) ? (-scale_min * inv_scale) : (scale_min < 0.0f ? 0.0f : 1.0f); // Where does the zero line stands const ImU32 col_base = GetColorU32((plot_type == ImGuiPlotType_Lines) ? ImGuiCol_PlotLines : ImGuiCol_PlotHistogram); const ImU32 col_hovered = GetColorU32((plot_type == ImGuiPlotType_Lines) ? ImGuiCol_PlotLinesHovered : ImGuiCol_PlotHistogramHovered); for (int n = 0; n < res_w; n++) { const float t1 = t0 + t_step; const int v1_idx = (int)(t0 * item_count + 0.5f); IM_ASSERT(v1_idx >= 0 && v1_idx < values_count); const float v1 = values_getter(data, (v1_idx + values_offset + 1) % values_count); const ImVec2 tp1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) * inv_scale) ); // NB: Draw calls are merged together by the DrawList system. Still, we should render our batch are lower level to save a bit of CPU. ImVec2 pos0 = ImLerp(inner_bb.Min, inner_bb.Max, tp0); ImVec2 pos1 = ImLerp(inner_bb.Min, inner_bb.Max, (plot_type == ImGuiPlotType_Lines) ? tp1 : ImVec2(tp1.x, histogram_zero_line_t)); if (plot_type == ImGuiPlotType_Lines) { window->DrawList->AddLine(pos0, pos1, v_hovered == v1_idx ? col_hovered : col_base); } else if (plot_type == ImGuiPlotType_Histogram) { if (pos1.x >= pos0.x + 2.0f) pos1.x -= 1.0f; window->DrawList->AddRectFilled(pos0, pos1, v_hovered == v1_idx ? col_hovered : col_base); } t0 = t1; tp0 = tp1; } } // Text overlay if (overlay_text) RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, overlay_text, NULL, NULL, ImVec2(0.5f,0.0f)); if (label_size.x > 0.0f) RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, inner_bb.Min.y), label); } struct ImGuiPlotArrayGetterData { const float* Values; int Stride; ImGuiPlotArrayGetterData(const float* values, int stride) { Values = values; Stride = stride; } }; static float Plot_ArrayGetter(void* data, int idx) { ImGuiPlotArrayGetterData* plot_data = (ImGuiPlotArrayGetterData*)data; const float v = *(const float*)(const void*)((const unsigned char*)plot_data->Values + (size_t)idx * plot_data->Stride); return v; } void ImGui::PlotLines(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, int stride) { ImGuiPlotArrayGetterData data(values, stride); PlotEx(ImGuiPlotType_Lines, label, &Plot_ArrayGetter, (void*)&data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); } void ImGui::PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size) { PlotEx(ImGuiPlotType_Lines, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); } void ImGui::PlotHistogram(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, int stride) { ImGuiPlotArrayGetterData data(values, stride); PlotEx(ImGuiPlotType_Histogram, label, &Plot_ArrayGetter, (void*)&data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); } void ImGui::PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size) { PlotEx(ImGuiPlotType_Histogram, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); } //------------------------------------------------------------------------- // [SECTION] Widgets: Value helpers // Those is not very useful, legacy API. //------------------------------------------------------------------------- // - Value() //------------------------------------------------------------------------- void ImGui::Value(const char* prefix, bool b) { Text("%s: %s", prefix, (b ? "true" : "false")); } void ImGui::Value(const char* prefix, int v) { Text("%s: %d", prefix, v); } void ImGui::Value(const char* prefix, unsigned int v) { Text("%s: %d", prefix, v); } void ImGui::Value(const char* prefix, float v, const char* float_format) { if (float_format) { char fmt[64]; ImFormatString(fmt, IM_ARRAYSIZE(fmt), "%%s: %s", float_format); Text(fmt, prefix, v); } else { Text("%s: %.3f", prefix, v); } } //------------------------------------------------------------------------- // [SECTION] MenuItem, BeginMenu, EndMenu, etc. //------------------------------------------------------------------------- // - ImGuiMenuColumns [Internal] // - BeginMenuBar() // - EndMenuBar() // - BeginMainMenuBar() // - EndMainMenuBar() // - BeginMenu() // - EndMenu() // - MenuItem() //------------------------------------------------------------------------- // Helpers for internal use ImGuiMenuColumns::ImGuiMenuColumns() { Spacing = Width = NextWidth = 0.0f; memset(Pos, 0, sizeof(Pos)); memset(NextWidths, 0, sizeof(NextWidths)); } void ImGuiMenuColumns::Update(int count, float spacing, bool clear) { IM_ASSERT(count == IM_ARRAYSIZE(Pos)); IM_UNUSED(count); Width = NextWidth = 0.0f; Spacing = spacing; if (clear) memset(NextWidths, 0, sizeof(NextWidths)); for (int i = 0; i < IM_ARRAYSIZE(Pos); i++) { if (i > 0 && NextWidths[i] > 0.0f) Width += Spacing; Pos[i] = IM_FLOOR(Width); Width += NextWidths[i]; NextWidths[i] = 0.0f; } } float ImGuiMenuColumns::DeclColumns(float w0, float w1, float w2) // not using va_arg because they promote float to double { NextWidth = 0.0f; NextWidths[0] = ImMax(NextWidths[0], w0); NextWidths[1] = ImMax(NextWidths[1], w1); NextWidths[2] = ImMax(NextWidths[2], w2); for (int i = 0; i < IM_ARRAYSIZE(Pos); i++) NextWidth += NextWidths[i] + ((i > 0 && NextWidths[i] > 0.0f) ? Spacing : 0.0f); return ImMax(Width, NextWidth); } float ImGuiMenuColumns::CalcExtraSpace(float avail_w) const { return ImMax(0.0f, avail_w - Width); } // FIXME: Provided a rectangle perhaps e.g. a BeginMenuBarEx() could be used anywhere.. // Currently the main responsibility of this function being to setup clip-rect + horizontal layout + menu navigation layer. // Ideally we also want this to be responsible for claiming space out of the main window scrolling rectangle, in which case ImGuiWindowFlags_MenuBar will become unnecessary. // Then later the same system could be used for multiple menu-bars, scrollbars, side-bars. bool ImGui::BeginMenuBar() { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; if (!(window->Flags & ImGuiWindowFlags_MenuBar)) return false; IM_ASSERT(!window->DC.MenuBarAppending); BeginGroup(); // Backup position on layer 0 // FIXME: Misleading to use a group for that backup/restore PushID("##menubar"); // We don't clip with current window clipping rectangle as it is already set to the area below. However we clip with window full rect. // We remove 1 worth of rounding to Max.x to that text in long menus and small windows don't tend to display over the lower-right rounded area, which looks particularly glitchy. ImRect bar_rect = window->MenuBarRect(); ImRect clip_rect(IM_ROUND(bar_rect.Min.x + window->WindowBorderSize), IM_ROUND(bar_rect.Min.y + window->WindowBorderSize), IM_ROUND(ImMax(bar_rect.Min.x, bar_rect.Max.x - ImMax(window->WindowRounding, window->WindowBorderSize))), IM_ROUND(bar_rect.Max.y)); clip_rect.ClipWith(window->OuterRectClipped); PushClipRect(clip_rect.Min, clip_rect.Max, false); window->DC.CursorPos = ImVec2(bar_rect.Min.x + window->DC.MenuBarOffset.x, bar_rect.Min.y + window->DC.MenuBarOffset.y); window->DC.LayoutType = ImGuiLayoutType_Horizontal; window->DC.NavLayerCurrent = ImGuiNavLayer_Menu; window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Menu); window->DC.MenuBarAppending = true; AlignTextToFramePadding(); return true; } void ImGui::EndMenuBar() { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return; ImGuiContext& g = *GImGui; // Nav: When a move request within one of our child menu failed, capture the request to navigate among our siblings. if (NavMoveRequestButNoResultYet() && (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right) && (g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu)) { ImGuiWindow* nav_earliest_child = g.NavWindow; while (nav_earliest_child->ParentWindow && (nav_earliest_child->ParentWindow->Flags & ImGuiWindowFlags_ChildMenu)) nav_earliest_child = nav_earliest_child->ParentWindow; if (nav_earliest_child->ParentWindow == window && nav_earliest_child->DC.ParentLayoutType == ImGuiLayoutType_Horizontal && g.NavMoveRequestForward == ImGuiNavForward_None) { // To do so we claim focus back, restore NavId and then process the movement request for yet another frame. // This involve a one-frame delay which isn't very problematic in this situation. We could remove it by scoring in advance for multiple window (probably not worth the hassle/cost) const ImGuiNavLayer layer = ImGuiNavLayer_Menu; IM_ASSERT(window->DC.NavLayerActiveMaskNext & (1 << layer)); // Sanity check FocusWindow(window); SetNavIDWithRectRel(window->NavLastIds[layer], layer, 0, window->NavRectRel[layer]); g.NavLayer = layer; g.NavDisableHighlight = true; // Hide highlight for the current frame so we don't see the intermediary selection. g.NavMoveRequestForward = ImGuiNavForward_ForwardQueued; NavMoveRequestCancel(); } } IM_ASSERT(window->Flags & ImGuiWindowFlags_MenuBar); IM_ASSERT(window->DC.MenuBarAppending); PopClipRect(); PopID(); window->DC.MenuBarOffset.x = window->DC.CursorPos.x - window->MenuBarRect().Min.x; // Save horizontal position so next append can reuse it. This is kinda equivalent to a per-layer CursorPos. window->DC.GroupStack.back().EmitItem = false; EndGroup(); // Restore position on layer 0 window->DC.LayoutType = ImGuiLayoutType_Vertical; window->DC.NavLayerCurrent = ImGuiNavLayer_Main; window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main); window->DC.MenuBarAppending = false; } // For the main menu bar, which cannot be moved, we honor g.Style.DisplaySafeAreaPadding to ensure text can be visible on a TV set. bool ImGui::BeginMainMenuBar() { ImGuiContext& g = *GImGui; g.NextWindowData.MenuBarOffsetMinVal = ImVec2(g.Style.DisplaySafeAreaPadding.x, ImMax(g.Style.DisplaySafeAreaPadding.y - g.Style.FramePadding.y, 0.0f)); SetNextWindowPos(ImVec2(0.0f, 0.0f)); SetNextWindowSize(ImVec2(g.IO.DisplaySize.x, g.NextWindowData.MenuBarOffsetMinVal.y + g.FontBaseSize + g.Style.FramePadding.y)); PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0, 0)); ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar; bool is_open = Begin("##MainMenuBar", NULL, window_flags) && BeginMenuBar(); PopStyleVar(2); g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f); if (!is_open) { End(); return false; } return true; //-V1020 } void ImGui::EndMainMenuBar() { EndMenuBar(); // When the user has left the menu layer (typically: closed menus through activation of an item), we restore focus to the previous window // FIXME: With this strategy we won't be able to restore a NULL focus. ImGuiContext& g = *GImGui; if (g.CurrentWindow == g.NavWindow && g.NavLayer == 0 && !g.NavAnyRequest) FocusTopMostWindowUnderOne(g.NavWindow, NULL); End(); } bool ImGui::BeginMenu(const char* label, bool enabled) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImGuiID id = window->GetID(label); ImVec2 label_size = CalcTextSize(label, NULL, true); bool pressed; bool menu_is_open = IsPopupOpen(id); bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].OpenParentId == window->IDStack.back()); ImGuiWindow* backed_nav_window = g.NavWindow; if (menuset_is_open) g.NavWindow = window; // Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent) // The reference position stored in popup_pos will be used by Begin() to find a suitable position for the child menu, // However the final position is going to be different! It is choosen by FindBestWindowPosForPopup(). // e.g. Menus tend to overlap each other horizontally to amplify relative Z-ordering. ImVec2 popup_pos, pos = window->DC.CursorPos; if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) { // Menu inside an horizontal menu bar // Selectable extend their highlight by half ItemSpacing in each direction. // For ChildMenu, the popup position will be overwritten by the call to FindBestWindowPosForPopup() in Begin() popup_pos = ImVec2(pos.x - 1.0f - IM_FLOOR(style.ItemSpacing.x * 0.5f), pos.y - style.FramePadding.y + window->MenuBarHeight()); window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * 0.5f); PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y)); float w = label_size.x; pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_PressedOnClick | ImGuiSelectableFlags_DontClosePopups | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f)); PopStyleVar(); window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar(). } else { // Menu inside a menu popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y); float w = window->DC.MenuColumns.DeclColumns(label_size.x, 0.0f, IM_FLOOR(g.FontSize * 1.20f)); // Feedback to next frame float extra_w = ImMax(0.0f, GetContentRegionAvail().x - w); pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_PressedOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_DrawFillAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f)); ImU32 text_col = GetColorU32(enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled); RenderArrow(window->DrawList, pos + ImVec2(window->DC.MenuColumns.Pos[2] + extra_w + g.FontSize * 0.30f, 0.0f), text_col, ImGuiDir_Right); } const bool hovered = enabled && ItemHoverable(window->DC.LastItemRect, id); if (menuset_is_open) g.NavWindow = backed_nav_window; bool want_open = false; bool want_close = false; if (window->DC.LayoutType == ImGuiLayoutType_Vertical) // (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu)) { // Close menu when not hovering it anymore unless we are moving roughly in the direction of the menu // Implement http://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown to avoid using timers, so menus feels more reactive. bool moving_toward_other_child_menu = false; ImGuiWindow* child_menu_window = (g.BeginPopupStack.Size < g.OpenPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].SourceWindow == window) ? g.OpenPopupStack[g.BeginPopupStack.Size].Window : NULL; if (g.HoveredWindow == window && child_menu_window != NULL && !(window->Flags & ImGuiWindowFlags_MenuBar)) { // FIXME-DPI: Values should be derived from a master "scale" factor. ImRect next_window_rect = child_menu_window->Rect(); ImVec2 ta = g.IO.MousePos - g.IO.MouseDelta; ImVec2 tb = (window->Pos.x < child_menu_window->Pos.x) ? next_window_rect.GetTL() : next_window_rect.GetTR(); ImVec2 tc = (window->Pos.x < child_menu_window->Pos.x) ? next_window_rect.GetBL() : next_window_rect.GetBR(); float extra = ImClamp(ImFabs(ta.x - tb.x) * 0.30f, 5.0f, 30.0f); // add a bit of extra slack. ta.x += (window->Pos.x < child_menu_window->Pos.x) ? -0.5f : +0.5f; // to avoid numerical issues tb.y = ta.y + ImMax((tb.y - extra) - ta.y, -100.0f); // triangle is maximum 200 high to limit the slope and the bias toward large sub-menus // FIXME: Multiply by fb_scale? tc.y = ta.y + ImMin((tc.y + extra) - ta.y, +100.0f); moving_toward_other_child_menu = ImTriangleContainsPoint(ta, tb, tc, g.IO.MousePos); //GetForegroundDrawList()->AddTriangleFilled(ta, tb, tc, moving_within_opened_triangle ? IM_COL32(0,128,0,128) : IM_COL32(128,0,0,128)); // [DEBUG] } if (menu_is_open && !hovered && g.HoveredWindow == window && g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrame != id && !moving_toward_other_child_menu) want_close = true; if (!menu_is_open && hovered && pressed) // Click to open want_open = true; else if (!menu_is_open && hovered && !moving_toward_other_child_menu) // Hover to open want_open = true; if (g.NavActivateId == id) { want_close = menu_is_open; want_open = !menu_is_open; } if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Right) // Nav-Right to open { want_open = true; NavMoveRequestCancel(); } } else { // Menu bar if (menu_is_open && pressed && menuset_is_open) // Click an open menu again to close it { want_close = true; want_open = menu_is_open = false; } else if (pressed || (hovered && menuset_is_open && !menu_is_open)) // First click to open, then hover to open others { want_open = true; } else if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Down) // Nav-Down to open { want_open = true; NavMoveRequestCancel(); } } if (!enabled) // explicitly close if an open menu becomes disabled, facilitate users code a lot in pattern such as 'if (BeginMenu("options", has_object)) { ..use object.. }' want_close = true; if (want_close && IsPopupOpen(id)) ClosePopupToLevel(g.BeginPopupStack.Size, true); IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Openable | (menu_is_open ? ImGuiItemStatusFlags_Opened : 0)); if (!menu_is_open && want_open && g.OpenPopupStack.Size > g.BeginPopupStack.Size) { // Don't recycle same menu level in the same frame, first close the other menu and yield for a frame. OpenPopup(label); return false; } menu_is_open |= want_open; if (want_open) OpenPopup(label); if (menu_is_open) { // Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu) SetNextWindowPos(popup_pos, ImGuiCond_Always); ImGuiWindowFlags flags = ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNavFocus; if (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu)) flags |= ImGuiWindowFlags_ChildWindow; menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display) } return menu_is_open; } void ImGui::EndMenu() { // Nav: When a left move request _within our child menu_ failed, close ourselves (the _parent_ menu). // A menu doesn't close itself because EndMenuBar() wants the catch the last Left<>Right inputs. // However, it means that with the current code, a BeginMenu() from outside another menu or a menu-bar won't be closable with the Left direction. ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (g.NavWindow && g.NavWindow->ParentWindow == window && g.NavMoveDir == ImGuiDir_Left && NavMoveRequestButNoResultYet() && window->DC.LayoutType == ImGuiLayoutType_Vertical) { ClosePopupToLevel(g.BeginPopupStack.Size, true); NavMoveRequestCancel(); } EndPopup(); } bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, bool enabled) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; ImGuiStyle& style = g.Style; ImVec2 pos = window->DC.CursorPos; ImVec2 label_size = CalcTextSize(label, NULL, true); // We've been using the equivalent of ImGuiSelectableFlags_SetNavIdOnHover on all Selectable() since early Nav system days (commit 43ee5d73), // but I am unsure whether this should be kept at all. For now moved it to be an opt-in feature used by menus only. ImGuiSelectableFlags flags = ImGuiSelectableFlags_PressedOnRelease | ImGuiSelectableFlags_SetNavIdOnHover | (enabled ? 0 : ImGuiSelectableFlags_Disabled); bool pressed; if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) { // Mimic the exact layout spacing of BeginMenu() to allow MenuItem() inside a menu bar, which is a little misleading but may be useful // Note that in this situation we render neither the shortcut neither the selected tick mark float w = label_size.x; window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * 0.5f); PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y)); pressed = Selectable(label, false, flags, ImVec2(w, 0.0f)); PopStyleVar(); window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar(). } else { ImVec2 shortcut_size = shortcut ? CalcTextSize(shortcut, NULL) : ImVec2(0.0f, 0.0f); float w = window->DC.MenuColumns.DeclColumns(label_size.x, shortcut_size.x, IM_FLOOR(g.FontSize * 1.20f)); // Feedback for next frame float extra_w = ImMax(0.0f, GetContentRegionAvail().x - w); pressed = Selectable(label, false, flags | ImGuiSelectableFlags_DrawFillAvailWidth, ImVec2(w, 0.0f)); if (shortcut_size.x > 0.0f) { PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]); RenderText(pos + ImVec2(window->DC.MenuColumns.Pos[1] + extra_w, 0.0f), shortcut, NULL, false); PopStyleColor(); } if (selected) RenderCheckMark(pos + ImVec2(window->DC.MenuColumns.Pos[2] + extra_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled), g.FontSize * 0.866f); } IMGUI_TEST_ENGINE_ITEM_INFO(window->DC.LastItemId, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Checkable | (selected ? ImGuiItemStatusFlags_Checked : 0)); return pressed; } bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled) { if (MenuItem(label, shortcut, p_selected ? *p_selected : false, enabled)) { if (p_selected) *p_selected = !*p_selected; return true; } return false; } //------------------------------------------------------------------------- // [SECTION] Widgets: BeginTabBar, EndTabBar, etc. //------------------------------------------------------------------------- // - BeginTabBar() // - BeginTabBarEx() [Internal] // - EndTabBar() // - TabBarLayout() [Internal] // - TabBarCalcTabID() [Internal] // - TabBarCalcMaxTabWidth() [Internal] // - TabBarFindTabById() [Internal] // - TabBarRemoveTab() [Internal] // - TabBarCloseTab() [Internal] // - TabBarScrollClamp()v // - TabBarScrollToTab() [Internal] // - TabBarQueueChangeTabOrder() [Internal] // - TabBarScrollingButtons() [Internal] // - TabBarTabListPopupButton() [Internal] //------------------------------------------------------------------------- namespace ImGui { static void TabBarLayout(ImGuiTabBar* tab_bar); static ImU32 TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label); static float TabBarCalcMaxTabWidth(); static float TabBarScrollClamp(ImGuiTabBar* tab_bar, float scrolling); static void TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab); static ImGuiTabItem* TabBarScrollingButtons(ImGuiTabBar* tab_bar); static ImGuiTabItem* TabBarTabListPopupButton(ImGuiTabBar* tab_bar); } ImGuiTabBar::ImGuiTabBar() { ID = 0; SelectedTabId = NextSelectedTabId = VisibleTabId = 0; CurrFrameVisible = PrevFrameVisible = -1; LastTabContentHeight = 0.0f; OffsetMax = OffsetMaxIdeal = OffsetNextTab = 0.0f; ScrollingAnim = ScrollingTarget = ScrollingTargetDistToVisibility = ScrollingSpeed = 0.0f; Flags = ImGuiTabBarFlags_None; ReorderRequestTabId = 0; ReorderRequestDir = 0; WantLayout = VisibleTabWasSubmitted = false; LastTabItemIdx = -1; } static int IMGUI_CDECL TabItemComparerByVisibleOffset(const void* lhs, const void* rhs) { const ImGuiTabItem* a = (const ImGuiTabItem*)lhs; const ImGuiTabItem* b = (const ImGuiTabItem*)rhs; return (int)(a->Offset - b->Offset); } static ImGuiTabBar* GetTabBarFromTabBarRef(const ImGuiPtrOrIndex& ref) { ImGuiContext& g = *GImGui; return ref.Ptr ? (ImGuiTabBar*)ref.Ptr : g.TabBars.GetByIndex(ref.Index); } static ImGuiPtrOrIndex GetTabBarRefFromTabBar(ImGuiTabBar* tab_bar) { ImGuiContext& g = *GImGui; if (g.TabBars.Contains(tab_bar)) return ImGuiPtrOrIndex(g.TabBars.GetIndex(tab_bar)); return ImGuiPtrOrIndex(tab_bar); } bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (window->SkipItems) return false; ImGuiID id = window->GetID(str_id); ImGuiTabBar* tab_bar = g.TabBars.GetOrAddByKey(id); ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->WorkRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2); tab_bar->ID = id; return BeginTabBarEx(tab_bar, tab_bar_bb, flags | ImGuiTabBarFlags_IsFocused); } bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImGuiTabBarFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (window->SkipItems) return false; if ((flags & ImGuiTabBarFlags_DockNode) == 0) PushOverrideID(tab_bar->ID); // Add to stack g.CurrentTabBarStack.push_back(GetTabBarRefFromTabBar(tab_bar)); g.CurrentTabBar = tab_bar; if (tab_bar->CurrFrameVisible == g.FrameCount) { //IMGUI_DEBUG_LOG("BeginTabBarEx already called this frame\n", g.FrameCount); IM_ASSERT(0); return true; } // When toggling back from ordered to manually-reorderable, shuffle tabs to enforce the last visible order. // Otherwise, the most recently inserted tabs would move at the end of visible list which can be a little too confusing or magic for the user. if ((flags & ImGuiTabBarFlags_Reorderable) && !(tab_bar->Flags & ImGuiTabBarFlags_Reorderable) && tab_bar->Tabs.Size > 1 && tab_bar->PrevFrameVisible != -1) ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerByVisibleOffset); // Flags if ((flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0) flags |= ImGuiTabBarFlags_FittingPolicyDefault_; tab_bar->Flags = flags; tab_bar->BarRect = tab_bar_bb; tab_bar->WantLayout = true; // Layout will be done on the first call to ItemTab() tab_bar->PrevFrameVisible = tab_bar->CurrFrameVisible; tab_bar->CurrFrameVisible = g.FrameCount; tab_bar->FramePadding = g.Style.FramePadding; // Layout ItemSize(ImVec2(tab_bar->OffsetMaxIdeal, tab_bar->BarRect.GetHeight()), tab_bar->FramePadding.y); window->DC.CursorPos.x = tab_bar->BarRect.Min.x; // Draw separator const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive); const float y = tab_bar->BarRect.Max.y - 1.0f; { const float separator_min_x = tab_bar->BarRect.Min.x - IM_FLOOR(window->WindowPadding.x * 0.5f); const float separator_max_x = tab_bar->BarRect.Max.x + IM_FLOOR(window->WindowPadding.x * 0.5f); window->DrawList->AddLine(ImVec2(separator_min_x, y), ImVec2(separator_max_x, y), col, 1.0f); } return true; } void ImGui::EndTabBar() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (window->SkipItems) return; ImGuiTabBar* tab_bar = g.CurrentTabBar; if (tab_bar == NULL) { IM_ASSERT_USER_ERROR(tab_bar != NULL, "Mismatched BeginTabBar()/EndTabBar()!"); return; } if (tab_bar->WantLayout) TabBarLayout(tab_bar); // Restore the last visible height if no tab is visible, this reduce vertical flicker/movement when a tabs gets removed without calling SetTabItemClosed(). const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount); if (tab_bar->VisibleTabWasSubmitted || tab_bar->VisibleTabId == 0 || tab_bar_appearing) tab_bar->LastTabContentHeight = ImMax(window->DC.CursorPos.y - tab_bar->BarRect.Max.y, 0.0f); else window->DC.CursorPos.y = tab_bar->BarRect.Max.y + tab_bar->LastTabContentHeight; if ((tab_bar->Flags & ImGuiTabBarFlags_DockNode) == 0) PopID(); g.CurrentTabBarStack.pop_back(); g.CurrentTabBar = g.CurrentTabBarStack.empty() ? NULL : GetTabBarFromTabBarRef(g.CurrentTabBarStack.back()); } // This is called only once a frame before by the first call to ItemTab() // The reason we're not calling it in BeginTabBar() is to leave a chance to the user to call the SetTabItemClosed() functions. static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar) { ImGuiContext& g = *GImGui; tab_bar->WantLayout = false; // Garbage collect int tab_dst_n = 0; for (int tab_src_n = 0; tab_src_n < tab_bar->Tabs.Size; tab_src_n++) { ImGuiTabItem* tab = &tab_bar->Tabs[tab_src_n]; if (tab->LastFrameVisible < tab_bar->PrevFrameVisible) { if (tab->ID == tab_bar->SelectedTabId) tab_bar->SelectedTabId = 0; continue; } if (tab_dst_n != tab_src_n) tab_bar->Tabs[tab_dst_n] = tab_bar->Tabs[tab_src_n]; tab_dst_n++; } if (tab_bar->Tabs.Size != tab_dst_n) tab_bar->Tabs.resize(tab_dst_n); // Setup next selected tab ImGuiID scroll_track_selected_tab_id = 0; if (tab_bar->NextSelectedTabId) { tab_bar->SelectedTabId = tab_bar->NextSelectedTabId; tab_bar->NextSelectedTabId = 0; scroll_track_selected_tab_id = tab_bar->SelectedTabId; } // Process order change request (we could probably process it when requested but it's just saner to do it in a single spot). if (tab_bar->ReorderRequestTabId != 0) { if (ImGuiTabItem* tab1 = TabBarFindTabByID(tab_bar, tab_bar->ReorderRequestTabId)) { //IM_ASSERT(tab_bar->Flags & ImGuiTabBarFlags_Reorderable); // <- this may happen when using debug tools int tab2_order = tab_bar->GetTabOrder(tab1) + tab_bar->ReorderRequestDir; if (tab2_order >= 0 && tab2_order < tab_bar->Tabs.Size) { ImGuiTabItem* tab2 = &tab_bar->Tabs[tab2_order]; ImGuiTabItem item_tmp = *tab1; *tab1 = *tab2; *tab2 = item_tmp; if (tab2->ID == tab_bar->SelectedTabId) scroll_track_selected_tab_id = tab2->ID; tab1 = tab2 = NULL; } if (tab_bar->Flags & ImGuiTabBarFlags_SaveSettings) MarkIniSettingsDirty(); } tab_bar->ReorderRequestTabId = 0; } // Tab List Popup (will alter tab_bar->BarRect and therefore the available width!) const bool tab_list_popup_button = (tab_bar->Flags & ImGuiTabBarFlags_TabListPopupButton) != 0; if (tab_list_popup_button) if (ImGuiTabItem* tab_to_select = TabBarTabListPopupButton(tab_bar)) // NB: Will alter BarRect.Max.x! scroll_track_selected_tab_id = tab_bar->SelectedTabId = tab_to_select->ID; // Compute ideal widths g.ShrinkWidthBuffer.resize(tab_bar->Tabs.Size); float width_total_contents = 0.0f; ImGuiTabItem* most_recently_selected_tab = NULL; bool found_selected_tab_id = false; for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) { ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; IM_ASSERT(tab->LastFrameVisible >= tab_bar->PrevFrameVisible); if (most_recently_selected_tab == NULL || most_recently_selected_tab->LastFrameSelected < tab->LastFrameSelected) most_recently_selected_tab = tab; if (tab->ID == tab_bar->SelectedTabId) found_selected_tab_id = true; // Refresh tab width immediately, otherwise changes of style e.g. style.FramePadding.x would noticeably lag in the tab bar. // Additionally, when using TabBarAddTab() to manipulate tab bar order we occasionally insert new tabs that don't have a width yet, // and we cannot wait for the next BeginTabItem() call. We cannot compute this width within TabBarAddTab() because font size depends on the active window. const char* tab_name = tab_bar->GetTabName(tab); const bool has_close_button = (tab->Flags & ImGuiTabItemFlags_NoCloseButton) ? false : true; tab->ContentWidth = TabItemCalcSize(tab_name, has_close_button).x; width_total_contents += (tab_n > 0 ? g.Style.ItemInnerSpacing.x : 0.0f) + tab->ContentWidth; // Store data so we can build an array sorted by width if we need to shrink tabs down g.ShrinkWidthBuffer[tab_n].Index = tab_n; g.ShrinkWidthBuffer[tab_n].Width = tab->ContentWidth; } // Compute width const float initial_offset_x = 0.0f; // g.Style.ItemInnerSpacing.x; const float width_avail = ImMax(tab_bar->BarRect.GetWidth() - initial_offset_x, 0.0f); float width_excess = (width_avail < width_total_contents) ? (width_total_contents - width_avail) : 0.0f; if (width_excess > 0.0f && (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyResizeDown)) { // If we don't have enough room, resize down the largest tabs first ShrinkWidths(g.ShrinkWidthBuffer.Data, g.ShrinkWidthBuffer.Size, width_excess); for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) tab_bar->Tabs[g.ShrinkWidthBuffer[tab_n].Index].Width = IM_FLOOR(g.ShrinkWidthBuffer[tab_n].Width); } else { const float tab_max_width = TabBarCalcMaxTabWidth(); for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) { ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; tab->Width = ImMin(tab->ContentWidth, tab_max_width); IM_ASSERT(tab->Width > 0.0f); } } // Layout all active tabs float offset_x = initial_offset_x; float offset_x_ideal = offset_x; tab_bar->OffsetNextTab = offset_x; // This is used by non-reorderable tab bar where the submission order is always honored. for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) { ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; tab->Offset = offset_x; if (scroll_track_selected_tab_id == 0 && g.NavJustMovedToId == tab->ID) scroll_track_selected_tab_id = tab->ID; offset_x += tab->Width + g.Style.ItemInnerSpacing.x; offset_x_ideal += tab->ContentWidth + g.Style.ItemInnerSpacing.x; } tab_bar->OffsetMax = ImMax(offset_x - g.Style.ItemInnerSpacing.x, 0.0f); tab_bar->OffsetMaxIdeal = ImMax(offset_x_ideal - g.Style.ItemInnerSpacing.x, 0.0f); // Horizontal scrolling buttons const bool scrolling_buttons = (tab_bar->OffsetMax > tab_bar->BarRect.GetWidth() && tab_bar->Tabs.Size > 1) && !(tab_bar->Flags & ImGuiTabBarFlags_NoTabListScrollingButtons) && (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyScroll); if (scrolling_buttons) if (ImGuiTabItem* tab_to_select = TabBarScrollingButtons(tab_bar)) // NB: Will alter BarRect.Max.x! scroll_track_selected_tab_id = tab_bar->SelectedTabId = tab_to_select->ID; // If we have lost the selected tab, select the next most recently active one if (found_selected_tab_id == false) tab_bar->SelectedTabId = 0; if (tab_bar->SelectedTabId == 0 && tab_bar->NextSelectedTabId == 0 && most_recently_selected_tab != NULL) scroll_track_selected_tab_id = tab_bar->SelectedTabId = most_recently_selected_tab->ID; // Lock in visible tab tab_bar->VisibleTabId = tab_bar->SelectedTabId; tab_bar->VisibleTabWasSubmitted = false; // Update scrolling if (scroll_track_selected_tab_id) if (ImGuiTabItem* scroll_track_selected_tab = TabBarFindTabByID(tab_bar, scroll_track_selected_tab_id)) TabBarScrollToTab(tab_bar, scroll_track_selected_tab); tab_bar->ScrollingAnim = TabBarScrollClamp(tab_bar, tab_bar->ScrollingAnim); tab_bar->ScrollingTarget = TabBarScrollClamp(tab_bar, tab_bar->ScrollingTarget); if (tab_bar->ScrollingAnim != tab_bar->ScrollingTarget) { // Scrolling speed adjust itself so we can always reach our target in 1/3 seconds. // Teleport if we are aiming far off the visible line tab_bar->ScrollingSpeed = ImMax(tab_bar->ScrollingSpeed, 70.0f * g.FontSize); tab_bar->ScrollingSpeed = ImMax(tab_bar->ScrollingSpeed, ImFabs(tab_bar->ScrollingTarget - tab_bar->ScrollingAnim) / 0.3f); const bool teleport = (tab_bar->PrevFrameVisible + 1 < g.FrameCount) || (tab_bar->ScrollingTargetDistToVisibility > 10.0f * g.FontSize); tab_bar->ScrollingAnim = teleport ? tab_bar->ScrollingTarget : ImLinearSweep(tab_bar->ScrollingAnim, tab_bar->ScrollingTarget, g.IO.DeltaTime * tab_bar->ScrollingSpeed); } else { tab_bar->ScrollingSpeed = 0.0f; } // Clear name buffers if ((tab_bar->Flags & ImGuiTabBarFlags_DockNode) == 0) tab_bar->TabsNames.Buf.resize(0); } // Dockables uses Name/ID in the global namespace. Non-dockable items use the ID stack. static ImU32 ImGui::TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label) { if (tab_bar->Flags & ImGuiTabBarFlags_DockNode) { ImGuiID id = ImHashStr(label); KeepAliveID(id); return id; } else { ImGuiWindow* window = GImGui->CurrentWindow; return window->GetID(label); } } static float ImGui::TabBarCalcMaxTabWidth() { ImGuiContext& g = *GImGui; return g.FontSize * 20.0f; } ImGuiTabItem* ImGui::TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id) { if (tab_id != 0) for (int n = 0; n < tab_bar->Tabs.Size; n++) if (tab_bar->Tabs[n].ID == tab_id) return &tab_bar->Tabs[n]; return NULL; } // The *TabId fields be already set by the docking system _before_ the actual TabItem was created, so we clear them regardless. void ImGui::TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id) { if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_id)) tab_bar->Tabs.erase(tab); if (tab_bar->VisibleTabId == tab_id) { tab_bar->VisibleTabId = 0; } if (tab_bar->SelectedTabId == tab_id) { tab_bar->SelectedTabId = 0; } if (tab_bar->NextSelectedTabId == tab_id) { tab_bar->NextSelectedTabId = 0; } } // Called on manual closure attempt void ImGui::TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab) { if ((tab_bar->VisibleTabId == tab->ID) && !(tab->Flags & ImGuiTabItemFlags_UnsavedDocument)) { // This will remove a frame of lag for selecting another tab on closure. // However we don't run it in the case where the 'Unsaved' flag is set, so user gets a chance to fully undo the closure tab->LastFrameVisible = -1; tab_bar->SelectedTabId = tab_bar->NextSelectedTabId = 0; } else if ((tab_bar->VisibleTabId != tab->ID) && (tab->Flags & ImGuiTabItemFlags_UnsavedDocument)) { // Actually select before expecting closure tab_bar->NextSelectedTabId = tab->ID; } } static float ImGui::TabBarScrollClamp(ImGuiTabBar* tab_bar, float scrolling) { scrolling = ImMin(scrolling, tab_bar->OffsetMax - tab_bar->BarRect.GetWidth()); return ImMax(scrolling, 0.0f); } static void ImGui::TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab) { ImGuiContext& g = *GImGui; float margin = g.FontSize * 1.0f; // When to scroll to make Tab N+1 visible always make a bit of N visible to suggest more scrolling area (since we don't have a scrollbar) int order = tab_bar->GetTabOrder(tab); float tab_x1 = tab->Offset + (order > 0 ? -margin : 0.0f); float tab_x2 = tab->Offset + tab->Width + (order + 1 < tab_bar->Tabs.Size ? margin : 1.0f); tab_bar->ScrollingTargetDistToVisibility = 0.0f; if (tab_bar->ScrollingTarget > tab_x1 || (tab_x2 - tab_x1 >= tab_bar->BarRect.GetWidth())) { tab_bar->ScrollingTargetDistToVisibility = ImMax(tab_bar->ScrollingAnim - tab_x2, 0.0f); tab_bar->ScrollingTarget = tab_x1; } else if (tab_bar->ScrollingTarget < tab_x2 - tab_bar->BarRect.GetWidth()) { tab_bar->ScrollingTargetDistToVisibility = ImMax((tab_x1 - tab_bar->BarRect.GetWidth()) - tab_bar->ScrollingAnim, 0.0f); tab_bar->ScrollingTarget = tab_x2 - tab_bar->BarRect.GetWidth(); } } void ImGui::TabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir) { IM_ASSERT(dir == -1 || dir == +1); IM_ASSERT(tab_bar->ReorderRequestTabId == 0); tab_bar->ReorderRequestTabId = tab->ID; tab_bar->ReorderRequestDir = (ImS8)dir; } static ImGuiTabItem* ImGui::TabBarScrollingButtons(ImGuiTabBar* tab_bar) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; const ImVec2 arrow_button_size(g.FontSize - 2.0f, g.FontSize + g.Style.FramePadding.y * 2.0f); const float scrolling_buttons_width = arrow_button_size.x * 2.0f; const ImVec2 backup_cursor_pos = window->DC.CursorPos; //window->DrawList->AddRect(ImVec2(tab_bar->BarRect.Max.x - scrolling_buttons_width, tab_bar->BarRect.Min.y), ImVec2(tab_bar->BarRect.Max.x, tab_bar->BarRect.Max.y), IM_COL32(255,0,0,255)); const ImRect avail_bar_rect = tab_bar->BarRect; bool want_clip_rect = !avail_bar_rect.Contains(ImRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(scrolling_buttons_width, 0.0f))); if (want_clip_rect) PushClipRect(tab_bar->BarRect.Min, tab_bar->BarRect.Max + ImVec2(g.Style.ItemInnerSpacing.x, 0.0f), true); ImGuiTabItem* tab_to_select = NULL; int select_dir = 0; ImVec4 arrow_col = g.Style.Colors[ImGuiCol_Text]; arrow_col.w *= 0.5f; PushStyleColor(ImGuiCol_Text, arrow_col); PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); const float backup_repeat_delay = g.IO.KeyRepeatDelay; const float backup_repeat_rate = g.IO.KeyRepeatRate; g.IO.KeyRepeatDelay = 0.250f; g.IO.KeyRepeatRate = 0.200f; window->DC.CursorPos = ImVec2(tab_bar->BarRect.Max.x - scrolling_buttons_width, tab_bar->BarRect.Min.y); if (ArrowButtonEx("##<", ImGuiDir_Left, arrow_button_size, ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_Repeat)) select_dir = -1; window->DC.CursorPos = ImVec2(tab_bar->BarRect.Max.x - scrolling_buttons_width + arrow_button_size.x, tab_bar->BarRect.Min.y); if (ArrowButtonEx("##>", ImGuiDir_Right, arrow_button_size, ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_Repeat)) select_dir = +1; PopStyleColor(2); g.IO.KeyRepeatRate = backup_repeat_rate; g.IO.KeyRepeatDelay = backup_repeat_delay; if (want_clip_rect) PopClipRect(); if (select_dir != 0) if (ImGuiTabItem* tab_item = TabBarFindTabByID(tab_bar, tab_bar->SelectedTabId)) { int selected_order = tab_bar->GetTabOrder(tab_item); int target_order = selected_order + select_dir; tab_to_select = &tab_bar->Tabs[(target_order >= 0 && target_order < tab_bar->Tabs.Size) ? target_order : selected_order]; // If we are at the end of the list, still scroll to make our tab visible } window->DC.CursorPos = backup_cursor_pos; tab_bar->BarRect.Max.x -= scrolling_buttons_width + 1.0f; return tab_to_select; } static ImGuiTabItem* ImGui::TabBarTabListPopupButton(ImGuiTabBar* tab_bar) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; // We use g.Style.FramePadding.y to match the square ArrowButton size const float tab_list_popup_button_width = g.FontSize + g.Style.FramePadding.y; const ImVec2 backup_cursor_pos = window->DC.CursorPos; window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x - g.Style.FramePadding.y, tab_bar->BarRect.Min.y); tab_bar->BarRect.Min.x += tab_list_popup_button_width; ImVec4 arrow_col = g.Style.Colors[ImGuiCol_Text]; arrow_col.w *= 0.5f; PushStyleColor(ImGuiCol_Text, arrow_col); PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); bool open = BeginCombo("##v", NULL, ImGuiComboFlags_NoPreview); PopStyleColor(2); ImGuiTabItem* tab_to_select = NULL; if (open) { for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) { ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; const char* tab_name = tab_bar->GetTabName(tab); if (Selectable(tab_name, tab_bar->SelectedTabId == tab->ID)) tab_to_select = tab; } EndCombo(); } window->DC.CursorPos = backup_cursor_pos; return tab_to_select; } //------------------------------------------------------------------------- // [SECTION] Widgets: BeginTabItem, EndTabItem, etc. //------------------------------------------------------------------------- // - BeginTabItem() // - EndTabItem() // - TabItemEx() [Internal] // - SetTabItemClosed() // - TabItemCalcSize() [Internal] // - TabItemBackground() [Internal] // - TabItemLabelAndCloseButton() [Internal] //------------------------------------------------------------------------- bool ImGui::BeginTabItem(const char* label, bool* p_open, ImGuiTabItemFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (window->SkipItems) return false; ImGuiTabBar* tab_bar = g.CurrentTabBar; if (tab_bar == NULL) { IM_ASSERT_USER_ERROR(tab_bar, "BeginTabItem() Needs to be called between BeginTabBar() and EndTabBar()!"); return false; } bool ret = TabItemEx(tab_bar, label, p_open, flags); if (ret && !(flags & ImGuiTabItemFlags_NoPushId)) { ImGuiTabItem* tab = &tab_bar->Tabs[tab_bar->LastTabItemIdx]; PushOverrideID(tab->ID); // We already hashed 'label' so push into the ID stack directly instead of doing another hash through PushID(label) } return ret; } void ImGui::EndTabItem() { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (window->SkipItems) return; ImGuiTabBar* tab_bar = g.CurrentTabBar; if (tab_bar == NULL) { IM_ASSERT(tab_bar != NULL && "Needs to be called between BeginTabBar() and EndTabBar()!"); return; } IM_ASSERT(tab_bar->LastTabItemIdx >= 0); ImGuiTabItem* tab = &tab_bar->Tabs[tab_bar->LastTabItemIdx]; if (!(tab->Flags & ImGuiTabItemFlags_NoPushId)) window->IDStack.pop_back(); } bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags) { // Layout whole tab bar if not already done if (tab_bar->WantLayout) TabBarLayout(tab_bar); ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; if (window->SkipItems) return false; const ImGuiStyle& style = g.Style; const ImGuiID id = TabBarCalcTabID(tab_bar, label); // If the user called us with *p_open == false, we early out and don't render. We make a dummy call to ItemAdd() so that attempts to use a contextual popup menu with an implicit ID won't use an older ID. if (p_open && !*p_open) { PushItemFlag(ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus, true); ItemAdd(ImRect(), id); PopItemFlag(); return false; } // Store into ImGuiTabItemFlags_NoCloseButton, also honor ImGuiTabItemFlags_NoCloseButton passed by user (although not documented) if (flags & ImGuiTabItemFlags_NoCloseButton) p_open = NULL; else if (p_open == NULL) flags |= ImGuiTabItemFlags_NoCloseButton; // Calculate tab contents size ImVec2 size = TabItemCalcSize(label, p_open != NULL); // Acquire tab data ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, id); bool tab_is_new = false; if (tab == NULL) { tab_bar->Tabs.push_back(ImGuiTabItem()); tab = &tab_bar->Tabs.back(); tab->ID = id; tab->Width = size.x; tab_is_new = true; } tab_bar->LastTabItemIdx = (short)tab_bar->Tabs.index_from_ptr(tab); tab->ContentWidth = size.x; const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount); const bool tab_bar_focused = (tab_bar->Flags & ImGuiTabBarFlags_IsFocused) != 0; const bool tab_appearing = (tab->LastFrameVisible + 1 < g.FrameCount); tab->LastFrameVisible = g.FrameCount; tab->Flags = flags; // Append name with zero-terminator tab->NameOffset = tab_bar->TabsNames.size(); tab_bar->TabsNames.append(label, label + strlen(label) + 1); // If we are not reorderable, always reset offset based on submission order. // (We already handled layout and sizing using the previous known order, but sizing is not affected by order!) if (!tab_appearing && !(tab_bar->Flags & ImGuiTabBarFlags_Reorderable)) { tab->Offset = tab_bar->OffsetNextTab; tab_bar->OffsetNextTab += tab->Width + g.Style.ItemInnerSpacing.x; } // Update selected tab if (tab_appearing && (tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs) && tab_bar->NextSelectedTabId == 0) if (!tab_bar_appearing || tab_bar->SelectedTabId == 0) tab_bar->NextSelectedTabId = id; // New tabs gets activated if ((flags & ImGuiTabItemFlags_SetSelected) && (tab_bar->SelectedTabId != id)) // SetSelected can only be passed on explicit tab bar tab_bar->NextSelectedTabId = id; // Lock visibility bool tab_contents_visible = (tab_bar->VisibleTabId == id); if (tab_contents_visible) tab_bar->VisibleTabWasSubmitted = true; // On the very first frame of a tab bar we let first tab contents be visible to minimize appearing glitches if (!tab_contents_visible && tab_bar->SelectedTabId == 0 && tab_bar_appearing) if (tab_bar->Tabs.Size == 1 && !(tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs)) tab_contents_visible = true; if (tab_appearing && !(tab_bar_appearing && !tab_is_new)) { PushItemFlag(ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus, true); ItemAdd(ImRect(), id); PopItemFlag(); return tab_contents_visible; } if (tab_bar->SelectedTabId == id) tab->LastFrameSelected = g.FrameCount; // Backup current layout position const ImVec2 backup_main_cursor_pos = window->DC.CursorPos; // Layout size.x = tab->Width; window->DC.CursorPos = tab_bar->BarRect.Min + ImVec2(IM_FLOOR(tab->Offset - tab_bar->ScrollingAnim), 0.0f); ImVec2 pos = window->DC.CursorPos; ImRect bb(pos, pos + size); // We don't have CPU clipping primitives to clip the CloseButton (until it becomes a texture), so need to add an extra draw call (temporary in the case of vertical animation) bool want_clip_rect = (bb.Min.x < tab_bar->BarRect.Min.x) || (bb.Max.x > tab_bar->BarRect.Max.x); if (want_clip_rect) PushClipRect(ImVec2(ImMax(bb.Min.x, tab_bar->BarRect.Min.x), bb.Min.y - 1), ImVec2(tab_bar->BarRect.Max.x, bb.Max.y), true); ImVec2 backup_cursor_max_pos = window->DC.CursorMaxPos; ItemSize(bb.GetSize(), style.FramePadding.y); window->DC.CursorMaxPos = backup_cursor_max_pos; if (!ItemAdd(bb, id)) { if (want_clip_rect) PopClipRect(); window->DC.CursorPos = backup_main_cursor_pos; return tab_contents_visible; } // Click to Select a tab ImGuiButtonFlags button_flags = (ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_AllowItemOverlap); if (g.DragDropActive) button_flags |= ImGuiButtonFlags_PressedOnDragDropHold; bool hovered, held; bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags); if (pressed) tab_bar->NextSelectedTabId = id; hovered |= (g.HoveredId == id); // Allow the close button to overlap unless we are dragging (in which case we don't want any overlapping tabs to be hovered) if (!held) SetItemAllowOverlap(); // Drag and drop: re-order tabs if (held && !tab_appearing && IsMouseDragging(0)) { if (!g.DragDropActive && (tab_bar->Flags & ImGuiTabBarFlags_Reorderable)) { // While moving a tab it will jump on the other side of the mouse, so we also test for MouseDelta.x if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < bb.Min.x) { if (tab_bar->Flags & ImGuiTabBarFlags_Reorderable) TabBarQueueChangeTabOrder(tab_bar, tab, -1); } else if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > bb.Max.x) { if (tab_bar->Flags & ImGuiTabBarFlags_Reorderable) TabBarQueueChangeTabOrder(tab_bar, tab, +1); } } } #if 0 if (hovered && g.HoveredIdNotActiveTimer > 0.50f && bb.GetWidth() < tab->ContentWidth) { // Enlarge tab display when hovering bb.Max.x = bb.Min.x + IM_FLOOR(ImLerp(bb.GetWidth(), tab->ContentWidth, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f))); display_draw_list = GetForegroundDrawList(window); TabItemBackground(display_draw_list, bb, flags, GetColorU32(ImGuiCol_TitleBgActive)); } #endif // Render tab shape ImDrawList* display_draw_list = window->DrawList; const ImU32 tab_col = GetColorU32((held || hovered) ? ImGuiCol_TabHovered : tab_contents_visible ? (tab_bar_focused ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive) : (tab_bar_focused ? ImGuiCol_Tab : ImGuiCol_TabUnfocused)); TabItemBackground(display_draw_list, bb, flags, tab_col); RenderNavHighlight(bb, id); // Select with right mouse button. This is so the common idiom for context menu automatically highlight the current widget. const bool hovered_unblocked = IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup); if (hovered_unblocked && (IsMouseClicked(1) || IsMouseReleased(1))) tab_bar->NextSelectedTabId = id; if (tab_bar->Flags & ImGuiTabBarFlags_NoCloseWithMiddleMouseButton) flags |= ImGuiTabItemFlags_NoCloseWithMiddleMouseButton; // Render tab label, process close button const ImGuiID close_button_id = p_open ? window->GetID((void*)((intptr_t)id + 1)) : 0; bool just_closed = TabItemLabelAndCloseButton(display_draw_list, bb, flags, tab_bar->FramePadding, label, id, close_button_id); if (just_closed && p_open != NULL) { *p_open = false; TabBarCloseTab(tab_bar, tab); } // Restore main window position so user can draw there if (want_clip_rect) PopClipRect(); window->DC.CursorPos = backup_main_cursor_pos; // Tooltip (FIXME: Won't work over the close button because ItemOverlap systems messes up with HoveredIdTimer) // We test IsItemHovered() to discard e.g. when another item is active or drag and drop over the tab bar (which g.HoveredId ignores) if (g.HoveredId == id && !held && g.HoveredIdNotActiveTimer > 0.50f && IsItemHovered()) if (!(tab_bar->Flags & ImGuiTabBarFlags_NoTooltip)) SetTooltip("%.*s", (int)(FindRenderedTextEnd(label) - label), label); return tab_contents_visible; } // [Public] This is call is 100% optional but it allows to remove some one-frame glitches when a tab has been unexpectedly removed. // To use it to need to call the function SetTabItemClosed() after BeginTabBar() and before any call to BeginTabItem() void ImGui::SetTabItemClosed(const char* label) { ImGuiContext& g = *GImGui; bool is_within_manual_tab_bar = g.CurrentTabBar && !(g.CurrentTabBar->Flags & ImGuiTabBarFlags_DockNode); if (is_within_manual_tab_bar) { ImGuiTabBar* tab_bar = g.CurrentTabBar; IM_ASSERT(tab_bar->WantLayout); // Needs to be called AFTER BeginTabBar() and BEFORE the first call to BeginTabItem() ImGuiID tab_id = TabBarCalcTabID(tab_bar, label); TabBarRemoveTab(tab_bar, tab_id); } } ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button) { ImGuiContext& g = *GImGui; ImVec2 label_size = CalcTextSize(label, NULL, true); ImVec2 size = ImVec2(label_size.x + g.Style.FramePadding.x, label_size.y + g.Style.FramePadding.y * 2.0f); if (has_close_button) size.x += g.Style.FramePadding.x + (g.Style.ItemInnerSpacing.x + g.FontSize); // We use Y intentionally to fit the close button circle. else size.x += g.Style.FramePadding.x + 1.0f; return ImVec2(ImMin(size.x, TabBarCalcMaxTabWidth()), size.y); } void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col) { // While rendering tabs, we trim 1 pixel off the top of our bounding box so they can fit within a regular frame height while looking "detached" from it. ImGuiContext& g = *GImGui; const float width = bb.GetWidth(); IM_UNUSED(flags); IM_ASSERT(width > 0.0f); const float rounding = ImMax(0.0f, ImMin(g.Style.TabRounding, width * 0.5f - 1.0f)); const float y1 = bb.Min.y + 1.0f; const float y2 = bb.Max.y - 1.0f; draw_list->PathLineTo(ImVec2(bb.Min.x, y2)); draw_list->PathArcToFast(ImVec2(bb.Min.x + rounding, y1 + rounding), rounding, 6, 9); draw_list->PathArcToFast(ImVec2(bb.Max.x - rounding, y1 + rounding), rounding, 9, 12); draw_list->PathLineTo(ImVec2(bb.Max.x, y2)); draw_list->PathFillConvex(col); if (g.Style.TabBorderSize > 0.0f) { draw_list->PathLineTo(ImVec2(bb.Min.x + 0.5f, y2)); draw_list->PathArcToFast(ImVec2(bb.Min.x + rounding + 0.5f, y1 + rounding + 0.5f), rounding, 6, 9); draw_list->PathArcToFast(ImVec2(bb.Max.x - rounding - 0.5f, y1 + rounding + 0.5f), rounding, 9, 12); draw_list->PathLineTo(ImVec2(bb.Max.x - 0.5f, y2)); draw_list->PathStroke(GetColorU32(ImGuiCol_Border), false, g.Style.TabBorderSize); } } // Render text label (with custom clipping) + Unsaved Document marker + Close Button logic // We tend to lock style.FramePadding for a given tab-bar, hence the 'frame_padding' parameter. bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id) { ImGuiContext& g = *GImGui; ImVec2 label_size = CalcTextSize(label, NULL, true); if (bb.GetWidth() <= 1.0f) return false; // Render text label (with clipping + alpha gradient) + unsaved marker const char* TAB_UNSAVED_MARKER = "*"; ImRect text_pixel_clip_bb(bb.Min.x + frame_padding.x, bb.Min.y + frame_padding.y, bb.Max.x - frame_padding.x, bb.Max.y); if (flags & ImGuiTabItemFlags_UnsavedDocument) { text_pixel_clip_bb.Max.x -= CalcTextSize(TAB_UNSAVED_MARKER, NULL, false).x; ImVec2 unsaved_marker_pos(ImMin(bb.Min.x + frame_padding.x + label_size.x + 2, text_pixel_clip_bb.Max.x), bb.Min.y + frame_padding.y + IM_FLOOR(-g.FontSize * 0.25f)); RenderTextClippedEx(draw_list, unsaved_marker_pos, bb.Max - frame_padding, TAB_UNSAVED_MARKER, NULL, NULL); } ImRect text_ellipsis_clip_bb = text_pixel_clip_bb; // Close Button // We are relying on a subtle and confusing distinction between 'hovered' and 'g.HoveredId' which happens because we are using ImGuiButtonFlags_AllowOverlapMode + SetItemAllowOverlap() // 'hovered' will be true when hovering the Tab but NOT when hovering the close button // 'g.HoveredId==id' will be true when hovering the Tab including when hovering the close button // 'g.ActiveId==close_button_id' will be true when we are holding on the close button, in which case both hovered booleans are false bool close_button_pressed = false; bool close_button_visible = false; if (close_button_id != 0) if (g.HoveredId == tab_id || g.HoveredId == close_button_id || g.ActiveId == close_button_id) close_button_visible = true; if (close_button_visible) { ImGuiItemHoveredDataBackup last_item_backup; const float close_button_sz = g.FontSize; PushStyleVar(ImGuiStyleVar_FramePadding, frame_padding); if (CloseButton(close_button_id, ImVec2(bb.Max.x - frame_padding.x * 2.0f - close_button_sz, bb.Min.y))) close_button_pressed = true; PopStyleVar(); last_item_backup.Restore(); // Close with middle mouse button if (!(flags & ImGuiTabItemFlags_NoCloseWithMiddleMouseButton) && IsMouseClicked(2)) close_button_pressed = true; text_pixel_clip_bb.Max.x -= close_button_sz; } float ellipsis_max_x = close_button_visible ? text_pixel_clip_bb.Max.x : bb.Max.x - 1.0f; RenderTextEllipsis(draw_list, text_ellipsis_clip_bb.Min, text_ellipsis_clip_bb.Max, text_pixel_clip_bb.Max.x, ellipsis_max_x, label, NULL, &label_size); return close_button_pressed; } //------------------------------------------------------------------------- // [SECTION] Widgets: Columns, BeginColumns, EndColumns, etc. // In the current version, Columns are very weak. Needs to be replaced with a more full-featured system. //------------------------------------------------------------------------- // - GetColumnIndex() // - GetColumnCount() // - GetColumnOffset() // - GetColumnWidth() // - SetColumnOffset() // - SetColumnWidth() // - PushColumnClipRect() [Internal] // - PushColumnsBackground() [Internal] // - PopColumnsBackground() [Internal] // - FindOrCreateColumns() [Internal] // - GetColumnsID() [Internal] // - BeginColumns() // - NextColumn() // - EndColumns() // - Columns() //------------------------------------------------------------------------- int ImGui::GetColumnIndex() { ImGuiWindow* window = GetCurrentWindowRead(); return window->DC.CurrentColumns ? window->DC.CurrentColumns->Current : 0; } int ImGui::GetColumnsCount() { ImGuiWindow* window = GetCurrentWindowRead(); return window->DC.CurrentColumns ? window->DC.CurrentColumns->Count : 1; } float ImGui::GetColumnOffsetFromNorm(const ImGuiColumns* columns, float offset_norm) { return offset_norm * (columns->OffMaxX - columns->OffMinX); } float ImGui::GetColumnNormFromOffset(const ImGuiColumns* columns, float offset) { return offset / (columns->OffMaxX - columns->OffMinX); } static const float COLUMNS_HIT_RECT_HALF_WIDTH = 4.0f; static float GetDraggedColumnOffset(ImGuiColumns* columns, int column_index) { // Active (dragged) column always follow mouse. The reason we need this is that dragging a column to the right edge of an auto-resizing // window creates a feedback loop because we store normalized positions. So while dragging we enforce absolute positioning. ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; IM_ASSERT(column_index > 0); // We are not supposed to drag column 0. IM_ASSERT(g.ActiveId == columns->ID + ImGuiID(column_index)); float x = g.IO.MousePos.x - g.ActiveIdClickOffset.x + COLUMNS_HIT_RECT_HALF_WIDTH - window->Pos.x; x = ImMax(x, ImGui::GetColumnOffset(column_index - 1) + g.Style.ColumnsMinSpacing); if ((columns->Flags & ImGuiColumnsFlags_NoPreserveWidths)) x = ImMin(x, ImGui::GetColumnOffset(column_index + 1) - g.Style.ColumnsMinSpacing); return x; } float ImGui::GetColumnOffset(int column_index) { ImGuiWindow* window = GetCurrentWindowRead(); ImGuiColumns* columns = window->DC.CurrentColumns; if (columns == NULL) return 0.0f; if (column_index < 0) column_index = columns->Current; IM_ASSERT(column_index < columns->Columns.Size); const float t = columns->Columns[column_index].OffsetNorm; const float x_offset = ImLerp(columns->OffMinX, columns->OffMaxX, t); return x_offset; } static float GetColumnWidthEx(ImGuiColumns* columns, int column_index, bool before_resize = false) { if (column_index < 0) column_index = columns->Current; float offset_norm; if (before_resize) offset_norm = columns->Columns[column_index + 1].OffsetNormBeforeResize - columns->Columns[column_index].OffsetNormBeforeResize; else offset_norm = columns->Columns[column_index + 1].OffsetNorm - columns->Columns[column_index].OffsetNorm; return ImGui::GetColumnOffsetFromNorm(columns, offset_norm); } float ImGui::GetColumnWidth(int column_index) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; ImGuiColumns* columns = window->DC.CurrentColumns; if (columns == NULL) return GetContentRegionAvail().x; if (column_index < 0) column_index = columns->Current; return GetColumnOffsetFromNorm(columns, columns->Columns[column_index + 1].OffsetNorm - columns->Columns[column_index].OffsetNorm); } void ImGui::SetColumnOffset(int column_index, float offset) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; ImGuiColumns* columns = window->DC.CurrentColumns; IM_ASSERT(columns != NULL); if (column_index < 0) column_index = columns->Current; IM_ASSERT(column_index < columns->Columns.Size); const bool preserve_width = !(columns->Flags & ImGuiColumnsFlags_NoPreserveWidths) && (column_index < columns->Count-1); const float width = preserve_width ? GetColumnWidthEx(columns, column_index, columns->IsBeingResized) : 0.0f; if (!(columns->Flags & ImGuiColumnsFlags_NoForceWithinWindow)) offset = ImMin(offset, columns->OffMaxX - g.Style.ColumnsMinSpacing * (columns->Count - column_index)); columns->Columns[column_index].OffsetNorm = GetColumnNormFromOffset(columns, offset - columns->OffMinX); if (preserve_width) SetColumnOffset(column_index + 1, offset + ImMax(g.Style.ColumnsMinSpacing, width)); } void ImGui::SetColumnWidth(int column_index, float width) { ImGuiWindow* window = GetCurrentWindowRead(); ImGuiColumns* columns = window->DC.CurrentColumns; IM_ASSERT(columns != NULL); if (column_index < 0) column_index = columns->Current; SetColumnOffset(column_index + 1, GetColumnOffset(column_index) + width); } void ImGui::PushColumnClipRect(int column_index) { ImGuiWindow* window = GetCurrentWindowRead(); ImGuiColumns* columns = window->DC.CurrentColumns; if (column_index < 0) column_index = columns->Current; ImGuiColumnData* column = &columns->Columns[column_index]; PushClipRect(column->ClipRect.Min, column->ClipRect.Max, false); } // Get into the columns background draw command (which is generally the same draw command as before we called BeginColumns) void ImGui::PushColumnsBackground() { ImGuiWindow* window = GetCurrentWindowRead(); ImGuiColumns* columns = window->DC.CurrentColumns; if (columns->Count == 1) return; columns->Splitter.SetCurrentChannel(window->DrawList, 0); int cmd_size = window->DrawList->CmdBuffer.Size; PushClipRect(columns->HostClipRect.Min, columns->HostClipRect.Max, false); IM_UNUSED(cmd_size); IM_ASSERT(cmd_size == window->DrawList->CmdBuffer.Size); // Being in channel 0 this should not have created an ImDrawCmd } void ImGui::PopColumnsBackground() { ImGuiWindow* window = GetCurrentWindowRead(); ImGuiColumns* columns = window->DC.CurrentColumns; if (columns->Count == 1) return; columns->Splitter.SetCurrentChannel(window->DrawList, columns->Current + 1); PopClipRect(); } ImGuiColumns* ImGui::FindOrCreateColumns(ImGuiWindow* window, ImGuiID id) { // We have few columns per window so for now we don't need bother much with turning this into a faster lookup. for (int n = 0; n < window->ColumnsStorage.Size; n++) if (window->ColumnsStorage[n].ID == id) return &window->ColumnsStorage[n]; window->ColumnsStorage.push_back(ImGuiColumns()); ImGuiColumns* columns = &window->ColumnsStorage.back(); columns->ID = id; return columns; } ImGuiID ImGui::GetColumnsID(const char* str_id, int columns_count) { ImGuiWindow* window = GetCurrentWindow(); // Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget. // In addition, when an identifier isn't explicitly provided we include the number of columns in the hash to make it uniquer. PushID(0x11223347 + (str_id ? 0 : columns_count)); ImGuiID id = window->GetID(str_id ? str_id : "columns"); PopID(); return id; } void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); IM_ASSERT(columns_count >= 1 && columns_count <= 64); // Maximum 64 columns IM_ASSERT(window->DC.CurrentColumns == NULL); // Nested columns are currently not supported // Acquire storage for the columns set ImGuiID id = GetColumnsID(str_id, columns_count); ImGuiColumns* columns = FindOrCreateColumns(window, id); IM_ASSERT(columns->ID == id); columns->Current = 0; columns->Count = columns_count; columns->Flags = flags; window->DC.CurrentColumns = columns; columns->HostCursorPosY = window->DC.CursorPos.y; columns->HostCursorMaxPosX = window->DC.CursorMaxPos.x; columns->HostClipRect = window->ClipRect; columns->HostWorkRect = window->WorkRect; // Set state for first column // We aim so that the right-most column will have the same clipping width as other after being clipped by parent ClipRect const float column_padding = g.Style.ItemSpacing.x; const float half_clip_extend_x = ImFloor(ImMax(window->WindowPadding.x * 0.5f, window->WindowBorderSize)); const float max_1 = window->WorkRect.Max.x + column_padding - ImMax(column_padding - window->WindowPadding.x, 0.0f); const float max_2 = window->WorkRect.Max.x + half_clip_extend_x; columns->OffMinX = window->DC.Indent.x - column_padding + ImMax(column_padding - window->WindowPadding.x, 0.0f); columns->OffMaxX = ImMax(ImMin(max_1, max_2) - window->Pos.x, columns->OffMinX + 1.0f); columns->LineMinY = columns->LineMaxY = window->DC.CursorPos.y; // Clear data if columns count changed if (columns->Columns.Size != 0 && columns->Columns.Size != columns_count + 1) columns->Columns.resize(0); // Initialize default widths columns->IsFirstFrame = (columns->Columns.Size == 0); if (columns->Columns.Size == 0) { columns->Columns.reserve(columns_count + 1); for (int n = 0; n < columns_count + 1; n++) { ImGuiColumnData column; column.OffsetNorm = n / (float)columns_count; columns->Columns.push_back(column); } } for (int n = 0; n < columns_count; n++) { // Compute clipping rectangle ImGuiColumnData* column = &columns->Columns[n]; float clip_x1 = IM_ROUND(window->Pos.x + GetColumnOffset(n)); float clip_x2 = IM_ROUND(window->Pos.x + GetColumnOffset(n + 1) - 1.0f); column->ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX); column->ClipRect.ClipWith(window->ClipRect); } if (columns->Count > 1) { columns->Splitter.Split(window->DrawList, 1 + columns->Count); columns->Splitter.SetCurrentChannel(window->DrawList, 1); PushColumnClipRect(0); } // We don't generally store Indent.x inside ColumnsOffset because it may be manipulated by the user. float offset_0 = GetColumnOffset(columns->Current); float offset_1 = GetColumnOffset(columns->Current + 1); float width = offset_1 - offset_0; PushItemWidth(width * 0.65f); window->DC.ColumnsOffset.x = ImMax(column_padding - window->WindowPadding.x, 0.0f); window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); window->WorkRect.Max.x = window->Pos.x + offset_1 - column_padding; } void ImGui::NextColumn() { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems || window->DC.CurrentColumns == NULL) return; ImGuiContext& g = *GImGui; ImGuiColumns* columns = window->DC.CurrentColumns; if (columns->Count == 1) { window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); IM_ASSERT(columns->Current == 0); return; } PopItemWidth(); PopClipRect(); const float column_padding = g.Style.ItemSpacing.x; columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y); if (++columns->Current < columns->Count) { // Columns 1+ ignore IndentX (by canceling it out) // FIXME-COLUMNS: Unnecessary, could be locked? window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + column_padding; columns->Splitter.SetCurrentChannel(window->DrawList, columns->Current + 1); } else { // New row/line // Column 0 honor IndentX window->DC.ColumnsOffset.x = ImMax(column_padding - window->WindowPadding.x, 0.0f); columns->Splitter.SetCurrentChannel(window->DrawList, 1); columns->Current = 0; columns->LineMinY = columns->LineMaxY; } window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); window->DC.CursorPos.y = columns->LineMinY; window->DC.CurrLineSize = ImVec2(0.0f, 0.0f); window->DC.CurrLineTextBaseOffset = 0.0f; PushColumnClipRect(columns->Current); // FIXME-COLUMNS: Could it be an overwrite? // FIXME-COLUMNS: Share code with BeginColumns() - move code on columns setup. float offset_0 = GetColumnOffset(columns->Current); float offset_1 = GetColumnOffset(columns->Current + 1); float width = offset_1 - offset_0; PushItemWidth(width * 0.65f); window->WorkRect.Max.x = window->Pos.x + offset_1 - column_padding; } void ImGui::EndColumns() { ImGuiContext& g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); ImGuiColumns* columns = window->DC.CurrentColumns; IM_ASSERT(columns != NULL); PopItemWidth(); if (columns->Count > 1) { PopClipRect(); columns->Splitter.Merge(window->DrawList); } const ImGuiColumnsFlags flags = columns->Flags; columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y); window->DC.CursorPos.y = columns->LineMaxY; if (!(flags & ImGuiColumnsFlags_GrowParentContentsSize)) window->DC.CursorMaxPos.x = columns->HostCursorMaxPosX; // Restore cursor max pos, as columns don't grow parent // Draw columns borders and handle resize // The IsBeingResized flag ensure we preserve pre-resize columns width so back-and-forth are not lossy bool is_being_resized = false; if (!(flags & ImGuiColumnsFlags_NoBorder) && !window->SkipItems) { // We clip Y boundaries CPU side because very long triangles are mishandled by some GPU drivers. const float y1 = ImMax(columns->HostCursorPosY, window->ClipRect.Min.y); const float y2 = ImMin(window->DC.CursorPos.y, window->ClipRect.Max.y); int dragging_column = -1; for (int n = 1; n < columns->Count; n++) { ImGuiColumnData* column = &columns->Columns[n]; float x = window->Pos.x + GetColumnOffset(n); const ImGuiID column_id = columns->ID + ImGuiID(n); const float column_hit_hw = COLUMNS_HIT_RECT_HALF_WIDTH; const ImRect column_hit_rect(ImVec2(x - column_hit_hw, y1), ImVec2(x + column_hit_hw, y2)); KeepAliveID(column_id); if (IsClippedEx(column_hit_rect, column_id, false)) continue; bool hovered = false, held = false; if (!(flags & ImGuiColumnsFlags_NoResize)) { ButtonBehavior(column_hit_rect, column_id, &hovered, &held); if (hovered || held) g.MouseCursor = ImGuiMouseCursor_ResizeEW; if (held && !(column->Flags & ImGuiColumnsFlags_NoResize)) dragging_column = n; } // Draw column const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : hovered ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator); const float xi = IM_FLOOR(x); window->DrawList->AddLine(ImVec2(xi, y1 + 1.0f), ImVec2(xi, y2), col); } // Apply dragging after drawing the column lines, so our rendered lines are in sync with how items were displayed during the frame. if (dragging_column != -1) { if (!columns->IsBeingResized) for (int n = 0; n < columns->Count + 1; n++) columns->Columns[n].OffsetNormBeforeResize = columns->Columns[n].OffsetNorm; columns->IsBeingResized = is_being_resized = true; float x = GetDraggedColumnOffset(columns, dragging_column); SetColumnOffset(dragging_column, x); } } columns->IsBeingResized = is_being_resized; window->WorkRect = columns->HostWorkRect; window->DC.CurrentColumns = NULL; window->DC.ColumnsOffset.x = 0.0f; window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); } // [2018-03: This is currently the only public API, while we are working on making BeginColumns/EndColumns user-facing] void ImGui::Columns(int columns_count, const char* id, bool border) { ImGuiWindow* window = GetCurrentWindow(); IM_ASSERT(columns_count >= 1); ImGuiColumnsFlags flags = (border ? 0 : ImGuiColumnsFlags_NoBorder); //flags |= ImGuiColumnsFlags_NoPreserveWidths; // NB: Legacy behavior ImGuiColumns* columns = window->DC.CurrentColumns; if (columns != NULL && columns->Count == columns_count && columns->Flags == flags) return; if (columns != NULL) EndColumns(); if (columns_count != 1) BeginColumns(id, columns_count, flags); } //------------------------------------------------------------------------- #endif // #ifndef IMGUI_DISABLE goxel-0.11.0/ext_src/imgui/imstb_rectpack.h000066400000000000000000000500741435762723100206530ustar00rootroot00000000000000// [DEAR IMGUI] // This is a slightly modified version of stb_rect_pack.h 1.00. // Those changes would need to be pushed into nothings/stb: // - Added STBRP__CDECL // Grep for [DEAR IMGUI] to find the changes. // stb_rect_pack.h - v1.00 - public domain - rectangle packing // Sean Barrett 2014 // // Useful for e.g. packing rectangular textures into an atlas. // Does not do rotation. // // Not necessarily the awesomest packing method, but better than // the totally naive one in stb_truetype (which is primarily what // this is meant to replace). // // Has only had a few tests run, may have issues. // // More docs to come. // // No memory allocations; uses qsort() and assert() from stdlib. // Can override those by defining STBRP_SORT and STBRP_ASSERT. // // This library currently uses the Skyline Bottom-Left algorithm. // // Please note: better rectangle packers are welcome! Please // implement them to the same API, but with a different init // function. // // Credits // // Library // Sean Barrett // Minor features // Martins Mozeiko // github:IntellectualKitty // // Bugfixes / warning fixes // Jeremy Jaussaud // Fabian Giesen // // Version history: // // 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles // 0.99 (2019-02-07) warning fixes // 0.11 (2017-03-03) return packing success/fail result // 0.10 (2016-10-25) remove cast-away-const to avoid warnings // 0.09 (2016-08-27) fix compiler warnings // 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0) // 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0) // 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort // 0.05: added STBRP_ASSERT to allow replacing assert // 0.04: fixed minor bug in STBRP_LARGE_RECTS support // 0.01: initial release // // LICENSE // // See end of file for license information. ////////////////////////////////////////////////////////////////////////////// // // INCLUDE SECTION // #ifndef STB_INCLUDE_STB_RECT_PACK_H #define STB_INCLUDE_STB_RECT_PACK_H #define STB_RECT_PACK_VERSION 1 #ifdef STBRP_STATIC #define STBRP_DEF static #else #define STBRP_DEF extern #endif #ifdef __cplusplus extern "C" { #endif typedef struct stbrp_context stbrp_context; typedef struct stbrp_node stbrp_node; typedef struct stbrp_rect stbrp_rect; #ifdef STBRP_LARGE_RECTS typedef int stbrp_coord; #else typedef unsigned short stbrp_coord; #endif STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); // Assign packed locations to rectangles. The rectangles are of type // 'stbrp_rect' defined below, stored in the array 'rects', and there // are 'num_rects' many of them. // // Rectangles which are successfully packed have the 'was_packed' flag // set to a non-zero value and 'x' and 'y' store the minimum location // on each axis (i.e. bottom-left in cartesian coordinates, top-left // if you imagine y increasing downwards). Rectangles which do not fit // have the 'was_packed' flag set to 0. // // You should not try to access the 'rects' array from another thread // while this function is running, as the function temporarily reorders // the array while it executes. // // To pack into another rectangle, you need to call stbrp_init_target // again. To continue packing into the same rectangle, you can call // this function again. Calling this multiple times with multiple rect // arrays will probably produce worse packing results than calling it // a single time with the full rectangle array, but the option is // available. // // The function returns 1 if all of the rectangles were successfully // packed and 0 otherwise. struct stbrp_rect { // reserved for your use: int id; // input: stbrp_coord w, h; // output: stbrp_coord x, y; int was_packed; // non-zero if valid packing }; // 16 bytes, nominally STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); // Initialize a rectangle packer to: // pack a rectangle that is 'width' by 'height' in dimensions // using temporary storage provided by the array 'nodes', which is 'num_nodes' long // // You must call this function every time you start packing into a new target. // // There is no "shutdown" function. The 'nodes' memory must stay valid for // the following stbrp_pack_rects() call (or calls), but can be freed after // the call (or calls) finish. // // Note: to guarantee best results, either: // 1. make sure 'num_nodes' >= 'width' // or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1' // // If you don't do either of the above things, widths will be quantized to multiples // of small integers to guarantee the algorithm doesn't run out of temporary storage. // // If you do #2, then the non-quantized algorithm will be used, but the algorithm // may run out of temporary storage and be unable to pack some rectangles. STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); // Optionally call this function after init but before doing any packing to // change the handling of the out-of-temp-memory scenario, described above. // If you call init again, this will be reset to the default (false). STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); // Optionally select which packing heuristic the library should use. Different // heuristics will produce better/worse results for different data sets. // If you call init again, this will be reset to the default. enum { STBRP_HEURISTIC_Skyline_default=0, STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, STBRP_HEURISTIC_Skyline_BF_sortHeight }; ////////////////////////////////////////////////////////////////////////////// // // the details of the following structures don't matter to you, but they must // be visible so you can handle the memory allocations for them struct stbrp_node { stbrp_coord x,y; stbrp_node *next; }; struct stbrp_context { int width; int height; int align; int init_mode; int heuristic; int num_nodes; stbrp_node *active_head; stbrp_node *free_head; stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' }; #ifdef __cplusplus } #endif #endif ////////////////////////////////////////////////////////////////////////////// // // IMPLEMENTATION SECTION // #ifdef STB_RECT_PACK_IMPLEMENTATION #ifndef STBRP_SORT #include #define STBRP_SORT qsort #endif #ifndef STBRP_ASSERT #include #define STBRP_ASSERT assert #endif // [DEAR IMGUI] Added STBRP__CDECL #ifdef _MSC_VER #define STBRP__NOTUSED(v) (void)(v) #define STBRP__CDECL __cdecl #else #define STBRP__NOTUSED(v) (void)sizeof(v) #define STBRP__CDECL #endif enum { STBRP__INIT_skyline = 1 }; STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) { switch (context->init_mode) { case STBRP__INIT_skyline: STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); context->heuristic = heuristic; break; default: STBRP_ASSERT(0); } } STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) { if (allow_out_of_mem) // if it's ok to run out of memory, then don't bother aligning them; // this gives better packing, but may fail due to OOM (even though // the rectangles easily fit). @TODO a smarter approach would be to only // quantize once we've hit OOM, then we could get rid of this parameter. context->align = 1; else { // if it's not ok to run out of memory, then quantize the widths // so that num_nodes is always enough nodes. // // I.e. num_nodes * align >= width // align >= width / num_nodes // align = ceil(width/num_nodes) context->align = (context->width + context->num_nodes-1) / context->num_nodes; } } STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) { int i; #ifndef STBRP_LARGE_RECTS STBRP_ASSERT(width <= 0xffff && height <= 0xffff); #endif for (i=0; i < num_nodes-1; ++i) nodes[i].next = &nodes[i+1]; nodes[i].next = NULL; context->init_mode = STBRP__INIT_skyline; context->heuristic = STBRP_HEURISTIC_Skyline_default; context->free_head = &nodes[0]; context->active_head = &context->extra[0]; context->width = width; context->height = height; context->num_nodes = num_nodes; stbrp_setup_allow_out_of_mem(context, 0); // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) context->extra[0].x = 0; context->extra[0].y = 0; context->extra[0].next = &context->extra[1]; context->extra[1].x = (stbrp_coord) width; #ifdef STBRP_LARGE_RECTS context->extra[1].y = (1<<30); #else context->extra[1].y = 65535; #endif context->extra[1].next = NULL; } // find minimum y position if it starts at x1 static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) { stbrp_node *node = first; int x1 = x0 + width; int min_y, visited_width, waste_area; STBRP__NOTUSED(c); STBRP_ASSERT(first->x <= x0); #if 0 // skip in case we're past the node while (node->next->x <= x0) ++node; #else STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency #endif STBRP_ASSERT(node->x <= x0); min_y = 0; waste_area = 0; visited_width = 0; while (node->x < x1) { if (node->y > min_y) { // raise min_y higher. // we've accounted for all waste up to min_y, // but we'll now add more waste for everything we've visted waste_area += visited_width * (node->y - min_y); min_y = node->y; // the first time through, visited_width might be reduced if (node->x < x0) visited_width += node->next->x - x0; else visited_width += node->next->x - node->x; } else { // add waste area int under_width = node->next->x - node->x; if (under_width + visited_width > width) under_width = width - visited_width; waste_area += under_width * (min_y - node->y); visited_width += under_width; } node = node->next; } *pwaste = waste_area; return min_y; } typedef struct { int x,y; stbrp_node **prev_link; } stbrp__findresult; static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) { int best_waste = (1<<30), best_x, best_y = (1 << 30); stbrp__findresult fr; stbrp_node **prev, *node, *tail, **best = NULL; // align to multiple of c->align width = (width + c->align - 1); width -= width % c->align; STBRP_ASSERT(width % c->align == 0); // if it can't possibly fit, bail immediately if (width > c->width || height > c->height) { fr.prev_link = NULL; fr.x = fr.y = 0; return fr; } node = c->active_head; prev = &c->active_head; while (node->x + width <= c->width) { int y,waste; y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL // bottom left if (y < best_y) { best_y = y; best = prev; } } else { // best-fit if (y + height <= c->height) { // can only use it if it first vertically if (y < best_y || (y == best_y && waste < best_waste)) { best_y = y; best_waste = waste; best = prev; } } } prev = &node->next; node = node->next; } best_x = (best == NULL) ? 0 : (*best)->x; // if doing best-fit (BF), we also have to try aligning right edge to each node position // // e.g, if fitting // // ____________________ // |____________________| // // into // // | | // | ____________| // |____________| // // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned // // This makes BF take about 2x the time if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { tail = c->active_head; node = c->active_head; prev = &c->active_head; // find first node that's admissible while (tail->x < width) tail = tail->next; while (tail) { int xpos = tail->x - width; int y,waste; STBRP_ASSERT(xpos >= 0); // find the left position that matches this while (node->next->x <= xpos) { prev = &node->next; node = node->next; } STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); if (y + height <= c->height) { if (y <= best_y) { if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { best_x = xpos; STBRP_ASSERT(y <= best_y); best_y = y; best_waste = waste; best = prev; } } } tail = tail->next; } } fr.prev_link = best; fr.x = best_x; fr.y = best_y; return fr; } static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) { // find best position according to heuristic stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); stbrp_node *node, *cur; // bail if: // 1. it failed // 2. the best node doesn't fit (we don't always check this) // 3. we're out of memory if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { res.prev_link = NULL; return res; } // on success, create new node node = context->free_head; node->x = (stbrp_coord) res.x; node->y = (stbrp_coord) (res.y + height); context->free_head = node->next; // insert the new node into the right starting point, and // let 'cur' point to the remaining nodes needing to be // stiched back in cur = *res.prev_link; if (cur->x < res.x) { // preserve the existing one, so start testing with the next one stbrp_node *next = cur->next; cur->next = node; cur = next; } else { *res.prev_link = node; } // from here, traverse cur and free the nodes, until we get to one // that shouldn't be freed while (cur->next && cur->next->x <= res.x + width) { stbrp_node *next = cur->next; // move the current node to the free list cur->next = context->free_head; context->free_head = cur; cur = next; } // stitch the list back in node->next = cur; if (cur->x < res.x + width) cur->x = (stbrp_coord) (res.x + width); #ifdef _DEBUG cur = context->active_head; while (cur->x < context->width) { STBRP_ASSERT(cur->x < cur->next->x); cur = cur->next; } STBRP_ASSERT(cur->next == NULL); { int count=0; cur = context->active_head; while (cur) { cur = cur->next; ++count; } cur = context->free_head; while (cur) { cur = cur->next; ++count; } STBRP_ASSERT(count == context->num_nodes+2); } #endif return res; } // [DEAR IMGUI] Added STBRP__CDECL static int STBRP__CDECL rect_height_compare(const void *a, const void *b) { const stbrp_rect *p = (const stbrp_rect *) a; const stbrp_rect *q = (const stbrp_rect *) b; if (p->h > q->h) return -1; if (p->h < q->h) return 1; return (p->w > q->w) ? -1 : (p->w < q->w); } // [DEAR IMGUI] Added STBRP__CDECL static int STBRP__CDECL rect_original_order(const void *a, const void *b) { const stbrp_rect *p = (const stbrp_rect *) a; const stbrp_rect *q = (const stbrp_rect *) b; return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); } #ifdef STBRP_LARGE_RECTS #define STBRP__MAXVAL 0xffffffff #else #define STBRP__MAXVAL 0xffff #endif STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) { int i, all_rects_packed = 1; // we use the 'was_packed' field internally to allow sorting/unsorting for (i=0; i < num_rects; ++i) { rects[i].was_packed = i; } // sort according to heuristic STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); for (i=0; i < num_rects; ++i) { if (rects[i].w == 0 || rects[i].h == 0) { rects[i].x = rects[i].y = 0; // empty rect needs no space } else { stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); if (fr.prev_link) { rects[i].x = (stbrp_coord) fr.x; rects[i].y = (stbrp_coord) fr.y; } else { rects[i].x = rects[i].y = STBRP__MAXVAL; } } } // unsort STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); // set was_packed flags and all_rects_packed status for (i=0; i < num_rects; ++i) { rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); if (!rects[i].was_packed) all_rects_packed = 0; } // return the all_rects_packed status return all_rects_packed; } #endif /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ goxel-0.11.0/ext_src/imgui/imstb_textedit.h000066400000000000000000001503031435762723100207050ustar00rootroot00000000000000// [DEAR IMGUI] // This is a slightly modified version of stb_textedit.h 1.13. // Those changes would need to be pushed into nothings/stb: // - Fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321) // Grep for [DEAR IMGUI] to find the changes. // stb_textedit.h - v1.13 - public domain - Sean Barrett // Development of this library was sponsored by RAD Game Tools // // This C header file implements the guts of a multi-line text-editing // widget; you implement display, word-wrapping, and low-level string // insertion/deletion, and stb_textedit will map user inputs into // insertions & deletions, plus updates to the cursor position, // selection state, and undo state. // // It is intended for use in games and other systems that need to build // their own custom widgets and which do not have heavy text-editing // requirements (this library is not recommended for use for editing large // texts, as its performance does not scale and it has limited undo). // // Non-trivial behaviors are modelled after Windows text controls. // // // LICENSE // // See end of file for license information. // // // DEPENDENCIES // // Uses the C runtime function 'memmove', which you can override // by defining STB_TEXTEDIT_memmove before the implementation. // Uses no other functions. Performs no runtime allocations. // // // VERSION HISTORY // // 1.13 (2019-02-07) fix bug in undo size management // 1.12 (2018-01-29) user can change STB_TEXTEDIT_KEYTYPE, fix redo to avoid crash // 1.11 (2017-03-03) fix HOME on last line, dragging off single-line textfield // 1.10 (2016-10-25) supress warnings about casting away const with -Wcast-qual // 1.9 (2016-08-27) customizable move-by-word // 1.8 (2016-04-02) better keyboard handling when mouse button is down // 1.7 (2015-09-13) change y range handling in case baseline is non-0 // 1.6 (2015-04-15) allow STB_TEXTEDIT_memmove // 1.5 (2014-09-10) add support for secondary keys for OS X // 1.4 (2014-08-17) fix signed/unsigned warnings // 1.3 (2014-06-19) fix mouse clicking to round to nearest char boundary // 1.2 (2014-05-27) fix some RAD types that had crept into the new code // 1.1 (2013-12-15) move-by-word (requires STB_TEXTEDIT_IS_SPACE ) // 1.0 (2012-07-26) improve documentation, initial public release // 0.3 (2012-02-24) bugfixes, single-line mode; insert mode // 0.2 (2011-11-28) fixes to undo/redo // 0.1 (2010-07-08) initial version // // ADDITIONAL CONTRIBUTORS // // Ulf Winklemann: move-by-word in 1.1 // Fabian Giesen: secondary key inputs in 1.5 // Martins Mozeiko: STB_TEXTEDIT_memmove in 1.6 // // Bugfixes: // Scott Graham // Daniel Keller // Omar Cornut // Dan Thompson // // USAGE // // This file behaves differently depending on what symbols you define // before including it. // // // Header-file mode: // // If you do not define STB_TEXTEDIT_IMPLEMENTATION before including this, // it will operate in "header file" mode. In this mode, it declares a // single public symbol, STB_TexteditState, which encapsulates the current // state of a text widget (except for the string, which you will store // separately). // // To compile in this mode, you must define STB_TEXTEDIT_CHARTYPE to a // primitive type that defines a single character (e.g. char, wchar_t, etc). // // To save space or increase undo-ability, you can optionally define the // following things that are used by the undo system: // // STB_TEXTEDIT_POSITIONTYPE small int type encoding a valid cursor position // STB_TEXTEDIT_UNDOSTATECOUNT the number of undo states to allow // STB_TEXTEDIT_UNDOCHARCOUNT the number of characters to store in the undo buffer // // If you don't define these, they are set to permissive types and // moderate sizes. The undo system does no memory allocations, so // it grows STB_TexteditState by the worst-case storage which is (in bytes): // // [4 + 3 * sizeof(STB_TEXTEDIT_POSITIONTYPE)] * STB_TEXTEDIT_UNDOSTATE_COUNT // + sizeof(STB_TEXTEDIT_CHARTYPE) * STB_TEXTEDIT_UNDOCHAR_COUNT // // // Implementation mode: // // If you define STB_TEXTEDIT_IMPLEMENTATION before including this, it // will compile the implementation of the text edit widget, depending // on a large number of symbols which must be defined before the include. // // The implementation is defined only as static functions. You will then // need to provide your own APIs in the same file which will access the // static functions. // // The basic concept is that you provide a "string" object which // behaves like an array of characters. stb_textedit uses indices to // refer to positions in the string, implicitly representing positions // in the displayed textedit. This is true for both plain text and // rich text; even with rich text stb_truetype interacts with your // code as if there was an array of all the displayed characters. // // Symbols that must be the same in header-file and implementation mode: // // STB_TEXTEDIT_CHARTYPE the character type // STB_TEXTEDIT_POSITIONTYPE small type that is a valid cursor position // STB_TEXTEDIT_UNDOSTATECOUNT the number of undo states to allow // STB_TEXTEDIT_UNDOCHARCOUNT the number of characters to store in the undo buffer // // Symbols you must define for implementation mode: // // STB_TEXTEDIT_STRING the type of object representing a string being edited, // typically this is a wrapper object with other data you need // // STB_TEXTEDIT_STRINGLEN(obj) the length of the string (ideally O(1)) // STB_TEXTEDIT_LAYOUTROW(&r,obj,n) returns the results of laying out a line of characters // starting from character #n (see discussion below) // STB_TEXTEDIT_GETWIDTH(obj,n,i) returns the pixel delta from the xpos of the i'th character // to the xpos of the i+1'th char for a line of characters // starting at character #n (i.e. accounts for kerning // with previous char) // STB_TEXTEDIT_KEYTOTEXT(k) maps a keyboard input to an insertable character // (return type is int, -1 means not valid to insert) // STB_TEXTEDIT_GETCHAR(obj,i) returns the i'th character of obj, 0-based // STB_TEXTEDIT_NEWLINE the character returned by _GETCHAR() we recognize // as manually wordwrapping for end-of-line positioning // // STB_TEXTEDIT_DELETECHARS(obj,i,n) delete n characters starting at i // STB_TEXTEDIT_INSERTCHARS(obj,i,c*,n) insert n characters at i (pointed to by STB_TEXTEDIT_CHARTYPE*) // // STB_TEXTEDIT_K_SHIFT a power of two that is or'd in to a keyboard input to represent the shift key // // STB_TEXTEDIT_K_LEFT keyboard input to move cursor left // STB_TEXTEDIT_K_RIGHT keyboard input to move cursor right // STB_TEXTEDIT_K_UP keyboard input to move cursor up // STB_TEXTEDIT_K_DOWN keyboard input to move cursor down // STB_TEXTEDIT_K_LINESTART keyboard input to move cursor to start of line // e.g. HOME // STB_TEXTEDIT_K_LINEEND keyboard input to move cursor to end of line // e.g. END // STB_TEXTEDIT_K_TEXTSTART keyboard input to move cursor to start of text // e.g. ctrl-HOME // STB_TEXTEDIT_K_TEXTEND keyboard input to move cursor to end of text // e.g. ctrl-END // STB_TEXTEDIT_K_DELETE keyboard input to delete selection or character under cursor // STB_TEXTEDIT_K_BACKSPACE keyboard input to delete selection or character left of cursor // STB_TEXTEDIT_K_UNDO keyboard input to perform undo // STB_TEXTEDIT_K_REDO keyboard input to perform redo // // Optional: // STB_TEXTEDIT_K_INSERT keyboard input to toggle insert mode // STB_TEXTEDIT_IS_SPACE(ch) true if character is whitespace (e.g. 'isspace'), // required for default WORDLEFT/WORDRIGHT handlers // STB_TEXTEDIT_MOVEWORDLEFT(obj,i) custom handler for WORDLEFT, returns index to move cursor to // STB_TEXTEDIT_MOVEWORDRIGHT(obj,i) custom handler for WORDRIGHT, returns index to move cursor to // STB_TEXTEDIT_K_WORDLEFT keyboard input to move cursor left one word // e.g. ctrl-LEFT // STB_TEXTEDIT_K_WORDRIGHT keyboard input to move cursor right one word // e.g. ctrl-RIGHT // STB_TEXTEDIT_K_LINESTART2 secondary keyboard input to move cursor to start of line // STB_TEXTEDIT_K_LINEEND2 secondary keyboard input to move cursor to end of line // STB_TEXTEDIT_K_TEXTSTART2 secondary keyboard input to move cursor to start of text // STB_TEXTEDIT_K_TEXTEND2 secondary keyboard input to move cursor to end of text // // Todo: // STB_TEXTEDIT_K_PGUP keyboard input to move cursor up a page // STB_TEXTEDIT_K_PGDOWN keyboard input to move cursor down a page // // Keyboard input must be encoded as a single integer value; e.g. a character code // and some bitflags that represent shift states. to simplify the interface, SHIFT must // be a bitflag, so we can test the shifted state of cursor movements to allow selection, // i.e. (STB_TEXTED_K_RIGHT|STB_TEXTEDIT_K_SHIFT) should be shifted right-arrow. // // You can encode other things, such as CONTROL or ALT, in additional bits, and // then test for their presence in e.g. STB_TEXTEDIT_K_WORDLEFT. For example, // my Windows implementations add an additional CONTROL bit, and an additional KEYDOWN // bit. Then all of the STB_TEXTEDIT_K_ values bitwise-or in the KEYDOWN bit, // and I pass both WM_KEYDOWN and WM_CHAR events to the "key" function in the // API below. The control keys will only match WM_KEYDOWN events because of the // keydown bit I add, and STB_TEXTEDIT_KEYTOTEXT only tests for the KEYDOWN // bit so it only decodes WM_CHAR events. // // STB_TEXTEDIT_LAYOUTROW returns information about the shape of one displayed // row of characters assuming they start on the i'th character--the width and // the height and the number of characters consumed. This allows this library // to traverse the entire layout incrementally. You need to compute word-wrapping // here. // // Each textfield keeps its own insert mode state, which is not how normal // applications work. To keep an app-wide insert mode, update/copy the // "insert_mode" field of STB_TexteditState before/after calling API functions. // // API // // void stb_textedit_initialize_state(STB_TexteditState *state, int is_single_line) // // void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) // void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) // int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) // int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE *text, int len) // void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXEDIT_KEYTYPE key) // // Each of these functions potentially updates the string and updates the // state. // // initialize_state: // set the textedit state to a known good default state when initially // constructing the textedit. // // click: // call this with the mouse x,y on a mouse down; it will update the cursor // and reset the selection start/end to the cursor point. the x,y must // be relative to the text widget, with (0,0) being the top left. // // drag: // call this with the mouse x,y on a mouse drag/up; it will update the // cursor and the selection end point // // cut: // call this to delete the current selection; returns true if there was // one. you should FIRST copy the current selection to the system paste buffer. // (To copy, just copy the current selection out of the string yourself.) // // paste: // call this to paste text at the current cursor point or over the current // selection if there is one. // // key: // call this for keyboard inputs sent to the textfield. you can use it // for "key down" events or for "translated" key events. if you need to // do both (as in Win32), or distinguish Unicode characters from control // inputs, set a high bit to distinguish the two; then you can define the // various definitions like STB_TEXTEDIT_K_LEFT have the is-key-event bit // set, and make STB_TEXTEDIT_KEYTOCHAR check that the is-key-event bit is // clear. STB_TEXTEDIT_KEYTYPE defaults to int, but you can #define it to // anything other type you wante before including. // // // When rendering, you can read the cursor position and selection state from // the STB_TexteditState. // // // Notes: // // This is designed to be usable in IMGUI, so it allows for the possibility of // running in an IMGUI that has NOT cached the multi-line layout. For this // reason, it provides an interface that is compatible with computing the // layout incrementally--we try to make sure we make as few passes through // as possible. (For example, to locate the mouse pointer in the text, we // could define functions that return the X and Y positions of characters // and binary search Y and then X, but if we're doing dynamic layout this // will run the layout algorithm many times, so instead we manually search // forward in one pass. Similar logic applies to e.g. up-arrow and // down-arrow movement.) // // If it's run in a widget that *has* cached the layout, then this is less // efficient, but it's not horrible on modern computers. But you wouldn't // want to edit million-line files with it. //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //// //// Header-file mode //// //// #ifndef INCLUDE_STB_TEXTEDIT_H #define INCLUDE_STB_TEXTEDIT_H //////////////////////////////////////////////////////////////////////// // // STB_TexteditState // // Definition of STB_TexteditState which you should store // per-textfield; it includes cursor position, selection state, // and undo state. // #ifndef STB_TEXTEDIT_UNDOSTATECOUNT #define STB_TEXTEDIT_UNDOSTATECOUNT 99 #endif #ifndef STB_TEXTEDIT_UNDOCHARCOUNT #define STB_TEXTEDIT_UNDOCHARCOUNT 999 #endif #ifndef STB_TEXTEDIT_CHARTYPE #define STB_TEXTEDIT_CHARTYPE int #endif #ifndef STB_TEXTEDIT_POSITIONTYPE #define STB_TEXTEDIT_POSITIONTYPE int #endif typedef struct { // private data STB_TEXTEDIT_POSITIONTYPE where; STB_TEXTEDIT_POSITIONTYPE insert_length; STB_TEXTEDIT_POSITIONTYPE delete_length; int char_storage; } StbUndoRecord; typedef struct { // private data StbUndoRecord undo_rec [STB_TEXTEDIT_UNDOSTATECOUNT]; STB_TEXTEDIT_CHARTYPE undo_char[STB_TEXTEDIT_UNDOCHARCOUNT]; short undo_point, redo_point; int undo_char_point, redo_char_point; } StbUndoState; typedef struct { ///////////////////// // // public data // int cursor; // position of the text cursor within the string int select_start; // selection start point int select_end; // selection start and end point in characters; if equal, no selection. // note that start may be less than or greater than end (e.g. when // dragging the mouse, start is where the initial click was, and you // can drag in either direction) unsigned char insert_mode; // each textfield keeps its own insert mode state. to keep an app-wide // insert mode, copy this value in/out of the app state ///////////////////// // // private data // unsigned char cursor_at_end_of_line; // not implemented yet unsigned char initialized; unsigned char has_preferred_x; unsigned char single_line; unsigned char padding1, padding2, padding3; float preferred_x; // this determines where the cursor up/down tries to seek to along x StbUndoState undostate; } STB_TexteditState; //////////////////////////////////////////////////////////////////////// // // StbTexteditRow // // Result of layout query, used by stb_textedit to determine where // the text in each row is. // result of layout query typedef struct { float x0,x1; // starting x location, end x location (allows for align=right, etc) float baseline_y_delta; // position of baseline relative to previous row's baseline float ymin,ymax; // height of row above and below baseline int num_chars; } StbTexteditRow; #endif //INCLUDE_STB_TEXTEDIT_H //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //// //// Implementation mode //// //// // implementation isn't include-guarded, since it might have indirectly // included just the "header" portion #ifdef STB_TEXTEDIT_IMPLEMENTATION #ifndef STB_TEXTEDIT_memmove #include #define STB_TEXTEDIT_memmove memmove #endif ///////////////////////////////////////////////////////////////////////////// // // Mouse input handling // // traverse the layout to locate the nearest character to a display position static int stb_text_locate_coord(STB_TEXTEDIT_STRING *str, float x, float y) { StbTexteditRow r; int n = STB_TEXTEDIT_STRINGLEN(str); float base_y = 0, prev_x; int i=0, k; r.x0 = r.x1 = 0; r.ymin = r.ymax = 0; r.num_chars = 0; // search rows to find one that straddles 'y' while (i < n) { STB_TEXTEDIT_LAYOUTROW(&r, str, i); if (r.num_chars <= 0) return n; if (i==0 && y < base_y + r.ymin) return 0; if (y < base_y + r.ymax) break; i += r.num_chars; base_y += r.baseline_y_delta; } // below all text, return 'after' last character if (i >= n) return n; // check if it's before the beginning of the line if (x < r.x0) return i; // check if it's before the end of the line if (x < r.x1) { // search characters in row for one that straddles 'x' prev_x = r.x0; for (k=0; k < r.num_chars; ++k) { float w = STB_TEXTEDIT_GETWIDTH(str, i, k); if (x < prev_x+w) { if (x < prev_x+w/2) return k+i; else return k+i+1; } prev_x += w; } // shouldn't happen, but if it does, fall through to end-of-line case } // if the last character is a newline, return that. otherwise return 'after' the last character if (STB_TEXTEDIT_GETCHAR(str, i+r.num_chars-1) == STB_TEXTEDIT_NEWLINE) return i+r.num_chars-1; else return i+r.num_chars; } // API click: on mouse down, move the cursor to the clicked location, and reset the selection static void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) { // In single-line mode, just always make y = 0. This lets the drag keep working if the mouse // goes off the top or bottom of the text if( state->single_line ) { StbTexteditRow r; STB_TEXTEDIT_LAYOUTROW(&r, str, 0); y = r.ymin; } state->cursor = stb_text_locate_coord(str, x, y); state->select_start = state->cursor; state->select_end = state->cursor; state->has_preferred_x = 0; } // API drag: on mouse drag, move the cursor and selection endpoint to the clicked location static void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) { int p = 0; // In single-line mode, just always make y = 0. This lets the drag keep working if the mouse // goes off the top or bottom of the text if( state->single_line ) { StbTexteditRow r; STB_TEXTEDIT_LAYOUTROW(&r, str, 0); y = r.ymin; } if (state->select_start == state->select_end) state->select_start = state->cursor; p = stb_text_locate_coord(str, x, y); state->cursor = state->select_end = p; } ///////////////////////////////////////////////////////////////////////////// // // Keyboard input handling // // forward declarations static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state); static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state); static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length); static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length); static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length); typedef struct { float x,y; // position of n'th character float height; // height of line int first_char, length; // first char of row, and length int prev_first; // first char of previous row } StbFindState; // find the x/y location of a character, and remember info about the previous row in // case we get a move-up event (for page up, we'll have to rescan) static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *str, int n, int single_line) { StbTexteditRow r; int prev_start = 0; int z = STB_TEXTEDIT_STRINGLEN(str); int i=0, first; if (n == z) { // if it's at the end, then find the last line -- simpler than trying to // explicitly handle this case in the regular code if (single_line) { STB_TEXTEDIT_LAYOUTROW(&r, str, 0); find->y = 0; find->first_char = 0; find->length = z; find->height = r.ymax - r.ymin; find->x = r.x1; } else { find->y = 0; find->x = 0; find->height = 1; while (i < z) { STB_TEXTEDIT_LAYOUTROW(&r, str, i); prev_start = i; i += r.num_chars; } find->first_char = i; find->length = 0; find->prev_first = prev_start; } return; } // search rows to find the one that straddles character n find->y = 0; for(;;) { STB_TEXTEDIT_LAYOUTROW(&r, str, i); if (n < i + r.num_chars) break; prev_start = i; i += r.num_chars; find->y += r.baseline_y_delta; } find->first_char = first = i; find->length = r.num_chars; find->height = r.ymax - r.ymin; find->prev_first = prev_start; // now scan to find xpos find->x = r.x0; for (i=0; first+i < n; ++i) find->x += STB_TEXTEDIT_GETWIDTH(str, first, i); } #define STB_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end) // make the selection/cursor state valid if client altered the string static void stb_textedit_clamp(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { int n = STB_TEXTEDIT_STRINGLEN(str); if (STB_TEXT_HAS_SELECTION(state)) { if (state->select_start > n) state->select_start = n; if (state->select_end > n) state->select_end = n; // if clamping forced them to be equal, move the cursor to match if (state->select_start == state->select_end) state->cursor = state->select_start; } if (state->cursor > n) state->cursor = n; } // delete characters while updating undo static void stb_textedit_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int len) { stb_text_makeundo_delete(str, state, where, len); STB_TEXTEDIT_DELETECHARS(str, where, len); state->has_preferred_x = 0; } // delete the section static void stb_textedit_delete_selection(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { stb_textedit_clamp(str, state); if (STB_TEXT_HAS_SELECTION(state)) { if (state->select_start < state->select_end) { stb_textedit_delete(str, state, state->select_start, state->select_end - state->select_start); state->select_end = state->cursor = state->select_start; } else { stb_textedit_delete(str, state, state->select_end, state->select_start - state->select_end); state->select_start = state->cursor = state->select_end; } state->has_preferred_x = 0; } } // canoncialize the selection so start <= end static void stb_textedit_sortselection(STB_TexteditState *state) { if (state->select_end < state->select_start) { int temp = state->select_end; state->select_end = state->select_start; state->select_start = temp; } } // move cursor to first character of selection static void stb_textedit_move_to_first(STB_TexteditState *state) { if (STB_TEXT_HAS_SELECTION(state)) { stb_textedit_sortselection(state); state->cursor = state->select_start; state->select_end = state->select_start; state->has_preferred_x = 0; } } // move cursor to last character of selection static void stb_textedit_move_to_last(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { if (STB_TEXT_HAS_SELECTION(state)) { stb_textedit_sortselection(state); stb_textedit_clamp(str, state); state->cursor = state->select_end; state->select_start = state->select_end; state->has_preferred_x = 0; } } #ifdef STB_TEXTEDIT_IS_SPACE static int is_word_boundary( STB_TEXTEDIT_STRING *str, int idx ) { return idx > 0 ? (STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str,idx-1) ) && !STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str, idx) ) ) : 1; } #ifndef STB_TEXTEDIT_MOVEWORDLEFT static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *str, int c ) { --c; // always move at least one character while( c >= 0 && !is_word_boundary( str, c ) ) --c; if( c < 0 ) c = 0; return c; } #define STB_TEXTEDIT_MOVEWORDLEFT stb_textedit_move_to_word_previous #endif #ifndef STB_TEXTEDIT_MOVEWORDRIGHT static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *str, int c ) { const int len = STB_TEXTEDIT_STRINGLEN(str); ++c; // always move at least one character while( c < len && !is_word_boundary( str, c ) ) ++c; if( c > len ) c = len; return c; } #define STB_TEXTEDIT_MOVEWORDRIGHT stb_textedit_move_to_word_next #endif #endif // update selection and cursor to match each other static void stb_textedit_prep_selection_at_cursor(STB_TexteditState *state) { if (!STB_TEXT_HAS_SELECTION(state)) state->select_start = state->select_end = state->cursor; else state->cursor = state->select_end; } // API cut: delete selection static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { if (STB_TEXT_HAS_SELECTION(state)) { stb_textedit_delete_selection(str,state); // implicitly clamps state->has_preferred_x = 0; return 1; } return 0; } // API paste: replace existing selection with passed-in text static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE *text, int len) { // if there's a selection, the paste should delete it stb_textedit_clamp(str, state); stb_textedit_delete_selection(str,state); // try to insert the characters if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, len)) { stb_text_makeundo_insert(state, state->cursor, len); state->cursor += len; state->has_preferred_x = 0; return 1; } // remove the undo since we didn't actually insert the characters if (state->undostate.undo_point) --state->undostate.undo_point; return 0; } #ifndef STB_TEXTEDIT_KEYTYPE #define STB_TEXTEDIT_KEYTYPE int #endif // API key: process a keyboard input static void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_KEYTYPE key) { retry: switch (key) { default: { int c = STB_TEXTEDIT_KEYTOTEXT(key); if (c > 0) { STB_TEXTEDIT_CHARTYPE ch = (STB_TEXTEDIT_CHARTYPE) c; // can't add newline in single-line mode if (c == '\n' && state->single_line) break; if (state->insert_mode && !STB_TEXT_HAS_SELECTION(state) && state->cursor < STB_TEXTEDIT_STRINGLEN(str)) { stb_text_makeundo_replace(str, state, state->cursor, 1, 1); STB_TEXTEDIT_DELETECHARS(str, state->cursor, 1); if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { ++state->cursor; state->has_preferred_x = 0; } } else { stb_textedit_delete_selection(str,state); // implicitly clamps if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { stb_text_makeundo_insert(state, state->cursor, 1); ++state->cursor; state->has_preferred_x = 0; } } } break; } #ifdef STB_TEXTEDIT_K_INSERT case STB_TEXTEDIT_K_INSERT: state->insert_mode = !state->insert_mode; break; #endif case STB_TEXTEDIT_K_UNDO: stb_text_undo(str, state); state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_REDO: stb_text_redo(str, state); state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_LEFT: // if currently there's a selection, move cursor to start of selection if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_first(state); else if (state->cursor > 0) --state->cursor; state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_RIGHT: // if currently there's a selection, move cursor to end of selection if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_last(str, state); else ++state->cursor; stb_textedit_clamp(str, state); state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_SHIFT: stb_textedit_clamp(str, state); stb_textedit_prep_selection_at_cursor(state); // move selection left if (state->select_end > 0) --state->select_end; state->cursor = state->select_end; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_MOVEWORDLEFT case STB_TEXTEDIT_K_WORDLEFT: if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_first(state); else { state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); stb_textedit_clamp( str, state ); } break; case STB_TEXTEDIT_K_WORDLEFT | STB_TEXTEDIT_K_SHIFT: if( !STB_TEXT_HAS_SELECTION( state ) ) stb_textedit_prep_selection_at_cursor(state); state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); state->select_end = state->cursor; stb_textedit_clamp( str, state ); break; #endif #ifdef STB_TEXTEDIT_MOVEWORDRIGHT case STB_TEXTEDIT_K_WORDRIGHT: if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_last(str, state); else { state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); stb_textedit_clamp( str, state ); } break; case STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT: if( !STB_TEXT_HAS_SELECTION( state ) ) stb_textedit_prep_selection_at_cursor(state); state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); state->select_end = state->cursor; stb_textedit_clamp( str, state ); break; #endif case STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_SHIFT: stb_textedit_prep_selection_at_cursor(state); // move selection right ++state->select_end; stb_textedit_clamp(str, state); state->cursor = state->select_end; state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_DOWN: case STB_TEXTEDIT_K_DOWN | STB_TEXTEDIT_K_SHIFT: { StbFindState find; StbTexteditRow row; int i, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; if (state->single_line) { // on windows, up&down in single-line behave like left&right key = STB_TEXTEDIT_K_RIGHT | (key & STB_TEXTEDIT_K_SHIFT); goto retry; } if (sel) stb_textedit_prep_selection_at_cursor(state); else if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_last(str,state); // compute current position of cursor point stb_textedit_clamp(str, state); stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); // now find character position down a row if (find.length) { float goal_x = state->has_preferred_x ? state->preferred_x : find.x; float x; int start = find.first_char + find.length; state->cursor = start; STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); x = row.x0; for (i=0; i < row.num_chars; ++i) { float dx = STB_TEXTEDIT_GETWIDTH(str, start, i); #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) break; #endif x += dx; if (x > goal_x) break; ++state->cursor; } stb_textedit_clamp(str, state); state->has_preferred_x = 1; state->preferred_x = goal_x; if (sel) state->select_end = state->cursor; } break; } case STB_TEXTEDIT_K_UP: case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT: { StbFindState find; StbTexteditRow row; int i, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; if (state->single_line) { // on windows, up&down become left&right key = STB_TEXTEDIT_K_LEFT | (key & STB_TEXTEDIT_K_SHIFT); goto retry; } if (sel) stb_textedit_prep_selection_at_cursor(state); else if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_first(state); // compute current position of cursor point stb_textedit_clamp(str, state); stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); // can only go up if there's a previous row if (find.prev_first != find.first_char) { // now find character position up a row float goal_x = state->has_preferred_x ? state->preferred_x : find.x; float x; state->cursor = find.prev_first; STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); x = row.x0; for (i=0; i < row.num_chars; ++i) { float dx = STB_TEXTEDIT_GETWIDTH(str, find.prev_first, i); #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) break; #endif x += dx; if (x > goal_x) break; ++state->cursor; } stb_textedit_clamp(str, state); state->has_preferred_x = 1; state->preferred_x = goal_x; if (sel) state->select_end = state->cursor; } break; } case STB_TEXTEDIT_K_DELETE: case STB_TEXTEDIT_K_DELETE | STB_TEXTEDIT_K_SHIFT: if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_delete_selection(str, state); else { int n = STB_TEXTEDIT_STRINGLEN(str); if (state->cursor < n) stb_textedit_delete(str, state, state->cursor, 1); } state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_BACKSPACE: case STB_TEXTEDIT_K_BACKSPACE | STB_TEXTEDIT_K_SHIFT: if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_delete_selection(str, state); else { stb_textedit_clamp(str, state); if (state->cursor > 0) { stb_textedit_delete(str, state, state->cursor-1, 1); --state->cursor; } } state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_TEXTSTART2 case STB_TEXTEDIT_K_TEXTSTART2: #endif case STB_TEXTEDIT_K_TEXTSTART: state->cursor = state->select_start = state->select_end = 0; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_TEXTEND2 case STB_TEXTEDIT_K_TEXTEND2: #endif case STB_TEXTEDIT_K_TEXTEND: state->cursor = STB_TEXTEDIT_STRINGLEN(str); state->select_start = state->select_end = 0; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_TEXTSTART2 case STB_TEXTEDIT_K_TEXTSTART2 | STB_TEXTEDIT_K_SHIFT: #endif case STB_TEXTEDIT_K_TEXTSTART | STB_TEXTEDIT_K_SHIFT: stb_textedit_prep_selection_at_cursor(state); state->cursor = state->select_end = 0; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_TEXTEND2 case STB_TEXTEDIT_K_TEXTEND2 | STB_TEXTEDIT_K_SHIFT: #endif case STB_TEXTEDIT_K_TEXTEND | STB_TEXTEDIT_K_SHIFT: stb_textedit_prep_selection_at_cursor(state); state->cursor = state->select_end = STB_TEXTEDIT_STRINGLEN(str); state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_LINESTART2 case STB_TEXTEDIT_K_LINESTART2: #endif case STB_TEXTEDIT_K_LINESTART: stb_textedit_clamp(str, state); stb_textedit_move_to_first(state); if (state->single_line) state->cursor = 0; else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) --state->cursor; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_LINEEND2 case STB_TEXTEDIT_K_LINEEND2: #endif case STB_TEXTEDIT_K_LINEEND: { int n = STB_TEXTEDIT_STRINGLEN(str); stb_textedit_clamp(str, state); stb_textedit_move_to_first(state); if (state->single_line) state->cursor = n; else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) ++state->cursor; state->has_preferred_x = 0; break; } #ifdef STB_TEXTEDIT_K_LINESTART2 case STB_TEXTEDIT_K_LINESTART2 | STB_TEXTEDIT_K_SHIFT: #endif case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT: stb_textedit_clamp(str, state); stb_textedit_prep_selection_at_cursor(state); if (state->single_line) state->cursor = 0; else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) --state->cursor; state->select_end = state->cursor; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_LINEEND2 case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT: #endif case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: { int n = STB_TEXTEDIT_STRINGLEN(str); stb_textedit_clamp(str, state); stb_textedit_prep_selection_at_cursor(state); if (state->single_line) state->cursor = n; else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) ++state->cursor; state->select_end = state->cursor; state->has_preferred_x = 0; break; } // @TODO: // STB_TEXTEDIT_K_PGUP - move cursor up a page // STB_TEXTEDIT_K_PGDOWN - move cursor down a page } } ///////////////////////////////////////////////////////////////////////////// // // Undo processing // // @OPTIMIZE: the undo/redo buffer should be circular static void stb_textedit_flush_redo(StbUndoState *state) { state->redo_point = STB_TEXTEDIT_UNDOSTATECOUNT; state->redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT; } // discard the oldest entry in the undo list static void stb_textedit_discard_undo(StbUndoState *state) { if (state->undo_point > 0) { // if the 0th undo state has characters, clean those up if (state->undo_rec[0].char_storage >= 0) { int n = state->undo_rec[0].insert_length, i; // delete n characters from all other records state->undo_char_point -= n; STB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE))); for (i=0; i < state->undo_point; ++i) if (state->undo_rec[i].char_storage >= 0) state->undo_rec[i].char_storage -= n; // @OPTIMIZE: get rid of char_storage and infer it } --state->undo_point; STB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0]))); } } // discard the oldest entry in the redo list--it's bad if this // ever happens, but because undo & redo have to store the actual // characters in different cases, the redo character buffer can // fill up even though the undo buffer didn't static void stb_textedit_discard_redo(StbUndoState *state) { int k = STB_TEXTEDIT_UNDOSTATECOUNT-1; if (state->redo_point <= k) { // if the k'th undo state has characters, clean those up if (state->undo_rec[k].char_storage >= 0) { int n = state->undo_rec[k].insert_length, i; // move the remaining redo character data to the end of the buffer state->redo_char_point += n; STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((STB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE))); // adjust the position of all the other records to account for above memmove for (i=state->redo_point; i < k; ++i) if (state->undo_rec[i].char_storage >= 0) state->undo_rec[i].char_storage += n; } // now move all the redo records towards the end of the buffer; the first one is at 'redo_point' // {DEAR IMGUI] size_t move_size = (size_t)((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point - 1) * sizeof(state->undo_rec[0])); const char* buf_begin = (char*)state->undo_rec; (void)buf_begin; const char* buf_end = (char*)state->undo_rec + sizeof(state->undo_rec); (void)buf_end; IM_ASSERT(((char*)(state->undo_rec + state->redo_point)) >= buf_begin); IM_ASSERT(((char*)(state->undo_rec + state->redo_point + 1) + move_size) <= buf_end); STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point+1, state->undo_rec + state->redo_point, move_size); // now move redo_point to point to the new one ++state->redo_point; } } static StbUndoRecord *stb_text_create_undo_record(StbUndoState *state, int numchars) { // any time we create a new undo record, we discard redo stb_textedit_flush_redo(state); // if we have no free records, we have to make room, by sliding the // existing records down if (state->undo_point == STB_TEXTEDIT_UNDOSTATECOUNT) stb_textedit_discard_undo(state); // if the characters to store won't possibly fit in the buffer, we can't undo if (numchars > STB_TEXTEDIT_UNDOCHARCOUNT) { state->undo_point = 0; state->undo_char_point = 0; return NULL; } // if we don't have enough free characters in the buffer, we have to make room while (state->undo_char_point + numchars > STB_TEXTEDIT_UNDOCHARCOUNT) stb_textedit_discard_undo(state); return &state->undo_rec[state->undo_point++]; } static STB_TEXTEDIT_CHARTYPE *stb_text_createundo(StbUndoState *state, int pos, int insert_len, int delete_len) { StbUndoRecord *r = stb_text_create_undo_record(state, insert_len); if (r == NULL) return NULL; r->where = pos; r->insert_length = (STB_TEXTEDIT_POSITIONTYPE) insert_len; r->delete_length = (STB_TEXTEDIT_POSITIONTYPE) delete_len; if (insert_len == 0) { r->char_storage = -1; return NULL; } else { r->char_storage = state->undo_char_point; state->undo_char_point += insert_len; return &state->undo_char[r->char_storage]; } } static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { StbUndoState *s = &state->undostate; StbUndoRecord u, *r; if (s->undo_point == 0) return; // we need to do two things: apply the undo record, and create a redo record u = s->undo_rec[s->undo_point-1]; r = &s->undo_rec[s->redo_point-1]; r->char_storage = -1; r->insert_length = u.delete_length; r->delete_length = u.insert_length; r->where = u.where; if (u.delete_length) { // if the undo record says to delete characters, then the redo record will // need to re-insert the characters that get deleted, so we need to store // them. // there are three cases: // there's enough room to store the characters // characters stored for *redoing* don't leave room for redo // characters stored for *undoing* don't leave room for redo // if the last is true, we have to bail if (s->undo_char_point + u.delete_length >= STB_TEXTEDIT_UNDOCHARCOUNT) { // the undo records take up too much character space; there's no space to store the redo characters r->insert_length = 0; } else { int i; // there's definitely room to store the characters eventually while (s->undo_char_point + u.delete_length > s->redo_char_point) { // should never happen: if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) return; // there's currently not enough room, so discard a redo record stb_textedit_discard_redo(s); } r = &s->undo_rec[s->redo_point-1]; r->char_storage = s->redo_char_point - u.delete_length; s->redo_char_point = s->redo_char_point - u.delete_length; // now save the characters for (i=0; i < u.delete_length; ++i) s->undo_char[r->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u.where + i); } // now we can carry out the deletion STB_TEXTEDIT_DELETECHARS(str, u.where, u.delete_length); } // check type of recorded action: if (u.insert_length) { // easy case: was a deletion, so we need to insert n characters STB_TEXTEDIT_INSERTCHARS(str, u.where, &s->undo_char[u.char_storage], u.insert_length); s->undo_char_point -= u.insert_length; } state->cursor = u.where + u.insert_length; s->undo_point--; s->redo_point--; } static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { StbUndoState *s = &state->undostate; StbUndoRecord *u, r; if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) return; // we need to do two things: apply the redo record, and create an undo record u = &s->undo_rec[s->undo_point]; r = s->undo_rec[s->redo_point]; // we KNOW there must be room for the undo record, because the redo record // was derived from an undo record u->delete_length = r.insert_length; u->insert_length = r.delete_length; u->where = r.where; u->char_storage = -1; if (r.delete_length) { // the redo record requires us to delete characters, so the undo record // needs to store the characters if (s->undo_char_point + u->insert_length > s->redo_char_point) { u->insert_length = 0; u->delete_length = 0; } else { int i; u->char_storage = s->undo_char_point; s->undo_char_point = s->undo_char_point + u->insert_length; // now save the characters for (i=0; i < u->insert_length; ++i) s->undo_char[u->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u->where + i); } STB_TEXTEDIT_DELETECHARS(str, r.where, r.delete_length); } if (r.insert_length) { // easy case: need to insert n characters STB_TEXTEDIT_INSERTCHARS(str, r.where, &s->undo_char[r.char_storage], r.insert_length); s->redo_char_point += r.insert_length; } state->cursor = r.where + r.insert_length; s->undo_point++; s->redo_point++; } static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length) { stb_text_createundo(&state->undostate, where, 0, length); } static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length) { int i; STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, length, 0); if (p) { for (i=0; i < length; ++i) p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); } } static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length) { int i; STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, old_length, new_length); if (p) { for (i=0; i < old_length; ++i) p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); } } // reset the state to default static void stb_textedit_clear_state(STB_TexteditState *state, int is_single_line) { state->undostate.undo_point = 0; state->undostate.undo_char_point = 0; state->undostate.redo_point = STB_TEXTEDIT_UNDOSTATECOUNT; state->undostate.redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT; state->select_end = state->select_start = 0; state->cursor = 0; state->has_preferred_x = 0; state->preferred_x = 0; state->cursor_at_end_of_line = 0; state->initialized = 1; state->single_line = (unsigned char) is_single_line; state->insert_mode = 0; } // API initialize static void stb_textedit_initialize_state(STB_TexteditState *state, int is_single_line) { stb_textedit_clear_state(state, is_single_line); } #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-qual" #endif static int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE const *ctext, int len) { return stb_textedit_paste_internal(str, state, (STB_TEXTEDIT_CHARTYPE *) ctext, len); } #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif #endif//STB_TEXTEDIT_IMPLEMENTATION /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ goxel-0.11.0/ext_src/imgui/imstb_truetype.h000066400000000000000000005676401435762723100207540ustar00rootroot00000000000000// [DEAR IMGUI] // This is a slightly modified version of stb_truetype.h 1.20. // Mostly fixing for compiler and static analyzer warnings. // Grep for [DEAR IMGUI] to find the changes. // stb_truetype.h - v1.20 - public domain // authored from 2009-2016 by Sean Barrett / RAD Game Tools // // This library processes TrueType files: // parse files // extract glyph metrics // extract glyph shapes // render glyphs to one-channel bitmaps with antialiasing (box filter) // render glyphs to one-channel SDF bitmaps (signed-distance field/function) // // Todo: // non-MS cmaps // crashproof on bad data // hinting? (no longer patented) // cleartype-style AA? // optimize: use simple memory allocator for intermediates // optimize: build edge-list directly from curves // optimize: rasterize directly from curves? // // ADDITIONAL CONTRIBUTORS // // Mikko Mononen: compound shape support, more cmap formats // Tor Andersson: kerning, subpixel rendering // Dougall Johnson: OpenType / Type 2 font handling // Daniel Ribeiro Maciel: basic GPOS-based kerning // // Misc other: // Ryan Gordon // Simon Glass // github:IntellectualKitty // Imanol Celaya // Daniel Ribeiro Maciel // // Bug/warning reports/fixes: // "Zer" on mollyrocket Fabian "ryg" Giesen // Cass Everitt Martins Mozeiko // stoiko (Haemimont Games) Cap Petschulat // Brian Hook Omar Cornut // Walter van Niftrik github:aloucks // David Gow Peter LaValle // David Given Sergey Popov // Ivan-Assen Ivanov Giumo X. Clanjor // Anthony Pesch Higor Euripedes // Johan Duparc Thomas Fields // Hou Qiming Derek Vinyard // Rob Loach Cort Stratton // Kenney Phillis Jr. github:oyvindjam // Brian Costabile github:vassvik // // VERSION HISTORY // // 1.20 (2019-02-07) PackFontRange skips missing codepoints; GetScaleFontVMetrics() // 1.19 (2018-02-11) GPOS kerning, STBTT_fmod // 1.18 (2018-01-29) add missing function // 1.17 (2017-07-23) make more arguments const; doc fix // 1.16 (2017-07-12) SDF support // 1.15 (2017-03-03) make more arguments const // 1.14 (2017-01-16) num-fonts-in-TTC function // 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts // 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual // 1.11 (2016-04-02) fix unused-variable warning // 1.10 (2016-04-02) user-defined fabs(); rare memory leak; remove duplicate typedef // 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use allocation userdata properly // 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges // 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; // variant PackFontRanges to pack and render in separate phases; // fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); // fixed an assert() bug in the new rasterizer // replace assert() with STBTT_assert() in new rasterizer // // Full history can be found at the end of this file. // // LICENSE // // See end of file for license information. // // USAGE // // Include this file in whatever places need to refer to it. In ONE C/C++ // file, write: // #define STB_TRUETYPE_IMPLEMENTATION // before the #include of this file. This expands out the actual // implementation into that C/C++ file. // // To make the implementation private to the file that generates the implementation, // #define STBTT_STATIC // // Simple 3D API (don't ship this, but it's fine for tools and quick start) // stbtt_BakeFontBitmap() -- bake a font to a bitmap for use as texture // stbtt_GetBakedQuad() -- compute quad to draw for a given char // // Improved 3D API (more shippable): // #include "stb_rect_pack.h" -- optional, but you really want it // stbtt_PackBegin() // stbtt_PackSetOversampling() -- for improved quality on small fonts // stbtt_PackFontRanges() -- pack and renders // stbtt_PackEnd() // stbtt_GetPackedQuad() // // "Load" a font file from a memory buffer (you have to keep the buffer loaded) // stbtt_InitFont() // stbtt_GetFontOffsetForIndex() -- indexing for TTC font collections // stbtt_GetNumberOfFonts() -- number of fonts for TTC font collections // // Render a unicode codepoint to a bitmap // stbtt_GetCodepointBitmap() -- allocates and returns a bitmap // stbtt_MakeCodepointBitmap() -- renders into bitmap you provide // stbtt_GetCodepointBitmapBox() -- how big the bitmap must be // // Character advance/positioning // stbtt_GetCodepointHMetrics() // stbtt_GetFontVMetrics() // stbtt_GetFontVMetricsOS2() // stbtt_GetCodepointKernAdvance() // // Starting with version 1.06, the rasterizer was replaced with a new, // faster and generally-more-precise rasterizer. The new rasterizer more // accurately measures pixel coverage for anti-aliasing, except in the case // where multiple shapes overlap, in which case it overestimates the AA pixel // coverage. Thus, anti-aliasing of intersecting shapes may look wrong. If // this turns out to be a problem, you can re-enable the old rasterizer with // #define STBTT_RASTERIZER_VERSION 1 // which will incur about a 15% speed hit. // // ADDITIONAL DOCUMENTATION // // Immediately after this block comment are a series of sample programs. // // After the sample programs is the "header file" section. This section // includes documentation for each API function. // // Some important concepts to understand to use this library: // // Codepoint // Characters are defined by unicode codepoints, e.g. 65 is // uppercase A, 231 is lowercase c with a cedilla, 0x7e30 is // the hiragana for "ma". // // Glyph // A visual character shape (every codepoint is rendered as // some glyph) // // Glyph index // A font-specific integer ID representing a glyph // // Baseline // Glyph shapes are defined relative to a baseline, which is the // bottom of uppercase characters. Characters extend both above // and below the baseline. // // Current Point // As you draw text to the screen, you keep track of a "current point" // which is the origin of each character. The current point's vertical // position is the baseline. Even "baked fonts" use this model. // // Vertical Font Metrics // The vertical qualities of the font, used to vertically position // and space the characters. See docs for stbtt_GetFontVMetrics. // // Font Size in Pixels or Points // The preferred interface for specifying font sizes in stb_truetype // is to specify how tall the font's vertical extent should be in pixels. // If that sounds good enough, skip the next paragraph. // // Most font APIs instead use "points", which are a common typographic // measurement for describing font size, defined as 72 points per inch. // stb_truetype provides a point API for compatibility. However, true // "per inch" conventions don't make much sense on computer displays // since different monitors have different number of pixels per // inch. For example, Windows traditionally uses a convention that // there are 96 pixels per inch, thus making 'inch' measurements have // nothing to do with inches, and thus effectively defining a point to // be 1.333 pixels. Additionally, the TrueType font data provides // an explicit scale factor to scale a given font's glyphs to points, // but the author has observed that this scale factor is often wrong // for non-commercial fonts, thus making fonts scaled in points // according to the TrueType spec incoherently sized in practice. // // DETAILED USAGE: // // Scale: // Select how high you want the font to be, in points or pixels. // Call ScaleForPixelHeight or ScaleForMappingEmToPixels to compute // a scale factor SF that will be used by all other functions. // // Baseline: // You need to select a y-coordinate that is the baseline of where // your text will appear. Call GetFontBoundingBox to get the baseline-relative // bounding box for all characters. SF*-y0 will be the distance in pixels // that the worst-case character could extend above the baseline, so if // you want the top edge of characters to appear at the top of the // screen where y=0, then you would set the baseline to SF*-y0. // // Current point: // Set the current point where the first character will appear. The // first character could extend left of the current point; this is font // dependent. You can either choose a current point that is the leftmost // point and hope, or add some padding, or check the bounding box or // left-side-bearing of the first character to be displayed and set // the current point based on that. // // Displaying a character: // Compute the bounding box of the character. It will contain signed values // relative to . I.e. if it returns x0,y0,x1,y1, // then the character should be displayed in the rectangle from // to = 32 && *text < 128) { stbtt_aligned_quad q; stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9 glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y0); glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y0); glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y1); glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y1); } ++text; } glEnd(); } #endif // // ////////////////////////////////////////////////////////////////////////////// // // Complete program (this compiles): get a single bitmap, print as ASCII art // #if 0 #include #define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation #include "stb_truetype.h" char ttf_buffer[1<<25]; int main(int argc, char **argv) { stbtt_fontinfo font; unsigned char *bitmap; int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 'a'), s = (argc > 2 ? atoi(argv[2]) : 20); fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb")); stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0)); bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0); for (j=0; j < h; ++j) { for (i=0; i < w; ++i) putchar(" .:ioVM@"[bitmap[j*w+i]>>5]); putchar('\n'); } return 0; } #endif // // Output: // // .ii. // @@@@@@. // V@Mio@@o // :i. V@V // :oM@@M // :@@@MM@M // @@o o@M // :@@. M@M // @@@o@@@@ // :M@@V:@@. // ////////////////////////////////////////////////////////////////////////////// // // Complete program: print "Hello World!" banner, with bugs // #if 0 char buffer[24<<20]; unsigned char screen[20][79]; int main(int arg, char **argv) { stbtt_fontinfo font; int i,j,ascent,baseline,ch=0; float scale, xpos=2; // leave a little padding in case the character extends left char *text = "Heljo World!"; // intentionally misspelled to show 'lj' brokenness fread(buffer, 1, 1000000, fopen("c:/windows/fonts/arialbd.ttf", "rb")); stbtt_InitFont(&font, buffer, 0); scale = stbtt_ScaleForPixelHeight(&font, 15); stbtt_GetFontVMetrics(&font, &ascent,0,0); baseline = (int) (ascent*scale); while (text[ch]) { int advance,lsb,x0,y0,x1,y1; float x_shift = xpos - (float) floor(xpos); stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb); stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1); stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]); // note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong // because this API is really for baking character bitmaps into textures. if you want to render // a sequence of characters, you really need to render each bitmap to a temp buffer, then // "alpha blend" that into the working buffer xpos += (advance * scale); if (text[ch+1]) xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]); ++ch; } for (j=0; j < 20; ++j) { for (i=0; i < 78; ++i) putchar(" .:ioVM@"[screen[j][i]>>5]); putchar('\n'); } return 0; } #endif ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// //// //// INTEGRATION WITH YOUR CODEBASE //// //// The following sections allow you to supply alternate definitions //// of C library functions used by stb_truetype, e.g. if you don't //// link with the C runtime library. #ifdef STB_TRUETYPE_IMPLEMENTATION // #define your own (u)stbtt_int8/16/32 before including to override this #ifndef stbtt_uint8 typedef unsigned char stbtt_uint8; typedef signed char stbtt_int8; typedef unsigned short stbtt_uint16; typedef signed short stbtt_int16; typedef unsigned int stbtt_uint32; typedef signed int stbtt_int32; #endif typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1]; typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1]; // e.g. #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h #ifndef STBTT_ifloor #include #define STBTT_ifloor(x) ((int) floor(x)) #define STBTT_iceil(x) ((int) ceil(x)) #endif #ifndef STBTT_sqrt #include #define STBTT_sqrt(x) sqrt(x) #define STBTT_pow(x,y) pow(x,y) #endif #ifndef STBTT_fmod #include #define STBTT_fmod(x,y) fmod(x,y) #endif #ifndef STBTT_cos #include #define STBTT_cos(x) cos(x) #define STBTT_acos(x) acos(x) #endif #ifndef STBTT_fabs #include #define STBTT_fabs(x) fabs(x) #endif // #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h #ifndef STBTT_malloc #include #define STBTT_malloc(x,u) ((void)(u),malloc(x)) #define STBTT_free(x,u) ((void)(u),free(x)) #endif #ifndef STBTT_assert #include #define STBTT_assert(x) assert(x) #endif #ifndef STBTT_strlen #include #define STBTT_strlen(x) strlen(x) #endif #ifndef STBTT_memcpy #include #define STBTT_memcpy memcpy #define STBTT_memset memset #endif #endif /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //// //// INTERFACE //// //// #ifndef __STB_INCLUDE_STB_TRUETYPE_H__ #define __STB_INCLUDE_STB_TRUETYPE_H__ #ifdef STBTT_STATIC #define STBTT_DEF static #else #define STBTT_DEF extern #endif #ifdef __cplusplus extern "C" { #endif // private structure typedef struct { unsigned char *data; int cursor; int size; } stbtt__buf; ////////////////////////////////////////////////////////////////////////////// // // TEXTURE BAKING API // // If you use this API, you only have to call two functions ever. // typedef struct { unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap float xoff,yoff,xadvance; } stbtt_bakedchar; STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) float pixel_height, // height of font in pixels unsigned char *pixels, int pw, int ph, // bitmap to be filled in int first_char, int num_chars, // characters to bake stbtt_bakedchar *chardata); // you allocate this, it's num_chars long // if return is positive, the first unused row of the bitmap // if return is negative, returns the negative of the number of characters that fit // if return is 0, no characters fit and no rows were used // This uses a very crappy packing. typedef struct { float x0,y0,s0,t0; // top-left float x1,y1,s1,t1; // bottom-right } stbtt_aligned_quad; STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, // same data as above int char_index, // character to display float *xpos, float *ypos, // pointers to current position in screen pixel space stbtt_aligned_quad *q, // output: quad to draw int opengl_fillrule); // true if opengl fill rule; false if DX9 or earlier // Call GetBakedQuad with char_index = 'character - first_char', and it // creates the quad you need to draw and advances the current position. // // The coordinate system used assumes y increases downwards. // // Characters will extend both above and below the current position; // see discussion of "BASELINE" above. // // It's inefficient; you might want to c&p it and optimize it. STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap); // Query the font vertical metrics without having to create a font first. ////////////////////////////////////////////////////////////////////////////// // // NEW TEXTURE BAKING API // // This provides options for packing multiple fonts into one atlas, not // perfectly but better than nothing. typedef struct { unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap float xoff,yoff,xadvance; float xoff2,yoff2; } stbtt_packedchar; typedef struct stbtt_pack_context stbtt_pack_context; typedef struct stbtt_fontinfo stbtt_fontinfo; #ifndef STB_RECT_PACK_VERSION typedef struct stbrp_rect stbrp_rect; #endif STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context); // Initializes a packing context stored in the passed-in stbtt_pack_context. // Future calls using this context will pack characters into the bitmap passed // in here: a 1-channel bitmap that is width * height. stride_in_bytes is // the distance from one row to the next (or 0 to mean they are packed tightly // together). "padding" is the amount of padding to leave between each // character (normally you want '1' for bitmaps you'll use as textures with // bilinear filtering). // // Returns 0 on failure, 1 on success. STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc); // Cleans up the packing context and frees all memory. #define STBTT_POINT_SIZE(x) (-(x)) STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range); // Creates character bitmaps from the font_index'th font found in fontdata (use // font_index=0 if you don't know what that is). It creates num_chars_in_range // bitmaps for characters with unicode values starting at first_unicode_char_in_range // and increasing. Data for how to render them is stored in chardata_for_range; // pass these to stbtt_GetPackedQuad to get back renderable quads. // // font_size is the full height of the character from ascender to descender, // as computed by stbtt_ScaleForPixelHeight. To use a point size as computed // by stbtt_ScaleForMappingEmToPixels, wrap the point size in STBTT_POINT_SIZE() // and pass that result as 'font_size': // ..., 20 , ... // font max minus min y is 20 pixels tall // ..., STBTT_POINT_SIZE(20), ... // 'M' is 20 pixels tall typedef struct { float font_size; int first_unicode_codepoint_in_range; // if non-zero, then the chars are continuous, and this is the first codepoint int *array_of_unicode_codepoints; // if non-zero, then this is an array of unicode codepoints int num_chars; stbtt_packedchar *chardata_for_range; // output unsigned char h_oversample, v_oversample; // don't set these, they're used internally } stbtt_pack_range; STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges); // Creates character bitmaps from multiple ranges of characters stored in // ranges. This will usually create a better-packed bitmap than multiple // calls to stbtt_PackFontRange. Note that you can call this multiple // times within a single PackBegin/PackEnd. STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample); // Oversampling a font increases the quality by allowing higher-quality subpixel // positioning, and is especially valuable at smaller text sizes. // // This function sets the amount of oversampling for all following calls to // stbtt_PackFontRange(s) or stbtt_PackFontRangesGatherRects for a given // pack context. The default (no oversampling) is achieved by h_oversample=1 // and v_oversample=1. The total number of pixels required is // h_oversample*v_oversample larger than the default; for example, 2x2 // oversampling requires 4x the storage of 1x1. For best results, render // oversampled textures with bilinear filtering. Look at the readme in // stb/tests/oversample for information about oversampled fonts // // To use with PackFontRangesGather etc., you must set it before calls // call to PackFontRangesGatherRects. STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip); // If skip != 0, this tells stb_truetype to skip any codepoints for which // there is no corresponding glyph. If skip=0, which is the default, then // codepoints without a glyph recived the font's "missing character" glyph, // typically an empty box by convention. STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above int char_index, // character to display float *xpos, float *ypos, // pointers to current position in screen pixel space stbtt_aligned_quad *q, // output: quad to draw int align_to_integer); STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects); STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); // Calling these functions in sequence is roughly equivalent to calling // stbtt_PackFontRanges(). If you more control over the packing of multiple // fonts, or if you want to pack custom data into a font texture, take a look // at the source to of stbtt_PackFontRanges() and create a custom version // using these functions, e.g. call GatherRects multiple times, // building up a single array of rects, then call PackRects once, // then call RenderIntoRects repeatedly. This may result in a // better packing than calling PackFontRanges multiple times // (or it may not). // this is an opaque structure that you shouldn't mess with which holds // all the context needed from PackBegin to PackEnd. struct stbtt_pack_context { void *user_allocator_context; void *pack_info; int width; int height; int stride_in_bytes; int padding; int skip_missing; unsigned int h_oversample, v_oversample; unsigned char *pixels; void *nodes; }; ////////////////////////////////////////////////////////////////////////////// // // FONT LOADING // // STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data); // This function will determine the number of fonts in a font file. TrueType // collection (.ttc) files may contain multiple fonts, while TrueType font // (.ttf) files only contain one font. The number of fonts can be used for // indexing with the previous function where the index is between zero and one // less than the total fonts. If an error occurs, -1 is returned. STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index); // Each .ttf/.ttc file may have more than one font. Each font has a sequential // index number starting from 0. Call this function to get the font offset for // a given index; it returns -1 if the index is out of range. A regular .ttf // file will only define one font and it always be at offset 0, so it will // return '0' for index 0, and -1 for all other indices. // The following structure is defined publicly so you can declare one on // the stack or as a global or etc, but you should treat it as opaque. struct stbtt_fontinfo { void * userdata; unsigned char * data; // pointer to .ttf file int fontstart; // offset of start of font int numGlyphs; // number of glyphs, needed for range checking int loca,head,glyf,hhea,hmtx,kern,gpos; // table locations as offset from start of .ttf int index_map; // a cmap mapping for our chosen character encoding int indexToLocFormat; // format needed to map from glyph index to glyph stbtt__buf cff; // cff font data stbtt__buf charstrings; // the charstring index stbtt__buf gsubrs; // global charstring subroutines index stbtt__buf subrs; // private charstring subroutines index stbtt__buf fontdicts; // array of font dicts stbtt__buf fdselect; // map from glyph to fontdict }; STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset); // Given an offset into the file that defines a font, this function builds // the necessary cached info for the rest of the system. You must allocate // the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't // need to do anything special to free it, because the contents are pure // value data with no additional data structures. Returns 0 on failure. ////////////////////////////////////////////////////////////////////////////// // // CHARACTER TO GLYPH-INDEX CONVERSIOn STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint); // If you're going to perform multiple operations on the same character // and you want a speed-up, call this function with the character you're // going to process, then use glyph-based functions instead of the // codepoint-based functions. // Returns 0 if the character codepoint is not defined in the font. ////////////////////////////////////////////////////////////////////////////// // // CHARACTER PROPERTIES // STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels); // computes a scale factor to produce a font whose "height" is 'pixels' tall. // Height is measured as the distance from the highest ascender to the lowest // descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics // and computing: // scale = pixels / (ascent - descent) // so if you prefer to measure height by the ascent only, use a similar calculation. STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels); // computes a scale factor to produce a font whose EM size is mapped to // 'pixels' tall. This is probably what traditional APIs compute, but // I'm not positive. STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap); // ascent is the coordinate above the baseline the font extends; descent // is the coordinate below the baseline the font extends (i.e. it is typically negative) // lineGap is the spacing between one row's descent and the next row's ascent... // so you should advance the vertical position by "*ascent - *descent + *lineGap" // these are expressed in unscaled coordinates, so you must multiply by // the scale factor for a given size STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap); // analogous to GetFontVMetrics, but returns the "typographic" values from the OS/2 // table (specific to MS/Windows TTF files). // // Returns 1 on success (table present), 0 on failure. STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1); // the bounding box around all possible characters STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing); // leftSideBearing is the offset from the current horizontal position to the left edge of the character // advanceWidth is the offset from the current horizontal position to the next horizontal position // these are expressed in unscaled coordinates STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2); // an additional amount to add to the 'advance' value between ch1 and ch2 STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1); // Gets the bounding box of the visible part of the glyph, in unscaled coordinates STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing); STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2); STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); // as above, but takes one or more glyph indices for greater efficiency ////////////////////////////////////////////////////////////////////////////// // // GLYPH SHAPES (you probably don't need these, but they have to go before // the bitmaps for C declaration-order reasons) // #ifndef STBTT_vmove // you can predefine these to use different values (but why?) enum { STBTT_vmove=1, STBTT_vline, STBTT_vcurve, STBTT_vcubic }; #endif #ifndef stbtt_vertex // you can predefine this to use different values // (we share this with other code at RAD) #define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file typedef struct { stbtt_vertex_type x,y,cx,cy,cx1,cy1; unsigned char type,padding; } stbtt_vertex; #endif STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index); // returns non-zero if nothing is drawn for this glyph STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices); STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices); // returns # of vertices and fills *vertices with the pointer to them // these are expressed in "unscaled" coordinates // // The shape is a series of contours. Each one starts with // a STBTT_moveto, then consists of a series of mixed // STBTT_lineto and STBTT_curveto segments. A lineto // draws a line from previous endpoint to its x,y; a curveto // draws a quadratic bezier from previous endpoint to // its x,y, using cx,cy as the bezier control point. STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices); // frees the data allocated above ////////////////////////////////////////////////////////////////////////////// // // BITMAP RENDERING // STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata); // frees the bitmap allocated below STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff); // allocates a large-enough single-channel 8bpp bitmap and renders the // specified character/glyph at the specified scale into it, with // antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque). // *width & *height are filled out with the width & height of the bitmap, // which is stored left-to-right, top-to-bottom. // // xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff); // the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel // shift for the character STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint); // the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap // in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap // is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the // width and height and positioning info for it first. STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint); // same as stbtt_MakeCodepointBitmap, but you can specify a subpixel // shift for the character STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint); // same as stbtt_MakeCodepointBitmapSubpixel, but prefiltering // is performed (see stbtt_PackSetOversampling) STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); // get the bbox of the bitmap centered around the glyph origin; so the // bitmap width is ix1-ix0, height is iy1-iy0, and location to place // the bitmap top left is (leftSideBearing*scale,iy0). // (Note that the bitmap uses y-increases-down, but the shape uses // y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.) STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); // same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel // shift for the character // the following functions are equivalent to the above functions, but operate // on glyph indices instead of Unicode codepoints (for efficiency) STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff); STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff); STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph); STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph); STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int glyph); STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); // @TODO: don't expose this structure typedef struct { int w,h,stride; unsigned char *pixels; } stbtt__bitmap; // rasterize a shape with quadratic beziers into a bitmap STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, // 1-channel bitmap to draw into float flatness_in_pixels, // allowable error of curve in pixels stbtt_vertex *vertices, // array of vertices defining shape int num_verts, // number of vertices in above array float scale_x, float scale_y, // scale applied to input vertices float shift_x, float shift_y, // translation applied to input vertices int x_off, int y_off, // another translation applied to input int invert, // if non-zero, vertically flip shape void *userdata); // context for to STBTT_MALLOC ////////////////////////////////////////////////////////////////////////////// // // Signed Distance Function (or Field) rendering STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata); // frees the SDF bitmap allocated below STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); // These functions compute a discretized SDF field for a single character, suitable for storing // in a single-channel texture, sampling with bilinear filtering, and testing against // larger than some threshold to produce scalable fonts. // info -- the font // scale -- controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap // glyph/codepoint -- the character to generate the SDF for // padding -- extra "pixels" around the character which are filled with the distance to the character (not 0), // which allows effects like bit outlines // onedge_value -- value 0-255 to test the SDF against to reconstruct the character (i.e. the isocontour of the character) // pixel_dist_scale -- what value the SDF should increase by when moving one SDF "pixel" away from the edge (on the 0..255 scale) // if positive, > onedge_value is inside; if negative, < onedge_value is inside // width,height -- output height & width of the SDF bitmap (including padding) // xoff,yoff -- output origin of the character // return value -- a 2D array of bytes 0..255, width*height in size // // pixel_dist_scale & onedge_value are a scale & bias that allows you to make // optimal use of the limited 0..255 for your application, trading off precision // and special effects. SDF values outside the range 0..255 are clamped to 0..255. // // Example: // scale = stbtt_ScaleForPixelHeight(22) // padding = 5 // onedge_value = 180 // pixel_dist_scale = 180/5.0 = 36.0 // // This will create an SDF bitmap in which the character is about 22 pixels // high but the whole bitmap is about 22+5+5=32 pixels high. To produce a filled // shape, sample the SDF at each pixel and fill the pixel if the SDF value // is greater than or equal to 180/255. (You'll actually want to antialias, // which is beyond the scope of this example.) Additionally, you can compute // offset outlines (e.g. to stroke the character border inside & outside, // or only outside). For example, to fill outside the character up to 3 SDF // pixels, you would compare against (180-36.0*3)/255 = 72/255. The above // choice of variables maps a range from 5 pixels outside the shape to // 2 pixels inside the shape to 0..255; this is intended primarily for apply // outside effects only (the interior range is needed to allow proper // antialiasing of the font at *smaller* sizes) // // The function computes the SDF analytically at each SDF pixel, not by e.g. // building a higher-res bitmap and approximating it. In theory the quality // should be as high as possible for an SDF of this size & representation, but // unclear if this is true in practice (perhaps building a higher-res bitmap // and computing from that can allow drop-out prevention). // // The algorithm has not been optimized at all, so expect it to be slow // if computing lots of characters or very large sizes. ////////////////////////////////////////////////////////////////////////////// // // Finding the right font... // // You should really just solve this offline, keep your own tables // of what font is what, and don't try to get it out of the .ttf file. // That's because getting it out of the .ttf file is really hard, because // the names in the file can appear in many possible encodings, in many // possible languages, and e.g. if you need a case-insensitive comparison, // the details of that depend on the encoding & language in a complex way // (actually underspecified in truetype, but also gigantic). // // But you can use the provided functions in two possible ways: // stbtt_FindMatchingFont() will use *case-sensitive* comparisons on // unicode-encoded names to try to find the font you want; // you can run this before calling stbtt_InitFont() // // stbtt_GetFontNameString() lets you get any of the various strings // from the file yourself and do your own comparisons on them. // You have to have called stbtt_InitFont() first. STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags); // returns the offset (not index) of the font that matches, or -1 if none // if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold". // if you use any other flag, use a font name like "Arial"; this checks // the 'macStyle' header field; i don't know if fonts set this consistently #define STBTT_MACSTYLE_DONTCARE 0 #define STBTT_MACSTYLE_BOLD 1 #define STBTT_MACSTYLE_ITALIC 2 #define STBTT_MACSTYLE_UNDERSCORE 4 #define STBTT_MACSTYLE_NONE 8 // <= not same as 0, this makes us check the bitfield is 0 STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2); // returns 1/0 whether the first string interpreted as utf8 is identical to // the second string interpreted as big-endian utf16... useful for strings from next func STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID); // returns the string (which may be big-endian double byte, e.g. for unicode) // and puts the length in bytes in *length. // // some of the values for the IDs are below; for more see the truetype spec: // http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html // http://www.microsoft.com/typography/otspec/name.htm enum { // platformID STBTT_PLATFORM_ID_UNICODE =0, STBTT_PLATFORM_ID_MAC =1, STBTT_PLATFORM_ID_ISO =2, STBTT_PLATFORM_ID_MICROSOFT =3 }; enum { // encodingID for STBTT_PLATFORM_ID_UNICODE STBTT_UNICODE_EID_UNICODE_1_0 =0, STBTT_UNICODE_EID_UNICODE_1_1 =1, STBTT_UNICODE_EID_ISO_10646 =2, STBTT_UNICODE_EID_UNICODE_2_0_BMP=3, STBTT_UNICODE_EID_UNICODE_2_0_FULL=4 }; enum { // encodingID for STBTT_PLATFORM_ID_MICROSOFT STBTT_MS_EID_SYMBOL =0, STBTT_MS_EID_UNICODE_BMP =1, STBTT_MS_EID_SHIFTJIS =2, STBTT_MS_EID_UNICODE_FULL =10 }; enum { // encodingID for STBTT_PLATFORM_ID_MAC; same as Script Manager codes STBTT_MAC_EID_ROMAN =0, STBTT_MAC_EID_ARABIC =4, STBTT_MAC_EID_JAPANESE =1, STBTT_MAC_EID_HEBREW =5, STBTT_MAC_EID_CHINESE_TRAD =2, STBTT_MAC_EID_GREEK =6, STBTT_MAC_EID_KOREAN =3, STBTT_MAC_EID_RUSSIAN =7 }; enum { // languageID for STBTT_PLATFORM_ID_MICROSOFT; same as LCID... // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs STBTT_MS_LANG_ENGLISH =0x0409, STBTT_MS_LANG_ITALIAN =0x0410, STBTT_MS_LANG_CHINESE =0x0804, STBTT_MS_LANG_JAPANESE =0x0411, STBTT_MS_LANG_DUTCH =0x0413, STBTT_MS_LANG_KOREAN =0x0412, STBTT_MS_LANG_FRENCH =0x040c, STBTT_MS_LANG_RUSSIAN =0x0419, STBTT_MS_LANG_GERMAN =0x0407, STBTT_MS_LANG_SPANISH =0x0409, STBTT_MS_LANG_HEBREW =0x040d, STBTT_MS_LANG_SWEDISH =0x041D }; enum { // languageID for STBTT_PLATFORM_ID_MAC STBTT_MAC_LANG_ENGLISH =0 , STBTT_MAC_LANG_JAPANESE =11, STBTT_MAC_LANG_ARABIC =12, STBTT_MAC_LANG_KOREAN =23, STBTT_MAC_LANG_DUTCH =4 , STBTT_MAC_LANG_RUSSIAN =32, STBTT_MAC_LANG_FRENCH =1 , STBTT_MAC_LANG_SPANISH =6 , STBTT_MAC_LANG_GERMAN =2 , STBTT_MAC_LANG_SWEDISH =5 , STBTT_MAC_LANG_HEBREW =10, STBTT_MAC_LANG_CHINESE_SIMPLIFIED =33, STBTT_MAC_LANG_ITALIAN =3 , STBTT_MAC_LANG_CHINESE_TRAD =19 }; #ifdef __cplusplus } #endif #endif // __STB_INCLUDE_STB_TRUETYPE_H__ /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //// //// IMPLEMENTATION //// //// #ifdef STB_TRUETYPE_IMPLEMENTATION #ifndef STBTT_MAX_OVERSAMPLE #define STBTT_MAX_OVERSAMPLE 8 #endif #if STBTT_MAX_OVERSAMPLE > 255 #error "STBTT_MAX_OVERSAMPLE cannot be > 255" #endif typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERSAMPLE-1)) == 0 ? 1 : -1]; #ifndef STBTT_RASTERIZER_VERSION #define STBTT_RASTERIZER_VERSION 2 #endif #ifdef _MSC_VER #define STBTT__NOTUSED(v) (void)(v) #else #define STBTT__NOTUSED(v) (void)sizeof(v) #endif ////////////////////////////////////////////////////////////////////////// // // stbtt__buf helpers to parse data from file // static stbtt_uint8 stbtt__buf_get8(stbtt__buf *b) { if (b->cursor >= b->size) return 0; return b->data[b->cursor++]; } static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b) { if (b->cursor >= b->size) return 0; return b->data[b->cursor]; } static void stbtt__buf_seek(stbtt__buf *b, int o) { STBTT_assert(!(o > b->size || o < 0)); b->cursor = (o > b->size || o < 0) ? b->size : o; } static void stbtt__buf_skip(stbtt__buf *b, int o) { stbtt__buf_seek(b, b->cursor + o); } static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n) { stbtt_uint32 v = 0; int i; STBTT_assert(n >= 1 && n <= 4); for (i = 0; i < n; i++) v = (v << 8) | stbtt__buf_get8(b); return v; } static stbtt__buf stbtt__new_buf(const void *p, size_t size) { stbtt__buf r; STBTT_assert(size < 0x40000000); r.data = (stbtt_uint8*) p; r.size = (int) size; r.cursor = 0; return r; } #define stbtt__buf_get16(b) stbtt__buf_get((b), 2) #define stbtt__buf_get32(b) stbtt__buf_get((b), 4) static stbtt__buf stbtt__buf_range(const stbtt__buf *b, int o, int s) { stbtt__buf r = stbtt__new_buf(NULL, 0); if (o < 0 || s < 0 || o > b->size || s > b->size - o) return r; r.data = b->data + o; r.size = s; return r; } static stbtt__buf stbtt__cff_get_index(stbtt__buf *b) { int count, start, offsize; start = b->cursor; count = stbtt__buf_get16(b); if (count) { offsize = stbtt__buf_get8(b); STBTT_assert(offsize >= 1 && offsize <= 4); stbtt__buf_skip(b, offsize * count); stbtt__buf_skip(b, stbtt__buf_get(b, offsize) - 1); } return stbtt__buf_range(b, start, b->cursor - start); } static stbtt_uint32 stbtt__cff_int(stbtt__buf *b) { int b0 = stbtt__buf_get8(b); if (b0 >= 32 && b0 <= 246) return b0 - 139; else if (b0 >= 247 && b0 <= 250) return (b0 - 247)*256 + stbtt__buf_get8(b) + 108; else if (b0 >= 251 && b0 <= 254) return -(b0 - 251)*256 - stbtt__buf_get8(b) - 108; else if (b0 == 28) return stbtt__buf_get16(b); else if (b0 == 29) return stbtt__buf_get32(b); STBTT_assert(0); return 0; } static void stbtt__cff_skip_operand(stbtt__buf *b) { int v, b0 = stbtt__buf_peek8(b); STBTT_assert(b0 >= 28); if (b0 == 30) { stbtt__buf_skip(b, 1); while (b->cursor < b->size) { v = stbtt__buf_get8(b); if ((v & 0xF) == 0xF || (v >> 4) == 0xF) break; } } else { stbtt__cff_int(b); } } static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key) { stbtt__buf_seek(b, 0); while (b->cursor < b->size) { int start = b->cursor, end, op; while (stbtt__buf_peek8(b) >= 28) stbtt__cff_skip_operand(b); end = b->cursor; op = stbtt__buf_get8(b); if (op == 12) op = stbtt__buf_get8(b) | 0x100; if (op == key) return stbtt__buf_range(b, start, end-start); } return stbtt__buf_range(b, 0, 0); } static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uint32 *out) { int i; stbtt__buf operands = stbtt__dict_get(b, key); for (i = 0; i < outcount && operands.cursor < operands.size; i++) out[i] = stbtt__cff_int(&operands); } static int stbtt__cff_index_count(stbtt__buf *b) { stbtt__buf_seek(b, 0); return stbtt__buf_get16(b); } static stbtt__buf stbtt__cff_index_get(stbtt__buf b, int i) { int count, offsize, start, end; stbtt__buf_seek(&b, 0); count = stbtt__buf_get16(&b); offsize = stbtt__buf_get8(&b); STBTT_assert(i >= 0 && i < count); STBTT_assert(offsize >= 1 && offsize <= 4); stbtt__buf_skip(&b, i*offsize); start = stbtt__buf_get(&b, offsize); end = stbtt__buf_get(&b, offsize); return stbtt__buf_range(&b, 2+(count+1)*offsize+start, end - start); } ////////////////////////////////////////////////////////////////////////// // // accessors to parse data from file // // on platforms that don't allow misaligned reads, if we want to allow // truetype fonts that aren't padded to alignment, define ALLOW_UNALIGNED_TRUETYPE #define ttBYTE(p) (* (stbtt_uint8 *) (p)) #define ttCHAR(p) (* (stbtt_int8 *) (p)) #define ttFixed(p) ttLONG(p) static stbtt_uint16 ttUSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } static stbtt_int16 ttSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } static stbtt_uint32 ttULONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } static stbtt_int32 ttLONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } #define stbtt_tag4(p,c0,c1,c2,c3) ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3)) #define stbtt_tag(p,str) stbtt_tag4(p,str[0],str[1],str[2],str[3]) static int stbtt__isfont(stbtt_uint8 *font) { // check the version number if (stbtt_tag4(font, '1',0,0,0)) return 1; // TrueType 1 if (stbtt_tag(font, "typ1")) return 1; // TrueType with type 1 font -- we don't support this! if (stbtt_tag(font, "OTTO")) return 1; // OpenType with CFF if (stbtt_tag4(font, 0,1,0,0)) return 1; // OpenType 1.0 if (stbtt_tag(font, "true")) return 1; // Apple specification for TrueType fonts return 0; } // @OPTIMIZE: binary search static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, const char *tag) { stbtt_int32 num_tables = ttUSHORT(data+fontstart+4); stbtt_uint32 tabledir = fontstart + 12; stbtt_int32 i; for (i=0; i < num_tables; ++i) { stbtt_uint32 loc = tabledir + 16*i; if (stbtt_tag(data+loc+0, tag)) return ttULONG(data+loc+8); } return 0; } static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, int index) { // if it's just a font, there's only one valid index if (stbtt__isfont(font_collection)) return index == 0 ? 0 : -1; // check if it's a TTC if (stbtt_tag(font_collection, "ttcf")) { // version 1? if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { stbtt_int32 n = ttLONG(font_collection+8); if (index >= n) return -1; return ttULONG(font_collection+12+index*4); } } return -1; } static int stbtt_GetNumberOfFonts_internal(unsigned char *font_collection) { // if it's just a font, there's only one valid font if (stbtt__isfont(font_collection)) return 1; // check if it's a TTC if (stbtt_tag(font_collection, "ttcf")) { // version 1? if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { return ttLONG(font_collection+8); } } return 0; } static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict) { stbtt_uint32 subrsoff = 0, private_loc[2] = { 0, 0 }; stbtt__buf pdict; stbtt__dict_get_ints(&fontdict, 18, 2, private_loc); if (!private_loc[1] || !private_loc[0]) return stbtt__new_buf(NULL, 0); pdict = stbtt__buf_range(&cff, private_loc[1], private_loc[0]); stbtt__dict_get_ints(&pdict, 19, 1, &subrsoff); if (!subrsoff) return stbtt__new_buf(NULL, 0); stbtt__buf_seek(&cff, private_loc[1]+subrsoff); return stbtt__cff_get_index(&cff); } static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart) { stbtt_uint32 cmap, t; stbtt_int32 i,numTables; info->data = data; info->fontstart = fontstart; info->cff = stbtt__new_buf(NULL, 0); cmap = stbtt__find_table(data, fontstart, "cmap"); // required info->loca = stbtt__find_table(data, fontstart, "loca"); // required info->head = stbtt__find_table(data, fontstart, "head"); // required info->glyf = stbtt__find_table(data, fontstart, "glyf"); // required info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required info->kern = stbtt__find_table(data, fontstart, "kern"); // not required info->gpos = stbtt__find_table(data, fontstart, "GPOS"); // not required if (!cmap || !info->head || !info->hhea || !info->hmtx) return 0; if (info->glyf) { // required for truetype if (!info->loca) return 0; } else { // initialization for CFF / Type2 fonts (OTF) stbtt__buf b, topdict, topdictidx; stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0; stbtt_uint32 cff; cff = stbtt__find_table(data, fontstart, "CFF "); if (!cff) return 0; info->fontdicts = stbtt__new_buf(NULL, 0); info->fdselect = stbtt__new_buf(NULL, 0); // @TODO this should use size from table (not 512MB) info->cff = stbtt__new_buf(data+cff, 512*1024*1024); b = info->cff; // read the header stbtt__buf_skip(&b, 2); stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize // @TODO the name INDEX could list multiple fonts, // but we just use the first one. stbtt__cff_get_index(&b); // name INDEX topdictidx = stbtt__cff_get_index(&b); topdict = stbtt__cff_index_get(topdictidx, 0); stbtt__cff_get_index(&b); // string INDEX info->gsubrs = stbtt__cff_get_index(&b); stbtt__dict_get_ints(&topdict, 17, 1, &charstrings); stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype); stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff); stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff); info->subrs = stbtt__get_subrs(b, topdict); // we only support Type 2 charstrings if (cstype != 2) return 0; if (charstrings == 0) return 0; if (fdarrayoff) { // looks like a CID font if (!fdselectoff) return 0; stbtt__buf_seek(&b, fdarrayoff); info->fontdicts = stbtt__cff_get_index(&b); info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff); } stbtt__buf_seek(&b, charstrings); info->charstrings = stbtt__cff_get_index(&b); } t = stbtt__find_table(data, fontstart, "maxp"); if (t) info->numGlyphs = ttUSHORT(data+t+4); else info->numGlyphs = 0xffff; // find a cmap encoding table we understand *now* to avoid searching // later. (todo: could make this installable) // the same regardless of glyph. numTables = ttUSHORT(data + cmap + 2); info->index_map = 0; for (i=0; i < numTables; ++i) { stbtt_uint32 encoding_record = cmap + 4 + 8 * i; // find an encoding we understand: switch(ttUSHORT(data+encoding_record)) { case STBTT_PLATFORM_ID_MICROSOFT: switch (ttUSHORT(data+encoding_record+2)) { case STBTT_MS_EID_UNICODE_BMP: case STBTT_MS_EID_UNICODE_FULL: // MS/Unicode info->index_map = cmap + ttULONG(data+encoding_record+4); break; } break; case STBTT_PLATFORM_ID_UNICODE: // Mac/iOS has these // all the encodingIDs are unicode, so we don't bother to check it info->index_map = cmap + ttULONG(data+encoding_record+4); break; } } if (info->index_map == 0) return 0; info->indexToLocFormat = ttUSHORT(data+info->head + 50); return 1; } STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint) { stbtt_uint8 *data = info->data; stbtt_uint32 index_map = info->index_map; stbtt_uint16 format = ttUSHORT(data + index_map + 0); if (format == 0) { // apple byte encoding stbtt_int32 bytes = ttUSHORT(data + index_map + 2); if (unicode_codepoint < bytes-6) return ttBYTE(data + index_map + 6 + unicode_codepoint); return 0; } else if (format == 6) { stbtt_uint32 first = ttUSHORT(data + index_map + 6); stbtt_uint32 count = ttUSHORT(data + index_map + 8); if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count) return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2); return 0; } else if (format == 2) { STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean return 0; } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1; stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1; stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10); stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1; // do a binary search of the segments stbtt_uint32 endCount = index_map + 14; stbtt_uint32 search = endCount; if (unicode_codepoint > 0xffff) return 0; // they lie from endCount .. endCount + segCount // but searchRange is the nearest power of two, so... if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2)) search += rangeShift*2; // now decrement to bias correctly to find smallest search -= 2; while (entrySelector) { stbtt_uint16 end; searchRange >>= 1; end = ttUSHORT(data + search + searchRange*2); if (unicode_codepoint > end) search += searchRange*2; --entrySelector; } search += 2; { stbtt_uint16 offset, start; stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1); STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item)); start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item); if (unicode_codepoint < start) return 0; offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item); if (offset == 0) return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item)); return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item); } } else if (format == 12 || format == 13) { stbtt_uint32 ngroups = ttULONG(data+index_map+12); stbtt_int32 low,high; low = 0; high = (stbtt_int32)ngroups; // Binary search the right group. while (low < high) { stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12); stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4); if ((stbtt_uint32) unicode_codepoint < start_char) high = mid; else if ((stbtt_uint32) unicode_codepoint > end_char) low = mid+1; else { stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8); if (format == 12) return start_glyph + unicode_codepoint-start_char; else // format == 13 return start_glyph; } } return 0; // not found } // @TODO STBTT_assert(0); return 0; } STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices) { return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices); } static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy) { v->type = type; v->x = (stbtt_int16) x; v->y = (stbtt_int16) y; v->cx = (stbtt_int16) cx; v->cy = (stbtt_int16) cy; } static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) { int g1,g2; STBTT_assert(!info->cff.size); if (glyph_index >= info->numGlyphs) return -1; // glyph index out of range if (info->indexToLocFormat >= 2) return -1; // unknown index->glyph map format if (info->indexToLocFormat == 0) { g1 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2) * 2; g2 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2; } else { g1 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4); g2 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4 + 4); } return g1==g2 ? -1 : g1; // if length is 0, return -1 } static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) { if (info->cff.size) { stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1); } else { int g = stbtt__GetGlyfOffset(info, glyph_index); if (g < 0) return 0; if (x0) *x0 = ttSHORT(info->data + g + 2); if (y0) *y0 = ttSHORT(info->data + g + 4); if (x1) *x1 = ttSHORT(info->data + g + 6); if (y1) *y1 = ttSHORT(info->data + g + 8); } return 1; } STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1) { return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1); } STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) { stbtt_int16 numberOfContours; int g; if (info->cff.size) return stbtt__GetGlyphInfoT2(info, glyph_index, NULL, NULL, NULL, NULL) == 0; g = stbtt__GetGlyfOffset(info, glyph_index); if (g < 0) return 1; numberOfContours = ttSHORT(info->data + g); return numberOfContours == 0; } static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off, stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy) { if (start_off) { if (was_off) stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy); stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, sx,sy,scx,scy); } else { if (was_off) stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve,sx,sy,cx,cy); else stbtt_setvertex(&vertices[num_vertices++], STBTT_vline,sx,sy,0,0); } return num_vertices; } static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) { stbtt_int16 numberOfContours; stbtt_uint8 *endPtsOfContours; stbtt_uint8 *data = info->data; stbtt_vertex *vertices=0; int num_vertices=0; int g = stbtt__GetGlyfOffset(info, glyph_index); *pvertices = NULL; if (g < 0) return 0; numberOfContours = ttSHORT(data + g); if (numberOfContours > 0) { stbtt_uint8 flags=0,flagcount; stbtt_int32 ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0; stbtt_int32 x,y,cx,cy,sx,sy, scx,scy; stbtt_uint8 *points; endPtsOfContours = (data + g + 10); ins = ttUSHORT(data + g + 10 + numberOfContours * 2); points = data + g + 10 + numberOfContours * 2 + 2 + ins; n = 1+ttUSHORT(endPtsOfContours + numberOfContours*2-2); m = n + 2*numberOfContours; // a loose bound on how many vertices we might need vertices = (stbtt_vertex *) STBTT_malloc(m * sizeof(vertices[0]), info->userdata); if (vertices == 0) return 0; next_move = 0; flagcount=0; // in first pass, we load uninterpreted data into the allocated array // above, shifted to the end of the array so we won't overwrite it when // we create our final data starting from the front off = m - n; // starting offset for uninterpreted data, regardless of how m ends up being calculated // first load flags for (i=0; i < n; ++i) { if (flagcount == 0) { flags = *points++; if (flags & 8) flagcount = *points++; } else --flagcount; vertices[off+i].type = flags; } // now load x coordinates x=0; for (i=0; i < n; ++i) { flags = vertices[off+i].type; if (flags & 2) { stbtt_int16 dx = *points++; x += (flags & 16) ? dx : -dx; // ??? } else { if (!(flags & 16)) { x = x + (stbtt_int16) (points[0]*256 + points[1]); points += 2; } } vertices[off+i].x = (stbtt_int16) x; } // now load y coordinates y=0; for (i=0; i < n; ++i) { flags = vertices[off+i].type; if (flags & 4) { stbtt_int16 dy = *points++; y += (flags & 32) ? dy : -dy; // ??? } else { if (!(flags & 32)) { y = y + (stbtt_int16) (points[0]*256 + points[1]); points += 2; } } vertices[off+i].y = (stbtt_int16) y; } // now convert them to our format num_vertices=0; sx = sy = cx = cy = scx = scy = 0; for (i=0; i < n; ++i) { flags = vertices[off+i].type; x = (stbtt_int16) vertices[off+i].x; y = (stbtt_int16) vertices[off+i].y; if (next_move == i) { if (i != 0) num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); // now start the new one start_off = !(flags & 1); if (start_off) { // if we start off with an off-curve point, then when we need to find a point on the curve // where we can start, and we need to save some state for when we wraparound. scx = x; scy = y; if (!(vertices[off+i+1].type & 1)) { // next point is also a curve point, so interpolate an on-point curve sx = (x + (stbtt_int32) vertices[off+i+1].x) >> 1; sy = (y + (stbtt_int32) vertices[off+i+1].y) >> 1; } else { // otherwise just use the next point as our start point sx = (stbtt_int32) vertices[off+i+1].x; sy = (stbtt_int32) vertices[off+i+1].y; ++i; // we're using point i+1 as the starting point, so skip it } } else { sx = x; sy = y; } stbtt_setvertex(&vertices[num_vertices++], STBTT_vmove,sx,sy,0,0); was_off = 0; next_move = 1 + ttUSHORT(endPtsOfContours+j*2); ++j; } else { if (!(flags & 1)) { // if it's a curve if (was_off) // two off-curve control points in a row means interpolate an on-curve midpoint stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy); cx = x; cy = y; was_off = 1; } else { if (was_off) stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, x,y, cx, cy); else stbtt_setvertex(&vertices[num_vertices++], STBTT_vline, x,y,0,0); was_off = 0; } } } num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); } else if (numberOfContours == -1) { // Compound shapes. int more = 1; stbtt_uint8 *comp = data + g + 10; num_vertices = 0; vertices = 0; while (more) { stbtt_uint16 flags, gidx; int comp_num_verts = 0, i; stbtt_vertex *comp_verts = 0, *tmp = 0; float mtx[6] = {1,0,0,1,0,0}, m, n; flags = ttSHORT(comp); comp+=2; gidx = ttSHORT(comp); comp+=2; if (flags & 2) { // XY values if (flags & 1) { // shorts mtx[4] = ttSHORT(comp); comp+=2; mtx[5] = ttSHORT(comp); comp+=2; } else { mtx[4] = ttCHAR(comp); comp+=1; mtx[5] = ttCHAR(comp); comp+=1; } } else { // @TODO handle matching point STBTT_assert(0); } if (flags & (1<<3)) { // WE_HAVE_A_SCALE mtx[0] = mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; mtx[1] = mtx[2] = 0; } else if (flags & (1<<6)) { // WE_HAVE_AN_X_AND_YSCALE mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; mtx[1] = mtx[2] = 0; mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; } else if (flags & (1<<7)) { // WE_HAVE_A_TWO_BY_TWO mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; mtx[1] = ttSHORT(comp)/16384.0f; comp+=2; mtx[2] = ttSHORT(comp)/16384.0f; comp+=2; mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; } // Find transformation scales. m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]); n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]); // Get indexed glyph. comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts); if (comp_num_verts > 0) { // Transform vertices. for (i = 0; i < comp_num_verts; ++i) { stbtt_vertex* v = &comp_verts[i]; stbtt_vertex_type x,y; x=v->x; y=v->y; v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); x=v->cx; y=v->cy; v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); } // Append vertices. tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata); if (!tmp) { if (vertices) STBTT_free(vertices, info->userdata); if (comp_verts) STBTT_free(comp_verts, info->userdata); return 0; } if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex)); //-V595 STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex)); if (vertices) STBTT_free(vertices, info->userdata); vertices = tmp; STBTT_free(comp_verts, info->userdata); num_vertices += comp_num_verts; } // More components ? more = flags & (1<<5); } } else if (numberOfContours < 0) { // @TODO other compound variations? STBTT_assert(0); } else { // numberOfCounters == 0, do nothing } *pvertices = vertices; return num_vertices; } typedef struct { int bounds; int started; float first_x, first_y; float x, y; stbtt_int32 min_x, max_x, min_y, max_y; stbtt_vertex *pvertices; int num_vertices; } stbtt__csctx; #define STBTT__CSCTX_INIT(bounds) {bounds,0, 0,0, 0,0, 0,0,0,0, NULL, 0} static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y) { if (x > c->max_x || !c->started) c->max_x = x; if (y > c->max_y || !c->started) c->max_y = y; if (x < c->min_x || !c->started) c->min_x = x; if (y < c->min_y || !c->started) c->min_y = y; c->started = 1; } static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1) { if (c->bounds) { stbtt__track_vertex(c, x, y); if (type == STBTT_vcubic) { stbtt__track_vertex(c, cx, cy); stbtt__track_vertex(c, cx1, cy1); } } else { stbtt_setvertex(&c->pvertices[c->num_vertices], type, x, y, cx, cy); c->pvertices[c->num_vertices].cx1 = (stbtt_int16) cx1; c->pvertices[c->num_vertices].cy1 = (stbtt_int16) cy1; } c->num_vertices++; } static void stbtt__csctx_close_shape(stbtt__csctx *ctx) { if (ctx->first_x != ctx->x || ctx->first_y != ctx->y) stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0); } static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy) { stbtt__csctx_close_shape(ctx); ctx->first_x = ctx->x = ctx->x + dx; ctx->first_y = ctx->y = ctx->y + dy; stbtt__csctx_v(ctx, STBTT_vmove, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); } static void stbtt__csctx_rline_to(stbtt__csctx *ctx, float dx, float dy) { ctx->x += dx; ctx->y += dy; stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); } static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3) { float cx1 = ctx->x + dx1; float cy1 = ctx->y + dy1; float cx2 = cx1 + dx2; float cy2 = cy1 + dy2; ctx->x = cx2 + dx3; ctx->y = cy2 + dy3; stbtt__csctx_v(ctx, STBTT_vcubic, (int)ctx->x, (int)ctx->y, (int)cx1, (int)cy1, (int)cx2, (int)cy2); } static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n) { int count = stbtt__cff_index_count(&idx); int bias = 107; if (count >= 33900) bias = 32768; else if (count >= 1240) bias = 1131; n += bias; if (n < 0 || n >= count) return stbtt__new_buf(NULL, 0); return stbtt__cff_index_get(idx, n); } static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int glyph_index) { stbtt__buf fdselect = info->fdselect; int nranges, start, end, v, fmt, fdselector = -1, i; stbtt__buf_seek(&fdselect, 0); fmt = stbtt__buf_get8(&fdselect); if (fmt == 0) { // untested stbtt__buf_skip(&fdselect, glyph_index); fdselector = stbtt__buf_get8(&fdselect); } else if (fmt == 3) { nranges = stbtt__buf_get16(&fdselect); start = stbtt__buf_get16(&fdselect); for (i = 0; i < nranges; i++) { v = stbtt__buf_get8(&fdselect); end = stbtt__buf_get16(&fdselect); if (glyph_index >= start && glyph_index < end) { fdselector = v; break; } start = end; } } if (fdselector == -1) stbtt__new_buf(NULL, 0); return stbtt__get_subrs(info->cff, stbtt__cff_index_get(info->fontdicts, fdselector)); } static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, stbtt__csctx *c) { int in_header = 1, maskbits = 0, subr_stack_height = 0, sp = 0, v, i, b0; int has_subrs = 0, clear_stack; float s[48]; stbtt__buf subr_stack[10], subrs = info->subrs, b; float f; #define STBTT__CSERR(s) (0) // this currently ignores the initial width value, which isn't needed if we have hmtx b = stbtt__cff_index_get(info->charstrings, glyph_index); while (b.cursor < b.size) { i = 0; clear_stack = 1; b0 = stbtt__buf_get8(&b); switch (b0) { // @TODO implement hinting case 0x13: // hintmask case 0x14: // cntrmask if (in_header) maskbits += (sp / 2); // implicit "vstem" in_header = 0; stbtt__buf_skip(&b, (maskbits + 7) / 8); break; case 0x01: // hstem case 0x03: // vstem case 0x12: // hstemhm case 0x17: // vstemhm maskbits += (sp / 2); break; case 0x15: // rmoveto in_header = 0; if (sp < 2) return STBTT__CSERR("rmoveto stack"); stbtt__csctx_rmove_to(c, s[sp-2], s[sp-1]); break; case 0x04: // vmoveto in_header = 0; if (sp < 1) return STBTT__CSERR("vmoveto stack"); stbtt__csctx_rmove_to(c, 0, s[sp-1]); break; case 0x16: // hmoveto in_header = 0; if (sp < 1) return STBTT__CSERR("hmoveto stack"); stbtt__csctx_rmove_to(c, s[sp-1], 0); break; case 0x05: // rlineto if (sp < 2) return STBTT__CSERR("rlineto stack"); for (; i + 1 < sp; i += 2) stbtt__csctx_rline_to(c, s[i], s[i+1]); break; // hlineto/vlineto and vhcurveto/hvcurveto alternate horizontal and vertical // starting from a different place. case 0x07: // vlineto if (sp < 1) return STBTT__CSERR("vlineto stack"); goto vlineto; case 0x06: // hlineto if (sp < 1) return STBTT__CSERR("hlineto stack"); for (;;) { if (i >= sp) break; stbtt__csctx_rline_to(c, s[i], 0); i++; vlineto: if (i >= sp) break; stbtt__csctx_rline_to(c, 0, s[i]); i++; } break; case 0x1F: // hvcurveto if (sp < 4) return STBTT__CSERR("hvcurveto stack"); goto hvcurveto; case 0x1E: // vhcurveto if (sp < 4) return STBTT__CSERR("vhcurveto stack"); for (;;) { if (i + 3 >= sp) break; stbtt__csctx_rccurve_to(c, 0, s[i], s[i+1], s[i+2], s[i+3], (sp - i == 5) ? s[i + 4] : 0.0f); i += 4; hvcurveto: if (i + 3 >= sp) break; stbtt__csctx_rccurve_to(c, s[i], 0, s[i+1], s[i+2], (sp - i == 5) ? s[i+4] : 0.0f, s[i+3]); i += 4; } break; case 0x08: // rrcurveto if (sp < 6) return STBTT__CSERR("rcurveline stack"); for (; i + 5 < sp; i += 6) stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); break; case 0x18: // rcurveline if (sp < 8) return STBTT__CSERR("rcurveline stack"); for (; i + 5 < sp - 2; i += 6) stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); if (i + 1 >= sp) return STBTT__CSERR("rcurveline stack"); stbtt__csctx_rline_to(c, s[i], s[i+1]); break; case 0x19: // rlinecurve if (sp < 8) return STBTT__CSERR("rlinecurve stack"); for (; i + 1 < sp - 6; i += 2) stbtt__csctx_rline_to(c, s[i], s[i+1]); if (i + 5 >= sp) return STBTT__CSERR("rlinecurve stack"); stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); break; case 0x1A: // vvcurveto case 0x1B: // hhcurveto if (sp < 4) return STBTT__CSERR("(vv|hh)curveto stack"); f = 0.0; if (sp & 1) { f = s[i]; i++; } for (; i + 3 < sp; i += 4) { if (b0 == 0x1B) stbtt__csctx_rccurve_to(c, s[i], f, s[i+1], s[i+2], s[i+3], 0.0); else stbtt__csctx_rccurve_to(c, f, s[i], s[i+1], s[i+2], 0.0, s[i+3]); f = 0.0; } break; case 0x0A: // callsubr if (!has_subrs) { if (info->fdselect.size) subrs = stbtt__cid_get_glyph_subrs(info, glyph_index); has_subrs = 1; } // fallthrough case 0x1D: // callgsubr if (sp < 1) return STBTT__CSERR("call(g|)subr stack"); v = (int) s[--sp]; if (subr_stack_height >= 10) return STBTT__CSERR("recursion limit"); subr_stack[subr_stack_height++] = b; b = stbtt__get_subr(b0 == 0x0A ? subrs : info->gsubrs, v); if (b.size == 0) return STBTT__CSERR("subr not found"); b.cursor = 0; clear_stack = 0; break; case 0x0B: // return if (subr_stack_height <= 0) return STBTT__CSERR("return outside subr"); b = subr_stack[--subr_stack_height]; clear_stack = 0; break; case 0x0E: // endchar stbtt__csctx_close_shape(c); return 1; case 0x0C: { // two-byte escape float dx1, dx2, dx3, dx4, dx5, dx6, dy1, dy2, dy3, dy4, dy5, dy6; float dx, dy; int b1 = stbtt__buf_get8(&b); switch (b1) { // @TODO These "flex" implementations ignore the flex-depth and resolution, // and always draw beziers. case 0x22: // hflex if (sp < 7) return STBTT__CSERR("hflex stack"); dx1 = s[0]; dx2 = s[1]; dy2 = s[2]; dx3 = s[3]; dx4 = s[4]; dx5 = s[5]; dx6 = s[6]; stbtt__csctx_rccurve_to(c, dx1, 0, dx2, dy2, dx3, 0); stbtt__csctx_rccurve_to(c, dx4, 0, dx5, -dy2, dx6, 0); break; case 0x23: // flex if (sp < 13) return STBTT__CSERR("flex stack"); dx1 = s[0]; dy1 = s[1]; dx2 = s[2]; dy2 = s[3]; dx3 = s[4]; dy3 = s[5]; dx4 = s[6]; dy4 = s[7]; dx5 = s[8]; dy5 = s[9]; dx6 = s[10]; dy6 = s[11]; //fd is s[12] stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); break; case 0x24: // hflex1 if (sp < 9) return STBTT__CSERR("hflex1 stack"); dx1 = s[0]; dy1 = s[1]; dx2 = s[2]; dy2 = s[3]; dx3 = s[4]; dx4 = s[5]; dx5 = s[6]; dy5 = s[7]; dx6 = s[8]; stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, 0); stbtt__csctx_rccurve_to(c, dx4, 0, dx5, dy5, dx6, -(dy1+dy2+dy5)); break; case 0x25: // flex1 if (sp < 11) return STBTT__CSERR("flex1 stack"); dx1 = s[0]; dy1 = s[1]; dx2 = s[2]; dy2 = s[3]; dx3 = s[4]; dy3 = s[5]; dx4 = s[6]; dy4 = s[7]; dx5 = s[8]; dy5 = s[9]; dx6 = dy6 = s[10]; dx = dx1+dx2+dx3+dx4+dx5; dy = dy1+dy2+dy3+dy4+dy5; if (STBTT_fabs(dx) > STBTT_fabs(dy)) dy6 = -dy; else dx6 = -dx; stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); break; default: return STBTT__CSERR("unimplemented"); } } break; default: if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254)) //-V560 return STBTT__CSERR("reserved operator"); // push immediate if (b0 == 255) { f = (float)(stbtt_int32)stbtt__buf_get32(&b) / 0x10000; } else { stbtt__buf_skip(&b, -1); f = (float)(stbtt_int16)stbtt__cff_int(&b); } if (sp >= 48) return STBTT__CSERR("push stack overflow"); s[sp++] = f; clear_stack = 0; break; } if (clear_stack) sp = 0; } return STBTT__CSERR("no endchar"); #undef STBTT__CSERR } static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) { // runs the charstring twice, once to count and once to output (to avoid realloc) stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1); stbtt__csctx output_ctx = STBTT__CSCTX_INIT(0); if (stbtt__run_charstring(info, glyph_index, &count_ctx)) { *pvertices = (stbtt_vertex*)STBTT_malloc(count_ctx.num_vertices*sizeof(stbtt_vertex), info->userdata); output_ctx.pvertices = *pvertices; if (stbtt__run_charstring(info, glyph_index, &output_ctx)) { STBTT_assert(output_ctx.num_vertices == count_ctx.num_vertices); return output_ctx.num_vertices; } } *pvertices = NULL; return 0; } static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) { stbtt__csctx c = STBTT__CSCTX_INIT(1); int r = stbtt__run_charstring(info, glyph_index, &c); if (x0) *x0 = r ? c.min_x : 0; if (y0) *y0 = r ? c.min_y : 0; if (x1) *x1 = r ? c.max_x : 0; if (y1) *y1 = r ? c.max_y : 0; return r ? c.num_vertices : 0; } STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) { if (!info->cff.size) return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices); else return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices); } STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing) { stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34); if (glyph_index < numOfLongHorMetrics) { if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*glyph_index); if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*glyph_index + 2); } else { if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1)); if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics)); } } static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) { stbtt_uint8 *data = info->data + info->kern; stbtt_uint32 needle, straw; int l, r, m; // we only look at the first table. it must be 'horizontal' and format 0. if (!info->kern) return 0; if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 return 0; if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format return 0; l = 0; r = ttUSHORT(data+10) - 1; needle = glyph1 << 16 | glyph2; while (l <= r) { m = (l + r) >> 1; straw = ttULONG(data+18+(m*6)); // note: unaligned read if (needle < straw) r = m - 1; else if (needle > straw) l = m + 1; else return ttSHORT(data+22+(m*6)); } return 0; } static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph) { stbtt_uint16 coverageFormat = ttUSHORT(coverageTable); switch(coverageFormat) { case 1: { stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2); // Binary search. stbtt_int32 l=0, r=glyphCount-1, m; int straw, needle=glyph; while (l <= r) { stbtt_uint8 *glyphArray = coverageTable + 4; stbtt_uint16 glyphID; m = (l + r) >> 1; glyphID = ttUSHORT(glyphArray + 2 * m); straw = glyphID; if (needle < straw) r = m - 1; else if (needle > straw) l = m + 1; else { return m; } } } break; case 2: { stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2); stbtt_uint8 *rangeArray = coverageTable + 4; // Binary search. stbtt_int32 l=0, r=rangeCount-1, m; int strawStart, strawEnd, needle=glyph; while (l <= r) { stbtt_uint8 *rangeRecord; m = (l + r) >> 1; rangeRecord = rangeArray + 6 * m; strawStart = ttUSHORT(rangeRecord); strawEnd = ttUSHORT(rangeRecord + 2); if (needle < strawStart) r = m - 1; else if (needle > strawEnd) l = m + 1; else { stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4); return startCoverageIndex + glyph - strawStart; } } } break; default: { // There are no other cases. STBTT_assert(0); } break; } return -1; } static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph) { stbtt_uint16 classDefFormat = ttUSHORT(classDefTable); switch(classDefFormat) { case 1: { stbtt_uint16 startGlyphID = ttUSHORT(classDefTable + 2); stbtt_uint16 glyphCount = ttUSHORT(classDefTable + 4); stbtt_uint8 *classDef1ValueArray = classDefTable + 6; if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount) return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID)); // [DEAR IMGUI] Commented to fix static analyzer warning //classDefTable = classDef1ValueArray + 2 * glyphCount; } break; case 2: { stbtt_uint16 classRangeCount = ttUSHORT(classDefTable + 2); stbtt_uint8 *classRangeRecords = classDefTable + 4; // Binary search. stbtt_int32 l=0, r=classRangeCount-1, m; int strawStart, strawEnd, needle=glyph; while (l <= r) { stbtt_uint8 *classRangeRecord; m = (l + r) >> 1; classRangeRecord = classRangeRecords + 6 * m; strawStart = ttUSHORT(classRangeRecord); strawEnd = ttUSHORT(classRangeRecord + 2); if (needle < strawStart) r = m - 1; else if (needle > strawEnd) l = m + 1; else return (stbtt_int32)ttUSHORT(classRangeRecord + 4); } // [DEAR IMGUI] Commented to fix static analyzer warning //classDefTable = classRangeRecords + 6 * classRangeCount; } break; default: { // There are no other cases. STBTT_assert(0); } break; } return -1; } // Define to STBTT_assert(x) if you want to break on unimplemented formats. #define STBTT_GPOS_TODO_assert(x) static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) { stbtt_uint16 lookupListOffset; stbtt_uint8 *lookupList; stbtt_uint16 lookupCount; stbtt_uint8 *data; stbtt_int32 i; if (!info->gpos) return 0; data = info->data + info->gpos; if (ttUSHORT(data+0) != 1) return 0; // Major version 1 if (ttUSHORT(data+2) != 0) return 0; // Minor version 0 lookupListOffset = ttUSHORT(data+8); lookupList = data + lookupListOffset; lookupCount = ttUSHORT(lookupList); for (i=0; i> 1; pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m; secondGlyph = ttUSHORT(pairValue); straw = secondGlyph; if (needle < straw) r = m - 1; else if (needle > straw) l = m + 1; else { stbtt_int16 xAdvance = ttSHORT(pairValue + 2); return xAdvance; } } } break; case 2: { stbtt_uint16 valueFormat1 = ttUSHORT(table + 4); stbtt_uint16 valueFormat2 = ttUSHORT(table + 6); stbtt_uint16 classDef1Offset = ttUSHORT(table + 8); stbtt_uint16 classDef2Offset = ttUSHORT(table + 10); int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1); int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2); stbtt_uint16 class1Count = ttUSHORT(table + 12); stbtt_uint16 class2Count = ttUSHORT(table + 14); STBTT_assert(glyph1class < class1Count); STBTT_assert(glyph2class < class2Count); // TODO: Support more formats. STBTT_GPOS_TODO_assert(valueFormat1 == 4); if (valueFormat1 != 4) return 0; STBTT_GPOS_TODO_assert(valueFormat2 == 0); if (valueFormat2 != 0) return 0; if (glyph1class >= 0 && glyph1class < class1Count && glyph2class >= 0 && glyph2class < class2Count) { stbtt_uint8 *class1Records = table + 16; stbtt_uint8 *class2Records = class1Records + 2 * (glyph1class * class2Count); stbtt_int16 xAdvance = ttSHORT(class2Records + 2 * glyph2class); return xAdvance; } } break; default: { // There are no other cases. STBTT_assert(0); break; }; } } break; }; default: // TODO: Implement other stuff. break; } } return 0; } STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int g2) { int xAdvance = 0; if (info->gpos) xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2); if (info->kern) xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2); return xAdvance; } STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2) { if (!info->kern && !info->gpos) // if no kerning table, don't waste time looking up both codepoint->glyphs return 0; return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2)); } STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing) { stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing); } STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap) { if (ascent ) *ascent = ttSHORT(info->data+info->hhea + 4); if (descent) *descent = ttSHORT(info->data+info->hhea + 6); if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8); } STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap) { int tab = stbtt__find_table(info->data, info->fontstart, "OS/2"); if (!tab) return 0; if (typoAscent ) *typoAscent = ttSHORT(info->data+tab + 68); if (typoDescent) *typoDescent = ttSHORT(info->data+tab + 70); if (typoLineGap) *typoLineGap = ttSHORT(info->data+tab + 72); return 1; } STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1) { *x0 = ttSHORT(info->data + info->head + 36); *y0 = ttSHORT(info->data + info->head + 38); *x1 = ttSHORT(info->data + info->head + 40); *y1 = ttSHORT(info->data + info->head + 42); } STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height) { int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6); return (float) height / fheight; } STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels) { int unitsPerEm = ttUSHORT(info->data + info->head + 18); return pixels / unitsPerEm; } STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v) { STBTT_free(v, info->userdata); } ////////////////////////////////////////////////////////////////////////////// // // antialiasing software rasterizer // STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) { int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) { // e.g. space character if (ix0) *ix0 = 0; if (iy0) *iy0 = 0; if (ix1) *ix1 = 0; if (iy1) *iy1 = 0; } else { // move to integral bboxes (treating pixels as little squares, what pixels get touched)? if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x); if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y); if (ix1) *ix1 = STBTT_iceil ( x1 * scale_x + shift_x); if (iy1) *iy1 = STBTT_iceil (-y0 * scale_y + shift_y); } } STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) { stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1); } STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) { stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1); } STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) { stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1); } ////////////////////////////////////////////////////////////////////////////// // // Rasterizer typedef struct stbtt__hheap_chunk { struct stbtt__hheap_chunk *next; } stbtt__hheap_chunk; typedef struct stbtt__hheap { struct stbtt__hheap_chunk *head; void *first_free; int num_remaining_in_head_chunk; } stbtt__hheap; static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata) { if (hh->first_free) { void *p = hh->first_free; hh->first_free = * (void **) p; return p; } else { if (hh->num_remaining_in_head_chunk == 0) { int count = (size < 32 ? 2000 : size < 128 ? 800 : 100); stbtt__hheap_chunk *c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata); if (c == NULL) return NULL; c->next = hh->head; hh->head = c; hh->num_remaining_in_head_chunk = count; } --hh->num_remaining_in_head_chunk; return (char *) (hh->head) + sizeof(stbtt__hheap_chunk) + size * hh->num_remaining_in_head_chunk; } } static void stbtt__hheap_free(stbtt__hheap *hh, void *p) { *(void **) p = hh->first_free; hh->first_free = p; } static void stbtt__hheap_cleanup(stbtt__hheap *hh, void *userdata) { stbtt__hheap_chunk *c = hh->head; while (c) { stbtt__hheap_chunk *n = c->next; STBTT_free(c, userdata); c = n; } } typedef struct stbtt__edge { float x0,y0, x1,y1; int invert; } stbtt__edge; typedef struct stbtt__active_edge { struct stbtt__active_edge *next; #if STBTT_RASTERIZER_VERSION==1 int x,dx; float ey; int direction; #elif STBTT_RASTERIZER_VERSION==2 float fx,fdx,fdy; float direction; float sy; float ey; #else #error "Unrecognized value of STBTT_RASTERIZER_VERSION" #endif } stbtt__active_edge; #if STBTT_RASTERIZER_VERSION == 1 #define STBTT_FIXSHIFT 10 #define STBTT_FIX (1 << STBTT_FIXSHIFT) #define STBTT_FIXMASK (STBTT_FIX-1) static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) { stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); STBTT_assert(z != NULL); if (!z) return z; // round dx down to avoid overshooting if (dxdy < 0) z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy); else z->dx = STBTT_ifloor(STBTT_FIX * dxdy); z->x = STBTT_ifloor(STBTT_FIX * e->x0 + z->dx * (start_point - e->y0)); // use z->dx so when we offset later it's by the same amount z->x -= off_x * STBTT_FIX; z->ey = e->y1; z->next = 0; z->direction = e->invert ? 1 : -1; return z; } #elif STBTT_RASTERIZER_VERSION == 2 static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) { stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); STBTT_assert(z != NULL); //STBTT_assert(e->y0 <= start_point); if (!z) return z; z->fdx = dxdy; z->fdy = dxdy != 0.0f ? (1.0f/dxdy) : 0.0f; z->fx = e->x0 + dxdy * (start_point - e->y0); z->fx -= off_x; z->direction = e->invert ? 1.0f : -1.0f; z->sy = e->y0; z->ey = e->y1; z->next = 0; return z; } #else #error "Unrecognized value of STBTT_RASTERIZER_VERSION" #endif #if STBTT_RASTERIZER_VERSION == 1 // note: this routine clips fills that extend off the edges... ideally this // wouldn't happen, but it could happen if the truetype glyph bounding boxes // are wrong, or if the user supplies a too-small bitmap static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__active_edge *e, int max_weight) { // non-zero winding fill int x0=0, w=0; while (e) { if (w == 0) { // if we're currently at zero, we need to record the edge start point x0 = e->x; w += e->direction; } else { int x1 = e->x; w += e->direction; // if we went to zero, we need to draw if (w == 0) { int i = x0 >> STBTT_FIXSHIFT; int j = x1 >> STBTT_FIXSHIFT; if (i < len && j >= 0) { if (i == j) { // x0,x1 are the same pixel, so compute combined coverage scanline[i] = scanline[i] + (stbtt_uint8) ((x1 - x0) * max_weight >> STBTT_FIXSHIFT); } else { if (i >= 0) // add antialiasing for x0 scanline[i] = scanline[i] + (stbtt_uint8) (((STBTT_FIX - (x0 & STBTT_FIXMASK)) * max_weight) >> STBTT_FIXSHIFT); else i = -1; // clip if (j < len) // add antialiasing for x1 scanline[j] = scanline[j] + (stbtt_uint8) (((x1 & STBTT_FIXMASK) * max_weight) >> STBTT_FIXSHIFT); else j = len; // clip for (++i; i < j; ++i) // fill pixels between x0 and x1 scanline[i] = scanline[i] + (stbtt_uint8) max_weight; } } } } e = e->next; } } static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) { stbtt__hheap hh = { 0, 0, 0 }; stbtt__active_edge *active = NULL; int y,j=0; int max_weight = (255 / vsubsample); // weight per vertical scanline int s; // vertical subsample index unsigned char scanline_data[512], *scanline; if (result->w > 512) scanline = (unsigned char *) STBTT_malloc(result->w, userdata); else scanline = scanline_data; y = off_y * vsubsample; e[n].y0 = (off_y + result->h) * (float) vsubsample + 1; while (j < result->h) { STBTT_memset(scanline, 0, result->w); for (s=0; s < vsubsample; ++s) { // find center of pixel for this scanline float scan_y = y + 0.5f; stbtt__active_edge **step = &active; // update all active edges; // remove all active edges that terminate before the center of this scanline while (*step) { stbtt__active_edge * z = *step; if (z->ey <= scan_y) { *step = z->next; // delete from list STBTT_assert(z->direction); z->direction = 0; stbtt__hheap_free(&hh, z); } else { z->x += z->dx; // advance to position for current scanline step = &((*step)->next); // advance through list } } // resort the list if needed for(;;) { int changed=0; step = &active; while (*step && (*step)->next) { if ((*step)->x > (*step)->next->x) { stbtt__active_edge *t = *step; stbtt__active_edge *q = t->next; t->next = q->next; q->next = t; *step = q; changed = 1; } step = &(*step)->next; } if (!changed) break; } // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline while (e->y0 <= scan_y) { if (e->y1 > scan_y) { stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y, userdata); if (z != NULL) { // find insertion point if (active == NULL) active = z; else if (z->x < active->x) { // insert at front z->next = active; active = z; } else { // find thing to insert AFTER stbtt__active_edge *p = active; while (p->next && p->next->x < z->x) p = p->next; // at this point, p->next->x is NOT < z->x z->next = p->next; p->next = z; } } } ++e; } // now process all active edges in XOR fashion if (active) stbtt__fill_active_edges(scanline, result->w, active, max_weight); ++y; } STBTT_memcpy(result->pixels + j * result->stride, scanline, result->w); ++j; } stbtt__hheap_cleanup(&hh, userdata); if (scanline != scanline_data) STBTT_free(scanline, userdata); } #elif STBTT_RASTERIZER_VERSION == 2 // the edge passed in here does not cross the vertical line at x or the vertical line at x+1 // (i.e. it has already been clipped to those) static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1) { if (y0 == y1) return; STBTT_assert(y0 < y1); STBTT_assert(e->sy <= e->ey); if (y0 > e->ey) return; if (y1 < e->sy) return; if (y0 < e->sy) { x0 += (x1-x0) * (e->sy - y0) / (y1-y0); y0 = e->sy; } if (y1 > e->ey) { x1 += (x1-x0) * (e->ey - y1) / (y1-y0); y1 = e->ey; } if (x0 == x) STBTT_assert(x1 <= x+1); else if (x0 == x+1) STBTT_assert(x1 >= x); else if (x0 <= x) STBTT_assert(x1 <= x); else if (x0 >= x+1) STBTT_assert(x1 >= x+1); else STBTT_assert(x1 >= x && x1 <= x+1); if (x0 <= x && x1 <= x) scanline[x] += e->direction * (y1-y0); else if (x0 >= x+1 && x1 >= x+1) ; else { STBTT_assert(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1); scanline[x] += e->direction * (y1-y0) * (1-((x0-x)+(x1-x))/2); // coverage = 1 - average x position } } static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, int len, stbtt__active_edge *e, float y_top) { float y_bottom = y_top+1; while (e) { // brute force every pixel // compute intersection points with top & bottom STBTT_assert(e->ey >= y_top); if (e->fdx == 0) { float x0 = e->fx; if (x0 < len) { if (x0 >= 0) { stbtt__handle_clipped_edge(scanline,(int) x0,e, x0,y_top, x0,y_bottom); stbtt__handle_clipped_edge(scanline_fill-1,(int) x0+1,e, x0,y_top, x0,y_bottom); } else { stbtt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom); } } } else { float x0 = e->fx; float dx = e->fdx; float xb = x0 + dx; float x_top, x_bottom; float sy0,sy1; float dy = e->fdy; STBTT_assert(e->sy <= y_bottom && e->ey >= y_top); // compute endpoints of line segment clipped to this scanline (if the // line segment starts on this scanline. x0 is the intersection of the // line with y_top, but that may be off the line segment. if (e->sy > y_top) { x_top = x0 + dx * (e->sy - y_top); sy0 = e->sy; } else { x_top = x0; sy0 = y_top; } if (e->ey < y_bottom) { x_bottom = x0 + dx * (e->ey - y_top); sy1 = e->ey; } else { x_bottom = xb; sy1 = y_bottom; } if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) { // from here on, we don't have to range check x values if ((int) x_top == (int) x_bottom) { float height; // simple case, only spans one pixel int x = (int) x_top; height = sy1 - sy0; STBTT_assert(x >= 0 && x < len); scanline[x] += e->direction * (1-((x_top - x) + (x_bottom-x))/2) * height; scanline_fill[x] += e->direction * height; // everything right of this pixel is filled } else { int x,x1,x2; float y_crossing, step, sign, area; // covers 2+ pixels if (x_top > x_bottom) { // flip scanline vertically; signed area is the same float t; sy0 = y_bottom - (sy0 - y_top); sy1 = y_bottom - (sy1 - y_top); t = sy0, sy0 = sy1, sy1 = t; t = x_bottom, x_bottom = x_top, x_top = t; dx = -dx; dy = -dy; t = x0, x0 = xb, xb = t; // [DEAR IMGUI] Fix static analyzer warning (void)dx; // [ImGui: fix static analyzer warning] } x1 = (int) x_top; x2 = (int) x_bottom; // compute intersection with y axis at x1+1 y_crossing = (x1+1 - x0) * dy + y_top; sign = e->direction; // area of the rectangle covered from y0..y_crossing area = sign * (y_crossing-sy0); // area of the triangle (x_top,y0), (x+1,y0), (x+1,y_crossing) scanline[x1] += area * (1-((x_top - x1)+(x1+1-x1))/2); step = sign * dy; for (x = x1+1; x < x2; ++x) { scanline[x] += area + step/2; area += step; } y_crossing += dy * (x2 - (x1+1)); STBTT_assert(STBTT_fabs(area) <= 1.01f); scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing); scanline_fill[x2] += sign * (sy1-sy0); } } else { // if edge goes outside of box we're drawing, we require // clipping logic. since this does not match the intended use // of this library, we use a different, very slow brute // force implementation int x; for (x=0; x < len; ++x) { // cases: // // there can be up to two intersections with the pixel. any intersection // with left or right edges can be handled by splitting into two (or three) // regions. intersections with top & bottom do not necessitate case-wise logic. // // the old way of doing this found the intersections with the left & right edges, // then used some simple logic to produce up to three segments in sorted order // from top-to-bottom. however, this had a problem: if an x edge was epsilon // across the x border, then the corresponding y position might not be distinct // from the other y segment, and it might ignored as an empty segment. to avoid // that, we need to explicitly produce segments based on x positions. // rename variables to clearly-defined pairs float y0 = y_top; float x1 = (float) (x); float x2 = (float) (x+1); float x3 = xb; float y3 = y_bottom; // x = e->x + e->dx * (y-y_top) // (y-y_top) = (x - e->x) / e->dx // y = (x - e->x) / e->dx + y_top float y1 = (x - x0) / dx + y_top; float y2 = (x+1 - x0) / dx + y_top; if (x0 < x1 && x3 > x2) { // three segments descending down-right stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x2,y2); stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); } else if (x3 < x1 && x0 > x2) { // three segments descending down-left stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x1,y1); stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); } else if (x0 < x1 && x3 > x1) { // two segments across x, down-right stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); } else if (x3 < x1 && x0 > x1) { // two segments across x, down-left stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); } else if (x0 < x2 && x3 > x2) { // two segments across x+1, down-right stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); } else if (x3 < x2 && x0 > x2) { // two segments across x+1, down-left stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); } else { // one segment stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x3,y3); } } } } e = e->next; } } // directly AA rasterize edges w/o supersampling static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) { stbtt__hheap hh = { 0, 0, 0 }; stbtt__active_edge *active = NULL; int y,j=0, i; float scanline_data[129], *scanline, *scanline2; STBTT__NOTUSED(vsubsample); if (result->w > 64) scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata); else scanline = scanline_data; scanline2 = scanline + result->w; y = off_y; e[n].y0 = (float) (off_y + result->h) + 1; while (j < result->h) { // find center of pixel for this scanline float scan_y_top = y + 0.0f; float scan_y_bottom = y + 1.0f; stbtt__active_edge **step = &active; STBTT_memset(scanline , 0, result->w*sizeof(scanline[0])); STBTT_memset(scanline2, 0, (result->w+1)*sizeof(scanline[0])); // update all active edges; // remove all active edges that terminate before the top of this scanline while (*step) { stbtt__active_edge * z = *step; if (z->ey <= scan_y_top) { *step = z->next; // delete from list STBTT_assert(z->direction); z->direction = 0; stbtt__hheap_free(&hh, z); } else { step = &((*step)->next); // advance through list } } // insert all edges that start before the bottom of this scanline while (e->y0 <= scan_y_bottom) { if (e->y0 != e->y1) { stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata); if (z != NULL) { if (j == 0 && off_y != 0) { if (z->ey < scan_y_top) { // this can happen due to subpixel positioning and some kind of fp rounding error i think z->ey = scan_y_top; } } STBTT_assert(z->ey >= scan_y_top); // if we get really unlucky a tiny bit of an edge can be out of bounds // insert at front z->next = active; active = z; } } ++e; } // now process all active edges if (active) stbtt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top); { float sum = 0; for (i=0; i < result->w; ++i) { float k; int m; sum += scanline2[i]; k = scanline[i] + sum; k = (float) STBTT_fabs(k)*255 + 0.5f; m = (int) k; if (m > 255) m = 255; result->pixels[j*result->stride + i] = (unsigned char) m; } } // advance all the edges step = &active; while (*step) { stbtt__active_edge *z = *step; z->fx += z->fdx; // advance to position for current scanline step = &((*step)->next); // advance through list } ++y; ++j; } stbtt__hheap_cleanup(&hh, userdata); if (scanline != scanline_data) STBTT_free(scanline, userdata); } #else #error "Unrecognized value of STBTT_RASTERIZER_VERSION" #endif #define STBTT__COMPARE(a,b) ((a)->y0 < (b)->y0) static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n) { int i,j; for (i=1; i < n; ++i) { stbtt__edge t = p[i], *a = &t; j = i; while (j > 0) { stbtt__edge *b = &p[j-1]; int c = STBTT__COMPARE(a,b); if (!c) break; p[j] = p[j-1]; --j; } if (i != j) p[j] = t; } } static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n) { /* threshold for transitioning to insertion sort */ while (n > 12) { stbtt__edge t; int c01,c12,c,m,i,j; /* compute median of three */ m = n >> 1; c01 = STBTT__COMPARE(&p[0],&p[m]); c12 = STBTT__COMPARE(&p[m],&p[n-1]); /* if 0 >= mid >= end, or 0 < mid < end, then use mid */ if (c01 != c12) { /* otherwise, we'll need to swap something else to middle */ int z; c = STBTT__COMPARE(&p[0],&p[n-1]); /* 0>mid && midn => n; 0 0 */ /* 0n: 0>n => 0; 0 n */ z = (c == c12) ? 0 : n-1; t = p[z]; p[z] = p[m]; p[m] = t; } /* now p[m] is the median-of-three */ /* swap it to the beginning so it won't move around */ t = p[0]; p[0] = p[m]; p[m] = t; /* partition loop */ i=1; j=n-1; for(;;) { /* handling of equality is crucial here */ /* for sentinels & efficiency with duplicates */ for (;;++i) { if (!STBTT__COMPARE(&p[i], &p[0])) break; } for (;;--j) { if (!STBTT__COMPARE(&p[0], &p[j])) break; } /* make sure we haven't crossed */ if (i >= j) break; t = p[i]; p[i] = p[j]; p[j] = t; ++i; --j; } /* recurse on smaller side, iterate on larger */ if (j < (n-i)) { stbtt__sort_edges_quicksort(p,j); p = p+i; n = n-i; } else { stbtt__sort_edges_quicksort(p+i, n-i); n = j; } } } static void stbtt__sort_edges(stbtt__edge *p, int n) { stbtt__sort_edges_quicksort(p, n); stbtt__sort_edges_ins_sort(p, n); } typedef struct { float x,y; } stbtt__point; static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert, void *userdata) { float y_scale_inv = invert ? -scale_y : scale_y; stbtt__edge *e; int n,i,j,k,m; #if STBTT_RASTERIZER_VERSION == 1 int vsubsample = result->h < 8 ? 15 : 5; #elif STBTT_RASTERIZER_VERSION == 2 int vsubsample = 1; #else #error "Unrecognized value of STBTT_RASTERIZER_VERSION" #endif // vsubsample should divide 255 evenly; otherwise we won't reach full opacity // now we have to blow out the windings into explicit edge lists n = 0; for (i=0; i < windings; ++i) n += wcount[i]; e = (stbtt__edge *) STBTT_malloc(sizeof(*e) * (n+1), userdata); // add an extra one as a sentinel if (e == 0) return; n = 0; m=0; for (i=0; i < windings; ++i) { stbtt__point *p = pts + m; m += wcount[i]; j = wcount[i]-1; for (k=0; k < wcount[i]; j=k++) { int a=k,b=j; // skip the edge if horizontal if (p[j].y == p[k].y) continue; // add edge from j to k to the list e[n].invert = 0; if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) { e[n].invert = 1; a=j,b=k; } e[n].x0 = p[a].x * scale_x + shift_x; e[n].y0 = (p[a].y * y_scale_inv + shift_y) * vsubsample; e[n].x1 = p[b].x * scale_x + shift_x; e[n].y1 = (p[b].y * y_scale_inv + shift_y) * vsubsample; ++n; } } // now sort the edges by their highest point (should snap to integer, and then by x) //STBTT_sort(e, n, sizeof(e[0]), stbtt__edge_compare); stbtt__sort_edges(e, n); // now, traverse the scanlines and find the intersections on each scanline, use xor winding rule stbtt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, userdata); STBTT_free(e, userdata); } static void stbtt__add_point(stbtt__point *points, int n, float x, float y) { if (!points) return; // during first pass, it's unallocated points[n].x = x; points[n].y = y; } // tessellate until threshold p is happy... @TODO warped to compensate for non-linear stretching static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n) { // midpoint float mx = (x0 + 2*x1 + x2)/4; float my = (y0 + 2*y1 + y2)/4; // versus directly drawn line float dx = (x0+x2)/2 - mx; float dy = (y0+y2)/2 - my; if (n > 16) // 65536 segments on one curve better be enough! return 1; if (dx*dx+dy*dy > objspace_flatness_squared) { // half-pixel error allowed... need to be smaller if AA stbtt__tesselate_curve(points, num_points, x0,y0, (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1); stbtt__tesselate_curve(points, num_points, mx,my, (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1); } else { stbtt__add_point(points, *num_points,x2,y2); *num_points = *num_points+1; } return 1; } static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n) { // @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough float dx0 = x1-x0; float dy0 = y1-y0; float dx1 = x2-x1; float dy1 = y2-y1; float dx2 = x3-x2; float dy2 = y3-y2; float dx = x3-x0; float dy = y3-y0; float longlen = (float) (STBTT_sqrt(dx0*dx0+dy0*dy0)+STBTT_sqrt(dx1*dx1+dy1*dy1)+STBTT_sqrt(dx2*dx2+dy2*dy2)); float shortlen = (float) STBTT_sqrt(dx*dx+dy*dy); float flatness_squared = longlen*longlen-shortlen*shortlen; if (n > 16) // 65536 segments on one curve better be enough! return; if (flatness_squared > objspace_flatness_squared) { float x01 = (x0+x1)/2; float y01 = (y0+y1)/2; float x12 = (x1+x2)/2; float y12 = (y1+y2)/2; float x23 = (x2+x3)/2; float y23 = (y2+y3)/2; float xa = (x01+x12)/2; float ya = (y01+y12)/2; float xb = (x12+x23)/2; float yb = (y12+y23)/2; float mx = (xa+xb)/2; float my = (ya+yb)/2; stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1); stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1); } else { stbtt__add_point(points, *num_points,x3,y3); *num_points = *num_points+1; } } // returns number of contours static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata) { stbtt__point *points=0; int num_points=0; float objspace_flatness_squared = objspace_flatness * objspace_flatness; int i,n=0,start=0, pass; // count how many "moves" there are to get the contour count for (i=0; i < num_verts; ++i) if (vertices[i].type == STBTT_vmove) ++n; *num_contours = n; if (n == 0) return 0; *contour_lengths = (int *) STBTT_malloc(sizeof(**contour_lengths) * n, userdata); if (*contour_lengths == 0) { *num_contours = 0; return 0; } // make two passes through the points so we don't need to realloc for (pass=0; pass < 2; ++pass) { float x=0,y=0; if (pass == 1) { points = (stbtt__point *) STBTT_malloc(num_points * sizeof(points[0]), userdata); if (points == NULL) goto error; } num_points = 0; n= -1; for (i=0; i < num_verts; ++i) { switch (vertices[i].type) { case STBTT_vmove: // start the next contour if (n >= 0) (*contour_lengths)[n] = num_points - start; ++n; start = num_points; x = vertices[i].x, y = vertices[i].y; stbtt__add_point(points, num_points++, x,y); break; case STBTT_vline: x = vertices[i].x, y = vertices[i].y; stbtt__add_point(points, num_points++, x, y); break; case STBTT_vcurve: stbtt__tesselate_curve(points, &num_points, x,y, vertices[i].cx, vertices[i].cy, vertices[i].x, vertices[i].y, objspace_flatness_squared, 0); x = vertices[i].x, y = vertices[i].y; break; case STBTT_vcubic: stbtt__tesselate_cubic(points, &num_points, x,y, vertices[i].cx, vertices[i].cy, vertices[i].cx1, vertices[i].cy1, vertices[i].x, vertices[i].y, objspace_flatness_squared, 0); x = vertices[i].x, y = vertices[i].y; break; } } (*contour_lengths)[n] = num_points - start; } return points; error: STBTT_free(points, userdata); STBTT_free(*contour_lengths, userdata); *contour_lengths = 0; *num_contours = 0; return NULL; } STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata) { float scale = scale_x > scale_y ? scale_y : scale_x; int winding_count = 0; int *winding_lengths = NULL; stbtt__point *windings = stbtt_FlattenCurves(vertices, num_verts, flatness_in_pixels / scale, &winding_lengths, &winding_count, userdata); if (windings) { stbtt__rasterize(result, windings, winding_lengths, winding_count, scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, userdata); STBTT_free(winding_lengths, userdata); STBTT_free(windings, userdata); } } STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata) { STBTT_free(bitmap, userdata); } STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff) { int ix0,iy0,ix1,iy1; stbtt__bitmap gbm; stbtt_vertex *vertices; int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); if (scale_x == 0) scale_x = scale_y; if (scale_y == 0) { if (scale_x == 0) { STBTT_free(vertices, info->userdata); return NULL; } scale_y = scale_x; } stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,&ix1,&iy1); // now we get the size gbm.w = (ix1 - ix0); gbm.h = (iy1 - iy0); gbm.pixels = NULL; // in case we error if (width ) *width = gbm.w; if (height) *height = gbm.h; if (xoff ) *xoff = ix0; if (yoff ) *yoff = iy0; if (gbm.w && gbm.h) { gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata); if (gbm.pixels) { gbm.stride = gbm.w; stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0, iy0, 1, info->userdata); } } STBTT_free(vertices, info->userdata); return gbm.pixels; } STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff); } STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph) { int ix0,iy0; stbtt_vertex *vertices; int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); stbtt__bitmap gbm; stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0); gbm.pixels = output; gbm.w = out_w; gbm.h = out_h; gbm.stride = out_stride; if (gbm.w && gbm.h) stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0,iy0, 1, info->userdata); STBTT_free(vertices, info->userdata); } STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph) { stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph); } STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff); } STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint) { stbtt_MakeGlyphBitmapSubpixelPrefilter(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, oversample_x, oversample_y, sub_x, sub_y, stbtt_FindGlyphIndex(info,codepoint)); } STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint) { stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint)); } STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff); } STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint) { stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint); } ////////////////////////////////////////////////////////////////////////////// // // bitmap baking // // This is SUPER-CRAPPY packing to keep source code small static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) float pixel_height, // height of font in pixels unsigned char *pixels, int pw, int ph, // bitmap to be filled in int first_char, int num_chars, // characters to bake stbtt_bakedchar *chardata) { float scale; int x,y,bottom_y, i; stbtt_fontinfo f; f.userdata = NULL; if (!stbtt_InitFont(&f, data, offset)) return -1; STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels x=y=1; bottom_y = 1; scale = stbtt_ScaleForPixelHeight(&f, pixel_height); for (i=0; i < num_chars; ++i) { int advance, lsb, x0,y0,x1,y1,gw,gh; int g = stbtt_FindGlyphIndex(&f, first_char + i); stbtt_GetGlyphHMetrics(&f, g, &advance, &lsb); stbtt_GetGlyphBitmapBox(&f, g, scale,scale, &x0,&y0,&x1,&y1); gw = x1-x0; gh = y1-y0; if (x + gw + 1 >= pw) y = bottom_y, x = 1; // advance to next row if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row return -i; STBTT_assert(x+gw < pw); STBTT_assert(y+gh < ph); stbtt_MakeGlyphBitmap(&f, pixels+x+y*pw, gw,gh,pw, scale,scale, g); chardata[i].x0 = (stbtt_int16) x; chardata[i].y0 = (stbtt_int16) y; chardata[i].x1 = (stbtt_int16) (x + gw); chardata[i].y1 = (stbtt_int16) (y + gh); chardata[i].xadvance = scale * advance; chardata[i].xoff = (float) x0; chardata[i].yoff = (float) y0; x = x + gw + 1; if (y+gh+1 > bottom_y) bottom_y = y+gh+1; } return bottom_y; } STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) { float d3d_bias = opengl_fillrule ? 0 : -0.5f; float ipw = 1.0f / pw, iph = 1.0f / ph; const stbtt_bakedchar *b = chardata + char_index; int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f); int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f); q->x0 = round_x + d3d_bias; q->y0 = round_y + d3d_bias; q->x1 = round_x + b->x1 - b->x0 + d3d_bias; q->y1 = round_y + b->y1 - b->y0 + d3d_bias; q->s0 = b->x0 * ipw; q->t0 = b->y0 * iph; q->s1 = b->x1 * ipw; q->t1 = b->y1 * iph; *xpos += b->xadvance; } ////////////////////////////////////////////////////////////////////////////// // // rectangle packing replacement routines if you don't have stb_rect_pack.h // #ifndef STB_RECT_PACK_VERSION typedef int stbrp_coord; //////////////////////////////////////////////////////////////////////////////////// // // // // // COMPILER WARNING ?!?!? // // // // // // if you get a compile warning due to these symbols being defined more than // // once, move #include "stb_rect_pack.h" before #include "stb_truetype.h" // // // //////////////////////////////////////////////////////////////////////////////////// typedef struct { int width,height; int x,y,bottom_y; } stbrp_context; typedef struct { unsigned char x; } stbrp_node; struct stbrp_rect { stbrp_coord x,y; int id,w,h,was_packed; }; static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes) { con->width = pw; con->height = ph; con->x = 0; con->y = 0; con->bottom_y = 0; STBTT__NOTUSED(nodes); STBTT__NOTUSED(num_nodes); } static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects) { int i; for (i=0; i < num_rects; ++i) { if (con->x + rects[i].w > con->width) { con->x = 0; con->y = con->bottom_y; } if (con->y + rects[i].h > con->height) break; rects[i].x = con->x; rects[i].y = con->y; rects[i].was_packed = 1; con->x += rects[i].w; if (con->y + rects[i].h > con->bottom_y) con->bottom_y = con->y + rects[i].h; } for ( ; i < num_rects; ++i) rects[i].was_packed = 0; } #endif ////////////////////////////////////////////////////////////////////////////// // // bitmap baking // // This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If // stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy. STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context) { stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context); int num_nodes = pw - padding; stbrp_node *nodes = (stbrp_node *) STBTT_malloc(sizeof(*nodes ) * num_nodes,alloc_context); if (context == NULL || nodes == NULL) { if (context != NULL) STBTT_free(context, alloc_context); if (nodes != NULL) STBTT_free(nodes , alloc_context); return 0; } spc->user_allocator_context = alloc_context; spc->width = pw; spc->height = ph; spc->pixels = pixels; spc->pack_info = context; spc->nodes = nodes; spc->padding = padding; spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw; spc->h_oversample = 1; spc->v_oversample = 1; spc->skip_missing = 0; stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes); if (pixels) STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels return 1; } STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc) { STBTT_free(spc->nodes , spc->user_allocator_context); STBTT_free(spc->pack_info, spc->user_allocator_context); } STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample) { STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE); STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE); if (h_oversample <= STBTT_MAX_OVERSAMPLE) spc->h_oversample = h_oversample; if (v_oversample <= STBTT_MAX_OVERSAMPLE) spc->v_oversample = v_oversample; } STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip) { spc->skip_missing = skip; } #define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1) static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) { unsigned char buffer[STBTT_MAX_OVERSAMPLE]; int safe_w = w - kernel_width; int j; STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze for (j=0; j < h; ++j) { int i; unsigned int total; STBTT_memset(buffer, 0, kernel_width); total = 0; // make kernel_width a constant in common cases so compiler can optimize out the divide switch (kernel_width) { case 2: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / 2); } break; case 3: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / 3); } break; case 4: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / 4); } break; case 5: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / 5); } break; default: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / kernel_width); } break; } for (; i < w; ++i) { STBTT_assert(pixels[i] == 0); total -= buffer[i & STBTT__OVER_MASK]; pixels[i] = (unsigned char) (total / kernel_width); } pixels += stride_in_bytes; } } static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) { unsigned char buffer[STBTT_MAX_OVERSAMPLE]; int safe_h = h - kernel_width; int j; STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze for (j=0; j < w; ++j) { int i; unsigned int total; STBTT_memset(buffer, 0, kernel_width); total = 0; // make kernel_width a constant in common cases so compiler can optimize out the divide switch (kernel_width) { case 2: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / 2); } break; case 3: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / 3); } break; case 4: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / 4); } break; case 5: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / 5); } break; default: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); } break; } for (; i < h; ++i) { STBTT_assert(pixels[i*stride_in_bytes] == 0); total -= buffer[i & STBTT__OVER_MASK]; pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); } pixels += 1; } } static float stbtt__oversample_shift(int oversample) { if (!oversample) return 0.0f; // The prefilter is a box filter of width "oversample", // which shifts phase by (oversample - 1)/2 pixels in // oversampled space. We want to shift in the opposite // direction to counter this. return (float)-(oversample - 1) / (2.0f * (float)oversample); } // rects array must be big enough to accommodate all characters in the given ranges STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) { int i,j,k; k=0; for (i=0; i < num_ranges; ++i) { float fh = ranges[i].font_size; float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); ranges[i].h_oversample = (unsigned char) spc->h_oversample; ranges[i].v_oversample = (unsigned char) spc->v_oversample; for (j=0; j < ranges[i].num_chars; ++j) { int x0,y0,x1,y1; int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; int glyph = stbtt_FindGlyphIndex(info, codepoint); if (glyph == 0 && spc->skip_missing) { rects[k].w = rects[k].h = 0; } else { stbtt_GetGlyphBitmapBoxSubpixel(info,glyph, scale * spc->h_oversample, scale * spc->v_oversample, 0,0, &x0,&y0,&x1,&y1); rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1); rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1); } ++k; } } return k; } STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int prefilter_x, int prefilter_y, float *sub_x, float *sub_y, int glyph) { stbtt_MakeGlyphBitmapSubpixel(info, output, out_w - (prefilter_x - 1), out_h - (prefilter_y - 1), out_stride, scale_x, scale_y, shift_x, shift_y, glyph); if (prefilter_x > 1) stbtt__h_prefilter(output, out_w, out_h, out_stride, prefilter_x); if (prefilter_y > 1) stbtt__v_prefilter(output, out_w, out_h, out_stride, prefilter_y); *sub_x = stbtt__oversample_shift(prefilter_x); *sub_y = stbtt__oversample_shift(prefilter_y); } // rects array must be big enough to accommodate all characters in the given ranges STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) { int i,j,k, return_value = 1; // save current values int old_h_over = spc->h_oversample; int old_v_over = spc->v_oversample; k = 0; for (i=0; i < num_ranges; ++i) { float fh = ranges[i].font_size; float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); float recip_h,recip_v,sub_x,sub_y; spc->h_oversample = ranges[i].h_oversample; spc->v_oversample = ranges[i].v_oversample; recip_h = 1.0f / spc->h_oversample; recip_v = 1.0f / spc->v_oversample; sub_x = stbtt__oversample_shift(spc->h_oversample); sub_y = stbtt__oversample_shift(spc->v_oversample); for (j=0; j < ranges[i].num_chars; ++j) { stbrp_rect *r = &rects[k]; if (r->was_packed && r->w != 0 && r->h != 0) { stbtt_packedchar *bc = &ranges[i].chardata_for_range[j]; int advance, lsb, x0,y0,x1,y1; int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; int glyph = stbtt_FindGlyphIndex(info, codepoint); stbrp_coord pad = (stbrp_coord) spc->padding; // pad on left and top r->x += pad; r->y += pad; r->w -= pad; r->h -= pad; stbtt_GetGlyphHMetrics(info, glyph, &advance, &lsb); stbtt_GetGlyphBitmapBox(info, glyph, scale * spc->h_oversample, scale * spc->v_oversample, &x0,&y0,&x1,&y1); stbtt_MakeGlyphBitmapSubpixel(info, spc->pixels + r->x + r->y*spc->stride_in_bytes, r->w - spc->h_oversample+1, r->h - spc->v_oversample+1, spc->stride_in_bytes, scale * spc->h_oversample, scale * spc->v_oversample, 0,0, glyph); if (spc->h_oversample > 1) stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, r->w, r->h, spc->stride_in_bytes, spc->h_oversample); if (spc->v_oversample > 1) stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, r->w, r->h, spc->stride_in_bytes, spc->v_oversample); bc->x0 = (stbtt_int16) r->x; bc->y0 = (stbtt_int16) r->y; bc->x1 = (stbtt_int16) (r->x + r->w); bc->y1 = (stbtt_int16) (r->y + r->h); bc->xadvance = scale * advance; bc->xoff = (float) x0 * recip_h + sub_x; bc->yoff = (float) y0 * recip_v + sub_y; bc->xoff2 = (x0 + r->w) * recip_h + sub_x; bc->yoff2 = (y0 + r->h) * recip_v + sub_y; } else { return_value = 0; // if any fail, report failure } ++k; } } // restore original values spc->h_oversample = old_h_over; spc->v_oversample = old_v_over; return return_value; } STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects) { stbrp_pack_rects((stbrp_context *) spc->pack_info, rects, num_rects); } STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges) { stbtt_fontinfo info; int i,j,n, return_value = 1; //stbrp_context *context = (stbrp_context *) spc->pack_info; stbrp_rect *rects; // flag all characters as NOT packed for (i=0; i < num_ranges; ++i) for (j=0; j < ranges[i].num_chars; ++j) ranges[i].chardata_for_range[j].x0 = ranges[i].chardata_for_range[j].y0 = ranges[i].chardata_for_range[j].x1 = ranges[i].chardata_for_range[j].y1 = 0; n = 0; for (i=0; i < num_ranges; ++i) n += ranges[i].num_chars; rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context); if (rects == NULL) return 0; info.userdata = spc->user_allocator_context; stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index)); n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects); stbtt_PackFontRangesPackRects(spc, rects, n); return_value = stbtt_PackFontRangesRenderIntoRects(spc, &info, ranges, num_ranges, rects); STBTT_free(rects, spc->user_allocator_context); return return_value; } STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range) { stbtt_pack_range range; range.first_unicode_codepoint_in_range = first_unicode_codepoint_in_range; range.array_of_unicode_codepoints = NULL; range.num_chars = num_chars_in_range; range.chardata_for_range = chardata_for_range; range.font_size = font_size; return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1); } STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap) { int i_ascent, i_descent, i_lineGap; float scale; stbtt_fontinfo info; stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata, index)); scale = size > 0 ? stbtt_ScaleForPixelHeight(&info, size) : stbtt_ScaleForMappingEmToPixels(&info, -size); stbtt_GetFontVMetrics(&info, &i_ascent, &i_descent, &i_lineGap); *ascent = (float) i_ascent * scale; *descent = (float) i_descent * scale; *lineGap = (float) i_lineGap * scale; } STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer) { float ipw = 1.0f / pw, iph = 1.0f / ph; const stbtt_packedchar *b = chardata + char_index; if (align_to_integer) { float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f); float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f); q->x0 = x; q->y0 = y; q->x1 = x + b->xoff2 - b->xoff; q->y1 = y + b->yoff2 - b->yoff; } else { q->x0 = *xpos + b->xoff; q->y0 = *ypos + b->yoff; q->x1 = *xpos + b->xoff2; q->y1 = *ypos + b->yoff2; } q->s0 = b->x0 * ipw; q->t0 = b->y0 * iph; q->s1 = b->x1 * ipw; q->t1 = b->y1 * iph; *xpos += b->xadvance; } ////////////////////////////////////////////////////////////////////////////// // // sdf computation // #define STBTT_min(a,b) ((a) < (b) ? (a) : (b)) #define STBTT_max(a,b) ((a) < (b) ? (b) : (a)) static int stbtt__ray_intersect_bezier(float orig[2], float ray[2], float q0[2], float q1[2], float q2[2], float hits[2][2]) { float q0perp = q0[1]*ray[0] - q0[0]*ray[1]; float q1perp = q1[1]*ray[0] - q1[0]*ray[1]; float q2perp = q2[1]*ray[0] - q2[0]*ray[1]; float roperp = orig[1]*ray[0] - orig[0]*ray[1]; float a = q0perp - 2*q1perp + q2perp; float b = q1perp - q0perp; float c = q0perp - roperp; float s0 = 0., s1 = 0.; int num_s = 0; if (a != 0.0) { float discr = b*b - a*c; if (discr > 0.0) { float rcpna = -1 / a; float d = (float) STBTT_sqrt(discr); s0 = (b+d) * rcpna; s1 = (b-d) * rcpna; if (s0 >= 0.0 && s0 <= 1.0) num_s = 1; if (d > 0.0 && s1 >= 0.0 && s1 <= 1.0) { if (num_s == 0) s0 = s1; ++num_s; } } } else { // 2*b*s + c = 0 // s = -c / (2*b) s0 = c / (-2 * b); if (s0 >= 0.0 && s0 <= 1.0) num_s = 1; } if (num_s == 0) return 0; else { float rcp_len2 = 1 / (ray[0]*ray[0] + ray[1]*ray[1]); float rayn_x = ray[0] * rcp_len2, rayn_y = ray[1] * rcp_len2; float q0d = q0[0]*rayn_x + q0[1]*rayn_y; float q1d = q1[0]*rayn_x + q1[1]*rayn_y; float q2d = q2[0]*rayn_x + q2[1]*rayn_y; float rod = orig[0]*rayn_x + orig[1]*rayn_y; float q10d = q1d - q0d; float q20d = q2d - q0d; float q0rd = q0d - rod; hits[0][0] = q0rd + s0*(2.0f - 2.0f*s0)*q10d + s0*s0*q20d; hits[0][1] = a*s0+b; if (num_s > 1) { hits[1][0] = q0rd + s1*(2.0f - 2.0f*s1)*q10d + s1*s1*q20d; hits[1][1] = a*s1+b; return 2; } else { return 1; } } } static int equal(float *a, float *b) { return (a[0] == b[0] && a[1] == b[1]); } static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex *verts) { int i; float orig[2], ray[2] = { 1, 0 }; float y_frac; int winding = 0; orig[0] = x; //orig[1] = y; // [DEAR IMGUI] commmented double assignment // make sure y never passes through a vertex of the shape y_frac = (float) STBTT_fmod(y, 1.0f); if (y_frac < 0.01f) y += 0.01f; else if (y_frac > 0.99f) y -= 0.01f; orig[1] = y; // test a ray from (-infinity,y) to (x,y) for (i=0; i < nverts; ++i) { if (verts[i].type == STBTT_vline) { int x0 = (int) verts[i-1].x, y0 = (int) verts[i-1].y; int x1 = (int) verts[i ].x, y1 = (int) verts[i ].y; if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; if (x_inter < x) winding += (y0 < y1) ? 1 : -1; } } if (verts[i].type == STBTT_vcurve) { int x0 = (int) verts[i-1].x , y0 = (int) verts[i-1].y ; int x1 = (int) verts[i ].cx, y1 = (int) verts[i ].cy; int x2 = (int) verts[i ].x , y2 = (int) verts[i ].y ; int ax = STBTT_min(x0,STBTT_min(x1,x2)), ay = STBTT_min(y0,STBTT_min(y1,y2)); int by = STBTT_max(y0,STBTT_max(y1,y2)); if (y > ay && y < by && x > ax) { float q0[2],q1[2],q2[2]; float hits[2][2]; q0[0] = (float)x0; q0[1] = (float)y0; q1[0] = (float)x1; q1[1] = (float)y1; q2[0] = (float)x2; q2[1] = (float)y2; if (equal(q0,q1) || equal(q1,q2)) { x0 = (int)verts[i-1].x; y0 = (int)verts[i-1].y; x1 = (int)verts[i ].x; y1 = (int)verts[i ].y; if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; if (x_inter < x) winding += (y0 < y1) ? 1 : -1; } } else { int num_hits = stbtt__ray_intersect_bezier(orig, ray, q0, q1, q2, hits); if (num_hits >= 1) if (hits[0][0] < 0) winding += (hits[0][1] < 0 ? -1 : 1); if (num_hits >= 2) if (hits[1][0] < 0) winding += (hits[1][1] < 0 ? -1 : 1); } } } } return winding; } static float stbtt__cuberoot( float x ) { if (x<0) return -(float) STBTT_pow(-x,1.0f/3.0f); else return (float) STBTT_pow( x,1.0f/3.0f); } // x^3 + c*x^2 + b*x + a = 0 static int stbtt__solve_cubic(float a, float b, float c, float* r) { float s = -a / 3; float p = b - a*a / 3; float q = a * (2*a*a - 9*b) / 27 + c; float p3 = p*p*p; float d = q*q + 4*p3 / 27; if (d >= 0) { float z = (float) STBTT_sqrt(d); float u = (-q + z) / 2; float v = (-q - z) / 2; u = stbtt__cuberoot(u); v = stbtt__cuberoot(v); r[0] = s + u + v; return 1; } else { float u = (float) STBTT_sqrt(-p/3); float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; // p3 must be negative, since d is negative float m = (float) STBTT_cos(v); float n = (float) STBTT_cos(v-3.141592/2)*1.732050808f; r[0] = s + u * 2 * m; r[1] = s - u * (m + n); r[2] = s - u * (m - n); //STBTT_assert( STBTT_fabs(((r[0]+a)*r[0]+b)*r[0]+c) < 0.05f); // these asserts may not be safe at all scales, though they're in bezier t parameter units so maybe? //STBTT_assert( STBTT_fabs(((r[1]+a)*r[1]+b)*r[1]+c) < 0.05f); //STBTT_assert( STBTT_fabs(((r[2]+a)*r[2]+b)*r[2]+c) < 0.05f); return 3; } } STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) { float scale_x = scale, scale_y = scale; int ix0,iy0,ix1,iy1; int w,h; unsigned char *data; // if one scale is 0, use same scale for both if (scale_x == 0) scale_x = scale_y; if (scale_y == 0) { if (scale_x == 0) return NULL; // if both scales are 0, return NULL scale_y = scale_x; } stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale, scale, 0.0f,0.0f, &ix0,&iy0,&ix1,&iy1); // if empty, return NULL if (ix0 == ix1 || iy0 == iy1) return NULL; ix0 -= padding; iy0 -= padding; ix1 += padding; iy1 += padding; w = (ix1 - ix0); h = (iy1 - iy0); if (width ) *width = w; if (height) *height = h; if (xoff ) *xoff = ix0; if (yoff ) *yoff = iy0; // invert for y-downwards bitmaps scale_y = -scale_y; { int x,y,i,j; float *precompute; stbtt_vertex *verts; int num_verts = stbtt_GetGlyphShape(info, glyph, &verts); data = (unsigned char *) STBTT_malloc(w * h, info->userdata); precompute = (float *) STBTT_malloc(num_verts * sizeof(float), info->userdata); for (i=0,j=num_verts-1; i < num_verts; j=i++) { if (verts[i].type == STBTT_vline) { float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y; float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0)); precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist; } else if (verts[i].type == STBTT_vcurve) { float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y; float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y; float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y; float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; float len2 = bx*bx + by*by; if (len2 != 0.0f) precompute[i] = 1.0f / (bx*bx + by*by); else precompute[i] = 0.0f; } else precompute[i] = 0.0f; } for (y=iy0; y < iy1; ++y) { for (x=ix0; x < ix1; ++x) { float val; float min_dist = 999999.0f; float sx = (float) x + 0.5f; float sy = (float) y + 0.5f; float x_gspace = (sx / scale_x); float y_gspace = (sy / scale_y); int winding = stbtt__compute_crossings_x(x_gspace, y_gspace, num_verts, verts); // @OPTIMIZE: this could just be a rasterization, but needs to be line vs. non-tesselated curves so a new path for (i=0; i < num_verts; ++i) { float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; // check against every point here rather than inside line/curve primitives -- @TODO: wrong if multiple 'moves' in a row produce a garbage point, and given culling, probably more efficient to do within line/curve float dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy); if (dist2 < min_dist*min_dist) min_dist = (float) STBTT_sqrt(dist2); if (verts[i].type == STBTT_vline) { float x1 = verts[i-1].x*scale_x, y1 = verts[i-1].y*scale_y; // coarse culling against bbox //if (sx > STBTT_min(x0,x1)-min_dist && sx < STBTT_max(x0,x1)+min_dist && // sy > STBTT_min(y0,y1)-min_dist && sy < STBTT_max(y0,y1)+min_dist) float dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i]; STBTT_assert(i != 0); if (dist < min_dist) { // check position along line // x' = x0 + t*(x1-x0), y' = y0 + t*(y1-y0) // minimize (x'-sx)*(x'-sx)+(y'-sy)*(y'-sy) float dx = x1-x0, dy = y1-y0; float px = x0-sx, py = y0-sy; // minimize (px+t*dx)^2 + (py+t*dy)^2 = px*px + 2*px*dx*t + t^2*dx*dx + py*py + 2*py*dy*t + t^2*dy*dy // derivative: 2*px*dx + 2*py*dy + (2*dx*dx+2*dy*dy)*t, set to 0 and solve float t = -(px*dx + py*dy) / (dx*dx + dy*dy); if (t >= 0.0f && t <= 1.0f) min_dist = dist; } } else if (verts[i].type == STBTT_vcurve) { float x2 = verts[i-1].x *scale_x, y2 = verts[i-1].y *scale_y; float x1 = verts[i ].cx*scale_x, y1 = verts[i ].cy*scale_y; float box_x0 = STBTT_min(STBTT_min(x0,x1),x2); float box_y0 = STBTT_min(STBTT_min(y0,y1),y2); float box_x1 = STBTT_max(STBTT_max(x0,x1),x2); float box_y1 = STBTT_max(STBTT_max(y0,y1),y2); // coarse culling against bbox to avoid computing cubic unnecessarily if (sx > box_x0-min_dist && sx < box_x1+min_dist && sy > box_y0-min_dist && sy < box_y1+min_dist) { int num=0; float ax = x1-x0, ay = y1-y0; float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; float mx = x0 - sx, my = y0 - sy; float res[3],px,py,t,it; float a_inv = precompute[i]; if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula float a = 3*(ax*bx + ay*by); float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by); float c = mx*ax+my*ay; if (a == 0.0) { // if a is 0, it's linear if (b != 0.0) { res[num++] = -c/b; } } else { float discriminant = b*b - 4*a*c; if (discriminant < 0) num = 0; else { float root = (float) STBTT_sqrt(discriminant); res[0] = (-b - root)/(2*a); res[1] = (-b + root)/(2*a); num = 2; // don't bother distinguishing 1-solution case, as code below will still work } } } else { float b = 3*(ax*bx + ay*by) * a_inv; // could precompute this as it doesn't depend on sample point float c = (2*(ax*ax + ay*ay) + (mx*bx+my*by)) * a_inv; float d = (mx*ax+my*ay) * a_inv; num = stbtt__solve_cubic(b, c, d, res); } if (num >= 1 && res[0] >= 0.0f && res[0] <= 1.0f) { t = res[0], it = 1.0f - t; px = it*it*x0 + 2*t*it*x1 + t*t*x2; py = it*it*y0 + 2*t*it*y1 + t*t*y2; dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); if (dist2 < min_dist * min_dist) min_dist = (float) STBTT_sqrt(dist2); } if (num >= 2 && res[1] >= 0.0f && res[1] <= 1.0f) { t = res[1], it = 1.0f - t; px = it*it*x0 + 2*t*it*x1 + t*t*x2; py = it*it*y0 + 2*t*it*y1 + t*t*y2; dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); if (dist2 < min_dist * min_dist) min_dist = (float) STBTT_sqrt(dist2); } if (num >= 3 && res[2] >= 0.0f && res[2] <= 1.0f) { t = res[2], it = 1.0f - t; px = it*it*x0 + 2*t*it*x1 + t*t*x2; py = it*it*y0 + 2*t*it*y1 + t*t*y2; dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); if (dist2 < min_dist * min_dist) min_dist = (float) STBTT_sqrt(dist2); } } } } if (winding == 0) min_dist = -min_dist; // if outside the shape, value is negative val = onedge_value + pixel_dist_scale * min_dist; if (val < 0) val = 0; else if (val > 255) val = 255; data[(y-iy0)*w+(x-ix0)] = (unsigned char) val; } } STBTT_free(precompute, info->userdata); STBTT_free(verts, info->userdata); } return data; } STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetGlyphSDF(info, scale, stbtt_FindGlyphIndex(info, codepoint), padding, onedge_value, pixel_dist_scale, width, height, xoff, yoff); } STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata) { STBTT_free(bitmap, userdata); } ////////////////////////////////////////////////////////////////////////////// // // font name matching -- recommended not to use this // // check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2) { stbtt_int32 i=0; // convert utf16 to utf8 and compare the results while converting while (len2) { stbtt_uint16 ch = s2[0]*256 + s2[1]; if (ch < 0x80) { if (i >= len1) return -1; if (s1[i++] != ch) return -1; } else if (ch < 0x800) { if (i+1 >= len1) return -1; if (s1[i++] != 0xc0 + (ch >> 6)) return -1; if (s1[i++] != 0x80 + (ch & 0x3f)) return -1; } else if (ch >= 0xd800 && ch < 0xdc00) { stbtt_uint32 c; stbtt_uint16 ch2 = s2[2]*256 + s2[3]; if (i+3 >= len1) return -1; c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000; if (s1[i++] != 0xf0 + (c >> 18)) return -1; if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1; if (s1[i++] != 0x80 + ((c >> 6) & 0x3f)) return -1; if (s1[i++] != 0x80 + ((c ) & 0x3f)) return -1; s2 += 2; // plus another 2 below len2 -= 2; } else if (ch >= 0xdc00 && ch < 0xe000) { return -1; } else { if (i+2 >= len1) return -1; if (s1[i++] != 0xe0 + (ch >> 12)) return -1; if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1; if (s1[i++] != 0x80 + ((ch ) & 0x3f)) return -1; } s2 += 2; len2 -= 2; } return i; } static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2) { return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2); } // returns results in whatever encoding you request... but note that 2-byte encodings // will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID) { stbtt_int32 i,count,stringOffset; stbtt_uint8 *fc = font->data; stbtt_uint32 offset = font->fontstart; stbtt_uint32 nm = stbtt__find_table(fc, offset, "name"); if (!nm) return NULL; count = ttUSHORT(fc+nm+2); stringOffset = nm + ttUSHORT(fc+nm+4); for (i=0; i < count; ++i) { stbtt_uint32 loc = nm + 6 + 12 * i; if (platformID == ttUSHORT(fc+loc+0) && encodingID == ttUSHORT(fc+loc+2) && languageID == ttUSHORT(fc+loc+4) && nameID == ttUSHORT(fc+loc+6)) { *length = ttUSHORT(fc+loc+8); return (const char *) (fc+stringOffset+ttUSHORT(fc+loc+10)); } } return NULL; } static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id) { stbtt_int32 i; stbtt_int32 count = ttUSHORT(fc+nm+2); stbtt_int32 stringOffset = nm + ttUSHORT(fc+nm+4); for (i=0; i < count; ++i) { stbtt_uint32 loc = nm + 6 + 12 * i; stbtt_int32 id = ttUSHORT(fc+loc+6); if (id == target_id) { // find the encoding stbtt_int32 platform = ttUSHORT(fc+loc+0), encoding = ttUSHORT(fc+loc+2), language = ttUSHORT(fc+loc+4); // is this a Unicode encoding? if (platform == 0 || (platform == 3 && encoding == 1) || (platform == 3 && encoding == 10)) { stbtt_int32 slen = ttUSHORT(fc+loc+8); stbtt_int32 off = ttUSHORT(fc+loc+10); // check if there's a prefix match stbtt_int32 matchlen = stbtt__CompareUTF8toUTF16_bigendian_prefix(name, nlen, fc+stringOffset+off,slen); if (matchlen >= 0) { // check for target_id+1 immediately following, with same encoding & language if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) { slen = ttUSHORT(fc+loc+12+8); off = ttUSHORT(fc+loc+12+10); if (slen == 0) { if (matchlen == nlen) return 1; } else if (matchlen < nlen && name[matchlen] == ' ') { ++matchlen; if (stbtt_CompareUTF8toUTF16_bigendian_internal((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) return 1; } } else { // if nothing immediately following if (matchlen == nlen) return 1; } } } // @TODO handle other encodings } } return 0; } static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *name, stbtt_int32 flags) { stbtt_int32 nlen = (stbtt_int32) STBTT_strlen((char *) name); stbtt_uint32 nm,hd; if (!stbtt__isfont(fc+offset)) return 0; // check italics/bold/underline flags in macStyle... if (flags) { hd = stbtt__find_table(fc, offset, "head"); if ((ttUSHORT(fc+hd+44) & 7) != (flags & 7)) return 0; } nm = stbtt__find_table(fc, offset, "name"); if (!nm) return 0; if (flags) { // if we checked the macStyle flags, then just check the family and ignore the subfamily if (stbtt__matchpair(fc, nm, name, nlen, 16, -1)) return 1; if (stbtt__matchpair(fc, nm, name, nlen, 1, -1)) return 1; if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; } else { if (stbtt__matchpair(fc, nm, name, nlen, 16, 17)) return 1; if (stbtt__matchpair(fc, nm, name, nlen, 1, 2)) return 1; if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; } return 0; } static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, stbtt_int32 flags) { stbtt_int32 i; for (i=0;;++i) { stbtt_int32 off = stbtt_GetFontOffsetForIndex(font_collection, i); if (off < 0) return off; if (stbtt__matches((stbtt_uint8 *) font_collection, off, (stbtt_uint8*) name_utf8, flags)) return off; } } #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-qual" #endif STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, float pixel_height, unsigned char *pixels, int pw, int ph, int first_char, int num_chars, stbtt_bakedchar *chardata) { return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata); } STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index) { return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index); } STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data) { return stbtt_GetNumberOfFonts_internal((unsigned char *) data); } STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset) { return stbtt_InitFont_internal(info, (unsigned char *) data, offset); } STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags) { return stbtt_FindMatchingFont_internal((unsigned char *) fontdata, (char *) name, flags); } STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) { return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2); } #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif #endif // STB_TRUETYPE_IMPLEMENTATION // FULL VERSION HISTORY // // 1.19 (2018-02-11) OpenType GPOS kerning (horizontal only), STBTT_fmod // 1.18 (2018-01-29) add missing function // 1.17 (2017-07-23) make more arguments const; doc fix // 1.16 (2017-07-12) SDF support // 1.15 (2017-03-03) make more arguments const // 1.14 (2017-01-16) num-fonts-in-TTC function // 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts // 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual // 1.11 (2016-04-02) fix unused-variable warning // 1.10 (2016-04-02) allow user-defined fabs() replacement // fix memory leak if fontsize=0.0 // fix warning from duplicate typedef // 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use alloc userdata for PackFontRanges // 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges // 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; // allow PackFontRanges to pack and render in separate phases; // fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); // fixed an assert() bug in the new rasterizer // replace assert() with STBTT_assert() in new rasterizer // 1.06 (2015-07-14) performance improvements (~35% faster on x86 and x64 on test machine) // also more precise AA rasterizer, except if shapes overlap // remove need for STBTT_sort // 1.05 (2015-04-15) fix misplaced definitions for STBTT_STATIC // 1.04 (2015-04-15) typo in example // 1.03 (2015-04-12) STBTT_STATIC, fix memory leak in new packing, various fixes // 1.02 (2014-12-10) fix various warnings & compile issues w/ stb_rect_pack, C++ // 1.01 (2014-12-08) fix subpixel position when oversampling to exactly match // non-oversampled; STBTT_POINT_SIZE for packed case only // 1.00 (2014-12-06) add new PackBegin etc. API, w/ support for oversampling // 0.99 (2014-09-18) fix multiple bugs with subpixel rendering (ryg) // 0.9 (2014-08-07) support certain mac/iOS fonts without an MS platformID // 0.8b (2014-07-07) fix a warning // 0.8 (2014-05-25) fix a few more warnings // 0.7 (2013-09-25) bugfix: subpixel glyph bug fixed in 0.5 had come back // 0.6c (2012-07-24) improve documentation // 0.6b (2012-07-20) fix a few more warnings // 0.6 (2012-07-17) fix warnings; added stbtt_ScaleForMappingEmToPixels, // stbtt_GetFontBoundingBox, stbtt_IsGlyphEmpty // 0.5 (2011-12-09) bugfixes: // subpixel glyph renderer computed wrong bounding box // first vertex of shape can be off-curve (FreeSans) // 0.4b (2011-12-03) fixed an error in the font baking example // 0.4 (2011-12-01) kerning, subpixel rendering (tor) // bugfixes for: // codepoint-to-glyph conversion using table fmt=12 // codepoint-to-glyph conversion using table fmt=4 // stbtt_GetBakedQuad with non-square texture (Zer) // updated Hello World! sample to use kerning and subpixel // fixed some warnings // 0.3 (2009-06-24) cmap fmt=12, compound shapes (MM) // userdata, malloc-from-userdata, non-zero fill (stb) // 0.2 (2009-03-11) Fix unsigned/signed char warnings // 0.1 (2009-03-09) First public release // /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ goxel-0.11.0/ext_src/inih/000077500000000000000000000000001435762723100153175ustar00rootroot00000000000000goxel-0.11.0/ext_src/inih/ini.c000066400000000000000000000161611435762723100162470ustar00rootroot00000000000000/* inih -- simple .INI file parser inih is released under the New BSD license (see LICENSE.txt). Go to the project home page for more info: https://github.com/benhoyt/inih */ #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) #define _CRT_SECURE_NO_WARNINGS #endif #include #include #include #include "ini.h" #if !INI_USE_STACK #include #endif #define MAX_SECTION 50 #define MAX_NAME 50 /* Used by ini_parse_string() to keep track of string parsing state. */ typedef struct { const char* ptr; size_t num_left; } ini_parse_string_ctx; /* Strip whitespace chars off end of given string, in place. Return s. */ static char* rstrip(char* s) { char* p = s + strlen(s); while (p > s && isspace((unsigned char)(*--p))) *p = '\0'; return s; } /* Return pointer to first non-whitespace char in given string. */ static char* lskip(const char* s) { while (*s && isspace((unsigned char)(*s))) s++; return (char*)s; } /* Return pointer to first char (of chars) or inline comment in given string, or pointer to null at end of string if neither found. Inline comment must be prefixed by a whitespace character to register as a comment. */ static char* find_chars_or_comment(const char* s, const char* chars) { #if INI_ALLOW_INLINE_COMMENTS int was_space = 0; while (*s && (!chars || !strchr(chars, *s)) && !(was_space && strchr(INI_INLINE_COMMENT_PREFIXES, *s))) { was_space = isspace((unsigned char)(*s)); s++; } #else while (*s && (!chars || !strchr(chars, *s))) { s++; } #endif return (char*)s; } /* Version of strncpy that ensures dest (size bytes) is null-terminated. */ static char* strncpy0(char* dest, const char* src, size_t size) { strncpy(dest, src, size - 1); dest[size - 1] = '\0'; return dest; } /* See documentation in header file. */ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, void* user) { /* Uses a fair bit of stack (use heap instead if you need to) */ #if INI_USE_STACK char line[INI_MAX_LINE]; int max_line = INI_MAX_LINE; #else char* line; int max_line = INI_INITIAL_ALLOC; #endif #if INI_ALLOW_REALLOC && !INI_USE_STACK char* new_line; int offset; #endif char section[MAX_SECTION] = ""; char prev_name[MAX_NAME] = ""; char* start; char* end; char* name; char* value; int lineno = 0; int error = 0; #if !INI_USE_STACK line = (char*)malloc(INI_INITIAL_ALLOC); if (!line) { return -2; } #endif #if INI_HANDLER_LINENO #define HANDLER(u, s, n, v) handler(u, s, n, v, lineno) #else #define HANDLER(u, s, n, v) handler(u, s, n, v) #endif /* Scan through stream line by line */ while (reader(line, max_line, stream) != NULL) { #if INI_ALLOW_REALLOC && !INI_USE_STACK offset = strlen(line); while (offset == max_line - 1 && line[offset - 1] != '\n') { max_line *= 2; if (max_line > INI_MAX_LINE) max_line = INI_MAX_LINE; new_line = realloc(line, max_line); if (!new_line) { free(line); return -2; } line = new_line; if (reader(line + offset, max_line - offset, stream) == NULL) break; if (max_line >= INI_MAX_LINE) break; offset += strlen(line + offset); } #endif lineno++; start = line; #if INI_ALLOW_BOM if (lineno == 1 && (unsigned char)start[0] == 0xEF && (unsigned char)start[1] == 0xBB && (unsigned char)start[2] == 0xBF) { start += 3; } #endif start = lskip(rstrip(start)); if (strchr(INI_START_COMMENT_PREFIXES, *start)) { /* Start-of-line comment */ } #if INI_ALLOW_MULTILINE else if (*prev_name && *start && start > line) { /* Non-blank line with leading whitespace, treat as continuation of previous name's value (as per Python configparser). */ if (!HANDLER(user, section, prev_name, start) && !error) error = lineno; } #endif else if (*start == '[') { /* A "[section]" line */ end = find_chars_or_comment(start + 1, "]"); if (*end == ']') { *end = '\0'; strncpy0(section, start + 1, sizeof(section)); *prev_name = '\0'; } else if (!error) { /* No ']' found on section line */ error = lineno; } } else if (*start) { /* Not a comment, must be a name[=:]value pair */ end = find_chars_or_comment(start, "=:"); if (*end == '=' || *end == ':') { *end = '\0'; name = rstrip(start); value = end + 1; #if INI_ALLOW_INLINE_COMMENTS end = find_chars_or_comment(value, NULL); if (*end) *end = '\0'; #endif value = lskip(value); rstrip(value); /* Valid name[=:]value pair found, call handler */ strncpy0(prev_name, name, sizeof(prev_name)); if (!HANDLER(user, section, name, value) && !error) error = lineno; } else if (!error) { /* No '=' or ':' found on name[=:]value line */ error = lineno; } } #if INI_STOP_ON_FIRST_ERROR if (error) break; #endif } #if !INI_USE_STACK free(line); #endif return error; } /* See documentation in header file. */ int ini_parse_file(FILE* file, ini_handler handler, void* user) { return ini_parse_stream((ini_reader)fgets, file, handler, user); } /* See documentation in header file. */ int ini_parse(const char* filename, ini_handler handler, void* user) { FILE* file; int error; file = fopen(filename, "r"); if (!file) return -1; error = ini_parse_file(file, handler, user); fclose(file); return error; } /* An ini_reader function to read the next line from a string buffer. This is the fgets() equivalent used by ini_parse_string(). */ static char* ini_reader_string(char* str, int num, void* stream) { ini_parse_string_ctx* ctx = (ini_parse_string_ctx*)stream; const char* ctx_ptr = ctx->ptr; size_t ctx_num_left = ctx->num_left; char* strp = str; char c; if (ctx_num_left == 0 || num < 2) return NULL; while (num > 1 && ctx_num_left != 0) { c = *ctx_ptr++; ctx_num_left--; *strp++ = c; if (c == '\n') break; num--; } *strp = '\0'; ctx->ptr = ctx_ptr; ctx->num_left = ctx_num_left; return str; } /* See documentation in header file. */ int ini_parse_string(const char* string, ini_handler handler, void* user) { ini_parse_string_ctx ctx; ctx.ptr = string; ctx.num_left = strlen(string); return ini_parse_stream((ini_reader)ini_reader_string, &ctx, handler, user); } goxel-0.11.0/ext_src/inih/ini.h000066400000000000000000000105141435762723100162500ustar00rootroot00000000000000/* inih -- simple .INI file parser inih is released under the New BSD license (see LICENSE.txt). Go to the project home page for more info: https://github.com/benhoyt/inih */ #ifndef __INI_H__ #define __INI_H__ /* Make this header file easier to include in C++ code */ #ifdef __cplusplus extern "C" { #endif #include /* Nonzero if ini_handler callback should accept lineno parameter. */ #ifndef INI_HANDLER_LINENO #define INI_HANDLER_LINENO 0 #endif /* Typedef for prototype of handler function. */ #if INI_HANDLER_LINENO typedef int (*ini_handler)(void* user, const char* section, const char* name, const char* value, int lineno); #else typedef int (*ini_handler)(void* user, const char* section, const char* name, const char* value); #endif /* Typedef for prototype of fgets-style reader function. */ typedef char* (*ini_reader)(char* str, int num, void* stream); /* Parse given INI-style file. May have [section]s, name=value pairs (whitespace stripped), and comments starting with ';' (semicolon). Section is "" if name=value pair parsed before any section heading. name:value pairs are also supported as a concession to Python's configparser. For each name=value pair parsed, call handler function with given user pointer as well as section, name, and value (data only valid for duration of handler call). Handler should return nonzero on success, zero on error. Returns 0 on success, line number of first error on parse error (doesn't stop on first error), -1 on file open error, or -2 on memory allocation error (only when INI_USE_STACK is zero). */ int ini_parse(const char* filename, ini_handler handler, void* user); /* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't close the file when it's finished -- the caller must do that. */ int ini_parse_file(FILE* file, ini_handler handler, void* user); /* Same as ini_parse(), but takes an ini_reader function pointer instead of filename. Used for implementing custom or string-based I/O (see also ini_parse_string). */ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, void* user); /* Same as ini_parse(), but takes a zero-terminated string with the INI data instead of a file. Useful for parsing INI data from a network socket or already in memory. */ int ini_parse_string(const char* string, ini_handler handler, void* user); /* Nonzero to allow multi-line value parsing, in the style of Python's configparser. If allowed, ini_parse() will call the handler with the same name for each subsequent line parsed. */ #ifndef INI_ALLOW_MULTILINE #define INI_ALLOW_MULTILINE 1 #endif /* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of the file. See https://github.com/benhoyt/inih/issues/21 */ #ifndef INI_ALLOW_BOM #define INI_ALLOW_BOM 1 #endif /* Chars that begin a start-of-line comment. Per Python configparser, allow both ; and # comments at the start of a line by default. */ #ifndef INI_START_COMMENT_PREFIXES #define INI_START_COMMENT_PREFIXES ";#" #endif /* Nonzero to allow inline comments (with valid inline comment characters specified by INI_INLINE_COMMENT_PREFIXES). Set to 0 to turn off and match Python 3.2+ configparser behaviour. */ #ifndef INI_ALLOW_INLINE_COMMENTS #define INI_ALLOW_INLINE_COMMENTS 1 #endif #ifndef INI_INLINE_COMMENT_PREFIXES #define INI_INLINE_COMMENT_PREFIXES ";" #endif /* Nonzero to use stack for line buffer, zero to use heap (malloc/free). */ #ifndef INI_USE_STACK #define INI_USE_STACK 1 #endif /* Maximum line length for any line in INI file (stack or heap). Note that this must be 3 more than the longest line (due to '\r', '\n', and '\0'). */ #ifndef INI_MAX_LINE #define INI_MAX_LINE 200 #endif /* Nonzero to allow heap line buffer to grow via realloc(), zero for a fixed-size buffer of INI_MAX_LINE bytes. Only applies if INI_USE_STACK is zero. */ #ifndef INI_ALLOW_REALLOC #define INI_ALLOW_REALLOC 0 #endif /* Initial size in bytes for heap line buffer. Only applies if INI_USE_STACK is zero. */ #ifndef INI_INITIAL_ALLOC #define INI_INITIAL_ALLOC 200 #endif /* Stop parsing on first error (default is to keep parsing). */ #ifndef INI_STOP_ON_FIRST_ERROR #define INI_STOP_ON_FIRST_ERROR 0 #endif #ifdef __cplusplus } #endif #endif /* __INI_H__ */ goxel-0.11.0/ext_src/json/000077500000000000000000000000001435762723100153415ustar00rootroot00000000000000goxel-0.11.0/ext_src/json/json-builder.c000066400000000000000000000606661435762723100201200ustar00rootroot00000000000000 /* vim: set et ts=3 sw=3 sts=3 ft=c: * * Copyright (C) 2014 James McLaughlin. All rights reserved. * https://github.com/udp/json-builder * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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 AUTHOR 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 AUTHOR 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 "json-builder.h" #include #include #include #include #ifdef _MSC_VER #define snprintf _snprintf #endif const static json_serialize_opts default_opts = { json_serialize_mode_single_line, 0, 3 /* indent_size */ }; typedef struct json_builder_value { json_value value; int is_builder_value; size_t additional_length_allocated; size_t length_iterated; } json_builder_value; static int builderize (json_value * value) { if (((json_builder_value *) value)->is_builder_value) return 1; if (value->type == json_object) { unsigned int i; /* Values straight out of the parser have the names of object entries * allocated in the same allocation as the values array itself. This is * not desirable when manipulating values because the names would be easy * to clobber. */ for (i = 0; i < value->u.object.length; ++ i) { json_char * name_copy; json_object_entry * entry = &value->u.object.values [i]; if (! (name_copy = (json_char *) malloc ((entry->name_length + 1) * sizeof (json_char)))) return 0; memcpy (name_copy, entry->name, entry->name_length + 1); entry->name = name_copy; } } ((json_builder_value *) value)->is_builder_value = 1; return 1; } const size_t json_builder_extra = sizeof(json_builder_value) - sizeof(json_value); /* These flags are set up from the opts before serializing to make the * serializer conditions simpler. */ const int f_spaces_around_brackets = (1 << 0); const int f_spaces_after_commas = (1 << 1); const int f_spaces_after_colons = (1 << 2); const int f_tabs = (1 << 3); int get_serialize_flags (json_serialize_opts opts) { int flags = 0; if (opts.mode == json_serialize_mode_packed) return 0; if (opts.mode == json_serialize_mode_multiline) { if (opts.opts & json_serialize_opt_use_tabs) flags |= f_tabs; } else { if (! (opts.opts & json_serialize_opt_pack_brackets)) flags |= f_spaces_around_brackets; if (! (opts.opts & json_serialize_opt_no_space_after_comma)) flags |= f_spaces_after_commas; } if (! (opts.opts & json_serialize_opt_no_space_after_colon)) flags |= f_spaces_after_colons; return flags; } json_value * json_array_new (size_t length) { json_value * value = (json_value *) calloc (1, sizeof (json_builder_value)); if (!value) return NULL; ((json_builder_value *) value)->is_builder_value = 1; value->type = json_array; if (! (value->u.array.values = (json_value **) malloc (length * sizeof (json_value *)))) { free (value); return NULL; } ((json_builder_value *) value)->additional_length_allocated = length; return value; } json_value * json_array_push (json_value * array, json_value * value) { assert (array->type == json_array); if (!builderize (array) || !builderize (value)) return NULL; if (((json_builder_value *) array)->additional_length_allocated > 0) { -- ((json_builder_value *) array)->additional_length_allocated; } else { json_value ** values_new = (json_value **) realloc (array->u.array.values, sizeof (json_value *) * (array->u.array.length + 1)); if (!values_new) return NULL; array->u.array.values = values_new; } array->u.array.values [array->u.array.length] = value; ++ array->u.array.length; value->parent = array; return value; } json_value * json_object_new (size_t length) { json_value * value = (json_value *) calloc (1, sizeof (json_builder_value)); if (!value) return NULL; ((json_builder_value *) value)->is_builder_value = 1; value->type = json_object; if (! (value->u.object.values = (json_object_entry *) calloc (length, sizeof (*value->u.object.values)))) { free (value); return NULL; } ((json_builder_value *) value)->additional_length_allocated = length; return value; } json_value * json_object_push (json_value * object, const json_char * name, json_value * value) { return json_object_push_length (object, strlen (name), name, value); } json_value * json_object_push_length (json_value * object, unsigned int name_length, const json_char * name, json_value * value) { json_char * name_copy; assert (object->type == json_object); if (! (name_copy = (json_char *) malloc ((name_length + 1) * sizeof (json_char)))) return NULL; memcpy (name_copy, name, name_length * sizeof (json_char)); name_copy [name_length] = 0; if (!json_object_push_nocopy (object, name_length, name_copy, value)) { free (name_copy); return NULL; } return value; } json_value * json_object_push_nocopy (json_value * object, unsigned int name_length, json_char * name, json_value * value) { json_object_entry * entry; assert (object->type == json_object); if (!builderize (object) || !builderize (value)) return NULL; if (((json_builder_value *) object)->additional_length_allocated > 0) { -- ((json_builder_value *) object)->additional_length_allocated; } else { json_object_entry * values_new = (json_object_entry *) realloc (object->u.object.values, sizeof (*object->u.object.values) * (object->u.object.length + 1)); if (!values_new) return NULL; object->u.object.values = values_new; } entry = object->u.object.values + object->u.object.length; entry->name_length = name_length; entry->name = name; entry->value = value; ++ object->u.object.length; value->parent = object; return value; } json_value * json_string_new (const json_char * buf) { return json_string_new_length (strlen (buf), buf); } json_value * json_string_new_length (unsigned int length, const json_char * buf) { json_value * value; json_char * copy = (json_char *) malloc ((length + 1) * sizeof (json_char)); if (!copy) return NULL; memcpy (copy, buf, length * sizeof (json_char)); copy [length] = 0; if (! (value = json_string_new_nocopy (length, copy))) { free (copy); return NULL; } return value; } json_value * json_string_new_nocopy (unsigned int length, json_char * buf) { json_value * value = (json_value *) calloc (1, sizeof (json_builder_value)); if (!value) return NULL; ((json_builder_value *) value)->is_builder_value = 1; value->type = json_string; value->u.string.length = length; value->u.string.ptr = buf; return value; } json_value * json_integer_new (json_int_t integer) { json_value * value = (json_value *) calloc (1, sizeof (json_builder_value)); if (!value) return NULL; ((json_builder_value *) value)->is_builder_value = 1; value->type = json_integer; value->u.integer = integer; return value; } json_value * json_double_new (double dbl) { json_value * value = (json_value *) calloc (1, sizeof (json_builder_value)); if (!value) return NULL; ((json_builder_value *) value)->is_builder_value = 1; value->type = json_double; value->u.dbl = dbl; return value; } json_value * json_boolean_new (int b) { json_value * value = (json_value *) calloc (1, sizeof (json_builder_value)); if (!value) return NULL; ((json_builder_value *) value)->is_builder_value = 1; value->type = json_boolean; value->u.boolean = b; return value; } json_value * json_null_new () { json_value * value = (json_value *) calloc (1, sizeof (json_builder_value)); if (!value) return NULL; ((json_builder_value *) value)->is_builder_value = 1; value->type = json_null; return value; } void json_object_sort (json_value * object, json_value * proto) { unsigned int i, out_index = 0; if (!builderize (object)) return; /* TODO error */ assert (object->type == json_object); assert (proto->type == json_object); for (i = 0; i < proto->u.object.length; ++ i) { unsigned int j; json_object_entry proto_entry = proto->u.object.values [i]; for (j = 0; j < object->u.object.length; ++ j) { json_object_entry entry = object->u.object.values [j]; if (entry.name_length != proto_entry.name_length) continue; if (memcmp (entry.name, proto_entry.name, entry.name_length) != 0) continue; object->u.object.values [j] = object->u.object.values [out_index]; object->u.object.values [out_index] = entry; ++ out_index; } } } json_value * json_object_merge (json_value * objectA, json_value * objectB) { unsigned int i; assert (objectA->type == json_object); assert (objectB->type == json_object); assert (objectA != objectB); if (!builderize (objectA) || !builderize (objectB)) return NULL; if (objectB->u.object.length <= ((json_builder_value *) objectA)->additional_length_allocated) { ((json_builder_value *) objectA)->additional_length_allocated -= objectB->u.object.length; } else { json_object_entry * values_new; unsigned int alloc = objectA->u.object.length + ((json_builder_value *) objectA)->additional_length_allocated + objectB->u.object.length; if (! (values_new = (json_object_entry *) realloc (objectA->u.object.values, sizeof (json_object_entry) * alloc))) { return NULL; } objectA->u.object.values = values_new; } for (i = 0; i < objectB->u.object.length; ++ i) { json_object_entry * entry = &objectA->u.object.values[objectA->u.object.length + i]; *entry = objectB->u.object.values[i]; entry->value->parent = objectA; } objectA->u.object.length += objectB->u.object.length; free (objectB->u.object.values); free (objectB); return objectA; } static size_t measure_string (unsigned int length, const json_char * str) { unsigned int i; size_t measured_length = 0; for(i = 0; i < length; ++ i) { json_char c = str [i]; switch (c) { case '"': case '\\': case '\b': case '\f': case '\n': case '\r': case '\t': measured_length += 2; break; default: ++ measured_length; break; }; }; return measured_length; } #define PRINT_ESCAPED(c) do { \ *buf ++ = '\\'; \ *buf ++ = (c); \ } while(0); \ static size_t serialize_string (json_char * buf, unsigned int length, const json_char * str) { json_char * orig_buf = buf; unsigned int i; for(i = 0; i < length; ++ i) { json_char c = str [i]; switch (c) { case '"': PRINT_ESCAPED ('\"'); continue; case '\\': PRINT_ESCAPED ('\\'); continue; case '\b': PRINT_ESCAPED ('b'); continue; case '\f': PRINT_ESCAPED ('f'); continue; case '\n': PRINT_ESCAPED ('n'); continue; case '\r': PRINT_ESCAPED ('r'); continue; case '\t': PRINT_ESCAPED ('t'); continue; default: *buf ++ = c; break; }; }; return buf - orig_buf; } size_t json_measure (json_value * value) { return json_measure_ex (value, default_opts); } #define MEASURE_NEWLINE() do { \ ++ newlines; \ indents += depth; \ } while(0); \ size_t json_measure_ex (json_value * value, json_serialize_opts opts) { size_t total = 1; /* null terminator */ size_t newlines = 0; size_t depth = 0; size_t indents = 0; int flags; int bracket_size, comma_size, colon_size; flags = get_serialize_flags (opts); /* to reduce branching */ bracket_size = flags & f_spaces_around_brackets ? 2 : 1; comma_size = flags & f_spaces_after_commas ? 2 : 1; colon_size = flags & f_spaces_after_colons ? 2 : 1; while (value) { json_int_t integer; json_object_entry * entry; switch (value->type) { case json_array: if (((json_builder_value *) value)->length_iterated == 0) { if (value->u.array.length == 0) { total += 2; /* `[]` */ break; } total += bracket_size; /* `[` */ ++ depth; MEASURE_NEWLINE(); /* \n after [ */ } if (((json_builder_value *) value)->length_iterated == value->u.array.length) { -- depth; MEASURE_NEWLINE(); total += bracket_size; /* `]` */ ((json_builder_value *) value)->length_iterated = 0; break; } if (((json_builder_value *) value)->length_iterated > 0) { total += comma_size; /* `, ` */ MEASURE_NEWLINE(); } ((json_builder_value *) value)->length_iterated++; value = value->u.array.values [((json_builder_value *) value)->length_iterated - 1]; continue; case json_object: if (((json_builder_value *) value)->length_iterated == 0) { if (value->u.object.length == 0) { total += 2; /* `{}` */ break; } total += bracket_size; /* `{` */ ++ depth; MEASURE_NEWLINE(); /* \n after { */ } if (((json_builder_value *) value)->length_iterated == value->u.object.length) { -- depth; MEASURE_NEWLINE(); total += bracket_size; /* `}` */ ((json_builder_value *) value)->length_iterated = 0; break; } if (((json_builder_value *) value)->length_iterated > 0) { total += comma_size; /* `, ` */ MEASURE_NEWLINE(); } entry = value->u.object.values + (((json_builder_value *) value)->length_iterated ++); total += 2 + colon_size; /* `"": ` */ total += measure_string (entry->name_length, entry->name); value = entry->value; continue; case json_string: total += 2; /* `""` */ total += measure_string (value->u.string.length, value->u.string.ptr); break; case json_integer: integer = value->u.integer; if (integer < 0) { total += 1; /* `-` */ integer = - integer; } ++ total; /* first digit */ while (integer >= 10) { ++ total; /* another digit */ integer /= 10; } break; case json_double: if (isnan(value->u.dbl)) { total += 4; break; } total += snprintf (NULL, 0, "%.12f", value->u.dbl); if (value->u.dbl - floor (value->u.dbl) < 0.001) total += 2; break; case json_boolean: total += value->u.boolean ? 4: /* `true` */ 5; /* `false` */ break; case json_null: total += 4; /* `null` */ break; default: break; }; value = value->parent; } if (opts.mode == json_serialize_mode_multiline) { total += newlines * (((opts.opts & json_serialize_opt_CRLF) ? 2 : 1) + opts.indent_size); total += indents * opts.indent_size; } return total; } void json_serialize (json_char * buf, json_value * value) { json_serialize_ex (buf, value, default_opts); } #define PRINT_NEWLINE() do { \ if (opts.mode == json_serialize_mode_multiline) { \ if (opts.opts & json_serialize_opt_CRLF) \ *buf ++ = '\r'; \ *buf ++ = '\n'; \ for(i = 0; i < indent; ++ i) \ *buf ++ = indent_char; \ } \ } while(0); \ #define PRINT_OPENING_BRACKET(c) do { \ *buf ++ = (c); \ if (flags & f_spaces_around_brackets) \ *buf ++ = ' '; \ } while(0); \ #define PRINT_CLOSING_BRACKET(c) do { \ if (flags & f_spaces_around_brackets) \ *buf ++ = ' '; \ *buf ++ = (c); \ } while(0); \ void json_serialize_ex (json_char * buf, json_value * value, json_serialize_opts opts) { json_int_t integer, orig_integer; json_object_entry * entry; json_char * ptr, * dot; int indent = 0; char indent_char; int i; int flags; flags = get_serialize_flags (opts); indent_char = flags & f_tabs ? '\t' : ' '; while (value) { switch (value->type) { case json_array: if (((json_builder_value *) value)->length_iterated == 0) { if (value->u.array.length == 0) { *buf ++ = '['; *buf ++ = ']'; break; } PRINT_OPENING_BRACKET ('['); indent += opts.indent_size; PRINT_NEWLINE(); } if (((json_builder_value *) value)->length_iterated == value->u.array.length) { indent -= opts.indent_size; PRINT_NEWLINE(); PRINT_CLOSING_BRACKET (']'); ((json_builder_value *) value)->length_iterated = 0; break; } if (((json_builder_value *) value)->length_iterated > 0) { *buf ++ = ','; if (flags & f_spaces_after_commas) *buf ++ = ' '; PRINT_NEWLINE(); } ((json_builder_value *) value)->length_iterated++; value = value->u.array.values [((json_builder_value *) value)->length_iterated - 1]; continue; case json_object: if (((json_builder_value *) value)->length_iterated == 0) { if (value->u.object.length == 0) { *buf ++ = '{'; *buf ++ = '}'; break; } PRINT_OPENING_BRACKET ('{'); indent += opts.indent_size; PRINT_NEWLINE(); } if (((json_builder_value *) value)->length_iterated == value->u.object.length) { indent -= opts.indent_size; PRINT_NEWLINE(); PRINT_CLOSING_BRACKET ('}'); ((json_builder_value *) value)->length_iterated = 0; break; } if (((json_builder_value *) value)->length_iterated > 0) { *buf ++ = ','; if (flags & f_spaces_after_commas) *buf ++ = ' '; PRINT_NEWLINE(); } entry = value->u.object.values + (((json_builder_value *) value)->length_iterated ++); *buf ++ = '\"'; buf += serialize_string (buf, entry->name_length, entry->name); *buf ++ = '\"'; *buf ++ = ':'; if (flags & f_spaces_after_colons) *buf ++ = ' '; value = entry->value; continue; case json_string: *buf ++ = '\"'; buf += serialize_string (buf, value->u.string.length, value->u.string.ptr); *buf ++ = '\"'; break; case json_integer: integer = value->u.integer; if (integer < 0) { *buf ++ = '-'; integer = - integer; } orig_integer = integer; ++ buf; while (integer >= 10) { ++ buf; integer /= 10; } integer = orig_integer; ptr = buf; do { *-- ptr = "0123456789"[integer % 10]; } while ((integer /= 10) > 0); break; case json_double: ptr = buf; if (isnan(value->u.dbl)) { memcpy (buf, "null", 4); buf += 4; break; } buf += sprintf (buf, "%.12f", value->u.dbl); if ((dot = strchr (ptr, ','))) { *dot = '.'; } else if (!strchr (ptr, '.')) { *buf ++ = '.'; *buf ++ = '0'; } break; case json_boolean: if (value->u.boolean) { memcpy (buf, "true", 4); buf += 4; } else { memcpy (buf, "false", 5); buf += 5; } break; case json_null: memcpy (buf, "null", 4); buf += 4; break; default: break; }; value = value->parent; } *buf = 0; } void json_builder_free (json_value * value) { json_value * cur_value; if (!value) return; value->parent = 0; while (value) { switch (value->type) { case json_array: if (!value->u.array.length) { free (value->u.array.values); break; } value = value->u.array.values [-- value->u.array.length]; continue; case json_object: if (!value->u.object.length) { free (value->u.object.values); break; } -- value->u.object.length; if (((json_builder_value *) value)->is_builder_value) { /* Names are allocated separately for builder values. In parser * values, they are part of the same allocation as the values array * itself. */ free (value->u.object.values [value->u.object.length].name); } value = value->u.object.values [value->u.object.length].value; continue; case json_string: free (value->u.string.ptr); break; default: break; }; cur_value = value; value = value->parent; free (cur_value); } } goxel-0.11.0/ext_src/json/json-builder.h000066400000000000000000000121701435762723100201100ustar00rootroot00000000000000 /* vim: set et ts=3 sw=3 sts=3 ft=c: * * Copyright (C) 2014 James McLaughlin. All rights reserved. * https://github.com/udp/json-builder * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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 AUTHOR 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 AUTHOR 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 _JSON_BUILDER_H #define _JSON_BUILDER_H /* Requires json.h from json-parser * https://github.com/udp/json-parser */ #include "json.h" #ifdef __cplusplus extern "C" { #endif /* IMPORTANT NOTE: If you want to use json-builder functions with values * allocated by json-parser as part of the parsing process, you must pass * json_builder_extra as the value_extra setting in json_settings when * parsing. Otherwise there will not be room for the extra state and * json-builder WILL invoke undefined behaviour. * * Also note that unlike json-parser, json-builder does not currently support * custom allocators (for no particular reason other than that it doesn't have * any settings or global state.) */ extern const size_t json_builder_extra; /*** Arrays *** * Note that all of these length arguments are just a hint to allow for * pre-allocation - passing 0 is fine. */ json_value * json_array_new (size_t length); json_value * json_array_push (json_value * array, json_value *); /*** Objects ***/ json_value * json_object_new (size_t length); json_value * json_object_push (json_value * object, const json_char * name, json_value *); /* Same as json_object_push, but doesn't call strlen() for you. */ json_value * json_object_push_length (json_value * object, unsigned int name_length, const json_char * name, json_value *); /* Same as json_object_push_length, but doesn't copy the name buffer before * storing it in the value. Use this micro-optimisation at your own risk. */ json_value * json_object_push_nocopy (json_value * object, unsigned int name_length, json_char * name, json_value *); /* Merges all entries from objectB into objectA and destroys objectB. */ json_value * json_object_merge (json_value * objectA, json_value * objectB); /* Sort the entries of an object based on the order in a prototype object. * Helpful when reading JSON and writing it again to preserve user order. */ void json_object_sort (json_value * object, json_value * proto); /*** Strings ***/ json_value * json_string_new (const json_char *); json_value * json_string_new_length (unsigned int length, const json_char *); json_value * json_string_new_nocopy (unsigned int length, json_char *); /*** Everything else ***/ json_value * json_integer_new (json_int_t); json_value * json_double_new (double); json_value * json_boolean_new (int); json_value * json_null_new (); /*** Serializing ***/ #define json_serialize_mode_multiline 0 #define json_serialize_mode_single_line 1 #define json_serialize_mode_packed 2 #define json_serialize_opt_CRLF (1 << 1) #define json_serialize_opt_pack_brackets (1 << 2) #define json_serialize_opt_no_space_after_comma (1 << 3) #define json_serialize_opt_no_space_after_colon (1 << 4) #define json_serialize_opt_use_tabs (1 << 5) typedef struct json_serialize_opts { int mode; int opts; int indent_size; } json_serialize_opts; /* Returns a length in characters that is at least large enough to hold the * value in its serialized form, including a null terminator. */ size_t json_measure (json_value *); size_t json_measure_ex (json_value *, json_serialize_opts); /* Serializes a JSON value into the buffer given (which must already be * allocated with a length of at least json_measure(value, opts)) */ void json_serialize (json_char * buf, json_value *); void json_serialize_ex (json_char * buf, json_value *, json_serialize_opts); /*** Cleaning up ***/ void json_builder_free (json_value *); #ifdef __cplusplus } #endif #endif goxel-0.11.0/ext_src/json/json.c000066400000000000000000000714271435762723100164710ustar00rootroot00000000000000/* vim: set et ts=3 sw=3 sts=3 ft=c: * * Copyright (C) 2012, 2013, 2014 James McLaughlin et al. All rights reserved. * https://github.com/udp/json-parser * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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 AUTHOR 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 AUTHOR 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 "json.h" #ifdef _MSC_VER #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS #endif #endif #if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ # pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif const struct _json_value json_value_none; #include #include #include #include typedef unsigned int json_uchar; static unsigned char hex_value (json_char c) { if (isdigit(c)) return c - '0'; switch (c) { case 'a': case 'A': return 0x0A; case 'b': case 'B': return 0x0B; case 'c': case 'C': return 0x0C; case 'd': case 'D': return 0x0D; case 'e': case 'E': return 0x0E; case 'f': case 'F': return 0x0F; default: return 0xFF; } } typedef struct { unsigned long used_memory; unsigned int uint_max; unsigned long ulong_max; json_settings settings; int first_pass; const json_char * ptr; unsigned int cur_line, cur_col; } json_state; static void * default_alloc (size_t size, int zero, void * user_data) { return zero ? calloc (1, size) : malloc (size); } static void default_free (void * ptr, void * user_data) { free (ptr); } static void * json_alloc (json_state * state, unsigned long size, int zero) { if ((state->ulong_max - state->used_memory) < size) return 0; if (state->settings.max_memory && (state->used_memory += size) > state->settings.max_memory) { return 0; } return state->settings.mem_alloc (size, zero, state->settings.user_data); } static int new_value (json_state * state, json_value ** top, json_value ** root, json_value ** alloc, json_type type) { json_value * value; int values_size; if (!state->first_pass) { value = *top = *alloc; *alloc = (*alloc)->_reserved.next_alloc; if (!*root) *root = value; switch (value->type) { case json_array: if (value->u.array.length == 0) break; if (! (value->u.array.values = (json_value **) json_alloc (state, value->u.array.length * sizeof (json_value *), 0)) ) { return 0; } value->u.array.length = 0; break; case json_object: if (value->u.object.length == 0) break; values_size = sizeof (*value->u.object.values) * value->u.object.length; if (! (value->u.object.values = (json_object_entry *) json_alloc (state, values_size + ((unsigned long) value->u.object.values), 0)) ) { return 0; } value->_reserved.object_mem = (*(char **) &value->u.object.values) + values_size; value->u.object.length = 0; break; case json_string: if (! (value->u.string.ptr = (json_char *) json_alloc (state, (value->u.string.length + 1) * sizeof (json_char), 0)) ) { return 0; } value->u.string.length = 0; break; default: break; }; return 1; } if (! (value = (json_value *) json_alloc (state, sizeof (json_value) + state->settings.value_extra, 1))) { return 0; } if (!*root) *root = value; value->type = type; value->parent = *top; #ifdef JSON_TRACK_SOURCE value->line = state->cur_line; value->col = state->cur_col; #endif if (*alloc) (*alloc)->_reserved.next_alloc = value; *alloc = *top = value; return 1; } #define whitespace \ case '\n': ++ state.cur_line; state.cur_col = 0; \ case ' ': case '\t': case '\r' #define string_add(b) \ do { if (!state.first_pass) string [string_length] = b; ++ string_length; } while (0); #define line_and_col \ state.cur_line, state.cur_col static const long flag_next = 1 << 0, flag_reproc = 1 << 1, flag_need_comma = 1 << 2, flag_seek_value = 1 << 3, flag_escaped = 1 << 4, flag_string = 1 << 5, flag_need_colon = 1 << 6, flag_done = 1 << 7, flag_num_negative = 1 << 8, flag_num_zero = 1 << 9, flag_num_e = 1 << 10, flag_num_e_got_sign = 1 << 11, flag_num_e_negative = 1 << 12, flag_line_comment = 1 << 13, flag_block_comment = 1 << 14; json_value * json_parse_ex (json_settings * settings, const json_char * json, size_t length, char * error_buf) { json_char error [json_error_max]; const json_char * end; json_value * top, * root, * alloc = 0; json_state state = { 0 }; long flags; long num_digits = 0, num_e = 0; json_int_t num_fraction = 0; /* Skip UTF-8 BOM */ if (length >= 3 && ((unsigned char) json [0]) == 0xEF && ((unsigned char) json [1]) == 0xBB && ((unsigned char) json [2]) == 0xBF) { json += 3; length -= 3; } error[0] = '\0'; end = (json + length); memcpy (&state.settings, settings, sizeof (json_settings)); if (!state.settings.mem_alloc) state.settings.mem_alloc = default_alloc; if (!state.settings.mem_free) state.settings.mem_free = default_free; memset (&state.uint_max, 0xFF, sizeof (state.uint_max)); memset (&state.ulong_max, 0xFF, sizeof (state.ulong_max)); state.uint_max -= 8; /* limit of how much can be added before next check */ state.ulong_max -= 8; for (state.first_pass = 1; state.first_pass >= 0; -- state.first_pass) { json_uchar uchar; unsigned char uc_b1, uc_b2, uc_b3, uc_b4; json_char * string = 0; unsigned int string_length = 0; top = root = 0; flags = flag_seek_value; state.cur_line = 1; for (state.ptr = json ;; ++ state.ptr) { json_char b = (state.ptr == end ? 0 : *state.ptr); if (flags & flag_string) { if (!b) { sprintf (error, "Unexpected EOF in string (at %d:%d)", line_and_col); goto e_failed; } if (string_length > state.uint_max) goto e_overflow; if (flags & flag_escaped) { flags &= ~ flag_escaped; switch (b) { case 'b': string_add ('\b'); break; case 'f': string_add ('\f'); break; case 'n': string_add ('\n'); break; case 'r': string_add ('\r'); break; case 't': string_add ('\t'); break; case 'u': if (end - state.ptr < 4 || (uc_b1 = hex_value (*++ state.ptr)) == 0xFF || (uc_b2 = hex_value (*++ state.ptr)) == 0xFF || (uc_b3 = hex_value (*++ state.ptr)) == 0xFF || (uc_b4 = hex_value (*++ state.ptr)) == 0xFF) { sprintf (error, "Invalid character value `%c` (at %d:%d)", b, line_and_col); goto e_failed; } uc_b1 = (uc_b1 << 4) | uc_b2; uc_b2 = (uc_b3 << 4) | uc_b4; uchar = (uc_b1 << 8) | uc_b2; if ((uchar & 0xF800) == 0xD800) { json_uchar uchar2; if (end - state.ptr < 6 || (*++ state.ptr) != '\\' || (*++ state.ptr) != 'u' || (uc_b1 = hex_value (*++ state.ptr)) == 0xFF || (uc_b2 = hex_value (*++ state.ptr)) == 0xFF || (uc_b3 = hex_value (*++ state.ptr)) == 0xFF || (uc_b4 = hex_value (*++ state.ptr)) == 0xFF) { sprintf (error, "Invalid character value `%c` (at %d:%d)", b, line_and_col); goto e_failed; } uc_b1 = (uc_b1 << 4) | uc_b2; uc_b2 = (uc_b3 << 4) | uc_b4; uchar2 = (uc_b1 << 8) | uc_b2; uchar = 0x010000 | ((uchar & 0x3FF) << 10) | (uchar2 & 0x3FF); } if (sizeof (json_char) >= sizeof (json_uchar) || (uchar <= 0x7F)) { string_add ((json_char) uchar); break; } if (uchar <= 0x7FF) { if (state.first_pass) string_length += 2; else { string [string_length ++] = 0xC0 | (uchar >> 6); string [string_length ++] = 0x80 | (uchar & 0x3F); } break; } if (uchar <= 0xFFFF) { if (state.first_pass) string_length += 3; else { string [string_length ++] = 0xE0 | (uchar >> 12); string [string_length ++] = 0x80 | ((uchar >> 6) & 0x3F); string [string_length ++] = 0x80 | (uchar & 0x3F); } break; } if (state.first_pass) string_length += 4; else { string [string_length ++] = 0xF0 | (uchar >> 18); string [string_length ++] = 0x80 | ((uchar >> 12) & 0x3F); string [string_length ++] = 0x80 | ((uchar >> 6) & 0x3F); string [string_length ++] = 0x80 | (uchar & 0x3F); } break; default: string_add (b); }; continue; } if (b == '\\') { flags |= flag_escaped; continue; } if (b == '"') { if (!state.first_pass) string [string_length] = 0; flags &= ~ flag_string; string = 0; switch (top->type) { case json_string: top->u.string.length = string_length; flags |= flag_next; break; case json_object: if (state.first_pass) (*(json_char **) &top->u.object.values) += string_length + 1; else { top->u.object.values [top->u.object.length].name = (json_char *) top->_reserved.object_mem; top->u.object.values [top->u.object.length].name_length = string_length; (*(json_char **) &top->_reserved.object_mem) += string_length + 1; } flags |= flag_seek_value | flag_need_colon; continue; default: break; }; } else { string_add (b); continue; } } if (state.settings.settings & json_enable_comments) { if (flags & (flag_line_comment | flag_block_comment)) { if (flags & flag_line_comment) { if (b == '\r' || b == '\n' || !b) { flags &= ~ flag_line_comment; -- state.ptr; /* so null can be reproc'd */ } continue; } if (flags & flag_block_comment) { if (!b) { sprintf (error, "%d:%d: Unexpected EOF in block comment", line_and_col); goto e_failed; } if (b == '*' && state.ptr < (end - 1) && state.ptr [1] == '/') { flags &= ~ flag_block_comment; ++ state.ptr; /* skip closing sequence */ } continue; } } else if (b == '/') { if (! (flags & (flag_seek_value | flag_done)) && top->type != json_object) { sprintf (error, "%d:%d: Comment not allowed here", line_and_col); goto e_failed; } if (++ state.ptr == end) { sprintf (error, "%d:%d: EOF unexpected", line_and_col); goto e_failed; } switch (b = *state.ptr) { case '/': flags |= flag_line_comment; continue; case '*': flags |= flag_block_comment; continue; default: sprintf (error, "%d:%d: Unexpected `%c` in comment opening sequence", line_and_col, b); goto e_failed; }; } } if (flags & flag_done) { if (!b) break; switch (b) { whitespace: continue; default: sprintf (error, "%d:%d: Trailing garbage: `%c`", state.cur_line, state.cur_col, b); goto e_failed; }; } if (flags & flag_seek_value) { switch (b) { whitespace: continue; case ']': if (top && top->type == json_array) flags = (flags & ~ (flag_need_comma | flag_seek_value)) | flag_next; else { sprintf (error, "%d:%d: Unexpected ]", line_and_col); goto e_failed; } break; default: if (flags & flag_need_comma) { if (b == ',') { flags &= ~ flag_need_comma; continue; } else { sprintf (error, "%d:%d: Expected , before %c", state.cur_line, state.cur_col, b); goto e_failed; } } if (flags & flag_need_colon) { if (b == ':') { flags &= ~ flag_need_colon; continue; } else { sprintf (error, "%d:%d: Expected : before %c", state.cur_line, state.cur_col, b); goto e_failed; } } flags &= ~ flag_seek_value; switch (b) { case '{': if (!new_value (&state, &top, &root, &alloc, json_object)) goto e_alloc_failure; continue; case '[': if (!new_value (&state, &top, &root, &alloc, json_array)) goto e_alloc_failure; flags |= flag_seek_value; continue; case '"': if (!new_value (&state, &top, &root, &alloc, json_string)) goto e_alloc_failure; flags |= flag_string; string = top->u.string.ptr; string_length = 0; continue; case 't': if ((end - state.ptr) < 3 || *(++ state.ptr) != 'r' || *(++ state.ptr) != 'u' || *(++ state.ptr) != 'e') { goto e_unknown_value; } if (!new_value (&state, &top, &root, &alloc, json_boolean)) goto e_alloc_failure; top->u.boolean = 1; flags |= flag_next; break; case 'f': if ((end - state.ptr) < 4 || *(++ state.ptr) != 'a' || *(++ state.ptr) != 'l' || *(++ state.ptr) != 's' || *(++ state.ptr) != 'e') { goto e_unknown_value; } if (!new_value (&state, &top, &root, &alloc, json_boolean)) goto e_alloc_failure; flags |= flag_next; break; case 'n': if ((end - state.ptr) < 3 || *(++ state.ptr) != 'u' || *(++ state.ptr) != 'l' || *(++ state.ptr) != 'l') { goto e_unknown_value; } if (!new_value (&state, &top, &root, &alloc, json_null)) goto e_alloc_failure; flags |= flag_next; break; default: if (isdigit (b) || b == '-') { if (!new_value (&state, &top, &root, &alloc, json_integer)) goto e_alloc_failure; if (!state.first_pass) { while (isdigit (b) || b == '+' || b == '-' || b == 'e' || b == 'E' || b == '.') { if ( (++ state.ptr) == end) { b = 0; break; } b = *state.ptr; } flags |= flag_next | flag_reproc; break; } flags &= ~ (flag_num_negative | flag_num_e | flag_num_e_got_sign | flag_num_e_negative | flag_num_zero); num_digits = 0; num_fraction = 0; num_e = 0; if (b != '-') { flags |= flag_reproc; break; } flags |= flag_num_negative; continue; } else { sprintf (error, "%d:%d: Unexpected %c when seeking value", line_and_col, b); goto e_failed; } }; }; } else { switch (top->type) { case json_object: switch (b) { whitespace: continue; case '"': if (flags & flag_need_comma) { sprintf (error, "%d:%d: Expected , before \"", line_and_col); goto e_failed; } flags |= flag_string; string = (json_char *) top->_reserved.object_mem; string_length = 0; break; case '}': flags = (flags & ~ flag_need_comma) | flag_next; break; case ',': if (flags & flag_need_comma) { flags &= ~ flag_need_comma; break; } default: sprintf (error, "%d:%d: Unexpected `%c` in object", line_and_col, b); goto e_failed; }; break; case json_integer: case json_double: if (isdigit (b)) { ++ num_digits; if (top->type == json_integer || flags & flag_num_e) { if (! (flags & flag_num_e)) { if (flags & flag_num_zero) { sprintf (error, "%d:%d: Unexpected `0` before `%c`", line_and_col, b); goto e_failed; } if (num_digits == 1 && b == '0') flags |= flag_num_zero; } else { flags |= flag_num_e_got_sign; num_e = (num_e * 10) + (b - '0'); continue; } top->u.integer = (top->u.integer * 10) + (b - '0'); continue; } num_fraction = (num_fraction * 10) + (b - '0'); continue; } if (b == '+' || b == '-') { if ( (flags & flag_num_e) && !(flags & flag_num_e_got_sign)) { flags |= flag_num_e_got_sign; if (b == '-') flags |= flag_num_e_negative; continue; } } else if (b == '.' && top->type == json_integer) { if (!num_digits) { sprintf (error, "%d:%d: Expected digit before `.`", line_and_col); goto e_failed; } top->type = json_double; top->u.dbl = (double) top->u.integer; num_digits = 0; continue; } if (! (flags & flag_num_e)) { if (top->type == json_double) { if (!num_digits) { sprintf (error, "%d:%d: Expected digit after `.`", line_and_col); goto e_failed; } top->u.dbl += ((double) num_fraction) / (pow (10.0, (double) num_digits)); } if (b == 'e' || b == 'E') { flags |= flag_num_e; if (top->type == json_integer) { top->type = json_double; top->u.dbl = (double) top->u.integer; } num_digits = 0; flags &= ~ flag_num_zero; continue; } } else { if (!num_digits) { sprintf (error, "%d:%d: Expected digit after `e`", line_and_col); goto e_failed; } top->u.dbl *= pow (10.0, (double) (flags & flag_num_e_negative ? - num_e : num_e)); } if (flags & flag_num_negative) { if (top->type == json_integer) top->u.integer = - top->u.integer; else top->u.dbl = - top->u.dbl; } flags |= flag_next | flag_reproc; break; default: break; }; } if (flags & flag_reproc) { flags &= ~ flag_reproc; -- state.ptr; } if (flags & flag_next) { flags = (flags & ~ flag_next) | flag_need_comma; if (!top->parent) { /* root value done */ flags |= flag_done; continue; } if (top->parent->type == json_array) flags |= flag_seek_value; if (!state.first_pass) { json_value * parent = top->parent; switch (parent->type) { case json_object: parent->u.object.values [parent->u.object.length].value = top; break; case json_array: parent->u.array.values [parent->u.array.length] = top; break; default: break; }; } if ( (++ top->parent->u.array.length) > state.uint_max) goto e_overflow; top = top->parent; continue; } } alloc = root; } return root; e_unknown_value: sprintf (error, "%d:%d: Unknown value", line_and_col); goto e_failed; e_alloc_failure: strcpy (error, "Memory allocation failure"); goto e_failed; e_overflow: sprintf (error, "%d:%d: Too long (caught overflow)", line_and_col); goto e_failed; e_failed: if (error_buf) { if (*error) strcpy (error_buf, error); else strcpy (error_buf, "Unknown error"); } if (state.first_pass) alloc = root; while (alloc) { top = alloc->_reserved.next_alloc; state.settings.mem_free (alloc, state.settings.user_data); alloc = top; } if (!state.first_pass) json_value_free_ex (&state.settings, root); return 0; } json_value * json_parse (const json_char * json, size_t length) { json_settings settings = { 0 }; return json_parse_ex (&settings, json, length, 0); } void json_value_free_ex (json_settings * settings, json_value * value) { json_value * cur_value; if (!value) return; value->parent = 0; while (value) { switch (value->type) { case json_array: if (!value->u.array.length) { settings->mem_free (value->u.array.values, settings->user_data); break; } value = value->u.array.values [-- value->u.array.length]; continue; case json_object: if (!value->u.object.length) { settings->mem_free (value->u.object.values, settings->user_data); break; } value = value->u.object.values [-- value->u.object.length].value; continue; case json_string: settings->mem_free (value->u.string.ptr, settings->user_data); break; default: break; }; cur_value = value; value = value->parent; settings->mem_free (cur_value, settings->user_data); } } void json_value_free (json_value * value) { json_settings settings = { 0 }; settings.mem_free = default_free; json_value_free_ex (&settings, value); } goxel-0.11.0/ext_src/json/json.h000066400000000000000000000144071435762723100164710ustar00rootroot00000000000000 /* vim: set et ts=3 sw=3 sts=3 ft=c: * * Copyright (C) 2012, 2013, 2014 James McLaughlin et al. All rights reserved. * https://github.com/udp/json-parser * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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 AUTHOR 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 AUTHOR 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 _JSON_H #define _JSON_H #ifndef json_char #define json_char char #endif #ifndef json_int_t #ifndef _MSC_VER #include #define json_int_t int64_t #else #define json_int_t __int64 #endif #endif #include #ifdef __cplusplus #include extern "C" { #endif typedef struct { unsigned long max_memory; int settings; /* Custom allocator support (leave null to use malloc/free) */ void * (* mem_alloc) (size_t, int zero, void * user_data); void (* mem_free) (void *, void * user_data); void * user_data; /* will be passed to mem_alloc and mem_free */ size_t value_extra; /* how much extra space to allocate for values? */ } json_settings; #define json_enable_comments 0x01 typedef enum { json_none, json_object, json_array, json_integer, json_double, json_string, json_boolean, json_null } json_type; extern const struct _json_value json_value_none; typedef struct _json_object_entry { json_char * name; unsigned int name_length; struct _json_value * value; } json_object_entry; typedef struct _json_value { struct _json_value * parent; json_type type; union { int boolean; json_int_t integer; double dbl; struct { unsigned int length; json_char * ptr; /* null terminated */ } string; struct { unsigned int length; json_object_entry * values; #if defined(__cplusplus) && __cplusplus >= 201103L decltype(values) begin () const { return values; } decltype(values) end () const { return values + length; } #endif } object; struct { unsigned int length; struct _json_value ** values; #if defined(__cplusplus) && __cplusplus >= 201103L decltype(values) begin () const { return values; } decltype(values) end () const { return values + length; } #endif } array; } u; union { struct _json_value * next_alloc; void * object_mem; } _reserved; #ifdef JSON_TRACK_SOURCE /* Location of the value in the source JSON */ unsigned int line, col; #endif /* Some C++ operator sugar */ #ifdef __cplusplus public: inline _json_value () { memset (this, 0, sizeof (_json_value)); } inline const struct _json_value &operator [] (int index) const { if (type != json_array || index < 0 || ((unsigned int) index) >= u.array.length) { return json_value_none; } return *u.array.values [index]; } inline const struct _json_value &operator [] (const char * index) const { if (type != json_object) return json_value_none; for (unsigned int i = 0; i < u.object.length; ++ i) if (!strcmp (u.object.values [i].name, index)) return *u.object.values [i].value; return json_value_none; } inline operator const char * () const { switch (type) { case json_string: return u.string.ptr; default: return ""; }; } inline operator json_int_t () const { switch (type) { case json_integer: return u.integer; case json_double: return (json_int_t) u.dbl; default: return 0; }; } inline operator bool () const { if (type != json_boolean) return false; return u.boolean != 0; } inline operator double () const { switch (type) { case json_integer: return (double) u.integer; case json_double: return u.dbl; default: return 0; }; } #endif } json_value; json_value * json_parse (const json_char * json, size_t length); #define json_error_max 128 json_value * json_parse_ex (json_settings * settings, const json_char * json, size_t length, char * error); void json_value_free (json_value *); /* Not usually necessary, unless you used a custom mem_alloc and now want to * use a custom mem_free. */ void json_value_free_ex (json_settings * settings, json_value *); #ifdef __cplusplus } /* extern "C" */ #endif #endif goxel-0.11.0/ext_src/noc/000077500000000000000000000000001435762723100151475ustar00rootroot00000000000000goxel-0.11.0/ext_src/noc/noc_file_dialog.h000066400000000000000000000227111435762723100204200ustar00rootroot00000000000000/* noc_file_dialog library * * Copyright (c) 2015 Guillaume Chereau * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ /* A portable library to create open and save dialogs on linux, osx and * windows. * * The library define a single function : noc_file_dialog_open. * With three different implementations. * * Usage: * * The library does not automatically select the implementation, you need to * define one of those macros before including this file: * * NOC_FILE_DIALOG_GTK * NOC_FILE_DIALOG_WIN32 * NOC_FILE_DIALOG_OSX */ #ifndef NOC_INCLUDE_NOC_FILE_DIALOG_H #define NOC_INCLUDE_NOC_FILE_DIALOG_H enum { NOC_FILE_DIALOG_OPEN = 1 << 0, // Create an open file dialog. NOC_FILE_DIALOG_SAVE = 1 << 1, // Create a save file dialog. NOC_FILE_DIALOG_DIR = 1 << 2, // Open a directory. NOC_FILE_DIALOG_NO_OVERWRITE_CONFIRMATION = 1 << 3, }; // There is a single function defined. /* flags : union of the NOC_FILE_DIALOG_XXX masks. * filters : a list of strings separated by '\0' of the form: * "name1 reg1 name2 reg2 ..." * The last value is followed by two '\0'. For example, * to filter png and jpeg files, you can use: * "png\0*.png\0jpeg\0*.jpeg\0" * You can also separate patterns with ';': * "jpeg\0*.jpg;*.jpeg\0" * Set to NULL for no filter. * default_path : the default file to use or NULL. * default_name : the default file name to use or NULL. * * The function return a C string. There is no need to free it, as it is * managed by the library. The string is valid until the next call to * no_dialog_open. If the user canceled, the return value is NULL. */ const char *noc_file_dialog_open(int flags, const char *filters, const char *default_path, const char *default_name); // End of header file #endif // NOC_INCLUDE_NOC_FILE_DIALOG_H #ifdef NOC_FILE_DIALOG_IMPLEMENTATION #include #include static char *g_noc_file_dialog_ret = NULL; #ifdef NOC_FILE_DIALOG_GTK #include const char *noc_file_dialog_open(int flags, const char *filters, const char *default_path, const char *default_name) { GtkWidget *dialog; GtkFileFilter *filter; GtkFileChooser *chooser; GtkFileChooserAction action; gint res; char buf[128], *patterns; action = flags & NOC_FILE_DIALOG_SAVE ? GTK_FILE_CHOOSER_ACTION_SAVE : GTK_FILE_CHOOSER_ACTION_OPEN; if (flags & NOC_FILE_DIALOG_DIR) action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; gtk_disable_setlocale(); gtk_init_check(NULL, NULL); dialog = gtk_file_chooser_dialog_new( flags & NOC_FILE_DIALOG_SAVE ? "Save File" : "Open File", NULL, action, "_Cancel", GTK_RESPONSE_CANCEL, flags & NOC_FILE_DIALOG_SAVE ? "_Save" : "_Open", GTK_RESPONSE_ACCEPT, NULL ); chooser = GTK_FILE_CHOOSER(dialog); if (!(flags & NOC_FILE_DIALOG_NO_OVERWRITE_CONFIRMATION)) gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE); if (default_path) gtk_file_chooser_set_filename(chooser, default_path); if (default_name) gtk_file_chooser_set_current_name(chooser, default_name); while (filters && *filters) { filter = gtk_file_filter_new(); gtk_file_filter_set_name(filter, filters); filters += strlen(filters) + 1; // Split the filter pattern with ';'. strcpy(buf, filters); buf[strlen(buf)] = '\0'; for (patterns = buf; *patterns; patterns++) if (*patterns == ';') *patterns = '\0'; patterns = buf; while (*patterns) { gtk_file_filter_add_pattern(filter, patterns); patterns += strlen(patterns); if (*patterns) patterns++; } gtk_file_chooser_add_filter(chooser, filter); filters += strlen(filters) + 1; } res = gtk_dialog_run(GTK_DIALOG(dialog)); free(g_noc_file_dialog_ret); g_noc_file_dialog_ret = NULL; if (res == GTK_RESPONSE_ACCEPT) g_noc_file_dialog_ret = gtk_file_chooser_get_filename(chooser); gtk_widget_destroy(dialog); while (gtk_events_pending()) gtk_main_iteration(); return g_noc_file_dialog_ret; } #endif #ifdef NOC_FILE_DIALOG_WIN32 #include #include #include const char *noc_file_dialog_open(int flags, const char *filters, const char *default_path, const char *default_name) { OPENFILENAME ofn; // common dialog box structure BROWSEINFO bif; // only used to open directory LPITEMIDLIST lpItem; // only for open directory char szFile[260]; // buffer for file name int ret; if (!(flags & NOC_FILE_DIALOG_DIR)) { ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.lpstrFile = szFile; ofn.lpstrFile[0] = '\0'; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFilter = filters; ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; if (default_name) strcpy(ofn.lpstrFile, default_name); if (flags & NOC_FILE_DIALOG_OPEN) ret = GetOpenFileName(&ofn); else ret = GetSaveFileName(&ofn); } else { ZeroMemory(&bif, sizeof(bif)); bif.pszDisplayName = szFile; lpItem = SHBrowseForFolder(&bif); if (lpItem) { SHGetPathFromIDList(lpItem, szFile); ret = 1; } else { ret = 0; } } free(g_noc_file_dialog_ret); g_noc_file_dialog_ret = ret ? strdup(szFile) : NULL; return g_noc_file_dialog_ret; } #endif #ifdef NOC_FILE_DIALOG_OSX #include const char *noc_file_dialog_open(int flags, const char *filters, const char *default_path, const char *default_name) { NSURL *url; const char *utf8_path; NSSavePanel *panel; NSOpenPanel *open_panel; NSMutableArray *types_array; NSURL *default_url; char buf[128], *patterns; // XXX: I don't know about memory management with cococa, need to check // if I leak memory here. // NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; if (flags & NOC_FILE_DIALOG_OPEN) { panel = open_panel = [NSOpenPanel openPanel]; } else { panel = [NSSavePanel savePanel]; } if (flags & NOC_FILE_DIALOG_DIR) { [open_panel setCanChooseDirectories:YES]; [open_panel setCanChooseFiles:NO]; } if (default_path) { default_url = [NSURL fileURLWithPath: [NSString stringWithUTF8String:default_path]]; [panel setDirectoryURL:default_url]; [panel setNameFieldStringValue:default_url.lastPathComponent]; } if (filters) { types_array = [NSMutableArray array]; while (*filters) { filters += strlen(filters) + 1; // skip the name // Split the filter pattern with ';'. strcpy(buf, filters); buf[strlen(buf) + 1] = '\0'; for (patterns = buf; *patterns; patterns++) if (*patterns == ';') *patterns = '\0'; patterns = buf; while (*patterns) { assert(strncmp(patterns, "*.", 2) == 0); patterns += 2; // Skip the "*." [types_array addObject:[NSString stringWithUTF8String: patterns]]; patterns += strlen(patterns); if (*patterns) patterns++; } filters += strlen(filters) + 1; } [panel setAllowedFileTypes:types_array]; } free(g_noc_file_dialog_ret); g_noc_file_dialog_ret = NULL; if ( [panel runModal] == NSModalResponseOK ) { url = [panel URL]; utf8_path = [[url path] UTF8String]; g_noc_file_dialog_ret = strdup(utf8_path); } // [pool release]; return g_noc_file_dialog_ret; } #endif #endif goxel-0.11.0/ext_src/stb/000077500000000000000000000000001435762723100151605ustar00rootroot00000000000000goxel-0.11.0/ext_src/stb/stb_image.h000066400000000000000000010021361435762723100172660ustar00rootroot00000000000000/* stb_image - v2.22 - public domain image loader - http://nothings.org/stb no warranty implied; use at your own risk Do this: #define STB_IMAGE_IMPLEMENTATION before you include this file in *one* C or C++ file to create the implementation. // i.e. it should look like this: #include ... #include ... #include ... #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free QUICK NOTES: Primarily of interest to game developers and other people who can avoid problematic images and only need the trivial interface JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) PNG 1/2/4/8/16-bit-per-channel TGA (not sure what subset, if a subset) BMP non-1bpp, non-RLE PSD (composited view only, no extra channels, 8/16 bit-per-channel) GIF (*comp always reports as 4-channel) HDR (radiance rgbE format) PIC (Softimage PIC) PNM (PPM and PGM binary only) Animated GIF still needs a proper API, but here's one way to do it: http://gist.github.com/urraka/685d9a6340b26b830d49 - decode from memory or through FILE (define STBI_NO_STDIO to remove code) - decode from arbitrary I/O callbacks - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON) Full documentation under "DOCUMENTATION" below. LICENSE See end of file for license information. RECENT REVISION HISTORY: 2.22 (2019-03-04) gif fixes, fix warnings 2.21 (2019-02-25) fix typo in comment 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs 2.19 (2018-02-11) fix warning 2.18 (2018-01-30) fix warnings 2.17 (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings 2.16 (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes 2.15 (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs 2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; fixes 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes 2.11 (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64 RGB-format JPEG; remove white matting in PSD; allocate large structures on the stack; correct channel count for PNG & BMP 2.10 (2016-01-22) avoid warning introduced in 2.09 2.09 (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED See end of file for full revision history. ============================ Contributors ========================= Image formats Extensions, features Sean Barrett (jpeg, png, bmp) Jetro Lauha (stbi_info) Nicolas Schulz (hdr, psd) Martin "SpartanJ" Golini (stbi_info) Jonathan Dummer (tga) James "moose2000" Brown (iPhone PNG) Jean-Marc Lienher (gif) Ben "Disch" Wenger (io callbacks) Tom Seddon (pic) Omar Cornut (1/2/4-bit PNG) Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) github:urraka (animated gif) Junggon Kim (PNM comments) Christopher Forseth (animated gif) Daniel Gibson (16-bit TGA) socks-the-fox (16-bit PNG) Jeremy Sawicki (handle all ImageNet JPGs) Optimizations & bugfixes Mikhail Morozov (1-bit BMP) Fabian "ryg" Giesen Anael Seghezzi (is-16-bit query) Arseny Kapoulkine John-Mark Allen Carmelo J Fdez-Aguera Bug & warning fixes Marc LeBlanc David Woo Guillaume George Martins Mozeiko Christpher Lloyd Jerry Jansson Joseph Thomson Phil Jordan Dave Moore Roy Eltham Hayaki Saito Nathan Reed Won Chun Luke Graham Johan Duparc Nick Verigakis the Horde3D community Thomas Ruf Ronny Chevalier github:rlyeh Janez Zemva John Bartholomew Michal Cichon github:romigrou Jonathan Blow Ken Hamada Tero Hanninen github:svdijk Laurent Gomila Cort Stratton Sergio Gonzalez github:snagar Aruelien Pocheville Thibault Reuille Cass Everitt github:Zelex Ryamond Barbiero Paul Du Bois Engin Manap github:grim210 Aldo Culquicondor Philipp Wiesemann Dale Weiler github:sammyhw Oriol Ferrer Mesia Josh Tobin Matthew Gregan github:phprus Julian Raschke Gregory Mullen Baldur Karlsson github:poppolopoppo Christian Floisand Kevin Schmidt JR Smith github:darealshinji Blazej Dariusz Roszkowski github:Michaelangel007 */ #ifndef STBI_INCLUDE_STB_IMAGE_H #define STBI_INCLUDE_STB_IMAGE_H // DOCUMENTATION // // Limitations: // - no 12-bit-per-channel JPEG // - no JPEGs with arithmetic coding // - GIF always returns *comp=4 // // Basic usage (see HDR discussion below for HDR usage): // int x,y,n; // unsigned char *data = stbi_load(filename, &x, &y, &n, 0); // // ... process data if not NULL ... // // ... x = width, y = height, n = # 8-bit components per pixel ... // // ... replace '0' with '1'..'4' to force that many components per pixel // // ... but 'n' will always be the number that it would have been if you said 0 // stbi_image_free(data) // // Standard parameters: // int *x -- outputs image width in pixels // int *y -- outputs image height in pixels // int *channels_in_file -- outputs # of image components in image file // int desired_channels -- if non-zero, # of image components requested in result // // The return value from an image loader is an 'unsigned char *' which points // to the pixel data, or NULL on an allocation failure or if the image is // corrupt or invalid. The pixel data consists of *y scanlines of *x pixels, // with each pixel consisting of N interleaved 8-bit components; the first // pixel pointed to is top-left-most in the image. There is no padding between // image scanlines or between pixels, regardless of format. The number of // components N is 'desired_channels' if desired_channels is non-zero, or // *channels_in_file otherwise. If desired_channels is non-zero, // *channels_in_file has the number of components that _would_ have been // output otherwise. E.g. if you set desired_channels to 4, you will always // get RGBA output, but you can check *channels_in_file to see if it's trivially // opaque because e.g. there were only 3 channels in the source image. // // An output image with N components has the following components interleaved // in this order in each pixel: // // N=#comp components // 1 grey // 2 grey, alpha // 3 red, green, blue // 4 red, green, blue, alpha // // If image loading fails for any reason, the return value will be NULL, // and *x, *y, *channels_in_file will be unchanged. The function // stbi_failure_reason() can be queried for an extremely brief, end-user // unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS // to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly // more user-friendly ones. // // Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. // // =========================================================================== // // UNICODE: // // If compiling for Windows and you wish to use Unicode filenames, compile // with // #define STBI_WINDOWS_UTF8 // and pass utf8-encoded filenames. Call stbi_convert_wchar_to_utf8 to convert // Windows wchar_t filenames to utf8. // // =========================================================================== // // Philosophy // // stb libraries are designed with the following priorities: // // 1. easy to use // 2. easy to maintain // 3. good performance // // Sometimes I let "good performance" creep up in priority over "easy to maintain", // and for best performance I may provide less-easy-to-use APIs that give higher // performance, in addition to the easy-to-use ones. Nevertheless, it's important // to keep in mind that from the standpoint of you, a client of this library, // all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all. // // Some secondary priorities arise directly from the first two, some of which // provide more explicit reasons why performance can't be emphasized. // // - Portable ("ease of use") // - Small source code footprint ("easy to maintain") // - No dependencies ("ease of use") // // =========================================================================== // // I/O callbacks // // I/O callbacks allow you to read from arbitrary sources, like packaged // files or some other source. Data read from callbacks are processed // through a small internal buffer (currently 128 bytes) to try to reduce // overhead. // // The three functions you must define are "read" (reads some bytes of data), // "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). // // =========================================================================== // // SIMD support // // The JPEG decoder will try to automatically use SIMD kernels on x86 when // supported by the compiler. For ARM Neon support, you must explicitly // request it. // // (The old do-it-yourself SIMD API is no longer supported in the current // code.) // // On x86, SSE2 will automatically be used when available based on a run-time // test; if not, the generic C versions are used as a fall-back. On ARM targets, // the typical path is to have separate builds for NEON and non-NEON devices // (at least this is true for iOS and Android). Therefore, the NEON support is // toggled by a build flag: define STBI_NEON to get NEON loops. // // If for some reason you do not want to use any of SIMD code, or if // you have issues compiling it, you can disable it entirely by // defining STBI_NO_SIMD. // // =========================================================================== // // HDR image support (disable by defining STBI_NO_HDR) // // stb_image supports loading HDR images in general, and currently the Radiance // .HDR file format specifically. You can still load any file through the existing // interface; if you attempt to load an HDR file, it will be automatically remapped // to LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; // both of these constants can be reconfigured through this interface: // // stbi_hdr_to_ldr_gamma(2.2f); // stbi_hdr_to_ldr_scale(1.0f); // // (note, do not use _inverse_ constants; stbi_image will invert them // appropriately). // // Additionally, there is a new, parallel interface for loading files as // (linear) floats to preserve the full dynamic range: // // float *data = stbi_loadf(filename, &x, &y, &n, 0); // // If you load LDR images through this interface, those images will // be promoted to floating point values, run through the inverse of // constants corresponding to the above: // // stbi_ldr_to_hdr_scale(1.0f); // stbi_ldr_to_hdr_gamma(2.2f); // // Finally, given a filename (or an open file or memory block--see header // file for details) containing image data, you can query for the "most // appropriate" interface to use (that is, whether the image is HDR or // not), using: // // stbi_is_hdr(char *filename); // // =========================================================================== // // iPhone PNG support: // // By default we convert iphone-formatted PNGs back to RGB, even though // they are internally encoded differently. You can disable this conversion // by calling stbi_convert_iphone_png_to_rgb(0), in which case // you will always just get the native iphone "format" through (which // is BGR stored in RGB). // // Call stbi_set_unpremultiply_on_load(1) as well to force a divide per // pixel to remove any premultiplied alpha *only* if the image file explicitly // says there's premultiplied data (currently only happens in iPhone images, // and only if iPhone convert-to-rgb processing is on). // // =========================================================================== // // ADDITIONAL CONFIGURATION // // - You can suppress implementation of any of the decoders to reduce // your code footprint by #defining one or more of the following // symbols before creating the implementation. // // STBI_NO_JPEG // STBI_NO_PNG // STBI_NO_BMP // STBI_NO_PSD // STBI_NO_TGA // STBI_NO_GIF // STBI_NO_HDR // STBI_NO_PIC // STBI_NO_PNM (.ppm and .pgm) // // - You can request *only* certain decoders and suppress all other ones // (this will be more forward-compatible, as addition of new decoders // doesn't require you to disable them explicitly): // // STBI_ONLY_JPEG // STBI_ONLY_PNG // STBI_ONLY_BMP // STBI_ONLY_PSD // STBI_ONLY_TGA // STBI_ONLY_GIF // STBI_ONLY_HDR // STBI_ONLY_PIC // STBI_ONLY_PNM (.ppm and .pgm) // // - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still // want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB // #ifndef STBI_NO_STDIO #include #endif // STBI_NO_STDIO #define STBI_VERSION 1 enum { STBI_default = 0, // only used for desired_channels STBI_grey = 1, STBI_grey_alpha = 2, STBI_rgb = 3, STBI_rgb_alpha = 4 }; #include typedef unsigned char stbi_uc; typedef unsigned short stbi_us; #ifdef __cplusplus extern "C" { #endif #ifndef STBIDEF #ifdef STB_IMAGE_STATIC #define STBIDEF static #else #define STBIDEF extern #endif #endif ////////////////////////////////////////////////////////////////////////////// // // PRIMARY API - works on images of any type // // // load image by filename, open file, or memory buffer // typedef struct { int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative int (*eof) (void *user); // returns nonzero if we are at end of file/data } stbi_io_callbacks; //////////////////////////////////// // // 8-bits-per-channel interface // STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len , int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); // for stbi_load_from_file, file pointer is left pointing immediately after image #endif #ifndef STBI_NO_GIF STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp); #endif #ifdef STBI_WINDOWS_UTF8 STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); #endif //////////////////////////////////// // // 16-bits-per-channel interface // STBIDEF stbi_us *stbi_load_16_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF stbi_us *stbi_load_16 (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); #endif //////////////////////////////////// // // float-per-channel interface // #ifndef STBI_NO_LINEAR STBIDEF float *stbi_loadf_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF float *stbi_loadf (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); #endif #endif #ifndef STBI_NO_HDR STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); STBIDEF void stbi_hdr_to_ldr_scale(float scale); #endif // STBI_NO_HDR #ifndef STBI_NO_LINEAR STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); STBIDEF void stbi_ldr_to_hdr_scale(float scale); #endif // STBI_NO_LINEAR // stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); #ifndef STBI_NO_STDIO STBIDEF int stbi_is_hdr (char const *filename); STBIDEF int stbi_is_hdr_from_file(FILE *f); #endif // STBI_NO_STDIO // get a VERY brief reason for failure // NOT THREADSAFE STBIDEF const char *stbi_failure_reason (void); // free the loaded image -- this is just free() STBIDEF void stbi_image_free (void *retval_from_stbi_load); // get image dimensions & components without fully decoding STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len); STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user); #ifndef STBI_NO_STDIO STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp); STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); STBIDEF int stbi_is_16_bit (char const *filename); STBIDEF int stbi_is_16_bit_from_file(FILE *f); #endif // for image formats that explicitly notate that they have premultiplied alpha, // we just return the colors as stored in the file. set this flag to force // unpremultiplication. results are undefined if the unpremultiply overflow. STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); // indicate whether we should process iphone images back to canonical format, // or just pass them through "as-is" STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); // flip the image vertically, so the first pixel in the output array is the bottom left STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); // ZLIB client - used by PNG, available for other purposes STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); #ifdef __cplusplus } #endif // // //// end header file ///////////////////////////////////////////////////// #endif // STBI_INCLUDE_STB_IMAGE_H #ifdef STB_IMAGE_IMPLEMENTATION #if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \ || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \ || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \ || defined(STBI_ONLY_ZLIB) #ifndef STBI_ONLY_JPEG #define STBI_NO_JPEG #endif #ifndef STBI_ONLY_PNG #define STBI_NO_PNG #endif #ifndef STBI_ONLY_BMP #define STBI_NO_BMP #endif #ifndef STBI_ONLY_PSD #define STBI_NO_PSD #endif #ifndef STBI_ONLY_TGA #define STBI_NO_TGA #endif #ifndef STBI_ONLY_GIF #define STBI_NO_GIF #endif #ifndef STBI_ONLY_HDR #define STBI_NO_HDR #endif #ifndef STBI_ONLY_PIC #define STBI_NO_PIC #endif #ifndef STBI_ONLY_PNM #define STBI_NO_PNM #endif #endif #if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) #define STBI_NO_ZLIB #endif #include #include // ptrdiff_t on osx #include #include #include #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) #include // ldexp, pow #endif #ifndef STBI_NO_STDIO #include #endif #ifndef STBI_ASSERT #include #define STBI_ASSERT(x) assert(x) #endif #ifdef __cplusplus #define STBI_EXTERN extern "C" #else #define STBI_EXTERN extern #endif #ifndef _MSC_VER #ifdef __cplusplus #define stbi_inline inline #else #define stbi_inline #endif #else #define stbi_inline __forceinline #endif #ifdef _MSC_VER typedef unsigned short stbi__uint16; typedef signed short stbi__int16; typedef unsigned int stbi__uint32; typedef signed int stbi__int32; #else #include typedef uint16_t stbi__uint16; typedef int16_t stbi__int16; typedef uint32_t stbi__uint32; typedef int32_t stbi__int32; #endif // should produce compiler error if size is wrong typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; #ifdef _MSC_VER #define STBI_NOTUSED(v) (void)(v) #else #define STBI_NOTUSED(v) (void)sizeof(v) #endif #ifdef _MSC_VER #define STBI_HAS_LROTL #endif #ifdef STBI_HAS_LROTL #define stbi_lrot(x,y) _lrotl(x,y) #else #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) #endif #if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) // ok #elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED) // ok #else #error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." #endif #ifndef STBI_MALLOC #define STBI_MALLOC(sz) malloc(sz) #define STBI_REALLOC(p,newsz) realloc(p,newsz) #define STBI_FREE(p) free(p) #endif #ifndef STBI_REALLOC_SIZED #define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz) #endif // x86/x64 detection #if defined(__x86_64__) || defined(_M_X64) #define STBI__X64_TARGET #elif defined(__i386) || defined(_M_IX86) #define STBI__X86_TARGET #endif #if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) // gcc doesn't support sse2 intrinsics unless you compile with -msse2, // which in turn means it gets to use SSE2 everywhere. This is unfortunate, // but previous attempts to provide the SSE2 functions with runtime // detection caused numerous issues. The way architecture extensions are // exposed in GCC/Clang is, sadly, not really suited for one-file libs. // New behavior: if compiled with -msse2, we use SSE2 without any // detection; if not, we don't use it at all. #define STBI_NO_SIMD #endif #if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) // Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET // // 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the // Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. // As a result, enabling SSE2 on 32-bit MinGW is dangerous when not // simultaneously enabling "-mstackrealign". // // See https://github.com/nothings/stb/issues/81 for more information. // // So default to no SSE2 on 32-bit MinGW. If you've read this far and added // -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. #define STBI_NO_SIMD #endif #if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) #define STBI_SSE2 #include #ifdef _MSC_VER #if _MSC_VER >= 1400 // not VC6 #include // __cpuid static int stbi__cpuid3(void) { int info[4]; __cpuid(info,1); return info[3]; } #else static int stbi__cpuid3(void) { int res; __asm { mov eax,1 cpuid mov res,edx } return res; } #endif #define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name #if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) static int stbi__sse2_available(void) { int info3 = stbi__cpuid3(); return ((info3 >> 26) & 1) != 0; } #endif #else // assume GCC-style if not VC++ #define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) #if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) static int stbi__sse2_available(void) { // If we're even attempting to compile this on GCC/Clang, that means // -msse2 is on, which means the compiler is allowed to use SSE2 // instructions at will, and so are we. return 1; } #endif #endif #endif // ARM NEON #if defined(STBI_NO_SIMD) && defined(STBI_NEON) #undef STBI_NEON #endif #ifdef STBI_NEON #include // assume GCC or Clang on ARM targets #define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) #endif #ifndef STBI_SIMD_ALIGN #define STBI_SIMD_ALIGN(type, name) type name #endif /////////////////////////////////////////////// // // stbi__context struct and start_xxx functions // stbi__context structure is our basic context used by all images, so it // contains all the IO context, plus some basic image information typedef struct { stbi__uint32 img_x, img_y; int img_n, img_out_n; stbi_io_callbacks io; void *io_user_data; int read_from_callbacks; int buflen; stbi_uc buffer_start[128]; stbi_uc *img_buffer, *img_buffer_end; stbi_uc *img_buffer_original, *img_buffer_original_end; } stbi__context; static void stbi__refill_buffer(stbi__context *s); // initialize a memory-decode context static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) { s->io.read = NULL; s->read_from_callbacks = 0; s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer; s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len; } // initialize a callback-based context static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) { s->io = *c; s->io_user_data = user; s->buflen = sizeof(s->buffer_start); s->read_from_callbacks = 1; s->img_buffer_original = s->buffer_start; stbi__refill_buffer(s); s->img_buffer_original_end = s->img_buffer_end; } #ifndef STBI_NO_STDIO static int stbi__stdio_read(void *user, char *data, int size) { return (int) fread(data,1,size,(FILE*) user); } static void stbi__stdio_skip(void *user, int n) { fseek((FILE*) user, n, SEEK_CUR); } static int stbi__stdio_eof(void *user) { return feof((FILE*) user); } static stbi_io_callbacks stbi__stdio_callbacks = { stbi__stdio_read, stbi__stdio_skip, stbi__stdio_eof, }; static void stbi__start_file(stbi__context *s, FILE *f) { stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f); } //static void stop_file(stbi__context *s) { } #endif // !STBI_NO_STDIO static void stbi__rewind(stbi__context *s) { // conceptually rewind SHOULD rewind to the beginning of the stream, // but we just rewind to the beginning of the initial buffer, because // we only use it after doing 'test', which only ever looks at at most 92 bytes s->img_buffer = s->img_buffer_original; s->img_buffer_end = s->img_buffer_original_end; } enum { STBI_ORDER_RGB, STBI_ORDER_BGR }; typedef struct { int bits_per_channel; int num_channels; int channel_order; } stbi__result_info; #ifndef STBI_NO_JPEG static int stbi__jpeg_test(stbi__context *s); static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PNG static int stbi__png_test(stbi__context *s); static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); static int stbi__png_is16(stbi__context *s); #endif #ifndef STBI_NO_BMP static int stbi__bmp_test(stbi__context *s); static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_TGA static int stbi__tga_test(stbi__context *s); static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PSD static int stbi__psd_test(stbi__context *s); static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc); static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); static int stbi__psd_is16(stbi__context *s); #endif #ifndef STBI_NO_HDR static int stbi__hdr_test(stbi__context *s); static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PIC static int stbi__pic_test(stbi__context *s); static void *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_GIF static int stbi__gif_test(stbi__context *s); static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp); static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PNM static int stbi__pnm_test(stbi__context *s); static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); #endif // this is not threadsafe static const char *stbi__g_failure_reason; STBIDEF const char *stbi_failure_reason(void) { return stbi__g_failure_reason; } static int stbi__err(const char *str) { stbi__g_failure_reason = str; return 0; } static void *stbi__malloc(size_t size) { return STBI_MALLOC(size); } // stb_image uses ints pervasively, including for offset calculations. // therefore the largest decoded image size we can support with the // current code, even on 64-bit targets, is INT_MAX. this is not a // significant limitation for the intended use case. // // we do, however, need to make sure our size calculations don't // overflow. hence a few helper functions for size calculations that // multiply integers together, making sure that they're non-negative // and no overflow occurs. // return 1 if the sum is valid, 0 on overflow. // negative terms are considered invalid. static int stbi__addsizes_valid(int a, int b) { if (b < 0) return 0; // now 0 <= b <= INT_MAX, hence also // 0 <= INT_MAX - b <= INTMAX. // And "a + b <= INT_MAX" (which might overflow) is the // same as a <= INT_MAX - b (no overflow) return a <= INT_MAX - b; } // returns 1 if the product is valid, 0 on overflow. // negative factors are considered invalid. static int stbi__mul2sizes_valid(int a, int b) { if (a < 0 || b < 0) return 0; if (b == 0) return 1; // mul-by-0 is always safe // portable way to check for no overflows in a*b return a <= INT_MAX/b; } // returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow static int stbi__mad2sizes_valid(int a, int b, int add) { return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add); } // returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow static int stbi__mad3sizes_valid(int a, int b, int c, int add) { return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && stbi__addsizes_valid(a*b*c, add); } // returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) { return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add); } #endif // mallocs with size overflow checking static void *stbi__malloc_mad2(int a, int b, int add) { if (!stbi__mad2sizes_valid(a, b, add)) return NULL; return stbi__malloc(a*b + add); } static void *stbi__malloc_mad3(int a, int b, int c, int add) { if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL; return stbi__malloc(a*b*c + add); } #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) { if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL; return stbi__malloc(a*b*c*d + add); } #endif // stbi__err - error // stbi__errpf - error returning pointer to float // stbi__errpuc - error returning pointer to unsigned char #ifdef STBI_NO_FAILURE_STRINGS #define stbi__err(x,y) 0 #elif defined(STBI_FAILURE_USERMSG) #define stbi__err(x,y) stbi__err(y) #else #define stbi__err(x,y) stbi__err(x) #endif #define stbi__errpf(x,y) ((float *)(size_t) (stbi__err(x,y)?NULL:NULL)) #define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL)) STBIDEF void stbi_image_free(void *retval_from_stbi_load) { STBI_FREE(retval_from_stbi_load); } #ifndef STBI_NO_LINEAR static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); #endif #ifndef STBI_NO_HDR static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); #endif static int stbi__vertically_flip_on_load = 0; STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) { stbi__vertically_flip_on_load = flag_true_if_should_flip; } static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) { memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order ri->num_channels = 0; #ifndef STBI_NO_JPEG if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_PNG if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_BMP if (stbi__bmp_test(s)) return stbi__bmp_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_GIF if (stbi__gif_test(s)) return stbi__gif_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_PSD if (stbi__psd_test(s)) return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc); #endif #ifndef STBI_NO_PIC if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_PNM if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_HDR if (stbi__hdr_test(s)) { float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri); return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); } #endif #ifndef STBI_NO_TGA // test tga last because it's a crappy test! if (stbi__tga_test(s)) return stbi__tga_load(s,x,y,comp,req_comp, ri); #endif return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); } static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels) { int i; int img_len = w * h * channels; stbi_uc *reduced; reduced = (stbi_uc *) stbi__malloc(img_len); if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory"); for (i = 0; i < img_len; ++i) reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling STBI_FREE(orig); return reduced; } static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels) { int i; int img_len = w * h * channels; stbi__uint16 *enlarged; enlarged = (stbi__uint16 *) stbi__malloc(img_len*2); if (enlarged == NULL) return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); for (i = 0; i < img_len; ++i) enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff STBI_FREE(orig); return enlarged; } static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) { int row; size_t bytes_per_row = (size_t)w * bytes_per_pixel; stbi_uc temp[2048]; stbi_uc *bytes = (stbi_uc *)image; for (row = 0; row < (h>>1); row++) { stbi_uc *row0 = bytes + row*bytes_per_row; stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row; // swap row0 with row1 size_t bytes_left = bytes_per_row; while (bytes_left) { size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp); memcpy(temp, row0, bytes_copy); memcpy(row0, row1, bytes_copy); memcpy(row1, temp, bytes_copy); row0 += bytes_copy; row1 += bytes_copy; bytes_left -= bytes_copy; } } } #ifndef STBI_NO_GIF static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel) { int slice; int slice_size = w * h * bytes_per_pixel; stbi_uc *bytes = (stbi_uc *)image; for (slice = 0; slice < z; ++slice) { stbi__vertical_flip(bytes, w, h, bytes_per_pixel); bytes += slice_size; } } #endif static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi__result_info ri; void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8); if (result == NULL) return NULL; if (ri.bits_per_channel != 8) { STBI_ASSERT(ri.bits_per_channel == 16); result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp); ri.bits_per_channel = 8; } // @TODO: move stbi__convert_format to here if (stbi__vertically_flip_on_load) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); } return (unsigned char *) result; } static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi__result_info ri; void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16); if (result == NULL) return NULL; if (ri.bits_per_channel != 16) { STBI_ASSERT(ri.bits_per_channel == 8); result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp); ri.bits_per_channel = 16; } // @TODO: move stbi__convert_format16 to here // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision if (stbi__vertically_flip_on_load) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16)); } return (stbi__uint16 *) result; } #if !defined(STBI_NO_HDR) && !defined(STBI_NO_LINEAR) static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) { if (stbi__vertically_flip_on_load && result != NULL) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(float)); } } #endif #ifndef STBI_NO_STDIO #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); #endif #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) { return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); } #endif static FILE *stbi__fopen(char const *filename, char const *mode) { FILE *f; #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) wchar_t wMode[64]; wchar_t wFilename[1024]; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename))) return 0; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode))) return 0; #if _MSC_VER >= 1400 if (0 != _wfopen_s(&f, wFilename, wMode)) f = 0; #else f = _wfopen(wFilename, wMode); #endif #elif defined(_MSC_VER) && _MSC_VER >= 1400 if (0 != fopen_s(&f, filename, mode)) f=0; #else f = fopen(filename, mode); #endif return f; } STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) { FILE *f = stbi__fopen(filename, "rb"); unsigned char *result; if (!f) return stbi__errpuc("can't fopen", "Unable to open file"); result = stbi_load_from_file(f,x,y,comp,req_comp); fclose(f); return result; } STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { unsigned char *result; stbi__context s; stbi__start_file(&s,f); result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); if (result) { // need to 'unget' all the characters in the IO buffer fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); } return result; } STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp) { stbi__uint16 *result; stbi__context s; stbi__start_file(&s,f); result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp); if (result) { // need to 'unget' all the characters in the IO buffer fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); } return result; } STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp) { FILE *f = stbi__fopen(filename, "rb"); stbi__uint16 *result; if (!f) return (stbi_us *) stbi__errpuc("can't fopen", "Unable to open file"); result = stbi_load_from_file_16(f,x,y,comp,req_comp); fclose(f); return result; } #endif //!STBI_NO_STDIO STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); } STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); } STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); } STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); } #ifndef STBI_NO_GIF STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp) { unsigned char *result; stbi__context s; stbi__start_mem(&s,buffer,len); result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp); if (stbi__vertically_flip_on_load) { stbi__vertical_flip_slices( result, *x, *y, *z, *comp ); } return result; } #endif #ifndef STBI_NO_LINEAR static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) { unsigned char *data; #ifndef STBI_NO_HDR if (stbi__hdr_test(s)) { stbi__result_info ri; float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp, &ri); if (hdr_data) stbi__float_postprocess(hdr_data,x,y,comp,req_comp); return hdr_data; } #endif data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp); if (data) return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); } STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__loadf_main(&s,x,y,comp,req_comp); } STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__loadf_main(&s,x,y,comp,req_comp); } #ifndef STBI_NO_STDIO STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) { float *result; FILE *f = stbi__fopen(filename, "rb"); if (!f) return stbi__errpf("can't fopen", "Unable to open file"); result = stbi_loadf_from_file(f,x,y,comp,req_comp); fclose(f); return result; } STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_file(&s,f); return stbi__loadf_main(&s,x,y,comp,req_comp); } #endif // !STBI_NO_STDIO #endif // !STBI_NO_LINEAR // these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is // defined, for API simplicity; if STBI_NO_LINEAR is defined, it always // reports false! STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) { #ifndef STBI_NO_HDR stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__hdr_test(&s); #else STBI_NOTUSED(buffer); STBI_NOTUSED(len); return 0; #endif } #ifndef STBI_NO_STDIO STBIDEF int stbi_is_hdr (char const *filename) { FILE *f = stbi__fopen(filename, "rb"); int result=0; if (f) { result = stbi_is_hdr_from_file(f); fclose(f); } return result; } STBIDEF int stbi_is_hdr_from_file(FILE *f) { #ifndef STBI_NO_HDR long pos = ftell(f); int res; stbi__context s; stbi__start_file(&s,f); res = stbi__hdr_test(&s); fseek(f, pos, SEEK_SET); return res; #else STBI_NOTUSED(f); return 0; #endif } #endif // !STBI_NO_STDIO STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) { #ifndef STBI_NO_HDR stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__hdr_test(&s); #else STBI_NOTUSED(clbk); STBI_NOTUSED(user); return 0; #endif } #ifndef STBI_NO_LINEAR static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f; STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } #endif static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f; STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } ////////////////////////////////////////////////////////////////////////////// // // Common code used by all image loaders // enum { STBI__SCAN_load=0, STBI__SCAN_type, STBI__SCAN_header }; static void stbi__refill_buffer(stbi__context *s) { int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); if (n == 0) { // at end of file, treat same as if from memory, but need to handle case // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file s->read_from_callbacks = 0; s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start+1; *s->img_buffer = 0; } else { s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start + n; } } stbi_inline static stbi_uc stbi__get8(stbi__context *s) { if (s->img_buffer < s->img_buffer_end) return *s->img_buffer++; if (s->read_from_callbacks) { stbi__refill_buffer(s); return *s->img_buffer++; } return 0; } stbi_inline static int stbi__at_eof(stbi__context *s) { if (s->io.read) { if (!(s->io.eof)(s->io_user_data)) return 0; // if feof() is true, check if buffer = end // special case: we've only got the special 0 character at the end if (s->read_from_callbacks == 0) return 1; } return s->img_buffer >= s->img_buffer_end; } static void stbi__skip(stbi__context *s, int n) { if (n < 0) { s->img_buffer = s->img_buffer_end; return; } if (s->io.read) { int blen = (int) (s->img_buffer_end - s->img_buffer); if (blen < n) { s->img_buffer = s->img_buffer_end; (s->io.skip)(s->io_user_data, n - blen); return; } } s->img_buffer += n; } static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) { if (s->io.read) { int blen = (int) (s->img_buffer_end - s->img_buffer); if (blen < n) { int res, count; memcpy(buffer, s->img_buffer, blen); count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); res = (count == (n-blen)); s->img_buffer = s->img_buffer_end; return res; } } if (s->img_buffer+n <= s->img_buffer_end) { memcpy(buffer, s->img_buffer, n); s->img_buffer += n; return 1; } else return 0; } static int stbi__get16be(stbi__context *s) { int z = stbi__get8(s); return (z << 8) + stbi__get8(s); } static stbi__uint32 stbi__get32be(stbi__context *s) { stbi__uint32 z = stbi__get16be(s); return (z << 16) + stbi__get16be(s); } #if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) // nothing #else static int stbi__get16le(stbi__context *s) { int z = stbi__get8(s); return z + (stbi__get8(s) << 8); } #endif #ifndef STBI_NO_BMP static stbi__uint32 stbi__get32le(stbi__context *s) { stbi__uint32 z = stbi__get16le(s); return z + (stbi__get16le(s) << 16); } #endif #define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings ////////////////////////////////////////////////////////////////////////////// // // generic converter from built-in img_n to req_comp // individual types do this automatically as much as possible (e.g. jpeg // does all cases internally since it needs to colorspace convert anyway, // and it never has alpha, so very few cases ). png can automatically // interleave an alpha=255 channel, but falls back to this for other cases // // assume data buffer is malloced, so malloc a new one and free that one // only failure mode is malloc failing static stbi_uc stbi__compute_y(int r, int g, int b) { return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8); } static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) { int i,j; unsigned char *good; if (req_comp == img_n) return data; STBI_ASSERT(req_comp >= 1 && req_comp <= 4); good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0); if (good == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } for (j=0; j < (int) y; ++j) { unsigned char *src = data + j * x * img_n ; unsigned char *dest = good + j * x * req_comp; #define STBI__COMBO(a,b) ((a)*8+(b)) #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) // convert source image with img_n components to one with req_comp components; // avoid switch per pixel, so use switch per scanline and massive macros switch (STBI__COMBO(img_n, req_comp)) { STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=255; } break; STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255; } break; STBI__CASE(2,1) { dest[0]=src[0]; } break; STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=255; } break; STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255; } break; STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break; STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; default: STBI_ASSERT(0); } #undef STBI__CASE } STBI_FREE(data); return good; } static stbi__uint16 stbi__compute_y_16(int r, int g, int b) { return (stbi__uint16) (((r*77) + (g*150) + (29*b)) >> 8); } static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y) { int i,j; stbi__uint16 *good; if (req_comp == img_n) return data; STBI_ASSERT(req_comp >= 1 && req_comp <= 4); good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2); if (good == NULL) { STBI_FREE(data); return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); } for (j=0; j < (int) y; ++j) { stbi__uint16 *src = data + j * x * img_n ; stbi__uint16 *dest = good + j * x * req_comp; #define STBI__COMBO(a,b) ((a)*8+(b)) #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) // convert source image with img_n components to one with req_comp components; // avoid switch per pixel, so use switch per scanline and massive macros switch (STBI__COMBO(img_n, req_comp)) { STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=0xffff; } break; STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=0xffff; } break; STBI__CASE(2,1) { dest[0]=src[0]; } break; STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=0xffff; } break; STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = 0xffff; } break; STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = src[3]; } break; STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; default: STBI_ASSERT(0); } #undef STBI__CASE } STBI_FREE(data); return good; } #ifndef STBI_NO_LINEAR static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) { int i,k,n; float *output; if (!data) return NULL; output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0); if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } // compute number of non-alpha components if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); } } if (n < comp) { for (i=0; i < x*y; ++i) { output[i*comp + n] = data[i*comp + n]/255.0f; } } STBI_FREE(data); return output; } #endif #ifndef STBI_NO_HDR #define stbi__float2int(x) ((int) (x)) static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) { int i,k,n; stbi_uc *output; if (!data) return NULL; output = (stbi_uc *) stbi__malloc_mad3(x, y, comp, 0); if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } // compute number of non-alpha components if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi_uc) stbi__float2int(z); } if (k < comp) { float z = data[i*comp+k] * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi_uc) stbi__float2int(z); } } STBI_FREE(data); return output; } #endif ////////////////////////////////////////////////////////////////////////////// // // "baseline" JPEG/JFIF decoder // // simple implementation // - doesn't support delayed output of y-dimension // - simple interface (only one output format: 8-bit interleaved RGB) // - doesn't try to recover corrupt jpegs // - doesn't allow partial loading, loading multiple at once // - still fast on x86 (copying globals into locals doesn't help x86) // - allocates lots of intermediate memory (full size of all components) // - non-interleaved case requires this anyway // - allows good upsampling (see next) // high-quality // - upsampled channels are bilinearly interpolated, even across blocks // - quality integer IDCT derived from IJG's 'slow' // performance // - fast huffman; reasonable integer IDCT // - some SIMD kernels for common paths on targets with SSE2/NEON // - uses a lot of intermediate memory, could cache poorly #ifndef STBI_NO_JPEG // huffman decoding acceleration #define FAST_BITS 9 // larger handles more cases; smaller stomps less cache typedef struct { stbi_uc fast[1 << FAST_BITS]; // weirdly, repacking this into AoS is a 10% speed loss, instead of a win stbi__uint16 code[256]; stbi_uc values[256]; stbi_uc size[257]; unsigned int maxcode[18]; int delta[17]; // old 'firstsymbol' - old 'firstcode' } stbi__huffman; typedef struct { stbi__context *s; stbi__huffman huff_dc[4]; stbi__huffman huff_ac[4]; stbi__uint16 dequant[4][64]; stbi__int16 fast_ac[4][1 << FAST_BITS]; // sizes for components, interleaved MCUs int img_h_max, img_v_max; int img_mcu_x, img_mcu_y; int img_mcu_w, img_mcu_h; // definition of jpeg image component struct { int id; int h,v; int tq; int hd,ha; int dc_pred; int x,y,w2,h2; stbi_uc *data; void *raw_data, *raw_coeff; stbi_uc *linebuf; short *coeff; // progressive only int coeff_w, coeff_h; // number of 8x8 coefficient blocks } img_comp[4]; stbi__uint32 code_buffer; // jpeg entropy-coded buffer int code_bits; // number of valid bits unsigned char marker; // marker seen while filling entropy buffer int nomore; // flag if we saw a marker so must stop int progressive; int spec_start; int spec_end; int succ_high; int succ_low; int eob_run; int jfif; int app14_color_transform; // Adobe APP14 tag int rgb; int scan_n, order[4]; int restart_interval, todo; // kernels void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step); stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs); } stbi__jpeg; static int stbi__build_huffman(stbi__huffman *h, int *count) { int i,j,k=0; unsigned int code; // build size list for each symbol (from JPEG spec) for (i=0; i < 16; ++i) for (j=0; j < count[i]; ++j) h->size[k++] = (stbi_uc) (i+1); h->size[k] = 0; // compute actual symbols (from jpeg spec) code = 0; k = 0; for(j=1; j <= 16; ++j) { // compute delta to add to code to compute symbol id h->delta[j] = k - code; if (h->size[k] == j) { while (h->size[k] == j) h->code[k++] = (stbi__uint16) (code++); if (code-1 >= (1u << j)) return stbi__err("bad code lengths","Corrupt JPEG"); } // compute largest code + 1 for this size, preshifted as needed later h->maxcode[j] = code << (16-j); code <<= 1; } h->maxcode[j] = 0xffffffff; // build non-spec acceleration table; 255 is flag for not-accelerated memset(h->fast, 255, 1 << FAST_BITS); for (i=0; i < k; ++i) { int s = h->size[i]; if (s <= FAST_BITS) { int c = h->code[i] << (FAST_BITS-s); int m = 1 << (FAST_BITS-s); for (j=0; j < m; ++j) { h->fast[c+j] = (stbi_uc) i; } } } return 1; } // build a table that decodes both magnitude and value of small ACs in // one go. static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) { int i; for (i=0; i < (1 << FAST_BITS); ++i) { stbi_uc fast = h->fast[i]; fast_ac[i] = 0; if (fast < 255) { int rs = h->values[fast]; int run = (rs >> 4) & 15; int magbits = rs & 15; int len = h->size[fast]; if (magbits && len + magbits <= FAST_BITS) { // magnitude code followed by receive_extend code int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); int m = 1 << (magbits - 1); if (k < m) k += (~0U << magbits) + 1; // if the result is small enough, we can fit it in fast_ac table if (k >= -128 && k <= 127) fast_ac[i] = (stbi__int16) ((k * 256) + (run * 16) + (len + magbits)); } } } } static void stbi__grow_buffer_unsafe(stbi__jpeg *j) { do { unsigned int b = j->nomore ? 0 : stbi__get8(j->s); if (b == 0xff) { int c = stbi__get8(j->s); while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes if (c != 0) { j->marker = (unsigned char) c; j->nomore = 1; return; } } j->code_buffer |= b << (24 - j->code_bits); j->code_bits += 8; } while (j->code_bits <= 24); } // (1 << n) - 1 static const stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; // decode a jpeg huffman value from the bitstream stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) { unsigned int temp; int c,k; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); // look at the top FAST_BITS and determine what symbol ID it is, // if the code is <= FAST_BITS c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); k = h->fast[c]; if (k < 255) { int s = h->size[k]; if (s > j->code_bits) return -1; j->code_buffer <<= s; j->code_bits -= s; return h->values[k]; } // naive test is to shift the code_buffer down so k bits are // valid, then test against maxcode. To speed this up, we've // preshifted maxcode left so that it has (16-k) 0s at the // end; in other words, regardless of the number of bits, it // wants to be compared against something shifted to have 16; // that way we don't need to shift inside the loop. temp = j->code_buffer >> 16; for (k=FAST_BITS+1 ; ; ++k) if (temp < h->maxcode[k]) break; if (k == 17) { // error! code not found j->code_bits -= 16; return -1; } if (k > j->code_bits) return -1; // convert the huffman code to the symbol id c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); // convert the id to a symbol j->code_bits -= k; j->code_buffer <<= k; return h->values[c]; } // bias[n] = (-1<code_bits < n) stbi__grow_buffer_unsafe(j); sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB k = stbi_lrot(j->code_buffer, n); STBI_ASSERT(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))); j->code_buffer = k & ~stbi__bmask[n]; k &= stbi__bmask[n]; j->code_bits -= n; return k + (stbi__jbias[n] & ~sgn); } // get some unsigned bits stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) { unsigned int k; if (j->code_bits < n) stbi__grow_buffer_unsafe(j); k = stbi_lrot(j->code_buffer, n); j->code_buffer = k & ~stbi__bmask[n]; k &= stbi__bmask[n]; j->code_bits -= n; return k; } stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) { unsigned int k; if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); k = j->code_buffer; j->code_buffer <<= 1; --j->code_bits; return k & 0x80000000; } // given a value that's at position X in the zigzag stream, // where does it appear in the 8x8 matrix coded as row-major? static const stbi_uc stbi__jpeg_dezigzag[64+15] = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, // let corrupt input sample past end 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 }; // decode one 64-entry block-- static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant) { int diff,dc,k; int t; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); t = stbi__jpeg_huff_decode(j, hdc); if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG"); // 0 all the ac values now so we can do it 32-bits at a time memset(data,0,64*sizeof(data[0])); diff = t ? stbi__extend_receive(j, t) : 0; dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; data[0] = (short) (dc * dequant[0]); // decode AC components, see JPEG spec k = 1; do { unsigned int zig; int c,r,s; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; if (r) { // fast-AC path k += (r >> 4) & 15; // run s = r & 15; // combined length j->code_buffer <<= s; j->code_bits -= s; // decode into unzigzag'd location zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) * dequant[zig]); } else { int rs = stbi__jpeg_huff_decode(j, hac); if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (rs != 0xf0) break; // end block k += 16; } else { k += r; // decode into unzigzag'd location zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); } } } while (k < 64); return 1; } static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) { int diff,dc; int t; if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); if (j->succ_high == 0) { // first scan for DC coefficient, must be first memset(data,0,64*sizeof(data[0])); // 0 all the ac values now t = stbi__jpeg_huff_decode(j, hdc); diff = t ? stbi__extend_receive(j, t) : 0; dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; data[0] = (short) (dc << j->succ_low); } else { // refinement scan for DC coefficient if (stbi__jpeg_get_bit(j)) data[0] += (short) (1 << j->succ_low); } return 1; } // @OPTIMIZE: store non-zigzagged during the decode passes, // and only de-zigzag when dequantizing static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac) { int k; if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); if (j->succ_high == 0) { int shift = j->succ_low; if (j->eob_run) { --j->eob_run; return 1; } k = j->spec_start; do { unsigned int zig; int c,r,s; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; if (r) { // fast-AC path k += (r >> 4) & 15; // run s = r & 15; // combined length j->code_buffer <<= s; j->code_bits -= s; zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) << shift); } else { int rs = stbi__jpeg_huff_decode(j, hac); if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (r < 15) { j->eob_run = (1 << r); if (r) j->eob_run += stbi__jpeg_get_bits(j, r); --j->eob_run; break; } k += 16; } else { k += r; zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) (stbi__extend_receive(j,s) << shift); } } } while (k <= j->spec_end); } else { // refinement scan for these AC coefficients short bit = (short) (1 << j->succ_low); if (j->eob_run) { --j->eob_run; for (k = j->spec_start; k <= j->spec_end; ++k) { short *p = &data[stbi__jpeg_dezigzag[k]]; if (*p != 0) if (stbi__jpeg_get_bit(j)) if ((*p & bit)==0) { if (*p > 0) *p += bit; else *p -= bit; } } } else { k = j->spec_start; do { int r,s; int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (r < 15) { j->eob_run = (1 << r) - 1; if (r) j->eob_run += stbi__jpeg_get_bits(j, r); r = 64; // force end of block } else { // r=15 s=0 should write 16 0s, so we just do // a run of 15 0s and then write s (which is 0), // so we don't have to do anything special here } } else { if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); // sign bit if (stbi__jpeg_get_bit(j)) s = bit; else s = -bit; } // advance by r while (k <= j->spec_end) { short *p = &data[stbi__jpeg_dezigzag[k++]]; if (*p != 0) { if (stbi__jpeg_get_bit(j)) if ((*p & bit)==0) { if (*p > 0) *p += bit; else *p -= bit; } } else { if (r == 0) { *p = (short) s; break; } --r; } } } while (k <= j->spec_end); } } return 1; } // take a -128..127 value and stbi__clamp it and convert to 0..255 stbi_inline static stbi_uc stbi__clamp(int x) { // trick to use a single test to catch both cases if ((unsigned int) x > 255) { if (x < 0) return 0; if (x > 255) return 255; } return (stbi_uc) x; } #define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) #define stbi__fsh(x) ((x) * 4096) // derived from jidctint -- DCT_ISLOW #define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ p2 = s2; \ p3 = s6; \ p1 = (p2+p3) * stbi__f2f(0.5411961f); \ t2 = p1 + p3*stbi__f2f(-1.847759065f); \ t3 = p1 + p2*stbi__f2f( 0.765366865f); \ p2 = s0; \ p3 = s4; \ t0 = stbi__fsh(p2+p3); \ t1 = stbi__fsh(p2-p3); \ x0 = t0+t3; \ x3 = t0-t3; \ x1 = t1+t2; \ x2 = t1-t2; \ t0 = s7; \ t1 = s5; \ t2 = s3; \ t3 = s1; \ p3 = t0+t2; \ p4 = t1+t3; \ p1 = t0+t3; \ p2 = t1+t2; \ p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ t0 = t0*stbi__f2f( 0.298631336f); \ t1 = t1*stbi__f2f( 2.053119869f); \ t2 = t2*stbi__f2f( 3.072711026f); \ t3 = t3*stbi__f2f( 1.501321110f); \ p1 = p5 + p1*stbi__f2f(-0.899976223f); \ p2 = p5 + p2*stbi__f2f(-2.562915447f); \ p3 = p3*stbi__f2f(-1.961570560f); \ p4 = p4*stbi__f2f(-0.390180644f); \ t3 += p1+p4; \ t2 += p2+p3; \ t1 += p2+p4; \ t0 += p1+p3; static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) { int i,val[64],*v=val; stbi_uc *o; short *d = data; // columns for (i=0; i < 8; ++i,++d, ++v) { // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 && d[40]==0 && d[48]==0 && d[56]==0) { // no shortcut 0 seconds // (1|2|3|4|5|6|7)==0 0 seconds // all separate -0.047 seconds // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds int dcterm = d[0]*4; v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; } else { STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) // constants scaled things up by 1<<12; let's bring them back // down, but keep 2 extra bits of precision x0 += 512; x1 += 512; x2 += 512; x3 += 512; v[ 0] = (x0+t3) >> 10; v[56] = (x0-t3) >> 10; v[ 8] = (x1+t2) >> 10; v[48] = (x1-t2) >> 10; v[16] = (x2+t1) >> 10; v[40] = (x2-t1) >> 10; v[24] = (x3+t0) >> 10; v[32] = (x3-t0) >> 10; } } for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { // no fast case since the first 1D IDCT spread components out STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) // constants scaled things up by 1<<12, plus we had 1<<2 from first // loop, plus horizontal and vertical each scale by sqrt(8) so together // we've got an extra 1<<3, so 1<<17 total we need to remove. // so we want to round that, which means adding 0.5 * 1<<17, // aka 65536. Also, we'll end up with -128 to 127 that we want // to encode as 0..255 by adding 128, so we'll add that before the shift x0 += 65536 + (128<<17); x1 += 65536 + (128<<17); x2 += 65536 + (128<<17); x3 += 65536 + (128<<17); // tried computing the shifts into temps, or'ing the temps to see // if any were out of range, but that was slower o[0] = stbi__clamp((x0+t3) >> 17); o[7] = stbi__clamp((x0-t3) >> 17); o[1] = stbi__clamp((x1+t2) >> 17); o[6] = stbi__clamp((x1-t2) >> 17); o[2] = stbi__clamp((x2+t1) >> 17); o[5] = stbi__clamp((x2-t1) >> 17); o[3] = stbi__clamp((x3+t0) >> 17); o[4] = stbi__clamp((x3-t0) >> 17); } } #ifdef STBI_SSE2 // sse2 integer IDCT. not the fastest possible implementation but it // produces bit-identical results to the generic C version so it's // fully "transparent". static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { // This is constructed to match our regular (generic) integer IDCT exactly. __m128i row0, row1, row2, row3, row4, row5, row6, row7; __m128i tmp; // dot product constant: even elems=x, odd elems=y #define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) // out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) // out(1) = c1[even]*x + c1[odd]*y #define dct_rot(out0,out1, x,y,c0,c1) \ __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) // out = in << 12 (in 16-bit, out 32-bit) #define dct_widen(out, in) \ __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) // wide add #define dct_wadd(out, a, b) \ __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ __m128i out##_h = _mm_add_epi32(a##_h, b##_h) // wide sub #define dct_wsub(out, a, b) \ __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) // butterfly a/b, add bias, then shift by "s" and pack #define dct_bfly32o(out0, out1, a,b,bias,s) \ { \ __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ dct_wadd(sum, abiased, b); \ dct_wsub(dif, abiased, b); \ out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ } // 8-bit interleave step (for transposes) #define dct_interleave8(a, b) \ tmp = a; \ a = _mm_unpacklo_epi8(a, b); \ b = _mm_unpackhi_epi8(tmp, b) // 16-bit interleave step (for transposes) #define dct_interleave16(a, b) \ tmp = a; \ a = _mm_unpacklo_epi16(a, b); \ b = _mm_unpackhi_epi16(tmp, b) #define dct_pass(bias,shift) \ { \ /* even part */ \ dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ __m128i sum04 = _mm_add_epi16(row0, row4); \ __m128i dif04 = _mm_sub_epi16(row0, row4); \ dct_widen(t0e, sum04); \ dct_widen(t1e, dif04); \ dct_wadd(x0, t0e, t3e); \ dct_wsub(x3, t0e, t3e); \ dct_wadd(x1, t1e, t2e); \ dct_wsub(x2, t1e, t2e); \ /* odd part */ \ dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ __m128i sum17 = _mm_add_epi16(row1, row7); \ __m128i sum35 = _mm_add_epi16(row3, row5); \ dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ dct_wadd(x4, y0o, y4o); \ dct_wadd(x5, y1o, y5o); \ dct_wadd(x6, y2o, y5o); \ dct_wadd(x7, y3o, y4o); \ dct_bfly32o(row0,row7, x0,x7,bias,shift); \ dct_bfly32o(row1,row6, x1,x6,bias,shift); \ dct_bfly32o(row2,row5, x2,x5,bias,shift); \ dct_bfly32o(row3,row4, x3,x4,bias,shift); \ } __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); // rounding biases in column/row passes, see stbi__idct_block for explanation. __m128i bias_0 = _mm_set1_epi32(512); __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); // load row0 = _mm_load_si128((const __m128i *) (data + 0*8)); row1 = _mm_load_si128((const __m128i *) (data + 1*8)); row2 = _mm_load_si128((const __m128i *) (data + 2*8)); row3 = _mm_load_si128((const __m128i *) (data + 3*8)); row4 = _mm_load_si128((const __m128i *) (data + 4*8)); row5 = _mm_load_si128((const __m128i *) (data + 5*8)); row6 = _mm_load_si128((const __m128i *) (data + 6*8)); row7 = _mm_load_si128((const __m128i *) (data + 7*8)); // column pass dct_pass(bias_0, 10); { // 16bit 8x8 transpose pass 1 dct_interleave16(row0, row4); dct_interleave16(row1, row5); dct_interleave16(row2, row6); dct_interleave16(row3, row7); // transpose pass 2 dct_interleave16(row0, row2); dct_interleave16(row1, row3); dct_interleave16(row4, row6); dct_interleave16(row5, row7); // transpose pass 3 dct_interleave16(row0, row1); dct_interleave16(row2, row3); dct_interleave16(row4, row5); dct_interleave16(row6, row7); } // row pass dct_pass(bias_1, 17); { // pack __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 __m128i p1 = _mm_packus_epi16(row2, row3); __m128i p2 = _mm_packus_epi16(row4, row5); __m128i p3 = _mm_packus_epi16(row6, row7); // 8bit 8x8 transpose pass 1 dct_interleave8(p0, p2); // a0e0a1e1... dct_interleave8(p1, p3); // c0g0c1g1... // transpose pass 2 dct_interleave8(p0, p1); // a0c0e0g0... dct_interleave8(p2, p3); // b0d0f0h0... // transpose pass 3 dct_interleave8(p0, p2); // a0b0c0d0... dct_interleave8(p1, p3); // a4b4c4d4... // store _mm_storel_epi64((__m128i *) out, p0); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p2); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p1); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p3); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); } #undef dct_const #undef dct_rot #undef dct_widen #undef dct_wadd #undef dct_wsub #undef dct_bfly32o #undef dct_interleave8 #undef dct_interleave16 #undef dct_pass } #endif // STBI_SSE2 #ifdef STBI_NEON // NEON integer IDCT. should produce bit-identical // results to the generic C version. static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); #define dct_long_mul(out, inq, coeff) \ int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) #define dct_long_mac(out, acc, inq, coeff) \ int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) #define dct_widen(out, inq) \ int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) // wide add #define dct_wadd(out, a, b) \ int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ int32x4_t out##_h = vaddq_s32(a##_h, b##_h) // wide sub #define dct_wsub(out, a, b) \ int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ int32x4_t out##_h = vsubq_s32(a##_h, b##_h) // butterfly a/b, then shift using "shiftop" by "s" and pack #define dct_bfly32o(out0,out1, a,b,shiftop,s) \ { \ dct_wadd(sum, a, b); \ dct_wsub(dif, a, b); \ out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ } #define dct_pass(shiftop, shift) \ { \ /* even part */ \ int16x8_t sum26 = vaddq_s16(row2, row6); \ dct_long_mul(p1e, sum26, rot0_0); \ dct_long_mac(t2e, p1e, row6, rot0_1); \ dct_long_mac(t3e, p1e, row2, rot0_2); \ int16x8_t sum04 = vaddq_s16(row0, row4); \ int16x8_t dif04 = vsubq_s16(row0, row4); \ dct_widen(t0e, sum04); \ dct_widen(t1e, dif04); \ dct_wadd(x0, t0e, t3e); \ dct_wsub(x3, t0e, t3e); \ dct_wadd(x1, t1e, t2e); \ dct_wsub(x2, t1e, t2e); \ /* odd part */ \ int16x8_t sum15 = vaddq_s16(row1, row5); \ int16x8_t sum17 = vaddq_s16(row1, row7); \ int16x8_t sum35 = vaddq_s16(row3, row5); \ int16x8_t sum37 = vaddq_s16(row3, row7); \ int16x8_t sumodd = vaddq_s16(sum17, sum35); \ dct_long_mul(p5o, sumodd, rot1_0); \ dct_long_mac(p1o, p5o, sum17, rot1_1); \ dct_long_mac(p2o, p5o, sum35, rot1_2); \ dct_long_mul(p3o, sum37, rot2_0); \ dct_long_mul(p4o, sum15, rot2_1); \ dct_wadd(sump13o, p1o, p3o); \ dct_wadd(sump24o, p2o, p4o); \ dct_wadd(sump23o, p2o, p3o); \ dct_wadd(sump14o, p1o, p4o); \ dct_long_mac(x4, sump13o, row7, rot3_0); \ dct_long_mac(x5, sump24o, row5, rot3_1); \ dct_long_mac(x6, sump23o, row3, rot3_2); \ dct_long_mac(x7, sump14o, row1, rot3_3); \ dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ } // load row0 = vld1q_s16(data + 0*8); row1 = vld1q_s16(data + 1*8); row2 = vld1q_s16(data + 2*8); row3 = vld1q_s16(data + 3*8); row4 = vld1q_s16(data + 4*8); row5 = vld1q_s16(data + 5*8); row6 = vld1q_s16(data + 6*8); row7 = vld1q_s16(data + 7*8); // add DC bias row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); // column pass dct_pass(vrshrn_n_s32, 10); // 16bit 8x8 transpose { // these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. // whether compilers actually get this is another story, sadly. #define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } #define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } #define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } // pass 1 dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 dct_trn16(row2, row3); dct_trn16(row4, row5); dct_trn16(row6, row7); // pass 2 dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 dct_trn32(row1, row3); dct_trn32(row4, row6); dct_trn32(row5, row7); // pass 3 dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 dct_trn64(row1, row5); dct_trn64(row2, row6); dct_trn64(row3, row7); #undef dct_trn16 #undef dct_trn32 #undef dct_trn64 } // row pass // vrshrn_n_s32 only supports shifts up to 16, we need // 17. so do a non-rounding shift of 16 first then follow // up with a rounding shift by 1. dct_pass(vshrn_n_s32, 16); { // pack and round uint8x8_t p0 = vqrshrun_n_s16(row0, 1); uint8x8_t p1 = vqrshrun_n_s16(row1, 1); uint8x8_t p2 = vqrshrun_n_s16(row2, 1); uint8x8_t p3 = vqrshrun_n_s16(row3, 1); uint8x8_t p4 = vqrshrun_n_s16(row4, 1); uint8x8_t p5 = vqrshrun_n_s16(row5, 1); uint8x8_t p6 = vqrshrun_n_s16(row6, 1); uint8x8_t p7 = vqrshrun_n_s16(row7, 1); // again, these can translate into one instruction, but often don't. #define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } #define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } #define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } // sadly can't use interleaved stores here since we only write // 8 bytes to each scan line! // 8x8 8-bit transpose pass 1 dct_trn8_8(p0, p1); dct_trn8_8(p2, p3); dct_trn8_8(p4, p5); dct_trn8_8(p6, p7); // pass 2 dct_trn8_16(p0, p2); dct_trn8_16(p1, p3); dct_trn8_16(p4, p6); dct_trn8_16(p5, p7); // pass 3 dct_trn8_32(p0, p4); dct_trn8_32(p1, p5); dct_trn8_32(p2, p6); dct_trn8_32(p3, p7); // store vst1_u8(out, p0); out += out_stride; vst1_u8(out, p1); out += out_stride; vst1_u8(out, p2); out += out_stride; vst1_u8(out, p3); out += out_stride; vst1_u8(out, p4); out += out_stride; vst1_u8(out, p5); out += out_stride; vst1_u8(out, p6); out += out_stride; vst1_u8(out, p7); #undef dct_trn8_8 #undef dct_trn8_16 #undef dct_trn8_32 } #undef dct_long_mul #undef dct_long_mac #undef dct_widen #undef dct_wadd #undef dct_wsub #undef dct_bfly32o #undef dct_pass } #endif // STBI_NEON #define STBI__MARKER_none 0xff // if there's a pending marker from the entropy stream, return that // otherwise, fetch from the stream and get a marker. if there's no // marker, return 0xff, which is never a valid marker value static stbi_uc stbi__get_marker(stbi__jpeg *j) { stbi_uc x; if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } x = stbi__get8(j->s); if (x != 0xff) return STBI__MARKER_none; while (x == 0xff) x = stbi__get8(j->s); // consume repeated 0xff fill bytes return x; } // in each scan, we'll have scan_n components, and the order // of the components is specified by order[] #define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) // after a restart interval, stbi__jpeg_reset the entropy decoder and // the dc prediction static void stbi__jpeg_reset(stbi__jpeg *j) { j->code_bits = 0; j->code_buffer = 0; j->nomore = 0; j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0; j->marker = STBI__MARKER_none; j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; j->eob_run = 0; // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, // since we don't even allow 1<<30 pixels } static int stbi__parse_entropy_coded_data(stbi__jpeg *z) { stbi__jpeg_reset(z); if (!z->progressive) { if (z->scan_n == 1) { int i,j; STBI_SIMD_ALIGN(short, data[64]); int n = z->order[0]; // non-interleaved data, we just need to process one block at a time, // in trivial scanline order // number of blocks to do just depends on how many actual "pixels" this // component has, independent of interleaved MCU blocking and such int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); // every data block is an MCU, so countdown the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); // if it's NOT a restart, then just bail, so we get corrupt data // rather than no data if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } else { // interleaved int i,j,k,x,y; STBI_SIMD_ALIGN(short, data[64]); for (j=0; j < z->img_mcu_y; ++j) { for (i=0; i < z->img_mcu_x; ++i) { // scan an interleaved mcu... process scan_n components in order for (k=0; k < z->scan_n; ++k) { int n = z->order[k]; // scan out an mcu's worth of this component; that's just determined // by the basic H and V specified for the component for (y=0; y < z->img_comp[n].v; ++y) { for (x=0; x < z->img_comp[n].h; ++x) { int x2 = (i*z->img_comp[n].h + x)*8; int y2 = (j*z->img_comp[n].v + y)*8; int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); } } } // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } } else { if (z->scan_n == 1) { int i,j; int n = z->order[0]; // non-interleaved data, we just need to process one block at a time, // in trivial scanline order // number of blocks to do just depends on how many actual "pixels" this // component has, independent of interleaved MCU blocking and such int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); if (z->spec_start == 0) { if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) return 0; } else { int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) return 0; } // every data block is an MCU, so countdown the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } else { // interleaved int i,j,k,x,y; for (j=0; j < z->img_mcu_y; ++j) { for (i=0; i < z->img_mcu_x; ++i) { // scan an interleaved mcu... process scan_n components in order for (k=0; k < z->scan_n; ++k) { int n = z->order[k]; // scan out an mcu's worth of this component; that's just determined // by the basic H and V specified for the component for (y=0; y < z->img_comp[n].v; ++y) { for (x=0; x < z->img_comp[n].h; ++x) { int x2 = (i*z->img_comp[n].h + x); int y2 = (j*z->img_comp[n].v + y); short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) return 0; } } } // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } } } static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant) { int i; for (i=0; i < 64; ++i) data[i] *= dequant[i]; } static void stbi__jpeg_finish(stbi__jpeg *z) { if (z->progressive) { // dequantize and idct the data int i,j,n; for (n=0; n < z->s->img_n; ++n) { int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); } } } } } static int stbi__process_marker(stbi__jpeg *z, int m) { int L; switch (m) { case STBI__MARKER_none: // no marker found return stbi__err("expected marker","Corrupt JPEG"); case 0xDD: // DRI - specify restart interval if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); z->restart_interval = stbi__get16be(z->s); return 1; case 0xDB: // DQT - define quantization table L = stbi__get16be(z->s)-2; while (L > 0) { int q = stbi__get8(z->s); int p = q >> 4, sixteen = (p != 0); int t = q & 15,i; if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG"); if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); for (i=0; i < 64; ++i) z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s)); L -= (sixteen ? 129 : 65); } return L==0; case 0xC4: // DHT - define huffman table L = stbi__get16be(z->s)-2; while (L > 0) { stbi_uc *v; int sizes[16],i,n=0; int q = stbi__get8(z->s); int tc = q >> 4; int th = q & 15; if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); for (i=0; i < 16; ++i) { sizes[i] = stbi__get8(z->s); n += sizes[i]; } L -= 17; if (tc == 0) { if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; v = z->huff_dc[th].values; } else { if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; v = z->huff_ac[th].values; } for (i=0; i < n; ++i) v[i] = stbi__get8(z->s); if (tc != 0) stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); L -= n; } return L==0; } // check for comment block or APP blocks if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { L = stbi__get16be(z->s); if (L < 2) { if (m == 0xFE) return stbi__err("bad COM len","Corrupt JPEG"); else return stbi__err("bad APP len","Corrupt JPEG"); } L -= 2; if (m == 0xE0 && L >= 5) { // JFIF APP0 segment static const unsigned char tag[5] = {'J','F','I','F','\0'}; int ok = 1; int i; for (i=0; i < 5; ++i) if (stbi__get8(z->s) != tag[i]) ok = 0; L -= 5; if (ok) z->jfif = 1; } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment static const unsigned char tag[6] = {'A','d','o','b','e','\0'}; int ok = 1; int i; for (i=0; i < 6; ++i) if (stbi__get8(z->s) != tag[i]) ok = 0; L -= 6; if (ok) { stbi__get8(z->s); // version stbi__get16be(z->s); // flags0 stbi__get16be(z->s); // flags1 z->app14_color_transform = stbi__get8(z->s); // color transform L -= 6; } } stbi__skip(z->s, L); return 1; } return stbi__err("unknown marker","Corrupt JPEG"); } // after we see SOS static int stbi__process_scan_header(stbi__jpeg *z) { int i; int Ls = stbi__get16be(z->s); z->scan_n = stbi__get8(z->s); if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG"); if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG"); for (i=0; i < z->scan_n; ++i) { int id = stbi__get8(z->s), which; int q = stbi__get8(z->s); for (which = 0; which < z->s->img_n; ++which) if (z->img_comp[which].id == id) break; if (which == z->s->img_n) return 0; // no match z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG"); z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG"); z->order[i] = which; } { int aa; z->spec_start = stbi__get8(z->s); z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 aa = stbi__get8(z->s); z->succ_high = (aa >> 4); z->succ_low = (aa & 15); if (z->progressive) { if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) return stbi__err("bad SOS", "Corrupt JPEG"); } else { if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); z->spec_end = 63; } } return 1; } static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) { int i; for (i=0; i < ncomp; ++i) { if (z->img_comp[i].raw_data) { STBI_FREE(z->img_comp[i].raw_data); z->img_comp[i].raw_data = NULL; z->img_comp[i].data = NULL; } if (z->img_comp[i].raw_coeff) { STBI_FREE(z->img_comp[i].raw_coeff); z->img_comp[i].raw_coeff = 0; z->img_comp[i].coeff = 0; } if (z->img_comp[i].linebuf) { STBI_FREE(z->img_comp[i].linebuf); z->img_comp[i].linebuf = NULL; } } return why; } static int stbi__process_frame_header(stbi__jpeg *z, int scan) { stbi__context *s = z->s; int Lf,p,i,q, h_max=1,v_max=1,c; Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires c = stbi__get8(s); if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG"); s->img_n = c; for (i=0; i < c; ++i) { z->img_comp[i].data = NULL; z->img_comp[i].linebuf = NULL; } if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); z->rgb = 0; for (i=0; i < s->img_n; ++i) { static const unsigned char rgb[3] = { 'R', 'G', 'B' }; z->img_comp[i].id = stbi__get8(s); if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) ++z->rgb; q = stbi__get8(s); z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); } if (scan != STBI__SCAN_load) return 1; if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode"); for (i=0; i < s->img_n; ++i) { if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; } // compute interleaved mcu info z->img_h_max = h_max; z->img_v_max = v_max; z->img_mcu_w = h_max * 8; z->img_mcu_h = v_max * 8; // these sizes can't be more than 17 bits z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; for (i=0; i < s->img_n; ++i) { // number of effective pixels (e.g. for non-interleaved MCU) z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; // to simplify generation, we'll allocate enough memory to decode // the bogus oversized data from using interleaved MCUs and their // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't // discard the extra data until colorspace conversion // // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier) // so these muls can't overflow with 32-bit ints (which we require) z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; z->img_comp[i].coeff = 0; z->img_comp[i].raw_coeff = 0; z->img_comp[i].linebuf = NULL; z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); if (z->img_comp[i].raw_data == NULL) return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); // align blocks for idct using mmx/sse z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); if (z->progressive) { // w2, h2 are multiples of 8 (see above) z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); if (z->img_comp[i].raw_coeff == NULL) return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); } } return 1; } // use comparisons since in some cases we handle more than one case (e.g. SOF) #define stbi__DNL(x) ((x) == 0xdc) #define stbi__SOI(x) ((x) == 0xd8) #define stbi__EOI(x) ((x) == 0xd9) #define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) #define stbi__SOS(x) ((x) == 0xda) #define stbi__SOF_progressive(x) ((x) == 0xc2) static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) { int m; z->jfif = 0; z->app14_color_transform = -1; // valid values are 0,1,2 z->marker = STBI__MARKER_none; // initialize cached marker to empty m = stbi__get_marker(z); if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); if (scan == STBI__SCAN_type) return 1; m = stbi__get_marker(z); while (!stbi__SOF(m)) { if (!stbi__process_marker(z,m)) return 0; m = stbi__get_marker(z); while (m == STBI__MARKER_none) { // some files have extra padding after their blocks, so ok, we'll scan if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); m = stbi__get_marker(z); } } z->progressive = stbi__SOF_progressive(m); if (!stbi__process_frame_header(z, scan)) return 0; return 1; } // decode image to YCbCr format static int stbi__decode_jpeg_image(stbi__jpeg *j) { int m; for (m = 0; m < 4; m++) { j->img_comp[m].raw_data = NULL; j->img_comp[m].raw_coeff = NULL; } j->restart_interval = 0; if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; m = stbi__get_marker(j); while (!stbi__EOI(m)) { if (stbi__SOS(m)) { if (!stbi__process_scan_header(j)) return 0; if (!stbi__parse_entropy_coded_data(j)) return 0; if (j->marker == STBI__MARKER_none ) { // handle 0s at the end of image data from IP Kamera 9060 while (!stbi__at_eof(j->s)) { int x = stbi__get8(j->s); if (x == 255) { j->marker = stbi__get8(j->s); break; } } // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 } } else if (stbi__DNL(m)) { int Ld = stbi__get16be(j->s); stbi__uint32 NL = stbi__get16be(j->s); if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG"); if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG"); } else { if (!stbi__process_marker(j, m)) return 0; } m = stbi__get_marker(j); } if (j->progressive) stbi__jpeg_finish(j); return 1; } // static jfif-centered resampling (across block boundaries) typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, int w, int hs); #define stbi__div4(x) ((stbi_uc) ((x) >> 2)) static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { STBI_NOTUSED(out); STBI_NOTUSED(in_far); STBI_NOTUSED(w); STBI_NOTUSED(hs); return in_near; } static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate two samples vertically for every one in input int i; STBI_NOTUSED(hs); for (i=0; i < w; ++i) out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); return out; } static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate two samples horizontally for every one in input int i; stbi_uc *input = in_near; if (w == 1) { // if only one sample, can't do any interpolation out[0] = out[1] = input[0]; return out; } out[0] = input[0]; out[1] = stbi__div4(input[0]*3 + input[1] + 2); for (i=1; i < w-1; ++i) { int n = 3*input[i]+2; out[i*2+0] = stbi__div4(n+input[i-1]); out[i*2+1] = stbi__div4(n+input[i+1]); } out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); out[i*2+1] = input[w-1]; STBI_NOTUSED(in_far); STBI_NOTUSED(hs); return out; } #define stbi__div16(x) ((stbi_uc) ((x) >> 4)) static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate 2x2 samples for every one in input int i,t0,t1; if (w == 1) { out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); return out; } t1 = 3*in_near[0] + in_far[0]; out[0] = stbi__div4(t1+2); for (i=1; i < w; ++i) { t0 = t1; t1 = 3*in_near[i]+in_far[i]; out[i*2-1] = stbi__div16(3*t0 + t1 + 8); out[i*2 ] = stbi__div16(3*t1 + t0 + 8); } out[w*2-1] = stbi__div4(t1+2); STBI_NOTUSED(hs); return out; } #if defined(STBI_SSE2) || defined(STBI_NEON) static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate 2x2 samples for every one in input int i=0,t0,t1; if (w == 1) { out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); return out; } t1 = 3*in_near[0] + in_far[0]; // process groups of 8 pixels for as long as we can. // note we can't handle the last pixel in a row in this loop // because we need to handle the filter boundary conditions. for (; i < ((w-1) & ~7); i += 8) { #if defined(STBI_SSE2) // load and perform the vertical filtering pass // this uses 3*x + y = 4*x + (y - x) __m128i zero = _mm_setzero_si128(); __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); __m128i farw = _mm_unpacklo_epi8(farb, zero); __m128i nearw = _mm_unpacklo_epi8(nearb, zero); __m128i diff = _mm_sub_epi16(farw, nearw); __m128i nears = _mm_slli_epi16(nearw, 2); __m128i curr = _mm_add_epi16(nears, diff); // current row // horizontal filter works the same based on shifted vers of current // row. "prev" is current row shifted right by 1 pixel; we need to // insert the previous pixel value (from t1). // "next" is current row shifted left by 1 pixel, with first pixel // of next block of 8 pixels added in. __m128i prv0 = _mm_slli_si128(curr, 2); __m128i nxt0 = _mm_srli_si128(curr, 2); __m128i prev = _mm_insert_epi16(prv0, t1, 0); __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7); // horizontal filter, polyphase implementation since it's convenient: // even pixels = 3*cur + prev = cur*4 + (prev - cur) // odd pixels = 3*cur + next = cur*4 + (next - cur) // note the shared term. __m128i bias = _mm_set1_epi16(8); __m128i curs = _mm_slli_epi16(curr, 2); __m128i prvd = _mm_sub_epi16(prev, curr); __m128i nxtd = _mm_sub_epi16(next, curr); __m128i curb = _mm_add_epi16(curs, bias); __m128i even = _mm_add_epi16(prvd, curb); __m128i odd = _mm_add_epi16(nxtd, curb); // interleave even and odd pixels, then undo scaling. __m128i int0 = _mm_unpacklo_epi16(even, odd); __m128i int1 = _mm_unpackhi_epi16(even, odd); __m128i de0 = _mm_srli_epi16(int0, 4); __m128i de1 = _mm_srli_epi16(int1, 4); // pack and write output __m128i outv = _mm_packus_epi16(de0, de1); _mm_storeu_si128((__m128i *) (out + i*2), outv); #elif defined(STBI_NEON) // load and perform the vertical filtering pass // this uses 3*x + y = 4*x + (y - x) uint8x8_t farb = vld1_u8(in_far + i); uint8x8_t nearb = vld1_u8(in_near + i); int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); int16x8_t curr = vaddq_s16(nears, diff); // current row // horizontal filter works the same based on shifted vers of current // row. "prev" is current row shifted right by 1 pixel; we need to // insert the previous pixel value (from t1). // "next" is current row shifted left by 1 pixel, with first pixel // of next block of 8 pixels added in. int16x8_t prv0 = vextq_s16(curr, curr, 7); int16x8_t nxt0 = vextq_s16(curr, curr, 1); int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7); // horizontal filter, polyphase implementation since it's convenient: // even pixels = 3*cur + prev = cur*4 + (prev - cur) // odd pixels = 3*cur + next = cur*4 + (next - cur) // note the shared term. int16x8_t curs = vshlq_n_s16(curr, 2); int16x8_t prvd = vsubq_s16(prev, curr); int16x8_t nxtd = vsubq_s16(next, curr); int16x8_t even = vaddq_s16(curs, prvd); int16x8_t odd = vaddq_s16(curs, nxtd); // undo scaling and round, then store with even/odd phases interleaved uint8x8x2_t o; o.val[0] = vqrshrun_n_s16(even, 4); o.val[1] = vqrshrun_n_s16(odd, 4); vst2_u8(out + i*2, o); #endif // "previous" value for next iter t1 = 3*in_near[i+7] + in_far[i+7]; } t0 = t1; t1 = 3*in_near[i] + in_far[i]; out[i*2] = stbi__div16(3*t1 + t0 + 8); for (++i; i < w; ++i) { t0 = t1; t1 = 3*in_near[i]+in_far[i]; out[i*2-1] = stbi__div16(3*t0 + t1 + 8); out[i*2 ] = stbi__div16(3*t1 + t0 + 8); } out[w*2-1] = stbi__div4(t1+2); STBI_NOTUSED(hs); return out; } #endif static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // resample with nearest-neighbor int i,j; STBI_NOTUSED(in_far); for (i=0; i < w; ++i) for (j=0; j < hs; ++j) out[i*hs+j] = in_near[i]; return out; } // this is a reduced-precision calculation of YCbCr-to-RGB introduced // to make sure the code produces the same results in both SIMD and scalar #define stbi__float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) { int i; for (i=0; i < count; ++i) { int y_fixed = (y[i] << 20) + (1<<19); // rounding int r,g,b; int cr = pcr[i] - 128; int cb = pcb[i] - 128; r = y_fixed + cr* stbi__float2fixed(1.40200f); g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); b = y_fixed + cb* stbi__float2fixed(1.77200f); r >>= 20; g >>= 20; b >>= 20; if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } out[0] = (stbi_uc)r; out[1] = (stbi_uc)g; out[2] = (stbi_uc)b; out[3] = 255; out += step; } } #if defined(STBI_SSE2) || defined(STBI_NEON) static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) { int i = 0; #ifdef STBI_SSE2 // step == 3 is pretty ugly on the final interleave, and i'm not convinced // it's useful in practice (you wouldn't use it for textures, for example). // so just accelerate step == 4 case. if (step == 4) { // this is a fairly straightforward implementation and not super-optimized. __m128i signflip = _mm_set1_epi8(-0x80); __m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); __m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128); __m128i xw = _mm_set1_epi16(255); // alpha channel for (; i+7 < count; i += 8) { // load __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 // unpack to short (and left-shift cr, cb by 8) __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); // color transform __m128i yws = _mm_srli_epi16(yw, 4); __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); __m128i rws = _mm_add_epi16(cr0, yws); __m128i gwt = _mm_add_epi16(cb0, yws); __m128i bws = _mm_add_epi16(yws, cb1); __m128i gws = _mm_add_epi16(gwt, cr1); // descale __m128i rw = _mm_srai_epi16(rws, 4); __m128i bw = _mm_srai_epi16(bws, 4); __m128i gw = _mm_srai_epi16(gws, 4); // back to byte, set up for transpose __m128i brb = _mm_packus_epi16(rw, bw); __m128i gxb = _mm_packus_epi16(gw, xw); // transpose to interleave channels __m128i t0 = _mm_unpacklo_epi8(brb, gxb); __m128i t1 = _mm_unpackhi_epi8(brb, gxb); __m128i o0 = _mm_unpacklo_epi16(t0, t1); __m128i o1 = _mm_unpackhi_epi16(t0, t1); // store _mm_storeu_si128((__m128i *) (out + 0), o0); _mm_storeu_si128((__m128i *) (out + 16), o1); out += 32; } } #endif #ifdef STBI_NEON // in this version, step=3 support would be easy to add. but is there demand? if (step == 4) { // this is a fairly straightforward implementation and not super-optimized. uint8x8_t signflip = vdup_n_u8(0x80); int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); for (; i+7 < count; i += 8) { // load uint8x8_t y_bytes = vld1_u8(y + i); uint8x8_t cr_bytes = vld1_u8(pcr + i); uint8x8_t cb_bytes = vld1_u8(pcb + i); int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); // expand to s16 int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); int16x8_t crw = vshll_n_s8(cr_biased, 7); int16x8_t cbw = vshll_n_s8(cb_biased, 7); // color transform int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); int16x8_t rws = vaddq_s16(yws, cr0); int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); int16x8_t bws = vaddq_s16(yws, cb1); // undo scaling, round, convert to byte uint8x8x4_t o; o.val[0] = vqrshrun_n_s16(rws, 4); o.val[1] = vqrshrun_n_s16(gws, 4); o.val[2] = vqrshrun_n_s16(bws, 4); o.val[3] = vdup_n_u8(255); // store, interleaving r/g/b/a vst4_u8(out, o); out += 8*4; } } #endif for (; i < count; ++i) { int y_fixed = (y[i] << 20) + (1<<19); // rounding int r,g,b; int cr = pcr[i] - 128; int cb = pcb[i] - 128; r = y_fixed + cr* stbi__float2fixed(1.40200f); g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); b = y_fixed + cb* stbi__float2fixed(1.77200f); r >>= 20; g >>= 20; b >>= 20; if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } out[0] = (stbi_uc)r; out[1] = (stbi_uc)g; out[2] = (stbi_uc)b; out[3] = 255; out += step; } } #endif // set up the kernels static void stbi__setup_jpeg(stbi__jpeg *j) { j->idct_block_kernel = stbi__idct_block; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; #ifdef STBI_SSE2 if (stbi__sse2_available()) { j->idct_block_kernel = stbi__idct_simd; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; } #endif #ifdef STBI_NEON j->idct_block_kernel = stbi__idct_simd; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; #endif } // clean up the temporary component buffers static void stbi__cleanup_jpeg(stbi__jpeg *j) { stbi__free_jpeg_components(j, j->s->img_n, 0); } typedef struct { resample_row_func resample; stbi_uc *line0,*line1; int hs,vs; // expansion factor in each axis int w_lores; // horizontal pixels pre-expansion int ystep; // how far through vertical expansion we are int ypos; // which pre-expansion row we're on } stbi__resample; // fast 0..255 * 0..255 => 0..255 rounded multiplication static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y) { unsigned int t = x*y + 128; return (stbi_uc) ((t + (t >>8)) >> 8); } static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) { int n, decode_n, is_rgb; z->s->img_n = 0; // make stbi__cleanup_jpeg safe // validate req_comp if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); // load a jpeg image from whichever source, but leave in YCbCr format if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } // determine actual number of components to generate n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1; is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif)); if (z->s->img_n == 3 && n < 3 && !is_rgb) decode_n = 1; else decode_n = z->s->img_n; // resample and color-convert { int k; unsigned int i,j; stbi_uc *output; stbi_uc *coutput[4] = { NULL, NULL, NULL, NULL }; stbi__resample res_comp[4]; for (k=0; k < decode_n; ++k) { stbi__resample *r = &res_comp[k]; // allocate line buffer big enough for upsampling off the edges // with upsample factor of 4 z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3); if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } r->hs = z->img_h_max / z->img_comp[k].h; r->vs = z->img_v_max / z->img_comp[k].v; r->ystep = r->vs >> 1; r->w_lores = (z->s->img_x + r->hs-1) / r->hs; r->ypos = 0; r->line0 = r->line1 = z->img_comp[k].data; if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; else r->resample = stbi__resample_row_generic; } // can't error after this so, this is safe output = (stbi_uc *) stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1); if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } // now go ahead and resample for (j=0; j < z->s->img_y; ++j) { stbi_uc *out = output + n * z->s->img_x * j; for (k=0; k < decode_n; ++k) { stbi__resample *r = &res_comp[k]; int y_bot = r->ystep >= (r->vs >> 1); coutput[k] = r->resample(z->img_comp[k].linebuf, y_bot ? r->line1 : r->line0, y_bot ? r->line0 : r->line1, r->w_lores, r->hs); if (++r->ystep >= r->vs) { r->ystep = 0; r->line0 = r->line1; if (++r->ypos < z->img_comp[k].y) r->line1 += z->img_comp[k].w2; } } if (n >= 3) { stbi_uc *y = coutput[0]; if (z->s->img_n == 3) { if (is_rgb) { for (i=0; i < z->s->img_x; ++i) { out[0] = y[i]; out[1] = coutput[1][i]; out[2] = coutput[2][i]; out[3] = 255; out += n; } } else { z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); } } else if (z->s->img_n == 4) { if (z->app14_color_transform == 0) { // CMYK for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; out[0] = stbi__blinn_8x8(coutput[0][i], m); out[1] = stbi__blinn_8x8(coutput[1][i], m); out[2] = stbi__blinn_8x8(coutput[2][i], m); out[3] = 255; out += n; } } else if (z->app14_color_transform == 2) { // YCCK z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; out[0] = stbi__blinn_8x8(255 - out[0], m); out[1] = stbi__blinn_8x8(255 - out[1], m); out[2] = stbi__blinn_8x8(255 - out[2], m); out += n; } } else { // YCbCr + alpha? Ignore the fourth channel for now z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); } } else for (i=0; i < z->s->img_x; ++i) { out[0] = out[1] = out[2] = y[i]; out[3] = 255; // not used if n==3 out += n; } } else { if (is_rgb) { if (n == 1) for (i=0; i < z->s->img_x; ++i) *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); else { for (i=0; i < z->s->img_x; ++i, out += 2) { out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); out[1] = 255; } } } else if (z->s->img_n == 4 && z->app14_color_transform == 0) { for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; stbi_uc r = stbi__blinn_8x8(coutput[0][i], m); stbi_uc g = stbi__blinn_8x8(coutput[1][i], m); stbi_uc b = stbi__blinn_8x8(coutput[2][i], m); out[0] = stbi__compute_y(r, g, b); out[1] = 255; out += n; } } else if (z->s->img_n == 4 && z->app14_color_transform == 2) { for (i=0; i < z->s->img_x; ++i) { out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]); out[1] = 255; out += n; } } else { stbi_uc *y = coutput[0]; if (n == 1) for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; else for (i=0; i < z->s->img_x; ++i) { *out++ = y[i]; *out++ = 255; } } } } stbi__cleanup_jpeg(z); *out_x = z->s->img_x; *out_y = z->s->img_y; if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output return output; } } static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { unsigned char* result; stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg)); STBI_NOTUSED(ri); j->s = s; stbi__setup_jpeg(j); result = load_jpeg_image(j, x,y,comp,req_comp); STBI_FREE(j); return result; } static int stbi__jpeg_test(stbi__context *s) { int r; stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg)); j->s = s; stbi__setup_jpeg(j); r = stbi__decode_jpeg_header(j, STBI__SCAN_type); stbi__rewind(s); STBI_FREE(j); return r; } static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) { if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { stbi__rewind( j->s ); return 0; } if (x) *x = j->s->img_x; if (y) *y = j->s->img_y; if (comp) *comp = j->s->img_n >= 3 ? 3 : 1; return 1; } static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) { int result; stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg))); j->s = s; result = stbi__jpeg_info_raw(j, x, y, comp); STBI_FREE(j); return result; } #endif // public domain zlib decode v0.2 Sean Barrett 2006-11-18 // simple implementation // - all input must be provided in an upfront buffer // - all output is written to a single output buffer (can malloc/realloc) // performance // - fast huffman #ifndef STBI_NO_ZLIB // fast-way is faster to check than jpeg huffman, but slow way is slower #define STBI__ZFAST_BITS 9 // accelerate all cases in default tables #define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) // zlib-style huffman encoding // (jpegs packs from left, zlib from right, so can't share code) typedef struct { stbi__uint16 fast[1 << STBI__ZFAST_BITS]; stbi__uint16 firstcode[16]; int maxcode[17]; stbi__uint16 firstsymbol[16]; stbi_uc size[288]; stbi__uint16 value[288]; } stbi__zhuffman; stbi_inline static int stbi__bitreverse16(int n) { n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); return n; } stbi_inline static int stbi__bit_reverse(int v, int bits) { STBI_ASSERT(bits <= 16); // to bit reverse n bits, reverse 16 and shift // e.g. 11 bits, bit reverse and shift away 5 return stbi__bitreverse16(v) >> (16-bits); } static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num) { int i,k=0; int code, next_code[16], sizes[17]; // DEFLATE spec for generating codes memset(sizes, 0, sizeof(sizes)); memset(z->fast, 0, sizeof(z->fast)); for (i=0; i < num; ++i) ++sizes[sizelist[i]]; sizes[0] = 0; for (i=1; i < 16; ++i) if (sizes[i] > (1 << i)) return stbi__err("bad sizes", "Corrupt PNG"); code = 0; for (i=1; i < 16; ++i) { next_code[i] = code; z->firstcode[i] = (stbi__uint16) code; z->firstsymbol[i] = (stbi__uint16) k; code = (code + sizes[i]); if (sizes[i]) if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG"); z->maxcode[i] = code << (16-i); // preshift for inner loop code <<= 1; k += sizes[i]; } z->maxcode[16] = 0x10000; // sentinel for (i=0; i < num; ++i) { int s = sizelist[i]; if (s) { int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i); z->size [c] = (stbi_uc ) s; z->value[c] = (stbi__uint16) i; if (s <= STBI__ZFAST_BITS) { int j = stbi__bit_reverse(next_code[s],s); while (j < (1 << STBI__ZFAST_BITS)) { z->fast[j] = fastv; j += (1 << s); } } ++next_code[s]; } } return 1; } // zlib-from-memory implementation for PNG reading // because PNG allows splitting the zlib stream arbitrarily, // and it's annoying structurally to have PNG call ZLIB call PNG, // we require PNG read all the IDATs and combine them into a single // memory buffer typedef struct { stbi_uc *zbuffer, *zbuffer_end; int num_bits; stbi__uint32 code_buffer; char *zout; char *zout_start; char *zout_end; int z_expandable; stbi__zhuffman z_length, z_distance; } stbi__zbuf; stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) { if (z->zbuffer >= z->zbuffer_end) return 0; return *z->zbuffer++; } static void stbi__fill_bits(stbi__zbuf *z) { do { STBI_ASSERT(z->code_buffer < (1U << z->num_bits)); z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits; z->num_bits += 8; } while (z->num_bits <= 24); } stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) { unsigned int k; if (z->num_bits < n) stbi__fill_bits(z); k = z->code_buffer & ((1 << n) - 1); z->code_buffer >>= n; z->num_bits -= n; return k; } static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) { int b,s,k; // not resolved by fast table, so compute it the slow way // use jpeg approach, which requires MSbits at top k = stbi__bit_reverse(a->code_buffer, 16); for (s=STBI__ZFAST_BITS+1; ; ++s) if (k < z->maxcode[s]) break; if (s == 16) return -1; // invalid code! // code size is s, so: b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; STBI_ASSERT(z->size[b] == s); a->code_buffer >>= s; a->num_bits -= s; return z->value[b]; } stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) { int b,s; if (a->num_bits < 16) stbi__fill_bits(a); b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; if (b) { s = b >> 9; a->code_buffer >>= s; a->num_bits -= s; return b & 511; } return stbi__zhuffman_decode_slowpath(a, z); } static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes { char *q; int cur, limit, old_limit; z->zout = zout; if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG"); cur = (int) (z->zout - z->zout_start); limit = old_limit = (int) (z->zout_end - z->zout_start); while (cur + n > limit) limit *= 2; q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); STBI_NOTUSED(old_limit); if (q == NULL) return stbi__err("outofmem", "Out of memory"); z->zout_start = q; z->zout = q + cur; z->zout_end = q + limit; return 1; } static const int stbi__zlength_base[31] = { 3,4,5,6,7,8,9,10,11,13, 15,17,19,23,27,31,35,43,51,59, 67,83,99,115,131,163,195,227,258,0,0 }; static const int stbi__zlength_extra[31]= { 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; static const int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, 257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; static const int stbi__zdist_extra[32] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; static int stbi__parse_huffman_block(stbi__zbuf *a) { char *zout = a->zout; for(;;) { int z = stbi__zhuffman_decode(a, &a->z_length); if (z < 256) { if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes if (zout >= a->zout_end) { if (!stbi__zexpand(a, zout, 1)) return 0; zout = a->zout; } *zout++ = (char) z; } else { stbi_uc *p; int len,dist; if (z == 256) { a->zout = zout; return 1; } z -= 257; len = stbi__zlength_base[z]; if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]); z = stbi__zhuffman_decode(a, &a->z_distance); if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); dist = stbi__zdist_base[z]; if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]); if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG"); if (zout + len > a->zout_end) { if (!stbi__zexpand(a, zout, len)) return 0; zout = a->zout; } p = (stbi_uc *) (zout - dist); if (dist == 1) { // run of one byte; common in images. stbi_uc v = *p; if (len) { do *zout++ = v; while (--len); } } else { if (len) { do *zout++ = *p++; while (--len); } } } } } static int stbi__compute_huffman_codes(stbi__zbuf *a) { static const stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; stbi__zhuffman z_codelength; stbi_uc lencodes[286+32+137];//padding for maximum single op stbi_uc codelength_sizes[19]; int i,n; int hlit = stbi__zreceive(a,5) + 257; int hdist = stbi__zreceive(a,5) + 1; int hclen = stbi__zreceive(a,4) + 4; int ntot = hlit + hdist; memset(codelength_sizes, 0, sizeof(codelength_sizes)); for (i=0; i < hclen; ++i) { int s = stbi__zreceive(a,3); codelength_sizes[length_dezigzag[i]] = (stbi_uc) s; } if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; n = 0; while (n < ntot) { int c = stbi__zhuffman_decode(a, &z_codelength); if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG"); if (c < 16) lencodes[n++] = (stbi_uc) c; else { stbi_uc fill = 0; if (c == 16) { c = stbi__zreceive(a,2)+3; if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG"); fill = lencodes[n-1]; } else if (c == 17) c = stbi__zreceive(a,3)+3; else { STBI_ASSERT(c == 18); c = stbi__zreceive(a,7)+11; } if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG"); memset(lencodes+n, fill, c); n += c; } } if (n != ntot) return stbi__err("bad codelengths","Corrupt PNG"); if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; return 1; } static int stbi__parse_uncompressed_block(stbi__zbuf *a) { stbi_uc header[4]; int len,nlen,k; if (a->num_bits & 7) stbi__zreceive(a, a->num_bits & 7); // discard // drain the bit-packed data into header k = 0; while (a->num_bits > 0) { header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check a->code_buffer >>= 8; a->num_bits -= 8; } STBI_ASSERT(a->num_bits == 0); // now fill header the normal way while (k < 4) header[k++] = stbi__zget8(a); len = header[1] * 256 + header[0]; nlen = header[3] * 256 + header[2]; if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG"); if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG"); if (a->zout + len > a->zout_end) if (!stbi__zexpand(a, a->zout, len)) return 0; memcpy(a->zout, a->zbuffer, len); a->zbuffer += len; a->zout += len; return 1; } static int stbi__parse_zlib_header(stbi__zbuf *a) { int cmf = stbi__zget8(a); int cm = cmf & 15; /* int cinfo = cmf >> 4; */ int flg = stbi__zget8(a); if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png // window = 1 << (8 + cinfo)... but who cares, we fully buffer output return 1; } static const stbi_uc stbi__zdefault_length[288] = { 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8 }; static const stbi_uc stbi__zdefault_distance[32] = { 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 }; /* Init algorithm: { int i; // use <= to match clearly with spec for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8; for ( ; i <= 255; ++i) stbi__zdefault_length[i] = 9; for ( ; i <= 279; ++i) stbi__zdefault_length[i] = 7; for ( ; i <= 287; ++i) stbi__zdefault_length[i] = 8; for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5; } */ static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) { int final, type; if (parse_header) if (!stbi__parse_zlib_header(a)) return 0; a->num_bits = 0; a->code_buffer = 0; do { final = stbi__zreceive(a,1); type = stbi__zreceive(a,2); if (type == 0) { if (!stbi__parse_uncompressed_block(a)) return 0; } else if (type == 3) { return 0; } else { if (type == 1) { // use fixed code lengths if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , 288)) return 0; if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0; } else { if (!stbi__compute_huffman_codes(a)) return 0; } if (!stbi__parse_huffman_block(a)) return 0; } } while (!final); return 1; } static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) { a->zout_start = obuf; a->zout = obuf; a->zout_end = obuf + olen; a->z_expandable = exp; return stbi__parse_zlib(a, parse_header); } STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) { stbi__zbuf a; char *p = (char *) stbi__malloc(initial_size); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer + len; if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) { return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); } STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) { stbi__zbuf a; char *p = (char *) stbi__malloc(initial_size); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer + len; if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) { stbi__zbuf a; a.zbuffer = (stbi_uc *) ibuffer; a.zbuffer_end = (stbi_uc *) ibuffer + ilen; if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) return (int) (a.zout - a.zout_start); else return -1; } STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) { stbi__zbuf a; char *p = (char *) stbi__malloc(16384); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer+len; if (stbi__do_zlib(&a, p, 16384, 1, 0)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) { stbi__zbuf a; a.zbuffer = (stbi_uc *) ibuffer; a.zbuffer_end = (stbi_uc *) ibuffer + ilen; if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) return (int) (a.zout - a.zout_start); else return -1; } #endif // public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 // simple implementation // - only 8-bit samples // - no CRC checking // - allocates lots of intermediate memory // - avoids problem of streaming data between subsystems // - avoids explicit window management // performance // - uses stb_zlib, a PD zlib implementation with fast huffman decoding #ifndef STBI_NO_PNG typedef struct { stbi__uint32 length; stbi__uint32 type; } stbi__pngchunk; static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) { stbi__pngchunk c; c.length = stbi__get32be(s); c.type = stbi__get32be(s); return c; } static int stbi__check_png_header(stbi__context *s) { static const stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 }; int i; for (i=0; i < 8; ++i) if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG"); return 1; } typedef struct { stbi__context *s; stbi_uc *idata, *expanded, *out; int depth; } stbi__png; enum { STBI__F_none=0, STBI__F_sub=1, STBI__F_up=2, STBI__F_avg=3, STBI__F_paeth=4, // synthetic filters used for first scanline to avoid needing a dummy row of 0s STBI__F_avg_first, STBI__F_paeth_first }; static stbi_uc first_row_filter[5] = { STBI__F_none, STBI__F_sub, STBI__F_none, STBI__F_avg_first, STBI__F_paeth_first }; static int stbi__paeth(int a, int b, int c) { int p = a + b - c; int pa = abs(p-a); int pb = abs(p-b); int pc = abs(p-c); if (pa <= pb && pa <= pc) return a; if (pb <= pc) return b; return c; } static const stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 }; // create the png data from post-deflated data static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) { int bytes = (depth == 16? 2 : 1); stbi__context *s = a->s; stbi__uint32 i,j,stride = x*out_n*bytes; stbi__uint32 img_len, img_width_bytes; int k; int img_n = s->img_n; // copy it into a local for later int output_bytes = out_n*bytes; int filter_bytes = img_n*bytes; int width = x; STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1); a->out = (stbi_uc *) stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into if (!a->out) return stbi__err("outofmem", "Out of memory"); if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) return stbi__err("too large", "Corrupt PNG"); img_width_bytes = (((img_n * x * depth) + 7) >> 3); img_len = (img_width_bytes + 1) * y; // we used to check for exact match between raw_len and img_len on non-interlaced PNGs, // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros), // so just check for raw_len < img_len always. if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG"); for (j=0; j < y; ++j) { stbi_uc *cur = a->out + stride*j; stbi_uc *prior; int filter = *raw++; if (filter > 4) return stbi__err("invalid filter","Corrupt PNG"); if (depth < 8) { STBI_ASSERT(img_width_bytes <= x); cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place filter_bytes = 1; width = img_width_bytes; } prior = cur - stride; // bugfix: need to compute this after 'cur +=' computation above // if first row, use special filter that doesn't sample previous row if (j == 0) filter = first_row_filter[filter]; // handle first byte explicitly for (k=0; k < filter_bytes; ++k) { switch (filter) { case STBI__F_none : cur[k] = raw[k]; break; case STBI__F_sub : cur[k] = raw[k]; break; case STBI__F_up : cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; case STBI__F_avg : cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); break; case STBI__F_paeth : cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0,prior[k],0)); break; case STBI__F_avg_first : cur[k] = raw[k]; break; case STBI__F_paeth_first: cur[k] = raw[k]; break; } } if (depth == 8) { if (img_n != out_n) cur[img_n] = 255; // first pixel raw += img_n; cur += out_n; prior += out_n; } else if (depth == 16) { if (img_n != out_n) { cur[filter_bytes] = 255; // first pixel top byte cur[filter_bytes+1] = 255; // first pixel bottom byte } raw += filter_bytes; cur += output_bytes; prior += output_bytes; } else { raw += 1; cur += 1; prior += 1; } // this is a little gross, so that we don't switch per-pixel or per-component if (depth < 8 || img_n == out_n) { int nk = (width - 1)*filter_bytes; #define STBI__CASE(f) \ case f: \ for (k=0; k < nk; ++k) switch (filter) { // "none" filter turns into a memcpy here; make that explicit. case STBI__F_none: memcpy(cur, raw, nk); break; STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); } break; STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); } break; STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); } break; STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); } break; STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); } break; } #undef STBI__CASE raw += nk; } else { STBI_ASSERT(img_n+1 == out_n); #define STBI__CASE(f) \ case f: \ for (i=x-1; i >= 1; --i, cur[filter_bytes]=255,raw+=filter_bytes,cur+=output_bytes,prior+=output_bytes) \ for (k=0; k < filter_bytes; ++k) switch (filter) { STBI__CASE(STBI__F_none) { cur[k] = raw[k]; } break; STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]); } break; STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1)); } break; STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes])); } break; STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1)); } break; STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0)); } break; } #undef STBI__CASE // the loop above sets the high byte of the pixels' alpha, but for // 16 bit png files we also need the low byte set. we'll do that here. if (depth == 16) { cur = a->out + stride*j; // start at the beginning of the row again for (i=0; i < x; ++i,cur+=output_bytes) { cur[filter_bytes+1] = 255; } } } } // we make a separate pass to expand bits to pixels; for performance, // this could run two scanlines behind the above code, so it won't // intefere with filtering but will still be in the cache. if (depth < 8) { for (j=0; j < y; ++j) { stbi_uc *cur = a->out + stride*j; stbi_uc *in = a->out + stride*j + x*out_n - img_width_bytes; // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range // note that the final byte might overshoot and write more data than desired. // we can allocate enough data that this never writes out of memory, but it // could also overwrite the next scanline. can it overwrite non-empty data // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel. // so we need to explicitly clamp the final ones if (depth == 4) { for (k=x*img_n; k >= 2; k-=2, ++in) { *cur++ = scale * ((*in >> 4) ); *cur++ = scale * ((*in ) & 0x0f); } if (k > 0) *cur++ = scale * ((*in >> 4) ); } else if (depth == 2) { for (k=x*img_n; k >= 4; k-=4, ++in) { *cur++ = scale * ((*in >> 6) ); *cur++ = scale * ((*in >> 4) & 0x03); *cur++ = scale * ((*in >> 2) & 0x03); *cur++ = scale * ((*in ) & 0x03); } if (k > 0) *cur++ = scale * ((*in >> 6) ); if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03); if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03); } else if (depth == 1) { for (k=x*img_n; k >= 8; k-=8, ++in) { *cur++ = scale * ((*in >> 7) ); *cur++ = scale * ((*in >> 6) & 0x01); *cur++ = scale * ((*in >> 5) & 0x01); *cur++ = scale * ((*in >> 4) & 0x01); *cur++ = scale * ((*in >> 3) & 0x01); *cur++ = scale * ((*in >> 2) & 0x01); *cur++ = scale * ((*in >> 1) & 0x01); *cur++ = scale * ((*in ) & 0x01); } if (k > 0) *cur++ = scale * ((*in >> 7) ); if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01); if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01); if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01); if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01); if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01); if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01); } if (img_n != out_n) { int q; // insert alpha = 255 cur = a->out + stride*j; if (img_n == 1) { for (q=x-1; q >= 0; --q) { cur[q*2+1] = 255; cur[q*2+0] = cur[q]; } } else { STBI_ASSERT(img_n == 3); for (q=x-1; q >= 0; --q) { cur[q*4+3] = 255; cur[q*4+2] = cur[q*3+2]; cur[q*4+1] = cur[q*3+1]; cur[q*4+0] = cur[q*3+0]; } } } } } else if (depth == 16) { // force the image data from big-endian to platform-native. // this is done in a separate pass due to the decoding relying // on the data being untouched, but could probably be done // per-line during decode if care is taken. stbi_uc *cur = a->out; stbi__uint16 *cur16 = (stbi__uint16*)cur; for(i=0; i < x*y*out_n; ++i,cur16++,cur+=2) { *cur16 = (cur[0] << 8) | cur[1]; } } return 1; } static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) { int bytes = (depth == 16 ? 2 : 1); int out_bytes = out_n * bytes; stbi_uc *final; int p; if (!interlaced) return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color); // de-interlacing final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0); for (p=0; p < 7; ++p) { int xorig[] = { 0,4,0,2,0,1,0 }; int yorig[] = { 0,0,4,0,2,0,1 }; int xspc[] = { 8,8,4,4,2,2,1 }; int yspc[] = { 8,8,8,4,4,2,2 }; int i,j,x,y; // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p]; y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p]; if (x && y) { stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) { STBI_FREE(final); return 0; } for (j=0; j < y; ++j) { for (i=0; i < x; ++i) { int out_y = j*yspc[p]+yorig[p]; int out_x = i*xspc[p]+xorig[p]; memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes, a->out + (j*x+i)*out_bytes, out_bytes); } } STBI_FREE(a->out); image_data += img_len; image_data_len -= img_len; } } a->out = final; return 1; } static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi_uc *p = z->out; // compute color-based transparency, assuming we've // already got 255 as the alpha value in the output STBI_ASSERT(out_n == 2 || out_n == 4); if (out_n == 2) { for (i=0; i < pixel_count; ++i) { p[1] = (p[0] == tc[0] ? 0 : 255); p += 2; } } else { for (i=0; i < pixel_count; ++i) { if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) p[3] = 0; p += 4; } } return 1; } static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi__uint16 *p = (stbi__uint16*) z->out; // compute color-based transparency, assuming we've // already got 65535 as the alpha value in the output STBI_ASSERT(out_n == 2 || out_n == 4); if (out_n == 2) { for (i = 0; i < pixel_count; ++i) { p[1] = (p[0] == tc[0] ? 0 : 65535); p += 2; } } else { for (i = 0; i < pixel_count; ++i) { if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) p[3] = 0; p += 4; } } return 1; } static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) { stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; stbi_uc *p, *temp_out, *orig = a->out; p = (stbi_uc *) stbi__malloc_mad2(pixel_count, pal_img_n, 0); if (p == NULL) return stbi__err("outofmem", "Out of memory"); // between here and free(out) below, exitting would leak temp_out = p; if (pal_img_n == 3) { for (i=0; i < pixel_count; ++i) { int n = orig[i]*4; p[0] = palette[n ]; p[1] = palette[n+1]; p[2] = palette[n+2]; p += 3; } } else { for (i=0; i < pixel_count; ++i) { int n = orig[i]*4; p[0] = palette[n ]; p[1] = palette[n+1]; p[2] = palette[n+2]; p[3] = palette[n+3]; p += 4; } } STBI_FREE(a->out); a->out = temp_out; STBI_NOTUSED(len); return 1; } static int stbi__unpremultiply_on_load = 0; static int stbi__de_iphone_flag = 0; STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) { stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply; } STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) { stbi__de_iphone_flag = flag_true_if_should_convert; } static void stbi__de_iphone(stbi__png *z) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi_uc *p = z->out; if (s->img_out_n == 3) { // convert bgr to rgb for (i=0; i < pixel_count; ++i) { stbi_uc t = p[0]; p[0] = p[2]; p[2] = t; p += 3; } } else { STBI_ASSERT(s->img_out_n == 4); if (stbi__unpremultiply_on_load) { // convert bgr to rgb and unpremultiply for (i=0; i < pixel_count; ++i) { stbi_uc a = p[3]; stbi_uc t = p[0]; if (a) { stbi_uc half = a / 2; p[0] = (p[2] * 255 + half) / a; p[1] = (p[1] * 255 + half) / a; p[2] = ( t * 255 + half) / a; } else { p[0] = p[2]; p[2] = t; } p += 4; } } else { // convert bgr to rgb for (i=0; i < pixel_count; ++i) { stbi_uc t = p[0]; p[0] = p[2]; p[2] = t; p += 4; } } } } #define STBI__PNG_TYPE(a,b,c,d) (((unsigned) (a) << 24) + ((unsigned) (b) << 16) + ((unsigned) (c) << 8) + (unsigned) (d)) static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) { stbi_uc palette[1024], pal_img_n=0; stbi_uc has_trans=0, tc[3]={0}; stbi__uint16 tc16[3]; stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0; int first=1,k,interlace=0, color=0, is_iphone=0; stbi__context *s = z->s; z->expanded = NULL; z->idata = NULL; z->out = NULL; if (!stbi__check_png_header(s)) return 0; if (scan == STBI__SCAN_type) return 1; for (;;) { stbi__pngchunk c = stbi__get_chunk_header(s); switch (c.type) { case STBI__PNG_TYPE('C','g','B','I'): is_iphone = 1; stbi__skip(s, c.length); break; case STBI__PNG_TYPE('I','H','D','R'): { int comp,filter; if (!first) return stbi__err("multiple IHDR","Corrupt PNG"); first = 0; if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG"); s->img_x = stbi__get32be(s); if (s->img_x > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); s->img_y = stbi__get32be(s); if (s->img_y > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); z->depth = stbi__get8(s); if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16) return stbi__err("1/2/4/8/16-bit only","PNG not supported: 1/2/4/8/16-bit only"); color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype","Corrupt PNG"); if (color == 3 && z->depth == 16) return stbi__err("bad ctype","Corrupt PNG"); if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG"); comp = stbi__get8(s); if (comp) return stbi__err("bad comp method","Corrupt PNG"); filter= stbi__get8(s); if (filter) return stbi__err("bad filter method","Corrupt PNG"); interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG"); if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG"); if (!pal_img_n) { s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); if (scan == STBI__SCAN_header) return 1; } else { // if paletted, then pal_n is our final components, and // img_n is # components to decompress/filter. s->img_n = 1; if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG"); // if SCAN_header, have to scan to see if we have a tRNS } break; } case STBI__PNG_TYPE('P','L','T','E'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG"); pal_len = c.length / 3; if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG"); for (i=0; i < pal_len; ++i) { palette[i*4+0] = stbi__get8(s); palette[i*4+1] = stbi__get8(s); palette[i*4+2] = stbi__get8(s); palette[i*4+3] = 255; } break; } case STBI__PNG_TYPE('t','R','N','S'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG"); if (pal_img_n) { if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; } if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG"); if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG"); pal_img_n = 4; for (i=0; i < c.length; ++i) palette[i*4+3] = stbi__get8(s); } else { if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG"); if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG"); has_trans = 1; if (z->depth == 16) { for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is } else { for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger } } break; } case STBI__PNG_TYPE('I','D','A','T'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG"); if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; } if ((int)(ioff + c.length) < (int)ioff) return 0; if (ioff + c.length > idata_limit) { stbi__uint32 idata_limit_old = idata_limit; stbi_uc *p; if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; while (ioff + c.length > idata_limit) idata_limit *= 2; STBI_NOTUSED(idata_limit_old); p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); z->idata = p; } if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG"); ioff += c.length; break; } case STBI__PNG_TYPE('I','E','N','D'): { stbi__uint32 raw_len, bpl; if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (scan != STBI__SCAN_load) return 1; if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG"); // initial guess for decoded data size to avoid unnecessary reallocs bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone); if (z->expanded == NULL) return 0; // zlib should set error STBI_FREE(z->idata); z->idata = NULL; if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) s->img_out_n = s->img_n+1; else s->img_out_n = s->img_n; if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0; if (has_trans) { if (z->depth == 16) { if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0; } else { if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0; } } if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) stbi__de_iphone(z); if (pal_img_n) { // pal_img_n == 3 or 4 s->img_n = pal_img_n; // record the actual colors we had s->img_out_n = pal_img_n; if (req_comp >= 3) s->img_out_n = req_comp; if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) return 0; } else if (has_trans) { // non-paletted image with tRNS -> source image has (constant) alpha ++s->img_n; } STBI_FREE(z->expanded); z->expanded = NULL; return 1; } default: // if critical, fail if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if ((c.type & (1 << 29)) == 0) { #ifndef STBI_NO_FAILURE_STRINGS // not threadsafe static char invalid_chunk[] = "XXXX PNG chunk not known"; invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); #endif return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); } stbi__skip(s, c.length); break; } // end of PNG chunk, read and skip CRC stbi__get32be(s); } } static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri) { void *result=NULL; if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { if (p->depth < 8) ri->bits_per_channel = 8; else ri->bits_per_channel = p->depth; result = p->out; p->out = NULL; if (req_comp && req_comp != p->s->img_out_n) { if (ri->bits_per_channel == 8) result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); else result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); p->s->img_out_n = req_comp; if (result == NULL) return result; } *x = p->s->img_x; *y = p->s->img_y; if (n) *n = p->s->img_n; } STBI_FREE(p->out); p->out = NULL; STBI_FREE(p->expanded); p->expanded = NULL; STBI_FREE(p->idata); p->idata = NULL; return result; } static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi__png p; p.s = s; return stbi__do_png(&p, x,y,comp,req_comp, ri); } static int stbi__png_test(stbi__context *s) { int r; r = stbi__check_png_header(s); stbi__rewind(s); return r; } static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) { if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { stbi__rewind( p->s ); return 0; } if (x) *x = p->s->img_x; if (y) *y = p->s->img_y; if (comp) *comp = p->s->img_n; return 1; } static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) { stbi__png p; p.s = s; return stbi__png_info_raw(&p, x, y, comp); } static int stbi__png_is16(stbi__context *s) { stbi__png p; p.s = s; if (!stbi__png_info_raw(&p, NULL, NULL, NULL)) return 0; if (p.depth != 16) { stbi__rewind(p.s); return 0; } return 1; } #endif // Microsoft/Windows BMP image #ifndef STBI_NO_BMP static int stbi__bmp_test_raw(stbi__context *s) { int r; int sz; if (stbi__get8(s) != 'B') return 0; if (stbi__get8(s) != 'M') return 0; stbi__get32le(s); // discard filesize stbi__get16le(s); // discard reserved stbi__get16le(s); // discard reserved stbi__get32le(s); // discard data offset sz = stbi__get32le(s); r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); return r; } static int stbi__bmp_test(stbi__context *s) { int r = stbi__bmp_test_raw(s); stbi__rewind(s); return r; } // returns 0..31 for the highest set bit static int stbi__high_bit(unsigned int z) { int n=0; if (z == 0) return -1; if (z >= 0x10000) { n += 16; z >>= 16; } if (z >= 0x00100) { n += 8; z >>= 8; } if (z >= 0x00010) { n += 4; z >>= 4; } if (z >= 0x00004) { n += 2; z >>= 2; } if (z >= 0x00002) { n += 1; z >>= 1; } return n; } static int stbi__bitcount(unsigned int a) { a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits a = (a + (a >> 8)); // max 16 per 8 bits a = (a + (a >> 16)); // max 32 per 8 bits return a & 0xff; } // extract an arbitrarily-aligned N-bit value (N=bits) // from v, and then make it 8-bits long and fractionally // extend it to full full range. static int stbi__shiftsigned(unsigned int v, int shift, int bits) { static unsigned int mul_table[9] = { 0, 0xff/*0b11111111*/, 0x55/*0b01010101*/, 0x49/*0b01001001*/, 0x11/*0b00010001*/, 0x21/*0b00100001*/, 0x41/*0b01000001*/, 0x81/*0b10000001*/, 0x01/*0b00000001*/, }; static unsigned int shift_table[9] = { 0, 0,0,1,0,2,4,6,0, }; if (shift < 0) v <<= -shift; else v >>= shift; STBI_ASSERT(v >= 0 && v < 256); v >>= (8-bits); STBI_ASSERT(bits >= 0 && bits <= 8); return (int) ((unsigned) v * mul_table[bits]) >> shift_table[bits]; } typedef struct { int bpp, offset, hsz; unsigned int mr,mg,mb,ma, all_a; } stbi__bmp_data; static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) { int hsz; if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP"); stbi__get32le(s); // discard filesize stbi__get16le(s); // discard reserved stbi__get16le(s); // discard reserved info->offset = stbi__get32le(s); info->hsz = hsz = stbi__get32le(s); info->mr = info->mg = info->mb = info->ma = 0; if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); if (hsz == 12) { s->img_x = stbi__get16le(s); s->img_y = stbi__get16le(s); } else { s->img_x = stbi__get32le(s); s->img_y = stbi__get32le(s); } if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP"); info->bpp = stbi__get16le(s); if (hsz != 12) { int compress = stbi__get32le(s); if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); stbi__get32le(s); // discard sizeof stbi__get32le(s); // discard hres stbi__get32le(s); // discard vres stbi__get32le(s); // discard colorsused stbi__get32le(s); // discard max important if (hsz == 40 || hsz == 56) { if (hsz == 56) { stbi__get32le(s); stbi__get32le(s); stbi__get32le(s); stbi__get32le(s); } if (info->bpp == 16 || info->bpp == 32) { if (compress == 0) { if (info->bpp == 32) { info->mr = 0xffu << 16; info->mg = 0xffu << 8; info->mb = 0xffu << 0; info->ma = 0xffu << 24; info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 } else { info->mr = 31u << 10; info->mg = 31u << 5; info->mb = 31u << 0; } } else if (compress == 3) { info->mr = stbi__get32le(s); info->mg = stbi__get32le(s); info->mb = stbi__get32le(s); // not documented, but generated by photoshop and handled by mspaint if (info->mr == info->mg && info->mg == info->mb) { // ?!?!? return stbi__errpuc("bad BMP", "bad BMP"); } } else return stbi__errpuc("bad BMP", "bad BMP"); } } else { int i; if (hsz != 108 && hsz != 124) return stbi__errpuc("bad BMP", "bad BMP"); info->mr = stbi__get32le(s); info->mg = stbi__get32le(s); info->mb = stbi__get32le(s); info->ma = stbi__get32le(s); stbi__get32le(s); // discard color space for (i=0; i < 12; ++i) stbi__get32le(s); // discard color space parameters if (hsz == 124) { stbi__get32le(s); // discard rendering intent stbi__get32le(s); // discard offset of profile data stbi__get32le(s); // discard size of profile data stbi__get32le(s); // discard reserved } } } return (void *) 1; } static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *out; unsigned int mr=0,mg=0,mb=0,ma=0, all_a; stbi_uc pal[256][4]; int psize=0,i,j,width; int flip_vertically, pad, target; stbi__bmp_data info; STBI_NOTUSED(ri); info.all_a = 255; if (stbi__bmp_parse_header(s, &info) == NULL) return NULL; // error code already set flip_vertically = ((int) s->img_y) > 0; s->img_y = abs((int) s->img_y); mr = info.mr; mg = info.mg; mb = info.mb; ma = info.ma; all_a = info.all_a; if (info.hsz == 12) { if (info.bpp < 24) psize = (info.offset - 14 - 24) / 3; } else { if (info.bpp < 16) psize = (info.offset - 14 - info.hsz) >> 2; } s->img_n = ma ? 4 : 3; if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 target = req_comp; else target = s->img_n; // if they want monochrome, we'll post-convert // sanity-check size if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0)) return stbi__errpuc("too large", "Corrupt BMP"); out = (stbi_uc *) stbi__malloc_mad3(target, s->img_x, s->img_y, 0); if (!out) return stbi__errpuc("outofmem", "Out of memory"); if (info.bpp < 16) { int z=0; if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); } for (i=0; i < psize; ++i) { pal[i][2] = stbi__get8(s); pal[i][1] = stbi__get8(s); pal[i][0] = stbi__get8(s); if (info.hsz != 12) stbi__get8(s); pal[i][3] = 255; } stbi__skip(s, info.offset - 14 - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); if (info.bpp == 1) width = (s->img_x + 7) >> 3; else if (info.bpp == 4) width = (s->img_x + 1) >> 1; else if (info.bpp == 8) width = s->img_x; else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); } pad = (-width)&3; if (info.bpp == 1) { for (j=0; j < (int) s->img_y; ++j) { int bit_offset = 7, v = stbi__get8(s); for (i=0; i < (int) s->img_x; ++i) { int color = (v>>bit_offset)&0x1; out[z++] = pal[color][0]; out[z++] = pal[color][1]; out[z++] = pal[color][2]; if (target == 4) out[z++] = 255; if (i+1 == (int) s->img_x) break; if((--bit_offset) < 0) { bit_offset = 7; v = stbi__get8(s); } } stbi__skip(s, pad); } } else { for (j=0; j < (int) s->img_y; ++j) { for (i=0; i < (int) s->img_x; i += 2) { int v=stbi__get8(s),v2=0; if (info.bpp == 4) { v2 = v & 15; v >>= 4; } out[z++] = pal[v][0]; out[z++] = pal[v][1]; out[z++] = pal[v][2]; if (target == 4) out[z++] = 255; if (i+1 == (int) s->img_x) break; v = (info.bpp == 8) ? stbi__get8(s) : v2; out[z++] = pal[v][0]; out[z++] = pal[v][1]; out[z++] = pal[v][2]; if (target == 4) out[z++] = 255; } stbi__skip(s, pad); } } } else { int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; int z = 0; int easy=0; stbi__skip(s, info.offset - 14 - info.hsz); if (info.bpp == 24) width = 3 * s->img_x; else if (info.bpp == 16) width = 2*s->img_x; else /* bpp = 32 and pad = 0 */ width=0; pad = (-width) & 3; if (info.bpp == 24) { easy = 1; } else if (info.bpp == 32) { if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) easy = 2; } if (!easy) { if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } // right shift amt to put high bit in position #7 rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr); gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg); bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb); ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma); } for (j=0; j < (int) s->img_y; ++j) { if (easy) { for (i=0; i < (int) s->img_x; ++i) { unsigned char a; out[z+2] = stbi__get8(s); out[z+1] = stbi__get8(s); out[z+0] = stbi__get8(s); z += 3; a = (easy == 2 ? stbi__get8(s) : 255); all_a |= a; if (target == 4) out[z++] = a; } } else { int bpp = info.bpp; for (i=0; i < (int) s->img_x; ++i) { stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s)); unsigned int a; out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); all_a |= a; if (target == 4) out[z++] = STBI__BYTECAST(a); } } stbi__skip(s, pad); } } // if alpha channel is all 0s, replace with all 255s if (target == 4 && all_a == 0) for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4) out[i] = 255; if (flip_vertically) { stbi_uc t; for (j=0; j < (int) s->img_y>>1; ++j) { stbi_uc *p1 = out + j *s->img_x*target; stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; for (i=0; i < (int) s->img_x*target; ++i) { t = p1[i]; p1[i] = p2[i]; p2[i] = t; } } } if (req_comp && req_comp != target) { out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); if (out == NULL) return out; // stbi__convert_format frees input on failure } *x = s->img_x; *y = s->img_y; if (comp) *comp = s->img_n; return out; } #endif // Targa Truevision - TGA // by Jonathan Dummer #ifndef STBI_NO_TGA // returns STBI_rgb or whatever, 0 on error static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16) { // only RGB or RGBA (incl. 16bit) or grey allowed if (is_rgb16) *is_rgb16 = 0; switch(bits_per_pixel) { case 8: return STBI_grey; case 16: if(is_grey) return STBI_grey_alpha; // fallthrough case 15: if(is_rgb16) *is_rgb16 = 1; return STBI_rgb; case 24: // fallthrough case 32: return bits_per_pixel/8; default: return 0; } } static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) { int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp; int sz, tga_colormap_type; stbi__get8(s); // discard Offset tga_colormap_type = stbi__get8(s); // colormap type if( tga_colormap_type > 1 ) { stbi__rewind(s); return 0; // only RGB or indexed allowed } tga_image_type = stbi__get8(s); // image type if ( tga_colormap_type == 1 ) { // colormapped (paletted) image if (tga_image_type != 1 && tga_image_type != 9) { stbi__rewind(s); return 0; } stbi__skip(s,4); // skip index of first colormap entry and number of entries sz = stbi__get8(s); // check bits per palette color entry if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) { stbi__rewind(s); return 0; } stbi__skip(s,4); // skip image x and y origin tga_colormap_bpp = sz; } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) { stbi__rewind(s); return 0; // only RGB or grey allowed, +/- RLE } stbi__skip(s,9); // skip colormap specification and image x/y origin tga_colormap_bpp = 0; } tga_w = stbi__get16le(s); if( tga_w < 1 ) { stbi__rewind(s); return 0; // test width } tga_h = stbi__get16le(s); if( tga_h < 1 ) { stbi__rewind(s); return 0; // test height } tga_bits_per_pixel = stbi__get8(s); // bits per pixel stbi__get8(s); // ignore alpha bits if (tga_colormap_bpp != 0) { if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { // when using a colormap, tga_bits_per_pixel is the size of the indexes // I don't think anything but 8 or 16bit indexes makes sense stbi__rewind(s); return 0; } tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); } else { tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL); } if(!tga_comp) { stbi__rewind(s); return 0; } if (x) *x = tga_w; if (y) *y = tga_h; if (comp) *comp = tga_comp; return 1; // seems to have passed everything } static int stbi__tga_test(stbi__context *s) { int res = 0; int sz, tga_color_type; stbi__get8(s); // discard Offset tga_color_type = stbi__get8(s); // color type if ( tga_color_type > 1 ) goto errorEnd; // only RGB or indexed allowed sz = stbi__get8(s); // image type if ( tga_color_type == 1 ) { // colormapped (paletted) image if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9 stbi__skip(s,4); // skip index of first colormap entry and number of entries sz = stbi__get8(s); // check bits per palette color entry if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; stbi__skip(s,4); // skip image x and y origin } else { // "normal" image w/o colormap if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE stbi__skip(s,9); // skip colormap specification and image x/y origin } if ( stbi__get16le(s) < 1 ) goto errorEnd; // test width if ( stbi__get16le(s) < 1 ) goto errorEnd; // test height sz = stbi__get8(s); // bits per pixel if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; res = 1; // if we got this far, everything's good and we can return 1 instead of 0 errorEnd: stbi__rewind(s); return res; } // read 16bit value and convert to 24bit RGB static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) { stbi__uint16 px = (stbi__uint16)stbi__get16le(s); stbi__uint16 fiveBitMask = 31; // we have 3 channels with 5bits each int r = (px >> 10) & fiveBitMask; int g = (px >> 5) & fiveBitMask; int b = px & fiveBitMask; // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later out[0] = (stbi_uc)((r * 255)/31); out[1] = (stbi_uc)((g * 255)/31); out[2] = (stbi_uc)((b * 255)/31); // some people claim that the most significant bit might be used for alpha // (possibly if an alpha-bit is set in the "image descriptor byte") // but that only made 16bit test images completely translucent.. // so let's treat all 15 and 16bit TGAs as RGB with no alpha. } static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { // read in the TGA header stuff int tga_offset = stbi__get8(s); int tga_indexed = stbi__get8(s); int tga_image_type = stbi__get8(s); int tga_is_RLE = 0; int tga_palette_start = stbi__get16le(s); int tga_palette_len = stbi__get16le(s); int tga_palette_bits = stbi__get8(s); int tga_x_origin = stbi__get16le(s); int tga_y_origin = stbi__get16le(s); int tga_width = stbi__get16le(s); int tga_height = stbi__get16le(s); int tga_bits_per_pixel = stbi__get8(s); int tga_comp, tga_rgb16=0; int tga_inverted = stbi__get8(s); // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?) // image data unsigned char *tga_data; unsigned char *tga_palette = NULL; int i, j; unsigned char raw_data[4] = {0}; int RLE_count = 0; int RLE_repeating = 0; int read_next_pixel = 1; STBI_NOTUSED(ri); // do a tiny bit of precessing if ( tga_image_type >= 8 ) { tga_image_type -= 8; tga_is_RLE = 1; } tga_inverted = 1 - ((tga_inverted >> 5) & 1); // If I'm paletted, then I'll use the number of bits from the palette if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16); if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); // tga info *x = tga_width; *y = tga_height; if (comp) *comp = tga_comp; if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0)) return stbi__errpuc("too large", "Corrupt TGA"); tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0); if (!tga_data) return stbi__errpuc("outofmem", "Out of memory"); // skip to the data's starting position (offset usually = 0) stbi__skip(s, tga_offset ); if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) { for (i=0; i < tga_height; ++i) { int row = tga_inverted ? tga_height -i - 1 : i; stbi_uc *tga_row = tga_data + row*tga_width*tga_comp; stbi__getn(s, tga_row, tga_width * tga_comp); } } else { // do I need to load a palette? if ( tga_indexed) { // any data to skip? (offset usually = 0) stbi__skip(s, tga_palette_start ); // load the palette tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0); if (!tga_palette) { STBI_FREE(tga_data); return stbi__errpuc("outofmem", "Out of memory"); } if (tga_rgb16) { stbi_uc *pal_entry = tga_palette; STBI_ASSERT(tga_comp == STBI_rgb); for (i=0; i < tga_palette_len; ++i) { stbi__tga_read_rgb16(s, pal_entry); pal_entry += tga_comp; } } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { STBI_FREE(tga_data); STBI_FREE(tga_palette); return stbi__errpuc("bad palette", "Corrupt TGA"); } } // load the data for (i=0; i < tga_width * tga_height; ++i) { // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? if ( tga_is_RLE ) { if ( RLE_count == 0 ) { // yep, get the next byte as a RLE command int RLE_cmd = stbi__get8(s); RLE_count = 1 + (RLE_cmd & 127); RLE_repeating = RLE_cmd >> 7; read_next_pixel = 1; } else if ( !RLE_repeating ) { read_next_pixel = 1; } } else { read_next_pixel = 1; } // OK, if I need to read a pixel, do it now if ( read_next_pixel ) { // load however much data we did have if ( tga_indexed ) { // read in index, then perform the lookup int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); if ( pal_idx >= tga_palette_len ) { // invalid index pal_idx = 0; } pal_idx *= tga_comp; for (j = 0; j < tga_comp; ++j) { raw_data[j] = tga_palette[pal_idx+j]; } } else if(tga_rgb16) { STBI_ASSERT(tga_comp == STBI_rgb); stbi__tga_read_rgb16(s, raw_data); } else { // read in the data raw for (j = 0; j < tga_comp; ++j) { raw_data[j] = stbi__get8(s); } } // clear the reading flag for the next pixel read_next_pixel = 0; } // end of reading a pixel // copy data for (j = 0; j < tga_comp; ++j) tga_data[i*tga_comp+j] = raw_data[j]; // in case we're in RLE mode, keep counting down --RLE_count; } // do I need to invert the image? if ( tga_inverted ) { for (j = 0; j*2 < tga_height; ++j) { int index1 = j * tga_width * tga_comp; int index2 = (tga_height - 1 - j) * tga_width * tga_comp; for (i = tga_width * tga_comp; i > 0; --i) { unsigned char temp = tga_data[index1]; tga_data[index1] = tga_data[index2]; tga_data[index2] = temp; ++index1; ++index2; } } } // clear my palette, if I had one if ( tga_palette != NULL ) { STBI_FREE( tga_palette ); } } // swap RGB - if the source data was RGB16, it already is in the right order if (tga_comp >= 3 && !tga_rgb16) { unsigned char* tga_pixel = tga_data; for (i=0; i < tga_width * tga_height; ++i) { unsigned char temp = tga_pixel[0]; tga_pixel[0] = tga_pixel[2]; tga_pixel[2] = temp; tga_pixel += tga_comp; } } // convert to target component count if (req_comp && req_comp != tga_comp) tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); // the things I do to get rid of an error message, and yet keep // Microsoft's C compilers happy... [8^( tga_palette_start = tga_palette_len = tga_palette_bits = tga_x_origin = tga_y_origin = 0; // OK, done return tga_data; } #endif // ************************************************************************************************* // Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB #ifndef STBI_NO_PSD static int stbi__psd_test(stbi__context *s) { int r = (stbi__get32be(s) == 0x38425053); stbi__rewind(s); return r; } static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) { int count, nleft, len; count = 0; while ((nleft = pixelCount - count) > 0) { len = stbi__get8(s); if (len == 128) { // No-op. } else if (len < 128) { // Copy next len+1 bytes literally. len++; if (len > nleft) return 0; // corrupt data count += len; while (len) { *p = stbi__get8(s); p += 4; len--; } } else if (len > 128) { stbi_uc val; // Next -len+1 bytes in the dest are replicated from next source byte. // (Interpret len as a negative 8-bit int.) len = 257 - len; if (len > nleft) return 0; // corrupt data val = stbi__get8(s); count += len; while (len) { *p = val; p += 4; len--; } } } return 1; } static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) { int pixelCount; int channelCount, compression; int channel, i; int bitdepth; int w,h; stbi_uc *out; STBI_NOTUSED(ri); // Check identifier if (stbi__get32be(s) != 0x38425053) // "8BPS" return stbi__errpuc("not PSD", "Corrupt PSD image"); // Check file type version. if (stbi__get16be(s) != 1) return stbi__errpuc("wrong version", "Unsupported version of PSD image"); // Skip 6 reserved bytes. stbi__skip(s, 6 ); // Read the number of channels (R, G, B, A, etc). channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); // Read the rows and columns of the image. h = stbi__get32be(s); w = stbi__get32be(s); // Make sure the depth is 8 bits. bitdepth = stbi__get16be(s); if (bitdepth != 8 && bitdepth != 16) return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); // Make sure the color mode is RGB. // Valid options are: // 0: Bitmap // 1: Grayscale // 2: Indexed color // 3: RGB color // 4: CMYK color // 7: Multichannel // 8: Duotone // 9: Lab color if (stbi__get16be(s) != 3) return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) stbi__skip(s,stbi__get32be(s) ); // Skip the image resources. (resolution, pen tool paths, etc) stbi__skip(s, stbi__get32be(s) ); // Skip the reserved data. stbi__skip(s, stbi__get32be(s) ); // Find out if the data is compressed. // Known values: // 0: no compression // 1: RLE compressed compression = stbi__get16be(s); if (compression > 1) return stbi__errpuc("bad compression", "PSD has an unknown compression format"); // Check size if (!stbi__mad3sizes_valid(4, w, h, 0)) return stbi__errpuc("too large", "Corrupt PSD"); // Create the destination image. if (!compression && bitdepth == 16 && bpc == 16) { out = (stbi_uc *) stbi__malloc_mad3(8, w, h, 0); ri->bits_per_channel = 16; } else out = (stbi_uc *) stbi__malloc(4 * w*h); if (!out) return stbi__errpuc("outofmem", "Out of memory"); pixelCount = w*h; // Initialize the data to zero. //memset( out, 0, pixelCount * 4 ); // Finally, the image data. if (compression) { // RLE as used by .PSD and .TIFF // Loop until you get the number of unpacked bytes you are expecting: // Read the next source byte into n. // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. // Else if n is 128, noop. // Endloop // The RLE-compressed data is preceded by a 2-byte data count for each row in the data, // which we're going to just skip. stbi__skip(s, h * channelCount * 2 ); // Read the RLE data by channel. for (channel = 0; channel < 4; channel++) { stbi_uc *p; p = out+channel; if (channel >= channelCount) { // Fill this channel with default data. for (i = 0; i < pixelCount; i++, p += 4) *p = (channel == 3 ? 255 : 0); } else { // Read the RLE data. if (!stbi__psd_decode_rle(s, p, pixelCount)) { STBI_FREE(out); return stbi__errpuc("corrupt", "bad RLE data"); } } } } else { // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image. // Read the data by channel. for (channel = 0; channel < 4; channel++) { if (channel >= channelCount) { // Fill this channel with default data. if (bitdepth == 16 && bpc == 16) { stbi__uint16 *q = ((stbi__uint16 *) out) + channel; stbi__uint16 val = channel == 3 ? 65535 : 0; for (i = 0; i < pixelCount; i++, q += 4) *q = val; } else { stbi_uc *p = out+channel; stbi_uc val = channel == 3 ? 255 : 0; for (i = 0; i < pixelCount; i++, p += 4) *p = val; } } else { if (ri->bits_per_channel == 16) { // output bpc stbi__uint16 *q = ((stbi__uint16 *) out) + channel; for (i = 0; i < pixelCount; i++, q += 4) *q = (stbi__uint16) stbi__get16be(s); } else { stbi_uc *p = out+channel; if (bitdepth == 16) { // input bpc for (i = 0; i < pixelCount; i++, p += 4) *p = (stbi_uc) (stbi__get16be(s) >> 8); } else { for (i = 0; i < pixelCount; i++, p += 4) *p = stbi__get8(s); } } } } } // remove weird white matte from PSD if (channelCount >= 4) { if (ri->bits_per_channel == 16) { for (i=0; i < w*h; ++i) { stbi__uint16 *pixel = (stbi__uint16 *) out + 4*i; if (pixel[3] != 0 && pixel[3] != 65535) { float a = pixel[3] / 65535.0f; float ra = 1.0f / a; float inv_a = 65535.0f * (1 - ra); pixel[0] = (stbi__uint16) (pixel[0]*ra + inv_a); pixel[1] = (stbi__uint16) (pixel[1]*ra + inv_a); pixel[2] = (stbi__uint16) (pixel[2]*ra + inv_a); } } } else { for (i=0; i < w*h; ++i) { unsigned char *pixel = out + 4*i; if (pixel[3] != 0 && pixel[3] != 255) { float a = pixel[3] / 255.0f; float ra = 1.0f / a; float inv_a = 255.0f * (1 - ra); pixel[0] = (unsigned char) (pixel[0]*ra + inv_a); pixel[1] = (unsigned char) (pixel[1]*ra + inv_a); pixel[2] = (unsigned char) (pixel[2]*ra + inv_a); } } } } // convert to desired output format if (req_comp && req_comp != 4) { if (ri->bits_per_channel == 16) out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, 4, req_comp, w, h); else out = stbi__convert_format(out, 4, req_comp, w, h); if (out == NULL) return out; // stbi__convert_format frees input on failure } if (comp) *comp = 4; *y = h; *x = w; return out; } #endif // ************************************************************************************************* // Softimage PIC loader // by Tom Seddon // // See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format // See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ #ifndef STBI_NO_PIC static int stbi__pic_is4(stbi__context *s,const char *str) { int i; for (i=0; i<4; ++i) if (stbi__get8(s) != (stbi_uc)str[i]) return 0; return 1; } static int stbi__pic_test_core(stbi__context *s) { int i; if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) return 0; for(i=0;i<84;++i) stbi__get8(s); if (!stbi__pic_is4(s,"PICT")) return 0; return 1; } typedef struct { stbi_uc size,type,channel; } stbi__pic_packet; static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) { int mask=0x80, i; for (i=0; i<4; ++i, mask>>=1) { if (channel & mask) { if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short"); dest[i]=stbi__get8(s); } } return dest; } static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) { int mask=0x80,i; for (i=0;i<4; ++i, mask>>=1) if (channel&mask) dest[i]=src[i]; } static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result) { int act_comp=0,num_packets=0,y,chained; stbi__pic_packet packets[10]; // this will (should...) cater for even some bizarre stuff like having data // for the same channel in multiple packets. do { stbi__pic_packet *packet; if (num_packets==sizeof(packets)/sizeof(packets[0])) return stbi__errpuc("bad format","too many packets"); packet = &packets[num_packets++]; chained = stbi__get8(s); packet->size = stbi__get8(s); packet->type = stbi__get8(s); packet->channel = stbi__get8(s); act_comp |= packet->channel; if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (reading packets)"); if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp"); } while (chained); *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? for(y=0; ytype) { default: return stbi__errpuc("bad format","packet has bad compression type"); case 0: {//uncompressed int x; for(x=0;xchannel,dest)) return 0; break; } case 1://Pure RLE { int left=width, i; while (left>0) { stbi_uc count,value[4]; count=stbi__get8(s); if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pure read count)"); if (count > left) count = (stbi_uc) left; if (!stbi__readval(s,packet->channel,value)) return 0; for(i=0; ichannel,dest,value); left -= count; } } break; case 2: {//Mixed RLE int left=width; while (left>0) { int count = stbi__get8(s), i; if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (mixed read count)"); if (count >= 128) { // Repeated stbi_uc value[4]; if (count==128) count = stbi__get16be(s); else count -= 127; if (count > left) return stbi__errpuc("bad file","scanline overrun"); if (!stbi__readval(s,packet->channel,value)) return 0; for(i=0;ichannel,dest,value); } else { // Raw ++count; if (count>left) return stbi__errpuc("bad file","scanline overrun"); for(i=0;ichannel,dest)) return 0; } left-=count; } break; } } } } return result; } static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri) { stbi_uc *result; int i, x,y, internal_comp; STBI_NOTUSED(ri); if (!comp) comp = &internal_comp; for (i=0; i<92; ++i) stbi__get8(s); x = stbi__get16be(s); y = stbi__get16be(s); if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)"); if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode"); stbi__get32be(s); //skip `ratio' stbi__get16be(s); //skip `fields' stbi__get16be(s); //skip `pad' // intermediate buffer is RGBA result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0); memset(result, 0xff, x*y*4); if (!stbi__pic_load_core(s,x,y,comp, result)) { STBI_FREE(result); result=0; } *px = x; *py = y; if (req_comp == 0) req_comp = *comp; result=stbi__convert_format(result,4,req_comp,x,y); return result; } static int stbi__pic_test(stbi__context *s) { int r = stbi__pic_test_core(s); stbi__rewind(s); return r; } #endif // ************************************************************************************************* // GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb #ifndef STBI_NO_GIF typedef struct { stbi__int16 prefix; stbi_uc first; stbi_uc suffix; } stbi__gif_lzw; typedef struct { int w,h; stbi_uc *out; // output buffer (always 4 components) stbi_uc *background; // The current "background" as far as a gif is concerned stbi_uc *history; int flags, bgindex, ratio, transparent, eflags; stbi_uc pal[256][4]; stbi_uc lpal[256][4]; stbi__gif_lzw codes[8192]; stbi_uc *color_table; int parse, step; int lflags; int start_x, start_y; int max_x, max_y; int cur_x, cur_y; int line_size; int delay; } stbi__gif; static int stbi__gif_test_raw(stbi__context *s) { int sz; if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0; sz = stbi__get8(s); if (sz != '9' && sz != '7') return 0; if (stbi__get8(s) != 'a') return 0; return 1; } static int stbi__gif_test(stbi__context *s) { int r = stbi__gif_test_raw(s); stbi__rewind(s); return r; } static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) { int i; for (i=0; i < num_entries; ++i) { pal[i][2] = stbi__get8(s); pal[i][1] = stbi__get8(s); pal[i][0] = stbi__get8(s); pal[i][3] = transp == i ? 0 : 255; } } static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) { stbi_uc version; if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return stbi__err("not GIF", "Corrupt GIF"); version = stbi__get8(s); if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); stbi__g_failure_reason = ""; g->w = stbi__get16le(s); g->h = stbi__get16le(s); g->flags = stbi__get8(s); g->bgindex = stbi__get8(s); g->ratio = stbi__get8(s); g->transparent = -1; if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments if (is_info) return 1; if (g->flags & 0x80) stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); return 1; } static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) { stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif)); if (!stbi__gif_header(s, g, comp, 1)) { STBI_FREE(g); stbi__rewind( s ); return 0; } if (x) *x = g->w; if (y) *y = g->h; STBI_FREE(g); return 1; } static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) { stbi_uc *p, *c; int idx; // recurse to decode the prefixes, since the linked-list is backwards, // and working backwards through an interleaved image would be nasty if (g->codes[code].prefix >= 0) stbi__out_gif_code(g, g->codes[code].prefix); if (g->cur_y >= g->max_y) return; idx = g->cur_x + g->cur_y; p = &g->out[idx]; g->history[idx / 4] = 1; c = &g->color_table[g->codes[code].suffix * 4]; if (c[3] > 128) { // don't render transparent pixels; p[0] = c[2]; p[1] = c[1]; p[2] = c[0]; p[3] = c[3]; } g->cur_x += 4; if (g->cur_x >= g->max_x) { g->cur_x = g->start_x; g->cur_y += g->step; while (g->cur_y >= g->max_y && g->parse > 0) { g->step = (1 << g->parse) * g->line_size; g->cur_y = g->start_y + (g->step >> 1); --g->parse; } } } static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) { stbi_uc lzw_cs; stbi__int32 len, init_code; stbi__uint32 first; stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; stbi__gif_lzw *p; lzw_cs = stbi__get8(s); if (lzw_cs > 12) return NULL; clear = 1 << lzw_cs; first = 1; codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; bits = 0; valid_bits = 0; for (init_code = 0; init_code < clear; init_code++) { g->codes[init_code].prefix = -1; g->codes[init_code].first = (stbi_uc) init_code; g->codes[init_code].suffix = (stbi_uc) init_code; } // support no starting clear code avail = clear+2; oldcode = -1; len = 0; for(;;) { if (valid_bits < codesize) { if (len == 0) { len = stbi__get8(s); // start new block if (len == 0) return g->out; } --len; bits |= (stbi__int32) stbi__get8(s) << valid_bits; valid_bits += 8; } else { stbi__int32 code = bits & codemask; bits >>= codesize; valid_bits -= codesize; // @OPTIMIZE: is there some way we can accelerate the non-clear path? if (code == clear) { // clear code codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; avail = clear + 2; oldcode = -1; first = 0; } else if (code == clear + 1) { // end of stream code stbi__skip(s, len); while ((len = stbi__get8(s)) > 0) stbi__skip(s,len); return g->out; } else if (code <= avail) { if (first) { return stbi__errpuc("no clear code", "Corrupt GIF"); } if (oldcode >= 0) { p = &g->codes[avail++]; if (avail > 8192) { return stbi__errpuc("too many codes", "Corrupt GIF"); } p->prefix = (stbi__int16) oldcode; p->first = g->codes[oldcode].first; p->suffix = (code == avail) ? p->first : g->codes[code].first; } else if (code == avail) return stbi__errpuc("illegal code in raster", "Corrupt GIF"); stbi__out_gif_code(g, (stbi__uint16) code); if ((avail & codemask) == 0 && avail <= 0x0FFF) { codesize++; codemask = (1 << codesize) - 1; } oldcode = code; } else { return stbi__errpuc("illegal code in raster", "Corrupt GIF"); } } } } // this function is designed to support animated gifs, although stb_image doesn't support it // two back is the image from two frames ago, used for a very specific disposal format static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back) { int dispose; int first_frame; int pi; int pcount; STBI_NOTUSED(req_comp); // on first frame, any non-written pixels get the background colour (non-transparent) first_frame = 0; if (g->out == 0) { if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header if (!stbi__mad3sizes_valid(4, g->w, g->h, 0)) return stbi__errpuc("too large", "GIF image is too large"); pcount = g->w * g->h; g->out = (stbi_uc *) stbi__malloc(4 * pcount); g->background = (stbi_uc *) stbi__malloc(4 * pcount); g->history = (stbi_uc *) stbi__malloc(pcount); if (!g->out || !g->background || !g->history) return stbi__errpuc("outofmem", "Out of memory"); // image is treated as "transparent" at the start - ie, nothing overwrites the current background; // background colour is only used for pixels that are not rendered first frame, after that "background" // color refers to the color that was there the previous frame. memset(g->out, 0x00, 4 * pcount); memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent) memset(g->history, 0x00, pcount); // pixels that were affected previous frame first_frame = 1; } else { // second frame - how do we dispoase of the previous one? dispose = (g->eflags & 0x1C) >> 2; pcount = g->w * g->h; if ((dispose == 3) && (two_back == 0)) { dispose = 2; // if I don't have an image to revert back to, default to the old background } if (dispose == 3) { // use previous graphic for (pi = 0; pi < pcount; ++pi) { if (g->history[pi]) { memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 ); } } } else if (dispose == 2) { // restore what was changed last frame to background before that frame; for (pi = 0; pi < pcount; ++pi) { if (g->history[pi]) { memcpy( &g->out[pi * 4], &g->background[pi * 4], 4 ); } } } else { // This is a non-disposal case eithe way, so just // leave the pixels as is, and they will become the new background // 1: do not dispose // 0: not specified. } // background is what out is after the undoing of the previou frame; memcpy( g->background, g->out, 4 * g->w * g->h ); } // clear my history; memset( g->history, 0x00, g->w * g->h ); // pixels that were affected previous frame for (;;) { int tag = stbi__get8(s); switch (tag) { case 0x2C: /* Image Descriptor */ { stbi__int32 x, y, w, h; stbi_uc *o; x = stbi__get16le(s); y = stbi__get16le(s); w = stbi__get16le(s); h = stbi__get16le(s); if (((x + w) > (g->w)) || ((y + h) > (g->h))) return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); g->line_size = g->w * 4; g->start_x = x * 4; g->start_y = y * g->line_size; g->max_x = g->start_x + w * 4; g->max_y = g->start_y + h * g->line_size; g->cur_x = g->start_x; g->cur_y = g->start_y; // if the width of the specified rectangle is 0, that means // we may not see *any* pixels or the image is malformed; // to make sure this is caught, move the current y down to // max_y (which is what out_gif_code checks). if (w == 0) g->cur_y = g->max_y; g->lflags = stbi__get8(s); if (g->lflags & 0x40) { g->step = 8 * g->line_size; // first interlaced spacing g->parse = 3; } else { g->step = g->line_size; g->parse = 0; } if (g->lflags & 0x80) { stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); g->color_table = (stbi_uc *) g->lpal; } else if (g->flags & 0x80) { g->color_table = (stbi_uc *) g->pal; } else return stbi__errpuc("missing color table", "Corrupt GIF"); o = stbi__process_gif_raster(s, g); if (!o) return NULL; // if this was the first frame, pcount = g->w * g->h; if (first_frame && (g->bgindex > 0)) { // if first frame, any pixel not drawn to gets the background color for (pi = 0; pi < pcount; ++pi) { if (g->history[pi] == 0) { g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be; memcpy( &g->out[pi * 4], &g->pal[g->bgindex], 4 ); } } } return o; } case 0x21: // Comment Extension. { int len; int ext = stbi__get8(s); if (ext == 0xF9) { // Graphic Control Extension. len = stbi__get8(s); if (len == 4) { g->eflags = stbi__get8(s); g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths. // unset old transparent if (g->transparent >= 0) { g->pal[g->transparent][3] = 255; } if (g->eflags & 0x01) { g->transparent = stbi__get8(s); if (g->transparent >= 0) { g->pal[g->transparent][3] = 0; } } else { // don't need transparent stbi__skip(s, 1); g->transparent = -1; } } else { stbi__skip(s, len); break; } } while ((len = stbi__get8(s)) != 0) { stbi__skip(s, len); } break; } case 0x3B: // gif stream termination code return (stbi_uc *) s; // using '1' causes warning on some compilers default: return stbi__errpuc("unknown code", "Corrupt GIF"); } } } static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp) { if (stbi__gif_test(s)) { int layers = 0; stbi_uc *u = 0; stbi_uc *out = 0; stbi_uc *two_back = 0; stbi__gif g; int stride; memset(&g, 0, sizeof(g)); if (delays) { *delays = 0; } do { u = stbi__gif_load_next(s, &g, comp, req_comp, two_back); if (u == (stbi_uc *) s) u = 0; // end of animated gif marker if (u) { *x = g.w; *y = g.h; ++layers; stride = g.w * g.h * 4; if (out) { out = (stbi_uc*) STBI_REALLOC( out, layers * stride ); if (delays) { *delays = (int*) STBI_REALLOC( *delays, sizeof(int) * layers ); } } else { out = (stbi_uc*)stbi__malloc( layers * stride ); if (delays) { *delays = (int*) stbi__malloc( layers * sizeof(int) ); } } memcpy( out + ((layers - 1) * stride), u, stride ); if (layers >= 2) { two_back = out - 2 * stride; } if (delays) { (*delays)[layers - 1U] = g.delay; } } } while (u != 0); // free temp buffer; STBI_FREE(g.out); STBI_FREE(g.history); STBI_FREE(g.background); // do the final conversion after loading everything; if (req_comp && req_comp != 4) out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h); *z = layers; return out; } else { return stbi__errpuc("not GIF", "Image was not as a gif type."); } } static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *u = 0; stbi__gif g; memset(&g, 0, sizeof(g)); STBI_NOTUSED(ri); u = stbi__gif_load_next(s, &g, comp, req_comp, 0); if (u == (stbi_uc *) s) u = 0; // end of animated gif marker if (u) { *x = g.w; *y = g.h; // moved conversion to after successful load so that the same // can be done for multiple frames. if (req_comp && req_comp != 4) u = stbi__convert_format(u, 4, req_comp, g.w, g.h); } else if (g.out) { // if there was an error and we allocated an image buffer, free it! STBI_FREE(g.out); } // free buffers needed for multiple frame loading; STBI_FREE(g.history); STBI_FREE(g.background); return u; } static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) { return stbi__gif_info_raw(s,x,y,comp); } #endif // ************************************************************************************************* // Radiance RGBE HDR loader // originally by Nicolas Schulz #ifndef STBI_NO_HDR static int stbi__hdr_test_core(stbi__context *s, const char *signature) { int i; for (i=0; signature[i]; ++i) if (stbi__get8(s) != signature[i]) return 0; stbi__rewind(s); return 1; } static int stbi__hdr_test(stbi__context* s) { int r = stbi__hdr_test_core(s, "#?RADIANCE\n"); stbi__rewind(s); if(!r) { r = stbi__hdr_test_core(s, "#?RGBE\n"); stbi__rewind(s); } return r; } #define STBI__HDR_BUFLEN 1024 static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) { int len=0; char c = '\0'; c = (char) stbi__get8(z); while (!stbi__at_eof(z) && c != '\n') { buffer[len++] = c; if (len == STBI__HDR_BUFLEN-1) { // flush to end of line while (!stbi__at_eof(z) && stbi__get8(z) != '\n') ; break; } c = (char) stbi__get8(z); } buffer[len] = 0; return buffer; } static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) { if ( input[3] != 0 ) { float f1; // Exponent f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); if (req_comp <= 2) output[0] = (input[0] + input[1] + input[2]) * f1 / 3; else { output[0] = input[0] * f1; output[1] = input[1] * f1; output[2] = input[2] * f1; } if (req_comp == 2) output[1] = 1; if (req_comp == 4) output[3] = 1; } else { switch (req_comp) { case 4: output[3] = 1; /* fallthrough */ case 3: output[0] = output[1] = output[2] = 0; break; case 2: output[1] = 1; /* fallthrough */ case 1: output[0] = 0; break; } } } static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { char buffer[STBI__HDR_BUFLEN]; char *token; int valid = 0; int width, height; stbi_uc *scanline; float *hdr_data; int len; unsigned char count, value; int i, j, k, c1,c2, z; const char *headerToken; STBI_NOTUSED(ri); // Check identifier headerToken = stbi__hdr_gettoken(s,buffer); if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0) return stbi__errpf("not HDR", "Corrupt HDR image"); // Parse header for(;;) { token = stbi__hdr_gettoken(s,buffer); if (token[0] == 0) break; if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; } if (!valid) return stbi__errpf("unsupported format", "Unsupported HDR format"); // Parse width and height // can't use sscanf() if we're not using stdio! token = stbi__hdr_gettoken(s,buffer); if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); token += 3; height = (int) strtol(token, &token, 10); while (*token == ' ') ++token; if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); token += 3; width = (int) strtol(token, NULL, 10); *x = width; *y = height; if (comp) *comp = 3; if (req_comp == 0) req_comp = 3; if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0)) return stbi__errpf("too large", "HDR image is too large"); // Read data hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0); if (!hdr_data) return stbi__errpf("outofmem", "Out of memory"); // Load image data // image data is stored as some number of sca if ( width < 8 || width >= 32768) { // Read flat data for (j=0; j < height; ++j) { for (i=0; i < width; ++i) { stbi_uc rgbe[4]; main_decode_loop: stbi__getn(s, rgbe, 4); stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); } } } else { // Read RLE-encoded data scanline = NULL; for (j = 0; j < height; ++j) { c1 = stbi__get8(s); c2 = stbi__get8(s); len = stbi__get8(s); if (c1 != 2 || c2 != 2 || (len & 0x80)) { // not run-length encoded, so we have to actually use THIS data as a decoded // pixel (note this can't be a valid pixel--one of RGB must be >= 128) stbi_uc rgbe[4]; rgbe[0] = (stbi_uc) c1; rgbe[1] = (stbi_uc) c2; rgbe[2] = (stbi_uc) len; rgbe[3] = (stbi_uc) stbi__get8(s); stbi__hdr_convert(hdr_data, rgbe, req_comp); i = 1; j = 0; STBI_FREE(scanline); goto main_decode_loop; // yes, this makes no sense } len <<= 8; len |= stbi__get8(s); if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } if (scanline == NULL) { scanline = (stbi_uc *) stbi__malloc_mad2(width, 4, 0); if (!scanline) { STBI_FREE(hdr_data); return stbi__errpf("outofmem", "Out of memory"); } } for (k = 0; k < 4; ++k) { int nleft; i = 0; while ((nleft = width - i) > 0) { count = stbi__get8(s); if (count > 128) { // Run value = stbi__get8(s); count -= 128; if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } for (z = 0; z < count; ++z) scanline[i++ * 4 + k] = value; } else { // Dump if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } for (z = 0; z < count; ++z) scanline[i++ * 4 + k] = stbi__get8(s); } } } for (i=0; i < width; ++i) stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); } if (scanline) STBI_FREE(scanline); } return hdr_data; } static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) { char buffer[STBI__HDR_BUFLEN]; char *token; int valid = 0; int dummy; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (stbi__hdr_test(s) == 0) { stbi__rewind( s ); return 0; } for(;;) { token = stbi__hdr_gettoken(s,buffer); if (token[0] == 0) break; if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; } if (!valid) { stbi__rewind( s ); return 0; } token = stbi__hdr_gettoken(s,buffer); if (strncmp(token, "-Y ", 3)) { stbi__rewind( s ); return 0; } token += 3; *y = (int) strtol(token, &token, 10); while (*token == ' ') ++token; if (strncmp(token, "+X ", 3)) { stbi__rewind( s ); return 0; } token += 3; *x = (int) strtol(token, NULL, 10); *comp = 3; return 1; } #endif // STBI_NO_HDR #ifndef STBI_NO_BMP static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) { void *p; stbi__bmp_data info; info.all_a = 255; p = stbi__bmp_parse_header(s, &info); stbi__rewind( s ); if (p == NULL) return 0; if (x) *x = s->img_x; if (y) *y = s->img_y; if (comp) *comp = info.ma ? 4 : 3; return 1; } #endif #ifndef STBI_NO_PSD static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) { int channelCount, dummy, depth; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (stbi__get32be(s) != 0x38425053) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 1) { stbi__rewind( s ); return 0; } stbi__skip(s, 6); channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) { stbi__rewind( s ); return 0; } *y = stbi__get32be(s); *x = stbi__get32be(s); depth = stbi__get16be(s); if (depth != 8 && depth != 16) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 3) { stbi__rewind( s ); return 0; } *comp = 4; return 1; } static int stbi__psd_is16(stbi__context *s) { int channelCount, depth; if (stbi__get32be(s) != 0x38425053) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 1) { stbi__rewind( s ); return 0; } stbi__skip(s, 6); channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) { stbi__rewind( s ); return 0; } (void) stbi__get32be(s); (void) stbi__get32be(s); depth = stbi__get16be(s); if (depth != 16) { stbi__rewind( s ); return 0; } return 1; } #endif #ifndef STBI_NO_PIC static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) { int act_comp=0,num_packets=0,chained,dummy; stbi__pic_packet packets[10]; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) { stbi__rewind(s); return 0; } stbi__skip(s, 88); *x = stbi__get16be(s); *y = stbi__get16be(s); if (stbi__at_eof(s)) { stbi__rewind( s); return 0; } if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) { stbi__rewind( s ); return 0; } stbi__skip(s, 8); do { stbi__pic_packet *packet; if (num_packets==sizeof(packets)/sizeof(packets[0])) return 0; packet = &packets[num_packets++]; chained = stbi__get8(s); packet->size = stbi__get8(s); packet->type = stbi__get8(s); packet->channel = stbi__get8(s); act_comp |= packet->channel; if (stbi__at_eof(s)) { stbi__rewind( s ); return 0; } if (packet->size != 8) { stbi__rewind( s ); return 0; } } while (chained); *comp = (act_comp & 0x10 ? 4 : 3); return 1; } #endif // ************************************************************************************************* // Portable Gray Map and Portable Pixel Map loader // by Ken Miller // // PGM: http://netpbm.sourceforge.net/doc/pgm.html // PPM: http://netpbm.sourceforge.net/doc/ppm.html // // Known limitations: // Does not support comments in the header section // Does not support ASCII image data (formats P2 and P3) // Does not support 16-bit-per-channel #ifndef STBI_NO_PNM static int stbi__pnm_test(stbi__context *s) { char p, t; p = (char) stbi__get8(s); t = (char) stbi__get8(s); if (p != 'P' || (t != '5' && t != '6')) { stbi__rewind( s ); return 0; } return 1; } static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *out; STBI_NOTUSED(ri); if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n)) return 0; *x = s->img_x; *y = s->img_y; if (comp) *comp = s->img_n; if (!stbi__mad3sizes_valid(s->img_n, s->img_x, s->img_y, 0)) return stbi__errpuc("too large", "PNM too large"); out = (stbi_uc *) stbi__malloc_mad3(s->img_n, s->img_x, s->img_y, 0); if (!out) return stbi__errpuc("outofmem", "Out of memory"); stbi__getn(s, out, s->img_n * s->img_x * s->img_y); if (req_comp && req_comp != s->img_n) { out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); if (out == NULL) return out; // stbi__convert_format frees input on failure } return out; } static int stbi__pnm_isspace(char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; } static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) { for (;;) { while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) *c = (char) stbi__get8(s); if (stbi__at_eof(s) || *c != '#') break; while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' ) *c = (char) stbi__get8(s); } } static int stbi__pnm_isdigit(char c) { return c >= '0' && c <= '9'; } static int stbi__pnm_getinteger(stbi__context *s, char *c) { int value = 0; while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { value = value*10 + (*c - '0'); *c = (char) stbi__get8(s); } return value; } static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) { int maxv, dummy; char c, p, t; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; stbi__rewind(s); // Get identifier p = (char) stbi__get8(s); t = (char) stbi__get8(s); if (p != 'P' || (t != '5' && t != '6')) { stbi__rewind(s); return 0; } *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm c = (char) stbi__get8(s); stbi__pnm_skip_whitespace(s, &c); *x = stbi__pnm_getinteger(s, &c); // read width stbi__pnm_skip_whitespace(s, &c); *y = stbi__pnm_getinteger(s, &c); // read height stbi__pnm_skip_whitespace(s, &c); maxv = stbi__pnm_getinteger(s, &c); // read max value if (maxv > 255) return stbi__err("max value > 255", "PPM image not 8-bit"); else return 1; } #endif static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) { #ifndef STBI_NO_JPEG if (stbi__jpeg_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PNG if (stbi__png_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_GIF if (stbi__gif_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_BMP if (stbi__bmp_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PSD if (stbi__psd_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PIC if (stbi__pic_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PNM if (stbi__pnm_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_HDR if (stbi__hdr_info(s, x, y, comp)) return 1; #endif // test tga last because it's a crappy test! #ifndef STBI_NO_TGA if (stbi__tga_info(s, x, y, comp)) return 1; #endif return stbi__err("unknown image type", "Image not of any known type, or corrupt"); } static int stbi__is_16_main(stbi__context *s) { #ifndef STBI_NO_PNG if (stbi__png_is16(s)) return 1; #endif #ifndef STBI_NO_PSD if (stbi__psd_is16(s)) return 1; #endif return 0; } #ifndef STBI_NO_STDIO STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) { FILE *f = stbi__fopen(filename, "rb"); int result; if (!f) return stbi__err("can't fopen", "Unable to open file"); result = stbi_info_from_file(f, x, y, comp); fclose(f); return result; } STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) { int r; stbi__context s; long pos = ftell(f); stbi__start_file(&s, f); r = stbi__info_main(&s,x,y,comp); fseek(f,pos,SEEK_SET); return r; } STBIDEF int stbi_is_16_bit(char const *filename) { FILE *f = stbi__fopen(filename, "rb"); int result; if (!f) return stbi__err("can't fopen", "Unable to open file"); result = stbi_is_16_bit_from_file(f); fclose(f); return result; } STBIDEF int stbi_is_16_bit_from_file(FILE *f) { int r; stbi__context s; long pos = ftell(f); stbi__start_file(&s, f); r = stbi__is_16_main(&s); fseek(f,pos,SEEK_SET); return r; } #endif // !STBI_NO_STDIO STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__info_main(&s,x,y,comp); } STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); return stbi__info_main(&s,x,y,comp); } STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__is_16_main(&s); } STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); return stbi__is_16_main(&s); } #endif // STB_IMAGE_IMPLEMENTATION /* revision history: 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs 2.19 (2018-02-11) fix warning 2.18 (2018-01-30) fix warnings 2.17 (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug 1-bit BMP *_is_16_bit api avoid warnings 2.16 (2017-07-23) all functions have 16-bit variants; STBI_NO_STDIO works again; compilation fixes; fix rounding in unpremultiply; optimize vertical flip; disable raw_len validation; documentation fixes 2.15 (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode; warning fixes; disable run-time SSE detection on gcc; uniform handling of optional "return" values; thread-safe initialization of zlib tables 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs 2.13 (2016-11-29) add 16-bit API, only supported for PNG right now 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes 2.11 (2016-04-02) allocate large structures on the stack remove white matting for transparent PSD fix reported channel count for PNG & BMP re-enable SSE2 in non-gcc 64-bit support RGB-formatted JPEG read 16-bit PNGs (only as 8-bit) 2.10 (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED 2.09 (2016-01-16) allow comments in PNM files 16-bit-per-pixel TGA (not bit-per-component) info() for TGA could break due to .hdr handling info() for BMP to shares code instead of sloppy parse can use STBI_REALLOC_SIZED if allocator doesn't support realloc code cleanup 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA 2.07 (2015-09-13) fix compiler warnings partial animated GIF support limited 16-bpc PSD support #ifdef unused functions bug with < 92 byte PIC,PNM,HDR,TGA 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit 2.03 (2015-04-12) extra corruption checking (mmozeiko) stbi_set_flip_vertically_on_load (nguillemot) fix NEON support; fix mingw support 2.02 (2015-01-19) fix incorrect assert, fix warning 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG 2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) progressive JPEG (stb) PGM/PPM support (Ken Miller) STBI_MALLOC,STBI_REALLOC,STBI_FREE GIF bugfix -- seemingly never worked STBI_NO_*, STBI_ONLY_* 1.48 (2014-12-14) fix incorrectly-named assert() 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) optimize PNG (ryg) fix bug in interlaced PNG with user-specified channel count (stb) 1.46 (2014-08-26) fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG 1.45 (2014-08-16) fix MSVC-ARM internal compiler error by wrapping malloc 1.44 (2014-08-07) various warning fixes from Ronny Chevalier 1.43 (2014-07-15) fix MSVC-only compiler problem in code changed in 1.42 1.42 (2014-07-09) don't define _CRT_SECURE_NO_WARNINGS (affects user code) fixes to stbi__cleanup_jpeg path added STBI_ASSERT to avoid requiring assert.h 1.41 (2014-06-25) fix search&replace from 1.36 that messed up comments/error messages 1.40 (2014-06-22) fix gcc struct-initialization warning 1.39 (2014-06-15) fix to TGA optimization when req_comp != number of components in TGA; fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) add support for BMP version 5 (more ignored fields) 1.38 (2014-06-06) suppress MSVC warnings on integer casts truncating values fix accidental rename of 'skip' field of I/O 1.37 (2014-06-04) remove duplicate typedef 1.36 (2014-06-03) convert to header file single-file library if de-iphone isn't set, load iphone images color-swapped instead of returning NULL 1.35 (2014-05-27) various warnings fix broken STBI_SIMD path fix bug where stbi_load_from_file no longer left file pointer in correct place fix broken non-easy path for 32-bit BMP (possibly never used) TGA optimization by Arseny Kapoulkine 1.34 (unknown) use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case 1.33 (2011-07-14) make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements 1.32 (2011-07-13) support for "info" function for all supported filetypes (SpartanJ) 1.31 (2011-06-20) a few more leak fixes, bug in PNG handling (SpartanJ) 1.30 (2011-06-11) added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) removed deprecated format-specific test/load functions removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) fix inefficiency in decoding 32-bit BMP (David Woo) 1.29 (2010-08-16) various warning fixes from Aurelien Pocheville 1.28 (2010-08-01) fix bug in GIF palette transparency (SpartanJ) 1.27 (2010-08-01) cast-to-stbi_uc to fix warnings 1.26 (2010-07-24) fix bug in file buffering for PNG reported by SpartanJ 1.25 (2010-07-17) refix trans_data warning (Won Chun) 1.24 (2010-07-12) perf improvements reading from files on platforms with lock-heavy fgetc() minor perf improvements for jpeg deprecated type-specific functions so we'll get feedback if they're needed attempt to fix trans_data warning (Won Chun) 1.23 fixed bug in iPhone support 1.22 (2010-07-10) removed image *writing* support stbi_info support from Jetro Lauha GIF support from Jean-Marc Lienher iPhone PNG-extensions from James Brown warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) 1.21 fix use of 'stbi_uc' in header (reported by jon blow) 1.20 added support for Softimage PIC, by Tom Seddon 1.19 bug in interlaced PNG corruption check (found by ryg) 1.18 (2008-08-02) fix a threading bug (local mutable static) 1.17 support interlaced PNG 1.16 major bugfix - stbi__convert_format converted one too many pixels 1.15 initialize some fields for thread safety 1.14 fix threadsafe conversion bug header-file-only version (#define STBI_HEADER_FILE_ONLY before including) 1.13 threadsafe 1.12 const qualifiers in the API 1.11 Support installable IDCT, colorspace conversion routines 1.10 Fixes for 64-bit (don't use "unsigned long") optimized upsampling by Fabian "ryg" Giesen 1.09 Fix format-conversion for PSD code (bad global variables!) 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz 1.07 attempt to fix C++ warning/errors again 1.06 attempt to fix C++ warning/errors again 1.05 fix TGA loading to return correct *comp and use good luminance calc 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR 1.02 support for (subset of) HDR files, float interface for preferred access to them 1.01 fix bug: possible bug in handling right-side up bmps... not sure fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all 1.00 interface to zlib that skips zlib header 0.99 correct handling of alpha in palette 0.98 TGA loader by lonesock; dynamically add loaders (untested) 0.97 jpeg errors on too large a file; also catch another malloc failure 0.96 fix detection of invalid v value - particleman@mollyrocket forum 0.95 during header scan, seek to markers in case of padding 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same 0.93 handle jpegtran output; verbose errors 0.92 read 4,8,16,24,32-bit BMP files of several formats 0.91 output 24-bit Windows 3.0 BMP files 0.90 fix a few more warnings; bump version number to approach 1.0 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd 0.60 fix compiling as c++ 0.59 fix warnings: merge Dave Moore's -Wall fixes 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available 0.56 fix bug: zlib uncompressed mode len vs. nlen 0.55 fix bug: restart_interval not initialized to 0 0.54 allow NULL for 'int *comp' 0.53 fix bug in png 3->4; speedup png decoding 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments 0.51 obey req_comp requests, 1-component jpegs return as 1-component, on 'test' only check type, not whether we support this variant 0.50 (2006-11-19) first released version */ /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ goxel-0.11.0/ext_src/stb/stb_image_write.h000066400000000000000000002015031435762723100204760ustar00rootroot00000000000000/* stb_image_write - v1.13 - public domain - http://nothings.org/stb/stb_image_write.h writes out PNG/BMP/TGA/JPEG/HDR images to C stdio - Sean Barrett 2010-2015 no warranty implied; use at your own risk Before #including, #define STB_IMAGE_WRITE_IMPLEMENTATION in the file that you want to have the implementation. Will probably not work correctly with strict-aliasing optimizations. ABOUT: This header file is a library for writing images to C stdio or a callback. The PNG output is not optimal; it is 20-50% larger than the file written by a decent optimizing implementation; though providing a custom zlib compress function (see STBIW_ZLIB_COMPRESS) can mitigate that. This library is designed for source code compactness and simplicity, not optimal image file size or run-time performance. BUILDING: You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h. You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace malloc,realloc,free. You can #define STBIW_MEMMOVE() to replace memmove() You can #define STBIW_ZLIB_COMPRESS to use a custom zlib-style compress function for PNG compression (instead of the builtin one), it must have the following signature: unsigned char * my_compress(unsigned char *data, int data_len, int *out_len, int quality); The returned data will be freed with STBIW_FREE() (free() by default), so it must be heap allocated with STBIW_MALLOC() (malloc() by default), UNICODE: If compiling for Windows and you wish to use Unicode filenames, compile with #define STBIW_WINDOWS_UTF8 and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert Windows wchar_t filenames to utf8. USAGE: There are five functions, one for each image file format: int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); int stbi_write_jpg(char const *filename, int w, int h, int comp, const void *data, int quality); int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); void stbi_flip_vertically_on_write(int flag); // flag is non-zero to flip data vertically There are also five equivalent functions that use an arbitrary write function. You are expected to open/close your file-equivalent before and after calling these: int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); where the callback is: void stbi_write_func(void *context, void *data, int size); You can configure it with these global variables: int stbi_write_tga_with_rle; // defaults to true; set to 0 to disable RLE int stbi_write_png_compression_level; // defaults to 8; set to higher for more compression int stbi_write_force_png_filter; // defaults to -1; set to 0..5 to force a filter mode You can define STBI_WRITE_NO_STDIO to disable the file variant of these functions, so the library will not use stdio.h at all. However, this will also disable HDR writing, because it requires stdio for formatted output. Each function returns 0 on failure and non-0 on success. The functions create an image file defined by the parameters. The image is a rectangle of pixels stored from left-to-right, top-to-bottom. Each pixel contains 'comp' channels of data stored interleaved with 8-bits per channel, in the following order: 1=Y, 2=YA, 3=RGB, 4=RGBA. (Y is monochrome color.) The rectangle is 'w' pixels wide and 'h' pixels tall. The *data pointer points to the first byte of the top-left-most pixel. For PNG, "stride_in_bytes" is the distance in bytes from the first byte of a row of pixels to the first byte of the next row of pixels. PNG creates output files with the same number of components as the input. The BMP format expands Y to RGB in the file format and does not output alpha. PNG supports writing rectangles of data even when the bytes storing rows of data are not consecutive in memory (e.g. sub-rectangles of a larger image), by supplying the stride between the beginning of adjacent rows. The other formats do not. (Thus you cannot write a native-format BMP through the BMP writer, both because it is in BGR order and because it may have padding at the end of the line.) PNG allows you to set the deflate compression level by setting the global variable 'stbi_write_png_compression_level' (it defaults to 8). HDR expects linear float data. Since the format is always 32-bit rgb(e) data, alpha (if provided) is discarded, and for monochrome data it is replicated across all three channels. TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed data, set the global variable 'stbi_write_tga_with_rle' to 0. JPEG does ignore alpha channels in input data; quality is between 1 and 100. Higher quality looks better but results in a bigger image. JPEG baseline (no JPEG progressive). CREDITS: Sean Barrett - PNG/BMP/TGA Baldur Karlsson - HDR Jean-Sebastien Guay - TGA monochrome Tim Kelsey - misc enhancements Alan Hickman - TGA RLE Emmanuel Julien - initial file IO callback implementation Jon Olick - original jo_jpeg.cpp code Daniel Gibson - integrate JPEG, allow external zlib Aarni Koskela - allow choosing PNG filter bugfixes: github:Chribba Guillaume Chereau github:jry2 github:romigrou Sergio Gonzalez Jonas Karlsson Filip Wasil Thatcher Ulrich github:poppolopoppo Patrick Boettcher github:xeekworx Cap Petschulat Simon Rodriguez Ivan Tikhonov github:ignotion Adam Schackart LICENSE See end of file for license information. */ #ifndef INCLUDE_STB_IMAGE_WRITE_H #define INCLUDE_STB_IMAGE_WRITE_H #include // if STB_IMAGE_WRITE_STATIC causes problems, try defining STBIWDEF to 'inline' or 'static inline' #ifndef STBIWDEF #ifdef STB_IMAGE_WRITE_STATIC #define STBIWDEF static #else #ifdef __cplusplus #define STBIWDEF extern "C" #else #define STBIWDEF extern #endif #endif #endif #ifndef STB_IMAGE_WRITE_STATIC // C++ forbids static forward declarations extern int stbi_write_tga_with_rle; extern int stbi_write_png_compression_level; extern int stbi_write_force_png_filter; #endif #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality); #ifdef STBI_WINDOWS_UTF8 STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); #endif #endif typedef void stbi_write_func(void *context, void *data, int size); STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean); #endif//INCLUDE_STB_IMAGE_WRITE_H #ifdef STB_IMAGE_WRITE_IMPLEMENTATION #ifdef _WIN32 #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS #endif #ifndef _CRT_NONSTDC_NO_DEPRECATE #define _CRT_NONSTDC_NO_DEPRECATE #endif #endif #ifndef STBI_WRITE_NO_STDIO #include #endif // STBI_WRITE_NO_STDIO #include #include #include #include #if defined(STBIW_MALLOC) && defined(STBIW_FREE) && (defined(STBIW_REALLOC) || defined(STBIW_REALLOC_SIZED)) // ok #elif !defined(STBIW_MALLOC) && !defined(STBIW_FREE) && !defined(STBIW_REALLOC) && !defined(STBIW_REALLOC_SIZED) // ok #else #error "Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC (or STBIW_REALLOC_SIZED)." #endif #ifndef STBIW_MALLOC #define STBIW_MALLOC(sz) malloc(sz) #define STBIW_REALLOC(p,newsz) realloc(p,newsz) #define STBIW_FREE(p) free(p) #endif #ifndef STBIW_REALLOC_SIZED #define STBIW_REALLOC_SIZED(p,oldsz,newsz) STBIW_REALLOC(p,newsz) #endif #ifndef STBIW_MEMMOVE #define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz) #endif #ifndef STBIW_ASSERT #include #define STBIW_ASSERT(x) assert(x) #endif #define STBIW_UCHAR(x) (unsigned char) ((x) & 0xff) #ifdef STB_IMAGE_WRITE_STATIC static int stbi__flip_vertically_on_write=0; static int stbi_write_png_compression_level = 8; static int stbi_write_tga_with_rle = 1; static int stbi_write_force_png_filter = -1; #else int stbi_write_png_compression_level = 8; int stbi__flip_vertically_on_write=0; int stbi_write_tga_with_rle = 1; int stbi_write_force_png_filter = -1; #endif STBIWDEF void stbi_flip_vertically_on_write(int flag) { stbi__flip_vertically_on_write = flag; } typedef struct { stbi_write_func *func; void *context; } stbi__write_context; // initialize a callback-based context static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func *c, void *context) { s->func = c; s->context = context; } #ifndef STBI_WRITE_NO_STDIO static void stbi__stdio_write(void *context, void *data, int size) { fwrite(data,1,size,(FILE*) context); } #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) #ifdef __cplusplus #define STBIW_EXTERN extern "C" #else #define STBIW_EXTERN extern #endif STBIW_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); STBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) { return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); } #endif static FILE *stbiw__fopen(char const *filename, char const *mode) { FILE *f; #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) wchar_t wMode[64]; wchar_t wFilename[1024]; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename))) return 0; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode))) return 0; #if _MSC_VER >= 1400 if (0 != _wfopen_s(&f, wFilename, wMode)) f = 0; #else f = _wfopen(wFilename, wMode); #endif #elif defined(_MSC_VER) && _MSC_VER >= 1400 if (0 != fopen_s(&f, filename, mode)) f=0; #else f = fopen(filename, mode); #endif return f; } static int stbi__start_write_file(stbi__write_context *s, const char *filename) { FILE *f = stbiw__fopen(filename, "wb"); stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f); return f != NULL; } static void stbi__end_write_file(stbi__write_context *s) { fclose((FILE *)s->context); } #endif // !STBI_WRITE_NO_STDIO typedef unsigned int stbiw_uint32; typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1]; static void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v) { while (*fmt) { switch (*fmt++) { case ' ': break; case '1': { unsigned char x = STBIW_UCHAR(va_arg(v, int)); s->func(s->context,&x,1); break; } case '2': { int x = va_arg(v,int); unsigned char b[2]; b[0] = STBIW_UCHAR(x); b[1] = STBIW_UCHAR(x>>8); s->func(s->context,b,2); break; } case '4': { stbiw_uint32 x = va_arg(v,int); unsigned char b[4]; b[0]=STBIW_UCHAR(x); b[1]=STBIW_UCHAR(x>>8); b[2]=STBIW_UCHAR(x>>16); b[3]=STBIW_UCHAR(x>>24); s->func(s->context,b,4); break; } default: STBIW_ASSERT(0); return; } } } static void stbiw__writef(stbi__write_context *s, const char *fmt, ...) { va_list v; va_start(v, fmt); stbiw__writefv(s, fmt, v); va_end(v); } static void stbiw__putc(stbi__write_context *s, unsigned char c) { s->func(s->context, &c, 1); } static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c) { unsigned char arr[3]; arr[0] = a; arr[1] = b; arr[2] = c; s->func(s->context, arr, 3); } static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d) { unsigned char bg[3] = { 255, 0, 255}, px[3]; int k; if (write_alpha < 0) s->func(s->context, &d[comp - 1], 1); switch (comp) { case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case case 1: if (expand_mono) stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp else s->func(s->context, d, 1); // monochrome TGA break; case 4: if (!write_alpha) { // composite against pink background for (k = 0; k < 3; ++k) px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255; stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]); break; } /* FALLTHROUGH */ case 3: stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]); break; } if (write_alpha > 0) s->func(s->context, &d[comp - 1], 1); } static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono) { stbiw_uint32 zero = 0; int i,j, j_end; if (y <= 0) return; if (stbi__flip_vertically_on_write) vdir *= -1; if (vdir < 0) { j_end = -1; j = y-1; } else { j_end = y; j = 0; } for (; j != j_end; j += vdir) { for (i=0; i < x; ++i) { unsigned char *d = (unsigned char *) data + (j*x+i)*comp; stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d); } s->func(s->context, &zero, scanline_pad); } } static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...) { if (y < 0 || x < 0) { return 0; } else { va_list v; va_start(v, fmt); stbiw__writefv(s, fmt, v); va_end(v); stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono); return 1; } } static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data) { int pad = (-x*3) & 3; return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad, "11 4 22 4" "4 44 22 444444", 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header } STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_bmp_core(&s, x, y, comp, data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_bmp_core(&s, x, y, comp, data); stbi__end_write_file(&s); return r; } else return 0; } #endif //!STBI_WRITE_NO_STDIO static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data) { int has_alpha = (comp == 2 || comp == 4); int colorbytes = has_alpha ? comp-1 : comp; int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3 if (y < 0 || x < 0) return 0; if (!stbi_write_tga_with_rle) { return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0, "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8); } else { int i,j,k; int jend, jdir; stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8); if (stbi__flip_vertically_on_write) { j = 0; jend = y; jdir = 1; } else { j = y-1; jend = -1; jdir = -1; } for (; j != jend; j += jdir) { unsigned char *row = (unsigned char *) data + j * x * comp; int len; for (i = 0; i < x; i += len) { unsigned char *begin = row + i * comp; int diff = 1; len = 1; if (i < x - 1) { ++len; diff = memcmp(begin, row + (i + 1) * comp, comp); if (diff) { const unsigned char *prev = begin; for (k = i + 2; k < x && len < 128; ++k) { if (memcmp(prev, row + k * comp, comp)) { prev += comp; ++len; } else { --len; break; } } } else { for (k = i + 2; k < x && len < 128; ++k) { if (!memcmp(begin, row + k * comp, comp)) { ++len; } else { break; } } } } if (diff) { unsigned char header = STBIW_UCHAR(len - 1); s->func(s->context, &header, 1); for (k = 0; k < len; ++k) { stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp); } } else { unsigned char header = STBIW_UCHAR(len - 129); s->func(s->context, &header, 1); stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin); } } } } return 1; } STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_tga_core(&s, x, y, comp, (void *) data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_tga_core(&s, x, y, comp, (void *) data); stbi__end_write_file(&s); return r; } else return 0; } #endif // ************************************************************************************************* // Radiance RGBE HDR writer // by Baldur Karlsson #define stbiw__max(a, b) ((a) > (b) ? (a) : (b)) static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) { int exponent; float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2])); if (maxcomp < 1e-32f) { rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0; } else { float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp; rgbe[0] = (unsigned char)(linear[0] * normalize); rgbe[1] = (unsigned char)(linear[1] * normalize); rgbe[2] = (unsigned char)(linear[2] * normalize); rgbe[3] = (unsigned char)(exponent + 128); } } static void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte) { unsigned char lengthbyte = STBIW_UCHAR(length+128); STBIW_ASSERT(length+128 <= 255); s->func(s->context, &lengthbyte, 1); s->func(s->context, &databyte, 1); } static void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data) { unsigned char lengthbyte = STBIW_UCHAR(length); STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code s->func(s->context, &lengthbyte, 1); s->func(s->context, data, length); } static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline) { unsigned char scanlineheader[4] = { 2, 2, 0, 0 }; unsigned char rgbe[4]; float linear[3]; int x; scanlineheader[2] = (width&0xff00)>>8; scanlineheader[3] = (width&0x00ff); /* skip RLE for images too small or large */ if (width < 8 || width >= 32768) { for (x=0; x < width; x++) { switch (ncomp) { case 4: /* fallthrough */ case 3: linear[2] = scanline[x*ncomp + 2]; linear[1] = scanline[x*ncomp + 1]; linear[0] = scanline[x*ncomp + 0]; break; default: linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; break; } stbiw__linear_to_rgbe(rgbe, linear); s->func(s->context, rgbe, 4); } } else { int c,r; /* encode into scratch buffer */ for (x=0; x < width; x++) { switch(ncomp) { case 4: /* fallthrough */ case 3: linear[2] = scanline[x*ncomp + 2]; linear[1] = scanline[x*ncomp + 1]; linear[0] = scanline[x*ncomp + 0]; break; default: linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; break; } stbiw__linear_to_rgbe(rgbe, linear); scratch[x + width*0] = rgbe[0]; scratch[x + width*1] = rgbe[1]; scratch[x + width*2] = rgbe[2]; scratch[x + width*3] = rgbe[3]; } s->func(s->context, scanlineheader, 4); /* RLE each component separately */ for (c=0; c < 4; c++) { unsigned char *comp = &scratch[width*c]; x = 0; while (x < width) { // find first run r = x; while (r+2 < width) { if (comp[r] == comp[r+1] && comp[r] == comp[r+2]) break; ++r; } if (r+2 >= width) r = width; // dump up to first run while (x < r) { int len = r-x; if (len > 128) len = 128; stbiw__write_dump_data(s, len, &comp[x]); x += len; } // if there's a run, output it if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd // find next byte after run while (r < width && comp[r] == comp[x]) ++r; // output run up to r while (x < r) { int len = r-x; if (len > 127) len = 127; stbiw__write_run_data(s, len, comp[x]); x += len; } } } } } } static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data) { if (y <= 0 || x <= 0 || data == NULL) return 0; else { // Each component is stored separately. Allocate scratch space for full output scanline. unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4); int i, len; char buffer[128]; char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n"; s->func(s->context, header, sizeof(header)-1); #ifdef __STDC_WANT_SECURE_LIB__ len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); #else len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); #endif s->func(s->context, buffer, len); for(i=0; i < y; i++) stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i)); STBIW_FREE(scratch); return 1; } } STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_hdr_core(&s, x, y, comp, (float *) data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data); stbi__end_write_file(&s); return r; } else return 0; } #endif // STBI_WRITE_NO_STDIO ////////////////////////////////////////////////////////////////////////////// // // PNG writer // #ifndef STBIW_ZLIB_COMPRESS // stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size() #define stbiw__sbraw(a) ((int *) (a) - 2) #define stbiw__sbm(a) stbiw__sbraw(a)[0] #define stbiw__sbn(a) stbiw__sbraw(a)[1] #define stbiw__sbneedgrow(a,n) ((a)==0 || stbiw__sbn(a)+n >= stbiw__sbm(a)) #define stbiw__sbmaybegrow(a,n) (stbiw__sbneedgrow(a,(n)) ? stbiw__sbgrow(a,n) : 0) #define stbiw__sbgrow(a,n) stbiw__sbgrowf((void **) &(a), (n), sizeof(*(a))) #define stbiw__sbpush(a, v) (stbiw__sbmaybegrow(a,1), (a)[stbiw__sbn(a)++] = (v)) #define stbiw__sbcount(a) ((a) ? stbiw__sbn(a) : 0) #define stbiw__sbfree(a) ((a) ? STBIW_FREE(stbiw__sbraw(a)),0 : 0) static void *stbiw__sbgrowf(void **arr, int increment, int itemsize) { int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1; void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2); STBIW_ASSERT(p); if (p) { if (!*arr) ((int *) p)[1] = 0; *arr = (void *) ((int *) p + 2); stbiw__sbm(*arr) = m; } return *arr; } static unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount) { while (*bitcount >= 8) { stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer)); *bitbuffer >>= 8; *bitcount -= 8; } return data; } static int stbiw__zlib_bitrev(int code, int codebits) { int res=0; while (codebits--) { res = (res << 1) | (code & 1); code >>= 1; } return res; } static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit) { int i; for (i=0; i < limit && i < 258; ++i) if (a[i] != b[i]) break; return i; } static unsigned int stbiw__zhash(unsigned char *data) { stbiw_uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16); hash ^= hash << 3; hash += hash >> 5; hash ^= hash << 4; hash += hash >> 17; hash ^= hash << 25; hash += hash >> 6; return hash; } #define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount)) #define stbiw__zlib_add(code,codebits) \ (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush()) #define stbiw__zlib_huffa(b,c) stbiw__zlib_add(stbiw__zlib_bitrev(b,c),c) // default huffman tables #define stbiw__zlib_huff1(n) stbiw__zlib_huffa(0x30 + (n), 8) #define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n)-144, 9) #define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n)-256,7) #define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n)-280,8) #define stbiw__zlib_huff(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : (n) <= 255 ? stbiw__zlib_huff2(n) : (n) <= 279 ? stbiw__zlib_huff3(n) : stbiw__zlib_huff4(n)) #define stbiw__zlib_huffb(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : stbiw__zlib_huff2(n)) #define stbiw__ZHASH 16384 #endif // STBIW_ZLIB_COMPRESS STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality) { #ifdef STBIW_ZLIB_COMPRESS // user provided a zlib compress implementation, use that return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality); #else // use builtin static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 }; static unsigned char lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 }; static unsigned short distc[] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 }; static unsigned char disteb[] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 }; unsigned int bitbuf=0; int i,j, bitcount=0; unsigned char *out = NULL; unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(char**)); if (hash_table == NULL) return NULL; if (quality < 5) quality = 5; stbiw__sbpush(out, 0x78); // DEFLATE 32K window stbiw__sbpush(out, 0x5e); // FLEVEL = 1 stbiw__zlib_add(1,1); // BFINAL = 1 stbiw__zlib_add(1,2); // BTYPE = 1 -- fixed huffman for (i=0; i < stbiw__ZHASH; ++i) hash_table[i] = NULL; i=0; while (i < data_len-3) { // hash next 3 bytes of data to be compressed int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3; unsigned char *bestloc = 0; unsigned char **hlist = hash_table[h]; int n = stbiw__sbcount(hlist); for (j=0; j < n; ++j) { if (hlist[j]-data > i-32768) { // if entry lies within window int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i); if (d >= best) { best=d; bestloc=hlist[j]; } } } // when hash table entry is too long, delete half the entries if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) { STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality); stbiw__sbn(hash_table[h]) = quality; } stbiw__sbpush(hash_table[h],data+i); if (bestloc) { // "lazy matching" - check match at *next* byte, and if it's better, do cur byte as literal h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1); hlist = hash_table[h]; n = stbiw__sbcount(hlist); for (j=0; j < n; ++j) { if (hlist[j]-data > i-32767) { int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1); if (e > best) { // if next match is better, bail on current match bestloc = NULL; break; } } } } if (bestloc) { int d = (int) (data+i - bestloc); // distance back STBIW_ASSERT(d <= 32767 && best <= 258); for (j=0; best > lengthc[j+1]-1; ++j); stbiw__zlib_huff(j+257); if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]); for (j=0; d > distc[j+1]-1; ++j); stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5); if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]); i += best; } else { stbiw__zlib_huffb(data[i]); ++i; } } // write out final bytes for (;i < data_len; ++i) stbiw__zlib_huffb(data[i]); stbiw__zlib_huff(256); // end of block // pad with 0 bits to byte boundary while (bitcount) stbiw__zlib_add(0,1); for (i=0; i < stbiw__ZHASH; ++i) (void) stbiw__sbfree(hash_table[i]); STBIW_FREE(hash_table); { // compute adler32 on input unsigned int s1=1, s2=0; int blocklen = (int) (data_len % 5552); j=0; while (j < data_len) { for (i=0; i < blocklen; ++i) { s1 += data[j+i]; s2 += s1; } s1 %= 65521; s2 %= 65521; j += blocklen; blocklen = 5552; } stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8)); stbiw__sbpush(out, STBIW_UCHAR(s2)); stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8)); stbiw__sbpush(out, STBIW_UCHAR(s1)); } *out_len = stbiw__sbn(out); // make returned pointer freeable STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len); return (unsigned char *) stbiw__sbraw(out); #endif // STBIW_ZLIB_COMPRESS } static unsigned int stbiw__crc32(unsigned char *buffer, int len) { #ifdef STBIW_CRC32 return STBIW_CRC32(buffer, len); #else static unsigned int crc_table[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D }; unsigned int crc = ~0u; int i; for (i=0; i < len; ++i) crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)]; return ~crc; #endif } #define stbiw__wpng4(o,a,b,c,d) ((o)[0]=STBIW_UCHAR(a),(o)[1]=STBIW_UCHAR(b),(o)[2]=STBIW_UCHAR(c),(o)[3]=STBIW_UCHAR(d),(o)+=4) #define stbiw__wp32(data,v) stbiw__wpng4(data, (v)>>24,(v)>>16,(v)>>8,(v)); #define stbiw__wptag(data,s) stbiw__wpng4(data, s[0],s[1],s[2],s[3]) static void stbiw__wpcrc(unsigned char **data, int len) { unsigned int crc = stbiw__crc32(*data - len - 4, len+4); stbiw__wp32(*data, crc); } static unsigned char stbiw__paeth(int a, int b, int c) { int p = a + b - c, pa = abs(p-a), pb = abs(p-b), pc = abs(p-c); if (pa <= pb && pa <= pc) return STBIW_UCHAR(a); if (pb <= pc) return STBIW_UCHAR(b); return STBIW_UCHAR(c); } // @OPTIMIZE: provide an option that always forces left-predict or paeth predict static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer) { static int mapping[] = { 0,1,2,3,4 }; static int firstmap[] = { 0,1,0,5,6 }; int *mymap = (y != 0) ? mapping : firstmap; int i; int type = mymap[filter_type]; unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y); int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes; if (type==0) { memcpy(line_buffer, z, width*n); return; } // first loop isn't optimized since it's just one pixel for (i = 0; i < n; ++i) { switch (type) { case 1: line_buffer[i] = z[i]; break; case 2: line_buffer[i] = z[i] - z[i-signed_stride]; break; case 3: line_buffer[i] = z[i] - (z[i-signed_stride]>>1); break; case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-signed_stride],0)); break; case 5: line_buffer[i] = z[i]; break; case 6: line_buffer[i] = z[i]; break; } } switch (type) { case 1: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-n]; break; case 2: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-signed_stride]; break; case 3: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - ((z[i-n] + z[i-signed_stride])>>1); break; case 4: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-signed_stride], z[i-signed_stride-n]); break; case 5: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - (z[i-n]>>1); break; case 6: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break; } } STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len) { int force_filter = stbi_write_force_png_filter; int ctype[5] = { -1, 0, 4, 2, 6 }; unsigned char sig[8] = { 137,80,78,71,13,10,26,10 }; unsigned char *out,*o, *filt, *zlib; signed char *line_buffer; int j,zlen; if (stride_bytes == 0) stride_bytes = x * n; if (force_filter >= 5) { force_filter = -1; } filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0; line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; } for (j=0; j < y; ++j) { int filter_type; if (force_filter > -1) { filter_type = force_filter; stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer); } else { // Estimate the best filter by running through all of them: int best_filter = 0, best_filter_val = 0x7fffffff, est, i; for (filter_type = 0; filter_type < 5; filter_type++) { stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer); // Estimate the entropy of the line using this filter; the less, the better. est = 0; for (i = 0; i < x*n; ++i) { est += abs((signed char) line_buffer[i]); } if (est < best_filter_val) { best_filter_val = est; best_filter = filter_type; } } if (filter_type != best_filter) { // If the last iteration already got us the best filter, don't redo it stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer); filter_type = best_filter; } } // when we get here, filter_type contains the filter type, and line_buffer contains the data filt[j*(x*n+1)] = (unsigned char) filter_type; STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n); } STBIW_FREE(line_buffer); zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level); STBIW_FREE(filt); if (!zlib) return 0; // each tag requires 12 bytes of overhead out = (unsigned char *) STBIW_MALLOC(8 + 12+13 + 12+zlen + 12); if (!out) return 0; *out_len = 8 + 12+13 + 12+zlen + 12; o=out; STBIW_MEMMOVE(o,sig,8); o+= 8; stbiw__wp32(o, 13); // header length stbiw__wptag(o, "IHDR"); stbiw__wp32(o, x); stbiw__wp32(o, y); *o++ = 8; *o++ = STBIW_UCHAR(ctype[n]); *o++ = 0; *o++ = 0; *o++ = 0; stbiw__wpcrc(&o,13); stbiw__wp32(o, zlen); stbiw__wptag(o, "IDAT"); STBIW_MEMMOVE(o, zlib, zlen); o += zlen; STBIW_FREE(zlib); stbiw__wpcrc(&o, zlen); stbiw__wp32(o,0); stbiw__wptag(o, "IEND"); stbiw__wpcrc(&o,0); STBIW_ASSERT(o == out + *out_len); return out; } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes) { FILE *f; int len; unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); if (png == NULL) return 0; f = stbiw__fopen(filename, "wb"); if (!f) { STBIW_FREE(png); return 0; } fwrite(png, 1, len, f); fclose(f); STBIW_FREE(png); return 1; } #endif STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes) { int len; unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); if (png == NULL) return 0; func(context, png, len); STBIW_FREE(png); return 1; } /* *************************************************************************** * * JPEG writer * * This is based on Jon Olick's jo_jpeg.cpp: * public domain Simple, Minimalistic JPEG writer - http://www.jonolick.com/code.html */ static const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18, 24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 }; static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) { int bitBuf = *bitBufP, bitCnt = *bitCntP; bitCnt += bs[1]; bitBuf |= bs[0] << (24 - bitCnt); while(bitCnt >= 8) { unsigned char c = (bitBuf >> 16) & 255; stbiw__putc(s, c); if(c == 255) { stbiw__putc(s, 0); } bitBuf <<= 8; bitCnt -= 8; } *bitBufP = bitBuf; *bitCntP = bitCnt; } static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p) { float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p; float z1, z2, z3, z4, z5, z11, z13; float tmp0 = d0 + d7; float tmp7 = d0 - d7; float tmp1 = d1 + d6; float tmp6 = d1 - d6; float tmp2 = d2 + d5; float tmp5 = d2 - d5; float tmp3 = d3 + d4; float tmp4 = d3 - d4; // Even part float tmp10 = tmp0 + tmp3; // phase 2 float tmp13 = tmp0 - tmp3; float tmp11 = tmp1 + tmp2; float tmp12 = tmp1 - tmp2; d0 = tmp10 + tmp11; // phase 3 d4 = tmp10 - tmp11; z1 = (tmp12 + tmp13) * 0.707106781f; // c4 d2 = tmp13 + z1; // phase 5 d6 = tmp13 - z1; // Odd part tmp10 = tmp4 + tmp5; // phase 2 tmp11 = tmp5 + tmp6; tmp12 = tmp6 + tmp7; // The rotator is modified from fig 4-8 to avoid extra negations. z5 = (tmp10 - tmp12) * 0.382683433f; // c6 z2 = tmp10 * 0.541196100f + z5; // c2-c6 z4 = tmp12 * 1.306562965f + z5; // c2+c6 z3 = tmp11 * 0.707106781f; // c4 z11 = tmp7 + z3; // phase 5 z13 = tmp7 - z3; *d5p = z13 + z2; // phase 6 *d3p = z13 - z2; *d1p = z11 + z4; *d7p = z11 - z4; *d0p = d0; *d2p = d2; *d4p = d4; *d6p = d6; } static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) { int tmp1 = val < 0 ? -val : val; val = val < 0 ? val-1 : val; bits[1] = 1; while(tmp1 >>= 1) { ++bits[1]; } bits[0] = val & ((1<0)&&(DU[end0pos]==0); --end0pos) { } // end0pos = first element in reverse order !=0 if(end0pos == 0) { stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); return DU[0]; } for(i = 1; i <= end0pos; ++i) { int startpos = i; int nrzeroes; unsigned short bits[2]; for (; DU[i]==0 && i<=end0pos; ++i) { } nrzeroes = i-startpos; if ( nrzeroes >= 16 ) { int lng = nrzeroes>>4; int nrmarker; for (nrmarker=1; nrmarker <= lng; ++nrmarker) stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes); nrzeroes &= 15; } stbiw__jpg_calcBits(DU[i], bits); stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]); stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); } if(end0pos != 63) { stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); } return DU[0]; } static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, const void* data, int quality) { // Constants that don't pollute global namespace static const unsigned char std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0}; static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d}; static const unsigned char std_ac_luminance_values[] = { 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08, 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28, 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59, 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89, 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6, 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2, 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa }; static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0}; static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77}; static const unsigned char std_ac_chrominance_values[] = { 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91, 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26, 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58, 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87, 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4, 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda, 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa }; // Huffman tables static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}}; static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}}; static const unsigned short YAC_HT[256][2] = { {10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0}, {2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} }; static const unsigned short UVAC_HT[256][2] = { {0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0}, {1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} }; static const int YQT[] = {16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22, 37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99}; static const int UVQT[] = {17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99}; static const float aasf[] = { 1.0f * 2.828427125f, 1.387039845f * 2.828427125f, 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f, 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f }; int row, col, i, k; float fdtbl_Y[64], fdtbl_UV[64]; unsigned char YTable[64], UVTable[64]; if(!data || !width || !height || comp > 4 || comp < 1) { return 0; } quality = quality ? quality : 90; quality = quality < 1 ? 1 : quality > 100 ? 100 : quality; quality = quality < 50 ? 5000 / quality : 200 - quality * 2; for(i = 0; i < 64; ++i) { int uvti, yti = (YQT[i]*quality+50)/100; YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti); uvti = (UVQT[i]*quality+50)/100; UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti); } for(row = 0, k = 0; row < 8; ++row) { for(col = 0; col < 8; ++col, ++k) { fdtbl_Y[k] = 1 / (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); } } // Write Headers { static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 }; static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 }; const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width), 3,1,0x11,0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 }; s->func(s->context, (void*)head0, sizeof(head0)); s->func(s->context, (void*)YTable, sizeof(YTable)); stbiw__putc(s, 1); s->func(s->context, UVTable, sizeof(UVTable)); s->func(s->context, (void*)head1, sizeof(head1)); s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1); s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values)); stbiw__putc(s, 0x10); // HTYACinfo s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1); s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values)); stbiw__putc(s, 1); // HTUDCinfo s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1); s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values)); stbiw__putc(s, 0x11); // HTUACinfo s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1); s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values)); s->func(s->context, (void*)head2, sizeof(head2)); } // Encode 8x8 macroblocks { static const unsigned short fillBits[] = {0x7F, 7}; const unsigned char *imageData = (const unsigned char *)data; int DCY=0, DCU=0, DCV=0; int bitBuf=0, bitCnt=0; // comp == 2 is grey+alpha (alpha is ignored) int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0; int x, y, pos; for(y = 0; y < height; y += 8) { for(x = 0; x < width; x += 8) { float YDU[64], UDU[64], VDU[64]; for(row = y, pos = 0; row < y+8; ++row) { // row >= height => use last input row int clamped_row = (row < height) ? row : height - 1; int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; for(col = x; col < x+8; ++col, ++pos) { float r, g, b; // if col >= width => use pixel from last input column int p = base_p + ((col < width) ? col : (width-1))*comp; r = imageData[p+0]; g = imageData[p+ofsG]; b = imageData[p+ofsB]; YDU[pos]=+0.29900f*r+0.58700f*g+0.11400f*b-128; UDU[pos]=-0.16874f*r-0.33126f*g+0.50000f*b; VDU[pos]=+0.50000f*r-0.41869f*g-0.08131f*b; } } DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT); DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); } } // Do the bit alignment of the EOI marker stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits); } // EOI stbiw__putc(s, 0xFF); stbiw__putc(s, 0xD9); return 1; } STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_jpg_core(&s, x, y, comp, data, quality); stbi__end_write_file(&s); return r; } else return 0; } #endif #endif // STB_IMAGE_WRITE_IMPLEMENTATION /* Revision history 1.10 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs 1.09 (2018-02-11) fix typo in zlib quality API, improve STB_I_W_STATIC in C++ 1.08 (2018-01-29) add stbi__flip_vertically_on_write, external zlib, zlib quality, choose PNG filter 1.07 (2017-07-24) doc fix 1.06 (2017-07-23) writing JPEG (using Jon Olick's code) 1.05 ??? 1.04 (2017-03-03) monochrome BMP expansion 1.03 ??? 1.02 (2016-04-02) avoid allocating large structures on the stack 1.01 (2016-01-16) STBIW_REALLOC_SIZED: support allocators with no realloc support avoid race-condition in crc initialization minor compile issues 1.00 (2015-09-14) installable file IO function 0.99 (2015-09-13) warning fixes; TGA rle support 0.98 (2015-04-08) added STBIW_MALLOC, STBIW_ASSERT etc 0.97 (2015-01-18) fixed HDR asserts, rewrote HDR rle logic 0.96 (2015-01-17) add HDR output fix monochrome BMP 0.95 (2014-08-17) add monochrome TGA output 0.94 (2014-05-31) rename private functions to avoid conflicts with stb_image.h 0.93 (2014-05-27) warning fixes 0.92 (2010-08-01) casts to unsigned char to fix warnings 0.91 (2010-07-17) first public release 0.90 first internal release */ /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ goxel-0.11.0/ext_src/stb/stb_rect_pack.h000066400000000000000000000470561435762723100201500ustar00rootroot00000000000000// stb_rect_pack.h - v0.11 - public domain - rectangle packing // Sean Barrett 2014 // // Useful for e.g. packing rectangular textures into an atlas. // Does not do rotation. // // Not necessarily the awesomest packing method, but better than // the totally naive one in stb_truetype (which is primarily what // this is meant to replace). // // Has only had a few tests run, may have issues. // // More docs to come. // // No memory allocations; uses qsort() and assert() from stdlib. // Can override those by defining STBRP_SORT and STBRP_ASSERT. // // This library currently uses the Skyline Bottom-Left algorithm. // // Please note: better rectangle packers are welcome! Please // implement them to the same API, but with a different init // function. // // Credits // // Library // Sean Barrett // Minor features // Martins Mozeiko // github:IntellectualKitty // // Bugfixes / warning fixes // Jeremy Jaussaud // // Version history: // // 0.11 (2017-03-03) return packing success/fail result // 0.10 (2016-10-25) remove cast-away-const to avoid warnings // 0.09 (2016-08-27) fix compiler warnings // 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0) // 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0) // 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort // 0.05: added STBRP_ASSERT to allow replacing assert // 0.04: fixed minor bug in STBRP_LARGE_RECTS support // 0.01: initial release // // LICENSE // // See end of file for license information. ////////////////////////////////////////////////////////////////////////////// // // INCLUDE SECTION // #ifndef STB_INCLUDE_STB_RECT_PACK_H #define STB_INCLUDE_STB_RECT_PACK_H #define STB_RECT_PACK_VERSION 1 #ifdef STBRP_STATIC #define STBRP_DEF static #else #define STBRP_DEF extern #endif #ifdef __cplusplus extern "C" { #endif typedef struct stbrp_context stbrp_context; typedef struct stbrp_node stbrp_node; typedef struct stbrp_rect stbrp_rect; #ifdef STBRP_LARGE_RECTS typedef int stbrp_coord; #else typedef unsigned short stbrp_coord; #endif STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); // Assign packed locations to rectangles. The rectangles are of type // 'stbrp_rect' defined below, stored in the array 'rects', and there // are 'num_rects' many of them. // // Rectangles which are successfully packed have the 'was_packed' flag // set to a non-zero value and 'x' and 'y' store the minimum location // on each axis (i.e. bottom-left in cartesian coordinates, top-left // if you imagine y increasing downwards). Rectangles which do not fit // have the 'was_packed' flag set to 0. // // You should not try to access the 'rects' array from another thread // while this function is running, as the function temporarily reorders // the array while it executes. // // To pack into another rectangle, you need to call stbrp_init_target // again. To continue packing into the same rectangle, you can call // this function again. Calling this multiple times with multiple rect // arrays will probably produce worse packing results than calling it // a single time with the full rectangle array, but the option is // available. // // The function returns 1 if all of the rectangles were successfully // packed and 0 otherwise. struct stbrp_rect { // reserved for your use: int id; // input: stbrp_coord w, h; // output: stbrp_coord x, y; int was_packed; // non-zero if valid packing }; // 16 bytes, nominally STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); // Initialize a rectangle packer to: // pack a rectangle that is 'width' by 'height' in dimensions // using temporary storage provided by the array 'nodes', which is 'num_nodes' long // // You must call this function every time you start packing into a new target. // // There is no "shutdown" function. The 'nodes' memory must stay valid for // the following stbrp_pack_rects() call (or calls), but can be freed after // the call (or calls) finish. // // Note: to guarantee best results, either: // 1. make sure 'num_nodes' >= 'width' // or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1' // // If you don't do either of the above things, widths will be quantized to multiples // of small integers to guarantee the algorithm doesn't run out of temporary storage. // // If you do #2, then the non-quantized algorithm will be used, but the algorithm // may run out of temporary storage and be unable to pack some rectangles. STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); // Optionally call this function after init but before doing any packing to // change the handling of the out-of-temp-memory scenario, described above. // If you call init again, this will be reset to the default (false). STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); // Optionally select which packing heuristic the library should use. Different // heuristics will produce better/worse results for different data sets. // If you call init again, this will be reset to the default. enum { STBRP_HEURISTIC_Skyline_default=0, STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, STBRP_HEURISTIC_Skyline_BF_sortHeight }; ////////////////////////////////////////////////////////////////////////////// // // the details of the following structures don't matter to you, but they must // be visible so you can handle the memory allocations for them struct stbrp_node { stbrp_coord x,y; stbrp_node *next; }; struct stbrp_context { int width; int height; int align; int init_mode; int heuristic; int num_nodes; stbrp_node *active_head; stbrp_node *free_head; stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' }; #ifdef __cplusplus } #endif #endif ////////////////////////////////////////////////////////////////////////////// // // IMPLEMENTATION SECTION // #ifdef STB_RECT_PACK_IMPLEMENTATION #ifndef STBRP_SORT #include #define STBRP_SORT qsort #endif #ifndef STBRP_ASSERT #include #define STBRP_ASSERT assert #endif #ifdef _MSC_VER #define STBRP__NOTUSED(v) (void)(v) #define STBRP__CDECL __cdecl #else #define STBRP__NOTUSED(v) (void)sizeof(v) #define STBRP__CDECL #endif enum { STBRP__INIT_skyline = 1 }; STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) { switch (context->init_mode) { case STBRP__INIT_skyline: STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); context->heuristic = heuristic; break; default: STBRP_ASSERT(0); } } STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) { if (allow_out_of_mem) // if it's ok to run out of memory, then don't bother aligning them; // this gives better packing, but may fail due to OOM (even though // the rectangles easily fit). @TODO a smarter approach would be to only // quantize once we've hit OOM, then we could get rid of this parameter. context->align = 1; else { // if it's not ok to run out of memory, then quantize the widths // so that num_nodes is always enough nodes. // // I.e. num_nodes * align >= width // align >= width / num_nodes // align = ceil(width/num_nodes) context->align = (context->width + context->num_nodes-1) / context->num_nodes; } } STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) { int i; #ifndef STBRP_LARGE_RECTS STBRP_ASSERT(width <= 0xffff && height <= 0xffff); #endif for (i=0; i < num_nodes-1; ++i) nodes[i].next = &nodes[i+1]; nodes[i].next = NULL; context->init_mode = STBRP__INIT_skyline; context->heuristic = STBRP_HEURISTIC_Skyline_default; context->free_head = &nodes[0]; context->active_head = &context->extra[0]; context->width = width; context->height = height; context->num_nodes = num_nodes; stbrp_setup_allow_out_of_mem(context, 0); // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) context->extra[0].x = 0; context->extra[0].y = 0; context->extra[0].next = &context->extra[1]; context->extra[1].x = (stbrp_coord) width; #ifdef STBRP_LARGE_RECTS context->extra[1].y = (1<<30); #else context->extra[1].y = 65535; #endif context->extra[1].next = NULL; } // find minimum y position if it starts at x1 static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) { stbrp_node *node = first; int x1 = x0 + width; int min_y, visited_width, waste_area; STBRP__NOTUSED(c); STBRP_ASSERT(first->x <= x0); #if 0 // skip in case we're past the node while (node->next->x <= x0) ++node; #else STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency #endif STBRP_ASSERT(node->x <= x0); min_y = 0; waste_area = 0; visited_width = 0; while (node->x < x1) { if (node->y > min_y) { // raise min_y higher. // we've accounted for all waste up to min_y, // but we'll now add more waste for everything we've visted waste_area += visited_width * (node->y - min_y); min_y = node->y; // the first time through, visited_width might be reduced if (node->x < x0) visited_width += node->next->x - x0; else visited_width += node->next->x - node->x; } else { // add waste area int under_width = node->next->x - node->x; if (under_width + visited_width > width) under_width = width - visited_width; waste_area += under_width * (min_y - node->y); visited_width += under_width; } node = node->next; } *pwaste = waste_area; return min_y; } typedef struct { int x,y; stbrp_node **prev_link; } stbrp__findresult; static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) { int best_waste = (1<<30), best_x, best_y = (1 << 30); stbrp__findresult fr; stbrp_node **prev, *node, *tail, **best = NULL; // align to multiple of c->align width = (width + c->align - 1); width -= width % c->align; STBRP_ASSERT(width % c->align == 0); node = c->active_head; prev = &c->active_head; while (node->x + width <= c->width) { int y,waste; y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL // bottom left if (y < best_y) { best_y = y; best = prev; } } else { // best-fit if (y + height <= c->height) { // can only use it if it first vertically if (y < best_y || (y == best_y && waste < best_waste)) { best_y = y; best_waste = waste; best = prev; } } } prev = &node->next; node = node->next; } best_x = (best == NULL) ? 0 : (*best)->x; // if doing best-fit (BF), we also have to try aligning right edge to each node position // // e.g, if fitting // // ____________________ // |____________________| // // into // // | | // | ____________| // |____________| // // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned // // This makes BF take about 2x the time if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { tail = c->active_head; node = c->active_head; prev = &c->active_head; // find first node that's admissible while (tail->x < width) tail = tail->next; while (tail) { int xpos = tail->x - width; int y,waste; STBRP_ASSERT(xpos >= 0); // find the left position that matches this while (node->next->x <= xpos) { prev = &node->next; node = node->next; } STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); if (y + height < c->height) { if (y <= best_y) { if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { best_x = xpos; STBRP_ASSERT(y <= best_y); best_y = y; best_waste = waste; best = prev; } } } tail = tail->next; } } fr.prev_link = best; fr.x = best_x; fr.y = best_y; return fr; } static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) { // find best position according to heuristic stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); stbrp_node *node, *cur; // bail if: // 1. it failed // 2. the best node doesn't fit (we don't always check this) // 3. we're out of memory if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { res.prev_link = NULL; return res; } // on success, create new node node = context->free_head; node->x = (stbrp_coord) res.x; node->y = (stbrp_coord) (res.y + height); context->free_head = node->next; // insert the new node into the right starting point, and // let 'cur' point to the remaining nodes needing to be // stiched back in cur = *res.prev_link; if (cur->x < res.x) { // preserve the existing one, so start testing with the next one stbrp_node *next = cur->next; cur->next = node; cur = next; } else { *res.prev_link = node; } // from here, traverse cur and free the nodes, until we get to one // that shouldn't be freed while (cur->next && cur->next->x <= res.x + width) { stbrp_node *next = cur->next; // move the current node to the free list cur->next = context->free_head; context->free_head = cur; cur = next; } // stitch the list back in node->next = cur; if (cur->x < res.x + width) cur->x = (stbrp_coord) (res.x + width); #ifdef _DEBUG cur = context->active_head; while (cur->x < context->width) { STBRP_ASSERT(cur->x < cur->next->x); cur = cur->next; } STBRP_ASSERT(cur->next == NULL); { int count=0; cur = context->active_head; while (cur) { cur = cur->next; ++count; } cur = context->free_head; while (cur) { cur = cur->next; ++count; } STBRP_ASSERT(count == context->num_nodes+2); } #endif return res; } static int STBRP__CDECL rect_height_compare(const void *a, const void *b) { const stbrp_rect *p = (const stbrp_rect *) a; const stbrp_rect *q = (const stbrp_rect *) b; if (p->h > q->h) return -1; if (p->h < q->h) return 1; return (p->w > q->w) ? -1 : (p->w < q->w); } static int STBRP__CDECL rect_original_order(const void *a, const void *b) { const stbrp_rect *p = (const stbrp_rect *) a; const stbrp_rect *q = (const stbrp_rect *) b; return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); } #ifdef STBRP_LARGE_RECTS #define STBRP__MAXVAL 0xffffffff #else #define STBRP__MAXVAL 0xffff #endif STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) { int i, all_rects_packed = 1; // we use the 'was_packed' field internally to allow sorting/unsorting for (i=0; i < num_rects; ++i) { rects[i].was_packed = i; #ifndef STBRP_LARGE_RECTS STBRP_ASSERT(rects[i].w <= 0xffff && rects[i].h <= 0xffff); #endif } // sort according to heuristic STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); for (i=0; i < num_rects; ++i) { if (rects[i].w == 0 || rects[i].h == 0) { rects[i].x = rects[i].y = 0; // empty rect needs no space } else { stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); if (fr.prev_link) { rects[i].x = (stbrp_coord) fr.x; rects[i].y = (stbrp_coord) fr.y; } else { rects[i].x = rects[i].y = STBRP__MAXVAL; } } } // unsort STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); // set was_packed flags and all_rects_packed status for (i=0; i < num_rects; ++i) { rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); if (!rects[i].was_packed) all_rects_packed = 0; } // return the all_rects_packed status return all_rects_packed; } #endif /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ goxel-0.11.0/ext_src/stb/stb_textedit.h000066400000000000000000001377061435762723100200510ustar00rootroot00000000000000// [ImGui] this is a slightly modified version of stb_truetype.h 1.9. Those changes would need to be pushed into nothings/sb // [ImGui] - fixed linestart handler when over last character of multi-line buffer + simplified existing code (#588, #815) // [ImGui] - fixed a state corruption/crash bug in stb_text_redo and stb_textedit_discard_redo (#715) // [ImGui] - fixed a crash bug in stb_textedit_discard_redo (#681) // [ImGui] - fixed some minor warnings // stb_textedit.h - v1.9 - public domain - Sean Barrett // Development of this library was sponsored by RAD Game Tools // // This C header file implements the guts of a multi-line text-editing // widget; you implement display, word-wrapping, and low-level string // insertion/deletion, and stb_textedit will map user inputs into // insertions & deletions, plus updates to the cursor position, // selection state, and undo state. // // It is intended for use in games and other systems that need to build // their own custom widgets and which do not have heavy text-editing // requirements (this library is not recommended for use for editing large // texts, as its performance does not scale and it has limited undo). // // Non-trivial behaviors are modelled after Windows text controls. // // // LICENSE // // This software is dual-licensed to the public domain and under the following // license: you are granted a perpetual, irrevocable license to copy, modify, // publish, and distribute this file as you see fit. // // // DEPENDENCIES // // Uses the C runtime function 'memmove', which you can override // by defining STB_TEXTEDIT_memmove before the implementation. // Uses no other functions. Performs no runtime allocations. // // // VERSION HISTORY // // 1.9 (2016-08-27) customizable move-by-word // 1.8 (2016-04-02) better keyboard handling when mouse button is down // 1.7 (2015-09-13) change y range handling in case baseline is non-0 // 1.6 (2015-04-15) allow STB_TEXTEDIT_memmove // 1.5 (2014-09-10) add support for secondary keys for OS X // 1.4 (2014-08-17) fix signed/unsigned warnings // 1.3 (2014-06-19) fix mouse clicking to round to nearest char boundary // 1.2 (2014-05-27) fix some RAD types that had crept into the new code // 1.1 (2013-12-15) move-by-word (requires STB_TEXTEDIT_IS_SPACE ) // 1.0 (2012-07-26) improve documentation, initial public release // 0.3 (2012-02-24) bugfixes, single-line mode; insert mode // 0.2 (2011-11-28) fixes to undo/redo // 0.1 (2010-07-08) initial version // // ADDITIONAL CONTRIBUTORS // // Ulf Winklemann: move-by-word in 1.1 // Fabian Giesen: secondary key inputs in 1.5 // Martins Mozeiko: STB_TEXTEDIT_memmove // // Bugfixes: // Scott Graham // Daniel Keller // Omar Cornut // // USAGE // // This file behaves differently depending on what symbols you define // before including it. // // // Header-file mode: // // If you do not define STB_TEXTEDIT_IMPLEMENTATION before including this, // it will operate in "header file" mode. In this mode, it declares a // single public symbol, STB_TexteditState, which encapsulates the current // state of a text widget (except for the string, which you will store // separately). // // To compile in this mode, you must define STB_TEXTEDIT_CHARTYPE to a // primitive type that defines a single character (e.g. char, wchar_t, etc). // // To save space or increase undo-ability, you can optionally define the // following things that are used by the undo system: // // STB_TEXTEDIT_POSITIONTYPE small int type encoding a valid cursor position // STB_TEXTEDIT_UNDOSTATECOUNT the number of undo states to allow // STB_TEXTEDIT_UNDOCHARCOUNT the number of characters to store in the undo buffer // // If you don't define these, they are set to permissive types and // moderate sizes. The undo system does no memory allocations, so // it grows STB_TexteditState by the worst-case storage which is (in bytes): // // [4 + sizeof(STB_TEXTEDIT_POSITIONTYPE)] * STB_TEXTEDIT_UNDOSTATE_COUNT // + sizeof(STB_TEXTEDIT_CHARTYPE) * STB_TEXTEDIT_UNDOCHAR_COUNT // // // Implementation mode: // // If you define STB_TEXTEDIT_IMPLEMENTATION before including this, it // will compile the implementation of the text edit widget, depending // on a large number of symbols which must be defined before the include. // // The implementation is defined only as static functions. You will then // need to provide your own APIs in the same file which will access the // static functions. // // The basic concept is that you provide a "string" object which // behaves like an array of characters. stb_textedit uses indices to // refer to positions in the string, implicitly representing positions // in the displayed textedit. This is true for both plain text and // rich text; even with rich text stb_truetype interacts with your // code as if there was an array of all the displayed characters. // // Symbols that must be the same in header-file and implementation mode: // // STB_TEXTEDIT_CHARTYPE the character type // STB_TEXTEDIT_POSITIONTYPE small type that a valid cursor position // STB_TEXTEDIT_UNDOSTATECOUNT the number of undo states to allow // STB_TEXTEDIT_UNDOCHARCOUNT the number of characters to store in the undo buffer // // Symbols you must define for implementation mode: // // STB_TEXTEDIT_STRING the type of object representing a string being edited, // typically this is a wrapper object with other data you need // // STB_TEXTEDIT_STRINGLEN(obj) the length of the string (ideally O(1)) // STB_TEXTEDIT_LAYOUTROW(&r,obj,n) returns the results of laying out a line of characters // starting from character #n (see discussion below) // STB_TEXTEDIT_GETWIDTH(obj,n,i) returns the pixel delta from the xpos of the i'th character // to the xpos of the i+1'th char for a line of characters // starting at character #n (i.e. accounts for kerning // with previous char) // STB_TEXTEDIT_KEYTOTEXT(k) maps a keyboard input to an insertable character // (return type is int, -1 means not valid to insert) // STB_TEXTEDIT_GETCHAR(obj,i) returns the i'th character of obj, 0-based // STB_TEXTEDIT_NEWLINE the character returned by _GETCHAR() we recognize // as manually wordwrapping for end-of-line positioning // // STB_TEXTEDIT_DELETECHARS(obj,i,n) delete n characters starting at i // STB_TEXTEDIT_INSERTCHARS(obj,i,c*,n) insert n characters at i (pointed to by STB_TEXTEDIT_CHARTYPE*) // // STB_TEXTEDIT_K_SHIFT a power of two that is or'd in to a keyboard input to represent the shift key // // STB_TEXTEDIT_K_LEFT keyboard input to move cursor left // STB_TEXTEDIT_K_RIGHT keyboard input to move cursor right // STB_TEXTEDIT_K_UP keyboard input to move cursor up // STB_TEXTEDIT_K_DOWN keyboard input to move cursor down // STB_TEXTEDIT_K_LINESTART keyboard input to move cursor to start of line // e.g. HOME // STB_TEXTEDIT_K_LINEEND keyboard input to move cursor to end of line // e.g. END // STB_TEXTEDIT_K_TEXTSTART keyboard input to move cursor to start of text // e.g. ctrl-HOME // STB_TEXTEDIT_K_TEXTEND keyboard input to move cursor to end of text // e.g. ctrl-END // STB_TEXTEDIT_K_DELETE keyboard input to delete selection or character under cursor // STB_TEXTEDIT_K_BACKSPACE keyboard input to delete selection or character left of cursor // STB_TEXTEDIT_K_UNDO keyboard input to perform undo // STB_TEXTEDIT_K_REDO keyboard input to perform redo // // Optional: // STB_TEXTEDIT_K_INSERT keyboard input to toggle insert mode // STB_TEXTEDIT_IS_SPACE(ch) true if character is whitespace (e.g. 'isspace'), // required for default WORDLEFT/WORDRIGHT handlers // STB_TEXTEDIT_MOVEWORDLEFT(obj,i) custom handler for WORDLEFT, returns index to move cursor to // STB_TEXTEDIT_MOVEWORDRIGHT(obj,i) custom handler for WORDRIGHT, returns index to move cursor to // STB_TEXTEDIT_K_WORDLEFT keyboard input to move cursor left one word // e.g. ctrl-LEFT // STB_TEXTEDIT_K_WORDRIGHT keyboard input to move cursor right one word // e.g. ctrl-RIGHT // STB_TEXTEDIT_K_LINESTART2 secondary keyboard input to move cursor to start of line // STB_TEXTEDIT_K_LINEEND2 secondary keyboard input to move cursor to end of line // STB_TEXTEDIT_K_TEXTSTART2 secondary keyboard input to move cursor to start of text // STB_TEXTEDIT_K_TEXTEND2 secondary keyboard input to move cursor to end of text // // Todo: // STB_TEXTEDIT_K_PGUP keyboard input to move cursor up a page // STB_TEXTEDIT_K_PGDOWN keyboard input to move cursor down a page // // Keyboard input must be encoded as a single integer value; e.g. a character code // and some bitflags that represent shift states. to simplify the interface, SHIFT must // be a bitflag, so we can test the shifted state of cursor movements to allow selection, // i.e. (STB_TEXTED_K_RIGHT|STB_TEXTEDIT_K_SHIFT) should be shifted right-arrow. // // You can encode other things, such as CONTROL or ALT, in additional bits, and // then test for their presence in e.g. STB_TEXTEDIT_K_WORDLEFT. For example, // my Windows implementations add an additional CONTROL bit, and an additional KEYDOWN // bit. Then all of the STB_TEXTEDIT_K_ values bitwise-or in the KEYDOWN bit, // and I pass both WM_KEYDOWN and WM_CHAR events to the "key" function in the // API below. The control keys will only match WM_KEYDOWN events because of the // keydown bit I add, and STB_TEXTEDIT_KEYTOTEXT only tests for the KEYDOWN // bit so it only decodes WM_CHAR events. // // STB_TEXTEDIT_LAYOUTROW returns information about the shape of one displayed // row of characters assuming they start on the i'th character--the width and // the height and the number of characters consumed. This allows this library // to traverse the entire layout incrementally. You need to compute word-wrapping // here. // // Each textfield keeps its own insert mode state, which is not how normal // applications work. To keep an app-wide insert mode, update/copy the // "insert_mode" field of STB_TexteditState before/after calling API functions. // // API // // void stb_textedit_initialize_state(STB_TexteditState *state, int is_single_line) // // void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) // void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) // int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) // int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE *text, int len) // void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int key) // // Each of these functions potentially updates the string and updates the // state. // // initialize_state: // set the textedit state to a known good default state when initially // constructing the textedit. // // click: // call this with the mouse x,y on a mouse down; it will update the cursor // and reset the selection start/end to the cursor point. the x,y must // be relative to the text widget, with (0,0) being the top left. // // drag: // call this with the mouse x,y on a mouse drag/up; it will update the // cursor and the selection end point // // cut: // call this to delete the current selection; returns true if there was // one. you should FIRST copy the current selection to the system paste buffer. // (To copy, just copy the current selection out of the string yourself.) // // paste: // call this to paste text at the current cursor point or over the current // selection if there is one. // // key: // call this for keyboard inputs sent to the textfield. you can use it // for "key down" events or for "translated" key events. if you need to // do both (as in Win32), or distinguish Unicode characters from control // inputs, set a high bit to distinguish the two; then you can define the // various definitions like STB_TEXTEDIT_K_LEFT have the is-key-event bit // set, and make STB_TEXTEDIT_KEYTOCHAR check that the is-key-event bit is // clear. // // When rendering, you can read the cursor position and selection state from // the STB_TexteditState. // // // Notes: // // This is designed to be usable in IMGUI, so it allows for the possibility of // running in an IMGUI that has NOT cached the multi-line layout. For this // reason, it provides an interface that is compatible with computing the // layout incrementally--we try to make sure we make as few passes through // as possible. (For example, to locate the mouse pointer in the text, we // could define functions that return the X and Y positions of characters // and binary search Y and then X, but if we're doing dynamic layout this // will run the layout algorithm many times, so instead we manually search // forward in one pass. Similar logic applies to e.g. up-arrow and // down-arrow movement.) // // If it's run in a widget that *has* cached the layout, then this is less // efficient, but it's not horrible on modern computers. But you wouldn't // want to edit million-line files with it. //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //// //// Header-file mode //// //// #ifndef INCLUDE_STB_TEXTEDIT_H #define INCLUDE_STB_TEXTEDIT_H //////////////////////////////////////////////////////////////////////// // // STB_TexteditState // // Definition of STB_TexteditState which you should store // per-textfield; it includes cursor position, selection state, // and undo state. // #ifndef STB_TEXTEDIT_UNDOSTATECOUNT #define STB_TEXTEDIT_UNDOSTATECOUNT 99 #endif #ifndef STB_TEXTEDIT_UNDOCHARCOUNT #define STB_TEXTEDIT_UNDOCHARCOUNT 999 #endif #ifndef STB_TEXTEDIT_CHARTYPE #define STB_TEXTEDIT_CHARTYPE int #endif #ifndef STB_TEXTEDIT_POSITIONTYPE #define STB_TEXTEDIT_POSITIONTYPE int #endif typedef struct { // private data STB_TEXTEDIT_POSITIONTYPE where; short insert_length; short delete_length; short char_storage; } StbUndoRecord; typedef struct { // private data StbUndoRecord undo_rec [STB_TEXTEDIT_UNDOSTATECOUNT]; STB_TEXTEDIT_CHARTYPE undo_char[STB_TEXTEDIT_UNDOCHARCOUNT]; short undo_point, redo_point; short undo_char_point, redo_char_point; } StbUndoState; typedef struct { ///////////////////// // // public data // int cursor; // position of the text cursor within the string int select_start; // selection start point int select_end; // selection start and end point in characters; if equal, no selection. // note that start may be less than or greater than end (e.g. when // dragging the mouse, start is where the initial click was, and you // can drag in either direction) unsigned char insert_mode; // each textfield keeps its own insert mode state. to keep an app-wide // insert mode, copy this value in/out of the app state ///////////////////// // // private data // unsigned char cursor_at_end_of_line; // not implemented yet unsigned char initialized; unsigned char has_preferred_x; unsigned char single_line; unsigned char padding1, padding2, padding3; float preferred_x; // this determines where the cursor up/down tries to seek to along x StbUndoState undostate; } STB_TexteditState; //////////////////////////////////////////////////////////////////////// // // StbTexteditRow // // Result of layout query, used by stb_textedit to determine where // the text in each row is. // result of layout query typedef struct { float x0,x1; // starting x location, end x location (allows for align=right, etc) float baseline_y_delta; // position of baseline relative to previous row's baseline float ymin,ymax; // height of row above and below baseline int num_chars; } StbTexteditRow; #endif //INCLUDE_STB_TEXTEDIT_H //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //// //// Implementation mode //// //// // implementation isn't include-guarded, since it might have indirectly // included just the "header" portion #ifdef STB_TEXTEDIT_IMPLEMENTATION #ifndef STB_TEXTEDIT_memmove #include #define STB_TEXTEDIT_memmove memmove #endif ///////////////////////////////////////////////////////////////////////////// // // Mouse input handling // // traverse the layout to locate the nearest character to a display position static int stb_text_locate_coord(STB_TEXTEDIT_STRING *str, float x, float y) { StbTexteditRow r; int n = STB_TEXTEDIT_STRINGLEN(str); float base_y = 0, prev_x; int i=0, k; r.x0 = r.x1 = 0; r.ymin = r.ymax = 0; r.num_chars = 0; // search rows to find one that straddles 'y' while (i < n) { STB_TEXTEDIT_LAYOUTROW(&r, str, i); if (r.num_chars <= 0) return n; if (i==0 && y < base_y + r.ymin) return 0; if (y < base_y + r.ymax) break; i += r.num_chars; base_y += r.baseline_y_delta; } // below all text, return 'after' last character if (i >= n) return n; // check if it's before the beginning of the line if (x < r.x0) return i; // check if it's before the end of the line if (x < r.x1) { // search characters in row for one that straddles 'x' prev_x = r.x0; for (k=0; k < r.num_chars; ++k) { float w = STB_TEXTEDIT_GETWIDTH(str, i, k); if (x < prev_x+w) { if (x < prev_x+w/2) return k+i; else return k+i+1; } prev_x += w; } // shouldn't happen, but if it does, fall through to end-of-line case } // if the last character is a newline, return that. otherwise return 'after' the last character if (STB_TEXTEDIT_GETCHAR(str, i+r.num_chars-1) == STB_TEXTEDIT_NEWLINE) return i+r.num_chars-1; else return i+r.num_chars; } // API click: on mouse down, move the cursor to the clicked location, and reset the selection static void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) { state->cursor = stb_text_locate_coord(str, x, y); state->select_start = state->cursor; state->select_end = state->cursor; state->has_preferred_x = 0; } // API drag: on mouse drag, move the cursor and selection endpoint to the clicked location static void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) { int p = stb_text_locate_coord(str, x, y); if (state->select_start == state->select_end) state->select_start = state->cursor; state->cursor = state->select_end = p; } ///////////////////////////////////////////////////////////////////////////// // // Keyboard input handling // // forward declarations static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state); static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state); static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length); static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length); static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length); typedef struct { float x,y; // position of n'th character float height; // height of line int first_char, length; // first char of row, and length int prev_first; // first char of previous row } StbFindState; // find the x/y location of a character, and remember info about the previous row in // case we get a move-up event (for page up, we'll have to rescan) static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *str, int n, int single_line) { StbTexteditRow r; int prev_start = 0; int z = STB_TEXTEDIT_STRINGLEN(str); int i=0, first; if (n == z) { // if it's at the end, then find the last line -- simpler than trying to // explicitly handle this case in the regular code if (single_line) { STB_TEXTEDIT_LAYOUTROW(&r, str, 0); find->y = 0; find->first_char = 0; find->length = z; find->height = r.ymax - r.ymin; find->x = r.x1; } else { find->y = 0; find->x = 0; find->height = 1; while (i < z) { STB_TEXTEDIT_LAYOUTROW(&r, str, i); prev_start = i; i += r.num_chars; } find->first_char = i; find->length = 0; find->prev_first = prev_start; } return; } // search rows to find the one that straddles character n find->y = 0; for(;;) { STB_TEXTEDIT_LAYOUTROW(&r, str, i); if (n < i + r.num_chars) break; prev_start = i; i += r.num_chars; find->y += r.baseline_y_delta; } find->first_char = first = i; find->length = r.num_chars; find->height = r.ymax - r.ymin; find->prev_first = prev_start; // now scan to find xpos find->x = r.x0; i = 0; for (i=0; first+i < n; ++i) find->x += STB_TEXTEDIT_GETWIDTH(str, first, i); } #define STB_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end) // make the selection/cursor state valid if client altered the string static void stb_textedit_clamp(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { int n = STB_TEXTEDIT_STRINGLEN(str); if (STB_TEXT_HAS_SELECTION(state)) { if (state->select_start > n) state->select_start = n; if (state->select_end > n) state->select_end = n; // if clamping forced them to be equal, move the cursor to match if (state->select_start == state->select_end) state->cursor = state->select_start; } if (state->cursor > n) state->cursor = n; } // delete characters while updating undo static void stb_textedit_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int len) { stb_text_makeundo_delete(str, state, where, len); STB_TEXTEDIT_DELETECHARS(str, where, len); state->has_preferred_x = 0; } // delete the section static void stb_textedit_delete_selection(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { stb_textedit_clamp(str, state); if (STB_TEXT_HAS_SELECTION(state)) { if (state->select_start < state->select_end) { stb_textedit_delete(str, state, state->select_start, state->select_end - state->select_start); state->select_end = state->cursor = state->select_start; } else { stb_textedit_delete(str, state, state->select_end, state->select_start - state->select_end); state->select_start = state->cursor = state->select_end; } state->has_preferred_x = 0; } } // canoncialize the selection so start <= end static void stb_textedit_sortselection(STB_TexteditState *state) { if (state->select_end < state->select_start) { int temp = state->select_end; state->select_end = state->select_start; state->select_start = temp; } } // move cursor to first character of selection static void stb_textedit_move_to_first(STB_TexteditState *state) { if (STB_TEXT_HAS_SELECTION(state)) { stb_textedit_sortselection(state); state->cursor = state->select_start; state->select_end = state->select_start; state->has_preferred_x = 0; } } // move cursor to last character of selection static void stb_textedit_move_to_last(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { if (STB_TEXT_HAS_SELECTION(state)) { stb_textedit_sortselection(state); stb_textedit_clamp(str, state); state->cursor = state->select_end; state->select_start = state->select_end; state->has_preferred_x = 0; } } #ifdef STB_TEXTEDIT_IS_SPACE static int is_word_boundary( STB_TEXTEDIT_STRING *str, int idx ) { return idx > 0 ? (STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str,idx-1) ) && !STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str, idx) ) ) : 1; } #ifndef STB_TEXTEDIT_MOVEWORDLEFT static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *str, int c ) { --c; // always move at least one character while( c >= 0 && !is_word_boundary( str, c ) ) --c; if( c < 0 ) c = 0; return c; } #define STB_TEXTEDIT_MOVEWORDLEFT stb_textedit_move_to_word_previous #endif #ifndef STB_TEXTEDIT_MOVEWORDRIGHT static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *str, int c ) { const int len = STB_TEXTEDIT_STRINGLEN(str); ++c; // always move at least one character while( c < len && !is_word_boundary( str, c ) ) ++c; if( c > len ) c = len; return c; } #define STB_TEXTEDIT_MOVEWORDRIGHT stb_textedit_move_to_word_next #endif #endif // update selection and cursor to match each other static void stb_textedit_prep_selection_at_cursor(STB_TexteditState *state) { if (!STB_TEXT_HAS_SELECTION(state)) state->select_start = state->select_end = state->cursor; else state->cursor = state->select_end; } // API cut: delete selection static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { if (STB_TEXT_HAS_SELECTION(state)) { stb_textedit_delete_selection(str,state); // implicity clamps state->has_preferred_x = 0; return 1; } return 0; } // API paste: replace existing selection with passed-in text static int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE const *text, int len) { // if there's a selection, the paste should delete it stb_textedit_clamp(str, state); stb_textedit_delete_selection(str,state); // try to insert the characters if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, len)) { stb_text_makeundo_insert(state, state->cursor, len); state->cursor += len; state->has_preferred_x = 0; return 1; } // remove the undo since we didn't actually insert the characters if (state->undostate.undo_point) --state->undostate.undo_point; return 0; } // API key: process a keyboard input static void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int key) { retry: switch (key) { default: { int c = STB_TEXTEDIT_KEYTOTEXT(key); if (c > 0) { STB_TEXTEDIT_CHARTYPE ch = (STB_TEXTEDIT_CHARTYPE) c; // can't add newline in single-line mode if (c == '\n' && state->single_line) break; if (state->insert_mode && !STB_TEXT_HAS_SELECTION(state) && state->cursor < STB_TEXTEDIT_STRINGLEN(str)) { stb_text_makeundo_replace(str, state, state->cursor, 1, 1); STB_TEXTEDIT_DELETECHARS(str, state->cursor, 1); if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { ++state->cursor; state->has_preferred_x = 0; } } else { stb_textedit_delete_selection(str,state); // implicity clamps if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { stb_text_makeundo_insert(state, state->cursor, 1); ++state->cursor; state->has_preferred_x = 0; } } } break; } #ifdef STB_TEXTEDIT_K_INSERT case STB_TEXTEDIT_K_INSERT: state->insert_mode = !state->insert_mode; break; #endif case STB_TEXTEDIT_K_UNDO: stb_text_undo(str, state); state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_REDO: stb_text_redo(str, state); state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_LEFT: // if currently there's a selection, move cursor to start of selection if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_first(state); else if (state->cursor > 0) --state->cursor; state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_RIGHT: // if currently there's a selection, move cursor to end of selection if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_last(str, state); else ++state->cursor; stb_textedit_clamp(str, state); state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_SHIFT: stb_textedit_clamp(str, state); stb_textedit_prep_selection_at_cursor(state); // move selection left if (state->select_end > 0) --state->select_end; state->cursor = state->select_end; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_MOVEWORDLEFT case STB_TEXTEDIT_K_WORDLEFT: if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_first(state); else { state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); stb_textedit_clamp( str, state ); } break; case STB_TEXTEDIT_K_WORDLEFT | STB_TEXTEDIT_K_SHIFT: if( !STB_TEXT_HAS_SELECTION( state ) ) stb_textedit_prep_selection_at_cursor(state); state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); state->select_end = state->cursor; stb_textedit_clamp( str, state ); break; #endif #ifdef STB_TEXTEDIT_MOVEWORDRIGHT case STB_TEXTEDIT_K_WORDRIGHT: if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_last(str, state); else { state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); stb_textedit_clamp( str, state ); } break; case STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT: if( !STB_TEXT_HAS_SELECTION( state ) ) stb_textedit_prep_selection_at_cursor(state); state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); state->select_end = state->cursor; stb_textedit_clamp( str, state ); break; #endif case STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_SHIFT: stb_textedit_prep_selection_at_cursor(state); // move selection right ++state->select_end; stb_textedit_clamp(str, state); state->cursor = state->select_end; state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_DOWN: case STB_TEXTEDIT_K_DOWN | STB_TEXTEDIT_K_SHIFT: { StbFindState find; StbTexteditRow row; int i, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; if (state->single_line) { // on windows, up&down in single-line behave like left&right key = STB_TEXTEDIT_K_RIGHT | (key & STB_TEXTEDIT_K_SHIFT); goto retry; } if (sel) stb_textedit_prep_selection_at_cursor(state); else if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_last(str,state); // compute current position of cursor point stb_textedit_clamp(str, state); stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); // now find character position down a row if (find.length) { float goal_x = state->has_preferred_x ? state->preferred_x : find.x; float x; int start = find.first_char + find.length; state->cursor = start; STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); x = row.x0; for (i=0; i < row.num_chars; ++i) { float dx = STB_TEXTEDIT_GETWIDTH(str, start, i); #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) break; #endif x += dx; if (x > goal_x) break; ++state->cursor; } stb_textedit_clamp(str, state); state->has_preferred_x = 1; state->preferred_x = goal_x; if (sel) state->select_end = state->cursor; } break; } case STB_TEXTEDIT_K_UP: case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT: { StbFindState find; StbTexteditRow row; int i, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; if (state->single_line) { // on windows, up&down become left&right key = STB_TEXTEDIT_K_LEFT | (key & STB_TEXTEDIT_K_SHIFT); goto retry; } if (sel) stb_textedit_prep_selection_at_cursor(state); else if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_move_to_first(state); // compute current position of cursor point stb_textedit_clamp(str, state); stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); // can only go up if there's a previous row if (find.prev_first != find.first_char) { // now find character position up a row float goal_x = state->has_preferred_x ? state->preferred_x : find.x; float x; state->cursor = find.prev_first; STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); x = row.x0; for (i=0; i < row.num_chars; ++i) { float dx = STB_TEXTEDIT_GETWIDTH(str, find.prev_first, i); #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) break; #endif x += dx; if (x > goal_x) break; ++state->cursor; } stb_textedit_clamp(str, state); state->has_preferred_x = 1; state->preferred_x = goal_x; if (sel) state->select_end = state->cursor; } break; } case STB_TEXTEDIT_K_DELETE: case STB_TEXTEDIT_K_DELETE | STB_TEXTEDIT_K_SHIFT: if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_delete_selection(str, state); else { int n = STB_TEXTEDIT_STRINGLEN(str); if (state->cursor < n) stb_textedit_delete(str, state, state->cursor, 1); } state->has_preferred_x = 0; break; case STB_TEXTEDIT_K_BACKSPACE: case STB_TEXTEDIT_K_BACKSPACE | STB_TEXTEDIT_K_SHIFT: if (STB_TEXT_HAS_SELECTION(state)) stb_textedit_delete_selection(str, state); else { stb_textedit_clamp(str, state); if (state->cursor > 0) { stb_textedit_delete(str, state, state->cursor-1, 1); --state->cursor; } } state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_TEXTSTART2 case STB_TEXTEDIT_K_TEXTSTART2: #endif case STB_TEXTEDIT_K_TEXTSTART: state->cursor = state->select_start = state->select_end = 0; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_TEXTEND2 case STB_TEXTEDIT_K_TEXTEND2: #endif case STB_TEXTEDIT_K_TEXTEND: state->cursor = STB_TEXTEDIT_STRINGLEN(str); state->select_start = state->select_end = 0; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_TEXTSTART2 case STB_TEXTEDIT_K_TEXTSTART2 | STB_TEXTEDIT_K_SHIFT: #endif case STB_TEXTEDIT_K_TEXTSTART | STB_TEXTEDIT_K_SHIFT: stb_textedit_prep_selection_at_cursor(state); state->cursor = state->select_end = 0; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_TEXTEND2 case STB_TEXTEDIT_K_TEXTEND2 | STB_TEXTEDIT_K_SHIFT: #endif case STB_TEXTEDIT_K_TEXTEND | STB_TEXTEDIT_K_SHIFT: stb_textedit_prep_selection_at_cursor(state); state->cursor = state->select_end = STB_TEXTEDIT_STRINGLEN(str); state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_LINESTART2 case STB_TEXTEDIT_K_LINESTART2: #endif case STB_TEXTEDIT_K_LINESTART: stb_textedit_clamp(str, state); stb_textedit_move_to_first(state); if (state->single_line) state->cursor = 0; else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) --state->cursor; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_LINEEND2 case STB_TEXTEDIT_K_LINEEND2: #endif case STB_TEXTEDIT_K_LINEEND: { int n = STB_TEXTEDIT_STRINGLEN(str); stb_textedit_clamp(str, state); stb_textedit_move_to_first(state); if (state->single_line) state->cursor = n; else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) ++state->cursor; state->has_preferred_x = 0; break; } #ifdef STB_TEXTEDIT_K_LINESTART2 case STB_TEXTEDIT_K_LINESTART2 | STB_TEXTEDIT_K_SHIFT: #endif case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT: stb_textedit_clamp(str, state); stb_textedit_prep_selection_at_cursor(state); if (state->single_line) state->cursor = 0; else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) --state->cursor; state->select_end = state->cursor; state->has_preferred_x = 0; break; #ifdef STB_TEXTEDIT_K_LINEEND2 case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT: #endif case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: { int n = STB_TEXTEDIT_STRINGLEN(str); stb_textedit_clamp(str, state); stb_textedit_prep_selection_at_cursor(state); if (state->single_line) state->cursor = n; else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) ++state->cursor; state->select_end = state->cursor; state->has_preferred_x = 0; break; } // @TODO: // STB_TEXTEDIT_K_PGUP - move cursor up a page // STB_TEXTEDIT_K_PGDOWN - move cursor down a page } } ///////////////////////////////////////////////////////////////////////////// // // Undo processing // // @OPTIMIZE: the undo/redo buffer should be circular static void stb_textedit_flush_redo(StbUndoState *state) { state->redo_point = STB_TEXTEDIT_UNDOSTATECOUNT; state->redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT; } // discard the oldest entry in the undo list static void stb_textedit_discard_undo(StbUndoState *state) { if (state->undo_point > 0) { // if the 0th undo state has characters, clean those up if (state->undo_rec[0].char_storage >= 0) { int n = state->undo_rec[0].insert_length, i; // delete n characters from all other records state->undo_char_point = state->undo_char_point - (short) n; // vsnet05 STB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) ((size_t)state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE))); for (i=0; i < state->undo_point; ++i) if (state->undo_rec[i].char_storage >= 0) state->undo_rec[i].char_storage = state->undo_rec[i].char_storage - (short) n; // vsnet05 // @OPTIMIZE: get rid of char_storage and infer it } --state->undo_point; STB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) ((size_t)state->undo_point*sizeof(state->undo_rec[0]))); } } // discard the oldest entry in the redo list--it's bad if this // ever happens, but because undo & redo have to store the actual // characters in different cases, the redo character buffer can // fill up even though the undo buffer didn't static void stb_textedit_discard_redo(StbUndoState *state) { int k = STB_TEXTEDIT_UNDOSTATECOUNT-1; if (state->redo_point <= k) { // if the k'th undo state has characters, clean those up if (state->undo_rec[k].char_storage >= 0) { int n = state->undo_rec[k].insert_length, i; // delete n characters from all other records state->redo_char_point = state->redo_char_point + (short) n; // vsnet05 STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((size_t)(STB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE))); for (i=state->redo_point; i < k; ++i) if (state->undo_rec[i].char_storage >= 0) state->undo_rec[i].char_storage = state->undo_rec[i].char_storage + (short) n; // vsnet05 } STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point, state->undo_rec + state->redo_point-1, (size_t) ((size_t)(STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0]))); ++state->redo_point; } } static StbUndoRecord *stb_text_create_undo_record(StbUndoState *state, int numchars) { // any time we create a new undo record, we discard redo stb_textedit_flush_redo(state); // if we have no free records, we have to make room, by sliding the // existing records down if (state->undo_point == STB_TEXTEDIT_UNDOSTATECOUNT) stb_textedit_discard_undo(state); // if the characters to store won't possibly fit in the buffer, we can't undo if (numchars > STB_TEXTEDIT_UNDOCHARCOUNT) { state->undo_point = 0; state->undo_char_point = 0; return NULL; } // if we don't have enough free characters in the buffer, we have to make room while (state->undo_char_point + numchars > STB_TEXTEDIT_UNDOCHARCOUNT) stb_textedit_discard_undo(state); return &state->undo_rec[state->undo_point++]; } static STB_TEXTEDIT_CHARTYPE *stb_text_createundo(StbUndoState *state, int pos, int insert_len, int delete_len) { StbUndoRecord *r = stb_text_create_undo_record(state, insert_len); if (r == NULL) return NULL; r->where = pos; r->insert_length = (short) insert_len; r->delete_length = (short) delete_len; if (insert_len == 0) { r->char_storage = -1; return NULL; } else { r->char_storage = state->undo_char_point; state->undo_char_point = state->undo_char_point + (short) insert_len; return &state->undo_char[r->char_storage]; } } static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { StbUndoState *s = &state->undostate; StbUndoRecord u, *r; if (s->undo_point == 0) return; // we need to do two things: apply the undo record, and create a redo record u = s->undo_rec[s->undo_point-1]; r = &s->undo_rec[s->redo_point-1]; r->char_storage = -1; r->insert_length = u.delete_length; r->delete_length = u.insert_length; r->where = u.where; if (u.delete_length) { // if the undo record says to delete characters, then the redo record will // need to re-insert the characters that get deleted, so we need to store // them. // there are three cases: // there's enough room to store the characters // characters stored for *redoing* don't leave room for redo // characters stored for *undoing* don't leave room for redo // if the last is true, we have to bail if (s->undo_char_point + u.delete_length >= STB_TEXTEDIT_UNDOCHARCOUNT) { // the undo records take up too much character space; there's no space to store the redo characters r->insert_length = 0; } else { int i; // there's definitely room to store the characters eventually while (s->undo_char_point + u.delete_length > s->redo_char_point) { // there's currently not enough room, so discard a redo record stb_textedit_discard_redo(s); // should never happen: if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) return; } r = &s->undo_rec[s->redo_point-1]; r->char_storage = s->redo_char_point - u.delete_length; s->redo_char_point = s->redo_char_point - (short) u.delete_length; // now save the characters for (i=0; i < u.delete_length; ++i) s->undo_char[r->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u.where + i); } // now we can carry out the deletion STB_TEXTEDIT_DELETECHARS(str, u.where, u.delete_length); } // check type of recorded action: if (u.insert_length) { // easy case: was a deletion, so we need to insert n characters STB_TEXTEDIT_INSERTCHARS(str, u.where, &s->undo_char[u.char_storage], u.insert_length); s->undo_char_point -= u.insert_length; } state->cursor = u.where + u.insert_length; s->undo_point--; s->redo_point--; } static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) { StbUndoState *s = &state->undostate; StbUndoRecord *u, r; if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) return; // we need to do two things: apply the redo record, and create an undo record u = &s->undo_rec[s->undo_point]; r = s->undo_rec[s->redo_point]; // we KNOW there must be room for the undo record, because the redo record // was derived from an undo record u->delete_length = r.insert_length; u->insert_length = r.delete_length; u->where = r.where; u->char_storage = -1; if (r.delete_length) { // the redo record requires us to delete characters, so the undo record // needs to store the characters if (s->undo_char_point + u->insert_length > s->redo_char_point) { u->insert_length = 0; u->delete_length = 0; } else { int i; u->char_storage = s->undo_char_point; s->undo_char_point = s->undo_char_point + u->insert_length; // now save the characters for (i=0; i < u->insert_length; ++i) s->undo_char[u->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u->where + i); } STB_TEXTEDIT_DELETECHARS(str, r.where, r.delete_length); } if (r.insert_length) { // easy case: need to insert n characters STB_TEXTEDIT_INSERTCHARS(str, r.where, &s->undo_char[r.char_storage], r.insert_length); s->redo_char_point += r.insert_length; } state->cursor = r.where + r.insert_length; s->undo_point++; s->redo_point++; } static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length) { stb_text_createundo(&state->undostate, where, 0, length); } static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length) { int i; STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, length, 0); if (p) { for (i=0; i < length; ++i) p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); } } static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length) { int i; STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, old_length, new_length); if (p) { for (i=0; i < old_length; ++i) p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); } } // reset the state to default static void stb_textedit_clear_state(STB_TexteditState *state, int is_single_line) { state->undostate.undo_point = 0; state->undostate.undo_char_point = 0; state->undostate.redo_point = STB_TEXTEDIT_UNDOSTATECOUNT; state->undostate.redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT; state->select_end = state->select_start = 0; state->cursor = 0; state->has_preferred_x = 0; state->preferred_x = 0; state->cursor_at_end_of_line = 0; state->initialized = 1; state->single_line = (unsigned char) is_single_line; state->insert_mode = 0; } // API initialize static void stb_textedit_initialize_state(STB_TexteditState *state, int is_single_line) { stb_textedit_clear_state(state, is_single_line); } #endif//STB_TEXTEDIT_IMPLEMENTATION goxel-0.11.0/ext_src/stb/stb_truetype.h000066400000000000000000005627301435762723100200770ustar00rootroot00000000000000// stb_truetype.h - v1.19 - public domain // authored from 2009-2016 by Sean Barrett / RAD Game Tools // // This library processes TrueType files: // parse files // extract glyph metrics // extract glyph shapes // render glyphs to one-channel bitmaps with antialiasing (box filter) // render glyphs to one-channel SDF bitmaps (signed-distance field/function) // // Todo: // non-MS cmaps // crashproof on bad data // hinting? (no longer patented) // cleartype-style AA? // optimize: use simple memory allocator for intermediates // optimize: build edge-list directly from curves // optimize: rasterize directly from curves? // // ADDITIONAL CONTRIBUTORS // // Mikko Mononen: compound shape support, more cmap formats // Tor Andersson: kerning, subpixel rendering // Dougall Johnson: OpenType / Type 2 font handling // Daniel Ribeiro Maciel: basic GPOS-based kerning // // Misc other: // Ryan Gordon // Simon Glass // github:IntellectualKitty // Imanol Celaya // Daniel Ribeiro Maciel // // Bug/warning reports/fixes: // "Zer" on mollyrocket Fabian "ryg" Giesen // Cass Everitt Martins Mozeiko // stoiko (Haemimont Games) Cap Petschulat // Brian Hook Omar Cornut // Walter van Niftrik github:aloucks // David Gow Peter LaValle // David Given Sergey Popov // Ivan-Assen Ivanov Giumo X. Clanjor // Anthony Pesch Higor Euripedes // Johan Duparc Thomas Fields // Hou Qiming Derek Vinyard // Rob Loach Cort Stratton // Kenney Phillis Jr. github:oyvindjam // Brian Costabile github:vassvik // // VERSION HISTORY // // 1.19 (2018-02-11) GPOS kerning, STBTT_fmod // 1.18 (2018-01-29) add missing function // 1.17 (2017-07-23) make more arguments const; doc fix // 1.16 (2017-07-12) SDF support // 1.15 (2017-03-03) make more arguments const // 1.14 (2017-01-16) num-fonts-in-TTC function // 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts // 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual // 1.11 (2016-04-02) fix unused-variable warning // 1.10 (2016-04-02) user-defined fabs(); rare memory leak; remove duplicate typedef // 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use allocation userdata properly // 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges // 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; // variant PackFontRanges to pack and render in separate phases; // fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); // fixed an assert() bug in the new rasterizer // replace assert() with STBTT_assert() in new rasterizer // // Full history can be found at the end of this file. // // LICENSE // // See end of file for license information. // // USAGE // // Include this file in whatever places neeed to refer to it. In ONE C/C++ // file, write: // #define STB_TRUETYPE_IMPLEMENTATION // before the #include of this file. This expands out the actual // implementation into that C/C++ file. // // To make the implementation private to the file that generates the implementation, // #define STBTT_STATIC // // Simple 3D API (don't ship this, but it's fine for tools and quick start) // stbtt_BakeFontBitmap() -- bake a font to a bitmap for use as texture // stbtt_GetBakedQuad() -- compute quad to draw for a given char // // Improved 3D API (more shippable): // #include "stb_rect_pack.h" -- optional, but you really want it // stbtt_PackBegin() // stbtt_PackSetOversampling() -- for improved quality on small fonts // stbtt_PackFontRanges() -- pack and renders // stbtt_PackEnd() // stbtt_GetPackedQuad() // // "Load" a font file from a memory buffer (you have to keep the buffer loaded) // stbtt_InitFont() // stbtt_GetFontOffsetForIndex() -- indexing for TTC font collections // stbtt_GetNumberOfFonts() -- number of fonts for TTC font collections // // Render a unicode codepoint to a bitmap // stbtt_GetCodepointBitmap() -- allocates and returns a bitmap // stbtt_MakeCodepointBitmap() -- renders into bitmap you provide // stbtt_GetCodepointBitmapBox() -- how big the bitmap must be // // Character advance/positioning // stbtt_GetCodepointHMetrics() // stbtt_GetFontVMetrics() // stbtt_GetFontVMetricsOS2() // stbtt_GetCodepointKernAdvance() // // Starting with version 1.06, the rasterizer was replaced with a new, // faster and generally-more-precise rasterizer. The new rasterizer more // accurately measures pixel coverage for anti-aliasing, except in the case // where multiple shapes overlap, in which case it overestimates the AA pixel // coverage. Thus, anti-aliasing of intersecting shapes may look wrong. If // this turns out to be a problem, you can re-enable the old rasterizer with // #define STBTT_RASTERIZER_VERSION 1 // which will incur about a 15% speed hit. // // ADDITIONAL DOCUMENTATION // // Immediately after this block comment are a series of sample programs. // // After the sample programs is the "header file" section. This section // includes documentation for each API function. // // Some important concepts to understand to use this library: // // Codepoint // Characters are defined by unicode codepoints, e.g. 65 is // uppercase A, 231 is lowercase c with a cedilla, 0x7e30 is // the hiragana for "ma". // // Glyph // A visual character shape (every codepoint is rendered as // some glyph) // // Glyph index // A font-specific integer ID representing a glyph // // Baseline // Glyph shapes are defined relative to a baseline, which is the // bottom of uppercase characters. Characters extend both above // and below the baseline. // // Current Point // As you draw text to the screen, you keep track of a "current point" // which is the origin of each character. The current point's vertical // position is the baseline. Even "baked fonts" use this model. // // Vertical Font Metrics // The vertical qualities of the font, used to vertically position // and space the characters. See docs for stbtt_GetFontVMetrics. // // Font Size in Pixels or Points // The preferred interface for specifying font sizes in stb_truetype // is to specify how tall the font's vertical extent should be in pixels. // If that sounds good enough, skip the next paragraph. // // Most font APIs instead use "points", which are a common typographic // measurement for describing font size, defined as 72 points per inch. // stb_truetype provides a point API for compatibility. However, true // "per inch" conventions don't make much sense on computer displays // since different monitors have different number of pixels per // inch. For example, Windows traditionally uses a convention that // there are 96 pixels per inch, thus making 'inch' measurements have // nothing to do with inches, and thus effectively defining a point to // be 1.333 pixels. Additionally, the TrueType font data provides // an explicit scale factor to scale a given font's glyphs to points, // but the author has observed that this scale factor is often wrong // for non-commercial fonts, thus making fonts scaled in points // according to the TrueType spec incoherently sized in practice. // // DETAILED USAGE: // // Scale: // Select how high you want the font to be, in points or pixels. // Call ScaleForPixelHeight or ScaleForMappingEmToPixels to compute // a scale factor SF that will be used by all other functions. // // Baseline: // You need to select a y-coordinate that is the baseline of where // your text will appear. Call GetFontBoundingBox to get the baseline-relative // bounding box for all characters. SF*-y0 will be the distance in pixels // that the worst-case character could extend above the baseline, so if // you want the top edge of characters to appear at the top of the // screen where y=0, then you would set the baseline to SF*-y0. // // Current point: // Set the current point where the first character will appear. The // first character could extend left of the current point; this is font // dependent. You can either choose a current point that is the leftmost // point and hope, or add some padding, or check the bounding box or // left-side-bearing of the first character to be displayed and set // the current point based on that. // // Displaying a character: // Compute the bounding box of the character. It will contain signed values // relative to . I.e. if it returns x0,y0,x1,y1, // then the character should be displayed in the rectangle from // to = 32 && *text < 128) { stbtt_aligned_quad q; stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9 glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y0); glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y0); glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y1); glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y1); } ++text; } glEnd(); } #endif // // ////////////////////////////////////////////////////////////////////////////// // // Complete program (this compiles): get a single bitmap, print as ASCII art // #if 0 #include #define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation #include "stb_truetype.h" char ttf_buffer[1<<25]; int main(int argc, char **argv) { stbtt_fontinfo font; unsigned char *bitmap; int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 'a'), s = (argc > 2 ? atoi(argv[2]) : 20); fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb")); stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0)); bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0); for (j=0; j < h; ++j) { for (i=0; i < w; ++i) putchar(" .:ioVM@"[bitmap[j*w+i]>>5]); putchar('\n'); } return 0; } #endif // // Output: // // .ii. // @@@@@@. // V@Mio@@o // :i. V@V // :oM@@M // :@@@MM@M // @@o o@M // :@@. M@M // @@@o@@@@ // :M@@V:@@. // ////////////////////////////////////////////////////////////////////////////// // // Complete program: print "Hello World!" banner, with bugs // #if 0 char buffer[24<<20]; unsigned char screen[20][79]; int main(int arg, char **argv) { stbtt_fontinfo font; int i,j,ascent,baseline,ch=0; float scale, xpos=2; // leave a little padding in case the character extends left char *text = "Heljo World!"; // intentionally misspelled to show 'lj' brokenness fread(buffer, 1, 1000000, fopen("c:/windows/fonts/arialbd.ttf", "rb")); stbtt_InitFont(&font, buffer, 0); scale = stbtt_ScaleForPixelHeight(&font, 15); stbtt_GetFontVMetrics(&font, &ascent,0,0); baseline = (int) (ascent*scale); while (text[ch]) { int advance,lsb,x0,y0,x1,y1; float x_shift = xpos - (float) floor(xpos); stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb); stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1); stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]); // note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong // because this API is really for baking character bitmaps into textures. if you want to render // a sequence of characters, you really need to render each bitmap to a temp buffer, then // "alpha blend" that into the working buffer xpos += (advance * scale); if (text[ch+1]) xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]); ++ch; } for (j=0; j < 20; ++j) { for (i=0; i < 78; ++i) putchar(" .:ioVM@"[screen[j][i]>>5]); putchar('\n'); } return 0; } #endif ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// //// //// INTEGRATION WITH YOUR CODEBASE //// //// The following sections allow you to supply alternate definitions //// of C library functions used by stb_truetype, e.g. if you don't //// link with the C runtime library. #ifdef STB_TRUETYPE_IMPLEMENTATION // #define your own (u)stbtt_int8/16/32 before including to override this #ifndef stbtt_uint8 typedef unsigned char stbtt_uint8; typedef signed char stbtt_int8; typedef unsigned short stbtt_uint16; typedef signed short stbtt_int16; typedef unsigned int stbtt_uint32; typedef signed int stbtt_int32; #endif typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1]; typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1]; // e.g. #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h #ifndef STBTT_ifloor #include #define STBTT_ifloor(x) ((int) floor(x)) #define STBTT_iceil(x) ((int) ceil(x)) #endif #ifndef STBTT_sqrt #include #define STBTT_sqrt(x) sqrt(x) #define STBTT_pow(x,y) pow(x,y) #endif #ifndef STBTT_fmod #include #define STBTT_fmod(x,y) fmod(x,y) #endif #ifndef STBTT_cos #include #define STBTT_cos(x) cos(x) #define STBTT_acos(x) acos(x) #endif #ifndef STBTT_fabs #include #define STBTT_fabs(x) fabs(x) #endif // #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h #ifndef STBTT_malloc #include #define STBTT_malloc(x,u) ((void)(u),malloc(x)) #define STBTT_free(x,u) ((void)(u),free(x)) #endif #ifndef STBTT_assert #include #define STBTT_assert(x) assert(x) #endif #ifndef STBTT_strlen #include #define STBTT_strlen(x) strlen(x) #endif #ifndef STBTT_memcpy #include #define STBTT_memcpy memcpy #define STBTT_memset memset #endif #endif /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //// //// INTERFACE //// //// #ifndef __STB_INCLUDE_STB_TRUETYPE_H__ #define __STB_INCLUDE_STB_TRUETYPE_H__ #ifdef STBTT_STATIC #define STBTT_DEF static #else #define STBTT_DEF extern #endif #ifdef __cplusplus extern "C" { #endif // private structure typedef struct { unsigned char *data; int cursor; int size; } stbtt__buf; ////////////////////////////////////////////////////////////////////////////// // // TEXTURE BAKING API // // If you use this API, you only have to call two functions ever. // typedef struct { unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap float xoff,yoff,xadvance; } stbtt_bakedchar; STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) float pixel_height, // height of font in pixels unsigned char *pixels, int pw, int ph, // bitmap to be filled in int first_char, int num_chars, // characters to bake stbtt_bakedchar *chardata); // you allocate this, it's num_chars long // if return is positive, the first unused row of the bitmap // if return is negative, returns the negative of the number of characters that fit // if return is 0, no characters fit and no rows were used // This uses a very crappy packing. typedef struct { float x0,y0,s0,t0; // top-left float x1,y1,s1,t1; // bottom-right } stbtt_aligned_quad; STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, // same data as above int char_index, // character to display float *xpos, float *ypos, // pointers to current position in screen pixel space stbtt_aligned_quad *q, // output: quad to draw int opengl_fillrule); // true if opengl fill rule; false if DX9 or earlier // Call GetBakedQuad with char_index = 'character - first_char', and it // creates the quad you need to draw and advances the current position. // // The coordinate system used assumes y increases downwards. // // Characters will extend both above and below the current position; // see discussion of "BASELINE" above. // // It's inefficient; you might want to c&p it and optimize it. ////////////////////////////////////////////////////////////////////////////// // // NEW TEXTURE BAKING API // // This provides options for packing multiple fonts into one atlas, not // perfectly but better than nothing. typedef struct { unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap float xoff,yoff,xadvance; float xoff2,yoff2; } stbtt_packedchar; typedef struct stbtt_pack_context stbtt_pack_context; typedef struct stbtt_fontinfo stbtt_fontinfo; #ifndef STB_RECT_PACK_VERSION typedef struct stbrp_rect stbrp_rect; #endif STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context); // Initializes a packing context stored in the passed-in stbtt_pack_context. // Future calls using this context will pack characters into the bitmap passed // in here: a 1-channel bitmap that is width * height. stride_in_bytes is // the distance from one row to the next (or 0 to mean they are packed tightly // together). "padding" is the amount of padding to leave between each // character (normally you want '1' for bitmaps you'll use as textures with // bilinear filtering). // // Returns 0 on failure, 1 on success. STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc); // Cleans up the packing context and frees all memory. #define STBTT_POINT_SIZE(x) (-(x)) STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range); // Creates character bitmaps from the font_index'th font found in fontdata (use // font_index=0 if you don't know what that is). It creates num_chars_in_range // bitmaps for characters with unicode values starting at first_unicode_char_in_range // and increasing. Data for how to render them is stored in chardata_for_range; // pass these to stbtt_GetPackedQuad to get back renderable quads. // // font_size is the full height of the character from ascender to descender, // as computed by stbtt_ScaleForPixelHeight. To use a point size as computed // by stbtt_ScaleForMappingEmToPixels, wrap the point size in STBTT_POINT_SIZE() // and pass that result as 'font_size': // ..., 20 , ... // font max minus min y is 20 pixels tall // ..., STBTT_POINT_SIZE(20), ... // 'M' is 20 pixels tall typedef struct { float font_size; int first_unicode_codepoint_in_range; // if non-zero, then the chars are continuous, and this is the first codepoint int *array_of_unicode_codepoints; // if non-zero, then this is an array of unicode codepoints int num_chars; stbtt_packedchar *chardata_for_range; // output unsigned char h_oversample, v_oversample; // don't set these, they're used internally } stbtt_pack_range; STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges); // Creates character bitmaps from multiple ranges of characters stored in // ranges. This will usually create a better-packed bitmap than multiple // calls to stbtt_PackFontRange. Note that you can call this multiple // times within a single PackBegin/PackEnd. STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample); // Oversampling a font increases the quality by allowing higher-quality subpixel // positioning, and is especially valuable at smaller text sizes. // // This function sets the amount of oversampling for all following calls to // stbtt_PackFontRange(s) or stbtt_PackFontRangesGatherRects for a given // pack context. The default (no oversampling) is achieved by h_oversample=1 // and v_oversample=1. The total number of pixels required is // h_oversample*v_oversample larger than the default; for example, 2x2 // oversampling requires 4x the storage of 1x1. For best results, render // oversampled textures with bilinear filtering. Look at the readme in // stb/tests/oversample for information about oversampled fonts // // To use with PackFontRangesGather etc., you must set it before calls // call to PackFontRangesGatherRects. STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above int char_index, // character to display float *xpos, float *ypos, // pointers to current position in screen pixel space stbtt_aligned_quad *q, // output: quad to draw int align_to_integer); STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects); STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); // Calling these functions in sequence is roughly equivalent to calling // stbtt_PackFontRanges(). If you more control over the packing of multiple // fonts, or if you want to pack custom data into a font texture, take a look // at the source to of stbtt_PackFontRanges() and create a custom version // using these functions, e.g. call GatherRects multiple times, // building up a single array of rects, then call PackRects once, // then call RenderIntoRects repeatedly. This may result in a // better packing than calling PackFontRanges multiple times // (or it may not). // this is an opaque structure that you shouldn't mess with which holds // all the context needed from PackBegin to PackEnd. struct stbtt_pack_context { void *user_allocator_context; void *pack_info; int width; int height; int stride_in_bytes; int padding; unsigned int h_oversample, v_oversample; unsigned char *pixels; void *nodes; }; ////////////////////////////////////////////////////////////////////////////// // // FONT LOADING // // STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data); // This function will determine the number of fonts in a font file. TrueType // collection (.ttc) files may contain multiple fonts, while TrueType font // (.ttf) files only contain one font. The number of fonts can be used for // indexing with the previous function where the index is between zero and one // less than the total fonts. If an error occurs, -1 is returned. STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index); // Each .ttf/.ttc file may have more than one font. Each font has a sequential // index number starting from 0. Call this function to get the font offset for // a given index; it returns -1 if the index is out of range. A regular .ttf // file will only define one font and it always be at offset 0, so it will // return '0' for index 0, and -1 for all other indices. // The following structure is defined publically so you can declare one on // the stack or as a global or etc, but you should treat it as opaque. struct stbtt_fontinfo { void * userdata; unsigned char * data; // pointer to .ttf file int fontstart; // offset of start of font int numGlyphs; // number of glyphs, needed for range checking int loca,head,glyf,hhea,hmtx,kern,gpos; // table locations as offset from start of .ttf int index_map; // a cmap mapping for our chosen character encoding int indexToLocFormat; // format needed to map from glyph index to glyph stbtt__buf cff; // cff font data stbtt__buf charstrings; // the charstring index stbtt__buf gsubrs; // global charstring subroutines index stbtt__buf subrs; // private charstring subroutines index stbtt__buf fontdicts; // array of font dicts stbtt__buf fdselect; // map from glyph to fontdict }; STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset); // Given an offset into the file that defines a font, this function builds // the necessary cached info for the rest of the system. You must allocate // the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't // need to do anything special to free it, because the contents are pure // value data with no additional data structures. Returns 0 on failure. ////////////////////////////////////////////////////////////////////////////// // // CHARACTER TO GLYPH-INDEX CONVERSIOn STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint); // If you're going to perform multiple operations on the same character // and you want a speed-up, call this function with the character you're // going to process, then use glyph-based functions instead of the // codepoint-based functions. ////////////////////////////////////////////////////////////////////////////// // // CHARACTER PROPERTIES // STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels); // computes a scale factor to produce a font whose "height" is 'pixels' tall. // Height is measured as the distance from the highest ascender to the lowest // descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics // and computing: // scale = pixels / (ascent - descent) // so if you prefer to measure height by the ascent only, use a similar calculation. STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels); // computes a scale factor to produce a font whose EM size is mapped to // 'pixels' tall. This is probably what traditional APIs compute, but // I'm not positive. STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap); // ascent is the coordinate above the baseline the font extends; descent // is the coordinate below the baseline the font extends (i.e. it is typically negative) // lineGap is the spacing between one row's descent and the next row's ascent... // so you should advance the vertical position by "*ascent - *descent + *lineGap" // these are expressed in unscaled coordinates, so you must multiply by // the scale factor for a given size STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap); // analogous to GetFontVMetrics, but returns the "typographic" values from the OS/2 // table (specific to MS/Windows TTF files). // // Returns 1 on success (table present), 0 on failure. STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1); // the bounding box around all possible characters STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing); // leftSideBearing is the offset from the current horizontal position to the left edge of the character // advanceWidth is the offset from the current horizontal position to the next horizontal position // these are expressed in unscaled coordinates STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2); // an additional amount to add to the 'advance' value between ch1 and ch2 STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1); // Gets the bounding box of the visible part of the glyph, in unscaled coordinates STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing); STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2); STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); // as above, but takes one or more glyph indices for greater efficiency ////////////////////////////////////////////////////////////////////////////// // // GLYPH SHAPES (you probably don't need these, but they have to go before // the bitmaps for C declaration-order reasons) // #ifndef STBTT_vmove // you can predefine these to use different values (but why?) enum { STBTT_vmove=1, STBTT_vline, STBTT_vcurve, STBTT_vcubic }; #endif #ifndef stbtt_vertex // you can predefine this to use different values // (we share this with other code at RAD) #define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file typedef struct { stbtt_vertex_type x,y,cx,cy,cx1,cy1; unsigned char type,padding; } stbtt_vertex; #endif STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index); // returns non-zero if nothing is drawn for this glyph STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices); STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices); // returns # of vertices and fills *vertices with the pointer to them // these are expressed in "unscaled" coordinates // // The shape is a series of countours. Each one starts with // a STBTT_moveto, then consists of a series of mixed // STBTT_lineto and STBTT_curveto segments. A lineto // draws a line from previous endpoint to its x,y; a curveto // draws a quadratic bezier from previous endpoint to // its x,y, using cx,cy as the bezier control point. STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices); // frees the data allocated above ////////////////////////////////////////////////////////////////////////////// // // BITMAP RENDERING // STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata); // frees the bitmap allocated below STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff); // allocates a large-enough single-channel 8bpp bitmap and renders the // specified character/glyph at the specified scale into it, with // antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque). // *width & *height are filled out with the width & height of the bitmap, // which is stored left-to-right, top-to-bottom. // // xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff); // the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel // shift for the character STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint); // the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap // in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap // is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the // width and height and positioning info for it first. STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint); // same as stbtt_MakeCodepointBitmap, but you can specify a subpixel // shift for the character STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint); // same as stbtt_MakeCodepointBitmapSubpixel, but prefiltering // is performed (see stbtt_PackSetOversampling) STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); // get the bbox of the bitmap centered around the glyph origin; so the // bitmap width is ix1-ix0, height is iy1-iy0, and location to place // the bitmap top left is (leftSideBearing*scale,iy0). // (Note that the bitmap uses y-increases-down, but the shape uses // y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.) STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); // same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel // shift for the character // the following functions are equivalent to the above functions, but operate // on glyph indices instead of Unicode codepoints (for efficiency) STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff); STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff); STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph); STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph); STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int glyph); STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); // @TODO: don't expose this structure typedef struct { int w,h,stride; unsigned char *pixels; } stbtt__bitmap; // rasterize a shape with quadratic beziers into a bitmap STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, // 1-channel bitmap to draw into float flatness_in_pixels, // allowable error of curve in pixels stbtt_vertex *vertices, // array of vertices defining shape int num_verts, // number of vertices in above array float scale_x, float scale_y, // scale applied to input vertices float shift_x, float shift_y, // translation applied to input vertices int x_off, int y_off, // another translation applied to input int invert, // if non-zero, vertically flip shape void *userdata); // context for to STBTT_MALLOC ////////////////////////////////////////////////////////////////////////////// // // Signed Distance Function (or Field) rendering STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata); // frees the SDF bitmap allocated below STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); // These functions compute a discretized SDF field for a single character, suitable for storing // in a single-channel texture, sampling with bilinear filtering, and testing against // larger than some threshhold to produce scalable fonts. // info -- the font // scale -- controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap // glyph/codepoint -- the character to generate the SDF for // padding -- extra "pixels" around the character which are filled with the distance to the character (not 0), // which allows effects like bit outlines // onedge_value -- value 0-255 to test the SDF against to reconstruct the character (i.e. the isocontour of the character) // pixel_dist_scale -- what value the SDF should increase by when moving one SDF "pixel" away from the edge (on the 0..255 scale) // if positive, > onedge_value is inside; if negative, < onedge_value is inside // width,height -- output height & width of the SDF bitmap (including padding) // xoff,yoff -- output origin of the character // return value -- a 2D array of bytes 0..255, width*height in size // // pixel_dist_scale & onedge_value are a scale & bias that allows you to make // optimal use of the limited 0..255 for your application, trading off precision // and special effects. SDF values outside the range 0..255 are clamped to 0..255. // // Example: // scale = stbtt_ScaleForPixelHeight(22) // padding = 5 // onedge_value = 180 // pixel_dist_scale = 180/5.0 = 36.0 // // This will create an SDF bitmap in which the character is about 22 pixels // high but the whole bitmap is about 22+5+5=32 pixels high. To produce a filled // shape, sample the SDF at each pixel and fill the pixel if the SDF value // is greater than or equal to 180/255. (You'll actually want to antialias, // which is beyond the scope of this example.) Additionally, you can compute // offset outlines (e.g. to stroke the character border inside & outside, // or only outside). For example, to fill outside the character up to 3 SDF // pixels, you would compare against (180-36.0*3)/255 = 72/255. The above // choice of variables maps a range from 5 pixels outside the shape to // 2 pixels inside the shape to 0..255; this is intended primarily for apply // outside effects only (the interior range is needed to allow proper // antialiasing of the font at *smaller* sizes) // // The function computes the SDF analytically at each SDF pixel, not by e.g. // building a higher-res bitmap and approximating it. In theory the quality // should be as high as possible for an SDF of this size & representation, but // unclear if this is true in practice (perhaps building a higher-res bitmap // and computing from that can allow drop-out prevention). // // The algorithm has not been optimized at all, so expect it to be slow // if computing lots of characters or very large sizes. ////////////////////////////////////////////////////////////////////////////// // // Finding the right font... // // You should really just solve this offline, keep your own tables // of what font is what, and don't try to get it out of the .ttf file. // That's because getting it out of the .ttf file is really hard, because // the names in the file can appear in many possible encodings, in many // possible languages, and e.g. if you need a case-insensitive comparison, // the details of that depend on the encoding & language in a complex way // (actually underspecified in truetype, but also gigantic). // // But you can use the provided functions in two possible ways: // stbtt_FindMatchingFont() will use *case-sensitive* comparisons on // unicode-encoded names to try to find the font you want; // you can run this before calling stbtt_InitFont() // // stbtt_GetFontNameString() lets you get any of the various strings // from the file yourself and do your own comparisons on them. // You have to have called stbtt_InitFont() first. STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags); // returns the offset (not index) of the font that matches, or -1 if none // if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold". // if you use any other flag, use a font name like "Arial"; this checks // the 'macStyle' header field; i don't know if fonts set this consistently #define STBTT_MACSTYLE_DONTCARE 0 #define STBTT_MACSTYLE_BOLD 1 #define STBTT_MACSTYLE_ITALIC 2 #define STBTT_MACSTYLE_UNDERSCORE 4 #define STBTT_MACSTYLE_NONE 8 // <= not same as 0, this makes us check the bitfield is 0 STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2); // returns 1/0 whether the first string interpreted as utf8 is identical to // the second string interpreted as big-endian utf16... useful for strings from next func STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID); // returns the string (which may be big-endian double byte, e.g. for unicode) // and puts the length in bytes in *length. // // some of the values for the IDs are below; for more see the truetype spec: // http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html // http://www.microsoft.com/typography/otspec/name.htm enum { // platformID STBTT_PLATFORM_ID_UNICODE =0, STBTT_PLATFORM_ID_MAC =1, STBTT_PLATFORM_ID_ISO =2, STBTT_PLATFORM_ID_MICROSOFT =3 }; enum { // encodingID for STBTT_PLATFORM_ID_UNICODE STBTT_UNICODE_EID_UNICODE_1_0 =0, STBTT_UNICODE_EID_UNICODE_1_1 =1, STBTT_UNICODE_EID_ISO_10646 =2, STBTT_UNICODE_EID_UNICODE_2_0_BMP=3, STBTT_UNICODE_EID_UNICODE_2_0_FULL=4 }; enum { // encodingID for STBTT_PLATFORM_ID_MICROSOFT STBTT_MS_EID_SYMBOL =0, STBTT_MS_EID_UNICODE_BMP =1, STBTT_MS_EID_SHIFTJIS =2, STBTT_MS_EID_UNICODE_FULL =10 }; enum { // encodingID for STBTT_PLATFORM_ID_MAC; same as Script Manager codes STBTT_MAC_EID_ROMAN =0, STBTT_MAC_EID_ARABIC =4, STBTT_MAC_EID_JAPANESE =1, STBTT_MAC_EID_HEBREW =5, STBTT_MAC_EID_CHINESE_TRAD =2, STBTT_MAC_EID_GREEK =6, STBTT_MAC_EID_KOREAN =3, STBTT_MAC_EID_RUSSIAN =7 }; enum { // languageID for STBTT_PLATFORM_ID_MICROSOFT; same as LCID... // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs STBTT_MS_LANG_ENGLISH =0x0409, STBTT_MS_LANG_ITALIAN =0x0410, STBTT_MS_LANG_CHINESE =0x0804, STBTT_MS_LANG_JAPANESE =0x0411, STBTT_MS_LANG_DUTCH =0x0413, STBTT_MS_LANG_KOREAN =0x0412, STBTT_MS_LANG_FRENCH =0x040c, STBTT_MS_LANG_RUSSIAN =0x0419, STBTT_MS_LANG_GERMAN =0x0407, STBTT_MS_LANG_SPANISH =0x0409, STBTT_MS_LANG_HEBREW =0x040d, STBTT_MS_LANG_SWEDISH =0x041D }; enum { // languageID for STBTT_PLATFORM_ID_MAC STBTT_MAC_LANG_ENGLISH =0 , STBTT_MAC_LANG_JAPANESE =11, STBTT_MAC_LANG_ARABIC =12, STBTT_MAC_LANG_KOREAN =23, STBTT_MAC_LANG_DUTCH =4 , STBTT_MAC_LANG_RUSSIAN =32, STBTT_MAC_LANG_FRENCH =1 , STBTT_MAC_LANG_SPANISH =6 , STBTT_MAC_LANG_GERMAN =2 , STBTT_MAC_LANG_SWEDISH =5 , STBTT_MAC_LANG_HEBREW =10, STBTT_MAC_LANG_CHINESE_SIMPLIFIED =33, STBTT_MAC_LANG_ITALIAN =3 , STBTT_MAC_LANG_CHINESE_TRAD =19 }; #ifdef __cplusplus } #endif #endif // __STB_INCLUDE_STB_TRUETYPE_H__ /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //// //// IMPLEMENTATION //// //// #ifdef STB_TRUETYPE_IMPLEMENTATION #ifndef STBTT_MAX_OVERSAMPLE #define STBTT_MAX_OVERSAMPLE 8 #endif #if STBTT_MAX_OVERSAMPLE > 255 #error "STBTT_MAX_OVERSAMPLE cannot be > 255" #endif typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERSAMPLE-1)) == 0 ? 1 : -1]; #ifndef STBTT_RASTERIZER_VERSION #define STBTT_RASTERIZER_VERSION 2 #endif #ifdef _MSC_VER #define STBTT__NOTUSED(v) (void)(v) #else #define STBTT__NOTUSED(v) (void)sizeof(v) #endif ////////////////////////////////////////////////////////////////////////// // // stbtt__buf helpers to parse data from file // static stbtt_uint8 stbtt__buf_get8(stbtt__buf *b) { if (b->cursor >= b->size) return 0; return b->data[b->cursor++]; } static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b) { if (b->cursor >= b->size) return 0; return b->data[b->cursor]; } static void stbtt__buf_seek(stbtt__buf *b, int o) { STBTT_assert(!(o > b->size || o < 0)); b->cursor = (o > b->size || o < 0) ? b->size : o; } static void stbtt__buf_skip(stbtt__buf *b, int o) { stbtt__buf_seek(b, b->cursor + o); } static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n) { stbtt_uint32 v = 0; int i; STBTT_assert(n >= 1 && n <= 4); for (i = 0; i < n; i++) v = (v << 8) | stbtt__buf_get8(b); return v; } static stbtt__buf stbtt__new_buf(const void *p, size_t size) { stbtt__buf r; STBTT_assert(size < 0x40000000); r.data = (stbtt_uint8*) p; r.size = (int) size; r.cursor = 0; return r; } #define stbtt__buf_get16(b) stbtt__buf_get((b), 2) #define stbtt__buf_get32(b) stbtt__buf_get((b), 4) static stbtt__buf stbtt__buf_range(const stbtt__buf *b, int o, int s) { stbtt__buf r = stbtt__new_buf(NULL, 0); if (o < 0 || s < 0 || o > b->size || s > b->size - o) return r; r.data = b->data + o; r.size = s; return r; } static stbtt__buf stbtt__cff_get_index(stbtt__buf *b) { int count, start, offsize; start = b->cursor; count = stbtt__buf_get16(b); if (count) { offsize = stbtt__buf_get8(b); STBTT_assert(offsize >= 1 && offsize <= 4); stbtt__buf_skip(b, offsize * count); stbtt__buf_skip(b, stbtt__buf_get(b, offsize) - 1); } return stbtt__buf_range(b, start, b->cursor - start); } static stbtt_uint32 stbtt__cff_int(stbtt__buf *b) { int b0 = stbtt__buf_get8(b); if (b0 >= 32 && b0 <= 246) return b0 - 139; else if (b0 >= 247 && b0 <= 250) return (b0 - 247)*256 + stbtt__buf_get8(b) + 108; else if (b0 >= 251 && b0 <= 254) return -(b0 - 251)*256 - stbtt__buf_get8(b) - 108; else if (b0 == 28) return stbtt__buf_get16(b); else if (b0 == 29) return stbtt__buf_get32(b); STBTT_assert(0); return 0; } static void stbtt__cff_skip_operand(stbtt__buf *b) { int v, b0 = stbtt__buf_peek8(b); STBTT_assert(b0 >= 28); if (b0 == 30) { stbtt__buf_skip(b, 1); while (b->cursor < b->size) { v = stbtt__buf_get8(b); if ((v & 0xF) == 0xF || (v >> 4) == 0xF) break; } } else { stbtt__cff_int(b); } } static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key) { stbtt__buf_seek(b, 0); while (b->cursor < b->size) { int start = b->cursor, end, op; while (stbtt__buf_peek8(b) >= 28) stbtt__cff_skip_operand(b); end = b->cursor; op = stbtt__buf_get8(b); if (op == 12) op = stbtt__buf_get8(b) | 0x100; if (op == key) return stbtt__buf_range(b, start, end-start); } return stbtt__buf_range(b, 0, 0); } static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uint32 *out) { int i; stbtt__buf operands = stbtt__dict_get(b, key); for (i = 0; i < outcount && operands.cursor < operands.size; i++) out[i] = stbtt__cff_int(&operands); } static int stbtt__cff_index_count(stbtt__buf *b) { stbtt__buf_seek(b, 0); return stbtt__buf_get16(b); } static stbtt__buf stbtt__cff_index_get(stbtt__buf b, int i) { int count, offsize, start, end; stbtt__buf_seek(&b, 0); count = stbtt__buf_get16(&b); offsize = stbtt__buf_get8(&b); STBTT_assert(i >= 0 && i < count); STBTT_assert(offsize >= 1 && offsize <= 4); stbtt__buf_skip(&b, i*offsize); start = stbtt__buf_get(&b, offsize); end = stbtt__buf_get(&b, offsize); return stbtt__buf_range(&b, 2+(count+1)*offsize+start, end - start); } ////////////////////////////////////////////////////////////////////////// // // accessors to parse data from file // // on platforms that don't allow misaligned reads, if we want to allow // truetype fonts that aren't padded to alignment, define ALLOW_UNALIGNED_TRUETYPE #define ttBYTE(p) (* (stbtt_uint8 *) (p)) #define ttCHAR(p) (* (stbtt_int8 *) (p)) #define ttFixed(p) ttLONG(p) static stbtt_uint16 ttUSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } static stbtt_int16 ttSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } static stbtt_uint32 ttULONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } static stbtt_int32 ttLONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } #define stbtt_tag4(p,c0,c1,c2,c3) ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3)) #define stbtt_tag(p,str) stbtt_tag4(p,str[0],str[1],str[2],str[3]) static int stbtt__isfont(stbtt_uint8 *font) { // check the version number if (stbtt_tag4(font, '1',0,0,0)) return 1; // TrueType 1 if (stbtt_tag(font, "typ1")) return 1; // TrueType with type 1 font -- we don't support this! if (stbtt_tag(font, "OTTO")) return 1; // OpenType with CFF if (stbtt_tag4(font, 0,1,0,0)) return 1; // OpenType 1.0 if (stbtt_tag(font, "true")) return 1; // Apple specification for TrueType fonts return 0; } // @OPTIMIZE: binary search static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, const char *tag) { stbtt_int32 num_tables = ttUSHORT(data+fontstart+4); stbtt_uint32 tabledir = fontstart + 12; stbtt_int32 i; for (i=0; i < num_tables; ++i) { stbtt_uint32 loc = tabledir + 16*i; if (stbtt_tag(data+loc+0, tag)) return ttULONG(data+loc+8); } return 0; } static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, int index) { // if it's just a font, there's only one valid index if (stbtt__isfont(font_collection)) return index == 0 ? 0 : -1; // check if it's a TTC if (stbtt_tag(font_collection, "ttcf")) { // version 1? if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { stbtt_int32 n = ttLONG(font_collection+8); if (index >= n) return -1; return ttULONG(font_collection+12+index*4); } } return -1; } static int stbtt_GetNumberOfFonts_internal(unsigned char *font_collection) { // if it's just a font, there's only one valid font if (stbtt__isfont(font_collection)) return 1; // check if it's a TTC if (stbtt_tag(font_collection, "ttcf")) { // version 1? if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { return ttLONG(font_collection+8); } } return 0; } static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict) { stbtt_uint32 subrsoff = 0, private_loc[2] = { 0, 0 }; stbtt__buf pdict; stbtt__dict_get_ints(&fontdict, 18, 2, private_loc); if (!private_loc[1] || !private_loc[0]) return stbtt__new_buf(NULL, 0); pdict = stbtt__buf_range(&cff, private_loc[1], private_loc[0]); stbtt__dict_get_ints(&pdict, 19, 1, &subrsoff); if (!subrsoff) return stbtt__new_buf(NULL, 0); stbtt__buf_seek(&cff, private_loc[1]+subrsoff); return stbtt__cff_get_index(&cff); } static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart) { stbtt_uint32 cmap, t; stbtt_int32 i,numTables; info->data = data; info->fontstart = fontstart; info->cff = stbtt__new_buf(NULL, 0); cmap = stbtt__find_table(data, fontstart, "cmap"); // required info->loca = stbtt__find_table(data, fontstart, "loca"); // required info->head = stbtt__find_table(data, fontstart, "head"); // required info->glyf = stbtt__find_table(data, fontstart, "glyf"); // required info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required info->kern = stbtt__find_table(data, fontstart, "kern"); // not required info->gpos = stbtt__find_table(data, fontstart, "GPOS"); // not required if (!cmap || !info->head || !info->hhea || !info->hmtx) return 0; if (info->glyf) { // required for truetype if (!info->loca) return 0; } else { // initialization for CFF / Type2 fonts (OTF) stbtt__buf b, topdict, topdictidx; stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0; stbtt_uint32 cff; cff = stbtt__find_table(data, fontstart, "CFF "); if (!cff) return 0; info->fontdicts = stbtt__new_buf(NULL, 0); info->fdselect = stbtt__new_buf(NULL, 0); // @TODO this should use size from table (not 512MB) info->cff = stbtt__new_buf(data+cff, 512*1024*1024); b = info->cff; // read the header stbtt__buf_skip(&b, 2); stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize // @TODO the name INDEX could list multiple fonts, // but we just use the first one. stbtt__cff_get_index(&b); // name INDEX topdictidx = stbtt__cff_get_index(&b); topdict = stbtt__cff_index_get(topdictidx, 0); stbtt__cff_get_index(&b); // string INDEX info->gsubrs = stbtt__cff_get_index(&b); stbtt__dict_get_ints(&topdict, 17, 1, &charstrings); stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype); stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff); stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff); info->subrs = stbtt__get_subrs(b, topdict); // we only support Type 2 charstrings if (cstype != 2) return 0; if (charstrings == 0) return 0; if (fdarrayoff) { // looks like a CID font if (!fdselectoff) return 0; stbtt__buf_seek(&b, fdarrayoff); info->fontdicts = stbtt__cff_get_index(&b); info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff); } stbtt__buf_seek(&b, charstrings); info->charstrings = stbtt__cff_get_index(&b); } t = stbtt__find_table(data, fontstart, "maxp"); if (t) info->numGlyphs = ttUSHORT(data+t+4); else info->numGlyphs = 0xffff; // find a cmap encoding table we understand *now* to avoid searching // later. (todo: could make this installable) // the same regardless of glyph. numTables = ttUSHORT(data + cmap + 2); info->index_map = 0; for (i=0; i < numTables; ++i) { stbtt_uint32 encoding_record = cmap + 4 + 8 * i; // find an encoding we understand: switch(ttUSHORT(data+encoding_record)) { case STBTT_PLATFORM_ID_MICROSOFT: switch (ttUSHORT(data+encoding_record+2)) { case STBTT_MS_EID_UNICODE_BMP: case STBTT_MS_EID_UNICODE_FULL: // MS/Unicode info->index_map = cmap + ttULONG(data+encoding_record+4); break; } break; case STBTT_PLATFORM_ID_UNICODE: // Mac/iOS has these // all the encodingIDs are unicode, so we don't bother to check it info->index_map = cmap + ttULONG(data+encoding_record+4); break; } } if (info->index_map == 0) return 0; info->indexToLocFormat = ttUSHORT(data+info->head + 50); return 1; } STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint) { stbtt_uint8 *data = info->data; stbtt_uint32 index_map = info->index_map; stbtt_uint16 format = ttUSHORT(data + index_map + 0); if (format == 0) { // apple byte encoding stbtt_int32 bytes = ttUSHORT(data + index_map + 2); if (unicode_codepoint < bytes-6) return ttBYTE(data + index_map + 6 + unicode_codepoint); return 0; } else if (format == 6) { stbtt_uint32 first = ttUSHORT(data + index_map + 6); stbtt_uint32 count = ttUSHORT(data + index_map + 8); if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count) return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2); return 0; } else if (format == 2) { STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean return 0; } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1; stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1; stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10); stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1; // do a binary search of the segments stbtt_uint32 endCount = index_map + 14; stbtt_uint32 search = endCount; if (unicode_codepoint > 0xffff) return 0; // they lie from endCount .. endCount + segCount // but searchRange is the nearest power of two, so... if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2)) search += rangeShift*2; // now decrement to bias correctly to find smallest search -= 2; while (entrySelector) { stbtt_uint16 end; searchRange >>= 1; end = ttUSHORT(data + search + searchRange*2); if (unicode_codepoint > end) search += searchRange*2; --entrySelector; } search += 2; { stbtt_uint16 offset, start; stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1); STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item)); start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item); if (unicode_codepoint < start) return 0; offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item); if (offset == 0) return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item)); return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item); } } else if (format == 12 || format == 13) { stbtt_uint32 ngroups = ttULONG(data+index_map+12); stbtt_int32 low,high; low = 0; high = (stbtt_int32)ngroups; // Binary search the right group. while (low < high) { stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12); stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4); if ((stbtt_uint32) unicode_codepoint < start_char) high = mid; else if ((stbtt_uint32) unicode_codepoint > end_char) low = mid+1; else { stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8); if (format == 12) return start_glyph + unicode_codepoint-start_char; else // format == 13 return start_glyph; } } return 0; // not found } // @TODO STBTT_assert(0); return 0; } STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices) { return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices); } static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy) { v->type = type; v->x = (stbtt_int16) x; v->y = (stbtt_int16) y; v->cx = (stbtt_int16) cx; v->cy = (stbtt_int16) cy; } static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) { int g1,g2; STBTT_assert(!info->cff.size); if (glyph_index >= info->numGlyphs) return -1; // glyph index out of range if (info->indexToLocFormat >= 2) return -1; // unknown index->glyph map format if (info->indexToLocFormat == 0) { g1 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2) * 2; g2 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2; } else { g1 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4); g2 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4 + 4); } return g1==g2 ? -1 : g1; // if length is 0, return -1 } static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) { if (info->cff.size) { stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1); } else { int g = stbtt__GetGlyfOffset(info, glyph_index); if (g < 0) return 0; if (x0) *x0 = ttSHORT(info->data + g + 2); if (y0) *y0 = ttSHORT(info->data + g + 4); if (x1) *x1 = ttSHORT(info->data + g + 6); if (y1) *y1 = ttSHORT(info->data + g + 8); } return 1; } STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1) { return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1); } STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) { stbtt_int16 numberOfContours; int g; if (info->cff.size) return stbtt__GetGlyphInfoT2(info, glyph_index, NULL, NULL, NULL, NULL) == 0; g = stbtt__GetGlyfOffset(info, glyph_index); if (g < 0) return 1; numberOfContours = ttSHORT(info->data + g); return numberOfContours == 0; } static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off, stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy) { if (start_off) { if (was_off) stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy); stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, sx,sy,scx,scy); } else { if (was_off) stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve,sx,sy,cx,cy); else stbtt_setvertex(&vertices[num_vertices++], STBTT_vline,sx,sy,0,0); } return num_vertices; } static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) { stbtt_int16 numberOfContours; stbtt_uint8 *endPtsOfContours; stbtt_uint8 *data = info->data; stbtt_vertex *vertices=0; int num_vertices=0; int g = stbtt__GetGlyfOffset(info, glyph_index); *pvertices = NULL; if (g < 0) return 0; numberOfContours = ttSHORT(data + g); if (numberOfContours > 0) { stbtt_uint8 flags=0,flagcount; stbtt_int32 ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0; stbtt_int32 x,y,cx,cy,sx,sy, scx,scy; stbtt_uint8 *points; endPtsOfContours = (data + g + 10); ins = ttUSHORT(data + g + 10 + numberOfContours * 2); points = data + g + 10 + numberOfContours * 2 + 2 + ins; n = 1+ttUSHORT(endPtsOfContours + numberOfContours*2-2); m = n + 2*numberOfContours; // a loose bound on how many vertices we might need vertices = (stbtt_vertex *) STBTT_malloc(m * sizeof(vertices[0]), info->userdata); if (vertices == 0) return 0; next_move = 0; flagcount=0; // in first pass, we load uninterpreted data into the allocated array // above, shifted to the end of the array so we won't overwrite it when // we create our final data starting from the front off = m - n; // starting offset for uninterpreted data, regardless of how m ends up being calculated // first load flags for (i=0; i < n; ++i) { if (flagcount == 0) { flags = *points++; if (flags & 8) flagcount = *points++; } else --flagcount; vertices[off+i].type = flags; } // now load x coordinates x=0; for (i=0; i < n; ++i) { flags = vertices[off+i].type; if (flags & 2) { stbtt_int16 dx = *points++; x += (flags & 16) ? dx : -dx; // ??? } else { if (!(flags & 16)) { x = x + (stbtt_int16) (points[0]*256 + points[1]); points += 2; } } vertices[off+i].x = (stbtt_int16) x; } // now load y coordinates y=0; for (i=0; i < n; ++i) { flags = vertices[off+i].type; if (flags & 4) { stbtt_int16 dy = *points++; y += (flags & 32) ? dy : -dy; // ??? } else { if (!(flags & 32)) { y = y + (stbtt_int16) (points[0]*256 + points[1]); points += 2; } } vertices[off+i].y = (stbtt_int16) y; } // now convert them to our format num_vertices=0; sx = sy = cx = cy = scx = scy = 0; for (i=0; i < n; ++i) { flags = vertices[off+i].type; x = (stbtt_int16) vertices[off+i].x; y = (stbtt_int16) vertices[off+i].y; if (next_move == i) { if (i != 0) num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); // now start the new one start_off = !(flags & 1); if (start_off) { // if we start off with an off-curve point, then when we need to find a point on the curve // where we can start, and we need to save some state for when we wraparound. scx = x; scy = y; if (!(vertices[off+i+1].type & 1)) { // next point is also a curve point, so interpolate an on-point curve sx = (x + (stbtt_int32) vertices[off+i+1].x) >> 1; sy = (y + (stbtt_int32) vertices[off+i+1].y) >> 1; } else { // otherwise just use the next point as our start point sx = (stbtt_int32) vertices[off+i+1].x; sy = (stbtt_int32) vertices[off+i+1].y; ++i; // we're using point i+1 as the starting point, so skip it } } else { sx = x; sy = y; } stbtt_setvertex(&vertices[num_vertices++], STBTT_vmove,sx,sy,0,0); was_off = 0; next_move = 1 + ttUSHORT(endPtsOfContours+j*2); ++j; } else { if (!(flags & 1)) { // if it's a curve if (was_off) // two off-curve control points in a row means interpolate an on-curve midpoint stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy); cx = x; cy = y; was_off = 1; } else { if (was_off) stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, x,y, cx, cy); else stbtt_setvertex(&vertices[num_vertices++], STBTT_vline, x,y,0,0); was_off = 0; } } } num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); } else if (numberOfContours == -1) { // Compound shapes. int more = 1; stbtt_uint8 *comp = data + g + 10; num_vertices = 0; vertices = 0; while (more) { stbtt_uint16 flags, gidx; int comp_num_verts = 0, i; stbtt_vertex *comp_verts = 0, *tmp = 0; float mtx[6] = {1,0,0,1,0,0}, m, n; flags = ttSHORT(comp); comp+=2; gidx = ttSHORT(comp); comp+=2; if (flags & 2) { // XY values if (flags & 1) { // shorts mtx[4] = ttSHORT(comp); comp+=2; mtx[5] = ttSHORT(comp); comp+=2; } else { mtx[4] = ttCHAR(comp); comp+=1; mtx[5] = ttCHAR(comp); comp+=1; } } else { // @TODO handle matching point STBTT_assert(0); } if (flags & (1<<3)) { // WE_HAVE_A_SCALE mtx[0] = mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; mtx[1] = mtx[2] = 0; } else if (flags & (1<<6)) { // WE_HAVE_AN_X_AND_YSCALE mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; mtx[1] = mtx[2] = 0; mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; } else if (flags & (1<<7)) { // WE_HAVE_A_TWO_BY_TWO mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; mtx[1] = ttSHORT(comp)/16384.0f; comp+=2; mtx[2] = ttSHORT(comp)/16384.0f; comp+=2; mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; } // Find transformation scales. m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]); n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]); // Get indexed glyph. comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts); if (comp_num_verts > 0) { // Transform vertices. for (i = 0; i < comp_num_verts; ++i) { stbtt_vertex* v = &comp_verts[i]; stbtt_vertex_type x,y; x=v->x; y=v->y; v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); x=v->cx; y=v->cy; v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); } // Append vertices. tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata); if (!tmp) { if (vertices) STBTT_free(vertices, info->userdata); if (comp_verts) STBTT_free(comp_verts, info->userdata); return 0; } if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex)); STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex)); if (vertices) STBTT_free(vertices, info->userdata); vertices = tmp; STBTT_free(comp_verts, info->userdata); num_vertices += comp_num_verts; } // More components ? more = flags & (1<<5); } } else if (numberOfContours < 0) { // @TODO other compound variations? STBTT_assert(0); } else { // numberOfCounters == 0, do nothing } *pvertices = vertices; return num_vertices; } typedef struct { int bounds; int started; float first_x, first_y; float x, y; stbtt_int32 min_x, max_x, min_y, max_y; stbtt_vertex *pvertices; int num_vertices; } stbtt__csctx; #define STBTT__CSCTX_INIT(bounds) {bounds,0, 0,0, 0,0, 0,0,0,0, NULL, 0} static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y) { if (x > c->max_x || !c->started) c->max_x = x; if (y > c->max_y || !c->started) c->max_y = y; if (x < c->min_x || !c->started) c->min_x = x; if (y < c->min_y || !c->started) c->min_y = y; c->started = 1; } static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1) { if (c->bounds) { stbtt__track_vertex(c, x, y); if (type == STBTT_vcubic) { stbtt__track_vertex(c, cx, cy); stbtt__track_vertex(c, cx1, cy1); } } else { stbtt_setvertex(&c->pvertices[c->num_vertices], type, x, y, cx, cy); c->pvertices[c->num_vertices].cx1 = (stbtt_int16) cx1; c->pvertices[c->num_vertices].cy1 = (stbtt_int16) cy1; } c->num_vertices++; } static void stbtt__csctx_close_shape(stbtt__csctx *ctx) { if (ctx->first_x != ctx->x || ctx->first_y != ctx->y) stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0); } static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy) { stbtt__csctx_close_shape(ctx); ctx->first_x = ctx->x = ctx->x + dx; ctx->first_y = ctx->y = ctx->y + dy; stbtt__csctx_v(ctx, STBTT_vmove, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); } static void stbtt__csctx_rline_to(stbtt__csctx *ctx, float dx, float dy) { ctx->x += dx; ctx->y += dy; stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); } static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3) { float cx1 = ctx->x + dx1; float cy1 = ctx->y + dy1; float cx2 = cx1 + dx2; float cy2 = cy1 + dy2; ctx->x = cx2 + dx3; ctx->y = cy2 + dy3; stbtt__csctx_v(ctx, STBTT_vcubic, (int)ctx->x, (int)ctx->y, (int)cx1, (int)cy1, (int)cx2, (int)cy2); } static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n) { int count = stbtt__cff_index_count(&idx); int bias = 107; if (count >= 33900) bias = 32768; else if (count >= 1240) bias = 1131; n += bias; if (n < 0 || n >= count) return stbtt__new_buf(NULL, 0); return stbtt__cff_index_get(idx, n); } static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int glyph_index) { stbtt__buf fdselect = info->fdselect; int nranges, start, end, v, fmt, fdselector = -1, i; stbtt__buf_seek(&fdselect, 0); fmt = stbtt__buf_get8(&fdselect); if (fmt == 0) { // untested stbtt__buf_skip(&fdselect, glyph_index); fdselector = stbtt__buf_get8(&fdselect); } else if (fmt == 3) { nranges = stbtt__buf_get16(&fdselect); start = stbtt__buf_get16(&fdselect); for (i = 0; i < nranges; i++) { v = stbtt__buf_get8(&fdselect); end = stbtt__buf_get16(&fdselect); if (glyph_index >= start && glyph_index < end) { fdselector = v; break; } start = end; } } if (fdselector == -1) stbtt__new_buf(NULL, 0); return stbtt__get_subrs(info->cff, stbtt__cff_index_get(info->fontdicts, fdselector)); } static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, stbtt__csctx *c) { int in_header = 1, maskbits = 0, subr_stack_height = 0, sp = 0, v, i, b0; int has_subrs = 0, clear_stack; float s[48]; stbtt__buf subr_stack[10], subrs = info->subrs, b; float f; #define STBTT__CSERR(s) (0) // this currently ignores the initial width value, which isn't needed if we have hmtx b = stbtt__cff_index_get(info->charstrings, glyph_index); while (b.cursor < b.size) { i = 0; clear_stack = 1; b0 = stbtt__buf_get8(&b); switch (b0) { // @TODO implement hinting case 0x13: // hintmask case 0x14: // cntrmask if (in_header) maskbits += (sp / 2); // implicit "vstem" in_header = 0; stbtt__buf_skip(&b, (maskbits + 7) / 8); break; case 0x01: // hstem case 0x03: // vstem case 0x12: // hstemhm case 0x17: // vstemhm maskbits += (sp / 2); break; case 0x15: // rmoveto in_header = 0; if (sp < 2) return STBTT__CSERR("rmoveto stack"); stbtt__csctx_rmove_to(c, s[sp-2], s[sp-1]); break; case 0x04: // vmoveto in_header = 0; if (sp < 1) return STBTT__CSERR("vmoveto stack"); stbtt__csctx_rmove_to(c, 0, s[sp-1]); break; case 0x16: // hmoveto in_header = 0; if (sp < 1) return STBTT__CSERR("hmoveto stack"); stbtt__csctx_rmove_to(c, s[sp-1], 0); break; case 0x05: // rlineto if (sp < 2) return STBTT__CSERR("rlineto stack"); for (; i + 1 < sp; i += 2) stbtt__csctx_rline_to(c, s[i], s[i+1]); break; // hlineto/vlineto and vhcurveto/hvcurveto alternate horizontal and vertical // starting from a different place. case 0x07: // vlineto if (sp < 1) return STBTT__CSERR("vlineto stack"); goto vlineto; case 0x06: // hlineto if (sp < 1) return STBTT__CSERR("hlineto stack"); for (;;) { if (i >= sp) break; stbtt__csctx_rline_to(c, s[i], 0); i++; vlineto: if (i >= sp) break; stbtt__csctx_rline_to(c, 0, s[i]); i++; } break; case 0x1F: // hvcurveto if (sp < 4) return STBTT__CSERR("hvcurveto stack"); goto hvcurveto; case 0x1E: // vhcurveto if (sp < 4) return STBTT__CSERR("vhcurveto stack"); for (;;) { if (i + 3 >= sp) break; stbtt__csctx_rccurve_to(c, 0, s[i], s[i+1], s[i+2], s[i+3], (sp - i == 5) ? s[i + 4] : 0.0f); i += 4; hvcurveto: if (i + 3 >= sp) break; stbtt__csctx_rccurve_to(c, s[i], 0, s[i+1], s[i+2], (sp - i == 5) ? s[i+4] : 0.0f, s[i+3]); i += 4; } break; case 0x08: // rrcurveto if (sp < 6) return STBTT__CSERR("rcurveline stack"); for (; i + 5 < sp; i += 6) stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); break; case 0x18: // rcurveline if (sp < 8) return STBTT__CSERR("rcurveline stack"); for (; i + 5 < sp - 2; i += 6) stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); if (i + 1 >= sp) return STBTT__CSERR("rcurveline stack"); stbtt__csctx_rline_to(c, s[i], s[i+1]); break; case 0x19: // rlinecurve if (sp < 8) return STBTT__CSERR("rlinecurve stack"); for (; i + 1 < sp - 6; i += 2) stbtt__csctx_rline_to(c, s[i], s[i+1]); if (i + 5 >= sp) return STBTT__CSERR("rlinecurve stack"); stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); break; case 0x1A: // vvcurveto case 0x1B: // hhcurveto if (sp < 4) return STBTT__CSERR("(vv|hh)curveto stack"); f = 0.0; if (sp & 1) { f = s[i]; i++; } for (; i + 3 < sp; i += 4) { if (b0 == 0x1B) stbtt__csctx_rccurve_to(c, s[i], f, s[i+1], s[i+2], s[i+3], 0.0); else stbtt__csctx_rccurve_to(c, f, s[i], s[i+1], s[i+2], 0.0, s[i+3]); f = 0.0; } break; case 0x0A: // callsubr if (!has_subrs) { if (info->fdselect.size) subrs = stbtt__cid_get_glyph_subrs(info, glyph_index); has_subrs = 1; } // fallthrough case 0x1D: // callgsubr if (sp < 1) return STBTT__CSERR("call(g|)subr stack"); v = (int) s[--sp]; if (subr_stack_height >= 10) return STBTT__CSERR("recursion limit"); subr_stack[subr_stack_height++] = b; b = stbtt__get_subr(b0 == 0x0A ? subrs : info->gsubrs, v); if (b.size == 0) return STBTT__CSERR("subr not found"); b.cursor = 0; clear_stack = 0; break; case 0x0B: // return if (subr_stack_height <= 0) return STBTT__CSERR("return outside subr"); b = subr_stack[--subr_stack_height]; clear_stack = 0; break; case 0x0E: // endchar stbtt__csctx_close_shape(c); return 1; case 0x0C: { // two-byte escape float dx1, dx2, dx3, dx4, dx5, dx6, dy1, dy2, dy3, dy4, dy5, dy6; float dx, dy; int b1 = stbtt__buf_get8(&b); switch (b1) { // @TODO These "flex" implementations ignore the flex-depth and resolution, // and always draw beziers. case 0x22: // hflex if (sp < 7) return STBTT__CSERR("hflex stack"); dx1 = s[0]; dx2 = s[1]; dy2 = s[2]; dx3 = s[3]; dx4 = s[4]; dx5 = s[5]; dx6 = s[6]; stbtt__csctx_rccurve_to(c, dx1, 0, dx2, dy2, dx3, 0); stbtt__csctx_rccurve_to(c, dx4, 0, dx5, -dy2, dx6, 0); break; case 0x23: // flex if (sp < 13) return STBTT__CSERR("flex stack"); dx1 = s[0]; dy1 = s[1]; dx2 = s[2]; dy2 = s[3]; dx3 = s[4]; dy3 = s[5]; dx4 = s[6]; dy4 = s[7]; dx5 = s[8]; dy5 = s[9]; dx6 = s[10]; dy6 = s[11]; //fd is s[12] stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); break; case 0x24: // hflex1 if (sp < 9) return STBTT__CSERR("hflex1 stack"); dx1 = s[0]; dy1 = s[1]; dx2 = s[2]; dy2 = s[3]; dx3 = s[4]; dx4 = s[5]; dx5 = s[6]; dy5 = s[7]; dx6 = s[8]; stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, 0); stbtt__csctx_rccurve_to(c, dx4, 0, dx5, dy5, dx6, -(dy1+dy2+dy5)); break; case 0x25: // flex1 if (sp < 11) return STBTT__CSERR("flex1 stack"); dx1 = s[0]; dy1 = s[1]; dx2 = s[2]; dy2 = s[3]; dx3 = s[4]; dy3 = s[5]; dx4 = s[6]; dy4 = s[7]; dx5 = s[8]; dy5 = s[9]; dx6 = dy6 = s[10]; dx = dx1+dx2+dx3+dx4+dx5; dy = dy1+dy2+dy3+dy4+dy5; if (STBTT_fabs(dx) > STBTT_fabs(dy)) dy6 = -dy; else dx6 = -dx; stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); break; default: return STBTT__CSERR("unimplemented"); } } break; default: if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254)) return STBTT__CSERR("reserved operator"); // push immediate if (b0 == 255) { f = (float)(stbtt_int32)stbtt__buf_get32(&b) / 0x10000; } else { stbtt__buf_skip(&b, -1); f = (float)(stbtt_int16)stbtt__cff_int(&b); } if (sp >= 48) return STBTT__CSERR("push stack overflow"); s[sp++] = f; clear_stack = 0; break; } if (clear_stack) sp = 0; } return STBTT__CSERR("no endchar"); #undef STBTT__CSERR } static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) { // runs the charstring twice, once to count and once to output (to avoid realloc) stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1); stbtt__csctx output_ctx = STBTT__CSCTX_INIT(0); if (stbtt__run_charstring(info, glyph_index, &count_ctx)) { *pvertices = (stbtt_vertex*)STBTT_malloc(count_ctx.num_vertices*sizeof(stbtt_vertex), info->userdata); output_ctx.pvertices = *pvertices; if (stbtt__run_charstring(info, glyph_index, &output_ctx)) { STBTT_assert(output_ctx.num_vertices == count_ctx.num_vertices); return output_ctx.num_vertices; } } *pvertices = NULL; return 0; } static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) { stbtt__csctx c = STBTT__CSCTX_INIT(1); int r = stbtt__run_charstring(info, glyph_index, &c); if (x0) *x0 = r ? c.min_x : 0; if (y0) *y0 = r ? c.min_y : 0; if (x1) *x1 = r ? c.max_x : 0; if (y1) *y1 = r ? c.max_y : 0; return r ? c.num_vertices : 0; } STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) { if (!info->cff.size) return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices); else return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices); } STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing) { stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34); if (glyph_index < numOfLongHorMetrics) { if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*glyph_index); if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*glyph_index + 2); } else { if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1)); if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics)); } } static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) { stbtt_uint8 *data = info->data + info->kern; stbtt_uint32 needle, straw; int l, r, m; // we only look at the first table. it must be 'horizontal' and format 0. if (!info->kern) return 0; if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 return 0; if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format return 0; l = 0; r = ttUSHORT(data+10) - 1; needle = glyph1 << 16 | glyph2; while (l <= r) { m = (l + r) >> 1; straw = ttULONG(data+18+(m*6)); // note: unaligned read if (needle < straw) r = m - 1; else if (needle > straw) l = m + 1; else return ttSHORT(data+22+(m*6)); } return 0; } static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph) { stbtt_uint16 coverageFormat = ttUSHORT(coverageTable); switch(coverageFormat) { case 1: { stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2); // Binary search. stbtt_int32 l=0, r=glyphCount-1, m; int straw, needle=glyph; while (l <= r) { stbtt_uint8 *glyphArray = coverageTable + 4; stbtt_uint16 glyphID; m = (l + r) >> 1; glyphID = ttUSHORT(glyphArray + 2 * m); straw = glyphID; if (needle < straw) r = m - 1; else if (needle > straw) l = m + 1; else { return m; } } } break; case 2: { stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2); stbtt_uint8 *rangeArray = coverageTable + 4; // Binary search. stbtt_int32 l=0, r=rangeCount-1, m; int strawStart, strawEnd, needle=glyph; while (l <= r) { stbtt_uint8 *rangeRecord; m = (l + r) >> 1; rangeRecord = rangeArray + 6 * m; strawStart = ttUSHORT(rangeRecord); strawEnd = ttUSHORT(rangeRecord + 2); if (needle < strawStart) r = m - 1; else if (needle > strawEnd) l = m + 1; else { stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4); return startCoverageIndex + glyph - strawStart; } } } break; default: { // There are no other cases. STBTT_assert(0); } break; } return -1; } static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph) { stbtt_uint16 classDefFormat = ttUSHORT(classDefTable); switch(classDefFormat) { case 1: { stbtt_uint16 startGlyphID = ttUSHORT(classDefTable + 2); stbtt_uint16 glyphCount = ttUSHORT(classDefTable + 4); stbtt_uint8 *classDef1ValueArray = classDefTable + 6; if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount) return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID)); classDefTable = classDef1ValueArray + 2 * glyphCount; } break; case 2: { stbtt_uint16 classRangeCount = ttUSHORT(classDefTable + 2); stbtt_uint8 *classRangeRecords = classDefTable + 4; // Binary search. stbtt_int32 l=0, r=classRangeCount-1, m; int strawStart, strawEnd, needle=glyph; while (l <= r) { stbtt_uint8 *classRangeRecord; m = (l + r) >> 1; classRangeRecord = classRangeRecords + 6 * m; strawStart = ttUSHORT(classRangeRecord); strawEnd = ttUSHORT(classRangeRecord + 2); if (needle < strawStart) r = m - 1; else if (needle > strawEnd) l = m + 1; else return (stbtt_int32)ttUSHORT(classRangeRecord + 4); } classDefTable = classRangeRecords + 6 * classRangeCount; } break; default: { // There are no other cases. STBTT_assert(0); } break; } return -1; } // Define to STBTT_assert(x) if you want to break on unimplemented formats. #define STBTT_GPOS_TODO_assert(x) static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) { stbtt_uint16 lookupListOffset; stbtt_uint8 *lookupList; stbtt_uint16 lookupCount; stbtt_uint8 *data; stbtt_int32 i; if (!info->gpos) return 0; data = info->data + info->gpos; if (ttUSHORT(data+0) != 1) return 0; // Major version 1 if (ttUSHORT(data+2) != 0) return 0; // Minor version 0 lookupListOffset = ttUSHORT(data+8); lookupList = data + lookupListOffset; lookupCount = ttUSHORT(lookupList); for (i=0; i> 1; pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m; secondGlyph = ttUSHORT(pairValue); straw = secondGlyph; if (needle < straw) r = m - 1; else if (needle > straw) l = m + 1; else { stbtt_int16 xAdvance = ttSHORT(pairValue + 2); return xAdvance; } } } break; case 2: { stbtt_uint16 valueFormat1 = ttUSHORT(table + 4); stbtt_uint16 valueFormat2 = ttUSHORT(table + 6); stbtt_uint16 classDef1Offset = ttUSHORT(table + 8); stbtt_uint16 classDef2Offset = ttUSHORT(table + 10); int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1); int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2); stbtt_uint16 class1Count = ttUSHORT(table + 12); stbtt_uint16 class2Count = ttUSHORT(table + 14); STBTT_assert(glyph1class < class1Count); STBTT_assert(glyph2class < class2Count); // TODO: Support more formats. STBTT_GPOS_TODO_assert(valueFormat1 == 4); if (valueFormat1 != 4) return 0; STBTT_GPOS_TODO_assert(valueFormat2 == 0); if (valueFormat2 != 0) return 0; if (glyph1class >= 0 && glyph1class < class1Count && glyph2class >= 0 && glyph2class < class2Count) { stbtt_uint8 *class1Records = table + 16; stbtt_uint8 *class2Records = class1Records + 2 * (glyph1class * class2Count); stbtt_int16 xAdvance = ttSHORT(class2Records + 2 * glyph2class); return xAdvance; } } break; default: { // There are no other cases. STBTT_assert(0); break; }; } } break; }; default: // TODO: Implement other stuff. break; } } return 0; } STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int g2) { int xAdvance = 0; if (info->gpos) xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2); if (info->kern) xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2); return xAdvance; } STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2) { if (!info->kern && !info->gpos) // if no kerning table, don't waste time looking up both codepoint->glyphs return 0; return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2)); } STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing) { stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing); } STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap) { if (ascent ) *ascent = ttSHORT(info->data+info->hhea + 4); if (descent) *descent = ttSHORT(info->data+info->hhea + 6); if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8); } STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap) { int tab = stbtt__find_table(info->data, info->fontstart, "OS/2"); if (!tab) return 0; if (typoAscent ) *typoAscent = ttSHORT(info->data+tab + 68); if (typoDescent) *typoDescent = ttSHORT(info->data+tab + 70); if (typoLineGap) *typoLineGap = ttSHORT(info->data+tab + 72); return 1; } STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1) { *x0 = ttSHORT(info->data + info->head + 36); *y0 = ttSHORT(info->data + info->head + 38); *x1 = ttSHORT(info->data + info->head + 40); *y1 = ttSHORT(info->data + info->head + 42); } STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height) { int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6); return (float) height / fheight; } STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels) { int unitsPerEm = ttUSHORT(info->data + info->head + 18); return pixels / unitsPerEm; } STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v) { STBTT_free(v, info->userdata); } ////////////////////////////////////////////////////////////////////////////// // // antialiasing software rasterizer // STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) { int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) { // e.g. space character if (ix0) *ix0 = 0; if (iy0) *iy0 = 0; if (ix1) *ix1 = 0; if (iy1) *iy1 = 0; } else { // move to integral bboxes (treating pixels as little squares, what pixels get touched)? if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x); if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y); if (ix1) *ix1 = STBTT_iceil ( x1 * scale_x + shift_x); if (iy1) *iy1 = STBTT_iceil (-y0 * scale_y + shift_y); } } STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) { stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1); } STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) { stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1); } STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) { stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1); } ////////////////////////////////////////////////////////////////////////////// // // Rasterizer typedef struct stbtt__hheap_chunk { struct stbtt__hheap_chunk *next; } stbtt__hheap_chunk; typedef struct stbtt__hheap { struct stbtt__hheap_chunk *head; void *first_free; int num_remaining_in_head_chunk; } stbtt__hheap; static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata) { if (hh->first_free) { void *p = hh->first_free; hh->first_free = * (void **) p; return p; } else { if (hh->num_remaining_in_head_chunk == 0) { int count = (size < 32 ? 2000 : size < 128 ? 800 : 100); stbtt__hheap_chunk *c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata); if (c == NULL) return NULL; c->next = hh->head; hh->head = c; hh->num_remaining_in_head_chunk = count; } --hh->num_remaining_in_head_chunk; return (char *) (hh->head) + sizeof(stbtt__hheap_chunk) + size * hh->num_remaining_in_head_chunk; } } static void stbtt__hheap_free(stbtt__hheap *hh, void *p) { *(void **) p = hh->first_free; hh->first_free = p; } static void stbtt__hheap_cleanup(stbtt__hheap *hh, void *userdata) { stbtt__hheap_chunk *c = hh->head; while (c) { stbtt__hheap_chunk *n = c->next; STBTT_free(c, userdata); c = n; } } typedef struct stbtt__edge { float x0,y0, x1,y1; int invert; } stbtt__edge; typedef struct stbtt__active_edge { struct stbtt__active_edge *next; #if STBTT_RASTERIZER_VERSION==1 int x,dx; float ey; int direction; #elif STBTT_RASTERIZER_VERSION==2 float fx,fdx,fdy; float direction; float sy; float ey; #else #error "Unrecognized value of STBTT_RASTERIZER_VERSION" #endif } stbtt__active_edge; #if STBTT_RASTERIZER_VERSION == 1 #define STBTT_FIXSHIFT 10 #define STBTT_FIX (1 << STBTT_FIXSHIFT) #define STBTT_FIXMASK (STBTT_FIX-1) static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) { stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); STBTT_assert(z != NULL); if (!z) return z; // round dx down to avoid overshooting if (dxdy < 0) z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy); else z->dx = STBTT_ifloor(STBTT_FIX * dxdy); z->x = STBTT_ifloor(STBTT_FIX * e->x0 + z->dx * (start_point - e->y0)); // use z->dx so when we offset later it's by the same amount z->x -= off_x * STBTT_FIX; z->ey = e->y1; z->next = 0; z->direction = e->invert ? 1 : -1; return z; } #elif STBTT_RASTERIZER_VERSION == 2 static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) { stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); STBTT_assert(z != NULL); //STBTT_assert(e->y0 <= start_point); if (!z) return z; z->fdx = dxdy; z->fdy = dxdy != 0.0f ? (1.0f/dxdy) : 0.0f; z->fx = e->x0 + dxdy * (start_point - e->y0); z->fx -= off_x; z->direction = e->invert ? 1.0f : -1.0f; z->sy = e->y0; z->ey = e->y1; z->next = 0; return z; } #else #error "Unrecognized value of STBTT_RASTERIZER_VERSION" #endif #if STBTT_RASTERIZER_VERSION == 1 // note: this routine clips fills that extend off the edges... ideally this // wouldn't happen, but it could happen if the truetype glyph bounding boxes // are wrong, or if the user supplies a too-small bitmap static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__active_edge *e, int max_weight) { // non-zero winding fill int x0=0, w=0; while (e) { if (w == 0) { // if we're currently at zero, we need to record the edge start point x0 = e->x; w += e->direction; } else { int x1 = e->x; w += e->direction; // if we went to zero, we need to draw if (w == 0) { int i = x0 >> STBTT_FIXSHIFT; int j = x1 >> STBTT_FIXSHIFT; if (i < len && j >= 0) { if (i == j) { // x0,x1 are the same pixel, so compute combined coverage scanline[i] = scanline[i] + (stbtt_uint8) ((x1 - x0) * max_weight >> STBTT_FIXSHIFT); } else { if (i >= 0) // add antialiasing for x0 scanline[i] = scanline[i] + (stbtt_uint8) (((STBTT_FIX - (x0 & STBTT_FIXMASK)) * max_weight) >> STBTT_FIXSHIFT); else i = -1; // clip if (j < len) // add antialiasing for x1 scanline[j] = scanline[j] + (stbtt_uint8) (((x1 & STBTT_FIXMASK) * max_weight) >> STBTT_FIXSHIFT); else j = len; // clip for (++i; i < j; ++i) // fill pixels between x0 and x1 scanline[i] = scanline[i] + (stbtt_uint8) max_weight; } } } } e = e->next; } } static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) { stbtt__hheap hh = { 0, 0, 0 }; stbtt__active_edge *active = NULL; int y,j=0; int max_weight = (255 / vsubsample); // weight per vertical scanline int s; // vertical subsample index unsigned char scanline_data[512], *scanline; if (result->w > 512) scanline = (unsigned char *) STBTT_malloc(result->w, userdata); else scanline = scanline_data; y = off_y * vsubsample; e[n].y0 = (off_y + result->h) * (float) vsubsample + 1; while (j < result->h) { STBTT_memset(scanline, 0, result->w); for (s=0; s < vsubsample; ++s) { // find center of pixel for this scanline float scan_y = y + 0.5f; stbtt__active_edge **step = &active; // update all active edges; // remove all active edges that terminate before the center of this scanline while (*step) { stbtt__active_edge * z = *step; if (z->ey <= scan_y) { *step = z->next; // delete from list STBTT_assert(z->direction); z->direction = 0; stbtt__hheap_free(&hh, z); } else { z->x += z->dx; // advance to position for current scanline step = &((*step)->next); // advance through list } } // resort the list if needed for(;;) { int changed=0; step = &active; while (*step && (*step)->next) { if ((*step)->x > (*step)->next->x) { stbtt__active_edge *t = *step; stbtt__active_edge *q = t->next; t->next = q->next; q->next = t; *step = q; changed = 1; } step = &(*step)->next; } if (!changed) break; } // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline while (e->y0 <= scan_y) { if (e->y1 > scan_y) { stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y, userdata); if (z != NULL) { // find insertion point if (active == NULL) active = z; else if (z->x < active->x) { // insert at front z->next = active; active = z; } else { // find thing to insert AFTER stbtt__active_edge *p = active; while (p->next && p->next->x < z->x) p = p->next; // at this point, p->next->x is NOT < z->x z->next = p->next; p->next = z; } } } ++e; } // now process all active edges in XOR fashion if (active) stbtt__fill_active_edges(scanline, result->w, active, max_weight); ++y; } STBTT_memcpy(result->pixels + j * result->stride, scanline, result->w); ++j; } stbtt__hheap_cleanup(&hh, userdata); if (scanline != scanline_data) STBTT_free(scanline, userdata); } #elif STBTT_RASTERIZER_VERSION == 2 // the edge passed in here does not cross the vertical line at x or the vertical line at x+1 // (i.e. it has already been clipped to those) static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1) { if (y0 == y1) return; STBTT_assert(y0 < y1); STBTT_assert(e->sy <= e->ey); if (y0 > e->ey) return; if (y1 < e->sy) return; if (y0 < e->sy) { x0 += (x1-x0) * (e->sy - y0) / (y1-y0); y0 = e->sy; } if (y1 > e->ey) { x1 += (x1-x0) * (e->ey - y1) / (y1-y0); y1 = e->ey; } if (x0 == x) STBTT_assert(x1 <= x+1); else if (x0 == x+1) STBTT_assert(x1 >= x); else if (x0 <= x) STBTT_assert(x1 <= x); else if (x0 >= x+1) STBTT_assert(x1 >= x+1); else STBTT_assert(x1 >= x && x1 <= x+1); if (x0 <= x && x1 <= x) scanline[x] += e->direction * (y1-y0); else if (x0 >= x+1 && x1 >= x+1) ; else { STBTT_assert(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1); scanline[x] += e->direction * (y1-y0) * (1-((x0-x)+(x1-x))/2); // coverage = 1 - average x position } } static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, int len, stbtt__active_edge *e, float y_top) { float y_bottom = y_top+1; while (e) { // brute force every pixel // compute intersection points with top & bottom STBTT_assert(e->ey >= y_top); if (e->fdx == 0) { float x0 = e->fx; if (x0 < len) { if (x0 >= 0) { stbtt__handle_clipped_edge(scanline,(int) x0,e, x0,y_top, x0,y_bottom); stbtt__handle_clipped_edge(scanline_fill-1,(int) x0+1,e, x0,y_top, x0,y_bottom); } else { stbtt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom); } } } else { float x0 = e->fx; float dx = e->fdx; float xb = x0 + dx; float x_top, x_bottom; float sy0,sy1; float dy = e->fdy; STBTT_assert(e->sy <= y_bottom && e->ey >= y_top); // compute endpoints of line segment clipped to this scanline (if the // line segment starts on this scanline. x0 is the intersection of the // line with y_top, but that may be off the line segment. if (e->sy > y_top) { x_top = x0 + dx * (e->sy - y_top); sy0 = e->sy; } else { x_top = x0; sy0 = y_top; } if (e->ey < y_bottom) { x_bottom = x0 + dx * (e->ey - y_top); sy1 = e->ey; } else { x_bottom = xb; sy1 = y_bottom; } if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) { // from here on, we don't have to range check x values if ((int) x_top == (int) x_bottom) { float height; // simple case, only spans one pixel int x = (int) x_top; height = sy1 - sy0; STBTT_assert(x >= 0 && x < len); scanline[x] += e->direction * (1-((x_top - x) + (x_bottom-x))/2) * height; scanline_fill[x] += e->direction * height; // everything right of this pixel is filled } else { int x,x1,x2; float y_crossing, step, sign, area; // covers 2+ pixels if (x_top > x_bottom) { // flip scanline vertically; signed area is the same float t; sy0 = y_bottom - (sy0 - y_top); sy1 = y_bottom - (sy1 - y_top); t = sy0, sy0 = sy1, sy1 = t; t = x_bottom, x_bottom = x_top, x_top = t; dx = -dx; dy = -dy; t = x0, x0 = xb, xb = t; } x1 = (int) x_top; x2 = (int) x_bottom; // compute intersection with y axis at x1+1 y_crossing = (x1+1 - x0) * dy + y_top; sign = e->direction; // area of the rectangle covered from y0..y_crossing area = sign * (y_crossing-sy0); // area of the triangle (x_top,y0), (x+1,y0), (x+1,y_crossing) scanline[x1] += area * (1-((x_top - x1)+(x1+1-x1))/2); step = sign * dy; for (x = x1+1; x < x2; ++x) { scanline[x] += area + step/2; area += step; } y_crossing += dy * (x2 - (x1+1)); STBTT_assert(STBTT_fabs(area) <= 1.01f); scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing); scanline_fill[x2] += sign * (sy1-sy0); } } else { // if edge goes outside of box we're drawing, we require // clipping logic. since this does not match the intended use // of this library, we use a different, very slow brute // force implementation int x; for (x=0; x < len; ++x) { // cases: // // there can be up to two intersections with the pixel. any intersection // with left or right edges can be handled by splitting into two (or three) // regions. intersections with top & bottom do not necessitate case-wise logic. // // the old way of doing this found the intersections with the left & right edges, // then used some simple logic to produce up to three segments in sorted order // from top-to-bottom. however, this had a problem: if an x edge was epsilon // across the x border, then the corresponding y position might not be distinct // from the other y segment, and it might ignored as an empty segment. to avoid // that, we need to explicitly produce segments based on x positions. // rename variables to clearly-defined pairs float y0 = y_top; float x1 = (float) (x); float x2 = (float) (x+1); float x3 = xb; float y3 = y_bottom; // x = e->x + e->dx * (y-y_top) // (y-y_top) = (x - e->x) / e->dx // y = (x - e->x) / e->dx + y_top float y1 = (x - x0) / dx + y_top; float y2 = (x+1 - x0) / dx + y_top; if (x0 < x1 && x3 > x2) { // three segments descending down-right stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x2,y2); stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); } else if (x3 < x1 && x0 > x2) { // three segments descending down-left stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x1,y1); stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); } else if (x0 < x1 && x3 > x1) { // two segments across x, down-right stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); } else if (x3 < x1 && x0 > x1) { // two segments across x, down-left stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); } else if (x0 < x2 && x3 > x2) { // two segments across x+1, down-right stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); } else if (x3 < x2 && x0 > x2) { // two segments across x+1, down-left stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); } else { // one segment stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x3,y3); } } } } e = e->next; } } // directly AA rasterize edges w/o supersampling static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) { stbtt__hheap hh = { 0, 0, 0 }; stbtt__active_edge *active = NULL; int y,j=0, i; float scanline_data[129], *scanline, *scanline2; STBTT__NOTUSED(vsubsample); if (result->w > 64) scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata); else scanline = scanline_data; scanline2 = scanline + result->w; y = off_y; e[n].y0 = (float) (off_y + result->h) + 1; while (j < result->h) { // find center of pixel for this scanline float scan_y_top = y + 0.0f; float scan_y_bottom = y + 1.0f; stbtt__active_edge **step = &active; STBTT_memset(scanline , 0, result->w*sizeof(scanline[0])); STBTT_memset(scanline2, 0, (result->w+1)*sizeof(scanline[0])); // update all active edges; // remove all active edges that terminate before the top of this scanline while (*step) { stbtt__active_edge * z = *step; if (z->ey <= scan_y_top) { *step = z->next; // delete from list STBTT_assert(z->direction); z->direction = 0; stbtt__hheap_free(&hh, z); } else { step = &((*step)->next); // advance through list } } // insert all edges that start before the bottom of this scanline while (e->y0 <= scan_y_bottom) { if (e->y0 != e->y1) { stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata); if (z != NULL) { STBTT_assert(z->ey >= scan_y_top); // insert at front z->next = active; active = z; } } ++e; } // now process all active edges if (active) stbtt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top); { float sum = 0; for (i=0; i < result->w; ++i) { float k; int m; sum += scanline2[i]; k = scanline[i] + sum; k = (float) STBTT_fabs(k)*255 + 0.5f; m = (int) k; if (m > 255) m = 255; result->pixels[j*result->stride + i] = (unsigned char) m; } } // advance all the edges step = &active; while (*step) { stbtt__active_edge *z = *step; z->fx += z->fdx; // advance to position for current scanline step = &((*step)->next); // advance through list } ++y; ++j; } stbtt__hheap_cleanup(&hh, userdata); if (scanline != scanline_data) STBTT_free(scanline, userdata); } #else #error "Unrecognized value of STBTT_RASTERIZER_VERSION" #endif #define STBTT__COMPARE(a,b) ((a)->y0 < (b)->y0) static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n) { int i,j; for (i=1; i < n; ++i) { stbtt__edge t = p[i], *a = &t; j = i; while (j > 0) { stbtt__edge *b = &p[j-1]; int c = STBTT__COMPARE(a,b); if (!c) break; p[j] = p[j-1]; --j; } if (i != j) p[j] = t; } } static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n) { /* threshhold for transitioning to insertion sort */ while (n > 12) { stbtt__edge t; int c01,c12,c,m,i,j; /* compute median of three */ m = n >> 1; c01 = STBTT__COMPARE(&p[0],&p[m]); c12 = STBTT__COMPARE(&p[m],&p[n-1]); /* if 0 >= mid >= end, or 0 < mid < end, then use mid */ if (c01 != c12) { /* otherwise, we'll need to swap something else to middle */ int z; c = STBTT__COMPARE(&p[0],&p[n-1]); /* 0>mid && midn => n; 0 0 */ /* 0n: 0>n => 0; 0 n */ z = (c == c12) ? 0 : n-1; t = p[z]; p[z] = p[m]; p[m] = t; } /* now p[m] is the median-of-three */ /* swap it to the beginning so it won't move around */ t = p[0]; p[0] = p[m]; p[m] = t; /* partition loop */ i=1; j=n-1; for(;;) { /* handling of equality is crucial here */ /* for sentinels & efficiency with duplicates */ for (;;++i) { if (!STBTT__COMPARE(&p[i], &p[0])) break; } for (;;--j) { if (!STBTT__COMPARE(&p[0], &p[j])) break; } /* make sure we haven't crossed */ if (i >= j) break; t = p[i]; p[i] = p[j]; p[j] = t; ++i; --j; } /* recurse on smaller side, iterate on larger */ if (j < (n-i)) { stbtt__sort_edges_quicksort(p,j); p = p+i; n = n-i; } else { stbtt__sort_edges_quicksort(p+i, n-i); n = j; } } } static void stbtt__sort_edges(stbtt__edge *p, int n) { stbtt__sort_edges_quicksort(p, n); stbtt__sort_edges_ins_sort(p, n); } typedef struct { float x,y; } stbtt__point; static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert, void *userdata) { float y_scale_inv = invert ? -scale_y : scale_y; stbtt__edge *e; int n,i,j,k,m; #if STBTT_RASTERIZER_VERSION == 1 int vsubsample = result->h < 8 ? 15 : 5; #elif STBTT_RASTERIZER_VERSION == 2 int vsubsample = 1; #else #error "Unrecognized value of STBTT_RASTERIZER_VERSION" #endif // vsubsample should divide 255 evenly; otherwise we won't reach full opacity // now we have to blow out the windings into explicit edge lists n = 0; for (i=0; i < windings; ++i) n += wcount[i]; e = (stbtt__edge *) STBTT_malloc(sizeof(*e) * (n+1), userdata); // add an extra one as a sentinel if (e == 0) return; n = 0; m=0; for (i=0; i < windings; ++i) { stbtt__point *p = pts + m; m += wcount[i]; j = wcount[i]-1; for (k=0; k < wcount[i]; j=k++) { int a=k,b=j; // skip the edge if horizontal if (p[j].y == p[k].y) continue; // add edge from j to k to the list e[n].invert = 0; if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) { e[n].invert = 1; a=j,b=k; } e[n].x0 = p[a].x * scale_x + shift_x; e[n].y0 = (p[a].y * y_scale_inv + shift_y) * vsubsample; e[n].x1 = p[b].x * scale_x + shift_x; e[n].y1 = (p[b].y * y_scale_inv + shift_y) * vsubsample; ++n; } } // now sort the edges by their highest point (should snap to integer, and then by x) //STBTT_sort(e, n, sizeof(e[0]), stbtt__edge_compare); stbtt__sort_edges(e, n); // now, traverse the scanlines and find the intersections on each scanline, use xor winding rule stbtt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, userdata); STBTT_free(e, userdata); } static void stbtt__add_point(stbtt__point *points, int n, float x, float y) { if (!points) return; // during first pass, it's unallocated points[n].x = x; points[n].y = y; } // tesselate until threshhold p is happy... @TODO warped to compensate for non-linear stretching static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n) { // midpoint float mx = (x0 + 2*x1 + x2)/4; float my = (y0 + 2*y1 + y2)/4; // versus directly drawn line float dx = (x0+x2)/2 - mx; float dy = (y0+y2)/2 - my; if (n > 16) // 65536 segments on one curve better be enough! return 1; if (dx*dx+dy*dy > objspace_flatness_squared) { // half-pixel error allowed... need to be smaller if AA stbtt__tesselate_curve(points, num_points, x0,y0, (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1); stbtt__tesselate_curve(points, num_points, mx,my, (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1); } else { stbtt__add_point(points, *num_points,x2,y2); *num_points = *num_points+1; } return 1; } static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n) { // @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough float dx0 = x1-x0; float dy0 = y1-y0; float dx1 = x2-x1; float dy1 = y2-y1; float dx2 = x3-x2; float dy2 = y3-y2; float dx = x3-x0; float dy = y3-y0; float longlen = (float) (STBTT_sqrt(dx0*dx0+dy0*dy0)+STBTT_sqrt(dx1*dx1+dy1*dy1)+STBTT_sqrt(dx2*dx2+dy2*dy2)); float shortlen = (float) STBTT_sqrt(dx*dx+dy*dy); float flatness_squared = longlen*longlen-shortlen*shortlen; if (n > 16) // 65536 segments on one curve better be enough! return; if (flatness_squared > objspace_flatness_squared) { float x01 = (x0+x1)/2; float y01 = (y0+y1)/2; float x12 = (x1+x2)/2; float y12 = (y1+y2)/2; float x23 = (x2+x3)/2; float y23 = (y2+y3)/2; float xa = (x01+x12)/2; float ya = (y01+y12)/2; float xb = (x12+x23)/2; float yb = (y12+y23)/2; float mx = (xa+xb)/2; float my = (ya+yb)/2; stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1); stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1); } else { stbtt__add_point(points, *num_points,x3,y3); *num_points = *num_points+1; } } // returns number of contours static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata) { stbtt__point *points=0; int num_points=0; float objspace_flatness_squared = objspace_flatness * objspace_flatness; int i,n=0,start=0, pass; // count how many "moves" there are to get the contour count for (i=0; i < num_verts; ++i) if (vertices[i].type == STBTT_vmove) ++n; *num_contours = n; if (n == 0) return 0; *contour_lengths = (int *) STBTT_malloc(sizeof(**contour_lengths) * n, userdata); if (*contour_lengths == 0) { *num_contours = 0; return 0; } // make two passes through the points so we don't need to realloc for (pass=0; pass < 2; ++pass) { float x=0,y=0; if (pass == 1) { points = (stbtt__point *) STBTT_malloc(num_points * sizeof(points[0]), userdata); if (points == NULL) goto error; } num_points = 0; n= -1; for (i=0; i < num_verts; ++i) { switch (vertices[i].type) { case STBTT_vmove: // start the next contour if (n >= 0) (*contour_lengths)[n] = num_points - start; ++n; start = num_points; x = vertices[i].x, y = vertices[i].y; stbtt__add_point(points, num_points++, x,y); break; case STBTT_vline: x = vertices[i].x, y = vertices[i].y; stbtt__add_point(points, num_points++, x, y); break; case STBTT_vcurve: stbtt__tesselate_curve(points, &num_points, x,y, vertices[i].cx, vertices[i].cy, vertices[i].x, vertices[i].y, objspace_flatness_squared, 0); x = vertices[i].x, y = vertices[i].y; break; case STBTT_vcubic: stbtt__tesselate_cubic(points, &num_points, x,y, vertices[i].cx, vertices[i].cy, vertices[i].cx1, vertices[i].cy1, vertices[i].x, vertices[i].y, objspace_flatness_squared, 0); x = vertices[i].x, y = vertices[i].y; break; } } (*contour_lengths)[n] = num_points - start; } return points; error: STBTT_free(points, userdata); STBTT_free(*contour_lengths, userdata); *contour_lengths = 0; *num_contours = 0; return NULL; } STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata) { float scale = scale_x > scale_y ? scale_y : scale_x; int winding_count = 0; int *winding_lengths = NULL; stbtt__point *windings = stbtt_FlattenCurves(vertices, num_verts, flatness_in_pixels / scale, &winding_lengths, &winding_count, userdata); if (windings) { stbtt__rasterize(result, windings, winding_lengths, winding_count, scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, userdata); STBTT_free(winding_lengths, userdata); STBTT_free(windings, userdata); } } STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata) { STBTT_free(bitmap, userdata); } STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff) { int ix0,iy0,ix1,iy1; stbtt__bitmap gbm; stbtt_vertex *vertices; int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); if (scale_x == 0) scale_x = scale_y; if (scale_y == 0) { if (scale_x == 0) { STBTT_free(vertices, info->userdata); return NULL; } scale_y = scale_x; } stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,&ix1,&iy1); // now we get the size gbm.w = (ix1 - ix0); gbm.h = (iy1 - iy0); gbm.pixels = NULL; // in case we error if (width ) *width = gbm.w; if (height) *height = gbm.h; if (xoff ) *xoff = ix0; if (yoff ) *yoff = iy0; if (gbm.w && gbm.h) { gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata); if (gbm.pixels) { gbm.stride = gbm.w; stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0, iy0, 1, info->userdata); } } STBTT_free(vertices, info->userdata); return gbm.pixels; } STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff); } STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph) { int ix0,iy0; stbtt_vertex *vertices; int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); stbtt__bitmap gbm; stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0); gbm.pixels = output; gbm.w = out_w; gbm.h = out_h; gbm.stride = out_stride; if (gbm.w && gbm.h) stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0,iy0, 1, info->userdata); STBTT_free(vertices, info->userdata); } STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph) { stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph); } STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff); } STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint) { stbtt_MakeGlyphBitmapSubpixelPrefilter(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, oversample_x, oversample_y, sub_x, sub_y, stbtt_FindGlyphIndex(info,codepoint)); } STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint) { stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint)); } STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff); } STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint) { stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint); } ////////////////////////////////////////////////////////////////////////////// // // bitmap baking // // This is SUPER-CRAPPY packing to keep source code small static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) float pixel_height, // height of font in pixels unsigned char *pixels, int pw, int ph, // bitmap to be filled in int first_char, int num_chars, // characters to bake stbtt_bakedchar *chardata) { float scale; int x,y,bottom_y, i; stbtt_fontinfo f; f.userdata = NULL; if (!stbtt_InitFont(&f, data, offset)) return -1; STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels x=y=1; bottom_y = 1; scale = stbtt_ScaleForPixelHeight(&f, pixel_height); for (i=0; i < num_chars; ++i) { int advance, lsb, x0,y0,x1,y1,gw,gh; int g = stbtt_FindGlyphIndex(&f, first_char + i); stbtt_GetGlyphHMetrics(&f, g, &advance, &lsb); stbtt_GetGlyphBitmapBox(&f, g, scale,scale, &x0,&y0,&x1,&y1); gw = x1-x0; gh = y1-y0; if (x + gw + 1 >= pw) y = bottom_y, x = 1; // advance to next row if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row return -i; STBTT_assert(x+gw < pw); STBTT_assert(y+gh < ph); stbtt_MakeGlyphBitmap(&f, pixels+x+y*pw, gw,gh,pw, scale,scale, g); chardata[i].x0 = (stbtt_int16) x; chardata[i].y0 = (stbtt_int16) y; chardata[i].x1 = (stbtt_int16) (x + gw); chardata[i].y1 = (stbtt_int16) (y + gh); chardata[i].xadvance = scale * advance; chardata[i].xoff = (float) x0; chardata[i].yoff = (float) y0; x = x + gw + 1; if (y+gh+1 > bottom_y) bottom_y = y+gh+1; } return bottom_y; } STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) { float d3d_bias = opengl_fillrule ? 0 : -0.5f; float ipw = 1.0f / pw, iph = 1.0f / ph; const stbtt_bakedchar *b = chardata + char_index; int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f); int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f); q->x0 = round_x + d3d_bias; q->y0 = round_y + d3d_bias; q->x1 = round_x + b->x1 - b->x0 + d3d_bias; q->y1 = round_y + b->y1 - b->y0 + d3d_bias; q->s0 = b->x0 * ipw; q->t0 = b->y0 * iph; q->s1 = b->x1 * ipw; q->t1 = b->y1 * iph; *xpos += b->xadvance; } ////////////////////////////////////////////////////////////////////////////// // // rectangle packing replacement routines if you don't have stb_rect_pack.h // #ifndef STB_RECT_PACK_VERSION typedef int stbrp_coord; //////////////////////////////////////////////////////////////////////////////////// // // // // // COMPILER WARNING ?!?!? // // // // // // if you get a compile warning due to these symbols being defined more than // // once, move #include "stb_rect_pack.h" before #include "stb_truetype.h" // // // //////////////////////////////////////////////////////////////////////////////////// typedef struct { int width,height; int x,y,bottom_y; } stbrp_context; typedef struct { unsigned char x; } stbrp_node; struct stbrp_rect { stbrp_coord x,y; int id,w,h,was_packed; }; static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes) { con->width = pw; con->height = ph; con->x = 0; con->y = 0; con->bottom_y = 0; STBTT__NOTUSED(nodes); STBTT__NOTUSED(num_nodes); } static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects) { int i; for (i=0; i < num_rects; ++i) { if (con->x + rects[i].w > con->width) { con->x = 0; con->y = con->bottom_y; } if (con->y + rects[i].h > con->height) break; rects[i].x = con->x; rects[i].y = con->y; rects[i].was_packed = 1; con->x += rects[i].w; if (con->y + rects[i].h > con->bottom_y) con->bottom_y = con->y + rects[i].h; } for ( ; i < num_rects; ++i) rects[i].was_packed = 0; } #endif ////////////////////////////////////////////////////////////////////////////// // // bitmap baking // // This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If // stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy. STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context) { stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context); int num_nodes = pw - padding; stbrp_node *nodes = (stbrp_node *) STBTT_malloc(sizeof(*nodes ) * num_nodes,alloc_context); if (context == NULL || nodes == NULL) { if (context != NULL) STBTT_free(context, alloc_context); if (nodes != NULL) STBTT_free(nodes , alloc_context); return 0; } spc->user_allocator_context = alloc_context; spc->width = pw; spc->height = ph; spc->pixels = pixels; spc->pack_info = context; spc->nodes = nodes; spc->padding = padding; spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw; spc->h_oversample = 1; spc->v_oversample = 1; stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes); if (pixels) STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels return 1; } STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc) { STBTT_free(spc->nodes , spc->user_allocator_context); STBTT_free(spc->pack_info, spc->user_allocator_context); } STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample) { STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE); STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE); if (h_oversample <= STBTT_MAX_OVERSAMPLE) spc->h_oversample = h_oversample; if (v_oversample <= STBTT_MAX_OVERSAMPLE) spc->v_oversample = v_oversample; } #define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1) static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) { unsigned char buffer[STBTT_MAX_OVERSAMPLE]; int safe_w = w - kernel_width; int j; STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze for (j=0; j < h; ++j) { int i; unsigned int total; STBTT_memset(buffer, 0, kernel_width); total = 0; // make kernel_width a constant in common cases so compiler can optimize out the divide switch (kernel_width) { case 2: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / 2); } break; case 3: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / 3); } break; case 4: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / 4); } break; case 5: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / 5); } break; default: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / kernel_width); } break; } for (; i < w; ++i) { STBTT_assert(pixels[i] == 0); total -= buffer[i & STBTT__OVER_MASK]; pixels[i] = (unsigned char) (total / kernel_width); } pixels += stride_in_bytes; } } static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) { unsigned char buffer[STBTT_MAX_OVERSAMPLE]; int safe_h = h - kernel_width; int j; STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze for (j=0; j < w; ++j) { int i; unsigned int total; STBTT_memset(buffer, 0, kernel_width); total = 0; // make kernel_width a constant in common cases so compiler can optimize out the divide switch (kernel_width) { case 2: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / 2); } break; case 3: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / 3); } break; case 4: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / 4); } break; case 5: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / 5); } break; default: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); } break; } for (; i < h; ++i) { STBTT_assert(pixels[i*stride_in_bytes] == 0); total -= buffer[i & STBTT__OVER_MASK]; pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); } pixels += 1; } } static float stbtt__oversample_shift(int oversample) { if (!oversample) return 0.0f; // The prefilter is a box filter of width "oversample", // which shifts phase by (oversample - 1)/2 pixels in // oversampled space. We want to shift in the opposite // direction to counter this. return (float)-(oversample - 1) / (2.0f * (float)oversample); } // rects array must be big enough to accommodate all characters in the given ranges STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) { int i,j,k; k=0; for (i=0; i < num_ranges; ++i) { float fh = ranges[i].font_size; float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); ranges[i].h_oversample = (unsigned char) spc->h_oversample; ranges[i].v_oversample = (unsigned char) spc->v_oversample; for (j=0; j < ranges[i].num_chars; ++j) { int x0,y0,x1,y1; int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; int glyph = stbtt_FindGlyphIndex(info, codepoint); stbtt_GetGlyphBitmapBoxSubpixel(info,glyph, scale * spc->h_oversample, scale * spc->v_oversample, 0,0, &x0,&y0,&x1,&y1); rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1); rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1); ++k; } } return k; } STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int prefilter_x, int prefilter_y, float *sub_x, float *sub_y, int glyph) { stbtt_MakeGlyphBitmapSubpixel(info, output, out_w - (prefilter_x - 1), out_h - (prefilter_y - 1), out_stride, scale_x, scale_y, shift_x, shift_y, glyph); if (prefilter_x > 1) stbtt__h_prefilter(output, out_w, out_h, out_stride, prefilter_x); if (prefilter_y > 1) stbtt__v_prefilter(output, out_w, out_h, out_stride, prefilter_y); *sub_x = stbtt__oversample_shift(prefilter_x); *sub_y = stbtt__oversample_shift(prefilter_y); } // rects array must be big enough to accommodate all characters in the given ranges STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) { int i,j,k, return_value = 1; // save current values int old_h_over = spc->h_oversample; int old_v_over = spc->v_oversample; k = 0; for (i=0; i < num_ranges; ++i) { float fh = ranges[i].font_size; float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); float recip_h,recip_v,sub_x,sub_y; spc->h_oversample = ranges[i].h_oversample; spc->v_oversample = ranges[i].v_oversample; recip_h = 1.0f / spc->h_oversample; recip_v = 1.0f / spc->v_oversample; sub_x = stbtt__oversample_shift(spc->h_oversample); sub_y = stbtt__oversample_shift(spc->v_oversample); for (j=0; j < ranges[i].num_chars; ++j) { stbrp_rect *r = &rects[k]; if (r->was_packed) { stbtt_packedchar *bc = &ranges[i].chardata_for_range[j]; int advance, lsb, x0,y0,x1,y1; int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; int glyph = stbtt_FindGlyphIndex(info, codepoint); stbrp_coord pad = (stbrp_coord) spc->padding; // pad on left and top r->x += pad; r->y += pad; r->w -= pad; r->h -= pad; stbtt_GetGlyphHMetrics(info, glyph, &advance, &lsb); stbtt_GetGlyphBitmapBox(info, glyph, scale * spc->h_oversample, scale * spc->v_oversample, &x0,&y0,&x1,&y1); stbtt_MakeGlyphBitmapSubpixel(info, spc->pixels + r->x + r->y*spc->stride_in_bytes, r->w - spc->h_oversample+1, r->h - spc->v_oversample+1, spc->stride_in_bytes, scale * spc->h_oversample, scale * spc->v_oversample, 0,0, glyph); if (spc->h_oversample > 1) stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, r->w, r->h, spc->stride_in_bytes, spc->h_oversample); if (spc->v_oversample > 1) stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, r->w, r->h, spc->stride_in_bytes, spc->v_oversample); bc->x0 = (stbtt_int16) r->x; bc->y0 = (stbtt_int16) r->y; bc->x1 = (stbtt_int16) (r->x + r->w); bc->y1 = (stbtt_int16) (r->y + r->h); bc->xadvance = scale * advance; bc->xoff = (float) x0 * recip_h + sub_x; bc->yoff = (float) y0 * recip_v + sub_y; bc->xoff2 = (x0 + r->w) * recip_h + sub_x; bc->yoff2 = (y0 + r->h) * recip_v + sub_y; } else { return_value = 0; // if any fail, report failure } ++k; } } // restore original values spc->h_oversample = old_h_over; spc->v_oversample = old_v_over; return return_value; } STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects) { stbrp_pack_rects((stbrp_context *) spc->pack_info, rects, num_rects); } STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges) { stbtt_fontinfo info; int i,j,n, return_value = 1; //stbrp_context *context = (stbrp_context *) spc->pack_info; stbrp_rect *rects; // flag all characters as NOT packed for (i=0; i < num_ranges; ++i) for (j=0; j < ranges[i].num_chars; ++j) ranges[i].chardata_for_range[j].x0 = ranges[i].chardata_for_range[j].y0 = ranges[i].chardata_for_range[j].x1 = ranges[i].chardata_for_range[j].y1 = 0; n = 0; for (i=0; i < num_ranges; ++i) n += ranges[i].num_chars; rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context); if (rects == NULL) return 0; info.userdata = spc->user_allocator_context; stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index)); n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects); stbtt_PackFontRangesPackRects(spc, rects, n); return_value = stbtt_PackFontRangesRenderIntoRects(spc, &info, ranges, num_ranges, rects); STBTT_free(rects, spc->user_allocator_context); return return_value; } STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range) { stbtt_pack_range range; range.first_unicode_codepoint_in_range = first_unicode_codepoint_in_range; range.array_of_unicode_codepoints = NULL; range.num_chars = num_chars_in_range; range.chardata_for_range = chardata_for_range; range.font_size = font_size; return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1); } STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer) { float ipw = 1.0f / pw, iph = 1.0f / ph; const stbtt_packedchar *b = chardata + char_index; if (align_to_integer) { float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f); float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f); q->x0 = x; q->y0 = y; q->x1 = x + b->xoff2 - b->xoff; q->y1 = y + b->yoff2 - b->yoff; } else { q->x0 = *xpos + b->xoff; q->y0 = *ypos + b->yoff; q->x1 = *xpos + b->xoff2; q->y1 = *ypos + b->yoff2; } q->s0 = b->x0 * ipw; q->t0 = b->y0 * iph; q->s1 = b->x1 * ipw; q->t1 = b->y1 * iph; *xpos += b->xadvance; } ////////////////////////////////////////////////////////////////////////////// // // sdf computation // #define STBTT_min(a,b) ((a) < (b) ? (a) : (b)) #define STBTT_max(a,b) ((a) < (b) ? (b) : (a)) static int stbtt__ray_intersect_bezier(float orig[2], float ray[2], float q0[2], float q1[2], float q2[2], float hits[2][2]) { float q0perp = q0[1]*ray[0] - q0[0]*ray[1]; float q1perp = q1[1]*ray[0] - q1[0]*ray[1]; float q2perp = q2[1]*ray[0] - q2[0]*ray[1]; float roperp = orig[1]*ray[0] - orig[0]*ray[1]; float a = q0perp - 2*q1perp + q2perp; float b = q1perp - q0perp; float c = q0perp - roperp; float s0 = 0., s1 = 0.; int num_s = 0; if (a != 0.0) { float discr = b*b - a*c; if (discr > 0.0) { float rcpna = -1 / a; float d = (float) STBTT_sqrt(discr); s0 = (b+d) * rcpna; s1 = (b-d) * rcpna; if (s0 >= 0.0 && s0 <= 1.0) num_s = 1; if (d > 0.0 && s1 >= 0.0 && s1 <= 1.0) { if (num_s == 0) s0 = s1; ++num_s; } } } else { // 2*b*s + c = 0 // s = -c / (2*b) s0 = c / (-2 * b); if (s0 >= 0.0 && s0 <= 1.0) num_s = 1; } if (num_s == 0) return 0; else { float rcp_len2 = 1 / (ray[0]*ray[0] + ray[1]*ray[1]); float rayn_x = ray[0] * rcp_len2, rayn_y = ray[1] * rcp_len2; float q0d = q0[0]*rayn_x + q0[1]*rayn_y; float q1d = q1[0]*rayn_x + q1[1]*rayn_y; float q2d = q2[0]*rayn_x + q2[1]*rayn_y; float rod = orig[0]*rayn_x + orig[1]*rayn_y; float q10d = q1d - q0d; float q20d = q2d - q0d; float q0rd = q0d - rod; hits[0][0] = q0rd + s0*(2.0f - 2.0f*s0)*q10d + s0*s0*q20d; hits[0][1] = a*s0+b; if (num_s > 1) { hits[1][0] = q0rd + s1*(2.0f - 2.0f*s1)*q10d + s1*s1*q20d; hits[1][1] = a*s1+b; return 2; } else { return 1; } } } static int equal(float *a, float *b) { return (a[0] == b[0] && a[1] == b[1]); } static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex *verts) { int i; float orig[2], ray[2] = { 1, 0 }; float y_frac; int winding = 0; orig[0] = x; orig[1] = y; // make sure y never passes through a vertex of the shape y_frac = (float) STBTT_fmod(y, 1.0f); if (y_frac < 0.01f) y += 0.01f; else if (y_frac > 0.99f) y -= 0.01f; orig[1] = y; // test a ray from (-infinity,y) to (x,y) for (i=0; i < nverts; ++i) { if (verts[i].type == STBTT_vline) { int x0 = (int) verts[i-1].x, y0 = (int) verts[i-1].y; int x1 = (int) verts[i ].x, y1 = (int) verts[i ].y; if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; if (x_inter < x) winding += (y0 < y1) ? 1 : -1; } } if (verts[i].type == STBTT_vcurve) { int x0 = (int) verts[i-1].x , y0 = (int) verts[i-1].y ; int x1 = (int) verts[i ].cx, y1 = (int) verts[i ].cy; int x2 = (int) verts[i ].x , y2 = (int) verts[i ].y ; int ax = STBTT_min(x0,STBTT_min(x1,x2)), ay = STBTT_min(y0,STBTT_min(y1,y2)); int by = STBTT_max(y0,STBTT_max(y1,y2)); if (y > ay && y < by && x > ax) { float q0[2],q1[2],q2[2]; float hits[2][2]; q0[0] = (float)x0; q0[1] = (float)y0; q1[0] = (float)x1; q1[1] = (float)y1; q2[0] = (float)x2; q2[1] = (float)y2; if (equal(q0,q1) || equal(q1,q2)) { x0 = (int)verts[i-1].x; y0 = (int)verts[i-1].y; x1 = (int)verts[i ].x; y1 = (int)verts[i ].y; if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; if (x_inter < x) winding += (y0 < y1) ? 1 : -1; } } else { int num_hits = stbtt__ray_intersect_bezier(orig, ray, q0, q1, q2, hits); if (num_hits >= 1) if (hits[0][0] < 0) winding += (hits[0][1] < 0 ? -1 : 1); if (num_hits >= 2) if (hits[1][0] < 0) winding += (hits[1][1] < 0 ? -1 : 1); } } } } return winding; } static float stbtt__cuberoot( float x ) { if (x<0) return -(float) STBTT_pow(-x,1.0f/3.0f); else return (float) STBTT_pow( x,1.0f/3.0f); } // x^3 + c*x^2 + b*x + a = 0 static int stbtt__solve_cubic(float a, float b, float c, float* r) { float s = -a / 3; float p = b - a*a / 3; float q = a * (2*a*a - 9*b) / 27 + c; float p3 = p*p*p; float d = q*q + 4*p3 / 27; if (d >= 0) { float z = (float) STBTT_sqrt(d); float u = (-q + z) / 2; float v = (-q - z) / 2; u = stbtt__cuberoot(u); v = stbtt__cuberoot(v); r[0] = s + u + v; return 1; } else { float u = (float) STBTT_sqrt(-p/3); float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; // p3 must be negative, since d is negative float m = (float) STBTT_cos(v); float n = (float) STBTT_cos(v-3.141592/2)*1.732050808f; r[0] = s + u * 2 * m; r[1] = s - u * (m + n); r[2] = s - u * (m - n); //STBTT_assert( STBTT_fabs(((r[0]+a)*r[0]+b)*r[0]+c) < 0.05f); // these asserts may not be safe at all scales, though they're in bezier t parameter units so maybe? //STBTT_assert( STBTT_fabs(((r[1]+a)*r[1]+b)*r[1]+c) < 0.05f); //STBTT_assert( STBTT_fabs(((r[2]+a)*r[2]+b)*r[2]+c) < 0.05f); return 3; } } STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) { float scale_x = scale, scale_y = scale; int ix0,iy0,ix1,iy1; int w,h; unsigned char *data; // if one scale is 0, use same scale for both if (scale_x == 0) scale_x = scale_y; if (scale_y == 0) { if (scale_x == 0) return NULL; // if both scales are 0, return NULL scale_y = scale_x; } stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale, scale, 0.0f,0.0f, &ix0,&iy0,&ix1,&iy1); // if empty, return NULL if (ix0 == ix1 || iy0 == iy1) return NULL; ix0 -= padding; iy0 -= padding; ix1 += padding; iy1 += padding; w = (ix1 - ix0); h = (iy1 - iy0); if (width ) *width = w; if (height) *height = h; if (xoff ) *xoff = ix0; if (yoff ) *yoff = iy0; // invert for y-downwards bitmaps scale_y = -scale_y; { int x,y,i,j; float *precompute; stbtt_vertex *verts; int num_verts = stbtt_GetGlyphShape(info, glyph, &verts); data = (unsigned char *) STBTT_malloc(w * h, info->userdata); precompute = (float *) STBTT_malloc(num_verts * sizeof(float), info->userdata); for (i=0,j=num_verts-1; i < num_verts; j=i++) { if (verts[i].type == STBTT_vline) { float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y; float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0)); precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist; } else if (verts[i].type == STBTT_vcurve) { float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y; float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y; float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y; float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; float len2 = bx*bx + by*by; if (len2 != 0.0f) precompute[i] = 1.0f / (bx*bx + by*by); else precompute[i] = 0.0f; } else precompute[i] = 0.0f; } for (y=iy0; y < iy1; ++y) { for (x=ix0; x < ix1; ++x) { float val; float min_dist = 999999.0f; float sx = (float) x + 0.5f; float sy = (float) y + 0.5f; float x_gspace = (sx / scale_x); float y_gspace = (sy / scale_y); int winding = stbtt__compute_crossings_x(x_gspace, y_gspace, num_verts, verts); // @OPTIMIZE: this could just be a rasterization, but needs to be line vs. non-tesselated curves so a new path for (i=0; i < num_verts; ++i) { float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; // check against every point here rather than inside line/curve primitives -- @TODO: wrong if multiple 'moves' in a row produce a garbage point, and given culling, probably more efficient to do within line/curve float dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy); if (dist2 < min_dist*min_dist) min_dist = (float) STBTT_sqrt(dist2); if (verts[i].type == STBTT_vline) { float x1 = verts[i-1].x*scale_x, y1 = verts[i-1].y*scale_y; // coarse culling against bbox //if (sx > STBTT_min(x0,x1)-min_dist && sx < STBTT_max(x0,x1)+min_dist && // sy > STBTT_min(y0,y1)-min_dist && sy < STBTT_max(y0,y1)+min_dist) float dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i]; STBTT_assert(i != 0); if (dist < min_dist) { // check position along line // x' = x0 + t*(x1-x0), y' = y0 + t*(y1-y0) // minimize (x'-sx)*(x'-sx)+(y'-sy)*(y'-sy) float dx = x1-x0, dy = y1-y0; float px = x0-sx, py = y0-sy; // minimize (px+t*dx)^2 + (py+t*dy)^2 = px*px + 2*px*dx*t + t^2*dx*dx + py*py + 2*py*dy*t + t^2*dy*dy // derivative: 2*px*dx + 2*py*dy + (2*dx*dx+2*dy*dy)*t, set to 0 and solve float t = -(px*dx + py*dy) / (dx*dx + dy*dy); if (t >= 0.0f && t <= 1.0f) min_dist = dist; } } else if (verts[i].type == STBTT_vcurve) { float x2 = verts[i-1].x *scale_x, y2 = verts[i-1].y *scale_y; float x1 = verts[i ].cx*scale_x, y1 = verts[i ].cy*scale_y; float box_x0 = STBTT_min(STBTT_min(x0,x1),x2); float box_y0 = STBTT_min(STBTT_min(y0,y1),y2); float box_x1 = STBTT_max(STBTT_max(x0,x1),x2); float box_y1 = STBTT_max(STBTT_max(y0,y1),y2); // coarse culling against bbox to avoid computing cubic unnecessarily if (sx > box_x0-min_dist && sx < box_x1+min_dist && sy > box_y0-min_dist && sy < box_y1+min_dist) { int num=0; float ax = x1-x0, ay = y1-y0; float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; float mx = x0 - sx, my = y0 - sy; float res[3],px,py,t,it; float a_inv = precompute[i]; if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula float a = 3*(ax*bx + ay*by); float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by); float c = mx*ax+my*ay; if (a == 0.0) { // if a is 0, it's linear if (b != 0.0) { res[num++] = -c/b; } } else { float discriminant = b*b - 4*a*c; if (discriminant < 0) num = 0; else { float root = (float) STBTT_sqrt(discriminant); res[0] = (-b - root)/(2*a); res[1] = (-b + root)/(2*a); num = 2; // don't bother distinguishing 1-solution case, as code below will still work } } } else { float b = 3*(ax*bx + ay*by) * a_inv; // could precompute this as it doesn't depend on sample point float c = (2*(ax*ax + ay*ay) + (mx*bx+my*by)) * a_inv; float d = (mx*ax+my*ay) * a_inv; num = stbtt__solve_cubic(b, c, d, res); } if (num >= 1 && res[0] >= 0.0f && res[0] <= 1.0f) { t = res[0], it = 1.0f - t; px = it*it*x0 + 2*t*it*x1 + t*t*x2; py = it*it*y0 + 2*t*it*y1 + t*t*y2; dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); if (dist2 < min_dist * min_dist) min_dist = (float) STBTT_sqrt(dist2); } if (num >= 2 && res[1] >= 0.0f && res[1] <= 1.0f) { t = res[1], it = 1.0f - t; px = it*it*x0 + 2*t*it*x1 + t*t*x2; py = it*it*y0 + 2*t*it*y1 + t*t*y2; dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); if (dist2 < min_dist * min_dist) min_dist = (float) STBTT_sqrt(dist2); } if (num >= 3 && res[2] >= 0.0f && res[2] <= 1.0f) { t = res[2], it = 1.0f - t; px = it*it*x0 + 2*t*it*x1 + t*t*x2; py = it*it*y0 + 2*t*it*y1 + t*t*y2; dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); if (dist2 < min_dist * min_dist) min_dist = (float) STBTT_sqrt(dist2); } } } } if (winding == 0) min_dist = -min_dist; // if outside the shape, value is negative val = onedge_value + pixel_dist_scale * min_dist; if (val < 0) val = 0; else if (val > 255) val = 255; data[(y-iy0)*w+(x-ix0)] = (unsigned char) val; } } STBTT_free(precompute, info->userdata); STBTT_free(verts, info->userdata); } return data; } STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetGlyphSDF(info, scale, stbtt_FindGlyphIndex(info, codepoint), padding, onedge_value, pixel_dist_scale, width, height, xoff, yoff); } STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata) { STBTT_free(bitmap, userdata); } ////////////////////////////////////////////////////////////////////////////// // // font name matching -- recommended not to use this // // check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2) { stbtt_int32 i=0; // convert utf16 to utf8 and compare the results while converting while (len2) { stbtt_uint16 ch = s2[0]*256 + s2[1]; if (ch < 0x80) { if (i >= len1) return -1; if (s1[i++] != ch) return -1; } else if (ch < 0x800) { if (i+1 >= len1) return -1; if (s1[i++] != 0xc0 + (ch >> 6)) return -1; if (s1[i++] != 0x80 + (ch & 0x3f)) return -1; } else if (ch >= 0xd800 && ch < 0xdc00) { stbtt_uint32 c; stbtt_uint16 ch2 = s2[2]*256 + s2[3]; if (i+3 >= len1) return -1; c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000; if (s1[i++] != 0xf0 + (c >> 18)) return -1; if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1; if (s1[i++] != 0x80 + ((c >> 6) & 0x3f)) return -1; if (s1[i++] != 0x80 + ((c ) & 0x3f)) return -1; s2 += 2; // plus another 2 below len2 -= 2; } else if (ch >= 0xdc00 && ch < 0xe000) { return -1; } else { if (i+2 >= len1) return -1; if (s1[i++] != 0xe0 + (ch >> 12)) return -1; if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1; if (s1[i++] != 0x80 + ((ch ) & 0x3f)) return -1; } s2 += 2; len2 -= 2; } return i; } static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2) { return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2); } // returns results in whatever encoding you request... but note that 2-byte encodings // will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID) { stbtt_int32 i,count,stringOffset; stbtt_uint8 *fc = font->data; stbtt_uint32 offset = font->fontstart; stbtt_uint32 nm = stbtt__find_table(fc, offset, "name"); if (!nm) return NULL; count = ttUSHORT(fc+nm+2); stringOffset = nm + ttUSHORT(fc+nm+4); for (i=0; i < count; ++i) { stbtt_uint32 loc = nm + 6 + 12 * i; if (platformID == ttUSHORT(fc+loc+0) && encodingID == ttUSHORT(fc+loc+2) && languageID == ttUSHORT(fc+loc+4) && nameID == ttUSHORT(fc+loc+6)) { *length = ttUSHORT(fc+loc+8); return (const char *) (fc+stringOffset+ttUSHORT(fc+loc+10)); } } return NULL; } static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id) { stbtt_int32 i; stbtt_int32 count = ttUSHORT(fc+nm+2); stbtt_int32 stringOffset = nm + ttUSHORT(fc+nm+4); for (i=0; i < count; ++i) { stbtt_uint32 loc = nm + 6 + 12 * i; stbtt_int32 id = ttUSHORT(fc+loc+6); if (id == target_id) { // find the encoding stbtt_int32 platform = ttUSHORT(fc+loc+0), encoding = ttUSHORT(fc+loc+2), language = ttUSHORT(fc+loc+4); // is this a Unicode encoding? if (platform == 0 || (platform == 3 && encoding == 1) || (platform == 3 && encoding == 10)) { stbtt_int32 slen = ttUSHORT(fc+loc+8); stbtt_int32 off = ttUSHORT(fc+loc+10); // check if there's a prefix match stbtt_int32 matchlen = stbtt__CompareUTF8toUTF16_bigendian_prefix(name, nlen, fc+stringOffset+off,slen); if (matchlen >= 0) { // check for target_id+1 immediately following, with same encoding & language if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) { slen = ttUSHORT(fc+loc+12+8); off = ttUSHORT(fc+loc+12+10); if (slen == 0) { if (matchlen == nlen) return 1; } else if (matchlen < nlen && name[matchlen] == ' ') { ++matchlen; if (stbtt_CompareUTF8toUTF16_bigendian_internal((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) return 1; } } else { // if nothing immediately following if (matchlen == nlen) return 1; } } } // @TODO handle other encodings } } return 0; } static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *name, stbtt_int32 flags) { stbtt_int32 nlen = (stbtt_int32) STBTT_strlen((char *) name); stbtt_uint32 nm,hd; if (!stbtt__isfont(fc+offset)) return 0; // check italics/bold/underline flags in macStyle... if (flags) { hd = stbtt__find_table(fc, offset, "head"); if ((ttUSHORT(fc+hd+44) & 7) != (flags & 7)) return 0; } nm = stbtt__find_table(fc, offset, "name"); if (!nm) return 0; if (flags) { // if we checked the macStyle flags, then just check the family and ignore the subfamily if (stbtt__matchpair(fc, nm, name, nlen, 16, -1)) return 1; if (stbtt__matchpair(fc, nm, name, nlen, 1, -1)) return 1; if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; } else { if (stbtt__matchpair(fc, nm, name, nlen, 16, 17)) return 1; if (stbtt__matchpair(fc, nm, name, nlen, 1, 2)) return 1; if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; } return 0; } static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, stbtt_int32 flags) { stbtt_int32 i; for (i=0;;++i) { stbtt_int32 off = stbtt_GetFontOffsetForIndex(font_collection, i); if (off < 0) return off; if (stbtt__matches((stbtt_uint8 *) font_collection, off, (stbtt_uint8*) name_utf8, flags)) return off; } } #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-qual" #endif STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, float pixel_height, unsigned char *pixels, int pw, int ph, int first_char, int num_chars, stbtt_bakedchar *chardata) { return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata); } STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index) { return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index); } STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data) { return stbtt_GetNumberOfFonts_internal((unsigned char *) data); } STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset) { return stbtt_InitFont_internal(info, (unsigned char *) data, offset); } STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags) { return stbtt_FindMatchingFont_internal((unsigned char *) fontdata, (char *) name, flags); } STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) { return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2); } #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif #endif // STB_TRUETYPE_IMPLEMENTATION // FULL VERSION HISTORY // // 1.19 (2018-02-11) OpenType GPOS kerning (horizontal only), STBTT_fmod // 1.18 (2018-01-29) add missing function // 1.17 (2017-07-23) make more arguments const; doc fix // 1.16 (2017-07-12) SDF support // 1.15 (2017-03-03) make more arguments const // 1.14 (2017-01-16) num-fonts-in-TTC function // 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts // 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual // 1.11 (2016-04-02) fix unused-variable warning // 1.10 (2016-04-02) allow user-defined fabs() replacement // fix memory leak if fontsize=0.0 // fix warning from duplicate typedef // 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use alloc userdata for PackFontRanges // 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges // 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; // allow PackFontRanges to pack and render in separate phases; // fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); // fixed an assert() bug in the new rasterizer // replace assert() with STBTT_assert() in new rasterizer // 1.06 (2015-07-14) performance improvements (~35% faster on x86 and x64 on test machine) // also more precise AA rasterizer, except if shapes overlap // remove need for STBTT_sort // 1.05 (2015-04-15) fix misplaced definitions for STBTT_STATIC // 1.04 (2015-04-15) typo in example // 1.03 (2015-04-12) STBTT_STATIC, fix memory leak in new packing, various fixes // 1.02 (2014-12-10) fix various warnings & compile issues w/ stb_rect_pack, C++ // 1.01 (2014-12-08) fix subpixel position when oversampling to exactly match // non-oversampled; STBTT_POINT_SIZE for packed case only // 1.00 (2014-12-06) add new PackBegin etc. API, w/ support for oversampling // 0.99 (2014-09-18) fix multiple bugs with subpixel rendering (ryg) // 0.9 (2014-08-07) support certain mac/iOS fonts without an MS platformID // 0.8b (2014-07-07) fix a warning // 0.8 (2014-05-25) fix a few more warnings // 0.7 (2013-09-25) bugfix: subpixel glyph bug fixed in 0.5 had come back // 0.6c (2012-07-24) improve documentation // 0.6b (2012-07-20) fix a few more warnings // 0.6 (2012-07-17) fix warnings; added stbtt_ScaleForMappingEmToPixels, // stbtt_GetFontBoundingBox, stbtt_IsGlyphEmpty // 0.5 (2011-12-09) bugfixes: // subpixel glyph renderer computed wrong bounding box // first vertex of shape can be off-curve (FreeSans) // 0.4b (2011-12-03) fixed an error in the font baking example // 0.4 (2011-12-01) kerning, subpixel rendering (tor) // bugfixes for: // codepoint-to-glyph conversion using table fmt=12 // codepoint-to-glyph conversion using table fmt=4 // stbtt_GetBakedQuad with non-square texture (Zer) // updated Hello World! sample to use kerning and subpixel // fixed some warnings // 0.3 (2009-06-24) cmap fmt=12, compound shapes (MM) // userdata, malloc-from-userdata, non-zero fill (stb) // 0.2 (2009-03-11) Fix unsigned/signed char warnings // 0.1 (2009-03-09) First public release // /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ goxel-0.11.0/ext_src/uthash/000077500000000000000000000000001435762723100156645ustar00rootroot00000000000000goxel-0.11.0/ext_src/uthash/utarray.h000066400000000000000000000321641435762723100175320ustar00rootroot00000000000000/* Copyright (c) 2008-2018, Troy D. Hanson http://troydhanson.github.com/uthash/ 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. 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 OWNER 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. */ /* a dynamic array implementation using macros */ #ifndef UTARRAY_H #define UTARRAY_H #define UTARRAY_VERSION 2.1.0 #include /* size_t */ #include /* memset, etc */ #include /* exit */ #ifdef __GNUC__ #define UTARRAY_UNUSED __attribute__((__unused__)) #else #define UTARRAY_UNUSED #endif #ifdef oom #error "The name of macro 'oom' has been changed to 'utarray_oom'. Please update your code." #define utarray_oom() oom() #endif #ifndef utarray_oom #define utarray_oom() exit(-1) #endif typedef void (ctor_f)(void *dst, const void *src); typedef void (dtor_f)(void *elt); typedef void (init_f)(void *elt); typedef struct { size_t sz; init_f *init; ctor_f *copy; dtor_f *dtor; } UT_icd; typedef struct { unsigned i,n;/* i: index of next available slot, n: num slots */ UT_icd icd; /* initializer, copy and destructor functions */ char *d; /* n slots of size icd->sz*/ } UT_array; #define utarray_init(a,_icd) do { \ memset(a,0,sizeof(UT_array)); \ (a)->icd = *(_icd); \ } while(0) #define utarray_done(a) do { \ if ((a)->n) { \ if ((a)->icd.dtor) { \ unsigned _ut_i; \ for(_ut_i=0; _ut_i < (a)->i; _ut_i++) { \ (a)->icd.dtor(utarray_eltptr(a,_ut_i)); \ } \ } \ free((a)->d); \ } \ (a)->n=0; \ } while(0) #define utarray_new(a,_icd) do { \ (a) = (UT_array*)malloc(sizeof(UT_array)); \ if ((a) == NULL) { \ utarray_oom(); \ } \ utarray_init(a,_icd); \ } while(0) #define utarray_free(a) do { \ utarray_done(a); \ free(a); \ } while(0) #define utarray_reserve(a,by) do { \ if (((a)->i+(by)) > (a)->n) { \ char *utarray_tmp; \ while (((a)->i+(by)) > (a)->n) { (a)->n = ((a)->n ? (2*(a)->n) : 8); } \ utarray_tmp=(char*)realloc((a)->d, (a)->n*(a)->icd.sz); \ if (utarray_tmp == NULL) { \ utarray_oom(); \ } \ (a)->d=utarray_tmp; \ } \ } while(0) #define utarray_push_back(a,p) do { \ utarray_reserve(a,1); \ if ((a)->icd.copy) { (a)->icd.copy( _utarray_eltptr(a,(a)->i++), p); } \ else { memcpy(_utarray_eltptr(a,(a)->i++), p, (a)->icd.sz); }; \ } while(0) #define utarray_pop_back(a) do { \ if ((a)->icd.dtor) { (a)->icd.dtor( _utarray_eltptr(a,--((a)->i))); } \ else { (a)->i--; } \ } while(0) #define utarray_extend_back(a) do { \ utarray_reserve(a,1); \ if ((a)->icd.init) { (a)->icd.init(_utarray_eltptr(a,(a)->i)); } \ else { memset(_utarray_eltptr(a,(a)->i),0,(a)->icd.sz); } \ (a)->i++; \ } while(0) #define utarray_len(a) ((a)->i) #define utarray_eltptr(a,j) (((j) < (a)->i) ? _utarray_eltptr(a,j) : NULL) #define _utarray_eltptr(a,j) ((a)->d + ((a)->icd.sz * (j))) #define utarray_insert(a,p,j) do { \ if ((j) > (a)->i) utarray_resize(a,j); \ utarray_reserve(a,1); \ if ((j) < (a)->i) { \ memmove( _utarray_eltptr(a,(j)+1), _utarray_eltptr(a,j), \ ((a)->i - (j))*((a)->icd.sz)); \ } \ if ((a)->icd.copy) { (a)->icd.copy( _utarray_eltptr(a,j), p); } \ else { memcpy(_utarray_eltptr(a,j), p, (a)->icd.sz); }; \ (a)->i++; \ } while(0) #define utarray_inserta(a,w,j) do { \ if (utarray_len(w) == 0) break; \ if ((j) > (a)->i) utarray_resize(a,j); \ utarray_reserve(a,utarray_len(w)); \ if ((j) < (a)->i) { \ memmove(_utarray_eltptr(a,(j)+utarray_len(w)), \ _utarray_eltptr(a,j), \ ((a)->i - (j))*((a)->icd.sz)); \ } \ if ((a)->icd.copy) { \ unsigned _ut_i; \ for(_ut_i=0;_ut_i<(w)->i;_ut_i++) { \ (a)->icd.copy(_utarray_eltptr(a, (j) + _ut_i), _utarray_eltptr(w, _ut_i)); \ } \ } else { \ memcpy(_utarray_eltptr(a,j), _utarray_eltptr(w,0), \ utarray_len(w)*((a)->icd.sz)); \ } \ (a)->i += utarray_len(w); \ } while(0) #define utarray_resize(dst,num) do { \ unsigned _ut_i; \ if ((dst)->i > (unsigned)(num)) { \ if ((dst)->icd.dtor) { \ for (_ut_i = (num); _ut_i < (dst)->i; ++_ut_i) { \ (dst)->icd.dtor(_utarray_eltptr(dst, _ut_i)); \ } \ } \ } else if ((dst)->i < (unsigned)(num)) { \ utarray_reserve(dst, (num) - (dst)->i); \ if ((dst)->icd.init) { \ for (_ut_i = (dst)->i; _ut_i < (unsigned)(num); ++_ut_i) { \ (dst)->icd.init(_utarray_eltptr(dst, _ut_i)); \ } \ } else { \ memset(_utarray_eltptr(dst, (dst)->i), 0, (dst)->icd.sz*((num) - (dst)->i)); \ } \ } \ (dst)->i = (num); \ } while(0) #define utarray_concat(dst,src) do { \ utarray_inserta(dst, src, utarray_len(dst)); \ } while(0) #define utarray_erase(a,pos,len) do { \ if ((a)->icd.dtor) { \ unsigned _ut_i; \ for (_ut_i = 0; _ut_i < (len); _ut_i++) { \ (a)->icd.dtor(utarray_eltptr(a, (pos) + _ut_i)); \ } \ } \ if ((a)->i > ((pos) + (len))) { \ memmove(_utarray_eltptr(a, pos), _utarray_eltptr(a, (pos) + (len)), \ ((a)->i - ((pos) + (len))) * (a)->icd.sz); \ } \ (a)->i -= (len); \ } while(0) #define utarray_renew(a,u) do { \ if (a) utarray_clear(a); \ else utarray_new(a, u); \ } while(0) #define utarray_clear(a) do { \ if ((a)->i > 0) { \ if ((a)->icd.dtor) { \ unsigned _ut_i; \ for(_ut_i=0; _ut_i < (a)->i; _ut_i++) { \ (a)->icd.dtor(_utarray_eltptr(a, _ut_i)); \ } \ } \ (a)->i = 0; \ } \ } while(0) #define utarray_sort(a,cmp) do { \ qsort((a)->d, (a)->i, (a)->icd.sz, cmp); \ } while(0) #define utarray_find(a,v,cmp) bsearch((v),(a)->d,(a)->i,(a)->icd.sz,cmp) #define utarray_front(a) (((a)->i) ? (_utarray_eltptr(a,0)) : NULL) #define utarray_next(a,e) (((e)==NULL) ? utarray_front(a) : (((a)->i != utarray_eltidx(a,e)+1) ? _utarray_eltptr(a,utarray_eltidx(a,e)+1) : NULL)) #define utarray_prev(a,e) (((e)==NULL) ? utarray_back(a) : ((utarray_eltidx(a,e) != 0) ? _utarray_eltptr(a,utarray_eltidx(a,e)-1) : NULL)) #define utarray_back(a) (((a)->i) ? (_utarray_eltptr(a,(a)->i-1)) : NULL) #define utarray_eltidx(a,e) (((char*)(e) - (a)->d) / (a)->icd.sz) /* last we pre-define a few icd for common utarrays of ints and strings */ static void utarray_str_cpy(void *dst, const void *src) { char **_src = (char**)src, **_dst = (char**)dst; *_dst = (*_src == NULL) ? NULL : strdup(*_src); } static void utarray_str_dtor(void *elt) { char **eltc = (char**)elt; if (*eltc != NULL) free(*eltc); } static const UT_icd ut_str_icd UTARRAY_UNUSED = {sizeof(char*),NULL,utarray_str_cpy,utarray_str_dtor}; static const UT_icd ut_int_icd UTARRAY_UNUSED = {sizeof(int),NULL,NULL,NULL}; static const UT_icd ut_ptr_icd UTARRAY_UNUSED = {sizeof(void*),NULL,NULL,NULL}; #endif /* UTARRAY_H */ goxel-0.11.0/ext_src/uthash/uthash.h000066400000000000000000002315561435762723100173450ustar00rootroot00000000000000/* Copyright (c) 2003-2018, Troy D. Hanson http://troydhanson.github.com/uthash/ 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. 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 OWNER 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 UTHASH_H #define UTHASH_H #define UTHASH_VERSION 2.1.0 #include /* memcmp, memset, strlen */ #include /* ptrdiff_t */ #include /* exit */ /* These macros use decltype or the earlier __typeof GNU extension. As decltype is only available in newer compilers (VS2010 or gcc 4.3+ when compiling c++ source) this code uses whatever method is needed or, for VS2008 where neither is available, uses casting workarounds. */ #if !defined(DECLTYPE) && !defined(NO_DECLTYPE) #if defined(_MSC_VER) /* MS compiler */ #if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */ #define DECLTYPE(x) (decltype(x)) #else /* VS2008 or older (or VS2010 in C mode) */ #define NO_DECLTYPE #endif #elif defined(__BORLANDC__) || defined(__ICCARM__) || defined(__LCC__) || defined(__WATCOMC__) #define NO_DECLTYPE #else /* GNU, Sun and other compilers */ #define DECLTYPE(x) (__typeof(x)) #endif #endif #ifdef NO_DECLTYPE #define DECLTYPE(x) #define DECLTYPE_ASSIGN(dst,src) \ do { \ char **_da_dst = (char**)(&(dst)); \ *_da_dst = (char*)(src); \ } while (0) #else #define DECLTYPE_ASSIGN(dst,src) \ do { \ (dst) = DECLTYPE(dst)(src); \ } while (0) #endif /* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */ #if defined(_WIN32) #if defined(_MSC_VER) && _MSC_VER >= 1600 #include #elif defined(__WATCOMC__) || defined(__MINGW32__) || defined(__CYGWIN__) #include #else typedef unsigned int uint32_t; typedef unsigned char uint8_t; #endif #elif defined(__GNUC__) && !defined(__VXWORKS__) #include #else typedef unsigned int uint32_t; typedef unsigned char uint8_t; #endif #ifndef uthash_malloc #define uthash_malloc(sz) malloc(sz) /* malloc fcn */ #endif #ifndef uthash_free #define uthash_free(ptr,sz) free(ptr) /* free fcn */ #endif #ifndef uthash_bzero #define uthash_bzero(a,n) memset(a,'\0',n) #endif #ifndef uthash_strlen #define uthash_strlen(s) strlen(s) #endif #ifdef uthash_memcmp /* This warning will not catch programs that define uthash_memcmp AFTER including uthash.h. */ #warning "uthash_memcmp is deprecated; please use HASH_KEYCMP instead" #else #define uthash_memcmp(a,b,n) memcmp(a,b,n) #endif #ifndef HASH_KEYCMP #define HASH_KEYCMP(a,b,n) uthash_memcmp(a,b,n) #endif #ifndef uthash_noexpand_fyi #define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */ #endif #ifndef uthash_expand_fyi #define uthash_expand_fyi(tbl) /* can be defined to log expands */ #endif #ifndef HASH_NONFATAL_OOM #define HASH_NONFATAL_OOM 0 #endif #if HASH_NONFATAL_OOM /* malloc failures can be recovered from */ #ifndef uthash_nonfatal_oom #define uthash_nonfatal_oom(obj) do {} while (0) /* non-fatal OOM error */ #endif #define HASH_RECORD_OOM(oomed) do { (oomed) = 1; } while (0) #define IF_HASH_NONFATAL_OOM(x) x #else /* malloc failures result in lost memory, hash tables are unusable */ #ifndef uthash_fatal #define uthash_fatal(msg) exit(-1) /* fatal OOM error */ #endif #define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory") #define IF_HASH_NONFATAL_OOM(x) #endif /* initial number of buckets */ #define HASH_INITIAL_NUM_BUCKETS 32U /* initial number of buckets */ #define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */ #define HASH_BKT_CAPACITY_THRESH 10U /* expand when bucket count reaches */ /* calculate the element whose hash handle address is hhp */ #define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho))) /* calculate the hash handle from element address elp */ #define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle *)(((char*)(elp)) + ((tbl)->hho))) #define HASH_ROLLBACK_BKT(hh, head, itemptrhh) \ do { \ struct UT_hash_handle *_hd_hh_item = (itemptrhh); \ unsigned _hd_bkt; \ HASH_TO_BKT(_hd_hh_item->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ (head)->hh.tbl->buckets[_hd_bkt].count++; \ _hd_hh_item->hh_next = NULL; \ _hd_hh_item->hh_prev = NULL; \ } while (0) #define HASH_VALUE(keyptr,keylen,hashv) \ do { \ HASH_FCN(keyptr, keylen, hashv); \ } while (0) #define HASH_FIND_BYHASHVALUE(hh,head,keyptr,keylen,hashval,out) \ do { \ (out) = NULL; \ if (head) { \ unsigned _hf_bkt; \ HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _hf_bkt); \ if (HASH_BLOOM_TEST((head)->hh.tbl, hashval) != 0) { \ HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], keyptr, keylen, hashval, out); \ } \ } \ } while (0) #define HASH_FIND(hh,head,keyptr,keylen,out) \ do { \ (out) = NULL; \ if (head) { \ unsigned _hf_hashv; \ HASH_VALUE(keyptr, keylen, _hf_hashv); \ HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \ } \ } while (0) #ifdef HASH_BLOOM #define HASH_BLOOM_BITLEN (1UL << HASH_BLOOM) #define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN/8UL) + (((HASH_BLOOM_BITLEN%8UL)!=0UL) ? 1UL : 0UL) #define HASH_BLOOM_MAKE(tbl,oomed) \ do { \ (tbl)->bloom_nbits = HASH_BLOOM; \ (tbl)->bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN); \ if (!(tbl)->bloom_bv) { \ HASH_RECORD_OOM(oomed); \ } else { \ uthash_bzero((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ } \ } while (0) #define HASH_BLOOM_FREE(tbl) \ do { \ uthash_free((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ } while (0) #define HASH_BLOOM_BITSET(bv,idx) (bv[(idx)/8U] |= (1U << ((idx)%8U))) #define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8U] & (1U << ((idx)%8U))) #define HASH_BLOOM_ADD(tbl,hashv) \ HASH_BLOOM_BITSET((tbl)->bloom_bv, ((hashv) & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) #define HASH_BLOOM_TEST(tbl,hashv) \ HASH_BLOOM_BITTEST((tbl)->bloom_bv, ((hashv) & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) #else #define HASH_BLOOM_MAKE(tbl,oomed) #define HASH_BLOOM_FREE(tbl) #define HASH_BLOOM_ADD(tbl,hashv) #define HASH_BLOOM_TEST(tbl,hashv) (1) #define HASH_BLOOM_BYTELEN 0U #endif #define HASH_MAKE_TABLE(hh,head,oomed) \ do { \ (head)->hh.tbl = (UT_hash_table*)uthash_malloc(sizeof(UT_hash_table)); \ if (!(head)->hh.tbl) { \ HASH_RECORD_OOM(oomed); \ } else { \ uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \ (head)->hh.tbl->tail = &((head)->hh); \ (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \ (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \ HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ (head)->hh.tbl->signature = HASH_SIGNATURE; \ if (!(head)->hh.tbl->buckets) { \ HASH_RECORD_OOM(oomed); \ uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ } else { \ uthash_bzero((head)->hh.tbl->buckets, \ HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ HASH_BLOOM_MAKE((head)->hh.tbl, oomed); \ IF_HASH_NONFATAL_OOM( \ if (oomed) { \ uthash_free((head)->hh.tbl->buckets, \ HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \ uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ } \ ) \ } \ } \ } while (0) #define HASH_REPLACE_BYHASHVALUE_INORDER(hh,head,fieldname,keylen_in,hashval,add,replaced,cmpfcn) \ do { \ (replaced) = NULL; \ HASH_FIND_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, replaced); \ if (replaced) { \ HASH_DELETE(hh, head, replaced); \ } \ HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn); \ } while (0) #define HASH_REPLACE_BYHASHVALUE(hh,head,fieldname,keylen_in,hashval,add,replaced) \ do { \ (replaced) = NULL; \ HASH_FIND_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, replaced); \ if (replaced) { \ HASH_DELETE(hh, head, replaced); \ } \ HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add); \ } while (0) #define HASH_REPLACE(hh,head,fieldname,keylen_in,add,replaced) \ do { \ unsigned _hr_hashv; \ HASH_VALUE(&((add)->fieldname), keylen_in, _hr_hashv); \ HASH_REPLACE_BYHASHVALUE(hh, head, fieldname, keylen_in, _hr_hashv, add, replaced); \ } while (0) #define HASH_REPLACE_INORDER(hh,head,fieldname,keylen_in,add,replaced,cmpfcn) \ do { \ unsigned _hr_hashv; \ HASH_VALUE(&((add)->fieldname), keylen_in, _hr_hashv); \ HASH_REPLACE_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, _hr_hashv, add, replaced, cmpfcn); \ } while (0) #define HASH_APPEND_LIST(hh, head, add) \ do { \ (add)->hh.next = NULL; \ (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \ (head)->hh.tbl->tail->next = (add); \ (head)->hh.tbl->tail = &((add)->hh); \ } while (0) #define HASH_AKBI_INNER_LOOP(hh,head,add,cmpfcn) \ do { \ do { \ if (cmpfcn(DECLTYPE(head)(_hs_iter), add) > 0) { \ break; \ } \ } while ((_hs_iter = HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->next)); \ } while (0) #ifdef NO_DECLTYPE #undef HASH_AKBI_INNER_LOOP #define HASH_AKBI_INNER_LOOP(hh,head,add,cmpfcn) \ do { \ char *_hs_saved_head = (char*)(head); \ do { \ DECLTYPE_ASSIGN(head, _hs_iter); \ if (cmpfcn(head, add) > 0) { \ DECLTYPE_ASSIGN(head, _hs_saved_head); \ break; \ } \ DECLTYPE_ASSIGN(head, _hs_saved_head); \ } while ((_hs_iter = HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->next)); \ } while (0) #endif #if HASH_NONFATAL_OOM #define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed) \ do { \ if (!(oomed)) { \ unsigned _ha_bkt; \ (head)->hh.tbl->num_items++; \ HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed); \ if (oomed) { \ HASH_ROLLBACK_BKT(hh, head, &(add)->hh); \ HASH_DELETE_HH(hh, head, &(add)->hh); \ (add)->hh.tbl = NULL; \ uthash_nonfatal_oom(add); \ } else { \ HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ } \ } else { \ (add)->hh.tbl = NULL; \ uthash_nonfatal_oom(add); \ } \ } while (0) #else #define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed) \ do { \ unsigned _ha_bkt; \ (head)->hh.tbl->num_items++; \ HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed); \ HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ } while (0) #endif #define HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh,head,keyptr,keylen_in,hashval,add,cmpfcn) \ do { \ IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; ) \ (add)->hh.hashv = (hashval); \ (add)->hh.key = (char*) (keyptr); \ (add)->hh.keylen = (unsigned) (keylen_in); \ if (!(head)) { \ (add)->hh.next = NULL; \ (add)->hh.prev = NULL; \ HASH_MAKE_TABLE(hh, add, _ha_oomed); \ IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { ) \ (head) = (add); \ IF_HASH_NONFATAL_OOM( } ) \ } else { \ void *_hs_iter = (head); \ (add)->hh.tbl = (head)->hh.tbl; \ HASH_AKBI_INNER_LOOP(hh, head, add, cmpfcn); \ if (_hs_iter) { \ (add)->hh.next = _hs_iter; \ if (((add)->hh.prev = HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->prev)) { \ HH_FROM_ELMT((head)->hh.tbl, (add)->hh.prev)->next = (add); \ } else { \ (head) = (add); \ } \ HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->prev = (add); \ } else { \ HASH_APPEND_LIST(hh, head, add); \ } \ } \ HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \ HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE_INORDER"); \ } while (0) #define HASH_ADD_KEYPTR_INORDER(hh,head,keyptr,keylen_in,add,cmpfcn) \ do { \ unsigned _hs_hashv; \ HASH_VALUE(keyptr, keylen_in, _hs_hashv); \ HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, keyptr, keylen_in, _hs_hashv, add, cmpfcn); \ } while (0) #define HASH_ADD_BYHASHVALUE_INORDER(hh,head,fieldname,keylen_in,hashval,add,cmpfcn) \ HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn) #define HASH_ADD_INORDER(hh,head,fieldname,keylen_in,add,cmpfcn) \ HASH_ADD_KEYPTR_INORDER(hh, head, &((add)->fieldname), keylen_in, add, cmpfcn) #define HASH_ADD_KEYPTR_BYHASHVALUE(hh,head,keyptr,keylen_in,hashval,add) \ do { \ IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; ) \ (add)->hh.hashv = (hashval); \ (add)->hh.key = (char*) (keyptr); \ (add)->hh.keylen = (unsigned) (keylen_in); \ if (!(head)) { \ (add)->hh.next = NULL; \ (add)->hh.prev = NULL; \ HASH_MAKE_TABLE(hh, add, _ha_oomed); \ IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { ) \ (head) = (add); \ IF_HASH_NONFATAL_OOM( } ) \ } else { \ (add)->hh.tbl = (head)->hh.tbl; \ HASH_APPEND_LIST(hh, head, add); \ } \ HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \ HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE"); \ } while (0) #define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \ do { \ unsigned _ha_hashv; \ HASH_VALUE(keyptr, keylen_in, _ha_hashv); \ HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, _ha_hashv, add); \ } while (0) #define HASH_ADD_BYHASHVALUE(hh,head,fieldname,keylen_in,hashval,add) \ HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add) #define HASH_ADD(hh,head,fieldname,keylen_in,add) \ HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add) #define HASH_TO_BKT(hashv,num_bkts,bkt) \ do { \ bkt = ((hashv) & ((num_bkts) - 1U)); \ } while (0) /* delete "delptr" from the hash table. * "the usual" patch-up process for the app-order doubly-linked-list. * The use of _hd_hh_del below deserves special explanation. * These used to be expressed using (delptr) but that led to a bug * if someone used the same symbol for the head and deletee, like * HASH_DELETE(hh,users,users); * We want that to work, but by changing the head (users) below * we were forfeiting our ability to further refer to the deletee (users) * in the patch-up process. Solution: use scratch space to * copy the deletee pointer, then the latter references are via that * scratch pointer rather than through the repointed (users) symbol. */ #define HASH_DELETE(hh,head,delptr) \ HASH_DELETE_HH(hh, head, &(delptr)->hh) #define HASH_DELETE_HH(hh,head,delptrhh) \ do { \ struct UT_hash_handle *_hd_hh_del = (delptrhh); \ if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) { \ HASH_BLOOM_FREE((head)->hh.tbl); \ uthash_free((head)->hh.tbl->buckets, \ (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ (head) = NULL; \ } else { \ unsigned _hd_bkt; \ if (_hd_hh_del == (head)->hh.tbl->tail) { \ (head)->hh.tbl->tail = HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev); \ } \ if (_hd_hh_del->prev != NULL) { \ HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev)->next = _hd_hh_del->next; \ } else { \ DECLTYPE_ASSIGN(head, _hd_hh_del->next); \ } \ if (_hd_hh_del->next != NULL) { \ HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->next)->prev = _hd_hh_del->prev; \ } \ HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \ (head)->hh.tbl->num_items--; \ } \ HASH_FSCK(hh, head, "HASH_DELETE_HH"); \ } while (0) /* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */ #define HASH_FIND_STR(head,findstr,out) \ do { \ unsigned _uthash_hfstr_keylen = (unsigned)uthash_strlen(findstr); \ HASH_FIND(hh, head, findstr, _uthash_hfstr_keylen, out); \ } while (0) #define HASH_ADD_STR(head,strfield,add) \ do { \ unsigned _uthash_hastr_keylen = (unsigned)uthash_strlen((add)->strfield); \ HASH_ADD(hh, head, strfield[0], _uthash_hastr_keylen, add); \ } while (0) #define HASH_REPLACE_STR(head,strfield,add,replaced) \ do { \ unsigned _uthash_hrstr_keylen = (unsigned)uthash_strlen((add)->strfield); \ HASH_REPLACE(hh, head, strfield[0], _uthash_hrstr_keylen, add, replaced); \ } while (0) #define HASH_FIND_INT(head,findint,out) \ HASH_FIND(hh,head,findint,sizeof(int),out) #define HASH_ADD_INT(head,intfield,add) \ HASH_ADD(hh,head,intfield,sizeof(int),add) #define HASH_REPLACE_INT(head,intfield,add,replaced) \ HASH_REPLACE(hh,head,intfield,sizeof(int),add,replaced) #define HASH_FIND_PTR(head,findptr,out) \ HASH_FIND(hh,head,findptr,sizeof(void *),out) #define HASH_ADD_PTR(head,ptrfield,add) \ HASH_ADD(hh,head,ptrfield,sizeof(void *),add) #define HASH_REPLACE_PTR(head,ptrfield,add,replaced) \ HASH_REPLACE(hh,head,ptrfield,sizeof(void *),add,replaced) #define HASH_DEL(head,delptr) \ HASH_DELETE(hh,head,delptr) /* HASH_FSCK checks hash integrity on every add/delete when HASH_DEBUG is defined. * This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined. */ #ifdef HASH_DEBUG #define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0) #define HASH_FSCK(hh,head,where) \ do { \ struct UT_hash_handle *_thh; \ if (head) { \ unsigned _bkt_i; \ unsigned _count = 0; \ char *_prev; \ for (_bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; ++_bkt_i) { \ unsigned _bkt_count = 0; \ _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \ _prev = NULL; \ while (_thh) { \ if (_prev != (char*)(_thh->hh_prev)) { \ HASH_OOPS("%s: invalid hh_prev %p, actual %p\n", \ (where), (void*)_thh->hh_prev, (void*)_prev); \ } \ _bkt_count++; \ _prev = (char*)(_thh); \ _thh = _thh->hh_next; \ } \ _count += _bkt_count; \ if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \ HASH_OOPS("%s: invalid bucket count %u, actual %u\n", \ (where), (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \ } \ } \ if (_count != (head)->hh.tbl->num_items) { \ HASH_OOPS("%s: invalid hh item count %u, actual %u\n", \ (where), (head)->hh.tbl->num_items, _count); \ } \ _count = 0; \ _prev = NULL; \ _thh = &(head)->hh; \ while (_thh) { \ _count++; \ if (_prev != (char*)_thh->prev) { \ HASH_OOPS("%s: invalid prev %p, actual %p\n", \ (where), (void*)_thh->prev, (void*)_prev); \ } \ _prev = (char*)ELMT_FROM_HH((head)->hh.tbl, _thh); \ _thh = (_thh->next ? HH_FROM_ELMT((head)->hh.tbl, _thh->next) : NULL); \ } \ if (_count != (head)->hh.tbl->num_items) { \ HASH_OOPS("%s: invalid app item count %u, actual %u\n", \ (where), (head)->hh.tbl->num_items, _count); \ } \ } \ } while (0) #else #define HASH_FSCK(hh,head,where) #endif /* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to * the descriptor to which this macro is defined for tuning the hash function. * The app can #include to get the prototype for write(2). */ #ifdef HASH_EMIT_KEYS #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) \ do { \ unsigned _klen = fieldlen; \ write(HASH_EMIT_KEYS, &_klen, sizeof(_klen)); \ write(HASH_EMIT_KEYS, keyptr, (unsigned long)fieldlen); \ } while (0) #else #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) #endif /* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */ #ifdef HASH_FUNCTION #define HASH_FCN HASH_FUNCTION #else #define HASH_FCN HASH_JEN #endif /* The Bernstein hash function, used in Perl prior to v5.6. Note (x<<5+x)=x*33. */ #define HASH_BER(key,keylen,hashv) \ do { \ unsigned _hb_keylen = (unsigned)keylen; \ const unsigned char *_hb_key = (const unsigned char*)(key); \ (hashv) = 0; \ while (_hb_keylen-- != 0U) { \ (hashv) = (((hashv) << 5) + (hashv)) + *_hb_key++; \ } \ } while (0) /* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */ #define HASH_SAX(key,keylen,hashv) \ do { \ unsigned _sx_i; \ const unsigned char *_hs_key = (const unsigned char*)(key); \ hashv = 0; \ for (_sx_i=0; _sx_i < keylen; _sx_i++) { \ hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \ } \ } while (0) /* FNV-1a variation */ #define HASH_FNV(key,keylen,hashv) \ do { \ unsigned _fn_i; \ const unsigned char *_hf_key = (const unsigned char*)(key); \ (hashv) = 2166136261U; \ for (_fn_i=0; _fn_i < keylen; _fn_i++) { \ hashv = hashv ^ _hf_key[_fn_i]; \ hashv = hashv * 16777619U; \ } \ } while (0) #define HASH_OAT(key,keylen,hashv) \ do { \ unsigned _ho_i; \ const unsigned char *_ho_key=(const unsigned char*)(key); \ hashv = 0; \ for(_ho_i=0; _ho_i < keylen; _ho_i++) { \ hashv += _ho_key[_ho_i]; \ hashv += (hashv << 10); \ hashv ^= (hashv >> 6); \ } \ hashv += (hashv << 3); \ hashv ^= (hashv >> 11); \ hashv += (hashv << 15); \ } while (0) #define HASH_JEN_MIX(a,b,c) \ do { \ a -= b; a -= c; a ^= ( c >> 13 ); \ b -= c; b -= a; b ^= ( a << 8 ); \ c -= a; c -= b; c ^= ( b >> 13 ); \ a -= b; a -= c; a ^= ( c >> 12 ); \ b -= c; b -= a; b ^= ( a << 16 ); \ c -= a; c -= b; c ^= ( b >> 5 ); \ a -= b; a -= c; a ^= ( c >> 3 ); \ b -= c; b -= a; b ^= ( a << 10 ); \ c -= a; c -= b; c ^= ( b >> 15 ); \ } while (0) #define HASH_JEN(key,keylen,hashv) \ do { \ unsigned _hj_i,_hj_j,_hj_k; \ unsigned const char *_hj_key=(unsigned const char*)(key); \ hashv = 0xfeedbeefu; \ _hj_i = _hj_j = 0x9e3779b9u; \ _hj_k = (unsigned)(keylen); \ while (_hj_k >= 12U) { \ _hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) \ + ( (unsigned)_hj_key[2] << 16 ) \ + ( (unsigned)_hj_key[3] << 24 ) ); \ _hj_j += (_hj_key[4] + ( (unsigned)_hj_key[5] << 8 ) \ + ( (unsigned)_hj_key[6] << 16 ) \ + ( (unsigned)_hj_key[7] << 24 ) ); \ hashv += (_hj_key[8] + ( (unsigned)_hj_key[9] << 8 ) \ + ( (unsigned)_hj_key[10] << 16 ) \ + ( (unsigned)_hj_key[11] << 24 ) ); \ \ HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ \ _hj_key += 12; \ _hj_k -= 12U; \ } \ hashv += (unsigned)(keylen); \ switch ( _hj_k ) { \ case 11: hashv += ( (unsigned)_hj_key[10] << 24 ); /* FALLTHROUGH */ \ case 10: hashv += ( (unsigned)_hj_key[9] << 16 ); /* FALLTHROUGH */ \ case 9: hashv += ( (unsigned)_hj_key[8] << 8 ); /* FALLTHROUGH */ \ case 8: _hj_j += ( (unsigned)_hj_key[7] << 24 ); /* FALLTHROUGH */ \ case 7: _hj_j += ( (unsigned)_hj_key[6] << 16 ); /* FALLTHROUGH */ \ case 6: _hj_j += ( (unsigned)_hj_key[5] << 8 ); /* FALLTHROUGH */ \ case 5: _hj_j += _hj_key[4]; /* FALLTHROUGH */ \ case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); /* FALLTHROUGH */ \ case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); /* FALLTHROUGH */ \ case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); /* FALLTHROUGH */ \ case 1: _hj_i += _hj_key[0]; \ } \ HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ } while (0) /* The Paul Hsieh hash function */ #undef get16bits #if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) #define get16bits(d) (*((const uint16_t *) (d))) #endif #if !defined (get16bits) #define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \ +(uint32_t)(((const uint8_t *)(d))[0]) ) #endif #define HASH_SFH(key,keylen,hashv) \ do { \ unsigned const char *_sfh_key=(unsigned const char*)(key); \ uint32_t _sfh_tmp, _sfh_len = (uint32_t)keylen; \ \ unsigned _sfh_rem = _sfh_len & 3U; \ _sfh_len >>= 2; \ hashv = 0xcafebabeu; \ \ /* Main loop */ \ for (;_sfh_len > 0U; _sfh_len--) { \ hashv += get16bits (_sfh_key); \ _sfh_tmp = ((uint32_t)(get16bits (_sfh_key+2)) << 11) ^ hashv; \ hashv = (hashv << 16) ^ _sfh_tmp; \ _sfh_key += 2U*sizeof (uint16_t); \ hashv += hashv >> 11; \ } \ \ /* Handle end cases */ \ switch (_sfh_rem) { \ case 3: hashv += get16bits (_sfh_key); \ hashv ^= hashv << 16; \ hashv ^= (uint32_t)(_sfh_key[sizeof (uint16_t)]) << 18; \ hashv += hashv >> 11; \ break; \ case 2: hashv += get16bits (_sfh_key); \ hashv ^= hashv << 11; \ hashv += hashv >> 17; \ break; \ case 1: hashv += *_sfh_key; \ hashv ^= hashv << 10; \ hashv += hashv >> 1; \ } \ \ /* Force "avalanching" of final 127 bits */ \ hashv ^= hashv << 3; \ hashv += hashv >> 5; \ hashv ^= hashv << 4; \ hashv += hashv >> 17; \ hashv ^= hashv << 25; \ hashv += hashv >> 6; \ } while (0) #ifdef HASH_USING_NO_STRICT_ALIASING /* The MurmurHash exploits some CPU's (x86,x86_64) tolerance for unaligned reads. * For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error. * MurmurHash uses the faster approach only on CPU's where we know it's safe. * * Note the preprocessor built-in defines can be emitted using: * * gcc -m64 -dM -E - < /dev/null (on gcc) * cc -## a.c (where a.c is a simple test file) (Sun Studio) */ #if (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86)) #define MUR_GETBLOCK(p,i) p[i] #else /* non intel */ #define MUR_PLUS0_ALIGNED(p) (((unsigned long)p & 3UL) == 0UL) #define MUR_PLUS1_ALIGNED(p) (((unsigned long)p & 3UL) == 1UL) #define MUR_PLUS2_ALIGNED(p) (((unsigned long)p & 3UL) == 2UL) #define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 3UL) == 3UL) #define WP(p) ((uint32_t*)((unsigned long)(p) & ~3UL)) #if (defined(__BIG_ENDIAN__) || defined(SPARC) || defined(__ppc__) || defined(__ppc64__)) #define MUR_THREE_ONE(p) ((((*WP(p))&0x00ffffff) << 8) | (((*(WP(p)+1))&0xff000000) >> 24)) #define MUR_TWO_TWO(p) ((((*WP(p))&0x0000ffff) <<16) | (((*(WP(p)+1))&0xffff0000) >> 16)) #define MUR_ONE_THREE(p) ((((*WP(p))&0x000000ff) <<24) | (((*(WP(p)+1))&0xffffff00) >> 8)) #else /* assume little endian non-intel */ #define MUR_THREE_ONE(p) ((((*WP(p))&0xffffff00) >> 8) | (((*(WP(p)+1))&0x000000ff) << 24)) #define MUR_TWO_TWO(p) ((((*WP(p))&0xffff0000) >>16) | (((*(WP(p)+1))&0x0000ffff) << 16)) #define MUR_ONE_THREE(p) ((((*WP(p))&0xff000000) >>24) | (((*(WP(p)+1))&0x00ffffff) << 8)) #endif #define MUR_GETBLOCK(p,i) (MUR_PLUS0_ALIGNED(p) ? ((p)[i]) : \ (MUR_PLUS1_ALIGNED(p) ? MUR_THREE_ONE(p) : \ (MUR_PLUS2_ALIGNED(p) ? MUR_TWO_TWO(p) : \ MUR_ONE_THREE(p)))) #endif #define MUR_ROTL32(x,r) (((x) << (r)) | ((x) >> (32 - (r)))) #define MUR_FMIX(_h) \ do { \ _h ^= _h >> 16; \ _h *= 0x85ebca6bu; \ _h ^= _h >> 13; \ _h *= 0xc2b2ae35u; \ _h ^= _h >> 16; \ } while (0) #define HASH_MUR(key,keylen,hashv) \ do { \ const uint8_t *_mur_data = (const uint8_t*)(key); \ const int _mur_nblocks = (int)(keylen) / 4; \ uint32_t _mur_h1 = 0xf88D5353u; \ uint32_t _mur_c1 = 0xcc9e2d51u; \ uint32_t _mur_c2 = 0x1b873593u; \ uint32_t _mur_k1 = 0; \ const uint8_t *_mur_tail; \ const uint32_t *_mur_blocks = (const uint32_t*)(_mur_data+(_mur_nblocks*4)); \ int _mur_i; \ for (_mur_i = -_mur_nblocks; _mur_i != 0; _mur_i++) { \ _mur_k1 = MUR_GETBLOCK(_mur_blocks,_mur_i); \ _mur_k1 *= _mur_c1; \ _mur_k1 = MUR_ROTL32(_mur_k1,15); \ _mur_k1 *= _mur_c2; \ \ _mur_h1 ^= _mur_k1; \ _mur_h1 = MUR_ROTL32(_mur_h1,13); \ _mur_h1 = (_mur_h1*5U) + 0xe6546b64u; \ } \ _mur_tail = (const uint8_t*)(_mur_data + (_mur_nblocks*4)); \ _mur_k1=0; \ switch ((keylen) & 3U) { \ case 0: break; \ case 3: _mur_k1 ^= (uint32_t)_mur_tail[2] << 16; /* FALLTHROUGH */ \ case 2: _mur_k1 ^= (uint32_t)_mur_tail[1] << 8; /* FALLTHROUGH */ \ case 1: _mur_k1 ^= (uint32_t)_mur_tail[0]; \ _mur_k1 *= _mur_c1; \ _mur_k1 = MUR_ROTL32(_mur_k1,15); \ _mur_k1 *= _mur_c2; \ _mur_h1 ^= _mur_k1; \ } \ _mur_h1 ^= (uint32_t)(keylen); \ MUR_FMIX(_mur_h1); \ hashv = _mur_h1; \ } while (0) #endif /* HASH_USING_NO_STRICT_ALIASING */ /* iterate over items in a known bucket to find desired item */ #define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,hashval,out) \ do { \ if ((head).hh_head != NULL) { \ DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (head).hh_head)); \ } else { \ (out) = NULL; \ } \ while ((out) != NULL) { \ if ((out)->hh.hashv == (hashval) && (out)->hh.keylen == (keylen_in)) { \ if (HASH_KEYCMP((out)->hh.key, keyptr, keylen_in) == 0) { \ break; \ } \ } \ if ((out)->hh.hh_next != NULL) { \ DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (out)->hh.hh_next)); \ } else { \ (out) = NULL; \ } \ } \ } while (0) /* add an item to a bucket */ #define HASH_ADD_TO_BKT(head,hh,addhh,oomed) \ do { \ UT_hash_bucket *_ha_head = &(head); \ _ha_head->count++; \ (addhh)->hh_next = _ha_head->hh_head; \ (addhh)->hh_prev = NULL; \ if (_ha_head->hh_head != NULL) { \ _ha_head->hh_head->hh_prev = (addhh); \ } \ _ha_head->hh_head = (addhh); \ if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \ && !(addhh)->tbl->noexpand) { \ HASH_EXPAND_BUCKETS(addhh,(addhh)->tbl, oomed); \ IF_HASH_NONFATAL_OOM( \ if (oomed) { \ HASH_DEL_IN_BKT(head,addhh); \ } \ ) \ } \ } while (0) /* remove an item from a given bucket */ #define HASH_DEL_IN_BKT(head,delhh) \ do { \ UT_hash_bucket *_hd_head = &(head); \ _hd_head->count--; \ if (_hd_head->hh_head == (delhh)) { \ _hd_head->hh_head = (delhh)->hh_next; \ } \ if ((delhh)->hh_prev) { \ (delhh)->hh_prev->hh_next = (delhh)->hh_next; \ } \ if ((delhh)->hh_next) { \ (delhh)->hh_next->hh_prev = (delhh)->hh_prev; \ } \ } while (0) /* Bucket expansion has the effect of doubling the number of buckets * and redistributing the items into the new buckets. Ideally the * items will distribute more or less evenly into the new buckets * (the extent to which this is true is a measure of the quality of * the hash function as it applies to the key domain). * * With the items distributed into more buckets, the chain length * (item count) in each bucket is reduced. Thus by expanding buckets * the hash keeps a bound on the chain length. This bounded chain * length is the essence of how a hash provides constant time lookup. * * The calculation of tbl->ideal_chain_maxlen below deserves some * explanation. First, keep in mind that we're calculating the ideal * maximum chain length based on the *new* (doubled) bucket count. * In fractions this is just n/b (n=number of items,b=new num buckets). * Since the ideal chain length is an integer, we want to calculate * ceil(n/b). We don't depend on floating point arithmetic in this * hash, so to calculate ceil(n/b) with integers we could write * * ceil(n/b) = (n/b) + ((n%b)?1:0) * * and in fact a previous version of this hash did just that. * But now we have improved things a bit by recognizing that b is * always a power of two. We keep its base 2 log handy (call it lb), * so now we can write this with a bit shift and logical AND: * * ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0) * */ #define HASH_EXPAND_BUCKETS(hh,tbl,oomed) \ do { \ unsigned _he_bkt; \ unsigned _he_bkt_i; \ struct UT_hash_handle *_he_thh, *_he_hh_nxt; \ UT_hash_bucket *_he_new_buckets, *_he_newbkt; \ _he_new_buckets = (UT_hash_bucket*)uthash_malloc( \ 2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ if (!_he_new_buckets) { \ HASH_RECORD_OOM(oomed); \ } else { \ uthash_bzero(_he_new_buckets, \ 2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ (tbl)->ideal_chain_maxlen = \ ((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) + \ ((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U); \ (tbl)->nonideal_items = 0; \ for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \ _he_thh = (tbl)->buckets[ _he_bkt_i ].hh_head; \ while (_he_thh != NULL) { \ _he_hh_nxt = _he_thh->hh_next; \ HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt); \ _he_newbkt = &(_he_new_buckets[_he_bkt]); \ if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) { \ (tbl)->nonideal_items++; \ if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \ _he_newbkt->expand_mult++; \ } \ } \ _he_thh->hh_prev = NULL; \ _he_thh->hh_next = _he_newbkt->hh_head; \ if (_he_newbkt->hh_head != NULL) { \ _he_newbkt->hh_head->hh_prev = _he_thh; \ } \ _he_newbkt->hh_head = _he_thh; \ _he_thh = _he_hh_nxt; \ } \ } \ uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ (tbl)->num_buckets *= 2U; \ (tbl)->log2_num_buckets++; \ (tbl)->buckets = _he_new_buckets; \ (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? \ ((tbl)->ineff_expands+1U) : 0U; \ if ((tbl)->ineff_expands > 1U) { \ (tbl)->noexpand = 1; \ uthash_noexpand_fyi(tbl); \ } \ uthash_expand_fyi(tbl); \ } \ } while (0) /* This is an adaptation of Simon Tatham's O(n log(n)) mergesort */ /* Note that HASH_SORT assumes the hash handle name to be hh. * HASH_SRT was added to allow the hash handle name to be passed in. */ #define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn) #define HASH_SRT(hh,head,cmpfcn) \ do { \ unsigned _hs_i; \ unsigned _hs_looping,_hs_nmerges,_hs_insize,_hs_psize,_hs_qsize; \ struct UT_hash_handle *_hs_p, *_hs_q, *_hs_e, *_hs_list, *_hs_tail; \ if (head != NULL) { \ _hs_insize = 1; \ _hs_looping = 1; \ _hs_list = &((head)->hh); \ while (_hs_looping != 0U) { \ _hs_p = _hs_list; \ _hs_list = NULL; \ _hs_tail = NULL; \ _hs_nmerges = 0; \ while (_hs_p != NULL) { \ _hs_nmerges++; \ _hs_q = _hs_p; \ _hs_psize = 0; \ for (_hs_i = 0; _hs_i < _hs_insize; ++_hs_i) { \ _hs_psize++; \ _hs_q = ((_hs_q->next != NULL) ? \ HH_FROM_ELMT((head)->hh.tbl, _hs_q->next) : NULL); \ if (_hs_q == NULL) { \ break; \ } \ } \ _hs_qsize = _hs_insize; \ while ((_hs_psize != 0U) || ((_hs_qsize != 0U) && (_hs_q != NULL))) { \ if (_hs_psize == 0U) { \ _hs_e = _hs_q; \ _hs_q = ((_hs_q->next != NULL) ? \ HH_FROM_ELMT((head)->hh.tbl, _hs_q->next) : NULL); \ _hs_qsize--; \ } else if ((_hs_qsize == 0U) || (_hs_q == NULL)) { \ _hs_e = _hs_p; \ if (_hs_p != NULL) { \ _hs_p = ((_hs_p->next != NULL) ? \ HH_FROM_ELMT((head)->hh.tbl, _hs_p->next) : NULL); \ } \ _hs_psize--; \ } else if ((cmpfcn( \ DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_p)), \ DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_q)) \ )) <= 0) { \ _hs_e = _hs_p; \ if (_hs_p != NULL) { \ _hs_p = ((_hs_p->next != NULL) ? \ HH_FROM_ELMT((head)->hh.tbl, _hs_p->next) : NULL); \ } \ _hs_psize--; \ } else { \ _hs_e = _hs_q; \ _hs_q = ((_hs_q->next != NULL) ? \ HH_FROM_ELMT((head)->hh.tbl, _hs_q->next) : NULL); \ _hs_qsize--; \ } \ if ( _hs_tail != NULL ) { \ _hs_tail->next = ((_hs_e != NULL) ? \ ELMT_FROM_HH((head)->hh.tbl, _hs_e) : NULL); \ } else { \ _hs_list = _hs_e; \ } \ if (_hs_e != NULL) { \ _hs_e->prev = ((_hs_tail != NULL) ? \ ELMT_FROM_HH((head)->hh.tbl, _hs_tail) : NULL); \ } \ _hs_tail = _hs_e; \ } \ _hs_p = _hs_q; \ } \ if (_hs_tail != NULL) { \ _hs_tail->next = NULL; \ } \ if (_hs_nmerges <= 1U) { \ _hs_looping = 0; \ (head)->hh.tbl->tail = _hs_tail; \ DECLTYPE_ASSIGN(head, ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \ } \ _hs_insize *= 2U; \ } \ HASH_FSCK(hh, head, "HASH_SRT"); \ } \ } while (0) /* This function selects items from one hash into another hash. * The end result is that the selected items have dual presence * in both hashes. There is no copy of the items made; rather * they are added into the new hash through a secondary hash * hash handle that must be present in the structure. */ #define HASH_SELECT(hh_dst, dst, hh_src, src, cond) \ do { \ unsigned _src_bkt, _dst_bkt; \ void *_last_elt = NULL, *_elt; \ UT_hash_handle *_src_hh, *_dst_hh, *_last_elt_hh=NULL; \ ptrdiff_t _dst_hho = ((char*)(&(dst)->hh_dst) - (char*)(dst)); \ if ((src) != NULL) { \ for (_src_bkt=0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \ for (_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; \ _src_hh != NULL; \ _src_hh = _src_hh->hh_next) { \ _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \ if (cond(_elt)) { \ IF_HASH_NONFATAL_OOM( int _hs_oomed = 0; ) \ _dst_hh = (UT_hash_handle*)(((char*)_elt) + _dst_hho); \ _dst_hh->key = _src_hh->key; \ _dst_hh->keylen = _src_hh->keylen; \ _dst_hh->hashv = _src_hh->hashv; \ _dst_hh->prev = _last_elt; \ _dst_hh->next = NULL; \ if (_last_elt_hh != NULL) { \ _last_elt_hh->next = _elt; \ } \ if ((dst) == NULL) { \ DECLTYPE_ASSIGN(dst, _elt); \ HASH_MAKE_TABLE(hh_dst, dst, _hs_oomed); \ IF_HASH_NONFATAL_OOM( \ if (_hs_oomed) { \ uthash_nonfatal_oom(_elt); \ (dst) = NULL; \ continue; \ } \ ) \ } else { \ _dst_hh->tbl = (dst)->hh_dst.tbl; \ } \ HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \ HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt], hh_dst, _dst_hh, _hs_oomed); \ (dst)->hh_dst.tbl->num_items++; \ IF_HASH_NONFATAL_OOM( \ if (_hs_oomed) { \ HASH_ROLLBACK_BKT(hh_dst, dst, _dst_hh); \ HASH_DELETE_HH(hh_dst, dst, _dst_hh); \ _dst_hh->tbl = NULL; \ uthash_nonfatal_oom(_elt); \ continue; \ } \ ) \ HASH_BLOOM_ADD(_dst_hh->tbl, _dst_hh->hashv); \ _last_elt = _elt; \ _last_elt_hh = _dst_hh; \ } \ } \ } \ } \ HASH_FSCK(hh_dst, dst, "HASH_SELECT"); \ } while (0) #define HASH_CLEAR(hh,head) \ do { \ if ((head) != NULL) { \ HASH_BLOOM_FREE((head)->hh.tbl); \ uthash_free((head)->hh.tbl->buckets, \ (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \ uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ (head) = NULL; \ } \ } while (0) #define HASH_OVERHEAD(hh,head) \ (((head) != NULL) ? ( \ (size_t)(((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \ ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \ sizeof(UT_hash_table) + \ (HASH_BLOOM_BYTELEN))) : 0U) #ifdef NO_DECLTYPE #define HASH_ITER(hh,head,el,tmp) \ for(((el)=(head)), ((*(char**)(&(tmp)))=(char*)((head!=NULL)?(head)->hh.next:NULL)); \ (el) != NULL; ((el)=(tmp)), ((*(char**)(&(tmp)))=(char*)((tmp!=NULL)?(tmp)->hh.next:NULL))) #else #define HASH_ITER(hh,head,el,tmp) \ for(((el)=(head)), ((tmp)=DECLTYPE(el)((head!=NULL)?(head)->hh.next:NULL)); \ (el) != NULL; ((el)=(tmp)), ((tmp)=DECLTYPE(el)((tmp!=NULL)?(tmp)->hh.next:NULL))) #endif /* obtain a count of items in the hash */ #define HASH_COUNT(head) HASH_CNT(hh,head) #define HASH_CNT(hh,head) ((head != NULL)?((head)->hh.tbl->num_items):0U) typedef struct UT_hash_bucket { struct UT_hash_handle *hh_head; unsigned count; /* expand_mult is normally set to 0. In this situation, the max chain length * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If * the bucket's chain exceeds this length, bucket expansion is triggered). * However, setting expand_mult to a non-zero value delays bucket expansion * (that would be triggered by additions to this particular bucket) * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH. * (The multiplier is simply expand_mult+1). The whole idea of this * multiplier is to reduce bucket expansions, since they are expensive, in * situations where we know that a particular bucket tends to be overused. * It is better to let its chain length grow to a longer yet-still-bounded * value, than to do an O(n) bucket expansion too often. */ unsigned expand_mult; } UT_hash_bucket; /* random signature used only to find hash tables in external analysis */ #define HASH_SIGNATURE 0xa0111fe1u #define HASH_BLOOM_SIGNATURE 0xb12220f2u typedef struct UT_hash_table { UT_hash_bucket *buckets; unsigned num_buckets, log2_num_buckets; unsigned num_items; struct UT_hash_handle *tail; /* tail hh in app order, for fast append */ ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */ /* in an ideal situation (all buckets used equally), no bucket would have * more than ceil(#items/#buckets) items. that's the ideal chain length. */ unsigned ideal_chain_maxlen; /* nonideal_items is the number of items in the hash whose chain position * exceeds the ideal chain maxlen. these items pay the penalty for an uneven * hash distribution; reaching them in a chain traversal takes >ideal steps */ unsigned nonideal_items; /* ineffective expands occur when a bucket doubling was performed, but * afterward, more than half the items in the hash had nonideal chain * positions. If this happens on two consecutive expansions we inhibit any * further expansion, as it's not helping; this happens when the hash * function isn't a good fit for the key domain. When expansion is inhibited * the hash will still work, albeit no longer in constant time. */ unsigned ineff_expands, noexpand; uint32_t signature; /* used only to find hash tables in external analysis */ #ifdef HASH_BLOOM uint32_t bloom_sig; /* used only to test bloom exists in external analysis */ uint8_t *bloom_bv; uint8_t bloom_nbits; #endif } UT_hash_table; typedef struct UT_hash_handle { struct UT_hash_table *tbl; void *prev; /* prev element in app order */ void *next; /* next element in app order */ struct UT_hash_handle *hh_prev; /* previous hh in bucket order */ struct UT_hash_handle *hh_next; /* next hh in bucket order */ void *key; /* ptr to enclosing struct's key */ unsigned keylen; /* enclosing struct's key len */ unsigned hashv; /* result of hash-fcn(key) */ } UT_hash_handle; #endif /* UTHASH_H */ goxel-0.11.0/ext_src/uthash/utlist.h000066400000000000000000002371401435762723100173700ustar00rootroot00000000000000/* Copyright (c) 2007-2018, Troy D. Hanson http://troydhanson.github.com/uthash/ 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. 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 OWNER 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 UTLIST_H #define UTLIST_H #define UTLIST_VERSION 2.1.0 #include /* * This file contains macros to manipulate singly and doubly-linked lists. * * 1. LL_ macros: singly-linked lists. * 2. DL_ macros: doubly-linked lists. * 3. CDL_ macros: circular doubly-linked lists. * * To use singly-linked lists, your structure must have a "next" pointer. * To use doubly-linked lists, your structure must "prev" and "next" pointers. * Either way, the pointer to the head of the list must be initialized to NULL. * * ----------------.EXAMPLE ------------------------- * struct item { * int id; * struct item *prev, *next; * } * * struct item *list = NULL: * * int main() { * struct item *item; * ... allocate and populate item ... * DL_APPEND(list, item); * } * -------------------------------------------------- * * For doubly-linked lists, the append and delete macros are O(1) * For singly-linked lists, append and delete are O(n) but prepend is O(1) * The sort macro is O(n log(n)) for all types of single/double/circular lists. */ /* These macros use decltype or the earlier __typeof GNU extension. As decltype is only available in newer compilers (VS2010 or gcc 4.3+ when compiling c++ source) this code uses whatever method is needed or, for VS2008 where neither is available, uses casting workarounds. */ #if !defined(LDECLTYPE) && !defined(NO_DECLTYPE) #if defined(_MSC_VER) /* MS compiler */ #if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */ #define LDECLTYPE(x) decltype(x) #else /* VS2008 or older (or VS2010 in C mode) */ #define NO_DECLTYPE #endif #elif defined(__BORLANDC__) || defined(__ICCARM__) || defined(__LCC__) || defined(__WATCOMC__) #define NO_DECLTYPE #else /* GNU, Sun and other compilers */ #define LDECLTYPE(x) __typeof(x) #endif #endif /* for VS2008 we use some workarounds to get around the lack of decltype, * namely, we always reassign our tmp variable to the list head if we need * to dereference its prev/next pointers, and save/restore the real head.*/ #ifdef NO_DECLTYPE #define IF_NO_DECLTYPE(x) x #define LDECLTYPE(x) char* #define UTLIST_SV(elt,list) _tmp = (char*)(list); {char **_alias = (char**)&(list); *_alias = (elt); } #define UTLIST_NEXT(elt,list,next) ((char*)((list)->next)) #define UTLIST_NEXTASGN(elt,list,to,next) { char **_alias = (char**)&((list)->next); *_alias=(char*)(to); } /* #define UTLIST_PREV(elt,list,prev) ((char*)((list)->prev)) */ #define UTLIST_PREVASGN(elt,list,to,prev) { char **_alias = (char**)&((list)->prev); *_alias=(char*)(to); } #define UTLIST_RS(list) { char **_alias = (char**)&(list); *_alias=_tmp; } #define UTLIST_CASTASGN(a,b) { char **_alias = (char**)&(a); *_alias=(char*)(b); } #else #define IF_NO_DECLTYPE(x) #define UTLIST_SV(elt,list) #define UTLIST_NEXT(elt,list,next) ((elt)->next) #define UTLIST_NEXTASGN(elt,list,to,next) ((elt)->next)=(to) /* #define UTLIST_PREV(elt,list,prev) ((elt)->prev) */ #define UTLIST_PREVASGN(elt,list,to,prev) ((elt)->prev)=(to) #define UTLIST_RS(list) #define UTLIST_CASTASGN(a,b) (a)=(b) #endif /****************************************************************************** * The sort macro is an adaptation of Simon Tatham's O(n log(n)) mergesort * * Unwieldy variable names used here to avoid shadowing passed-in variables. * *****************************************************************************/ #define LL_SORT(list, cmp) \ LL_SORT2(list, cmp, next) #define LL_SORT2(list, cmp, next) \ do { \ LDECLTYPE(list) _ls_p; \ LDECLTYPE(list) _ls_q; \ LDECLTYPE(list) _ls_e; \ LDECLTYPE(list) _ls_tail; \ IF_NO_DECLTYPE(LDECLTYPE(list) _tmp;) \ int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \ if (list) { \ _ls_insize = 1; \ _ls_looping = 1; \ while (_ls_looping) { \ UTLIST_CASTASGN(_ls_p,list); \ (list) = NULL; \ _ls_tail = NULL; \ _ls_nmerges = 0; \ while (_ls_p) { \ _ls_nmerges++; \ _ls_q = _ls_p; \ _ls_psize = 0; \ for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \ _ls_psize++; \ UTLIST_SV(_ls_q,list); _ls_q = UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); \ if (!_ls_q) break; \ } \ _ls_qsize = _ls_insize; \ while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \ if (_ls_psize == 0) { \ _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q = \ UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--; \ } else if (_ls_qsize == 0 || !_ls_q) { \ _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p = \ UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--; \ } else if (cmp(_ls_p,_ls_q) <= 0) { \ _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p = \ UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--; \ } else { \ _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q = \ UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--; \ } \ if (_ls_tail) { \ UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_ls_e,next); UTLIST_RS(list); \ } else { \ UTLIST_CASTASGN(list,_ls_e); \ } \ _ls_tail = _ls_e; \ } \ _ls_p = _ls_q; \ } \ if (_ls_tail) { \ UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,NULL,next); UTLIST_RS(list); \ } \ if (_ls_nmerges <= 1) { \ _ls_looping=0; \ } \ _ls_insize *= 2; \ } \ } \ } while (0) #define DL_SORT(list, cmp) \ DL_SORT2(list, cmp, prev, next) #define DL_SORT2(list, cmp, prev, next) \ do { \ LDECLTYPE(list) _ls_p; \ LDECLTYPE(list) _ls_q; \ LDECLTYPE(list) _ls_e; \ LDECLTYPE(list) _ls_tail; \ IF_NO_DECLTYPE(LDECLTYPE(list) _tmp;) \ int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \ if (list) { \ _ls_insize = 1; \ _ls_looping = 1; \ while (_ls_looping) { \ UTLIST_CASTASGN(_ls_p,list); \ (list) = NULL; \ _ls_tail = NULL; \ _ls_nmerges = 0; \ while (_ls_p) { \ _ls_nmerges++; \ _ls_q = _ls_p; \ _ls_psize = 0; \ for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \ _ls_psize++; \ UTLIST_SV(_ls_q,list); _ls_q = UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); \ if (!_ls_q) break; \ } \ _ls_qsize = _ls_insize; \ while ((_ls_psize > 0) || ((_ls_qsize > 0) && _ls_q)) { \ if (_ls_psize == 0) { \ _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q = \ UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--; \ } else if ((_ls_qsize == 0) || (!_ls_q)) { \ _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p = \ UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--; \ } else if (cmp(_ls_p,_ls_q) <= 0) { \ _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p = \ UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--; \ } else { \ _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q = \ UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--; \ } \ if (_ls_tail) { \ UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_ls_e,next); UTLIST_RS(list); \ } else { \ UTLIST_CASTASGN(list,_ls_e); \ } \ UTLIST_SV(_ls_e,list); UTLIST_PREVASGN(_ls_e,list,_ls_tail,prev); UTLIST_RS(list); \ _ls_tail = _ls_e; \ } \ _ls_p = _ls_q; \ } \ UTLIST_CASTASGN((list)->prev, _ls_tail); \ UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,NULL,next); UTLIST_RS(list); \ if (_ls_nmerges <= 1) { \ _ls_looping=0; \ } \ _ls_insize *= 2; \ } \ } \ } while (0) #define CDL_SORT(list, cmp) \ CDL_SORT2(list, cmp, prev, next) #define CDL_SORT2(list, cmp, prev, next) \ do { \ LDECLTYPE(list) _ls_p; \ LDECLTYPE(list) _ls_q; \ LDECLTYPE(list) _ls_e; \ LDECLTYPE(list) _ls_tail; \ LDECLTYPE(list) _ls_oldhead; \ LDECLTYPE(list) _tmp; \ int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \ if (list) { \ _ls_insize = 1; \ _ls_looping = 1; \ while (_ls_looping) { \ UTLIST_CASTASGN(_ls_p,list); \ UTLIST_CASTASGN(_ls_oldhead,list); \ (list) = NULL; \ _ls_tail = NULL; \ _ls_nmerges = 0; \ while (_ls_p) { \ _ls_nmerges++; \ _ls_q = _ls_p; \ _ls_psize = 0; \ for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \ _ls_psize++; \ UTLIST_SV(_ls_q,list); \ if (UTLIST_NEXT(_ls_q,list,next) == _ls_oldhead) { \ _ls_q = NULL; \ } else { \ _ls_q = UTLIST_NEXT(_ls_q,list,next); \ } \ UTLIST_RS(list); \ if (!_ls_q) break; \ } \ _ls_qsize = _ls_insize; \ while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \ if (_ls_psize == 0) { \ _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q = \ UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--; \ if (_ls_q == _ls_oldhead) { _ls_q = NULL; } \ } else if (_ls_qsize == 0 || !_ls_q) { \ _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p = \ UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--; \ if (_ls_p == _ls_oldhead) { _ls_p = NULL; } \ } else if (cmp(_ls_p,_ls_q) <= 0) { \ _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p = \ UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--; \ if (_ls_p == _ls_oldhead) { _ls_p = NULL; } \ } else { \ _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q = \ UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--; \ if (_ls_q == _ls_oldhead) { _ls_q = NULL; } \ } \ if (_ls_tail) { \ UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_ls_e,next); UTLIST_RS(list); \ } else { \ UTLIST_CASTASGN(list,_ls_e); \ } \ UTLIST_SV(_ls_e,list); UTLIST_PREVASGN(_ls_e,list,_ls_tail,prev); UTLIST_RS(list); \ _ls_tail = _ls_e; \ } \ _ls_p = _ls_q; \ } \ UTLIST_CASTASGN((list)->prev,_ls_tail); \ UTLIST_CASTASGN(_tmp,list); \ UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_tmp,next); UTLIST_RS(list); \ if (_ls_nmerges <= 1) { \ _ls_looping=0; \ } \ _ls_insize *= 2; \ } \ } \ } while (0) /****************************************************************************** * singly linked list macros (non-circular) * *****************************************************************************/ #define LL_PREPEND(head,add) \ LL_PREPEND2(head,add,next) #define LL_PREPEND2(head,add,next) \ do { \ (add)->next = (head); \ (head) = (add); \ } while (0) #define LL_CONCAT(head1,head2) \ LL_CONCAT2(head1,head2,next) #define LL_CONCAT2(head1,head2,next) \ do { \ LDECLTYPE(head1) _tmp; \ if (head1) { \ _tmp = (head1); \ while (_tmp->next) { _tmp = _tmp->next; } \ _tmp->next=(head2); \ } else { \ (head1)=(head2); \ } \ } while (0) #define LL_APPEND(head,add) \ LL_APPEND2(head,add,next) #define LL_APPEND2(head,add,next) \ do { \ LDECLTYPE(head) _tmp; \ (add)->next=NULL; \ if (head) { \ _tmp = (head); \ while (_tmp->next) { _tmp = _tmp->next; } \ _tmp->next=(add); \ } else { \ (head)=(add); \ } \ } while (0) #define LL_INSERT_INORDER(head,add,cmp) \ LL_INSERT_INORDER2(head,add,cmp,next) #define LL_INSERT_INORDER2(head,add,cmp,next) \ do { \ LDECLTYPE(head) _tmp; \ if (head) { \ LL_LOWER_BOUND2(head, _tmp, add, cmp, next); \ LL_APPEND_ELEM2(head, _tmp, add, next); \ } else { \ (head) = (add); \ (head)->next = NULL; \ } \ } while (0) #define LL_LOWER_BOUND(head,elt,like,cmp) \ LL_LOWER_BOUND2(head,elt,like,cmp,next) #define LL_LOWER_BOUND2(head,elt,like,cmp,next) \ do { \ if ((head) == NULL || (cmp(head, like)) >= 0) { \ (elt) = NULL; \ } else { \ for ((elt) = (head); (elt)->next != NULL; (elt) = (elt)->next) { \ if (cmp((elt)->next, like) >= 0) { \ break; \ } \ } \ } \ } while (0) #define LL_DELETE(head,del) \ LL_DELETE2(head,del,next) #define LL_DELETE2(head,del,next) \ do { \ LDECLTYPE(head) _tmp; \ if ((head) == (del)) { \ (head)=(head)->next; \ } else { \ _tmp = (head); \ while (_tmp->next && (_tmp->next != (del))) { \ _tmp = _tmp->next; \ } \ if (_tmp->next) { \ _tmp->next = (del)->next; \ } \ } \ } while (0) #define LL_COUNT(head,el,counter) \ LL_COUNT2(head,el,counter,next) \ #define LL_COUNT2(head,el,counter,next) \ do { \ (counter) = 0; \ LL_FOREACH2(head,el,next) { ++(counter); } \ } while (0) #define LL_FOREACH(head,el) \ LL_FOREACH2(head,el,next) #define LL_FOREACH2(head,el,next) \ for ((el) = (head); el; (el) = (el)->next) #define LL_FOREACH_SAFE(head,el,tmp) \ LL_FOREACH_SAFE2(head,el,tmp,next) #define LL_FOREACH_SAFE2(head,el,tmp,next) \ for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp)) #define LL_SEARCH_SCALAR(head,out,field,val) \ LL_SEARCH_SCALAR2(head,out,field,val,next) #define LL_SEARCH_SCALAR2(head,out,field,val,next) \ do { \ LL_FOREACH2(head,out,next) { \ if ((out)->field == (val)) break; \ } \ } while (0) #define LL_SEARCH(head,out,elt,cmp) \ LL_SEARCH2(head,out,elt,cmp,next) #define LL_SEARCH2(head,out,elt,cmp,next) \ do { \ LL_FOREACH2(head,out,next) { \ if ((cmp(out,elt))==0) break; \ } \ } while (0) #define LL_REPLACE_ELEM2(head, el, add, next) \ do { \ LDECLTYPE(head) _tmp; \ assert((head) != NULL); \ assert((el) != NULL); \ assert((add) != NULL); \ (add)->next = (el)->next; \ if ((head) == (el)) { \ (head) = (add); \ } else { \ _tmp = (head); \ while (_tmp->next && (_tmp->next != (el))) { \ _tmp = _tmp->next; \ } \ if (_tmp->next) { \ _tmp->next = (add); \ } \ } \ } while (0) #define LL_REPLACE_ELEM(head, el, add) \ LL_REPLACE_ELEM2(head, el, add, next) #define LL_PREPEND_ELEM2(head, el, add, next) \ do { \ if (el) { \ LDECLTYPE(head) _tmp; \ assert((head) != NULL); \ assert((add) != NULL); \ (add)->next = (el); \ if ((head) == (el)) { \ (head) = (add); \ } else { \ _tmp = (head); \ while (_tmp->next && (_tmp->next != (el))) { \ _tmp = _tmp->next; \ } \ if (_tmp->next) { \ _tmp->next = (add); \ } \ } \ } else { \ LL_APPEND2(head, add, next); \ } \ } while (0) \ #define LL_PREPEND_ELEM(head, el, add) \ LL_PREPEND_ELEM2(head, el, add, next) #define LL_APPEND_ELEM2(head, el, add, next) \ do { \ if (el) { \ assert((head) != NULL); \ assert((add) != NULL); \ (add)->next = (el)->next; \ (el)->next = (add); \ } else { \ LL_PREPEND2(head, add, next); \ } \ } while (0) \ #define LL_APPEND_ELEM(head, el, add) \ LL_APPEND_ELEM2(head, el, add, next) #ifdef NO_DECLTYPE /* Here are VS2008 / NO_DECLTYPE replacements for a few functions */ #undef LL_CONCAT2 #define LL_CONCAT2(head1,head2,next) \ do { \ char *_tmp; \ if (head1) { \ _tmp = (char*)(head1); \ while ((head1)->next) { (head1) = (head1)->next; } \ (head1)->next = (head2); \ UTLIST_RS(head1); \ } else { \ (head1)=(head2); \ } \ } while (0) #undef LL_APPEND2 #define LL_APPEND2(head,add,next) \ do { \ if (head) { \ (add)->next = head; /* use add->next as a temp variable */ \ while ((add)->next->next) { (add)->next = (add)->next->next; } \ (add)->next->next=(add); \ } else { \ (head)=(add); \ } \ (add)->next=NULL; \ } while (0) #undef LL_INSERT_INORDER2 #define LL_INSERT_INORDER2(head,add,cmp,next) \ do { \ if ((head) == NULL || (cmp(head, add)) >= 0) { \ (add)->next = (head); \ (head) = (add); \ } else { \ char *_tmp = (char*)(head); \ while ((head)->next != NULL && (cmp((head)->next, add)) < 0) { \ (head) = (head)->next; \ } \ (add)->next = (head)->next; \ (head)->next = (add); \ UTLIST_RS(head); \ } \ } while (0) #undef LL_DELETE2 #define LL_DELETE2(head,del,next) \ do { \ if ((head) == (del)) { \ (head)=(head)->next; \ } else { \ char *_tmp = (char*)(head); \ while ((head)->next && ((head)->next != (del))) { \ (head) = (head)->next; \ } \ if ((head)->next) { \ (head)->next = ((del)->next); \ } \ UTLIST_RS(head); \ } \ } while (0) #undef LL_REPLACE_ELEM2 #define LL_REPLACE_ELEM2(head, el, add, next) \ do { \ assert((head) != NULL); \ assert((el) != NULL); \ assert((add) != NULL); \ if ((head) == (el)) { \ (head) = (add); \ } else { \ (add)->next = head; \ while ((add)->next->next && ((add)->next->next != (el))) { \ (add)->next = (add)->next->next; \ } \ if ((add)->next->next) { \ (add)->next->next = (add); \ } \ } \ (add)->next = (el)->next; \ } while (0) #undef LL_PREPEND_ELEM2 #define LL_PREPEND_ELEM2(head, el, add, next) \ do { \ if (el) { \ assert((head) != NULL); \ assert((add) != NULL); \ if ((head) == (el)) { \ (head) = (add); \ } else { \ (add)->next = (head); \ while ((add)->next->next && ((add)->next->next != (el))) { \ (add)->next = (add)->next->next; \ } \ if ((add)->next->next) { \ (add)->next->next = (add); \ } \ } \ (add)->next = (el); \ } else { \ LL_APPEND2(head, add, next); \ } \ } while (0) \ #endif /* NO_DECLTYPE */ /****************************************************************************** * doubly linked list macros (non-circular) * *****************************************************************************/ #define DL_PREPEND(head,add) \ DL_PREPEND2(head,add,prev,next) #define DL_PREPEND2(head,add,prev,next) \ do { \ (add)->next = (head); \ if (head) { \ (add)->prev = (head)->prev; \ (head)->prev = (add); \ } else { \ (add)->prev = (add); \ } \ (head) = (add); \ } while (0) #define DL_APPEND(head,add) \ DL_APPEND2(head,add,prev,next) #define DL_APPEND2(head,add,prev,next) \ do { \ if (head) { \ (add)->prev = (head)->prev; \ (head)->prev->next = (add); \ (head)->prev = (add); \ (add)->next = NULL; \ } else { \ (head)=(add); \ (head)->prev = (head); \ (head)->next = NULL; \ } \ } while (0) #define DL_INSERT_INORDER(head,add,cmp) \ DL_INSERT_INORDER2(head,add,cmp,prev,next) #define DL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ LDECLTYPE(head) _tmp; \ if (head) { \ DL_LOWER_BOUND2(head, _tmp, add, cmp, next); \ DL_APPEND_ELEM2(head, _tmp, add, prev, next); \ } else { \ (head) = (add); \ (head)->prev = (head); \ (head)->next = NULL; \ } \ } while (0) #define DL_LOWER_BOUND(head,elt,like,cmp) \ DL_LOWER_BOUND2(head,elt,like,cmp,next) #define DL_LOWER_BOUND2(head,elt,like,cmp,next) \ do { \ if ((head) == NULL || (cmp(head, like)) >= 0) { \ (elt) = NULL; \ } else { \ for ((elt) = (head); (elt)->next != NULL; (elt) = (elt)->next) { \ if ((cmp((elt)->next, like)) >= 0) { \ break; \ } \ } \ } \ } while (0) #define DL_CONCAT(head1,head2) \ DL_CONCAT2(head1,head2,prev,next) #define DL_CONCAT2(head1,head2,prev,next) \ do { \ LDECLTYPE(head1) _tmp; \ if (head2) { \ if (head1) { \ UTLIST_CASTASGN(_tmp, (head2)->prev); \ (head2)->prev = (head1)->prev; \ (head1)->prev->next = (head2); \ UTLIST_CASTASGN((head1)->prev, _tmp); \ } else { \ (head1)=(head2); \ } \ } \ } while (0) #define DL_DELETE(head,del) \ DL_DELETE2(head,del,prev,next) #define DL_DELETE2(head,del,prev,next) \ do { \ assert((head) != NULL); \ assert((del)->prev != NULL); \ if ((del)->prev == (del)) { \ (head)=NULL; \ } else if ((del)==(head)) { \ (del)->next->prev = (del)->prev; \ (head) = (del)->next; \ } else { \ (del)->prev->next = (del)->next; \ if ((del)->next) { \ (del)->next->prev = (del)->prev; \ } else { \ (head)->prev = (del)->prev; \ } \ } \ } while (0) #define DL_COUNT(head,el,counter) \ DL_COUNT2(head,el,counter,next) \ #define DL_COUNT2(head,el,counter,next) \ do { \ (counter) = 0; \ DL_FOREACH2(head,el,next) { ++(counter); } \ } while (0) #define DL_FOREACH(head,el) \ DL_FOREACH2(head,el,next) #define DL_FOREACH2(head,el,next) \ for ((el) = (head); el; (el) = (el)->next) /* this version is safe for deleting the elements during iteration */ #define DL_FOREACH_SAFE(head,el,tmp) \ DL_FOREACH_SAFE2(head,el,tmp,next) #define DL_FOREACH_SAFE2(head,el,tmp,next) \ for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp)) /* these are identical to their singly-linked list counterparts */ #define DL_SEARCH_SCALAR LL_SEARCH_SCALAR #define DL_SEARCH LL_SEARCH #define DL_SEARCH_SCALAR2 LL_SEARCH_SCALAR2 #define DL_SEARCH2 LL_SEARCH2 #define DL_REPLACE_ELEM2(head, el, add, prev, next) \ do { \ assert((head) != NULL); \ assert((el) != NULL); \ assert((add) != NULL); \ if ((head) == (el)) { \ (head) = (add); \ (add)->next = (el)->next; \ if ((el)->next == NULL) { \ (add)->prev = (add); \ } else { \ (add)->prev = (el)->prev; \ (add)->next->prev = (add); \ } \ } else { \ (add)->next = (el)->next; \ (add)->prev = (el)->prev; \ (add)->prev->next = (add); \ if ((el)->next == NULL) { \ (head)->prev = (add); \ } else { \ (add)->next->prev = (add); \ } \ } \ } while (0) #define DL_REPLACE_ELEM(head, el, add) \ DL_REPLACE_ELEM2(head, el, add, prev, next) #define DL_PREPEND_ELEM2(head, el, add, prev, next) \ do { \ if (el) { \ assert((head) != NULL); \ assert((add) != NULL); \ (add)->next = (el); \ (add)->prev = (el)->prev; \ (el)->prev = (add); \ if ((head) == (el)) { \ (head) = (add); \ } else { \ (add)->prev->next = (add); \ } \ } else { \ DL_APPEND2(head, add, prev, next); \ } \ } while (0) \ #define DL_PREPEND_ELEM(head, el, add) \ DL_PREPEND_ELEM2(head, el, add, prev, next) #define DL_APPEND_ELEM2(head, el, add, prev, next) \ do { \ if (el) { \ assert((head) != NULL); \ assert((add) != NULL); \ (add)->next = (el)->next; \ (add)->prev = (el); \ (el)->next = (add); \ if ((add)->next) { \ (add)->next->prev = (add); \ } else { \ (head)->prev = (add); \ } \ } else { \ DL_PREPEND2(head, add, prev, next); \ } \ } while (0) \ #define DL_APPEND_ELEM(head, el, add) \ DL_APPEND_ELEM2(head, el, add, prev, next) #ifdef NO_DECLTYPE /* Here are VS2008 / NO_DECLTYPE replacements for a few functions */ #undef DL_INSERT_INORDER2 #define DL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ if ((head) == NULL) { \ (add)->prev = (add); \ (add)->next = NULL; \ (head) = (add); \ } else if ((cmp(head, add)) >= 0) { \ (add)->prev = (head)->prev; \ (add)->next = (head); \ (head)->prev = (add); \ (head) = (add); \ } else { \ char *_tmp = (char*)(head); \ while ((head)->next && (cmp((head)->next, add)) < 0) { \ (head) = (head)->next; \ } \ (add)->prev = (head); \ (add)->next = (head)->next; \ (head)->next = (add); \ UTLIST_RS(head); \ if ((add)->next) { \ (add)->next->prev = (add); \ } else { \ (head)->prev = (add); \ } \ } \ } while (0) #endif /* NO_DECLTYPE */ /****************************************************************************** * circular doubly linked list macros * *****************************************************************************/ #define CDL_APPEND(head,add) \ CDL_APPEND2(head,add,prev,next) #define CDL_APPEND2(head,add,prev,next) \ do { \ if (head) { \ (add)->prev = (head)->prev; \ (add)->next = (head); \ (head)->prev = (add); \ (add)->prev->next = (add); \ } else { \ (add)->prev = (add); \ (add)->next = (add); \ (head) = (add); \ } \ } while (0) #define CDL_PREPEND(head,add) \ CDL_PREPEND2(head,add,prev,next) #define CDL_PREPEND2(head,add,prev,next) \ do { \ if (head) { \ (add)->prev = (head)->prev; \ (add)->next = (head); \ (head)->prev = (add); \ (add)->prev->next = (add); \ } else { \ (add)->prev = (add); \ (add)->next = (add); \ } \ (head) = (add); \ } while (0) #define CDL_INSERT_INORDER(head,add,cmp) \ CDL_INSERT_INORDER2(head,add,cmp,prev,next) #define CDL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ LDECLTYPE(head) _tmp; \ if (head) { \ CDL_LOWER_BOUND2(head, _tmp, add, cmp, next); \ CDL_APPEND_ELEM2(head, _tmp, add, prev, next); \ } else { \ (head) = (add); \ (head)->next = (head); \ (head)->prev = (head); \ } \ } while (0) #define CDL_LOWER_BOUND(head,elt,like,cmp) \ CDL_LOWER_BOUND2(head,elt,like,cmp,next) #define CDL_LOWER_BOUND2(head,elt,like,cmp,next) \ do { \ if ((head) == NULL || (cmp(head, like)) >= 0) { \ (elt) = NULL; \ } else { \ for ((elt) = (head); (elt)->next != (head); (elt) = (elt)->next) { \ if ((cmp((elt)->next, like)) >= 0) { \ break; \ } \ } \ } \ } while (0) #define CDL_DELETE(head,del) \ CDL_DELETE2(head,del,prev,next) #define CDL_DELETE2(head,del,prev,next) \ do { \ if (((head)==(del)) && ((head)->next == (head))) { \ (head) = NULL; \ } else { \ (del)->next->prev = (del)->prev; \ (del)->prev->next = (del)->next; \ if ((del) == (head)) (head)=(del)->next; \ } \ } while (0) #define CDL_COUNT(head,el,counter) \ CDL_COUNT2(head,el,counter,next) \ #define CDL_COUNT2(head, el, counter,next) \ do { \ (counter) = 0; \ CDL_FOREACH2(head,el,next) { ++(counter); } \ } while (0) #define CDL_FOREACH(head,el) \ CDL_FOREACH2(head,el,next) #define CDL_FOREACH2(head,el,next) \ for ((el)=(head);el;(el)=(((el)->next==(head)) ? NULL : (el)->next)) #define CDL_FOREACH_SAFE(head,el,tmp1,tmp2) \ CDL_FOREACH_SAFE2(head,el,tmp1,tmp2,prev,next) #define CDL_FOREACH_SAFE2(head,el,tmp1,tmp2,prev,next) \ for ((el) = (head), (tmp1) = (head) ? (head)->prev : NULL; \ (el) && ((tmp2) = (el)->next, 1); \ (el) = ((el) == (tmp1) ? NULL : (tmp2))) #define CDL_SEARCH_SCALAR(head,out,field,val) \ CDL_SEARCH_SCALAR2(head,out,field,val,next) #define CDL_SEARCH_SCALAR2(head,out,field,val,next) \ do { \ CDL_FOREACH2(head,out,next) { \ if ((out)->field == (val)) break; \ } \ } while (0) #define CDL_SEARCH(head,out,elt,cmp) \ CDL_SEARCH2(head,out,elt,cmp,next) #define CDL_SEARCH2(head,out,elt,cmp,next) \ do { \ CDL_FOREACH2(head,out,next) { \ if ((cmp(out,elt))==0) break; \ } \ } while (0) #define CDL_REPLACE_ELEM2(head, el, add, prev, next) \ do { \ assert((head) != NULL); \ assert((el) != NULL); \ assert((add) != NULL); \ if ((el)->next == (el)) { \ (add)->next = (add); \ (add)->prev = (add); \ (head) = (add); \ } else { \ (add)->next = (el)->next; \ (add)->prev = (el)->prev; \ (add)->next->prev = (add); \ (add)->prev->next = (add); \ if ((head) == (el)) { \ (head) = (add); \ } \ } \ } while (0) #define CDL_REPLACE_ELEM(head, el, add) \ CDL_REPLACE_ELEM2(head, el, add, prev, next) #define CDL_PREPEND_ELEM2(head, el, add, prev, next) \ do { \ if (el) { \ assert((head) != NULL); \ assert((add) != NULL); \ (add)->next = (el); \ (add)->prev = (el)->prev; \ (el)->prev = (add); \ (add)->prev->next = (add); \ if ((head) == (el)) { \ (head) = (add); \ } \ } else { \ CDL_APPEND2(head, add, prev, next); \ } \ } while (0) #define CDL_PREPEND_ELEM(head, el, add) \ CDL_PREPEND_ELEM2(head, el, add, prev, next) #define CDL_APPEND_ELEM2(head, el, add, prev, next) \ do { \ if (el) { \ assert((head) != NULL); \ assert((add) != NULL); \ (add)->next = (el)->next; \ (add)->prev = (el); \ (el)->next = (add); \ (add)->next->prev = (add); \ } else { \ CDL_PREPEND2(head, add, prev, next); \ } \ } while (0) #define CDL_APPEND_ELEM(head, el, add) \ CDL_APPEND_ELEM2(head, el, add, prev, next) #ifdef NO_DECLTYPE /* Here are VS2008 / NO_DECLTYPE replacements for a few functions */ #undef CDL_INSERT_INORDER2 #define CDL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ if ((head) == NULL) { \ (add)->prev = (add); \ (add)->next = (add); \ (head) = (add); \ } else if ((cmp(head, add)) >= 0) { \ (add)->prev = (head)->prev; \ (add)->next = (head); \ (add)->prev->next = (add); \ (head)->prev = (add); \ (head) = (add); \ } else { \ char *_tmp = (char*)(head); \ while ((char*)(head)->next != _tmp && (cmp((head)->next, add)) < 0) { \ (head) = (head)->next; \ } \ (add)->prev = (head); \ (add)->next = (head)->next; \ (add)->next->prev = (add); \ (head)->next = (add); \ UTLIST_RS(head); \ } \ } while (0) #endif /* NO_DECLTYPE */ #endif /* UTLIST_H */ goxel-0.11.0/ext_src/xxhash/000077500000000000000000000000001435762723100156735ustar00rootroot00000000000000goxel-0.11.0/ext_src/xxhash/xxhash.c000066400000000000000000001111711435762723100173440ustar00rootroot00000000000000/* * xxHash - Fast Hash algorithm * Copyright (C) 2012-2016, Yann Collet * * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) * * 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 * OWNER 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. * * You can contact the author at : * - xxHash homepage: http://www.xxhash.com * - xxHash source repository : https://github.com/Cyan4973/xxHash */ /* ************************************* * Tuning parameters ***************************************/ /*!XXH_FORCE_MEMORY_ACCESS : * By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable. * Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal. * The below switch allow to select different access method for improved performance. * Method 0 (default) : use `memcpy()`. Safe and portable. * Method 1 : `__packed` statement. It depends on compiler extension (ie, not portable). * This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`. * Method 2 : direct access. This method doesn't depend on compiler but violate C standard. * It can generate buggy code on targets which do not support unaligned memory accesses. * But in some circumstances, it's the only known way to get the most performance (ie GCC + ARMv6) * See http://stackoverflow.com/a/32095106/646947 for details. * Prefer these methods in priority order (0 > 1 > 2) */ #ifndef XXH_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */ # if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \ || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \ || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) ) # define XXH_FORCE_MEMORY_ACCESS 2 # elif (defined(__INTEL_COMPILER) && !defined(_WIN32)) || \ (defined(__GNUC__) && ( defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \ || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \ || defined(__ARM_ARCH_7S__) )) # define XXH_FORCE_MEMORY_ACCESS 1 # endif #endif /*!XXH_ACCEPT_NULL_INPUT_POINTER : * If input pointer is NULL, xxHash default behavior is to dereference it, triggering a segfault. * When this macro is enabled, xxHash actively checks input for null pointer. * It it is, result for null input pointers is the same as a null-length input. */ #ifndef XXH_ACCEPT_NULL_INPUT_POINTER /* can be defined externally */ # define XXH_ACCEPT_NULL_INPUT_POINTER 0 #endif /*!XXH_FORCE_ALIGN_CHECK : * This is a minor performance trick, only useful with lots of very small keys. * It means : check for aligned/unaligned input. * The check costs one initial branch per hash; * set it to 0 when the input is guaranteed to be aligned, * or when alignment doesn't matter for performance. */ #ifndef XXH_FORCE_ALIGN_CHECK /* can be defined externally */ # if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) # define XXH_FORCE_ALIGN_CHECK 0 # else # define XXH_FORCE_ALIGN_CHECK 1 # endif #endif /*!XXH_REROLL: * Whether to reroll XXH32_finalize, and XXH64_finalize, * instead of using an unrolled jump table/if statement loop. * * This is automatically defined on -Os/-Oz on GCC and Clang. */ #ifndef XXH_REROLL # if defined(__OPTIMIZE_SIZE__) # define XXH_REROLL 1 # else # define XXH_REROLL 0 # endif #endif /* ************************************* * Includes & Memory related functions ***************************************/ /*! Modify the local functions below should you wish to use some other memory routines * for malloc(), free() */ #include static void* XXH_malloc(size_t s) { return malloc(s); } static void XXH_free (void* p) { free(p); } /*! and for memcpy() */ #include static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); } #include /* ULLONG_MAX */ #define XXH_STATIC_LINKING_ONLY #include "xxhash.h" /* ************************************* * Compiler Specific Options ***************************************/ #ifdef _MSC_VER /* Visual Studio */ # pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ # define XXH_FORCE_INLINE static __forceinline # define XXH_NO_INLINE static __declspec(noinline) #else # if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ # ifdef __GNUC__ # define XXH_FORCE_INLINE static inline __attribute__((always_inline)) # define XXH_NO_INLINE static __attribute__((noinline)) # else # define XXH_FORCE_INLINE static inline # define XXH_NO_INLINE static # endif # else # define XXH_FORCE_INLINE static # define XXH_NO_INLINE static # endif /* __STDC_VERSION__ */ #endif /* ************************************* * Debug ***************************************/ /* DEBUGLEVEL is expected to be defined externally, * typically through compiler command line. * Value must be a number. */ #ifndef DEBUGLEVEL # define DEBUGLEVEL 0 #endif #if (DEBUGLEVEL>=1) # include /* note : can still be disabled with NDEBUG */ # define XXH_ASSERT(c) assert(c) #else # define XXH_ASSERT(c) ((void)0) #endif /* note : use after variable declarations */ #define XXH_STATIC_ASSERT(c) { enum { XXH_sa = 1/(int)(!!(c)) }; } /* ************************************* * Basic Types ***************************************/ #ifndef MEM_MODULE # if !defined (__VMS) \ && (defined (__cplusplus) \ || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) # include typedef uint8_t BYTE; typedef uint16_t U16; typedef uint32_t U32; # else typedef unsigned char BYTE; typedef unsigned short U16; typedef unsigned int U32; # endif #endif /* === Memory access === */ #if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==2)) /* Force direct memory access. Only works on CPU which support unaligned memory access in hardware */ static U32 XXH_read32(const void* memPtr) { return *(const U32*) memPtr; } #elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1)) /* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */ /* currently only defined for gcc and icc */ typedef union { U32 u32; } __attribute__((packed)) unalign; static U32 XXH_read32(const void* ptr) { return ((const unalign*)ptr)->u32; } #else /* portable and safe solution. Generally efficient. * see : http://stackoverflow.com/a/32095106/646947 */ static U32 XXH_read32(const void* memPtr) { U32 val; memcpy(&val, memPtr, sizeof(val)); return val; } #endif /* XXH_FORCE_DIRECT_MEMORY_ACCESS */ /* === Endianess === */ typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess; /* XXH_CPU_LITTLE_ENDIAN can be defined externally, for example on the compiler command line */ #ifndef XXH_CPU_LITTLE_ENDIAN static int XXH_isLittleEndian(void) { const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */ return one.c[0]; } # define XXH_CPU_LITTLE_ENDIAN XXH_isLittleEndian() #endif /* **************************************** * Compiler-specific Functions and Macros ******************************************/ #define XXH_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) #ifndef __has_builtin # define __has_builtin(x) 0 #endif #if !defined(NO_CLANG_BUILTIN) && __has_builtin(__builtin_rotateleft32) && __has_builtin(__builtin_rotateleft64) # define XXH_rotl32 __builtin_rotateleft32 # define XXH_rotl64 __builtin_rotateleft64 /* Note : although _rotl exists for minGW (GCC under windows), performance seems poor */ #elif defined(_MSC_VER) # define XXH_rotl32(x,r) _rotl(x,r) # define XXH_rotl64(x,r) _rotl64(x,r) #else # define XXH_rotl32(x,r) (((x) << (r)) | ((x) >> (32 - (r)))) # define XXH_rotl64(x,r) (((x) << (r)) | ((x) >> (64 - (r)))) #endif #if defined(_MSC_VER) /* Visual Studio */ # define XXH_swap32 _byteswap_ulong #elif XXH_GCC_VERSION >= 403 # define XXH_swap32 __builtin_bswap32 #else static U32 XXH_swap32 (U32 x) { return ((x << 24) & 0xff000000 ) | ((x << 8) & 0x00ff0000 ) | ((x >> 8) & 0x0000ff00 ) | ((x >> 24) & 0x000000ff ); } #endif /* *************************** * Memory reads *****************************/ typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment; XXH_FORCE_INLINE U32 XXH_readLE32(const void* ptr) { return XXH_CPU_LITTLE_ENDIAN ? XXH_read32(ptr) : XXH_swap32(XXH_read32(ptr)); } static U32 XXH_readBE32(const void* ptr) { return XXH_CPU_LITTLE_ENDIAN ? XXH_swap32(XXH_read32(ptr)) : XXH_read32(ptr); } XXH_FORCE_INLINE U32 XXH_readLE32_align(const void* ptr, XXH_alignment align) { if (align==XXH_unaligned) { return XXH_readLE32(ptr); } else { return XXH_CPU_LITTLE_ENDIAN ? *(const U32*)ptr : XXH_swap32(*(const U32*)ptr); } } /* ************************************* * Misc ***************************************/ XXH_PUBLIC_API unsigned XXH_versionNumber (void) { return XXH_VERSION_NUMBER; } /* ******************************************************************* * 32-bit hash functions *********************************************************************/ static const U32 PRIME32_1 = 0x9E3779B1U; /* 0b10011110001101110111100110110001 */ static const U32 PRIME32_2 = 0x85EBCA77U; /* 0b10000101111010111100101001110111 */ static const U32 PRIME32_3 = 0xC2B2AE3DU; /* 0b11000010101100101010111000111101 */ static const U32 PRIME32_4 = 0x27D4EB2FU; /* 0b00100111110101001110101100101111 */ static const U32 PRIME32_5 = 0x165667B1U; /* 0b00010110010101100110011110110001 */ static U32 XXH32_round(U32 acc, U32 input) { acc += input * PRIME32_2; acc = XXH_rotl32(acc, 13); acc *= PRIME32_1; #if defined(__GNUC__) && defined(__SSE4_1__) && !defined(XXH_ENABLE_AUTOVECTORIZE) /* UGLY HACK: * This inline assembly hack forces acc into a normal register. This is the * only thing that prevents GCC and Clang from autovectorizing the XXH32 loop * (pragmas and attributes don't work for some resason) without globally * disabling SSE4.1. * * The reason we want to avoid vectorization is because despite working on * 4 integers at a time, there are multiple factors slowing XXH32 down on * SSE4: * - There's a ridiculous amount of lag from pmulld (10 cycles of latency on newer chips!) * making it slightly slower to multiply four integers at once compared to four * integers independently. Even when pmulld was fastest, Sandy/Ivy Bridge, it is * still not worth it to go into SSE just to multiply unless doing a long operation. * * - Four instructions are required to rotate, * movqda tmp, v // not required with VEX encoding * pslld tmp, 13 // tmp <<= 13 * psrld v, 19 // x >>= 19 * por v, tmp // x |= tmp * compared to one for scalar: * roll v, 13 // reliably fast across the board * shldl v, v, 13 // Sandy Bridge and later prefer this for some reason * * - Instruction level parallelism is actually more beneficial here because the * SIMD actually serializes this operation: While v1 is rotating, v2 can load data, * while v3 can multiply. SSE forces them to operate together. * * How this hack works: * __asm__("" // Declare an assembly block but don't declare any instructions * : // However, as an Input/Output Operand, * "+r" // constrain a read/write operand (+) as a general purpose register (r). * (acc) // and set acc as the operand * ); * * Because of the 'r', the compiler has promised that seed will be in a * general purpose register and the '+' says that it will be 'read/write', * so it has to assume it has changed. It is like volatile without all the * loads and stores. * * Since the argument has to be in a normal register (not an SSE register), * each time XXH32_round is called, it is impossible to vectorize. */ __asm__("" : "+r" (acc)); #endif return acc; } /* mix all bits */ static U32 XXH32_avalanche(U32 h32) { h32 ^= h32 >> 15; h32 *= PRIME32_2; h32 ^= h32 >> 13; h32 *= PRIME32_3; h32 ^= h32 >> 16; return(h32); } #define XXH_get32bits(p) XXH_readLE32_align(p, align) static U32 XXH32_finalize(U32 h32, const void* ptr, size_t len, XXH_alignment align) { const BYTE* p = (const BYTE*)ptr; #define PROCESS1 \ h32 += (*p++) * PRIME32_5; \ h32 = XXH_rotl32(h32, 11) * PRIME32_1 ; #define PROCESS4 \ h32 += XXH_get32bits(p) * PRIME32_3; \ p+=4; \ h32 = XXH_rotl32(h32, 17) * PRIME32_4 ; /* Compact rerolled version */ if (XXH_REROLL) { len &= 15; while (len >= 4) { PROCESS4; len -= 4; } while (len > 0) { PROCESS1; --len; } return XXH32_avalanche(h32); } else { switch(len&15) /* or switch(bEnd - p) */ { case 12: PROCESS4; /* fallthrough */ case 8: PROCESS4; /* fallthrough */ case 4: PROCESS4; return XXH32_avalanche(h32); case 13: PROCESS4; /* fallthrough */ case 9: PROCESS4; /* fallthrough */ case 5: PROCESS4; PROCESS1; return XXH32_avalanche(h32); case 14: PROCESS4; /* fallthrough */ case 10: PROCESS4; /* fallthrough */ case 6: PROCESS4; PROCESS1; PROCESS1; return XXH32_avalanche(h32); case 15: PROCESS4; /* fallthrough */ case 11: PROCESS4; /* fallthrough */ case 7: PROCESS4; /* fallthrough */ case 3: PROCESS1; /* fallthrough */ case 2: PROCESS1; /* fallthrough */ case 1: PROCESS1; /* fallthrough */ case 0: return XXH32_avalanche(h32); } XXH_ASSERT(0); return h32; /* reaching this point is deemed impossible */ } } XXH_FORCE_INLINE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH_alignment align) { const BYTE* p = (const BYTE*)input; const BYTE* bEnd = p + len; U32 h32; #if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1) if (p==NULL) { len=0; bEnd=p=(const BYTE*)(size_t)16; } #endif if (len>=16) { const BYTE* const limit = bEnd - 15; U32 v1 = seed + PRIME32_1 + PRIME32_2; U32 v2 = seed + PRIME32_2; U32 v3 = seed + 0; U32 v4 = seed - PRIME32_1; do { v1 = XXH32_round(v1, XXH_get32bits(p)); p+=4; v2 = XXH32_round(v2, XXH_get32bits(p)); p+=4; v3 = XXH32_round(v3, XXH_get32bits(p)); p+=4; v4 = XXH32_round(v4, XXH_get32bits(p)); p+=4; } while (p < limit); h32 = XXH_rotl32(v1, 1) + XXH_rotl32(v2, 7) + XXH_rotl32(v3, 12) + XXH_rotl32(v4, 18); } else { h32 = seed + PRIME32_5; } h32 += (U32)len; return XXH32_finalize(h32, p, len&15, align); } XXH_PUBLIC_API unsigned int XXH32 (const void* input, size_t len, unsigned int seed) { #if 0 /* Simple version, good for code maintenance, but unfortunately slow for small inputs */ XXH32_state_t state; XXH32_reset(&state, seed); XXH32_update(&state, input, len); return XXH32_digest(&state); #else if (XXH_FORCE_ALIGN_CHECK) { if ((((size_t)input) & 3) == 0) { /* Input is 4-bytes aligned, leverage the speed benefit */ return XXH32_endian_align(input, len, seed, XXH_aligned); } } return XXH32_endian_align(input, len, seed, XXH_unaligned); #endif } /*====== Hash streaming ======*/ XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void) { return (XXH32_state_t*)XXH_malloc(sizeof(XXH32_state_t)); } XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr) { XXH_free(statePtr); return XXH_OK; } XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* dstState, const XXH32_state_t* srcState) { memcpy(dstState, srcState, sizeof(*dstState)); } XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t* statePtr, unsigned int seed) { XXH32_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */ memset(&state, 0, sizeof(state)); state.v1 = seed + PRIME32_1 + PRIME32_2; state.v2 = seed + PRIME32_2; state.v3 = seed + 0; state.v4 = seed - PRIME32_1; /* do not write into reserved, planned to be removed in a future version */ memcpy(statePtr, &state, sizeof(state) - sizeof(state.reserved)); return XXH_OK; } XXH_PUBLIC_API XXH_errorcode XXH32_update(XXH32_state_t* state, const void* input, size_t len) { if (input==NULL) #if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1) return XXH_OK; #else return XXH_ERROR; #endif { const BYTE* p = (const BYTE*)input; const BYTE* const bEnd = p + len; state->total_len_32 += (XXH32_hash_t)len; state->large_len |= (XXH32_hash_t)((len>=16) | (state->total_len_32>=16)); if (state->memsize + len < 16) { /* fill in tmp buffer */ XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, len); state->memsize += (XXH32_hash_t)len; return XXH_OK; } if (state->memsize) { /* some data left from previous update */ XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, 16-state->memsize); { const U32* p32 = state->mem32; state->v1 = XXH32_round(state->v1, XXH_readLE32(p32)); p32++; state->v2 = XXH32_round(state->v2, XXH_readLE32(p32)); p32++; state->v3 = XXH32_round(state->v3, XXH_readLE32(p32)); p32++; state->v4 = XXH32_round(state->v4, XXH_readLE32(p32)); } p += 16-state->memsize; state->memsize = 0; } if (p <= bEnd-16) { const BYTE* const limit = bEnd - 16; U32 v1 = state->v1; U32 v2 = state->v2; U32 v3 = state->v3; U32 v4 = state->v4; do { v1 = XXH32_round(v1, XXH_readLE32(p)); p+=4; v2 = XXH32_round(v2, XXH_readLE32(p)); p+=4; v3 = XXH32_round(v3, XXH_readLE32(p)); p+=4; v4 = XXH32_round(v4, XXH_readLE32(p)); p+=4; } while (p<=limit); state->v1 = v1; state->v2 = v2; state->v3 = v3; state->v4 = v4; } if (p < bEnd) { XXH_memcpy(state->mem32, p, (size_t)(bEnd-p)); state->memsize = (unsigned)(bEnd-p); } } return XXH_OK; } XXH_PUBLIC_API unsigned int XXH32_digest (const XXH32_state_t* state) { U32 h32; if (state->large_len) { h32 = XXH_rotl32(state->v1, 1) + XXH_rotl32(state->v2, 7) + XXH_rotl32(state->v3, 12) + XXH_rotl32(state->v4, 18); } else { h32 = state->v3 /* == seed */ + PRIME32_5; } h32 += state->total_len_32; return XXH32_finalize(h32, state->mem32, state->memsize, XXH_aligned); } /*====== Canonical representation ======*/ /*! Default XXH result types are basic unsigned 32 and 64 bits. * The canonical representation follows human-readable write convention, aka big-endian (large digits first). * These functions allow transformation of hash result into and from its canonical format. * This way, hash values can be written into a file or buffer, remaining comparable across different systems. */ XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t hash) { XXH_STATIC_ASSERT(sizeof(XXH32_canonical_t) == sizeof(XXH32_hash_t)); if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap32(hash); memcpy(dst, &hash, sizeof(*dst)); } XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src) { return XXH_readBE32(src); } #ifndef XXH_NO_LONG_LONG /* ******************************************************************* * 64-bit hash functions *********************************************************************/ /*====== Memory access ======*/ #ifndef MEM_MODULE # define MEM_MODULE # if !defined (__VMS) \ && (defined (__cplusplus) \ || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) # include typedef uint64_t U64; # else /* if compiler doesn't support unsigned long long, replace by another 64-bit type */ typedef unsigned long long U64; # endif #endif /*! XXH_REROLL_XXH64: * Whether to reroll the XXH64_finalize() loop. * * Just like XXH32, we can unroll the XXH64_finalize() loop. This can be a performance gain * on 64-bit hosts, as only one jump is required. * * However, on 32-bit hosts, because arithmetic needs to be done with two 32-bit registers, * and 64-bit arithmetic needs to be simulated, it isn't beneficial to unroll. The code becomes * ridiculously large (the largest function in the binary on i386!), and rerolling it saves * anywhere from 3kB to 20kB. It is also slightly faster because it fits into cache better * and is more likely to be inlined by the compiler. * * If XXH_REROLL is defined, this is ignored and the loop is always rerolled. */ #ifndef XXH_REROLL_XXH64 # if (defined(__ILP32__) || defined(_ILP32)) /* ILP32 is often defined on 32-bit GCC family */ \ || !(defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) /* x86-64 */ \ || defined(_M_ARM64) || defined(__aarch64__) || defined(__arm64__) /* aarch64 */ \ || defined(__PPC64__) || defined(__PPC64LE__) || defined(__ppc64__) || defined(__powerpc64__) /* ppc64 */ \ || defined(__mips64__) || defined(__mips64)) /* mips64 */ \ || (!defined(SIZE_MAX) || SIZE_MAX < ULLONG_MAX) /* check limits */ # define XXH_REROLL_XXH64 1 # else # define XXH_REROLL_XXH64 0 # endif #endif /* !defined(XXH_REROLL_XXH64) */ #if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==2)) /* Force direct memory access. Only works on CPU which support unaligned memory access in hardware */ static U64 XXH_read64(const void* memPtr) { return *(const U64*) memPtr; } #elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1)) /* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */ /* currently only defined for gcc and icc */ typedef union { U32 u32; U64 u64; } __attribute__((packed)) unalign64; static U64 XXH_read64(const void* ptr) { return ((const unalign64*)ptr)->u64; } #else /* portable and safe solution. Generally efficient. * see : http://stackoverflow.com/a/32095106/646947 */ static U64 XXH_read64(const void* memPtr) { U64 val; memcpy(&val, memPtr, sizeof(val)); return val; } #endif /* XXH_FORCE_DIRECT_MEMORY_ACCESS */ #if defined(_MSC_VER) /* Visual Studio */ # define XXH_swap64 _byteswap_uint64 #elif XXH_GCC_VERSION >= 403 # define XXH_swap64 __builtin_bswap64 #else static U64 XXH_swap64 (U64 x) { return ((x << 56) & 0xff00000000000000ULL) | ((x << 40) & 0x00ff000000000000ULL) | ((x << 24) & 0x0000ff0000000000ULL) | ((x << 8) & 0x000000ff00000000ULL) | ((x >> 8) & 0x00000000ff000000ULL) | ((x >> 24) & 0x0000000000ff0000ULL) | ((x >> 40) & 0x000000000000ff00ULL) | ((x >> 56) & 0x00000000000000ffULL); } #endif XXH_FORCE_INLINE U64 XXH_readLE64(const void* ptr) { return XXH_CPU_LITTLE_ENDIAN ? XXH_read64(ptr) : XXH_swap64(XXH_read64(ptr)); } static U64 XXH_readBE64(const void* ptr) { return XXH_CPU_LITTLE_ENDIAN ? XXH_swap64(XXH_read64(ptr)) : XXH_read64(ptr); } XXH_FORCE_INLINE U64 XXH_readLE64_align(const void* ptr, XXH_alignment align) { if (align==XXH_unaligned) return XXH_readLE64(ptr); else return XXH_CPU_LITTLE_ENDIAN ? *(const U64*)ptr : XXH_swap64(*(const U64*)ptr); } /*====== xxh64 ======*/ static const U64 PRIME64_1 = 0x9E3779B185EBCA87ULL; /* 0b1001111000110111011110011011000110000101111010111100101010000111 */ static const U64 PRIME64_2 = 0xC2B2AE3D27D4EB4FULL; /* 0b1100001010110010101011100011110100100111110101001110101101001111 */ static const U64 PRIME64_3 = 0x165667B19E3779F9ULL; /* 0b0001011001010110011001111011000110011110001101110111100111111001 */ static const U64 PRIME64_4 = 0x85EBCA77C2B2AE63ULL; /* 0b1000010111101011110010100111011111000010101100101010111001100011 */ static const U64 PRIME64_5 = 0x27D4EB2F165667C5ULL; /* 0b0010011111010100111010110010111100010110010101100110011111000101 */ static U64 XXH64_round(U64 acc, U64 input) { acc += input * PRIME64_2; acc = XXH_rotl64(acc, 31); acc *= PRIME64_1; return acc; } static U64 XXH64_mergeRound(U64 acc, U64 val) { val = XXH64_round(0, val); acc ^= val; acc = acc * PRIME64_1 + PRIME64_4; return acc; } static U64 XXH64_avalanche(U64 h64) { h64 ^= h64 >> 33; h64 *= PRIME64_2; h64 ^= h64 >> 29; h64 *= PRIME64_3; h64 ^= h64 >> 32; return h64; } #define XXH_get64bits(p) XXH_readLE64_align(p, align) static U64 XXH64_finalize(U64 h64, const void* ptr, size_t len, XXH_alignment align) { const BYTE* p = (const BYTE*)ptr; #define PROCESS1_64 \ h64 ^= (*p++) * PRIME64_5; \ h64 = XXH_rotl64(h64, 11) * PRIME64_1; #define PROCESS4_64 \ h64 ^= (U64)(XXH_get32bits(p)) * PRIME64_1; \ p+=4; \ h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3; #define PROCESS8_64 { \ U64 const k1 = XXH64_round(0, XXH_get64bits(p)); \ p+=8; \ h64 ^= k1; \ h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4; \ } /* Rerolled version for 32-bit targets is faster and much smaller. */ if (XXH_REROLL || XXH_REROLL_XXH64) { len &= 31; while (len >= 8) { PROCESS8_64; len -= 8; } if (len >= 4) { PROCESS4_64; len -= 4; } while (len > 0) { PROCESS1_64; --len; } return XXH64_avalanche(h64); } else { switch(len & 31) { case 24: PROCESS8_64; /* fallthrough */ case 16: PROCESS8_64; /* fallthrough */ case 8: PROCESS8_64; return XXH64_avalanche(h64); case 28: PROCESS8_64; /* fallthrough */ case 20: PROCESS8_64; /* fallthrough */ case 12: PROCESS8_64; /* fallthrough */ case 4: PROCESS4_64; return XXH64_avalanche(h64); case 25: PROCESS8_64; /* fallthrough */ case 17: PROCESS8_64; /* fallthrough */ case 9: PROCESS8_64; PROCESS1_64; return XXH64_avalanche(h64); case 29: PROCESS8_64; /* fallthrough */ case 21: PROCESS8_64; /* fallthrough */ case 13: PROCESS8_64; /* fallthrough */ case 5: PROCESS4_64; PROCESS1_64; return XXH64_avalanche(h64); case 26: PROCESS8_64; /* fallthrough */ case 18: PROCESS8_64; /* fallthrough */ case 10: PROCESS8_64; PROCESS1_64; PROCESS1_64; return XXH64_avalanche(h64); case 30: PROCESS8_64; /* fallthrough */ case 22: PROCESS8_64; /* fallthrough */ case 14: PROCESS8_64; /* fallthrough */ case 6: PROCESS4_64; PROCESS1_64; PROCESS1_64; return XXH64_avalanche(h64); case 27: PROCESS8_64; /* fallthrough */ case 19: PROCESS8_64; /* fallthrough */ case 11: PROCESS8_64; PROCESS1_64; PROCESS1_64; PROCESS1_64; return XXH64_avalanche(h64); case 31: PROCESS8_64; /* fallthrough */ case 23: PROCESS8_64; /* fallthrough */ case 15: PROCESS8_64; /* fallthrough */ case 7: PROCESS4_64; /* fallthrough */ case 3: PROCESS1_64; /* fallthrough */ case 2: PROCESS1_64; /* fallthrough */ case 1: PROCESS1_64; /* fallthrough */ case 0: return XXH64_avalanche(h64); } } /* impossible to reach */ XXH_ASSERT(0); return 0; /* unreachable, but some compilers complain without it */ } XXH_FORCE_INLINE U64 XXH64_endian_align(const void* input, size_t len, U64 seed, XXH_alignment align) { const BYTE* p = (const BYTE*)input; const BYTE* bEnd = p + len; U64 h64; #if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1) if (p==NULL) { len=0; bEnd=p=(const BYTE*)(size_t)32; } #endif if (len>=32) { const BYTE* const limit = bEnd - 32; U64 v1 = seed + PRIME64_1 + PRIME64_2; U64 v2 = seed + PRIME64_2; U64 v3 = seed + 0; U64 v4 = seed - PRIME64_1; do { v1 = XXH64_round(v1, XXH_get64bits(p)); p+=8; v2 = XXH64_round(v2, XXH_get64bits(p)); p+=8; v3 = XXH64_round(v3, XXH_get64bits(p)); p+=8; v4 = XXH64_round(v4, XXH_get64bits(p)); p+=8; } while (p<=limit); h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18); h64 = XXH64_mergeRound(h64, v1); h64 = XXH64_mergeRound(h64, v2); h64 = XXH64_mergeRound(h64, v3); h64 = XXH64_mergeRound(h64, v4); } else { h64 = seed + PRIME64_5; } h64 += (U64) len; return XXH64_finalize(h64, p, len, align); } XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t len, unsigned long long seed) { #if 0 /* Simple version, good for code maintenance, but unfortunately slow for small inputs */ XXH64_state_t state; XXH64_reset(&state, seed); XXH64_update(&state, input, len); return XXH64_digest(&state); #else if (XXH_FORCE_ALIGN_CHECK) { if ((((size_t)input) & 7)==0) { /* Input is aligned, let's leverage the speed advantage */ return XXH64_endian_align(input, len, seed, XXH_aligned); } } return XXH64_endian_align(input, len, seed, XXH_unaligned); #endif } /*====== Hash Streaming ======*/ XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void) { return (XXH64_state_t*)XXH_malloc(sizeof(XXH64_state_t)); } XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr) { XXH_free(statePtr); return XXH_OK; } XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* dstState, const XXH64_state_t* srcState) { memcpy(dstState, srcState, sizeof(*dstState)); } XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t* statePtr, unsigned long long seed) { XXH64_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */ memset(&state, 0, sizeof(state)); state.v1 = seed + PRIME64_1 + PRIME64_2; state.v2 = seed + PRIME64_2; state.v3 = seed + 0; state.v4 = seed - PRIME64_1; /* do not write into reserved, might be removed in a future version */ memcpy(statePtr, &state, sizeof(state) - sizeof(state.reserved)); return XXH_OK; } XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* state, const void* input, size_t len) { if (input==NULL) #if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1) return XXH_OK; #else return XXH_ERROR; #endif { const BYTE* p = (const BYTE*)input; const BYTE* const bEnd = p + len; state->total_len += len; if (state->memsize + len < 32) { /* fill in tmp buffer */ XXH_memcpy(((BYTE*)state->mem64) + state->memsize, input, len); state->memsize += (U32)len; return XXH_OK; } if (state->memsize) { /* tmp buffer is full */ XXH_memcpy(((BYTE*)state->mem64) + state->memsize, input, 32-state->memsize); state->v1 = XXH64_round(state->v1, XXH_readLE64(state->mem64+0)); state->v2 = XXH64_round(state->v2, XXH_readLE64(state->mem64+1)); state->v3 = XXH64_round(state->v3, XXH_readLE64(state->mem64+2)); state->v4 = XXH64_round(state->v4, XXH_readLE64(state->mem64+3)); p += 32-state->memsize; state->memsize = 0; } if (p+32 <= bEnd) { const BYTE* const limit = bEnd - 32; U64 v1 = state->v1; U64 v2 = state->v2; U64 v3 = state->v3; U64 v4 = state->v4; do { v1 = XXH64_round(v1, XXH_readLE64(p)); p+=8; v2 = XXH64_round(v2, XXH_readLE64(p)); p+=8; v3 = XXH64_round(v3, XXH_readLE64(p)); p+=8; v4 = XXH64_round(v4, XXH_readLE64(p)); p+=8; } while (p<=limit); state->v1 = v1; state->v2 = v2; state->v3 = v3; state->v4 = v4; } if (p < bEnd) { XXH_memcpy(state->mem64, p, (size_t)(bEnd-p)); state->memsize = (unsigned)(bEnd-p); } } return XXH_OK; } XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t* state) { U64 h64; if (state->total_len >= 32) { U64 const v1 = state->v1; U64 const v2 = state->v2; U64 const v3 = state->v3; U64 const v4 = state->v4; h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18); h64 = XXH64_mergeRound(h64, v1); h64 = XXH64_mergeRound(h64, v2); h64 = XXH64_mergeRound(h64, v3); h64 = XXH64_mergeRound(h64, v4); } else { h64 = state->v3 /*seed*/ + PRIME64_5; } h64 += (U64) state->total_len; return XXH64_finalize(h64, state->mem64, (size_t)state->total_len, XXH_aligned); } /*====== Canonical representation ======*/ XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash) { XXH_STATIC_ASSERT(sizeof(XXH64_canonical_t) == sizeof(XXH64_hash_t)); if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap64(hash); memcpy(dst, &hash, sizeof(*dst)); } XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src) { return XXH_readBE64(src); } /* ********************************************************************* * XXH3 * New generation hash designed for speed on small keys and vectorization ************************************************************************ */ #include "xxh3.h" #endif /* XXH_NO_LONG_LONG */ goxel-0.11.0/ext_src/xxhash/xxhash.h000066400000000000000000000602601435762723100173530ustar00rootroot00000000000000/* xxHash - Extremely Fast Hash algorithm Header File Copyright (C) 2012-2016, Yann Collet. BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) 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 OWNER 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. You can contact the author at : - xxHash source repository : https://github.com/Cyan4973/xxHash */ /* Notice extracted from xxHash homepage : xxHash is an extremely fast Hash algorithm, running at RAM speed limits. It also successfully passes all tests from the SMHasher suite. Comparison (single thread, Windows Seven 32 bits, using SMHasher on a Core 2 Duo @3GHz) Name Speed Q.Score Author xxHash 5.4 GB/s 10 CrapWow 3.2 GB/s 2 Andrew MumurHash 3a 2.7 GB/s 10 Austin Appleby SpookyHash 2.0 GB/s 10 Bob Jenkins SBox 1.4 GB/s 9 Bret Mulvey Lookup3 1.2 GB/s 9 Bob Jenkins SuperFastHash 1.2 GB/s 1 Paul Hsieh CityHash64 1.05 GB/s 10 Pike & Alakuijala FNV 0.55 GB/s 5 Fowler, Noll, Vo CRC32 0.43 GB/s 9 MD5-32 0.33 GB/s 10 Ronald L. Rivest SHA1-32 0.28 GB/s 10 Q.Score is a measure of quality of the hash function. It depends on successfully passing SMHasher test set. 10 is a perfect score. A 64-bit version, named XXH64, is available since r35. It offers much better speed, but for 64-bit applications only. Name Speed on 64 bits Speed on 32 bits XXH64 13.8 GB/s 1.9 GB/s XXH32 6.8 GB/s 6.0 GB/s */ #ifndef XXHASH_H_5627135585666179 #define XXHASH_H_5627135585666179 1 #if defined (__cplusplus) extern "C" { #endif /* **************************** * Definitions ******************************/ #include /* size_t */ typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode; /* **************************** * API modifier ******************************/ /** XXH_INLINE_ALL (and XXH_PRIVATE_API) * This build macro includes xxhash functions in `static` mode * in order to inline them, and remove their symbol from the public list. * Inlining offers great performance improvement on small keys, * and dramatic ones when length is expressed as a compile-time constant. * See https://fastcompression.blogspot.com/2018/03/xxhash-for-small-keys-impressive-power.html . * Methodology : * #define XXH_INLINE_ALL * #include "xxhash.h" * `xxhash.c` is automatically included. * It's not useful to compile and link it as a separate object. */ #if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API) # ifndef XXH_STATIC_LINKING_ONLY # define XXH_STATIC_LINKING_ONLY # endif # if defined(__GNUC__) # define XXH_PUBLIC_API static __inline __attribute__((unused)) # elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) # define XXH_PUBLIC_API static inline # elif defined(_MSC_VER) # define XXH_PUBLIC_API static __inline # else /* this version may generate warnings for unused static functions */ # define XXH_PUBLIC_API static # endif #else # if defined(WIN32) && defined(_MSC_VER) && (defined(XXH_IMPORT) || defined(XXH_EXPORT)) # ifdef XXH_EXPORT # define XXH_PUBLIC_API __declspec(dllexport) # elif XXH_IMPORT # define XXH_PUBLIC_API __declspec(dllimport) # endif # else # define XXH_PUBLIC_API /* do nothing */ # endif #endif /* XXH_INLINE_ALL || XXH_PRIVATE_API */ /*! XXH_NAMESPACE, aka Namespace Emulation : * * If you want to include _and expose_ xxHash functions from within your own library, * but also want to avoid symbol collisions with other libraries which may also include xxHash, * * you can use XXH_NAMESPACE, to automatically prefix any public symbol from xxhash library * with the value of XXH_NAMESPACE (therefore, avoid NULL and numeric values). * * Note that no change is required within the calling program as long as it includes `xxhash.h` : * regular symbol name will be automatically translated by this header. */ #ifdef XXH_NAMESPACE # define XXH_CAT(A,B) A##B # define XXH_NAME2(A,B) XXH_CAT(A,B) # define XXH_versionNumber XXH_NAME2(XXH_NAMESPACE, XXH_versionNumber) # define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32) # define XXH32_createState XXH_NAME2(XXH_NAMESPACE, XXH32_createState) # define XXH32_freeState XXH_NAME2(XXH_NAMESPACE, XXH32_freeState) # define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset) # define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update) # define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest) # define XXH32_copyState XXH_NAME2(XXH_NAMESPACE, XXH32_copyState) # define XXH32_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH32_canonicalFromHash) # define XXH32_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH32_hashFromCanonical) # define XXH64 XXH_NAME2(XXH_NAMESPACE, XXH64) # define XXH64_createState XXH_NAME2(XXH_NAMESPACE, XXH64_createState) # define XXH64_freeState XXH_NAME2(XXH_NAMESPACE, XXH64_freeState) # define XXH64_reset XXH_NAME2(XXH_NAMESPACE, XXH64_reset) # define XXH64_update XXH_NAME2(XXH_NAMESPACE, XXH64_update) # define XXH64_digest XXH_NAME2(XXH_NAMESPACE, XXH64_digest) # define XXH64_copyState XXH_NAME2(XXH_NAMESPACE, XXH64_copyState) # define XXH64_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH64_canonicalFromHash) # define XXH64_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH64_hashFromCanonical) #endif /* ************************************* * Version ***************************************/ #define XXH_VERSION_MAJOR 0 #define XXH_VERSION_MINOR 7 #define XXH_VERSION_RELEASE 1 #define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE) XXH_PUBLIC_API unsigned XXH_versionNumber (void); /*-********************************************************************** * 32-bit hash ************************************************************************/ #if !defined (__VMS) \ && (defined (__cplusplus) \ || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) # include typedef uint32_t XXH32_hash_t; #else typedef unsigned int XXH32_hash_t; #endif /*! XXH32() : Calculate the 32-bit hash of sequence "length" bytes stored at memory address "input". The memory between input & input+length must be valid (allocated and read-accessible). "seed" can be used to alter the result predictably. Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s */ XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t length, unsigned int seed); /*====== Streaming ======*/ typedef struct XXH32_state_s XXH32_state_t; /* incomplete type */ XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void); XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr); XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* dst_state, const XXH32_state_t* src_state); XXH_PUBLIC_API XXH_errorcode XXH32_reset (XXH32_state_t* statePtr, unsigned int seed); XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* statePtr, const void* input, size_t length); XXH_PUBLIC_API XXH32_hash_t XXH32_digest (const XXH32_state_t* statePtr); /* * Streaming functions generate the xxHash of an input provided in multiple segments. * Note that, for small input, they are slower than single-call functions, due to state management. * For small inputs, prefer `XXH32()` and `XXH64()`, which are better optimized. * * XXH state must first be allocated, using XXH*_createState() . * * Start a new hash by initializing state with a seed, using XXH*_reset(). * * Then, feed the hash state by calling XXH*_update() as many times as necessary. * The function returns an error code, with 0 meaning OK, and any other value meaning there is an error. * * Finally, a hash value can be produced anytime, by using XXH*_digest(). * This function returns the nn-bits hash as an int or long long. * * It's still possible to continue inserting input into the hash state after a digest, * and generate some new hashes later on, by calling again XXH*_digest(). * * When done, free XXH state space if it was allocated dynamically. */ /*====== Canonical representation ======*/ typedef struct { unsigned char digest[4]; } XXH32_canonical_t; XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t hash); XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src); /* Default result type for XXH functions are primitive unsigned 32 and 64 bits. * The canonical representation uses human-readable write convention, aka big-endian (large digits first). * These functions allow transformation of hash result into and from its canonical format. * This way, hash values can be written into a file / memory, and remain comparable on different systems and programs. */ #ifndef XXH_NO_LONG_LONG /*-********************************************************************** * 64-bit hash ************************************************************************/ #if !defined (__VMS) \ && (defined (__cplusplus) \ || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) # include typedef uint64_t XXH64_hash_t; #else typedef unsigned long long XXH64_hash_t; #endif /*! XXH64() : Calculate the 64-bit hash of sequence of length "len" stored at memory address "input". "seed" can be used to alter the result predictably. This function runs faster on 64-bit systems, but slower on 32-bit systems (see benchmark). */ XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t length, unsigned long long seed); /*====== Streaming ======*/ typedef struct XXH64_state_s XXH64_state_t; /* incomplete type */ XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void); XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr); XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* dst_state, const XXH64_state_t* src_state); XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH64_state_t* statePtr, unsigned long long seed); XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const void* input, size_t length); XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t* statePtr); /*====== Canonical representation ======*/ typedef struct { unsigned char digest[8]; } XXH64_canonical_t; XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash); XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src); #endif /* XXH_NO_LONG_LONG */ #ifdef XXH_STATIC_LINKING_ONLY /* ================================================================================================ This section contains declarations which are not guaranteed to remain stable. They may change in future versions, becoming incompatible with a different version of the library. These declarations should only be used with static linking. Never use them in association with dynamic linking ! =================================================================================================== */ /* These definitions are only present to allow * static allocation of XXH state, on stack or in a struct for example. * Never **ever** use members directly. */ struct XXH32_state_s { XXH32_hash_t total_len_32; XXH32_hash_t large_len; XXH32_hash_t v1; XXH32_hash_t v2; XXH32_hash_t v3; XXH32_hash_t v4; XXH32_hash_t mem32[4]; XXH32_hash_t memsize; XXH32_hash_t reserved; /* never read nor write, might be removed in a future version */ }; /* typedef'd to XXH32_state_t */ #ifndef XXH_NO_LONG_LONG /* remove 64-bit support */ struct XXH64_state_s { XXH64_hash_t total_len; XXH64_hash_t v1; XXH64_hash_t v2; XXH64_hash_t v3; XXH64_hash_t v4; XXH64_hash_t mem64[4]; XXH32_hash_t memsize; XXH32_hash_t reserved[2]; /* never read nor write, might be removed in a future version */ }; /* typedef'd to XXH64_state_t */ #endif /* XXH_NO_LONG_LONG */ /*-********************************************************************** * XXH3 * New experimental hash ************************************************************************/ #ifndef XXH_NO_LONG_LONG /* ============================================ * XXH3 is a new hash algorithm, * featuring improved speed performance for both small and large inputs. * See full speed analysis at : http://fastcompression.blogspot.com/2019/03/presenting-xxh3.html * In general, expect XXH3 to run about ~2x faster on large inputs, * and >3x faster on small ones, though exact differences depend on platform. * * The algorithm is portable, will generate the same hash on all platforms. * It benefits greatly from vectorization units, but does not require it. * * XXH3 offers 2 variants, _64bits and _128bits. * When only 64 bits are needed, prefer calling the _64bits variant : * it reduces the amount of mixing, resulting in faster speed on small inputs. * It's also generally simpler to manipulate a scalar return type than a struct. * * The XXH3 algorithm is still considered experimental. * Produced results can still change between versions. * For example, results produced by v0.7.1 are not comparable with results from v0.7.0 . * It's nonetheless possible to use XXH3 for ephemeral data (local sessions), * but avoid storing values in long-term storage for later re-use. * * The API supports one-shot hashing, streaming mode, and custom secrets. * * There are still a number of opened questions that community can influence during the experimental period. * I'm trying to list a few of them below, though don't consider this list as complete. * * - 128-bits output type : currently defined as a structure of two 64-bits fields. * That's because 128-bit values do not exist in C standard. * Note that it means that, at byte level, result is not identical depending on endianess. * However, at field level, they are identical on all platforms. * The canonical representation solves the issue of identical byte-level representation across platforms, * which is necessary for serialization. * Would there be a better representation for a 128-bit hash result ? * Are the names of the inner 64-bit fields important ? Should they be changed ? * * - Seed type for 128-bits variant : currently, it's a single 64-bit value, like the 64-bit variant. * It could be argued that it's more logical to offer a 128-bit seed input parameter for a 128-bit hash. * But 128-bit seed is more difficult to use, since it requires to pass a structure instead of a scalar value. * Such a variant could either replace current one, or become an additional one. * Farmhash, for example, offers both variants (the 128-bits seed variant is called `doubleSeed`). * If both 64-bit and 128-bit seeds are possible, which variant should be called XXH128 ? * * - Result for len==0 : Currently, the result of hashing a zero-length input is `0`. * It seems okay as a return value when using all "default" secret and seed (it used to be a request for XXH32/XXH64). * But is it still fine to return `0` when secret or seed are non-default ? * Are there use cases which could depend on generating a different hash result for zero-length input when the secret is different ? */ #ifdef XXH_NAMESPACE # define XXH3_64bits XXH_NAME2(XXH_NAMESPACE, XXH3_64bits) # define XXH3_64bits_withSecret XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_withSecret) # define XXH3_64bits_withSeed XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_withSeed) # define XXH3_createState XXH_NAME2(XXH_NAMESPACE, XXH3_createState) # define XXH3_freeState XXH_NAME2(XXH_NAMESPACE, XXH3_freeState) # define XXH3_copyState XXH_NAME2(XXH_NAMESPACE, XXH3_copyState) # define XXH3_64bits_reset XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_reset) # define XXH3_64bits_reset_withSeed XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_reset_withSeed) # define XXH3_64bits_reset_withSecret XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_reset_withSecret) # define XXH3_64bits_update XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_update) # define XXH3_64bits_digest XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_digest) #endif /* XXH3_64bits() : * default 64-bit variant, using default secret and default seed of 0. * It's the fastest variant. */ XXH_PUBLIC_API XXH64_hash_t XXH3_64bits(const void* data, size_t len); /* XXH3_64bits_withSecret() : * It's possible to provide any blob of bytes as a "secret" to generate the hash. * This makes it more difficult for an external actor to prepare an intentional collision. * The secret *must* be large enough (>= XXH3_SECRET_SIZE_MIN). * It should consist of random bytes. * Avoid repeating same character, or sequences of bytes, * and especially avoid swathes of \0. * Failure to respect these conditions will result in a poor quality hash. */ #define XXH3_SECRET_SIZE_MIN 136 XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSecret(const void* data, size_t len, const void* secret, size_t secretSize); /* XXH3_64bits_withSeed() : * This variant generates on the fly a custom secret, * based on the default secret, altered using the `seed` value. * While this operation is decently fast, note that it's not completely free. * note : seed==0 produces same results as XXH3_64bits() */ XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSeed(const void* data, size_t len, XXH64_hash_t seed); /* streaming 64-bit */ #if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11+ */ # include # define XXH_ALIGN(n) alignas(n) #elif defined(__GNUC__) # define XXH_ALIGN(n) __attribute__ ((aligned(n))) #elif defined(_MSC_VER) # define XXH_ALIGN(n) __declspec(align(n)) #else # define XXH_ALIGN(n) /* disabled */ #endif typedef struct XXH3_state_s XXH3_state_t; #define XXH3_SECRET_DEFAULT_SIZE 192 /* minimum XXH3_SECRET_SIZE_MIN */ #define XXH3_INTERNALBUFFER_SIZE 256 struct XXH3_state_s { XXH_ALIGN(64) XXH64_hash_t acc[8]; XXH_ALIGN(64) char customSecret[XXH3_SECRET_DEFAULT_SIZE]; /* used to store a custom secret generated from the seed. Makes state larger. Design might change */ XXH_ALIGN(64) char buffer[XXH3_INTERNALBUFFER_SIZE]; const void* secret; XXH32_hash_t bufferedSize; XXH32_hash_t nbStripesPerBlock; XXH32_hash_t nbStripesSoFar; XXH32_hash_t reserved32; XXH32_hash_t reserved32_2; XXH32_hash_t secretLimit; XXH64_hash_t totalLen; XXH64_hash_t seed; XXH64_hash_t reserved64; }; /* typedef'd to XXH3_state_t */ /* Streaming requires state maintenance. * This operation costs memory and cpu. * As a consequence, streaming is slower than one-shot hashing. * For better performance, prefer using one-shot functions whenever possible. */ XXH_PUBLIC_API XXH3_state_t* XXH3_createState(void); XXH_PUBLIC_API XXH_errorcode XXH3_freeState(XXH3_state_t* statePtr); XXH_PUBLIC_API void XXH3_copyState(XXH3_state_t* dst_state, const XXH3_state_t* src_state); /* XXH3_64bits_reset() : * initialize with default parameters. * result will be equivalent to `XXH3_64bits()`. */ XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset(XXH3_state_t* statePtr); /* XXH3_64bits_reset_withSeed() : * generate a custom secret from `seed`, and store it into state. * digest will be equivalent to `XXH3_64bits_withSeed()`. */ XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSeed(XXH3_state_t* statePtr, XXH64_hash_t seed); /* XXH3_64bits_reset_withSecret() : * `secret` is referenced, and must outlive the hash streaming session. * secretSize must be >= XXH3_SECRET_SIZE_MIN. */ XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSecret(XXH3_state_t* statePtr, const void* secret, size_t secretSize); XXH_PUBLIC_API XXH_errorcode XXH3_64bits_update (XXH3_state_t* statePtr, const void* input, size_t length); XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_digest (const XXH3_state_t* statePtr); /* 128-bit */ #ifdef XXH_NAMESPACE # define XXH128 XXH_NAME2(XXH_NAMESPACE, XXH128) # define XXH3_128bits XXH_NAME2(XXH_NAMESPACE, XXH3_128bits) # define XXH3_128bits_withSeed XXH_NAME2(XXH_NAMESPACE, XXH3_128bits_withSeed) # define XXH3_128bits_withSecret XXH_NAME2(XXH_NAMESPACE, XXH3_128bits_withSecret) # define XXH3_128bits_reset XXH_NAME2(XXH_NAMESPACE, XXH3_128bits_reset) # define XXH3_128bits_reset_withSeed XXH_NAME2(XXH_NAMESPACE, XXH3_128bits_reset_withSeed) # define XXH3_128bits_reset_withSecret XXH_NAME2(XXH_NAMESPACE, XXH3_128bits_reset_withSecret) # define XXH3_128bits_update XXH_NAME2(XXH_NAMESPACE, XXH3_128bits_update) # define XXH3_128bits_digest XXH_NAME2(XXH_NAMESPACE, XXH3_128bits_digest) # define XXH128_isEqual XXH_NAME2(XXH_NAMESPACE, XXH128_isEqual) # define XXH128_cmp XXH_NAME2(XXH_NAMESPACE, XXH128_cmp) # define XXH128_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH128_canonicalFromHash) # define XXH128_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH128_hashFromCanonical) #endif typedef struct { XXH64_hash_t low64; XXH64_hash_t high64; } XXH128_hash_t; XXH_PUBLIC_API XXH128_hash_t XXH128(const void* data, size_t len, XXH64_hash_t seed); XXH_PUBLIC_API XXH128_hash_t XXH3_128bits(const void* data, size_t len); XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_withSeed(const void* data, size_t len, XXH64_hash_t seed); /* == XXH128() */ XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_withSecret(const void* data, size_t len, const void* secret, size_t secretSize); XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset(XXH3_state_t* statePtr); XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSeed(XXH3_state_t* statePtr, XXH64_hash_t seed); XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSecret(XXH3_state_t* statePtr, const void* secret, size_t secretSize); XXH_PUBLIC_API XXH_errorcode XXH3_128bits_update (XXH3_state_t* statePtr, const void* input, size_t length); XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (const XXH3_state_t* statePtr); /* Note : for better performance, following functions should be inlined, * using XXH_INLINE_ALL */ /* return : 1 is equal, 0 if different */ XXH_PUBLIC_API int XXH128_isEqual(XXH128_hash_t h1, XXH128_hash_t h2); /* This comparator is compatible with stdlib's qsort(). * return : >0 if *h128_1 > *h128_2 * <0 if *h128_1 < *h128_2 * =0 if *h128_1 == *h128_2 */ XXH_PUBLIC_API int XXH128_cmp(const void* h128_1, const void* h128_2); /*====== Canonical representation ======*/ typedef struct { unsigned char digest[16]; } XXH128_canonical_t; XXH_PUBLIC_API void XXH128_canonicalFromHash(XXH128_canonical_t* dst, XXH128_hash_t hash); XXH_PUBLIC_API XXH128_hash_t XXH128_hashFromCanonical(const XXH128_canonical_t* src); #endif /* XXH_NO_LONG_LONG */ /*-********************************************************************** * XXH_INLINE_ALL ************************************************************************/ #if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API) # include "xxhash.c" /* include xxhash function bodies as `static`, for inlining */ #endif #endif /* XXH_STATIC_LINKING_ONLY */ #if defined (__cplusplus) } #endif #endif /* XXHASH_H_5627135585666179 */ goxel-0.11.0/ext_src/yocto/000077500000000000000000000000001435762723100155255ustar00rootroot00000000000000goxel-0.11.0/ext_src/yocto/ext/000077500000000000000000000000001435762723100163255ustar00rootroot00000000000000goxel-0.11.0/ext_src/yocto/ext/cgltf.h000077500000000000000000003447301435762723100176130ustar00rootroot00000000000000/** * cgltf - a single-file glTF 2.0 parser written in C99. * * Version: 1.1 * * Website: https://github.com/jkuhlmann/cgltf * * Distributed under the MIT License, see notice at the end of this file. * * Building: * Include this file where you need the struct and function * declarations. Have exactly one source file where you define * `CGLTF_IMPLEMENTATION` before including this file to get the * function definitions. * * Reference: * `cgltf_result cgltf_parse(const cgltf_options*, const void*, * cgltf_size, cgltf_data**)` parses both glTF and GLB data. If * this function returns `cgltf_result_success`, you have to call * `cgltf_free()` on the created `cgltf_data*` variable. * Note that contents of external files for buffers and images are not * automatically loaded. You'll need to read these files yourself using * URIs in the `cgltf_data` structure. * * `cgltf_options` is the struct passed to `cgltf_parse()` to control * parts of the parsing process. You can use it to force the file type * and provide memory allocation callbacks. Should be zero-initialized * to trigger default behavior. * * `cgltf_data` is the struct allocated and filled by `cgltf_parse()`. * It generally mirrors the glTF format as described by the spec (see * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0). * * `void cgltf_free(cgltf_data*)` frees the allocated `cgltf_data` * variable. * * `cgltf_result cgltf_load_buffers(const cgltf_options*, cgltf_data*, * const char*)` can be optionally called to open and read buffer * files using the `FILE*` APIs. * * `cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, * cgltf_size size, const char* base64, void** out_data)` decodes * base64-encoded data content. Used internally by `cgltf_load_buffers()` * and may be useful if you're not dealing with normal files. * * `cgltf_result cgltf_parse_file(const cgltf_options* options, const * char* path, cgltf_data** out_data)` can be used to open the given * file using `FILE*` APIs and parse the data using `cgltf_parse()`. * * `cgltf_result cgltf_validate(cgltf_data*)` can be used to do additional * checks to make sure the parsed glTF data is valid. * * `cgltf_node_transform_local` converts the translation / rotation / scale properties of a node * into a mat4. * * `cgltf_node_transform_world` calls `cgltf_node_transform_local` on every ancestor in order * to compute the root-to-node transformation. * * `cgltf_accessor_read_float` reads a certain element from an accessor and converts it to * floating point, assuming that `cgltf_load_buffers` has already been called. The passed-in element * size is the number of floats in the output buffer, which should be in the range [1, 16]. Returns * false if the passed-in element_size is too small, or if the accessor is sparse. * * `cgltf_accessor_read_index` is similar to its floating-point counterpart, but it returns size_t * and only works with single-component data types. */ #ifndef CGLTF_H_INCLUDED__ #define CGLTF_H_INCLUDED__ #include #ifdef __cplusplus extern "C" { #endif typedef size_t cgltf_size; typedef float cgltf_float; typedef int cgltf_int; typedef int cgltf_bool; typedef enum cgltf_file_type { cgltf_file_type_invalid, cgltf_file_type_gltf, cgltf_file_type_glb, } cgltf_file_type; typedef struct cgltf_options { cgltf_file_type type; /* invalid == auto detect */ cgltf_size json_token_count; /* 0 == auto */ void* (*memory_alloc)(void* user, cgltf_size size); void (*memory_free) (void* user, void* ptr); void* memory_user_data; } cgltf_options; typedef enum cgltf_result { cgltf_result_success, cgltf_result_data_too_short, cgltf_result_unknown_format, cgltf_result_invalid_json, cgltf_result_invalid_gltf, cgltf_result_invalid_options, cgltf_result_file_not_found, cgltf_result_io_error, cgltf_result_out_of_memory, } cgltf_result; typedef enum cgltf_buffer_view_type { cgltf_buffer_view_type_invalid, cgltf_buffer_view_type_indices, cgltf_buffer_view_type_vertices, } cgltf_buffer_view_type; typedef enum cgltf_attribute_type { cgltf_attribute_type_invalid, cgltf_attribute_type_position, cgltf_attribute_type_normal, cgltf_attribute_type_tangent, cgltf_attribute_type_texcoord, cgltf_attribute_type_color, cgltf_attribute_type_joints, cgltf_attribute_type_weights, } cgltf_attribute_type; typedef enum cgltf_component_type { cgltf_component_type_invalid, cgltf_component_type_r_8, /* BYTE */ cgltf_component_type_r_8u, /* UNSIGNED_BYTE */ cgltf_component_type_r_16, /* SHORT */ cgltf_component_type_r_16u, /* UNSIGNED_SHORT */ cgltf_component_type_r_32u, /* UNSIGNED_INT */ cgltf_component_type_r_32f, /* FLOAT */ } cgltf_component_type; typedef enum cgltf_type { cgltf_type_invalid, cgltf_type_scalar, cgltf_type_vec2, cgltf_type_vec3, cgltf_type_vec4, cgltf_type_mat2, cgltf_type_mat3, cgltf_type_mat4, } cgltf_type; typedef enum cgltf_primitive_type { cgltf_primitive_type_points, cgltf_primitive_type_lines, cgltf_primitive_type_line_loop, cgltf_primitive_type_line_strip, cgltf_primitive_type_triangles, cgltf_primitive_type_triangle_strip, cgltf_primitive_type_triangle_fan, } cgltf_primitive_type; typedef enum cgltf_alpha_mode { cgltf_alpha_mode_opaque, cgltf_alpha_mode_mask, cgltf_alpha_mode_blend, } cgltf_alpha_mode; typedef enum cgltf_animation_path_type { cgltf_animation_path_type_invalid, cgltf_animation_path_type_translation, cgltf_animation_path_type_rotation, cgltf_animation_path_type_scale, cgltf_animation_path_type_weights, } cgltf_animation_path_type; typedef enum cgltf_interpolation_type { cgltf_interpolation_type_linear, cgltf_interpolation_type_step, cgltf_interpolation_type_cubic_spline, } cgltf_interpolation_type; typedef enum cgltf_camera_type { cgltf_camera_type_invalid, cgltf_camera_type_perspective, cgltf_camera_type_orthographic, } cgltf_camera_type; typedef enum cgltf_light_type { cgltf_light_type_invalid, cgltf_light_type_directional, cgltf_light_type_point, cgltf_light_type_spot, } cgltf_light_type; typedef struct cgltf_buffer { cgltf_size size; char* uri; void* data; /* loaded by cgltf_load_buffers */ } cgltf_buffer; typedef struct cgltf_buffer_view { cgltf_buffer* buffer; cgltf_size offset; cgltf_size size; cgltf_size stride; /* 0 == automatically determined by accessor */ cgltf_buffer_view_type type; } cgltf_buffer_view; typedef struct cgltf_accessor_sparse { cgltf_size count; cgltf_buffer_view* indices_buffer_view; cgltf_size indices_byte_offset; cgltf_component_type indices_component_type; cgltf_buffer_view* values_buffer_view; cgltf_size values_byte_offset; } cgltf_accessor_sparse; typedef struct cgltf_accessor { cgltf_component_type component_type; cgltf_bool normalized; cgltf_type type; cgltf_size offset; cgltf_size count; cgltf_size stride; cgltf_buffer_view* buffer_view; cgltf_bool has_min; cgltf_float min[16]; cgltf_bool has_max; cgltf_float max[16]; cgltf_bool is_sparse; cgltf_accessor_sparse sparse; } cgltf_accessor; typedef struct cgltf_attribute { char* name; cgltf_attribute_type type; cgltf_int index; cgltf_accessor* data; } cgltf_attribute; typedef struct cgltf_image { char* name; char* uri; cgltf_buffer_view* buffer_view; char* mime_type; } cgltf_image; typedef struct cgltf_sampler { cgltf_int mag_filter; cgltf_int min_filter; cgltf_int wrap_s; cgltf_int wrap_t; } cgltf_sampler; typedef struct cgltf_texture { char* name; cgltf_image* image; cgltf_sampler* sampler; } cgltf_texture; typedef struct cgltf_texture_transform { cgltf_float offset[2]; cgltf_float rotation; cgltf_float scale[2]; cgltf_int texcoord; } cgltf_texture_transform; typedef struct cgltf_texture_view { cgltf_texture* texture; cgltf_int texcoord; cgltf_float scale; /* equivalent to strength for occlusion_texture */ cgltf_bool has_transform; cgltf_texture_transform transform; } cgltf_texture_view; typedef struct cgltf_pbr_metallic_roughness { cgltf_texture_view base_color_texture; cgltf_texture_view metallic_roughness_texture; cgltf_float base_color_factor[4]; cgltf_float metallic_factor; cgltf_float roughness_factor; } cgltf_pbr_metallic_roughness; typedef struct cgltf_pbr_specular_glossiness { cgltf_texture_view diffuse_texture; cgltf_texture_view specular_glossiness_texture; cgltf_float diffuse_factor[4]; cgltf_float specular_factor[3]; cgltf_float glossiness_factor; } cgltf_pbr_specular_glossiness; typedef struct cgltf_material { char* name; cgltf_bool has_pbr_metallic_roughness; cgltf_bool has_pbr_specular_glossiness; cgltf_pbr_metallic_roughness pbr_metallic_roughness; cgltf_pbr_specular_glossiness pbr_specular_glossiness; cgltf_texture_view normal_texture; cgltf_texture_view occlusion_texture; cgltf_texture_view emissive_texture; cgltf_float emissive_factor[3]; cgltf_alpha_mode alpha_mode; cgltf_float alpha_cutoff; cgltf_bool double_sided; cgltf_bool unlit; } cgltf_material; typedef struct cgltf_morph_target { cgltf_attribute* attributes; cgltf_size attributes_count; } cgltf_morph_target; typedef struct cgltf_primitive { cgltf_primitive_type type; cgltf_accessor* indices; cgltf_material* material; cgltf_attribute* attributes; cgltf_size attributes_count; cgltf_morph_target* targets; cgltf_size targets_count; } cgltf_primitive; typedef struct cgltf_mesh { char* name; cgltf_primitive* primitives; cgltf_size primitives_count; cgltf_float* weights; cgltf_size weights_count; } cgltf_mesh; typedef struct cgltf_node cgltf_node; typedef struct cgltf_skin { char* name; cgltf_node** joints; cgltf_size joints_count; cgltf_node* skeleton; cgltf_accessor* inverse_bind_matrices; } cgltf_skin; typedef struct cgltf_camera_perspective { cgltf_float aspect_ratio; cgltf_float yfov; cgltf_float zfar; cgltf_float znear; } cgltf_camera_perspective; typedef struct cgltf_camera_orthographic { cgltf_float xmag; cgltf_float ymag; cgltf_float zfar; cgltf_float znear; } cgltf_camera_orthographic; typedef struct cgltf_camera { char* name; cgltf_camera_type type; union { cgltf_camera_perspective perspective; cgltf_camera_orthographic orthographic; }; } cgltf_camera; typedef struct cgltf_light { char* name; cgltf_float color[3]; cgltf_float intensity; cgltf_light_type type; cgltf_float range; cgltf_float spot_inner_cone_angle; cgltf_float spot_outer_cone_angle; } cgltf_light; typedef struct cgltf_node { char* name; cgltf_node* parent; cgltf_node** children; cgltf_size children_count; cgltf_skin* skin; cgltf_mesh* mesh; cgltf_camera* camera; cgltf_light* light; cgltf_float* weights; cgltf_size weights_count; cgltf_bool has_translation; cgltf_bool has_rotation; cgltf_bool has_scale; cgltf_bool has_matrix; cgltf_float translation[3]; cgltf_float rotation[4]; cgltf_float scale[3]; cgltf_float matrix[16]; } cgltf_node; typedef struct cgltf_scene { char* name; cgltf_node** nodes; cgltf_size nodes_count; } cgltf_scene; typedef struct cgltf_animation_sampler { cgltf_accessor* input; cgltf_accessor* output; cgltf_interpolation_type interpolation; } cgltf_animation_sampler; typedef struct cgltf_animation_channel { cgltf_animation_sampler* sampler; cgltf_node* target_node; cgltf_animation_path_type target_path; } cgltf_animation_channel; typedef struct cgltf_animation { char* name; cgltf_animation_sampler* samplers; cgltf_size samplers_count; cgltf_animation_channel* channels; cgltf_size channels_count; } cgltf_animation; typedef struct cgltf_asset { char* copyright; char* generator; char* version; char* min_version; } cgltf_asset; typedef struct cgltf_data { cgltf_file_type file_type; void* file_data; cgltf_asset asset; cgltf_mesh* meshes; cgltf_size meshes_count; cgltf_material* materials; cgltf_size materials_count; cgltf_accessor* accessors; cgltf_size accessors_count; cgltf_buffer_view* buffer_views; cgltf_size buffer_views_count; cgltf_buffer* buffers; cgltf_size buffers_count; cgltf_image* images; cgltf_size images_count; cgltf_texture* textures; cgltf_size textures_count; cgltf_sampler* samplers; cgltf_size samplers_count; cgltf_skin* skins; cgltf_size skins_count; cgltf_camera* cameras; cgltf_size cameras_count; cgltf_light* lights; cgltf_size lights_count; cgltf_node* nodes; cgltf_size nodes_count; cgltf_scene* scenes; cgltf_size scenes_count; cgltf_scene* scene; cgltf_animation* animations; cgltf_size animations_count; const void* bin; cgltf_size bin_size; void (*memory_free) (void* user, void* ptr); void* memory_user_data; } cgltf_data; cgltf_result cgltf_parse( const cgltf_options* options, const void* data, cgltf_size size, cgltf_data** out_data); cgltf_result cgltf_parse_file( const cgltf_options* options, const char* path, cgltf_data** out_data); cgltf_result cgltf_load_buffers( const cgltf_options* options, cgltf_data* data, const char* base_path); cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data); cgltf_result cgltf_validate( cgltf_data* data); void cgltf_free(cgltf_data* data); void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix); void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix); cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size); cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index); #ifdef __cplusplus } #endif #endif /* #ifndef CGLTF_H_INCLUDED__ */ /* * * Stop now, if you are only interested in the API. * Below, you find the implementation. * */ #ifdef __INTELLISENSE__ /* This makes MSVC intellisense work. */ #define CGLTF_IMPLEMENTATION #endif #ifdef CGLTF_IMPLEMENTATION #include /* For uint8_t, uint32_t */ #include /* For strncpy */ #include /* For malloc, free */ #include /* For fopen */ #include /* For UINT_MAX etc */ /* * -- jsmn.h start -- * Source: https://github.com/zserge/jsmn * License: MIT */ typedef enum { JSMN_UNDEFINED = 0, JSMN_OBJECT = 1, JSMN_ARRAY = 2, JSMN_STRING = 3, JSMN_PRIMITIVE = 4 } jsmntype_t; enum jsmnerr { /* Not enough tokens were provided */ JSMN_ERROR_NOMEM = -1, /* Invalid character inside JSON string */ JSMN_ERROR_INVAL = -2, /* The string is not a full JSON packet, more bytes expected */ JSMN_ERROR_PART = -3 }; typedef struct { jsmntype_t type; int start; int end; int size; #ifdef JSMN_PARENT_LINKS int parent; #endif } jsmntok_t; typedef struct { unsigned int pos; /* offset in the JSON string */ unsigned int toknext; /* next token to allocate */ int toksuper; /* superior token node, e.g parent object or array */ } jsmn_parser; static void jsmn_init(jsmn_parser *parser); static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens); /* * -- jsmn.h end -- */ static const cgltf_size GlbHeaderSize = 12; static const cgltf_size GlbChunkHeaderSize = 8; static const uint32_t GlbVersion = 2; static const uint32_t GlbMagic = 0x46546C67; static const uint32_t GlbMagicJsonChunk = 0x4E4F534A; static const uint32_t GlbMagicBinChunk = 0x004E4942; static void* cgltf_default_alloc(void* user, cgltf_size size) { return malloc(size); } static void cgltf_default_free(void* user, void* ptr) { free(ptr); } static void* cgltf_calloc(cgltf_options* options, size_t element_size, cgltf_size count) { if (SIZE_MAX / element_size < count) { return NULL; } void* result = options->memory_alloc(options->memory_user_data, element_size * count); if (!result) { return NULL; } memset(result, 0, element_size * count); return result; } static cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk, cgltf_size size, cgltf_data** out_data); cgltf_result cgltf_parse(const cgltf_options* options, const void* data, cgltf_size size, cgltf_data** out_data) { if (size < GlbHeaderSize) { return cgltf_result_data_too_short; } if (options == NULL) { return cgltf_result_invalid_options; } cgltf_options fixed_options = *options; if (fixed_options.memory_alloc == NULL) { fixed_options.memory_alloc = &cgltf_default_alloc; } if (fixed_options.memory_free == NULL) { fixed_options.memory_free = &cgltf_default_free; } uint32_t tmp; // Magic memcpy(&tmp, data, 4); if (tmp != GlbMagic) { if (fixed_options.type == cgltf_file_type_invalid) { fixed_options.type = cgltf_file_type_gltf; } else if (fixed_options.type == cgltf_file_type_glb) { return cgltf_result_unknown_format; } } if (fixed_options.type == cgltf_file_type_gltf) { cgltf_result json_result = cgltf_parse_json(&fixed_options, (const uint8_t*)data, size, out_data); if (json_result != cgltf_result_success) { return json_result; } (*out_data)->file_type = cgltf_file_type_gltf; return cgltf_result_success; } const uint8_t* ptr = (const uint8_t*)data; // Version memcpy(&tmp, ptr + 4, 4); uint32_t version = tmp; if (version != GlbVersion) { return cgltf_result_unknown_format; } // Total length memcpy(&tmp, ptr + 8, 4); if (tmp > size) { return cgltf_result_data_too_short; } const uint8_t* json_chunk = ptr + GlbHeaderSize; if (GlbHeaderSize + GlbChunkHeaderSize > size) { return cgltf_result_data_too_short; } // JSON chunk: length uint32_t json_length; memcpy(&json_length, json_chunk, 4); if (GlbHeaderSize + GlbChunkHeaderSize + json_length > size) { return cgltf_result_data_too_short; } // JSON chunk: magic memcpy(&tmp, json_chunk + 4, 4); if (tmp != GlbMagicJsonChunk) { return cgltf_result_unknown_format; } json_chunk += GlbChunkHeaderSize; const void* bin = 0; cgltf_size bin_size = 0; if (GlbHeaderSize + GlbChunkHeaderSize + json_length + GlbChunkHeaderSize <= size) { // We can read another chunk const uint8_t* bin_chunk = json_chunk + json_length; // Bin chunk: length uint32_t bin_length; memcpy(&bin_length, bin_chunk, 4); if (GlbHeaderSize + GlbChunkHeaderSize + json_length + GlbChunkHeaderSize + bin_length > size) { return cgltf_result_data_too_short; } // Bin chunk: magic memcpy(&tmp, bin_chunk + 4, 4); if (tmp != GlbMagicBinChunk) { return cgltf_result_unknown_format; } bin_chunk += GlbChunkHeaderSize; bin = bin_chunk; bin_size = bin_length; } cgltf_result json_result = cgltf_parse_json(&fixed_options, json_chunk, json_length, out_data); if (json_result != cgltf_result_success) { return json_result; } (*out_data)->file_type = cgltf_file_type_glb; (*out_data)->bin = bin; (*out_data)->bin_size = bin_size; return cgltf_result_success; } cgltf_result cgltf_parse_file(const cgltf_options* options, const char* path, cgltf_data** out_data) { if (options == NULL) { return cgltf_result_invalid_options; } void* (*memory_alloc)(void*, cgltf_size) = options->memory_alloc ? options->memory_alloc : &cgltf_default_alloc; void (*memory_free)(void*, void*) = options->memory_free ? options->memory_free : &cgltf_default_free; FILE* file = fopen(path, "rb"); if (!file) { return cgltf_result_file_not_found; } fseek(file, 0, SEEK_END); long length = ftell(file); if (length < 0) { fclose(file); return cgltf_result_io_error; } fseek(file, 0, SEEK_SET); char* file_data = (char*)memory_alloc(options->memory_user_data, length); if (!file_data) { fclose(file); return cgltf_result_out_of_memory; } cgltf_size file_size = (cgltf_size)length; cgltf_size read_size = fread(file_data, 1, file_size, file); fclose(file); if (read_size != file_size) { memory_free(options->memory_user_data, file_data); return cgltf_result_io_error; } cgltf_result result = cgltf_parse(options, file_data, file_size, out_data); if (result != cgltf_result_success) { memory_free(options->memory_user_data, file_data); return result; } (*out_data)->file_data = file_data; return cgltf_result_success; } static void cgltf_combine_paths(char* path, const char* base, const char* uri) { const char* s0 = strrchr(base, '/'); const char* s1 = strrchr(base, '\\'); const char* slash = s0 ? (s1 && s1 > s0 ? s1 : s0) : s1; if (slash) { size_t prefix = slash - base + 1; strncpy(path, base, prefix); strcpy(path + prefix, uri); } else { strcpy(path, base); } } static cgltf_result cgltf_load_buffer_file(const cgltf_options* options, cgltf_size size, const char* uri, const char* base_path, void** out_data) { void* (*memory_alloc)(void*, cgltf_size) = options->memory_alloc ? options->memory_alloc : &cgltf_default_alloc; void (*memory_free)(void*, void*) = options->memory_free ? options->memory_free : &cgltf_default_free; char* path = (char*)memory_alloc(options->memory_user_data, strlen(uri) + strlen(base_path) + 1); if (!path) { return cgltf_result_out_of_memory; } cgltf_combine_paths(path, base_path, uri); FILE* file = fopen(path, "rb"); memory_free(options->memory_user_data, path); if (!file) { return cgltf_result_file_not_found; } char* file_data = (char*)memory_alloc(options->memory_user_data, size); if (!file_data) { fclose(file); return cgltf_result_out_of_memory; } cgltf_size read_size = fread(file_data, 1, size, file); fclose(file); if (read_size != size) { memory_free(options->memory_user_data, file_data); return cgltf_result_io_error; } *out_data = file_data; return cgltf_result_success; } cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data) { void* (*memory_alloc)(void*, cgltf_size) = options->memory_alloc ? options->memory_alloc : &cgltf_default_alloc; void (*memory_free)(void*, void*) = options->memory_free ? options->memory_free : &cgltf_default_free; unsigned char* data = (unsigned char*)memory_alloc(options->memory_user_data, size); if (!data) { return cgltf_result_out_of_memory; } unsigned int buffer = 0; unsigned int buffer_bits = 0; for (cgltf_size i = 0; i < size; ++i) { while (buffer_bits < 8) { char ch = *base64++; int index = (unsigned)(ch - 'A') < 26 ? (ch - 'A') : (unsigned)(ch - 'a') < 26 ? (ch - 'a') + 26 : (unsigned)(ch - '0') < 10 ? (ch - '0') + 52 : ch == '+' ? 62 : ch == '/' ? 63 : -1; if (index < 0) { memory_free(options->memory_user_data, data); return cgltf_result_io_error; } buffer = (buffer << 6) | index; buffer_bits += 6; } data[i] = (unsigned char)(buffer >> (buffer_bits - 8)); buffer_bits -= 8; } *out_data = data; return cgltf_result_success; } cgltf_result cgltf_load_buffers(const cgltf_options* options, cgltf_data* data, const char* base_path) { if (options == NULL) { return cgltf_result_invalid_options; } if (data->buffers_count && data->buffers[0].data == NULL && data->buffers[0].uri == NULL && data->bin) { if (data->bin_size < data->buffers[0].size) { return cgltf_result_data_too_short; } data->buffers[0].data = (void*)data->bin; } for (cgltf_size i = 0; i < data->buffers_count; ++i) { if (data->buffers[i].data) { continue; } const char* uri = data->buffers[i].uri; if (uri == NULL) { continue; } if (strncmp(uri, "data:", 5) == 0) { const char* comma = strchr(uri, ','); if (comma && comma - uri >= 7 && strncmp(comma - 7, ";base64", 7) == 0) { cgltf_result res = cgltf_load_buffer_base64(options, data->buffers[i].size, comma + 1, &data->buffers[i].data); if (res != cgltf_result_success) { return res; } } else { return cgltf_result_unknown_format; } } else if (strstr(uri, "://") == NULL) { cgltf_result res = cgltf_load_buffer_file(options, data->buffers[i].size, uri, base_path, &data->buffers[i].data); if (res != cgltf_result_success) { return res; } } else { return cgltf_result_unknown_format; } } return cgltf_result_success; } static cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type); static cgltf_size cgltf_calc_index_bound(cgltf_buffer_view* buffer_view, cgltf_size offset, cgltf_component_type component_type, cgltf_size count) { char* data = (char*)buffer_view->buffer->data + offset + buffer_view->offset; cgltf_size bound = 0; switch (component_type) { case cgltf_component_type_r_8u: for (size_t i = 0; i < count; ++i) { cgltf_size v = ((unsigned char*)data)[i]; bound = bound > v ? bound : v; } break; case cgltf_component_type_r_16u: for (size_t i = 0; i < count; ++i) { cgltf_size v = ((unsigned short*)data)[i]; bound = bound > v ? bound : v; } break; case cgltf_component_type_r_32u: for (size_t i = 0; i < count; ++i) { cgltf_size v = ((unsigned int*)data)[i]; bound = bound > v ? bound : v; } break; default: ; } return bound; } cgltf_result cgltf_validate(cgltf_data* data) { for (cgltf_size i = 0; i < data->accessors_count; ++i) { cgltf_accessor* accessor = &data->accessors[i]; cgltf_size element_size = cgltf_calc_size(accessor->type, accessor->component_type); if (accessor->buffer_view) { cgltf_size req_size = accessor->offset + accessor->stride * (accessor->count - 1) + element_size; if (accessor->buffer_view->size < req_size) { return cgltf_result_data_too_short; } } if (accessor->is_sparse) { cgltf_accessor_sparse* sparse = &accessor->sparse; cgltf_size indices_component_size = cgltf_calc_size(cgltf_type_scalar, sparse->indices_component_type); cgltf_size indices_req_size = sparse->indices_byte_offset + indices_component_size * sparse->count; cgltf_size values_req_size = sparse->values_byte_offset + element_size * sparse->count; if (sparse->indices_buffer_view->size < indices_req_size || sparse->values_buffer_view->size < values_req_size) { return cgltf_result_data_too_short; } if (sparse->indices_component_type != cgltf_component_type_r_8u && sparse->indices_component_type != cgltf_component_type_r_16u && sparse->indices_component_type != cgltf_component_type_r_32u) { return cgltf_result_invalid_gltf; } if (sparse->indices_buffer_view->buffer->data) { cgltf_size index_bound = cgltf_calc_index_bound(sparse->indices_buffer_view, sparse->indices_byte_offset, sparse->indices_component_type, sparse->count); if (index_bound >= accessor->count) { return cgltf_result_data_too_short; } } } } for (cgltf_size i = 0; i < data->buffer_views_count; ++i) { cgltf_size req_size = data->buffer_views[i].offset + data->buffer_views[i].size; if (data->buffer_views[i].buffer && data->buffer_views[i].buffer->size < req_size) { return cgltf_result_data_too_short; } } for (cgltf_size i = 0; i < data->meshes_count; ++i) { if (data->meshes[i].weights) { if (data->meshes[i].primitives_count && data->meshes[i].primitives[0].targets_count != data->meshes[i].weights_count) { return cgltf_result_invalid_gltf; } } for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j) { if (data->meshes[i].primitives[j].targets_count != data->meshes[i].primitives[0].targets_count) { return cgltf_result_invalid_gltf; } if (data->meshes[i].primitives[j].attributes_count) { cgltf_accessor* first = data->meshes[i].primitives[j].attributes[0].data; for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k) { if (data->meshes[i].primitives[j].attributes[k].data->count != first->count) { return cgltf_result_invalid_gltf; } } for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k) { for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m) { if (data->meshes[i].primitives[j].targets[k].attributes[m].data->count != first->count) { return cgltf_result_invalid_gltf; } } } cgltf_accessor* indices = data->meshes[i].primitives[j].indices; if (indices && indices->component_type != cgltf_component_type_r_8u && indices->component_type != cgltf_component_type_r_16u && indices->component_type != cgltf_component_type_r_32u) { return cgltf_result_invalid_gltf; } if (indices && indices->buffer_view && indices->buffer_view->buffer->data) { cgltf_size index_bound = cgltf_calc_index_bound(indices->buffer_view, indices->offset, indices->component_type, indices->count); if (index_bound >= first->count) { return cgltf_result_data_too_short; } } } } } for (cgltf_size i = 0; i < data->nodes_count; ++i) { if (data->nodes[i].weights && data->nodes[i].mesh) { if (data->nodes[i].mesh->primitives_count && data->nodes[i].mesh->primitives[0].targets_count != data->nodes[i].weights_count) { return cgltf_result_invalid_gltf; } } } return cgltf_result_success; } void cgltf_free(cgltf_data* data) { if (!data) { return; } data->memory_free(data->memory_user_data, data->asset.copyright); data->memory_free(data->memory_user_data, data->asset.generator); data->memory_free(data->memory_user_data, data->asset.version); data->memory_free(data->memory_user_data, data->asset.min_version); data->memory_free(data->memory_user_data, data->accessors); data->memory_free(data->memory_user_data, data->buffer_views); for (cgltf_size i = 0; i < data->buffers_count; ++i) { if (data->buffers[i].data != data->bin) { data->memory_free(data->memory_user_data, data->buffers[i].data); } data->memory_free(data->memory_user_data, data->buffers[i].uri); } data->memory_free(data->memory_user_data, data->buffers); for (cgltf_size i = 0; i < data->meshes_count; ++i) { data->memory_free(data->memory_user_data, data->meshes[i].name); for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j) { for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k) { data->memory_free(data->memory_user_data, data->meshes[i].primitives[j].attributes[k].name); } data->memory_free(data->memory_user_data, data->meshes[i].primitives[j].attributes); for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k) { for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m) { data->memory_free(data->memory_user_data, data->meshes[i].primitives[j].targets[k].attributes[m].name); } data->memory_free(data->memory_user_data, data->meshes[i].primitives[j].targets[k].attributes); } data->memory_free(data->memory_user_data, data->meshes[i].primitives[j].targets); } data->memory_free(data->memory_user_data, data->meshes[i].primitives); data->memory_free(data->memory_user_data, data->meshes[i].weights); } data->memory_free(data->memory_user_data, data->meshes); for (cgltf_size i = 0; i < data->materials_count; ++i) { data->memory_free(data->memory_user_data, data->materials[i].name); } data->memory_free(data->memory_user_data, data->materials); for (cgltf_size i = 0; i < data->images_count; ++i) { data->memory_free(data->memory_user_data, data->images[i].name); data->memory_free(data->memory_user_data, data->images[i].uri); data->memory_free(data->memory_user_data, data->images[i].mime_type); } data->memory_free(data->memory_user_data, data->images); for (cgltf_size i = 0; i < data->textures_count; ++i) { data->memory_free(data->memory_user_data, data->textures[i].name); } data->memory_free(data->memory_user_data, data->textures); data->memory_free(data->memory_user_data, data->samplers); for (cgltf_size i = 0; i < data->skins_count; ++i) { data->memory_free(data->memory_user_data, data->skins[i].name); data->memory_free(data->memory_user_data, data->skins[i].joints); } data->memory_free(data->memory_user_data, data->skins); for (cgltf_size i = 0; i < data->cameras_count; ++i) { data->memory_free(data->memory_user_data, data->cameras[i].name); } data->memory_free(data->memory_user_data, data->cameras); for (cgltf_size i = 0; i < data->lights_count; ++i) { data->memory_free(data->memory_user_data, data->lights[i].name); } data->memory_free(data->memory_user_data, data->lights); for (cgltf_size i = 0; i < data->nodes_count; ++i) { data->memory_free(data->memory_user_data, data->nodes[i].name); data->memory_free(data->memory_user_data, data->nodes[i].children); data->memory_free(data->memory_user_data, data->nodes[i].weights); } data->memory_free(data->memory_user_data, data->nodes); for (cgltf_size i = 0; i < data->scenes_count; ++i) { data->memory_free(data->memory_user_data, data->scenes[i].name); data->memory_free(data->memory_user_data, data->scenes[i].nodes); } data->memory_free(data->memory_user_data, data->scenes); for (cgltf_size i = 0; i < data->animations_count; ++i) { data->memory_free(data->memory_user_data, data->animations[i].name); data->memory_free(data->memory_user_data, data->animations[i].samplers); data->memory_free(data->memory_user_data, data->animations[i].channels); } data->memory_free(data->memory_user_data, data->animations); data->memory_free(data->memory_user_data, data->file_data); data->memory_free(data->memory_user_data, data); } void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix) { cgltf_float* lm = out_matrix; if (node->has_matrix) { memcpy(lm, node->matrix, sizeof(float) * 16); } else { float tx = node->translation[0]; float ty = node->translation[1]; float tz = node->translation[2]; float qx = node->rotation[0]; float qy = node->rotation[1]; float qz = node->rotation[2]; float qw = node->rotation[3]; float sx = node->scale[0]; float sy = node->scale[1]; float sz = node->scale[2]; lm[0] = (1 - 2 * qy*qy - 2 * qz*qz) * sx; lm[1] = (2 * qx*qy + 2 * qz*qw) * sy; lm[2] = (2 * qx*qz - 2 * qy*qw) * sz; lm[3] = 0.f; lm[4] = (2 * qx*qy - 2 * qz*qw) * sx; lm[5] = (1 - 2 * qx*qx - 2 * qz*qz) * sy; lm[6] = (2 * qy*qz + 2 * qx*qw) * sz; lm[7] = 0.f; lm[8] = (2 * qx*qz + 2 * qy*qw) * sx; lm[9] = (2 * qy*qz - 2 * qx*qw) * sy; lm[10] = (1 - 2 * qx*qx - 2 * qy*qy) * sz; lm[11] = 0.f; lm[12] = tx; lm[13] = ty; lm[14] = tz; lm[15] = 1.f; } } void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix) { cgltf_float* lm = out_matrix; cgltf_node_transform_local(node, lm); const cgltf_node* parent = node->parent; while (parent) { float pm[16]; cgltf_node_transform_local(parent, pm); for (int i = 0; i < 4; ++i) { float l0 = lm[i * 4 + 0]; float l1 = lm[i * 4 + 1]; float l2 = lm[i * 4 + 2]; float r0 = l0 * pm[0] + l1 * pm[4] + l2 * pm[8]; float r1 = l0 * pm[1] + l1 * pm[5] + l2 * pm[9]; float r2 = l0 * pm[2] + l1 * pm[6] + l2 * pm[10]; lm[i * 4 + 0] = r0; lm[i * 4 + 1] = r1; lm[i * 4 + 2] = r2; } lm[12] += pm[12]; lm[13] += pm[13]; lm[14] += pm[14]; parent = parent->parent; } } static cgltf_size cgltf_component_read_index(const void* in, cgltf_component_type component_type) { switch (component_type) { case cgltf_component_type_r_16: return *((const int16_t*) in); case cgltf_component_type_r_16u: return *((const uint16_t*) in); case cgltf_component_type_r_32u: return *((const uint32_t*) in); case cgltf_component_type_r_32f: return *((const float*) in); case cgltf_component_type_r_8: return *((const int8_t*) in); case cgltf_component_type_r_8u: case cgltf_component_type_invalid: default: return *((const uint8_t*) in); } } static cgltf_float cgltf_component_read_float(const void* in, cgltf_component_type component_type, cgltf_bool normalized) { if (component_type == cgltf_component_type_r_32f) { return *((const float*) in); } if (normalized) { switch (component_type) { case cgltf_component_type_r_32u: return *((const uint32_t*) in) / (float) UINT_MAX; case cgltf_component_type_r_16: return *((const int16_t*) in) / (float) SHRT_MAX; case cgltf_component_type_r_16u: return *((const uint16_t*) in) / (float) USHRT_MAX; case cgltf_component_type_r_8: return *((const int8_t*) in) / (float) SCHAR_MAX; case cgltf_component_type_r_8u: case cgltf_component_type_invalid: default: return *((const uint8_t*) in) / (float) CHAR_MAX; } } return cgltf_component_read_index(in, component_type); } static cgltf_size cgltf_num_components(cgltf_type type); static cgltf_size cgltf_component_size(cgltf_component_type component_type); static cgltf_bool cgltf_element_read_float(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_bool normalized, cgltf_float* out, cgltf_size element_size) { cgltf_size num_components = cgltf_num_components(type); if (element_size < num_components) { return 0; } // There are three special cases for component extraction, see #data-alignment in the 2.0 spec. cgltf_size component_size = cgltf_component_size(component_type); if (type == cgltf_type_mat2 && component_size == 1) { out[0] = cgltf_component_read_float(element, component_type, normalized); out[1] = cgltf_component_read_float(element + 1, component_type, normalized); out[2] = cgltf_component_read_float(element + 4, component_type, normalized); out[3] = cgltf_component_read_float(element + 5, component_type, normalized); return 1; } if (type == cgltf_type_mat3 && component_size == 1) { out[0] = cgltf_component_read_float(element, component_type, normalized); out[1] = cgltf_component_read_float(element + 1, component_type, normalized); out[2] = cgltf_component_read_float(element + 2, component_type, normalized); out[3] = cgltf_component_read_float(element + 4, component_type, normalized); out[4] = cgltf_component_read_float(element + 5, component_type, normalized); out[5] = cgltf_component_read_float(element + 6, component_type, normalized); out[6] = cgltf_component_read_float(element + 8, component_type, normalized); out[7] = cgltf_component_read_float(element + 9, component_type, normalized); out[8] = cgltf_component_read_float(element + 10, component_type, normalized); return 1; } if (type == cgltf_type_mat3 && component_size == 2) { out[0] = cgltf_component_read_float(element, component_type, normalized); out[1] = cgltf_component_read_float(element + 2, component_type, normalized); out[2] = cgltf_component_read_float(element + 4, component_type, normalized); out[3] = cgltf_component_read_float(element + 8, component_type, normalized); out[4] = cgltf_component_read_float(element + 10, component_type, normalized); out[5] = cgltf_component_read_float(element + 12, component_type, normalized); out[6] = cgltf_component_read_float(element + 16, component_type, normalized); out[7] = cgltf_component_read_float(element + 18, component_type, normalized); out[8] = cgltf_component_read_float(element + 20, component_type, normalized); return 1; } for (cgltf_size i = 0; i < num_components; ++i) { out[i] = cgltf_component_read_float(element + component_size * i, component_type, normalized); } return 1; } cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size) { if (accessor->is_sparse || accessor->buffer_view == NULL) { return 0; } cgltf_size offset = accessor->offset + accessor->buffer_view->offset; const uint8_t* element = (const uint8_t*) accessor->buffer_view->buffer->data; element += offset + accessor->stride * index; return cgltf_element_read_float(element, accessor->type, accessor->component_type, accessor->normalized, out, element_size); } cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index) { if (accessor->buffer_view) { cgltf_size offset = accessor->offset + accessor->buffer_view->offset; const uint8_t* element = (const uint8_t*) accessor->buffer_view->buffer->data; element += offset + accessor->stride * index; return cgltf_component_read_index(element, accessor->component_type); } return 0; } #define CGLTF_ERROR_JSON -1 #define CGLTF_ERROR_NOMEM -2 #define CGLTF_CHECK_TOKTYPE(tok_, type_) if ((tok_).type != (type_)) { return CGLTF_ERROR_JSON; } #define CGLTF_CHECK_KEY(tok_) if ((tok_).type != JSMN_STRING || (tok_).size == 0) { return CGLTF_ERROR_JSON; } /* checking size for 0 verifies that a value follows the key */ #define CGLTF_PTRINDEX(type, idx) (type*)(cgltf_size)(idx + 1) #define CGLTF_PTRFIXUP(var, data, size) if (var) { if ((cgltf_size)var > size) { return CGLTF_ERROR_JSON; } var = &data[(cgltf_size)var-1]; } #define CGLTF_PTRFIXUP_REQ(var, data, size) if (!var || (cgltf_size)var > size) { return CGLTF_ERROR_JSON; } var = &data[(cgltf_size)var-1]; static int cgltf_json_strcmp(jsmntok_t const* tok, const uint8_t* json_chunk, const char* str) { CGLTF_CHECK_TOKTYPE(*tok, JSMN_STRING); size_t const str_len = strlen(str); size_t const name_length = tok->end - tok->start; return (str_len == name_length) ? strncmp((const char*)json_chunk + tok->start, str, str_len) : 128; } static int cgltf_json_to_int(jsmntok_t const* tok, const uint8_t* json_chunk) { CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE); char tmp[128]; int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : sizeof(tmp) - 1; strncpy(tmp, (const char*)json_chunk + tok->start, size); tmp[size] = 0; return atoi(tmp); } static cgltf_float cgltf_json_to_float(jsmntok_t const* tok, const uint8_t* json_chunk) { CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE); char tmp[128]; int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : sizeof(tmp) - 1; strncpy(tmp, (const char*)json_chunk + tok->start, size); tmp[size] = 0; return (cgltf_float)atof(tmp); } static cgltf_bool cgltf_json_to_bool(jsmntok_t const* tok, const uint8_t* json_chunk) { int size = tok->end - tok->start; return size == 4 && memcmp(json_chunk + tok->start, "true", 4) == 0; } static int cgltf_skip_json(jsmntok_t const* tokens, int i) { if (tokens[i].type == JSMN_ARRAY) { int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { i = cgltf_skip_json(tokens, i); if (i < 0) { return i; } } } else if (tokens[i].type == JSMN_OBJECT) { int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); ++i; i = cgltf_skip_json(tokens, i); if (i < 0) { return i; } } } else if (tokens[i].type == JSMN_PRIMITIVE || tokens[i].type == JSMN_STRING) { return i + 1; } return i; } static void cgltf_fill_float_array(float* out_array, int size, float value) { for (int j = 0; j < size; ++j) { out_array[j] = value; } } static int cgltf_parse_json_float_array(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, float* out_array, int size) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY); if (tokens[i].size != size) { return CGLTF_ERROR_JSON; } ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); out_array[j] = cgltf_json_to_float(tokens + i, json_chunk); ++i; } return i; } static int cgltf_parse_json_string(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, char** out_string) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING); if (*out_string) { return CGLTF_ERROR_JSON; } int size = tokens[i].end - tokens[i].start; char* result = (char*)options->memory_alloc(options->memory_user_data, size + 1); if (!result) { return CGLTF_ERROR_NOMEM; } strncpy(result, (const char*)json_chunk + tokens[i].start, size); result[size] = 0; *out_string = result; return i + 1; } static int cgltf_parse_json_array(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, size_t element_size, void** out_array, cgltf_size* out_size) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY); if (*out_array) { return CGLTF_ERROR_JSON; } int size = tokens[i].size; void* result = cgltf_calloc(options, element_size, size); if (!result) { return CGLTF_ERROR_NOMEM; } *out_array = result; *out_size = size; return i + 1; } static void cgltf_parse_attribute_type(const char* name, cgltf_attribute_type* out_type, int* out_index) { const char* us = strchr(name, '_'); size_t len = us ? us - name : strlen(name); if (len == 8 && strncmp(name, "POSITION", 8) == 0) { *out_type = cgltf_attribute_type_position; } else if (len == 6 && strncmp(name, "NORMAL", 6) == 0) { *out_type = cgltf_attribute_type_normal; } else if (len == 7 && strncmp(name, "TANGENT", 7) == 0) { *out_type = cgltf_attribute_type_tangent; } else if (len == 8 && strncmp(name, "TEXCOORD", 8) == 0) { *out_type = cgltf_attribute_type_texcoord; } else if (len == 5 && strncmp(name, "COLOR", 5) == 0) { *out_type = cgltf_attribute_type_color; } else if (len == 6 && strncmp(name, "JOINTS", 6) == 0) { *out_type = cgltf_attribute_type_joints; } else if (len == 7 && strncmp(name, "WEIGHTS", 7) == 0) { *out_type = cgltf_attribute_type_weights; } else { *out_type = cgltf_attribute_type_invalid; } if (us && *out_type != cgltf_attribute_type_invalid) { *out_index = atoi(us + 1); } } static int cgltf_parse_json_attribute_list(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_attribute** out_attributes, cgltf_size* out_attributes_count) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); if (*out_attributes) { return CGLTF_ERROR_JSON; } *out_attributes_count = tokens[i].size; *out_attributes = (cgltf_attribute*)cgltf_calloc(options, sizeof(cgltf_attribute), *out_attributes_count); ++i; if (!*out_attributes) { return CGLTF_ERROR_NOMEM; } for (cgltf_size j = 0; j < *out_attributes_count; ++j) { CGLTF_CHECK_KEY(tokens[i]); i = cgltf_parse_json_string(options, tokens, i, json_chunk, &(*out_attributes)[j].name); if (i < 0) { return CGLTF_ERROR_JSON; } cgltf_parse_attribute_type((*out_attributes)[j].name, &(*out_attributes)[j].type, &(*out_attributes)[j].index); (*out_attributes)[j].data = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } return i; } static int cgltf_parse_json_primitive(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_primitive* out_prim) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); out_prim->type = cgltf_primitive_type_triangles; int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "mode") == 0) { ++i; out_prim->type = (cgltf_primitive_type) cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "indices") == 0) { ++i; out_prim->indices = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "material") == 0) { ++i; out_prim->material = CGLTF_PTRINDEX(cgltf_material, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "attributes") == 0) { i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_prim->attributes, &out_prim->attributes_count); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "targets") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_morph_target), (void**)&out_prim->targets, &out_prim->targets_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_prim->targets_count; ++j) { i = cgltf_parse_json_attribute_list(options, tokens, i, json_chunk, &out_prim->targets[j].attributes, &out_prim->targets[j].attributes_count); if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_mesh(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_mesh* out_mesh) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_mesh->name); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "primitives") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_primitive), (void**)&out_mesh->primitives, &out_mesh->primitives_count); if (i < 0) { return i; } for (cgltf_size prim_index = 0; prim_index < out_mesh->primitives_count; ++prim_index) { i = cgltf_parse_json_primitive(options, tokens, i, json_chunk, &out_mesh->primitives[prim_index]); if (i < 0) { return i; } } } else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_float), (void**)&out_mesh->weights, &out_mesh->weights_count); if (i < 0) { return i; } i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, out_mesh->weights, (int)out_mesh->weights_count); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_meshes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_mesh), (void**)&out_data->meshes, &out_data->meshes_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->meshes_count; ++j) { i = cgltf_parse_json_mesh(options, tokens, i, json_chunk, &out_data->meshes[j]); if (i < 0) { return i; } } return i; } static cgltf_component_type cgltf_json_to_component_type(jsmntok_t const* tok, const uint8_t* json_chunk) { int type = cgltf_json_to_int(tok, json_chunk); switch (type) { case 5120: return cgltf_component_type_r_8; case 5121: return cgltf_component_type_r_8u; case 5122: return cgltf_component_type_r_16; case 5123: return cgltf_component_type_r_16u; case 5125: return cgltf_component_type_r_32u; case 5126: return cgltf_component_type_r_32f; default: return cgltf_component_type_invalid; } } static int cgltf_parse_json_accessor_sparse(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_accessor_sparse* out_sparse) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0) { ++i; out_sparse->count = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "indices") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int indices_size = tokens[i].size; ++i; for (int k = 0; k < indices_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0) { ++i; out_sparse->indices_buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0) { ++i; out_sparse->indices_byte_offset = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "componentType") == 0) { ++i; out_sparse->indices_component_type = cgltf_json_to_component_type(tokens + i, json_chunk); ++i; } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else if (cgltf_json_strcmp(tokens+i, json_chunk, "values") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int values_size = tokens[i].size; ++i; for (int k = 0; k < values_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0) { ++i; out_sparse->values_buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0) { ++i; out_sparse->values_byte_offset = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_accessor(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_accessor* out_accessor) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0) { ++i; out_accessor->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0) { ++i; out_accessor->offset = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "componentType") == 0) { ++i; out_accessor->component_type = cgltf_json_to_component_type(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "normalized") == 0) { ++i; out_accessor->normalized = cgltf_json_to_bool(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0) { ++i; out_accessor->count = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0) { ++i; if (cgltf_json_strcmp(tokens+i, json_chunk, "SCALAR") == 0) { out_accessor->type = cgltf_type_scalar; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC2") == 0) { out_accessor->type = cgltf_type_vec2; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC3") == 0) { out_accessor->type = cgltf_type_vec3; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC4") == 0) { out_accessor->type = cgltf_type_vec4; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT2") == 0) { out_accessor->type = cgltf_type_mat2; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT3") == 0) { out_accessor->type = cgltf_type_mat3; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT4") == 0) { out_accessor->type = cgltf_type_mat4; } ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "min") == 0) { ++i; out_accessor->has_min = 1; // note: we can't parse the precise number of elements since type may not have been computed yet int min_size = tokens[i].size > 16 ? 16 : tokens[i].size; i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->min, min_size); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "max") == 0) { ++i; out_accessor->has_max = 1; // note: we can't parse the precise number of elements since type may not have been computed yet int max_size = tokens[i].size > 16 ? 16 : tokens[i].size; i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->max, max_size); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "sparse") == 0) { out_accessor->is_sparse = 1; i = cgltf_parse_json_accessor_sparse(tokens, i + 1, json_chunk, &out_accessor->sparse); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_texture_transform(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture_transform* out_texture_transform) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "offset") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_texture_transform->offset, 2); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "rotation") == 0) { ++i; out_texture_transform->rotation = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_texture_transform->scale, 2); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0) { ++i; out_texture_transform->texcoord = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_texture_view(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture_view* out_texture_view) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); out_texture_view->scale = 1.0f; cgltf_fill_float_array(out_texture_view->transform.scale, 2, 1.0f); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "index") == 0) { ++i; out_texture_view->texture = CGLTF_PTRINDEX(cgltf_texture, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0) { ++i; out_texture_view->texcoord = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0) { ++i; out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "strength") == 0) { ++i; out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int extensions_size = tokens[i].size; ++i; for (int k = 0; k < extensions_size; ++k) { if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_texture_transform") == 0) { out_texture_view->has_transform = 1; i = cgltf_parse_json_texture_transform(tokens, i + 1, json_chunk, &out_texture_view->transform); } else { i = cgltf_skip_json(tokens, i+1); } } } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_pbr_metallic_roughness(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_pbr_metallic_roughness* out_pbr) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "metallicFactor") == 0) { ++i; out_pbr->metallic_factor = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "roughnessFactor") == 0) { ++i; out_pbr->roughness_factor = cgltf_json_to_float(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "baseColorFactor") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->base_color_factor, 4); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "baseColorTexture") == 0) { i = cgltf_parse_json_texture_view(tokens, i + 1, json_chunk, &out_pbr->base_color_texture); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "metallicRoughnessTexture") == 0) { i = cgltf_parse_json_texture_view(tokens, i + 1, json_chunk, &out_pbr->metallic_roughness_texture); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_pbr_specular_glossiness(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_pbr_specular_glossiness* out_pbr) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "diffuseFactor") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->diffuse_factor, 4); if (i < 0) { return i; } } else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularFactor") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->specular_factor, 3); if (i < 0) { return i; } } else if (cgltf_json_strcmp(tokens+i, json_chunk, "glossinessFactor") == 0) { ++i; out_pbr->glossiness_factor = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "diffuseTexture") == 0) { i = cgltf_parse_json_texture_view(tokens, i + 1, json_chunk, &out_pbr->diffuse_texture); if (i < 0) { return i; } } else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularGlossinessTexture") == 0) { i = cgltf_parse_json_texture_view(tokens, i + 1, json_chunk, &out_pbr->specular_glossiness_texture); if (i < 0) { return i; } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_image(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_image* out_image) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "uri") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->uri); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0) { ++i; out_image->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "mimeType") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->mime_type); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->name); } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_sampler(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_sampler* out_sampler) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); out_sampler->wrap_s = 10497; out_sampler->wrap_t = 10497; int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "magFilter") == 0) { ++i; out_sampler->mag_filter = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "minFilter") == 0) { ++i; out_sampler->min_filter = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapS") == 0) { ++i; out_sampler->wrap_s = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapT") == 0) { ++i; out_sampler->wrap_t = cgltf_json_to_int(tokens + i, json_chunk); ++i; } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_texture(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture* out_texture) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_texture->name); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "sampler") == 0) { ++i; out_texture->sampler = CGLTF_PTRINDEX(cgltf_sampler, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0) { ++i; out_texture->image = CGLTF_PTRINDEX(cgltf_image, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_material(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material* out_material) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); cgltf_fill_float_array(out_material->pbr_metallic_roughness.base_color_factor, 4, 1.0f); out_material->pbr_metallic_roughness.metallic_factor = 1.0f; out_material->pbr_metallic_roughness.roughness_factor = 1.0f; cgltf_fill_float_array(out_material->pbr_specular_glossiness.diffuse_factor, 4, 1.0f); cgltf_fill_float_array(out_material->pbr_specular_glossiness.specular_factor, 3, 1.0f); out_material->pbr_specular_glossiness.glossiness_factor = 1.0f; out_material->alpha_cutoff = 0.5f; int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_material->name); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "pbrMetallicRoughness") == 0) { out_material->has_pbr_metallic_roughness = 1; i = cgltf_parse_json_pbr_metallic_roughness(tokens, i + 1, json_chunk, &out_material->pbr_metallic_roughness); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "emissiveFactor") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_material->emissive_factor, 3); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "normalTexture") == 0) { i = cgltf_parse_json_texture_view(tokens, i + 1, json_chunk, &out_material->normal_texture); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "occlusionTexture") == 0) { i = cgltf_parse_json_texture_view(tokens, i + 1, json_chunk, &out_material->occlusion_texture); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "emissiveTexture") == 0) { i = cgltf_parse_json_texture_view(tokens, i + 1, json_chunk, &out_material->emissive_texture); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaMode") == 0) { ++i; if (cgltf_json_strcmp(tokens + i, json_chunk, "OPAQUE") == 0) { out_material->alpha_mode = cgltf_alpha_mode_opaque; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "MASK") == 0) { out_material->alpha_mode = cgltf_alpha_mode_mask; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "BLEND") == 0) { out_material->alpha_mode = cgltf_alpha_mode_blend; } ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaCutoff") == 0) { ++i; out_material->alpha_cutoff = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "doubleSided") == 0) { ++i; out_material->double_sided = cgltf_json_to_bool(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int extensions_size = tokens[i].size; ++i; for (int k = 0; k < extensions_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_pbrSpecularGlossiness") == 0) { out_material->has_pbr_specular_glossiness = 1; i = cgltf_parse_json_pbr_specular_glossiness(tokens, i + 1, json_chunk, &out_material->pbr_specular_glossiness); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_unlit") == 0) { out_material->unlit = 1; i = cgltf_skip_json(tokens, i+1); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_accessors(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_accessor), (void**)&out_data->accessors, &out_data->accessors_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->accessors_count; ++j) { i = cgltf_parse_json_accessor(tokens, i, json_chunk, &out_data->accessors[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_materials(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_material), (void**)&out_data->materials, &out_data->materials_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->materials_count; ++j) { i = cgltf_parse_json_material(options, tokens, i, json_chunk, &out_data->materials[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_images(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_image), (void**)&out_data->images, &out_data->images_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->images_count; ++j) { i = cgltf_parse_json_image(options, tokens, i, json_chunk, &out_data->images[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_textures(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_texture), (void**)&out_data->textures, &out_data->textures_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->textures_count; ++j) { i = cgltf_parse_json_texture(options, tokens, i, json_chunk, &out_data->textures[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_samplers(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_sampler), (void**)&out_data->samplers, &out_data->samplers_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->samplers_count; ++j) { i = cgltf_parse_json_sampler(options, tokens, i, json_chunk, &out_data->samplers[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_buffer_view(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_buffer_view* out_buffer_view) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "buffer") == 0) { ++i; out_buffer_view->buffer = CGLTF_PTRINDEX(cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0) { ++i; out_buffer_view->offset = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0) { ++i; out_buffer_view->size = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteStride") == 0) { ++i; out_buffer_view->stride = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "target") == 0) { ++i; int type = cgltf_json_to_int(tokens+i, json_chunk); switch (type) { case 34962: type = cgltf_buffer_view_type_vertices; break; case 34963: type = cgltf_buffer_view_type_indices; break; default: type = cgltf_buffer_view_type_invalid; break; } out_buffer_view->type = (cgltf_buffer_view_type)type; ++i; } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_buffer_views(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_buffer_view), (void**)&out_data->buffer_views, &out_data->buffer_views_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->buffer_views_count; ++j) { i = cgltf_parse_json_buffer_view(tokens, i, json_chunk, &out_data->buffer_views[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_buffer(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_buffer* out_buffer) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0) { ++i; out_buffer->size = cgltf_json_to_int(tokens+i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "uri") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer->uri); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_buffers(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_buffer), (void**)&out_data->buffers, &out_data->buffers_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->buffers_count; ++j) { i = cgltf_parse_json_buffer(options, tokens, i, json_chunk, &out_data->buffers[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_skin(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_skin* out_skin) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_skin->name); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "joints") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_skin->joints, &out_skin->joints_count); if (i < 0) { return i; } for (cgltf_size k = 0; k < out_skin->joints_count; ++k) { out_skin->joints[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } } else if (cgltf_json_strcmp(tokens+i, json_chunk, "skeleton") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); out_skin->skeleton = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "inverseBindMatrices") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); out_skin->inverse_bind_matrices = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_skins(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_skin), (void**)&out_data->skins, &out_data->skins_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->skins_count; ++j) { i = cgltf_parse_json_skin(options, tokens, i, json_chunk, &out_data->skins[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_camera* out_camera) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_camera->name); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0) { ++i; if (cgltf_json_strcmp(tokens + i, json_chunk, "perspective") == 0) { out_camera->type = cgltf_camera_type_perspective; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "orthographic") == 0) { out_camera->type = cgltf_camera_type_orthographic; } ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "perspective") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int data_size = tokens[i].size; ++i; out_camera->type = cgltf_camera_type_perspective; for (int k = 0; k < data_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "aspectRatio") == 0) { ++i; out_camera->perspective.aspect_ratio = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "yfov") == 0) { ++i; out_camera->perspective.yfov = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "zfar") == 0) { ++i; out_camera->perspective.zfar = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "znear") == 0) { ++i; out_camera->perspective.znear = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else if (cgltf_json_strcmp(tokens+i, json_chunk, "orthographic") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int data_size = tokens[i].size; ++i; out_camera->type = cgltf_camera_type_orthographic; for (int k = 0; k < data_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "xmag") == 0) { ++i; out_camera->orthographic.xmag = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "ymag") == 0) { ++i; out_camera->orthographic.ymag = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "zfar") == 0) { ++i; out_camera->orthographic.zfar = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "znear") == 0) { ++i; out_camera->orthographic.znear = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_cameras(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_camera), (void**)&out_data->cameras, &out_data->cameras_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->cameras_count; ++j) { i = cgltf_parse_json_camera(options, tokens, i, json_chunk, &out_data->cameras[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_light(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_light* out_light) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_light->name); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "color") == 0) { i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_light->color, 3); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "intensity") == 0) { ++i; out_light->intensity = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0) { ++i; if (cgltf_json_strcmp(tokens + i, json_chunk, "directional") == 0) { out_light->type = cgltf_light_type_directional; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "point") == 0) { out_light->type = cgltf_light_type_point; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "spot") == 0) { out_light->type = cgltf_light_type_spot; } ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "range") == 0) { ++i; out_light->range = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "spot") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int data_size = tokens[i].size; ++i; for (int k = 0; k < data_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "innerConeAngle") == 0) { ++i; out_light->spot_inner_cone_angle = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "outerConeAngle") == 0) { ++i; out_light->spot_outer_cone_angle = cgltf_json_to_float(tokens + i, json_chunk); ++i; } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_lights(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_light), (void**)&out_data->lights, &out_data->lights_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->lights_count; ++j) { i = cgltf_parse_json_light(options, tokens, i, json_chunk, &out_data->lights[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_node(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_node* out_node) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); out_node->rotation[3] = 1.0f; out_node->scale[0] = 1.0f; out_node->scale[1] = 1.0f; out_node->scale[2] = 1.0f; out_node->matrix[0] = 1.0f; out_node->matrix[5] = 1.0f; out_node->matrix[10] = 1.0f; out_node->matrix[15] = 1.0f; int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_node->name); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "children") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_node->children, &out_node->children_count); if (i < 0) { return i; } for (cgltf_size k = 0; k < out_node->children_count; ++k) { out_node->children[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } } else if (cgltf_json_strcmp(tokens+i, json_chunk, "mesh") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); out_node->mesh = CGLTF_PTRINDEX(cgltf_mesh, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "skin") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); out_node->skin = CGLTF_PTRINDEX(cgltf_skin, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "camera") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); out_node->camera = CGLTF_PTRINDEX(cgltf_camera, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "translation") == 0) { out_node->has_translation = 1; i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->translation, 3); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "rotation") == 0) { out_node->has_rotation = 1; i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->rotation, 4); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "scale") == 0) { out_node->has_scale = 1; i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->scale, 3); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "matrix") == 0) { out_node->has_matrix = 1; i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->matrix, 16); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_float), (void**)&out_node->weights, &out_node->weights_count); if (i < 0) { return i; } i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, out_node->weights, (int)out_node->weights_count); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int extensions_size = tokens[i].size; ++i; for (int k = 0; k < extensions_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_lights_punctual") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int data_size = tokens[i].size; ++i; for (int m = 0; m < data_size; ++m) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "light") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); out_node->light = CGLTF_PTRINDEX(cgltf_light, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_nodes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_node), (void**)&out_data->nodes, &out_data->nodes_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->nodes_count; ++j) { i = cgltf_parse_json_node(options, tokens, i, json_chunk, &out_data->nodes[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_scene(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_scene* out_scene) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_scene->name); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "nodes") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_scene->nodes, &out_scene->nodes_count); if (i < 0) { return i; } for (cgltf_size k = 0; k < out_scene->nodes_count; ++k) { out_scene->nodes[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_scenes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_scene), (void**)&out_data->scenes, &out_data->scenes_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->scenes_count; ++j) { i = cgltf_parse_json_scene(options, tokens, i, json_chunk, &out_data->scenes[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_animation_sampler(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation_sampler* out_sampler) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "input") == 0) { ++i; out_sampler->input = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "output") == 0) { ++i; out_sampler->output = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "interpolation") == 0) { ++i; if (cgltf_json_strcmp(tokens + i, json_chunk, "LINEAR") == 0) { out_sampler->interpolation = cgltf_interpolation_type_linear; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "STEP") == 0) { out_sampler->interpolation = cgltf_interpolation_type_step; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "CUBICSPLINE") == 0) { out_sampler->interpolation = cgltf_interpolation_type_cubic_spline; } ++i; } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_animation_channel(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation_channel* out_channel) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "sampler") == 0) { ++i; out_channel->sampler = CGLTF_PTRINDEX(cgltf_animation_sampler, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "target") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int target_size = tokens[i].size; ++i; for (int k = 0; k < target_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "node") == 0) { ++i; out_channel->target_node = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "path") == 0) { ++i; if (cgltf_json_strcmp(tokens+i, json_chunk, "translation") == 0) { out_channel->target_path = cgltf_animation_path_type_translation; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "rotation") == 0) { out_channel->target_path = cgltf_animation_path_type_rotation; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "scale") == 0) { out_channel->target_path = cgltf_animation_path_type_scale; } else if (cgltf_json_strcmp(tokens+i, json_chunk, "weights") == 0) { out_channel->target_path = cgltf_animation_path_type_weights; } ++i; } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_animation(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation* out_animation) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_animation->name); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "samplers") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_sampler), (void**)&out_animation->samplers, &out_animation->samplers_count); if (i < 0) { return i; } for (cgltf_size k = 0; k < out_animation->samplers_count; ++k) { i = cgltf_parse_json_animation_sampler(options, tokens, i, json_chunk, &out_animation->samplers[k]); if (i < 0) { return i; } } } else if (cgltf_json_strcmp(tokens+i, json_chunk, "channels") == 0) { i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_channel), (void**)&out_animation->channels, &out_animation->channels_count); if (i < 0) { return i; } for (cgltf_size k = 0; k < out_animation->channels_count; ++k) { i = cgltf_parse_json_animation_channel(options, tokens, i, json_chunk, &out_animation->channels[k]); if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static int cgltf_parse_json_animations(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_animation), (void**)&out_data->animations, &out_data->animations_count); if (i < 0) { return i; } for (cgltf_size j = 0; j < out_data->animations_count; ++j) { i = cgltf_parse_json_animation(options, tokens, i, json_chunk, &out_data->animations[j]); if (i < 0) { return i; } } return i; } static int cgltf_parse_json_asset(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_asset* out_asset) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "copyright") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->copyright); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "generator") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->generator); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "version") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->version); } else if (cgltf_json_strcmp(tokens+i, json_chunk, "minVersion") == 0) { i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->min_version); } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } return i; } static cgltf_size cgltf_num_components(cgltf_type type) { switch (type) { case cgltf_type_vec2: return 2; case cgltf_type_vec3: return 3; case cgltf_type_vec4: return 4; case cgltf_type_mat2: return 4; case cgltf_type_mat3: return 9; case cgltf_type_mat4: return 16; case cgltf_type_invalid: case cgltf_type_scalar: default: return 1; } } static cgltf_size cgltf_component_size(cgltf_component_type component_type) { switch (component_type) { case cgltf_component_type_r_8: case cgltf_component_type_r_8u: return 1; case cgltf_component_type_r_16: case cgltf_component_type_r_16u: return 2; case cgltf_component_type_r_32u: case cgltf_component_type_r_32f: return 4; case cgltf_component_type_invalid: default: return 0; } } static cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type) { cgltf_size component_size = cgltf_component_size(component_type); if (type == cgltf_type_mat2 && component_size == 1) { return 8 * component_size; } else if (type == cgltf_type_mat3 && (component_size == 1 || component_size == 2)) { return 12 * component_size; } return component_size * cgltf_num_components(type); } static int cgltf_fixup_pointers(cgltf_data* out_data); static int cgltf_parse_json_root(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) { CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int size = tokens[i].size; ++i; for (int j = 0; j < size; ++j) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "asset") == 0) { i = cgltf_parse_json_asset(options, tokens, i + 1, json_chunk, &out_data->asset); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "meshes") == 0) { i = cgltf_parse_json_meshes(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "accessors") == 0) { i = cgltf_parse_json_accessors(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferViews") == 0) { i = cgltf_parse_json_buffer_views(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "buffers") == 0) { i = cgltf_parse_json_buffers(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "materials") == 0) { i = cgltf_parse_json_materials(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "images") == 0) { i = cgltf_parse_json_images(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "textures") == 0) { i = cgltf_parse_json_textures(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "samplers") == 0) { i = cgltf_parse_json_samplers(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "skins") == 0) { i = cgltf_parse_json_skins(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "cameras") == 0) { i = cgltf_parse_json_cameras(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "nodes") == 0) { i = cgltf_parse_json_nodes(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "scenes") == 0) { i = cgltf_parse_json_scenes(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "scene") == 0) { ++i; out_data->scene = CGLTF_PTRINDEX(cgltf_scene, cgltf_json_to_int(tokens + i, json_chunk)); ++i; } else if (cgltf_json_strcmp(tokens + i, json_chunk, "animations") == 0) { i = cgltf_parse_json_animations(options, tokens, i + 1, json_chunk, out_data); } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int extensions_size = tokens[i].size; ++i; for (int k = 0; k < extensions_size; ++k) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_lights_punctual") == 0) { ++i; CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); int data_size = tokens[i].size; ++i; for (int m = 0; m < data_size; ++m) { CGLTF_CHECK_KEY(tokens[i]); if (cgltf_json_strcmp(tokens + i, json_chunk, "lights") == 0) { i = cgltf_parse_json_lights(options, tokens, i + 1, json_chunk, out_data); } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i+1); } if (i < 0) { return i; } } } else { i = cgltf_skip_json(tokens, i + 1); } if (i < 0) { return i; } } return i; } cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk, cgltf_size size, cgltf_data** out_data) { jsmn_parser parser = { 0 }; if (options->json_token_count == 0) { int token_count = jsmn_parse(&parser, (const char*)json_chunk, size, NULL, 0); if (token_count <= 0) { return cgltf_result_invalid_json; } options->json_token_count = token_count; } jsmntok_t* tokens = (jsmntok_t*)options->memory_alloc(options->memory_user_data, sizeof(jsmntok_t) * options->json_token_count); if (!tokens) { return cgltf_result_out_of_memory; } jsmn_init(&parser); int token_count = jsmn_parse(&parser, (const char*)json_chunk, size, tokens, options->json_token_count); if (token_count <= 0) { options->memory_free(options->memory_user_data, tokens); return cgltf_result_invalid_json; } cgltf_data* data = (cgltf_data*)options->memory_alloc(options->memory_user_data, sizeof(cgltf_data)); if (!data) { options->memory_free(options->memory_user_data, tokens); return cgltf_result_out_of_memory; } memset(data, 0, sizeof(cgltf_data)); data->memory_free = options->memory_free; data->memory_user_data = options->memory_user_data; int i = cgltf_parse_json_root(options, tokens, 0, json_chunk, data); options->memory_free(options->memory_user_data, tokens); if (i < 0) { cgltf_free(data); return (i == CGLTF_ERROR_NOMEM) ? cgltf_result_out_of_memory : cgltf_result_invalid_gltf; } if (cgltf_fixup_pointers(data) < 0) { cgltf_free(data); return cgltf_result_invalid_gltf; } *out_data = data; return cgltf_result_success; } static int cgltf_fixup_pointers(cgltf_data* data) { for (cgltf_size i = 0; i < data->meshes_count; ++i) { for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j) { CGLTF_PTRFIXUP(data->meshes[i].primitives[j].indices, data->accessors, data->accessors_count); CGLTF_PTRFIXUP(data->meshes[i].primitives[j].material, data->materials, data->materials_count); for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k) { CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].attributes[k].data, data->accessors, data->accessors_count); } for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k) { for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m) { CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].targets[k].attributes[m].data, data->accessors, data->accessors_count); } } } } for (cgltf_size i = 0; i < data->accessors_count; ++i) { CGLTF_PTRFIXUP(data->accessors[i].buffer_view, data->buffer_views, data->buffer_views_count); if (data->accessors[i].is_sparse) { CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.indices_buffer_view, data->buffer_views, data->buffer_views_count); CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.values_buffer_view, data->buffer_views, data->buffer_views_count); } if (data->accessors[i].buffer_view) { data->accessors[i].stride = data->accessors[i].buffer_view->stride; } if (data->accessors[i].stride == 0) { data->accessors[i].stride = cgltf_calc_size(data->accessors[i].type, data->accessors[i].component_type); } } for (cgltf_size i = 0; i < data->textures_count; ++i) { CGLTF_PTRFIXUP(data->textures[i].image, data->images, data->images_count); CGLTF_PTRFIXUP(data->textures[i].sampler, data->samplers, data->samplers_count); } for (cgltf_size i = 0; i < data->images_count; ++i) { CGLTF_PTRFIXUP(data->images[i].buffer_view, data->buffer_views, data->buffer_views_count); } for (cgltf_size i = 0; i < data->materials_count; ++i) { CGLTF_PTRFIXUP(data->materials[i].normal_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].emissive_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].occlusion_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].pbr_metallic_roughness.base_color_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].pbr_specular_glossiness.diffuse_texture.texture, data->textures, data->textures_count); CGLTF_PTRFIXUP(data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.texture, data->textures, data->textures_count); } for (cgltf_size i = 0; i < data->buffer_views_count; ++i) { CGLTF_PTRFIXUP_REQ(data->buffer_views[i].buffer, data->buffers, data->buffers_count); } for (cgltf_size i = 0; i < data->skins_count; ++i) { for (cgltf_size j = 0; j < data->skins[i].joints_count; ++j) { CGLTF_PTRFIXUP_REQ(data->skins[i].joints[j], data->nodes, data->nodes_count); } CGLTF_PTRFIXUP(data->skins[i].skeleton, data->nodes, data->nodes_count); CGLTF_PTRFIXUP(data->skins[i].inverse_bind_matrices, data->accessors, data->accessors_count); } for (cgltf_size i = 0; i < data->nodes_count; ++i) { for (cgltf_size j = 0; j < data->nodes[i].children_count; ++j) { CGLTF_PTRFIXUP_REQ(data->nodes[i].children[j], data->nodes, data->nodes_count); if (data->nodes[i].children[j]->parent) { return CGLTF_ERROR_JSON; } data->nodes[i].children[j]->parent = &data->nodes[i]; } CGLTF_PTRFIXUP(data->nodes[i].mesh, data->meshes, data->meshes_count); CGLTF_PTRFIXUP(data->nodes[i].skin, data->skins, data->skins_count); CGLTF_PTRFIXUP(data->nodes[i].camera, data->cameras, data->cameras_count); CGLTF_PTRFIXUP(data->nodes[i].light, data->lights, data->lights_count); } for (cgltf_size i = 0; i < data->scenes_count; ++i) { for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j) { CGLTF_PTRFIXUP_REQ(data->scenes[i].nodes[j], data->nodes, data->nodes_count); if (data->scenes[i].nodes[j]->parent) { return CGLTF_ERROR_JSON; } } } CGLTF_PTRFIXUP(data->scene, data->scenes, data->scenes_count); for (cgltf_size i = 0; i < data->animations_count; ++i) { for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j) { CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].input, data->accessors, data->accessors_count); CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].output, data->accessors, data->accessors_count); } for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j) { CGLTF_PTRFIXUP_REQ(data->animations[i].channels[j].sampler, data->animations[i].samplers, data->animations[i].samplers_count); CGLTF_PTRFIXUP(data->animations[i].channels[j].target_node, data->nodes, data->nodes_count); } } return 0; } /* * -- jsmn.c start -- * Source: https://github.com/zserge/jsmn * License: MIT * * Copyright (c) 2010 Serge A. Zaitsev * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ /** * Allocates a fresh unused token from the token pull. */ static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens, size_t num_tokens) { jsmntok_t *tok; if (parser->toknext >= num_tokens) { return NULL; } tok = &tokens[parser->toknext++]; tok->start = tok->end = -1; tok->size = 0; #ifdef JSMN_PARENT_LINKS tok->parent = -1; #endif return tok; } /** * Fills token type and boundaries. */ static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type, int start, int end) { token->type = type; token->start = start; token->end = end; token->size = 0; } /** * Fills next available token with JSON primitive. */ static int jsmn_parse_primitive(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens) { jsmntok_t *token; int start; start = parser->pos; for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { switch (js[parser->pos]) { #ifndef JSMN_STRICT /* In strict mode primitive must be followed by "," or "}" or "]" */ case ':': #endif case '\t' : case '\r' : case '\n' : case ' ' : case ',' : case ']' : case '}' : goto found; } if (js[parser->pos] < 32 || js[parser->pos] >= 127) { parser->pos = start; return JSMN_ERROR_INVAL; } } #ifdef JSMN_STRICT /* In strict mode primitive must be followed by a comma/object/array */ parser->pos = start; return JSMN_ERROR_PART; #endif found: if (tokens == NULL) { parser->pos--; return 0; } token = jsmn_alloc_token(parser, tokens, num_tokens); if (token == NULL) { parser->pos = start; return JSMN_ERROR_NOMEM; } jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos); #ifdef JSMN_PARENT_LINKS token->parent = parser->toksuper; #endif parser->pos--; return 0; } /** * Fills next token with JSON string. */ static int jsmn_parse_string(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens) { jsmntok_t *token; int start = parser->pos; parser->pos++; /* Skip starting quote */ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { char c = js[parser->pos]; /* Quote: end of string */ if (c == '\"') { if (tokens == NULL) { return 0; } token = jsmn_alloc_token(parser, tokens, num_tokens); if (token == NULL) { parser->pos = start; return JSMN_ERROR_NOMEM; } jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos); #ifdef JSMN_PARENT_LINKS token->parent = parser->toksuper; #endif return 0; } /* Backslash: Quoted symbol expected */ if (c == '\\' && parser->pos + 1 < len) { int i; parser->pos++; switch (js[parser->pos]) { /* Allowed escaped symbols */ case '\"': case '/' : case '\\' : case 'b' : case 'f' : case 'r' : case 'n' : case 't' : break; /* Allows escaped symbol \uXXXX */ case 'u': parser->pos++; for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) { /* If it isn't a hex character we have an error */ if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */ (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */ (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */ parser->pos = start; return JSMN_ERROR_INVAL; } parser->pos++; } parser->pos--; break; /* Unexpected symbol */ default: parser->pos = start; return JSMN_ERROR_INVAL; } } } parser->pos = start; return JSMN_ERROR_PART; } /** * Parse JSON string and fill tokens. */ static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens) { int r; int i; jsmntok_t *token; int count = parser->toknext; for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { char c; jsmntype_t type; c = js[parser->pos]; switch (c) { case '{': case '[': count++; if (tokens == NULL) { break; } token = jsmn_alloc_token(parser, tokens, num_tokens); if (token == NULL) return JSMN_ERROR_NOMEM; if (parser->toksuper != -1) { tokens[parser->toksuper].size++; #ifdef JSMN_PARENT_LINKS token->parent = parser->toksuper; #endif } token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY); token->start = parser->pos; parser->toksuper = parser->toknext - 1; break; case '}': case ']': if (tokens == NULL) break; type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY); #ifdef JSMN_PARENT_LINKS if (parser->toknext < 1) { return JSMN_ERROR_INVAL; } token = &tokens[parser->toknext - 1]; for (;;) { if (token->start != -1 && token->end == -1) { if (token->type != type) { return JSMN_ERROR_INVAL; } token->end = parser->pos + 1; parser->toksuper = token->parent; break; } if (token->parent == -1) { if(token->type != type || parser->toksuper == -1) { return JSMN_ERROR_INVAL; } break; } token = &tokens[token->parent]; } #else for (i = parser->toknext - 1; i >= 0; i--) { token = &tokens[i]; if (token->start != -1 && token->end == -1) { if (token->type != type) { return JSMN_ERROR_INVAL; } parser->toksuper = -1; token->end = parser->pos + 1; break; } } /* Error if unmatched closing bracket */ if (i == -1) return JSMN_ERROR_INVAL; for (; i >= 0; i--) { token = &tokens[i]; if (token->start != -1 && token->end == -1) { parser->toksuper = i; break; } } #endif break; case '\"': r = jsmn_parse_string(parser, js, len, tokens, num_tokens); if (r < 0) return r; count++; if (parser->toksuper != -1 && tokens != NULL) tokens[parser->toksuper].size++; break; case '\t' : case '\r' : case '\n' : case ' ': break; case ':': parser->toksuper = parser->toknext - 1; break; case ',': if (tokens != NULL && parser->toksuper != -1 && tokens[parser->toksuper].type != JSMN_ARRAY && tokens[parser->toksuper].type != JSMN_OBJECT) { #ifdef JSMN_PARENT_LINKS parser->toksuper = tokens[parser->toksuper].parent; #else for (i = parser->toknext - 1; i >= 0; i--) { if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) { if (tokens[i].start != -1 && tokens[i].end == -1) { parser->toksuper = i; break; } } } #endif } break; #ifdef JSMN_STRICT /* In strict mode primitives are: numbers and booleans */ case '-': case '0': case '1' : case '2': case '3' : case '4': case '5': case '6': case '7' : case '8': case '9': case 't': case 'f': case 'n' : /* And they must not be keys of the object */ if (tokens != NULL && parser->toksuper != -1) { jsmntok_t *t = &tokens[parser->toksuper]; if (t->type == JSMN_OBJECT || (t->type == JSMN_STRING && t->size != 0)) { return JSMN_ERROR_INVAL; } } #else /* In non-strict mode every unquoted value is a primitive */ default: #endif r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens); if (r < 0) return r; count++; if (parser->toksuper != -1 && tokens != NULL) tokens[parser->toksuper].size++; break; #ifdef JSMN_STRICT /* Unexpected char in strict mode */ default: return JSMN_ERROR_INVAL; #endif } } if (tokens != NULL) { for (i = parser->toknext - 1; i >= 0; i--) { /* Unmatched opened object or array */ if (tokens[i].start != -1 && tokens[i].end == -1) { return JSMN_ERROR_PART; } } } return count; } /** * Creates a new parser based over a given buffer with an array of tokens * available. */ static void jsmn_init(jsmn_parser *parser) { parser->pos = 0; parser->toknext = 0; parser->toksuper = -1; } /* * -- jsmn.c end -- */ #endif /* #ifdef CGLTF_IMPLEMENTATION */ /* cgltf is distributed under MIT license: * * Copyright (c) 2018 Johannes Kuhlmann * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ goxel-0.11.0/ext_src/yocto/ext/filesystem.hpp000066400000000000000000004706771435762723100212470ustar00rootroot00000000000000//--------------------------------------------------------------------------------------- // // ghc::filesystem - A C++17-like filesystem implementation for C++11/C++147/C++17 // //--------------------------------------------------------------------------------------- // // Copyright (c) 2018, Steffen Schümann // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this // list of conditions and the following disclaimer. // // 2. 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. // // 3. Neither the name of the copyright holder nor the names of its contributors // may be used to endorse or promote products derived from this software without // specific prior written permission. // // 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. // //--------------------------------------------------------------------------------------- // // To dynamically select std::filesystem where available, you could use: // // #if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) && __has_include() // #include // namespace fs = std::filesystem; // #else // #include // namespace fs = ghc::filesystem; // #endif // //--------------------------------------------------------------------------------------- #ifndef GHC_FILESYSTEM_H #define GHC_FILESYSTEM_H #if defined(__APPLE__) && defined(__MACH__) #define GHC_OS_MACOS #elif defined(__linux__) #define GHC_OS_LINUX #elif defined(_WIN64) #define GHC_OS_WINDOWS #define GHC_OS_WIN64 #elif defined(_WIN32) #define GHC_OS_WINDOWS #define GHC_OS_WIN32 #else // #error "Operating system currently not supported!" #endif #if defined(GHC_FILESYSTEM_IMPLEMENTATION) #define GHC_EXPAND_IMPL #define GHC_INLINE #ifdef GHC_OS_WINDOWS #define GHC_FS_API #define GHC_FS_API_CLASS #else #define GHC_FS_API __attribute__((visibility("default"))) #define GHC_FS_API_CLASS __attribute__((visibility("default"))) #endif #elif defined(GHC_FILESYSTEM_FWD) #define GHC_INLINE #ifdef GHC_OS_WINDOWS #define GHC_FS_API extern #define GHC_FS_API_CLASS #else #define GHC_FS_API extern #define GHC_FS_API_CLASS #endif #else #define GHC_EXPAND_IMPL #define GHC_INLINE inline #define GHC_FS_API #define GHC_FS_API_CLASS #endif #ifdef GHC_EXPAND_IMPL #ifdef GHC_OS_WINDOWS #define NOMINMAX #include // additional includes #include #include #include #include #include #else #include #include #include #include #include #include #include #include #include #if defined(__ANDROID__) #define GHC_OS_ANDROID #include #endif #endif #ifdef GHC_OS_MACOS #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #else // GHC_EXPAND_IMPL #include #include #include #include #include #include #include #ifdef GHC_OS_WINDOWS #include #endif #endif // GHC_EXPAND_IMPL //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Behaviour Switches (see README.md, should match the config in test/filesystem_test.cpp): //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // LWG #2682 disables the since then invalid use of the copy option create_symlinks on directories // configure LWG conformance () #define LWG_2682_BEHAVIOUR //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // LWG #2395 makes crate_directory/create_directories not emit an error if there is a regular // file with that name, it is superceded by P1164R1, so only activate if really needed // #define LWG_2935_BEHAVIOUR //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // LWG #2937 enforces that fs::equivalent emits an error, if !fs::exists(p1)||!exists(p2) #define LWG_2937_BEHAVIOUR //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // UTF8-Everywhere is the original behaviour of ghc::filesystem. With this define you can // enable the more standard conforming implementation option that uses wstring on Windows // as ghc::filesystem::string_type. // #define GHC_WIN_WSTRING_STRING_TYPE //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Rais errors/exceptions when invalid unicode codepoints or UTF-8 sequences are found, // instead of replacing them with the unicode replacement character (U+FFFD). // #define GHC_RAISE_UNICODE_ERRORS //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ghc::filesystem version in decimal (major * 10000 + minor * 100 + patch) #define GHC_FILESYSTEM_VERSION 10200L namespace ghc { namespace filesystem { // temporary existing exception type for yet unimplemented parts class GHC_FS_API_CLASS not_implemented_exception : public std::logic_error { public: not_implemented_exception() : std::logic_error("function not implemented yet.") { } }; // 30.10.8 class path class GHC_FS_API_CLASS path { public: #ifdef GHC_OS_WINDOWS #ifdef GHC_WIN_WSTRING_STRING_TYPE #define GHC_USE_WCHAR_T using value_type = std::wstring::value_type; #else using value_type = std::string::value_type; #endif using string_type = std::basic_string; static constexpr value_type preferred_separator = '\\'; #else using value_type = std::string::value_type; using string_type = std::basic_string; static constexpr value_type preferred_separator = '/'; #endif // 30.10.10.1 enumeration format /// The path format in wich the constructor argument is given. enum format { generic_format, ///< The generic format, internally used by ///< ghc::filesystem::path with slashes native_format, ///< The format native to the current platform this code ///< is build for auto_format, ///< Try to auto-detect the format, fallback to native }; template struct _is_basic_string : std::false_type { }; template struct _is_basic_string> : std::true_type { }; #ifdef __cpp_lib_string_view // template // struct _is_basic_string> : std::true_type // { // }; #endif template using path_type = typename std::enable_if::value, path>::type; #ifdef GHC_USE_WCHAR_T template using path_from_string = typename std::enable_if<_is_basic_string::value || std::is_same::type>::value || std::is_same::type>::value || std::is_same::type>::value || std::is_same::type>::value, path>::type; template using path_type_EcharT = typename std::enable_if::value || std::is_same::value || std::is_same::value, path>::type; #else template using path_from_string = typename std::enable_if<_is_basic_string::value || std::is_same::type>::value || std::is_same::type>::value, path>::type; template using path_type_EcharT = typename std::enable_if::value || std::is_same::value || std::is_same::value || std::is_same::value, path>::type; #endif // 30.10.8.4.1 constructors and destructor path() noexcept; path(const path& p); path(path&& p) noexcept; path(string_type&& source, format fmt = auto_format); template > path(const Source& source, format fmt = auto_format); template path(InputIterator first, InputIterator last, format fmt = auto_format); template > path(const Source& source, const std::locale& loc, format fmt = auto_format); template path(InputIterator first, InputIterator last, const std::locale& loc, format fmt = auto_format); ~path(); // 30.10.8.4.2 assignments path& operator=(const path& p); path& operator=(path&& p) noexcept; path& operator=(string_type&& source); path& assign(string_type&& source); template path& operator=(const Source& source); template path& assign(const Source& source); template path& assign(InputIterator first, InputIterator last); // 30.10.8.4.3 appends path& operator/=(const path& p); template path& operator/=(const Source& source); template path& append(const Source& source); template path& append(InputIterator first, InputIterator last); // 30.10.8.4.4 concatenation path& operator+=(const path& x); path& operator+=(const string_type& x); #ifdef __cpp_lib_string_view // path& operator+=(std::basic_string_view x); #endif path& operator+=(const value_type* x); path& operator+=(value_type x); template path_from_string& operator+=(const Source& x); template path_type_EcharT& operator+=(EcharT x); template path& concat(const Source& x); template path& concat(InputIterator first, InputIterator last); // 30.10.8.4.5 modifiers void clear() noexcept; path& make_preferred(); path& remove_filename(); path& replace_filename(const path& replacement); path& replace_extension(const path& replacement = path()); void swap(path& rhs) noexcept; // 30.10.8.4.6 native format observers const string_type& native() const; // this implementation doesn't support noexcept for native() const value_type* c_str() const; // this implementation doesn't support noexcept for c_str() operator string_type() const; template , class Allocator = std::allocator> std::basic_string string(const Allocator& a = Allocator()) const; std::string string() const; std::wstring wstring() const; std::string u8string() const; std::u16string u16string() const; std::u32string u32string() const; // 30.10.8.4.7 generic format observers template , class Allocator = std::allocator> std::basic_string generic_string(const Allocator& a = Allocator()) const; const std::string& generic_string() const; // this is different from the standard, that returns by value std::wstring generic_wstring() const; std::string generic_u8string() const; std::u16string generic_u16string() const; std::u32string generic_u32string() const; // 30.10.8.4.8 compare int compare(const path& p) const noexcept; int compare(const string_type& s) const; #ifdef __cpp_lib_string_view // int compare(std::basic_string_view s) const; #endif int compare(const value_type* s) const; // 30.10.8.4.9 decomposition path root_name() const; path root_directory() const; path root_path() const; path relative_path() const; path parent_path() const; path filename() const; path stem() const; path extension() const; // 30.10.8.4.10 query bool empty() const noexcept; bool has_root_name() const; bool has_root_directory() const; bool has_root_path() const; bool has_relative_path() const; bool has_parent_path() const; bool has_filename() const; bool has_stem() const; bool has_extension() const; bool is_absolute() const; bool is_relative() const; // 30.10.8.4.11 generation path lexically_normal() const; path lexically_relative(const path& base) const; path lexically_proximate(const path& base) const; // 30.10.8.5 iterators class iterator; using const_iterator = iterator; iterator begin() const; iterator end() const; private: using impl_value_type = std::string::value_type; using impl_string_type = std::basic_string; friend class directory_iterator; void append_name(const char* name); static constexpr impl_value_type generic_separator = '/'; template class input_iterator_range { public: typedef InputIterator iterator; typedef InputIterator const_iterator; typedef typename InputIterator::difference_type difference_type; input_iterator_range(const InputIterator& first, const InputIterator& last) : _first(first) , _last(last) { } InputIterator begin() const { return _first; } InputIterator end() const { return _last; } private: InputIterator _first; InputIterator _last; }; friend void swap(path& lhs, path& rhs) noexcept; friend size_t hash_value(const path& p) noexcept; static void postprocess_path_with_format(impl_string_type& p, format fmt); impl_string_type _path; #ifdef GHC_OS_WINDOWS impl_string_type native_impl() const; mutable string_type _native_cache; #else const impl_string_type& native_impl() const; #endif }; // 30.10.8.6 path non-member functions GHC_FS_API void swap(path& lhs, path& rhs) noexcept; GHC_FS_API size_t hash_value(const path& p) noexcept; GHC_FS_API bool operator==(const path& lhs, const path& rhs) noexcept; GHC_FS_API bool operator!=(const path& lhs, const path& rhs) noexcept; GHC_FS_API bool operator<(const path& lhs, const path& rhs) noexcept; GHC_FS_API bool operator<=(const path& lhs, const path& rhs) noexcept; GHC_FS_API bool operator>(const path& lhs, const path& rhs) noexcept; GHC_FS_API bool operator>=(const path& lhs, const path& rhs) noexcept; GHC_FS_API path operator/(const path& lhs, const path& rhs); // 30.10.8.6.1 path inserter and extractor template std::basic_ostream& operator<<(std::basic_ostream& os, const path& p); template std::basic_istream& operator>>(std::basic_istream& is, path& p); // 30.10.8.6.2 path factory functions template > path u8path(const Source& source); template path u8path(InputIterator first, InputIterator last); // 30.10.9 class filesystem_error class GHC_FS_API_CLASS filesystem_error : public std::system_error { public: filesystem_error(const std::string& what_arg, std::error_code ec); filesystem_error(const std::string& what_arg, const path& p1, std::error_code ec); filesystem_error(const std::string& what_arg, const path& p1, const path& p2, std::error_code ec); const path& path1() const noexcept; const path& path2() const noexcept; const char* what() const noexcept override; private: std::string _what_arg; std::error_code _ec; path _p1, _p2; }; class GHC_FS_API_CLASS path::iterator { public: using value_type = const path; using difference_type = std::ptrdiff_t; using pointer = const path*; using reference = const path&; using iterator_category = std::bidirectional_iterator_tag; iterator(); iterator(const impl_string_type::const_iterator& first, const impl_string_type::const_iterator& last, const impl_string_type::const_iterator& pos); iterator& operator++(); iterator operator++(int); iterator& operator--(); iterator operator--(int); bool operator==(const iterator& other) const; bool operator!=(const iterator& other) const; reference operator*() const; pointer operator->() const; private: impl_string_type::const_iterator increment(const std::string::const_iterator& pos) const; impl_string_type::const_iterator decrement(const std::string::const_iterator& pos) const; void updateCurrent(); impl_string_type::const_iterator _first; impl_string_type::const_iterator _last; impl_string_type::const_iterator _root; impl_string_type::const_iterator _iter; path _current; }; struct space_info { uintmax_t capacity; uintmax_t free; uintmax_t available; }; // 30.10.10, enumerations enum class file_type { none, not_found, regular, directory, symlink, block, character, fifo, socket, unknown, }; enum class perms : uint16_t { none = 0, owner_read = 0400, owner_write = 0200, owner_exec = 0100, owner_all = 0700, group_read = 040, group_write = 020, group_exec = 010, group_all = 070, others_read = 04, others_write = 02, others_exec = 01, others_all = 07, all = 0777, set_uid = 04000, set_gid = 02000, sticky_bit = 01000, mask = 07777, unknown = 0xffff }; enum class perm_options : uint16_t { replace = 3, add = 1, remove = 2, nofollow = 4, }; enum class copy_options : uint16_t { none = 0, skip_existing = 1, overwrite_existing = 2, update_existing = 4, recursive = 8, copy_symlinks = 0x10, skip_symlinks = 0x20, directories_only = 0x40, create_symlinks = 0x80, create_hard_links = 0x100 }; enum class directory_options : uint16_t { none = 0, follow_directory_symlink = 1, skip_permission_denied = 2, }; // 30.10.11 class file_status class GHC_FS_API_CLASS file_status { public: // 30.10.11.1 constructors and destructor file_status() noexcept; explicit file_status(file_type ft, perms prms = perms::unknown) noexcept; file_status(const file_status&) noexcept; file_status(file_status&&) noexcept; ~file_status(); // assignments: file_status& operator=(const file_status&) noexcept; file_status& operator=(file_status&&) noexcept; // 30.10.11.3 modifiers void type(file_type ft) noexcept; void permissions(perms prms) noexcept; // 30.10.11.2 observers file_type type() const noexcept; perms permissions() const noexcept; private: file_type _type; perms _perms; }; using file_time_type = std::chrono::time_point; // 30.10.12 Class directory_entry class GHC_FS_API_CLASS directory_entry { public: // 30.10.12.1 constructors and destructor directory_entry() noexcept = default; directory_entry(const directory_entry&) = default; directory_entry(directory_entry&&) noexcept = default; explicit directory_entry(const path& p); directory_entry(const path& p, std::error_code& ec); ~directory_entry(); // assignments: directory_entry& operator=(const directory_entry&) = default; directory_entry& operator=(directory_entry&&) noexcept = default; // 30.10.12.2 modifiers void assign(const path& p); void assign(const path& p, std::error_code& ec); void replace_filename(const path& p); void replace_filename(const path& p, std::error_code& ec); void refresh(); void refresh(std::error_code& ec) noexcept; // 30.10.12.3 observers const filesystem::path& path() const noexcept; operator const filesystem::path&() const noexcept; bool exists() const; bool exists(std::error_code& ec) const noexcept; bool is_block_file() const; bool is_block_file(std::error_code& ec) const noexcept; bool is_character_file() const; bool is_character_file(std::error_code& ec) const noexcept; bool is_directory() const; bool is_directory(std::error_code& ec) const noexcept; bool is_fifo() const; bool is_fifo(std::error_code& ec) const noexcept; bool is_other() const; bool is_other(std::error_code& ec) const noexcept; bool is_regular_file() const; bool is_regular_file(std::error_code& ec) const noexcept; bool is_socket() const; bool is_socket(std::error_code& ec) const noexcept; bool is_symlink() const; bool is_symlink(std::error_code& ec) const noexcept; uintmax_t file_size() const; uintmax_t file_size(std::error_code& ec) const noexcept; uintmax_t hard_link_count() const; uintmax_t hard_link_count(std::error_code& ec) const noexcept; file_time_type last_write_time() const; file_time_type last_write_time(std::error_code& ec) const noexcept; file_status status() const; file_status status(std::error_code& ec) const noexcept; file_status symlink_status() const; file_status symlink_status(std::error_code& ec) const noexcept; bool operator<(const directory_entry& rhs) const noexcept; bool operator==(const directory_entry& rhs) const noexcept; bool operator!=(const directory_entry& rhs) const noexcept; bool operator<=(const directory_entry& rhs) const noexcept; bool operator>(const directory_entry& rhs) const noexcept; bool operator>=(const directory_entry& rhs) const noexcept; private: friend class directory_iterator; filesystem::path _path; file_status _status; file_status _symlink_status; uintmax_t _file_size = 0; #ifndef GHC_OS_WINDOWS uintmax_t _hard_link_count; #endif time_t _last_write_time = 0; }; // 30.10.13 Class directory_iterator class GHC_FS_API_CLASS directory_iterator { public: class GHC_FS_API_CLASS proxy { public: const directory_entry& operator*() const& noexcept { return _dir_entry; } directory_entry operator*() && noexcept { return std::move(_dir_entry); } private: explicit proxy(const directory_entry& dir_entry) : _dir_entry(dir_entry) { } friend class directory_iterator; friend class recursive_directory_iterator; directory_entry _dir_entry; }; using iterator_category = std::input_iterator_tag; using value_type = directory_entry; using difference_type = std::ptrdiff_t; using pointer = const directory_entry*; using reference = const directory_entry&; // 30.10.13.1 member functions directory_iterator() noexcept; explicit directory_iterator(const path& p); directory_iterator(const path& p, directory_options options); directory_iterator(const path& p, std::error_code& ec) noexcept; directory_iterator(const path& p, directory_options options, std::error_code& ec) noexcept; directory_iterator(const directory_iterator& rhs); directory_iterator(directory_iterator&& rhs) noexcept; ~directory_iterator(); directory_iterator& operator=(const directory_iterator& rhs); directory_iterator& operator=(directory_iterator&& rhs) noexcept; const directory_entry& operator*() const; const directory_entry* operator->() const; directory_iterator& operator++(); directory_iterator& increment(std::error_code& ec) noexcept; // other members as required by 27.2.3, input iterators proxy operator++(int) { proxy proxy{**this}; ++*this; return proxy; } bool operator==(const directory_iterator& rhs) const; bool operator!=(const directory_iterator& rhs) const; private: friend class recursive_directory_iterator; class impl; std::shared_ptr _impl; }; // 30.10.13.2 directory_iterator non-member functions GHC_FS_API directory_iterator begin(directory_iterator iter) noexcept; GHC_FS_API directory_iterator end(const directory_iterator&) noexcept; // 30.10.14 class recursive_directory_iterator class GHC_FS_API_CLASS recursive_directory_iterator { public: using iterator_category = std::input_iterator_tag; using value_type = directory_entry; using difference_type = std::ptrdiff_t; using pointer = const directory_entry*; using reference = const directory_entry&; // 30.10.14.1 constructors and destructor recursive_directory_iterator() noexcept; explicit recursive_directory_iterator(const path& p); recursive_directory_iterator(const path& p, directory_options options); recursive_directory_iterator(const path& p, directory_options options, std::error_code& ec) noexcept; recursive_directory_iterator(const path& p, std::error_code& ec) noexcept; recursive_directory_iterator(const recursive_directory_iterator& rhs); recursive_directory_iterator(recursive_directory_iterator&& rhs) noexcept; ~recursive_directory_iterator(); // 30.10.14.1 observers directory_options options() const; int depth() const; bool recursion_pending() const; const directory_entry& operator*() const; const directory_entry* operator->() const; // 30.10.14.1 modifiers recursive_directory_iterator& recursive_directory_iterator& operator=(const recursive_directory_iterator& rhs); recursive_directory_iterator& operator=(recursive_directory_iterator&& rhs) noexcept; recursive_directory_iterator& operator++(); recursive_directory_iterator& increment(std::error_code& ec) noexcept; void pop(); void pop(std::error_code& ec); void disable_recursion_pending(); // other members as required by 27.2.3, input iterators directory_iterator::proxy operator++(int) { directory_iterator::proxy proxy{**this}; ++*this; return proxy; } bool operator==(const recursive_directory_iterator& rhs) const; bool operator!=(const recursive_directory_iterator& rhs) const; private: struct recursive_directory_iterator_impl { directory_options _options; bool _recursion_pending; std::stack _dir_iter_stack; recursive_directory_iterator_impl(directory_options options, bool recursion_pending) : _options(options) , _recursion_pending(recursion_pending) { } }; std::shared_ptr _impl; }; // 30.10.14.2 directory_iterator non-member functions GHC_FS_API recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; GHC_FS_API recursive_directory_iterator end(const recursive_directory_iterator&) noexcept; // 30.10.15 filesystem operations GHC_FS_API path absolute(const path& p); GHC_FS_API path absolute(const path& p, std::error_code& ec); GHC_FS_API path canonical(const path& p); GHC_FS_API path canonical(const path& p, std::error_code& ec); GHC_FS_API void copy(const path& from, const path& to); GHC_FS_API void copy(const path& from, const path& to, std::error_code& ec) noexcept; GHC_FS_API void copy(const path& from, const path& to, copy_options options); GHC_FS_API void copy(const path& from, const path& to, copy_options options, std::error_code& ec) noexcept; GHC_FS_API bool copy_file(const path& from, const path& to); GHC_FS_API bool copy_file(const path& from, const path& to, std::error_code& ec) noexcept; GHC_FS_API bool copy_file(const path& from, const path& to, copy_options option); GHC_FS_API bool copy_file(const path& from, const path& to, copy_options option, std::error_code& ec) noexcept; GHC_FS_API void copy_symlink(const path& existing_symlink, const path& new_symlink); GHC_FS_API void copy_symlink(const path& existing_symlink, const path& new_symlink, std::error_code& ec) noexcept; GHC_FS_API bool create_directories(const path& p); GHC_FS_API bool create_directories(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool create_directory(const path& p); GHC_FS_API bool create_directory(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool create_directory(const path& p, const path& attributes); GHC_FS_API bool create_directory(const path& p, const path& attributes, std::error_code& ec) noexcept; GHC_FS_API void create_directory_symlink(const path& to, const path& new_symlink); GHC_FS_API void create_directory_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept; GHC_FS_API void create_hard_link(const path& to, const path& new_hard_link); GHC_FS_API void create_hard_link(const path& to, const path& new_hard_link, std::error_code& ec) noexcept; GHC_FS_API void create_symlink(const path& to, const path& new_symlink); GHC_FS_API void create_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept; GHC_FS_API path current_path(); GHC_FS_API path current_path(std::error_code& ec); GHC_FS_API void current_path(const path& p); GHC_FS_API void current_path(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool exists(file_status s) noexcept; GHC_FS_API bool exists(const path& p); GHC_FS_API bool exists(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool equivalent(const path& p1, const path& p2); GHC_FS_API bool equivalent(const path& p1, const path& p2, std::error_code& ec) noexcept; GHC_FS_API uintmax_t file_size(const path& p); GHC_FS_API uintmax_t file_size(const path& p, std::error_code& ec) noexcept; GHC_FS_API uintmax_t hard_link_count(const path& p); GHC_FS_API uintmax_t hard_link_count(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_block_file(file_status s) noexcept; GHC_FS_API bool is_block_file(const path& p); GHC_FS_API bool is_block_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_character_file(file_status s) noexcept; GHC_FS_API bool is_character_file(const path& p); GHC_FS_API bool is_character_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_directory(file_status s) noexcept; GHC_FS_API bool is_directory(const path& p); GHC_FS_API bool is_directory(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_empty(const path& p); GHC_FS_API bool is_empty(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_fifo(file_status s) noexcept; GHC_FS_API bool is_fifo(const path& p); GHC_FS_API bool is_fifo(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_other(file_status s) noexcept; GHC_FS_API bool is_other(const path& p); GHC_FS_API bool is_other(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_regular_file(file_status s) noexcept; GHC_FS_API bool is_regular_file(const path& p); GHC_FS_API bool is_regular_file(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_socket(file_status s) noexcept; GHC_FS_API bool is_socket(const path& p); GHC_FS_API bool is_socket(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool is_symlink(file_status s) noexcept; GHC_FS_API bool is_symlink(const path& p); GHC_FS_API bool is_symlink(const path& p, std::error_code& ec) noexcept; GHC_FS_API file_time_type last_write_time(const path& p); GHC_FS_API file_time_type last_write_time(const path& p, std::error_code& ec) noexcept; GHC_FS_API void last_write_time(const path& p, file_time_type new_time); GHC_FS_API void last_write_time(const path& p, file_time_type new_time, std::error_code& ec) noexcept; GHC_FS_API void permissions(const path& p, perms prms, perm_options opts = perm_options::replace); GHC_FS_API void permissions(const path& p, perms prms, std::error_code& ec) noexcept; GHC_FS_API void permissions(const path& p, perms prms, perm_options opts, std::error_code& ec); GHC_FS_API path proximate(const path& p, std::error_code& ec); GHC_FS_API path proximate(const path& p, const path& base = current_path()); GHC_FS_API path proximate(const path& p, const path& base, std::error_code& ec); GHC_FS_API path read_symlink(const path& p); GHC_FS_API path read_symlink(const path& p, std::error_code& ec); GHC_FS_API path relative(const path& p, std::error_code& ec); GHC_FS_API path relative(const path& p, const path& base = current_path()); GHC_FS_API path relative(const path& p, const path& base, std::error_code& ec); GHC_FS_API bool remove(const path& p); GHC_FS_API bool remove(const path& p, std::error_code& ec) noexcept; GHC_FS_API uintmax_t remove_all(const path& p); GHC_FS_API uintmax_t remove_all(const path& p, std::error_code& ec) noexcept; GHC_FS_API void rename(const path& from, const path& to); GHC_FS_API void rename(const path& from, const path& to, std::error_code& ec) noexcept; GHC_FS_API void resize_file(const path& p, uintmax_t size); GHC_FS_API void resize_file(const path& p, uintmax_t size, std::error_code& ec) noexcept; GHC_FS_API space_info space(const path& p); GHC_FS_API space_info space(const path& p, std::error_code& ec) noexcept; GHC_FS_API file_status status(const path& p); GHC_FS_API file_status status(const path& p, std::error_code& ec) noexcept; GHC_FS_API bool status_known(file_status s) noexcept; GHC_FS_API file_status symlink_status(const path& p); GHC_FS_API file_status symlink_status(const path& p, std::error_code& ec) noexcept; GHC_FS_API path temp_directory_path(); GHC_FS_API path temp_directory_path(std::error_code& ec) noexcept; GHC_FS_API path weakly_canonical(const path& p); GHC_FS_API path weakly_canonical(const path& p, std::error_code& ec) noexcept; // Non-C++17 add-on std::fstream wrappers with path template > class basic_filebuf : public std::basic_filebuf { public: basic_filebuf() {} ~basic_filebuf() override {} basic_filebuf(const basic_filebuf&) = delete; const basic_filebuf& operator=(const basic_filebuf&) = delete; basic_filebuf* open(const path& p, std::ios_base::openmode mode) { #if defined(GHC_OS_WINDOWS) && !defined(__GNUC__) return std::basic_filebuf::open(p.wstring().c_str(), mode) ? this : 0; #else return std::basic_filebuf::open(p.string().c_str(), mode) ? this : 0; #endif } }; template > class basic_ifstream : public std::basic_ifstream { public: basic_ifstream() {} #if defined(GHC_OS_WINDOWS) && !defined(__GNUC__) explicit basic_ifstream(const path& p, std::ios_base::openmode mode = std::ios_base::in) : std::basic_ifstream(p.wstring().c_str(), mode) { } void open(const path& p, std::ios_base::openmode mode = std::ios_base::in) { std::basic_ifstream::open(p.wstring().c_str(), mode); } #else explicit basic_ifstream(const path& p, std::ios_base::openmode mode = std::ios_base::in) : std::basic_ifstream(p.string().c_str(), mode) { } void open(const path& p, std::ios_base::openmode mode = std::ios_base::in) { std::basic_ifstream::open(p.string().c_str(), mode); } #endif basic_ifstream(const basic_ifstream&) = delete; const basic_ifstream& operator=(const basic_ifstream&) = delete; ~basic_ifstream() override {} }; template > class basic_ofstream : public std::basic_ofstream { public: basic_ofstream() {} #if defined(GHC_OS_WINDOWS) && !defined(__GNUC__) explicit basic_ofstream(const path& p, std::ios_base::openmode mode = std::ios_base::out) : std::basic_ofstream(p.wstring().c_str(), mode) { } void open(const path& p, std::ios_base::openmode mode = std::ios_base::out) { std::basic_ofstream::open(p.wstring().c_str(), mode); } #else explicit basic_ofstream(const path& p, std::ios_base::openmode mode = std::ios_base::out) : std::basic_ofstream(p.string().c_str(), mode) { } void open(const path& p, std::ios_base::openmode mode = std::ios_base::out) { std::basic_ofstream::open(p.string().c_str(), mode); } #endif basic_ofstream(const basic_ofstream&) = delete; const basic_ofstream& operator=(const basic_ofstream&) = delete; ~basic_ofstream() override {} }; template > class basic_fstream : public std::basic_fstream { public: basic_fstream() {} #if defined(GHC_OS_WINDOWS) && !defined(__GNUC__) explicit basic_fstream(const path& p, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) : std::basic_fstream(p.wstring().c_str(), mode) { } void open(const path& p, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) { std::basic_fstream::open(p.wstring().c_str(), mode); } #else explicit basic_fstream(const path& p, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) : std::basic_fstream(p.string().c_str(), mode) { } void open(const path& p, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) { std::basic_fstream::open(p.string().c_str(), mode); } #endif basic_fstream(const basic_fstream&) = delete; const basic_fstream& operator=(const basic_fstream&) = delete; ~basic_fstream() override {} }; typedef basic_filebuf filebuf; typedef basic_filebuf wfilebuf; typedef basic_ifstream ifstream; typedef basic_ifstream wifstream; typedef basic_ofstream ofstream; typedef basic_ofstream wofstream; typedef basic_fstream fstream; typedef basic_fstream wfstream; class GHC_FS_API_CLASS u8arguments { public: u8arguments(int& argc, char**& argv); ~u8arguments() { _refargc = _argc; _refargv = _argv; } bool valid() const { return _isvalid; } private: int _argc; char** _argv; int& _refargc; char**& _refargv; bool _isvalid; #ifdef GHC_OS_WINDOWS std::vector _args; std::vector _argp; #endif }; //------------------------------------------------------------------------------------------------- // Implementation //------------------------------------------------------------------------------------------------- namespace detail { // GHC_FS_API void postprocess_path_with_format(path::impl_string_type& p, path::format fmt); enum utf8_states_t { S_STRT = 0, S_RJCT = 8 }; GHC_FS_API void appendUTF8(std::string& str, uint32_t unicode); GHC_FS_API bool is_surrogate(uint32_t c); GHC_FS_API bool is_high_surrogate(uint32_t c); GHC_FS_API bool is_low_surrogate(uint32_t c); GHC_FS_API unsigned consumeUtf8Fragment(const unsigned state, const uint8_t fragment, uint32_t& codepoint); enum class portable_error { none = 0, exists, not_found, not_supported, not_implemented, invalid_argument, is_a_directory, }; GHC_FS_API std::error_code make_error_code(portable_error err); } // namespace detail namespace detail { #ifdef GHC_EXPAND_IMPL GHC_INLINE std::error_code make_error_code(portable_error err) { #ifdef GHC_OS_WINDOWS switch (err) { case portable_error::none: return std::error_code(); case portable_error::exists: return std::error_code(ERROR_ALREADY_EXISTS, std::system_category()); case portable_error::not_found: return std::error_code(ERROR_PATH_NOT_FOUND, std::system_category()); case portable_error::not_supported: return std::error_code(ERROR_NOT_SUPPORTED, std::system_category()); case portable_error::not_implemented: return std::error_code(ERROR_CALL_NOT_IMPLEMENTED, std::system_category()); case portable_error::invalid_argument: return std::error_code(ERROR_INVALID_PARAMETER, std::system_category()); case portable_error::is_a_directory: #ifdef ERROR_DIRECTORY_NOT_SUPPORTED return std::error_code(ERROR_DIRECTORY_NOT_SUPPORTED, std::system_category()); #else return std::error_code(ERROR_NOT_SUPPORTED, std::system_category()); #endif } #else switch (err) { case portable_error::none: return std::error_code(); case portable_error::exists: return std::error_code(EEXIST, std::system_category()); case portable_error::not_found: return std::error_code(ENOENT, std::system_category()); case portable_error::not_supported: return std::error_code(ENOTSUP, std::system_category()); case portable_error::not_implemented: return std::error_code(ENOSYS, std::system_category()); case portable_error::invalid_argument: return std::error_code(EINVAL, std::system_category()); case portable_error::is_a_directory: return std::error_code(EISDIR, std::system_category()); } #endif return std::error_code(); } #endif // GHC_EXPAND_IMPL template using EnableBitmask = typename std::enable_if::value || std::is_same::value || std::is_same::value || std::is_same::value, Enum>::type; } // namespace detail template detail::EnableBitmask operator&(Enum X, Enum Y) { using underlying = typename std::underlying_type::type; return static_cast(static_cast(X) & static_cast(Y)); } template detail::EnableBitmask operator|(Enum X, Enum Y) { using underlying = typename std::underlying_type::type; return static_cast(static_cast(X) | static_cast(Y)); } template detail::EnableBitmask operator^(Enum X, Enum Y) { using underlying = typename std::underlying_type::type; return static_cast(static_cast(X) ^ static_cast(Y)); } template detail::EnableBitmask operator~(Enum X) { using underlying = typename std::underlying_type::type; return static_cast(~static_cast(X)); } template detail::EnableBitmask& operator&=(Enum& X, Enum Y) { X = X & Y; return X; } template detail::EnableBitmask& operator|=(Enum& X, Enum Y) { X = X | Y; return X; } template detail::EnableBitmask& operator^=(Enum& X, Enum Y) { X = X ^ Y; return X; } #ifdef GHC_EXPAND_IMPL namespace detail { GHC_INLINE bool in_range(uint32_t c, uint32_t lo, uint32_t hi) { return ((uint32_t)(c - lo) < (hi - lo + 1)); } GHC_INLINE bool is_surrogate(uint32_t c) { return in_range(c, 0xd800, 0xdfff); } GHC_INLINE bool is_high_surrogate(uint32_t c) { return (c & 0xfffffc00) == 0xd800; } GHC_INLINE bool is_low_surrogate(uint32_t c) { return (c & 0xfffffc00) == 0xdc00; } GHC_INLINE void appendUTF8(std::string& str, uint32_t unicode) { if (unicode <= 0x7f) { str.push_back(static_cast(unicode)); } else if (unicode >= 0x80 && unicode <= 0x7ff) { str.push_back(static_cast((unicode >> 6) + 192)); str.push_back(static_cast((unicode & 0x3f) + 128)); } else if ((unicode >= 0x800 && unicode <= 0xd7ff) || (unicode >= 0xe000 && unicode <= 0xffff)) { str.push_back(static_cast((unicode >> 12) + 224)); str.push_back(static_cast(((unicode & 0xfff) >> 6) + 128)); str.push_back(static_cast((unicode & 0x3f) + 128)); } else if (unicode >= 0x10000 && unicode <= 0x10ffff) { str.push_back(static_cast((unicode >> 18) + 240)); str.push_back(static_cast(((unicode & 0x3ffff) >> 12) + 128)); str.push_back(static_cast(((unicode & 0xfff) >> 6) + 128)); str.push_back(static_cast((unicode & 0x3f) + 128)); } else { #ifdef GHC_RAISE_UNICODE_ERRORS throw filesystem_error("Illegal code point for unicode character.", str, std::make_error_code(std::errc::illegal_byte_sequence)); #else appendUTF8(str, 0xfffd); #endif } } // Thanks to Bjoern Hoehrmann (https://bjoern.hoehrmann.de/utf-8/decoder/dfa/) // and Taylor R Campbell for the ideas to this DFA approach of UTF-8 decoding; // Generating debugging and shrinking my own DFA from scratch was a day of fun! GHC_INLINE unsigned consumeUtf8Fragment(const unsigned state, const uint8_t fragment, uint32_t& codepoint) { static const uint32_t utf8_state_info[] = { // encoded states 0x11111111u, 0x11111111u, 0x77777777u, 0x77777777u, 0x88888888u, 0x88888888u, 0x88888888u, 0x88888888u, 0x22222299u, 0x22222222u, 0x22222222u, 0x22222222u, 0x3333333au, 0x33433333u, 0x9995666bu, 0x99999999u, 0x88888880u, 0x22818108u, 0x88888881u, 0x88888882u, 0x88888884u, 0x88888887u, 0x88888886u, 0x82218108u, 0x82281108u, 0x88888888u, 0x88888883u, 0x88888885u, 0u, 0u, 0u, 0u, }; uint8_t category = fragment < 128 ? 0 : (utf8_state_info[(fragment >> 3) & 0xf] >> ((fragment & 7) << 2)) & 0xf; codepoint = (state ? (codepoint << 6) | (fragment & 0x3f) : (0xff >> category) & fragment); return state == S_RJCT ? static_cast(S_RJCT) : static_cast((utf8_state_info[category + 16] >> (state << 2)) & 0xf); } GHC_INLINE bool validUtf8(const std::string& utf8String) { std::string::const_iterator iter = utf8String.begin(); unsigned utf8_state = S_STRT; std::uint32_t codepoint = 0; while (iter < utf8String.end()) { if ((utf8_state = consumeUtf8Fragment(utf8_state, (uint8_t)*iter++, codepoint)) == S_RJCT) { return false; } } if (utf8_state) { return false; } return true; } } // namespace detail #endif namespace detail { template ::type* = nullptr> inline StringType fromUtf8(const std::string& utf8String, const typename StringType::allocator_type& alloc = typename StringType::allocator_type()) { return StringType(utf8String.begin(), utf8String.end(), alloc); } template ::type* = nullptr> inline StringType fromUtf8(const std::string& utf8String, const typename StringType::allocator_type& alloc = typename StringType::allocator_type()) { StringType result(alloc); result.reserve(utf8String.length()); std::string::const_iterator iter = utf8String.begin(); unsigned utf8_state = S_STRT; std::uint32_t codepoint = 0; while (iter < utf8String.end()) { if ((utf8_state = consumeUtf8Fragment(utf8_state, (uint8_t)*iter++, codepoint)) == S_STRT) { if (codepoint <= 0xffff) { result += (typename StringType::value_type)codepoint; } else { codepoint -= 0x10000; result += (typename StringType::value_type)((codepoint >> 10) + 0xd800); result += (typename StringType::value_type)((codepoint & 0x3ff) + 0xdc00); } codepoint = 0; } else if (utf8_state == S_RJCT) { #ifdef GHC_RAISE_UNICODE_ERRORS throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence)); #else result += (typename StringType::value_type)0xfffd; utf8_state = S_STRT; codepoint = 0; #endif } } if (utf8_state) { #ifdef GHC_RAISE_UNICODE_ERRORS throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence)); #else result += (typename StringType::value_type)0xfffd; #endif } return result; } template ::type* = nullptr> inline StringType fromUtf8(const std::string& utf8String, const typename StringType::allocator_type& alloc = typename StringType::allocator_type()) { StringType result(alloc); result.reserve(utf8String.length()); std::string::const_iterator iter = utf8String.begin(); unsigned utf8_state = S_STRT; std::uint32_t codepoint = 0; while (iter < utf8String.end()) { if ((utf8_state = consumeUtf8Fragment(utf8_state, (uint8_t)*iter++, codepoint)) == S_STRT) { result += codepoint; codepoint = 0; } else if (utf8_state == S_RJCT) { #ifdef GHC_RAISE_UNICODE_ERRORS throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence)); #else result += (typename StringType::value_type)0xfffd; utf8_state = S_STRT; codepoint = 0; #endif } } if (utf8_state) { #ifdef GHC_RAISE_UNICODE_ERRORS throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence)); #else result += (typename StringType::value_type)0xfffd; #endif } return result; } template ::type size = 1> inline std::string toUtf8(const std::basic_string& unicodeString) { return std::string(unicodeString.begin(), unicodeString.end()); } template ::type size = 2> inline std::string toUtf8(const std::basic_string& unicodeString) { std::string result; for (auto iter = unicodeString.begin(); iter != unicodeString.end(); ++iter) { char32_t c = *iter; if (is_surrogate(c)) { ++iter; if (iter != unicodeString.end() && is_high_surrogate(c) && is_low_surrogate(*iter)) { appendUTF8(result, (char32_t(c) << 10) + *iter - 0x35fdc00); } else { #ifdef GHC_RAISE_UNICODE_ERRORS throw filesystem_error("Illegal code point for unicode character.", result, std::make_error_code(std::errc::illegal_byte_sequence)); #else appendUTF8(result, 0xfffd); if(iter == unicodeString.end()) { break; } #endif } } else { appendUTF8(result, c); } } return result; } template ::type size = 4> inline std::string toUtf8(const std::basic_string& unicodeString) { std::string result; for (auto c : unicodeString) { appendUTF8(result, c); } return result; } template inline std::string toUtf8(const charT* unicodeString) { return toUtf8(std::basic_string>(unicodeString)); } } // namespace detail #ifdef GHC_EXPAND_IMPL namespace detail { GHC_INLINE bool startsWith(const std::string& what, const std::string& with) { return with.length() <= what.length() && equal(with.begin(), with.end(), what.begin()); } } // namespace detail GHC_INLINE void path::postprocess_path_with_format(path::impl_string_type& p, path::format fmt) { #ifdef GHC_RAISE_UNICODE_ERRORS if(!detail::validUtf8(p)) { path t; t._path = p; throw filesystem_error("Illegal byte sequence for unicode character.", t, std::make_error_code(std::errc::illegal_byte_sequence)); } #endif switch (fmt) { #ifndef GHC_OS_WINDOWS case path::auto_format: case path::native_format: #endif case path::generic_format: // nothing to do break; #ifdef GHC_OS_WINDOWS case path::auto_format: case path::native_format: if (detail::startsWith(p, std::string("\\\\?\\"))) { // remove Windows long filename marker p.erase(0, 4); if (detail::startsWith(p, std::string("UNC\\"))) { p.erase(0, 2); p[0] = '\\'; } } for (auto& c : p) { if (c == '\\') { c = '/'; } } break; #endif } if (p.length() > 2 && p[0] == '/' && p[1] == '/' && p[2] != '/') { std::string::iterator new_end = std::unique(p.begin() + 2, p.end(), [](path::value_type lhs, path::value_type rhs) { return lhs == rhs && lhs == '/'; }); p.erase(new_end, p.end()); } else { std::string::iterator new_end = std::unique(p.begin(), p.end(), [](path::value_type lhs, path::value_type rhs) { return lhs == rhs && lhs == '/'; }); p.erase(new_end, p.end()); } } #endif // GHC_EXPAND_IMPL template inline path::path(const Source& source, format fmt) : _path(detail::toUtf8(source)) { postprocess_path_with_format(_path, fmt); } template <> inline path::path(const std::wstring& source, format fmt) { _path = detail::toUtf8(source); postprocess_path_with_format(_path, fmt); } template <> inline path::path(const std::u16string& source, format fmt) { _path = detail::toUtf8(source); postprocess_path_with_format(_path, fmt); } template <> inline path::path(const std::u32string& source, format fmt) { _path = detail::toUtf8(source); postprocess_path_with_format(_path, fmt); } template inline path u8path(const Source& source) { return path(source); } template inline path u8path(InputIterator first, InputIterator last) { return path(first, last); } template inline path::path(InputIterator first, InputIterator last, format fmt) : path(std::basic_string::value_type>(first, last), fmt) { // delegated } #ifdef GHC_EXPAND_IMPL namespace detail { GHC_INLINE bool equals_simple_insensitive(const char* str1, const char* str2) { #ifdef GHC_OS_WINDOWS #ifdef __GNUC__ while (::tolower((unsigned char)*str1) == ::tolower((unsigned char)*str2++)) { if (*str1++ == 0) return true; } return false; #else return 0 == ::_stricmp(str1, str2); #endif #else return 0 == ::strcasecmp(str1, str2); #endif } template GHC_INLINE std::string systemErrorText(ErrorNumber code = 0) { #if defined(GHC_OS_WINDOWS) LPVOID msgBuf; DWORD dw = code ? code : ::GetLastError(); FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&msgBuf, 0, NULL); std::string msg = toUtf8(std::wstring((LPWSTR)msgBuf)); LocalFree(msgBuf); return msg; #elif defined(GHC_OS_MACOS) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE)) || (defined(GHC_OS_ANDROID) && __ANDROID_API__ < 23) || defined(EMSCRIPTEN) char buffer[512]; int rc = strerror_r(code ? code : errno, buffer, sizeof(buffer)); return rc == 0 ? (const char*)buffer : "Error in strerror_r!"; #else char buffer[512]; char* msg = strerror_r(code ? code : errno, buffer, sizeof(buffer)); return msg ? msg : buffer; #endif } #ifdef GHC_OS_WINDOWS using CreateSymbolicLinkW_fp = BOOLEAN(WINAPI*)(LPCWSTR, LPCWSTR, DWORD); using CreateHardLinkW_fp = BOOLEAN(WINAPI*)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES); GHC_INLINE void create_symlink(const path& target_name, const path& new_symlink, bool to_directory, std::error_code& ec) { std::error_code tec; auto fs = status(target_name, tec); if ((fs.type() == file_type::directory && !to_directory) || (fs.type() == file_type::regular && to_directory)) { ec = detail::make_error_code(detail::portable_error::not_supported); return; } static CreateSymbolicLinkW_fp api_call = reinterpret_cast(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateSymbolicLinkW")); if (api_call) { if (api_call(detail::fromUtf8(new_symlink.u8string()).c_str(), detail::fromUtf8(target_name.u8string()).c_str(), to_directory ? 1 : 0) == 0) { auto result = ::GetLastError(); if (result == ERROR_PRIVILEGE_NOT_HELD && api_call(detail::fromUtf8(new_symlink.u8string()).c_str(), detail::fromUtf8(target_name.u8string()).c_str(), to_directory ? 3 : 2) != 0) { return; } ec = std::error_code(result, std::system_category()); } } else { ec = std::error_code(ERROR_NOT_SUPPORTED, std::system_category()); } } GHC_INLINE void create_hardlink(const path& target_name, const path& new_hardlink, std::error_code& ec) { static CreateHardLinkW_fp api_call = reinterpret_cast(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateHardLinkW")); if (api_call) { if (api_call(detail::fromUtf8(new_hardlink.u8string()).c_str(), detail::fromUtf8(target_name.u8string()).c_str(), NULL) == 0) { ec = std::error_code(::GetLastError(), std::system_category()); } } else { ec = std::error_code(ERROR_NOT_SUPPORTED, std::system_category()); } } #else GHC_INLINE void create_symlink(const path& target_name, const path& new_symlink, bool, std::error_code& ec) { if (::symlink(target_name.c_str(), new_symlink.c_str()) != 0) { ec = std::error_code(errno, std::system_category()); } } GHC_INLINE void create_hardlink(const path& target_name, const path& new_hardlink, std::error_code& ec) { if (::link(target_name.c_str(), new_hardlink.c_str()) != 0) { ec = std::error_code(errno, std::system_category()); } } #endif template GHC_INLINE file_status file_status_from_st_mode(T mode) { #ifdef GHC_OS_WINDOWS file_type ft = file_type::unknown; if ((mode & _S_IFDIR) == _S_IFDIR) { ft = file_type::directory; } else if ((mode & _S_IFREG) == _S_IFREG) { ft = file_type::regular; } else if ((mode & _S_IFCHR) == _S_IFCHR) { ft = file_type::character; } perms prms = static_cast(mode & 0xfff); return file_status(ft, prms); #else file_type ft = file_type::unknown; if (S_ISDIR(mode)) { ft = file_type::directory; } else if (S_ISREG(mode)) { ft = file_type::regular; } else if (S_ISCHR(mode)) { ft = file_type::character; } else if (S_ISBLK(mode)) { ft = file_type::block; } else if (S_ISFIFO(mode)) { ft = file_type::fifo; } else if (S_ISLNK(mode)) { ft = file_type::symlink; } else if (S_ISSOCK(mode)) { ft = file_type::socket; } perms prms = static_cast(mode & 0xfff); return file_status(ft, prms); #endif } GHC_INLINE path resolveSymlink(const path& p, std::error_code& ec) { #ifdef GHC_OS_WINDOWS #ifndef REPARSE_DATA_BUFFER_HEADER_SIZE typedef struct _REPARSE_DATA_BUFFER { ULONG ReparseTag; USHORT ReparseDataLength; USHORT Reserved; union { struct { USHORT SubstituteNameOffset; USHORT SubstituteNameLength; USHORT PrintNameOffset; USHORT PrintNameLength; ULONG Flags; WCHAR PathBuffer[1]; } SymbolicLinkReparseBuffer; struct { USHORT SubstituteNameOffset; USHORT SubstituteNameLength; USHORT PrintNameOffset; USHORT PrintNameLength; WCHAR PathBuffer[1]; } MountPointReparseBuffer; struct { UCHAR DataBuffer[1]; } GenericReparseBuffer; } DUMMYUNIONNAME; } REPARSE_DATA_BUFFER; #ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 * 1024) #endif #endif std::shared_ptr file(CreateFileW(p.wstring().c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, 0), CloseHandle); if (file.get() == INVALID_HANDLE_VALUE) { ec = std::error_code(::GetLastError(), std::system_category()); return path(); } std::shared_ptr reparseData((REPARSE_DATA_BUFFER*)std::calloc(1, MAXIMUM_REPARSE_DATA_BUFFER_SIZE), std::free); ULONG bufferUsed; path result; if (DeviceIoControl(file.get(), FSCTL_GET_REPARSE_POINT, 0, 0, reparseData.get(), MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &bufferUsed, 0)) { if (IsReparseTagMicrosoft(reparseData->ReparseTag)) { switch (reparseData->ReparseTag) { case IO_REPARSE_TAG_SYMLINK: result = std::wstring(&reparseData->SymbolicLinkReparseBuffer.PathBuffer[reparseData->SymbolicLinkReparseBuffer.PrintNameOffset / sizeof(WCHAR)], reparseData->SymbolicLinkReparseBuffer.PrintNameLength / sizeof(WCHAR)); break; case IO_REPARSE_TAG_MOUNT_POINT: result = std::wstring(&reparseData->MountPointReparseBuffer.PathBuffer[reparseData->MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR)], reparseData->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR)); break; default: break; } } } else { ec = std::error_code(::GetLastError(), std::system_category()); } return result; #else size_t bufferSize = 256; while (true) { std::vector buffer(bufferSize, (char)0); auto rc = ::readlink(p.c_str(), buffer.data(), buffer.size()); if (rc < 0) { ec = std::error_code(errno, std::system_category()); return path(); } else if (rc < static_cast(bufferSize)) { return path(std::string(buffer.data(), rc)); } bufferSize *= 2; } return path(); #endif } #ifdef GHC_OS_WINDOWS GHC_INLINE time_t timeFromFILETIME(const FILETIME& ft) { ULARGE_INTEGER ull; ull.LowPart = ft.dwLowDateTime; ull.HighPart = ft.dwHighDateTime; return ull.QuadPart / 10000000ULL - 11644473600ULL; } GHC_INLINE void timeToFILETIME(time_t t, FILETIME& ft) { LONGLONG ll; ll = Int32x32To64(t, 10000000) + 116444736000000000; ft.dwLowDateTime = (DWORD)ll; ft.dwHighDateTime = ll >> 32; } template GHC_INLINE uintmax_t hard_links_from_INFO(const INFO* info) { return static_cast(-1); } template <> GHC_INLINE uintmax_t hard_links_from_INFO(const BY_HANDLE_FILE_INFORMATION* info) { return info->nNumberOfLinks; } template GHC_INLINE file_status status_from_INFO(const path& p, const INFO* info, std::error_code& ec, uintmax_t* sz = nullptr, time_t* lwt = nullptr) noexcept { file_type ft = file_type::unknown; if ((info->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) { ft = file_type::symlink; } else { if ((info->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { ft = file_type::directory; } else { ft = file_type::regular; } } perms prms = perms::owner_read | perms::group_read | perms::others_read; if (!(info->dwFileAttributes & FILE_ATTRIBUTE_READONLY)) { prms = prms | perms::owner_write | perms::group_write | perms::others_write; } std::string ext = p.extension().generic_string(); if (equals_simple_insensitive(ext.c_str(), ".exe") || equals_simple_insensitive(ext.c_str(), ".cmd") || equals_simple_insensitive(ext.c_str(), ".bat") || equals_simple_insensitive(ext.c_str(), ".com")) { prms = prms | perms::owner_exec | perms::group_exec | perms::others_exec; } if (sz) { *sz = static_cast(info->nFileSizeHigh) << (sizeof(info->nFileSizeHigh) * 8) | info->nFileSizeLow; } if (lwt) { *lwt = detail::timeFromFILETIME(info->ftLastWriteTime); } return file_status(ft, prms); } #endif GHC_INLINE bool is_not_found_error(std::error_code& ec) { #ifdef GHC_OS_WINDOWS return ec.value() == ERROR_FILE_NOT_FOUND || ec.value() == ERROR_PATH_NOT_FOUND || ec.value() == ERROR_INVALID_NAME; #else return ec.value() == ENOENT || ec.value() == ENOTDIR; #endif } GHC_INLINE file_status symlink_status_ex(const path& p, std::error_code& ec, uintmax_t* sz = nullptr, uintmax_t* nhl = nullptr, time_t* lwt = nullptr) noexcept { #ifdef GHC_OS_WINDOWS file_status fs; WIN32_FILE_ATTRIBUTE_DATA attr; if (!GetFileAttributesExW(detail::fromUtf8(p.u8string()).c_str(), GetFileExInfoStandard, &attr)) { ec = std::error_code(::GetLastError(), std::system_category()); } else { ec.clear(); fs = detail::status_from_INFO(p, &attr, ec, sz, lwt); if (nhl) { *nhl = 0; } if (attr.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { fs.type(file_type::symlink); } } if (detail::is_not_found_error(ec)) { return file_status(file_type::not_found); } return ec ? file_status(file_type::none) : fs; #else (void)sz; (void)nhl; (void)lwt; struct ::stat fs; auto result = ::lstat(p.c_str(), &fs); if (result == 0) { ec.clear(); file_status f_s = detail::file_status_from_st_mode(fs.st_mode); return f_s; } ec = std::error_code(errno, std::system_category()); if (detail::is_not_found_error(ec)) { return file_status(file_type::not_found, perms::unknown); } return file_status(file_type::none); #endif } GHC_INLINE file_status status_ex(const path& p, std::error_code& ec, file_status* sls = nullptr, uintmax_t* sz = nullptr, uintmax_t* nhl = nullptr, time_t* lwt = nullptr, int recurse_count = 0) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS if (recurse_count > 16) { ec = std::error_code(0x2A9 /*ERROR_STOPPED_ON_SYMLINK*/, std::system_category()); return file_status(file_type::unknown); } WIN32_FILE_ATTRIBUTE_DATA attr; if (!::GetFileAttributesExW(p.wstring().c_str(), GetFileExInfoStandard, &attr)) { ec = std::error_code(::GetLastError(), std::system_category()); } else if (attr.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { path target = resolveSymlink(p, ec); file_status result; if (!ec && !target.empty()) { if (sls) { *sls = status_from_INFO(p, &attr, ec); } return detail::status_ex(target, ec, nullptr, sz, nhl, lwt, recurse_count + 1); } return file_status(file_type::unknown); } if (ec) { if (detail::is_not_found_error(ec)) { return file_status(file_type::not_found); } return file_status(file_type::none); } if (nhl) { *nhl = 0; } return detail::status_from_INFO(p, &attr, ec, sz, lwt); #else (void)recurse_count; struct ::stat st; auto result = ::lstat(p.c_str(), &st); if (result == 0) { ec.clear(); file_status fs = detail::file_status_from_st_mode(st.st_mode); if (fs.type() == file_type::symlink) { result = ::stat(p.c_str(), &st); if (result == 0) { if (sls) { *sls = fs; } fs = detail::file_status_from_st_mode(st.st_mode); } } if (sz) { *sz = st.st_size; } if (nhl) { *nhl = st.st_nlink; } if (lwt) { *lwt = st.st_mtime; } return fs; } else { ec = std::error_code(errno, std::system_category()); if (detail::is_not_found_error(ec)) { return file_status(file_type::not_found, perms::unknown); } return file_status(file_type::none); } #endif } } // namespace detail GHC_INLINE u8arguments::u8arguments(int& argc, char**& argv) : _argc(argc) , _argv(argv) , _refargc(argc) , _refargv(argv) , _isvalid(false) { #ifdef GHC_OS_WINDOWS LPWSTR* p; p = ::CommandLineToArgvW(::GetCommandLineW(), &argc); _args.reserve(argc); _argp.reserve(argc); for (size_t i = 0; i < static_cast(argc); ++i) { _args.push_back(detail::toUtf8(std::wstring(p[i]))); _argp.push_back((char*)_args[i].data()); } argv = _argp.data(); ::LocalFree(p); _isvalid = true; #else std::setlocale(LC_ALL, ""); #if defined(__ANDROID__) && __ANDROID_API__ < 26 _isvalid = true; #else if (detail::equals_simple_insensitive(::nl_langinfo(CODESET), "UTF-8")) { _isvalid = true; } #endif #endif } //----------------------------------------------------------------------------- // 30.10.8.4.1 constructors and destructor GHC_INLINE path::path() noexcept {} GHC_INLINE path::path(const path& p) : _path(p._path) { } GHC_INLINE path::path(path&& p) noexcept : _path(std::move(p._path)) { } GHC_INLINE path::path(string_type&& source, format fmt) #ifdef GHC_USE_WCHAR_T : _path(detail::toUtf8(source)) #else : _path(std::move(source)) #endif { postprocess_path_with_format(_path, fmt); } #endif // GHC_EXPAND_IMPL template inline path::path(const Source& source, const std::locale& loc, format fmt) : path(source, fmt) { std::string locName = loc.name(); if (!(locName.length() >= 5 && (locName.substr(locName.length() - 5) == "UTF-8" || locName.substr(locName.length() - 5) == "utf-8"))) { throw filesystem_error("This implementation only supports UTF-8 locales!", path(_path), detail::make_error_code(detail::portable_error::not_supported)); } } template inline path::path(InputIterator first, InputIterator last, const std::locale& loc, format fmt) : path(std::basic_string::value_type>(first, last), fmt) { std::string locName = loc.name(); if (!(locName.length() >= 5 && (locName.substr(locName.length() - 5) == "UTF-8" || locName.substr(locName.length() - 5) == "utf-8"))) { throw filesystem_error("This implementation only supports UTF-8 locales!", path(_path), detail::make_error_code(detail::portable_error::not_supported)); } } #ifdef GHC_EXPAND_IMPL GHC_INLINE path::~path() {} //----------------------------------------------------------------------------- // 30.10.8.4.2 assignments GHC_INLINE path& path::operator=(const path& p) { _path = p._path; return *this; } GHC_INLINE path& path::operator=(path&& p) noexcept { _path = std::move(p._path); return *this; } GHC_INLINE path& path::operator=(path::string_type&& source) { return assign(source); } GHC_INLINE path& path::assign(path::string_type&& source) { #ifdef GHC_USE_WCHAR_T _path = detail::toUtf8(source); #else _path = std::move(source); #endif postprocess_path_with_format(_path, native_format); return *this; } #endif // GHC_EXPAND_IMPL template inline path& path::operator=(const Source& source) { return assign(source); } template inline path& path::assign(const Source& source) { _path.assign(detail::toUtf8(source)); postprocess_path_with_format(_path, native_format); return *this; } template <> inline path& path::assign(const path& source) { _path = source._path; return *this; } template inline path& path::assign(InputIterator first, InputIterator last) { _path.assign(first, last); postprocess_path_with_format(_path, native_format); return *this; } #ifdef GHC_EXPAND_IMPL //----------------------------------------------------------------------------- // 30.10.8.4.3 appends GHC_INLINE path& path::operator/=(const path& p) { if (p.empty()) { // was: if ((!has_root_directory() && is_absolute()) || has_filename()) if (!_path.empty() && _path[_path.length() - 1] != '/' && _path[_path.length() - 1] != ':') { _path += '/'; } return *this; } if ((p.is_absolute() && (_path != root_name() || p._path != "/")) || (p.has_root_name() && p.root_name() != root_name())) { assign(p); return *this; } if (p.has_root_directory()) { assign(root_name()); } else if ((!has_root_directory() && is_absolute()) || has_filename()) { _path += '/'; } auto iter = p.begin(); bool first = true; if (p.has_root_name()) { ++iter; } while (iter != p.end()) { if (!first && !(!_path.empty() && _path[_path.length() - 1] == '/')) { _path += '/'; } first = false; _path += (*iter++).generic_string(); } return *this; } GHC_INLINE void path::append_name(const char* name) { if (_path.empty()) { this->operator/=(path(name)); } else { if (_path.back() != path::generic_separator) { _path.push_back(path::generic_separator); } _path += name; } } #endif // GHC_EXPAND_IMPL template inline path& path::operator/=(const Source& source) { return append(source); } template inline path& path::append(const Source& source) { return this->operator/=(path(detail::toUtf8(source))); } template <> inline path& path::append(const path& p) { return this->operator/=(p); } template inline path& path::append(InputIterator first, InputIterator last) { std::basic_string::value_type> part(first, last); return append(part); } #ifdef GHC_EXPAND_IMPL //----------------------------------------------------------------------------- // 30.10.8.4.4 concatenation GHC_INLINE path& path::operator+=(const path& x) { return concat(x._path); } GHC_INLINE path& path::operator+=(const string_type& x) { return concat(x); } #ifdef __cpp_lib_string_view // GHC_INLINE path& path::operator+=(std::basic_string_view x) // { // return concat(x); // } #endif GHC_INLINE path& path::operator+=(const value_type* x) { return concat(string_type(x)); } GHC_INLINE path& path::operator+=(value_type x) { #ifdef GHC_OS_WINDOWS if (x == '\\') { x = generic_separator; } #endif if (_path.empty() || _path.back() != generic_separator) { #ifdef GHC_USE_WCHAR_T _path += detail::toUtf8(string_type(1, x)); #else _path += x; #endif } return *this; } #endif // GHC_EXPAND_IMPL template inline path::path_from_string& path::operator+=(const Source& x) { return concat(x); } template inline path::path_type_EcharT& path::operator+=(EcharT x) { std::basic_string part(1, x); concat(detail::toUtf8(part)); return *this; } template inline path& path::concat(const Source& x) { path p(x); postprocess_path_with_format(p._path, native_format); _path += p._path; return *this; } template inline path& path::concat(InputIterator first, InputIterator last) { _path.append(first, last); postprocess_path_with_format(_path, native_format); return *this; } #ifdef GHC_EXPAND_IMPL //----------------------------------------------------------------------------- // 30.10.8.4.5 modifiers GHC_INLINE void path::clear() noexcept { _path.clear(); } GHC_INLINE path& path::make_preferred() { // as this filesystem implementation only uses generic_format // internally, this must be a no-op return *this; } GHC_INLINE path& path::remove_filename() { if (has_filename()) { _path.erase(_path.size() - filename()._path.size()); } return *this; } GHC_INLINE path& path::replace_filename(const path& replacement) { remove_filename(); return append(replacement); } GHC_INLINE path& path::replace_extension(const path& replacement) { if (has_extension()) { _path.erase(_path.size() - extension()._path.size()); } if (!replacement.empty() && replacement._path[0] != '.') { _path += '.'; } return concat(replacement); } GHC_INLINE void path::swap(path& rhs) noexcept { _path.swap(rhs._path); } //----------------------------------------------------------------------------- // 30.10.8.4.6, native format observers #ifdef GHC_OS_WINDOWS GHC_INLINE path::impl_string_type path::native_impl() const { impl_string_type result; if (is_absolute() && _path.length() > MAX_PATH - 10) { // expand long Windows filenames with marker if (has_root_name() && _path[0] == '/') { result = "\\\\?\\UNC" + _path.substr(1); } else { result = "\\\\?\\" + _path; } } else { result = _path; } /*if (has_root_name() && root_name()._path[0] == '/') { return _path; }*/ for (auto& c : result) { if (c == '/') { c = '\\'; } } return result; } #else GHC_INLINE const path::impl_string_type& path::native_impl() const { return _path; } #endif GHC_INLINE const path::string_type& path::native() const { #ifdef GHC_OS_WINDOWS #ifdef GHC_USE_WCHAR_T _native_cache = detail::fromUtf8(native_impl()); #else _native_cache = native_impl(); #endif return _native_cache; #else return _path; #endif } GHC_INLINE const path::value_type* path::c_str() const { return native().c_str(); } GHC_INLINE path::operator path::string_type() const { return native(); } #endif // GHC_EXPAND_IMPL template inline std::basic_string path::string(const Allocator& a) const { return detail::fromUtf8>(native_impl(), a); } #ifdef GHC_EXPAND_IMPL GHC_INLINE std::string path::string() const { return native_impl(); } GHC_INLINE std::wstring path::wstring() const { #ifdef GHC_USE_WCHAR_T return native(); #else return detail::fromUtf8(native()); #endif } GHC_INLINE std::string path::u8string() const { return native_impl(); } GHC_INLINE std::u16string path::u16string() const { return detail::fromUtf8(native_impl()); } GHC_INLINE std::u32string path::u32string() const { return detail::fromUtf8(native_impl()); } #endif // GHC_EXPAND_IMPL //----------------------------------------------------------------------------- // 30.10.8.4.7, generic format observers template inline std::basic_string path::generic_string(const Allocator& a) const { return detail::fromUtf8>(_path, a); } #ifdef GHC_EXPAND_IMPL GHC_INLINE const std::string& path::generic_string() const { return _path; } GHC_INLINE std::wstring path::generic_wstring() const { return detail::fromUtf8(_path); } GHC_INLINE std::string path::generic_u8string() const { return _path; } GHC_INLINE std::u16string path::generic_u16string() const { return detail::fromUtf8(_path); } GHC_INLINE std::u32string path::generic_u32string() const { return detail::fromUtf8(_path); } //----------------------------------------------------------------------------- // 30.10.8.4.8, compare GHC_INLINE int path::compare(const path& p) const noexcept { return native().compare(p.native()); } GHC_INLINE int path::compare(const string_type& s) const { return native().compare(path(s).native()); } #ifdef __cpp_lib_string_view // GHC_INLINE int path::compare(std::basic_string_view s) const // { // return native().compare(path(s).native()); // } #endif GHC_INLINE int path::compare(const value_type* s) const { return native().compare(path(s).native()); } //----------------------------------------------------------------------------- // 30.10.8.4.9, decomposition GHC_INLINE path path::root_name() const { #ifdef GHC_OS_WINDOWS if (_path.length() >= 2 && std::toupper(static_cast(_path[0])) >= 'A' && std::toupper(static_cast(_path[0])) <= 'Z' && _path[1] == ':') { return path(_path.substr(0, 2)); } #endif if (_path.length() > 2 && _path[0] == '/' && _path[1] == '/' && _path[2] != '/' && std::isprint(_path[2])) { impl_string_type::size_type pos = _path.find_first_of("/\\", 3); if (pos == impl_string_type::npos) { return path(_path); } else { return path(_path.substr(0, pos)); } } return path(); } GHC_INLINE path path::root_directory() const { path root = root_name(); if (_path.length() > root._path.length() && _path[root._path.length()] == '/') { return path("/"); } return path(); } GHC_INLINE path path::root_path() const { return root_name().generic_string() + root_directory().generic_string(); } GHC_INLINE path path::relative_path() const { std::string root = root_path()._path; return path(_path.substr((std::min)(root.length(), _path.length())), generic_format); } GHC_INLINE path path::parent_path() const { if (has_relative_path()) { if (empty() || begin() == --end()) { return path(); } else { path pp; for (const string_type s : input_iterator_range(begin(), --end())) { if (s == "/") { // don't use append to join a path- pp += s; } else { pp /= s; } } return pp; } } else { return *this; } } GHC_INLINE path path::filename() const { return relative_path().empty() ? path() : path(*--end()); } GHC_INLINE path path::stem() const { impl_string_type fn = filename().string(); if (fn != "." && fn != "..") { impl_string_type::size_type n = fn.rfind("."); if (n != impl_string_type::npos && n != 0) { return fn.substr(0, n); } } return fn; } GHC_INLINE path path::extension() const { impl_string_type fn = filename().string(); impl_string_type::size_type pos = fn.find_last_of('.'); if (pos == std::string::npos || pos == 0) { return ""; } return fn.substr(pos); } //----------------------------------------------------------------------------- // 30.10.8.4.10, query GHC_INLINE bool path::empty() const noexcept { return _path.empty(); } GHC_INLINE bool path::has_root_name() const { return !root_name().empty(); } GHC_INLINE bool path::has_root_directory() const { return !root_directory().empty(); } GHC_INLINE bool path::has_root_path() const { return !root_path().empty(); } GHC_INLINE bool path::has_relative_path() const { return !relative_path().empty(); } GHC_INLINE bool path::has_parent_path() const { return !parent_path().empty(); } GHC_INLINE bool path::has_filename() const { return !filename().empty(); } GHC_INLINE bool path::has_stem() const { return !stem().empty(); } GHC_INLINE bool path::has_extension() const { return !extension().empty(); } GHC_INLINE bool path::is_absolute() const { #ifdef GHC_OS_WINDOWS return has_root_name() && has_root_directory(); #else return has_root_directory(); #endif } GHC_INLINE bool path::is_relative() const { return !is_absolute(); } //----------------------------------------------------------------------------- // 30.10.8.4.11, generation GHC_INLINE path path::lexically_normal() const { path dest; for (const string_type s : *this) { if (s == ".") { dest /= ""; continue; } else if (s == ".." && !dest.empty()) { auto root = root_path(); if (dest == root) { continue; } else if (*(--dest.end()) != "..") { if (dest._path.back() == generic_separator) { dest._path.pop_back(); } dest.remove_filename(); continue; } } dest /= s; } if (dest.empty()) { dest = "."; } return dest; } GHC_INLINE path path::lexically_relative(const path& base) const { if (root_name() != base.root_name() || is_absolute() != base.is_absolute() || (!has_root_directory() && base.has_root_directory())) { return path(); } const_iterator a = begin(), b = base.begin(); while (a != end() && b != base.end() && *a == *b) { ++a; ++b; } if (a == end() && b == base.end()) { return path("."); } int count = 0; for (const auto& element : input_iterator_range(b, base.end())) { if (element != "." && element != "..") { ++count; } else if (element == "..") { --count; } } if (count < 0) { return path(); } path result; for (int i = 0; i < count; ++i) { result /= ".."; } for (const auto& element : input_iterator_range(a, end())) { result /= element; } return result; } GHC_INLINE path path::lexically_proximate(const path& base) const { path result = lexically_relative(base); return result.empty() ? *this : result; } //----------------------------------------------------------------------------- // 30.10.8.5, iterators GHC_INLINE path::iterator::iterator() {} GHC_INLINE path::iterator::iterator(const path::impl_string_type::const_iterator& first, const path::impl_string_type::const_iterator& last, const path::impl_string_type::const_iterator& pos) : _first(first) , _last(last) , _iter(pos) { updateCurrent(); // find the position of a potential root directory slash #ifdef GHC_OS_WINDOWS if (_last - _first >= 3 && std::toupper(static_cast(*first)) >= 'A' && std::toupper(static_cast(*first)) <= 'Z' && *(first + 1) == ':' && *(first + 2) == '/') { _root = _first + 2; } else #endif { if (_first != _last && *_first == '/') { if (_last - _first >= 2 && *(_first + 1) == '/' && !(_last - _first >= 3 && *(_first + 2) == '/')) { _root = increment(_first); } else { _root = _first; } } else { _root = _last; } } } GHC_INLINE path::impl_string_type::const_iterator path::iterator::increment(const path::impl_string_type::const_iterator& pos) const { path::impl_string_type::const_iterator i = pos; bool fromStart = i == _first; if (i != _last) { // we can only sit on a slash if it is a network name or a root if (*i++ == '/') { if (i != _last && *i == '/') { if (fromStart && !(i + 1 != _last && *(i + 1) == '/')) { // leadind double slashes detected, treat this and the // following until a slash as one unit i = std::find(++i, _last, '/'); } else { // skip redundant slashes while (i != _last && *i == '/') { ++i; } } } } else { if (fromStart && i != _last && *i == ':') { ++i; } else { i = std::find(i, _last, '/'); } } } return i; } GHC_INLINE path::impl_string_type::const_iterator path::iterator::decrement(const path::impl_string_type::const_iterator& pos) const { path::impl_string_type::const_iterator i = pos; if (i != _first) { --i; // if this is now the root slash or the trailing slash, we are done, // else check for network name if (i != _root && (pos != _last || *i != '/')) { #ifdef GHC_OS_WINDOWS static const std::string seps = "/:"; i = std::find_first_of(std::reverse_iterator(i), std::reverse_iterator(_first), seps.begin(), seps.end()).base(); if (i > _first && *i == ':') { i++; } #else i = std::find(std::reverse_iterator(i), std::reverse_iterator(_first), '/').base(); #endif // Now we have to check if this is a network name if (i - _first == 2 && *_first == '/' && *(_first + 1) == '/') { i -= 2; } } } return i; } GHC_INLINE void path::iterator::updateCurrent() { if (_iter != _first && _iter != _last && (*_iter == '/' && _iter != _root) && (_iter + 1 == _last)) { _current = ""; } else { _current.assign(_iter, increment(_iter)); if (_current.generic_string().size() > 1 && _current.generic_string()[0] == '/' && _current.generic_string()[_current.generic_string().size() - 1] == '/') { // shrink successive slashes to one _current = "/"; } } } GHC_INLINE path::iterator& path::iterator::operator++() { _iter = increment(_iter); while (_iter != _last && // we didn't reach the end _iter != _root && // this is not a root position *_iter == '/' && // we are on a slash (_iter + 1) != _last // the slash is not the last char ) { ++_iter; } updateCurrent(); return *this; } GHC_INLINE path::iterator path::iterator::operator++(int) { path::iterator i{*this}; ++(*this); return i; } GHC_INLINE path::iterator& path::iterator::operator--() { _iter = decrement(_iter); updateCurrent(); return *this; } GHC_INLINE path::iterator path::iterator::operator--(int) { auto i = *this; --(*this); return i; } GHC_INLINE bool path::iterator::operator==(const path::iterator& other) const { return _iter == other._iter; } GHC_INLINE bool path::iterator::operator!=(const path::iterator& other) const { return _iter != other._iter; } GHC_INLINE path::iterator::reference path::iterator::operator*() const { return _current; } GHC_INLINE path::iterator::pointer path::iterator::operator->() const { return &_current; } GHC_INLINE path::iterator path::begin() const { return iterator(_path.begin(), _path.end(), _path.begin()); } GHC_INLINE path::iterator path::end() const { return iterator(_path.begin(), _path.end(), _path.end()); } //----------------------------------------------------------------------------- // 30.10.8.6, path non-member functions GHC_INLINE void swap(path& lhs, path& rhs) noexcept { swap(lhs._path, rhs._path); } GHC_INLINE size_t hash_value(const path& p) noexcept { return std::hash()(p.generic_string()); } GHC_INLINE bool operator==(const path& lhs, const path& rhs) noexcept { return lhs.generic_string() == rhs.generic_string(); } GHC_INLINE bool operator!=(const path& lhs, const path& rhs) noexcept { return lhs.generic_string() != rhs.generic_string(); } GHC_INLINE bool operator<(const path& lhs, const path& rhs) noexcept { return lhs.generic_string() < rhs.generic_string(); } GHC_INLINE bool operator<=(const path& lhs, const path& rhs) noexcept { return lhs.generic_string() <= rhs.generic_string(); } GHC_INLINE bool operator>(const path& lhs, const path& rhs) noexcept { return lhs.generic_string() > rhs.generic_string(); } GHC_INLINE bool operator>=(const path& lhs, const path& rhs) noexcept { return lhs.generic_string() >= rhs.generic_string(); } GHC_INLINE path operator/(const path& lhs, const path& rhs) { path result(lhs); result /= rhs; return result; } #endif // GHC_EXPAND_IMPL //----------------------------------------------------------------------------- // 30.10.8.6.1 path inserter and extractor template inline std::basic_ostream& operator<<(std::basic_ostream& os, const path& p) { os << "\""; auto ps = p.string(); for (auto c : ps) { if (c == '"' || c == '\\') { os << '\\'; } os << c; } os << "\""; return os; } template inline std::basic_istream& operator>>(std::basic_istream& is, path& p) { std::basic_string tmp; auto c = is.get(); if (c == '"') { auto sf = is.flags(); is >> std::noskipws; while (is) { c = is.get(); if (is) { if (c == '\\') { c = is.get(); if (is) { tmp += static_cast(c); } } else if (c == '"') { break; } else { tmp += static_cast(c); } } } if ((sf & std::ios_base::skipws) == std::ios_base::skipws) { is >> std::skipws; } p = path(tmp); } else { is >> tmp; p = path(static_cast(c) + tmp); } return is; } #ifdef GHC_EXPAND_IMPL //----------------------------------------------------------------------------- // 30.10.9 Class filesystem_error GHC_INLINE filesystem_error::filesystem_error(const std::string& what_arg, std::error_code ec) : std::system_error(ec, what_arg) , _what_arg(what_arg) , _ec(ec) { } GHC_INLINE filesystem_error::filesystem_error(const std::string& what_arg, const path& p1, std::error_code ec) : std::system_error(ec, what_arg) , _what_arg(what_arg) , _ec(ec) , _p1(p1) { if (!_p1.empty()) { _what_arg += ": '" + _p1.u8string() + "'"; } } GHC_INLINE filesystem_error::filesystem_error(const std::string& what_arg, const path& p1, const path& p2, std::error_code ec) : std::system_error(ec, what_arg) , _what_arg(what_arg) , _ec(ec) , _p1(p1) , _p2(p2) { if (!_p1.empty()) { _what_arg += ": '" + _p1.u8string() + "'"; } if (!_p2.empty()) { _what_arg += ", '" + _p2.u8string() + "'"; } } GHC_INLINE const path& filesystem_error::path1() const noexcept { return _p1; } GHC_INLINE const path& filesystem_error::path2() const noexcept { return _p2; } GHC_INLINE const char* filesystem_error::what() const noexcept { return _what_arg.c_str(); } //----------------------------------------------------------------------------- // 30.10.15, filesystem operations GHC_INLINE path absolute(const path& p) { std::error_code ec; path result = absolute(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } GHC_INLINE path absolute(const path& p, std::error_code& ec) { ec.clear(); #ifdef GHC_OS_WINDOWS if (p.empty()) { return absolute(current_path(ec), ec) / ""; } ULONG size = ::GetFullPathNameW(p.wstring().c_str(), 0, 0, 0); if (size) { std::vector buf(size, 0); ULONG s2 = GetFullPathNameW(p.wstring().c_str(), size, buf.data(), nullptr); if (s2 && s2 < size) { path result = path(std::wstring(buf.data(), s2)); if (p.filename() == ".") { result /= "."; } return result; } } ec = std::error_code(::GetLastError(), std::system_category()); return path(); #else path base = current_path(ec); if (!ec) { if (p.empty()) { return base / p; } if (p.has_root_name()) { if (p.has_root_directory()) { return p; } else { return p.root_name() / base.root_directory() / base.relative_path() / p.relative_path(); } } else { if (p.has_root_directory()) { return base.root_name() / p; } else { return base / p; } } } ec = std::error_code(errno, std::system_category()); return path(); #endif } GHC_INLINE path canonical(const path& p) { std::error_code ec; auto result = canonical(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } GHC_INLINE path canonical(const path& p, std::error_code& ec) { if (p.empty()) { ec = detail::make_error_code(detail::portable_error::not_found); return path(); } path work = p.is_absolute() ? p : absolute(p, ec); path root = work.root_path(); path result; auto fs = status(work, ec); if (ec) { return path(); } if (fs.type() == file_type::not_found) { ec = detail::make_error_code(detail::portable_error::not_found); return path(); } bool redo; do { redo = false; result.clear(); for (auto pe : work) { if (pe.empty() || pe == ".") { continue; } else if (pe == "..") { result = result.parent_path(); continue; } else if ((result / pe).string().length() <= root.string().length()) { result /= pe; continue; } auto sls = symlink_status(result / pe, ec); if (ec) { return path(); } if (is_symlink(sls)) { redo = true; auto target = read_symlink(result / pe, ec); if (ec) { return path(); } if (target.is_absolute()) { result = target; continue; } else { result /= target; continue; } } else { result /= pe; } } work = result; } while (redo); ec.clear(); return result; } GHC_INLINE void copy(const path& from, const path& to) { copy(from, to, copy_options::none); } GHC_INLINE void copy(const path& from, const path& to, std::error_code& ec) noexcept { copy(from, to, copy_options::none, ec); } GHC_INLINE void copy(const path& from, const path& to, copy_options options) { std::error_code ec; copy(from, to, options, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), from, to, ec); } } GHC_INLINE void copy(const path& from, const path& to, copy_options options, std::error_code& ec) noexcept { std::error_code tec; file_status fs_from, fs_to; ec.clear(); if ((options & (copy_options::skip_symlinks | copy_options::copy_symlinks | copy_options::create_symlinks)) != copy_options::none) { fs_from = symlink_status(from, ec); } else { fs_from = status(from, ec); } if (!exists(fs_from)) { if (!ec) { ec = detail::make_error_code(detail::portable_error::not_found); } return; } if ((options & (copy_options::skip_symlinks | copy_options::create_symlinks)) != copy_options::none) { fs_to = symlink_status(to, tec); } else { fs_to = status(to, tec); } if (is_other(fs_from) || is_other(fs_to) || (is_directory(fs_from) && is_regular_file(fs_to)) || (exists(fs_to) && equivalent(from, to, ec))) { ec = detail::make_error_code(detail::portable_error::invalid_argument); } else if (is_symlink(fs_from)) { if ((options & copy_options::skip_symlinks) == copy_options::none) { if (!exists(fs_to) && (options & copy_options::copy_symlinks) != copy_options::none) { copy_symlink(from, to, ec); } else { ec = detail::make_error_code(detail::portable_error::invalid_argument); } } } else if (is_regular_file(fs_from)) { if ((options & copy_options::directories_only) == copy_options::none) { if ((options & copy_options::create_symlinks) != copy_options::none) { create_symlink(from.is_absolute() ? from : canonical(from, ec), to, ec); } else if ((options & copy_options::create_hard_links) != copy_options::none) { create_hard_link(from, to, ec); } else if (is_directory(fs_to)) { copy_file(from, to / from.filename(), options, ec); } else { copy_file(from, to, ec); } } } #ifdef LWG_2682_BEHAVIOUR else if (is_directory(fs_from) && (options & copy_options::create_symlinks) != copy_options::none) { ec = detail::make_error_code(detail::portable_error::is_a_directory); } #endif else if (is_directory(fs_from) && (options == copy_options::none || (options & copy_options::recursive) != copy_options::none)) { if (!exists(fs_to)) { create_directory(to, from, ec); if (ec) { return; } } for (auto iter = directory_iterator(from, ec); iter != directory_iterator(); iter.increment(ec)) { if (!ec) { copy(iter->path(), to / iter->path().filename(), options | static_cast(0x8000), ec); } if (ec) { return; } } } return; } GHC_INLINE bool copy_file(const path& from, const path& to) { return copy_file(from, to, copy_options::none); } GHC_INLINE bool copy_file(const path& from, const path& to, std::error_code& ec) noexcept { return copy_file(from, to, copy_options::none, ec); } GHC_INLINE bool copy_file(const path& from, const path& to, copy_options option) { std::error_code ec; auto result = copy_file(from, to, option, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), from, to, ec); } return result; } GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options, std::error_code& ec) noexcept { std::error_code tecf, tect; auto sf = status(from, tecf); auto st = status(to, tect); bool overwrite = false; ec.clear(); if (!is_regular_file(sf)) { ec = tecf; return false; } if (exists(st) && (!is_regular_file(st) || equivalent(from, to, ec) || (options & (copy_options::skip_existing | copy_options::overwrite_existing | copy_options::update_existing)) == copy_options::none)) { ec = tect ? tect : detail::make_error_code(detail::portable_error::exists); return false; } if (exists(st)) { if ((options & copy_options::update_existing) == copy_options::update_existing) { auto from_time = last_write_time(from, ec); if (ec) { ec = std::error_code(errno, std::system_category()); return false; } auto to_time = last_write_time(to, ec); if (ec) { ec = std::error_code(errno, std::system_category()); return false; } if (from_time <= to_time) { return false; } } overwrite = true; } #ifdef GHC_OS_WINDOWS if (!::CopyFileW(detail::fromUtf8(from.u8string()).c_str(), detail::fromUtf8(to.u8string()).c_str(), !overwrite)) { ec = std::error_code(::GetLastError(), std::system_category()); return false; } return true; #else std::vector buffer(16384, '\0'); int in = -1, out = -1; if ((in = ::open(from.c_str(), O_RDONLY)) < 0) { ec = std::error_code(errno, std::system_category()); return false; } std::shared_ptr guard_in(nullptr, [in](void*) { ::close(in); }); int mode = O_CREAT | O_WRONLY | O_TRUNC; if (!overwrite) { mode |= O_EXCL; } if ((out = ::open(to.c_str(), mode, static_cast(sf.permissions() & perms::all))) < 0) { ec = std::error_code(errno, std::system_category()); return false; } std::shared_ptr guard_out(nullptr, [out](void*) { ::close(out); }); ssize_t br, bw; while ((br = ::read(in, buffer.data(), buffer.size())) > 0) { int offset = 0; do { if ((bw = ::write(out, buffer.data() + offset, br)) > 0) { br -= bw; offset += bw; } else if (bw < 0) { ec = std::error_code(errno, std::system_category()); return false; } } while (br); } return true; #endif } GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symlink) { std::error_code ec; copy_symlink(existing_symlink, new_symlink, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), existing_symlink, new_symlink, ec); } } GHC_INLINE void copy_symlink(const path& existing_symlink, const path& new_symlink, std::error_code& ec) noexcept { ec.clear(); auto to = read_symlink(existing_symlink, ec); if (!ec) { if (exists(to, ec) && is_directory(to, ec)) { create_directory_symlink(to, new_symlink, ec); } else { create_symlink(to, new_symlink, ec); } } } GHC_INLINE bool create_directories(const path& p) { std::error_code ec; auto result = create_directories(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } GHC_INLINE bool create_directories(const path& p, std::error_code& ec) noexcept { path current; ec.clear(); for (const path::string_type part : p) { current /= part; if (current != p.root_name() && current != p.root_path()) { std::error_code tec; auto fs = status(current, tec); if (tec && fs.type() != file_type::not_found) { ec = tec; return false; } if (!exists(fs)) { create_directory(current, ec); if (ec) { return false; } } #ifndef LWG_2935_BEHAVIOUR else if (!is_directory(fs)) { ec = detail::make_error_code(detail::portable_error::exists); return false; } #endif } } return true; } GHC_INLINE bool create_directory(const path& p) { std::error_code ec; auto result = create_directory(p, path(), ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } GHC_INLINE bool create_directory(const path& p, std::error_code& ec) noexcept { return create_directory(p, path(), ec); } GHC_INLINE bool create_directory(const path& p, const path& attributes) { std::error_code ec; auto result = create_directory(p, attributes, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } GHC_INLINE bool create_directory(const path& p, const path& attributes, std::error_code& ec) noexcept { std::error_code tec; ec.clear(); auto fs = status(p, tec); #ifdef LWG_2935_BEHAVIOUR if (status_known(fs) && exists(fs)) { return false; } #else if (status_known(fs) && exists(fs) && is_directory(fs)) { return false; } #endif #ifdef GHC_OS_WINDOWS if (!attributes.empty()) { if (!::CreateDirectoryExW(detail::fromUtf8(attributes.u8string()).c_str(), detail::fromUtf8(p.u8string()).c_str(), NULL)) { ec = std::error_code(::GetLastError(), std::system_category()); return false; } } else if (!::CreateDirectoryW(detail::fromUtf8(p.u8string()).c_str(), NULL)) { ec = std::error_code(::GetLastError(), std::system_category()); return false; } #else ::mode_t attribs = static_cast(perms::all); if (!attributes.empty()) { struct ::stat fileStat; if (::stat(attributes.c_str(), &fileStat) != 0) { ec = std::error_code(errno, std::system_category()); return false; } attribs = fileStat.st_mode; } if (::mkdir(p.c_str(), attribs) != 0) { ec = std::error_code(errno, std::system_category()); return false; } #endif return true; } GHC_INLINE void create_directory_symlink(const path& to, const path& new_symlink) { std::error_code ec; create_directory_symlink(to, new_symlink, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), to, new_symlink, ec); } } GHC_INLINE void create_directory_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept { detail::create_symlink(to, new_symlink, true, ec); } GHC_INLINE void create_hard_link(const path& to, const path& new_hard_link) { std::error_code ec; create_hard_link(to, new_hard_link, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), to, new_hard_link, ec); } } GHC_INLINE void create_hard_link(const path& to, const path& new_hard_link, std::error_code& ec) noexcept { detail::create_hardlink(to, new_hard_link, ec); } GHC_INLINE void create_symlink(const path& to, const path& new_symlink) { std::error_code ec; create_symlink(to, new_symlink, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), to, new_symlink, ec); } } GHC_INLINE void create_symlink(const path& to, const path& new_symlink, std::error_code& ec) noexcept { detail::create_symlink(to, new_symlink, false, ec); } GHC_INLINE path current_path() { std::error_code ec; auto result = current_path(ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), ec); } return result; } GHC_INLINE path current_path(std::error_code& ec) { ec.clear(); #ifdef GHC_OS_WINDOWS DWORD pathlen = ::GetCurrentDirectoryW(0, 0); std::unique_ptr buffer(new wchar_t[size_t(pathlen) + 1]); if (::GetCurrentDirectoryW(pathlen, buffer.get()) == 0) { ec = std::error_code(::GetLastError(), std::system_category()); return path(); } return path(std::wstring(buffer.get()), path::native_format); #else size_t pathlen = static_cast(std::max(int(::pathconf(".", _PC_PATH_MAX)), int(PATH_MAX))); std::unique_ptr buffer(new char[pathlen + 1]); if (::getcwd(buffer.get(), pathlen) == NULL) { ec = std::error_code(errno, std::system_category()); return path(); } return path(buffer.get()); #endif } GHC_INLINE void current_path(const path& p) { std::error_code ec; current_path(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } } GHC_INLINE void current_path(const path& p, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS if (!::SetCurrentDirectoryW(detail::fromUtf8(p.u8string()).c_str())) { ec = std::error_code(::GetLastError(), std::system_category()); } #else if (::chdir(p.string().c_str()) == -1) { ec = std::error_code(errno, std::system_category()); } #endif } GHC_INLINE bool exists(file_status s) noexcept { return status_known(s) && s.type() != file_type::not_found; } GHC_INLINE bool exists(const path& p) { return exists(status(p)); } GHC_INLINE bool exists(const path& p, std::error_code& ec) noexcept { file_status s = status(p, ec); if (status_known(s)) { ec.clear(); } return exists(s); } GHC_INLINE bool equivalent(const path& p1, const path& p2) { std::error_code ec; bool result = equivalent(p1, p2, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p1, p2, ec); } return result; } GHC_INLINE bool equivalent(const path& p1, const path& p2, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS std::shared_ptr file1(::CreateFileW(p1.wstring().c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0), CloseHandle); auto e1 = ::GetLastError(); std::shared_ptr file2(::CreateFileW(p2.wstring().c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0), CloseHandle); if (file1.get() == INVALID_HANDLE_VALUE || file2.get() == INVALID_HANDLE_VALUE) { #ifdef LWG_2937_BEHAVIOUR ec = std::error_code(e1 ? e1 : ::GetLastError(), std::system_category()); #else if (file1 == file2) { ec = std::error_code(e1 ? e1 : ::GetLastError(), std::system_category()); } #endif return false; } BY_HANDLE_FILE_INFORMATION inf1, inf2; if (!::GetFileInformationByHandle(file1.get(), &inf1)) { ec = std::error_code(::GetLastError(), std::system_category()); return false; } if (!::GetFileInformationByHandle(file2.get(), &inf2)) { ec = std::error_code(::GetLastError(), std::system_category()); return false; } return inf1.ftLastWriteTime.dwLowDateTime == inf2.ftLastWriteTime.dwLowDateTime && inf1.ftLastWriteTime.dwHighDateTime == inf2.ftLastWriteTime.dwHighDateTime && inf1.nFileIndexHigh == inf2.nFileIndexHigh && inf1.nFileIndexLow == inf2.nFileIndexLow && inf1.nFileSizeHigh == inf2.nFileSizeHigh && inf1.nFileSizeLow == inf2.nFileSizeLow && inf1.dwVolumeSerialNumber == inf2.dwVolumeSerialNumber; #else struct ::stat s1, s2; auto rc1 = ::stat(p1.c_str(), &s1); auto e1 = errno; auto rc2 = ::stat(p2.c_str(), &s2); if (rc1 || rc2) { #ifdef LWG_2937_BEHAVIOUR ec = std::error_code(e1 ? e1 : errno, std::system_category()); #else if (rc1 && rc2) { ec = std::error_code(e1 ? e1 : errno, std::system_category()); } #endif return false; } return s1.st_dev == s2.st_dev && s1.st_ino == s2.st_ino && s1.st_size == s2.st_size && s1.st_mtime == s2.st_mtime; #endif } GHC_INLINE uintmax_t file_size(const path& p) { std::error_code ec; auto result = file_size(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } GHC_INLINE uintmax_t file_size(const path& p, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS WIN32_FILE_ATTRIBUTE_DATA attr; if (!GetFileAttributesExW(detail::fromUtf8(p.u8string()).c_str(), GetFileExInfoStandard, &attr)) { ec = std::error_code(::GetLastError(), std::system_category()); return static_cast(-1); } return static_cast(attr.nFileSizeHigh) << (sizeof(attr.nFileSizeHigh) * 8) | attr.nFileSizeLow; #else struct ::stat fileStat; if (::stat(p.c_str(), &fileStat) == -1) { ec = std::error_code(errno, std::system_category()); return static_cast(-1); } return static_cast(fileStat.st_size); #endif } GHC_INLINE uintmax_t hard_link_count(const path& p) { std::error_code ec; auto result = hard_link_count(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } GHC_INLINE uintmax_t hard_link_count(const path& p, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS uintmax_t result = static_cast(-1); std::shared_ptr file(::CreateFileW(p.wstring().c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0), CloseHandle); BY_HANDLE_FILE_INFORMATION inf; if (file.get() == INVALID_HANDLE_VALUE) { ec = std::error_code(::GetLastError(), std::system_category()); } else { if (!::GetFileInformationByHandle(file.get(), &inf)) { ec = std::error_code(::GetLastError(), std::system_category()); } else { result = inf.nNumberOfLinks; } } return result; #else uintmax_t result = 0; file_status fs = detail::status_ex(p, ec, nullptr, nullptr, &result, nullptr); if (fs.type() == file_type::not_found) { ec = detail::make_error_code(detail::portable_error::not_found); } return ec ? static_cast(-1) : result; #endif } GHC_INLINE bool is_block_file(file_status s) noexcept { return s.type() == file_type::block; } GHC_INLINE bool is_block_file(const path& p) { return is_block_file(status(p)); } GHC_INLINE bool is_block_file(const path& p, std::error_code& ec) noexcept { return is_block_file(status(p, ec)); } GHC_INLINE bool is_character_file(file_status s) noexcept { return s.type() == file_type::character; } GHC_INLINE bool is_character_file(const path& p) { return is_character_file(status(p)); } GHC_INLINE bool is_character_file(const path& p, std::error_code& ec) noexcept { return is_character_file(status(p, ec)); } GHC_INLINE bool is_directory(file_status s) noexcept { return s.type() == file_type::directory; } GHC_INLINE bool is_directory(const path& p) { return is_directory(status(p)); } GHC_INLINE bool is_directory(const path& p, std::error_code& ec) noexcept { return is_directory(status(p, ec)); } GHC_INLINE bool is_empty(const path& p) { if (is_directory(p)) { return directory_iterator(p) == directory_iterator(); } else { return file_size(p) == 0; } } GHC_INLINE bool is_empty(const path& p, std::error_code& ec) noexcept { auto fs = status(p, ec); if (ec) { return false; } if (is_directory(fs)) { directory_iterator iter(p, ec); if (ec) { return false; } return iter == directory_iterator(); } else { auto sz = file_size(p, ec); if (ec) { return false; } return sz == 0; } } GHC_INLINE bool is_fifo(file_status s) noexcept { return s.type() == file_type::fifo; } GHC_INLINE bool is_fifo(const path& p) { return is_fifo(status(p)); } GHC_INLINE bool is_fifo(const path& p, std::error_code& ec) noexcept { return is_fifo(status(p, ec)); } GHC_INLINE bool is_other(file_status s) noexcept { return exists(s) && !is_regular_file(s) && !is_directory(s) && !is_symlink(s); } GHC_INLINE bool is_other(const path& p) { return is_other(status(p)); } GHC_INLINE bool is_other(const path& p, std::error_code& ec) noexcept { return is_other(status(p, ec)); } GHC_INLINE bool is_regular_file(file_status s) noexcept { return s.type() == file_type::regular; } GHC_INLINE bool is_regular_file(const path& p) { return is_regular_file(status(p)); } GHC_INLINE bool is_regular_file(const path& p, std::error_code& ec) noexcept { return is_regular_file(status(p, ec)); } GHC_INLINE bool is_socket(file_status s) noexcept { return s.type() == file_type::socket; } GHC_INLINE bool is_socket(const path& p) { return is_socket(status(p)); } GHC_INLINE bool is_socket(const path& p, std::error_code& ec) noexcept { return is_socket(status(p, ec)); } GHC_INLINE bool is_symlink(file_status s) noexcept { return s.type() == file_type::symlink; } GHC_INLINE bool is_symlink(const path& p) { return is_symlink(symlink_status(p)); } GHC_INLINE bool is_symlink(const path& p, std::error_code& ec) noexcept { return is_symlink(symlink_status(p, ec)); } GHC_INLINE file_time_type last_write_time(const path& p) { std::error_code ec; auto result = last_write_time(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } GHC_INLINE file_time_type last_write_time(const path& p, std::error_code& ec) noexcept { time_t result = 0; ec.clear(); file_status fs = detail::status_ex(p, ec, nullptr, nullptr, nullptr, &result); return ec ? (file_time_type::min)() : std::chrono::system_clock::from_time_t(result); } GHC_INLINE void last_write_time(const path& p, file_time_type new_time) { std::error_code ec; last_write_time(p, new_time, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } } GHC_INLINE void last_write_time(const path& p, file_time_type new_time, std::error_code& ec) noexcept { ec.clear(); auto d = new_time.time_since_epoch(); #ifdef GHC_OS_WINDOWS std::shared_ptr file(::CreateFileW(p.wstring().c_str(), FILE_WRITE_ATTRIBUTES, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL), ::CloseHandle); FILETIME ft; auto tt = std::chrono::duration_cast(d).count() * 10 + 116444736000000000; ft.dwLowDateTime = (unsigned long)tt; ft.dwHighDateTime = tt >> 32; if (!::SetFileTime(file.get(), 0, 0, &ft)) { ec = std::error_code(::GetLastError(), std::system_category()); } #elif defined(GHC_OS_MACOS) #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED #if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300 struct ::stat fs; if (::stat(p.c_str(), &fs) == 0) { struct ::timeval tv[2]; tv[0].tv_sec = fs.st_atimespec.tv_sec; tv[0].tv_usec = static_cast(fs.st_atimespec.tv_nsec / 1000); tv[1].tv_sec = std::chrono::duration_cast(d).count(); tv[1].tv_usec = static_cast(std::chrono::duration_cast(d).count() % 1000000); if (::utimes(p.c_str(), tv) == 0) { return; } } ec = std::error_code(errno, std::system_category()); return; #else struct ::timespec times[2]; times[0].tv_sec = 0; times[0].tv_nsec = UTIME_OMIT; times[1].tv_sec = std::chrono::duration_cast(d).count(); times[1].tv_nsec = std::chrono::duration_cast(d).count() % 1000000000; if (::utimensat(AT_FDCWD, p.c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) { ec = std::error_code(errno, std::system_category()); } return; #endif #endif #else struct ::timespec times[2]; times[0].tv_sec = 0; times[0].tv_nsec = UTIME_OMIT; times[1].tv_sec = std::chrono::duration_cast(d).count(); times[1].tv_nsec = std::chrono::duration_cast(d).count() % 1000000000; if (::utimensat(AT_FDCWD, p.c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) { ec = std::error_code(errno, std::system_category()); } return; #endif } GHC_INLINE void permissions(const path& p, perms prms, perm_options opts) { std::error_code ec; permissions(p, prms, opts, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } } GHC_INLINE void permissions(const path& p, perms prms, std::error_code& ec) noexcept { permissions(p, prms, perm_options::replace, ec); } GHC_INLINE void permissions(const path& p, perms prms, perm_options opts, std::error_code& ec) { if (static_cast(opts & (perm_options::replace | perm_options::add | perm_options::remove)) == 0) { ec = detail::make_error_code(detail::portable_error::invalid_argument); return; } auto fs = symlink_status(p, ec); if ((opts & perm_options::replace) != perm_options::replace) { if ((opts & perm_options::add) == perm_options::add) { prms = fs.permissions() | prms; } else { prms = fs.permissions() & ~prms; } } #ifdef GHC_OS_WINDOWS #ifdef __GNUC__ auto oldAttr = GetFileAttributesW(p.wstring().c_str()); if (oldAttr != INVALID_FILE_ATTRIBUTES) { DWORD newAttr = ((prms & perms::owner_write) == perms::owner_write) ? oldAttr & ~FILE_ATTRIBUTE_READONLY : oldAttr | FILE_ATTRIBUTE_READONLY; if (oldAttr == newAttr || SetFileAttributesW(p.wstring().c_str(), newAttr)) { return; } } ec = std::error_code(::GetLastError(), std::system_category()); #else int mode = 0; if ((prms & perms::owner_read) == perms::owner_read) { mode |= _S_IREAD; } if ((prms & perms::owner_write) == perms::owner_write) { mode |= _S_IWRITE; } if (::_wchmod(p.wstring().c_str(), mode) != 0) { ec = std::error_code(::GetLastError(), std::system_category()); } #endif #else if ((opts & perm_options::nofollow) != perm_options::nofollow) { if (::chmod(p.c_str(), static_cast(prms)) != 0) { ec = std::error_code(errno, std::system_category()); } } #endif } GHC_INLINE path proximate(const path& p, std::error_code& ec) { return proximate(p, current_path(), ec); } GHC_INLINE path proximate(const path& p, const path& base) { return weakly_canonical(p).lexically_proximate(weakly_canonical(base)); } GHC_INLINE path proximate(const path& p, const path& base, std::error_code& ec) { return weakly_canonical(p, ec).lexically_proximate(weakly_canonical(base, ec)); } GHC_INLINE path read_symlink(const path& p) { std::error_code ec; auto result = read_symlink(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } GHC_INLINE path read_symlink(const path& p, std::error_code& ec) { file_status fs = symlink_status(p, ec); if (fs.type() != file_type::symlink) { ec = detail::make_error_code(detail::portable_error::invalid_argument); return path(); } auto result = detail::resolveSymlink(p, ec); return ec ? path() : result; } GHC_INLINE path relative(const path& p, std::error_code& ec) { return relative(p, current_path(ec), ec); } GHC_INLINE path relative(const path& p, const path& base) { return weakly_canonical(p).lexically_relative(weakly_canonical(base)); } GHC_INLINE path relative(const path& p, const path& base, std::error_code& ec) { return weakly_canonical(p, ec).lexically_relative(weakly_canonical(base, ec)); } GHC_INLINE bool remove(const path& p) { std::error_code ec; auto result = remove(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } GHC_INLINE bool remove(const path& p, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS std::wstring np = detail::fromUtf8(p.u8string()); DWORD attr = GetFileAttributesW(np.c_str()); if (attr == INVALID_FILE_ATTRIBUTES) { auto error = ::GetLastError(); if (error == ERROR_FILE_NOT_FOUND || error == ERROR_PATH_NOT_FOUND) { return false; } ec = std::error_code(error, std::system_category()); } if (!ec) { if (attr & FILE_ATTRIBUTE_DIRECTORY) { if (!RemoveDirectoryW(np.c_str())) { ec = std::error_code(::GetLastError(), std::system_category()); } } else { if (!DeleteFileW(np.c_str())) { ec = std::error_code(::GetLastError(), std::system_category()); } } } #else if (::remove(p.c_str()) == -1) { auto error = errno; if (error == ENOENT) { return false; } ec = std::error_code(errno, std::system_category()); } #endif return ec ? false : true; } GHC_INLINE uintmax_t remove_all(const path& p) { std::error_code ec; auto result = remove_all(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } GHC_INLINE uintmax_t remove_all(const path& p, std::error_code& ec) noexcept { ec.clear(); uintmax_t count = 0; if (p == "/") { ec = detail::make_error_code(detail::portable_error::not_supported); return static_cast(-1); } std::error_code tec; auto fs = status(p, tec); if (exists(fs) && is_directory(fs)) { for (auto iter = directory_iterator(p, ec); iter != directory_iterator(); iter.increment(ec)) { if (ec) { break; } if (!iter->is_symlink() && iter->is_directory()) { count += remove_all(iter->path(), ec); if (ec) { return static_cast(-1); } } else { remove(iter->path(), ec); if (ec) { return static_cast(-1); } ++count; } } } if (!ec) { if (remove(p, ec)) { ++count; } } if (ec) { return static_cast(-1); } return count; } GHC_INLINE void rename(const path& from, const path& to) { std::error_code ec; rename(from, to, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), from, to, ec); } } GHC_INLINE void rename(const path& from, const path& to, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS if (from != to) { if (!MoveFileW(detail::fromUtf8(from.u8string()).c_str(), detail::fromUtf8(to.u8string()).c_str())) { ec = std::error_code(::GetLastError(), std::system_category()); } } #else if (from != to) { if (::rename(from.c_str(), to.c_str()) != 0) { ec = std::error_code(errno, std::system_category()); } } #endif } GHC_INLINE void resize_file(const path& p, uintmax_t size) { std::error_code ec; resize_file(p, size, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } } GHC_INLINE void resize_file(const path& p, uintmax_t size, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS LARGE_INTEGER lisize; lisize.QuadPart = size; std::shared_ptr file(CreateFileW(detail::fromUtf8(p.u8string()).c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL), CloseHandle); if (file.get() == INVALID_HANDLE_VALUE) { ec = std::error_code(::GetLastError(), std::system_category()); } else if (SetFilePointerEx(file.get(), lisize, NULL, FILE_BEGIN) == 0 || SetEndOfFile(file.get()) == 0) { ec = std::error_code(::GetLastError(), std::system_category()); } #else if (::truncate(p.c_str(), size) != 0) { ec = std::error_code(errno, std::system_category()); } #endif } GHC_INLINE space_info space(const path& p) { std::error_code ec; auto result = space(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } GHC_INLINE space_info space(const path& p, std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS ULARGE_INTEGER freeBytesAvailableToCaller = {0}; ULARGE_INTEGER totalNumberOfBytes = {0}; ULARGE_INTEGER totalNumberOfFreeBytes = {0}; if (!GetDiskFreeSpaceExW(detail::fromUtf8(p.u8string()).c_str(), &freeBytesAvailableToCaller, &totalNumberOfBytes, &totalNumberOfFreeBytes)) { ec = std::error_code(::GetLastError(), std::system_category()); return {static_cast(-1), static_cast(-1), static_cast(-1)}; } return {static_cast(totalNumberOfBytes.QuadPart), static_cast(totalNumberOfFreeBytes.QuadPart), static_cast(freeBytesAvailableToCaller.QuadPart)}; #elif !defined(__ANDROID__) || __ANDROID_API__ >= 19 struct ::statvfs sfs; if (::statvfs(p.c_str(), &sfs) != 0) { ec = std::error_code(errno, std::system_category()); return {static_cast(-1), static_cast(-1), static_cast(-1)}; } return {static_cast(sfs.f_blocks * sfs.f_frsize), static_cast(sfs.f_bfree * sfs.f_frsize), static_cast(sfs.f_bavail * sfs.f_frsize)}; #else ec = detail::make_error_code(detail::portable_error::not_supported); return {static_cast(-1), static_cast(-1), static_cast(-1)}; #endif } GHC_INLINE file_status status(const path& p) { std::error_code ec; auto result = status(p, ec); if (result.type() == file_type::none) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } GHC_INLINE file_status status(const path& p, std::error_code& ec) noexcept { return detail::status_ex(p, ec); } GHC_INLINE bool status_known(file_status s) noexcept { return s.type() != file_type::none; } GHC_INLINE file_status symlink_status(const path& p) { std::error_code ec; auto result = symlink_status(p, ec); if (result.type() == file_type::none) { throw filesystem_error(detail::systemErrorText(ec.value()), ec); } return result; } GHC_INLINE file_status symlink_status(const path& p, std::error_code& ec) noexcept { return detail::symlink_status_ex(p, ec); } GHC_INLINE path temp_directory_path() { std::error_code ec; path result = temp_directory_path(ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), ec); } return result; } GHC_INLINE path temp_directory_path(std::error_code& ec) noexcept { ec.clear(); #ifdef GHC_OS_WINDOWS wchar_t buffer[512]; int rc = GetTempPathW(511, buffer); if (!rc || rc > 511) { ec = std::error_code(::GetLastError(), std::system_category()); return path(); } return path(std::wstring(buffer)); #else static const char* temp_vars[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR", nullptr}; const char* temp_path = nullptr; for (auto temp_name = temp_vars; *temp_name != nullptr; ++temp_name) { temp_path = std::getenv(*temp_name); if (temp_path) { return path(temp_path); } } return path("/tmp"); #endif } GHC_INLINE path weakly_canonical(const path& p) { std::error_code ec; auto result = weakly_canonical(p, ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), p, ec); } return result; } GHC_INLINE path weakly_canonical(const path& p, std::error_code& ec) noexcept { path result; ec.clear(); bool scan = true; for (auto pe : p) { if (scan) { std::error_code tec; if (exists(result / pe, tec)) { result /= pe; } else { if (ec) { return path(); } scan = false; if (!result.empty()) { result = canonical(result, ec) / pe; if (ec) { break; } } else { result /= pe; } } } else { result /= pe; } } if (scan) { if (!result.empty()) { result = canonical(result, ec); } } return ec ? path() : result.lexically_normal(); } //----------------------------------------------------------------------------- // 30.10.11 class file_status // 30.10.11.1 constructors and destructor GHC_INLINE file_status::file_status() noexcept : file_status(file_type::none) { } GHC_INLINE file_status::file_status(file_type ft, perms prms) noexcept : _type(ft) , _perms(prms) { } GHC_INLINE file_status::file_status(const file_status& other) noexcept : _type(other._type) , _perms(other._perms) { } GHC_INLINE file_status::file_status(file_status&& other) noexcept : _type(other._type) , _perms(other._perms) { } GHC_INLINE file_status::~file_status() {} // assignments: GHC_INLINE file_status& file_status::operator=(const file_status& rhs) noexcept { _type = rhs._type; _perms = rhs._perms; return *this; } GHC_INLINE file_status& file_status::operator=(file_status&& rhs) noexcept { _type = rhs._type; _perms = rhs._perms; return *this; } // 30.10.11.3 modifiers GHC_INLINE void file_status::type(file_type ft) noexcept { _type = ft; } GHC_INLINE void file_status::permissions(perms prms) noexcept { _perms = prms; } // 30.10.11.2 observers GHC_INLINE file_type file_status::type() const noexcept { return _type; } GHC_INLINE perms file_status::permissions() const noexcept { return _perms; } //----------------------------------------------------------------------------- // 30.10.12 class directory_entry // 30.10.12.1 constructors and destructor // directory_entry::directory_entry() noexcept = default; // directory_entry::directory_entry(const directory_entry&) = default; // directory_entry::directory_entry(directory_entry&&) noexcept = default; GHC_INLINE directory_entry::directory_entry(const filesystem::path& p) : _path(p) , _file_size(0) #ifndef GHC_OS_WINDOWS , _hard_link_count(0) #endif , _last_write_time(0) { refresh(); } GHC_INLINE directory_entry::directory_entry(const filesystem::path& p, std::error_code& ec) : _path(p) , _file_size(0) #ifndef GHC_OS_WINDOWS , _hard_link_count(0) #endif , _last_write_time(0) { refresh(ec); } GHC_INLINE directory_entry::~directory_entry() {} // assignments: // directory_entry& directory_entry::operator=(const directory_entry&) = default; // directory_entry& directory_entry::operator=(directory_entry&&) noexcept = default; // 30.10.12.2 directory_entry modifiers GHC_INLINE void directory_entry::assign(const filesystem::path& p) { _path = p; refresh(); } GHC_INLINE void directory_entry::assign(const filesystem::path& p, std::error_code& ec) { _path = p; refresh(ec); } GHC_INLINE void directory_entry::replace_filename(const filesystem::path& p) { _path.replace_filename(p); refresh(); } GHC_INLINE void directory_entry::replace_filename(const filesystem::path& p, std::error_code& ec) { _path.replace_filename(p); refresh(ec); } GHC_INLINE void directory_entry::refresh() { std::error_code ec; refresh(ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), _path, ec); } } GHC_INLINE void directory_entry::refresh(std::error_code& ec) noexcept { #ifdef GHC_OS_WINDOWS _status = detail::status_ex(_path, ec, &_symlink_status, &_file_size, nullptr, &_last_write_time); #else _status = detail::status_ex(_path, ec, &_symlink_status, &_file_size, &_hard_link_count, &_last_write_time); #endif } // 30.10.12.3 directory_entry observers GHC_INLINE const filesystem::path& directory_entry::path() const noexcept { return _path; } GHC_INLINE directory_entry::operator const filesystem::path&() const noexcept { return _path; } GHC_INLINE bool directory_entry::exists() const { return filesystem::exists(status()); } GHC_INLINE bool directory_entry::exists(std::error_code& ec) const noexcept { return filesystem::exists(status(ec)); } GHC_INLINE bool directory_entry::is_block_file() const { return filesystem::is_block_file(status()); } GHC_INLINE bool directory_entry::is_block_file(std::error_code& ec) const noexcept { return filesystem::is_block_file(status(ec)); } GHC_INLINE bool directory_entry::is_character_file() const { return filesystem::is_character_file(status()); } GHC_INLINE bool directory_entry::is_character_file(std::error_code& ec) const noexcept { return filesystem::is_character_file(status(ec)); } GHC_INLINE bool directory_entry::is_directory() const { return filesystem::is_directory(status()); } GHC_INLINE bool directory_entry::is_directory(std::error_code& ec) const noexcept { return filesystem::is_directory(status(ec)); } GHC_INLINE bool directory_entry::is_fifo() const { return filesystem::is_fifo(status()); } GHC_INLINE bool directory_entry::is_fifo(std::error_code& ec) const noexcept { return filesystem::is_fifo(status(ec)); } GHC_INLINE bool directory_entry::is_other() const { return filesystem::is_other(status()); } GHC_INLINE bool directory_entry::is_other(std::error_code& ec) const noexcept { return filesystem::is_other(status(ec)); } GHC_INLINE bool directory_entry::is_regular_file() const { return filesystem::is_regular_file(status()); } GHC_INLINE bool directory_entry::is_regular_file(std::error_code& ec) const noexcept { return filesystem::is_regular_file(status(ec)); } GHC_INLINE bool directory_entry::is_socket() const { return filesystem::is_socket(status()); } GHC_INLINE bool directory_entry::is_socket(std::error_code& ec) const noexcept { return filesystem::is_socket(status(ec)); } GHC_INLINE bool directory_entry::is_symlink() const { return filesystem::is_symlink(symlink_status()); } GHC_INLINE bool directory_entry::is_symlink(std::error_code& ec) const noexcept { return filesystem::is_symlink(symlink_status(ec)); } GHC_INLINE uintmax_t directory_entry::file_size() const { if (_status.type() != file_type::none) { return _file_size; } return filesystem::file_size(path()); } GHC_INLINE uintmax_t directory_entry::file_size(std::error_code& ec) const noexcept { if (_status.type() != file_type::none) { return _file_size; } return filesystem::file_size(path(), ec); } GHC_INLINE uintmax_t directory_entry::hard_link_count() const { #ifndef GHC_OS_WINDOWS if (_status.type() != file_type::none) { return _hard_link_count; } #endif return filesystem::hard_link_count(path()); } GHC_INLINE uintmax_t directory_entry::hard_link_count(std::error_code& ec) const noexcept { #ifndef GHC_OS_WINDOWS if (_status.type() != file_type::none) { return _hard_link_count; } #endif return filesystem::hard_link_count(path(), ec); } GHC_INLINE file_time_type directory_entry::last_write_time() const { if (_status.type() != file_type::none) { return std::chrono::system_clock::from_time_t(_last_write_time); } return filesystem::last_write_time(path()); } GHC_INLINE file_time_type directory_entry::last_write_time(std::error_code& ec) const noexcept { if (_status.type() != file_type::none) { return std::chrono::system_clock::from_time_t(_last_write_time); } return filesystem::last_write_time(path(), ec); } GHC_INLINE file_status directory_entry::status() const { if (_status.type() != file_type::none) { return _status; } return filesystem::status(path()); } GHC_INLINE file_status directory_entry::status(std::error_code& ec) const noexcept { if (_status.type() != file_type::none) { return _status; } return filesystem::status(path(), ec); } GHC_INLINE file_status directory_entry::symlink_status() const { if (_symlink_status.type() != file_type::none) { return _symlink_status; } return filesystem::symlink_status(path()); } GHC_INLINE file_status directory_entry::symlink_status(std::error_code& ec) const noexcept { if (_symlink_status.type() != file_type::none) { return _symlink_status; } return filesystem::symlink_status(path(), ec); } GHC_INLINE bool directory_entry::operator<(const directory_entry& rhs) const noexcept { return _path < rhs._path; } GHC_INLINE bool directory_entry::operator==(const directory_entry& rhs) const noexcept { return _path == rhs._path; } GHC_INLINE bool directory_entry::operator!=(const directory_entry& rhs) const noexcept { return _path != rhs._path; } GHC_INLINE bool directory_entry::operator<=(const directory_entry& rhs) const noexcept { return _path <= rhs._path; } GHC_INLINE bool directory_entry::operator>(const directory_entry& rhs) const noexcept { return _path > rhs._path; } GHC_INLINE bool directory_entry::operator>=(const directory_entry& rhs) const noexcept { return _path >= rhs._path; } //----------------------------------------------------------------------------- // 30.10.13 class directory_iterator #ifdef GHC_OS_WINDOWS class directory_iterator::impl { public: impl(const path& p, directory_options options) : _base(p) , _options(options) , _findData{0} , _dirHandle(INVALID_HANDLE_VALUE) { if (!_base.empty()) { ZeroMemory(&_findData, sizeof(WIN32_FIND_DATAW)); if ((_dirHandle = FindFirstFileW(detail::fromUtf8((_base / "*").u8string()).c_str(), &_findData)) != INVALID_HANDLE_VALUE) { if (std::wstring(_findData.cFileName) == L"." || std::wstring(_findData.cFileName) == L"..") { increment(_ec); } else { _current = _base / std::wstring(_findData.cFileName); copyToDirEntry(_ec); } } else { auto error = ::GetLastError(); _base = filesystem::path(); if (error != ERROR_ACCESS_DENIED || (options & directory_options::skip_permission_denied) == directory_options::none) { _ec = std::error_code(::GetLastError(), std::system_category()); } } } } impl(const impl& other) = delete; ~impl() { if (_dirHandle != INVALID_HANDLE_VALUE) { FindClose(_dirHandle); _dirHandle = INVALID_HANDLE_VALUE; } } void increment(std::error_code& ec) { if (_dirHandle != INVALID_HANDLE_VALUE) { do { if (FindNextFileW(_dirHandle, &_findData)) { _current = _base; try { _current.append_name(detail::toUtf8(_findData.cFileName).c_str()); } catch(filesystem_error& fe) { ec = fe.code(); return; } copyToDirEntry(ec); } else { auto err = ::GetLastError(); if(err != ERROR_NO_MORE_FILES) { _ec = ec = std::error_code(err, std::system_category()); } FindClose(_dirHandle); _dirHandle = INVALID_HANDLE_VALUE; _current = filesystem::path(); break; } } while (std::wstring(_findData.cFileName) == L"." || std::wstring(_findData.cFileName) == L".."); } else { ec = _ec; } } void copyToDirEntry(std::error_code& ec) { _dir_entry._path = _current; if (_findData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { _dir_entry._status = detail::status_ex(_current, ec, &_dir_entry._symlink_status, &_dir_entry._file_size, nullptr, &_dir_entry._last_write_time); } else { _dir_entry._status = detail::status_from_INFO(_current, &_findData, ec, &_dir_entry._file_size, &_dir_entry._last_write_time); _dir_entry._symlink_status = _dir_entry._status; } if (ec) { if (_dir_entry._status.type() != file_type::none && _dir_entry._symlink_status.type() != file_type::none) { ec.clear(); } else { _dir_entry._file_size = static_cast(-1); _dir_entry._last_write_time = 0; } } } path _base; directory_options _options; WIN32_FIND_DATAW _findData; HANDLE _dirHandle; path _current; directory_entry _dir_entry; std::error_code _ec; }; #else // POSIX implementation class directory_iterator::impl { public: impl(const path& path, directory_options options) : _base(path) , _options(options) , _dir(nullptr) , _entry(nullptr) { if (!path.empty()) { _dir = ::opendir(path.native().c_str()); } if (!path.empty()) { if (!_dir) { auto error = errno; _base = filesystem::path(); if (error != EACCES || (options & directory_options::skip_permission_denied) == directory_options::none) { _ec = std::error_code(errno, std::system_category()); } } else { increment(_ec); } } } impl(const impl& other) = delete; ~impl() { if (_dir) { ::closedir(_dir); } } void increment(std::error_code& ec) { if (_dir) { do { errno = 0; _entry = readdir(_dir); if (_entry) { _current = _base; _current.append_name(_entry->d_name); _dir_entry = directory_entry(_current, ec); } else { ::closedir(_dir); _dir = nullptr; _current = path(); if (errno) { ec = std::error_code(errno, std::system_category()); } break; } } while (std::strcmp(_entry->d_name, ".") == 0 || std::strcmp(_entry->d_name, "..") == 0); } } path _base; directory_options _options; path _current; DIR* _dir; struct ::dirent* _entry; directory_entry _dir_entry; std::error_code _ec; }; #endif // 30.10.13.1 member functions GHC_INLINE directory_iterator::directory_iterator() noexcept : _impl(new impl(path(), directory_options::none)) { } GHC_INLINE directory_iterator::directory_iterator(const path& p) : _impl(new impl(p, directory_options::none)) { if (_impl->_ec) { throw filesystem_error(detail::systemErrorText(_impl->_ec.value()), p, _impl->_ec); } _impl->_ec.clear(); } GHC_INLINE directory_iterator::directory_iterator(const path& p, directory_options options) : _impl(new impl(p, options)) { if (_impl->_ec) { throw filesystem_error(detail::systemErrorText(_impl->_ec.value()), p, _impl->_ec); } } GHC_INLINE directory_iterator::directory_iterator(const path& p, std::error_code& ec) noexcept : _impl(new impl(p, directory_options::none)) { if (_impl->_ec) { ec = _impl->_ec; } } GHC_INLINE directory_iterator::directory_iterator(const path& p, directory_options options, std::error_code& ec) noexcept : _impl(new impl(p, options)) { if (_impl->_ec) { ec = _impl->_ec; } } GHC_INLINE directory_iterator::directory_iterator(const directory_iterator& rhs) : _impl(rhs._impl) { } GHC_INLINE directory_iterator::directory_iterator(directory_iterator&& rhs) noexcept : _impl(std::move(rhs._impl)) { } GHC_INLINE directory_iterator::~directory_iterator() {} GHC_INLINE directory_iterator& directory_iterator::operator=(const directory_iterator& rhs) { _impl = rhs._impl; return *this; } GHC_INLINE directory_iterator& directory_iterator::operator=(directory_iterator&& rhs) noexcept { _impl = std::move(rhs._impl); return *this; } GHC_INLINE const directory_entry& directory_iterator::operator*() const { return _impl->_dir_entry; } GHC_INLINE const directory_entry* directory_iterator::operator->() const { return &_impl->_dir_entry; } GHC_INLINE directory_iterator& directory_iterator::operator++() { std::error_code ec; _impl->increment(ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), _impl->_current, ec); } return *this; } GHC_INLINE directory_iterator& directory_iterator::increment(std::error_code& ec) noexcept { _impl->increment(ec); return *this; } GHC_INLINE bool directory_iterator::operator==(const directory_iterator& rhs) const { return _impl->_current == rhs._impl->_current; } GHC_INLINE bool directory_iterator::operator!=(const directory_iterator& rhs) const { return _impl->_current != rhs._impl->_current; } // 30.10.13.2 directory_iterator non-member functions GHC_INLINE directory_iterator begin(directory_iterator iter) noexcept { return iter; } GHC_INLINE directory_iterator end(const directory_iterator&) noexcept { return directory_iterator(); } //----------------------------------------------------------------------------- // 30.10.14 class recursive_directory_iterator GHC_INLINE recursive_directory_iterator::recursive_directory_iterator() noexcept : _impl(new recursive_directory_iterator_impl(directory_options::none, true)) { _impl->_dir_iter_stack.push(directory_iterator()); } GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const path& p) : _impl(new recursive_directory_iterator_impl(directory_options::none, true)) { _impl->_dir_iter_stack.push(directory_iterator(p)); } GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const path& p, directory_options options) : _impl(new recursive_directory_iterator_impl(options, true)) { _impl->_dir_iter_stack.push(directory_iterator(p, options)); } GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const path& p, directory_options options, std::error_code& ec) noexcept : _impl(new recursive_directory_iterator_impl(options, true)) { _impl->_dir_iter_stack.push(directory_iterator(p, options, ec)); } GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const path& p, std::error_code& ec) noexcept : _impl(new recursive_directory_iterator_impl(directory_options::none, true)) { _impl->_dir_iter_stack.push(directory_iterator(p, ec)); } GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(const recursive_directory_iterator& rhs) : _impl(rhs._impl) { } GHC_INLINE recursive_directory_iterator::recursive_directory_iterator(recursive_directory_iterator&& rhs) noexcept : _impl(std::move(rhs._impl)) { } GHC_INLINE recursive_directory_iterator::~recursive_directory_iterator() {} // 30.10.14.1 observers GHC_INLINE directory_options recursive_directory_iterator::options() const { return _impl->_options; } GHC_INLINE int recursive_directory_iterator::depth() const { return static_cast(_impl->_dir_iter_stack.size() - 1); } GHC_INLINE bool recursive_directory_iterator::recursion_pending() const { return _impl->_recursion_pending; } GHC_INLINE const directory_entry& recursive_directory_iterator::operator*() const { return *(_impl->_dir_iter_stack.top()); } GHC_INLINE const directory_entry* recursive_directory_iterator::operator->() const { return &(*(_impl->_dir_iter_stack.top())); } // 30.10.14.1 modifiers recursive_directory_iterator& GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator=(const recursive_directory_iterator& rhs) { _impl = rhs._impl; return *this; } GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator=(recursive_directory_iterator&& rhs) noexcept { _impl = std::move(rhs._impl); return *this; } GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::operator++() { std::error_code ec; increment(ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), _impl->_dir_iter_stack.empty() ? path() : _impl->_dir_iter_stack.top()->path(), ec); } return *this; } GHC_INLINE recursive_directory_iterator& recursive_directory_iterator::increment(std::error_code& ec) noexcept { if (recursion_pending() && is_directory((*this)->status()) && (!is_symlink((*this)->symlink_status()) || (options() & directory_options::follow_directory_symlink) != directory_options::none)) { _impl->_dir_iter_stack.push(directory_iterator((*this)->path(), _impl->_options, ec)); } else { _impl->_dir_iter_stack.top().increment(ec); } if (!ec) { while (depth() && _impl->_dir_iter_stack.top() == directory_iterator()) { _impl->_dir_iter_stack.pop(); _impl->_dir_iter_stack.top().increment(ec); } } else if (!_impl->_dir_iter_stack.empty()) { _impl->_dir_iter_stack.pop(); } _impl->_recursion_pending = true; return *this; } GHC_INLINE void recursive_directory_iterator::pop() { std::error_code ec; pop(ec); if (ec) { throw filesystem_error(detail::systemErrorText(ec.value()), _impl->_dir_iter_stack.empty() ? path() : _impl->_dir_iter_stack.top()->path(), ec); } } GHC_INLINE void recursive_directory_iterator::pop(std::error_code& ec) { if (depth() == 0) { *this = recursive_directory_iterator(); } else { do { _impl->_dir_iter_stack.pop(); _impl->_dir_iter_stack.top().increment(ec); } while (depth() && _impl->_dir_iter_stack.top() == directory_iterator()); } } GHC_INLINE void recursive_directory_iterator::disable_recursion_pending() { _impl->_recursion_pending = false; } // other members as required by 27.2.3, input iterators GHC_INLINE bool recursive_directory_iterator::operator==(const recursive_directory_iterator& rhs) const { return _impl->_dir_iter_stack.top() == rhs._impl->_dir_iter_stack.top(); } GHC_INLINE bool recursive_directory_iterator::operator!=(const recursive_directory_iterator& rhs) const { return _impl->_dir_iter_stack.top() != rhs._impl->_dir_iter_stack.top(); } // 30.10.14.2 directory_iterator non-member functions GHC_INLINE recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept { return iter; } GHC_INLINE recursive_directory_iterator end(const recursive_directory_iterator&) noexcept { return recursive_directory_iterator(); } #endif // GHC_EXPAND_IMPL } // namespace filesystem } // namespace ghc #endif // GHC_FILESYSTEM_H goxel-0.11.0/ext_src/yocto/ext/happly.h000066400000000000000000001474701435762723100200100ustar00rootroot00000000000000#pragma once /* A header-only implementation of the .ply file format. * https://github.com/nmwsharp/happly * By Nicholas Sharp - nsharp@cs.cmu.edu */ /* MIT License Copyright (c) 2018 Nick Sharp Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include #include #include #include #include #include #include #include #include // General namespace wrapping all Happly things. namespace happly { // Enum specifying binary or ASCII filetypes. Binary is always little-endian. enum class DataFormat { ASCII, Binary }; // Type name strings // clang-format off template std::string typeName() { return "unknown"; } template<> inline std::string typeName() { return "char"; } template<> inline std::string typeName() { return "uchar"; } template<> inline std::string typeName() { return "short"; } template<> inline std::string typeName() { return "ushort"; } template<> inline std::string typeName() { return "int"; } template<> inline std::string typeName() { return "uint"; } template<> inline std::string typeName() { return "float"; } template<> inline std::string typeName() { return "double"; } // clang-format on // Template hackery that makes getProperty() and friends pretty while automatically picking up smaller types namespace { // A pointer for the equivalent/smaller equivalent of a type (eg. when a double is requested a float works too, etc) // long int is intentionally absent to avoid platform confusion // clang-format off template struct TypeChain { bool hasChildType = false; typedef T type; }; template <> struct TypeChain { bool hasChildType = true; typedef int32_t type; }; template <> struct TypeChain { bool hasChildType = true; typedef int16_t type; }; template <> struct TypeChain { bool hasChildType = true; typedef int8_t type; }; template <> struct TypeChain { bool hasChildType = true; typedef uint32_t type; }; template <> struct TypeChain { bool hasChildType = true; typedef uint16_t type; }; template <> struct TypeChain { bool hasChildType = true; typedef uint8_t type; }; template <> struct TypeChain { bool hasChildType = true; typedef float type; }; // clang-format on // clang-format off template struct CanonicalName { typedef T type; }; template <> struct CanonicalName { typedef int8_t type; }; template <> struct CanonicalName { typedef uint8_t type; }; template <> struct CanonicalName { typedef std::conditional::type, int>::value, uint32_t, uint64_t>::type type; }; // clang-format on } // namespace /** * @brief A generic property, which is associated with some element. Can be plain Property or a ListProperty, of some * type. Generally, the user should not need to interact with these directly, but they are exposed in case someone * wants to get clever. */ class Property { public: /** * @brief Create a new Property with the given name. * * @param name_ */ Property(const std::string& name_) : name(name_){}; virtual ~Property(){}; std::string name; /** * @brief Reserve memory. * * @param capacity Expected number of elements. */ virtual void reserve(size_t capacity) = 0; /** * @brief (ASCII reading) Parse out the next value of this property from a list of tokens. * * @param tokens The list of property tokens for the element. * @param currEntry Index in to tokens, updated after this property is read. */ virtual void parseNext(const std::vector& tokens, size_t& currEntry) = 0; /** * @brief (binary reading) Copy the next value of this property from a stream of bits. * * @param stream Stream to read from. */ virtual void readNext(std::ifstream& stream) = 0; /** * @brief (reading) Write a header entry for this property. * * @param outStream Stream to write to. */ virtual void writeHeader(std::ofstream& outStream) = 0; /** * @brief (ASCII writing) write this property for some element to a stream in plaintext * * @param outStream Stream to write to. * @param iElement index of the element to write. */ virtual void writeDataASCII(std::ofstream& outStream, size_t iElement) = 0; /** * @brief (binary writing) copy the bits of this property for some element to a stream * * @param outStream Stream to write to. * @param iElement index of the element to write. */ virtual void writeDataBinary(std::ofstream& outStream, size_t iElement) = 0; /** * @brief Number of element entries for this property * * @return */ virtual size_t size() = 0; /** * @brief A string naming the type of the property * * @return */ virtual std::string propertyTypeName() = 0; }; /** * @brief A property which takes a single value (not a list). */ template class TypedProperty : public Property { public: /** * @brief Create a new Property with the given name. * * @param name_ */ TypedProperty(const std::string& name_) : Property(name_) { if (typeName() == "unknown") { // TODO should really be a compile-time error throw std::runtime_error("Attempted property type does not match any type defined by the .ply format."); } }; /** * @brief Create a new property and initialize with data. * * @param name_ * @param data_ */ TypedProperty(const std::string& name_, const std::vector& data_) : Property(name_), data(data_) { if (typeName() == "unknown") { throw std::runtime_error("Attempted property type does not match any type defined by the .ply format."); } }; virtual ~TypedProperty() override{}; /** * @brief Reserve memory. * * @param capacity Expected number of elements. */ virtual void reserve(size_t capacity) override { data.reserve(capacity); } /** * @brief (ASCII reading) Parse out the next value of this property from a list of tokens. * * @param tokens The list of property tokens for the element. * @param currEntry Index in to tokens, updated after this property is read. */ virtual void parseNext(const std::vector& tokens, size_t& currEntry) override { data.emplace_back(); std::istringstream iss(tokens[currEntry]); iss >> data.back(); currEntry++; }; /** * @brief (binary reading) Copy the next value of this property from a stream of bits. * * @param stream Stream to read from. */ virtual void readNext(std::ifstream& stream) override { data.emplace_back(); stream.read((char*)&data.back(), sizeof(T)); } /** * @brief (reading) Write a header entry for this property. * * @param outStream Stream to write to. */ virtual void writeHeader(std::ofstream& outStream) override { outStream << "property " << typeName() << " " << name << "\n"; } /** * @brief (ASCII writing) write this property for some element to a stream in plaintext * * @param outStream Stream to write to. * @param iElement index of the element to write. */ virtual void writeDataASCII(std::ofstream& outStream, size_t iElement) override { outStream.precision(std::numeric_limits::max_digits10); outStream << data[iElement]; } /** * @brief (binary writing) copy the bits of this property for some element to a stream * * @param outStream Stream to write to. * @param iElement index of the element to write. */ virtual void writeDataBinary(std::ofstream& outStream, size_t iElement) override { outStream.write((char*)&data[iElement], sizeof(T)); } /** * @brief Number of element entries for this property * * @return */ virtual size_t size() override { return data.size(); } /** * @brief A string naming the type of the property * * @return */ virtual std::string propertyTypeName() override { return typeName(); } /** * @brief The actual data contained in the property */ std::vector data; }; // outstream doesn't do what we want with chars, these specializations supersede the general behavior to ensure chars // get written correctly. template <> inline void TypedProperty::writeDataASCII(std::ofstream& outStream, size_t iElement) { outStream << (int)data[iElement]; } template <> inline void TypedProperty::writeDataASCII(std::ofstream& outStream, size_t iElement) { outStream << (int)data[iElement]; } template <> inline void TypedProperty::parseNext(const std::vector& tokens, size_t& currEntry) { std::istringstream iss(tokens[currEntry]); int intVal; iss >> intVal; data.push_back((uint8_t)intVal); currEntry++; } template <> inline void TypedProperty::parseNext(const std::vector& tokens, size_t& currEntry) { std::istringstream iss(tokens[currEntry]); int intVal; iss >> intVal; data.push_back((int8_t)intVal); currEntry++; } /** * @brief A property which is a list of value (eg, 3 doubles). Note that lists are always variable length per-element. */ template class TypedListProperty : public Property { public: /** * @brief Create a new Property with the given name. * * @param name_ */ TypedListProperty(const std::string& name_, int listCountBytes_) : Property(name_), listCountBytes(listCountBytes_) { if (typeName() == "unknown") { throw std::runtime_error("Attempted property type does not match any type defined by the .ply format."); } }; /** * @brief Create a new property and initialize with data * * @param name_ * @param data_ */ TypedListProperty(const std::string& name_, const std::vector>& data_) : Property(name_), data(data_) { if (typeName() == "unknown") { throw std::runtime_error("Attempted property type does not match any type defined by the .ply format."); } }; virtual ~TypedListProperty() override{}; /** * @brief Reserve memory. * * @param capacity Expected number of elements. */ virtual void reserve(size_t capacity) override { data.reserve(capacity); for (size_t i = 0; i < data.size(); i++) { data[i].reserve(3); // optimize for triangle meshes } } /** * @brief (ASCII reading) Parse out the next value of this property from a list of tokens. * * @param tokens The list of property tokens for the element. * @param currEntry Index in to tokens, updated after this property is read. */ virtual void parseNext(const std::vector& tokens, size_t& currEntry) override { std::istringstream iss(tokens[currEntry]); size_t count; iss >> count; currEntry++; data.emplace_back(); data.back().resize(count); for (size_t iCount = 0; iCount < count; iCount++) { std::istringstream iss(tokens[currEntry]); iss >> data.back()[iCount]; currEntry++; } } /** * @brief (binary reading) Copy the next value of this property from a stream of bits. * * @param stream Stream to read from. */ virtual void readNext(std::ifstream& stream) override { // Read the size of the list size_t count = 0; stream.read(((char*)&count), listCountBytes); // Read list elements data.emplace_back(); data.back().resize(count); stream.read((char*)&data.back().front(), count*sizeof(T)); } /** * @brief (reading) Write a header entry for this property. Note that we already use "uchar" for the list count type. * * @param outStream Stream to write to. */ virtual void writeHeader(std::ofstream& outStream) override { // NOTE: We ALWAYS use uchar as the list count output type outStream << "property list uchar " << typeName() << " " << name << "\n"; } /** * @brief (ASCII writing) write this property for some element to a stream in plaintext * * @param outStream Stream to write to. * @param iElement index of the element to write. */ virtual void writeDataASCII(std::ofstream& outStream, size_t iElement) override { std::vector& elemList = data[iElement]; // Get the number of list elements as a uchar, and ensure the value fits uint8_t count = elemList.size(); if(count != elemList.size()) { throw std::runtime_error("List property has an element with more entries than fit in a uchar. See note in README."); } outStream << elemList.size(); outStream.precision(std::numeric_limits::max_digits10); for (size_t iEntry = 0; iEntry < elemList.size(); iEntry++) { outStream << " " << elemList[iEntry]; } } /** * @brief (binary writing) copy the bits of this property for some element to a stream * * @param outStream Stream to write to. * @param iElement index of the element to write. */ virtual void writeDataBinary(std::ofstream& outStream, size_t iElement) override { std::vector& elemList = data[iElement]; // Get the number of list elements as a uchar, and ensure the value fits uint8_t count = elemList.size(); if(count != elemList.size()) { throw std::runtime_error("List property has an element with more entries than fit in a uchar. See note in README."); } outStream.write((char*)&count, sizeof(uint8_t)); for (size_t iEntry = 0; iEntry < elemList.size(); iEntry++) { outStream.write((char*)&elemList[iEntry], sizeof(T)); } } /** * @brief Number of element entries for this property * * @return */ virtual size_t size() override { return data.size(); } /** * @brief A string naming the type of the property * * @return */ virtual std::string propertyTypeName() override { return typeName(); } /** * @brief The actualy data lists for the property */ std::vector> data; /** * @brief The number of bytes used to store the count for lists of data. */ int listCountBytes = -1; }; // outstream doesn't do what we want with int8_ts, these specializations supersede the general behavior to ensure // int8_ts get written correctly. template <> inline void TypedListProperty::writeDataASCII(std::ofstream& outStream, size_t iElement) { std::vector& elemList = data[iElement]; outStream << elemList.size(); outStream.precision(std::numeric_limits::max_digits10); for (size_t iEntry = 0; iEntry < elemList.size(); iEntry++) { outStream << " " << (int)elemList[iEntry]; } } template <> inline void TypedListProperty::writeDataASCII(std::ofstream& outStream, size_t iElement) { std::vector& elemList = data[iElement]; outStream << elemList.size(); outStream.precision(std::numeric_limits::max_digits10); for (size_t iEntry = 0; iEntry < elemList.size(); iEntry++) { outStream << " " << (int)elemList[iEntry]; } } template <> inline void TypedListProperty::parseNext(const std::vector& tokens, size_t& currEntry) { std::istringstream iss(tokens[currEntry]); size_t count; iss >> count; currEntry++; std::vector thisVec; for (size_t iCount = 0; iCount < count; iCount++) { std::istringstream iss(tokens[currEntry]); int intVal; iss >> intVal; thisVec.push_back((uint8_t)intVal); currEntry++; } data.push_back(thisVec); } template <> inline void TypedListProperty::parseNext(const std::vector& tokens, size_t& currEntry) { std::istringstream iss(tokens[currEntry]); size_t count; iss >> count; currEntry++; std::vector thisVec; for (size_t iCount = 0; iCount < count; iCount++) { std::istringstream iss(tokens[currEntry]); int intVal; iss >> intVal; thisVec.push_back((int8_t)intVal); currEntry++; } data.push_back(thisVec); } /** * @brief Helper function to construct a new property of the appropriate type. * * @param name The name of the property to construct. * @param typeStr A string naming the type according to the format. * @param isList Is this a plain property, or a list property? * @param listCountTypeStr If a list property, the type of the count varible. * * @return A new Property with the proper type. */ inline std::unique_ptr createPropertyWithType(const std::string& name, const std::string& typeStr, bool isList, const std::string& listCountTypeStr) { // == Figure out how many bytes the list count field has, if this is a list type // Note: some files seem to use signed types here, we read the width but always parse as if unsigned int listCountBytes = -1; if (isList) { if (listCountTypeStr == "uchar" || listCountTypeStr == "uint8" || listCountTypeStr == "char" || listCountTypeStr == "int8") { listCountBytes = 1; } else if (listCountTypeStr == "ushort" || listCountTypeStr == "uint16" || listCountTypeStr == "short" || listCountTypeStr == "int16") { listCountBytes = 2; } else if (listCountTypeStr == "uint" || listCountTypeStr == "uint32" || listCountTypeStr == "int" || listCountTypeStr == "int32") { listCountBytes = 4; } else { throw std::runtime_error("Unrecognized list count type: " + listCountTypeStr); } } // = Unsigned int // 8 bit unsigned if (typeStr == "uchar" || typeStr == "uint8") { if (isList) { return std::unique_ptr(new TypedListProperty(name, listCountBytes)); } else { return std::unique_ptr(new TypedProperty(name)); } } // 16 bit unsigned else if (typeStr == "ushort" || typeStr == "uint16") { if (isList) { return std::unique_ptr(new TypedListProperty(name, listCountBytes)); } else { return std::unique_ptr(new TypedProperty(name)); } } // 32 bit unsigned else if (typeStr == "uint" || typeStr == "uint32") { if (isList) { return std::unique_ptr(new TypedListProperty(name, listCountBytes)); } else { return std::unique_ptr(new TypedProperty(name)); } } // = Signed int // 8 bit signed if (typeStr == "char" || typeStr == "int8") { if (isList) { return std::unique_ptr(new TypedListProperty(name, listCountBytes)); } else { return std::unique_ptr(new TypedProperty(name)); } } // 16 bit signed else if (typeStr == "short" || typeStr == "int16") { if (isList) { return std::unique_ptr(new TypedListProperty(name, listCountBytes)); } else { return std::unique_ptr(new TypedProperty(name)); } } // 32 bit signed else if (typeStr == "int" || typeStr == "int32") { if (isList) { return std::unique_ptr(new TypedListProperty(name, listCountBytes)); } else { return std::unique_ptr(new TypedProperty(name)); } } // = Float // 32 bit float else if (typeStr == "float" || typeStr == "float32") { if (isList) { return std::unique_ptr(new TypedListProperty(name, listCountBytes)); } else { return std::unique_ptr(new TypedProperty(name)); } } // 64 bit float else if (typeStr == "double" || typeStr == "float64") { if (isList) { return std::unique_ptr(new TypedListProperty(name, listCountBytes)); } else { return std::unique_ptr(new TypedProperty(name)); } } else { throw std::runtime_error("Data type: " + typeStr + " cannot be mapped to .ply format"); } } /** * @brief An element (more properly an element type) in the .ply object. Tracks the name of the elemnt type (eg, * "vertices"), the number of elements of that type (eg, 1244), and any properties associated with that element (eg, * "position", "color"). */ class Element { public: /** * @brief Create a new element type. * * @param name_ Name of the element type (eg, "vertices") * @param count_ Number of instances of this element. */ Element(const std::string& name_, size_t count_) : name(name_), count(count_) {} std::string name; size_t count; std::vector> properties; /** * @brief Check if a property exists. * * @param target The name of the property to get. * * @return Whether the target property exists. */ bool hasProperty(const std::string& target) { for (std::unique_ptr& prop : properties) { if (prop->name == target) { return true; } } return false; } /** * @brief Low-level method to get a pointer to a property. Users probably don't need to call this. * * @param target The name of the property to get. * * @return A (unique_ptr) pointer to the property. */ std::unique_ptr& getPropertyPtr(const std::string& target) { for (std::unique_ptr& prop : properties) { if (prop->name == target) { return prop; } } throw std::runtime_error("PLY parser: element " + name + " does not have property " + target); } /** * @brief Add a new (plain, not list) property for this element type. * * @tparam T The type of the property * @param propertyName The name of the property * @param data The data for the property. Must have the same length as the number of elements. */ template void addProperty(const std::string& propertyName, const std::vector& data) { if (data.size() != count) { throw std::runtime_error("PLY write: new property " + propertyName + " has size which does not match element"); } // If there is already some property with this name, remove it for (size_t i = 0; i < properties.size(); i++) { if (properties[i]->name == propertyName) { properties.erase(properties.begin() + i); i--; } } // Copy to canonical type. Often a no-op, but takes care of standardizing widths across platforms. std::vector::type> canonicalVec(data.begin(), data.end()); properties.push_back( std::unique_ptr(new TypedProperty::type>(propertyName, canonicalVec))); } /** * @brief Add a new list property for this element type. * * @tparam T The type of the property (eg, "double" for a list of doubles) * @param propertyName The name of the property * @param data The data for the property. Outer vector must have the same length as the number of elements. */ template void addListProperty(const std::string& propertyName, const std::vector>& data) { if (data.size() != count) { throw std::runtime_error("PLY write: new property " + propertyName + " has size which does not match element"); } // If there is already some property with this name, remove it for (size_t i = 0; i < properties.size(); i++) { if (properties[i]->name == propertyName) { properties.erase(properties.begin() + i); i--; } } // Copy to canonical type. Often a no-op, but takes care of standardizing widths across platforms. std::vector::type>> canonicalListVec; for (const std::vector& subList : data) { canonicalListVec.emplace_back(subList.begin(), subList.end()); } properties.push_back(std::unique_ptr( new TypedListProperty::type>(propertyName, canonicalListVec))); } /** * @brief Get a vector of a data from a property for this element. Automatically promotes to larger types. Throws if * requested data is unavailable. * * @tparam T The type of data requested * @param propertyName The name of the property to get. * * @return The data. */ template std::vector getProperty(const std::string& propertyName) { // Find the property std::unique_ptr& prop = getPropertyPtr(propertyName); // Get a copy of the data with auto-promoting type magic return getDataFromPropertyRecursive(prop.get()); } /** * @brief Get a vector of lists of data from a property for this element. Automatically promotes to larger types. * Throws if requested data is unavailable. * * @tparam T The type of data requested * @param propertyName The name of the property to get. * * @return The data. */ template std::vector> getListProperty(const std::string& propertyName) { // Find the property std::unique_ptr& prop = getPropertyPtr(propertyName); // Get a copy of the data with auto-promoting type magic return getDataFromListPropertyRecursive(prop.get()); } /** * @brief Get a vector of lists of data from a property for this element. Automatically promotes to larger types. * Unlike getListProperty(), this method will additionally convert between types of different sign (eg, requesting and * int32 would get data from a uint32); doing so naively converts between signed and unsigned types. This is typically * useful for data representing indices, which might be stored as signed or unsigned numbers. * * @tparam T The type of data requested * @param propertyName The name of the property to get. * * @return The data. */ template std::vector> getListPropertyAnySign(const std::string& propertyName) { // Find the property std::unique_ptr& prop = getPropertyPtr(propertyName); // Get a copy of the data with auto-promoting type magic try { // First, try the usual approach, looking for a version of the property with the same signed-ness and possibly // smaller size return getDataFromListPropertyRecursive(prop.get()); } catch (std::runtime_error orig_e) { // If the usual approach fails, look for a version with opposite signed-ness try { // This type has the oppopsite signeness as the input type typedef typename CanonicalName::type Tcan; typedef typename std::conditional::value, typename std::make_unsigned::type, typename std::make_signed::type>::type OppsignType; std::vector> oppSignedResult = getListProperty(propertyName); // Very explicitly convert while copying std::vector> origSignResult; for (std::vector& l : oppSignedResult) { std::vector newL; for (OppsignType& v : l) { newL.push_back(static_cast(v)); } origSignResult.push_back(newL); } return origSignResult; } catch (std::runtime_error new_e) { throw orig_e; } throw orig_e; } } /** * @brief Performs sanity checks on the element, throwing if any fail. */ void validate() { // Make sure no properties have duplicate names, and no names have whitespace for (size_t iP = 0; iP < properties.size(); iP++) { for (char c : properties[iP]->name) { if (std::isspace(c)) { throw std::runtime_error("Ply validate: illegal whitespace in name " + properties[iP]->name); } } for (size_t jP = iP + 1; jP < properties.size(); jP++) { if (properties[iP]->name == properties[jP]->name) { throw std::runtime_error("Ply validate: multiple properties with name " + properties[iP]->name); } } } // Make sure all properties have right length for (size_t iP = 0; iP < properties.size(); iP++) { if (properties[iP]->size() != count) { throw std::runtime_error("Ply validate: property has wrong size. " + properties[iP]->name + " does not match element size."); } } } /** * @brief Writes out this element's information to the file header. * * @param outStream The stream to use. */ void writeHeader(std::ofstream& outStream) { outStream << "element " << name << " " << count << "\n"; for (std::unique_ptr& p : properties) { p->writeHeader(outStream); } } /** * @brief (ASCII writing) Writes out all of the data for every element of this element type to the stream, including * all contained properties. * * @param outStream The stream to write to. */ void writeDataASCII(std::ofstream& outStream) { // Question: what is the proper output for an element with no properties? Here, we write a blank line, so there is // one line per element no matter what. for (size_t iE = 0; iE < count; iE++) { for (size_t iP = 0; iP < properties.size(); iP++) { properties[iP]->writeDataASCII(outStream, iE); if (iP < properties.size() - 1) { outStream << " "; } } outStream << "\n"; } } /** * @brief (binary writing) Writes out all of the data for every element of this element type to the stream, including * all contained properties. * * @param outStream The stream to write to. */ void writeDataBinary(std::ofstream& outStream) { for (size_t iE = 0; iE < count; iE++) { for (size_t iP = 0; iP < properties.size(); iP++) { properties[iP]->writeDataBinary(outStream, iE); } } } /** * @brief Helper function which does the hard work to implement type promotion for data getters. Throws if type * conversion fails. * * @tparam D The desired output type * @tparam T The current attempt for the actual type of the property * @param prop The property to get (does not delete nor share pointer) * * @return The data, with the requested type */ template std::vector getDataFromPropertyRecursive(Property* prop) { typedef typename CanonicalName::type Tcan; { // Try to return data of type D from a property of type T TypedProperty* castedProp = dynamic_cast*>(prop); if (castedProp) { // Succeeded, return a buffer of the data (copy while converting type) std::vector castedVec; for (Tcan& v : castedProp->data) { castedVec.push_back(static_cast(v)); } return castedVec; } } TypeChain chainType; if (chainType.hasChildType) { return getDataFromPropertyRecursive::type>(prop); } else { // No smaller type to try, failure throw std::runtime_error("PLY parser: property " + prop->name + " cannot be coerced to requested type " + typeName() + ". Has type " + prop->propertyTypeName()); } } /** * @brief Helper function which does the hard work to implement type promotion for list data getters. Throws if type * conversion fails. * * @tparam D The desired output type * @tparam T The current attempt for the actual type of the property * @param prop The property to get (does not delete nor share pointer) * * @return The data, with the requested type */ template std::vector> getDataFromListPropertyRecursive(Property* prop) { typedef typename CanonicalName::type Tcan; TypedListProperty* castedProp = dynamic_cast*>(prop); if (castedProp) { // Succeeded, return a buffer of the data (copy while converting type) std::vector> castedListVec; for (std::vector& l : castedProp->data) { std::vector newL; for (Tcan& v : l) { newL.push_back(static_cast(v)); } castedListVec.push_back(newL); } return castedListVec; } TypeChain chainType; if (chainType.hasChildType) { return getDataFromListPropertyRecursive::type>(prop); } else { // No smaller type to try, failure throw std::runtime_error("PLY parser: list property " + prop->name + " cannot be coerced to requested type list " + typeName() + ". Has type list " + prop->propertyTypeName()); } } }; // Some string helpers namespace { inline std::string trimSpaces(const std::string& input) { size_t start = 0; while (start < input.size() && input[start] == ' ') start++; size_t end = input.size(); while (end > start && (input[end - 1] == ' ' || input[end - 1] == '\n' || input[end - 1] == '\r')) end--; return input.substr(start, end - start); } inline std::vector tokenSplit(const std::string& input) { std::vector result; size_t curr = 0; size_t found = 0; while ((found = input.find_first_of(' ', curr)) != std::string::npos) { std::string token = input.substr(curr, found - curr); token = trimSpaces(token); if (token.size() > 0) { result.push_back(token); } curr = found + 1; } std::string token = input.substr(curr); token = trimSpaces(token); if (token.size() > 0) { result.push_back(token); } return result; } inline bool startsWith(const std::string& input, const std::string& query) { return input.compare(0, query.length(), query) == 0; } }; // namespace /** * @brief Primary class; represents a set of data in the .ply format. */ class PLYData { public: /** * @brief Create an empty PLYData object. */ PLYData(){}; /** * @brief Initialize a PLYData by reading from a file. Throws if any failures occur. * * @param filename The file to read from. * @param verbose If true, print useful info about the file to stdout */ PLYData(const std::string& filename, bool verbose = false) { using std::cout; using std::endl; using std::string; using std::vector; if (verbose) cout << "PLY parser: Reading ply file: " << filename << endl; // Open a file in binary always, in case it turns out to have binary data. std::ifstream inStream(filename, std::ios::binary); if (inStream.fail()) { throw std::runtime_error("PLY parser: Could not open file " + filename); } // == Process the header parseHeader(inStream, verbose); // === Parse data from a binary file if (inputDataFormat == DataFormat::Binary) { parseBinary(inStream, verbose); } // === Parse data from an ASCII file else if (inputDataFormat == DataFormat::ASCII) { parseASCII(inStream, verbose); } if (verbose) { cout << " - Finished parsing file." << endl; } } /** * @brief Perform sanity checks on the file, throwing if any fail. */ void validate() { for (size_t iE = 0; iE < elements.size(); iE++) { for (char c : elements[iE].name) { if (std::isspace(c)) { throw std::runtime_error("Ply validate: illegal whitespace in element name " + elements[iE].name); } } for (size_t jE = iE + 1; jE < elements.size(); jE++) { if (elements[iE].name == elements[jE].name) { throw std::runtime_error("Ply validate: duplcate element name " + elements[iE].name); } } } // Do a quick validation sanity check for (Element& e : elements) { e.validate(); } } /** * @brief Write this data to a .ply file. * * @param filename The file to write to. * @param format The format to use (binary or ascii?) */ void write(const std::string& filename, DataFormat format = DataFormat::ASCII) { outputDataFormat = format; validate(); // Open stream for writing std::ofstream outStream(filename, std::ios::out | std::ios::binary); if (!outStream.good()) { throw std::runtime_error("Ply writer: Could not open output file " + filename + " for writing"); } writeHeader(outStream); // Write all elements for (Element& e : elements) { if (outputDataFormat == DataFormat::Binary) { e.writeDataBinary(outStream); } else if (outputDataFormat == DataFormat::ASCII) { e.writeDataASCII(outStream); } } } /** * @brief Get an element type by name ("vertices") * * @param target The name of the element type to get * * @return A reference to the element type. */ Element& getElement(const std::string& target) { for (Element& e : elements) { if (e.name == target) return e; } throw std::runtime_error("PLY parser: no element with name: " + target); } /** * @brief Check if an element type exists * * @param target The name to check for. * * @return True if exists. */ bool hasElement(const std::string& target) { for (Element& e : elements) { if (e.name == target) return true; } return false; } /** * @brief Add a new element type to the object * * @param name The name of the new element type ("vertices"). * @param count The number of elements of this type. */ void addElement(const std::string& name, size_t count) { elements.emplace_back(name, count); } // === Common-case helpers /** * @brief Common-case helper get mesh vertex positions * * @param vertexElementName The element name to use (default: "vertex") * * @return A vector of vertex positions. */ std::vector> getVertexPositions(const std::string& vertexElementName = "vertex") { std::vector xPos = getElement(vertexElementName).getProperty("x"); std::vector yPos = getElement(vertexElementName).getProperty("y"); std::vector zPos = getElement(vertexElementName).getProperty("z"); std::vector> result(xPos.size()); for (size_t i = 0; i < result.size(); i++) { result[i][0] = xPos[i]; result[i][1] = yPos[i]; result[i][2] = zPos[i]; } return result; } /** * @brief Common-case helper get mesh vertex colors * * @param vertexElementName The element name to use (default: "vertex") * * @return A vector of vertex colors (unsigned chars [0,255]). */ std::vector> getVertexColors(const std::string& vertexElementName = "vertex") { std::vector r = getElement(vertexElementName).getProperty("red"); std::vector g = getElement(vertexElementName).getProperty("green"); std::vector b = getElement(vertexElementName).getProperty("blue"); std::vector> result(r.size()); for (size_t i = 0; i < result.size(); i++) { result[i][0] = r[i]; result[i][1] = g[i]; result[i][2] = b[i]; } return result; } /** * @brief Common-case helper to get face indices for a mesh. If not template type is given, size_t is used. Naively * converts to requested signedness, which may lead to unexpected values if an unsigned type is used and file contains * negative values. * * @return The indices into the vertex elements for each face. Usually 0-based, though there are no formal rules. */ template std::vector> getFaceIndices() { for (const std::string& f : std::vector{"face"}) { for (const std::string& p : std::vector{"vertex_indices", "vertex_index"}) { try { return getElement(f).getListPropertyAnySign(p); } catch (std::runtime_error e) { // that's fine } } } throw std::runtime_error("PLY parser: could not find face vertex indices attribute under any common name."); } /** * @brief Common-case helper set mesh vertex positons. Creates vertex element, if necessary. * * @param vertexPositions A vector of vertex positions */ void addVertexPositions(std::vector>& vertexPositions) { std::string vertexName = "vertex"; size_t N = vertexPositions.size(); // Create the element if (!hasElement(vertexName)) { addElement(vertexName, N); } // De-interleave std::vector xPos(N); std::vector yPos(N); std::vector zPos(N); for (size_t i = 0; i < vertexPositions.size(); i++) { xPos[i] = vertexPositions[i][0]; yPos[i] = vertexPositions[i][1]; zPos[i] = vertexPositions[i][2]; } // Store getElement(vertexName).addProperty("x", xPos); getElement(vertexName).addProperty("y", yPos); getElement(vertexName).addProperty("z", zPos); } /** * @brief Common-case helper set mesh vertex colors. Creates a vertex element, if necessary. * * @param colors A vector of vertex colors (unsigned chars [0,255]). */ void addVertexColors(std::vector>& colors) { std::string vertexName = "vertex"; size_t N = colors.size(); // Create the element if (!hasElement(vertexName)) { addElement(vertexName, N); } // De-interleave std::vector r(N); std::vector g(N); std::vector b(N); for (size_t i = 0; i < colors.size(); i++) { r[i] = colors[i][0]; g[i] = colors[i][1]; b[i] = colors[i][2]; } // Store getElement(vertexName).addProperty("red", r); getElement(vertexName).addProperty("green", g); getElement(vertexName).addProperty("blue", b); } /** * @brief Common-case helper set mesh vertex colors. Creates a vertex element, if necessary. * * @param colors A vector of vertex colors as floating point [0,1] values. Internally converted to [0,255] chars. */ void addVertexColors(std::vector>& colors) { std::string vertexName = "vertex"; size_t N = colors.size(); // Create the element if (!hasElement(vertexName)) { addElement(vertexName, N); } auto toChar = [](double v) { if (v < 0.0) v = 0.0; if (v > 1.0) v = 1.0; return static_cast(v * 255.); }; // De-interleave std::vector r(N); std::vector g(N); std::vector b(N); for (size_t i = 0; i < colors.size(); i++) { r[i] = toChar(colors[i][0]); g[i] = toChar(colors[i][1]); b[i] = toChar(colors[i][2]); } // Store getElement(vertexName).addProperty("red", r); getElement(vertexName).addProperty("green", g); getElement(vertexName).addProperty("blue", b); } /** * @brief Common-case helper to set face indices. Creates a face element if needed. The input type will be casted to a * 32 bit integer of the same signedness. * * @param indices The indices into the vertex list around each face. */ template void addFaceIndices(std::vector>& indices) { std::string faceName = "face"; size_t N = indices.size(); // Create the element if (!hasElement(faceName)) { addElement(faceName, N); } // Cast to 32 bit typedef typename std::conditional::value, int32_t, uint32_t>::type IndType; std::vector> intInds; for (std::vector& l : indices) { std::vector thisInds; for (T& val : l) { IndType valConverted = static_cast(val); if (valConverted != val) { throw std::runtime_error("Index value " + std::to_string(val) + " could not be converted to a .ply integer without loss of data. Note that .ply " "only supports 32-bit ints."); } thisInds.push_back(valConverted); } intInds.push_back(thisInds); } // Store getElement(faceName).addListProperty("vertex_indices", intInds); } /** * @brief Comments for the file. When writing, each entry will be written as a sequential comment line. */ std::vector comments; private: std::vector elements; const int majorVersion = 1; // I'll buy you a drink if these ever get bumped const int minorVersion = 0; DataFormat inputDataFormat = DataFormat::ASCII; // set when reading from a file DataFormat outputDataFormat = DataFormat::ASCII; // option for writing files // === Reading === /** * @brief Read the header for a file * * @param inStream * @param verbose */ void parseHeader(std::ifstream& inStream, bool verbose) { using std::cout; using std::endl; using std::string; using std::vector; // First two lines are predetermined { // First line is magic constant string plyLine; std::getline(inStream, plyLine); if (trimSpaces(plyLine) != "ply") { throw std::runtime_error("PLY parser: File does not appear to be ply file. First line should be 'ply'"); } } { // second line is version string styleLine; std::getline(inStream, styleLine); vector tokens = tokenSplit(styleLine); if (tokens.size() != 3) throw std::runtime_error("PLY parser: bad format line"); std::string formatStr = tokens[0]; std::string typeStr = tokens[1]; std::string versionStr = tokens[2]; // "format" if (formatStr != "format") throw std::runtime_error("PLY parser: bad format line"); // ascii/binary if (typeStr == "ascii") { inputDataFormat = DataFormat::ASCII; if (verbose) cout << " - Type: ascii" << endl; } else if (typeStr == "binary_little_endian") { inputDataFormat = DataFormat::Binary; if (verbose) cout << " - Type: binary" << endl; } else if (typeStr == "binary_big_endian") { throw std::runtime_error("PLY parser: encountered scary big endian file. Don't know how to parse that"); } else { throw std::runtime_error("PLY parser: bad format line"); } // version if (versionStr != "1.0") { throw std::runtime_error("PLY parser: encountered file with version != 1.0. Don't know how to parse that"); } if (verbose) cout << " - Version: " << versionStr << endl; } // Consume header line by line while (inStream.good()) { string line; std::getline(inStream, line); // Parse a comment if (startsWith(line, "comment")) { string comment = line.substr(7); if (verbose) cout << " - Comment: " << comment << endl; comments.push_back(comment); continue; } // Parse an element else if (startsWith(line, "element")) { vector tokens = tokenSplit(line); if (tokens.size() != 3) throw std::runtime_error("PLY parser: Invalid element line"); string name = tokens[1]; size_t count; std::istringstream iss(tokens[2]); iss >> count; elements.emplace_back(name, count); if (verbose) cout << " - Found element: " << name << " (count = " << count << ")" << endl; continue; } // Parse a property list else if (startsWith(line, "property list")) { vector tokens = tokenSplit(line); if (tokens.size() != 5) throw std::runtime_error("PLY parser: Invalid property list line"); if (elements.size() == 0) throw std::runtime_error("PLY parser: Found property list without previous element"); string countType = tokens[2]; string type = tokens[3]; string name = tokens[4]; elements.back().properties.push_back(createPropertyWithType(name, type, true, countType)); if (verbose) cout << " - Found list property: " << name << " (count type = " << countType << ", data type = " << type << ")" << endl; continue; } // Parse a property else if (startsWith(line, "property")) { vector tokens = tokenSplit(line); if (tokens.size() != 3) throw std::runtime_error("PLY parser: Invalid property line"); if (elements.size() == 0) throw std::runtime_error("PLY parser: Found property without previous element"); string type = tokens[1]; string name = tokens[2]; elements.back().properties.push_back(createPropertyWithType(name, type, false, "")); if (verbose) cout << " - Found property: " << name << " (type = " << type << ")" << endl; continue; } // Parse end of header else if (startsWith(line, "end_header")) { break; } // Error! else { throw std::runtime_error("Unrecognized header line: " + line); } } } /** * @brief Read the actual data for a file, in ASCII * * @param inStream * @param verbose */ void parseASCII(std::ifstream& inStream, bool verbose) { using std::string; using std::vector; // Read all elements for (Element& elem : elements) { if (verbose) { std::cout << " - Processing element: " << elem.name << std::endl; } for (size_t iP = 0; iP < elem.properties.size(); iP++) { elem.properties[iP]->reserve(elem.count); } for (size_t iEntry = 0; iEntry < elem.count; iEntry++) { string line; std::getline(inStream, line); vector tokens = tokenSplit(line); size_t iTok = 0; for (size_t iP = 0; iP < elem.properties.size(); iP++) { elem.properties[iP]->parseNext(tokens, iTok); } } } } /** * @brief Read the actual data for a file, in binary. * * @param inStream * @param verbose */ void parseBinary(std::ifstream& inStream, bool verbose) { using std::string; using std::vector; // Read all elements for (Element& elem : elements) { if (verbose) { std::cout << " - Processing element: " << elem.name << std::endl; } for (size_t iP = 0; iP < elem.properties.size(); iP++) { elem.properties[iP]->reserve(elem.count); } for (size_t iEntry = 0; iEntry < elem.count; iEntry++) { for (size_t iP = 0; iP < elem.properties.size(); iP++) { elem.properties[iP]->readNext(inStream); } } } } // === Writing === /** * @brief Write out a header for a file * * @param outStream */ void writeHeader(std::ofstream& outStream) { // Magic line outStream << "ply\n"; // Type line outStream << "format "; if (outputDataFormat == DataFormat::Binary) { outStream << "binary_little_endian "; } else if (outputDataFormat == DataFormat::ASCII) { outStream << "ascii "; } // Version number outStream << majorVersion << "." << minorVersion << "\n"; // Write comments for (const std::string& comment : comments) { outStream << "comment " << comment << "\n"; } outStream << "comment " << "Written with hapPLY (https://github.com/nmwsharp/happly)" << "\n"; // Write elements (and their properties) for (Element& e : elements) { e.writeHeader(outStream); } // End header outStream << "end_header\n"; } }; } // namespace happly goxel-0.11.0/ext_src/yocto/ext/stb_image.h000077500000000000000000010021361435762723100204360ustar00rootroot00000000000000/* stb_image - v2.22 - public domain image loader - http://nothings.org/stb no warranty implied; use at your own risk Do this: #define STB_IMAGE_IMPLEMENTATION before you include this file in *one* C or C++ file to create the implementation. // i.e. it should look like this: #include ... #include ... #include ... #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free QUICK NOTES: Primarily of interest to game developers and other people who can avoid problematic images and only need the trivial interface JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) PNG 1/2/4/8/16-bit-per-channel TGA (not sure what subset, if a subset) BMP non-1bpp, non-RLE PSD (composited view only, no extra channels, 8/16 bit-per-channel) GIF (*comp always reports as 4-channel) HDR (radiance rgbE format) PIC (Softimage PIC) PNM (PPM and PGM binary only) Animated GIF still needs a proper API, but here's one way to do it: http://gist.github.com/urraka/685d9a6340b26b830d49 - decode from memory or through FILE (define STBI_NO_STDIO to remove code) - decode from arbitrary I/O callbacks - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON) Full documentation under "DOCUMENTATION" below. LICENSE See end of file for license information. RECENT REVISION HISTORY: 2.22 (2019-03-04) gif fixes, fix warnings 2.21 (2019-02-25) fix typo in comment 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs 2.19 (2018-02-11) fix warning 2.18 (2018-01-30) fix warnings 2.17 (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings 2.16 (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes 2.15 (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs 2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; fixes 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes 2.11 (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64 RGB-format JPEG; remove white matting in PSD; allocate large structures on the stack; correct channel count for PNG & BMP 2.10 (2016-01-22) avoid warning introduced in 2.09 2.09 (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED See end of file for full revision history. ============================ Contributors ========================= Image formats Extensions, features Sean Barrett (jpeg, png, bmp) Jetro Lauha (stbi_info) Nicolas Schulz (hdr, psd) Martin "SpartanJ" Golini (stbi_info) Jonathan Dummer (tga) James "moose2000" Brown (iPhone PNG) Jean-Marc Lienher (gif) Ben "Disch" Wenger (io callbacks) Tom Seddon (pic) Omar Cornut (1/2/4-bit PNG) Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) github:urraka (animated gif) Junggon Kim (PNM comments) Christopher Forseth (animated gif) Daniel Gibson (16-bit TGA) socks-the-fox (16-bit PNG) Jeremy Sawicki (handle all ImageNet JPGs) Optimizations & bugfixes Mikhail Morozov (1-bit BMP) Fabian "ryg" Giesen Anael Seghezzi (is-16-bit query) Arseny Kapoulkine John-Mark Allen Carmelo J Fdez-Aguera Bug & warning fixes Marc LeBlanc David Woo Guillaume George Martins Mozeiko Christpher Lloyd Jerry Jansson Joseph Thomson Phil Jordan Dave Moore Roy Eltham Hayaki Saito Nathan Reed Won Chun Luke Graham Johan Duparc Nick Verigakis the Horde3D community Thomas Ruf Ronny Chevalier github:rlyeh Janez Zemva John Bartholomew Michal Cichon github:romigrou Jonathan Blow Ken Hamada Tero Hanninen github:svdijk Laurent Gomila Cort Stratton Sergio Gonzalez github:snagar Aruelien Pocheville Thibault Reuille Cass Everitt github:Zelex Ryamond Barbiero Paul Du Bois Engin Manap github:grim210 Aldo Culquicondor Philipp Wiesemann Dale Weiler github:sammyhw Oriol Ferrer Mesia Josh Tobin Matthew Gregan github:phprus Julian Raschke Gregory Mullen Baldur Karlsson github:poppolopoppo Christian Floisand Kevin Schmidt JR Smith github:darealshinji Blazej Dariusz Roszkowski github:Michaelangel007 */ #ifndef STBI_INCLUDE_STB_IMAGE_H #define STBI_INCLUDE_STB_IMAGE_H // DOCUMENTATION // // Limitations: // - no 12-bit-per-channel JPEG // - no JPEGs with arithmetic coding // - GIF always returns *comp=4 // // Basic usage (see HDR discussion below for HDR usage): // int x,y,n; // unsigned char *data = stbi_load(filename, &x, &y, &n, 0); // // ... process data if not NULL ... // // ... x = width, y = height, n = # 8-bit components per pixel ... // // ... replace '0' with '1'..'4' to force that many components per pixel // // ... but 'n' will always be the number that it would have been if you said 0 // stbi_image_free(data) // // Standard parameters: // int *x -- outputs image width in pixels // int *y -- outputs image height in pixels // int *channels_in_file -- outputs # of image components in image file // int desired_channels -- if non-zero, # of image components requested in result // // The return value from an image loader is an 'unsigned char *' which points // to the pixel data, or NULL on an allocation failure or if the image is // corrupt or invalid. The pixel data consists of *y scanlines of *x pixels, // with each pixel consisting of N interleaved 8-bit components; the first // pixel pointed to is top-left-most in the image. There is no padding between // image scanlines or between pixels, regardless of format. The number of // components N is 'desired_channels' if desired_channels is non-zero, or // *channels_in_file otherwise. If desired_channels is non-zero, // *channels_in_file has the number of components that _would_ have been // output otherwise. E.g. if you set desired_channels to 4, you will always // get RGBA output, but you can check *channels_in_file to see if it's trivially // opaque because e.g. there were only 3 channels in the source image. // // An output image with N components has the following components interleaved // in this order in each pixel: // // N=#comp components // 1 grey // 2 grey, alpha // 3 red, green, blue // 4 red, green, blue, alpha // // If image loading fails for any reason, the return value will be NULL, // and *x, *y, *channels_in_file will be unchanged. The function // stbi_failure_reason() can be queried for an extremely brief, end-user // unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS // to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly // more user-friendly ones. // // Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. // // =========================================================================== // // UNICODE: // // If compiling for Windows and you wish to use Unicode filenames, compile // with // #define STBI_WINDOWS_UTF8 // and pass utf8-encoded filenames. Call stbi_convert_wchar_to_utf8 to convert // Windows wchar_t filenames to utf8. // // =========================================================================== // // Philosophy // // stb libraries are designed with the following priorities: // // 1. easy to use // 2. easy to maintain // 3. good performance // // Sometimes I let "good performance" creep up in priority over "easy to maintain", // and for best performance I may provide less-easy-to-use APIs that give higher // performance, in addition to the easy-to-use ones. Nevertheless, it's important // to keep in mind that from the standpoint of you, a client of this library, // all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all. // // Some secondary priorities arise directly from the first two, some of which // provide more explicit reasons why performance can't be emphasized. // // - Portable ("ease of use") // - Small source code footprint ("easy to maintain") // - No dependencies ("ease of use") // // =========================================================================== // // I/O callbacks // // I/O callbacks allow you to read from arbitrary sources, like packaged // files or some other source. Data read from callbacks are processed // through a small internal buffer (currently 128 bytes) to try to reduce // overhead. // // The three functions you must define are "read" (reads some bytes of data), // "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). // // =========================================================================== // // SIMD support // // The JPEG decoder will try to automatically use SIMD kernels on x86 when // supported by the compiler. For ARM Neon support, you must explicitly // request it. // // (The old do-it-yourself SIMD API is no longer supported in the current // code.) // // On x86, SSE2 will automatically be used when available based on a run-time // test; if not, the generic C versions are used as a fall-back. On ARM targets, // the typical path is to have separate builds for NEON and non-NEON devices // (at least this is true for iOS and Android). Therefore, the NEON support is // toggled by a build flag: define STBI_NEON to get NEON loops. // // If for some reason you do not want to use any of SIMD code, or if // you have issues compiling it, you can disable it entirely by // defining STBI_NO_SIMD. // // =========================================================================== // // HDR image support (disable by defining STBI_NO_HDR) // // stb_image supports loading HDR images in general, and currently the Radiance // .HDR file format specifically. You can still load any file through the existing // interface; if you attempt to load an HDR file, it will be automatically remapped // to LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; // both of these constants can be reconfigured through this interface: // // stbi_hdr_to_ldr_gamma(2.2f); // stbi_hdr_to_ldr_scale(1.0f); // // (note, do not use _inverse_ constants; stbi_image will invert them // appropriately). // // Additionally, there is a new, parallel interface for loading files as // (linear) floats to preserve the full dynamic range: // // float *data = stbi_loadf(filename, &x, &y, &n, 0); // // If you load LDR images through this interface, those images will // be promoted to floating point values, run through the inverse of // constants corresponding to the above: // // stbi_ldr_to_hdr_scale(1.0f); // stbi_ldr_to_hdr_gamma(2.2f); // // Finally, given a filename (or an open file or memory block--see header // file for details) containing image data, you can query for the "most // appropriate" interface to use (that is, whether the image is HDR or // not), using: // // stbi_is_hdr(char *filename); // // =========================================================================== // // iPhone PNG support: // // By default we convert iphone-formatted PNGs back to RGB, even though // they are internally encoded differently. You can disable this conversion // by calling stbi_convert_iphone_png_to_rgb(0), in which case // you will always just get the native iphone "format" through (which // is BGR stored in RGB). // // Call stbi_set_unpremultiply_on_load(1) as well to force a divide per // pixel to remove any premultiplied alpha *only* if the image file explicitly // says there's premultiplied data (currently only happens in iPhone images, // and only if iPhone convert-to-rgb processing is on). // // =========================================================================== // // ADDITIONAL CONFIGURATION // // - You can suppress implementation of any of the decoders to reduce // your code footprint by #defining one or more of the following // symbols before creating the implementation. // // STBI_NO_JPEG // STBI_NO_PNG // STBI_NO_BMP // STBI_NO_PSD // STBI_NO_TGA // STBI_NO_GIF // STBI_NO_HDR // STBI_NO_PIC // STBI_NO_PNM (.ppm and .pgm) // // - You can request *only* certain decoders and suppress all other ones // (this will be more forward-compatible, as addition of new decoders // doesn't require you to disable them explicitly): // // STBI_ONLY_JPEG // STBI_ONLY_PNG // STBI_ONLY_BMP // STBI_ONLY_PSD // STBI_ONLY_TGA // STBI_ONLY_GIF // STBI_ONLY_HDR // STBI_ONLY_PIC // STBI_ONLY_PNM (.ppm and .pgm) // // - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still // want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB // #ifndef STBI_NO_STDIO #include #endif // STBI_NO_STDIO #define STBI_VERSION 1 enum { STBI_default = 0, // only used for desired_channels STBI_grey = 1, STBI_grey_alpha = 2, STBI_rgb = 3, STBI_rgb_alpha = 4 }; #include typedef unsigned char stbi_uc; typedef unsigned short stbi_us; #ifdef __cplusplus extern "C" { #endif #ifndef STBIDEF #ifdef STB_IMAGE_STATIC #define STBIDEF static #else #define STBIDEF extern #endif #endif ////////////////////////////////////////////////////////////////////////////// // // PRIMARY API - works on images of any type // // // load image by filename, open file, or memory buffer // typedef struct { int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative int (*eof) (void *user); // returns nonzero if we are at end of file/data } stbi_io_callbacks; //////////////////////////////////// // // 8-bits-per-channel interface // STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len , int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); // for stbi_load_from_file, file pointer is left pointing immediately after image #endif #ifndef STBI_NO_GIF STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp); #endif #ifdef STBI_WINDOWS_UTF8 STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); #endif //////////////////////////////////// // // 16-bits-per-channel interface // STBIDEF stbi_us *stbi_load_16_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF stbi_us *stbi_load_16 (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); #endif //////////////////////////////////// // // float-per-channel interface // #ifndef STBI_NO_LINEAR STBIDEF float *stbi_loadf_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF float *stbi_loadf (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); #endif #endif #ifndef STBI_NO_HDR STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); STBIDEF void stbi_hdr_to_ldr_scale(float scale); #endif // STBI_NO_HDR #ifndef STBI_NO_LINEAR STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); STBIDEF void stbi_ldr_to_hdr_scale(float scale); #endif // STBI_NO_LINEAR // stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); #ifndef STBI_NO_STDIO STBIDEF int stbi_is_hdr (char const *filename); STBIDEF int stbi_is_hdr_from_file(FILE *f); #endif // STBI_NO_STDIO // get a VERY brief reason for failure // NOT THREADSAFE STBIDEF const char *stbi_failure_reason (void); // free the loaded image -- this is just free() STBIDEF void stbi_image_free (void *retval_from_stbi_load); // get image dimensions & components without fully decoding STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len); STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user); #ifndef STBI_NO_STDIO STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp); STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); STBIDEF int stbi_is_16_bit (char const *filename); STBIDEF int stbi_is_16_bit_from_file(FILE *f); #endif // for image formats that explicitly notate that they have premultiplied alpha, // we just return the colors as stored in the file. set this flag to force // unpremultiplication. results are undefined if the unpremultiply overflow. STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); // indicate whether we should process iphone images back to canonical format, // or just pass them through "as-is" STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); // flip the image vertically, so the first pixel in the output array is the bottom left STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); // ZLIB client - used by PNG, available for other purposes STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); #ifdef __cplusplus } #endif // // //// end header file ///////////////////////////////////////////////////// #endif // STBI_INCLUDE_STB_IMAGE_H #ifdef STB_IMAGE_IMPLEMENTATION #if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \ || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \ || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \ || defined(STBI_ONLY_ZLIB) #ifndef STBI_ONLY_JPEG #define STBI_NO_JPEG #endif #ifndef STBI_ONLY_PNG #define STBI_NO_PNG #endif #ifndef STBI_ONLY_BMP #define STBI_NO_BMP #endif #ifndef STBI_ONLY_PSD #define STBI_NO_PSD #endif #ifndef STBI_ONLY_TGA #define STBI_NO_TGA #endif #ifndef STBI_ONLY_GIF #define STBI_NO_GIF #endif #ifndef STBI_ONLY_HDR #define STBI_NO_HDR #endif #ifndef STBI_ONLY_PIC #define STBI_NO_PIC #endif #ifndef STBI_ONLY_PNM #define STBI_NO_PNM #endif #endif #if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) #define STBI_NO_ZLIB #endif #include #include // ptrdiff_t on osx #include #include #include #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) #include // ldexp, pow #endif #ifndef STBI_NO_STDIO #include #endif #ifndef STBI_ASSERT #include #define STBI_ASSERT(x) assert(x) #endif #ifdef __cplusplus #define STBI_EXTERN extern "C" #else #define STBI_EXTERN extern #endif #ifndef _MSC_VER #ifdef __cplusplus #define stbi_inline inline #else #define stbi_inline #endif #else #define stbi_inline __forceinline #endif #ifdef _MSC_VER typedef unsigned short stbi__uint16; typedef signed short stbi__int16; typedef unsigned int stbi__uint32; typedef signed int stbi__int32; #else #include typedef uint16_t stbi__uint16; typedef int16_t stbi__int16; typedef uint32_t stbi__uint32; typedef int32_t stbi__int32; #endif // should produce compiler error if size is wrong typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; #ifdef _MSC_VER #define STBI_NOTUSED(v) (void)(v) #else #define STBI_NOTUSED(v) (void)sizeof(v) #endif #ifdef _MSC_VER #define STBI_HAS_LROTL #endif #ifdef STBI_HAS_LROTL #define stbi_lrot(x,y) _lrotl(x,y) #else #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) #endif #if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) // ok #elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED) // ok #else #error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." #endif #ifndef STBI_MALLOC #define STBI_MALLOC(sz) malloc(sz) #define STBI_REALLOC(p,newsz) realloc(p,newsz) #define STBI_FREE(p) free(p) #endif #ifndef STBI_REALLOC_SIZED #define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz) #endif // x86/x64 detection #if defined(__x86_64__) || defined(_M_X64) #define STBI__X64_TARGET #elif defined(__i386) || defined(_M_IX86) #define STBI__X86_TARGET #endif #if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) // gcc doesn't support sse2 intrinsics unless you compile with -msse2, // which in turn means it gets to use SSE2 everywhere. This is unfortunate, // but previous attempts to provide the SSE2 functions with runtime // detection caused numerous issues. The way architecture extensions are // exposed in GCC/Clang is, sadly, not really suited for one-file libs. // New behavior: if compiled with -msse2, we use SSE2 without any // detection; if not, we don't use it at all. #define STBI_NO_SIMD #endif #if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) // Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET // // 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the // Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. // As a result, enabling SSE2 on 32-bit MinGW is dangerous when not // simultaneously enabling "-mstackrealign". // // See https://github.com/nothings/stb/issues/81 for more information. // // So default to no SSE2 on 32-bit MinGW. If you've read this far and added // -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. #define STBI_NO_SIMD #endif #if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) #define STBI_SSE2 #include #ifdef _MSC_VER #if _MSC_VER >= 1400 // not VC6 #include // __cpuid static int stbi__cpuid3(void) { int info[4]; __cpuid(info,1); return info[3]; } #else static int stbi__cpuid3(void) { int res; __asm { mov eax,1 cpuid mov res,edx } return res; } #endif #define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name #if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) static int stbi__sse2_available(void) { int info3 = stbi__cpuid3(); return ((info3 >> 26) & 1) != 0; } #endif #else // assume GCC-style if not VC++ #define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) #if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) static int stbi__sse2_available(void) { // If we're even attempting to compile this on GCC/Clang, that means // -msse2 is on, which means the compiler is allowed to use SSE2 // instructions at will, and so are we. return 1; } #endif #endif #endif // ARM NEON #if defined(STBI_NO_SIMD) && defined(STBI_NEON) #undef STBI_NEON #endif #ifdef STBI_NEON #include // assume GCC or Clang on ARM targets #define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) #endif #ifndef STBI_SIMD_ALIGN #define STBI_SIMD_ALIGN(type, name) type name #endif /////////////////////////////////////////////// // // stbi__context struct and start_xxx functions // stbi__context structure is our basic context used by all images, so it // contains all the IO context, plus some basic image information typedef struct { stbi__uint32 img_x, img_y; int img_n, img_out_n; stbi_io_callbacks io; void *io_user_data; int read_from_callbacks; int buflen; stbi_uc buffer_start[128]; stbi_uc *img_buffer, *img_buffer_end; stbi_uc *img_buffer_original, *img_buffer_original_end; } stbi__context; static void stbi__refill_buffer(stbi__context *s); // initialize a memory-decode context static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) { s->io.read = NULL; s->read_from_callbacks = 0; s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer; s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len; } // initialize a callback-based context static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) { s->io = *c; s->io_user_data = user; s->buflen = sizeof(s->buffer_start); s->read_from_callbacks = 1; s->img_buffer_original = s->buffer_start; stbi__refill_buffer(s); s->img_buffer_original_end = s->img_buffer_end; } #ifndef STBI_NO_STDIO static int stbi__stdio_read(void *user, char *data, int size) { return (int) fread(data,1,size,(FILE*) user); } static void stbi__stdio_skip(void *user, int n) { fseek((FILE*) user, n, SEEK_CUR); } static int stbi__stdio_eof(void *user) { return feof((FILE*) user); } static stbi_io_callbacks stbi__stdio_callbacks = { stbi__stdio_read, stbi__stdio_skip, stbi__stdio_eof, }; static void stbi__start_file(stbi__context *s, FILE *f) { stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f); } //static void stop_file(stbi__context *s) { } #endif // !STBI_NO_STDIO static void stbi__rewind(stbi__context *s) { // conceptually rewind SHOULD rewind to the beginning of the stream, // but we just rewind to the beginning of the initial buffer, because // we only use it after doing 'test', which only ever looks at at most 92 bytes s->img_buffer = s->img_buffer_original; s->img_buffer_end = s->img_buffer_original_end; } enum { STBI_ORDER_RGB, STBI_ORDER_BGR }; typedef struct { int bits_per_channel; int num_channels; int channel_order; } stbi__result_info; #ifndef STBI_NO_JPEG static int stbi__jpeg_test(stbi__context *s); static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PNG static int stbi__png_test(stbi__context *s); static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); static int stbi__png_is16(stbi__context *s); #endif #ifndef STBI_NO_BMP static int stbi__bmp_test(stbi__context *s); static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_TGA static int stbi__tga_test(stbi__context *s); static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PSD static int stbi__psd_test(stbi__context *s); static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc); static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); static int stbi__psd_is16(stbi__context *s); #endif #ifndef STBI_NO_HDR static int stbi__hdr_test(stbi__context *s); static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PIC static int stbi__pic_test(stbi__context *s); static void *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_GIF static int stbi__gif_test(stbi__context *s); static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp); static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PNM static int stbi__pnm_test(stbi__context *s); static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); #endif // this is not threadsafe static const char *stbi__g_failure_reason; STBIDEF const char *stbi_failure_reason(void) { return stbi__g_failure_reason; } static int stbi__err(const char *str) { stbi__g_failure_reason = str; return 0; } static void *stbi__malloc(size_t size) { return STBI_MALLOC(size); } // stb_image uses ints pervasively, including for offset calculations. // therefore the largest decoded image size we can support with the // current code, even on 64-bit targets, is INT_MAX. this is not a // significant limitation for the intended use case. // // we do, however, need to make sure our size calculations don't // overflow. hence a few helper functions for size calculations that // multiply integers together, making sure that they're non-negative // and no overflow occurs. // return 1 if the sum is valid, 0 on overflow. // negative terms are considered invalid. static int stbi__addsizes_valid(int a, int b) { if (b < 0) return 0; // now 0 <= b <= INT_MAX, hence also // 0 <= INT_MAX - b <= INTMAX. // And "a + b <= INT_MAX" (which might overflow) is the // same as a <= INT_MAX - b (no overflow) return a <= INT_MAX - b; } // returns 1 if the product is valid, 0 on overflow. // negative factors are considered invalid. static int stbi__mul2sizes_valid(int a, int b) { if (a < 0 || b < 0) return 0; if (b == 0) return 1; // mul-by-0 is always safe // portable way to check for no overflows in a*b return a <= INT_MAX/b; } // returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow static int stbi__mad2sizes_valid(int a, int b, int add) { return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add); } // returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow static int stbi__mad3sizes_valid(int a, int b, int c, int add) { return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && stbi__addsizes_valid(a*b*c, add); } // returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) { return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add); } #endif // mallocs with size overflow checking static void *stbi__malloc_mad2(int a, int b, int add) { if (!stbi__mad2sizes_valid(a, b, add)) return NULL; return stbi__malloc(a*b + add); } static void *stbi__malloc_mad3(int a, int b, int c, int add) { if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL; return stbi__malloc(a*b*c + add); } #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) { if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL; return stbi__malloc(a*b*c*d + add); } #endif // stbi__err - error // stbi__errpf - error returning pointer to float // stbi__errpuc - error returning pointer to unsigned char #ifdef STBI_NO_FAILURE_STRINGS #define stbi__err(x,y) 0 #elif defined(STBI_FAILURE_USERMSG) #define stbi__err(x,y) stbi__err(y) #else #define stbi__err(x,y) stbi__err(x) #endif #define stbi__errpf(x,y) ((float *)(size_t) (stbi__err(x,y)?NULL:NULL)) #define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL)) STBIDEF void stbi_image_free(void *retval_from_stbi_load) { STBI_FREE(retval_from_stbi_load); } #ifndef STBI_NO_LINEAR static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); #endif #ifndef STBI_NO_HDR static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); #endif static int stbi__vertically_flip_on_load = 0; STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) { stbi__vertically_flip_on_load = flag_true_if_should_flip; } static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) { memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order ri->num_channels = 0; #ifndef STBI_NO_JPEG if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_PNG if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_BMP if (stbi__bmp_test(s)) return stbi__bmp_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_GIF if (stbi__gif_test(s)) return stbi__gif_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_PSD if (stbi__psd_test(s)) return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc); #endif #ifndef STBI_NO_PIC if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_PNM if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_HDR if (stbi__hdr_test(s)) { float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri); return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); } #endif #ifndef STBI_NO_TGA // test tga last because it's a crappy test! if (stbi__tga_test(s)) return stbi__tga_load(s,x,y,comp,req_comp, ri); #endif return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); } static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels) { int i; int img_len = w * h * channels; stbi_uc *reduced; reduced = (stbi_uc *) stbi__malloc(img_len); if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory"); for (i = 0; i < img_len; ++i) reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling STBI_FREE(orig); return reduced; } static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels) { int i; int img_len = w * h * channels; stbi__uint16 *enlarged; enlarged = (stbi__uint16 *) stbi__malloc(img_len*2); if (enlarged == NULL) return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); for (i = 0; i < img_len; ++i) enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff STBI_FREE(orig); return enlarged; } static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) { int row; size_t bytes_per_row = (size_t)w * bytes_per_pixel; stbi_uc temp[2048]; stbi_uc *bytes = (stbi_uc *)image; for (row = 0; row < (h>>1); row++) { stbi_uc *row0 = bytes + row*bytes_per_row; stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row; // swap row0 with row1 size_t bytes_left = bytes_per_row; while (bytes_left) { size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp); memcpy(temp, row0, bytes_copy); memcpy(row0, row1, bytes_copy); memcpy(row1, temp, bytes_copy); row0 += bytes_copy; row1 += bytes_copy; bytes_left -= bytes_copy; } } } #ifndef STBI_NO_GIF static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel) { int slice; int slice_size = w * h * bytes_per_pixel; stbi_uc *bytes = (stbi_uc *)image; for (slice = 0; slice < z; ++slice) { stbi__vertical_flip(bytes, w, h, bytes_per_pixel); bytes += slice_size; } } #endif static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi__result_info ri; void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8); if (result == NULL) return NULL; if (ri.bits_per_channel != 8) { STBI_ASSERT(ri.bits_per_channel == 16); result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp); ri.bits_per_channel = 8; } // @TODO: move stbi__convert_format to here if (stbi__vertically_flip_on_load) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); } return (unsigned char *) result; } static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi__result_info ri; void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16); if (result == NULL) return NULL; if (ri.bits_per_channel != 16) { STBI_ASSERT(ri.bits_per_channel == 8); result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp); ri.bits_per_channel = 16; } // @TODO: move stbi__convert_format16 to here // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision if (stbi__vertically_flip_on_load) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16)); } return (stbi__uint16 *) result; } #if !defined(STBI_NO_HDR) && !defined(STBI_NO_LINEAR) static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) { if (stbi__vertically_flip_on_load && result != NULL) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(float)); } } #endif #ifndef STBI_NO_STDIO #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); #endif #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) { return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); } #endif static FILE *stbi__fopen(char const *filename, char const *mode) { FILE *f; #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) wchar_t wMode[64]; wchar_t wFilename[1024]; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename))) return 0; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode))) return 0; #if _MSC_VER >= 1400 if (0 != _wfopen_s(&f, wFilename, wMode)) f = 0; #else f = _wfopen(wFilename, wMode); #endif #elif defined(_MSC_VER) && _MSC_VER >= 1400 if (0 != fopen_s(&f, filename, mode)) f=0; #else f = fopen(filename, mode); #endif return f; } STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) { FILE *f = stbi__fopen(filename, "rb"); unsigned char *result; if (!f) return stbi__errpuc("can't fopen", "Unable to open file"); result = stbi_load_from_file(f,x,y,comp,req_comp); fclose(f); return result; } STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { unsigned char *result; stbi__context s; stbi__start_file(&s,f); result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); if (result) { // need to 'unget' all the characters in the IO buffer fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); } return result; } STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp) { stbi__uint16 *result; stbi__context s; stbi__start_file(&s,f); result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp); if (result) { // need to 'unget' all the characters in the IO buffer fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); } return result; } STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp) { FILE *f = stbi__fopen(filename, "rb"); stbi__uint16 *result; if (!f) return (stbi_us *) stbi__errpuc("can't fopen", "Unable to open file"); result = stbi_load_from_file_16(f,x,y,comp,req_comp); fclose(f); return result; } #endif //!STBI_NO_STDIO STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); } STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); } STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); } STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); } #ifndef STBI_NO_GIF STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp) { unsigned char *result; stbi__context s; stbi__start_mem(&s,buffer,len); result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp); if (stbi__vertically_flip_on_load) { stbi__vertical_flip_slices( result, *x, *y, *z, *comp ); } return result; } #endif #ifndef STBI_NO_LINEAR static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) { unsigned char *data; #ifndef STBI_NO_HDR if (stbi__hdr_test(s)) { stbi__result_info ri; float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp, &ri); if (hdr_data) stbi__float_postprocess(hdr_data,x,y,comp,req_comp); return hdr_data; } #endif data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp); if (data) return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); } STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__loadf_main(&s,x,y,comp,req_comp); } STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__loadf_main(&s,x,y,comp,req_comp); } #ifndef STBI_NO_STDIO STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) { float *result; FILE *f = stbi__fopen(filename, "rb"); if (!f) return stbi__errpf("can't fopen", "Unable to open file"); result = stbi_loadf_from_file(f,x,y,comp,req_comp); fclose(f); return result; } STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_file(&s,f); return stbi__loadf_main(&s,x,y,comp,req_comp); } #endif // !STBI_NO_STDIO #endif // !STBI_NO_LINEAR // these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is // defined, for API simplicity; if STBI_NO_LINEAR is defined, it always // reports false! STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) { #ifndef STBI_NO_HDR stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__hdr_test(&s); #else STBI_NOTUSED(buffer); STBI_NOTUSED(len); return 0; #endif } #ifndef STBI_NO_STDIO STBIDEF int stbi_is_hdr (char const *filename) { FILE *f = stbi__fopen(filename, "rb"); int result=0; if (f) { result = stbi_is_hdr_from_file(f); fclose(f); } return result; } STBIDEF int stbi_is_hdr_from_file(FILE *f) { #ifndef STBI_NO_HDR long pos = ftell(f); int res; stbi__context s; stbi__start_file(&s,f); res = stbi__hdr_test(&s); fseek(f, pos, SEEK_SET); return res; #else STBI_NOTUSED(f); return 0; #endif } #endif // !STBI_NO_STDIO STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) { #ifndef STBI_NO_HDR stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__hdr_test(&s); #else STBI_NOTUSED(clbk); STBI_NOTUSED(user); return 0; #endif } #ifndef STBI_NO_LINEAR static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f; STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } #endif static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f; STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } ////////////////////////////////////////////////////////////////////////////// // // Common code used by all image loaders // enum { STBI__SCAN_load=0, STBI__SCAN_type, STBI__SCAN_header }; static void stbi__refill_buffer(stbi__context *s) { int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); if (n == 0) { // at end of file, treat same as if from memory, but need to handle case // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file s->read_from_callbacks = 0; s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start+1; *s->img_buffer = 0; } else { s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start + n; } } stbi_inline static stbi_uc stbi__get8(stbi__context *s) { if (s->img_buffer < s->img_buffer_end) return *s->img_buffer++; if (s->read_from_callbacks) { stbi__refill_buffer(s); return *s->img_buffer++; } return 0; } stbi_inline static int stbi__at_eof(stbi__context *s) { if (s->io.read) { if (!(s->io.eof)(s->io_user_data)) return 0; // if feof() is true, check if buffer = end // special case: we've only got the special 0 character at the end if (s->read_from_callbacks == 0) return 1; } return s->img_buffer >= s->img_buffer_end; } static void stbi__skip(stbi__context *s, int n) { if (n < 0) { s->img_buffer = s->img_buffer_end; return; } if (s->io.read) { int blen = (int) (s->img_buffer_end - s->img_buffer); if (blen < n) { s->img_buffer = s->img_buffer_end; (s->io.skip)(s->io_user_data, n - blen); return; } } s->img_buffer += n; } static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) { if (s->io.read) { int blen = (int) (s->img_buffer_end - s->img_buffer); if (blen < n) { int res, count; memcpy(buffer, s->img_buffer, blen); count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); res = (count == (n-blen)); s->img_buffer = s->img_buffer_end; return res; } } if (s->img_buffer+n <= s->img_buffer_end) { memcpy(buffer, s->img_buffer, n); s->img_buffer += n; return 1; } else return 0; } static int stbi__get16be(stbi__context *s) { int z = stbi__get8(s); return (z << 8) + stbi__get8(s); } static stbi__uint32 stbi__get32be(stbi__context *s) { stbi__uint32 z = stbi__get16be(s); return (z << 16) + stbi__get16be(s); } #if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) // nothing #else static int stbi__get16le(stbi__context *s) { int z = stbi__get8(s); return z + (stbi__get8(s) << 8); } #endif #ifndef STBI_NO_BMP static stbi__uint32 stbi__get32le(stbi__context *s) { stbi__uint32 z = stbi__get16le(s); return z + (stbi__get16le(s) << 16); } #endif #define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings ////////////////////////////////////////////////////////////////////////////// // // generic converter from built-in img_n to req_comp // individual types do this automatically as much as possible (e.g. jpeg // does all cases internally since it needs to colorspace convert anyway, // and it never has alpha, so very few cases ). png can automatically // interleave an alpha=255 channel, but falls back to this for other cases // // assume data buffer is malloced, so malloc a new one and free that one // only failure mode is malloc failing static stbi_uc stbi__compute_y(int r, int g, int b) { return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8); } static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) { int i,j; unsigned char *good; if (req_comp == img_n) return data; STBI_ASSERT(req_comp >= 1 && req_comp <= 4); good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0); if (good == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } for (j=0; j < (int) y; ++j) { unsigned char *src = data + j * x * img_n ; unsigned char *dest = good + j * x * req_comp; #define STBI__COMBO(a,b) ((a)*8+(b)) #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) // convert source image with img_n components to one with req_comp components; // avoid switch per pixel, so use switch per scanline and massive macros switch (STBI__COMBO(img_n, req_comp)) { STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=255; } break; STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255; } break; STBI__CASE(2,1) { dest[0]=src[0]; } break; STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=255; } break; STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255; } break; STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break; STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; default: STBI_ASSERT(0); } #undef STBI__CASE } STBI_FREE(data); return good; } static stbi__uint16 stbi__compute_y_16(int r, int g, int b) { return (stbi__uint16) (((r*77) + (g*150) + (29*b)) >> 8); } static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y) { int i,j; stbi__uint16 *good; if (req_comp == img_n) return data; STBI_ASSERT(req_comp >= 1 && req_comp <= 4); good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2); if (good == NULL) { STBI_FREE(data); return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); } for (j=0; j < (int) y; ++j) { stbi__uint16 *src = data + j * x * img_n ; stbi__uint16 *dest = good + j * x * req_comp; #define STBI__COMBO(a,b) ((a)*8+(b)) #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) // convert source image with img_n components to one with req_comp components; // avoid switch per pixel, so use switch per scanline and massive macros switch (STBI__COMBO(img_n, req_comp)) { STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=0xffff; } break; STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=0xffff; } break; STBI__CASE(2,1) { dest[0]=src[0]; } break; STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=0xffff; } break; STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = 0xffff; } break; STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = src[3]; } break; STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; default: STBI_ASSERT(0); } #undef STBI__CASE } STBI_FREE(data); return good; } #ifndef STBI_NO_LINEAR static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) { int i,k,n; float *output; if (!data) return NULL; output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0); if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } // compute number of non-alpha components if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); } } if (n < comp) { for (i=0; i < x*y; ++i) { output[i*comp + n] = data[i*comp + n]/255.0f; } } STBI_FREE(data); return output; } #endif #ifndef STBI_NO_HDR #define stbi__float2int(x) ((int) (x)) static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) { int i,k,n; stbi_uc *output; if (!data) return NULL; output = (stbi_uc *) stbi__malloc_mad3(x, y, comp, 0); if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } // compute number of non-alpha components if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi_uc) stbi__float2int(z); } if (k < comp) { float z = data[i*comp+k] * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi_uc) stbi__float2int(z); } } STBI_FREE(data); return output; } #endif ////////////////////////////////////////////////////////////////////////////// // // "baseline" JPEG/JFIF decoder // // simple implementation // - doesn't support delayed output of y-dimension // - simple interface (only one output format: 8-bit interleaved RGB) // - doesn't try to recover corrupt jpegs // - doesn't allow partial loading, loading multiple at once // - still fast on x86 (copying globals into locals doesn't help x86) // - allocates lots of intermediate memory (full size of all components) // - non-interleaved case requires this anyway // - allows good upsampling (see next) // high-quality // - upsampled channels are bilinearly interpolated, even across blocks // - quality integer IDCT derived from IJG's 'slow' // performance // - fast huffman; reasonable integer IDCT // - some SIMD kernels for common paths on targets with SSE2/NEON // - uses a lot of intermediate memory, could cache poorly #ifndef STBI_NO_JPEG // huffman decoding acceleration #define FAST_BITS 9 // larger handles more cases; smaller stomps less cache typedef struct { stbi_uc fast[1 << FAST_BITS]; // weirdly, repacking this into AoS is a 10% speed loss, instead of a win stbi__uint16 code[256]; stbi_uc values[256]; stbi_uc size[257]; unsigned int maxcode[18]; int delta[17]; // old 'firstsymbol' - old 'firstcode' } stbi__huffman; typedef struct { stbi__context *s; stbi__huffman huff_dc[4]; stbi__huffman huff_ac[4]; stbi__uint16 dequant[4][64]; stbi__int16 fast_ac[4][1 << FAST_BITS]; // sizes for components, interleaved MCUs int img_h_max, img_v_max; int img_mcu_x, img_mcu_y; int img_mcu_w, img_mcu_h; // definition of jpeg image component struct { int id; int h,v; int tq; int hd,ha; int dc_pred; int x,y,w2,h2; stbi_uc *data; void *raw_data, *raw_coeff; stbi_uc *linebuf; short *coeff; // progressive only int coeff_w, coeff_h; // number of 8x8 coefficient blocks } img_comp[4]; stbi__uint32 code_buffer; // jpeg entropy-coded buffer int code_bits; // number of valid bits unsigned char marker; // marker seen while filling entropy buffer int nomore; // flag if we saw a marker so must stop int progressive; int spec_start; int spec_end; int succ_high; int succ_low; int eob_run; int jfif; int app14_color_transform; // Adobe APP14 tag int rgb; int scan_n, order[4]; int restart_interval, todo; // kernels void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step); stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs); } stbi__jpeg; static int stbi__build_huffman(stbi__huffman *h, int *count) { int i,j,k=0; unsigned int code; // build size list for each symbol (from JPEG spec) for (i=0; i < 16; ++i) for (j=0; j < count[i]; ++j) h->size[k++] = (stbi_uc) (i+1); h->size[k] = 0; // compute actual symbols (from jpeg spec) code = 0; k = 0; for(j=1; j <= 16; ++j) { // compute delta to add to code to compute symbol id h->delta[j] = k - code; if (h->size[k] == j) { while (h->size[k] == j) h->code[k++] = (stbi__uint16) (code++); if (code-1 >= (1u << j)) return stbi__err("bad code lengths","Corrupt JPEG"); } // compute largest code + 1 for this size, preshifted as needed later h->maxcode[j] = code << (16-j); code <<= 1; } h->maxcode[j] = 0xffffffff; // build non-spec acceleration table; 255 is flag for not-accelerated memset(h->fast, 255, 1 << FAST_BITS); for (i=0; i < k; ++i) { int s = h->size[i]; if (s <= FAST_BITS) { int c = h->code[i] << (FAST_BITS-s); int m = 1 << (FAST_BITS-s); for (j=0; j < m; ++j) { h->fast[c+j] = (stbi_uc) i; } } } return 1; } // build a table that decodes both magnitude and value of small ACs in // one go. static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) { int i; for (i=0; i < (1 << FAST_BITS); ++i) { stbi_uc fast = h->fast[i]; fast_ac[i] = 0; if (fast < 255) { int rs = h->values[fast]; int run = (rs >> 4) & 15; int magbits = rs & 15; int len = h->size[fast]; if (magbits && len + magbits <= FAST_BITS) { // magnitude code followed by receive_extend code int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); int m = 1 << (magbits - 1); if (k < m) k += (~0U << magbits) + 1; // if the result is small enough, we can fit it in fast_ac table if (k >= -128 && k <= 127) fast_ac[i] = (stbi__int16) ((k * 256) + (run * 16) + (len + magbits)); } } } } static void stbi__grow_buffer_unsafe(stbi__jpeg *j) { do { unsigned int b = j->nomore ? 0 : stbi__get8(j->s); if (b == 0xff) { int c = stbi__get8(j->s); while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes if (c != 0) { j->marker = (unsigned char) c; j->nomore = 1; return; } } j->code_buffer |= b << (24 - j->code_bits); j->code_bits += 8; } while (j->code_bits <= 24); } // (1 << n) - 1 static const stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; // decode a jpeg huffman value from the bitstream stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) { unsigned int temp; int c,k; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); // look at the top FAST_BITS and determine what symbol ID it is, // if the code is <= FAST_BITS c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); k = h->fast[c]; if (k < 255) { int s = h->size[k]; if (s > j->code_bits) return -1; j->code_buffer <<= s; j->code_bits -= s; return h->values[k]; } // naive test is to shift the code_buffer down so k bits are // valid, then test against maxcode. To speed this up, we've // preshifted maxcode left so that it has (16-k) 0s at the // end; in other words, regardless of the number of bits, it // wants to be compared against something shifted to have 16; // that way we don't need to shift inside the loop. temp = j->code_buffer >> 16; for (k=FAST_BITS+1 ; ; ++k) if (temp < h->maxcode[k]) break; if (k == 17) { // error! code not found j->code_bits -= 16; return -1; } if (k > j->code_bits) return -1; // convert the huffman code to the symbol id c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); // convert the id to a symbol j->code_bits -= k; j->code_buffer <<= k; return h->values[c]; } // bias[n] = (-1<code_bits < n) stbi__grow_buffer_unsafe(j); sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB k = stbi_lrot(j->code_buffer, n); STBI_ASSERT(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))); j->code_buffer = k & ~stbi__bmask[n]; k &= stbi__bmask[n]; j->code_bits -= n; return k + (stbi__jbias[n] & ~sgn); } // get some unsigned bits stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) { unsigned int k; if (j->code_bits < n) stbi__grow_buffer_unsafe(j); k = stbi_lrot(j->code_buffer, n); j->code_buffer = k & ~stbi__bmask[n]; k &= stbi__bmask[n]; j->code_bits -= n; return k; } stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) { unsigned int k; if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); k = j->code_buffer; j->code_buffer <<= 1; --j->code_bits; return k & 0x80000000; } // given a value that's at position X in the zigzag stream, // where does it appear in the 8x8 matrix coded as row-major? static const stbi_uc stbi__jpeg_dezigzag[64+15] = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, // let corrupt input sample past end 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 }; // decode one 64-entry block-- static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant) { int diff,dc,k; int t; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); t = stbi__jpeg_huff_decode(j, hdc); if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG"); // 0 all the ac values now so we can do it 32-bits at a time memset(data,0,64*sizeof(data[0])); diff = t ? stbi__extend_receive(j, t) : 0; dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; data[0] = (short) (dc * dequant[0]); // decode AC components, see JPEG spec k = 1; do { unsigned int zig; int c,r,s; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; if (r) { // fast-AC path k += (r >> 4) & 15; // run s = r & 15; // combined length j->code_buffer <<= s; j->code_bits -= s; // decode into unzigzag'd location zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) * dequant[zig]); } else { int rs = stbi__jpeg_huff_decode(j, hac); if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (rs != 0xf0) break; // end block k += 16; } else { k += r; // decode into unzigzag'd location zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); } } } while (k < 64); return 1; } static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) { int diff,dc; int t; if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); if (j->succ_high == 0) { // first scan for DC coefficient, must be first memset(data,0,64*sizeof(data[0])); // 0 all the ac values now t = stbi__jpeg_huff_decode(j, hdc); diff = t ? stbi__extend_receive(j, t) : 0; dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; data[0] = (short) (dc << j->succ_low); } else { // refinement scan for DC coefficient if (stbi__jpeg_get_bit(j)) data[0] += (short) (1 << j->succ_low); } return 1; } // @OPTIMIZE: store non-zigzagged during the decode passes, // and only de-zigzag when dequantizing static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac) { int k; if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); if (j->succ_high == 0) { int shift = j->succ_low; if (j->eob_run) { --j->eob_run; return 1; } k = j->spec_start; do { unsigned int zig; int c,r,s; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; if (r) { // fast-AC path k += (r >> 4) & 15; // run s = r & 15; // combined length j->code_buffer <<= s; j->code_bits -= s; zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) << shift); } else { int rs = stbi__jpeg_huff_decode(j, hac); if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (r < 15) { j->eob_run = (1 << r); if (r) j->eob_run += stbi__jpeg_get_bits(j, r); --j->eob_run; break; } k += 16; } else { k += r; zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) (stbi__extend_receive(j,s) << shift); } } } while (k <= j->spec_end); } else { // refinement scan for these AC coefficients short bit = (short) (1 << j->succ_low); if (j->eob_run) { --j->eob_run; for (k = j->spec_start; k <= j->spec_end; ++k) { short *p = &data[stbi__jpeg_dezigzag[k]]; if (*p != 0) if (stbi__jpeg_get_bit(j)) if ((*p & bit)==0) { if (*p > 0) *p += bit; else *p -= bit; } } } else { k = j->spec_start; do { int r,s; int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (r < 15) { j->eob_run = (1 << r) - 1; if (r) j->eob_run += stbi__jpeg_get_bits(j, r); r = 64; // force end of block } else { // r=15 s=0 should write 16 0s, so we just do // a run of 15 0s and then write s (which is 0), // so we don't have to do anything special here } } else { if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); // sign bit if (stbi__jpeg_get_bit(j)) s = bit; else s = -bit; } // advance by r while (k <= j->spec_end) { short *p = &data[stbi__jpeg_dezigzag[k++]]; if (*p != 0) { if (stbi__jpeg_get_bit(j)) if ((*p & bit)==0) { if (*p > 0) *p += bit; else *p -= bit; } } else { if (r == 0) { *p = (short) s; break; } --r; } } } while (k <= j->spec_end); } } return 1; } // take a -128..127 value and stbi__clamp it and convert to 0..255 stbi_inline static stbi_uc stbi__clamp(int x) { // trick to use a single test to catch both cases if ((unsigned int) x > 255) { if (x < 0) return 0; if (x > 255) return 255; } return (stbi_uc) x; } #define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) #define stbi__fsh(x) ((x) * 4096) // derived from jidctint -- DCT_ISLOW #define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ p2 = s2; \ p3 = s6; \ p1 = (p2+p3) * stbi__f2f(0.5411961f); \ t2 = p1 + p3*stbi__f2f(-1.847759065f); \ t3 = p1 + p2*stbi__f2f( 0.765366865f); \ p2 = s0; \ p3 = s4; \ t0 = stbi__fsh(p2+p3); \ t1 = stbi__fsh(p2-p3); \ x0 = t0+t3; \ x3 = t0-t3; \ x1 = t1+t2; \ x2 = t1-t2; \ t0 = s7; \ t1 = s5; \ t2 = s3; \ t3 = s1; \ p3 = t0+t2; \ p4 = t1+t3; \ p1 = t0+t3; \ p2 = t1+t2; \ p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ t0 = t0*stbi__f2f( 0.298631336f); \ t1 = t1*stbi__f2f( 2.053119869f); \ t2 = t2*stbi__f2f( 3.072711026f); \ t3 = t3*stbi__f2f( 1.501321110f); \ p1 = p5 + p1*stbi__f2f(-0.899976223f); \ p2 = p5 + p2*stbi__f2f(-2.562915447f); \ p3 = p3*stbi__f2f(-1.961570560f); \ p4 = p4*stbi__f2f(-0.390180644f); \ t3 += p1+p4; \ t2 += p2+p3; \ t1 += p2+p4; \ t0 += p1+p3; static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) { int i,val[64],*v=val; stbi_uc *o; short *d = data; // columns for (i=0; i < 8; ++i,++d, ++v) { // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 && d[40]==0 && d[48]==0 && d[56]==0) { // no shortcut 0 seconds // (1|2|3|4|5|6|7)==0 0 seconds // all separate -0.047 seconds // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds int dcterm = d[0]*4; v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; } else { STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) // constants scaled things up by 1<<12; let's bring them back // down, but keep 2 extra bits of precision x0 += 512; x1 += 512; x2 += 512; x3 += 512; v[ 0] = (x0+t3) >> 10; v[56] = (x0-t3) >> 10; v[ 8] = (x1+t2) >> 10; v[48] = (x1-t2) >> 10; v[16] = (x2+t1) >> 10; v[40] = (x2-t1) >> 10; v[24] = (x3+t0) >> 10; v[32] = (x3-t0) >> 10; } } for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { // no fast case since the first 1D IDCT spread components out STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) // constants scaled things up by 1<<12, plus we had 1<<2 from first // loop, plus horizontal and vertical each scale by sqrt(8) so together // we've got an extra 1<<3, so 1<<17 total we need to remove. // so we want to round that, which means adding 0.5 * 1<<17, // aka 65536. Also, we'll end up with -128 to 127 that we want // to encode as 0..255 by adding 128, so we'll add that before the shift x0 += 65536 + (128<<17); x1 += 65536 + (128<<17); x2 += 65536 + (128<<17); x3 += 65536 + (128<<17); // tried computing the shifts into temps, or'ing the temps to see // if any were out of range, but that was slower o[0] = stbi__clamp((x0+t3) >> 17); o[7] = stbi__clamp((x0-t3) >> 17); o[1] = stbi__clamp((x1+t2) >> 17); o[6] = stbi__clamp((x1-t2) >> 17); o[2] = stbi__clamp((x2+t1) >> 17); o[5] = stbi__clamp((x2-t1) >> 17); o[3] = stbi__clamp((x3+t0) >> 17); o[4] = stbi__clamp((x3-t0) >> 17); } } #ifdef STBI_SSE2 // sse2 integer IDCT. not the fastest possible implementation but it // produces bit-identical results to the generic C version so it's // fully "transparent". static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { // This is constructed to match our regular (generic) integer IDCT exactly. __m128i row0, row1, row2, row3, row4, row5, row6, row7; __m128i tmp; // dot product constant: even elems=x, odd elems=y #define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) // out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) // out(1) = c1[even]*x + c1[odd]*y #define dct_rot(out0,out1, x,y,c0,c1) \ __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) // out = in << 12 (in 16-bit, out 32-bit) #define dct_widen(out, in) \ __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) // wide add #define dct_wadd(out, a, b) \ __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ __m128i out##_h = _mm_add_epi32(a##_h, b##_h) // wide sub #define dct_wsub(out, a, b) \ __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) // butterfly a/b, add bias, then shift by "s" and pack #define dct_bfly32o(out0, out1, a,b,bias,s) \ { \ __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ dct_wadd(sum, abiased, b); \ dct_wsub(dif, abiased, b); \ out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ } // 8-bit interleave step (for transposes) #define dct_interleave8(a, b) \ tmp = a; \ a = _mm_unpacklo_epi8(a, b); \ b = _mm_unpackhi_epi8(tmp, b) // 16-bit interleave step (for transposes) #define dct_interleave16(a, b) \ tmp = a; \ a = _mm_unpacklo_epi16(a, b); \ b = _mm_unpackhi_epi16(tmp, b) #define dct_pass(bias,shift) \ { \ /* even part */ \ dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ __m128i sum04 = _mm_add_epi16(row0, row4); \ __m128i dif04 = _mm_sub_epi16(row0, row4); \ dct_widen(t0e, sum04); \ dct_widen(t1e, dif04); \ dct_wadd(x0, t0e, t3e); \ dct_wsub(x3, t0e, t3e); \ dct_wadd(x1, t1e, t2e); \ dct_wsub(x2, t1e, t2e); \ /* odd part */ \ dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ __m128i sum17 = _mm_add_epi16(row1, row7); \ __m128i sum35 = _mm_add_epi16(row3, row5); \ dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ dct_wadd(x4, y0o, y4o); \ dct_wadd(x5, y1o, y5o); \ dct_wadd(x6, y2o, y5o); \ dct_wadd(x7, y3o, y4o); \ dct_bfly32o(row0,row7, x0,x7,bias,shift); \ dct_bfly32o(row1,row6, x1,x6,bias,shift); \ dct_bfly32o(row2,row5, x2,x5,bias,shift); \ dct_bfly32o(row3,row4, x3,x4,bias,shift); \ } __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); // rounding biases in column/row passes, see stbi__idct_block for explanation. __m128i bias_0 = _mm_set1_epi32(512); __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); // load row0 = _mm_load_si128((const __m128i *) (data + 0*8)); row1 = _mm_load_si128((const __m128i *) (data + 1*8)); row2 = _mm_load_si128((const __m128i *) (data + 2*8)); row3 = _mm_load_si128((const __m128i *) (data + 3*8)); row4 = _mm_load_si128((const __m128i *) (data + 4*8)); row5 = _mm_load_si128((const __m128i *) (data + 5*8)); row6 = _mm_load_si128((const __m128i *) (data + 6*8)); row7 = _mm_load_si128((const __m128i *) (data + 7*8)); // column pass dct_pass(bias_0, 10); { // 16bit 8x8 transpose pass 1 dct_interleave16(row0, row4); dct_interleave16(row1, row5); dct_interleave16(row2, row6); dct_interleave16(row3, row7); // transpose pass 2 dct_interleave16(row0, row2); dct_interleave16(row1, row3); dct_interleave16(row4, row6); dct_interleave16(row5, row7); // transpose pass 3 dct_interleave16(row0, row1); dct_interleave16(row2, row3); dct_interleave16(row4, row5); dct_interleave16(row6, row7); } // row pass dct_pass(bias_1, 17); { // pack __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 __m128i p1 = _mm_packus_epi16(row2, row3); __m128i p2 = _mm_packus_epi16(row4, row5); __m128i p3 = _mm_packus_epi16(row6, row7); // 8bit 8x8 transpose pass 1 dct_interleave8(p0, p2); // a0e0a1e1... dct_interleave8(p1, p3); // c0g0c1g1... // transpose pass 2 dct_interleave8(p0, p1); // a0c0e0g0... dct_interleave8(p2, p3); // b0d0f0h0... // transpose pass 3 dct_interleave8(p0, p2); // a0b0c0d0... dct_interleave8(p1, p3); // a4b4c4d4... // store _mm_storel_epi64((__m128i *) out, p0); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p2); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p1); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p3); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); } #undef dct_const #undef dct_rot #undef dct_widen #undef dct_wadd #undef dct_wsub #undef dct_bfly32o #undef dct_interleave8 #undef dct_interleave16 #undef dct_pass } #endif // STBI_SSE2 #ifdef STBI_NEON // NEON integer IDCT. should produce bit-identical // results to the generic C version. static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); #define dct_long_mul(out, inq, coeff) \ int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) #define dct_long_mac(out, acc, inq, coeff) \ int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) #define dct_widen(out, inq) \ int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) // wide add #define dct_wadd(out, a, b) \ int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ int32x4_t out##_h = vaddq_s32(a##_h, b##_h) // wide sub #define dct_wsub(out, a, b) \ int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ int32x4_t out##_h = vsubq_s32(a##_h, b##_h) // butterfly a/b, then shift using "shiftop" by "s" and pack #define dct_bfly32o(out0,out1, a,b,shiftop,s) \ { \ dct_wadd(sum, a, b); \ dct_wsub(dif, a, b); \ out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ } #define dct_pass(shiftop, shift) \ { \ /* even part */ \ int16x8_t sum26 = vaddq_s16(row2, row6); \ dct_long_mul(p1e, sum26, rot0_0); \ dct_long_mac(t2e, p1e, row6, rot0_1); \ dct_long_mac(t3e, p1e, row2, rot0_2); \ int16x8_t sum04 = vaddq_s16(row0, row4); \ int16x8_t dif04 = vsubq_s16(row0, row4); \ dct_widen(t0e, sum04); \ dct_widen(t1e, dif04); \ dct_wadd(x0, t0e, t3e); \ dct_wsub(x3, t0e, t3e); \ dct_wadd(x1, t1e, t2e); \ dct_wsub(x2, t1e, t2e); \ /* odd part */ \ int16x8_t sum15 = vaddq_s16(row1, row5); \ int16x8_t sum17 = vaddq_s16(row1, row7); \ int16x8_t sum35 = vaddq_s16(row3, row5); \ int16x8_t sum37 = vaddq_s16(row3, row7); \ int16x8_t sumodd = vaddq_s16(sum17, sum35); \ dct_long_mul(p5o, sumodd, rot1_0); \ dct_long_mac(p1o, p5o, sum17, rot1_1); \ dct_long_mac(p2o, p5o, sum35, rot1_2); \ dct_long_mul(p3o, sum37, rot2_0); \ dct_long_mul(p4o, sum15, rot2_1); \ dct_wadd(sump13o, p1o, p3o); \ dct_wadd(sump24o, p2o, p4o); \ dct_wadd(sump23o, p2o, p3o); \ dct_wadd(sump14o, p1o, p4o); \ dct_long_mac(x4, sump13o, row7, rot3_0); \ dct_long_mac(x5, sump24o, row5, rot3_1); \ dct_long_mac(x6, sump23o, row3, rot3_2); \ dct_long_mac(x7, sump14o, row1, rot3_3); \ dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ } // load row0 = vld1q_s16(data + 0*8); row1 = vld1q_s16(data + 1*8); row2 = vld1q_s16(data + 2*8); row3 = vld1q_s16(data + 3*8); row4 = vld1q_s16(data + 4*8); row5 = vld1q_s16(data + 5*8); row6 = vld1q_s16(data + 6*8); row7 = vld1q_s16(data + 7*8); // add DC bias row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); // column pass dct_pass(vrshrn_n_s32, 10); // 16bit 8x8 transpose { // these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. // whether compilers actually get this is another story, sadly. #define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } #define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } #define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } // pass 1 dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 dct_trn16(row2, row3); dct_trn16(row4, row5); dct_trn16(row6, row7); // pass 2 dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 dct_trn32(row1, row3); dct_trn32(row4, row6); dct_trn32(row5, row7); // pass 3 dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 dct_trn64(row1, row5); dct_trn64(row2, row6); dct_trn64(row3, row7); #undef dct_trn16 #undef dct_trn32 #undef dct_trn64 } // row pass // vrshrn_n_s32 only supports shifts up to 16, we need // 17. so do a non-rounding shift of 16 first then follow // up with a rounding shift by 1. dct_pass(vshrn_n_s32, 16); { // pack and round uint8x8_t p0 = vqrshrun_n_s16(row0, 1); uint8x8_t p1 = vqrshrun_n_s16(row1, 1); uint8x8_t p2 = vqrshrun_n_s16(row2, 1); uint8x8_t p3 = vqrshrun_n_s16(row3, 1); uint8x8_t p4 = vqrshrun_n_s16(row4, 1); uint8x8_t p5 = vqrshrun_n_s16(row5, 1); uint8x8_t p6 = vqrshrun_n_s16(row6, 1); uint8x8_t p7 = vqrshrun_n_s16(row7, 1); // again, these can translate into one instruction, but often don't. #define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } #define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } #define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } // sadly can't use interleaved stores here since we only write // 8 bytes to each scan line! // 8x8 8-bit transpose pass 1 dct_trn8_8(p0, p1); dct_trn8_8(p2, p3); dct_trn8_8(p4, p5); dct_trn8_8(p6, p7); // pass 2 dct_trn8_16(p0, p2); dct_trn8_16(p1, p3); dct_trn8_16(p4, p6); dct_trn8_16(p5, p7); // pass 3 dct_trn8_32(p0, p4); dct_trn8_32(p1, p5); dct_trn8_32(p2, p6); dct_trn8_32(p3, p7); // store vst1_u8(out, p0); out += out_stride; vst1_u8(out, p1); out += out_stride; vst1_u8(out, p2); out += out_stride; vst1_u8(out, p3); out += out_stride; vst1_u8(out, p4); out += out_stride; vst1_u8(out, p5); out += out_stride; vst1_u8(out, p6); out += out_stride; vst1_u8(out, p7); #undef dct_trn8_8 #undef dct_trn8_16 #undef dct_trn8_32 } #undef dct_long_mul #undef dct_long_mac #undef dct_widen #undef dct_wadd #undef dct_wsub #undef dct_bfly32o #undef dct_pass } #endif // STBI_NEON #define STBI__MARKER_none 0xff // if there's a pending marker from the entropy stream, return that // otherwise, fetch from the stream and get a marker. if there's no // marker, return 0xff, which is never a valid marker value static stbi_uc stbi__get_marker(stbi__jpeg *j) { stbi_uc x; if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } x = stbi__get8(j->s); if (x != 0xff) return STBI__MARKER_none; while (x == 0xff) x = stbi__get8(j->s); // consume repeated 0xff fill bytes return x; } // in each scan, we'll have scan_n components, and the order // of the components is specified by order[] #define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) // after a restart interval, stbi__jpeg_reset the entropy decoder and // the dc prediction static void stbi__jpeg_reset(stbi__jpeg *j) { j->code_bits = 0; j->code_buffer = 0; j->nomore = 0; j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0; j->marker = STBI__MARKER_none; j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; j->eob_run = 0; // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, // since we don't even allow 1<<30 pixels } static int stbi__parse_entropy_coded_data(stbi__jpeg *z) { stbi__jpeg_reset(z); if (!z->progressive) { if (z->scan_n == 1) { int i,j; STBI_SIMD_ALIGN(short, data[64]); int n = z->order[0]; // non-interleaved data, we just need to process one block at a time, // in trivial scanline order // number of blocks to do just depends on how many actual "pixels" this // component has, independent of interleaved MCU blocking and such int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); // every data block is an MCU, so countdown the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); // if it's NOT a restart, then just bail, so we get corrupt data // rather than no data if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } else { // interleaved int i,j,k,x,y; STBI_SIMD_ALIGN(short, data[64]); for (j=0; j < z->img_mcu_y; ++j) { for (i=0; i < z->img_mcu_x; ++i) { // scan an interleaved mcu... process scan_n components in order for (k=0; k < z->scan_n; ++k) { int n = z->order[k]; // scan out an mcu's worth of this component; that's just determined // by the basic H and V specified for the component for (y=0; y < z->img_comp[n].v; ++y) { for (x=0; x < z->img_comp[n].h; ++x) { int x2 = (i*z->img_comp[n].h + x)*8; int y2 = (j*z->img_comp[n].v + y)*8; int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); } } } // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } } else { if (z->scan_n == 1) { int i,j; int n = z->order[0]; // non-interleaved data, we just need to process one block at a time, // in trivial scanline order // number of blocks to do just depends on how many actual "pixels" this // component has, independent of interleaved MCU blocking and such int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); if (z->spec_start == 0) { if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) return 0; } else { int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) return 0; } // every data block is an MCU, so countdown the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } else { // interleaved int i,j,k,x,y; for (j=0; j < z->img_mcu_y; ++j) { for (i=0; i < z->img_mcu_x; ++i) { // scan an interleaved mcu... process scan_n components in order for (k=0; k < z->scan_n; ++k) { int n = z->order[k]; // scan out an mcu's worth of this component; that's just determined // by the basic H and V specified for the component for (y=0; y < z->img_comp[n].v; ++y) { for (x=0; x < z->img_comp[n].h; ++x) { int x2 = (i*z->img_comp[n].h + x); int y2 = (j*z->img_comp[n].v + y); short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) return 0; } } } // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } } } static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant) { int i; for (i=0; i < 64; ++i) data[i] *= dequant[i]; } static void stbi__jpeg_finish(stbi__jpeg *z) { if (z->progressive) { // dequantize and idct the data int i,j,n; for (n=0; n < z->s->img_n; ++n) { int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); } } } } } static int stbi__process_marker(stbi__jpeg *z, int m) { int L; switch (m) { case STBI__MARKER_none: // no marker found return stbi__err("expected marker","Corrupt JPEG"); case 0xDD: // DRI - specify restart interval if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); z->restart_interval = stbi__get16be(z->s); return 1; case 0xDB: // DQT - define quantization table L = stbi__get16be(z->s)-2; while (L > 0) { int q = stbi__get8(z->s); int p = q >> 4, sixteen = (p != 0); int t = q & 15,i; if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG"); if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); for (i=0; i < 64; ++i) z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s)); L -= (sixteen ? 129 : 65); } return L==0; case 0xC4: // DHT - define huffman table L = stbi__get16be(z->s)-2; while (L > 0) { stbi_uc *v; int sizes[16],i,n=0; int q = stbi__get8(z->s); int tc = q >> 4; int th = q & 15; if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); for (i=0; i < 16; ++i) { sizes[i] = stbi__get8(z->s); n += sizes[i]; } L -= 17; if (tc == 0) { if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; v = z->huff_dc[th].values; } else { if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; v = z->huff_ac[th].values; } for (i=0; i < n; ++i) v[i] = stbi__get8(z->s); if (tc != 0) stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); L -= n; } return L==0; } // check for comment block or APP blocks if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { L = stbi__get16be(z->s); if (L < 2) { if (m == 0xFE) return stbi__err("bad COM len","Corrupt JPEG"); else return stbi__err("bad APP len","Corrupt JPEG"); } L -= 2; if (m == 0xE0 && L >= 5) { // JFIF APP0 segment static const unsigned char tag[5] = {'J','F','I','F','\0'}; int ok = 1; int i; for (i=0; i < 5; ++i) if (stbi__get8(z->s) != tag[i]) ok = 0; L -= 5; if (ok) z->jfif = 1; } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment static const unsigned char tag[6] = {'A','d','o','b','e','\0'}; int ok = 1; int i; for (i=0; i < 6; ++i) if (stbi__get8(z->s) != tag[i]) ok = 0; L -= 6; if (ok) { stbi__get8(z->s); // version stbi__get16be(z->s); // flags0 stbi__get16be(z->s); // flags1 z->app14_color_transform = stbi__get8(z->s); // color transform L -= 6; } } stbi__skip(z->s, L); return 1; } return stbi__err("unknown marker","Corrupt JPEG"); } // after we see SOS static int stbi__process_scan_header(stbi__jpeg *z) { int i; int Ls = stbi__get16be(z->s); z->scan_n = stbi__get8(z->s); if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG"); if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG"); for (i=0; i < z->scan_n; ++i) { int id = stbi__get8(z->s), which; int q = stbi__get8(z->s); for (which = 0; which < z->s->img_n; ++which) if (z->img_comp[which].id == id) break; if (which == z->s->img_n) return 0; // no match z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG"); z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG"); z->order[i] = which; } { int aa; z->spec_start = stbi__get8(z->s); z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 aa = stbi__get8(z->s); z->succ_high = (aa >> 4); z->succ_low = (aa & 15); if (z->progressive) { if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) return stbi__err("bad SOS", "Corrupt JPEG"); } else { if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); z->spec_end = 63; } } return 1; } static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) { int i; for (i=0; i < ncomp; ++i) { if (z->img_comp[i].raw_data) { STBI_FREE(z->img_comp[i].raw_data); z->img_comp[i].raw_data = NULL; z->img_comp[i].data = NULL; } if (z->img_comp[i].raw_coeff) { STBI_FREE(z->img_comp[i].raw_coeff); z->img_comp[i].raw_coeff = 0; z->img_comp[i].coeff = 0; } if (z->img_comp[i].linebuf) { STBI_FREE(z->img_comp[i].linebuf); z->img_comp[i].linebuf = NULL; } } return why; } static int stbi__process_frame_header(stbi__jpeg *z, int scan) { stbi__context *s = z->s; int Lf,p,i,q, h_max=1,v_max=1,c; Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires c = stbi__get8(s); if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG"); s->img_n = c; for (i=0; i < c; ++i) { z->img_comp[i].data = NULL; z->img_comp[i].linebuf = NULL; } if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); z->rgb = 0; for (i=0; i < s->img_n; ++i) { static const unsigned char rgb[3] = { 'R', 'G', 'B' }; z->img_comp[i].id = stbi__get8(s); if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) ++z->rgb; q = stbi__get8(s); z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); } if (scan != STBI__SCAN_load) return 1; if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode"); for (i=0; i < s->img_n; ++i) { if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; } // compute interleaved mcu info z->img_h_max = h_max; z->img_v_max = v_max; z->img_mcu_w = h_max * 8; z->img_mcu_h = v_max * 8; // these sizes can't be more than 17 bits z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; for (i=0; i < s->img_n; ++i) { // number of effective pixels (e.g. for non-interleaved MCU) z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; // to simplify generation, we'll allocate enough memory to decode // the bogus oversized data from using interleaved MCUs and their // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't // discard the extra data until colorspace conversion // // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier) // so these muls can't overflow with 32-bit ints (which we require) z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; z->img_comp[i].coeff = 0; z->img_comp[i].raw_coeff = 0; z->img_comp[i].linebuf = NULL; z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); if (z->img_comp[i].raw_data == NULL) return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); // align blocks for idct using mmx/sse z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); if (z->progressive) { // w2, h2 are multiples of 8 (see above) z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); if (z->img_comp[i].raw_coeff == NULL) return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); } } return 1; } // use comparisons since in some cases we handle more than one case (e.g. SOF) #define stbi__DNL(x) ((x) == 0xdc) #define stbi__SOI(x) ((x) == 0xd8) #define stbi__EOI(x) ((x) == 0xd9) #define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) #define stbi__SOS(x) ((x) == 0xda) #define stbi__SOF_progressive(x) ((x) == 0xc2) static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) { int m; z->jfif = 0; z->app14_color_transform = -1; // valid values are 0,1,2 z->marker = STBI__MARKER_none; // initialize cached marker to empty m = stbi__get_marker(z); if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); if (scan == STBI__SCAN_type) return 1; m = stbi__get_marker(z); while (!stbi__SOF(m)) { if (!stbi__process_marker(z,m)) return 0; m = stbi__get_marker(z); while (m == STBI__MARKER_none) { // some files have extra padding after their blocks, so ok, we'll scan if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); m = stbi__get_marker(z); } } z->progressive = stbi__SOF_progressive(m); if (!stbi__process_frame_header(z, scan)) return 0; return 1; } // decode image to YCbCr format static int stbi__decode_jpeg_image(stbi__jpeg *j) { int m; for (m = 0; m < 4; m++) { j->img_comp[m].raw_data = NULL; j->img_comp[m].raw_coeff = NULL; } j->restart_interval = 0; if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; m = stbi__get_marker(j); while (!stbi__EOI(m)) { if (stbi__SOS(m)) { if (!stbi__process_scan_header(j)) return 0; if (!stbi__parse_entropy_coded_data(j)) return 0; if (j->marker == STBI__MARKER_none ) { // handle 0s at the end of image data from IP Kamera 9060 while (!stbi__at_eof(j->s)) { int x = stbi__get8(j->s); if (x == 255) { j->marker = stbi__get8(j->s); break; } } // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 } } else if (stbi__DNL(m)) { int Ld = stbi__get16be(j->s); stbi__uint32 NL = stbi__get16be(j->s); if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG"); if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG"); } else { if (!stbi__process_marker(j, m)) return 0; } m = stbi__get_marker(j); } if (j->progressive) stbi__jpeg_finish(j); return 1; } // static jfif-centered resampling (across block boundaries) typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, int w, int hs); #define stbi__div4(x) ((stbi_uc) ((x) >> 2)) static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { STBI_NOTUSED(out); STBI_NOTUSED(in_far); STBI_NOTUSED(w); STBI_NOTUSED(hs); return in_near; } static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate two samples vertically for every one in input int i; STBI_NOTUSED(hs); for (i=0; i < w; ++i) out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); return out; } static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate two samples horizontally for every one in input int i; stbi_uc *input = in_near; if (w == 1) { // if only one sample, can't do any interpolation out[0] = out[1] = input[0]; return out; } out[0] = input[0]; out[1] = stbi__div4(input[0]*3 + input[1] + 2); for (i=1; i < w-1; ++i) { int n = 3*input[i]+2; out[i*2+0] = stbi__div4(n+input[i-1]); out[i*2+1] = stbi__div4(n+input[i+1]); } out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); out[i*2+1] = input[w-1]; STBI_NOTUSED(in_far); STBI_NOTUSED(hs); return out; } #define stbi__div16(x) ((stbi_uc) ((x) >> 4)) static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate 2x2 samples for every one in input int i,t0,t1; if (w == 1) { out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); return out; } t1 = 3*in_near[0] + in_far[0]; out[0] = stbi__div4(t1+2); for (i=1; i < w; ++i) { t0 = t1; t1 = 3*in_near[i]+in_far[i]; out[i*2-1] = stbi__div16(3*t0 + t1 + 8); out[i*2 ] = stbi__div16(3*t1 + t0 + 8); } out[w*2-1] = stbi__div4(t1+2); STBI_NOTUSED(hs); return out; } #if defined(STBI_SSE2) || defined(STBI_NEON) static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate 2x2 samples for every one in input int i=0,t0,t1; if (w == 1) { out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); return out; } t1 = 3*in_near[0] + in_far[0]; // process groups of 8 pixels for as long as we can. // note we can't handle the last pixel in a row in this loop // because we need to handle the filter boundary conditions. for (; i < ((w-1) & ~7); i += 8) { #if defined(STBI_SSE2) // load and perform the vertical filtering pass // this uses 3*x + y = 4*x + (y - x) __m128i zero = _mm_setzero_si128(); __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); __m128i farw = _mm_unpacklo_epi8(farb, zero); __m128i nearw = _mm_unpacklo_epi8(nearb, zero); __m128i diff = _mm_sub_epi16(farw, nearw); __m128i nears = _mm_slli_epi16(nearw, 2); __m128i curr = _mm_add_epi16(nears, diff); // current row // horizontal filter works the same based on shifted vers of current // row. "prev" is current row shifted right by 1 pixel; we need to // insert the previous pixel value (from t1). // "next" is current row shifted left by 1 pixel, with first pixel // of next block of 8 pixels added in. __m128i prv0 = _mm_slli_si128(curr, 2); __m128i nxt0 = _mm_srli_si128(curr, 2); __m128i prev = _mm_insert_epi16(prv0, t1, 0); __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7); // horizontal filter, polyphase implementation since it's convenient: // even pixels = 3*cur + prev = cur*4 + (prev - cur) // odd pixels = 3*cur + next = cur*4 + (next - cur) // note the shared term. __m128i bias = _mm_set1_epi16(8); __m128i curs = _mm_slli_epi16(curr, 2); __m128i prvd = _mm_sub_epi16(prev, curr); __m128i nxtd = _mm_sub_epi16(next, curr); __m128i curb = _mm_add_epi16(curs, bias); __m128i even = _mm_add_epi16(prvd, curb); __m128i odd = _mm_add_epi16(nxtd, curb); // interleave even and odd pixels, then undo scaling. __m128i int0 = _mm_unpacklo_epi16(even, odd); __m128i int1 = _mm_unpackhi_epi16(even, odd); __m128i de0 = _mm_srli_epi16(int0, 4); __m128i de1 = _mm_srli_epi16(int1, 4); // pack and write output __m128i outv = _mm_packus_epi16(de0, de1); _mm_storeu_si128((__m128i *) (out + i*2), outv); #elif defined(STBI_NEON) // load and perform the vertical filtering pass // this uses 3*x + y = 4*x + (y - x) uint8x8_t farb = vld1_u8(in_far + i); uint8x8_t nearb = vld1_u8(in_near + i); int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); int16x8_t curr = vaddq_s16(nears, diff); // current row // horizontal filter works the same based on shifted vers of current // row. "prev" is current row shifted right by 1 pixel; we need to // insert the previous pixel value (from t1). // "next" is current row shifted left by 1 pixel, with first pixel // of next block of 8 pixels added in. int16x8_t prv0 = vextq_s16(curr, curr, 7); int16x8_t nxt0 = vextq_s16(curr, curr, 1); int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7); // horizontal filter, polyphase implementation since it's convenient: // even pixels = 3*cur + prev = cur*4 + (prev - cur) // odd pixels = 3*cur + next = cur*4 + (next - cur) // note the shared term. int16x8_t curs = vshlq_n_s16(curr, 2); int16x8_t prvd = vsubq_s16(prev, curr); int16x8_t nxtd = vsubq_s16(next, curr); int16x8_t even = vaddq_s16(curs, prvd); int16x8_t odd = vaddq_s16(curs, nxtd); // undo scaling and round, then store with even/odd phases interleaved uint8x8x2_t o; o.val[0] = vqrshrun_n_s16(even, 4); o.val[1] = vqrshrun_n_s16(odd, 4); vst2_u8(out + i*2, o); #endif // "previous" value for next iter t1 = 3*in_near[i+7] + in_far[i+7]; } t0 = t1; t1 = 3*in_near[i] + in_far[i]; out[i*2] = stbi__div16(3*t1 + t0 + 8); for (++i; i < w; ++i) { t0 = t1; t1 = 3*in_near[i]+in_far[i]; out[i*2-1] = stbi__div16(3*t0 + t1 + 8); out[i*2 ] = stbi__div16(3*t1 + t0 + 8); } out[w*2-1] = stbi__div4(t1+2); STBI_NOTUSED(hs); return out; } #endif static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // resample with nearest-neighbor int i,j; STBI_NOTUSED(in_far); for (i=0; i < w; ++i) for (j=0; j < hs; ++j) out[i*hs+j] = in_near[i]; return out; } // this is a reduced-precision calculation of YCbCr-to-RGB introduced // to make sure the code produces the same results in both SIMD and scalar #define stbi__float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) { int i; for (i=0; i < count; ++i) { int y_fixed = (y[i] << 20) + (1<<19); // rounding int r,g,b; int cr = pcr[i] - 128; int cb = pcb[i] - 128; r = y_fixed + cr* stbi__float2fixed(1.40200f); g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); b = y_fixed + cb* stbi__float2fixed(1.77200f); r >>= 20; g >>= 20; b >>= 20; if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } out[0] = (stbi_uc)r; out[1] = (stbi_uc)g; out[2] = (stbi_uc)b; out[3] = 255; out += step; } } #if defined(STBI_SSE2) || defined(STBI_NEON) static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) { int i = 0; #ifdef STBI_SSE2 // step == 3 is pretty ugly on the final interleave, and i'm not convinced // it's useful in practice (you wouldn't use it for textures, for example). // so just accelerate step == 4 case. if (step == 4) { // this is a fairly straightforward implementation and not super-optimized. __m128i signflip = _mm_set1_epi8(-0x80); __m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); __m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128); __m128i xw = _mm_set1_epi16(255); // alpha channel for (; i+7 < count; i += 8) { // load __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 // unpack to short (and left-shift cr, cb by 8) __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); // color transform __m128i yws = _mm_srli_epi16(yw, 4); __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); __m128i rws = _mm_add_epi16(cr0, yws); __m128i gwt = _mm_add_epi16(cb0, yws); __m128i bws = _mm_add_epi16(yws, cb1); __m128i gws = _mm_add_epi16(gwt, cr1); // descale __m128i rw = _mm_srai_epi16(rws, 4); __m128i bw = _mm_srai_epi16(bws, 4); __m128i gw = _mm_srai_epi16(gws, 4); // back to byte, set up for transpose __m128i brb = _mm_packus_epi16(rw, bw); __m128i gxb = _mm_packus_epi16(gw, xw); // transpose to interleave channels __m128i t0 = _mm_unpacklo_epi8(brb, gxb); __m128i t1 = _mm_unpackhi_epi8(brb, gxb); __m128i o0 = _mm_unpacklo_epi16(t0, t1); __m128i o1 = _mm_unpackhi_epi16(t0, t1); // store _mm_storeu_si128((__m128i *) (out + 0), o0); _mm_storeu_si128((__m128i *) (out + 16), o1); out += 32; } } #endif #ifdef STBI_NEON // in this version, step=3 support would be easy to add. but is there demand? if (step == 4) { // this is a fairly straightforward implementation and not super-optimized. uint8x8_t signflip = vdup_n_u8(0x80); int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); for (; i+7 < count; i += 8) { // load uint8x8_t y_bytes = vld1_u8(y + i); uint8x8_t cr_bytes = vld1_u8(pcr + i); uint8x8_t cb_bytes = vld1_u8(pcb + i); int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); // expand to s16 int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); int16x8_t crw = vshll_n_s8(cr_biased, 7); int16x8_t cbw = vshll_n_s8(cb_biased, 7); // color transform int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); int16x8_t rws = vaddq_s16(yws, cr0); int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); int16x8_t bws = vaddq_s16(yws, cb1); // undo scaling, round, convert to byte uint8x8x4_t o; o.val[0] = vqrshrun_n_s16(rws, 4); o.val[1] = vqrshrun_n_s16(gws, 4); o.val[2] = vqrshrun_n_s16(bws, 4); o.val[3] = vdup_n_u8(255); // store, interleaving r/g/b/a vst4_u8(out, o); out += 8*4; } } #endif for (; i < count; ++i) { int y_fixed = (y[i] << 20) + (1<<19); // rounding int r,g,b; int cr = pcr[i] - 128; int cb = pcb[i] - 128; r = y_fixed + cr* stbi__float2fixed(1.40200f); g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); b = y_fixed + cb* stbi__float2fixed(1.77200f); r >>= 20; g >>= 20; b >>= 20; if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } out[0] = (stbi_uc)r; out[1] = (stbi_uc)g; out[2] = (stbi_uc)b; out[3] = 255; out += step; } } #endif // set up the kernels static void stbi__setup_jpeg(stbi__jpeg *j) { j->idct_block_kernel = stbi__idct_block; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; #ifdef STBI_SSE2 if (stbi__sse2_available()) { j->idct_block_kernel = stbi__idct_simd; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; } #endif #ifdef STBI_NEON j->idct_block_kernel = stbi__idct_simd; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; #endif } // clean up the temporary component buffers static void stbi__cleanup_jpeg(stbi__jpeg *j) { stbi__free_jpeg_components(j, j->s->img_n, 0); } typedef struct { resample_row_func resample; stbi_uc *line0,*line1; int hs,vs; // expansion factor in each axis int w_lores; // horizontal pixels pre-expansion int ystep; // how far through vertical expansion we are int ypos; // which pre-expansion row we're on } stbi__resample; // fast 0..255 * 0..255 => 0..255 rounded multiplication static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y) { unsigned int t = x*y + 128; return (stbi_uc) ((t + (t >>8)) >> 8); } static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) { int n, decode_n, is_rgb; z->s->img_n = 0; // make stbi__cleanup_jpeg safe // validate req_comp if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); // load a jpeg image from whichever source, but leave in YCbCr format if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } // determine actual number of components to generate n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1; is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif)); if (z->s->img_n == 3 && n < 3 && !is_rgb) decode_n = 1; else decode_n = z->s->img_n; // resample and color-convert { int k; unsigned int i,j; stbi_uc *output; stbi_uc *coutput[4] = { NULL, NULL, NULL, NULL }; stbi__resample res_comp[4]; for (k=0; k < decode_n; ++k) { stbi__resample *r = &res_comp[k]; // allocate line buffer big enough for upsampling off the edges // with upsample factor of 4 z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3); if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } r->hs = z->img_h_max / z->img_comp[k].h; r->vs = z->img_v_max / z->img_comp[k].v; r->ystep = r->vs >> 1; r->w_lores = (z->s->img_x + r->hs-1) / r->hs; r->ypos = 0; r->line0 = r->line1 = z->img_comp[k].data; if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; else r->resample = stbi__resample_row_generic; } // can't error after this so, this is safe output = (stbi_uc *) stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1); if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } // now go ahead and resample for (j=0; j < z->s->img_y; ++j) { stbi_uc *out = output + n * z->s->img_x * j; for (k=0; k < decode_n; ++k) { stbi__resample *r = &res_comp[k]; int y_bot = r->ystep >= (r->vs >> 1); coutput[k] = r->resample(z->img_comp[k].linebuf, y_bot ? r->line1 : r->line0, y_bot ? r->line0 : r->line1, r->w_lores, r->hs); if (++r->ystep >= r->vs) { r->ystep = 0; r->line0 = r->line1; if (++r->ypos < z->img_comp[k].y) r->line1 += z->img_comp[k].w2; } } if (n >= 3) { stbi_uc *y = coutput[0]; if (z->s->img_n == 3) { if (is_rgb) { for (i=0; i < z->s->img_x; ++i) { out[0] = y[i]; out[1] = coutput[1][i]; out[2] = coutput[2][i]; out[3] = 255; out += n; } } else { z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); } } else if (z->s->img_n == 4) { if (z->app14_color_transform == 0) { // CMYK for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; out[0] = stbi__blinn_8x8(coutput[0][i], m); out[1] = stbi__blinn_8x8(coutput[1][i], m); out[2] = stbi__blinn_8x8(coutput[2][i], m); out[3] = 255; out += n; } } else if (z->app14_color_transform == 2) { // YCCK z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; out[0] = stbi__blinn_8x8(255 - out[0], m); out[1] = stbi__blinn_8x8(255 - out[1], m); out[2] = stbi__blinn_8x8(255 - out[2], m); out += n; } } else { // YCbCr + alpha? Ignore the fourth channel for now z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); } } else for (i=0; i < z->s->img_x; ++i) { out[0] = out[1] = out[2] = y[i]; out[3] = 255; // not used if n==3 out += n; } } else { if (is_rgb) { if (n == 1) for (i=0; i < z->s->img_x; ++i) *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); else { for (i=0; i < z->s->img_x; ++i, out += 2) { out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); out[1] = 255; } } } else if (z->s->img_n == 4 && z->app14_color_transform == 0) { for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; stbi_uc r = stbi__blinn_8x8(coutput[0][i], m); stbi_uc g = stbi__blinn_8x8(coutput[1][i], m); stbi_uc b = stbi__blinn_8x8(coutput[2][i], m); out[0] = stbi__compute_y(r, g, b); out[1] = 255; out += n; } } else if (z->s->img_n == 4 && z->app14_color_transform == 2) { for (i=0; i < z->s->img_x; ++i) { out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]); out[1] = 255; out += n; } } else { stbi_uc *y = coutput[0]; if (n == 1) for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; else for (i=0; i < z->s->img_x; ++i) { *out++ = y[i]; *out++ = 255; } } } } stbi__cleanup_jpeg(z); *out_x = z->s->img_x; *out_y = z->s->img_y; if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output return output; } } static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { unsigned char* result; stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg)); STBI_NOTUSED(ri); j->s = s; stbi__setup_jpeg(j); result = load_jpeg_image(j, x,y,comp,req_comp); STBI_FREE(j); return result; } static int stbi__jpeg_test(stbi__context *s) { int r; stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg)); j->s = s; stbi__setup_jpeg(j); r = stbi__decode_jpeg_header(j, STBI__SCAN_type); stbi__rewind(s); STBI_FREE(j); return r; } static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) { if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { stbi__rewind( j->s ); return 0; } if (x) *x = j->s->img_x; if (y) *y = j->s->img_y; if (comp) *comp = j->s->img_n >= 3 ? 3 : 1; return 1; } static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) { int result; stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg))); j->s = s; result = stbi__jpeg_info_raw(j, x, y, comp); STBI_FREE(j); return result; } #endif // public domain zlib decode v0.2 Sean Barrett 2006-11-18 // simple implementation // - all input must be provided in an upfront buffer // - all output is written to a single output buffer (can malloc/realloc) // performance // - fast huffman #ifndef STBI_NO_ZLIB // fast-way is faster to check than jpeg huffman, but slow way is slower #define STBI__ZFAST_BITS 9 // accelerate all cases in default tables #define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) // zlib-style huffman encoding // (jpegs packs from left, zlib from right, so can't share code) typedef struct { stbi__uint16 fast[1 << STBI__ZFAST_BITS]; stbi__uint16 firstcode[16]; int maxcode[17]; stbi__uint16 firstsymbol[16]; stbi_uc size[288]; stbi__uint16 value[288]; } stbi__zhuffman; stbi_inline static int stbi__bitreverse16(int n) { n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); return n; } stbi_inline static int stbi__bit_reverse(int v, int bits) { STBI_ASSERT(bits <= 16); // to bit reverse n bits, reverse 16 and shift // e.g. 11 bits, bit reverse and shift away 5 return stbi__bitreverse16(v) >> (16-bits); } static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num) { int i,k=0; int code, next_code[16], sizes[17]; // DEFLATE spec for generating codes memset(sizes, 0, sizeof(sizes)); memset(z->fast, 0, sizeof(z->fast)); for (i=0; i < num; ++i) ++sizes[sizelist[i]]; sizes[0] = 0; for (i=1; i < 16; ++i) if (sizes[i] > (1 << i)) return stbi__err("bad sizes", "Corrupt PNG"); code = 0; for (i=1; i < 16; ++i) { next_code[i] = code; z->firstcode[i] = (stbi__uint16) code; z->firstsymbol[i] = (stbi__uint16) k; code = (code + sizes[i]); if (sizes[i]) if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG"); z->maxcode[i] = code << (16-i); // preshift for inner loop code <<= 1; k += sizes[i]; } z->maxcode[16] = 0x10000; // sentinel for (i=0; i < num; ++i) { int s = sizelist[i]; if (s) { int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i); z->size [c] = (stbi_uc ) s; z->value[c] = (stbi__uint16) i; if (s <= STBI__ZFAST_BITS) { int j = stbi__bit_reverse(next_code[s],s); while (j < (1 << STBI__ZFAST_BITS)) { z->fast[j] = fastv; j += (1 << s); } } ++next_code[s]; } } return 1; } // zlib-from-memory implementation for PNG reading // because PNG allows splitting the zlib stream arbitrarily, // and it's annoying structurally to have PNG call ZLIB call PNG, // we require PNG read all the IDATs and combine them into a single // memory buffer typedef struct { stbi_uc *zbuffer, *zbuffer_end; int num_bits; stbi__uint32 code_buffer; char *zout; char *zout_start; char *zout_end; int z_expandable; stbi__zhuffman z_length, z_distance; } stbi__zbuf; stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) { if (z->zbuffer >= z->zbuffer_end) return 0; return *z->zbuffer++; } static void stbi__fill_bits(stbi__zbuf *z) { do { STBI_ASSERT(z->code_buffer < (1U << z->num_bits)); z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits; z->num_bits += 8; } while (z->num_bits <= 24); } stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) { unsigned int k; if (z->num_bits < n) stbi__fill_bits(z); k = z->code_buffer & ((1 << n) - 1); z->code_buffer >>= n; z->num_bits -= n; return k; } static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) { int b,s,k; // not resolved by fast table, so compute it the slow way // use jpeg approach, which requires MSbits at top k = stbi__bit_reverse(a->code_buffer, 16); for (s=STBI__ZFAST_BITS+1; ; ++s) if (k < z->maxcode[s]) break; if (s == 16) return -1; // invalid code! // code size is s, so: b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; STBI_ASSERT(z->size[b] == s); a->code_buffer >>= s; a->num_bits -= s; return z->value[b]; } stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) { int b,s; if (a->num_bits < 16) stbi__fill_bits(a); b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; if (b) { s = b >> 9; a->code_buffer >>= s; a->num_bits -= s; return b & 511; } return stbi__zhuffman_decode_slowpath(a, z); } static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes { char *q; int cur, limit, old_limit; z->zout = zout; if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG"); cur = (int) (z->zout - z->zout_start); limit = old_limit = (int) (z->zout_end - z->zout_start); while (cur + n > limit) limit *= 2; q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); STBI_NOTUSED(old_limit); if (q == NULL) return stbi__err("outofmem", "Out of memory"); z->zout_start = q; z->zout = q + cur; z->zout_end = q + limit; return 1; } static const int stbi__zlength_base[31] = { 3,4,5,6,7,8,9,10,11,13, 15,17,19,23,27,31,35,43,51,59, 67,83,99,115,131,163,195,227,258,0,0 }; static const int stbi__zlength_extra[31]= { 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; static const int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, 257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; static const int stbi__zdist_extra[32] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; static int stbi__parse_huffman_block(stbi__zbuf *a) { char *zout = a->zout; for(;;) { int z = stbi__zhuffman_decode(a, &a->z_length); if (z < 256) { if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes if (zout >= a->zout_end) { if (!stbi__zexpand(a, zout, 1)) return 0; zout = a->zout; } *zout++ = (char) z; } else { stbi_uc *p; int len,dist; if (z == 256) { a->zout = zout; return 1; } z -= 257; len = stbi__zlength_base[z]; if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]); z = stbi__zhuffman_decode(a, &a->z_distance); if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); dist = stbi__zdist_base[z]; if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]); if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG"); if (zout + len > a->zout_end) { if (!stbi__zexpand(a, zout, len)) return 0; zout = a->zout; } p = (stbi_uc *) (zout - dist); if (dist == 1) { // run of one byte; common in images. stbi_uc v = *p; if (len) { do *zout++ = v; while (--len); } } else { if (len) { do *zout++ = *p++; while (--len); } } } } } static int stbi__compute_huffman_codes(stbi__zbuf *a) { static const stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; stbi__zhuffman z_codelength; stbi_uc lencodes[286+32+137];//padding for maximum single op stbi_uc codelength_sizes[19]; int i,n; int hlit = stbi__zreceive(a,5) + 257; int hdist = stbi__zreceive(a,5) + 1; int hclen = stbi__zreceive(a,4) + 4; int ntot = hlit + hdist; memset(codelength_sizes, 0, sizeof(codelength_sizes)); for (i=0; i < hclen; ++i) { int s = stbi__zreceive(a,3); codelength_sizes[length_dezigzag[i]] = (stbi_uc) s; } if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; n = 0; while (n < ntot) { int c = stbi__zhuffman_decode(a, &z_codelength); if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG"); if (c < 16) lencodes[n++] = (stbi_uc) c; else { stbi_uc fill = 0; if (c == 16) { c = stbi__zreceive(a,2)+3; if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG"); fill = lencodes[n-1]; } else if (c == 17) c = stbi__zreceive(a,3)+3; else { STBI_ASSERT(c == 18); c = stbi__zreceive(a,7)+11; } if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG"); memset(lencodes+n, fill, c); n += c; } } if (n != ntot) return stbi__err("bad codelengths","Corrupt PNG"); if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; return 1; } static int stbi__parse_uncompressed_block(stbi__zbuf *a) { stbi_uc header[4]; int len,nlen,k; if (a->num_bits & 7) stbi__zreceive(a, a->num_bits & 7); // discard // drain the bit-packed data into header k = 0; while (a->num_bits > 0) { header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check a->code_buffer >>= 8; a->num_bits -= 8; } STBI_ASSERT(a->num_bits == 0); // now fill header the normal way while (k < 4) header[k++] = stbi__zget8(a); len = header[1] * 256 + header[0]; nlen = header[3] * 256 + header[2]; if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG"); if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG"); if (a->zout + len > a->zout_end) if (!stbi__zexpand(a, a->zout, len)) return 0; memcpy(a->zout, a->zbuffer, len); a->zbuffer += len; a->zout += len; return 1; } static int stbi__parse_zlib_header(stbi__zbuf *a) { int cmf = stbi__zget8(a); int cm = cmf & 15; /* int cinfo = cmf >> 4; */ int flg = stbi__zget8(a); if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png // window = 1 << (8 + cinfo)... but who cares, we fully buffer output return 1; } static const stbi_uc stbi__zdefault_length[288] = { 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8 }; static const stbi_uc stbi__zdefault_distance[32] = { 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 }; /* Init algorithm: { int i; // use <= to match clearly with spec for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8; for ( ; i <= 255; ++i) stbi__zdefault_length[i] = 9; for ( ; i <= 279; ++i) stbi__zdefault_length[i] = 7; for ( ; i <= 287; ++i) stbi__zdefault_length[i] = 8; for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5; } */ static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) { int final, type; if (parse_header) if (!stbi__parse_zlib_header(a)) return 0; a->num_bits = 0; a->code_buffer = 0; do { final = stbi__zreceive(a,1); type = stbi__zreceive(a,2); if (type == 0) { if (!stbi__parse_uncompressed_block(a)) return 0; } else if (type == 3) { return 0; } else { if (type == 1) { // use fixed code lengths if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , 288)) return 0; if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0; } else { if (!stbi__compute_huffman_codes(a)) return 0; } if (!stbi__parse_huffman_block(a)) return 0; } } while (!final); return 1; } static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) { a->zout_start = obuf; a->zout = obuf; a->zout_end = obuf + olen; a->z_expandable = exp; return stbi__parse_zlib(a, parse_header); } STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) { stbi__zbuf a; char *p = (char *) stbi__malloc(initial_size); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer + len; if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) { return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); } STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) { stbi__zbuf a; char *p = (char *) stbi__malloc(initial_size); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer + len; if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) { stbi__zbuf a; a.zbuffer = (stbi_uc *) ibuffer; a.zbuffer_end = (stbi_uc *) ibuffer + ilen; if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) return (int) (a.zout - a.zout_start); else return -1; } STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) { stbi__zbuf a; char *p = (char *) stbi__malloc(16384); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer+len; if (stbi__do_zlib(&a, p, 16384, 1, 0)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) { stbi__zbuf a; a.zbuffer = (stbi_uc *) ibuffer; a.zbuffer_end = (stbi_uc *) ibuffer + ilen; if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) return (int) (a.zout - a.zout_start); else return -1; } #endif // public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 // simple implementation // - only 8-bit samples // - no CRC checking // - allocates lots of intermediate memory // - avoids problem of streaming data between subsystems // - avoids explicit window management // performance // - uses stb_zlib, a PD zlib implementation with fast huffman decoding #ifndef STBI_NO_PNG typedef struct { stbi__uint32 length; stbi__uint32 type; } stbi__pngchunk; static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) { stbi__pngchunk c; c.length = stbi__get32be(s); c.type = stbi__get32be(s); return c; } static int stbi__check_png_header(stbi__context *s) { static const stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 }; int i; for (i=0; i < 8; ++i) if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG"); return 1; } typedef struct { stbi__context *s; stbi_uc *idata, *expanded, *out; int depth; } stbi__png; enum { STBI__F_none=0, STBI__F_sub=1, STBI__F_up=2, STBI__F_avg=3, STBI__F_paeth=4, // synthetic filters used for first scanline to avoid needing a dummy row of 0s STBI__F_avg_first, STBI__F_paeth_first }; static stbi_uc first_row_filter[5] = { STBI__F_none, STBI__F_sub, STBI__F_none, STBI__F_avg_first, STBI__F_paeth_first }; static int stbi__paeth(int a, int b, int c) { int p = a + b - c; int pa = abs(p-a); int pb = abs(p-b); int pc = abs(p-c); if (pa <= pb && pa <= pc) return a; if (pb <= pc) return b; return c; } static const stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 }; // create the png data from post-deflated data static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) { int bytes = (depth == 16? 2 : 1); stbi__context *s = a->s; stbi__uint32 i,j,stride = x*out_n*bytes; stbi__uint32 img_len, img_width_bytes; int k; int img_n = s->img_n; // copy it into a local for later int output_bytes = out_n*bytes; int filter_bytes = img_n*bytes; int width = x; STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1); a->out = (stbi_uc *) stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into if (!a->out) return stbi__err("outofmem", "Out of memory"); if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) return stbi__err("too large", "Corrupt PNG"); img_width_bytes = (((img_n * x * depth) + 7) >> 3); img_len = (img_width_bytes + 1) * y; // we used to check for exact match between raw_len and img_len on non-interlaced PNGs, // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros), // so just check for raw_len < img_len always. if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG"); for (j=0; j < y; ++j) { stbi_uc *cur = a->out + stride*j; stbi_uc *prior; int filter = *raw++; if (filter > 4) return stbi__err("invalid filter","Corrupt PNG"); if (depth < 8) { STBI_ASSERT(img_width_bytes <= x); cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place filter_bytes = 1; width = img_width_bytes; } prior = cur - stride; // bugfix: need to compute this after 'cur +=' computation above // if first row, use special filter that doesn't sample previous row if (j == 0) filter = first_row_filter[filter]; // handle first byte explicitly for (k=0; k < filter_bytes; ++k) { switch (filter) { case STBI__F_none : cur[k] = raw[k]; break; case STBI__F_sub : cur[k] = raw[k]; break; case STBI__F_up : cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; case STBI__F_avg : cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); break; case STBI__F_paeth : cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0,prior[k],0)); break; case STBI__F_avg_first : cur[k] = raw[k]; break; case STBI__F_paeth_first: cur[k] = raw[k]; break; } } if (depth == 8) { if (img_n != out_n) cur[img_n] = 255; // first pixel raw += img_n; cur += out_n; prior += out_n; } else if (depth == 16) { if (img_n != out_n) { cur[filter_bytes] = 255; // first pixel top byte cur[filter_bytes+1] = 255; // first pixel bottom byte } raw += filter_bytes; cur += output_bytes; prior += output_bytes; } else { raw += 1; cur += 1; prior += 1; } // this is a little gross, so that we don't switch per-pixel or per-component if (depth < 8 || img_n == out_n) { int nk = (width - 1)*filter_bytes; #define STBI__CASE(f) \ case f: \ for (k=0; k < nk; ++k) switch (filter) { // "none" filter turns into a memcpy here; make that explicit. case STBI__F_none: memcpy(cur, raw, nk); break; STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); } break; STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); } break; STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); } break; STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); } break; STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); } break; } #undef STBI__CASE raw += nk; } else { STBI_ASSERT(img_n+1 == out_n); #define STBI__CASE(f) \ case f: \ for (i=x-1; i >= 1; --i, cur[filter_bytes]=255,raw+=filter_bytes,cur+=output_bytes,prior+=output_bytes) \ for (k=0; k < filter_bytes; ++k) switch (filter) { STBI__CASE(STBI__F_none) { cur[k] = raw[k]; } break; STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]); } break; STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1)); } break; STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes])); } break; STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1)); } break; STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0)); } break; } #undef STBI__CASE // the loop above sets the high byte of the pixels' alpha, but for // 16 bit png files we also need the low byte set. we'll do that here. if (depth == 16) { cur = a->out + stride*j; // start at the beginning of the row again for (i=0; i < x; ++i,cur+=output_bytes) { cur[filter_bytes+1] = 255; } } } } // we make a separate pass to expand bits to pixels; for performance, // this could run two scanlines behind the above code, so it won't // intefere with filtering but will still be in the cache. if (depth < 8) { for (j=0; j < y; ++j) { stbi_uc *cur = a->out + stride*j; stbi_uc *in = a->out + stride*j + x*out_n - img_width_bytes; // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range // note that the final byte might overshoot and write more data than desired. // we can allocate enough data that this never writes out of memory, but it // could also overwrite the next scanline. can it overwrite non-empty data // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel. // so we need to explicitly clamp the final ones if (depth == 4) { for (k=x*img_n; k >= 2; k-=2, ++in) { *cur++ = scale * ((*in >> 4) ); *cur++ = scale * ((*in ) & 0x0f); } if (k > 0) *cur++ = scale * ((*in >> 4) ); } else if (depth == 2) { for (k=x*img_n; k >= 4; k-=4, ++in) { *cur++ = scale * ((*in >> 6) ); *cur++ = scale * ((*in >> 4) & 0x03); *cur++ = scale * ((*in >> 2) & 0x03); *cur++ = scale * ((*in ) & 0x03); } if (k > 0) *cur++ = scale * ((*in >> 6) ); if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03); if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03); } else if (depth == 1) { for (k=x*img_n; k >= 8; k-=8, ++in) { *cur++ = scale * ((*in >> 7) ); *cur++ = scale * ((*in >> 6) & 0x01); *cur++ = scale * ((*in >> 5) & 0x01); *cur++ = scale * ((*in >> 4) & 0x01); *cur++ = scale * ((*in >> 3) & 0x01); *cur++ = scale * ((*in >> 2) & 0x01); *cur++ = scale * ((*in >> 1) & 0x01); *cur++ = scale * ((*in ) & 0x01); } if (k > 0) *cur++ = scale * ((*in >> 7) ); if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01); if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01); if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01); if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01); if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01); if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01); } if (img_n != out_n) { int q; // insert alpha = 255 cur = a->out + stride*j; if (img_n == 1) { for (q=x-1; q >= 0; --q) { cur[q*2+1] = 255; cur[q*2+0] = cur[q]; } } else { STBI_ASSERT(img_n == 3); for (q=x-1; q >= 0; --q) { cur[q*4+3] = 255; cur[q*4+2] = cur[q*3+2]; cur[q*4+1] = cur[q*3+1]; cur[q*4+0] = cur[q*3+0]; } } } } } else if (depth == 16) { // force the image data from big-endian to platform-native. // this is done in a separate pass due to the decoding relying // on the data being untouched, but could probably be done // per-line during decode if care is taken. stbi_uc *cur = a->out; stbi__uint16 *cur16 = (stbi__uint16*)cur; for(i=0; i < x*y*out_n; ++i,cur16++,cur+=2) { *cur16 = (cur[0] << 8) | cur[1]; } } return 1; } static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) { int bytes = (depth == 16 ? 2 : 1); int out_bytes = out_n * bytes; stbi_uc *final; int p; if (!interlaced) return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color); // de-interlacing final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0); for (p=0; p < 7; ++p) { int xorig[] = { 0,4,0,2,0,1,0 }; int yorig[] = { 0,0,4,0,2,0,1 }; int xspc[] = { 8,8,4,4,2,2,1 }; int yspc[] = { 8,8,8,4,4,2,2 }; int i,j,x,y; // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p]; y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p]; if (x && y) { stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) { STBI_FREE(final); return 0; } for (j=0; j < y; ++j) { for (i=0; i < x; ++i) { int out_y = j*yspc[p]+yorig[p]; int out_x = i*xspc[p]+xorig[p]; memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes, a->out + (j*x+i)*out_bytes, out_bytes); } } STBI_FREE(a->out); image_data += img_len; image_data_len -= img_len; } } a->out = final; return 1; } static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi_uc *p = z->out; // compute color-based transparency, assuming we've // already got 255 as the alpha value in the output STBI_ASSERT(out_n == 2 || out_n == 4); if (out_n == 2) { for (i=0; i < pixel_count; ++i) { p[1] = (p[0] == tc[0] ? 0 : 255); p += 2; } } else { for (i=0; i < pixel_count; ++i) { if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) p[3] = 0; p += 4; } } return 1; } static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi__uint16 *p = (stbi__uint16*) z->out; // compute color-based transparency, assuming we've // already got 65535 as the alpha value in the output STBI_ASSERT(out_n == 2 || out_n == 4); if (out_n == 2) { for (i = 0; i < pixel_count; ++i) { p[1] = (p[0] == tc[0] ? 0 : 65535); p += 2; } } else { for (i = 0; i < pixel_count; ++i) { if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) p[3] = 0; p += 4; } } return 1; } static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) { stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; stbi_uc *p, *temp_out, *orig = a->out; p = (stbi_uc *) stbi__malloc_mad2(pixel_count, pal_img_n, 0); if (p == NULL) return stbi__err("outofmem", "Out of memory"); // between here and free(out) below, exitting would leak temp_out = p; if (pal_img_n == 3) { for (i=0; i < pixel_count; ++i) { int n = orig[i]*4; p[0] = palette[n ]; p[1] = palette[n+1]; p[2] = palette[n+2]; p += 3; } } else { for (i=0; i < pixel_count; ++i) { int n = orig[i]*4; p[0] = palette[n ]; p[1] = palette[n+1]; p[2] = palette[n+2]; p[3] = palette[n+3]; p += 4; } } STBI_FREE(a->out); a->out = temp_out; STBI_NOTUSED(len); return 1; } static int stbi__unpremultiply_on_load = 0; static int stbi__de_iphone_flag = 0; STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) { stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply; } STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) { stbi__de_iphone_flag = flag_true_if_should_convert; } static void stbi__de_iphone(stbi__png *z) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi_uc *p = z->out; if (s->img_out_n == 3) { // convert bgr to rgb for (i=0; i < pixel_count; ++i) { stbi_uc t = p[0]; p[0] = p[2]; p[2] = t; p += 3; } } else { STBI_ASSERT(s->img_out_n == 4); if (stbi__unpremultiply_on_load) { // convert bgr to rgb and unpremultiply for (i=0; i < pixel_count; ++i) { stbi_uc a = p[3]; stbi_uc t = p[0]; if (a) { stbi_uc half = a / 2; p[0] = (p[2] * 255 + half) / a; p[1] = (p[1] * 255 + half) / a; p[2] = ( t * 255 + half) / a; } else { p[0] = p[2]; p[2] = t; } p += 4; } } else { // convert bgr to rgb for (i=0; i < pixel_count; ++i) { stbi_uc t = p[0]; p[0] = p[2]; p[2] = t; p += 4; } } } } #define STBI__PNG_TYPE(a,b,c,d) (((unsigned) (a) << 24) + ((unsigned) (b) << 16) + ((unsigned) (c) << 8) + (unsigned) (d)) static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) { stbi_uc palette[1024], pal_img_n=0; stbi_uc has_trans=0, tc[3]={0}; stbi__uint16 tc16[3]; stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0; int first=1,k,interlace=0, color=0, is_iphone=0; stbi__context *s = z->s; z->expanded = NULL; z->idata = NULL; z->out = NULL; if (!stbi__check_png_header(s)) return 0; if (scan == STBI__SCAN_type) return 1; for (;;) { stbi__pngchunk c = stbi__get_chunk_header(s); switch (c.type) { case STBI__PNG_TYPE('C','g','B','I'): is_iphone = 1; stbi__skip(s, c.length); break; case STBI__PNG_TYPE('I','H','D','R'): { int comp,filter; if (!first) return stbi__err("multiple IHDR","Corrupt PNG"); first = 0; if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG"); s->img_x = stbi__get32be(s); if (s->img_x > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); s->img_y = stbi__get32be(s); if (s->img_y > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); z->depth = stbi__get8(s); if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16) return stbi__err("1/2/4/8/16-bit only","PNG not supported: 1/2/4/8/16-bit only"); color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype","Corrupt PNG"); if (color == 3 && z->depth == 16) return stbi__err("bad ctype","Corrupt PNG"); if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG"); comp = stbi__get8(s); if (comp) return stbi__err("bad comp method","Corrupt PNG"); filter= stbi__get8(s); if (filter) return stbi__err("bad filter method","Corrupt PNG"); interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG"); if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG"); if (!pal_img_n) { s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); if (scan == STBI__SCAN_header) return 1; } else { // if paletted, then pal_n is our final components, and // img_n is # components to decompress/filter. s->img_n = 1; if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG"); // if SCAN_header, have to scan to see if we have a tRNS } break; } case STBI__PNG_TYPE('P','L','T','E'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG"); pal_len = c.length / 3; if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG"); for (i=0; i < pal_len; ++i) { palette[i*4+0] = stbi__get8(s); palette[i*4+1] = stbi__get8(s); palette[i*4+2] = stbi__get8(s); palette[i*4+3] = 255; } break; } case STBI__PNG_TYPE('t','R','N','S'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG"); if (pal_img_n) { if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; } if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG"); if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG"); pal_img_n = 4; for (i=0; i < c.length; ++i) palette[i*4+3] = stbi__get8(s); } else { if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG"); if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG"); has_trans = 1; if (z->depth == 16) { for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is } else { for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger } } break; } case STBI__PNG_TYPE('I','D','A','T'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG"); if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; } if ((int)(ioff + c.length) < (int)ioff) return 0; if (ioff + c.length > idata_limit) { stbi__uint32 idata_limit_old = idata_limit; stbi_uc *p; if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; while (ioff + c.length > idata_limit) idata_limit *= 2; STBI_NOTUSED(idata_limit_old); p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); z->idata = p; } if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG"); ioff += c.length; break; } case STBI__PNG_TYPE('I','E','N','D'): { stbi__uint32 raw_len, bpl; if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (scan != STBI__SCAN_load) return 1; if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG"); // initial guess for decoded data size to avoid unnecessary reallocs bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone); if (z->expanded == NULL) return 0; // zlib should set error STBI_FREE(z->idata); z->idata = NULL; if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) s->img_out_n = s->img_n+1; else s->img_out_n = s->img_n; if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0; if (has_trans) { if (z->depth == 16) { if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0; } else { if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0; } } if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) stbi__de_iphone(z); if (pal_img_n) { // pal_img_n == 3 or 4 s->img_n = pal_img_n; // record the actual colors we had s->img_out_n = pal_img_n; if (req_comp >= 3) s->img_out_n = req_comp; if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) return 0; } else if (has_trans) { // non-paletted image with tRNS -> source image has (constant) alpha ++s->img_n; } STBI_FREE(z->expanded); z->expanded = NULL; return 1; } default: // if critical, fail if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if ((c.type & (1 << 29)) == 0) { #ifndef STBI_NO_FAILURE_STRINGS // not threadsafe static char invalid_chunk[] = "XXXX PNG chunk not known"; invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); #endif return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); } stbi__skip(s, c.length); break; } // end of PNG chunk, read and skip CRC stbi__get32be(s); } } static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri) { void *result=NULL; if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { if (p->depth < 8) ri->bits_per_channel = 8; else ri->bits_per_channel = p->depth; result = p->out; p->out = NULL; if (req_comp && req_comp != p->s->img_out_n) { if (ri->bits_per_channel == 8) result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); else result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); p->s->img_out_n = req_comp; if (result == NULL) return result; } *x = p->s->img_x; *y = p->s->img_y; if (n) *n = p->s->img_n; } STBI_FREE(p->out); p->out = NULL; STBI_FREE(p->expanded); p->expanded = NULL; STBI_FREE(p->idata); p->idata = NULL; return result; } static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi__png p; p.s = s; return stbi__do_png(&p, x,y,comp,req_comp, ri); } static int stbi__png_test(stbi__context *s) { int r; r = stbi__check_png_header(s); stbi__rewind(s); return r; } static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) { if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { stbi__rewind( p->s ); return 0; } if (x) *x = p->s->img_x; if (y) *y = p->s->img_y; if (comp) *comp = p->s->img_n; return 1; } static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) { stbi__png p; p.s = s; return stbi__png_info_raw(&p, x, y, comp); } static int stbi__png_is16(stbi__context *s) { stbi__png p; p.s = s; if (!stbi__png_info_raw(&p, NULL, NULL, NULL)) return 0; if (p.depth != 16) { stbi__rewind(p.s); return 0; } return 1; } #endif // Microsoft/Windows BMP image #ifndef STBI_NO_BMP static int stbi__bmp_test_raw(stbi__context *s) { int r; int sz; if (stbi__get8(s) != 'B') return 0; if (stbi__get8(s) != 'M') return 0; stbi__get32le(s); // discard filesize stbi__get16le(s); // discard reserved stbi__get16le(s); // discard reserved stbi__get32le(s); // discard data offset sz = stbi__get32le(s); r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); return r; } static int stbi__bmp_test(stbi__context *s) { int r = stbi__bmp_test_raw(s); stbi__rewind(s); return r; } // returns 0..31 for the highest set bit static int stbi__high_bit(unsigned int z) { int n=0; if (z == 0) return -1; if (z >= 0x10000) { n += 16; z >>= 16; } if (z >= 0x00100) { n += 8; z >>= 8; } if (z >= 0x00010) { n += 4; z >>= 4; } if (z >= 0x00004) { n += 2; z >>= 2; } if (z >= 0x00002) { n += 1; z >>= 1; } return n; } static int stbi__bitcount(unsigned int a) { a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits a = (a + (a >> 8)); // max 16 per 8 bits a = (a + (a >> 16)); // max 32 per 8 bits return a & 0xff; } // extract an arbitrarily-aligned N-bit value (N=bits) // from v, and then make it 8-bits long and fractionally // extend it to full full range. static int stbi__shiftsigned(unsigned int v, int shift, int bits) { static unsigned int mul_table[9] = { 0, 0xff/*0b11111111*/, 0x55/*0b01010101*/, 0x49/*0b01001001*/, 0x11/*0b00010001*/, 0x21/*0b00100001*/, 0x41/*0b01000001*/, 0x81/*0b10000001*/, 0x01/*0b00000001*/, }; static unsigned int shift_table[9] = { 0, 0,0,1,0,2,4,6,0, }; if (shift < 0) v <<= -shift; else v >>= shift; STBI_ASSERT(v >= 0 && v < 256); v >>= (8-bits); STBI_ASSERT(bits >= 0 && bits <= 8); return (int) ((unsigned) v * mul_table[bits]) >> shift_table[bits]; } typedef struct { int bpp, offset, hsz; unsigned int mr,mg,mb,ma, all_a; } stbi__bmp_data; static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) { int hsz; if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP"); stbi__get32le(s); // discard filesize stbi__get16le(s); // discard reserved stbi__get16le(s); // discard reserved info->offset = stbi__get32le(s); info->hsz = hsz = stbi__get32le(s); info->mr = info->mg = info->mb = info->ma = 0; if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); if (hsz == 12) { s->img_x = stbi__get16le(s); s->img_y = stbi__get16le(s); } else { s->img_x = stbi__get32le(s); s->img_y = stbi__get32le(s); } if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP"); info->bpp = stbi__get16le(s); if (hsz != 12) { int compress = stbi__get32le(s); if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); stbi__get32le(s); // discard sizeof stbi__get32le(s); // discard hres stbi__get32le(s); // discard vres stbi__get32le(s); // discard colorsused stbi__get32le(s); // discard max important if (hsz == 40 || hsz == 56) { if (hsz == 56) { stbi__get32le(s); stbi__get32le(s); stbi__get32le(s); stbi__get32le(s); } if (info->bpp == 16 || info->bpp == 32) { if (compress == 0) { if (info->bpp == 32) { info->mr = 0xffu << 16; info->mg = 0xffu << 8; info->mb = 0xffu << 0; info->ma = 0xffu << 24; info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 } else { info->mr = 31u << 10; info->mg = 31u << 5; info->mb = 31u << 0; } } else if (compress == 3) { info->mr = stbi__get32le(s); info->mg = stbi__get32le(s); info->mb = stbi__get32le(s); // not documented, but generated by photoshop and handled by mspaint if (info->mr == info->mg && info->mg == info->mb) { // ?!?!? return stbi__errpuc("bad BMP", "bad BMP"); } } else return stbi__errpuc("bad BMP", "bad BMP"); } } else { int i; if (hsz != 108 && hsz != 124) return stbi__errpuc("bad BMP", "bad BMP"); info->mr = stbi__get32le(s); info->mg = stbi__get32le(s); info->mb = stbi__get32le(s); info->ma = stbi__get32le(s); stbi__get32le(s); // discard color space for (i=0; i < 12; ++i) stbi__get32le(s); // discard color space parameters if (hsz == 124) { stbi__get32le(s); // discard rendering intent stbi__get32le(s); // discard offset of profile data stbi__get32le(s); // discard size of profile data stbi__get32le(s); // discard reserved } } } return (void *) 1; } static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *out; unsigned int mr=0,mg=0,mb=0,ma=0, all_a; stbi_uc pal[256][4]; int psize=0,i,j,width; int flip_vertically, pad, target; stbi__bmp_data info; STBI_NOTUSED(ri); info.all_a = 255; if (stbi__bmp_parse_header(s, &info) == NULL) return NULL; // error code already set flip_vertically = ((int) s->img_y) > 0; s->img_y = abs((int) s->img_y); mr = info.mr; mg = info.mg; mb = info.mb; ma = info.ma; all_a = info.all_a; if (info.hsz == 12) { if (info.bpp < 24) psize = (info.offset - 14 - 24) / 3; } else { if (info.bpp < 16) psize = (info.offset - 14 - info.hsz) >> 2; } s->img_n = ma ? 4 : 3; if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 target = req_comp; else target = s->img_n; // if they want monochrome, we'll post-convert // sanity-check size if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0)) return stbi__errpuc("too large", "Corrupt BMP"); out = (stbi_uc *) stbi__malloc_mad3(target, s->img_x, s->img_y, 0); if (!out) return stbi__errpuc("outofmem", "Out of memory"); if (info.bpp < 16) { int z=0; if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); } for (i=0; i < psize; ++i) { pal[i][2] = stbi__get8(s); pal[i][1] = stbi__get8(s); pal[i][0] = stbi__get8(s); if (info.hsz != 12) stbi__get8(s); pal[i][3] = 255; } stbi__skip(s, info.offset - 14 - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); if (info.bpp == 1) width = (s->img_x + 7) >> 3; else if (info.bpp == 4) width = (s->img_x + 1) >> 1; else if (info.bpp == 8) width = s->img_x; else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); } pad = (-width)&3; if (info.bpp == 1) { for (j=0; j < (int) s->img_y; ++j) { int bit_offset = 7, v = stbi__get8(s); for (i=0; i < (int) s->img_x; ++i) { int color = (v>>bit_offset)&0x1; out[z++] = pal[color][0]; out[z++] = pal[color][1]; out[z++] = pal[color][2]; if (target == 4) out[z++] = 255; if (i+1 == (int) s->img_x) break; if((--bit_offset) < 0) { bit_offset = 7; v = stbi__get8(s); } } stbi__skip(s, pad); } } else { for (j=0; j < (int) s->img_y; ++j) { for (i=0; i < (int) s->img_x; i += 2) { int v=stbi__get8(s),v2=0; if (info.bpp == 4) { v2 = v & 15; v >>= 4; } out[z++] = pal[v][0]; out[z++] = pal[v][1]; out[z++] = pal[v][2]; if (target == 4) out[z++] = 255; if (i+1 == (int) s->img_x) break; v = (info.bpp == 8) ? stbi__get8(s) : v2; out[z++] = pal[v][0]; out[z++] = pal[v][1]; out[z++] = pal[v][2]; if (target == 4) out[z++] = 255; } stbi__skip(s, pad); } } } else { int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; int z = 0; int easy=0; stbi__skip(s, info.offset - 14 - info.hsz); if (info.bpp == 24) width = 3 * s->img_x; else if (info.bpp == 16) width = 2*s->img_x; else /* bpp = 32 and pad = 0 */ width=0; pad = (-width) & 3; if (info.bpp == 24) { easy = 1; } else if (info.bpp == 32) { if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) easy = 2; } if (!easy) { if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } // right shift amt to put high bit in position #7 rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr); gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg); bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb); ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma); } for (j=0; j < (int) s->img_y; ++j) { if (easy) { for (i=0; i < (int) s->img_x; ++i) { unsigned char a; out[z+2] = stbi__get8(s); out[z+1] = stbi__get8(s); out[z+0] = stbi__get8(s); z += 3; a = (easy == 2 ? stbi__get8(s) : 255); all_a |= a; if (target == 4) out[z++] = a; } } else { int bpp = info.bpp; for (i=0; i < (int) s->img_x; ++i) { stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s)); unsigned int a; out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); all_a |= a; if (target == 4) out[z++] = STBI__BYTECAST(a); } } stbi__skip(s, pad); } } // if alpha channel is all 0s, replace with all 255s if (target == 4 && all_a == 0) for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4) out[i] = 255; if (flip_vertically) { stbi_uc t; for (j=0; j < (int) s->img_y>>1; ++j) { stbi_uc *p1 = out + j *s->img_x*target; stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; for (i=0; i < (int) s->img_x*target; ++i) { t = p1[i]; p1[i] = p2[i]; p2[i] = t; } } } if (req_comp && req_comp != target) { out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); if (out == NULL) return out; // stbi__convert_format frees input on failure } *x = s->img_x; *y = s->img_y; if (comp) *comp = s->img_n; return out; } #endif // Targa Truevision - TGA // by Jonathan Dummer #ifndef STBI_NO_TGA // returns STBI_rgb or whatever, 0 on error static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16) { // only RGB or RGBA (incl. 16bit) or grey allowed if (is_rgb16) *is_rgb16 = 0; switch(bits_per_pixel) { case 8: return STBI_grey; case 16: if(is_grey) return STBI_grey_alpha; // fallthrough case 15: if(is_rgb16) *is_rgb16 = 1; return STBI_rgb; case 24: // fallthrough case 32: return bits_per_pixel/8; default: return 0; } } static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) { int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp; int sz, tga_colormap_type; stbi__get8(s); // discard Offset tga_colormap_type = stbi__get8(s); // colormap type if( tga_colormap_type > 1 ) { stbi__rewind(s); return 0; // only RGB or indexed allowed } tga_image_type = stbi__get8(s); // image type if ( tga_colormap_type == 1 ) { // colormapped (paletted) image if (tga_image_type != 1 && tga_image_type != 9) { stbi__rewind(s); return 0; } stbi__skip(s,4); // skip index of first colormap entry and number of entries sz = stbi__get8(s); // check bits per palette color entry if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) { stbi__rewind(s); return 0; } stbi__skip(s,4); // skip image x and y origin tga_colormap_bpp = sz; } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) { stbi__rewind(s); return 0; // only RGB or grey allowed, +/- RLE } stbi__skip(s,9); // skip colormap specification and image x/y origin tga_colormap_bpp = 0; } tga_w = stbi__get16le(s); if( tga_w < 1 ) { stbi__rewind(s); return 0; // test width } tga_h = stbi__get16le(s); if( tga_h < 1 ) { stbi__rewind(s); return 0; // test height } tga_bits_per_pixel = stbi__get8(s); // bits per pixel stbi__get8(s); // ignore alpha bits if (tga_colormap_bpp != 0) { if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { // when using a colormap, tga_bits_per_pixel is the size of the indexes // I don't think anything but 8 or 16bit indexes makes sense stbi__rewind(s); return 0; } tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); } else { tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL); } if(!tga_comp) { stbi__rewind(s); return 0; } if (x) *x = tga_w; if (y) *y = tga_h; if (comp) *comp = tga_comp; return 1; // seems to have passed everything } static int stbi__tga_test(stbi__context *s) { int res = 0; int sz, tga_color_type; stbi__get8(s); // discard Offset tga_color_type = stbi__get8(s); // color type if ( tga_color_type > 1 ) goto errorEnd; // only RGB or indexed allowed sz = stbi__get8(s); // image type if ( tga_color_type == 1 ) { // colormapped (paletted) image if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9 stbi__skip(s,4); // skip index of first colormap entry and number of entries sz = stbi__get8(s); // check bits per palette color entry if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; stbi__skip(s,4); // skip image x and y origin } else { // "normal" image w/o colormap if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE stbi__skip(s,9); // skip colormap specification and image x/y origin } if ( stbi__get16le(s) < 1 ) goto errorEnd; // test width if ( stbi__get16le(s) < 1 ) goto errorEnd; // test height sz = stbi__get8(s); // bits per pixel if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; res = 1; // if we got this far, everything's good and we can return 1 instead of 0 errorEnd: stbi__rewind(s); return res; } // read 16bit value and convert to 24bit RGB static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) { stbi__uint16 px = (stbi__uint16)stbi__get16le(s); stbi__uint16 fiveBitMask = 31; // we have 3 channels with 5bits each int r = (px >> 10) & fiveBitMask; int g = (px >> 5) & fiveBitMask; int b = px & fiveBitMask; // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later out[0] = (stbi_uc)((r * 255)/31); out[1] = (stbi_uc)((g * 255)/31); out[2] = (stbi_uc)((b * 255)/31); // some people claim that the most significant bit might be used for alpha // (possibly if an alpha-bit is set in the "image descriptor byte") // but that only made 16bit test images completely translucent.. // so let's treat all 15 and 16bit TGAs as RGB with no alpha. } static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { // read in the TGA header stuff int tga_offset = stbi__get8(s); int tga_indexed = stbi__get8(s); int tga_image_type = stbi__get8(s); int tga_is_RLE = 0; int tga_palette_start = stbi__get16le(s); int tga_palette_len = stbi__get16le(s); int tga_palette_bits = stbi__get8(s); int tga_x_origin = stbi__get16le(s); int tga_y_origin = stbi__get16le(s); int tga_width = stbi__get16le(s); int tga_height = stbi__get16le(s); int tga_bits_per_pixel = stbi__get8(s); int tga_comp, tga_rgb16=0; int tga_inverted = stbi__get8(s); // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?) // image data unsigned char *tga_data; unsigned char *tga_palette = NULL; int i, j; unsigned char raw_data[4] = {0}; int RLE_count = 0; int RLE_repeating = 0; int read_next_pixel = 1; STBI_NOTUSED(ri); // do a tiny bit of precessing if ( tga_image_type >= 8 ) { tga_image_type -= 8; tga_is_RLE = 1; } tga_inverted = 1 - ((tga_inverted >> 5) & 1); // If I'm paletted, then I'll use the number of bits from the palette if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16); if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); // tga info *x = tga_width; *y = tga_height; if (comp) *comp = tga_comp; if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0)) return stbi__errpuc("too large", "Corrupt TGA"); tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0); if (!tga_data) return stbi__errpuc("outofmem", "Out of memory"); // skip to the data's starting position (offset usually = 0) stbi__skip(s, tga_offset ); if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) { for (i=0; i < tga_height; ++i) { int row = tga_inverted ? tga_height -i - 1 : i; stbi_uc *tga_row = tga_data + row*tga_width*tga_comp; stbi__getn(s, tga_row, tga_width * tga_comp); } } else { // do I need to load a palette? if ( tga_indexed) { // any data to skip? (offset usually = 0) stbi__skip(s, tga_palette_start ); // load the palette tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0); if (!tga_palette) { STBI_FREE(tga_data); return stbi__errpuc("outofmem", "Out of memory"); } if (tga_rgb16) { stbi_uc *pal_entry = tga_palette; STBI_ASSERT(tga_comp == STBI_rgb); for (i=0; i < tga_palette_len; ++i) { stbi__tga_read_rgb16(s, pal_entry); pal_entry += tga_comp; } } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { STBI_FREE(tga_data); STBI_FREE(tga_palette); return stbi__errpuc("bad palette", "Corrupt TGA"); } } // load the data for (i=0; i < tga_width * tga_height; ++i) { // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? if ( tga_is_RLE ) { if ( RLE_count == 0 ) { // yep, get the next byte as a RLE command int RLE_cmd = stbi__get8(s); RLE_count = 1 + (RLE_cmd & 127); RLE_repeating = RLE_cmd >> 7; read_next_pixel = 1; } else if ( !RLE_repeating ) { read_next_pixel = 1; } } else { read_next_pixel = 1; } // OK, if I need to read a pixel, do it now if ( read_next_pixel ) { // load however much data we did have if ( tga_indexed ) { // read in index, then perform the lookup int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); if ( pal_idx >= tga_palette_len ) { // invalid index pal_idx = 0; } pal_idx *= tga_comp; for (j = 0; j < tga_comp; ++j) { raw_data[j] = tga_palette[pal_idx+j]; } } else if(tga_rgb16) { STBI_ASSERT(tga_comp == STBI_rgb); stbi__tga_read_rgb16(s, raw_data); } else { // read in the data raw for (j = 0; j < tga_comp; ++j) { raw_data[j] = stbi__get8(s); } } // clear the reading flag for the next pixel read_next_pixel = 0; } // end of reading a pixel // copy data for (j = 0; j < tga_comp; ++j) tga_data[i*tga_comp+j] = raw_data[j]; // in case we're in RLE mode, keep counting down --RLE_count; } // do I need to invert the image? if ( tga_inverted ) { for (j = 0; j*2 < tga_height; ++j) { int index1 = j * tga_width * tga_comp; int index2 = (tga_height - 1 - j) * tga_width * tga_comp; for (i = tga_width * tga_comp; i > 0; --i) { unsigned char temp = tga_data[index1]; tga_data[index1] = tga_data[index2]; tga_data[index2] = temp; ++index1; ++index2; } } } // clear my palette, if I had one if ( tga_palette != NULL ) { STBI_FREE( tga_palette ); } } // swap RGB - if the source data was RGB16, it already is in the right order if (tga_comp >= 3 && !tga_rgb16) { unsigned char* tga_pixel = tga_data; for (i=0; i < tga_width * tga_height; ++i) { unsigned char temp = tga_pixel[0]; tga_pixel[0] = tga_pixel[2]; tga_pixel[2] = temp; tga_pixel += tga_comp; } } // convert to target component count if (req_comp && req_comp != tga_comp) tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); // the things I do to get rid of an error message, and yet keep // Microsoft's C compilers happy... [8^( tga_palette_start = tga_palette_len = tga_palette_bits = tga_x_origin = tga_y_origin = 0; // OK, done return tga_data; } #endif // ************************************************************************************************* // Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB #ifndef STBI_NO_PSD static int stbi__psd_test(stbi__context *s) { int r = (stbi__get32be(s) == 0x38425053); stbi__rewind(s); return r; } static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) { int count, nleft, len; count = 0; while ((nleft = pixelCount - count) > 0) { len = stbi__get8(s); if (len == 128) { // No-op. } else if (len < 128) { // Copy next len+1 bytes literally. len++; if (len > nleft) return 0; // corrupt data count += len; while (len) { *p = stbi__get8(s); p += 4; len--; } } else if (len > 128) { stbi_uc val; // Next -len+1 bytes in the dest are replicated from next source byte. // (Interpret len as a negative 8-bit int.) len = 257 - len; if (len > nleft) return 0; // corrupt data val = stbi__get8(s); count += len; while (len) { *p = val; p += 4; len--; } } } return 1; } static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) { int pixelCount; int channelCount, compression; int channel, i; int bitdepth; int w,h; stbi_uc *out; STBI_NOTUSED(ri); // Check identifier if (stbi__get32be(s) != 0x38425053) // "8BPS" return stbi__errpuc("not PSD", "Corrupt PSD image"); // Check file type version. if (stbi__get16be(s) != 1) return stbi__errpuc("wrong version", "Unsupported version of PSD image"); // Skip 6 reserved bytes. stbi__skip(s, 6 ); // Read the number of channels (R, G, B, A, etc). channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); // Read the rows and columns of the image. h = stbi__get32be(s); w = stbi__get32be(s); // Make sure the depth is 8 bits. bitdepth = stbi__get16be(s); if (bitdepth != 8 && bitdepth != 16) return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); // Make sure the color mode is RGB. // Valid options are: // 0: Bitmap // 1: Grayscale // 2: Indexed color // 3: RGB color // 4: CMYK color // 7: Multichannel // 8: Duotone // 9: Lab color if (stbi__get16be(s) != 3) return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) stbi__skip(s,stbi__get32be(s) ); // Skip the image resources. (resolution, pen tool paths, etc) stbi__skip(s, stbi__get32be(s) ); // Skip the reserved data. stbi__skip(s, stbi__get32be(s) ); // Find out if the data is compressed. // Known values: // 0: no compression // 1: RLE compressed compression = stbi__get16be(s); if (compression > 1) return stbi__errpuc("bad compression", "PSD has an unknown compression format"); // Check size if (!stbi__mad3sizes_valid(4, w, h, 0)) return stbi__errpuc("too large", "Corrupt PSD"); // Create the destination image. if (!compression && bitdepth == 16 && bpc == 16) { out = (stbi_uc *) stbi__malloc_mad3(8, w, h, 0); ri->bits_per_channel = 16; } else out = (stbi_uc *) stbi__malloc(4 * w*h); if (!out) return stbi__errpuc("outofmem", "Out of memory"); pixelCount = w*h; // Initialize the data to zero. //memset( out, 0, pixelCount * 4 ); // Finally, the image data. if (compression) { // RLE as used by .PSD and .TIFF // Loop until you get the number of unpacked bytes you are expecting: // Read the next source byte into n. // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. // Else if n is 128, noop. // Endloop // The RLE-compressed data is preceded by a 2-byte data count for each row in the data, // which we're going to just skip. stbi__skip(s, h * channelCount * 2 ); // Read the RLE data by channel. for (channel = 0; channel < 4; channel++) { stbi_uc *p; p = out+channel; if (channel >= channelCount) { // Fill this channel with default data. for (i = 0; i < pixelCount; i++, p += 4) *p = (channel == 3 ? 255 : 0); } else { // Read the RLE data. if (!stbi__psd_decode_rle(s, p, pixelCount)) { STBI_FREE(out); return stbi__errpuc("corrupt", "bad RLE data"); } } } } else { // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image. // Read the data by channel. for (channel = 0; channel < 4; channel++) { if (channel >= channelCount) { // Fill this channel with default data. if (bitdepth == 16 && bpc == 16) { stbi__uint16 *q = ((stbi__uint16 *) out) + channel; stbi__uint16 val = channel == 3 ? 65535 : 0; for (i = 0; i < pixelCount; i++, q += 4) *q = val; } else { stbi_uc *p = out+channel; stbi_uc val = channel == 3 ? 255 : 0; for (i = 0; i < pixelCount; i++, p += 4) *p = val; } } else { if (ri->bits_per_channel == 16) { // output bpc stbi__uint16 *q = ((stbi__uint16 *) out) + channel; for (i = 0; i < pixelCount; i++, q += 4) *q = (stbi__uint16) stbi__get16be(s); } else { stbi_uc *p = out+channel; if (bitdepth == 16) { // input bpc for (i = 0; i < pixelCount; i++, p += 4) *p = (stbi_uc) (stbi__get16be(s) >> 8); } else { for (i = 0; i < pixelCount; i++, p += 4) *p = stbi__get8(s); } } } } } // remove weird white matte from PSD if (channelCount >= 4) { if (ri->bits_per_channel == 16) { for (i=0; i < w*h; ++i) { stbi__uint16 *pixel = (stbi__uint16 *) out + 4*i; if (pixel[3] != 0 && pixel[3] != 65535) { float a = pixel[3] / 65535.0f; float ra = 1.0f / a; float inv_a = 65535.0f * (1 - ra); pixel[0] = (stbi__uint16) (pixel[0]*ra + inv_a); pixel[1] = (stbi__uint16) (pixel[1]*ra + inv_a); pixel[2] = (stbi__uint16) (pixel[2]*ra + inv_a); } } } else { for (i=0; i < w*h; ++i) { unsigned char *pixel = out + 4*i; if (pixel[3] != 0 && pixel[3] != 255) { float a = pixel[3] / 255.0f; float ra = 1.0f / a; float inv_a = 255.0f * (1 - ra); pixel[0] = (unsigned char) (pixel[0]*ra + inv_a); pixel[1] = (unsigned char) (pixel[1]*ra + inv_a); pixel[2] = (unsigned char) (pixel[2]*ra + inv_a); } } } } // convert to desired output format if (req_comp && req_comp != 4) { if (ri->bits_per_channel == 16) out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, 4, req_comp, w, h); else out = stbi__convert_format(out, 4, req_comp, w, h); if (out == NULL) return out; // stbi__convert_format frees input on failure } if (comp) *comp = 4; *y = h; *x = w; return out; } #endif // ************************************************************************************************* // Softimage PIC loader // by Tom Seddon // // See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format // See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ #ifndef STBI_NO_PIC static int stbi__pic_is4(stbi__context *s,const char *str) { int i; for (i=0; i<4; ++i) if (stbi__get8(s) != (stbi_uc)str[i]) return 0; return 1; } static int stbi__pic_test_core(stbi__context *s) { int i; if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) return 0; for(i=0;i<84;++i) stbi__get8(s); if (!stbi__pic_is4(s,"PICT")) return 0; return 1; } typedef struct { stbi_uc size,type,channel; } stbi__pic_packet; static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) { int mask=0x80, i; for (i=0; i<4; ++i, mask>>=1) { if (channel & mask) { if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short"); dest[i]=stbi__get8(s); } } return dest; } static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) { int mask=0x80,i; for (i=0;i<4; ++i, mask>>=1) if (channel&mask) dest[i]=src[i]; } static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result) { int act_comp=0,num_packets=0,y,chained; stbi__pic_packet packets[10]; // this will (should...) cater for even some bizarre stuff like having data // for the same channel in multiple packets. do { stbi__pic_packet *packet; if (num_packets==sizeof(packets)/sizeof(packets[0])) return stbi__errpuc("bad format","too many packets"); packet = &packets[num_packets++]; chained = stbi__get8(s); packet->size = stbi__get8(s); packet->type = stbi__get8(s); packet->channel = stbi__get8(s); act_comp |= packet->channel; if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (reading packets)"); if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp"); } while (chained); *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? for(y=0; ytype) { default: return stbi__errpuc("bad format","packet has bad compression type"); case 0: {//uncompressed int x; for(x=0;xchannel,dest)) return 0; break; } case 1://Pure RLE { int left=width, i; while (left>0) { stbi_uc count,value[4]; count=stbi__get8(s); if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pure read count)"); if (count > left) count = (stbi_uc) left; if (!stbi__readval(s,packet->channel,value)) return 0; for(i=0; ichannel,dest,value); left -= count; } } break; case 2: {//Mixed RLE int left=width; while (left>0) { int count = stbi__get8(s), i; if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (mixed read count)"); if (count >= 128) { // Repeated stbi_uc value[4]; if (count==128) count = stbi__get16be(s); else count -= 127; if (count > left) return stbi__errpuc("bad file","scanline overrun"); if (!stbi__readval(s,packet->channel,value)) return 0; for(i=0;ichannel,dest,value); } else { // Raw ++count; if (count>left) return stbi__errpuc("bad file","scanline overrun"); for(i=0;ichannel,dest)) return 0; } left-=count; } break; } } } } return result; } static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri) { stbi_uc *result; int i, x,y, internal_comp; STBI_NOTUSED(ri); if (!comp) comp = &internal_comp; for (i=0; i<92; ++i) stbi__get8(s); x = stbi__get16be(s); y = stbi__get16be(s); if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)"); if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode"); stbi__get32be(s); //skip `ratio' stbi__get16be(s); //skip `fields' stbi__get16be(s); //skip `pad' // intermediate buffer is RGBA result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0); memset(result, 0xff, x*y*4); if (!stbi__pic_load_core(s,x,y,comp, result)) { STBI_FREE(result); result=0; } *px = x; *py = y; if (req_comp == 0) req_comp = *comp; result=stbi__convert_format(result,4,req_comp,x,y); return result; } static int stbi__pic_test(stbi__context *s) { int r = stbi__pic_test_core(s); stbi__rewind(s); return r; } #endif // ************************************************************************************************* // GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb #ifndef STBI_NO_GIF typedef struct { stbi__int16 prefix; stbi_uc first; stbi_uc suffix; } stbi__gif_lzw; typedef struct { int w,h; stbi_uc *out; // output buffer (always 4 components) stbi_uc *background; // The current "background" as far as a gif is concerned stbi_uc *history; int flags, bgindex, ratio, transparent, eflags; stbi_uc pal[256][4]; stbi_uc lpal[256][4]; stbi__gif_lzw codes[8192]; stbi_uc *color_table; int parse, step; int lflags; int start_x, start_y; int max_x, max_y; int cur_x, cur_y; int line_size; int delay; } stbi__gif; static int stbi__gif_test_raw(stbi__context *s) { int sz; if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0; sz = stbi__get8(s); if (sz != '9' && sz != '7') return 0; if (stbi__get8(s) != 'a') return 0; return 1; } static int stbi__gif_test(stbi__context *s) { int r = stbi__gif_test_raw(s); stbi__rewind(s); return r; } static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) { int i; for (i=0; i < num_entries; ++i) { pal[i][2] = stbi__get8(s); pal[i][1] = stbi__get8(s); pal[i][0] = stbi__get8(s); pal[i][3] = transp == i ? 0 : 255; } } static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) { stbi_uc version; if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return stbi__err("not GIF", "Corrupt GIF"); version = stbi__get8(s); if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); stbi__g_failure_reason = ""; g->w = stbi__get16le(s); g->h = stbi__get16le(s); g->flags = stbi__get8(s); g->bgindex = stbi__get8(s); g->ratio = stbi__get8(s); g->transparent = -1; if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments if (is_info) return 1; if (g->flags & 0x80) stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); return 1; } static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) { stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif)); if (!stbi__gif_header(s, g, comp, 1)) { STBI_FREE(g); stbi__rewind( s ); return 0; } if (x) *x = g->w; if (y) *y = g->h; STBI_FREE(g); return 1; } static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) { stbi_uc *p, *c; int idx; // recurse to decode the prefixes, since the linked-list is backwards, // and working backwards through an interleaved image would be nasty if (g->codes[code].prefix >= 0) stbi__out_gif_code(g, g->codes[code].prefix); if (g->cur_y >= g->max_y) return; idx = g->cur_x + g->cur_y; p = &g->out[idx]; g->history[idx / 4] = 1; c = &g->color_table[g->codes[code].suffix * 4]; if (c[3] > 128) { // don't render transparent pixels; p[0] = c[2]; p[1] = c[1]; p[2] = c[0]; p[3] = c[3]; } g->cur_x += 4; if (g->cur_x >= g->max_x) { g->cur_x = g->start_x; g->cur_y += g->step; while (g->cur_y >= g->max_y && g->parse > 0) { g->step = (1 << g->parse) * g->line_size; g->cur_y = g->start_y + (g->step >> 1); --g->parse; } } } static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) { stbi_uc lzw_cs; stbi__int32 len, init_code; stbi__uint32 first; stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; stbi__gif_lzw *p; lzw_cs = stbi__get8(s); if (lzw_cs > 12) return NULL; clear = 1 << lzw_cs; first = 1; codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; bits = 0; valid_bits = 0; for (init_code = 0; init_code < clear; init_code++) { g->codes[init_code].prefix = -1; g->codes[init_code].first = (stbi_uc) init_code; g->codes[init_code].suffix = (stbi_uc) init_code; } // support no starting clear code avail = clear+2; oldcode = -1; len = 0; for(;;) { if (valid_bits < codesize) { if (len == 0) { len = stbi__get8(s); // start new block if (len == 0) return g->out; } --len; bits |= (stbi__int32) stbi__get8(s) << valid_bits; valid_bits += 8; } else { stbi__int32 code = bits & codemask; bits >>= codesize; valid_bits -= codesize; // @OPTIMIZE: is there some way we can accelerate the non-clear path? if (code == clear) { // clear code codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; avail = clear + 2; oldcode = -1; first = 0; } else if (code == clear + 1) { // end of stream code stbi__skip(s, len); while ((len = stbi__get8(s)) > 0) stbi__skip(s,len); return g->out; } else if (code <= avail) { if (first) { return stbi__errpuc("no clear code", "Corrupt GIF"); } if (oldcode >= 0) { p = &g->codes[avail++]; if (avail > 8192) { return stbi__errpuc("too many codes", "Corrupt GIF"); } p->prefix = (stbi__int16) oldcode; p->first = g->codes[oldcode].first; p->suffix = (code == avail) ? p->first : g->codes[code].first; } else if (code == avail) return stbi__errpuc("illegal code in raster", "Corrupt GIF"); stbi__out_gif_code(g, (stbi__uint16) code); if ((avail & codemask) == 0 && avail <= 0x0FFF) { codesize++; codemask = (1 << codesize) - 1; } oldcode = code; } else { return stbi__errpuc("illegal code in raster", "Corrupt GIF"); } } } } // this function is designed to support animated gifs, although stb_image doesn't support it // two back is the image from two frames ago, used for a very specific disposal format static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back) { int dispose; int first_frame; int pi; int pcount; STBI_NOTUSED(req_comp); // on first frame, any non-written pixels get the background colour (non-transparent) first_frame = 0; if (g->out == 0) { if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header if (!stbi__mad3sizes_valid(4, g->w, g->h, 0)) return stbi__errpuc("too large", "GIF image is too large"); pcount = g->w * g->h; g->out = (stbi_uc *) stbi__malloc(4 * pcount); g->background = (stbi_uc *) stbi__malloc(4 * pcount); g->history = (stbi_uc *) stbi__malloc(pcount); if (!g->out || !g->background || !g->history) return stbi__errpuc("outofmem", "Out of memory"); // image is treated as "transparent" at the start - ie, nothing overwrites the current background; // background colour is only used for pixels that are not rendered first frame, after that "background" // color refers to the color that was there the previous frame. memset(g->out, 0x00, 4 * pcount); memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent) memset(g->history, 0x00, pcount); // pixels that were affected previous frame first_frame = 1; } else { // second frame - how do we dispoase of the previous one? dispose = (g->eflags & 0x1C) >> 2; pcount = g->w * g->h; if ((dispose == 3) && (two_back == 0)) { dispose = 2; // if I don't have an image to revert back to, default to the old background } if (dispose == 3) { // use previous graphic for (pi = 0; pi < pcount; ++pi) { if (g->history[pi]) { memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 ); } } } else if (dispose == 2) { // restore what was changed last frame to background before that frame; for (pi = 0; pi < pcount; ++pi) { if (g->history[pi]) { memcpy( &g->out[pi * 4], &g->background[pi * 4], 4 ); } } } else { // This is a non-disposal case eithe way, so just // leave the pixels as is, and they will become the new background // 1: do not dispose // 0: not specified. } // background is what out is after the undoing of the previou frame; memcpy( g->background, g->out, 4 * g->w * g->h ); } // clear my history; memset( g->history, 0x00, g->w * g->h ); // pixels that were affected previous frame for (;;) { int tag = stbi__get8(s); switch (tag) { case 0x2C: /* Image Descriptor */ { stbi__int32 x, y, w, h; stbi_uc *o; x = stbi__get16le(s); y = stbi__get16le(s); w = stbi__get16le(s); h = stbi__get16le(s); if (((x + w) > (g->w)) || ((y + h) > (g->h))) return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); g->line_size = g->w * 4; g->start_x = x * 4; g->start_y = y * g->line_size; g->max_x = g->start_x + w * 4; g->max_y = g->start_y + h * g->line_size; g->cur_x = g->start_x; g->cur_y = g->start_y; // if the width of the specified rectangle is 0, that means // we may not see *any* pixels or the image is malformed; // to make sure this is caught, move the current y down to // max_y (which is what out_gif_code checks). if (w == 0) g->cur_y = g->max_y; g->lflags = stbi__get8(s); if (g->lflags & 0x40) { g->step = 8 * g->line_size; // first interlaced spacing g->parse = 3; } else { g->step = g->line_size; g->parse = 0; } if (g->lflags & 0x80) { stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); g->color_table = (stbi_uc *) g->lpal; } else if (g->flags & 0x80) { g->color_table = (stbi_uc *) g->pal; } else return stbi__errpuc("missing color table", "Corrupt GIF"); o = stbi__process_gif_raster(s, g); if (!o) return NULL; // if this was the first frame, pcount = g->w * g->h; if (first_frame && (g->bgindex > 0)) { // if first frame, any pixel not drawn to gets the background color for (pi = 0; pi < pcount; ++pi) { if (g->history[pi] == 0) { g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be; memcpy( &g->out[pi * 4], &g->pal[g->bgindex], 4 ); } } } return o; } case 0x21: // Comment Extension. { int len; int ext = stbi__get8(s); if (ext == 0xF9) { // Graphic Control Extension. len = stbi__get8(s); if (len == 4) { g->eflags = stbi__get8(s); g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths. // unset old transparent if (g->transparent >= 0) { g->pal[g->transparent][3] = 255; } if (g->eflags & 0x01) { g->transparent = stbi__get8(s); if (g->transparent >= 0) { g->pal[g->transparent][3] = 0; } } else { // don't need transparent stbi__skip(s, 1); g->transparent = -1; } } else { stbi__skip(s, len); break; } } while ((len = stbi__get8(s)) != 0) { stbi__skip(s, len); } break; } case 0x3B: // gif stream termination code return (stbi_uc *) s; // using '1' causes warning on some compilers default: return stbi__errpuc("unknown code", "Corrupt GIF"); } } } static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp) { if (stbi__gif_test(s)) { int layers = 0; stbi_uc *u = 0; stbi_uc *out = 0; stbi_uc *two_back = 0; stbi__gif g; int stride; memset(&g, 0, sizeof(g)); if (delays) { *delays = 0; } do { u = stbi__gif_load_next(s, &g, comp, req_comp, two_back); if (u == (stbi_uc *) s) u = 0; // end of animated gif marker if (u) { *x = g.w; *y = g.h; ++layers; stride = g.w * g.h * 4; if (out) { out = (stbi_uc*) STBI_REALLOC( out, layers * stride ); if (delays) { *delays = (int*) STBI_REALLOC( *delays, sizeof(int) * layers ); } } else { out = (stbi_uc*)stbi__malloc( layers * stride ); if (delays) { *delays = (int*) stbi__malloc( layers * sizeof(int) ); } } memcpy( out + ((layers - 1) * stride), u, stride ); if (layers >= 2) { two_back = out - 2 * stride; } if (delays) { (*delays)[layers - 1U] = g.delay; } } } while (u != 0); // free temp buffer; STBI_FREE(g.out); STBI_FREE(g.history); STBI_FREE(g.background); // do the final conversion after loading everything; if (req_comp && req_comp != 4) out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h); *z = layers; return out; } else { return stbi__errpuc("not GIF", "Image was not as a gif type."); } } static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *u = 0; stbi__gif g; memset(&g, 0, sizeof(g)); STBI_NOTUSED(ri); u = stbi__gif_load_next(s, &g, comp, req_comp, 0); if (u == (stbi_uc *) s) u = 0; // end of animated gif marker if (u) { *x = g.w; *y = g.h; // moved conversion to after successful load so that the same // can be done for multiple frames. if (req_comp && req_comp != 4) u = stbi__convert_format(u, 4, req_comp, g.w, g.h); } else if (g.out) { // if there was an error and we allocated an image buffer, free it! STBI_FREE(g.out); } // free buffers needed for multiple frame loading; STBI_FREE(g.history); STBI_FREE(g.background); return u; } static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) { return stbi__gif_info_raw(s,x,y,comp); } #endif // ************************************************************************************************* // Radiance RGBE HDR loader // originally by Nicolas Schulz #ifndef STBI_NO_HDR static int stbi__hdr_test_core(stbi__context *s, const char *signature) { int i; for (i=0; signature[i]; ++i) if (stbi__get8(s) != signature[i]) return 0; stbi__rewind(s); return 1; } static int stbi__hdr_test(stbi__context* s) { int r = stbi__hdr_test_core(s, "#?RADIANCE\n"); stbi__rewind(s); if(!r) { r = stbi__hdr_test_core(s, "#?RGBE\n"); stbi__rewind(s); } return r; } #define STBI__HDR_BUFLEN 1024 static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) { int len=0; char c = '\0'; c = (char) stbi__get8(z); while (!stbi__at_eof(z) && c != '\n') { buffer[len++] = c; if (len == STBI__HDR_BUFLEN-1) { // flush to end of line while (!stbi__at_eof(z) && stbi__get8(z) != '\n') ; break; } c = (char) stbi__get8(z); } buffer[len] = 0; return buffer; } static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) { if ( input[3] != 0 ) { float f1; // Exponent f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); if (req_comp <= 2) output[0] = (input[0] + input[1] + input[2]) * f1 / 3; else { output[0] = input[0] * f1; output[1] = input[1] * f1; output[2] = input[2] * f1; } if (req_comp == 2) output[1] = 1; if (req_comp == 4) output[3] = 1; } else { switch (req_comp) { case 4: output[3] = 1; /* fallthrough */ case 3: output[0] = output[1] = output[2] = 0; break; case 2: output[1] = 1; /* fallthrough */ case 1: output[0] = 0; break; } } } static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { char buffer[STBI__HDR_BUFLEN]; char *token; int valid = 0; int width, height; stbi_uc *scanline; float *hdr_data; int len; unsigned char count, value; int i, j, k, c1,c2, z; const char *headerToken; STBI_NOTUSED(ri); // Check identifier headerToken = stbi__hdr_gettoken(s,buffer); if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0) return stbi__errpf("not HDR", "Corrupt HDR image"); // Parse header for(;;) { token = stbi__hdr_gettoken(s,buffer); if (token[0] == 0) break; if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; } if (!valid) return stbi__errpf("unsupported format", "Unsupported HDR format"); // Parse width and height // can't use sscanf() if we're not using stdio! token = stbi__hdr_gettoken(s,buffer); if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); token += 3; height = (int) strtol(token, &token, 10); while (*token == ' ') ++token; if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); token += 3; width = (int) strtol(token, NULL, 10); *x = width; *y = height; if (comp) *comp = 3; if (req_comp == 0) req_comp = 3; if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0)) return stbi__errpf("too large", "HDR image is too large"); // Read data hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0); if (!hdr_data) return stbi__errpf("outofmem", "Out of memory"); // Load image data // image data is stored as some number of sca if ( width < 8 || width >= 32768) { // Read flat data for (j=0; j < height; ++j) { for (i=0; i < width; ++i) { stbi_uc rgbe[4]; main_decode_loop: stbi__getn(s, rgbe, 4); stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); } } } else { // Read RLE-encoded data scanline = NULL; for (j = 0; j < height; ++j) { c1 = stbi__get8(s); c2 = stbi__get8(s); len = stbi__get8(s); if (c1 != 2 || c2 != 2 || (len & 0x80)) { // not run-length encoded, so we have to actually use THIS data as a decoded // pixel (note this can't be a valid pixel--one of RGB must be >= 128) stbi_uc rgbe[4]; rgbe[0] = (stbi_uc) c1; rgbe[1] = (stbi_uc) c2; rgbe[2] = (stbi_uc) len; rgbe[3] = (stbi_uc) stbi__get8(s); stbi__hdr_convert(hdr_data, rgbe, req_comp); i = 1; j = 0; STBI_FREE(scanline); goto main_decode_loop; // yes, this makes no sense } len <<= 8; len |= stbi__get8(s); if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } if (scanline == NULL) { scanline = (stbi_uc *) stbi__malloc_mad2(width, 4, 0); if (!scanline) { STBI_FREE(hdr_data); return stbi__errpf("outofmem", "Out of memory"); } } for (k = 0; k < 4; ++k) { int nleft; i = 0; while ((nleft = width - i) > 0) { count = stbi__get8(s); if (count > 128) { // Run value = stbi__get8(s); count -= 128; if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } for (z = 0; z < count; ++z) scanline[i++ * 4 + k] = value; } else { // Dump if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } for (z = 0; z < count; ++z) scanline[i++ * 4 + k] = stbi__get8(s); } } } for (i=0; i < width; ++i) stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); } if (scanline) STBI_FREE(scanline); } return hdr_data; } static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) { char buffer[STBI__HDR_BUFLEN]; char *token; int valid = 0; int dummy; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (stbi__hdr_test(s) == 0) { stbi__rewind( s ); return 0; } for(;;) { token = stbi__hdr_gettoken(s,buffer); if (token[0] == 0) break; if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; } if (!valid) { stbi__rewind( s ); return 0; } token = stbi__hdr_gettoken(s,buffer); if (strncmp(token, "-Y ", 3)) { stbi__rewind( s ); return 0; } token += 3; *y = (int) strtol(token, &token, 10); while (*token == ' ') ++token; if (strncmp(token, "+X ", 3)) { stbi__rewind( s ); return 0; } token += 3; *x = (int) strtol(token, NULL, 10); *comp = 3; return 1; } #endif // STBI_NO_HDR #ifndef STBI_NO_BMP static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) { void *p; stbi__bmp_data info; info.all_a = 255; p = stbi__bmp_parse_header(s, &info); stbi__rewind( s ); if (p == NULL) return 0; if (x) *x = s->img_x; if (y) *y = s->img_y; if (comp) *comp = info.ma ? 4 : 3; return 1; } #endif #ifndef STBI_NO_PSD static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) { int channelCount, dummy, depth; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (stbi__get32be(s) != 0x38425053) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 1) { stbi__rewind( s ); return 0; } stbi__skip(s, 6); channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) { stbi__rewind( s ); return 0; } *y = stbi__get32be(s); *x = stbi__get32be(s); depth = stbi__get16be(s); if (depth != 8 && depth != 16) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 3) { stbi__rewind( s ); return 0; } *comp = 4; return 1; } static int stbi__psd_is16(stbi__context *s) { int channelCount, depth; if (stbi__get32be(s) != 0x38425053) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 1) { stbi__rewind( s ); return 0; } stbi__skip(s, 6); channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) { stbi__rewind( s ); return 0; } (void) stbi__get32be(s); (void) stbi__get32be(s); depth = stbi__get16be(s); if (depth != 16) { stbi__rewind( s ); return 0; } return 1; } #endif #ifndef STBI_NO_PIC static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) { int act_comp=0,num_packets=0,chained,dummy; stbi__pic_packet packets[10]; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) { stbi__rewind(s); return 0; } stbi__skip(s, 88); *x = stbi__get16be(s); *y = stbi__get16be(s); if (stbi__at_eof(s)) { stbi__rewind( s); return 0; } if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) { stbi__rewind( s ); return 0; } stbi__skip(s, 8); do { stbi__pic_packet *packet; if (num_packets==sizeof(packets)/sizeof(packets[0])) return 0; packet = &packets[num_packets++]; chained = stbi__get8(s); packet->size = stbi__get8(s); packet->type = stbi__get8(s); packet->channel = stbi__get8(s); act_comp |= packet->channel; if (stbi__at_eof(s)) { stbi__rewind( s ); return 0; } if (packet->size != 8) { stbi__rewind( s ); return 0; } } while (chained); *comp = (act_comp & 0x10 ? 4 : 3); return 1; } #endif // ************************************************************************************************* // Portable Gray Map and Portable Pixel Map loader // by Ken Miller // // PGM: http://netpbm.sourceforge.net/doc/pgm.html // PPM: http://netpbm.sourceforge.net/doc/ppm.html // // Known limitations: // Does not support comments in the header section // Does not support ASCII image data (formats P2 and P3) // Does not support 16-bit-per-channel #ifndef STBI_NO_PNM static int stbi__pnm_test(stbi__context *s) { char p, t; p = (char) stbi__get8(s); t = (char) stbi__get8(s); if (p != 'P' || (t != '5' && t != '6')) { stbi__rewind( s ); return 0; } return 1; } static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *out; STBI_NOTUSED(ri); if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n)) return 0; *x = s->img_x; *y = s->img_y; if (comp) *comp = s->img_n; if (!stbi__mad3sizes_valid(s->img_n, s->img_x, s->img_y, 0)) return stbi__errpuc("too large", "PNM too large"); out = (stbi_uc *) stbi__malloc_mad3(s->img_n, s->img_x, s->img_y, 0); if (!out) return stbi__errpuc("outofmem", "Out of memory"); stbi__getn(s, out, s->img_n * s->img_x * s->img_y); if (req_comp && req_comp != s->img_n) { out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); if (out == NULL) return out; // stbi__convert_format frees input on failure } return out; } static int stbi__pnm_isspace(char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; } static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) { for (;;) { while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) *c = (char) stbi__get8(s); if (stbi__at_eof(s) || *c != '#') break; while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' ) *c = (char) stbi__get8(s); } } static int stbi__pnm_isdigit(char c) { return c >= '0' && c <= '9'; } static int stbi__pnm_getinteger(stbi__context *s, char *c) { int value = 0; while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { value = value*10 + (*c - '0'); *c = (char) stbi__get8(s); } return value; } static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) { int maxv, dummy; char c, p, t; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; stbi__rewind(s); // Get identifier p = (char) stbi__get8(s); t = (char) stbi__get8(s); if (p != 'P' || (t != '5' && t != '6')) { stbi__rewind(s); return 0; } *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm c = (char) stbi__get8(s); stbi__pnm_skip_whitespace(s, &c); *x = stbi__pnm_getinteger(s, &c); // read width stbi__pnm_skip_whitespace(s, &c); *y = stbi__pnm_getinteger(s, &c); // read height stbi__pnm_skip_whitespace(s, &c); maxv = stbi__pnm_getinteger(s, &c); // read max value if (maxv > 255) return stbi__err("max value > 255", "PPM image not 8-bit"); else return 1; } #endif static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) { #ifndef STBI_NO_JPEG if (stbi__jpeg_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PNG if (stbi__png_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_GIF if (stbi__gif_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_BMP if (stbi__bmp_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PSD if (stbi__psd_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PIC if (stbi__pic_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PNM if (stbi__pnm_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_HDR if (stbi__hdr_info(s, x, y, comp)) return 1; #endif // test tga last because it's a crappy test! #ifndef STBI_NO_TGA if (stbi__tga_info(s, x, y, comp)) return 1; #endif return stbi__err("unknown image type", "Image not of any known type, or corrupt"); } static int stbi__is_16_main(stbi__context *s) { #ifndef STBI_NO_PNG if (stbi__png_is16(s)) return 1; #endif #ifndef STBI_NO_PSD if (stbi__psd_is16(s)) return 1; #endif return 0; } #ifndef STBI_NO_STDIO STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) { FILE *f = stbi__fopen(filename, "rb"); int result; if (!f) return stbi__err("can't fopen", "Unable to open file"); result = stbi_info_from_file(f, x, y, comp); fclose(f); return result; } STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) { int r; stbi__context s; long pos = ftell(f); stbi__start_file(&s, f); r = stbi__info_main(&s,x,y,comp); fseek(f,pos,SEEK_SET); return r; } STBIDEF int stbi_is_16_bit(char const *filename) { FILE *f = stbi__fopen(filename, "rb"); int result; if (!f) return stbi__err("can't fopen", "Unable to open file"); result = stbi_is_16_bit_from_file(f); fclose(f); return result; } STBIDEF int stbi_is_16_bit_from_file(FILE *f) { int r; stbi__context s; long pos = ftell(f); stbi__start_file(&s, f); r = stbi__is_16_main(&s); fseek(f,pos,SEEK_SET); return r; } #endif // !STBI_NO_STDIO STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__info_main(&s,x,y,comp); } STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); return stbi__info_main(&s,x,y,comp); } STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__is_16_main(&s); } STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); return stbi__is_16_main(&s); } #endif // STB_IMAGE_IMPLEMENTATION /* revision history: 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs 2.19 (2018-02-11) fix warning 2.18 (2018-01-30) fix warnings 2.17 (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug 1-bit BMP *_is_16_bit api avoid warnings 2.16 (2017-07-23) all functions have 16-bit variants; STBI_NO_STDIO works again; compilation fixes; fix rounding in unpremultiply; optimize vertical flip; disable raw_len validation; documentation fixes 2.15 (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode; warning fixes; disable run-time SSE detection on gcc; uniform handling of optional "return" values; thread-safe initialization of zlib tables 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs 2.13 (2016-11-29) add 16-bit API, only supported for PNG right now 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes 2.11 (2016-04-02) allocate large structures on the stack remove white matting for transparent PSD fix reported channel count for PNG & BMP re-enable SSE2 in non-gcc 64-bit support RGB-formatted JPEG read 16-bit PNGs (only as 8-bit) 2.10 (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED 2.09 (2016-01-16) allow comments in PNM files 16-bit-per-pixel TGA (not bit-per-component) info() for TGA could break due to .hdr handling info() for BMP to shares code instead of sloppy parse can use STBI_REALLOC_SIZED if allocator doesn't support realloc code cleanup 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA 2.07 (2015-09-13) fix compiler warnings partial animated GIF support limited 16-bpc PSD support #ifdef unused functions bug with < 92 byte PIC,PNM,HDR,TGA 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit 2.03 (2015-04-12) extra corruption checking (mmozeiko) stbi_set_flip_vertically_on_load (nguillemot) fix NEON support; fix mingw support 2.02 (2015-01-19) fix incorrect assert, fix warning 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG 2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) progressive JPEG (stb) PGM/PPM support (Ken Miller) STBI_MALLOC,STBI_REALLOC,STBI_FREE GIF bugfix -- seemingly never worked STBI_NO_*, STBI_ONLY_* 1.48 (2014-12-14) fix incorrectly-named assert() 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) optimize PNG (ryg) fix bug in interlaced PNG with user-specified channel count (stb) 1.46 (2014-08-26) fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG 1.45 (2014-08-16) fix MSVC-ARM internal compiler error by wrapping malloc 1.44 (2014-08-07) various warning fixes from Ronny Chevalier 1.43 (2014-07-15) fix MSVC-only compiler problem in code changed in 1.42 1.42 (2014-07-09) don't define _CRT_SECURE_NO_WARNINGS (affects user code) fixes to stbi__cleanup_jpeg path added STBI_ASSERT to avoid requiring assert.h 1.41 (2014-06-25) fix search&replace from 1.36 that messed up comments/error messages 1.40 (2014-06-22) fix gcc struct-initialization warning 1.39 (2014-06-15) fix to TGA optimization when req_comp != number of components in TGA; fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) add support for BMP version 5 (more ignored fields) 1.38 (2014-06-06) suppress MSVC warnings on integer casts truncating values fix accidental rename of 'skip' field of I/O 1.37 (2014-06-04) remove duplicate typedef 1.36 (2014-06-03) convert to header file single-file library if de-iphone isn't set, load iphone images color-swapped instead of returning NULL 1.35 (2014-05-27) various warnings fix broken STBI_SIMD path fix bug where stbi_load_from_file no longer left file pointer in correct place fix broken non-easy path for 32-bit BMP (possibly never used) TGA optimization by Arseny Kapoulkine 1.34 (unknown) use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case 1.33 (2011-07-14) make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements 1.32 (2011-07-13) support for "info" function for all supported filetypes (SpartanJ) 1.31 (2011-06-20) a few more leak fixes, bug in PNG handling (SpartanJ) 1.30 (2011-06-11) added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) removed deprecated format-specific test/load functions removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) fix inefficiency in decoding 32-bit BMP (David Woo) 1.29 (2010-08-16) various warning fixes from Aurelien Pocheville 1.28 (2010-08-01) fix bug in GIF palette transparency (SpartanJ) 1.27 (2010-08-01) cast-to-stbi_uc to fix warnings 1.26 (2010-07-24) fix bug in file buffering for PNG reported by SpartanJ 1.25 (2010-07-17) refix trans_data warning (Won Chun) 1.24 (2010-07-12) perf improvements reading from files on platforms with lock-heavy fgetc() minor perf improvements for jpeg deprecated type-specific functions so we'll get feedback if they're needed attempt to fix trans_data warning (Won Chun) 1.23 fixed bug in iPhone support 1.22 (2010-07-10) removed image *writing* support stbi_info support from Jetro Lauha GIF support from Jean-Marc Lienher iPhone PNG-extensions from James Brown warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) 1.21 fix use of 'stbi_uc' in header (reported by jon blow) 1.20 added support for Softimage PIC, by Tom Seddon 1.19 bug in interlaced PNG corruption check (found by ryg) 1.18 (2008-08-02) fix a threading bug (local mutable static) 1.17 support interlaced PNG 1.16 major bugfix - stbi__convert_format converted one too many pixels 1.15 initialize some fields for thread safety 1.14 fix threadsafe conversion bug header-file-only version (#define STBI_HEADER_FILE_ONLY before including) 1.13 threadsafe 1.12 const qualifiers in the API 1.11 Support installable IDCT, colorspace conversion routines 1.10 Fixes for 64-bit (don't use "unsigned long") optimized upsampling by Fabian "ryg" Giesen 1.09 Fix format-conversion for PSD code (bad global variables!) 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz 1.07 attempt to fix C++ warning/errors again 1.06 attempt to fix C++ warning/errors again 1.05 fix TGA loading to return correct *comp and use good luminance calc 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR 1.02 support for (subset of) HDR files, float interface for preferred access to them 1.01 fix bug: possible bug in handling right-side up bmps... not sure fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all 1.00 interface to zlib that skips zlib header 0.99 correct handling of alpha in palette 0.98 TGA loader by lonesock; dynamically add loaders (untested) 0.97 jpeg errors on too large a file; also catch another malloc failure 0.96 fix detection of invalid v value - particleman@mollyrocket forum 0.95 during header scan, seek to markers in case of padding 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same 0.93 handle jpegtran output; verbose errors 0.92 read 4,8,16,24,32-bit BMP files of several formats 0.91 output 24-bit Windows 3.0 BMP files 0.90 fix a few more warnings; bump version number to approach 1.0 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd 0.60 fix compiling as c++ 0.59 fix warnings: merge Dave Moore's -Wall fixes 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available 0.56 fix bug: zlib uncompressed mode len vs. nlen 0.55 fix bug: restart_interval not initialized to 0 0.54 allow NULL for 'int *comp' 0.53 fix bug in png 3->4; speedup png decoding 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments 0.51 obey req_comp requests, 1-component jpegs return as 1-component, on 'test' only check type, not whether we support this variant 0.50 (2006-11-19) first released version */ /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ goxel-0.11.0/ext_src/yocto/ext/stb_image_resize.h000077500000000000000000003425451435762723100220310ustar00rootroot00000000000000/* stb_image_resize - v0.96 - public domain image resizing by Jorge L Rodriguez (@VinoBS) - 2014 http://github.com/nothings/stb Written with emphasis on usability, portability, and efficiency. (No SIMD or threads, so it be easily outperformed by libs that use those.) Only scaling and translation is supported, no rotations or shears. Easy API downsamples w/Mitchell filter, upsamples w/cubic interpolation. COMPILING & LINKING In one C/C++ file that #includes this file, do this: #define STB_IMAGE_RESIZE_IMPLEMENTATION before the #include. That will create the implementation in that file. QUICKSTART stbir_resize_uint8( input_pixels , in_w , in_h , 0, output_pixels, out_w, out_h, 0, num_channels) stbir_resize_float(...) stbir_resize_uint8_srgb( input_pixels , in_w , in_h , 0, output_pixels, out_w, out_h, 0, num_channels , alpha_chan , 0) stbir_resize_uint8_srgb_edgemode( input_pixels , in_w , in_h , 0, output_pixels, out_w, out_h, 0, num_channels , alpha_chan , 0, STBIR_EDGE_CLAMP) // WRAP/REFLECT/ZERO FULL API See the "header file" section of the source for API documentation. ADDITIONAL DOCUMENTATION SRGB & FLOATING POINT REPRESENTATION The sRGB functions presume IEEE floating point. If you do not have IEEE floating point, define STBIR_NON_IEEE_FLOAT. This will use a slower implementation. MEMORY ALLOCATION The resize functions here perform a single memory allocation using malloc. To control the memory allocation, before the #include that triggers the implementation, do: #define STBIR_MALLOC(size,context) ... #define STBIR_FREE(ptr,context) ... Each resize function makes exactly one call to malloc/free, so to use temp memory, store the temp memory in the context and return that. ASSERT Define STBIR_ASSERT(boolval) to override assert() and not use assert.h OPTIMIZATION Define STBIR_SATURATE_INT to compute clamp values in-range using integer operations instead of float operations. This may be faster on some platforms. DEFAULT FILTERS For functions which don't provide explicit control over what filters to use, you can change the compile-time defaults with #define STBIR_DEFAULT_FILTER_UPSAMPLE STBIR_FILTER_something #define STBIR_DEFAULT_FILTER_DOWNSAMPLE STBIR_FILTER_something See stbir_filter in the header-file section for the list of filters. NEW FILTERS A number of 1D filter kernels are used. For a list of supported filters see the stbir_filter enum. To add a new filter, write a filter function and add it to stbir__filter_info_table. PROGRESS For interactive use with slow resize operations, you can install a progress-report callback: #define STBIR_PROGRESS_REPORT(val) some_func(val) The parameter val is a float which goes from 0 to 1 as progress is made. For example: static void my_progress_report(float progress); #define STBIR_PROGRESS_REPORT(val) my_progress_report(val) #define STB_IMAGE_RESIZE_IMPLEMENTATION #include "stb_image_resize.h" static void my_progress_report(float progress) { printf("Progress: %f%%\n", progress*100); } MAX CHANNELS If your image has more than 64 channels, define STBIR_MAX_CHANNELS to the max you'll have. ALPHA CHANNEL Most of the resizing functions provide the ability to control how the alpha channel of an image is processed. The important things to know about this: 1. The best mathematically-behaved version of alpha to use is called "premultiplied alpha", in which the other color channels have had the alpha value multiplied in. If you use premultiplied alpha, linear filtering (such as image resampling done by this library, or performed in texture units on GPUs) does the "right thing". While premultiplied alpha is standard in the movie CGI industry, it is still uncommon in the videogame/real-time world. If you linearly filter non-premultiplied alpha, strange effects occur. (For example, the 50/50 average of 99% transparent bright green and 1% transparent black produces 50% transparent dark green when non-premultiplied, whereas premultiplied it produces 50% transparent near-black. The former introduces green energy that doesn't exist in the source image.) 2. Artists should not edit premultiplied-alpha images; artists want non-premultiplied alpha images. Thus, art tools generally output non-premultiplied alpha images. 3. You will get best results in most cases by converting images to premultiplied alpha before processing them mathematically. 4. If you pass the flag STBIR_FLAG_ALPHA_PREMULTIPLIED, the resizer does not do anything special for the alpha channel; it is resampled identically to other channels. This produces the correct results for premultiplied-alpha images, but produces less-than-ideal results for non-premultiplied-alpha images. 5. If you do not pass the flag STBIR_FLAG_ALPHA_PREMULTIPLIED, then the resizer weights the contribution of input pixels based on their alpha values, or, equivalently, it multiplies the alpha value into the color channels, resamples, then divides by the resultant alpha value. Input pixels which have alpha=0 do not contribute at all to output pixels unless _all_ of the input pixels affecting that output pixel have alpha=0, in which case the result for that pixel is the same as it would be without STBIR_FLAG_ALPHA_PREMULTIPLIED. However, this is only true for input images in integer formats. For input images in float format, input pixels with alpha=0 have no effect, and output pixels which have alpha=0 will be 0 in all channels. (For float images, you can manually achieve the same result by adding a tiny epsilon value to the alpha channel of every image, and then subtracting or clamping it at the end.) 6. You can suppress the behavior described in #5 and make all-0-alpha pixels have 0 in all channels by #defining STBIR_NO_ALPHA_EPSILON. 7. You can separately control whether the alpha channel is interpreted as linear or affected by the colorspace. By default it is linear; you almost never want to apply the colorspace. (For example, graphics hardware does not apply sRGB conversion to the alpha channel.) CONTRIBUTORS Jorge L Rodriguez: Implementation Sean Barrett: API design, optimizations Aras Pranckevicius: bugfix Nathan Reed: warning fixes REVISIONS 0.96 (2019-03-04) fixed warnings 0.95 (2017-07-23) fixed warnings 0.94 (2017-03-18) fixed warnings 0.93 (2017-03-03) fixed bug with certain combinations of heights 0.92 (2017-01-02) fix integer overflow on large (>2GB) images 0.91 (2016-04-02) fix warnings; fix handling of subpixel regions 0.90 (2014-09-17) first released version LICENSE See end of file for license information. TODO Don't decode all of the image data when only processing a partial tile Don't use full-width decode buffers when only processing a partial tile When processing wide images, break processing into tiles so data fits in L1 cache Installable filters? Resize that respects alpha test coverage (Reference code: FloatImage::alphaTestCoverage and FloatImage::scaleAlphaToCoverage: https://code.google.com/p/nvidia-texture-tools/source/browse/trunk/src/nvimage/FloatImage.cpp ) */ #ifndef STBIR_INCLUDE_STB_IMAGE_RESIZE_H #define STBIR_INCLUDE_STB_IMAGE_RESIZE_H #ifdef _MSC_VER typedef unsigned char stbir_uint8; typedef unsigned short stbir_uint16; typedef unsigned int stbir_uint32; #else #include typedef uint8_t stbir_uint8; typedef uint16_t stbir_uint16; typedef uint32_t stbir_uint32; #endif #ifndef STBIRDEF #ifdef STB_IMAGE_RESIZE_STATIC #define STBIRDEF static #else #ifdef __cplusplus #define STBIRDEF extern "C" #else #define STBIRDEF extern #endif #endif #endif ////////////////////////////////////////////////////////////////////////////// // // Easy-to-use API: // // * "input pixels" points to an array of image data with 'num_channels' channels (e.g. RGB=3, RGBA=4) // * input_w is input image width (x-axis), input_h is input image height (y-axis) // * stride is the offset between successive rows of image data in memory, in bytes. you can // specify 0 to mean packed continuously in memory // * alpha channel is treated identically to other channels. // * colorspace is linear or sRGB as specified by function name // * returned result is 1 for success or 0 in case of an error. // #define STBIR_ASSERT() to trigger an assert on parameter validation errors. // * Memory required grows approximately linearly with input and output size, but with // discontinuities at input_w == output_w and input_h == output_h. // * These functions use a "default" resampling filter defined at compile time. To change the filter, // you can change the compile-time defaults by #defining STBIR_DEFAULT_FILTER_UPSAMPLE // and STBIR_DEFAULT_FILTER_DOWNSAMPLE, or you can use the medium-complexity API. STBIRDEF int stbir_resize_uint8( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels); STBIRDEF int stbir_resize_float( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, float *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels); // The following functions interpret image data as gamma-corrected sRGB. // Specify STBIR_ALPHA_CHANNEL_NONE if you have no alpha channel, // or otherwise provide the index of the alpha channel. Flags value // of 0 will probably do the right thing if you're not sure what // the flags mean. #define STBIR_ALPHA_CHANNEL_NONE -1 // Set this flag if your texture has premultiplied alpha. Otherwise, stbir will // use alpha-weighted resampling (effectively premultiplying, resampling, // then unpremultiplying). #define STBIR_FLAG_ALPHA_PREMULTIPLIED (1 << 0) // The specified alpha channel should be handled as gamma-corrected value even // when doing sRGB operations. #define STBIR_FLAG_ALPHA_USES_COLORSPACE (1 << 1) STBIRDEF int stbir_resize_uint8_srgb(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags); typedef enum { STBIR_EDGE_CLAMP = 1, STBIR_EDGE_REFLECT = 2, STBIR_EDGE_WRAP = 3, STBIR_EDGE_ZERO = 4, } stbir_edge; // This function adds the ability to specify how requests to sample off the edge of the image are handled. STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode); ////////////////////////////////////////////////////////////////////////////// // // Medium-complexity API // // This extends the easy-to-use API as follows: // // * Alpha-channel can be processed separately // * If alpha_channel is not STBIR_ALPHA_CHANNEL_NONE // * Alpha channel will not be gamma corrected (unless flags&STBIR_FLAG_GAMMA_CORRECT) // * Filters will be weighted by alpha channel (unless flags&STBIR_FLAG_ALPHA_PREMULTIPLIED) // * Filter can be selected explicitly // * uint16 image type // * sRGB colorspace available for all types // * context parameter for passing to STBIR_MALLOC typedef enum { STBIR_FILTER_DEFAULT = 0, // use same filter type that easy-to-use API chooses STBIR_FILTER_BOX = 1, // A trapezoid w/1-pixel wide ramps, same result as box for integer scale ratios STBIR_FILTER_TRIANGLE = 2, // On upsampling, produces same results as bilinear texture filtering STBIR_FILTER_CUBICBSPLINE = 3, // The cubic b-spline (aka Mitchell-Netrevalli with B=1,C=0), gaussian-esque STBIR_FILTER_CATMULLROM = 4, // An interpolating cubic spline STBIR_FILTER_MITCHELL = 5, // Mitchell-Netrevalli filter with B=1/3, C=1/3 } stbir_filter; typedef enum { STBIR_COLORSPACE_LINEAR, STBIR_COLORSPACE_SRGB, STBIR_MAX_COLORSPACES, } stbir_colorspace; // The following functions are all identical except for the type of the image data STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context); STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels , int input_w , int input_h , int input_stride_in_bytes, stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context); STBIRDEF int stbir_resize_float_generic( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, float *output_pixels , int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context); ////////////////////////////////////////////////////////////////////////////// // // Full-complexity API // // This extends the medium API as follows: // // * uint32 image type // * not typesafe // * separate filter types for each axis // * separate edge modes for each axis // * can specify scale explicitly for subpixel correctness // * can specify image source tile using texture coordinates typedef enum { STBIR_TYPE_UINT8 , STBIR_TYPE_UINT16, STBIR_TYPE_UINT32, STBIR_TYPE_FLOAT , STBIR_MAX_TYPES } stbir_datatype; STBIRDEF int stbir_resize( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context); STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context, float x_scale, float y_scale, float x_offset, float y_offset); STBIRDEF int stbir_resize_region( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context, float s0, float t0, float s1, float t1); // (s0, t0) & (s1, t1) are the top-left and bottom right corner (uv addressing style: [0, 1]x[0, 1]) of a region of the input image to use. // // //// end header file ///////////////////////////////////////////////////// #endif // STBIR_INCLUDE_STB_IMAGE_RESIZE_H #ifdef STB_IMAGE_RESIZE_IMPLEMENTATION #ifndef STBIR_ASSERT #include #define STBIR_ASSERT(x) assert(x) #endif // For memset #include #include #ifndef STBIR_MALLOC #include // use comma operator to evaluate c, to avoid "unused parameter" warnings #define STBIR_MALLOC(size,c) ((void)(c), malloc(size)) #define STBIR_FREE(ptr,c) ((void)(c), free(ptr)) #endif #ifndef _MSC_VER #ifdef __cplusplus #define stbir__inline inline #else #define stbir__inline #endif #else #define stbir__inline __forceinline #endif // should produce compiler error if size is wrong typedef unsigned char stbir__validate_uint32[sizeof(stbir_uint32) == 4 ? 1 : -1]; #ifdef _MSC_VER #define STBIR__NOTUSED(v) (void)(v) #else #define STBIR__NOTUSED(v) (void)sizeof(v) #endif #define STBIR__ARRAY_SIZE(a) (sizeof((a))/sizeof((a)[0])) #ifndef STBIR_DEFAULT_FILTER_UPSAMPLE #define STBIR_DEFAULT_FILTER_UPSAMPLE STBIR_FILTER_CATMULLROM #endif #ifndef STBIR_DEFAULT_FILTER_DOWNSAMPLE #define STBIR_DEFAULT_FILTER_DOWNSAMPLE STBIR_FILTER_MITCHELL #endif #ifndef STBIR_PROGRESS_REPORT #define STBIR_PROGRESS_REPORT(float_0_to_1) #endif #ifndef STBIR_MAX_CHANNELS #define STBIR_MAX_CHANNELS 64 #endif #if STBIR_MAX_CHANNELS > 65536 #error "Too many channels; STBIR_MAX_CHANNELS must be no more than 65536." // because we store the indices in 16-bit variables #endif // This value is added to alpha just before premultiplication to avoid // zeroing out color values. It is equivalent to 2^-80. If you don't want // that behavior (it may interfere if you have floating point images with // very small alpha values) then you can define STBIR_NO_ALPHA_EPSILON to // disable it. #ifndef STBIR_ALPHA_EPSILON #define STBIR_ALPHA_EPSILON ((float)1 / (1 << 20) / (1 << 20) / (1 << 20) / (1 << 20)) #endif #ifdef _MSC_VER #define STBIR__UNUSED_PARAM(v) (void)(v) #else #define STBIR__UNUSED_PARAM(v) (void)sizeof(v) #endif // must match stbir_datatype static unsigned char stbir__type_size[] = { 1, // STBIR_TYPE_UINT8 2, // STBIR_TYPE_UINT16 4, // STBIR_TYPE_UINT32 4, // STBIR_TYPE_FLOAT }; // Kernel function centered at 0 typedef float (stbir__kernel_fn)(float x, float scale); typedef float (stbir__support_fn)(float scale); typedef struct { stbir__kernel_fn* kernel; stbir__support_fn* support; } stbir__filter_info; // When upsampling, the contributors are which source pixels contribute. // When downsampling, the contributors are which destination pixels are contributed to. typedef struct { int n0; // First contributing pixel int n1; // Last contributing pixel } stbir__contributors; typedef struct { const void* input_data; int input_w; int input_h; int input_stride_bytes; void* output_data; int output_w; int output_h; int output_stride_bytes; float s0, t0, s1, t1; float horizontal_shift; // Units: output pixels float vertical_shift; // Units: output pixels float horizontal_scale; float vertical_scale; int channels; int alpha_channel; stbir_uint32 flags; stbir_datatype type; stbir_filter horizontal_filter; stbir_filter vertical_filter; stbir_edge edge_horizontal; stbir_edge edge_vertical; stbir_colorspace colorspace; stbir__contributors* horizontal_contributors; float* horizontal_coefficients; stbir__contributors* vertical_contributors; float* vertical_coefficients; int decode_buffer_pixels; float* decode_buffer; float* horizontal_buffer; // cache these because ceil/floor are inexplicably showing up in profile int horizontal_coefficient_width; int vertical_coefficient_width; int horizontal_filter_pixel_width; int vertical_filter_pixel_width; int horizontal_filter_pixel_margin; int vertical_filter_pixel_margin; int horizontal_num_contributors; int vertical_num_contributors; int ring_buffer_length_bytes; // The length of an individual entry in the ring buffer. The total number of ring buffers is stbir__get_filter_pixel_width(filter) int ring_buffer_num_entries; // Total number of entries in the ring buffer. int ring_buffer_first_scanline; int ring_buffer_last_scanline; int ring_buffer_begin_index; // first_scanline is at this index in the ring buffer float* ring_buffer; float* encode_buffer; // A temporary buffer to store floats so we don't lose precision while we do multiply-adds. int horizontal_contributors_size; int horizontal_coefficients_size; int vertical_contributors_size; int vertical_coefficients_size; int decode_buffer_size; int horizontal_buffer_size; int ring_buffer_size; int encode_buffer_size; } stbir__info; static const float stbir__max_uint8_as_float = 255.0f; static const float stbir__max_uint16_as_float = 65535.0f; static const double stbir__max_uint32_as_float = 4294967295.0; static stbir__inline int stbir__min(int a, int b) { return a < b ? a : b; } static stbir__inline float stbir__saturate(float x) { if (x < 0) return 0; if (x > 1) return 1; return x; } #ifdef STBIR_SATURATE_INT static stbir__inline stbir_uint8 stbir__saturate8(int x) { if ((unsigned int) x <= 255) return x; if (x < 0) return 0; return 255; } static stbir__inline stbir_uint16 stbir__saturate16(int x) { if ((unsigned int) x <= 65535) return x; if (x < 0) return 0; return 65535; } #endif static float stbir__srgb_uchar_to_linear_float[256] = { 0.000000f, 0.000304f, 0.000607f, 0.000911f, 0.001214f, 0.001518f, 0.001821f, 0.002125f, 0.002428f, 0.002732f, 0.003035f, 0.003347f, 0.003677f, 0.004025f, 0.004391f, 0.004777f, 0.005182f, 0.005605f, 0.006049f, 0.006512f, 0.006995f, 0.007499f, 0.008023f, 0.008568f, 0.009134f, 0.009721f, 0.010330f, 0.010960f, 0.011612f, 0.012286f, 0.012983f, 0.013702f, 0.014444f, 0.015209f, 0.015996f, 0.016807f, 0.017642f, 0.018500f, 0.019382f, 0.020289f, 0.021219f, 0.022174f, 0.023153f, 0.024158f, 0.025187f, 0.026241f, 0.027321f, 0.028426f, 0.029557f, 0.030713f, 0.031896f, 0.033105f, 0.034340f, 0.035601f, 0.036889f, 0.038204f, 0.039546f, 0.040915f, 0.042311f, 0.043735f, 0.045186f, 0.046665f, 0.048172f, 0.049707f, 0.051269f, 0.052861f, 0.054480f, 0.056128f, 0.057805f, 0.059511f, 0.061246f, 0.063010f, 0.064803f, 0.066626f, 0.068478f, 0.070360f, 0.072272f, 0.074214f, 0.076185f, 0.078187f, 0.080220f, 0.082283f, 0.084376f, 0.086500f, 0.088656f, 0.090842f, 0.093059f, 0.095307f, 0.097587f, 0.099899f, 0.102242f, 0.104616f, 0.107023f, 0.109462f, 0.111932f, 0.114435f, 0.116971f, 0.119538f, 0.122139f, 0.124772f, 0.127438f, 0.130136f, 0.132868f, 0.135633f, 0.138432f, 0.141263f, 0.144128f, 0.147027f, 0.149960f, 0.152926f, 0.155926f, 0.158961f, 0.162029f, 0.165132f, 0.168269f, 0.171441f, 0.174647f, 0.177888f, 0.181164f, 0.184475f, 0.187821f, 0.191202f, 0.194618f, 0.198069f, 0.201556f, 0.205079f, 0.208637f, 0.212231f, 0.215861f, 0.219526f, 0.223228f, 0.226966f, 0.230740f, 0.234551f, 0.238398f, 0.242281f, 0.246201f, 0.250158f, 0.254152f, 0.258183f, 0.262251f, 0.266356f, 0.270498f, 0.274677f, 0.278894f, 0.283149f, 0.287441f, 0.291771f, 0.296138f, 0.300544f, 0.304987f, 0.309469f, 0.313989f, 0.318547f, 0.323143f, 0.327778f, 0.332452f, 0.337164f, 0.341914f, 0.346704f, 0.351533f, 0.356400f, 0.361307f, 0.366253f, 0.371238f, 0.376262f, 0.381326f, 0.386430f, 0.391573f, 0.396755f, 0.401978f, 0.407240f, 0.412543f, 0.417885f, 0.423268f, 0.428691f, 0.434154f, 0.439657f, 0.445201f, 0.450786f, 0.456411f, 0.462077f, 0.467784f, 0.473532f, 0.479320f, 0.485150f, 0.491021f, 0.496933f, 0.502887f, 0.508881f, 0.514918f, 0.520996f, 0.527115f, 0.533276f, 0.539480f, 0.545725f, 0.552011f, 0.558340f, 0.564712f, 0.571125f, 0.577581f, 0.584078f, 0.590619f, 0.597202f, 0.603827f, 0.610496f, 0.617207f, 0.623960f, 0.630757f, 0.637597f, 0.644480f, 0.651406f, 0.658375f, 0.665387f, 0.672443f, 0.679543f, 0.686685f, 0.693872f, 0.701102f, 0.708376f, 0.715694f, 0.723055f, 0.730461f, 0.737911f, 0.745404f, 0.752942f, 0.760525f, 0.768151f, 0.775822f, 0.783538f, 0.791298f, 0.799103f, 0.806952f, 0.814847f, 0.822786f, 0.830770f, 0.838799f, 0.846873f, 0.854993f, 0.863157f, 0.871367f, 0.879622f, 0.887923f, 0.896269f, 0.904661f, 0.913099f, 0.921582f, 0.930111f, 0.938686f, 0.947307f, 0.955974f, 0.964686f, 0.973445f, 0.982251f, 0.991102f, 1.0f }; static float stbir__srgb_to_linear(float f) { if (f <= 0.04045f) return f / 12.92f; else return (float)pow((f + 0.055f) / 1.055f, 2.4f); } static float stbir__linear_to_srgb(float f) { if (f <= 0.0031308f) return f * 12.92f; else return 1.055f * (float)pow(f, 1 / 2.4f) - 0.055f; } #ifndef STBIR_NON_IEEE_FLOAT // From https://gist.github.com/rygorous/2203834 typedef union { stbir_uint32 u; float f; } stbir__FP32; static const stbir_uint32 fp32_to_srgb8_tab4[104] = { 0x0073000d, 0x007a000d, 0x0080000d, 0x0087000d, 0x008d000d, 0x0094000d, 0x009a000d, 0x00a1000d, 0x00a7001a, 0x00b4001a, 0x00c1001a, 0x00ce001a, 0x00da001a, 0x00e7001a, 0x00f4001a, 0x0101001a, 0x010e0033, 0x01280033, 0x01410033, 0x015b0033, 0x01750033, 0x018f0033, 0x01a80033, 0x01c20033, 0x01dc0067, 0x020f0067, 0x02430067, 0x02760067, 0x02aa0067, 0x02dd0067, 0x03110067, 0x03440067, 0x037800ce, 0x03df00ce, 0x044600ce, 0x04ad00ce, 0x051400ce, 0x057b00c5, 0x05dd00bc, 0x063b00b5, 0x06970158, 0x07420142, 0x07e30130, 0x087b0120, 0x090b0112, 0x09940106, 0x0a1700fc, 0x0a9500f2, 0x0b0f01cb, 0x0bf401ae, 0x0ccb0195, 0x0d950180, 0x0e56016e, 0x0f0d015e, 0x0fbc0150, 0x10630143, 0x11070264, 0x1238023e, 0x1357021d, 0x14660201, 0x156601e9, 0x165a01d3, 0x174401c0, 0x182401af, 0x18fe0331, 0x1a9602fe, 0x1c1502d2, 0x1d7e02ad, 0x1ed4028d, 0x201a0270, 0x21520256, 0x227d0240, 0x239f0443, 0x25c003fe, 0x27bf03c4, 0x29a10392, 0x2b6a0367, 0x2d1d0341, 0x2ebe031f, 0x304d0300, 0x31d105b0, 0x34a80555, 0x37520507, 0x39d504c5, 0x3c37048b, 0x3e7c0458, 0x40a8042a, 0x42bd0401, 0x44c20798, 0x488e071e, 0x4c1c06b6, 0x4f76065d, 0x52a50610, 0x55ac05cc, 0x5892058f, 0x5b590559, 0x5e0c0a23, 0x631c0980, 0x67db08f6, 0x6c55087f, 0x70940818, 0x74a007bd, 0x787d076c, 0x7c330723, }; static stbir_uint8 stbir__linear_to_srgb_uchar(float in) { static const stbir__FP32 almostone = { 0x3f7fffff }; // 1-eps static const stbir__FP32 minval = { (127-13) << 23 }; stbir_uint32 tab,bias,scale,t; stbir__FP32 f; // Clamp to [2^(-13), 1-eps]; these two values map to 0 and 1, respectively. // The tests are carefully written so that NaNs map to 0, same as in the reference // implementation. if (!(in > minval.f)) // written this way to catch NaNs in = minval.f; if (in > almostone.f) in = almostone.f; // Do the table lookup and unpack bias, scale f.f = in; tab = fp32_to_srgb8_tab4[(f.u - minval.u) >> 20]; bias = (tab >> 16) << 9; scale = tab & 0xffff; // Grab next-highest mantissa bits and perform linear interpolation t = (f.u >> 12) & 0xff; return (unsigned char) ((bias + scale*t) >> 16); } #else // sRGB transition values, scaled by 1<<28 static int stbir__srgb_offset_to_linear_scaled[256] = { 0, 40738, 122216, 203693, 285170, 366648, 448125, 529603, 611080, 692557, 774035, 855852, 942009, 1033024, 1128971, 1229926, 1335959, 1447142, 1563542, 1685229, 1812268, 1944725, 2082664, 2226148, 2375238, 2529996, 2690481, 2856753, 3028870, 3206888, 3390865, 3580856, 3776916, 3979100, 4187460, 4402049, 4622919, 4850123, 5083710, 5323731, 5570236, 5823273, 6082892, 6349140, 6622065, 6901714, 7188133, 7481369, 7781466, 8088471, 8402427, 8723380, 9051372, 9386448, 9728650, 10078021, 10434603, 10798439, 11169569, 11548036, 11933879, 12327139, 12727857, 13136073, 13551826, 13975156, 14406100, 14844697, 15290987, 15745007, 16206795, 16676389, 17153826, 17639142, 18132374, 18633560, 19142734, 19659934, 20185196, 20718552, 21260042, 21809696, 22367554, 22933648, 23508010, 24090680, 24681686, 25281066, 25888850, 26505076, 27129772, 27762974, 28404716, 29055026, 29713942, 30381490, 31057708, 31742624, 32436272, 33138682, 33849884, 34569912, 35298800, 36036568, 36783260, 37538896, 38303512, 39077136, 39859796, 40651528, 41452360, 42262316, 43081432, 43909732, 44747252, 45594016, 46450052, 47315392, 48190064, 49074096, 49967516, 50870356, 51782636, 52704392, 53635648, 54576432, 55526772, 56486700, 57456236, 58435408, 59424248, 60422780, 61431036, 62449032, 63476804, 64514376, 65561776, 66619028, 67686160, 68763192, 69850160, 70947088, 72053992, 73170912, 74297864, 75434880, 76581976, 77739184, 78906536, 80084040, 81271736, 82469648, 83677792, 84896192, 86124888, 87363888, 88613232, 89872928, 91143016, 92423512, 93714432, 95015816, 96327688, 97650056, 98982952, 100326408, 101680440, 103045072, 104420320, 105806224, 107202800, 108610064, 110028048, 111456776, 112896264, 114346544, 115807632, 117279552, 118762328, 120255976, 121760536, 123276016, 124802440, 126339832, 127888216, 129447616, 131018048, 132599544, 134192112, 135795792, 137410592, 139036528, 140673648, 142321952, 143981456, 145652208, 147334208, 149027488, 150732064, 152447968, 154175200, 155913792, 157663776, 159425168, 161197984, 162982240, 164777968, 166585184, 168403904, 170234160, 172075968, 173929344, 175794320, 177670896, 179559120, 181458992, 183370528, 185293776, 187228736, 189175424, 191133888, 193104112, 195086128, 197079968, 199085648, 201103184, 203132592, 205173888, 207227120, 209292272, 211369392, 213458480, 215559568, 217672656, 219797792, 221934976, 224084240, 226245600, 228419056, 230604656, 232802400, 235012320, 237234432, 239468736, 241715280, 243974080, 246245120, 248528464, 250824112, 253132064, 255452368, 257785040, 260130080, 262487520, 264857376, 267239664, }; static stbir_uint8 stbir__linear_to_srgb_uchar(float f) { int x = (int) (f * (1 << 28)); // has headroom so you don't need to clamp int v = 0; int i; // Refine the guess with a short binary search. i = v + 128; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 64; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 32; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 16; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 8; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 4; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 2; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 1; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; return (stbir_uint8) v; } #endif static float stbir__filter_trapezoid(float x, float scale) { float halfscale = scale / 2; float t = 0.5f + halfscale; STBIR_ASSERT(scale <= 1); x = (float)fabs(x); if (x >= t) return 0; else { float r = 0.5f - halfscale; if (x <= r) return 1; else return (t - x) / scale; } } static float stbir__support_trapezoid(float scale) { STBIR_ASSERT(scale <= 1); return 0.5f + scale / 2; } static float stbir__filter_triangle(float x, float s) { STBIR__UNUSED_PARAM(s); x = (float)fabs(x); if (x <= 1.0f) return 1 - x; else return 0; } static float stbir__filter_cubic(float x, float s) { STBIR__UNUSED_PARAM(s); x = (float)fabs(x); if (x < 1.0f) return (4 + x*x*(3*x - 6))/6; else if (x < 2.0f) return (8 + x*(-12 + x*(6 - x)))/6; return (0.0f); } static float stbir__filter_catmullrom(float x, float s) { STBIR__UNUSED_PARAM(s); x = (float)fabs(x); if (x < 1.0f) return 1 - x*x*(2.5f - 1.5f*x); else if (x < 2.0f) return 2 - x*(4 + x*(0.5f*x - 2.5f)); return (0.0f); } static float stbir__filter_mitchell(float x, float s) { STBIR__UNUSED_PARAM(s); x = (float)fabs(x); if (x < 1.0f) return (16 + x*x*(21 * x - 36))/18; else if (x < 2.0f) return (32 + x*(-60 + x*(36 - 7*x)))/18; return (0.0f); } static float stbir__support_zero(float s) { STBIR__UNUSED_PARAM(s); return 0; } static float stbir__support_one(float s) { STBIR__UNUSED_PARAM(s); return 1; } static float stbir__support_two(float s) { STBIR__UNUSED_PARAM(s); return 2; } static stbir__filter_info stbir__filter_info_table[] = { { NULL, stbir__support_zero }, { stbir__filter_trapezoid, stbir__support_trapezoid }, { stbir__filter_triangle, stbir__support_one }, { stbir__filter_cubic, stbir__support_two }, { stbir__filter_catmullrom, stbir__support_two }, { stbir__filter_mitchell, stbir__support_two }, }; stbir__inline static int stbir__use_upsampling(float ratio) { return ratio > 1; } stbir__inline static int stbir__use_width_upsampling(stbir__info* stbir_info) { return stbir__use_upsampling(stbir_info->horizontal_scale); } stbir__inline static int stbir__use_height_upsampling(stbir__info* stbir_info) { return stbir__use_upsampling(stbir_info->vertical_scale); } // This is the maximum number of input samples that can affect an output sample // with the given filter static int stbir__get_filter_pixel_width(stbir_filter filter, float scale) { STBIR_ASSERT(filter != 0); STBIR_ASSERT(filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); if (stbir__use_upsampling(scale)) return (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2); else return (int)ceil(stbir__filter_info_table[filter].support(scale) * 2 / scale); } // This is how much to expand buffers to account for filters seeking outside // the image boundaries. static int stbir__get_filter_pixel_margin(stbir_filter filter, float scale) { return stbir__get_filter_pixel_width(filter, scale) / 2; } static int stbir__get_coefficient_width(stbir_filter filter, float scale) { if (stbir__use_upsampling(scale)) return (int)ceil(stbir__filter_info_table[filter].support(1 / scale) * 2); else return (int)ceil(stbir__filter_info_table[filter].support(scale) * 2); } static int stbir__get_contributors(float scale, stbir_filter filter, int input_size, int output_size) { if (stbir__use_upsampling(scale)) return output_size; else return (input_size + stbir__get_filter_pixel_margin(filter, scale) * 2); } static int stbir__get_total_horizontal_coefficients(stbir__info* info) { return info->horizontal_num_contributors * stbir__get_coefficient_width (info->horizontal_filter, info->horizontal_scale); } static int stbir__get_total_vertical_coefficients(stbir__info* info) { return info->vertical_num_contributors * stbir__get_coefficient_width (info->vertical_filter, info->vertical_scale); } static stbir__contributors* stbir__get_contributor(stbir__contributors* contributors, int n) { return &contributors[n]; } // For perf reasons this code is duplicated in stbir__resample_horizontal_upsample/downsample, // if you change it here change it there too. static float* stbir__get_coefficient(float* coefficients, stbir_filter filter, float scale, int n, int c) { int width = stbir__get_coefficient_width(filter, scale); return &coefficients[width*n + c]; } static int stbir__edge_wrap_slow(stbir_edge edge, int n, int max) { switch (edge) { case STBIR_EDGE_ZERO: return 0; // we'll decode the wrong pixel here, and then overwrite with 0s later case STBIR_EDGE_CLAMP: if (n < 0) return 0; if (n >= max) return max - 1; return n; // NOTREACHED case STBIR_EDGE_REFLECT: { if (n < 0) { if (n < max) return -n; else return max - 1; } if (n >= max) { int max2 = max * 2; if (n >= max2) return 0; else return max2 - n - 1; } return n; // NOTREACHED } case STBIR_EDGE_WRAP: if (n >= 0) return (n % max); else { int m = (-n) % max; if (m != 0) m = max - m; return (m); } // NOTREACHED default: STBIR_ASSERT(!"Unimplemented edge type"); return 0; } } stbir__inline static int stbir__edge_wrap(stbir_edge edge, int n, int max) { // avoid per-pixel switch if (n >= 0 && n < max) return n; return stbir__edge_wrap_slow(edge, n, max); } // What input pixels contribute to this output pixel? static void stbir__calculate_sample_range_upsample(int n, float out_filter_radius, float scale_ratio, float out_shift, int* in_first_pixel, int* in_last_pixel, float* in_center_of_out) { float out_pixel_center = (float)n + 0.5f; float out_pixel_influence_lowerbound = out_pixel_center - out_filter_radius; float out_pixel_influence_upperbound = out_pixel_center + out_filter_radius; float in_pixel_influence_lowerbound = (out_pixel_influence_lowerbound + out_shift) / scale_ratio; float in_pixel_influence_upperbound = (out_pixel_influence_upperbound + out_shift) / scale_ratio; *in_center_of_out = (out_pixel_center + out_shift) / scale_ratio; *in_first_pixel = (int)(floor(in_pixel_influence_lowerbound + 0.5)); *in_last_pixel = (int)(floor(in_pixel_influence_upperbound - 0.5)); } // What output pixels does this input pixel contribute to? static void stbir__calculate_sample_range_downsample(int n, float in_pixels_radius, float scale_ratio, float out_shift, int* out_first_pixel, int* out_last_pixel, float* out_center_of_in) { float in_pixel_center = (float)n + 0.5f; float in_pixel_influence_lowerbound = in_pixel_center - in_pixels_radius; float in_pixel_influence_upperbound = in_pixel_center + in_pixels_radius; float out_pixel_influence_lowerbound = in_pixel_influence_lowerbound * scale_ratio - out_shift; float out_pixel_influence_upperbound = in_pixel_influence_upperbound * scale_ratio - out_shift; *out_center_of_in = in_pixel_center * scale_ratio - out_shift; *out_first_pixel = (int)(floor(out_pixel_influence_lowerbound + 0.5)); *out_last_pixel = (int)(floor(out_pixel_influence_upperbound - 0.5)); } static void stbir__calculate_coefficients_upsample(stbir_filter filter, float scale, int in_first_pixel, int in_last_pixel, float in_center_of_out, stbir__contributors* contributor, float* coefficient_group) { int i; float total_filter = 0; float filter_scale; STBIR_ASSERT(in_last_pixel - in_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical. contributor->n0 = in_first_pixel; contributor->n1 = in_last_pixel; STBIR_ASSERT(contributor->n1 >= contributor->n0); for (i = 0; i <= in_last_pixel - in_first_pixel; i++) { float in_pixel_center = (float)(i + in_first_pixel) + 0.5f; coefficient_group[i] = stbir__filter_info_table[filter].kernel(in_center_of_out - in_pixel_center, 1 / scale); // If the coefficient is zero, skip it. (Don't do the <0 check here, we want the influence of those outside pixels.) if (i == 0 && !coefficient_group[i]) { contributor->n0 = ++in_first_pixel; i--; continue; } total_filter += coefficient_group[i]; } STBIR_ASSERT(stbir__filter_info_table[filter].kernel((float)(in_last_pixel + 1) + 0.5f - in_center_of_out, 1/scale) == 0); STBIR_ASSERT(total_filter > 0.9); STBIR_ASSERT(total_filter < 1.1f); // Make sure it's not way off. // Make sure the sum of all coefficients is 1. filter_scale = 1 / total_filter; for (i = 0; i <= in_last_pixel - in_first_pixel; i++) coefficient_group[i] *= filter_scale; for (i = in_last_pixel - in_first_pixel; i >= 0; i--) { if (coefficient_group[i]) break; // This line has no weight. We can skip it. contributor->n1 = contributor->n0 + i - 1; } } static void stbir__calculate_coefficients_downsample(stbir_filter filter, float scale_ratio, int out_first_pixel, int out_last_pixel, float out_center_of_in, stbir__contributors* contributor, float* coefficient_group) { int i; STBIR_ASSERT(out_last_pixel - out_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(scale_ratio) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical. contributor->n0 = out_first_pixel; contributor->n1 = out_last_pixel; STBIR_ASSERT(contributor->n1 >= contributor->n0); for (i = 0; i <= out_last_pixel - out_first_pixel; i++) { float out_pixel_center = (float)(i + out_first_pixel) + 0.5f; float x = out_pixel_center - out_center_of_in; coefficient_group[i] = stbir__filter_info_table[filter].kernel(x, scale_ratio) * scale_ratio; } STBIR_ASSERT(stbir__filter_info_table[filter].kernel((float)(out_last_pixel + 1) + 0.5f - out_center_of_in, scale_ratio) == 0); for (i = out_last_pixel - out_first_pixel; i >= 0; i--) { if (coefficient_group[i]) break; // This line has no weight. We can skip it. contributor->n1 = contributor->n0 + i - 1; } } static void stbir__normalize_downsample_coefficients(stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, int input_size, int output_size) { int num_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size); int num_coefficients = stbir__get_coefficient_width(filter, scale_ratio); int i, j; int skip; for (i = 0; i < output_size; i++) { float scale; float total = 0; for (j = 0; j < num_contributors; j++) { if (i >= contributors[j].n0 && i <= contributors[j].n1) { float coefficient = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0); total += coefficient; } else if (i < contributors[j].n0) break; } STBIR_ASSERT(total > 0.9f); STBIR_ASSERT(total < 1.1f); scale = 1 / total; for (j = 0; j < num_contributors; j++) { if (i >= contributors[j].n0 && i <= contributors[j].n1) *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0) *= scale; else if (i < contributors[j].n0) break; } } // Optimize: Skip zero coefficients and contributions outside of image bounds. // Do this after normalizing because normalization depends on the n0/n1 values. for (j = 0; j < num_contributors; j++) { int range, max, width; skip = 0; while (*stbir__get_coefficient(coefficients, filter, scale_ratio, j, skip) == 0) skip++; contributors[j].n0 += skip; while (contributors[j].n0 < 0) { contributors[j].n0++; skip++; } range = contributors[j].n1 - contributors[j].n0 + 1; max = stbir__min(num_coefficients, range); width = stbir__get_coefficient_width(filter, scale_ratio); for (i = 0; i < max; i++) { if (i + skip >= width) break; *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i) = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i + skip); } continue; } // Using min to avoid writing into invalid pixels. for (i = 0; i < num_contributors; i++) contributors[i].n1 = stbir__min(contributors[i].n1, output_size - 1); } // Each scan line uses the same kernel values so we should calculate the kernel // values once and then we can use them for every scan line. static void stbir__calculate_filters(stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, float shift, int input_size, int output_size) { int n; int total_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size); if (stbir__use_upsampling(scale_ratio)) { float out_pixels_radius = stbir__filter_info_table[filter].support(1 / scale_ratio) * scale_ratio; // Looping through out pixels for (n = 0; n < total_contributors; n++) { float in_center_of_out; // Center of the current out pixel in the in pixel space int in_first_pixel, in_last_pixel; stbir__calculate_sample_range_upsample(n, out_pixels_radius, scale_ratio, shift, &in_first_pixel, &in_last_pixel, &in_center_of_out); stbir__calculate_coefficients_upsample(filter, scale_ratio, in_first_pixel, in_last_pixel, in_center_of_out, stbir__get_contributor(contributors, n), stbir__get_coefficient(coefficients, filter, scale_ratio, n, 0)); } } else { float in_pixels_radius = stbir__filter_info_table[filter].support(scale_ratio) / scale_ratio; // Looping through in pixels for (n = 0; n < total_contributors; n++) { float out_center_of_in; // Center of the current out pixel in the in pixel space int out_first_pixel, out_last_pixel; int n_adjusted = n - stbir__get_filter_pixel_margin(filter, scale_ratio); stbir__calculate_sample_range_downsample(n_adjusted, in_pixels_radius, scale_ratio, shift, &out_first_pixel, &out_last_pixel, &out_center_of_in); stbir__calculate_coefficients_downsample(filter, scale_ratio, out_first_pixel, out_last_pixel, out_center_of_in, stbir__get_contributor(contributors, n), stbir__get_coefficient(coefficients, filter, scale_ratio, n, 0)); } stbir__normalize_downsample_coefficients(contributors, coefficients, filter, scale_ratio, input_size, output_size); } } static float* stbir__get_decode_buffer(stbir__info* stbir_info) { // The 0 index of the decode buffer starts after the margin. This makes // it okay to use negative indexes on the decode buffer. return &stbir_info->decode_buffer[stbir_info->horizontal_filter_pixel_margin * stbir_info->channels]; } #define STBIR__DECODE(type, colorspace) ((type) * (STBIR_MAX_COLORSPACES) + (colorspace)) static void stbir__decode_scanline(stbir__info* stbir_info, int n) { int c; int channels = stbir_info->channels; int alpha_channel = stbir_info->alpha_channel; int type = stbir_info->type; int colorspace = stbir_info->colorspace; int input_w = stbir_info->input_w; size_t input_stride_bytes = stbir_info->input_stride_bytes; float* decode_buffer = stbir__get_decode_buffer(stbir_info); stbir_edge edge_horizontal = stbir_info->edge_horizontal; stbir_edge edge_vertical = stbir_info->edge_vertical; size_t in_buffer_row_offset = stbir__edge_wrap(edge_vertical, n, stbir_info->input_h) * input_stride_bytes; const void* input_data = (char *) stbir_info->input_data + in_buffer_row_offset; int max_x = input_w + stbir_info->horizontal_filter_pixel_margin; int decode = STBIR__DECODE(type, colorspace); int x = -stbir_info->horizontal_filter_pixel_margin; // special handling for STBIR_EDGE_ZERO because it needs to return an item that doesn't appear in the input, // and we want to avoid paying overhead on every pixel if not STBIR_EDGE_ZERO if (edge_vertical == STBIR_EDGE_ZERO && (n < 0 || n >= stbir_info->input_h)) { for (; x < max_x; x++) for (c = 0; c < channels; c++) decode_buffer[x*channels + c] = 0; return; } switch (decode) { case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_LINEAR): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = ((float)((const unsigned char*)input_data)[input_pixel_index + c]) / stbir__max_uint8_as_float; } break; case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_SRGB): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = stbir__srgb_uchar_to_linear_float[((const unsigned char*)input_data)[input_pixel_index + c]]; if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned char*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint8_as_float; } break; case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = ((float)((const unsigned short*)input_data)[input_pixel_index + c]) / stbir__max_uint16_as_float; } break; case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear(((float)((const unsigned short*)input_data)[input_pixel_index + c]) / stbir__max_uint16_as_float); if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned short*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint16_as_float; } break; case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = (float)(((double)((const unsigned int*)input_data)[input_pixel_index + c]) / stbir__max_uint32_as_float); } break; case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear((float)(((double)((const unsigned int*)input_data)[input_pixel_index + c]) / stbir__max_uint32_as_float)); if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) decode_buffer[decode_pixel_index + alpha_channel] = (float)(((double)((const unsigned int*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint32_as_float); } break; case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = ((const float*)input_data)[input_pixel_index + c]; } break; case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear(((const float*)input_data)[input_pixel_index + c]); if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) decode_buffer[decode_pixel_index + alpha_channel] = ((const float*)input_data)[input_pixel_index + alpha_channel]; } break; default: STBIR_ASSERT(!"Unknown type/colorspace/channels combination."); break; } if (!(stbir_info->flags & STBIR_FLAG_ALPHA_PREMULTIPLIED)) { for (x = -stbir_info->horizontal_filter_pixel_margin; x < max_x; x++) { int decode_pixel_index = x * channels; // If the alpha value is 0 it will clobber the color values. Make sure it's not. float alpha = decode_buffer[decode_pixel_index + alpha_channel]; #ifndef STBIR_NO_ALPHA_EPSILON if (stbir_info->type != STBIR_TYPE_FLOAT) { alpha += STBIR_ALPHA_EPSILON; decode_buffer[decode_pixel_index + alpha_channel] = alpha; } #endif for (c = 0; c < channels; c++) { if (c == alpha_channel) continue; decode_buffer[decode_pixel_index + c] *= alpha; } } } if (edge_horizontal == STBIR_EDGE_ZERO) { for (x = -stbir_info->horizontal_filter_pixel_margin; x < 0; x++) { for (c = 0; c < channels; c++) decode_buffer[x*channels + c] = 0; } for (x = input_w; x < max_x; x++) { for (c = 0; c < channels; c++) decode_buffer[x*channels + c] = 0; } } } static float* stbir__get_ring_buffer_entry(float* ring_buffer, int index, int ring_buffer_length) { return &ring_buffer[index * ring_buffer_length]; } static float* stbir__add_empty_ring_buffer_entry(stbir__info* stbir_info, int n) { int ring_buffer_index; float* ring_buffer; stbir_info->ring_buffer_last_scanline = n; if (stbir_info->ring_buffer_begin_index < 0) { ring_buffer_index = stbir_info->ring_buffer_begin_index = 0; stbir_info->ring_buffer_first_scanline = n; } else { ring_buffer_index = (stbir_info->ring_buffer_begin_index + (stbir_info->ring_buffer_last_scanline - stbir_info->ring_buffer_first_scanline)) % stbir_info->ring_buffer_num_entries; STBIR_ASSERT(ring_buffer_index != stbir_info->ring_buffer_begin_index); } ring_buffer = stbir__get_ring_buffer_entry(stbir_info->ring_buffer, ring_buffer_index, stbir_info->ring_buffer_length_bytes / sizeof(float)); memset(ring_buffer, 0, stbir_info->ring_buffer_length_bytes); return ring_buffer; } static void stbir__resample_horizontal_upsample(stbir__info* stbir_info, float* output_buffer) { int x, k; int output_w = stbir_info->output_w; int channels = stbir_info->channels; float* decode_buffer = stbir__get_decode_buffer(stbir_info); stbir__contributors* horizontal_contributors = stbir_info->horizontal_contributors; float* horizontal_coefficients = stbir_info->horizontal_coefficients; int coefficient_width = stbir_info->horizontal_coefficient_width; for (x = 0; x < output_w; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int out_pixel_index = x * channels; int coefficient_group = coefficient_width * x; int coefficient_counter = 0; STBIR_ASSERT(n1 >= n0); STBIR_ASSERT(n0 >= -stbir_info->horizontal_filter_pixel_margin); STBIR_ASSERT(n1 >= -stbir_info->horizontal_filter_pixel_margin); STBIR_ASSERT(n0 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin); STBIR_ASSERT(n1 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin); switch (channels) { case 1: for (k = n0; k <= n1; k++) { int in_pixel_index = k * 1; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; } break; case 2: for (k = n0; k <= n1; k++) { int in_pixel_index = k * 2; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; } break; case 3: for (k = n0; k <= n1; k++) { int in_pixel_index = k * 3; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; } break; case 4: for (k = n0; k <= n1; k++) { int in_pixel_index = k * 4; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; output_buffer[out_pixel_index + 3] += decode_buffer[in_pixel_index + 3] * coefficient; } break; default: for (k = n0; k <= n1; k++) { int in_pixel_index = k * channels; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; int c; STBIR_ASSERT(coefficient != 0); for (c = 0; c < channels; c++) output_buffer[out_pixel_index + c] += decode_buffer[in_pixel_index + c] * coefficient; } break; } } } static void stbir__resample_horizontal_downsample(stbir__info* stbir_info, float* output_buffer) { int x, k; int input_w = stbir_info->input_w; int channels = stbir_info->channels; float* decode_buffer = stbir__get_decode_buffer(stbir_info); stbir__contributors* horizontal_contributors = stbir_info->horizontal_contributors; float* horizontal_coefficients = stbir_info->horizontal_coefficients; int coefficient_width = stbir_info->horizontal_coefficient_width; int filter_pixel_margin = stbir_info->horizontal_filter_pixel_margin; int max_x = input_w + filter_pixel_margin * 2; STBIR_ASSERT(!stbir__use_width_upsampling(stbir_info)); switch (channels) { case 1: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * 1; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int out_pixel_index = k * 1; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; } } break; case 2: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * 2; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int out_pixel_index = k * 2; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; } } break; case 3: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * 3; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int out_pixel_index = k * 3; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; } } break; case 4: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * 4; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int out_pixel_index = k * 4; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; output_buffer[out_pixel_index + 3] += decode_buffer[in_pixel_index + 3] * coefficient; } } break; default: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * channels; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int c; int out_pixel_index = k * channels; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); for (c = 0; c < channels; c++) output_buffer[out_pixel_index + c] += decode_buffer[in_pixel_index + c] * coefficient; } } break; } } static void stbir__decode_and_resample_upsample(stbir__info* stbir_info, int n) { // Decode the nth scanline from the source image into the decode buffer. stbir__decode_scanline(stbir_info, n); // Now resample it into the ring buffer. if (stbir__use_width_upsampling(stbir_info)) stbir__resample_horizontal_upsample(stbir_info, stbir__add_empty_ring_buffer_entry(stbir_info, n)); else stbir__resample_horizontal_downsample(stbir_info, stbir__add_empty_ring_buffer_entry(stbir_info, n)); // Now it's sitting in the ring buffer ready to be used as source for the vertical sampling. } static void stbir__decode_and_resample_downsample(stbir__info* stbir_info, int n) { // Decode the nth scanline from the source image into the decode buffer. stbir__decode_scanline(stbir_info, n); memset(stbir_info->horizontal_buffer, 0, stbir_info->output_w * stbir_info->channels * sizeof(float)); // Now resample it into the horizontal buffer. if (stbir__use_width_upsampling(stbir_info)) stbir__resample_horizontal_upsample(stbir_info, stbir_info->horizontal_buffer); else stbir__resample_horizontal_downsample(stbir_info, stbir_info->horizontal_buffer); // Now it's sitting in the horizontal buffer ready to be distributed into the ring buffers. } // Get the specified scan line from the ring buffer. static float* stbir__get_ring_buffer_scanline(int get_scanline, float* ring_buffer, int begin_index, int first_scanline, int ring_buffer_num_entries, int ring_buffer_length) { int ring_buffer_index = (begin_index + (get_scanline - first_scanline)) % ring_buffer_num_entries; return stbir__get_ring_buffer_entry(ring_buffer, ring_buffer_index, ring_buffer_length); } static void stbir__encode_scanline(stbir__info* stbir_info, int num_pixels, void *output_buffer, float *encode_buffer, int channels, int alpha_channel, int decode) { int x; int n; int num_nonalpha; stbir_uint16 nonalpha[STBIR_MAX_CHANNELS]; if (!(stbir_info->flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)) { for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; float alpha = encode_buffer[pixel_index + alpha_channel]; float reciprocal_alpha = alpha ? 1.0f / alpha : 0; // unrolling this produced a 1% slowdown upscaling a large RGBA linear-space image on my machine - stb for (n = 0; n < channels; n++) if (n != alpha_channel) encode_buffer[pixel_index + n] *= reciprocal_alpha; // We added in a small epsilon to prevent the color channel from being deleted with zero alpha. // Because we only add it for integer types, it will automatically be discarded on integer // conversion, so we don't need to subtract it back out (which would be problematic for // numeric precision reasons). } } // build a table of all channels that need colorspace correction, so // we don't perform colorspace correction on channels that don't need it. for (x = 0, num_nonalpha = 0; x < channels; ++x) { if (x != alpha_channel || (stbir_info->flags & STBIR_FLAG_ALPHA_USES_COLORSPACE)) { nonalpha[num_nonalpha++] = (stbir_uint16)x; } } #define STBIR__ROUND_INT(f) ((int) ((f)+0.5)) #define STBIR__ROUND_UINT(f) ((stbir_uint32) ((f)+0.5)) #ifdef STBIR__SATURATE_INT #define STBIR__ENCODE_LINEAR8(f) stbir__saturate8 (STBIR__ROUND_INT((f) * stbir__max_uint8_as_float )) #define STBIR__ENCODE_LINEAR16(f) stbir__saturate16(STBIR__ROUND_INT((f) * stbir__max_uint16_as_float)) #else #define STBIR__ENCODE_LINEAR8(f) (unsigned char ) STBIR__ROUND_INT(stbir__saturate(f) * stbir__max_uint8_as_float ) #define STBIR__ENCODE_LINEAR16(f) (unsigned short) STBIR__ROUND_INT(stbir__saturate(f) * stbir__max_uint16_as_float) #endif switch (decode) { case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_LINEAR): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < channels; n++) { int index = pixel_index + n; ((unsigned char*)output_buffer)[index] = STBIR__ENCODE_LINEAR8(encode_buffer[index]); } } break; case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_SRGB): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < num_nonalpha; n++) { int index = pixel_index + nonalpha[n]; ((unsigned char*)output_buffer)[index] = stbir__linear_to_srgb_uchar(encode_buffer[index]); } if (!(stbir_info->flags & STBIR_FLAG_ALPHA_USES_COLORSPACE)) ((unsigned char *)output_buffer)[pixel_index + alpha_channel] = STBIR__ENCODE_LINEAR8(encode_buffer[pixel_index+alpha_channel]); } break; case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < channels; n++) { int index = pixel_index + n; ((unsigned short*)output_buffer)[index] = STBIR__ENCODE_LINEAR16(encode_buffer[index]); } } break; case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < num_nonalpha; n++) { int index = pixel_index + nonalpha[n]; ((unsigned short*)output_buffer)[index] = (unsigned short)STBIR__ROUND_INT(stbir__linear_to_srgb(stbir__saturate(encode_buffer[index])) * stbir__max_uint16_as_float); } if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) ((unsigned short*)output_buffer)[pixel_index + alpha_channel] = STBIR__ENCODE_LINEAR16(encode_buffer[pixel_index + alpha_channel]); } break; case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < channels; n++) { int index = pixel_index + n; ((unsigned int*)output_buffer)[index] = (unsigned int)STBIR__ROUND_UINT(((double)stbir__saturate(encode_buffer[index])) * stbir__max_uint32_as_float); } } break; case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < num_nonalpha; n++) { int index = pixel_index + nonalpha[n]; ((unsigned int*)output_buffer)[index] = (unsigned int)STBIR__ROUND_UINT(((double)stbir__linear_to_srgb(stbir__saturate(encode_buffer[index]))) * stbir__max_uint32_as_float); } if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) ((unsigned int*)output_buffer)[pixel_index + alpha_channel] = (unsigned int)STBIR__ROUND_INT(((double)stbir__saturate(encode_buffer[pixel_index + alpha_channel])) * stbir__max_uint32_as_float); } break; case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < channels; n++) { int index = pixel_index + n; ((float*)output_buffer)[index] = encode_buffer[index]; } } break; case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < num_nonalpha; n++) { int index = pixel_index + nonalpha[n]; ((float*)output_buffer)[index] = stbir__linear_to_srgb(encode_buffer[index]); } if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) ((float*)output_buffer)[pixel_index + alpha_channel] = encode_buffer[pixel_index + alpha_channel]; } break; default: STBIR_ASSERT(!"Unknown type/colorspace/channels combination."); break; } } static void stbir__resample_vertical_upsample(stbir__info* stbir_info, int n) { int x, k; int output_w = stbir_info->output_w; stbir__contributors* vertical_contributors = stbir_info->vertical_contributors; float* vertical_coefficients = stbir_info->vertical_coefficients; int channels = stbir_info->channels; int alpha_channel = stbir_info->alpha_channel; int type = stbir_info->type; int colorspace = stbir_info->colorspace; int ring_buffer_entries = stbir_info->ring_buffer_num_entries; void* output_data = stbir_info->output_data; float* encode_buffer = stbir_info->encode_buffer; int decode = STBIR__DECODE(type, colorspace); int coefficient_width = stbir_info->vertical_coefficient_width; int coefficient_counter; int contributor = n; float* ring_buffer = stbir_info->ring_buffer; int ring_buffer_begin_index = stbir_info->ring_buffer_begin_index; int ring_buffer_first_scanline = stbir_info->ring_buffer_first_scanline; int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); int n0,n1, output_row_start; int coefficient_group = coefficient_width * contributor; n0 = vertical_contributors[contributor].n0; n1 = vertical_contributors[contributor].n1; output_row_start = n * stbir_info->output_stride_bytes; STBIR_ASSERT(stbir__use_height_upsampling(stbir_info)); memset(encode_buffer, 0, output_w * sizeof(float) * channels); // I tried reblocking this for better cache usage of encode_buffer // (using x_outer, k, x_inner), but it lost speed. -- stb coefficient_counter = 0; switch (channels) { case 1: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * 1; encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; } } break; case 2: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * 2; encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; } } break; case 3: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * 3; encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; encode_buffer[in_pixel_index + 2] += ring_buffer_entry[in_pixel_index + 2] * coefficient; } } break; case 4: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * 4; encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; encode_buffer[in_pixel_index + 2] += ring_buffer_entry[in_pixel_index + 2] * coefficient; encode_buffer[in_pixel_index + 3] += ring_buffer_entry[in_pixel_index + 3] * coefficient; } } break; default: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * channels; int c; for (c = 0; c < channels; c++) encode_buffer[in_pixel_index + c] += ring_buffer_entry[in_pixel_index + c] * coefficient; } } break; } stbir__encode_scanline(stbir_info, output_w, (char *) output_data + output_row_start, encode_buffer, channels, alpha_channel, decode); } static void stbir__resample_vertical_downsample(stbir__info* stbir_info, int n) { int x, k; int output_w = stbir_info->output_w; stbir__contributors* vertical_contributors = stbir_info->vertical_contributors; float* vertical_coefficients = stbir_info->vertical_coefficients; int channels = stbir_info->channels; int ring_buffer_entries = stbir_info->ring_buffer_num_entries; float* horizontal_buffer = stbir_info->horizontal_buffer; int coefficient_width = stbir_info->vertical_coefficient_width; int contributor = n + stbir_info->vertical_filter_pixel_margin; float* ring_buffer = stbir_info->ring_buffer; int ring_buffer_begin_index = stbir_info->ring_buffer_begin_index; int ring_buffer_first_scanline = stbir_info->ring_buffer_first_scanline; int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); int n0,n1; n0 = vertical_contributors[contributor].n0; n1 = vertical_contributors[contributor].n1; STBIR_ASSERT(!stbir__use_height_upsampling(stbir_info)); for (k = n0; k <= n1; k++) { int coefficient_index = k - n0; int coefficient_group = coefficient_width * contributor; float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); switch (channels) { case 1: for (x = 0; x < output_w; x++) { int in_pixel_index = x * 1; ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; } break; case 2: for (x = 0; x < output_w; x++) { int in_pixel_index = x * 2; ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; } break; case 3: for (x = 0; x < output_w; x++) { int in_pixel_index = x * 3; ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; ring_buffer_entry[in_pixel_index + 2] += horizontal_buffer[in_pixel_index + 2] * coefficient; } break; case 4: for (x = 0; x < output_w; x++) { int in_pixel_index = x * 4; ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; ring_buffer_entry[in_pixel_index + 2] += horizontal_buffer[in_pixel_index + 2] * coefficient; ring_buffer_entry[in_pixel_index + 3] += horizontal_buffer[in_pixel_index + 3] * coefficient; } break; default: for (x = 0; x < output_w; x++) { int in_pixel_index = x * channels; int c; for (c = 0; c < channels; c++) ring_buffer_entry[in_pixel_index + c] += horizontal_buffer[in_pixel_index + c] * coefficient; } break; } } } static void stbir__buffer_loop_upsample(stbir__info* stbir_info) { int y; float scale_ratio = stbir_info->vertical_scale; float out_scanlines_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(1/scale_ratio) * scale_ratio; STBIR_ASSERT(stbir__use_height_upsampling(stbir_info)); for (y = 0; y < stbir_info->output_h; y++) { float in_center_of_out = 0; // Center of the current out scanline in the in scanline space int in_first_scanline = 0, in_last_scanline = 0; stbir__calculate_sample_range_upsample(y, out_scanlines_radius, scale_ratio, stbir_info->vertical_shift, &in_first_scanline, &in_last_scanline, &in_center_of_out); STBIR_ASSERT(in_last_scanline - in_first_scanline + 1 <= stbir_info->ring_buffer_num_entries); if (stbir_info->ring_buffer_begin_index >= 0) { // Get rid of whatever we don't need anymore. while (in_first_scanline > stbir_info->ring_buffer_first_scanline) { if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline) { // We just popped the last scanline off the ring buffer. // Reset it to the empty state. stbir_info->ring_buffer_begin_index = -1; stbir_info->ring_buffer_first_scanline = 0; stbir_info->ring_buffer_last_scanline = 0; break; } else { stbir_info->ring_buffer_first_scanline++; stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->ring_buffer_num_entries; } } } // Load in new ones. if (stbir_info->ring_buffer_begin_index < 0) stbir__decode_and_resample_upsample(stbir_info, in_first_scanline); while (in_last_scanline > stbir_info->ring_buffer_last_scanline) stbir__decode_and_resample_upsample(stbir_info, stbir_info->ring_buffer_last_scanline + 1); // Now all buffers should be ready to write a row of vertical sampling. stbir__resample_vertical_upsample(stbir_info, y); STBIR_PROGRESS_REPORT((float)y / stbir_info->output_h); } } static void stbir__empty_ring_buffer(stbir__info* stbir_info, int first_necessary_scanline) { int output_stride_bytes = stbir_info->output_stride_bytes; int channels = stbir_info->channels; int alpha_channel = stbir_info->alpha_channel; int type = stbir_info->type; int colorspace = stbir_info->colorspace; int output_w = stbir_info->output_w; void* output_data = stbir_info->output_data; int decode = STBIR__DECODE(type, colorspace); float* ring_buffer = stbir_info->ring_buffer; int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); if (stbir_info->ring_buffer_begin_index >= 0) { // Get rid of whatever we don't need anymore. while (first_necessary_scanline > stbir_info->ring_buffer_first_scanline) { if (stbir_info->ring_buffer_first_scanline >= 0 && stbir_info->ring_buffer_first_scanline < stbir_info->output_h) { int output_row_start = stbir_info->ring_buffer_first_scanline * output_stride_bytes; float* ring_buffer_entry = stbir__get_ring_buffer_entry(ring_buffer, stbir_info->ring_buffer_begin_index, ring_buffer_length); stbir__encode_scanline(stbir_info, output_w, (char *) output_data + output_row_start, ring_buffer_entry, channels, alpha_channel, decode); STBIR_PROGRESS_REPORT((float)stbir_info->ring_buffer_first_scanline / stbir_info->output_h); } if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline) { // We just popped the last scanline off the ring buffer. // Reset it to the empty state. stbir_info->ring_buffer_begin_index = -1; stbir_info->ring_buffer_first_scanline = 0; stbir_info->ring_buffer_last_scanline = 0; break; } else { stbir_info->ring_buffer_first_scanline++; stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->ring_buffer_num_entries; } } } } static void stbir__buffer_loop_downsample(stbir__info* stbir_info) { int y; float scale_ratio = stbir_info->vertical_scale; int output_h = stbir_info->output_h; float in_pixels_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(scale_ratio) / scale_ratio; int pixel_margin = stbir_info->vertical_filter_pixel_margin; int max_y = stbir_info->input_h + pixel_margin; STBIR_ASSERT(!stbir__use_height_upsampling(stbir_info)); for (y = -pixel_margin; y < max_y; y++) { float out_center_of_in; // Center of the current out scanline in the in scanline space int out_first_scanline, out_last_scanline; stbir__calculate_sample_range_downsample(y, in_pixels_radius, scale_ratio, stbir_info->vertical_shift, &out_first_scanline, &out_last_scanline, &out_center_of_in); STBIR_ASSERT(out_last_scanline - out_first_scanline + 1 <= stbir_info->ring_buffer_num_entries); if (out_last_scanline < 0 || out_first_scanline >= output_h) continue; stbir__empty_ring_buffer(stbir_info, out_first_scanline); stbir__decode_and_resample_downsample(stbir_info, y); // Load in new ones. if (stbir_info->ring_buffer_begin_index < 0) stbir__add_empty_ring_buffer_entry(stbir_info, out_first_scanline); while (out_last_scanline > stbir_info->ring_buffer_last_scanline) stbir__add_empty_ring_buffer_entry(stbir_info, stbir_info->ring_buffer_last_scanline + 1); // Now the horizontal buffer is ready to write to all ring buffer rows. stbir__resample_vertical_downsample(stbir_info, y); } stbir__empty_ring_buffer(stbir_info, stbir_info->output_h); } static void stbir__setup(stbir__info *info, int input_w, int input_h, int output_w, int output_h, int channels) { info->input_w = input_w; info->input_h = input_h; info->output_w = output_w; info->output_h = output_h; info->channels = channels; } static void stbir__calculate_transform(stbir__info *info, float s0, float t0, float s1, float t1, float *transform) { info->s0 = s0; info->t0 = t0; info->s1 = s1; info->t1 = t1; if (transform) { info->horizontal_scale = transform[0]; info->vertical_scale = transform[1]; info->horizontal_shift = transform[2]; info->vertical_shift = transform[3]; } else { info->horizontal_scale = ((float)info->output_w / info->input_w) / (s1 - s0); info->vertical_scale = ((float)info->output_h / info->input_h) / (t1 - t0); info->horizontal_shift = s0 * info->output_w / (s1 - s0); info->vertical_shift = t0 * info->output_h / (t1 - t0); } } static void stbir__choose_filter(stbir__info *info, stbir_filter h_filter, stbir_filter v_filter) { if (h_filter == 0) h_filter = stbir__use_upsampling(info->horizontal_scale) ? STBIR_DEFAULT_FILTER_UPSAMPLE : STBIR_DEFAULT_FILTER_DOWNSAMPLE; if (v_filter == 0) v_filter = stbir__use_upsampling(info->vertical_scale) ? STBIR_DEFAULT_FILTER_UPSAMPLE : STBIR_DEFAULT_FILTER_DOWNSAMPLE; info->horizontal_filter = h_filter; info->vertical_filter = v_filter; } static stbir_uint32 stbir__calculate_memory(stbir__info *info) { int pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale); int filter_height = stbir__get_filter_pixel_width(info->vertical_filter, info->vertical_scale); info->horizontal_num_contributors = stbir__get_contributors(info->horizontal_scale, info->horizontal_filter, info->input_w, info->output_w); info->vertical_num_contributors = stbir__get_contributors(info->vertical_scale , info->vertical_filter , info->input_h, info->output_h); // One extra entry because floating point precision problems sometimes cause an extra to be necessary. info->ring_buffer_num_entries = filter_height + 1; info->horizontal_contributors_size = info->horizontal_num_contributors * sizeof(stbir__contributors); info->horizontal_coefficients_size = stbir__get_total_horizontal_coefficients(info) * sizeof(float); info->vertical_contributors_size = info->vertical_num_contributors * sizeof(stbir__contributors); info->vertical_coefficients_size = stbir__get_total_vertical_coefficients(info) * sizeof(float); info->decode_buffer_size = (info->input_w + pixel_margin * 2) * info->channels * sizeof(float); info->horizontal_buffer_size = info->output_w * info->channels * sizeof(float); info->ring_buffer_size = info->output_w * info->channels * info->ring_buffer_num_entries * sizeof(float); info->encode_buffer_size = info->output_w * info->channels * sizeof(float); STBIR_ASSERT(info->horizontal_filter != 0); STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); // this now happens too late STBIR_ASSERT(info->vertical_filter != 0); STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); // this now happens too late if (stbir__use_height_upsampling(info)) // The horizontal buffer is for when we're downsampling the height and we // can't output the result of sampling the decode buffer directly into the // ring buffers. info->horizontal_buffer_size = 0; else // The encode buffer is to retain precision in the height upsampling method // and isn't used when height downsampling. info->encode_buffer_size = 0; return info->horizontal_contributors_size + info->horizontal_coefficients_size + info->vertical_contributors_size + info->vertical_coefficients_size + info->decode_buffer_size + info->horizontal_buffer_size + info->ring_buffer_size + info->encode_buffer_size; } static int stbir__resize_allocated(stbir__info *info, const void* input_data, int input_stride_in_bytes, void* output_data, int output_stride_in_bytes, int alpha_channel, stbir_uint32 flags, stbir_datatype type, stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace, void* tempmem, size_t tempmem_size_in_bytes) { size_t memory_required = stbir__calculate_memory(info); int width_stride_input = input_stride_in_bytes ? input_stride_in_bytes : info->channels * info->input_w * stbir__type_size[type]; int width_stride_output = output_stride_in_bytes ? output_stride_in_bytes : info->channels * info->output_w * stbir__type_size[type]; #ifdef STBIR_DEBUG_OVERWRITE_TEST #define OVERWRITE_ARRAY_SIZE 8 unsigned char overwrite_output_before_pre[OVERWRITE_ARRAY_SIZE]; unsigned char overwrite_tempmem_before_pre[OVERWRITE_ARRAY_SIZE]; unsigned char overwrite_output_after_pre[OVERWRITE_ARRAY_SIZE]; unsigned char overwrite_tempmem_after_pre[OVERWRITE_ARRAY_SIZE]; size_t begin_forbidden = width_stride_output * (info->output_h - 1) + info->output_w * info->channels * stbir__type_size[type]; memcpy(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE); memcpy(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE); memcpy(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE); memcpy(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE); #endif STBIR_ASSERT(info->channels >= 0); STBIR_ASSERT(info->channels <= STBIR_MAX_CHANNELS); if (info->channels < 0 || info->channels > STBIR_MAX_CHANNELS) return 0; STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); if (info->horizontal_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table)) return 0; if (info->vertical_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table)) return 0; if (alpha_channel < 0) flags |= STBIR_FLAG_ALPHA_USES_COLORSPACE | STBIR_FLAG_ALPHA_PREMULTIPLIED; if (!(flags&STBIR_FLAG_ALPHA_USES_COLORSPACE) || !(flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)) { STBIR_ASSERT(alpha_channel >= 0 && alpha_channel < info->channels); } if (alpha_channel >= info->channels) return 0; STBIR_ASSERT(tempmem); if (!tempmem) return 0; STBIR_ASSERT(tempmem_size_in_bytes >= memory_required); if (tempmem_size_in_bytes < memory_required) return 0; memset(tempmem, 0, tempmem_size_in_bytes); info->input_data = input_data; info->input_stride_bytes = width_stride_input; info->output_data = output_data; info->output_stride_bytes = width_stride_output; info->alpha_channel = alpha_channel; info->flags = flags; info->type = type; info->edge_horizontal = edge_horizontal; info->edge_vertical = edge_vertical; info->colorspace = colorspace; info->horizontal_coefficient_width = stbir__get_coefficient_width (info->horizontal_filter, info->horizontal_scale); info->vertical_coefficient_width = stbir__get_coefficient_width (info->vertical_filter , info->vertical_scale ); info->horizontal_filter_pixel_width = stbir__get_filter_pixel_width (info->horizontal_filter, info->horizontal_scale); info->vertical_filter_pixel_width = stbir__get_filter_pixel_width (info->vertical_filter , info->vertical_scale ); info->horizontal_filter_pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale); info->vertical_filter_pixel_margin = stbir__get_filter_pixel_margin(info->vertical_filter , info->vertical_scale ); info->ring_buffer_length_bytes = info->output_w * info->channels * sizeof(float); info->decode_buffer_pixels = info->input_w + info->horizontal_filter_pixel_margin * 2; #define STBIR__NEXT_MEMPTR(current, newtype) (newtype*)(((unsigned char*)current) + current##_size) info->horizontal_contributors = (stbir__contributors *) tempmem; info->horizontal_coefficients = STBIR__NEXT_MEMPTR(info->horizontal_contributors, float); info->vertical_contributors = STBIR__NEXT_MEMPTR(info->horizontal_coefficients, stbir__contributors); info->vertical_coefficients = STBIR__NEXT_MEMPTR(info->vertical_contributors, float); info->decode_buffer = STBIR__NEXT_MEMPTR(info->vertical_coefficients, float); if (stbir__use_height_upsampling(info)) { info->horizontal_buffer = NULL; info->ring_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float); info->encode_buffer = STBIR__NEXT_MEMPTR(info->ring_buffer, float); STBIR_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->encode_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes); } else { info->horizontal_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float); info->ring_buffer = STBIR__NEXT_MEMPTR(info->horizontal_buffer, float); info->encode_buffer = NULL; STBIR_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->ring_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes); } #undef STBIR__NEXT_MEMPTR // This signals that the ring buffer is empty info->ring_buffer_begin_index = -1; stbir__calculate_filters(info->horizontal_contributors, info->horizontal_coefficients, info->horizontal_filter, info->horizontal_scale, info->horizontal_shift, info->input_w, info->output_w); stbir__calculate_filters(info->vertical_contributors, info->vertical_coefficients, info->vertical_filter, info->vertical_scale, info->vertical_shift, info->input_h, info->output_h); STBIR_PROGRESS_REPORT(0); if (stbir__use_height_upsampling(info)) stbir__buffer_loop_upsample(info); else stbir__buffer_loop_downsample(info); STBIR_PROGRESS_REPORT(1); #ifdef STBIR_DEBUG_OVERWRITE_TEST STBIR_ASSERT(memcmp(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0); STBIR_ASSERT(memcmp(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE) == 0); STBIR_ASSERT(memcmp(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0); STBIR_ASSERT(memcmp(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE) == 0); #endif return 1; } static int stbir__resize_arbitrary( void *alloc_context, const void* input_data, int input_w, int input_h, int input_stride_in_bytes, void* output_data, int output_w, int output_h, int output_stride_in_bytes, float s0, float t0, float s1, float t1, float *transform, int channels, int alpha_channel, stbir_uint32 flags, stbir_datatype type, stbir_filter h_filter, stbir_filter v_filter, stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace) { stbir__info info; int result; size_t memory_required; void* extra_memory; stbir__setup(&info, input_w, input_h, output_w, output_h, channels); stbir__calculate_transform(&info, s0,t0,s1,t1,transform); stbir__choose_filter(&info, h_filter, v_filter); memory_required = stbir__calculate_memory(&info); extra_memory = STBIR_MALLOC(memory_required, alloc_context); if (!extra_memory) return 0; result = stbir__resize_allocated(&info, input_data, input_stride_in_bytes, output_data, output_stride_in_bytes, alpha_channel, flags, type, edge_horizontal, edge_vertical, colorspace, extra_memory, memory_required); STBIR_FREE(extra_memory, alloc_context); return result; } STBIRDEF int stbir_resize_uint8( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels) { return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,-1,0, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR); } STBIRDEF int stbir_resize_float( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, float *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels) { return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,-1,0, STBIR_TYPE_FLOAT, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR); } STBIRDEF int stbir_resize_uint8_srgb(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags) { return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB); } STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode) { return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, edge_wrap_mode, edge_wrap_mode, STBIR_COLORSPACE_SRGB); } STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, filter, filter, edge_wrap_mode, edge_wrap_mode, space); } STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels , int input_w , int input_h , int input_stride_in_bytes, stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT16, filter, filter, edge_wrap_mode, edge_wrap_mode, space); } STBIRDEF int stbir_resize_float_generic( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, float *output_pixels , int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_FLOAT, filter, filter, edge_wrap_mode, edge_wrap_mode, space); } STBIRDEF int stbir_resize( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, edge_mode_horizontal, edge_mode_vertical, space); } STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context, float x_scale, float y_scale, float x_offset, float y_offset) { float transform[4]; transform[0] = x_scale; transform[1] = y_scale; transform[2] = x_offset; transform[3] = y_offset; return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,transform,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, edge_mode_horizontal, edge_mode_vertical, space); } STBIRDEF int stbir_resize_region( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context, float s0, float t0, float s1, float t1) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, s0,t0,s1,t1,NULL,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, edge_mode_horizontal, edge_mode_vertical, space); } #endif // STB_IMAGE_RESIZE_IMPLEMENTATION /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ goxel-0.11.0/ext_src/yocto/ext/stb_image_write.h000077500000000000000000002020121435762723100216420ustar00rootroot00000000000000/* stb_image_write - v1.13 - public domain - http://nothings.org/stb/stb_image_write.h writes out PNG/BMP/TGA/JPEG/HDR images to C stdio - Sean Barrett 2010-2015 no warranty implied; use at your own risk Before #including, #define STB_IMAGE_WRITE_IMPLEMENTATION in the file that you want to have the implementation. Will probably not work correctly with strict-aliasing optimizations. If using a modern Microsoft Compiler, non-safe versions of CRT calls may cause compilation warnings or even errors. To avoid this, also before #including, #define STBI_MSC_SECURE_CRT ABOUT: This header file is a library for writing images to C stdio or a callback. The PNG output is not optimal; it is 20-50% larger than the file written by a decent optimizing implementation; though providing a custom zlib compress function (see STBIW_ZLIB_COMPRESS) can mitigate that. This library is designed for source code compactness and simplicity, not optimal image file size or run-time performance. BUILDING: You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h. You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace malloc,realloc,free. You can #define STBIW_MEMMOVE() to replace memmove() You can #define STBIW_ZLIB_COMPRESS to use a custom zlib-style compress function for PNG compression (instead of the builtin one), it must have the following signature: unsigned char * my_compress(unsigned char *data, int data_len, int *out_len, int quality); The returned data will be freed with STBIW_FREE() (free() by default), so it must be heap allocated with STBIW_MALLOC() (malloc() by default), UNICODE: If compiling for Windows and you wish to use Unicode filenames, compile with #define STBIW_WINDOWS_UTF8 and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert Windows wchar_t filenames to utf8. USAGE: There are five functions, one for each image file format: int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); int stbi_write_jpg(char const *filename, int w, int h, int comp, const void *data, int quality); int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); void stbi_flip_vertically_on_write(int flag); // flag is non-zero to flip data vertically There are also five equivalent functions that use an arbitrary write function. You are expected to open/close your file-equivalent before and after calling these: int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); where the callback is: void stbi_write_func(void *context, void *data, int size); You can configure it with these global variables: int stbi_write_tga_with_rle; // defaults to true; set to 0 to disable RLE int stbi_write_png_compression_level; // defaults to 8; set to higher for more compression int stbi_write_force_png_filter; // defaults to -1; set to 0..5 to force a filter mode You can define STBI_WRITE_NO_STDIO to disable the file variant of these functions, so the library will not use stdio.h at all. However, this will also disable HDR writing, because it requires stdio for formatted output. Each function returns 0 on failure and non-0 on success. The functions create an image file defined by the parameters. The image is a rectangle of pixels stored from left-to-right, top-to-bottom. Each pixel contains 'comp' channels of data stored interleaved with 8-bits per channel, in the following order: 1=Y, 2=YA, 3=RGB, 4=RGBA. (Y is monochrome color.) The rectangle is 'w' pixels wide and 'h' pixels tall. The *data pointer points to the first byte of the top-left-most pixel. For PNG, "stride_in_bytes" is the distance in bytes from the first byte of a row of pixels to the first byte of the next row of pixels. PNG creates output files with the same number of components as the input. The BMP format expands Y to RGB in the file format and does not output alpha. PNG supports writing rectangles of data even when the bytes storing rows of data are not consecutive in memory (e.g. sub-rectangles of a larger image), by supplying the stride between the beginning of adjacent rows. The other formats do not. (Thus you cannot write a native-format BMP through the BMP writer, both because it is in BGR order and because it may have padding at the end of the line.) PNG allows you to set the deflate compression level by setting the global variable 'stbi_write_png_compression_level' (it defaults to 8). HDR expects linear float data. Since the format is always 32-bit rgb(e) data, alpha (if provided) is discarded, and for monochrome data it is replicated across all three channels. TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed data, set the global variable 'stbi_write_tga_with_rle' to 0. JPEG does ignore alpha channels in input data; quality is between 1 and 100. Higher quality looks better but results in a bigger image. JPEG baseline (no JPEG progressive). CREDITS: Sean Barrett - PNG/BMP/TGA Baldur Karlsson - HDR Jean-Sebastien Guay - TGA monochrome Tim Kelsey - misc enhancements Alan Hickman - TGA RLE Emmanuel Julien - initial file IO callback implementation Jon Olick - original jo_jpeg.cpp code Daniel Gibson - integrate JPEG, allow external zlib Aarni Koskela - allow choosing PNG filter bugfixes: github:Chribba Guillaume Chereau github:jry2 github:romigrou Sergio Gonzalez Jonas Karlsson Filip Wasil Thatcher Ulrich github:poppolopoppo Patrick Boettcher github:xeekworx Cap Petschulat Simon Rodriguez Ivan Tikhonov github:ignotion Adam Schackart LICENSE See end of file for license information. */ #ifndef INCLUDE_STB_IMAGE_WRITE_H #define INCLUDE_STB_IMAGE_WRITE_H #include // if STB_IMAGE_WRITE_STATIC causes problems, try defining STBIWDEF to 'inline' or 'static inline' #ifndef STBIWDEF #ifdef STB_IMAGE_WRITE_STATIC #define STBIWDEF static #else #ifdef __cplusplus #define STBIWDEF extern "C" #else #define STBIWDEF extern #endif #endif #endif #ifndef STB_IMAGE_WRITE_STATIC // C++ forbids static forward declarations extern int stbi_write_tga_with_rle; extern int stbi_write_png_compression_level; extern int stbi_write_force_png_filter; #endif #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality); #ifdef STBI_WINDOWS_UTF8 STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); #endif #endif typedef void stbi_write_func(void *context, void *data, int size); STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean); #endif//INCLUDE_STB_IMAGE_WRITE_H #ifdef STB_IMAGE_WRITE_IMPLEMENTATION #ifdef _WIN32 #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS #endif #ifndef _CRT_NONSTDC_NO_DEPRECATE #define _CRT_NONSTDC_NO_DEPRECATE #endif #endif #ifndef STBI_WRITE_NO_STDIO #include #endif // STBI_WRITE_NO_STDIO #include #include #include #include #if defined(STBIW_MALLOC) && defined(STBIW_FREE) && (defined(STBIW_REALLOC) || defined(STBIW_REALLOC_SIZED)) // ok #elif !defined(STBIW_MALLOC) && !defined(STBIW_FREE) && !defined(STBIW_REALLOC) && !defined(STBIW_REALLOC_SIZED) // ok #else #error "Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC (or STBIW_REALLOC_SIZED)." #endif #ifndef STBIW_MALLOC #define STBIW_MALLOC(sz) malloc(sz) #define STBIW_REALLOC(p,newsz) realloc(p,newsz) #define STBIW_FREE(p) free(p) #endif #ifndef STBIW_REALLOC_SIZED #define STBIW_REALLOC_SIZED(p,oldsz,newsz) STBIW_REALLOC(p,newsz) #endif #ifndef STBIW_MEMMOVE #define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz) #endif #ifndef STBIW_ASSERT #include #define STBIW_ASSERT(x) assert(x) #endif #define STBIW_UCHAR(x) (unsigned char) ((x) & 0xff) #ifdef STB_IMAGE_WRITE_STATIC static int stbi__flip_vertically_on_write=0; static int stbi_write_png_compression_level = 8; static int stbi_write_tga_with_rle = 1; static int stbi_write_force_png_filter = -1; #else int stbi_write_png_compression_level = 8; int stbi__flip_vertically_on_write=0; int stbi_write_tga_with_rle = 1; int stbi_write_force_png_filter = -1; #endif STBIWDEF void stbi_flip_vertically_on_write(int flag) { stbi__flip_vertically_on_write = flag; } typedef struct { stbi_write_func *func; void *context; } stbi__write_context; // initialize a callback-based context static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func *c, void *context) { s->func = c; s->context = context; } #ifndef STBI_WRITE_NO_STDIO static void stbi__stdio_write(void *context, void *data, int size) { fwrite(data,1,size,(FILE*) context); } #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) #ifdef __cplusplus #define STBIW_EXTERN extern "C" #else #define STBIW_EXTERN extern #endif STBIW_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); STBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) { return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); } #endif static FILE *stbiw__fopen(char const *filename, char const *mode) { FILE *f; #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) wchar_t wMode[64]; wchar_t wFilename[1024]; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename))) return 0; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode))) return 0; #if _MSC_VER >= 1400 if (0 != _wfopen_s(&f, wFilename, wMode)) f = 0; #else f = _wfopen(wFilename, wMode); #endif #elif defined(_MSC_VER) && _MSC_VER >= 1400 if (0 != fopen_s(&f, filename, mode)) f=0; #else f = fopen(filename, mode); #endif return f; } static int stbi__start_write_file(stbi__write_context *s, const char *filename) { FILE *f = stbiw__fopen(filename, "wb"); stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f); return f != NULL; } static void stbi__end_write_file(stbi__write_context *s) { fclose((FILE *)s->context); } #endif // !STBI_WRITE_NO_STDIO typedef unsigned int stbiw_uint32; typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1]; static void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v) { while (*fmt) { switch (*fmt++) { case ' ': break; case '1': { unsigned char x = STBIW_UCHAR(va_arg(v, int)); s->func(s->context,&x,1); break; } case '2': { int x = va_arg(v,int); unsigned char b[2]; b[0] = STBIW_UCHAR(x); b[1] = STBIW_UCHAR(x>>8); s->func(s->context,b,2); break; } case '4': { stbiw_uint32 x = va_arg(v,int); unsigned char b[4]; b[0]=STBIW_UCHAR(x); b[1]=STBIW_UCHAR(x>>8); b[2]=STBIW_UCHAR(x>>16); b[3]=STBIW_UCHAR(x>>24); s->func(s->context,b,4); break; } default: STBIW_ASSERT(0); return; } } } static void stbiw__writef(stbi__write_context *s, const char *fmt, ...) { va_list v; va_start(v, fmt); stbiw__writefv(s, fmt, v); va_end(v); } static void stbiw__putc(stbi__write_context *s, unsigned char c) { s->func(s->context, &c, 1); } static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c) { unsigned char arr[3]; arr[0] = a; arr[1] = b; arr[2] = c; s->func(s->context, arr, 3); } static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d) { unsigned char bg[3] = { 255, 0, 255}, px[3]; int k; if (write_alpha < 0) s->func(s->context, &d[comp - 1], 1); switch (comp) { case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case case 1: if (expand_mono) stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp else s->func(s->context, d, 1); // monochrome TGA break; case 4: if (!write_alpha) { // composite against pink background for (k = 0; k < 3; ++k) px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255; stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]); break; } /* FALLTHROUGH */ case 3: stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]); break; } if (write_alpha > 0) s->func(s->context, &d[comp - 1], 1); } static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono) { stbiw_uint32 zero = 0; int i,j, j_end; if (y <= 0) return; if (stbi__flip_vertically_on_write) vdir *= -1; if (vdir < 0) { j_end = -1; j = y-1; } else { j_end = y; j = 0; } for (; j != j_end; j += vdir) { for (i=0; i < x; ++i) { unsigned char *d = (unsigned char *) data + (j*x+i)*comp; stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d); } s->func(s->context, &zero, scanline_pad); } } static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...) { if (y < 0 || x < 0) { return 0; } else { va_list v; va_start(v, fmt); stbiw__writefv(s, fmt, v); va_end(v); stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono); return 1; } } static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data) { int pad = (-x*3) & 3; return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad, "11 4 22 4" "4 44 22 444444", 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header } STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_bmp_core(&s, x, y, comp, data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_bmp_core(&s, x, y, comp, data); stbi__end_write_file(&s); return r; } else return 0; } #endif //!STBI_WRITE_NO_STDIO static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data) { int has_alpha = (comp == 2 || comp == 4); int colorbytes = has_alpha ? comp-1 : comp; int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3 if (y < 0 || x < 0) return 0; if (!stbi_write_tga_with_rle) { return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0, "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8); } else { int i,j,k; int jend, jdir; stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8); if (stbi__flip_vertically_on_write) { j = 0; jend = y; jdir = 1; } else { j = y-1; jend = -1; jdir = -1; } for (; j != jend; j += jdir) { unsigned char *row = (unsigned char *) data + j * x * comp; int len; for (i = 0; i < x; i += len) { unsigned char *begin = row + i * comp; int diff = 1; len = 1; if (i < x - 1) { ++len; diff = memcmp(begin, row + (i + 1) * comp, comp); if (diff) { const unsigned char *prev = begin; for (k = i + 2; k < x && len < 128; ++k) { if (memcmp(prev, row + k * comp, comp)) { prev += comp; ++len; } else { --len; break; } } } else { for (k = i + 2; k < x && len < 128; ++k) { if (!memcmp(begin, row + k * comp, comp)) { ++len; } else { break; } } } } if (diff) { unsigned char header = STBIW_UCHAR(len - 1); s->func(s->context, &header, 1); for (k = 0; k < len; ++k) { stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp); } } else { unsigned char header = STBIW_UCHAR(len - 129); s->func(s->context, &header, 1); stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin); } } } } return 1; } STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_tga_core(&s, x, y, comp, (void *) data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_tga_core(&s, x, y, comp, (void *) data); stbi__end_write_file(&s); return r; } else return 0; } #endif // ************************************************************************************************* // Radiance RGBE HDR writer // by Baldur Karlsson #define stbiw__max(a, b) ((a) > (b) ? (a) : (b)) static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) { int exponent; float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2])); if (maxcomp < 1e-32f) { rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0; } else { float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp; rgbe[0] = (unsigned char)(linear[0] * normalize); rgbe[1] = (unsigned char)(linear[1] * normalize); rgbe[2] = (unsigned char)(linear[2] * normalize); rgbe[3] = (unsigned char)(exponent + 128); } } static void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte) { unsigned char lengthbyte = STBIW_UCHAR(length+128); STBIW_ASSERT(length+128 <= 255); s->func(s->context, &lengthbyte, 1); s->func(s->context, &databyte, 1); } static void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data) { unsigned char lengthbyte = STBIW_UCHAR(length); STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code s->func(s->context, &lengthbyte, 1); s->func(s->context, data, length); } static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline) { unsigned char scanlineheader[4] = { 2, 2, 0, 0 }; unsigned char rgbe[4]; float linear[3]; int x; scanlineheader[2] = (width&0xff00)>>8; scanlineheader[3] = (width&0x00ff); /* skip RLE for images too small or large */ if (width < 8 || width >= 32768) { for (x=0; x < width; x++) { switch (ncomp) { case 4: /* fallthrough */ case 3: linear[2] = scanline[x*ncomp + 2]; linear[1] = scanline[x*ncomp + 1]; linear[0] = scanline[x*ncomp + 0]; break; default: linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; break; } stbiw__linear_to_rgbe(rgbe, linear); s->func(s->context, rgbe, 4); } } else { int c,r; /* encode into scratch buffer */ for (x=0; x < width; x++) { switch(ncomp) { case 4: /* fallthrough */ case 3: linear[2] = scanline[x*ncomp + 2]; linear[1] = scanline[x*ncomp + 1]; linear[0] = scanline[x*ncomp + 0]; break; default: linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; break; } stbiw__linear_to_rgbe(rgbe, linear); scratch[x + width*0] = rgbe[0]; scratch[x + width*1] = rgbe[1]; scratch[x + width*2] = rgbe[2]; scratch[x + width*3] = rgbe[3]; } s->func(s->context, scanlineheader, 4); /* RLE each component separately */ for (c=0; c < 4; c++) { unsigned char *comp = &scratch[width*c]; x = 0; while (x < width) { // find first run r = x; while (r+2 < width) { if (comp[r] == comp[r+1] && comp[r] == comp[r+2]) break; ++r; } if (r+2 >= width) r = width; // dump up to first run while (x < r) { int len = r-x; if (len > 128) len = 128; stbiw__write_dump_data(s, len, &comp[x]); x += len; } // if there's a run, output it if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd // find next byte after run while (r < width && comp[r] == comp[x]) ++r; // output run up to r while (x < r) { int len = r-x; if (len > 127) len = 127; stbiw__write_run_data(s, len, comp[x]); x += len; } } } } } } static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data) { if (y <= 0 || x <= 0 || data == NULL) return 0; else { // Each component is stored separately. Allocate scratch space for full output scanline. unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4); int i, len; char buffer[128]; char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n"; s->func(s->context, header, sizeof(header)-1); #ifdef __STDC_WANT_SECURE_LIB__ len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); #else len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); #endif s->func(s->context, buffer, len); for(i=0; i < y; i++) stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i)); STBIW_FREE(scratch); return 1; } } STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_hdr_core(&s, x, y, comp, (float *) data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data); stbi__end_write_file(&s); return r; } else return 0; } #endif // STBI_WRITE_NO_STDIO ////////////////////////////////////////////////////////////////////////////// // // PNG writer // #ifndef STBIW_ZLIB_COMPRESS // stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size() #define stbiw__sbraw(a) ((int *) (a) - 2) #define stbiw__sbm(a) stbiw__sbraw(a)[0] #define stbiw__sbn(a) stbiw__sbraw(a)[1] #define stbiw__sbneedgrow(a,n) ((a)==0 || stbiw__sbn(a)+n >= stbiw__sbm(a)) #define stbiw__sbmaybegrow(a,n) (stbiw__sbneedgrow(a,(n)) ? stbiw__sbgrow(a,n) : 0) #define stbiw__sbgrow(a,n) stbiw__sbgrowf((void **) &(a), (n), sizeof(*(a))) #define stbiw__sbpush(a, v) (stbiw__sbmaybegrow(a,1), (a)[stbiw__sbn(a)++] = (v)) #define stbiw__sbcount(a) ((a) ? stbiw__sbn(a) : 0) #define stbiw__sbfree(a) ((a) ? STBIW_FREE(stbiw__sbraw(a)),0 : 0) static void *stbiw__sbgrowf(void **arr, int increment, int itemsize) { int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1; void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2); STBIW_ASSERT(p); if (p) { if (!*arr) ((int *) p)[1] = 0; *arr = (void *) ((int *) p + 2); stbiw__sbm(*arr) = m; } return *arr; } static unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount) { while (*bitcount >= 8) { stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer)); *bitbuffer >>= 8; *bitcount -= 8; } return data; } static int stbiw__zlib_bitrev(int code, int codebits) { int res=0; while (codebits--) { res = (res << 1) | (code & 1); code >>= 1; } return res; } static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit) { int i; for (i=0; i < limit && i < 258; ++i) if (a[i] != b[i]) break; return i; } static unsigned int stbiw__zhash(unsigned char *data) { stbiw_uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16); hash ^= hash << 3; hash += hash >> 5; hash ^= hash << 4; hash += hash >> 17; hash ^= hash << 25; hash += hash >> 6; return hash; } #define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount)) #define stbiw__zlib_add(code,codebits) \ (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush()) #define stbiw__zlib_huffa(b,c) stbiw__zlib_add(stbiw__zlib_bitrev(b,c),c) // default huffman tables #define stbiw__zlib_huff1(n) stbiw__zlib_huffa(0x30 + (n), 8) #define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n)-144, 9) #define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n)-256,7) #define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n)-280,8) #define stbiw__zlib_huff(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : (n) <= 255 ? stbiw__zlib_huff2(n) : (n) <= 279 ? stbiw__zlib_huff3(n) : stbiw__zlib_huff4(n)) #define stbiw__zlib_huffb(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : stbiw__zlib_huff2(n)) #define stbiw__ZHASH 16384 #endif // STBIW_ZLIB_COMPRESS STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality) { #ifdef STBIW_ZLIB_COMPRESS // user provided a zlib compress implementation, use that return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality); #else // use builtin static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 }; static unsigned char lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 }; static unsigned short distc[] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 }; static unsigned char disteb[] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 }; unsigned int bitbuf=0; int i,j, bitcount=0; unsigned char *out = NULL; unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(char**)); if (hash_table == NULL) return NULL; if (quality < 5) quality = 5; stbiw__sbpush(out, 0x78); // DEFLATE 32K window stbiw__sbpush(out, 0x5e); // FLEVEL = 1 stbiw__zlib_add(1,1); // BFINAL = 1 stbiw__zlib_add(1,2); // BTYPE = 1 -- fixed huffman for (i=0; i < stbiw__ZHASH; ++i) hash_table[i] = NULL; i=0; while (i < data_len-3) { // hash next 3 bytes of data to be compressed int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3; unsigned char *bestloc = 0; unsigned char **hlist = hash_table[h]; int n = stbiw__sbcount(hlist); for (j=0; j < n; ++j) { if (hlist[j]-data > i-32768) { // if entry lies within window int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i); if (d >= best) { best=d; bestloc=hlist[j]; } } } // when hash table entry is too long, delete half the entries if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) { STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality); stbiw__sbn(hash_table[h]) = quality; } stbiw__sbpush(hash_table[h],data+i); if (bestloc) { // "lazy matching" - check match at *next* byte, and if it's better, do cur byte as literal h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1); hlist = hash_table[h]; n = stbiw__sbcount(hlist); for (j=0; j < n; ++j) { if (hlist[j]-data > i-32767) { int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1); if (e > best) { // if next match is better, bail on current match bestloc = NULL; break; } } } } if (bestloc) { int d = (int) (data+i - bestloc); // distance back STBIW_ASSERT(d <= 32767 && best <= 258); for (j=0; best > lengthc[j+1]-1; ++j); stbiw__zlib_huff(j+257); if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]); for (j=0; d > distc[j+1]-1; ++j); stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5); if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]); i += best; } else { stbiw__zlib_huffb(data[i]); ++i; } } // write out final bytes for (;i < data_len; ++i) stbiw__zlib_huffb(data[i]); stbiw__zlib_huff(256); // end of block // pad with 0 bits to byte boundary while (bitcount) stbiw__zlib_add(0,1); for (i=0; i < stbiw__ZHASH; ++i) (void) stbiw__sbfree(hash_table[i]); STBIW_FREE(hash_table); { // compute adler32 on input unsigned int s1=1, s2=0; int blocklen = (int) (data_len % 5552); j=0; while (j < data_len) { for (i=0; i < blocklen; ++i) { s1 += data[j+i]; s2 += s1; } s1 %= 65521; s2 %= 65521; j += blocklen; blocklen = 5552; } stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8)); stbiw__sbpush(out, STBIW_UCHAR(s2)); stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8)); stbiw__sbpush(out, STBIW_UCHAR(s1)); } *out_len = stbiw__sbn(out); // make returned pointer freeable STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len); return (unsigned char *) stbiw__sbraw(out); #endif // STBIW_ZLIB_COMPRESS } static unsigned int stbiw__crc32(unsigned char *buffer, int len) { #ifdef STBIW_CRC32 return STBIW_CRC32(buffer, len); #else static unsigned int crc_table[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D }; unsigned int crc = ~0u; int i; for (i=0; i < len; ++i) crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)]; return ~crc; #endif } #define stbiw__wpng4(o,a,b,c,d) ((o)[0]=STBIW_UCHAR(a),(o)[1]=STBIW_UCHAR(b),(o)[2]=STBIW_UCHAR(c),(o)[3]=STBIW_UCHAR(d),(o)+=4) #define stbiw__wp32(data,v) stbiw__wpng4(data, (v)>>24,(v)>>16,(v)>>8,(v)); #define stbiw__wptag(data,s) stbiw__wpng4(data, s[0],s[1],s[2],s[3]) static void stbiw__wpcrc(unsigned char **data, int len) { unsigned int crc = stbiw__crc32(*data - len - 4, len+4); stbiw__wp32(*data, crc); } static unsigned char stbiw__paeth(int a, int b, int c) { int p = a + b - c, pa = abs(p-a), pb = abs(p-b), pc = abs(p-c); if (pa <= pb && pa <= pc) return STBIW_UCHAR(a); if (pb <= pc) return STBIW_UCHAR(b); return STBIW_UCHAR(c); } // @OPTIMIZE: provide an option that always forces left-predict or paeth predict static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer) { static int mapping[] = { 0,1,2,3,4 }; static int firstmap[] = { 0,1,0,5,6 }; int *mymap = (y != 0) ? mapping : firstmap; int i; int type = mymap[filter_type]; unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y); int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes; if (type==0) { memcpy(line_buffer, z, width*n); return; } // first loop isn't optimized since it's just one pixel for (i = 0; i < n; ++i) { switch (type) { case 1: line_buffer[i] = z[i]; break; case 2: line_buffer[i] = z[i] - z[i-signed_stride]; break; case 3: line_buffer[i] = z[i] - (z[i-signed_stride]>>1); break; case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-signed_stride],0)); break; case 5: line_buffer[i] = z[i]; break; case 6: line_buffer[i] = z[i]; break; } } switch (type) { case 1: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-n]; break; case 2: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-signed_stride]; break; case 3: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - ((z[i-n] + z[i-signed_stride])>>1); break; case 4: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-signed_stride], z[i-signed_stride-n]); break; case 5: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - (z[i-n]>>1); break; case 6: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break; } } STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len) { int force_filter = stbi_write_force_png_filter; int ctype[5] = { -1, 0, 4, 2, 6 }; unsigned char sig[8] = { 137,80,78,71,13,10,26,10 }; unsigned char *out,*o, *filt, *zlib; signed char *line_buffer; int j,zlen; if (stride_bytes == 0) stride_bytes = x * n; if (force_filter >= 5) { force_filter = -1; } filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0; line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; } for (j=0; j < y; ++j) { int filter_type; if (force_filter > -1) { filter_type = force_filter; stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer); } else { // Estimate the best filter by running through all of them: int best_filter = 0, best_filter_val = 0x7fffffff, est, i; for (filter_type = 0; filter_type < 5; filter_type++) { stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer); // Estimate the entropy of the line using this filter; the less, the better. est = 0; for (i = 0; i < x*n; ++i) { est += abs((signed char) line_buffer[i]); } if (est < best_filter_val) { best_filter_val = est; best_filter = filter_type; } } if (filter_type != best_filter) { // If the last iteration already got us the best filter, don't redo it stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer); filter_type = best_filter; } } // when we get here, filter_type contains the filter type, and line_buffer contains the data filt[j*(x*n+1)] = (unsigned char) filter_type; STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n); } STBIW_FREE(line_buffer); zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level); STBIW_FREE(filt); if (!zlib) return 0; // each tag requires 12 bytes of overhead out = (unsigned char *) STBIW_MALLOC(8 + 12+13 + 12+zlen + 12); if (!out) return 0; *out_len = 8 + 12+13 + 12+zlen + 12; o=out; STBIW_MEMMOVE(o,sig,8); o+= 8; stbiw__wp32(o, 13); // header length stbiw__wptag(o, "IHDR"); stbiw__wp32(o, x); stbiw__wp32(o, y); *o++ = 8; *o++ = STBIW_UCHAR(ctype[n]); *o++ = 0; *o++ = 0; *o++ = 0; stbiw__wpcrc(&o,13); stbiw__wp32(o, zlen); stbiw__wptag(o, "IDAT"); STBIW_MEMMOVE(o, zlib, zlen); o += zlen; STBIW_FREE(zlib); stbiw__wpcrc(&o, zlen); stbiw__wp32(o,0); stbiw__wptag(o, "IEND"); stbiw__wpcrc(&o,0); STBIW_ASSERT(o == out + *out_len); return out; } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes) { FILE *f; int len; unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); if (png == NULL) return 0; f = stbiw__fopen(filename, "wb"); if (!f) { STBIW_FREE(png); return 0; } fwrite(png, 1, len, f); fclose(f); STBIW_FREE(png); return 1; } #endif STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes) { int len; unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); if (png == NULL) return 0; func(context, png, len); STBIW_FREE(png); return 1; } /* *************************************************************************** * * JPEG writer * * This is based on Jon Olick's jo_jpeg.cpp: * public domain Simple, Minimalistic JPEG writer - http://www.jonolick.com/code.html */ static const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18, 24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 }; static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) { int bitBuf = *bitBufP, bitCnt = *bitCntP; bitCnt += bs[1]; bitBuf |= bs[0] << (24 - bitCnt); while(bitCnt >= 8) { unsigned char c = (bitBuf >> 16) & 255; stbiw__putc(s, c); if(c == 255) { stbiw__putc(s, 0); } bitBuf <<= 8; bitCnt -= 8; } *bitBufP = bitBuf; *bitCntP = bitCnt; } static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p) { float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p; float z1, z2, z3, z4, z5, z11, z13; float tmp0 = d0 + d7; float tmp7 = d0 - d7; float tmp1 = d1 + d6; float tmp6 = d1 - d6; float tmp2 = d2 + d5; float tmp5 = d2 - d5; float tmp3 = d3 + d4; float tmp4 = d3 - d4; // Even part float tmp10 = tmp0 + tmp3; // phase 2 float tmp13 = tmp0 - tmp3; float tmp11 = tmp1 + tmp2; float tmp12 = tmp1 - tmp2; d0 = tmp10 + tmp11; // phase 3 d4 = tmp10 - tmp11; z1 = (tmp12 + tmp13) * 0.707106781f; // c4 d2 = tmp13 + z1; // phase 5 d6 = tmp13 - z1; // Odd part tmp10 = tmp4 + tmp5; // phase 2 tmp11 = tmp5 + tmp6; tmp12 = tmp6 + tmp7; // The rotator is modified from fig 4-8 to avoid extra negations. z5 = (tmp10 - tmp12) * 0.382683433f; // c6 z2 = tmp10 * 0.541196100f + z5; // c2-c6 z4 = tmp12 * 1.306562965f + z5; // c2+c6 z3 = tmp11 * 0.707106781f; // c4 z11 = tmp7 + z3; // phase 5 z13 = tmp7 - z3; *d5p = z13 + z2; // phase 6 *d3p = z13 - z2; *d1p = z11 + z4; *d7p = z11 - z4; *d0p = d0; *d2p = d2; *d4p = d4; *d6p = d6; } static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) { int tmp1 = val < 0 ? -val : val; val = val < 0 ? val-1 : val; bits[1] = 1; while(tmp1 >>= 1) { ++bits[1]; } bits[0] = val & ((1<0)&&(DU[end0pos]==0); --end0pos) { } // end0pos = first element in reverse order !=0 if(end0pos == 0) { stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); return DU[0]; } for(i = 1; i <= end0pos; ++i) { int startpos = i; int nrzeroes; unsigned short bits[2]; for (; DU[i]==0 && i<=end0pos; ++i) { } nrzeroes = i-startpos; if ( nrzeroes >= 16 ) { int lng = nrzeroes>>4; int nrmarker; for (nrmarker=1; nrmarker <= lng; ++nrmarker) stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes); nrzeroes &= 15; } stbiw__jpg_calcBits(DU[i], bits); stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]); stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); } if(end0pos != 63) { stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); } return DU[0]; } static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, const void* data, int quality) { // Constants that don't pollute global namespace static const unsigned char std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0}; static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d}; static const unsigned char std_ac_luminance_values[] = { 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08, 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28, 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59, 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89, 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6, 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2, 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa }; static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0}; static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77}; static const unsigned char std_ac_chrominance_values[] = { 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91, 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26, 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58, 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87, 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4, 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda, 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa }; // Huffman tables static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}}; static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}}; static const unsigned short YAC_HT[256][2] = { {10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0}, {2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} }; static const unsigned short UVAC_HT[256][2] = { {0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0}, {1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} }; static const int YQT[] = {16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22, 37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99}; static const int UVQT[] = {17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99}; static const float aasf[] = { 1.0f * 2.828427125f, 1.387039845f * 2.828427125f, 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f, 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f }; int row, col, i, k; float fdtbl_Y[64], fdtbl_UV[64]; unsigned char YTable[64], UVTable[64]; if(!data || !width || !height || comp > 4 || comp < 1) { return 0; } quality = quality ? quality : 90; quality = quality < 1 ? 1 : quality > 100 ? 100 : quality; quality = quality < 50 ? 5000 / quality : 200 - quality * 2; for(i = 0; i < 64; ++i) { int uvti, yti = (YQT[i]*quality+50)/100; YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti); uvti = (UVQT[i]*quality+50)/100; UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti); } for(row = 0, k = 0; row < 8; ++row) { for(col = 0; col < 8; ++col, ++k) { fdtbl_Y[k] = 1 / (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); } } // Write Headers { static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 }; static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 }; const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width), 3,1,0x11,0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 }; s->func(s->context, (void*)head0, sizeof(head0)); s->func(s->context, (void*)YTable, sizeof(YTable)); stbiw__putc(s, 1); s->func(s->context, UVTable, sizeof(UVTable)); s->func(s->context, (void*)head1, sizeof(head1)); s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1); s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values)); stbiw__putc(s, 0x10); // HTYACinfo s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1); s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values)); stbiw__putc(s, 1); // HTUDCinfo s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1); s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values)); stbiw__putc(s, 0x11); // HTUACinfo s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1); s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values)); s->func(s->context, (void*)head2, sizeof(head2)); } // Encode 8x8 macroblocks { static const unsigned short fillBits[] = {0x7F, 7}; const unsigned char *imageData = (const unsigned char *)data; int DCY=0, DCU=0, DCV=0; int bitBuf=0, bitCnt=0; // comp == 2 is grey+alpha (alpha is ignored) int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0; int x, y, pos; for(y = 0; y < height; y += 8) { for(x = 0; x < width; x += 8) { float YDU[64], UDU[64], VDU[64]; for(row = y, pos = 0; row < y+8; ++row) { // row >= height => use last input row int clamped_row = (row < height) ? row : height - 1; int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; for(col = x; col < x+8; ++col, ++pos) { float r, g, b; // if col >= width => use pixel from last input column int p = base_p + ((col < width) ? col : (width-1))*comp; r = imageData[p+0]; g = imageData[p+ofsG]; b = imageData[p+ofsB]; YDU[pos]=+0.29900f*r+0.58700f*g+0.11400f*b-128; UDU[pos]=-0.16874f*r-0.33126f*g+0.50000f*b; VDU[pos]=+0.50000f*r-0.41869f*g-0.08131f*b; } } DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT); DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); } } // Do the bit alignment of the EOI marker stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits); } // EOI stbiw__putc(s, 0xFF); stbiw__putc(s, 0xD9); return 1; } STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_jpg_core(&s, x, y, comp, data, quality); stbi__end_write_file(&s); return r; } else return 0; } #endif #endif // STB_IMAGE_WRITE_IMPLEMENTATION /* Revision history 1.10 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs 1.09 (2018-02-11) fix typo in zlib quality API, improve STB_I_W_STATIC in C++ 1.08 (2018-01-29) add stbi__flip_vertically_on_write, external zlib, zlib quality, choose PNG filter 1.07 (2017-07-24) doc fix 1.06 (2017-07-23) writing JPEG (using Jon Olick's code) 1.05 ??? 1.04 (2017-03-03) monochrome BMP expansion 1.03 ??? 1.02 (2016-04-02) avoid allocating large structures on the stack 1.01 (2016-01-16) STBIW_REALLOC_SIZED: support allocators with no realloc support avoid race-condition in crc initialization minor compile issues 1.00 (2015-09-14) installable file IO function 0.99 (2015-09-13) warning fixes; TGA rle support 0.98 (2015-04-08) added STBIW_MALLOC, STBIW_ASSERT etc 0.97 (2015-01-18) fixed HDR asserts, rewrote HDR rle logic 0.96 (2015-01-17) add HDR output fix monochrome BMP 0.95 (2014-08-17) add monochrome TGA output 0.94 (2014-05-31) rename private functions to avoid conflicts with stb_image.h 0.93 (2014-05-27) warning fixes 0.92 (2010-08-01) casts to unsigned char to fix warnings 0.91 (2010-07-17) first public release 0.90 first internal release */ /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ goxel-0.11.0/ext_src/yocto/ext/tinyexr.h000066400000000000000000015355701435762723100202200ustar00rootroot00000000000000/* Copyright (c) 2014 - 2017, Syoyo Fujita 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. * Neither the name of the Syoyo Fujita nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 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 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. */ // TinyEXR contains some OpenEXR code, which is licensed under ------------ /////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas // Digital Ltd. LLC // // 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. // * Neither the name of Industrial Light & Magic nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // 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 // OWNER 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. // /////////////////////////////////////////////////////////////////////////// // End of OpenEXR license ------------------------------------------------- #ifndef TINYEXR_H_ #define TINYEXR_H_ // // // Do this: // #define TINYEXR_IMPLEMENTATION // before you include this file in *one* C or C++ file to create the // implementation. // // // i.e. it should look like this: // #include ... // #include ... // #include ... // #define TINYEXR_IMPLEMENTATION // #include "tinyexr.h" // // #include // for size_t #include // guess stdint.h is available(C99) #ifdef __cplusplus extern "C" { #endif // Use embedded miniz or not to decode ZIP format pixel. Linking with zlib // required if this flas is 0. #ifndef TINYEXR_USE_MINIZ #define TINYEXR_USE_MINIZ (1) #endif // Disable PIZ comporession when applying cpplint. #ifndef TINYEXR_USE_PIZ #define TINYEXR_USE_PIZ (1) #endif #ifndef TINYEXR_USE_ZFP #define TINYEXR_USE_ZFP (0) // TinyEXR extension. // http://computation.llnl.gov/projects/floating-point-compression #endif #define TINYEXR_SUCCESS (0) #define TINYEXR_ERROR_INVALID_MAGIC_NUMBER (-1) #define TINYEXR_ERROR_INVALID_EXR_VERSION (-2) #define TINYEXR_ERROR_INVALID_ARGUMENT (-3) #define TINYEXR_ERROR_INVALID_DATA (-4) #define TINYEXR_ERROR_INVALID_FILE (-5) #define TINYEXR_ERROR_INVALID_PARAMETER (-5) #define TINYEXR_ERROR_CANT_OPEN_FILE (-6) #define TINYEXR_ERROR_UNSUPPORTED_FORMAT (-7) #define TINYEXR_ERROR_INVALID_HEADER (-8) // @note { OpenEXR file format: http://www.openexr.com/openexrfilelayout.pdf } // pixel type: possible values are: UINT = 0 HALF = 1 FLOAT = 2 #define TINYEXR_PIXELTYPE_UINT (0) #define TINYEXR_PIXELTYPE_HALF (1) #define TINYEXR_PIXELTYPE_FLOAT (2) #define TINYEXR_MAX_ATTRIBUTES (128) #define TINYEXR_COMPRESSIONTYPE_NONE (0) #define TINYEXR_COMPRESSIONTYPE_RLE (1) #define TINYEXR_COMPRESSIONTYPE_ZIPS (2) #define TINYEXR_COMPRESSIONTYPE_ZIP (3) #define TINYEXR_COMPRESSIONTYPE_PIZ (4) #define TINYEXR_COMPRESSIONTYPE_ZFP (128) // TinyEXR extension #define TINYEXR_ZFP_COMPRESSIONTYPE_RATE (0) #define TINYEXR_ZFP_COMPRESSIONTYPE_PRECISION (1) #define TINYEXR_ZFP_COMPRESSIONTYPE_ACCURACY (2) #define TINYEXR_TILE_ONE_LEVEL (0) #define TINYEXR_TILE_MIPMAP_LEVELS (1) #define TINYEXR_TILE_RIPMAP_LEVELS (2) #define TINYEXR_TILE_ROUND_DOWN (0) #define TINYEXR_TILE_ROUND_UP (1) typedef struct _EXRVersion { int version; // this must be 2 int tiled; // tile format image int long_name; // long name attribute int non_image; // deep image(EXR 2.0) int multipart; // multi-part(EXR 2.0) } EXRVersion; typedef struct _EXRAttribute { char name[256]; // name and type are up to 255 chars long. char type[256]; unsigned char *value; // uint8_t* int size; int pad0; } EXRAttribute; typedef struct _EXRChannelInfo { char name[256]; // less than 255 bytes long int pixel_type; int x_sampling; int y_sampling; unsigned char p_linear; unsigned char pad[3]; } EXRChannelInfo; typedef struct _EXRTile { int offset_x; int offset_y; int level_x; int level_y; int width; // actual width in a tile. int height; // actual height int a tile. unsigned char **images; // image[channels][pixels] } EXRTile; typedef struct _EXRHeader { float pixel_aspect_ratio; int line_order; int data_window[4]; int display_window[4]; float screen_window_center[2]; float screen_window_width; int chunk_count; // Properties for tiled format(`tiledesc`). int tiled; int tile_size_x; int tile_size_y; int tile_level_mode; int tile_rounding_mode; int long_name; int non_image; int multipart; unsigned int header_len; // Custom attributes(exludes required attributes(e.g. `channels`, // `compression`, etc) int num_custom_attributes; EXRAttribute custom_attributes[TINYEXR_MAX_ATTRIBUTES]; EXRChannelInfo *channels; // [num_channels] int *pixel_types; // Loaded pixel type(TINYEXR_PIXELTYPE_*) of `images` for // each channel. This is overwritten with `requested_pixel_types` when // loading. int num_channels; int compression_type; // compression type(TINYEXR_COMPRESSIONTYPE_*) int *requested_pixel_types; // Filled initially by // ParseEXRHeaderFrom(Meomory|File), then users // can edit it(only valid for HALF pixel type // channel) } EXRHeader; typedef struct _EXRMultiPartHeader { int num_headers; EXRHeader *headers; } EXRMultiPartHeader; typedef struct _EXRImage { EXRTile *tiles; // Tiled pixel data. The application must reconstruct image // from tiles manually. NULL if scanline format. unsigned char **images; // image[channels][pixels]. NULL if tiled format. int width; int height; int num_channels; // Properties for tile format. int num_tiles; } EXRImage; typedef struct _EXRMultiPartImage { int num_images; EXRImage *images; } EXRMultiPartImage; typedef struct _DeepImage { const char **channel_names; float ***image; // image[channels][scanlines][samples] int **offset_table; // offset_table[scanline][offsets] int num_channels; int width; int height; int pad0; } DeepImage; // @deprecated { to be removed. } // Loads single-frame OpenEXR image. Assume EXR image contains RGB(A) channels. // Application must free image data as returned by `out_rgba` // Result image format is: float x RGBA x width x hight // Returns negative value and may set error string in `err` when there's an // error extern int LoadEXR(float **out_rgba, int *width, int *height, const char *filename, const char **err); // @deprecated { to be removed. } // Saves single-frame OpenEXR image. Assume EXR image contains RGB(A) channels. // components must be 3(RGB) or 4(RGBA). // Result image format is: float x RGB(A) x width x hight extern int SaveEXR(const float *data, int width, int height, int components, const char *filename); // Initialize EXRHeader struct extern void InitEXRHeader(EXRHeader *exr_header); // Initialize EXRImage struct extern void InitEXRImage(EXRImage *exr_image); // Free's internal data of EXRHeader struct extern int FreeEXRHeader(EXRHeader *exr_header); // Free's internal data of EXRImage struct extern int FreeEXRImage(EXRImage *exr_image); // Parse EXR version header of a file. extern int ParseEXRVersionFromFile(EXRVersion *version, const char *filename); // Parse EXR version header from memory-mapped EXR data. extern int ParseEXRVersionFromMemory(EXRVersion *version, const unsigned char *memory, size_t size); // Parse single-part OpenEXR header from a file and initialize `EXRHeader`. extern int ParseEXRHeaderFromFile(EXRHeader *header, const EXRVersion *version, const char *filename, const char **err); // Parse single-part OpenEXR header from a memory and initialize `EXRHeader`. extern int ParseEXRHeaderFromMemory(EXRHeader *header, const EXRVersion *version, const unsigned char *memory, size_t size, const char **err); // Parse multi-part OpenEXR headers from a file and initialize `EXRHeader*` // array. extern int ParseEXRMultipartHeaderFromFile(EXRHeader ***headers, int *num_headers, const EXRVersion *version, const char *filename, const char **err); // Parse multi-part OpenEXR headers from a memory and initialize `EXRHeader*` // array extern int ParseEXRMultipartHeaderFromMemory(EXRHeader ***headers, int *num_headers, const EXRVersion *version, const unsigned char *memory, size_t size, const char **err); // Loads single-part OpenEXR image from a file. // Application must setup `ParseEXRHeaderFromFile` before calling this function. // Application can free EXRImage using `FreeEXRImage` // Returns negative value and may set error string in `err` when there's an // error extern int LoadEXRImageFromFile(EXRImage *image, const EXRHeader *header, const char *filename, const char **err); // Loads single-part OpenEXR image from a memory. // Application must setup `EXRHeader` with // `ParseEXRHeaderFromMemory` before calling this function. // Application can free EXRImage using `FreeEXRImage` // Returns negative value and may set error string in `err` when there's an // error extern int LoadEXRImageFromMemory(EXRImage *image, const EXRHeader *header, const unsigned char *memory, const size_t size, const char **err); // Loads multi-part OpenEXR image from a file. // Application must setup `ParseEXRMultipartHeaderFromFile` before calling this // function. // Application can free EXRImage using `FreeEXRImage` // Returns negative value and may set error string in `err` when there's an // error extern int LoadEXRMultipartImageFromFile(EXRImage *images, const EXRHeader **headers, unsigned int num_parts, const char *filename, const char **err); // Loads multi-part OpenEXR image from a memory. // Application must setup `EXRHeader*` array with // `ParseEXRMultipartHeaderFromMemory` before calling this function. // Application can free EXRImage using `FreeEXRImage` // Returns negative value and may set error string in `err` when there's an // error extern int LoadEXRMultipartImageFromMemory(EXRImage *images, const EXRHeader **headers, unsigned int num_parts, const unsigned char *memory, const size_t size, const char **err); // Saves multi-channel, single-frame OpenEXR image to a file. // Returns negative value and may set error string in `err` when there's an // error extern int SaveEXRImageToFile(const EXRImage *image, const EXRHeader *exr_header, const char *filename, const char **err); // Saves multi-channel, single-frame OpenEXR image to a memory. // Image is compressed using EXRImage.compression value. // Return the number of bytes if succes. // Returns negative value and may set error string in `err` when there's an // error extern size_t SaveEXRImageToMemory(const EXRImage *image, const EXRHeader *exr_header, unsigned char **memory, const char **err); // Loads single-frame OpenEXR deep image. // Application must free memory of variables in DeepImage(image, offset_table) // Returns negative value and may set error string in `err` when there's an // error extern int LoadDeepEXR(DeepImage *out_image, const char *filename, const char **err); // NOT YET IMPLEMENTED: // Saves single-frame OpenEXR deep image. // Returns negative value and may set error string in `err` when there's an // error // extern int SaveDeepEXR(const DeepImage *in_image, const char *filename, // const char **err); // NOT YET IMPLEMENTED: // Loads multi-part OpenEXR deep image. // Application must free memory of variables in DeepImage(image, offset_table) // extern int LoadMultiPartDeepEXR(DeepImage **out_image, int num_parts, const // char *filename, // const char **err); // For emscripten. // Loads single-frame OpenEXR image from memory. Assume EXR image contains // RGB(A) channels. // `out_rgba` must have enough memory(at least sizeof(float) x 4(RGBA) x width x // hight) // Returns negative value and may set error string in `err` when there's an // error extern int LoadEXRFromMemory(float *out_rgba, const unsigned char *memory, size_t size, const char **err); #ifdef __cplusplus } #endif #endif // TINYEXR_H_ #ifdef TINYEXR_IMPLEMENTATION #ifndef TINYEXR_IMPLEMENTATION_DEIFNED #define TINYEXR_IMPLEMENTATION_DEIFNED #include #include #include #include #include #include #include #include #if __cplusplus > 199711L // C++11 #include #endif // __cplusplus > 199711L #ifdef _OPENMP #include #endif #if TINYEXR_USE_MINIZ #else #include "zlib.h" #endif #if TINYEXR_USE_ZFP #include "zfp.h" #endif namespace tinyexr { #if __cplusplus > 199711L // C++11 typedef uint64_t tinyexr_uint64; typedef int64_t tinyexr_int64; #else // Although `long long` is not a standard type pre C++11, assume it is defined // as a compiler's extension. #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc++11-long-long" #endif typedef unsigned long long tinyexr_uint64; typedef long long tinyexr_int64; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif #if TINYEXR_USE_MINIZ namespace miniz { #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc++11-long-long" #pragma clang diagnostic ignored "-Wold-style-cast" #pragma clang diagnostic ignored "-Wpadded" #pragma clang diagnostic ignored "-Wsign-conversion" #pragma clang diagnostic ignored "-Wc++11-extensions" #pragma clang diagnostic ignored "-Wconversion" #pragma clang diagnostic ignored "-Wunused-function" #ifdef __APPLE__ #if __clang_major__ >= 8 && __clang_minor__ >= 1 #pragma clang diagnostic ignored "-Wcomma" #endif #else // __APPLE__ #if (__clang_major__ >= 4) || (__clang_major__ >= 3 && __clang_minor__ > 8) #pragma clang diagnostic ignored "-Wcomma" #endif #endif // __APPLE__ #endif /* miniz.c v1.15 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing See "unlicense" statement at the end of this file. Rich Geldreich , last updated Oct. 13, 2013 Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt Most API's defined in miniz.c are optional. For example, to disable the archive related functions just define MINIZ_NO_ARCHIVE_APIS, or to get rid of all stdio usage define MINIZ_NO_STDIO (see the list below for more macros). * Change History 10/13/13 v1.15 r4 - Interim bugfix release while I work on the next major release with Zip64 support (almost there!): - Critical fix for the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug (thanks kahmyong.moon@hp.com) which could cause locate files to not find files. This bug would only have occured in earlier versions if you explicitly used this flag, OR if you used mz_zip_extract_archive_file_to_heap() or mz_zip_add_mem_to_archive_file_in_place() (which used this flag). If you can't switch to v1.15 but want to fix this bug, just remove the uses of this flag from both helper funcs (and of course don't use the flag). - Bugfix in mz_zip_reader_extract_to_mem_no_alloc() from kymoon when pUser_read_buf is not NULL and compressed size is > uncompressed size - Fixing mz_zip_reader_extract_*() funcs so they don't try to extract compressed data from directory entries, to account for weird zipfiles which contain zero-size compressed data on dir entries. Hopefully this fix won't cause any issues on weird zip archives, because it assumes the low 16-bits of zip external attributes are DOS attributes (which I believe they always are in practice). - Fixing mz_zip_reader_is_file_a_directory() so it doesn't check the internal attributes, just the filename and external attributes - mz_zip_reader_init_file() - missing MZ_FCLOSE() call if the seek failed - Added cmake support for Linux builds which builds all the examples, tested with clang v3.3 and gcc v4.6. - Clang fix for tdefl_write_image_to_png_file_in_memory() from toffaletti - Merged MZ_FORCEINLINE fix from hdeanclark - Fix include before config #ifdef, thanks emil.brink - Added tdefl_write_image_to_png_file_in_memory_ex(): supports Y flipping (super useful for OpenGL apps), and explicit control over the compression level (so you can set it to 1 for real-time compression). - Merged in some compiler fixes from paulharris's github repro. - Retested this build under Windows (VS 2010, including static analysis), tcc 0.9.26, gcc v4.6 and clang v3.3. - Added example6.c, which dumps an image of the mandelbrot set to a PNG file. - Modified example2 to help test the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY flag more. - In r3: Bugfix to mz_zip_writer_add_file() found during merge: Fix possible src file fclose() leak if alignment bytes+local header file write faiiled - In r4: Minor bugfix to mz_zip_writer_add_from_zip_reader(): Was pushing the wrong central dir header offset, appears harmless in this release, but it became a problem in the zip64 branch 5/20/12 v1.14 - MinGW32/64 GCC 4.6.1 compiler fixes: added MZ_FORCEINLINE, #include (thanks fermtect). 5/19/12 v1.13 - From jason@cornsyrup.org and kelwert@mtu.edu - Fix mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bit. - Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files. - Eliminated a bunch of warnings when compiling with GCC 32-bit/64. - Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly "Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning). - Created 32-bit and 64-bit Codeblocks projects/workspace. Built and tested Linux executables. The codeblocks workspace is compatible with Linux+Win32/x64. - Added miniz_tester solution/project, which is a useful little app derived from LZHAM's tester app that I use as part of the regression test. - Ran miniz.c and tinfl.c through another series of regression testing on ~500,000 files and archives. - Modified example5.c so it purposely disables a bunch of high-level functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the MINIZ_NO_STDIO bug report.) - Fix ftell() usage in examples so they exit with an error on files which are too large (a limitation of the examples, not miniz itself). 4/12/12 v1.12 - More comments, added low-level example5.c, fixed a couple minor level_and_flags issues in the archive API's. level_and_flags can now be set to MZ_DEFAULT_COMPRESSION. Thanks to Bruce Dawson for the feedback/bug report. 5/28/11 v1.11 - Added statement from unlicense.org 5/27/11 v1.10 - Substantial compressor optimizations: - Level 1 is now ~4x faster than before. The L1 compressor's throughput now varies between 70-110MB/sec. on a - Core i7 (actual throughput varies depending on the type of data, and x64 vs. x86). - Improved baseline L2-L9 compression perf. Also, greatly improved compression perf. issues on some file types. - Refactored the compression code for better readability and maintainability. - Added level 10 compression level (L10 has slightly better ratio than level 9, but could have a potentially large drop in throughput on some files). 5/15/11 v1.09 - Initial stable release. * Low-level Deflate/Inflate implementation notes: Compression: Use the "tdefl" API's. The compressor supports raw, static, and dynamic blocks, lazy or greedy parsing, match length filtering, RLE-only, and Huffman-only streams. It performs and compresses approximately as well as zlib. Decompression: Use the "tinfl" API's. The entire decompressor is implemented as a single function coroutine: see tinfl_decompress(). It supports decompression into a 32KB (or larger power of 2) wrapping buffer, or into a memory block large enough to hold the entire file. The low-level tdefl/tinfl API's do not make any use of dynamic memory allocation. * zlib-style API notes: miniz.c implements a fairly large subset of zlib. There's enough functionality present for it to be a drop-in zlib replacement in many apps: The z_stream struct, optional memory allocation callbacks deflateInit/deflateInit2/deflate/deflateReset/deflateEnd/deflateBound inflateInit/inflateInit2/inflate/inflateEnd compress, compress2, compressBound, uncompress CRC-32, Adler-32 - Using modern, minimal code size, CPU cache friendly routines. Supports raw deflate streams or standard zlib streams with adler-32 checking. Limitations: The callback API's are not implemented yet. No support for gzip headers or zlib static dictionaries. I've tried to closely emulate zlib's various flavors of stream flushing and return status codes, but there are no guarantees that miniz.c pulls this off perfectly. * PNG writing: See the tdefl_write_image_to_png_file_in_memory() function, originally written by Alex Evans. Supports 1-4 bytes/pixel images. * ZIP archive API notes: The ZIP archive API's where designed with simplicity and efficiency in mind, with just enough abstraction to get the job done with minimal fuss. There are simple API's to retrieve file information, read files from existing archives, create new archives, append new files to existing archives, or clone archive data from one archive to another. It supports archives located in memory or the heap, on disk (using stdio.h), or you can specify custom file read/write callbacks. - Archive reading: Just call this function to read a single file from a disk archive: void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint zip_flags); For more complex cases, use the "mz_zip_reader" functions. Upon opening an archive, the entire central directory is located and read as-is into memory, and subsequent file access only occurs when reading individual files. - Archives file scanning: The simple way is to use this function to scan a loaded archive for a specific file: int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags); The locate operation can optionally check file comments too, which (as one example) can be used to identify multiple versions of the same file in an archive. This function uses a simple linear search through the central directory, so it's not very fast. Alternately, you can iterate through all the files in an archive (using mz_zip_reader_get_num_files()) and retrieve detailed info on each file by calling mz_zip_reader_file_stat(). - Archive creation: Use the "mz_zip_writer" functions. The ZIP writer immediately writes compressed file data to disk and builds an exact image of the central directory in memory. The central directory image is written all at once at the end of the archive file when the archive is finalized. The archive writer can optionally align each file's local header and file data to any power of 2 alignment, which can be useful when the archive will be read from optical media. Also, the writer supports placing arbitrary data blobs at the very beginning of ZIP archives. Archives written using either feature are still readable by any ZIP tool. - Archive appending: The simple way to add a single file to an archive is to call this function: mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); The archive will be created if it doesn't already exist, otherwise it'll be appended to. Note the appending is done in-place and is not an atomic operation, so if something goes wrong during the operation it's possible the archive could be left without a central directory (although the local file headers and file data will be fine, so the archive will be recoverable). For more complex archive modification scenarios: 1. The safest way is to use a mz_zip_reader to read the existing archive, cloning only those bits you want to preserve into a new archive using using the mz_zip_writer_add_from_zip_reader() function (which compiles the compressed file data as-is). When you're done, delete the old archive and rename the newly written archive, and you're done. This is safe but requires a bunch of temporary disk space or heap memory. 2. Or, you can convert an mz_zip_reader in-place to an mz_zip_writer using mz_zip_writer_init_from_reader(), append new files as needed, then finalize the archive which will write an updated central directory to the original archive. (This is basically what mz_zip_add_mem_to_archive_file_in_place() does.) There's a possibility that the archive's central directory could be lost with this method if anything goes wrong, though. - ZIP archive support limitations: No zip64 or spanning support. Extraction functions can only handle unencrypted, stored or deflated files. Requires streams capable of seeking. * This is a header file library, like stb_image.c. To get only a header file, either cut and paste the below header, or create miniz.h, #define MINIZ_HEADER_FILE_ONLY, and then include miniz.c from it. * Important: For best perf. be sure to customize the below macros for your target platform: #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 #define MINIZ_LITTLE_ENDIAN 1 #define MINIZ_HAS_64BIT_REGISTERS 1 * On platforms using glibc, Be sure to "#define _LARGEFILE64_SOURCE 1" before including miniz.c to ensure miniz uses the 64-bit variants: fopen64(), stat64(), etc. Otherwise you won't be able to process large files (i.e. 32-bit stat() fails for me on files > 0x7FFFFFFF bytes). */ #ifndef MINIZ_HEADER_INCLUDED #define MINIZ_HEADER_INCLUDED //#include // Defines to completely disable specific portions of miniz.c: // If all macros here are defined the only functionality remaining will be // CRC-32, adler-32, tinfl, and tdefl. // Define MINIZ_NO_STDIO to disable all usage and any functions which rely on // stdio for file I/O. //#define MINIZ_NO_STDIO // If MINIZ_NO_TIME is specified then the ZIP archive functions will not be able // to get the current time, or // get/set file times, and the C run-time funcs that get/set times won't be // called. // The current downside is the times written to your archives will be from 1979. #define MINIZ_NO_TIME // Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's. #define MINIZ_NO_ARCHIVE_APIS // Define MINIZ_NO_ARCHIVE_APIS to disable all writing related ZIP archive // API's. //#define MINIZ_NO_ARCHIVE_WRITING_APIS // Define MINIZ_NO_ZLIB_APIS to remove all ZLIB-style compression/decompression // API's. //#define MINIZ_NO_ZLIB_APIS // Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent // conflicts against stock zlib. //#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES // Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc. // Note if MINIZ_NO_MALLOC is defined then the user must always provide custom // user alloc/free/realloc // callbacks to the zlib and archive API's, and a few stand-alone helper API's // which don't provide custom user // functions (such as tdefl_compress_mem_to_heap() and // tinfl_decompress_mem_to_heap()) won't work. //#define MINIZ_NO_MALLOC #if defined(__TINYC__) && (defined(__linux) || defined(__linux__)) // TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc // on Linux #define MINIZ_NO_TIME #endif #if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS) //#include #endif #if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || \ defined(__i386) || defined(__i486__) || defined(__i486) || \ defined(i386) || defined(__ia64__) || defined(__x86_64__) // MINIZ_X86_OR_X64_CPU is only used to help set the below macros. #define MINIZ_X86_OR_X64_CPU 1 #endif #if defined(__sparcv9) // Big endian #else #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU // Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian. #define MINIZ_LITTLE_ENDIAN 1 #endif #endif #if MINIZ_X86_OR_X64_CPU // Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient // integer loads and stores from unaligned addresses. //#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES \ 0 // disable to suppress compiler warnings #endif #if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || \ defined(_LP64) || defined(__LP64__) || defined(__ia64__) || \ defined(__x86_64__) // Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are // reasonably fast (and don't involve compiler generated calls to helper // functions). #define MINIZ_HAS_64BIT_REGISTERS 1 #endif #ifdef __cplusplus extern "C" { #endif // ------------------- zlib-style API Definitions. // For more compatibility with zlib, miniz.c uses unsigned long for some // parameters/struct members. Beware: mz_ulong can be either 32 or 64-bits! typedef unsigned long mz_ulong; // mz_free() internally uses the MZ_FREE() macro (which by default calls free() // unless you've modified the MZ_MALLOC macro) to release a block allocated from // the heap. void mz_free(void *p); #define MZ_ADLER32_INIT (1) // mz_adler32() returns the initial adler-32 value to use when called with // ptr==NULL. mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len); #define MZ_CRC32_INIT (0) // mz_crc32() returns the initial CRC-32 value to use when called with // ptr==NULL. mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len); // Compression strategies. enum { MZ_DEFAULT_STRATEGY = 0, MZ_FILTERED = 1, MZ_HUFFMAN_ONLY = 2, MZ_RLE = 3, MZ_FIXED = 4 }; // Method #define MZ_DEFLATED 8 #ifndef MINIZ_NO_ZLIB_APIS // Heap allocation callbacks. // Note that mz_alloc_func parameter types purpsosely differ from zlib's: // items/size is size_t, not unsigned long. typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size); typedef void (*mz_free_func)(void *opaque, void *address); typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size); #define MZ_VERSION "9.1.15" #define MZ_VERNUM 0x91F0 #define MZ_VER_MAJOR 9 #define MZ_VER_MINOR 1 #define MZ_VER_REVISION 15 #define MZ_VER_SUBREVISION 0 // Flush values. For typical usage you only need MZ_NO_FLUSH and MZ_FINISH. The // other values are for advanced use (refer to the zlib docs). enum { MZ_NO_FLUSH = 0, MZ_PARTIAL_FLUSH = 1, MZ_SYNC_FLUSH = 2, MZ_FULL_FLUSH = 3, MZ_FINISH = 4, MZ_BLOCK = 5 }; // Return status codes. MZ_PARAM_ERROR is non-standard. enum { MZ_OK = 0, MZ_STREAM_END = 1, MZ_NEED_DICT = 2, MZ_ERRNO = -1, MZ_STREAM_ERROR = -2, MZ_DATA_ERROR = -3, MZ_MEM_ERROR = -4, MZ_BUF_ERROR = -5, MZ_VERSION_ERROR = -6, MZ_PARAM_ERROR = -10000 }; // Compression levels: 0-9 are the standard zlib-style levels, 10 is best // possible compression (not zlib compatible, and may be very slow), // MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL. enum { MZ_NO_COMPRESSION = 0, MZ_BEST_SPEED = 1, MZ_BEST_COMPRESSION = 9, MZ_UBER_COMPRESSION = 10, MZ_DEFAULT_LEVEL = 6, MZ_DEFAULT_COMPRESSION = -1 }; // Window bits #define MZ_DEFAULT_WINDOW_BITS 15 struct mz_internal_state; // Compression/decompression stream struct. typedef struct mz_stream_s { const unsigned char *next_in; // pointer to next byte to read unsigned int avail_in; // number of bytes available at next_in mz_ulong total_in; // total number of bytes consumed so far unsigned char *next_out; // pointer to next byte to write unsigned int avail_out; // number of bytes that can be written to next_out mz_ulong total_out; // total number of bytes produced so far char *msg; // error msg (unused) struct mz_internal_state *state; // internal state, allocated by zalloc/zfree mz_alloc_func zalloc; // optional heap allocation function (defaults to malloc) mz_free_func zfree; // optional heap free function (defaults to free) void *opaque; // heap alloc function user pointer int data_type; // data_type (unused) mz_ulong adler; // adler32 of the source or uncompressed data mz_ulong reserved; // not used } mz_stream; typedef mz_stream *mz_streamp; // Returns the version string of miniz.c. const char *mz_version(void); // mz_deflateInit() initializes a compressor with default options: // Parameters: // pStream must point to an initialized mz_stream struct. // level must be between [MZ_NO_COMPRESSION, MZ_BEST_COMPRESSION]. // level 1 enables a specially optimized compression function that's been // optimized purely for performance, not ratio. // (This special func. is currently only enabled when // MINIZ_USE_UNALIGNED_LOADS_AND_STORES and MINIZ_LITTLE_ENDIAN are defined.) // Return values: // MZ_OK on success. // MZ_STREAM_ERROR if the stream is bogus. // MZ_PARAM_ERROR if the input parameters are bogus. // MZ_MEM_ERROR on out of memory. int mz_deflateInit(mz_streamp pStream, int level); // mz_deflateInit2() is like mz_deflate(), except with more control: // Additional parameters: // method must be MZ_DEFLATED // window_bits must be MZ_DEFAULT_WINDOW_BITS (to wrap the deflate stream with // zlib header/adler-32 footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate/no // header or footer) // mem_level must be between [1, 9] (it's checked but ignored by miniz.c) int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy); // Quickly resets a compressor without having to reallocate anything. Same as // calling mz_deflateEnd() followed by mz_deflateInit()/mz_deflateInit2(). int mz_deflateReset(mz_streamp pStream); // mz_deflate() compresses the input to output, consuming as much of the input // and producing as much output as possible. // Parameters: // pStream is the stream to read from and write to. You must initialize/update // the next_in, avail_in, next_out, and avail_out members. // flush may be MZ_NO_FLUSH, MZ_PARTIAL_FLUSH/MZ_SYNC_FLUSH, MZ_FULL_FLUSH, or // MZ_FINISH. // Return values: // MZ_OK on success (when flushing, or if more input is needed but not // available, and/or there's more output to be written but the output buffer // is full). // MZ_STREAM_END if all input has been consumed and all output bytes have been // written. Don't call mz_deflate() on the stream anymore. // MZ_STREAM_ERROR if the stream is bogus. // MZ_PARAM_ERROR if one of the parameters is invalid. // MZ_BUF_ERROR if no forward progress is possible because the input and/or // output buffers are empty. (Fill up the input buffer or free up some output // space and try again.) int mz_deflate(mz_streamp pStream, int flush); // mz_deflateEnd() deinitializes a compressor: // Return values: // MZ_OK on success. // MZ_STREAM_ERROR if the stream is bogus. int mz_deflateEnd(mz_streamp pStream); // mz_deflateBound() returns a (very) conservative upper bound on the amount of // data that could be generated by deflate(), assuming flush is set to only // MZ_NO_FLUSH or MZ_FINISH. mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len); // Single-call compression functions mz_compress() and mz_compress2(): // Returns MZ_OK on success, or one of the error codes from mz_deflate() on // failure. int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level); // mz_compressBound() returns a (very) conservative upper bound on the amount of // data that could be generated by calling mz_compress(). mz_ulong mz_compressBound(mz_ulong source_len); // Initializes a decompressor. int mz_inflateInit(mz_streamp pStream); // mz_inflateInit2() is like mz_inflateInit() with an additional option that // controls the window size and whether or not the stream has been wrapped with // a zlib header/footer: // window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or // -MZ_DEFAULT_WINDOW_BITS (raw deflate). int mz_inflateInit2(mz_streamp pStream, int window_bits); // Decompresses the input stream to the output, consuming only as much of the // input as needed, and writing as much to the output as possible. // Parameters: // pStream is the stream to read from and write to. You must initialize/update // the next_in, avail_in, next_out, and avail_out members. // flush may be MZ_NO_FLUSH, MZ_SYNC_FLUSH, or MZ_FINISH. // On the first call, if flush is MZ_FINISH it's assumed the input and output // buffers are both sized large enough to decompress the entire stream in a // single call (this is slightly faster). // MZ_FINISH implies that there are no more source bytes available beside // what's already in the input buffer, and that the output buffer is large // enough to hold the rest of the decompressed data. // Return values: // MZ_OK on success. Either more input is needed but not available, and/or // there's more output to be written but the output buffer is full. // MZ_STREAM_END if all needed input has been consumed and all output bytes // have been written. For zlib streams, the adler-32 of the decompressed data // has also been verified. // MZ_STREAM_ERROR if the stream is bogus. // MZ_DATA_ERROR if the deflate stream is invalid. // MZ_PARAM_ERROR if one of the parameters is invalid. // MZ_BUF_ERROR if no forward progress is possible because the input buffer is // empty but the inflater needs more input to continue, or if the output // buffer is not large enough. Call mz_inflate() again // with more input data, or with more room in the output buffer (except when // using single call decompression, described above). int mz_inflate(mz_streamp pStream, int flush); // Deinitializes a decompressor. int mz_inflateEnd(mz_streamp pStream); // Single-call decompression. // Returns MZ_OK on success, or one of the error codes from mz_inflate() on // failure. int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); // Returns a string description of the specified error code, or NULL if the // error code is invalid. const char *mz_error(int err); // Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used // as a drop-in replacement for the subset of zlib that miniz.c supports. // Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you // use zlib in the same project. #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES typedef unsigned char Byte; typedef unsigned int uInt; typedef mz_ulong uLong; typedef Byte Bytef; typedef uInt uIntf; typedef char charf; typedef int intf; typedef void *voidpf; typedef uLong uLongf; typedef void *voidp; typedef void *const voidpc; #define Z_NULL 0 #define Z_NO_FLUSH MZ_NO_FLUSH #define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH #define Z_SYNC_FLUSH MZ_SYNC_FLUSH #define Z_FULL_FLUSH MZ_FULL_FLUSH #define Z_FINISH MZ_FINISH #define Z_BLOCK MZ_BLOCK #define Z_OK MZ_OK #define Z_STREAM_END MZ_STREAM_END #define Z_NEED_DICT MZ_NEED_DICT #define Z_ERRNO MZ_ERRNO #define Z_STREAM_ERROR MZ_STREAM_ERROR #define Z_DATA_ERROR MZ_DATA_ERROR #define Z_MEM_ERROR MZ_MEM_ERROR #define Z_BUF_ERROR MZ_BUF_ERROR #define Z_VERSION_ERROR MZ_VERSION_ERROR #define Z_PARAM_ERROR MZ_PARAM_ERROR #define Z_NO_COMPRESSION MZ_NO_COMPRESSION #define Z_BEST_SPEED MZ_BEST_SPEED #define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION #define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION #define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY #define Z_FILTERED MZ_FILTERED #define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY #define Z_RLE MZ_RLE #define Z_FIXED MZ_FIXED #define Z_DEFLATED MZ_DEFLATED #define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS #define alloc_func mz_alloc_func #define free_func mz_free_func #define internal_state mz_internal_state #define z_stream mz_stream #define deflateInit mz_deflateInit #define deflateInit2 mz_deflateInit2 #define deflateReset mz_deflateReset #define deflate mz_deflate #define deflateEnd mz_deflateEnd #define deflateBound mz_deflateBound #define compress mz_compress #define compress2 mz_compress2 #define compressBound mz_compressBound #define inflateInit mz_inflateInit #define inflateInit2 mz_inflateInit2 #define inflate mz_inflate #define inflateEnd mz_inflateEnd #define uncompress mz_uncompress #define crc32 mz_crc32 #define adler32 mz_adler32 #define MAX_WBITS 15 #define MAX_MEM_LEVEL 9 #define zError mz_error #define ZLIB_VERSION MZ_VERSION #define ZLIB_VERNUM MZ_VERNUM #define ZLIB_VER_MAJOR MZ_VER_MAJOR #define ZLIB_VER_MINOR MZ_VER_MINOR #define ZLIB_VER_REVISION MZ_VER_REVISION #define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION #define zlibVersion mz_version #define zlib_version mz_version() #endif // #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES #endif // MINIZ_NO_ZLIB_APIS // ------------------- Types and macros typedef unsigned char mz_uint8; typedef signed short mz_int16; typedef unsigned short mz_uint16; typedef unsigned int mz_uint32; typedef unsigned int mz_uint; typedef long long mz_int64; typedef unsigned long long mz_uint64; typedef int mz_bool; #define MZ_FALSE (0) #define MZ_TRUE (1) // An attempt to work around MSVC's spammy "warning C4127: conditional // expression is constant" message. #ifdef _MSC_VER #define MZ_MACRO_END while (0, 0) #else #define MZ_MACRO_END while (0) #endif // ------------------- ZIP archive reading/writing #ifndef MINIZ_NO_ARCHIVE_APIS enum { MZ_ZIP_MAX_IO_BUF_SIZE = 64 * 1024, MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE = 260, MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE = 256 }; typedef struct { mz_uint32 m_file_index; mz_uint32 m_central_dir_ofs; mz_uint16 m_version_made_by; mz_uint16 m_version_needed; mz_uint16 m_bit_flag; mz_uint16 m_method; #ifndef MINIZ_NO_TIME time_t m_time; #endif mz_uint32 m_crc32; mz_uint64 m_comp_size; mz_uint64 m_uncomp_size; mz_uint16 m_internal_attr; mz_uint32 m_external_attr; mz_uint64 m_local_header_ofs; mz_uint32 m_comment_size; char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE]; char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE]; } mz_zip_archive_file_stat; typedef size_t (*mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n); typedef size_t (*mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n); struct mz_zip_internal_state_tag; typedef struct mz_zip_internal_state_tag mz_zip_internal_state; typedef enum { MZ_ZIP_MODE_INVALID = 0, MZ_ZIP_MODE_READING = 1, MZ_ZIP_MODE_WRITING = 2, MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3 } mz_zip_mode; typedef struct mz_zip_archive_tag { mz_uint64 m_archive_size; mz_uint64 m_central_directory_file_ofs; mz_uint m_total_files; mz_zip_mode m_zip_mode; mz_uint m_file_offset_alignment; mz_alloc_func m_pAlloc; mz_free_func m_pFree; mz_realloc_func m_pRealloc; void *m_pAlloc_opaque; mz_file_read_func m_pRead; mz_file_write_func m_pWrite; void *m_pIO_opaque; mz_zip_internal_state *m_pState; } mz_zip_archive; typedef enum { MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100, MZ_ZIP_FLAG_IGNORE_PATH = 0x0200, MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400, MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY = 0x0800 } mz_zip_flags; // ZIP archive reading // Inits a ZIP archive reader. // These functions read and validate the archive's central directory. mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags); mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags); #ifndef MINIZ_NO_STDIO mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags); #endif // Returns the total number of files in the archive. mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip); // Returns detailed information about an archive file entry. mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat); // Determines if an archive file entry is a directory entry. mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index); mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index); // Retrieves the filename of an archive file entry. // Returns the number of bytes written to pFilename, or if filename_buf_size is // 0 this function returns the number of bytes needed to fully store the // filename. mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size); // Attempts to locates a file in the archive's central directory. // Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH // Returns -1 if the file cannot be found. int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags); // Extracts a archive file to a memory buffer using no memory allocation. mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size); mz_bool mz_zip_reader_extract_file_to_mem_no_alloc( mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size); // Extracts a archive file to a memory buffer. mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags); mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags); // Extracts a archive file to a dynamically allocated heap buffer. void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags); void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags); // Extracts a archive file using a callback function to output the file's data. mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags); mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags); #ifndef MINIZ_NO_STDIO // Extracts a archive file to a disk file and sets its last accessed and // modified times. // This function only extracts files, not archive directory records. mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags); mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags); #endif // Ends archive reading, freeing all allocations, and closing the input archive // file if mz_zip_reader_init_file() was used. mz_bool mz_zip_reader_end(mz_zip_archive *pZip); // ZIP archive writing #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS // Inits a ZIP archive writer. mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size); mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size); #ifndef MINIZ_NO_STDIO mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning); #endif // Converts a ZIP archive reader object into a writer object, to allow efficient // in-place file appends to occur on an existing archive. // For archives opened using mz_zip_reader_init_file, pFilename must be the // archive's filename so it can be reopened for writing. If the file can't be // reopened, mz_zip_reader_end() will be called. // For archives opened using mz_zip_reader_init_mem, the memory block must be // growable using the realloc callback (which defaults to realloc unless you've // overridden it). // Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's // user provided m_pWrite function cannot be NULL. // Note: In-place archive modification is not recommended unless you know what // you're doing, because if execution stops or something goes wrong before // the archive is finalized the file's central directory will be hosed. mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename); // Adds the contents of a memory buffer to an archive. These functions record // the current local time into the archive. // To add a directory entry, call this method with an archive name ending in a // forwardslash with empty buffer. // level_and_flags - compression level (0-10, see MZ_BEST_SPEED, // MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or // just set to MZ_DEFAULT_COMPRESSION. mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags); mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32); #ifndef MINIZ_NO_STDIO // Adds the contents of a disk file to an archive. This function also records // the disk file's modified time into the archive. // level_and_flags - compression level (0-10, see MZ_BEST_SPEED, // MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or // just set to MZ_DEFAULT_COMPRESSION. mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); #endif // Adds a file to an archive by fully cloning the data from another archive. // This function fully clones the source file's compressed data (no // recompression), along with its full filename, extra data, and comment fields. mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint file_index); // Finalizes the archive by writing the central directory records followed by // the end of central directory record. // After an archive is finalized, the only valid call on the mz_zip_archive // struct is mz_zip_writer_end(). // An archive must be manually finalized by calling this function for it to be // valid. mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip); mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, size_t *pSize); // Ends archive writing, freeing all allocations, and closing the output file if // mz_zip_writer_init_file() was used. // Note for the archive to be valid, it must have been finalized before ending. mz_bool mz_zip_writer_end(mz_zip_archive *pZip); // Misc. high-level helper functions: // mz_zip_add_mem_to_archive_file_in_place() efficiently (but not atomically) // appends a memory blob to a ZIP archive. // level_and_flags - compression level (0-10, see MZ_BEST_SPEED, // MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or // just set to MZ_DEFAULT_COMPRESSION. mz_bool mz_zip_add_mem_to_archive_file_in_place( const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); // Reads a single file from an archive into a heap block. // Returns NULL on failure. void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint zip_flags); #endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS #endif // #ifndef MINIZ_NO_ARCHIVE_APIS // ------------------- Low-level Decompression API Definitions // Decompression flags used by tinfl_decompress(). // TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and // ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the // input is a raw deflate stream. // TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available // beyond the end of the supplied input buffer. If clear, the input buffer // contains all remaining input. // TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large // enough to hold the entire decompressed stream. If clear, the output buffer is // at least the size of the dictionary (typically 32KB). // TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the // decompressed bytes. enum { TINFL_FLAG_PARSE_ZLIB_HEADER = 1, TINFL_FLAG_HAS_MORE_INPUT = 2, TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4, TINFL_FLAG_COMPUTE_ADLER32 = 8 }; // High level decompression functions: // tinfl_decompress_mem_to_heap() decompresses a block in memory to a heap block // allocated via malloc(). // On entry: // pSrc_buf, src_buf_len: Pointer and size of the Deflate or zlib source data // to decompress. // On return: // Function returns a pointer to the decompressed data, or NULL on failure. // *pOut_len will be set to the decompressed data's size, which could be larger // than src_buf_len on uncompressible data. // The caller must call mz_free() on the returned block when it's no longer // needed. void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags); // tinfl_decompress_mem_to_mem() decompresses a block in memory to another block // in memory. // Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes // written on success. #define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1)) size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags); // tinfl_decompress_mem_to_callback() decompresses a block in memory to an // internal 32KB buffer, and a user provided callback function will be called to // flush the buffer. // Returns 1 on success or 0 on failure. typedef int (*tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser); int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); struct tinfl_decompressor_tag; typedef struct tinfl_decompressor_tag tinfl_decompressor; // Max size of LZ dictionary. #define TINFL_LZ_DICT_SIZE 32768 // Return status. typedef enum { TINFL_STATUS_BAD_PARAM = -3, TINFL_STATUS_ADLER32_MISMATCH = -2, TINFL_STATUS_FAILED = -1, TINFL_STATUS_DONE = 0, TINFL_STATUS_NEEDS_MORE_INPUT = 1, TINFL_STATUS_HAS_MORE_OUTPUT = 2 } tinfl_status; // Initializes the decompressor to its initial state. #define tinfl_init(r) \ do { \ (r)->m_state = 0; \ } \ MZ_MACRO_END #define tinfl_get_adler32(r) (r)->m_check_adler32 // Main low-level decompressor coroutine function. This is the only function // actually needed for decompression. All the other functions are just // high-level helpers for improved usability. // This is a universal API, i.e. it can be used as a building block to build any // desired higher level decompression API. In the limit case, it can be called // once per every byte input or output. tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags); // Internal/private bits follow. enum { TINFL_MAX_HUFF_TABLES = 3, TINFL_MAX_HUFF_SYMBOLS_0 = 288, TINFL_MAX_HUFF_SYMBOLS_1 = 32, TINFL_MAX_HUFF_SYMBOLS_2 = 19, TINFL_FAST_LOOKUP_BITS = 10, TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS }; typedef struct { mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0]; mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE], m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2]; } tinfl_huff_table; #if MINIZ_HAS_64BIT_REGISTERS #define TINFL_USE_64BIT_BITBUF 1 #endif #if TINFL_USE_64BIT_BITBUF typedef mz_uint64 tinfl_bit_buf_t; #define TINFL_BITBUF_SIZE (64) #else typedef mz_uint32 tinfl_bit_buf_t; #define TINFL_BITBUF_SIZE (32) #endif struct tinfl_decompressor_tag { mz_uint32 m_state, m_num_bits, m_zhdr0, m_zhdr1, m_z_adler32, m_final, m_type, m_check_adler32, m_dist, m_counter, m_num_extra, m_table_sizes[TINFL_MAX_HUFF_TABLES]; tinfl_bit_buf_t m_bit_buf; size_t m_dist_from_out_buf_start; tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES]; mz_uint8 m_raw_header[4], m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137]; }; // ------------------- Low-level Compression API Definitions // Set TDEFL_LESS_MEMORY to 1 to use less memory (compression will be slightly // slower, and raw/dynamic blocks will be output more frequently). #define TDEFL_LESS_MEMORY 0 // tdefl_init() compression flags logically OR'd together (low 12 bits contain // the max. number of probes per dictionary search): // TDEFL_DEFAULT_MAX_PROBES: The compressor defaults to 128 dictionary probes // per dictionary search. 0=Huffman only, 1=Huffman+LZ (fastest/crap // compression), 4095=Huffman+LZ (slowest/best compression). enum { TDEFL_HUFFMAN_ONLY = 0, TDEFL_DEFAULT_MAX_PROBES = 128, TDEFL_MAX_PROBES_MASK = 0xFFF }; // TDEFL_WRITE_ZLIB_HEADER: If set, the compressor outputs a zlib header before // the deflate data, and the Adler-32 of the source data at the end. Otherwise, // you'll get raw deflate data. // TDEFL_COMPUTE_ADLER32: Always compute the adler-32 of the input data (even // when not writing zlib headers). // TDEFL_GREEDY_PARSING_FLAG: Set to use faster greedy parsing, instead of more // efficient lazy parsing. // TDEFL_NONDETERMINISTIC_PARSING_FLAG: Enable to decrease the compressor's // initialization time to the minimum, but the output may vary from run to run // given the same input (depending on the contents of memory). // TDEFL_RLE_MATCHES: Only look for RLE matches (matches with a distance of 1) // TDEFL_FILTER_MATCHES: Discards matches <= 5 chars if enabled. // TDEFL_FORCE_ALL_STATIC_BLOCKS: Disable usage of optimized Huffman tables. // TDEFL_FORCE_ALL_RAW_BLOCKS: Only use raw (uncompressed) deflate blocks. // The low 12 bits are reserved to control the max # of hash probes per // dictionary lookup (see TDEFL_MAX_PROBES_MASK). enum { TDEFL_WRITE_ZLIB_HEADER = 0x01000, TDEFL_COMPUTE_ADLER32 = 0x02000, TDEFL_GREEDY_PARSING_FLAG = 0x04000, TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000, TDEFL_RLE_MATCHES = 0x10000, TDEFL_FILTER_MATCHES = 0x20000, TDEFL_FORCE_ALL_STATIC_BLOCKS = 0x40000, TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000 }; // High level compression functions: // tdefl_compress_mem_to_heap() compresses a block in memory to a heap block // allocated via malloc(). // On entry: // pSrc_buf, src_buf_len: Pointer and size of source block to compress. // flags: The max match finder probes (default is 128) logically OR'd against // the above flags. Higher probes are slower but improve compression. // On return: // Function returns a pointer to the compressed data, or NULL on failure. // *pOut_len will be set to the compressed data's size, which could be larger // than src_buf_len on uncompressible data. // The caller must free() the returned block when it's no longer needed. void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags); // tdefl_compress_mem_to_mem() compresses a block in memory to another block in // memory. // Returns 0 on failure. size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags); // Compresses an image to a compressed PNG file in memory. // On entry: // pImage, w, h, and num_chans describe the image to compress. num_chans may be // 1, 2, 3, or 4. // The image pitch in bytes per scanline will be w*num_chans. The leftmost // pixel on the top scanline is stored first in memory. // level may range from [0,10], use MZ_NO_COMPRESSION, MZ_BEST_SPEED, // MZ_BEST_COMPRESSION, etc. or a decent default is MZ_DEFAULT_LEVEL // If flip is true, the image will be flipped on the Y axis (useful for OpenGL // apps). // On return: // Function returns a pointer to the compressed data, or NULL on failure. // *pLen_out will be set to the size of the PNG image file. // The caller must mz_free() the returned heap block (which will typically be // larger than *pLen_out) when it's no longer needed. void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip); void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out); // Output stream interface. The compressor uses this interface to write // compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. typedef mz_bool (*tdefl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser); // tdefl_compress_mem_to_output() compresses a block to an output stream. The // above helpers use this function internally. mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); enum { TDEFL_MAX_HUFF_TABLES = 3, TDEFL_MAX_HUFF_SYMBOLS_0 = 288, TDEFL_MAX_HUFF_SYMBOLS_1 = 32, TDEFL_MAX_HUFF_SYMBOLS_2 = 19, TDEFL_LZ_DICT_SIZE = 32768, TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1, TDEFL_MIN_MATCH_LEN = 3, TDEFL_MAX_MATCH_LEN = 258 }; // TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed // output block (using static/fixed Huffman codes). #if TDEFL_LESS_MEMORY enum { TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024, TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10, TDEFL_MAX_HUFF_SYMBOLS = 288, TDEFL_LZ_HASH_BITS = 12, TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS }; #else enum { TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024, TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10, TDEFL_MAX_HUFF_SYMBOLS = 288, TDEFL_LZ_HASH_BITS = 15, TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS }; #endif // The low-level tdefl functions below may be used directly if the above helper // functions aren't flexible enough. The low-level functions don't make any heap // allocations, unlike the above helper functions. typedef enum { TDEFL_STATUS_BAD_PARAM = -2, TDEFL_STATUS_PUT_BUF_FAILED = -1, TDEFL_STATUS_OKAY = 0, TDEFL_STATUS_DONE = 1 } tdefl_status; // Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums typedef enum { TDEFL_NO_FLUSH = 0, TDEFL_SYNC_FLUSH = 2, TDEFL_FULL_FLUSH = 3, TDEFL_FINISH = 4 } tdefl_flush; // tdefl's compression state structure. typedef struct { tdefl_put_buf_func_ptr m_pPut_buf_func; void *m_pPut_buf_user; mz_uint m_flags, m_max_probes[2]; int m_greedy_parsing; mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size; mz_uint8 *m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end; mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, m_bit_buffer; mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, m_wants_to_finish; tdefl_status m_prev_return_status; const void *m_pIn_buf; void *m_pOut_buf; size_t *m_pIn_buf_size, *m_pOut_buf_size; tdefl_flush m_flush; const mz_uint8 *m_pSrc; size_t m_src_buf_left, m_out_buf_ofs; mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1]; mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE]; mz_uint16 m_next[TDEFL_LZ_DICT_SIZE]; mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE]; mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE]; } tdefl_compressor; // Initializes the compressor. // There is no corresponding deinit() function because the tdefl API's do not // dynamically allocate memory. // pBut_buf_func: If NULL, output data will be supplied to the specified // callback. In this case, the user should call the tdefl_compress_buffer() API // for compression. // If pBut_buf_func is NULL the user should always call the tdefl_compress() // API. // flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, // etc.) tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); // Compresses a block of data, consuming as much of the specified input buffer // as possible, and writing as much compressed data to the specified output // buffer as possible. tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush); // tdefl_compress_buffer() is only usable when the tdefl_init() is called with a // non-NULL tdefl_put_buf_func_ptr. // tdefl_compress_buffer() always consumes the entire input buffer. tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush); tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d); mz_uint32 tdefl_get_adler32(tdefl_compressor *d); // Can't use tdefl_create_comp_flags_from_zip_params if MINIZ_NO_ZLIB_APIS isn't // defined, because it uses some of its macros. #ifndef MINIZ_NO_ZLIB_APIS // Create tdefl_compress() flags given zlib-style compression parameters. // level may range from [0,10] (where 10 is absolute max compression, but may be // much slower on some files) // window_bits may be -15 (raw deflate) or 15 (zlib) // strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, // MZ_RLE, or MZ_FIXED mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy); #endif // #ifndef MINIZ_NO_ZLIB_APIS #ifdef __cplusplus } #endif #endif // MINIZ_HEADER_INCLUDED // ------------------- End of Header: Implementation follows. (If you only want // the header, define MINIZ_HEADER_FILE_ONLY.) #ifndef MINIZ_HEADER_FILE_ONLY typedef unsigned char mz_validate_uint16[sizeof(mz_uint16) == 2 ? 1 : -1]; typedef unsigned char mz_validate_uint32[sizeof(mz_uint32) == 4 ? 1 : -1]; typedef unsigned char mz_validate_uint64[sizeof(mz_uint64) == 8 ? 1 : -1]; //#include //#include #define MZ_ASSERT(x) assert(x) #ifdef MINIZ_NO_MALLOC #define MZ_MALLOC(x) NULL #define MZ_FREE(x) (void)x, ((void)0) #define MZ_REALLOC(p, x) NULL #else #define MZ_MALLOC(x) malloc(x) #define MZ_FREE(x) free(x) #define MZ_REALLOC(p, x) realloc(p, x) #endif #define MZ_MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MZ_MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj)) #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN #define MZ_READ_LE16(p) *((const mz_uint16 *)(p)) #define MZ_READ_LE32(p) *((const mz_uint32 *)(p)) #else #define MZ_READ_LE16(p) \ ((mz_uint32)(((const mz_uint8 *)(p))[0]) | \ ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U)) #define MZ_READ_LE32(p) \ ((mz_uint32)(((const mz_uint8 *)(p))[0]) | \ ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | \ ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | \ ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U)) #endif #ifdef _MSC_VER #define MZ_FORCEINLINE __forceinline #elif defined(__GNUC__) #define MZ_FORCEINLINE inline __attribute__((__always_inline__)) #else #define MZ_FORCEINLINE inline #endif #ifdef __cplusplus extern "C" { #endif // ------------------- zlib-style API's mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len) { mz_uint32 i, s1 = (mz_uint32)(adler & 0xffff), s2 = (mz_uint32)(adler >> 16); size_t block_len = buf_len % 5552; if (!ptr) return MZ_ADLER32_INIT; while (buf_len) { for (i = 0; i + 7 < block_len; i += 8, ptr += 8) { s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1; s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1; } for (; i < block_len; ++i) s1 += *ptr++, s2 += s1; s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552; } return (s2 << 16) + s1; } // Karl Malbrain's compact CRC-32. See "A compact CCITT crc16 and crc32 C // implementation that balances processor cache usage against speed": // http://www.geocities.com/malbrain/ mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len) { static const mz_uint32 s_crc32[16] = { 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c}; mz_uint32 crcu32 = (mz_uint32)crc; if (!ptr) return MZ_CRC32_INIT; crcu32 = ~crcu32; while (buf_len--) { mz_uint8 b = *ptr++; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b & 0xF)]; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b >> 4)]; } return ~crcu32; } void mz_free(void *p) { MZ_FREE(p); } #ifndef MINIZ_NO_ZLIB_APIS static void *def_alloc_func(void *opaque, size_t items, size_t size) { (void)opaque, (void)items, (void)size; return MZ_MALLOC(items * size); } static void def_free_func(void *opaque, void *address) { (void)opaque, (void)address; MZ_FREE(address); } //static void *def_realloc_func(void *opaque, void *address, size_t items, // size_t size) { // (void)opaque, (void)address, (void)items, (void)size; // return MZ_REALLOC(address, items * size); //} const char *mz_version(void) { return MZ_VERSION; } int mz_deflateInit(mz_streamp pStream, int level) { return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9, MZ_DEFAULT_STRATEGY); } int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy) { tdefl_compressor *pComp; mz_uint comp_flags = TDEFL_COMPUTE_ADLER32 | tdefl_create_comp_flags_from_zip_params(level, window_bits, strategy); if (!pStream) return MZ_STREAM_ERROR; if ((method != MZ_DEFLATED) || ((mem_level < 1) || (mem_level > 9)) || ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS))) return MZ_PARAM_ERROR; pStream->data_type = 0; pStream->adler = MZ_ADLER32_INIT; pStream->msg = NULL; pStream->reserved = 0; pStream->total_in = 0; pStream->total_out = 0; if (!pStream->zalloc) pStream->zalloc = def_alloc_func; if (!pStream->zfree) pStream->zfree = def_free_func; pComp = (tdefl_compressor *)pStream->zalloc(pStream->opaque, 1, sizeof(tdefl_compressor)); if (!pComp) return MZ_MEM_ERROR; pStream->state = (struct mz_internal_state *)pComp; if (tdefl_init(pComp, NULL, NULL, comp_flags) != TDEFL_STATUS_OKAY) { mz_deflateEnd(pStream); return MZ_PARAM_ERROR; } return MZ_OK; } int mz_deflateReset(mz_streamp pStream) { if ((!pStream) || (!pStream->state) || (!pStream->zalloc) || (!pStream->zfree)) return MZ_STREAM_ERROR; pStream->total_in = pStream->total_out = 0; tdefl_init((tdefl_compressor *)pStream->state, NULL, NULL, ((tdefl_compressor *)pStream->state)->m_flags); return MZ_OK; } int mz_deflate(mz_streamp pStream, int flush) { size_t in_bytes, out_bytes; mz_ulong orig_total_in, orig_total_out; int mz_status = MZ_OK; if ((!pStream) || (!pStream->state) || (flush < 0) || (flush > MZ_FINISH) || (!pStream->next_out)) return MZ_STREAM_ERROR; if (!pStream->avail_out) return MZ_BUF_ERROR; if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH; if (((tdefl_compressor *)pStream->state)->m_prev_return_status == TDEFL_STATUS_DONE) return (flush == MZ_FINISH) ? MZ_STREAM_END : MZ_BUF_ERROR; orig_total_in = pStream->total_in; orig_total_out = pStream->total_out; for (;;) { tdefl_status defl_status; in_bytes = pStream->avail_in; out_bytes = pStream->avail_out; defl_status = tdefl_compress((tdefl_compressor *)pStream->state, pStream->next_in, &in_bytes, pStream->next_out, &out_bytes, (tdefl_flush)flush); pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; pStream->total_in += (mz_uint)in_bytes; pStream->adler = tdefl_get_adler32((tdefl_compressor *)pStream->state); pStream->next_out += (mz_uint)out_bytes; pStream->avail_out -= (mz_uint)out_bytes; pStream->total_out += (mz_uint)out_bytes; if (defl_status < 0) { mz_status = MZ_STREAM_ERROR; break; } else if (defl_status == TDEFL_STATUS_DONE) { mz_status = MZ_STREAM_END; break; } else if (!pStream->avail_out) break; else if ((!pStream->avail_in) && (flush != MZ_FINISH)) { if ((flush) || (pStream->total_in != orig_total_in) || (pStream->total_out != orig_total_out)) break; return MZ_BUF_ERROR; // Can't make forward progress without some input. } } return mz_status; } int mz_deflateEnd(mz_streamp pStream) { if (!pStream) return MZ_STREAM_ERROR; if (pStream->state) { pStream->zfree(pStream->opaque, pStream->state); pStream->state = NULL; } return MZ_OK; } mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len) { (void)pStream; // This is really over conservative. (And lame, but it's actually pretty // tricky to compute a true upper bound given the way tdefl's blocking works.) return MZ_MAX(128 + (source_len * 110) / 100, 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5); } int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level) { int status; mz_stream stream; memset(&stream, 0, sizeof(stream)); // In case mz_ulong is 64-bits (argh I hate longs). if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; stream.next_in = pSource; stream.avail_in = (mz_uint32)source_len; stream.next_out = pDest; stream.avail_out = (mz_uint32)*pDest_len; status = mz_deflateInit(&stream, level); if (status != MZ_OK) return status; status = mz_deflate(&stream, MZ_FINISH); if (status != MZ_STREAM_END) { mz_deflateEnd(&stream); return (status == MZ_OK) ? MZ_BUF_ERROR : status; } *pDest_len = stream.total_out; return mz_deflateEnd(&stream); } int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) { return mz_compress2(pDest, pDest_len, pSource, source_len, MZ_DEFAULT_COMPRESSION); } mz_ulong mz_compressBound(mz_ulong source_len) { return mz_deflateBound(NULL, source_len); } typedef struct { tinfl_decompressor m_decomp; mz_uint m_dict_ofs, m_dict_avail, m_first_call, m_has_flushed; int m_window_bits; mz_uint8 m_dict[TINFL_LZ_DICT_SIZE]; tinfl_status m_last_status; } inflate_state; int mz_inflateInit2(mz_streamp pStream, int window_bits) { inflate_state *pDecomp; if (!pStream) return MZ_STREAM_ERROR; if ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS)) return MZ_PARAM_ERROR; pStream->data_type = 0; pStream->adler = 0; pStream->msg = NULL; pStream->total_in = 0; pStream->total_out = 0; pStream->reserved = 0; if (!pStream->zalloc) pStream->zalloc = def_alloc_func; if (!pStream->zfree) pStream->zfree = def_free_func; pDecomp = (inflate_state *)pStream->zalloc(pStream->opaque, 1, sizeof(inflate_state)); if (!pDecomp) return MZ_MEM_ERROR; pStream->state = (struct mz_internal_state *)pDecomp; tinfl_init(&pDecomp->m_decomp); pDecomp->m_dict_ofs = 0; pDecomp->m_dict_avail = 0; pDecomp->m_last_status = TINFL_STATUS_NEEDS_MORE_INPUT; pDecomp->m_first_call = 1; pDecomp->m_has_flushed = 0; pDecomp->m_window_bits = window_bits; return MZ_OK; } int mz_inflateInit(mz_streamp pStream) { return mz_inflateInit2(pStream, MZ_DEFAULT_WINDOW_BITS); } int mz_inflate(mz_streamp pStream, int flush) { inflate_state *pState; mz_uint n, first_call, decomp_flags = TINFL_FLAG_COMPUTE_ADLER32; size_t in_bytes, out_bytes, orig_avail_in; tinfl_status status; if ((!pStream) || (!pStream->state)) return MZ_STREAM_ERROR; if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH; if ((flush) && (flush != MZ_SYNC_FLUSH) && (flush != MZ_FINISH)) return MZ_STREAM_ERROR; pState = (inflate_state *)pStream->state; if (pState->m_window_bits > 0) decomp_flags |= TINFL_FLAG_PARSE_ZLIB_HEADER; orig_avail_in = pStream->avail_in; first_call = pState->m_first_call; pState->m_first_call = 0; if (pState->m_last_status < 0) return MZ_DATA_ERROR; if (pState->m_has_flushed && (flush != MZ_FINISH)) return MZ_STREAM_ERROR; pState->m_has_flushed |= (flush == MZ_FINISH); if ((flush == MZ_FINISH) && (first_call)) { // MZ_FINISH on the first call implies that the input and output buffers are // large enough to hold the entire compressed/decompressed file. decomp_flags |= TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF; in_bytes = pStream->avail_in; out_bytes = pStream->avail_out; status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pStream->next_out, pStream->next_out, &out_bytes, decomp_flags); pState->m_last_status = status; pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; pStream->total_in += (mz_uint)in_bytes; pStream->adler = tinfl_get_adler32(&pState->m_decomp); pStream->next_out += (mz_uint)out_bytes; pStream->avail_out -= (mz_uint)out_bytes; pStream->total_out += (mz_uint)out_bytes; if (status < 0) return MZ_DATA_ERROR; else if (status != TINFL_STATUS_DONE) { pState->m_last_status = TINFL_STATUS_FAILED; return MZ_BUF_ERROR; } return MZ_STREAM_END; } // flush != MZ_FINISH then we must assume there's more input. if (flush != MZ_FINISH) decomp_flags |= TINFL_FLAG_HAS_MORE_INPUT; if (pState->m_dict_avail) { n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); pStream->next_out += n; pStream->avail_out -= n; pStream->total_out += n; pState->m_dict_avail -= n; pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1); return ((pState->m_last_status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK; } for (;;) { in_bytes = pStream->avail_in; out_bytes = TINFL_LZ_DICT_SIZE - pState->m_dict_ofs; status = tinfl_decompress( &pState->m_decomp, pStream->next_in, &in_bytes, pState->m_dict, pState->m_dict + pState->m_dict_ofs, &out_bytes, decomp_flags); pState->m_last_status = status; pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; pStream->total_in += (mz_uint)in_bytes; pStream->adler = tinfl_get_adler32(&pState->m_decomp); pState->m_dict_avail = (mz_uint)out_bytes; n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); pStream->next_out += n; pStream->avail_out -= n; pStream->total_out += n; pState->m_dict_avail -= n; pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1); if (status < 0) return MZ_DATA_ERROR; // Stream is corrupted (there could be some // uncompressed data left in the output dictionary - // oh well). else if ((status == TINFL_STATUS_NEEDS_MORE_INPUT) && (!orig_avail_in)) return MZ_BUF_ERROR; // Signal caller that we can't make forward progress // without supplying more input or by setting flush // to MZ_FINISH. else if (flush == MZ_FINISH) { // The output buffer MUST be large to hold the remaining uncompressed data // when flush==MZ_FINISH. if (status == TINFL_STATUS_DONE) return pState->m_dict_avail ? MZ_BUF_ERROR : MZ_STREAM_END; // status here must be TINFL_STATUS_HAS_MORE_OUTPUT, which means there's // at least 1 more byte on the way. If there's no more room left in the // output buffer then something is wrong. else if (!pStream->avail_out) return MZ_BUF_ERROR; } else if ((status == TINFL_STATUS_DONE) || (!pStream->avail_in) || (!pStream->avail_out) || (pState->m_dict_avail)) break; } return ((status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK; } int mz_inflateEnd(mz_streamp pStream) { if (!pStream) return MZ_STREAM_ERROR; if (pStream->state) { pStream->zfree(pStream->opaque, pStream->state); pStream->state = NULL; } return MZ_OK; } int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) { mz_stream stream; int status; memset(&stream, 0, sizeof(stream)); // In case mz_ulong is 64-bits (argh I hate longs). if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; stream.next_in = pSource; stream.avail_in = (mz_uint32)source_len; stream.next_out = pDest; stream.avail_out = (mz_uint32)*pDest_len; status = mz_inflateInit(&stream); if (status != MZ_OK) return status; status = mz_inflate(&stream, MZ_FINISH); if (status != MZ_STREAM_END) { mz_inflateEnd(&stream); return ((status == MZ_BUF_ERROR) && (!stream.avail_in)) ? MZ_DATA_ERROR : status; } *pDest_len = stream.total_out; return mz_inflateEnd(&stream); } const char *mz_error(int err) { static struct { int m_err; const char *m_pDesc; } s_error_descs[] = {{MZ_OK, ""}, {MZ_STREAM_END, "stream end"}, {MZ_NEED_DICT, "need dictionary"}, {MZ_ERRNO, "file error"}, {MZ_STREAM_ERROR, "stream error"}, {MZ_DATA_ERROR, "data error"}, {MZ_MEM_ERROR, "out of memory"}, {MZ_BUF_ERROR, "buf error"}, {MZ_VERSION_ERROR, "version error"}, {MZ_PARAM_ERROR, "parameter error"}}; mz_uint i; for (i = 0; i < sizeof(s_error_descs) / sizeof(s_error_descs[0]); ++i) if (s_error_descs[i].m_err == err) return s_error_descs[i].m_pDesc; return NULL; } #endif // MINIZ_NO_ZLIB_APIS // ------------------- Low-level Decompression (completely independent from all // compression API's) #define TINFL_MEMCPY(d, s, l) memcpy(d, s, l) #define TINFL_MEMSET(p, c, l) memset(p, c, l) #define TINFL_CR_BEGIN \ switch (r->m_state) { \ case 0: #define TINFL_CR_RETURN(state_index, result) \ do { \ status = result; \ r->m_state = state_index; \ goto common_exit; \ case state_index:; \ } \ MZ_MACRO_END #define TINFL_CR_RETURN_FOREVER(state_index, result) \ do { \ for (;;) { \ TINFL_CR_RETURN(state_index, result); \ } \ } \ MZ_MACRO_END #define TINFL_CR_FINISH } // TODO: If the caller has indicated that there's no more input, and we attempt // to read beyond the input buf, then something is wrong with the input because // the inflator never // reads ahead more than it needs to. Currently TINFL_GET_BYTE() pads the end of // the stream with 0's in this scenario. #define TINFL_GET_BYTE(state_index, c) \ do { \ if (pIn_buf_cur >= pIn_buf_end) { \ for (;;) { \ if (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) { \ TINFL_CR_RETURN(state_index, TINFL_STATUS_NEEDS_MORE_INPUT); \ if (pIn_buf_cur < pIn_buf_end) { \ c = *pIn_buf_cur++; \ break; \ } \ } else { \ c = 0; \ break; \ } \ } \ } else \ c = *pIn_buf_cur++; \ } \ MZ_MACRO_END #define TINFL_NEED_BITS(state_index, n) \ do { \ mz_uint c; \ TINFL_GET_BYTE(state_index, c); \ bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); \ num_bits += 8; \ } while (num_bits < (mz_uint)(n)) #define TINFL_SKIP_BITS(state_index, n) \ do { \ if (num_bits < (mz_uint)(n)) { \ TINFL_NEED_BITS(state_index, n); \ } \ bit_buf >>= (n); \ num_bits -= (n); \ } \ MZ_MACRO_END #define TINFL_GET_BITS(state_index, b, n) \ do { \ if (num_bits < (mz_uint)(n)) { \ TINFL_NEED_BITS(state_index, n); \ } \ b = bit_buf & ((1 << (n)) - 1); \ bit_buf >>= (n); \ num_bits -= (n); \ } \ MZ_MACRO_END // TINFL_HUFF_BITBUF_FILL() is only used rarely, when the number of bytes // remaining in the input buffer falls below 2. // It reads just enough bytes from the input stream that are needed to decode // the next Huffman code (and absolutely no more). It works by trying to fully // decode a // Huffman code by using whatever bits are currently present in the bit buffer. // If this fails, it reads another byte, and tries again until it succeeds or // until the // bit buffer contains >=15 bits (deflate's max. Huffman code size). #define TINFL_HUFF_BITBUF_FILL(state_index, pHuff) \ do { \ temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]; \ if (temp >= 0) { \ code_len = temp >> 9; \ if ((code_len) && (num_bits >= code_len)) break; \ } else if (num_bits > TINFL_FAST_LOOKUP_BITS) { \ code_len = TINFL_FAST_LOOKUP_BITS; \ do { \ temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \ } while ((temp < 0) && (num_bits >= (code_len + 1))); \ if (temp >= 0) break; \ } \ TINFL_GET_BYTE(state_index, c); \ bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); \ num_bits += 8; \ } while (num_bits < 15); // TINFL_HUFF_DECODE() decodes the next Huffman coded symbol. It's more complex // than you would initially expect because the zlib API expects the decompressor // to never read // beyond the final byte of the deflate stream. (In other words, when this macro // wants to read another byte from the input, it REALLY needs another byte in // order to fully // decode the next Huffman code.) Handling this properly is particularly // important on raw deflate (non-zlib) streams, which aren't followed by a byte // aligned adler-32. // The slow path is only executed at the very end of the input buffer. #define TINFL_HUFF_DECODE(state_index, sym, pHuff) \ do { \ int temp; \ mz_uint code_len, c; \ if (num_bits < 15) { \ if ((pIn_buf_end - pIn_buf_cur) < 2) { \ TINFL_HUFF_BITBUF_FILL(state_index, pHuff); \ } else { \ bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) | \ (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8)); \ pIn_buf_cur += 2; \ num_bits += 16; \ } \ } \ if ((temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= \ 0) \ code_len = temp >> 9, temp &= 511; \ else { \ code_len = TINFL_FAST_LOOKUP_BITS; \ do { \ temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \ } while (temp < 0); \ } \ sym = temp; \ bit_buf >>= code_len; \ num_bits -= code_len; \ } \ MZ_MACRO_END tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags) { static const int s_length_base[31] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; static const int s_length_extra[31] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0}; static const int s_dist_base[32] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0}; static const int s_dist_extra[32] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; static const mz_uint8 s_length_dezigzag[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; static const int s_min_table_sizes[3] = {257, 1, 4}; tinfl_status status = TINFL_STATUS_FAILED; mz_uint32 num_bits, dist, counter, num_extra; tinfl_bit_buf_t bit_buf; const mz_uint8 *pIn_buf_cur = pIn_buf_next, *const pIn_buf_end = pIn_buf_next + *pIn_buf_size; mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = pOut_buf_next + *pOut_buf_size; size_t out_buf_size_mask = (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) ? (size_t)-1 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, dist_from_out_buf_start; // Ensure the output buffer's size is a power of 2, unless the output buffer // is large enough to hold the entire output file (in which case it doesn't // matter). if (((out_buf_size_mask + 1) & out_buf_size_mask) || (pOut_buf_next < pOut_buf_start)) { *pIn_buf_size = *pOut_buf_size = 0; return TINFL_STATUS_BAD_PARAM; } num_bits = r->m_num_bits; bit_buf = r->m_bit_buf; dist = r->m_dist; counter = r->m_counter; num_extra = r->m_num_extra; dist_from_out_buf_start = r->m_dist_from_out_buf_start; TINFL_CR_BEGIN bit_buf = num_bits = dist = counter = num_extra = r->m_zhdr0 = r->m_zhdr1 = 0; r->m_z_adler32 = r->m_check_adler32 = 1; if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) { TINFL_GET_BYTE(1, r->m_zhdr0); TINFL_GET_BYTE(2, r->m_zhdr1); counter = (((r->m_zhdr0 * 256 + r->m_zhdr1) % 31 != 0) || (r->m_zhdr1 & 32) || ((r->m_zhdr0 & 15) != 8)); if (!(decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) counter |= (((1U << (8U + (r->m_zhdr0 >> 4))) > 32768U) || ((out_buf_size_mask + 1) < (size_t)(1ULL << (8U + (r->m_zhdr0 >> 4))))); if (counter) { TINFL_CR_RETURN_FOREVER(36, TINFL_STATUS_FAILED); } } do { TINFL_GET_BITS(3, r->m_final, 3); r->m_type = r->m_final >> 1; if (r->m_type == 0) { TINFL_SKIP_BITS(5, num_bits & 7); for (counter = 0; counter < 4; ++counter) { if (num_bits) TINFL_GET_BITS(6, r->m_raw_header[counter], 8); else TINFL_GET_BYTE(7, r->m_raw_header[counter]); } if ((counter = (r->m_raw_header[0] | (r->m_raw_header[1] << 8))) != (mz_uint)(0xFFFF ^ (r->m_raw_header[2] | (r->m_raw_header[3] << 8)))) { TINFL_CR_RETURN_FOREVER(39, TINFL_STATUS_FAILED); } while ((counter) && (num_bits)) { TINFL_GET_BITS(51, dist, 8); while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(52, TINFL_STATUS_HAS_MORE_OUTPUT); } *pOut_buf_cur++ = (mz_uint8)dist; counter--; } while (counter) { size_t n; while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(9, TINFL_STATUS_HAS_MORE_OUTPUT); } while (pIn_buf_cur >= pIn_buf_end) { if (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) { TINFL_CR_RETURN(38, TINFL_STATUS_NEEDS_MORE_INPUT); } else { TINFL_CR_RETURN_FOREVER(40, TINFL_STATUS_FAILED); } } n = MZ_MIN(MZ_MIN((size_t)(pOut_buf_end - pOut_buf_cur), (size_t)(pIn_buf_end - pIn_buf_cur)), counter); TINFL_MEMCPY(pOut_buf_cur, pIn_buf_cur, n); pIn_buf_cur += n; pOut_buf_cur += n; counter -= (mz_uint)n; } } else if (r->m_type == 3) { TINFL_CR_RETURN_FOREVER(10, TINFL_STATUS_FAILED); } else { if (r->m_type == 1) { mz_uint8 *p = r->m_tables[0].m_code_size; mz_uint i; r->m_table_sizes[0] = 288; r->m_table_sizes[1] = 32; TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32); for (i = 0; i <= 143; ++i) *p++ = 8; for (; i <= 255; ++i) *p++ = 9; for (; i <= 279; ++i) *p++ = 7; for (; i <= 287; ++i) *p++ = 8; } else { for (counter = 0; counter < 3; counter++) { TINFL_GET_BITS(11, r->m_table_sizes[counter], "\05\05\04"[counter]); r->m_table_sizes[counter] += s_min_table_sizes[counter]; } MZ_CLEAR_OBJ(r->m_tables[2].m_code_size); for (counter = 0; counter < r->m_table_sizes[2]; counter++) { mz_uint s; TINFL_GET_BITS(14, s, 3); r->m_tables[2].m_code_size[s_length_dezigzag[counter]] = (mz_uint8)s; } r->m_table_sizes[2] = 19; } for (; (int)r->m_type >= 0; r->m_type--) { int tree_next, tree_cur; tinfl_huff_table *pTable; mz_uint i, j, used_syms, total, sym_index, next_code[17], total_syms[16]; pTable = &r->m_tables[r->m_type]; MZ_CLEAR_OBJ(total_syms); MZ_CLEAR_OBJ(pTable->m_look_up); MZ_CLEAR_OBJ(pTable->m_tree); for (i = 0; i < r->m_table_sizes[r->m_type]; ++i) total_syms[pTable->m_code_size[i]]++; used_syms = 0, total = 0; next_code[0] = next_code[1] = 0; for (i = 1; i <= 15; ++i) { used_syms += total_syms[i]; next_code[i + 1] = (total = ((total + total_syms[i]) << 1)); } if ((65536 != total) && (used_syms > 1)) { TINFL_CR_RETURN_FOREVER(35, TINFL_STATUS_FAILED); } for (tree_next = -1, sym_index = 0; sym_index < r->m_table_sizes[r->m_type]; ++sym_index) { mz_uint rev_code = 0, l, cur_code, code_size = pTable->m_code_size[sym_index]; if (!code_size) continue; cur_code = next_code[code_size]++; for (l = code_size; l > 0; l--, cur_code >>= 1) rev_code = (rev_code << 1) | (cur_code & 1); if (code_size <= TINFL_FAST_LOOKUP_BITS) { mz_int16 k = (mz_int16)((code_size << 9) | sym_index); while (rev_code < TINFL_FAST_LOOKUP_SIZE) { pTable->m_look_up[rev_code] = k; rev_code += (1 << code_size); } continue; } if (0 == (tree_cur = pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)])) { pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)] = (mz_int16)tree_next; tree_cur = tree_next; tree_next -= 2; } rev_code >>= (TINFL_FAST_LOOKUP_BITS - 1); for (j = code_size; j > (TINFL_FAST_LOOKUP_BITS + 1); j--) { tree_cur -= ((rev_code >>= 1) & 1); if (!pTable->m_tree[-tree_cur - 1]) { pTable->m_tree[-tree_cur - 1] = (mz_int16)tree_next; tree_cur = tree_next; tree_next -= 2; } else tree_cur = pTable->m_tree[-tree_cur - 1]; } tree_cur -= ((rev_code >>= 1) & 1); pTable->m_tree[-tree_cur - 1] = (mz_int16)sym_index; } if (r->m_type == 2) { for (counter = 0; counter < (r->m_table_sizes[0] + r->m_table_sizes[1]);) { mz_uint s; TINFL_HUFF_DECODE(16, dist, &r->m_tables[2]); if (dist < 16) { r->m_len_codes[counter++] = (mz_uint8)dist; continue; } if ((dist == 16) && (!counter)) { TINFL_CR_RETURN_FOREVER(17, TINFL_STATUS_FAILED); } num_extra = "\02\03\07"[dist - 16]; TINFL_GET_BITS(18, s, num_extra); s += "\03\03\013"[dist - 16]; TINFL_MEMSET(r->m_len_codes + counter, (dist == 16) ? r->m_len_codes[counter - 1] : 0, s); counter += s; } if ((r->m_table_sizes[0] + r->m_table_sizes[1]) != counter) { TINFL_CR_RETURN_FOREVER(21, TINFL_STATUS_FAILED); } TINFL_MEMCPY(r->m_tables[0].m_code_size, r->m_len_codes, r->m_table_sizes[0]); TINFL_MEMCPY(r->m_tables[1].m_code_size, r->m_len_codes + r->m_table_sizes[0], r->m_table_sizes[1]); } } for (;;) { mz_uint8 *pSrc; for (;;) { if (((pIn_buf_end - pIn_buf_cur) < 4) || ((pOut_buf_end - pOut_buf_cur) < 2)) { TINFL_HUFF_DECODE(23, counter, &r->m_tables[0]); if (counter >= 256) break; while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(24, TINFL_STATUS_HAS_MORE_OUTPUT); } *pOut_buf_cur++ = (mz_uint8)counter; } else { int sym2; mz_uint code_len; #if TINFL_USE_64BIT_BITBUF if (num_bits < 30) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE32(pIn_buf_cur)) << num_bits); pIn_buf_cur += 4; num_bits += 32; } #else if (num_bits < 15) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); pIn_buf_cur += 2; num_bits += 16; } #endif if ((sym2 = r->m_tables[0] .m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) code_len = sym2 >> 9; else { code_len = TINFL_FAST_LOOKUP_BITS; do { sym2 = r->m_tables[0] .m_tree[~sym2 + ((bit_buf >> code_len++) & 1)]; } while (sym2 < 0); } counter = sym2; bit_buf >>= code_len; num_bits -= code_len; if (counter & 256) break; #if !TINFL_USE_64BIT_BITBUF if (num_bits < 15) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); pIn_buf_cur += 2; num_bits += 16; } #endif if ((sym2 = r->m_tables[0] .m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) code_len = sym2 >> 9; else { code_len = TINFL_FAST_LOOKUP_BITS; do { sym2 = r->m_tables[0] .m_tree[~sym2 + ((bit_buf >> code_len++) & 1)]; } while (sym2 < 0); } bit_buf >>= code_len; num_bits -= code_len; pOut_buf_cur[0] = (mz_uint8)counter; if (sym2 & 256) { pOut_buf_cur++; counter = sym2; break; } pOut_buf_cur[1] = (mz_uint8)sym2; pOut_buf_cur += 2; } } if ((counter &= 511) == 256) break; num_extra = s_length_extra[counter - 257]; counter = s_length_base[counter - 257]; if (num_extra) { mz_uint extra_bits; TINFL_GET_BITS(25, extra_bits, num_extra); counter += extra_bits; } TINFL_HUFF_DECODE(26, dist, &r->m_tables[1]); num_extra = s_dist_extra[dist]; dist = s_dist_base[dist]; if (num_extra) { mz_uint extra_bits; TINFL_GET_BITS(27, extra_bits, num_extra); dist += extra_bits; } dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start; if ((dist > dist_from_out_buf_start) && (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) { TINFL_CR_RETURN_FOREVER(37, TINFL_STATUS_FAILED); } pSrc = pOut_buf_start + ((dist_from_out_buf_start - dist) & out_buf_size_mask); if ((MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end) { while (counter--) { while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(53, TINFL_STATUS_HAS_MORE_OUTPUT); } *pOut_buf_cur++ = pOut_buf_start[(dist_from_out_buf_start++ - dist) & out_buf_size_mask]; } continue; } #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES else if ((counter >= 9) && (counter <= dist)) { const mz_uint8 *pSrc_end = pSrc + (counter & ~7); do { ((mz_uint32 *)pOut_buf_cur)[0] = ((const mz_uint32 *)pSrc)[0]; ((mz_uint32 *)pOut_buf_cur)[1] = ((const mz_uint32 *)pSrc)[1]; pOut_buf_cur += 8; } while ((pSrc += 8) < pSrc_end); if ((counter &= 7) < 3) { if (counter) { pOut_buf_cur[0] = pSrc[0]; if (counter > 1) pOut_buf_cur[1] = pSrc[1]; pOut_buf_cur += counter; } continue; } } #endif do { pOut_buf_cur[0] = pSrc[0]; pOut_buf_cur[1] = pSrc[1]; pOut_buf_cur[2] = pSrc[2]; pOut_buf_cur += 3; pSrc += 3; } while ((int)(counter -= 3) > 2); if ((int)counter > 0) { pOut_buf_cur[0] = pSrc[0]; if ((int)counter > 1) pOut_buf_cur[1] = pSrc[1]; pOut_buf_cur += counter; } } } } while (!(r->m_final & 1)); if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) { TINFL_SKIP_BITS(32, num_bits & 7); for (counter = 0; counter < 4; ++counter) { mz_uint s; if (num_bits) TINFL_GET_BITS(41, s, 8); else TINFL_GET_BYTE(42, s); r->m_z_adler32 = (r->m_z_adler32 << 8) | s; } } TINFL_CR_RETURN_FOREVER(34, TINFL_STATUS_DONE); TINFL_CR_FINISH common_exit: r->m_num_bits = num_bits; r->m_bit_buf = bit_buf; r->m_dist = dist; r->m_counter = counter; r->m_num_extra = num_extra; r->m_dist_from_out_buf_start = dist_from_out_buf_start; *pIn_buf_size = pIn_buf_cur - pIn_buf_next; *pOut_buf_size = pOut_buf_cur - pOut_buf_next; if ((decomp_flags & (TINFL_FLAG_PARSE_ZLIB_HEADER | TINFL_FLAG_COMPUTE_ADLER32)) && (status >= 0)) { const mz_uint8 *ptr = pOut_buf_next; size_t buf_len = *pOut_buf_size; mz_uint32 i, s1 = r->m_check_adler32 & 0xffff, s2 = r->m_check_adler32 >> 16; size_t block_len = buf_len % 5552; while (buf_len) { for (i = 0; i + 7 < block_len; i += 8, ptr += 8) { s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1; s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1; } for (; i < block_len; ++i) s1 += *ptr++, s2 += s1; s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552; } r->m_check_adler32 = (s2 << 16) + s1; if ((status == TINFL_STATUS_DONE) && (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) && (r->m_check_adler32 != r->m_z_adler32)) status = TINFL_STATUS_ADLER32_MISMATCH; } return status; } // Higher level helper functions. void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags) { tinfl_decompressor decomp; void *pBuf = NULL, *pNew_buf; size_t src_buf_ofs = 0, out_buf_capacity = 0; *pOut_len = 0; tinfl_init(&decomp); for (;;) { size_t src_buf_size = src_buf_len - src_buf_ofs, dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity; tinfl_status status = tinfl_decompress( &decomp, (const mz_uint8 *)pSrc_buf + src_buf_ofs, &src_buf_size, (mz_uint8 *)pBuf, pBuf ? (mz_uint8 *)pBuf + *pOut_len : NULL, &dst_buf_size, (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); if ((status < 0) || (status == TINFL_STATUS_NEEDS_MORE_INPUT)) { MZ_FREE(pBuf); *pOut_len = 0; return NULL; } src_buf_ofs += src_buf_size; *pOut_len += dst_buf_size; if (status == TINFL_STATUS_DONE) break; new_out_buf_capacity = out_buf_capacity * 2; if (new_out_buf_capacity < 128) new_out_buf_capacity = 128; pNew_buf = MZ_REALLOC(pBuf, new_out_buf_capacity); if (!pNew_buf) { MZ_FREE(pBuf); *pOut_len = 0; return NULL; } pBuf = pNew_buf; out_buf_capacity = new_out_buf_capacity; } return pBuf; } size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags) { tinfl_decompressor decomp; tinfl_status status; tinfl_init(&decomp); status = tinfl_decompress(&decomp, (const mz_uint8 *)pSrc_buf, &src_buf_len, (mz_uint8 *)pOut_buf, (mz_uint8 *)pOut_buf, &out_buf_len, (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); return (status != TINFL_STATUS_DONE) ? TINFL_DECOMPRESS_MEM_TO_MEM_FAILED : out_buf_len; } int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) { int result = 0; tinfl_decompressor decomp; mz_uint8 *pDict = (mz_uint8 *)MZ_MALLOC(TINFL_LZ_DICT_SIZE); size_t in_buf_ofs = 0, dict_ofs = 0; if (!pDict) return TINFL_STATUS_FAILED; tinfl_init(&decomp); for (;;) { size_t in_buf_size = *pIn_buf_size - in_buf_ofs, dst_buf_size = TINFL_LZ_DICT_SIZE - dict_ofs; tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8 *)pIn_buf + in_buf_ofs, &in_buf_size, pDict, pDict + dict_ofs, &dst_buf_size, (flags & ~(TINFL_FLAG_HAS_MORE_INPUT | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF))); in_buf_ofs += in_buf_size; if ((dst_buf_size) && (!(*pPut_buf_func)(pDict + dict_ofs, (int)dst_buf_size, pPut_buf_user))) break; if (status != TINFL_STATUS_HAS_MORE_OUTPUT) { result = (status == TINFL_STATUS_DONE); break; } dict_ofs = (dict_ofs + dst_buf_size) & (TINFL_LZ_DICT_SIZE - 1); } MZ_FREE(pDict); *pIn_buf_size = in_buf_ofs; return result; } // ------------------- Low-level Compression (independent from all decompression // API's) // Purposely making these tables static for faster init and thread safety. static const mz_uint16 s_tdefl_len_sym[256] = { 257, 258, 259, 260, 261, 262, 263, 264, 265, 265, 266, 266, 267, 267, 268, 268, 269, 269, 269, 269, 270, 270, 270, 270, 271, 271, 271, 271, 272, 272, 272, 272, 273, 273, 273, 273, 273, 273, 273, 273, 274, 274, 274, 274, 274, 274, 274, 274, 275, 275, 275, 275, 275, 275, 275, 275, 276, 276, 276, 276, 276, 276, 276, 276, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 285}; static const mz_uint8 s_tdefl_len_extra[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0}; static const mz_uint8 s_tdefl_small_dist_sym[512] = { 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17}; static const mz_uint8 s_tdefl_small_dist_extra[512] = { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}; static const mz_uint8 s_tdefl_large_dist_sym[128] = { 0, 0, 18, 19, 20, 20, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29}; static const mz_uint8 s_tdefl_large_dist_extra[128] = { 0, 0, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13}; // Radix sorts tdefl_sym_freq[] array by 16-bit key m_key. Returns ptr to sorted // values. typedef struct { mz_uint16 m_key, m_sym_index; } tdefl_sym_freq; static tdefl_sym_freq *tdefl_radix_sort_syms(mz_uint num_syms, tdefl_sym_freq *pSyms0, tdefl_sym_freq *pSyms1) { mz_uint32 total_passes = 2, pass_shift, pass, i, hist[256 * 2]; tdefl_sym_freq *pCur_syms = pSyms0, *pNew_syms = pSyms1; MZ_CLEAR_OBJ(hist); for (i = 0; i < num_syms; i++) { mz_uint freq = pSyms0[i].m_key; hist[freq & 0xFF]++; hist[256 + ((freq >> 8) & 0xFF)]++; } while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256])) total_passes--; for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8) { const mz_uint32 *pHist = &hist[pass << 8]; mz_uint offsets[256], cur_ofs = 0; for (i = 0; i < 256; i++) { offsets[i] = cur_ofs; cur_ofs += pHist[i]; } for (i = 0; i < num_syms; i++) pNew_syms[offsets[(pCur_syms[i].m_key >> pass_shift) & 0xFF]++] = pCur_syms[i]; { tdefl_sym_freq *t = pCur_syms; pCur_syms = pNew_syms; pNew_syms = t; } } return pCur_syms; } // tdefl_calculate_minimum_redundancy() originally written by: Alistair Moffat, // alistair@cs.mu.oz.au, Jyrki Katajainen, jyrki@diku.dk, November 1996. static void tdefl_calculate_minimum_redundancy(tdefl_sym_freq *A, int n) { int root, leaf, next, avbl, used, dpth; if (n == 0) return; else if (n == 1) { A[0].m_key = 1; return; } A[0].m_key += A[1].m_key; root = 0; leaf = 2; for (next = 1; next < n - 1; next++) { if (leaf >= n || A[root].m_key < A[leaf].m_key) { A[next].m_key = A[root].m_key; A[root++].m_key = (mz_uint16)next; } else A[next].m_key = A[leaf++].m_key; if (leaf >= n || (root < next && A[root].m_key < A[leaf].m_key)) { A[next].m_key = (mz_uint16)(A[next].m_key + A[root].m_key); A[root++].m_key = (mz_uint16)next; } else A[next].m_key = (mz_uint16)(A[next].m_key + A[leaf++].m_key); } A[n - 2].m_key = 0; for (next = n - 3; next >= 0; next--) A[next].m_key = A[A[next].m_key].m_key + 1; avbl = 1; used = dpth = 0; root = n - 2; next = n - 1; while (avbl > 0) { while (root >= 0 && (int)A[root].m_key == dpth) { used++; root--; } while (avbl > used) { A[next--].m_key = (mz_uint16)(dpth); avbl--; } avbl = 2 * used; dpth++; used = 0; } } // Limits canonical Huffman code table's max code size. enum { TDEFL_MAX_SUPPORTED_HUFF_CODESIZE = 32 }; static void tdefl_huffman_enforce_max_code_size(int *pNum_codes, int code_list_len, int max_code_size) { int i; mz_uint32 total = 0; if (code_list_len <= 1) return; for (i = max_code_size + 1; i <= TDEFL_MAX_SUPPORTED_HUFF_CODESIZE; i++) pNum_codes[max_code_size] += pNum_codes[i]; for (i = max_code_size; i > 0; i--) total += (((mz_uint32)pNum_codes[i]) << (max_code_size - i)); while (total != (1UL << max_code_size)) { pNum_codes[max_code_size]--; for (i = max_code_size - 1; i > 0; i--) if (pNum_codes[i]) { pNum_codes[i]--; pNum_codes[i + 1] += 2; break; } total--; } } static void tdefl_optimize_huffman_table(tdefl_compressor *d, int table_num, int table_len, int code_size_limit, int static_table) { int i, j, l, num_codes[1 + TDEFL_MAX_SUPPORTED_HUFF_CODESIZE]; mz_uint next_code[TDEFL_MAX_SUPPORTED_HUFF_CODESIZE + 1]; MZ_CLEAR_OBJ(num_codes); if (static_table) { for (i = 0; i < table_len; i++) num_codes[d->m_huff_code_sizes[table_num][i]]++; } else { tdefl_sym_freq syms0[TDEFL_MAX_HUFF_SYMBOLS], syms1[TDEFL_MAX_HUFF_SYMBOLS], *pSyms; int num_used_syms = 0; const mz_uint16 *pSym_count = &d->m_huff_count[table_num][0]; for (i = 0; i < table_len; i++) if (pSym_count[i]) { syms0[num_used_syms].m_key = (mz_uint16)pSym_count[i]; syms0[num_used_syms++].m_sym_index = (mz_uint16)i; } pSyms = tdefl_radix_sort_syms(num_used_syms, syms0, syms1); tdefl_calculate_minimum_redundancy(pSyms, num_used_syms); for (i = 0; i < num_used_syms; i++) num_codes[pSyms[i].m_key]++; tdefl_huffman_enforce_max_code_size(num_codes, num_used_syms, code_size_limit); MZ_CLEAR_OBJ(d->m_huff_code_sizes[table_num]); MZ_CLEAR_OBJ(d->m_huff_codes[table_num]); for (i = 1, j = num_used_syms; i <= code_size_limit; i++) for (l = num_codes[i]; l > 0; l--) d->m_huff_code_sizes[table_num][pSyms[--j].m_sym_index] = (mz_uint8)(i); } next_code[1] = 0; for (j = 0, i = 2; i <= code_size_limit; i++) next_code[i] = j = ((j + num_codes[i - 1]) << 1); for (i = 0; i < table_len; i++) { mz_uint rev_code = 0, code, code_size; if ((code_size = d->m_huff_code_sizes[table_num][i]) == 0) continue; code = next_code[code_size]++; for (l = code_size; l > 0; l--, code >>= 1) rev_code = (rev_code << 1) | (code & 1); d->m_huff_codes[table_num][i] = (mz_uint16)rev_code; } } #define TDEFL_PUT_BITS(b, l) \ do { \ mz_uint bits = b; \ mz_uint len = l; \ MZ_ASSERT(bits <= ((1U << len) - 1U)); \ d->m_bit_buffer |= (bits << d->m_bits_in); \ d->m_bits_in += len; \ while (d->m_bits_in >= 8) { \ if (d->m_pOutput_buf < d->m_pOutput_buf_end) \ *d->m_pOutput_buf++ = (mz_uint8)(d->m_bit_buffer); \ d->m_bit_buffer >>= 8; \ d->m_bits_in -= 8; \ } \ } \ MZ_MACRO_END #define TDEFL_RLE_PREV_CODE_SIZE() \ { \ if (rle_repeat_count) { \ if (rle_repeat_count < 3) { \ d->m_huff_count[2][prev_code_size] = (mz_uint16)( \ d->m_huff_count[2][prev_code_size] + rle_repeat_count); \ while (rle_repeat_count--) \ packed_code_sizes[num_packed_code_sizes++] = prev_code_size; \ } else { \ d->m_huff_count[2][16] = (mz_uint16)(d->m_huff_count[2][16] + 1); \ packed_code_sizes[num_packed_code_sizes++] = 16; \ packed_code_sizes[num_packed_code_sizes++] = \ (mz_uint8)(rle_repeat_count - 3); \ } \ rle_repeat_count = 0; \ } \ } #define TDEFL_RLE_ZERO_CODE_SIZE() \ { \ if (rle_z_count) { \ if (rle_z_count < 3) { \ d->m_huff_count[2][0] = \ (mz_uint16)(d->m_huff_count[2][0] + rle_z_count); \ while (rle_z_count--) packed_code_sizes[num_packed_code_sizes++] = 0; \ } else if (rle_z_count <= 10) { \ d->m_huff_count[2][17] = (mz_uint16)(d->m_huff_count[2][17] + 1); \ packed_code_sizes[num_packed_code_sizes++] = 17; \ packed_code_sizes[num_packed_code_sizes++] = \ (mz_uint8)(rle_z_count - 3); \ } else { \ d->m_huff_count[2][18] = (mz_uint16)(d->m_huff_count[2][18] + 1); \ packed_code_sizes[num_packed_code_sizes++] = 18; \ packed_code_sizes[num_packed_code_sizes++] = \ (mz_uint8)(rle_z_count - 11); \ } \ rle_z_count = 0; \ } \ } static mz_uint8 s_tdefl_packed_code_size_syms_swizzle[] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; static void tdefl_start_dynamic_block(tdefl_compressor *d) { int num_lit_codes, num_dist_codes, num_bit_lengths; mz_uint i, total_code_sizes_to_pack, num_packed_code_sizes, rle_z_count, rle_repeat_count, packed_code_sizes_index; mz_uint8 code_sizes_to_pack[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], packed_code_sizes[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], prev_code_size = 0xFF; d->m_huff_count[0][256] = 1; tdefl_optimize_huffman_table(d, 0, TDEFL_MAX_HUFF_SYMBOLS_0, 15, MZ_FALSE); tdefl_optimize_huffman_table(d, 1, TDEFL_MAX_HUFF_SYMBOLS_1, 15, MZ_FALSE); for (num_lit_codes = 286; num_lit_codes > 257; num_lit_codes--) if (d->m_huff_code_sizes[0][num_lit_codes - 1]) break; for (num_dist_codes = 30; num_dist_codes > 1; num_dist_codes--) if (d->m_huff_code_sizes[1][num_dist_codes - 1]) break; memcpy(code_sizes_to_pack, &d->m_huff_code_sizes[0][0], num_lit_codes); memcpy(code_sizes_to_pack + num_lit_codes, &d->m_huff_code_sizes[1][0], num_dist_codes); total_code_sizes_to_pack = num_lit_codes + num_dist_codes; num_packed_code_sizes = 0; rle_z_count = 0; rle_repeat_count = 0; memset(&d->m_huff_count[2][0], 0, sizeof(d->m_huff_count[2][0]) * TDEFL_MAX_HUFF_SYMBOLS_2); for (i = 0; i < total_code_sizes_to_pack; i++) { mz_uint8 code_size = code_sizes_to_pack[i]; if (!code_size) { TDEFL_RLE_PREV_CODE_SIZE(); if (++rle_z_count == 138) { TDEFL_RLE_ZERO_CODE_SIZE(); } } else { TDEFL_RLE_ZERO_CODE_SIZE(); if (code_size != prev_code_size) { TDEFL_RLE_PREV_CODE_SIZE(); d->m_huff_count[2][code_size] = (mz_uint16)(d->m_huff_count[2][code_size] + 1); packed_code_sizes[num_packed_code_sizes++] = code_size; } else if (++rle_repeat_count == 6) { TDEFL_RLE_PREV_CODE_SIZE(); } } prev_code_size = code_size; } if (rle_repeat_count) { TDEFL_RLE_PREV_CODE_SIZE(); } else { TDEFL_RLE_ZERO_CODE_SIZE(); } tdefl_optimize_huffman_table(d, 2, TDEFL_MAX_HUFF_SYMBOLS_2, 7, MZ_FALSE); TDEFL_PUT_BITS(2, 2); TDEFL_PUT_BITS(num_lit_codes - 257, 5); TDEFL_PUT_BITS(num_dist_codes - 1, 5); for (num_bit_lengths = 18; num_bit_lengths >= 0; num_bit_lengths--) if (d->m_huff_code_sizes [2][s_tdefl_packed_code_size_syms_swizzle[num_bit_lengths]]) break; num_bit_lengths = MZ_MAX(4, (num_bit_lengths + 1)); TDEFL_PUT_BITS(num_bit_lengths - 4, 4); for (i = 0; (int)i < num_bit_lengths; i++) TDEFL_PUT_BITS( d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[i]], 3); for (packed_code_sizes_index = 0; packed_code_sizes_index < num_packed_code_sizes;) { mz_uint code = packed_code_sizes[packed_code_sizes_index++]; MZ_ASSERT(code < TDEFL_MAX_HUFF_SYMBOLS_2); TDEFL_PUT_BITS(d->m_huff_codes[2][code], d->m_huff_code_sizes[2][code]); if (code >= 16) TDEFL_PUT_BITS(packed_code_sizes[packed_code_sizes_index++], "\02\03\07"[code - 16]); } } static void tdefl_start_static_block(tdefl_compressor *d) { mz_uint i; mz_uint8 *p = &d->m_huff_code_sizes[0][0]; for (i = 0; i <= 143; ++i) *p++ = 8; for (; i <= 255; ++i) *p++ = 9; for (; i <= 279; ++i) *p++ = 7; for (; i <= 287; ++i) *p++ = 8; memset(d->m_huff_code_sizes[1], 5, 32); tdefl_optimize_huffman_table(d, 0, 288, 15, MZ_TRUE); tdefl_optimize_huffman_table(d, 1, 32, 15, MZ_TRUE); TDEFL_PUT_BITS(1, 2); } static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF}; #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && \ MINIZ_HAS_64BIT_REGISTERS static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) { mz_uint flags; mz_uint8 *pLZ_codes; mz_uint8 *pOutput_buf = d->m_pOutput_buf; mz_uint8 *pLZ_code_buf_end = d->m_pLZ_code_buf; mz_uint64 bit_buffer = d->m_bit_buffer; mz_uint bits_in = d->m_bits_in; #define TDEFL_PUT_BITS_FAST(b, l) \ { \ bit_buffer |= (((mz_uint64)(b)) << bits_in); \ bits_in += (l); \ } flags = 1; for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; flags >>= 1) { if (flags == 1) flags = *pLZ_codes++ | 0x100; if (flags & 1) { mz_uint s0, s1, n0, n1, sym, num_extra_bits; mz_uint match_len = pLZ_codes[0], match_dist = *(const mz_uint16 *)(pLZ_codes + 1); pLZ_codes += 3; MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); TDEFL_PUT_BITS_FAST(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]); // This sequence coaxes MSVC into using cmov's vs. jmp's. s0 = s_tdefl_small_dist_sym[match_dist & 511]; n0 = s_tdefl_small_dist_extra[match_dist & 511]; s1 = s_tdefl_large_dist_sym[match_dist >> 8]; n1 = s_tdefl_large_dist_extra[match_dist >> 8]; sym = (match_dist < 512) ? s0 : s1; num_extra_bits = (match_dist < 512) ? n0 : n1; MZ_ASSERT(d->m_huff_code_sizes[1][sym]); TDEFL_PUT_BITS_FAST(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]); TDEFL_PUT_BITS_FAST(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits); } else { mz_uint lit = *pLZ_codes++; MZ_ASSERT(d->m_huff_code_sizes[0][lit]); TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) { flags >>= 1; lit = *pLZ_codes++; MZ_ASSERT(d->m_huff_code_sizes[0][lit]); TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) { flags >>= 1; lit = *pLZ_codes++; MZ_ASSERT(d->m_huff_code_sizes[0][lit]); TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); } } } if (pOutput_buf >= d->m_pOutput_buf_end) return MZ_FALSE; *(mz_uint64 *)pOutput_buf = bit_buffer; pOutput_buf += (bits_in >> 3); bit_buffer >>= (bits_in & ~7); bits_in &= 7; } #undef TDEFL_PUT_BITS_FAST d->m_pOutput_buf = pOutput_buf; d->m_bits_in = 0; d->m_bit_buffer = 0; while (bits_in) { mz_uint32 n = MZ_MIN(bits_in, 16); TDEFL_PUT_BITS((mz_uint)bit_buffer & mz_bitmasks[n], n); bit_buffer >>= n; bits_in -= n; } TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]); return (d->m_pOutput_buf < d->m_pOutput_buf_end); } #else static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) { mz_uint flags; mz_uint8 *pLZ_codes; flags = 1; for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < d->m_pLZ_code_buf; flags >>= 1) { if (flags == 1) flags = *pLZ_codes++ | 0x100; if (flags & 1) { mz_uint sym, num_extra_bits; mz_uint match_len = pLZ_codes[0], match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8)); pLZ_codes += 3; MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); TDEFL_PUT_BITS(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); TDEFL_PUT_BITS(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]); if (match_dist < 512) { sym = s_tdefl_small_dist_sym[match_dist]; num_extra_bits = s_tdefl_small_dist_extra[match_dist]; } else { sym = s_tdefl_large_dist_sym[match_dist >> 8]; num_extra_bits = s_tdefl_large_dist_extra[match_dist >> 8]; } MZ_ASSERT(d->m_huff_code_sizes[1][sym]); TDEFL_PUT_BITS(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]); TDEFL_PUT_BITS(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits); } else { mz_uint lit = *pLZ_codes++; MZ_ASSERT(d->m_huff_code_sizes[0][lit]); TDEFL_PUT_BITS(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); } } TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]); return (d->m_pOutput_buf < d->m_pOutput_buf_end); } #endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && // MINIZ_HAS_64BIT_REGISTERS static mz_bool tdefl_compress_block(tdefl_compressor *d, mz_bool static_block) { if (static_block) tdefl_start_static_block(d); else tdefl_start_dynamic_block(d); return tdefl_compress_lz_codes(d); } static int tdefl_flush_block(tdefl_compressor *d, int flush) { mz_uint saved_bit_buf, saved_bits_in; mz_uint8 *pSaved_output_buf; mz_bool comp_block_succeeded = MZ_FALSE; int n, use_raw_block = ((d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS) != 0) && (d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size; mz_uint8 *pOutput_buf_start = ((d->m_pPut_buf_func == NULL) && ((*d->m_pOut_buf_size - d->m_out_buf_ofs) >= TDEFL_OUT_BUF_SIZE)) ? ((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs) : d->m_output_buf; d->m_pOutput_buf = pOutput_buf_start; d->m_pOutput_buf_end = d->m_pOutput_buf + TDEFL_OUT_BUF_SIZE - 16; MZ_ASSERT(!d->m_output_flush_remaining); d->m_output_flush_ofs = 0; d->m_output_flush_remaining = 0; *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> d->m_num_flags_left); d->m_pLZ_code_buf -= (d->m_num_flags_left == 8); if ((d->m_flags & TDEFL_WRITE_ZLIB_HEADER) && (!d->m_block_index)) { TDEFL_PUT_BITS(0x78, 8); TDEFL_PUT_BITS(0x01, 8); } TDEFL_PUT_BITS(flush == TDEFL_FINISH, 1); pSaved_output_buf = d->m_pOutput_buf; saved_bit_buf = d->m_bit_buffer; saved_bits_in = d->m_bits_in; if (!use_raw_block) comp_block_succeeded = tdefl_compress_block(d, (d->m_flags & TDEFL_FORCE_ALL_STATIC_BLOCKS) || (d->m_total_lz_bytes < 48)); // If the block gets expanded, forget the current contents of the output // buffer and send a raw block instead. if (((use_raw_block) || ((d->m_total_lz_bytes) && ((d->m_pOutput_buf - pSaved_output_buf + 1U) >= d->m_total_lz_bytes))) && ((d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size)) { mz_uint i; d->m_pOutput_buf = pSaved_output_buf; d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in; TDEFL_PUT_BITS(0, 2); if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } for (i = 2; i; --i, d->m_total_lz_bytes ^= 0xFFFF) { TDEFL_PUT_BITS(d->m_total_lz_bytes & 0xFFFF, 16); } for (i = 0; i < d->m_total_lz_bytes; ++i) { TDEFL_PUT_BITS( d->m_dict[(d->m_lz_code_buf_dict_pos + i) & TDEFL_LZ_DICT_SIZE_MASK], 8); } } // Check for the extremely unlikely (if not impossible) case of the compressed // block not fitting into the output buffer when using dynamic codes. else if (!comp_block_succeeded) { d->m_pOutput_buf = pSaved_output_buf; d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in; tdefl_compress_block(d, MZ_TRUE); } if (flush) { if (flush == TDEFL_FINISH) { if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } if (d->m_flags & TDEFL_WRITE_ZLIB_HEADER) { mz_uint i, a = d->m_adler32; for (i = 0; i < 4; i++) { TDEFL_PUT_BITS((a >> 24) & 0xFF, 8); a <<= 8; } } } else { mz_uint i, z = 0; TDEFL_PUT_BITS(0, 3); if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } for (i = 2; i; --i, z ^= 0xFFFF) { TDEFL_PUT_BITS(z & 0xFFFF, 16); } } } MZ_ASSERT(d->m_pOutput_buf < d->m_pOutput_buf_end); memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0); memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1); d->m_pLZ_code_buf = d->m_lz_code_buf + 1; d->m_pLZ_flags = d->m_lz_code_buf; d->m_num_flags_left = 8; d->m_lz_code_buf_dict_pos += d->m_total_lz_bytes; d->m_total_lz_bytes = 0; d->m_block_index++; if ((n = (int)(d->m_pOutput_buf - pOutput_buf_start)) != 0) { if (d->m_pPut_buf_func) { *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf; if (!(*d->m_pPut_buf_func)(d->m_output_buf, n, d->m_pPut_buf_user)) return (d->m_prev_return_status = TDEFL_STATUS_PUT_BUF_FAILED); } else if (pOutput_buf_start == d->m_output_buf) { int bytes_to_copy = (int)MZ_MIN( (size_t)n, (size_t)(*d->m_pOut_buf_size - d->m_out_buf_ofs)); memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf, bytes_to_copy); d->m_out_buf_ofs += bytes_to_copy; if ((n -= bytes_to_copy) != 0) { d->m_output_flush_ofs = bytes_to_copy; d->m_output_flush_remaining = n; } } else { d->m_out_buf_ofs += n; } } return d->m_output_flush_remaining; } #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES #define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16 *)(p) static MZ_FORCEINLINE void tdefl_find_match( tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) { mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; const mz_uint16 *s = (const mz_uint16 *)(d->m_dict + pos), *p, *q; mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD(s); MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); if (max_match_len <= match_len) return; for (;;) { for (;;) { if (--num_probes_left == 0) return; #define TDEFL_PROBE \ next_probe_pos = d->m_next[probe_pos]; \ if ((!next_probe_pos) || \ ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) \ return; \ probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) \ break; TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE; } if (!dist) break; q = (const mz_uint16 *)(d->m_dict + probe_pos); if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue; p = s; probe_len = 32; do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0)); if (!probe_len) { *pMatch_dist = dist; *pMatch_len = MZ_MIN(max_match_len, TDEFL_MAX_MATCH_LEN); break; } else if ((probe_len = ((mz_uint)(p - s) * 2) + (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q)) > match_len) { *pMatch_dist = dist; if ((*pMatch_len = match_len = MZ_MIN(max_match_len, probe_len)) == max_match_len) break; c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]); } } } #else static MZ_FORCEINLINE void tdefl_find_match( tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) { mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; const mz_uint8 *s = d->m_dict + pos, *p, *q; mz_uint8 c0 = d->m_dict[pos + match_len], c1 = d->m_dict[pos + match_len - 1]; MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); if (max_match_len <= match_len) return; for (;;) { for (;;) { if (--num_probes_left == 0) return; #define TDEFL_PROBE \ next_probe_pos = d->m_next[probe_pos]; \ if ((!next_probe_pos) || \ ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) \ return; \ probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ if ((d->m_dict[probe_pos + match_len] == c0) && \ (d->m_dict[probe_pos + match_len - 1] == c1)) \ break; TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE; } if (!dist) break; p = s; q = d->m_dict + probe_pos; for (probe_len = 0; probe_len < max_match_len; probe_len++) if (*p++ != *q++) break; if (probe_len > match_len) { *pMatch_dist = dist; if ((*pMatch_len = match_len = probe_len) == max_match_len) return; c0 = d->m_dict[pos + match_len]; c1 = d->m_dict[pos + match_len - 1]; } } } #endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN static mz_bool tdefl_compress_fast(tdefl_compressor *d) { // Faster, minimally featured LZRW1-style match+parse loop with better // register utilization. Intended for applications where raw throughput is // valued more highly than ratio. mz_uint lookahead_pos = d->m_lookahead_pos, lookahead_size = d->m_lookahead_size, dict_size = d->m_dict_size, total_lz_bytes = d->m_total_lz_bytes, num_flags_left = d->m_num_flags_left; mz_uint8 *pLZ_code_buf = d->m_pLZ_code_buf, *pLZ_flags = d->m_pLZ_flags; mz_uint cur_pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; while ((d->m_src_buf_left) || ((d->m_flush) && (lookahead_size))) { const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096; mz_uint dst_pos = (lookahead_pos + lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK; mz_uint num_bytes_to_process = (mz_uint)MZ_MIN( d->m_src_buf_left, TDEFL_COMP_FAST_LOOKAHEAD_SIZE - lookahead_size); d->m_src_buf_left -= num_bytes_to_process; lookahead_size += num_bytes_to_process; while (num_bytes_to_process) { mz_uint32 n = MZ_MIN(TDEFL_LZ_DICT_SIZE - dst_pos, num_bytes_to_process); memcpy(d->m_dict + dst_pos, d->m_pSrc, n); if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) memcpy(d->m_dict + TDEFL_LZ_DICT_SIZE + dst_pos, d->m_pSrc, MZ_MIN(n, (TDEFL_MAX_MATCH_LEN - 1) - dst_pos)); d->m_pSrc += n; dst_pos = (dst_pos + n) & TDEFL_LZ_DICT_SIZE_MASK; num_bytes_to_process -= n; } dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - lookahead_size, dict_size); if ((!d->m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE)) break; while (lookahead_size >= 4) { mz_uint cur_match_dist, cur_match_len = 1; mz_uint8 *pCur_dict = d->m_dict + cur_pos; mz_uint first_trigram = (*(const mz_uint32 *)pCur_dict) & 0xFFFFFF; mz_uint hash = (first_trigram ^ (first_trigram >> (24 - (TDEFL_LZ_HASH_BITS - 8)))) & TDEFL_LEVEL1_HASH_SIZE_MASK; mz_uint probe_pos = d->m_hash[hash]; d->m_hash[hash] = (mz_uint16)lookahead_pos; if (((cur_match_dist = (mz_uint16)(lookahead_pos - probe_pos)) <= dict_size) && ((*(const mz_uint32 *)(d->m_dict + (probe_pos &= TDEFL_LZ_DICT_SIZE_MASK)) & 0xFFFFFF) == first_trigram)) { const mz_uint16 *p = (const mz_uint16 *)pCur_dict; const mz_uint16 *q = (const mz_uint16 *)(d->m_dict + probe_pos); mz_uint32 probe_len = 32; do { } while ((TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0)); cur_match_len = ((mz_uint)(p - (const mz_uint16 *)pCur_dict) * 2) + (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q); if (!probe_len) cur_match_len = cur_match_dist ? TDEFL_MAX_MATCH_LEN : 0; if ((cur_match_len < TDEFL_MIN_MATCH_LEN) || ((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U * 1024U))) { cur_match_len = 1; *pLZ_code_buf++ = (mz_uint8)first_trigram; *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); d->m_huff_count[0][(mz_uint8)first_trigram]++; } else { mz_uint32 s0, s1; cur_match_len = MZ_MIN(cur_match_len, lookahead_size); MZ_ASSERT((cur_match_len >= TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 1) && (cur_match_dist <= TDEFL_LZ_DICT_SIZE)); cur_match_dist--; pLZ_code_buf[0] = (mz_uint8)(cur_match_len - TDEFL_MIN_MATCH_LEN); *(mz_uint16 *)(&pLZ_code_buf[1]) = (mz_uint16)cur_match_dist; pLZ_code_buf += 3; *pLZ_flags = (mz_uint8)((*pLZ_flags >> 1) | 0x80); s0 = s_tdefl_small_dist_sym[cur_match_dist & 511]; s1 = s_tdefl_large_dist_sym[cur_match_dist >> 8]; d->m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++; d->m_huff_count[0][s_tdefl_len_sym[cur_match_len - TDEFL_MIN_MATCH_LEN]]++; } } else { *pLZ_code_buf++ = (mz_uint8)first_trigram; *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); d->m_huff_count[0][(mz_uint8)first_trigram]++; } if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; } total_lz_bytes += cur_match_len; lookahead_pos += cur_match_len; dict_size = MZ_MIN(dict_size + cur_match_len, TDEFL_LZ_DICT_SIZE); cur_pos = (cur_pos + cur_match_len) & TDEFL_LZ_DICT_SIZE_MASK; MZ_ASSERT(lookahead_size >= cur_match_len); lookahead_size -= cur_match_len; if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) { int n; d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; if ((n = tdefl_flush_block(d, 0)) != 0) return (n < 0) ? MZ_FALSE : MZ_TRUE; total_lz_bytes = d->m_total_lz_bytes; pLZ_code_buf = d->m_pLZ_code_buf; pLZ_flags = d->m_pLZ_flags; num_flags_left = d->m_num_flags_left; } } while (lookahead_size) { mz_uint8 lit = d->m_dict[cur_pos]; total_lz_bytes++; *pLZ_code_buf++ = lit; *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; } d->m_huff_count[0][lit]++; lookahead_pos++; dict_size = MZ_MIN(dict_size + 1, TDEFL_LZ_DICT_SIZE); cur_pos = (cur_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; lookahead_size--; if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) { int n; d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; if ((n = tdefl_flush_block(d, 0)) != 0) return (n < 0) ? MZ_FALSE : MZ_TRUE; total_lz_bytes = d->m_total_lz_bytes; pLZ_code_buf = d->m_pLZ_code_buf; pLZ_flags = d->m_pLZ_flags; num_flags_left = d->m_num_flags_left; } } } d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; return MZ_TRUE; } #endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN static MZ_FORCEINLINE void tdefl_record_literal(tdefl_compressor *d, mz_uint8 lit) { d->m_total_lz_bytes++; *d->m_pLZ_code_buf++ = lit; *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> 1); if (--d->m_num_flags_left == 0) { d->m_num_flags_left = 8; d->m_pLZ_flags = d->m_pLZ_code_buf++; } d->m_huff_count[0][lit]++; } static MZ_FORCEINLINE void tdefl_record_match(tdefl_compressor *d, mz_uint match_len, mz_uint match_dist) { mz_uint32 s0, s1; MZ_ASSERT((match_len >= TDEFL_MIN_MATCH_LEN) && (match_dist >= 1) && (match_dist <= TDEFL_LZ_DICT_SIZE)); d->m_total_lz_bytes += match_len; d->m_pLZ_code_buf[0] = (mz_uint8)(match_len - TDEFL_MIN_MATCH_LEN); match_dist -= 1; d->m_pLZ_code_buf[1] = (mz_uint8)(match_dist & 0xFF); d->m_pLZ_code_buf[2] = (mz_uint8)(match_dist >> 8); d->m_pLZ_code_buf += 3; *d->m_pLZ_flags = (mz_uint8)((*d->m_pLZ_flags >> 1) | 0x80); if (--d->m_num_flags_left == 0) { d->m_num_flags_left = 8; d->m_pLZ_flags = d->m_pLZ_code_buf++; } s0 = s_tdefl_small_dist_sym[match_dist & 511]; s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127]; d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++; if (match_len >= TDEFL_MIN_MATCH_LEN) d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++; } static mz_bool tdefl_compress_normal(tdefl_compressor *d) { const mz_uint8 *pSrc = d->m_pSrc; size_t src_buf_left = d->m_src_buf_left; tdefl_flush flush = d->m_flush; while ((src_buf_left) || ((flush) && (d->m_lookahead_size))) { mz_uint len_to_move, cur_match_dist, cur_match_len, cur_pos; // Update dictionary and hash chains. Keeps the lookahead size equal to // TDEFL_MAX_MATCH_LEN. if ((d->m_lookahead_size + d->m_dict_size) >= (TDEFL_MIN_MATCH_LEN - 1)) { mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK, ins_pos = d->m_lookahead_pos + d->m_lookahead_size - 2; mz_uint hash = (d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK]; mz_uint num_bytes_to_process = (mz_uint)MZ_MIN( src_buf_left, TDEFL_MAX_MATCH_LEN - d->m_lookahead_size); const mz_uint8 *pSrc_end = pSrc + num_bytes_to_process; src_buf_left -= num_bytes_to_process; d->m_lookahead_size += num_bytes_to_process; while (pSrc != pSrc_end) { mz_uint8 c = *pSrc++; d->m_dict[dst_pos] = c; if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c; hash = ((hash << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1); d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; d->m_hash[hash] = (mz_uint16)(ins_pos); dst_pos = (dst_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; ins_pos++; } } else { while ((src_buf_left) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) { mz_uint8 c = *pSrc++; mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK; src_buf_left--; d->m_dict[dst_pos] = c; if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c; if ((++d->m_lookahead_size + d->m_dict_size) >= TDEFL_MIN_MATCH_LEN) { mz_uint ins_pos = d->m_lookahead_pos + (d->m_lookahead_size - 1) - 2; mz_uint hash = ((d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << (TDEFL_LZ_HASH_SHIFT * 2)) ^ (d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1); d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; d->m_hash[hash] = (mz_uint16)(ins_pos); } } } d->m_dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - d->m_lookahead_size, d->m_dict_size); if ((!flush) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) break; // Simple lazy/greedy parsing state machine. len_to_move = 1; cur_match_dist = 0; cur_match_len = d->m_saved_match_len ? d->m_saved_match_len : (TDEFL_MIN_MATCH_LEN - 1); cur_pos = d->m_lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; if (d->m_flags & (TDEFL_RLE_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS)) { if ((d->m_dict_size) && (!(d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))) { mz_uint8 c = d->m_dict[(cur_pos - 1) & TDEFL_LZ_DICT_SIZE_MASK]; cur_match_len = 0; while (cur_match_len < d->m_lookahead_size) { if (d->m_dict[cur_pos + cur_match_len] != c) break; cur_match_len++; } if (cur_match_len < TDEFL_MIN_MATCH_LEN) cur_match_len = 0; else cur_match_dist = 1; } } else { tdefl_find_match(d, d->m_lookahead_pos, d->m_dict_size, d->m_lookahead_size, &cur_match_dist, &cur_match_len); } if (((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U * 1024U)) || (cur_pos == cur_match_dist) || ((d->m_flags & TDEFL_FILTER_MATCHES) && (cur_match_len <= 5))) { cur_match_dist = cur_match_len = 0; } if (d->m_saved_match_len) { if (cur_match_len > d->m_saved_match_len) { tdefl_record_literal(d, (mz_uint8)d->m_saved_lit); if (cur_match_len >= 128) { tdefl_record_match(d, cur_match_len, cur_match_dist); d->m_saved_match_len = 0; len_to_move = cur_match_len; } else { d->m_saved_lit = d->m_dict[cur_pos]; d->m_saved_match_dist = cur_match_dist; d->m_saved_match_len = cur_match_len; } } else { tdefl_record_match(d, d->m_saved_match_len, d->m_saved_match_dist); len_to_move = d->m_saved_match_len - 1; d->m_saved_match_len = 0; } } else if (!cur_match_dist) tdefl_record_literal(d, d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]); else if ((d->m_greedy_parsing) || (d->m_flags & TDEFL_RLE_MATCHES) || (cur_match_len >= 128)) { tdefl_record_match(d, cur_match_len, cur_match_dist); len_to_move = cur_match_len; } else { d->m_saved_lit = d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]; d->m_saved_match_dist = cur_match_dist; d->m_saved_match_len = cur_match_len; } // Move the lookahead forward by len_to_move bytes. d->m_lookahead_pos += len_to_move; MZ_ASSERT(d->m_lookahead_size >= len_to_move); d->m_lookahead_size -= len_to_move; d->m_dict_size = MZ_MIN(d->m_dict_size + len_to_move, (mz_uint)TDEFL_LZ_DICT_SIZE); // Check if it's time to flush the current LZ codes to the internal output // buffer. if ((d->m_pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) || ((d->m_total_lz_bytes > 31 * 1024) && (((((mz_uint)(d->m_pLZ_code_buf - d->m_lz_code_buf) * 115) >> 7) >= d->m_total_lz_bytes) || (d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS)))) { int n; d->m_pSrc = pSrc; d->m_src_buf_left = src_buf_left; if ((n = tdefl_flush_block(d, 0)) != 0) return (n < 0) ? MZ_FALSE : MZ_TRUE; } } d->m_pSrc = pSrc; d->m_src_buf_left = src_buf_left; return MZ_TRUE; } static tdefl_status tdefl_flush_output_buffer(tdefl_compressor *d) { if (d->m_pIn_buf_size) { *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf; } if (d->m_pOut_buf_size) { size_t n = MZ_MIN(*d->m_pOut_buf_size - d->m_out_buf_ofs, d->m_output_flush_remaining); memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf + d->m_output_flush_ofs, n); d->m_output_flush_ofs += (mz_uint)n; d->m_output_flush_remaining -= (mz_uint)n; d->m_out_buf_ofs += n; *d->m_pOut_buf_size = d->m_out_buf_ofs; } return (d->m_finished && !d->m_output_flush_remaining) ? TDEFL_STATUS_DONE : TDEFL_STATUS_OKAY; } tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush) { if (!d) { if (pIn_buf_size) *pIn_buf_size = 0; if (pOut_buf_size) *pOut_buf_size = 0; return TDEFL_STATUS_BAD_PARAM; } d->m_pIn_buf = pIn_buf; d->m_pIn_buf_size = pIn_buf_size; d->m_pOut_buf = pOut_buf; d->m_pOut_buf_size = pOut_buf_size; d->m_pSrc = (const mz_uint8 *)(pIn_buf); d->m_src_buf_left = pIn_buf_size ? *pIn_buf_size : 0; d->m_out_buf_ofs = 0; d->m_flush = flush; if (((d->m_pPut_buf_func != NULL) == ((pOut_buf != NULL) || (pOut_buf_size != NULL))) || (d->m_prev_return_status != TDEFL_STATUS_OKAY) || (d->m_wants_to_finish && (flush != TDEFL_FINISH)) || (pIn_buf_size && *pIn_buf_size && !pIn_buf) || (pOut_buf_size && *pOut_buf_size && !pOut_buf)) { if (pIn_buf_size) *pIn_buf_size = 0; if (pOut_buf_size) *pOut_buf_size = 0; return (d->m_prev_return_status = TDEFL_STATUS_BAD_PARAM); } d->m_wants_to_finish |= (flush == TDEFL_FINISH); if ((d->m_output_flush_remaining) || (d->m_finished)) return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN if (((d->m_flags & TDEFL_MAX_PROBES_MASK) == 1) && ((d->m_flags & TDEFL_GREEDY_PARSING_FLAG) != 0) && ((d->m_flags & (TDEFL_FILTER_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS | TDEFL_RLE_MATCHES)) == 0)) { if (!tdefl_compress_fast(d)) return d->m_prev_return_status; } else #endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN { if (!tdefl_compress_normal(d)) return d->m_prev_return_status; } if ((d->m_flags & (TDEFL_WRITE_ZLIB_HEADER | TDEFL_COMPUTE_ADLER32)) && (pIn_buf)) d->m_adler32 = (mz_uint32)mz_adler32(d->m_adler32, (const mz_uint8 *)pIn_buf, d->m_pSrc - (const mz_uint8 *)pIn_buf); if ((flush) && (!d->m_lookahead_size) && (!d->m_src_buf_left) && (!d->m_output_flush_remaining)) { if (tdefl_flush_block(d, flush) < 0) return d->m_prev_return_status; d->m_finished = (flush == TDEFL_FINISH); if (flush == TDEFL_FULL_FLUSH) { MZ_CLEAR_OBJ(d->m_hash); MZ_CLEAR_OBJ(d->m_next); d->m_dict_size = 0; } } return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); } tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush) { MZ_ASSERT(d->m_pPut_buf_func); return tdefl_compress(d, pIn_buf, &in_buf_size, NULL, NULL, flush); } tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) { d->m_pPut_buf_func = pPut_buf_func; d->m_pPut_buf_user = pPut_buf_user; d->m_flags = (mz_uint)(flags); d->m_max_probes[0] = 1 + ((flags & 0xFFF) + 2) / 3; d->m_greedy_parsing = (flags & TDEFL_GREEDY_PARSING_FLAG) != 0; d->m_max_probes[1] = 1 + (((flags & 0xFFF) >> 2) + 2) / 3; if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG)) MZ_CLEAR_OBJ(d->m_hash); d->m_lookahead_pos = d->m_lookahead_size = d->m_dict_size = d->m_total_lz_bytes = d->m_lz_code_buf_dict_pos = d->m_bits_in = 0; d->m_output_flush_ofs = d->m_output_flush_remaining = d->m_finished = d->m_block_index = d->m_bit_buffer = d->m_wants_to_finish = 0; d->m_pLZ_code_buf = d->m_lz_code_buf + 1; d->m_pLZ_flags = d->m_lz_code_buf; d->m_num_flags_left = 8; d->m_pOutput_buf = d->m_output_buf; d->m_pOutput_buf_end = d->m_output_buf; d->m_prev_return_status = TDEFL_STATUS_OKAY; d->m_saved_match_dist = d->m_saved_match_len = d->m_saved_lit = 0; d->m_adler32 = 1; d->m_pIn_buf = NULL; d->m_pOut_buf = NULL; d->m_pIn_buf_size = NULL; d->m_pOut_buf_size = NULL; d->m_flush = TDEFL_NO_FLUSH; d->m_pSrc = NULL; d->m_src_buf_left = 0; d->m_out_buf_ofs = 0; memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0); memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1); return TDEFL_STATUS_OKAY; } tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d) { return d->m_prev_return_status; } mz_uint32 tdefl_get_adler32(tdefl_compressor *d) { return d->m_adler32; } mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) { tdefl_compressor *pComp; mz_bool succeeded; if (((buf_len) && (!pBuf)) || (!pPut_buf_func)) return MZ_FALSE; pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); if (!pComp) return MZ_FALSE; succeeded = (tdefl_init(pComp, pPut_buf_func, pPut_buf_user, flags) == TDEFL_STATUS_OKAY); succeeded = succeeded && (tdefl_compress_buffer(pComp, pBuf, buf_len, TDEFL_FINISH) == TDEFL_STATUS_DONE); MZ_FREE(pComp); return succeeded; } typedef struct { size_t m_size, m_capacity; mz_uint8 *m_pBuf; mz_bool m_expandable; } tdefl_output_buffer; static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len, void *pUser) { tdefl_output_buffer *p = (tdefl_output_buffer *)pUser; size_t new_size = p->m_size + len; if (new_size > p->m_capacity) { size_t new_capacity = p->m_capacity; mz_uint8 *pNew_buf; if (!p->m_expandable) return MZ_FALSE; do { new_capacity = MZ_MAX(128U, new_capacity << 1U); } while (new_size > new_capacity); pNew_buf = (mz_uint8 *)MZ_REALLOC(p->m_pBuf, new_capacity); if (!pNew_buf) return MZ_FALSE; p->m_pBuf = pNew_buf; p->m_capacity = new_capacity; } memcpy((mz_uint8 *)p->m_pBuf + p->m_size, pBuf, len); p->m_size = new_size; return MZ_TRUE; } void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags) { tdefl_output_buffer out_buf; MZ_CLEAR_OBJ(out_buf); if (!pOut_len) return MZ_FALSE; else *pOut_len = 0; out_buf.m_expandable = MZ_TRUE; if (!tdefl_compress_mem_to_output( pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) return NULL; *pOut_len = out_buf.m_size; return out_buf.m_pBuf; } size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags) { tdefl_output_buffer out_buf; MZ_CLEAR_OBJ(out_buf); if (!pOut_buf) return 0; out_buf.m_pBuf = (mz_uint8 *)pOut_buf; out_buf.m_capacity = out_buf_len; if (!tdefl_compress_mem_to_output( pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) return 0; return out_buf.m_size; } #ifndef MINIZ_NO_ZLIB_APIS static const mz_uint s_tdefl_num_probes[11] = {0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500}; // level may actually range from [0,10] (10 is a "hidden" max level, where we // want a bit more compression and it's fine if throughput to fall off a cliff // on some files). mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy) { mz_uint comp_flags = s_tdefl_num_probes[(level >= 0) ? MZ_MIN(10, level) : MZ_DEFAULT_LEVEL] | ((level <= 3) ? TDEFL_GREEDY_PARSING_FLAG : 0); if (window_bits > 0) comp_flags |= TDEFL_WRITE_ZLIB_HEADER; if (!level) comp_flags |= TDEFL_FORCE_ALL_RAW_BLOCKS; else if (strategy == MZ_FILTERED) comp_flags |= TDEFL_FILTER_MATCHES; else if (strategy == MZ_HUFFMAN_ONLY) comp_flags &= ~TDEFL_MAX_PROBES_MASK; else if (strategy == MZ_FIXED) comp_flags |= TDEFL_FORCE_ALL_STATIC_BLOCKS; else if (strategy == MZ_RLE) comp_flags |= TDEFL_RLE_MATCHES; return comp_flags; } #endif // MINIZ_NO_ZLIB_APIS #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4204) // nonstandard extension used : non-constant // aggregate initializer (also supported by GNU // C and C99, so no big deal) #pragma warning(disable : 4244) // 'initializing': conversion from '__int64' to // 'int', possible loss of data #pragma warning( \ disable : 4267) // 'argument': conversion from '__int64' to 'int', // possible loss of data #pragma warning(disable : 4996) // 'strdup': The POSIX name for this item is // deprecated. Instead, use the ISO C and C++ // conformant name: _strdup. #endif // Simple PNG writer function by Alex Evans, 2011. Released into the public // domain: https://gist.github.com/908299, more context at // http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/. // This is actually a modification of Alex's original code so PNG files // generated by this function pass pngcheck. void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip) { // Using a local copy of this array here in case MINIZ_NO_ZLIB_APIS was // defined. static const mz_uint s_tdefl_png_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500}; tdefl_compressor *pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); tdefl_output_buffer out_buf; int i, bpl = w * num_chans, y, z; mz_uint32 c; *pLen_out = 0; if (!pComp) return NULL; MZ_CLEAR_OBJ(out_buf); out_buf.m_expandable = MZ_TRUE; out_buf.m_capacity = 57 + MZ_MAX(64, (1 + bpl) * h); if (NULL == (out_buf.m_pBuf = (mz_uint8 *)MZ_MALLOC(out_buf.m_capacity))) { MZ_FREE(pComp); return NULL; } // write dummy header for (z = 41; z; --z) tdefl_output_buffer_putter(&z, 1, &out_buf); // compress image data tdefl_init( pComp, tdefl_output_buffer_putter, &out_buf, s_tdefl_png_num_probes[MZ_MIN(10, level)] | TDEFL_WRITE_ZLIB_HEADER); for (y = 0; y < h; ++y) { tdefl_compress_buffer(pComp, &z, 1, TDEFL_NO_FLUSH); tdefl_compress_buffer(pComp, (mz_uint8 *)pImage + (flip ? (h - 1 - y) : y) * bpl, bpl, TDEFL_NO_FLUSH); } if (tdefl_compress_buffer(pComp, NULL, 0, TDEFL_FINISH) != TDEFL_STATUS_DONE) { MZ_FREE(pComp); MZ_FREE(out_buf.m_pBuf); return NULL; } // write real header *pLen_out = out_buf.m_size - 41; { static const mz_uint8 chans[] = {0x00, 0x00, 0x04, 0x02, 0x06}; mz_uint8 pnghdr[41] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0, 0, (mz_uint8)(w >> 8), (mz_uint8)w, 0, 0, (mz_uint8)(h >> 8), (mz_uint8)h, 8, chans[num_chans], 0, 0, 0, 0, 0, 0, 0, (mz_uint8)(*pLen_out >> 24), (mz_uint8)(*pLen_out >> 16), (mz_uint8)(*pLen_out >> 8), (mz_uint8)*pLen_out, 0x49, 0x44, 0x41, 0x54}; c = (mz_uint32)mz_crc32(MZ_CRC32_INIT, pnghdr + 12, 17); for (i = 0; i < 4; ++i, c <<= 8) ((mz_uint8 *)(pnghdr + 29))[i] = (mz_uint8)(c >> 24); memcpy(out_buf.m_pBuf, pnghdr, 41); } // write footer (IDAT CRC-32, followed by IEND chunk) if (!tdefl_output_buffer_putter( "\0\0\0\0\0\0\0\0\x49\x45\x4e\x44\xae\x42\x60\x82", 16, &out_buf)) { *pLen_out = 0; MZ_FREE(pComp); MZ_FREE(out_buf.m_pBuf); return NULL; } c = (mz_uint32)mz_crc32(MZ_CRC32_INIT, out_buf.m_pBuf + 41 - 4, *pLen_out + 4); for (i = 0; i < 4; ++i, c <<= 8) (out_buf.m_pBuf + out_buf.m_size - 16)[i] = (mz_uint8)(c >> 24); // compute final size of file, grab compressed data buffer and return *pLen_out += 57; MZ_FREE(pComp); return out_buf.m_pBuf; } void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out) { // Level 6 corresponds to TDEFL_DEFAULT_MAX_PROBES or MZ_DEFAULT_LEVEL (but we // can't depend on MZ_DEFAULT_LEVEL being available in case the zlib API's // where #defined out) return tdefl_write_image_to_png_file_in_memory_ex(pImage, w, h, num_chans, pLen_out, 6, MZ_FALSE); } // ------------------- .ZIP archive reading #ifndef MINIZ_NO_ARCHIVE_APIS #error "No arvhive APIs" #ifdef MINIZ_NO_STDIO #define MZ_FILE void * #else #include #include #if defined(_MSC_VER) || defined(__MINGW64__) static FILE *mz_fopen(const char *pFilename, const char *pMode) { FILE *pFile = NULL; fopen_s(&pFile, pFilename, pMode); return pFile; } static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream) { FILE *pFile = NULL; if (freopen_s(&pFile, pPath, pMode, pStream)) return NULL; return pFile; } #ifndef MINIZ_NO_TIME #include #endif #define MZ_FILE FILE #define MZ_FOPEN mz_fopen #define MZ_FCLOSE fclose #define MZ_FREAD fread #define MZ_FWRITE fwrite #define MZ_FTELL64 _ftelli64 #define MZ_FSEEK64 _fseeki64 #define MZ_FILE_STAT_STRUCT _stat #define MZ_FILE_STAT _stat #define MZ_FFLUSH fflush #define MZ_FREOPEN mz_freopen #define MZ_DELETE_FILE remove #elif defined(__MINGW32__) #ifndef MINIZ_NO_TIME #include #endif #define MZ_FILE FILE #define MZ_FOPEN(f, m) fopen(f, m) #define MZ_FCLOSE fclose #define MZ_FREAD fread #define MZ_FWRITE fwrite #define MZ_FTELL64 ftello64 #define MZ_FSEEK64 fseeko64 #define MZ_FILE_STAT_STRUCT _stat #define MZ_FILE_STAT _stat #define MZ_FFLUSH fflush #define MZ_FREOPEN(f, m, s) freopen(f, m, s) #define MZ_DELETE_FILE remove #elif defined(__TINYC__) #ifndef MINIZ_NO_TIME #include #endif #define MZ_FILE FILE #define MZ_FOPEN(f, m) fopen(f, m) #define MZ_FCLOSE fclose #define MZ_FREAD fread #define MZ_FWRITE fwrite #define MZ_FTELL64 ftell #define MZ_FSEEK64 fseek #define MZ_FILE_STAT_STRUCT stat #define MZ_FILE_STAT stat #define MZ_FFLUSH fflush #define MZ_FREOPEN(f, m, s) freopen(f, m, s) #define MZ_DELETE_FILE remove #elif defined(__GNUC__) && defined(_LARGEFILE64_SOURCE) && _LARGEFILE64_SOURCE #ifndef MINIZ_NO_TIME #include #endif #define MZ_FILE FILE #define MZ_FOPEN(f, m) fopen64(f, m) #define MZ_FCLOSE fclose #define MZ_FREAD fread #define MZ_FWRITE fwrite #define MZ_FTELL64 ftello64 #define MZ_FSEEK64 fseeko64 #define MZ_FILE_STAT_STRUCT stat64 #define MZ_FILE_STAT stat64 #define MZ_FFLUSH fflush #define MZ_FREOPEN(p, m, s) freopen64(p, m, s) #define MZ_DELETE_FILE remove #else #ifndef MINIZ_NO_TIME #include #endif #define MZ_FILE FILE #define MZ_FOPEN(f, m) fopen(f, m) #define MZ_FCLOSE fclose #define MZ_FREAD fread #define MZ_FWRITE fwrite #define MZ_FTELL64 ftello #define MZ_FSEEK64 fseeko #define MZ_FILE_STAT_STRUCT stat #define MZ_FILE_STAT stat #define MZ_FFLUSH fflush #define MZ_FREOPEN(f, m, s) freopen(f, m, s) #define MZ_DELETE_FILE remove #endif // #ifdef _MSC_VER #endif // #ifdef MINIZ_NO_STDIO #define MZ_TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c)) // Various ZIP archive enums. To completely avoid cross platform compiler // alignment and platform endian issues, miniz.c doesn't use structs for any of // this stuff. enum { // ZIP archive identifiers and record sizes MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06054b50, MZ_ZIP_CENTRAL_DIR_HEADER_SIG = 0x02014b50, MZ_ZIP_LOCAL_DIR_HEADER_SIG = 0x04034b50, MZ_ZIP_LOCAL_DIR_HEADER_SIZE = 30, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE = 46, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE = 22, // Central directory header record offsets MZ_ZIP_CDH_SIG_OFS = 0, MZ_ZIP_CDH_VERSION_MADE_BY_OFS = 4, MZ_ZIP_CDH_VERSION_NEEDED_OFS = 6, MZ_ZIP_CDH_BIT_FLAG_OFS = 8, MZ_ZIP_CDH_METHOD_OFS = 10, MZ_ZIP_CDH_FILE_TIME_OFS = 12, MZ_ZIP_CDH_FILE_DATE_OFS = 14, MZ_ZIP_CDH_CRC32_OFS = 16, MZ_ZIP_CDH_COMPRESSED_SIZE_OFS = 20, MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS = 24, MZ_ZIP_CDH_FILENAME_LEN_OFS = 28, MZ_ZIP_CDH_EXTRA_LEN_OFS = 30, MZ_ZIP_CDH_COMMENT_LEN_OFS = 32, MZ_ZIP_CDH_DISK_START_OFS = 34, MZ_ZIP_CDH_INTERNAL_ATTR_OFS = 36, MZ_ZIP_CDH_EXTERNAL_ATTR_OFS = 38, MZ_ZIP_CDH_LOCAL_HEADER_OFS = 42, // Local directory header offsets MZ_ZIP_LDH_SIG_OFS = 0, MZ_ZIP_LDH_VERSION_NEEDED_OFS = 4, MZ_ZIP_LDH_BIT_FLAG_OFS = 6, MZ_ZIP_LDH_METHOD_OFS = 8, MZ_ZIP_LDH_FILE_TIME_OFS = 10, MZ_ZIP_LDH_FILE_DATE_OFS = 12, MZ_ZIP_LDH_CRC32_OFS = 14, MZ_ZIP_LDH_COMPRESSED_SIZE_OFS = 18, MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS = 22, MZ_ZIP_LDH_FILENAME_LEN_OFS = 26, MZ_ZIP_LDH_EXTRA_LEN_OFS = 28, // End of central directory offsets MZ_ZIP_ECDH_SIG_OFS = 0, MZ_ZIP_ECDH_NUM_THIS_DISK_OFS = 4, MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS = 6, MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS = 8, MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS = 10, MZ_ZIP_ECDH_CDIR_SIZE_OFS = 12, MZ_ZIP_ECDH_CDIR_OFS_OFS = 16, MZ_ZIP_ECDH_COMMENT_SIZE_OFS = 20, }; typedef struct { void *m_p; size_t m_size, m_capacity; mz_uint m_element_size; } mz_zip_array; struct mz_zip_internal_state_tag { mz_zip_array m_central_dir; mz_zip_array m_central_dir_offsets; mz_zip_array m_sorted_central_dir_offsets; MZ_FILE *m_pFile; void *m_pMem; size_t m_mem_size; size_t m_mem_capacity; }; #define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) \ (array_ptr)->m_element_size = element_size #define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) \ ((element_type *)((array_ptr)->m_p))[index] static MZ_FORCEINLINE void mz_zip_array_clear(mz_zip_archive *pZip, mz_zip_array *pArray) { pZip->m_pFree(pZip->m_pAlloc_opaque, pArray->m_p); memset(pArray, 0, sizeof(mz_zip_array)); } static mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip, mz_zip_array *pArray, size_t min_new_capacity, mz_uint growing) { void *pNew_p; size_t new_capacity = min_new_capacity; MZ_ASSERT(pArray->m_element_size); if (pArray->m_capacity >= min_new_capacity) return MZ_TRUE; if (growing) { new_capacity = MZ_MAX(1, pArray->m_capacity); while (new_capacity < min_new_capacity) new_capacity *= 2; } if (NULL == (pNew_p = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pArray->m_p, pArray->m_element_size, new_capacity))) return MZ_FALSE; pArray->m_p = pNew_p; pArray->m_capacity = new_capacity; return MZ_TRUE; } static MZ_FORCEINLINE mz_bool mz_zip_array_reserve(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_capacity, mz_uint growing) { if (new_capacity > pArray->m_capacity) { if (!mz_zip_array_ensure_capacity(pZip, pArray, new_capacity, growing)) return MZ_FALSE; } return MZ_TRUE; } static MZ_FORCEINLINE mz_bool mz_zip_array_resize(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_size, mz_uint growing) { if (new_size > pArray->m_capacity) { if (!mz_zip_array_ensure_capacity(pZip, pArray, new_size, growing)) return MZ_FALSE; } pArray->m_size = new_size; return MZ_TRUE; } static MZ_FORCEINLINE mz_bool mz_zip_array_ensure_room(mz_zip_archive *pZip, mz_zip_array *pArray, size_t n) { return mz_zip_array_reserve(pZip, pArray, pArray->m_size + n, MZ_TRUE); } static MZ_FORCEINLINE mz_bool mz_zip_array_push_back(mz_zip_archive *pZip, mz_zip_array *pArray, const void *pElements, size_t n) { size_t orig_size = pArray->m_size; if (!mz_zip_array_resize(pZip, pArray, orig_size + n, MZ_TRUE)) return MZ_FALSE; memcpy((mz_uint8 *)pArray->m_p + orig_size * pArray->m_element_size, pElements, n * pArray->m_element_size); return MZ_TRUE; } #ifndef MINIZ_NO_TIME static time_t mz_zip_dos_to_time_t(int dos_time, int dos_date) { struct tm tm; memset(&tm, 0, sizeof(tm)); tm.tm_isdst = -1; tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900; tm.tm_mon = ((dos_date >> 5) & 15) - 1; tm.tm_mday = dos_date & 31; tm.tm_hour = (dos_time >> 11) & 31; tm.tm_min = (dos_time >> 5) & 63; tm.tm_sec = (dos_time << 1) & 62; return mktime(&tm); } static void mz_zip_time_to_dos_time(time_t time, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date) { #ifdef _MSC_VER struct tm tm_struct; struct tm *tm = &tm_struct; errno_t err = localtime_s(tm, &time); if (err) { *pDOS_date = 0; *pDOS_time = 0; return; } #else struct tm *tm = localtime(&time); #endif *pDOS_time = (mz_uint16)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) + ((tm->tm_sec) >> 1)); *pDOS_date = (mz_uint16)(((tm->tm_year + 1900 - 1980) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday); } #endif #ifndef MINIZ_NO_STDIO static mz_bool mz_zip_get_file_modified_time(const char *pFilename, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date) { #ifdef MINIZ_NO_TIME (void)pFilename; *pDOS_date = *pDOS_time = 0; #else struct MZ_FILE_STAT_STRUCT file_stat; // On Linux with x86 glibc, this call will fail on large files (>= 0x80000000 // bytes) unless you compiled with _LARGEFILE64_SOURCE. Argh. if (MZ_FILE_STAT(pFilename, &file_stat) != 0) return MZ_FALSE; mz_zip_time_to_dos_time(file_stat.st_mtime, pDOS_time, pDOS_date); #endif // #ifdef MINIZ_NO_TIME return MZ_TRUE; } #ifndef MINIZ_NO_TIME static mz_bool mz_zip_set_file_times(const char *pFilename, time_t access_time, time_t modified_time) { struct utimbuf t; t.actime = access_time; t.modtime = modified_time; return !utime(pFilename, &t); } #endif // #ifndef MINIZ_NO_TIME #endif // #ifndef MINIZ_NO_STDIO static mz_bool mz_zip_reader_init_internal(mz_zip_archive *pZip, mz_uint32 flags) { (void)flags; if ((!pZip) || (pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID)) return MZ_FALSE; if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func; if (!pZip->m_pFree) pZip->m_pFree = def_free_func; if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func; pZip->m_zip_mode = MZ_ZIP_MODE_READING; pZip->m_archive_size = 0; pZip->m_central_directory_file_ofs = 0; pZip->m_total_files = 0; if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc( pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state)))) return MZ_FALSE; memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state)); MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8)); MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32)); MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32)); return MZ_TRUE; } static MZ_FORCEINLINE mz_bool mz_zip_reader_filename_less(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, mz_uint r_index) { const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT( pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE; const mz_uint8 *pR = &MZ_ZIP_ARRAY_ELEMENT( pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, r_index)); mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS), r_len = MZ_READ_LE16(pR + MZ_ZIP_CDH_FILENAME_LEN_OFS); mz_uint8 l = 0, r = 0; pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; pR += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; pE = pL + MZ_MIN(l_len, r_len); while (pL < pE) { if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) break; pL++; pR++; } return (pL == pE) ? (l_len < r_len) : (l < r); } #define MZ_SWAP_UINT32(a, b) \ do { \ mz_uint32 t = a; \ a = b; \ b = t; \ } \ MZ_MACRO_END // Heap sort of lowercased filenames, used to help accelerate plain central // directory searches by mz_zip_reader_locate_file(). (Could also use qsort(), // but it could allocate memory.) static void mz_zip_reader_sort_central_dir_offsets_by_filename( mz_zip_archive *pZip) { mz_zip_internal_state *pState = pZip->m_pState; const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets; const mz_zip_array *pCentral_dir = &pState->m_central_dir; mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT( &pState->m_sorted_central_dir_offsets, mz_uint32, 0); const int size = pZip->m_total_files; int start = (size - 2) >> 1, end; while (start >= 0) { int child, root = start; for (;;) { if ((child = (root << 1) + 1) >= size) break; child += (((child + 1) < size) && (mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1]))); if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child])) break; MZ_SWAP_UINT32(pIndices[root], pIndices[child]); root = child; } start--; } end = size - 1; while (end > 0) { int child, root = 0; MZ_SWAP_UINT32(pIndices[end], pIndices[0]); for (;;) { if ((child = (root << 1) + 1) >= end) break; child += (((child + 1) < end) && mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1])); if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child])) break; MZ_SWAP_UINT32(pIndices[root], pIndices[child]); root = child; } end--; } } static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint32 flags) { mz_uint cdir_size, num_this_disk, cdir_disk_index; mz_uint64 cdir_ofs; mz_int64 cur_file_ofs; const mz_uint8 *p; mz_uint32 buf_u32[4096 / sizeof(mz_uint32)]; mz_uint8 *pBuf = (mz_uint8 *)buf_u32; mz_bool sort_central_dir = ((flags & MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY) == 0); // Basic sanity checks - reject files which are too small, and check the first // 4 bytes of the file to make sure a local header is there. if (pZip->m_archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) return MZ_FALSE; // Find the end of central directory record by scanning the file from the end // towards the beginning. cur_file_ofs = MZ_MAX((mz_int64)pZip->m_archive_size - (mz_int64)sizeof(buf_u32), 0); for (;;) { int i, n = (int)MZ_MIN(sizeof(buf_u32), pZip->m_archive_size - cur_file_ofs); if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, n) != (mz_uint)n) return MZ_FALSE; for (i = n - 4; i >= 0; --i) if (MZ_READ_LE32(pBuf + i) == MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) break; if (i >= 0) { cur_file_ofs += i; break; } if ((!cur_file_ofs) || ((pZip->m_archive_size - cur_file_ofs) >= (0xFFFF + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE))) return MZ_FALSE; cur_file_ofs = MZ_MAX(cur_file_ofs - (sizeof(buf_u32) - 3), 0); } // Read and verify the end of central directory record. if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) return MZ_FALSE; if ((MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_SIG_OFS) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) || ((pZip->m_total_files = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS)) != MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS))) return MZ_FALSE; num_this_disk = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_THIS_DISK_OFS); cdir_disk_index = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS); if (((num_this_disk | cdir_disk_index) != 0) && ((num_this_disk != 1) || (cdir_disk_index != 1))) return MZ_FALSE; if ((cdir_size = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_SIZE_OFS)) < pZip->m_total_files * MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) return MZ_FALSE; cdir_ofs = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_OFS_OFS); if ((cdir_ofs + (mz_uint64)cdir_size) > pZip->m_archive_size) return MZ_FALSE; pZip->m_central_directory_file_ofs = cdir_ofs; if (pZip->m_total_files) { mz_uint i, n; // Read the entire central directory into a heap block, and allocate another // heap block to hold the unsorted central dir file record offsets, and // another to hold the sorted indices. if ((!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir, cdir_size, MZ_FALSE)) || (!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir_offsets, pZip->m_total_files, MZ_FALSE))) return MZ_FALSE; if (sort_central_dir) { if (!mz_zip_array_resize(pZip, &pZip->m_pState->m_sorted_central_dir_offsets, pZip->m_total_files, MZ_FALSE)) return MZ_FALSE; } if (pZip->m_pRead(pZip->m_pIO_opaque, cdir_ofs, pZip->m_pState->m_central_dir.m_p, cdir_size) != cdir_size) return MZ_FALSE; // Now create an index into the central directory file records, do some // basic sanity checking on each record, and check for zip64 entries (which // are not yet supported). p = (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p; for (n = cdir_size, i = 0; i < pZip->m_total_files; ++i) { mz_uint total_header_size, comp_size, decomp_size, disk_index; if ((n < MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) || (MZ_READ_LE32(p) != MZ_ZIP_CENTRAL_DIR_HEADER_SIG)) return MZ_FALSE; MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, i) = (mz_uint32)(p - (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p); if (sort_central_dir) MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_sorted_central_dir_offsets, mz_uint32, i) = i; comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); decomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); if (((!MZ_READ_LE32(p + MZ_ZIP_CDH_METHOD_OFS)) && (decomp_size != comp_size)) || (decomp_size && !comp_size) || (decomp_size == 0xFFFFFFFF) || (comp_size == 0xFFFFFFFF)) return MZ_FALSE; disk_index = MZ_READ_LE16(p + MZ_ZIP_CDH_DISK_START_OFS); if ((disk_index != num_this_disk) && (disk_index != 1)) return MZ_FALSE; if (((mz_uint64)MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS) + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + comp_size) > pZip->m_archive_size) return MZ_FALSE; if ((total_header_size = MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS)) > n) return MZ_FALSE; n -= total_header_size; p += total_header_size; } } if (sort_central_dir) mz_zip_reader_sort_central_dir_offsets_by_filename(pZip); return MZ_TRUE; } mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags) { if ((!pZip) || (!pZip->m_pRead)) return MZ_FALSE; if (!mz_zip_reader_init_internal(pZip, flags)) return MZ_FALSE; pZip->m_archive_size = size; if (!mz_zip_reader_read_central_dir(pZip, flags)) { mz_zip_reader_end(pZip); return MZ_FALSE; } return MZ_TRUE; } static size_t mz_zip_mem_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n) { mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; size_t s = (file_ofs >= pZip->m_archive_size) ? 0 : (size_t)MZ_MIN(pZip->m_archive_size - file_ofs, n); memcpy(pBuf, (const mz_uint8 *)pZip->m_pState->m_pMem + file_ofs, s); return s; } mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags) { if (!mz_zip_reader_init_internal(pZip, flags)) return MZ_FALSE; pZip->m_archive_size = size; pZip->m_pRead = mz_zip_mem_read_func; pZip->m_pIO_opaque = pZip; #ifdef __cplusplus pZip->m_pState->m_pMem = const_cast(pMem); #else pZip->m_pState->m_pMem = (void *)pMem; #endif pZip->m_pState->m_mem_size = size; if (!mz_zip_reader_read_central_dir(pZip, flags)) { mz_zip_reader_end(pZip); return MZ_FALSE; } return MZ_TRUE; } #ifndef MINIZ_NO_STDIO static size_t mz_zip_file_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n) { mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET)))) return 0; return MZ_FREAD(pBuf, 1, n, pZip->m_pState->m_pFile); } mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags) { mz_uint64 file_size; MZ_FILE *pFile = MZ_FOPEN(pFilename, "rb"); if (!pFile) return MZ_FALSE; if (MZ_FSEEK64(pFile, 0, SEEK_END)) { MZ_FCLOSE(pFile); return MZ_FALSE; } file_size = MZ_FTELL64(pFile); if (!mz_zip_reader_init_internal(pZip, flags)) { MZ_FCLOSE(pFile); return MZ_FALSE; } pZip->m_pRead = mz_zip_file_read_func; pZip->m_pIO_opaque = pZip; pZip->m_pState->m_pFile = pFile; pZip->m_archive_size = file_size; if (!mz_zip_reader_read_central_dir(pZip, flags)) { mz_zip_reader_end(pZip); return MZ_FALSE; } return MZ_TRUE; } #endif // #ifndef MINIZ_NO_STDIO mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip) { return pZip ? pZip->m_total_files : 0; } static MZ_FORCEINLINE const mz_uint8 *mz_zip_reader_get_cdh( mz_zip_archive *pZip, mz_uint file_index) { if ((!pZip) || (!pZip->m_pState) || (file_index >= pZip->m_total_files) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) return NULL; return &MZ_ZIP_ARRAY_ELEMENT( &pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index)); } mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index) { mz_uint m_bit_flag; const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); if (!p) return MZ_FALSE; m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); return (m_bit_flag & 1); } mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index) { mz_uint filename_len, external_attr; const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); if (!p) return MZ_FALSE; // First see if the filename ends with a '/' character. filename_len = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); if (filename_len) { if (*(p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_len - 1) == '/') return MZ_TRUE; } // Bugfix: This code was also checking if the internal attribute was non-zero, // which wasn't correct. // Most/all zip writers (hopefully) set DOS file/directory attributes in the // low 16-bits, so check for the DOS directory flag and ignore the source OS // ID in the created by field. // FIXME: Remove this check? Is it necessary - we already check the filename. external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS); if ((external_attr & 0x10) != 0) return MZ_TRUE; return MZ_FALSE; } mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat) { mz_uint n; const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); if ((!p) || (!pStat)) return MZ_FALSE; // Unpack the central directory record. pStat->m_file_index = file_index; pStat->m_central_dir_ofs = MZ_ZIP_ARRAY_ELEMENT( &pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index); pStat->m_version_made_by = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS); pStat->m_version_needed = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_NEEDED_OFS); pStat->m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); pStat->m_method = MZ_READ_LE16(p + MZ_ZIP_CDH_METHOD_OFS); #ifndef MINIZ_NO_TIME pStat->m_time = mz_zip_dos_to_time_t(MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_TIME_OFS), MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_DATE_OFS)); #endif pStat->m_crc32 = MZ_READ_LE32(p + MZ_ZIP_CDH_CRC32_OFS); pStat->m_comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); pStat->m_uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); pStat->m_internal_attr = MZ_READ_LE16(p + MZ_ZIP_CDH_INTERNAL_ATTR_OFS); pStat->m_external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS); pStat->m_local_header_ofs = MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS); // Copy as much of the filename and comment as possible. n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE - 1); memcpy(pStat->m_filename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); pStat->m_filename[n] = '\0'; n = MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS); n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE - 1); pStat->m_comment_size = n; memcpy(pStat->m_comment, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS), n); pStat->m_comment[n] = '\0'; return MZ_TRUE; } mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size) { mz_uint n; const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); if (!p) { if (filename_buf_size) pFilename[0] = '\0'; return 0; } n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); if (filename_buf_size) { n = MZ_MIN(n, filename_buf_size - 1); memcpy(pFilename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); pFilename[n] = '\0'; } return n + 1; } static MZ_FORCEINLINE mz_bool mz_zip_reader_string_equal(const char *pA, const char *pB, mz_uint len, mz_uint flags) { mz_uint i; if (flags & MZ_ZIP_FLAG_CASE_SENSITIVE) return 0 == memcmp(pA, pB, len); for (i = 0; i < len; ++i) if (MZ_TOLOWER(pA[i]) != MZ_TOLOWER(pB[i])) return MZ_FALSE; return MZ_TRUE; } static MZ_FORCEINLINE int mz_zip_reader_filename_compare( const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, const char *pR, mz_uint r_len) { const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT( pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE; mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS); mz_uint8 l = 0, r = 0; pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; pE = pL + MZ_MIN(l_len, r_len); while (pL < pE) { if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) break; pL++; pR++; } return (pL == pE) ? (int)(l_len - r_len) : (l - r); } static int mz_zip_reader_locate_file_binary_search(mz_zip_archive *pZip, const char *pFilename) { mz_zip_internal_state *pState = pZip->m_pState; const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets; const mz_zip_array *pCentral_dir = &pState->m_central_dir; mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT( &pState->m_sorted_central_dir_offsets, mz_uint32, 0); const int size = pZip->m_total_files; const mz_uint filename_len = (mz_uint)strlen(pFilename); int l = 0, h = size - 1; while (l <= h) { int m = (l + h) >> 1, file_index = pIndices[m], comp = mz_zip_reader_filename_compare(pCentral_dir, pCentral_dir_offsets, file_index, pFilename, filename_len); if (!comp) return file_index; else if (comp < 0) l = m + 1; else h = m - 1; } return -1; } int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags) { mz_uint file_index; size_t name_len, comment_len; if ((!pZip) || (!pZip->m_pState) || (!pName) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) return -1; if (((flags & (MZ_ZIP_FLAG_IGNORE_PATH | MZ_ZIP_FLAG_CASE_SENSITIVE)) == 0) && (!pComment) && (pZip->m_pState->m_sorted_central_dir_offsets.m_size)) return mz_zip_reader_locate_file_binary_search(pZip, pName); name_len = strlen(pName); if (name_len > 0xFFFF) return -1; comment_len = pComment ? strlen(pComment) : 0; if (comment_len > 0xFFFF) return -1; for (file_index = 0; file_index < pZip->m_total_files; file_index++) { const mz_uint8 *pHeader = &MZ_ZIP_ARRAY_ELEMENT( &pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index)); mz_uint filename_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_FILENAME_LEN_OFS); const char *pFilename = (const char *)pHeader + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; if (filename_len < name_len) continue; if (comment_len) { mz_uint file_extra_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_EXTRA_LEN_OFS), file_comment_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_COMMENT_LEN_OFS); const char *pFile_comment = pFilename + filename_len + file_extra_len; if ((file_comment_len != comment_len) || (!mz_zip_reader_string_equal(pComment, pFile_comment, file_comment_len, flags))) continue; } if ((flags & MZ_ZIP_FLAG_IGNORE_PATH) && (filename_len)) { int ofs = filename_len - 1; do { if ((pFilename[ofs] == '/') || (pFilename[ofs] == '\\') || (pFilename[ofs] == ':')) break; } while (--ofs >= 0); ofs++; pFilename += ofs; filename_len -= ofs; } if ((filename_len == name_len) && (mz_zip_reader_string_equal(pName, pFilename, filename_len, flags))) return file_index; } return -1; } mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) { int status = TINFL_STATUS_DONE; mz_uint64 needed_size, cur_file_ofs, comp_remaining, out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail; mz_zip_archive_file_stat file_stat; void *pRead_buf; mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; tinfl_decompressor inflator; if ((buf_size) && (!pBuf)) return MZ_FALSE; if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) return MZ_FALSE; // Empty file, or a directory (but not always a directory - I've seen odd zips // with directories that have compressed data which inflates to 0 bytes) if (!file_stat.m_comp_size) return MZ_TRUE; // Entry is a subdirectory (I've seen old zips with dir entries which have // compressed deflate data which inflates to 0 bytes, but these entries claim // to uncompress to 512 bytes in the headers). // I'm torn how to handle this case - should it fail instead? if (mz_zip_reader_is_file_a_directory(pZip, file_index)) return MZ_TRUE; // Encryption and patch files are not supported. if (file_stat.m_bit_flag & (1 | 32)) return MZ_FALSE; // This function only supports stored and deflate. if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED)) return MZ_FALSE; // Ensure supplied output buffer is large enough. needed_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? file_stat.m_comp_size : file_stat.m_uncomp_size; if (buf_size < needed_size) return MZ_FALSE; // Read and parse the local directory entry. cur_file_ofs = file_stat.m_local_header_ofs; if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) return MZ_FALSE; if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) return MZ_FALSE; cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size) return MZ_FALSE; if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) { // The file is stored or the caller has requested the compressed data. if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, (size_t)needed_size) != needed_size) return MZ_FALSE; return ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) != 0) || (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) == file_stat.m_crc32); } // Decompress the file either directly from memory or from a file input // buffer. tinfl_init(&inflator); if (pZip->m_pState->m_pMem) { // Read directly from the archive in memory. pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs; read_buf_size = read_buf_avail = file_stat.m_comp_size; comp_remaining = 0; } else if (pUser_read_buf) { // Use a user provided read buffer. if (!user_read_buf_size) return MZ_FALSE; pRead_buf = (mz_uint8 *)pUser_read_buf; read_buf_size = user_read_buf_size; read_buf_avail = 0; comp_remaining = file_stat.m_comp_size; } else { // Temporarily allocate a read buffer. read_buf_size = MZ_MIN(file_stat.m_comp_size, (mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE); #ifdef _MSC_VER if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF)) #else if (((sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF)) #endif return MZ_FALSE; if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size))) return MZ_FALSE; read_buf_avail = 0; comp_remaining = file_stat.m_comp_size; } do { size_t in_buf_size, out_buf_size = (size_t)(file_stat.m_uncomp_size - out_buf_ofs); if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) { read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) { status = TINFL_STATUS_FAILED; break; } cur_file_ofs += read_buf_avail; comp_remaining -= read_buf_avail; read_buf_ofs = 0; } in_buf_size = (size_t)read_buf_avail; status = tinfl_decompress( &inflator, (mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pBuf, (mz_uint8 *)pBuf + out_buf_ofs, &out_buf_size, TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF | (comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0)); read_buf_avail -= in_buf_size; read_buf_ofs += in_buf_size; out_buf_ofs += out_buf_size; } while (status == TINFL_STATUS_NEEDS_MORE_INPUT); if (status == TINFL_STATUS_DONE) { // Make sure the entire file was decompressed, and check its CRC. if ((out_buf_ofs != file_stat.m_uncomp_size) || (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) != file_stat.m_crc32)) status = TINFL_STATUS_FAILED; } if ((!pZip->m_pState->m_pMem) && (!pUser_read_buf)) pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); return status == TINFL_STATUS_DONE; } mz_bool mz_zip_reader_extract_file_to_mem_no_alloc( mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) { int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); if (file_index < 0) return MZ_FALSE; return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, pUser_read_buf, user_read_buf_size); } mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags) { return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, NULL, 0); } mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags) { return mz_zip_reader_extract_file_to_mem_no_alloc(pZip, pFilename, pBuf, buf_size, flags, NULL, 0); } void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags) { mz_uint64 comp_size, uncomp_size, alloc_size; const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); void *pBuf; if (pSize) *pSize = 0; if (!p) return NULL; comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size; #ifdef _MSC_VER if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) #else if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) #endif return NULL; if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)alloc_size))) return NULL; if (!mz_zip_reader_extract_to_mem(pZip, file_index, pBuf, (size_t)alloc_size, flags)) { pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); return NULL; } if (pSize) *pSize = (size_t)alloc_size; return pBuf; } void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags) { int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); if (file_index < 0) { if (pSize) *pSize = 0; return MZ_FALSE; } return mz_zip_reader_extract_to_heap(pZip, file_index, pSize, flags); } mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags) { int status = TINFL_STATUS_DONE; mz_uint file_crc32 = MZ_CRC32_INIT; mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, out_buf_ofs = 0, cur_file_ofs; mz_zip_archive_file_stat file_stat; void *pRead_buf = NULL; void *pWrite_buf = NULL; mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) return MZ_FALSE; // Empty file, or a directory (but not always a directory - I've seen odd zips // with directories that have compressed data which inflates to 0 bytes) if (!file_stat.m_comp_size) return MZ_TRUE; // Entry is a subdirectory (I've seen old zips with dir entries which have // compressed deflate data which inflates to 0 bytes, but these entries claim // to uncompress to 512 bytes in the headers). // I'm torn how to handle this case - should it fail instead? if (mz_zip_reader_is_file_a_directory(pZip, file_index)) return MZ_TRUE; // Encryption and patch files are not supported. if (file_stat.m_bit_flag & (1 | 32)) return MZ_FALSE; // This function only supports stored and deflate. if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED)) return MZ_FALSE; // Read and parse the local directory entry. cur_file_ofs = file_stat.m_local_header_ofs; if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) return MZ_FALSE; if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) return MZ_FALSE; cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size) return MZ_FALSE; // Decompress the file either directly from memory or from a file input // buffer. if (pZip->m_pState->m_pMem) { pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs; read_buf_size = read_buf_avail = file_stat.m_comp_size; comp_remaining = 0; } else { read_buf_size = MZ_MIN(file_stat.m_comp_size, (mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE); if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size))) return MZ_FALSE; read_buf_avail = 0; comp_remaining = file_stat.m_comp_size; } if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) { // The file is stored or the caller has requested the compressed data. if (pZip->m_pState->m_pMem) { #ifdef _MSC_VER if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > 0xFFFFFFFF)) #else if (((sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > 0xFFFFFFFF)) #endif return MZ_FALSE; if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)file_stat.m_comp_size) != file_stat.m_comp_size) status = TINFL_STATUS_FAILED; else if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)file_stat.m_comp_size); cur_file_ofs += file_stat.m_comp_size; out_buf_ofs += file_stat.m_comp_size; comp_remaining = 0; } else { while (comp_remaining) { read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) { status = TINFL_STATUS_FAILED; break; } if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) file_crc32 = (mz_uint32)mz_crc32( file_crc32, (const mz_uint8 *)pRead_buf, (size_t)read_buf_avail); if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) { status = TINFL_STATUS_FAILED; break; } cur_file_ofs += read_buf_avail; out_buf_ofs += read_buf_avail; comp_remaining -= read_buf_avail; } } } else { tinfl_decompressor inflator; tinfl_init(&inflator); if (NULL == (pWrite_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, TINFL_LZ_DICT_SIZE))) status = TINFL_STATUS_FAILED; else { do { mz_uint8 *pWrite_buf_cur = (mz_uint8 *)pWrite_buf + (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); size_t in_buf_size, out_buf_size = TINFL_LZ_DICT_SIZE - (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) { read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) { status = TINFL_STATUS_FAILED; break; } cur_file_ofs += read_buf_avail; comp_remaining -= read_buf_avail; read_buf_ofs = 0; } in_buf_size = (size_t)read_buf_avail; status = tinfl_decompress( &inflator, (const mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pWrite_buf, pWrite_buf_cur, &out_buf_size, comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0); read_buf_avail -= in_buf_size; read_buf_ofs += in_buf_size; if (out_buf_size) { if (pCallback(pOpaque, out_buf_ofs, pWrite_buf_cur, out_buf_size) != out_buf_size) { status = TINFL_STATUS_FAILED; break; } file_crc32 = (mz_uint32)mz_crc32(file_crc32, pWrite_buf_cur, out_buf_size); if ((out_buf_ofs += out_buf_size) > file_stat.m_uncomp_size) { status = TINFL_STATUS_FAILED; break; } } } while ((status == TINFL_STATUS_NEEDS_MORE_INPUT) || (status == TINFL_STATUS_HAS_MORE_OUTPUT)); } } if ((status == TINFL_STATUS_DONE) && (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA))) { // Make sure the entire file was decompressed, and check its CRC. if ((out_buf_ofs != file_stat.m_uncomp_size) || (file_crc32 != file_stat.m_crc32)) status = TINFL_STATUS_FAILED; } if (!pZip->m_pState->m_pMem) pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); if (pWrite_buf) pZip->m_pFree(pZip->m_pAlloc_opaque, pWrite_buf); return status == TINFL_STATUS_DONE; } mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags) { int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); if (file_index < 0) return MZ_FALSE; return mz_zip_reader_extract_to_callback(pZip, file_index, pCallback, pOpaque, flags); } #ifndef MINIZ_NO_STDIO static size_t mz_zip_file_write_callback(void *pOpaque, mz_uint64 ofs, const void *pBuf, size_t n) { (void)ofs; return MZ_FWRITE(pBuf, 1, n, (MZ_FILE *)pOpaque); } mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags) { mz_bool status; mz_zip_archive_file_stat file_stat; MZ_FILE *pFile; if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) return MZ_FALSE; pFile = MZ_FOPEN(pDst_filename, "wb"); if (!pFile) return MZ_FALSE; status = mz_zip_reader_extract_to_callback( pZip, file_index, mz_zip_file_write_callback, pFile, flags); if (MZ_FCLOSE(pFile) == EOF) return MZ_FALSE; #ifndef MINIZ_NO_TIME if (status) mz_zip_set_file_times(pDst_filename, file_stat.m_time, file_stat.m_time); #endif return status; } #endif // #ifndef MINIZ_NO_STDIO mz_bool mz_zip_reader_end(mz_zip_archive *pZip) { if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) return MZ_FALSE; if (pZip->m_pState) { mz_zip_internal_state *pState = pZip->m_pState; pZip->m_pState = NULL; mz_zip_array_clear(pZip, &pState->m_central_dir); mz_zip_array_clear(pZip, &pState->m_central_dir_offsets); mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets); #ifndef MINIZ_NO_STDIO if (pState->m_pFile) { MZ_FCLOSE(pState->m_pFile); pState->m_pFile = NULL; } #endif // #ifndef MINIZ_NO_STDIO pZip->m_pFree(pZip->m_pAlloc_opaque, pState); } pZip->m_zip_mode = MZ_ZIP_MODE_INVALID; return MZ_TRUE; } #ifndef MINIZ_NO_STDIO mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags) { int file_index = mz_zip_reader_locate_file(pZip, pArchive_filename, NULL, flags); if (file_index < 0) return MZ_FALSE; return mz_zip_reader_extract_to_file(pZip, file_index, pDst_filename, flags); } #endif // ------------------- .ZIP archive writing #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS static void mz_write_le16(mz_uint8 *p, mz_uint16 v) { p[0] = (mz_uint8)v; p[1] = (mz_uint8)(v >> 8); } static void mz_write_le32(mz_uint8 *p, mz_uint32 v) { p[0] = (mz_uint8)v; p[1] = (mz_uint8)(v >> 8); p[2] = (mz_uint8)(v >> 16); p[3] = (mz_uint8)(v >> 24); } #define MZ_WRITE_LE16(p, v) mz_write_le16((mz_uint8 *)(p), (mz_uint16)(v)) #define MZ_WRITE_LE32(p, v) mz_write_le32((mz_uint8 *)(p), (mz_uint32)(v)) mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size) { if ((!pZip) || (pZip->m_pState) || (!pZip->m_pWrite) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID)) return MZ_FALSE; if (pZip->m_file_offset_alignment) { // Ensure user specified file offset alignment is a power of 2. if (pZip->m_file_offset_alignment & (pZip->m_file_offset_alignment - 1)) return MZ_FALSE; } if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func; if (!pZip->m_pFree) pZip->m_pFree = def_free_func; if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func; pZip->m_zip_mode = MZ_ZIP_MODE_WRITING; pZip->m_archive_size = existing_size; pZip->m_central_directory_file_ofs = 0; pZip->m_total_files = 0; if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc( pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state)))) return MZ_FALSE; memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state)); MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8)); MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32)); MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32)); return MZ_TRUE; } static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n) { mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; mz_zip_internal_state *pState = pZip->m_pState; mz_uint64 new_size = MZ_MAX(file_ofs + n, pState->m_mem_size); #ifdef _MSC_VER if ((!n) || ((0, sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) #else if ((!n) || ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) #endif return 0; if (new_size > pState->m_mem_capacity) { void *pNew_block; size_t new_capacity = MZ_MAX(64, pState->m_mem_capacity); while (new_capacity < new_size) new_capacity *= 2; if (NULL == (pNew_block = pZip->m_pRealloc( pZip->m_pAlloc_opaque, pState->m_pMem, 1, new_capacity))) return 0; pState->m_pMem = pNew_block; pState->m_mem_capacity = new_capacity; } memcpy((mz_uint8 *)pState->m_pMem + file_ofs, pBuf, n); pState->m_mem_size = (size_t)new_size; return n; } mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size) { pZip->m_pWrite = mz_zip_heap_write_func; pZip->m_pIO_opaque = pZip; if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning)) return MZ_FALSE; if (0 != (initial_allocation_size = MZ_MAX(initial_allocation_size, size_to_reserve_at_beginning))) { if (NULL == (pZip->m_pState->m_pMem = pZip->m_pAlloc( pZip->m_pAlloc_opaque, 1, initial_allocation_size))) { mz_zip_writer_end(pZip); return MZ_FALSE; } pZip->m_pState->m_mem_capacity = initial_allocation_size; } return MZ_TRUE; } #ifndef MINIZ_NO_STDIO static size_t mz_zip_file_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n) { mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET)))) return 0; return MZ_FWRITE(pBuf, 1, n, pZip->m_pState->m_pFile); } mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning) { MZ_FILE *pFile; pZip->m_pWrite = mz_zip_file_write_func; pZip->m_pIO_opaque = pZip; if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning)) return MZ_FALSE; if (NULL == (pFile = MZ_FOPEN(pFilename, "wb"))) { mz_zip_writer_end(pZip); return MZ_FALSE; } pZip->m_pState->m_pFile = pFile; if (size_to_reserve_at_beginning) { mz_uint64 cur_ofs = 0; char buf[4096]; MZ_CLEAR_OBJ(buf); do { size_t n = (size_t)MZ_MIN(sizeof(buf), size_to_reserve_at_beginning); if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_ofs, buf, n) != n) { mz_zip_writer_end(pZip); return MZ_FALSE; } cur_ofs += n; size_to_reserve_at_beginning -= n; } while (size_to_reserve_at_beginning); } return MZ_TRUE; } #endif // #ifndef MINIZ_NO_STDIO mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename) { mz_zip_internal_state *pState; if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) return MZ_FALSE; // No sense in trying to write to an archive that's already at the support max // size if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_ZIP_LOCAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) return MZ_FALSE; pState = pZip->m_pState; if (pState->m_pFile) { #ifdef MINIZ_NO_STDIO pFilename; return MZ_FALSE; #else // Archive is being read from stdio - try to reopen as writable. if (pZip->m_pIO_opaque != pZip) return MZ_FALSE; if (!pFilename) return MZ_FALSE; pZip->m_pWrite = mz_zip_file_write_func; if (NULL == (pState->m_pFile = MZ_FREOPEN(pFilename, "r+b", pState->m_pFile))) { // The mz_zip_archive is now in a bogus state because pState->m_pFile is // NULL, so just close it. mz_zip_reader_end(pZip); return MZ_FALSE; } #endif // #ifdef MINIZ_NO_STDIO } else if (pState->m_pMem) { // Archive lives in a memory block. Assume it's from the heap that we can // resize using the realloc callback. if (pZip->m_pIO_opaque != pZip) return MZ_FALSE; pState->m_mem_capacity = pState->m_mem_size; pZip->m_pWrite = mz_zip_heap_write_func; } // Archive is being read via a user provided read function - make sure the // user has specified a write function too. else if (!pZip->m_pWrite) return MZ_FALSE; // Start writing new files at the archive's current central directory // location. pZip->m_archive_size = pZip->m_central_directory_file_ofs; pZip->m_zip_mode = MZ_ZIP_MODE_WRITING; pZip->m_central_directory_file_ofs = 0; return MZ_TRUE; } mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags) { return mz_zip_writer_add_mem_ex(pZip, pArchive_name, pBuf, buf_size, NULL, 0, level_and_flags, 0, 0); } typedef struct { mz_zip_archive *m_pZip; mz_uint64 m_cur_archive_file_ofs; mz_uint64 m_comp_size; } mz_zip_writer_add_state; static mz_bool mz_zip_writer_add_put_buf_callback(const void *pBuf, int len, void *pUser) { mz_zip_writer_add_state *pState = (mz_zip_writer_add_state *)pUser; if ((int)pState->m_pZip->m_pWrite(pState->m_pZip->m_pIO_opaque, pState->m_cur_archive_file_ofs, pBuf, len) != len) return MZ_FALSE; pState->m_cur_archive_file_ofs += len; pState->m_comp_size += len; return MZ_TRUE; } static mz_bool mz_zip_writer_create_local_dir_header( mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, mz_uint16 extra_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date) { (void)pZip; memset(pDst, 0, MZ_ZIP_LOCAL_DIR_HEADER_SIZE); MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_SIG_OFS, MZ_ZIP_LOCAL_DIR_HEADER_SIG); MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_VERSION_NEEDED_OFS, method ? 20 : 0); MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_BIT_FLAG_OFS, bit_flags); MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_METHOD_OFS, method); MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_TIME_OFS, dos_time); MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_DATE_OFS, dos_date); MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_CRC32_OFS, uncomp_crc32); MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS, comp_size); MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS, uncomp_size); MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILENAME_LEN_OFS, filename_size); MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_EXTRA_LEN_OFS, extra_size); return MZ_TRUE; } static mz_bool mz_zip_writer_create_central_dir_header( mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, mz_uint16 extra_size, mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs, mz_uint32 ext_attributes) { (void)pZip; memset(pDst, 0, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE); MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_SIG_OFS, MZ_ZIP_CENTRAL_DIR_HEADER_SIG); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_VERSION_NEEDED_OFS, method ? 20 : 0); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_BIT_FLAG_OFS, bit_flags); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_METHOD_OFS, method); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_TIME_OFS, dos_time); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_DATE_OFS, dos_date); MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_CRC32_OFS, uncomp_crc32); MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS, comp_size); MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS, uncomp_size); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILENAME_LEN_OFS, filename_size); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_EXTRA_LEN_OFS, extra_size); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_COMMENT_LEN_OFS, comment_size); MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS, ext_attributes); MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_header_ofs); return MZ_TRUE; } static mz_bool mz_zip_writer_add_to_central_dir( mz_zip_archive *pZip, const char *pFilename, mz_uint16 filename_size, const void *pExtra, mz_uint16 extra_size, const void *pComment, mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs, mz_uint32 ext_attributes) { mz_zip_internal_state *pState = pZip->m_pState; mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size; size_t orig_central_dir_size = pState->m_central_dir.m_size; mz_uint8 central_dir_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; // No zip64 support yet if ((local_header_ofs > 0xFFFFFFFF) || (((mz_uint64)pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + extra_size + comment_size) > 0xFFFFFFFF)) return MZ_FALSE; if (!mz_zip_writer_create_central_dir_header( pZip, central_dir_header, filename_size, extra_size, comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_header_ofs, ext_attributes)) return MZ_FALSE; if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) || (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pFilename, filename_size)) || (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pExtra, extra_size)) || (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pComment, comment_size)) || (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, ¢ral_dir_ofs, 1))) { // Try to push the central directory array back into its original state. mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); return MZ_FALSE; } return MZ_TRUE; } static mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name) { // Basic ZIP archive filename validity checks: Valid filenames cannot start // with a forward slash, cannot contain a drive letter, and cannot use // DOS-style backward slashes. if (*pArchive_name == '/') return MZ_FALSE; while (*pArchive_name) { if ((*pArchive_name == '\\') || (*pArchive_name == ':')) return MZ_FALSE; pArchive_name++; } return MZ_TRUE; } static mz_uint mz_zip_writer_compute_padding_needed_for_file_alignment( mz_zip_archive *pZip) { mz_uint32 n; if (!pZip->m_file_offset_alignment) return 0; n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1)); return (pZip->m_file_offset_alignment - n) & (pZip->m_file_offset_alignment - 1); } static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip, mz_uint64 cur_file_ofs, mz_uint32 n) { char buf[4096]; memset(buf, 0, MZ_MIN(sizeof(buf), n)); while (n) { mz_uint32 s = MZ_MIN(sizeof(buf), n); if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_file_ofs, buf, s) != s) return MZ_FALSE; cur_file_ofs += s; n -= s; } return MZ_TRUE; } mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32) { mz_uint16 method = 0, dos_time = 0, dos_date = 0; mz_uint level, ext_attributes = 0, num_alignment_padding_bytes; mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, comp_size = 0; size_t archive_name_size; mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; tdefl_compressor *pComp = NULL; mz_bool store_data_uncompressed; mz_zip_internal_state *pState; if ((int)level_and_flags < 0) level_and_flags = MZ_DEFAULT_LEVEL; level = level_and_flags & 0xF; store_data_uncompressed = ((!level) || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)); if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || ((buf_size) && (!pBuf)) || (!pArchive_name) || ((comment_size) && (!pComment)) || (pZip->m_total_files == 0xFFFF) || (level > MZ_UBER_COMPRESSION)) return MZ_FALSE; pState = pZip->m_pState; if ((!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (uncomp_size)) return MZ_FALSE; // No zip64 support yet if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF)) return MZ_FALSE; if (!mz_zip_writer_validate_archive_name(pArchive_name)) return MZ_FALSE; #ifndef MINIZ_NO_TIME { time_t cur_time; time(&cur_time); mz_zip_time_to_dos_time(cur_time, &dos_time, &dos_date); } #endif // #ifndef MINIZ_NO_TIME archive_name_size = strlen(pArchive_name); if (archive_name_size > 0xFFFF) return MZ_FALSE; num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); // no zip64 support yet if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + comment_size + archive_name_size) > 0xFFFFFFFF)) return MZ_FALSE; if ((archive_name_size) && (pArchive_name[archive_name_size - 1] == '/')) { // Set DOS Subdirectory attribute bit. ext_attributes |= 0x10; // Subdirectories cannot contain data. if ((buf_size) || (uncomp_size)) return MZ_FALSE; } // Try to do any allocations before writing to the archive, so if an // allocation fails the file remains unmodified. (A good idea if we're doing // an in-place modification.) if ((!mz_zip_array_ensure_room( pZip, &pState->m_central_dir, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size)) || (!mz_zip_array_ensure_room(pZip, &pState->m_central_dir_offsets, 1))) return MZ_FALSE; if ((!store_data_uncompressed) && (buf_size)) { if (NULL == (pComp = (tdefl_compressor *)pZip->m_pAlloc( pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)))) return MZ_FALSE; } if (!mz_zip_writer_write_zeros( pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header))) { pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); return MZ_FALSE; } local_dir_header_ofs += num_alignment_padding_bytes; if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header); MZ_CLEAR_OBJ(local_dir_header); if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) { pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); return MZ_FALSE; } cur_archive_file_ofs += archive_name_size; if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) { uncomp_crc32 = (mz_uint32)mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, buf_size); uncomp_size = buf_size; if (uncomp_size <= 3) { level = 0; store_data_uncompressed = MZ_TRUE; } } if (store_data_uncompressed) { if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pBuf, buf_size) != buf_size) { pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); return MZ_FALSE; } cur_archive_file_ofs += buf_size; comp_size = buf_size; if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) method = MZ_DEFLATED; } else if (buf_size) { mz_zip_writer_add_state state; state.m_pZip = pZip; state.m_cur_archive_file_ofs = cur_archive_file_ofs; state.m_comp_size = 0; if ((tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params( level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) || (tdefl_compress_buffer(pComp, pBuf, buf_size, TDEFL_FINISH) != TDEFL_STATUS_DONE)) { pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); return MZ_FALSE; } comp_size = state.m_comp_size; cur_archive_file_ofs = state.m_cur_archive_file_ofs; method = MZ_DEFLATED; } pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); pComp = NULL; // no zip64 support yet if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF)) return MZ_FALSE; if (!mz_zip_writer_create_local_dir_header( pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date)) return MZ_FALSE; if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) return MZ_FALSE; if (!mz_zip_writer_add_to_central_dir( pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes)) return MZ_FALSE; pZip->m_total_files++; pZip->m_archive_size = cur_archive_file_ofs; return MZ_TRUE; } #ifndef MINIZ_NO_STDIO mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags) { mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes; mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0; mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = 0, comp_size = 0; size_t archive_name_size; mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; MZ_FILE *pSrc_file = NULL; if ((int)level_and_flags < 0) level_and_flags = MZ_DEFAULT_LEVEL; level = level_and_flags & 0xF; if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pArchive_name) || ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION)) return MZ_FALSE; if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) return MZ_FALSE; if (!mz_zip_writer_validate_archive_name(pArchive_name)) return MZ_FALSE; archive_name_size = strlen(pArchive_name); if (archive_name_size > 0xFFFF) return MZ_FALSE; num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); // no zip64 support yet if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + comment_size + archive_name_size) > 0xFFFFFFFF)) return MZ_FALSE; if (!mz_zip_get_file_modified_time(pSrc_filename, &dos_time, &dos_date)) return MZ_FALSE; pSrc_file = MZ_FOPEN(pSrc_filename, "rb"); if (!pSrc_file) return MZ_FALSE; MZ_FSEEK64(pSrc_file, 0, SEEK_END); uncomp_size = MZ_FTELL64(pSrc_file); MZ_FSEEK64(pSrc_file, 0, SEEK_SET); if (uncomp_size > 0xFFFFFFFF) { // No zip64 support yet MZ_FCLOSE(pSrc_file); return MZ_FALSE; } if (uncomp_size <= 3) level = 0; if (!mz_zip_writer_write_zeros( pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header))) { MZ_FCLOSE(pSrc_file); return MZ_FALSE; } local_dir_header_ofs += num_alignment_padding_bytes; if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header); MZ_CLEAR_OBJ(local_dir_header); if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) { MZ_FCLOSE(pSrc_file); return MZ_FALSE; } cur_archive_file_ofs += archive_name_size; if (uncomp_size) { mz_uint64 uncomp_remaining = uncomp_size; void *pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, MZ_ZIP_MAX_IO_BUF_SIZE); if (!pRead_buf) { MZ_FCLOSE(pSrc_file); return MZ_FALSE; } if (!level) { while (uncomp_remaining) { mz_uint n = (mz_uint)MZ_MIN((mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining); if ((MZ_FREAD(pRead_buf, 1, n, pSrc_file) != n) || (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n)) { pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); MZ_FCLOSE(pSrc_file); return MZ_FALSE; } uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n); uncomp_remaining -= n; cur_archive_file_ofs += n; } comp_size = uncomp_size; } else { mz_bool result = MZ_FALSE; mz_zip_writer_add_state state; tdefl_compressor *pComp = (tdefl_compressor *)pZip->m_pAlloc( pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)); if (!pComp) { pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); MZ_FCLOSE(pSrc_file); return MZ_FALSE; } state.m_pZip = pZip; state.m_cur_archive_file_ofs = cur_archive_file_ofs; state.m_comp_size = 0; if (tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params( level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) { pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); MZ_FCLOSE(pSrc_file); return MZ_FALSE; } for (;;) { size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining, (mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE); tdefl_status status; if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size) break; uncomp_crc32 = (mz_uint32)mz_crc32( uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size); uncomp_remaining -= in_buf_size; status = tdefl_compress_buffer( pComp, pRead_buf, in_buf_size, uncomp_remaining ? TDEFL_NO_FLUSH : TDEFL_FINISH); if (status == TDEFL_STATUS_DONE) { result = MZ_TRUE; break; } else if (status != TDEFL_STATUS_OKAY) break; } pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); if (!result) { pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); MZ_FCLOSE(pSrc_file); return MZ_FALSE; } comp_size = state.m_comp_size; cur_archive_file_ofs = state.m_cur_archive_file_ofs; method = MZ_DEFLATED; } pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); } MZ_FCLOSE(pSrc_file); pSrc_file = NULL; // no zip64 support yet if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF)) return MZ_FALSE; if (!mz_zip_writer_create_local_dir_header( pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date)) return MZ_FALSE; if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) return MZ_FALSE; if (!mz_zip_writer_add_to_central_dir( pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes)) return MZ_FALSE; pZip->m_total_files++; pZip->m_archive_size = cur_archive_file_ofs; return MZ_TRUE; } #endif // #ifndef MINIZ_NO_STDIO mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint file_index) { mz_uint n, bit_flags, num_alignment_padding_bytes; mz_uint64 comp_bytes_remaining, local_dir_header_ofs; mz_uint64 cur_src_file_ofs, cur_dst_file_ofs; mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; mz_uint8 central_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; size_t orig_central_dir_size; mz_zip_internal_state *pState; void *pBuf; const mz_uint8 *pSrc_central_header; if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING)) return MZ_FALSE; if (NULL == (pSrc_central_header = mz_zip_reader_get_cdh(pSource_zip, file_index))) return MZ_FALSE; pState = pZip->m_pState; num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); // no zip64 support yet if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) return MZ_FALSE; cur_src_file_ofs = MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS); cur_dst_file_ofs = pZip->m_archive_size; if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) return MZ_FALSE; if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) return MZ_FALSE; cur_src_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE; if (!mz_zip_writer_write_zeros(pZip, cur_dst_file_ofs, num_alignment_padding_bytes)) return MZ_FALSE; cur_dst_file_ofs += num_alignment_padding_bytes; local_dir_header_ofs = cur_dst_file_ofs; if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) return MZ_FALSE; cur_dst_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE; n = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); comp_bytes_remaining = n + MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); if (NULL == (pBuf = pZip->m_pAlloc( pZip->m_pAlloc_opaque, 1, (size_t)MZ_MAX(sizeof(mz_uint32) * 4, MZ_MIN((mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining))))) return MZ_FALSE; while (comp_bytes_remaining) { n = (mz_uint)MZ_MIN((mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining); if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, n) != n) { pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); return MZ_FALSE; } cur_src_file_ofs += n; if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) { pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); return MZ_FALSE; } cur_dst_file_ofs += n; comp_bytes_remaining -= n; } bit_flags = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_BIT_FLAG_OFS); if (bit_flags & 8) { // Copy data descriptor if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, sizeof(mz_uint32) * 4) != sizeof(mz_uint32) * 4) { pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); return MZ_FALSE; } n = sizeof(mz_uint32) * ((MZ_READ_LE32(pBuf) == 0x08074b50) ? 4 : 3); if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) { pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); return MZ_FALSE; } cur_src_file_ofs += n; cur_dst_file_ofs += n; } pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); // no zip64 support yet if (cur_dst_file_ofs > 0xFFFFFFFF) return MZ_FALSE; orig_central_dir_size = pState->m_central_dir.m_size; memcpy(central_header, pSrc_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE); MZ_WRITE_LE32(central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_dir_header_ofs); if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) return MZ_FALSE; n = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_EXTRA_LEN_OFS) + MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_COMMENT_LEN_OFS); if (!mz_zip_array_push_back( pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n)) { mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); return MZ_FALSE; } if (pState->m_central_dir.m_size > 0xFFFFFFFF) return MZ_FALSE; n = (mz_uint32)orig_central_dir_size; if (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, &n, 1)) { mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); return MZ_FALSE; } pZip->m_total_files++; pZip->m_archive_size = cur_dst_file_ofs; return MZ_TRUE; } mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip) { mz_zip_internal_state *pState; mz_uint64 central_dir_ofs, central_dir_size; mz_uint8 hdr[MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE]; if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING)) return MZ_FALSE; pState = pZip->m_pState; // no zip64 support yet if ((pZip->m_total_files > 0xFFFF) || ((pZip->m_archive_size + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) return MZ_FALSE; central_dir_ofs = 0; central_dir_size = 0; if (pZip->m_total_files) { // Write central directory central_dir_ofs = pZip->m_archive_size; central_dir_size = pState->m_central_dir.m_size; pZip->m_central_directory_file_ofs = central_dir_ofs; if (pZip->m_pWrite(pZip->m_pIO_opaque, central_dir_ofs, pState->m_central_dir.m_p, (size_t)central_dir_size) != central_dir_size) return MZ_FALSE; pZip->m_archive_size += central_dir_size; } // Write end of central directory record MZ_CLEAR_OBJ(hdr); MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_SIG_OFS, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG); MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS, pZip->m_total_files); MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS, pZip->m_total_files); MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_SIZE_OFS, central_dir_size); MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_OFS_OFS, central_dir_ofs); if (pZip->m_pWrite(pZip->m_pIO_opaque, pZip->m_archive_size, hdr, sizeof(hdr)) != sizeof(hdr)) return MZ_FALSE; #ifndef MINIZ_NO_STDIO if ((pState->m_pFile) && (MZ_FFLUSH(pState->m_pFile) == EOF)) return MZ_FALSE; #endif // #ifndef MINIZ_NO_STDIO pZip->m_archive_size += sizeof(hdr); pZip->m_zip_mode = MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED; return MZ_TRUE; } mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, size_t *pSize) { if ((!pZip) || (!pZip->m_pState) || (!pBuf) || (!pSize)) return MZ_FALSE; if (pZip->m_pWrite != mz_zip_heap_write_func) return MZ_FALSE; if (!mz_zip_writer_finalize_archive(pZip)) return MZ_FALSE; *pBuf = pZip->m_pState->m_pMem; *pSize = pZip->m_pState->m_mem_size; pZip->m_pState->m_pMem = NULL; pZip->m_pState->m_mem_size = pZip->m_pState->m_mem_capacity = 0; return MZ_TRUE; } mz_bool mz_zip_writer_end(mz_zip_archive *pZip) { mz_zip_internal_state *pState; mz_bool status = MZ_TRUE; if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || ((pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) && (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED))) return MZ_FALSE; pState = pZip->m_pState; pZip->m_pState = NULL; mz_zip_array_clear(pZip, &pState->m_central_dir); mz_zip_array_clear(pZip, &pState->m_central_dir_offsets); mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets); #ifndef MINIZ_NO_STDIO if (pState->m_pFile) { MZ_FCLOSE(pState->m_pFile); pState->m_pFile = NULL; } #endif // #ifndef MINIZ_NO_STDIO if ((pZip->m_pWrite == mz_zip_heap_write_func) && (pState->m_pMem)) { pZip->m_pFree(pZip->m_pAlloc_opaque, pState->m_pMem); pState->m_pMem = NULL; } pZip->m_pFree(pZip->m_pAlloc_opaque, pState); pZip->m_zip_mode = MZ_ZIP_MODE_INVALID; return status; } #ifndef MINIZ_NO_STDIO mz_bool mz_zip_add_mem_to_archive_file_in_place( const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags) { mz_bool status, created_new_archive = MZ_FALSE; mz_zip_archive zip_archive; struct MZ_FILE_STAT_STRUCT file_stat; MZ_CLEAR_OBJ(zip_archive); if ((int)level_and_flags < 0) level_and_flags = MZ_DEFAULT_LEVEL; if ((!pZip_filename) || (!pArchive_name) || ((buf_size) && (!pBuf)) || ((comment_size) && (!pComment)) || ((level_and_flags & 0xF) > MZ_UBER_COMPRESSION)) return MZ_FALSE; if (!mz_zip_writer_validate_archive_name(pArchive_name)) return MZ_FALSE; if (MZ_FILE_STAT(pZip_filename, &file_stat) != 0) { // Create a new archive. if (!mz_zip_writer_init_file(&zip_archive, pZip_filename, 0)) return MZ_FALSE; created_new_archive = MZ_TRUE; } else { // Append to an existing archive. if (!mz_zip_reader_init_file( &zip_archive, pZip_filename, level_and_flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY)) return MZ_FALSE; if (!mz_zip_writer_init_from_reader(&zip_archive, pZip_filename)) { mz_zip_reader_end(&zip_archive); return MZ_FALSE; } } status = mz_zip_writer_add_mem_ex(&zip_archive, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, 0, 0); // Always finalize, even if adding failed for some reason, so we have a valid // central directory. (This may not always succeed, but we can try.) if (!mz_zip_writer_finalize_archive(&zip_archive)) status = MZ_FALSE; if (!mz_zip_writer_end(&zip_archive)) status = MZ_FALSE; if ((!status) && (created_new_archive)) { // It's a new archive and something went wrong, so just delete it. int ignoredStatus = MZ_DELETE_FILE(pZip_filename); (void)ignoredStatus; } return status; } void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags) { int file_index; mz_zip_archive zip_archive; void *p = NULL; if (pSize) *pSize = 0; if ((!pZip_filename) || (!pArchive_name)) return NULL; MZ_CLEAR_OBJ(zip_archive); if (!mz_zip_reader_init_file( &zip_archive, pZip_filename, flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY)) return NULL; if ((file_index = mz_zip_reader_locate_file(&zip_archive, pArchive_name, NULL, flags)) >= 0) p = mz_zip_reader_extract_to_heap(&zip_archive, file_index, pSize, flags); mz_zip_reader_end(&zip_archive); return p; } #endif // #ifndef MINIZ_NO_STDIO #endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS #endif // #ifndef MINIZ_NO_ARCHIVE_APIS #ifdef __cplusplus } #endif #endif // MINIZ_HEADER_FILE_ONLY /* This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to */ // ---------------------- end of miniz ---------------------------------------- #ifdef __clang__ #pragma clang diagnostic pop #endif } #else // Reuse MINIZ_LITTE_ENDIAN macro #if defined(__sparcv9) // Big endian #else #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU // Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian. #define MINIZ_LITTLE_ENDIAN 1 #endif #endif #endif // TINYEXR_USE_MINIZ // static bool IsBigEndian(void) { // union { // unsigned int i; // char c[4]; // } bint = {0x01020304}; // // return bint.c[0] == 1; //} static const int kEXRVersionSize = 8; static void swap2(unsigned short *val) { #ifdef MINIZ_LITTLE_ENDIAN (void)val; #else unsigned short tmp = *val; unsigned char *dst = reinterpret_cast(val); unsigned char *src = reinterpret_cast(&tmp); dst[0] = src[1]; dst[1] = src[0]; #endif } static void swap4(unsigned int *val) { #ifdef MINIZ_LITTLE_ENDIAN (void)val; #else unsigned int tmp = *val; unsigned char *dst = reinterpret_cast(val); unsigned char *src = reinterpret_cast(&tmp); dst[0] = src[3]; dst[1] = src[2]; dst[2] = src[1]; dst[3] = src[0]; #endif } static void swap8(tinyexr::tinyexr_uint64 *val) { #ifdef MINIZ_LITTLE_ENDIAN (void)val; #else tinyexr::tinyexr_uint64 tmp = (*val); unsigned char *dst = reinterpret_cast(val); unsigned char *src = reinterpret_cast(&tmp); dst[0] = src[7]; dst[1] = src[6]; dst[2] = src[5]; dst[3] = src[4]; dst[4] = src[3]; dst[5] = src[2]; dst[6] = src[1]; dst[7] = src[0]; #endif } // https://gist.github.com/rygorous/2156668 // Reuse MINIZ_LITTLE_ENDIAN flag from miniz. union FP32 { unsigned int u; float f; struct { #if MINIZ_LITTLE_ENDIAN unsigned int Mantissa : 23; unsigned int Exponent : 8; unsigned int Sign : 1; #else unsigned int Sign : 1; unsigned int Exponent : 8; unsigned int Mantissa : 23; #endif } s; }; #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" #endif union FP16 { unsigned short u; struct { #if MINIZ_LITTLE_ENDIAN unsigned int Mantissa : 10; unsigned int Exponent : 5; unsigned int Sign : 1; #else unsigned int Sign : 1; unsigned int Exponent : 5; unsigned int Mantissa : 10; #endif } s; }; #ifdef __clang__ #pragma clang diagnostic pop #endif static FP32 half_to_float(FP16 h) { static const FP32 magic = {113 << 23}; static const unsigned int shifted_exp = 0x7c00 << 13; // exponent mask after shift FP32 o; o.u = (h.u & 0x7fffU) << 13U; // exponent/mantissa bits unsigned int exp_ = shifted_exp & o.u; // just the exponent o.u += (127 - 15) << 23; // exponent adjust // handle exponent special cases if (exp_ == shifted_exp) // Inf/NaN? o.u += (128 - 16) << 23; // extra exp adjust else if (exp_ == 0) // Zero/Denormal? { o.u += 1 << 23; // extra exp adjust o.f -= magic.f; // renormalize } o.u |= (h.u & 0x8000U) << 16U; // sign bit return o; } static FP16 float_to_half_full(FP32 f) { FP16 o = {0}; // Based on ISPC reference code (with minor modifications) if (f.s.Exponent == 0) // Signed zero/denormal (which will underflow) o.s.Exponent = 0; else if (f.s.Exponent == 255) // Inf or NaN (all exponent bits set) { o.s.Exponent = 31; o.s.Mantissa = f.s.Mantissa ? 0x200 : 0; // NaN->qNaN and Inf->Inf } else // Normalized number { // Exponent unbias the single, then bias the halfp int newexp = f.s.Exponent - 127 + 15; if (newexp >= 31) // Overflow, return signed infinity o.s.Exponent = 31; else if (newexp <= 0) // Underflow { if ((14 - newexp) <= 24) // Mantissa might be non-zero { unsigned int mant = f.s.Mantissa | 0x800000; // Hidden 1 bit o.s.Mantissa = mant >> (14 - newexp); if ((mant >> (13 - newexp)) & 1) // Check for rounding o.u++; // Round, might overflow into exp bit, but this is OK } } else { o.s.Exponent = static_cast(newexp); o.s.Mantissa = f.s.Mantissa >> 13; if (f.s.Mantissa & 0x1000) // Check for rounding o.u++; // Round, might overflow to inf, this is OK } } o.s.Sign = f.s.Sign; return o; } // NOTE: From OpenEXR code // #define IMF_INCREASING_Y 0 // #define IMF_DECREASING_Y 1 // #define IMF_RAMDOM_Y 2 // // #define IMF_NO_COMPRESSION 0 // #define IMF_RLE_COMPRESSION 1 // #define IMF_ZIPS_COMPRESSION 2 // #define IMF_ZIP_COMPRESSION 3 // #define IMF_PIZ_COMPRESSION 4 // #define IMF_PXR24_COMPRESSION 5 // #define IMF_B44_COMPRESSION 6 // #define IMF_B44A_COMPRESSION 7 static const char *ReadString(std::string *s, const char *ptr) { // Read untile NULL(\0). const char *p = ptr; const char *q = ptr; while ((*q) != 0) q++; (*s) = std::string(p, q); return q + 1; // skip '\0' } static bool ReadAttribute(std::string *name, std::string *type, std::vector *data, size_t *marker_size, const char *marker, size_t size) { size_t name_len = strnlen(marker, size); if (name_len == size) { // String does not have a terminating character. return false; } *name = std::string(marker, name_len); marker += name_len + 1; size -= name_len + 1; size_t type_len = strnlen(marker, size); if (type_len == size) { return false; } *type = std::string(marker, type_len); marker += type_len + 1; size -= type_len + 1; if (size < sizeof(uint32_t)) { return false; } uint32_t data_len; memcpy(&data_len, marker, sizeof(uint32_t)); tinyexr::swap4(reinterpret_cast(&data_len)); marker += sizeof(uint32_t); size -= sizeof(uint32_t); if (size < data_len) { return false; } data->resize(static_cast(data_len)); memcpy(&data->at(0), marker, static_cast(data_len)); *marker_size = name_len + 1 + type_len + 1 + sizeof(uint32_t) + data_len; return true; } static void WriteAttributeToMemory(std::vector *out, const char *name, const char *type, const unsigned char *data, int len) { out->insert(out->end(), name, name + strlen(name) + 1); out->insert(out->end(), type, type + strlen(type) + 1); int outLen = len; tinyexr::swap4(reinterpret_cast(&outLen)); out->insert(out->end(), reinterpret_cast(&outLen), reinterpret_cast(&outLen) + sizeof(int)); out->insert(out->end(), data, data + len); } typedef struct { std::string name; // less than 255 bytes long int pixel_type; int x_sampling; int y_sampling; unsigned char p_linear; unsigned char pad[3]; } ChannelInfo; typedef struct HeaderInfo_t { std::vector channels; std::vector attributes; int data_window[4]; int line_order; int display_window[4]; float screen_window_center[2]; float screen_window_width; float pixel_aspect_ratio; int chunk_count; // Tiled format int tile_size_x; int tile_size_y; int tile_level_mode; int tile_rounding_mode; unsigned int header_len; int compression_type; void clear() { channels.clear(); attributes.clear(); data_window[0] = 0; data_window[1] = 0; data_window[2] = 0; data_window[3] = 0; line_order = 0; display_window[0] = 0; display_window[1] = 0; display_window[2] = 0; display_window[3] = 0; screen_window_center[0] = 0.0f; screen_window_center[1] = 0.0f; screen_window_width = 0.0f; pixel_aspect_ratio = 0.0f; chunk_count = 0; // Tiled format tile_size_x = 0; tile_size_y = 0; tile_level_mode = 0; tile_rounding_mode = 0; header_len = 0; compression_type = 0; } } HeaderInfo; static void ReadChannelInfo(std::vector &channels, const std::vector &data) { const char *p = reinterpret_cast(&data.at(0)); for (;;) { if ((*p) == 0) { break; } ChannelInfo info; p = ReadString(&info.name, p); memcpy(&info.pixel_type, p, sizeof(int)); p += 4; info.p_linear = static_cast(p[0]); // uchar p += 1 + 3; // reserved: uchar[3] memcpy(&info.x_sampling, p, sizeof(int)); // int p += 4; memcpy(&info.y_sampling, p, sizeof(int)); // int p += 4; tinyexr::swap4(reinterpret_cast(&info.pixel_type)); tinyexr::swap4(reinterpret_cast(&info.x_sampling)); tinyexr::swap4(reinterpret_cast(&info.y_sampling)); channels.push_back(info); } } static void WriteChannelInfo(std::vector &data, const std::vector &channels) { size_t sz = 0; // Calculate total size. for (size_t c = 0; c < channels.size(); c++) { sz += strlen(channels[c].name.c_str()) + 1; // +1 for \0 sz += 16; // 4 * int } data.resize(sz + 1); unsigned char *p = &data.at(0); for (size_t c = 0; c < channels.size(); c++) { memcpy(p, channels[c].name.c_str(), strlen(channels[c].name.c_str())); p += strlen(channels[c].name.c_str()); (*p) = '\0'; p++; int pixel_type = channels[c].pixel_type; int x_sampling = channels[c].x_sampling; int y_sampling = channels[c].y_sampling; tinyexr::swap4(reinterpret_cast(&pixel_type)); tinyexr::swap4(reinterpret_cast(&x_sampling)); tinyexr::swap4(reinterpret_cast(&y_sampling)); memcpy(p, &pixel_type, sizeof(int)); p += sizeof(int); (*p) = channels[c].p_linear; p += 4; memcpy(p, &x_sampling, sizeof(int)); p += sizeof(int); memcpy(p, &y_sampling, sizeof(int)); p += sizeof(int); } (*p) = '\0'; } static void CompressZip(unsigned char *dst, tinyexr::tinyexr_uint64 &compressedSize, const unsigned char *src, unsigned long src_size) { std::vector tmpBuf(src_size); // // Apply EXR-specific? postprocess. Grabbed from OpenEXR's // ImfZipCompressor.cpp // // // Reorder the pixel data. // const char *srcPtr = reinterpret_cast(src); { char *t1 = reinterpret_cast(&tmpBuf.at(0)); char *t2 = reinterpret_cast(&tmpBuf.at(0)) + (src_size + 1) / 2; const char *stop = srcPtr + src_size; for (;;) { if (srcPtr < stop) *(t1++) = *(srcPtr++); else break; if (srcPtr < stop) *(t2++) = *(srcPtr++); else break; } } // // Predictor. // { unsigned char *t = &tmpBuf.at(0) + 1; unsigned char *stop = &tmpBuf.at(0) + src_size; int p = t[-1]; while (t < stop) { int d = int(t[0]) - p + (128 + 256); p = t[0]; t[0] = static_cast(d); ++t; } } #if TINYEXR_USE_MINIZ // // Compress the data using miniz // miniz::mz_ulong outSize = miniz::mz_compressBound(src_size); int ret = miniz::mz_compress( dst, &outSize, static_cast(&tmpBuf.at(0)), src_size); assert(ret == miniz::MZ_OK); (void)ret; compressedSize = outSize; #else uLong outSize = compressBound(static_cast(src_size)); int ret = compress(dst, &outSize, static_cast(&tmpBuf.at(0)), src_size); assert(ret == Z_OK); compressedSize = outSize; #endif // Use uncompressed data when compressed data is larger than uncompressed. // (Issue 40) if (compressedSize >= src_size) { compressedSize = src_size; memcpy(dst, src, src_size); } } static void DecompressZip(unsigned char *dst, unsigned long *uncompressed_size /* inout */, const unsigned char *src, unsigned long src_size) { if ((*uncompressed_size) == src_size) { // Data is not compressed(Issue 40). memcpy(dst, src, src_size); return; } std::vector tmpBuf(*uncompressed_size); #if TINYEXR_USE_MINIZ int ret = miniz::mz_uncompress(&tmpBuf.at(0), uncompressed_size, src, src_size); assert(ret == miniz::MZ_OK); (void)ret; #else int ret = uncompress(&tmpBuf.at(0), uncompressed_size, src, src_size); assert(ret == Z_OK); (void)ret; #endif // // Apply EXR-specific? postprocess. Grabbed from OpenEXR's // ImfZipCompressor.cpp // // Predictor. { unsigned char *t = &tmpBuf.at(0) + 1; unsigned char *stop = &tmpBuf.at(0) + (*uncompressed_size); while (t < stop) { int d = int(t[-1]) + int(t[0]) - 128; t[0] = static_cast(d); ++t; } } // Reorder the pixel data. { const char *t1 = reinterpret_cast(&tmpBuf.at(0)); const char *t2 = reinterpret_cast(&tmpBuf.at(0)) + (*uncompressed_size + 1) / 2; char *s = reinterpret_cast(dst); char *stop = s + (*uncompressed_size); for (;;) { if (s < stop) *(s++) = *(t1++); else break; if (s < stop) *(s++) = *(t2++); else break; } } } // RLE code from OpenEXR -------------------------------------- #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wsign-conversion" #endif const int MIN_RUN_LENGTH = 3; const int MAX_RUN_LENGTH = 127; // // Compress an array of bytes, using run-length encoding, // and return the length of the compressed data. // static int rleCompress(int inLength, const char in[], signed char out[]) { const char *inEnd = in + inLength; const char *runStart = in; const char *runEnd = in + 1; signed char *outWrite = out; while (runStart < inEnd) { while (runEnd < inEnd && *runStart == *runEnd && runEnd - runStart - 1 < MAX_RUN_LENGTH) { ++runEnd; } if (runEnd - runStart >= MIN_RUN_LENGTH) { // // Compressable run // *outWrite++ = static_cast(runEnd - runStart) - 1; *outWrite++ = *(reinterpret_cast(runStart)); runStart = runEnd; } else { // // Uncompressable run // while (runEnd < inEnd && ((runEnd + 1 >= inEnd || *runEnd != *(runEnd + 1)) || (runEnd + 2 >= inEnd || *(runEnd + 1) != *(runEnd + 2))) && runEnd - runStart < MAX_RUN_LENGTH) { ++runEnd; } *outWrite++ = static_cast(runStart - runEnd); while (runStart < runEnd) { *outWrite++ = *(reinterpret_cast(runStart++)); } } ++runEnd; } return static_cast(outWrite - out); } // // Uncompress an array of bytes compressed with rleCompress(). // Returns the length of the oncompressed data, or 0 if the // length of the uncompressed data would be more than maxLength. // static int rleUncompress(int inLength, int maxLength, const signed char in[], char out[]) { char *outStart = out; while (inLength > 0) { if (*in < 0) { int count = -(static_cast(*in++)); inLength -= count + 1; if (0 > (maxLength -= count)) return 0; memcpy(out, in, count); out += count; in += count; } else { int count = *in++; inLength -= 2; if (0 > (maxLength -= count + 1)) return 0; memset(out, *reinterpret_cast(in), count + 1); out += count + 1; in++; } } return static_cast(out - outStart); } #ifdef __clang__ #pragma clang diagnostic pop #endif // End of RLE code from OpenEXR ----------------------------------- static void CompressRle(unsigned char *dst, tinyexr::tinyexr_uint64 &compressedSize, const unsigned char *src, unsigned long src_size) { std::vector tmpBuf(src_size); // // Apply EXR-specific? postprocess. Grabbed from OpenEXR's // ImfRleCompressor.cpp // // // Reorder the pixel data. // const char *srcPtr = reinterpret_cast(src); { char *t1 = reinterpret_cast(&tmpBuf.at(0)); char *t2 = reinterpret_cast(&tmpBuf.at(0)) + (src_size + 1) / 2; const char *stop = srcPtr + src_size; for (;;) { if (srcPtr < stop) *(t1++) = *(srcPtr++); else break; if (srcPtr < stop) *(t2++) = *(srcPtr++); else break; } } // // Predictor. // { unsigned char *t = &tmpBuf.at(0) + 1; unsigned char *stop = &tmpBuf.at(0) + src_size; int p = t[-1]; while (t < stop) { int d = int(t[0]) - p + (128 + 256); p = t[0]; t[0] = static_cast(d); ++t; } } // outSize will be (srcSiz * 3) / 2 at max. int outSize = rleCompress(static_cast(src_size), reinterpret_cast(&tmpBuf.at(0)), reinterpret_cast(dst)); assert(outSize > 0); compressedSize = static_cast(outSize); // Use uncompressed data when compressed data is larger than uncompressed. // (Issue 40) if (compressedSize >= src_size) { compressedSize = src_size; memcpy(dst, src, src_size); } } static void DecompressRle(unsigned char *dst, const unsigned long uncompressed_size, const unsigned char *src, unsigned long src_size) { if (uncompressed_size == src_size) { // Data is not compressed(Issue 40). memcpy(dst, src, src_size); return; } std::vector tmpBuf(uncompressed_size); int ret = rleUncompress(static_cast(src_size), static_cast(uncompressed_size), reinterpret_cast(src), reinterpret_cast(&tmpBuf.at(0))); assert(ret == static_cast(uncompressed_size)); (void)ret; // // Apply EXR-specific? postprocess. Grabbed from OpenEXR's // ImfRleCompressor.cpp // // Predictor. { unsigned char *t = &tmpBuf.at(0) + 1; unsigned char *stop = &tmpBuf.at(0) + uncompressed_size; while (t < stop) { int d = int(t[-1]) + int(t[0]) - 128; t[0] = static_cast(d); ++t; } } // Reorder the pixel data. { const char *t1 = reinterpret_cast(&tmpBuf.at(0)); const char *t2 = reinterpret_cast(&tmpBuf.at(0)) + (uncompressed_size + 1) / 2; char *s = reinterpret_cast(dst); char *stop = s + uncompressed_size; for (;;) { if (s < stop) *(s++) = *(t1++); else break; if (s < stop) *(s++) = *(t2++); else break; } } } #if TINYEXR_USE_PIZ #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc++11-long-long" #pragma clang diagnostic ignored "-Wold-style-cast" #pragma clang diagnostic ignored "-Wpadded" #pragma clang diagnostic ignored "-Wsign-conversion" #pragma clang diagnostic ignored "-Wc++11-extensions" #pragma clang diagnostic ignored "-Wconversion" #endif // // PIZ compress/uncompress, based on OpenEXR's ImfPizCompressor.cpp // // ----------------------------------------------------------------- // Copyright (c) 2004, Industrial Light & Magic, a division of Lucas // Digital Ltd. LLC) // (3 clause BSD license) // struct PIZChannelData { unsigned short *start; unsigned short *end; int nx; int ny; int ys; int size; }; //----------------------------------------------------------------------------- // // 16-bit Haar Wavelet encoding and decoding // // The source code in this file is derived from the encoding // and decoding routines written by Christian Rouet for his // PIZ image file format. // //----------------------------------------------------------------------------- // // Wavelet basis functions without modulo arithmetic; they produce // the best compression ratios when the wavelet-transformed data are // Huffman-encoded, but the wavelet transform works only for 14-bit // data (untransformed data values must be less than (1 << 14)). // inline void wenc14(unsigned short a, unsigned short b, unsigned short &l, unsigned short &h) { short as = static_cast(a); short bs = static_cast(b); short ms = (as + bs) >> 1; short ds = as - bs; l = static_cast(ms); h = static_cast(ds); } inline void wdec14(unsigned short l, unsigned short h, unsigned short &a, unsigned short &b) { short ls = static_cast(l); short hs = static_cast(h); int hi = hs; int ai = ls + (hi & 1) + (hi >> 1); short as = static_cast(ai); short bs = static_cast(ai - hi); a = static_cast(as); b = static_cast(bs); } // // Wavelet basis functions with modulo arithmetic; they work with full // 16-bit data, but Huffman-encoding the wavelet-transformed data doesn't // compress the data quite as well. // const int NBITS = 16; const int A_OFFSET = 1 << (NBITS - 1); const int M_OFFSET = 1 << (NBITS - 1); const int MOD_MASK = (1 << NBITS) - 1; inline void wenc16(unsigned short a, unsigned short b, unsigned short &l, unsigned short &h) { int ao = (a + A_OFFSET) & MOD_MASK; int m = ((ao + b) >> 1); int d = ao - b; if (d < 0) m = (m + M_OFFSET) & MOD_MASK; d &= MOD_MASK; l = static_cast(m); h = static_cast(d); } inline void wdec16(unsigned short l, unsigned short h, unsigned short &a, unsigned short &b) { int m = l; int d = h; int bb = (m - (d >> 1)) & MOD_MASK; int aa = (d + bb - A_OFFSET) & MOD_MASK; b = static_cast(bb); a = static_cast(aa); } // // 2D Wavelet encoding: // static void wav2Encode( unsigned short *in, // io: values are transformed in place int nx, // i : x size int ox, // i : x offset int ny, // i : y size int oy, // i : y offset unsigned short mx) // i : maximum in[x][y] value { bool w14 = (mx < (1 << 14)); int n = (nx > ny) ? ny : nx; int p = 1; // == 1 << level int p2 = 2; // == 1 << (level+1) // // Hierachical loop on smaller dimension n // while (p2 <= n) { unsigned short *py = in; unsigned short *ey = in + oy * (ny - p2); int oy1 = oy * p; int oy2 = oy * p2; int ox1 = ox * p; int ox2 = ox * p2; unsigned short i00, i01, i10, i11; // // Y loop // for (; py <= ey; py += oy2) { unsigned short *px = py; unsigned short *ex = py + ox * (nx - p2); // // X loop // for (; px <= ex; px += ox2) { unsigned short *p01 = px + ox1; unsigned short *p10 = px + oy1; unsigned short *p11 = p10 + ox1; // // 2D wavelet encoding // if (w14) { wenc14(*px, *p01, i00, i01); wenc14(*p10, *p11, i10, i11); wenc14(i00, i10, *px, *p10); wenc14(i01, i11, *p01, *p11); } else { wenc16(*px, *p01, i00, i01); wenc16(*p10, *p11, i10, i11); wenc16(i00, i10, *px, *p10); wenc16(i01, i11, *p01, *p11); } } // // Encode (1D) odd column (still in Y loop) // if (nx & p) { unsigned short *p10 = px + oy1; if (w14) wenc14(*px, *p10, i00, *p10); else wenc16(*px, *p10, i00, *p10); *px = i00; } } // // Encode (1D) odd line (must loop in X) // if (ny & p) { unsigned short *px = py; unsigned short *ex = py + ox * (nx - p2); for (; px <= ex; px += ox2) { unsigned short *p01 = px + ox1; if (w14) wenc14(*px, *p01, i00, *p01); else wenc16(*px, *p01, i00, *p01); *px = i00; } } // // Next level // p = p2; p2 <<= 1; } } // // 2D Wavelet decoding: // static void wav2Decode( unsigned short *in, // io: values are transformed in place int nx, // i : x size int ox, // i : x offset int ny, // i : y size int oy, // i : y offset unsigned short mx) // i : maximum in[x][y] value { bool w14 = (mx < (1 << 14)); int n = (nx > ny) ? ny : nx; int p = 1; int p2; // // Search max level // while (p <= n) p <<= 1; p >>= 1; p2 = p; p >>= 1; // // Hierarchical loop on smaller dimension n // while (p >= 1) { unsigned short *py = in; unsigned short *ey = in + oy * (ny - p2); int oy1 = oy * p; int oy2 = oy * p2; int ox1 = ox * p; int ox2 = ox * p2; unsigned short i00, i01, i10, i11; // // Y loop // for (; py <= ey; py += oy2) { unsigned short *px = py; unsigned short *ex = py + ox * (nx - p2); // // X loop // for (; px <= ex; px += ox2) { unsigned short *p01 = px + ox1; unsigned short *p10 = px + oy1; unsigned short *p11 = p10 + ox1; // // 2D wavelet decoding // if (w14) { wdec14(*px, *p10, i00, i10); wdec14(*p01, *p11, i01, i11); wdec14(i00, i01, *px, *p01); wdec14(i10, i11, *p10, *p11); } else { wdec16(*px, *p10, i00, i10); wdec16(*p01, *p11, i01, i11); wdec16(i00, i01, *px, *p01); wdec16(i10, i11, *p10, *p11); } } // // Decode (1D) odd column (still in Y loop) // if (nx & p) { unsigned short *p10 = px + oy1; if (w14) wdec14(*px, *p10, i00, *p10); else wdec16(*px, *p10, i00, *p10); *px = i00; } } // // Decode (1D) odd line (must loop in X) // if (ny & p) { unsigned short *px = py; unsigned short *ex = py + ox * (nx - p2); for (; px <= ex; px += ox2) { unsigned short *p01 = px + ox1; if (w14) wdec14(*px, *p01, i00, *p01); else wdec16(*px, *p01, i00, *p01); *px = i00; } } // // Next level // p2 = p; p >>= 1; } } //----------------------------------------------------------------------------- // // 16-bit Huffman compression and decompression. // // The source code in this file is derived from the 8-bit // Huffman compression and decompression routines written // by Christian Rouet for his PIZ image file format. // //----------------------------------------------------------------------------- // Adds some modification for tinyexr. const int HUF_ENCBITS = 16; // literal (value) bit length const int HUF_DECBITS = 14; // decoding bit size (>= 8) const int HUF_ENCSIZE = (1 << HUF_ENCBITS) + 1; // encoding table size const int HUF_DECSIZE = 1 << HUF_DECBITS; // decoding table size const int HUF_DECMASK = HUF_DECSIZE - 1; struct HufDec { // short code long code //------------------------------- int len : 8; // code length 0 int lit : 24; // lit p size int *p; // 0 lits }; inline long long hufLength(long long code) { return code & 63; } inline long long hufCode(long long code) { return code >> 6; } inline void outputBits(int nBits, long long bits, long long &c, int &lc, char *&out) { c <<= nBits; lc += nBits; c |= bits; while (lc >= 8) *out++ = static_cast((c >> (lc -= 8))); } inline long long getBits(int nBits, long long &c, int &lc, const char *&in) { while (lc < nBits) { c = (c << 8) | *(reinterpret_cast(in++)); lc += 8; } lc -= nBits; return (c >> lc) & ((1 << nBits) - 1); } // // ENCODING TABLE BUILDING & (UN)PACKING // // // Build a "canonical" Huffman code table: // - for each (uncompressed) symbol, hcode contains the length // of the corresponding code (in the compressed data) // - canonical codes are computed and stored in hcode // - the rules for constructing canonical codes are as follows: // * shorter codes (if filled with zeroes to the right) // have a numerically higher value than longer codes // * for codes with the same length, numerical values // increase with numerical symbol values // - because the canonical code table can be constructed from // symbol lengths alone, the code table can be transmitted // without sending the actual code values // - see http://www.compressconsult.com/huffman/ // static void hufCanonicalCodeTable(long long hcode[HUF_ENCSIZE]) { long long n[59]; // // For each i from 0 through 58, count the // number of different codes of length i, and // store the count in n[i]. // for (int i = 0; i <= 58; ++i) n[i] = 0; for (int i = 0; i < HUF_ENCSIZE; ++i) n[hcode[i]] += 1; // // For each i from 58 through 1, compute the // numerically lowest code with length i, and // store that code in n[i]. // long long c = 0; for (int i = 58; i > 0; --i) { long long nc = ((c + n[i]) >> 1); n[i] = c; c = nc; } // // hcode[i] contains the length, l, of the // code for symbol i. Assign the next available // code of length l to the symbol and store both // l and the code in hcode[i]. // for (int i = 0; i < HUF_ENCSIZE; ++i) { int l = static_cast(hcode[i]); if (l > 0) hcode[i] = l | (n[l]++ << 6); } } // // Compute Huffman codes (based on frq input) and store them in frq: // - code structure is : [63:lsb - 6:msb] | [5-0: bit length]; // - max code length is 58 bits; // - codes outside the range [im-iM] have a null length (unused values); // - original frequencies are destroyed; // - encoding tables are used by hufEncode() and hufBuildDecTable(); // struct FHeapCompare { bool operator()(long long *a, long long *b) { return *a > *b; } }; static void hufBuildEncTable( long long *frq, // io: input frequencies [HUF_ENCSIZE], output table int *im, // o: min frq index int *iM) // o: max frq index { // // This function assumes that when it is called, array frq // indicates the frequency of all possible symbols in the data // that are to be Huffman-encoded. (frq[i] contains the number // of occurrences of symbol i in the data.) // // The loop below does three things: // // 1) Finds the minimum and maximum indices that point // to non-zero entries in frq: // // frq[im] != 0, and frq[i] == 0 for all i < im // frq[iM] != 0, and frq[i] == 0 for all i > iM // // 2) Fills array fHeap with pointers to all non-zero // entries in frq. // // 3) Initializes array hlink such that hlink[i] == i // for all array entries. // int hlink[HUF_ENCSIZE]; long long *fHeap[HUF_ENCSIZE]; *im = 0; while (!frq[*im]) (*im)++; int nf = 0; for (int i = *im; i < HUF_ENCSIZE; i++) { hlink[i] = i; if (frq[i]) { fHeap[nf] = &frq[i]; nf++; *iM = i; } } // // Add a pseudo-symbol, with a frequency count of 1, to frq; // adjust the fHeap and hlink array accordingly. Function // hufEncode() uses the pseudo-symbol for run-length encoding. // (*iM)++; frq[*iM] = 1; fHeap[nf] = &frq[*iM]; nf++; // // Build an array, scode, such that scode[i] contains the number // of bits assigned to symbol i. Conceptually this is done by // constructing a tree whose leaves are the symbols with non-zero // frequency: // // Make a heap that contains all symbols with a non-zero frequency, // with the least frequent symbol on top. // // Repeat until only one symbol is left on the heap: // // Take the two least frequent symbols off the top of the heap. // Create a new node that has first two nodes as children, and // whose frequency is the sum of the frequencies of the first // two nodes. Put the new node back into the heap. // // The last node left on the heap is the root of the tree. For each // leaf node, the distance between the root and the leaf is the length // of the code for the corresponding symbol. // // The loop below doesn't actually build the tree; instead we compute // the distances of the leaves from the root on the fly. When a new // node is added to the heap, then that node's descendants are linked // into a single linear list that starts at the new node, and the code // lengths of the descendants (that is, their distance from the root // of the tree) are incremented by one. // std::make_heap(&fHeap[0], &fHeap[nf], FHeapCompare()); long long scode[HUF_ENCSIZE]; memset(scode, 0, sizeof(long long) * HUF_ENCSIZE); while (nf > 1) { // // Find the indices, mm and m, of the two smallest non-zero frq // values in fHeap, add the smallest frq to the second-smallest // frq, and remove the smallest frq value from fHeap. // int mm = fHeap[0] - frq; std::pop_heap(&fHeap[0], &fHeap[nf], FHeapCompare()); --nf; int m = fHeap[0] - frq; std::pop_heap(&fHeap[0], &fHeap[nf], FHeapCompare()); frq[m] += frq[mm]; std::push_heap(&fHeap[0], &fHeap[nf], FHeapCompare()); // // The entries in scode are linked into lists with the // entries in hlink serving as "next" pointers and with // the end of a list marked by hlink[j] == j. // // Traverse the lists that start at scode[m] and scode[mm]. // For each element visited, increment the length of the // corresponding code by one bit. (If we visit scode[j] // during the traversal, then the code for symbol j becomes // one bit longer.) // // Merge the lists that start at scode[m] and scode[mm] // into a single list that starts at scode[m]. // // // Add a bit to all codes in the first list. // for (int j = m;; j = hlink[j]) { scode[j]++; assert(scode[j] <= 58); if (hlink[j] == j) { // // Merge the two lists. // hlink[j] = mm; break; } } // // Add a bit to all codes in the second list // for (int j = mm;; j = hlink[j]) { scode[j]++; assert(scode[j] <= 58); if (hlink[j] == j) break; } } // // Build a canonical Huffman code table, replacing the code // lengths in scode with (code, code length) pairs. Copy the // code table from scode into frq. // hufCanonicalCodeTable(scode); memcpy(frq, scode, sizeof(long long) * HUF_ENCSIZE); } // // Pack an encoding table: // - only code lengths, not actual codes, are stored // - runs of zeroes are compressed as follows: // // unpacked packed // -------------------------------- // 1 zero 0 (6 bits) // 2 zeroes 59 // 3 zeroes 60 // 4 zeroes 61 // 5 zeroes 62 // n zeroes (6 or more) 63 n-6 (6 + 8 bits) // const int SHORT_ZEROCODE_RUN = 59; const int LONG_ZEROCODE_RUN = 63; const int SHORTEST_LONG_RUN = 2 + LONG_ZEROCODE_RUN - SHORT_ZEROCODE_RUN; const int LONGEST_LONG_RUN = 255 + SHORTEST_LONG_RUN; static void hufPackEncTable( const long long *hcode, // i : encoding table [HUF_ENCSIZE] int im, // i : min hcode index int iM, // i : max hcode index char **pcode) // o: ptr to packed table (updated) { char *p = *pcode; long long c = 0; int lc = 0; for (; im <= iM; im++) { int l = hufLength(hcode[im]); if (l == 0) { int zerun = 1; while ((im < iM) && (zerun < LONGEST_LONG_RUN)) { if (hufLength(hcode[im + 1]) > 0) break; im++; zerun++; } if (zerun >= 2) { if (zerun >= SHORTEST_LONG_RUN) { outputBits(6, LONG_ZEROCODE_RUN, c, lc, p); outputBits(8, zerun - SHORTEST_LONG_RUN, c, lc, p); } else { outputBits(6, SHORT_ZEROCODE_RUN + zerun - 2, c, lc, p); } continue; } } outputBits(6, l, c, lc, p); } if (lc > 0) *p++ = (unsigned char)(c << (8 - lc)); *pcode = p; } // // Unpack an encoding table packed by hufPackEncTable(): // static bool hufUnpackEncTable( const char **pcode, // io: ptr to packed table (updated) int ni, // i : input size (in bytes) int im, // i : min hcode index int iM, // i : max hcode index long long *hcode) // o: encoding table [HUF_ENCSIZE] { memset(hcode, 0, sizeof(long long) * HUF_ENCSIZE); const char *p = *pcode; long long c = 0; int lc = 0; for (; im <= iM; im++) { if (p - *pcode > ni) { return false; } long long l = hcode[im] = getBits(6, c, lc, p); // code length if (l == (long long)LONG_ZEROCODE_RUN) { if (p - *pcode > ni) { return false; } int zerun = getBits(8, c, lc, p) + SHORTEST_LONG_RUN; if (im + zerun > iM + 1) { return false; } while (zerun--) hcode[im++] = 0; im--; } else if (l >= (long long)SHORT_ZEROCODE_RUN) { int zerun = l - SHORT_ZEROCODE_RUN + 2; if (im + zerun > iM + 1) { return false; } while (zerun--) hcode[im++] = 0; im--; } } *pcode = const_cast(p); hufCanonicalCodeTable(hcode); return true; } // // DECODING TABLE BUILDING // // // Clear a newly allocated decoding table so that it contains only zeroes. // static void hufClearDecTable(HufDec *hdecod) // io: (allocated by caller) // decoding table [HUF_DECSIZE] { for (int i = 0; i < HUF_DECSIZE; i++) { hdecod[i].len = 0; hdecod[i].lit = 0; hdecod[i].p = NULL; } // memset(hdecod, 0, sizeof(HufDec) * HUF_DECSIZE); } // // Build a decoding hash table based on the encoding table hcode: // - short codes (<= HUF_DECBITS) are resolved with a single table access; // - long code entry allocations are not optimized, because long codes are // unfrequent; // - decoding tables are used by hufDecode(); // static bool hufBuildDecTable(const long long *hcode, // i : encoding table int im, // i : min index in hcode int iM, // i : max index in hcode HufDec *hdecod) // o: (allocated by caller) // decoding table [HUF_DECSIZE] { // // Init hashtable & loop on all codes. // Assumes that hufClearDecTable(hdecod) has already been called. // for (; im <= iM; im++) { long long c = hufCode(hcode[im]); int l = hufLength(hcode[im]); if (c >> l) { // // Error: c is supposed to be an l-bit code, // but c contains a value that is greater // than the largest l-bit number. // // invalidTableEntry(); return false; } if (l > HUF_DECBITS) { // // Long code: add a secondary entry // HufDec *pl = hdecod + (c >> (l - HUF_DECBITS)); if (pl->len) { // // Error: a short code has already // been stored in table entry *pl. // // invalidTableEntry(); return false; } pl->lit++; if (pl->p) { int *p = pl->p; pl->p = new int[pl->lit]; for (int i = 0; i < pl->lit - 1; ++i) pl->p[i] = p[i]; delete[] p; } else { pl->p = new int[1]; } pl->p[pl->lit - 1] = im; } else if (l) { // // Short code: init all primary entries // HufDec *pl = hdecod + (c << (HUF_DECBITS - l)); for (long long i = 1ULL << (HUF_DECBITS - l); i > 0; i--, pl++) { if (pl->len || pl->p) { // // Error: a short code or a long code has // already been stored in table entry *pl. // // invalidTableEntry(); return false; } pl->len = l; pl->lit = im; } } } return true; } // // Free the long code entries of a decoding table built by hufBuildDecTable() // static void hufFreeDecTable(HufDec *hdecod) // io: Decoding table { for (int i = 0; i < HUF_DECSIZE; i++) { if (hdecod[i].p) { delete[] hdecod[i].p; hdecod[i].p = 0; } } } // // ENCODING // inline void outputCode(long long code, long long &c, int &lc, char *&out) { outputBits(hufLength(code), hufCode(code), c, lc, out); } inline void sendCode(long long sCode, int runCount, long long runCode, long long &c, int &lc, char *&out) { // // Output a run of runCount instances of the symbol sCount. // Output the symbols explicitly, or if that is shorter, output // the sCode symbol once followed by a runCode symbol and runCount // expressed as an 8-bit number. // if (hufLength(sCode) + hufLength(runCode) + 8 < hufLength(sCode) * runCount) { outputCode(sCode, c, lc, out); outputCode(runCode, c, lc, out); outputBits(8, runCount, c, lc, out); } else { while (runCount-- >= 0) outputCode(sCode, c, lc, out); } } // // Encode (compress) ni values based on the Huffman encoding table hcode: // static int hufEncode // return: output size (in bits) (const long long *hcode, // i : encoding table const unsigned short *in, // i : uncompressed input buffer const int ni, // i : input buffer size (in bytes) int rlc, // i : rl code char *out) // o: compressed output buffer { char *outStart = out; long long c = 0; // bits not yet written to out int lc = 0; // number of valid bits in c (LSB) int s = in[0]; int cs = 0; // // Loop on input values // for (int i = 1; i < ni; i++) { // // Count same values or send code // if (s == in[i] && cs < 255) { cs++; } else { sendCode(hcode[s], cs, hcode[rlc], c, lc, out); cs = 0; } s = in[i]; } // // Send remaining code // sendCode(hcode[s], cs, hcode[rlc], c, lc, out); if (lc) *out = (c << (8 - lc)) & 0xff; return (out - outStart) * 8 + lc; } // // DECODING // // // In order to force the compiler to inline them, // getChar() and getCode() are implemented as macros // instead of "inline" functions. // #define getChar(c, lc, in) \ { \ c = (c << 8) | *(unsigned char *)(in++); \ lc += 8; \ } #define getCode(po, rlc, c, lc, in, out, oe) \ { \ if (po == rlc) { \ if (lc < 8) getChar(c, lc, in); \ \ lc -= 8; \ \ unsigned char cs = (c >> lc); \ \ if (out + cs > oe) return false; \ \ unsigned short s = out[-1]; \ \ while (cs-- > 0) *out++ = s; \ } else if (out < oe) { \ *out++ = po; \ } else { \ return false; \ } \ } // // Decode (uncompress) ni bits based on encoding & decoding tables: // static bool hufDecode(const long long *hcode, // i : encoding table const HufDec *hdecod, // i : decoding table const char *in, // i : compressed input buffer int ni, // i : input size (in bits) int rlc, // i : run-length code int no, // i : expected output size (in bytes) unsigned short *out) // o: uncompressed output buffer { long long c = 0; int lc = 0; unsigned short *outb = out; unsigned short *oe = out + no; const char *ie = in + (ni + 7) / 8; // input byte size // // Loop on input bytes // while (in < ie) { getChar(c, lc, in); // // Access decoding table // while (lc >= HUF_DECBITS) { const HufDec pl = hdecod[(c >> (lc - HUF_DECBITS)) & HUF_DECMASK]; if (pl.len) { // // Get short code // lc -= pl.len; getCode(pl.lit, rlc, c, lc, in, out, oe); } else { if (!pl.p) { return false; } // invalidCode(); // wrong code // // Search long code // int j; for (j = 0; j < pl.lit; j++) { int l = hufLength(hcode[pl.p[j]]); while (lc < l && in < ie) // get more bits getChar(c, lc, in); if (lc >= l) { if (hufCode(hcode[pl.p[j]]) == ((c >> (lc - l)) & (((long long)(1) << l) - 1))) { // // Found : get long code // lc -= l; getCode(pl.p[j], rlc, c, lc, in, out, oe); break; } } } if (j == pl.lit) { return false; // invalidCode(); // Not found } } } } // // Get remaining (short) codes // int i = (8 - ni) & 7; c >>= i; lc -= i; while (lc > 0) { const HufDec pl = hdecod[(c << (HUF_DECBITS - lc)) & HUF_DECMASK]; if (pl.len) { lc -= pl.len; getCode(pl.lit, rlc, c, lc, in, out, oe); } else { return false; // invalidCode(); // wrong (long) code } } if (out - outb != no) { return false; } // notEnoughData (); return true; } static void countFrequencies(long long freq[HUF_ENCSIZE], const unsigned short data[/*n*/], int n) { for (int i = 0; i < HUF_ENCSIZE; ++i) freq[i] = 0; for (int i = 0; i < n; ++i) ++freq[data[i]]; } static void writeUInt(char buf[4], unsigned int i) { unsigned char *b = (unsigned char *)buf; b[0] = i; b[1] = i >> 8; b[2] = i >> 16; b[3] = i >> 24; } static unsigned int readUInt(const char buf[4]) { const unsigned char *b = (const unsigned char *)buf; return (b[0] & 0x000000ff) | ((b[1] << 8) & 0x0000ff00) | ((b[2] << 16) & 0x00ff0000) | ((b[3] << 24) & 0xff000000); } // // EXTERNAL INTERFACE // static int hufCompress(const unsigned short raw[], int nRaw, char compressed[]) { if (nRaw == 0) return 0; long long freq[HUF_ENCSIZE]; countFrequencies(freq, raw, nRaw); int im = 0; int iM = 0; hufBuildEncTable(freq, &im, &iM); char *tableStart = compressed + 20; char *tableEnd = tableStart; hufPackEncTable(freq, im, iM, &tableEnd); int tableLength = tableEnd - tableStart; char *dataStart = tableEnd; int nBits = hufEncode(freq, raw, nRaw, iM, dataStart); int data_length = (nBits + 7) / 8; writeUInt(compressed, im); writeUInt(compressed + 4, iM); writeUInt(compressed + 8, tableLength); writeUInt(compressed + 12, nBits); writeUInt(compressed + 16, 0); // room for future extensions return dataStart + data_length - compressed; } static bool hufUncompress(const char compressed[], int nCompressed, unsigned short raw[], int nRaw) { if (nCompressed == 0) { if (nRaw != 0) return false; return false; } int im = readUInt(compressed); int iM = readUInt(compressed + 4); // int tableLength = readUInt (compressed + 8); int nBits = readUInt(compressed + 12); if (im < 0 || im >= HUF_ENCSIZE || iM < 0 || iM >= HUF_ENCSIZE) return false; const char *ptr = compressed + 20; // // Fast decoder needs at least 2x64-bits of compressed data, and // needs to be run-able on this platform. Otherwise, fall back // to the original decoder // // if (FastHufDecoder::enabled() && nBits > 128) //{ // FastHufDecoder fhd (ptr, nCompressed - (ptr - compressed), im, iM, iM); // fhd.decode ((unsigned char*)ptr, nBits, raw, nRaw); //} // else { std::vector freq(HUF_ENCSIZE); std::vector hdec(HUF_DECSIZE); hufClearDecTable(&hdec.at(0)); hufUnpackEncTable(&ptr, nCompressed - (ptr - compressed), im, iM, &freq.at(0)); { if (nBits > 8 * (nCompressed - (ptr - compressed))) { return false; } hufBuildDecTable(&freq.at(0), im, iM, &hdec.at(0)); hufDecode(&freq.at(0), &hdec.at(0), ptr, nBits, iM, nRaw, raw); } // catch (...) //{ // hufFreeDecTable (hdec); // throw; //} hufFreeDecTable(&hdec.at(0)); } return true; } // // Functions to compress the range of values in the pixel data // const int USHORT_RANGE = (1 << 16); const int BITMAP_SIZE = (USHORT_RANGE >> 3); static void bitmapFromData(const unsigned short data[/*nData*/], int nData, unsigned char bitmap[BITMAP_SIZE], unsigned short &minNonZero, unsigned short &maxNonZero) { for (int i = 0; i < BITMAP_SIZE; ++i) bitmap[i] = 0; for (int i = 0; i < nData; ++i) bitmap[data[i] >> 3] |= (1 << (data[i] & 7)); bitmap[0] &= ~1; // zero is not explicitly stored in // the bitmap; we assume that the // data always contain zeroes minNonZero = BITMAP_SIZE - 1; maxNonZero = 0; for (int i = 0; i < BITMAP_SIZE; ++i) { if (bitmap[i]) { if (minNonZero > i) minNonZero = i; if (maxNonZero < i) maxNonZero = i; } } } static unsigned short forwardLutFromBitmap( const unsigned char bitmap[BITMAP_SIZE], unsigned short lut[USHORT_RANGE]) { int k = 0; for (int i = 0; i < USHORT_RANGE; ++i) { if ((i == 0) || (bitmap[i >> 3] & (1 << (i & 7)))) lut[i] = k++; else lut[i] = 0; } return k - 1; // maximum value stored in lut[], } // i.e. number of ones in bitmap minus 1 static unsigned short reverseLutFromBitmap( const unsigned char bitmap[BITMAP_SIZE], unsigned short lut[USHORT_RANGE]) { int k = 0; for (int i = 0; i < USHORT_RANGE; ++i) { if ((i == 0) || (bitmap[i >> 3] & (1 << (i & 7)))) lut[k++] = i; } int n = k - 1; while (k < USHORT_RANGE) lut[k++] = 0; return n; // maximum k where lut[k] is non-zero, } // i.e. number of ones in bitmap minus 1 static void applyLut(const unsigned short lut[USHORT_RANGE], unsigned short data[/*nData*/], int nData) { for (int i = 0; i < nData; ++i) data[i] = lut[data[i]]; } #ifdef __clang__ #pragma clang diagnostic pop #endif // __clang__ static bool CompressPiz(unsigned char *outPtr, unsigned int *outSize, const unsigned char *inPtr, size_t inSize, const std::vector &channelInfo, int data_width, int num_lines) { unsigned char bitmap[BITMAP_SIZE]; unsigned short minNonZero; unsigned short maxNonZero; #if !MINIZ_LITTLE_ENDIAN // @todo { PIZ compression on BigEndian architecture. } assert(0); return false; #endif // Assume `inSize` is multiple of 2 or 4. std::vector tmpBuffer(inSize / sizeof(unsigned short)); std::vector channelData(channelInfo.size()); unsigned short *tmpBufferEnd = &tmpBuffer.at(0); for (size_t c = 0; c < channelData.size(); c++) { PIZChannelData &cd = channelData[c]; cd.start = tmpBufferEnd; cd.end = cd.start; cd.nx = data_width; cd.ny = num_lines; // cd.ys = c.channel().ySampling; size_t pixelSize = sizeof(int); // UINT and FLOAT if (channelInfo[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { pixelSize = sizeof(short); } cd.size = static_cast(pixelSize / sizeof(short)); tmpBufferEnd += cd.nx * cd.ny * cd.size; } const unsigned char *ptr = inPtr; for (int y = 0; y < num_lines; ++y) { for (size_t i = 0; i < channelData.size(); ++i) { PIZChannelData &cd = channelData[i]; // if (modp (y, cd.ys) != 0) // continue; size_t n = static_cast(cd.nx * cd.size); memcpy(cd.end, ptr, n * sizeof(unsigned short)); ptr += n * sizeof(unsigned short); cd.end += n; } } bitmapFromData(&tmpBuffer.at(0), static_cast(tmpBuffer.size()), bitmap, minNonZero, maxNonZero); unsigned short lut[USHORT_RANGE]; unsigned short maxValue = forwardLutFromBitmap(bitmap, lut); applyLut(lut, &tmpBuffer.at(0), static_cast(tmpBuffer.size())); // // Store range compression info in _outBuffer // char *buf = reinterpret_cast(outPtr); memcpy(buf, &minNonZero, sizeof(unsigned short)); buf += sizeof(unsigned short); memcpy(buf, &maxNonZero, sizeof(unsigned short)); buf += sizeof(unsigned short); if (minNonZero <= maxNonZero) { memcpy(buf, reinterpret_cast(&bitmap[0] + minNonZero), maxNonZero - minNonZero + 1); buf += maxNonZero - minNonZero + 1; } // // Apply wavelet encoding // for (size_t i = 0; i < channelData.size(); ++i) { PIZChannelData &cd = channelData[i]; for (int j = 0; j < cd.size; ++j) { wav2Encode(cd.start + j, cd.nx, cd.size, cd.ny, cd.nx * cd.size, maxValue); } } // // Apply Huffman encoding; append the result to _outBuffer // // length header(4byte), then huff data. Initialize length header with zero, // then later fill it by `length`. char *lengthPtr = buf; int zero = 0; memcpy(buf, &zero, sizeof(int)); buf += sizeof(int); int length = hufCompress(&tmpBuffer.at(0), static_cast(tmpBuffer.size()), buf); memcpy(lengthPtr, &length, sizeof(int)); (*outSize) = static_cast( (reinterpret_cast(buf) - outPtr) + static_cast(length)); // Use uncompressed data when compressed data is larger than uncompressed. // (Issue 40) if ((*outSize) >= inSize) { (*outSize) = inSize; memcpy(outPtr, inPtr, inSize); } return true; } static bool DecompressPiz(unsigned char *outPtr, const unsigned char *inPtr, size_t tmpBufSize, size_t inLen, int num_channels, const EXRChannelInfo *channels, int data_width, int num_lines) { if (inLen == tmpBufSize) { // Data is not compressed(Issue 40). memcpy(outPtr, inPtr, inLen); return true; } unsigned char bitmap[BITMAP_SIZE]; unsigned short minNonZero; unsigned short maxNonZero; #if !MINIZ_LITTLE_ENDIAN // @todo { PIZ compression on BigEndian architecture. } assert(0); return false; #endif memset(bitmap, 0, BITMAP_SIZE); const unsigned char *ptr = inPtr; minNonZero = *(reinterpret_cast(ptr)); maxNonZero = *(reinterpret_cast(ptr + 2)); ptr += 4; if (maxNonZero >= BITMAP_SIZE) { return false; } if (minNonZero <= maxNonZero) { memcpy(reinterpret_cast(&bitmap[0] + minNonZero), ptr, maxNonZero - minNonZero + 1); ptr += maxNonZero - minNonZero + 1; } unsigned short lut[USHORT_RANGE]; memset(lut, 0, sizeof(unsigned short) * USHORT_RANGE); unsigned short maxValue = reverseLutFromBitmap(bitmap, lut); // // Huffman decoding // int length; length = *(reinterpret_cast(ptr)); ptr += sizeof(int); std::vector tmpBuffer(tmpBufSize); hufUncompress(reinterpret_cast(ptr), length, &tmpBuffer.at(0), static_cast(tmpBufSize)); // // Wavelet decoding // std::vector channelData(static_cast(num_channels)); unsigned short *tmpBufferEnd = &tmpBuffer.at(0); for (size_t i = 0; i < static_cast(num_channels); ++i) { const EXRChannelInfo &chan = channels[i]; size_t pixelSize = sizeof(int); // UINT and FLOAT if (chan.pixel_type == TINYEXR_PIXELTYPE_HALF) { pixelSize = sizeof(short); } channelData[i].start = tmpBufferEnd; channelData[i].end = channelData[i].start; channelData[i].nx = data_width; channelData[i].ny = num_lines; // channelData[i].ys = 1; channelData[i].size = static_cast(pixelSize / sizeof(short)); tmpBufferEnd += channelData[i].nx * channelData[i].ny * channelData[i].size; } for (size_t i = 0; i < channelData.size(); ++i) { PIZChannelData &cd = channelData[i]; for (int j = 0; j < cd.size; ++j) { wav2Decode(cd.start + j, cd.nx, cd.size, cd.ny, cd.nx * cd.size, maxValue); } } // // Expand the pixel data to their original range // applyLut(lut, &tmpBuffer.at(0), static_cast(tmpBufSize)); for (int y = 0; y < num_lines; y++) { for (size_t i = 0; i < channelData.size(); ++i) { PIZChannelData &cd = channelData[i]; // if (modp (y, cd.ys) != 0) // continue; size_t n = static_cast(cd.nx * cd.size); memcpy(outPtr, cd.end, static_cast(n * sizeof(unsigned short))); outPtr += n * sizeof(unsigned short); cd.end += n; } } return true; } #endif // TINYEXR_USE_PIZ #if TINYEXR_USE_ZFP struct ZFPCompressionParam { double rate; int precision; double tolerance; int type; // TINYEXR_ZFP_COMPRESSIONTYPE_* ZFPCompressionParam() { type = TINYEXR_ZFP_COMPRESSIONTYPE_RATE; rate = 2.0; precision = 0; tolerance = 0.0f; } }; bool FindZFPCompressionParam(ZFPCompressionParam *param, const EXRAttribute *attributes, int num_attributes) { bool foundType = false; for (int i = 0; i < num_attributes; i++) { if ((strcmp(attributes[i].name, "zfpCompressionType") == 0) && (attributes[i].size == 1)) { param->type = static_cast(attributes[i].value[0]); foundType = true; } } if (!foundType) { return false; } if (param->type == TINYEXR_ZFP_COMPRESSIONTYPE_RATE) { for (int i = 0; i < num_attributes; i++) { if ((strcmp(attributes[i].name, "zfpCompressionRate") == 0) && (attributes[i].size == 8)) { param->rate = *(reinterpret_cast(attributes[i].value)); return true; } } } else if (param->type == TINYEXR_ZFP_COMPRESSIONTYPE_PRECISION) { for (int i = 0; i < num_attributes; i++) { if ((strcmp(attributes[i].name, "zfpCompressionPrecision") == 0) && (attributes[i].size == 4)) { param->rate = *(reinterpret_cast(attributes[i].value)); return true; } } } else if (param->type == TINYEXR_ZFP_COMPRESSIONTYPE_ACCURACY) { for (int i = 0; i < num_attributes; i++) { if ((strcmp(attributes[i].name, "zfpCompressionTolerance") == 0) && (attributes[i].size == 8)) { param->tolerance = *(reinterpret_cast(attributes[i].value)); return true; } } } else { assert(0); } return false; } // Assume pixel format is FLOAT for all channels. static bool DecompressZfp(float *dst, int dst_width, int dst_num_lines, int num_channels, const unsigned char *src, unsigned long src_size, const ZFPCompressionParam ¶m) { size_t uncompressed_size = dst_width * dst_num_lines * num_channels; if (uncompressed_size == src_size) { // Data is not compressed(Issue 40). memcpy(dst, src, src_size); } zfp_stream *zfp = NULL; zfp_field *field = NULL; assert((dst_width % 4) == 0); assert((dst_num_lines % 4) == 0); if ((dst_width & 3U) || (dst_num_lines & 3U)) { return false; } field = zfp_field_2d(reinterpret_cast(const_cast(src)), zfp_type_float, dst_width, dst_num_lines * num_channels); zfp = zfp_stream_open(NULL); if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_RATE) { zfp_stream_set_rate(zfp, param.rate, zfp_type_float, /* dimention */ 2, /* write random access */ 0); } else if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_PRECISION) { zfp_stream_set_precision(zfp, param.precision, zfp_type_float); } else if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_ACCURACY) { zfp_stream_set_accuracy(zfp, param.tolerance, zfp_type_float); } else { assert(0); } size_t buf_size = zfp_stream_maximum_size(zfp, field); std::vector buf(buf_size); memcpy(&buf.at(0), src, src_size); bitstream *stream = stream_open(&buf.at(0), buf_size); zfp_stream_set_bit_stream(zfp, stream); zfp_stream_rewind(zfp); size_t image_size = dst_width * dst_num_lines; for (int c = 0; c < num_channels; c++) { // decompress 4x4 pixel block. for (int y = 0; y < dst_num_lines; y += 4) { for (int x = 0; x < dst_width; x += 4) { float fblock[16]; zfp_decode_block_float_2(zfp, fblock); for (int j = 0; j < 4; j++) { for (int i = 0; i < 4; i++) { dst[c * image_size + ((y + j) * dst_width + (x + i))] = fblock[j * 4 + i]; } } } } } zfp_field_free(field); zfp_stream_close(zfp); stream_close(stream); return true; } // Assume pixel format is FLOAT for all channels. bool CompressZfp(std::vector *outBuf, unsigned int *outSize, const float *inPtr, int width, int num_lines, int num_channels, const ZFPCompressionParam ¶m) { zfp_stream *zfp = NULL; zfp_field *field = NULL; assert((width % 4) == 0); assert((num_lines % 4) == 0); if ((width & 3U) || (num_lines & 3U)) { return false; } // create input array. field = zfp_field_2d(reinterpret_cast(const_cast(inPtr)), zfp_type_float, width, num_lines * num_channels); zfp = zfp_stream_open(NULL); if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_RATE) { zfp_stream_set_rate(zfp, param.rate, zfp_type_float, 2, 0); } else if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_PRECISION) { zfp_stream_set_precision(zfp, param.precision, zfp_type_float); } else if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_ACCURACY) { zfp_stream_set_accuracy(zfp, param.tolerance, zfp_type_float); } else { assert(0); } size_t buf_size = zfp_stream_maximum_size(zfp, field); outBuf->resize(buf_size); bitstream *stream = stream_open(&outBuf->at(0), buf_size); zfp_stream_set_bit_stream(zfp, stream); zfp_field_free(field); size_t image_size = width * num_lines; for (int c = 0; c < num_channels; c++) { // compress 4x4 pixel block. for (int y = 0; y < num_lines; y += 4) { for (int x = 0; x < width; x += 4) { float fblock[16]; for (int j = 0; j < 4; j++) { for (int i = 0; i < 4; i++) { fblock[j * 4 + i] = inPtr[c * image_size + ((y + j) * width + (x + i))]; } } zfp_encode_block_float_2(zfp, fblock); } } } zfp_stream_flush(zfp); (*outSize) = zfp_stream_compressed_size(zfp); zfp_stream_close(zfp); return true; } #endif // // ----------------------------------------------------------------- // static void DecodePixelData(/* out */ unsigned char **out_images, const int *requested_pixel_types, const unsigned char *data_ptr, size_t data_len, int compression_type, int line_order, int width, int height, int x_stride, int y, int line_no, int num_lines, size_t pixel_data_size, size_t num_attributes, const EXRAttribute *attributes, size_t num_channels, const EXRChannelInfo *channels, const std::vector &channel_offset_list) { if (compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { // PIZ #if TINYEXR_USE_PIZ // Allocate original data size. std::vector outBuf(static_cast( static_cast(width * num_lines) * pixel_data_size)); size_t tmpBufLen = outBuf.size(); bool ret = tinyexr::DecompressPiz( reinterpret_cast(&outBuf.at(0)), data_ptr, tmpBufLen, data_len, static_cast(num_channels), channels, width, num_lines); assert(ret); (void)ret; // For PIZ_COMPRESSION: // pixel sample data for channel 0 for scanline 0 // pixel sample data for channel 1 for scanline 0 // pixel sample data for channel ... for scanline 0 // pixel sample data for channel n for scanline 0 // pixel sample data for channel 0 for scanline 1 // pixel sample data for channel 1 for scanline 1 // pixel sample data for channel ... for scanline 1 // pixel sample data for channel n for scanline 1 // ... for (size_t c = 0; c < static_cast(num_channels); c++) { if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { for (size_t v = 0; v < static_cast(num_lines); v++) { const unsigned short *line_ptr = reinterpret_cast( &outBuf.at(v * pixel_data_size * static_cast(width) + channel_offset_list[c] * static_cast(width))); for (size_t u = 0; u < static_cast(width); u++) { FP16 hf; hf.u = line_ptr[u]; tinyexr::swap2(reinterpret_cast(&hf.u)); if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { unsigned short *image = reinterpret_cast(out_images)[c]; if (line_order == 0) { image += (static_cast(line_no) + v) * static_cast(x_stride) + u; } else { image += static_cast( (height - 1 - (line_no + static_cast(v)))) * static_cast(x_stride) + u; } *image = hf.u; } else { // HALF -> FLOAT FP32 f32 = half_to_float(hf); float *image = reinterpret_cast(out_images)[c]; if (line_order == 0) { image += (static_cast(line_no) + v) * static_cast(x_stride) + u; } else { image += static_cast( (height - 1 - (line_no + static_cast(v)))) * static_cast(x_stride) + u; } *image = f32.f; } } } } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) { assert(requested_pixel_types[c] == TINYEXR_PIXELTYPE_UINT); for (size_t v = 0; v < static_cast(num_lines); v++) { const unsigned int *line_ptr = reinterpret_cast( &outBuf.at(v * pixel_data_size * static_cast(width) + channel_offset_list[c] * static_cast(width))); for (size_t u = 0; u < static_cast(width); u++) { unsigned int val = line_ptr[u]; tinyexr::swap4(&val); unsigned int *image = reinterpret_cast(out_images)[c]; if (line_order == 0) { image += (static_cast(line_no) + v) * static_cast(x_stride) + u; } else { image += static_cast( (height - 1 - (line_no + static_cast(v)))) * static_cast(x_stride) + u; } *image = val; } } } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { assert(requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT); for (size_t v = 0; v < static_cast(num_lines); v++) { const float *line_ptr = reinterpret_cast(&outBuf.at( v * pixel_data_size * static_cast(x_stride) + channel_offset_list[c] * static_cast(x_stride))); for (size_t u = 0; u < static_cast(width); u++) { float val = line_ptr[u]; tinyexr::swap4(reinterpret_cast(&val)); float *image = reinterpret_cast(out_images)[c]; if (line_order == 0) { image += (static_cast(line_no) + v) * static_cast(x_stride) + u; } else { image += static_cast( (height - 1 - (line_no + static_cast(v)))) * static_cast(x_stride) + u; } *image = val; } } } else { assert(0); } } #else assert(0 && "PIZ is enabled in this build"); #endif } else if (compression_type == TINYEXR_COMPRESSIONTYPE_ZIPS || compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) { // Allocate original data size. std::vector outBuf(static_cast(width) * static_cast(num_lines) * pixel_data_size); unsigned long dstLen = static_cast(outBuf.size()); assert(dstLen > 0); tinyexr::DecompressZip(reinterpret_cast(&outBuf.at(0)), &dstLen, data_ptr, static_cast(data_len)); // For ZIP_COMPRESSION: // pixel sample data for channel 0 for scanline 0 // pixel sample data for channel 1 for scanline 0 // pixel sample data for channel ... for scanline 0 // pixel sample data for channel n for scanline 0 // pixel sample data for channel 0 for scanline 1 // pixel sample data for channel 1 for scanline 1 // pixel sample data for channel ... for scanline 1 // pixel sample data for channel n for scanline 1 // ... for (size_t c = 0; c < static_cast(num_channels); c++) { if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { for (size_t v = 0; v < static_cast(num_lines); v++) { const unsigned short *line_ptr = reinterpret_cast( &outBuf.at(v * static_cast(pixel_data_size) * static_cast(width) + channel_offset_list[c] * static_cast(width))); for (size_t u = 0; u < static_cast(width); u++) { tinyexr::FP16 hf; hf.u = line_ptr[u]; tinyexr::swap2(reinterpret_cast(&hf.u)); if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { unsigned short *image = reinterpret_cast(out_images)[c]; if (line_order == 0) { image += (static_cast(line_no) + v) * static_cast(x_stride) + u; } else { image += (static_cast(height) - 1U - (static_cast(line_no) + v)) * static_cast(x_stride) + u; } *image = hf.u; } else { // HALF -> FLOAT tinyexr::FP32 f32 = half_to_float(hf); float *image = reinterpret_cast(out_images)[c]; if (line_order == 0) { image += (static_cast(line_no) + v) * static_cast(x_stride) + u; } else { image += (static_cast(height) - 1U - (static_cast(line_no) + v)) * static_cast(x_stride) + u; } *image = f32.f; } } } } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) { assert(requested_pixel_types[c] == TINYEXR_PIXELTYPE_UINT); for (size_t v = 0; v < static_cast(num_lines); v++) { const unsigned int *line_ptr = reinterpret_cast( &outBuf.at(v * pixel_data_size * static_cast(width) + channel_offset_list[c] * static_cast(width))); for (size_t u = 0; u < static_cast(width); u++) { unsigned int val = line_ptr[u]; tinyexr::swap4(&val); unsigned int *image = reinterpret_cast(out_images)[c]; if (line_order == 0) { image += (static_cast(line_no) + v) * static_cast(x_stride) + u; } else { image += (static_cast(height) - 1U - (static_cast(line_no) + v)) * static_cast(x_stride) + u; } *image = val; } } } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { assert(requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT); for (size_t v = 0; v < static_cast(num_lines); v++) { const float *line_ptr = reinterpret_cast( &outBuf.at(v * pixel_data_size * static_cast(width) + channel_offset_list[c] * static_cast(width))); for (size_t u = 0; u < static_cast(width); u++) { float val = line_ptr[u]; tinyexr::swap4(reinterpret_cast(&val)); float *image = reinterpret_cast(out_images)[c]; if (line_order == 0) { image += (static_cast(line_no) + v) * static_cast(x_stride) + u; } else { image += (static_cast(height) - 1U - (static_cast(line_no) + v)) * static_cast(x_stride) + u; } *image = val; } } } else { assert(0); } } } else if (compression_type == TINYEXR_COMPRESSIONTYPE_RLE) { // Allocate original data size. std::vector outBuf(static_cast(width) * static_cast(num_lines) * pixel_data_size); unsigned long dstLen = static_cast(outBuf.size()); assert(dstLen > 0); tinyexr::DecompressRle(reinterpret_cast(&outBuf.at(0)), dstLen, data_ptr, static_cast(data_len)); // For RLE_COMPRESSION: // pixel sample data for channel 0 for scanline 0 // pixel sample data for channel 1 for scanline 0 // pixel sample data for channel ... for scanline 0 // pixel sample data for channel n for scanline 0 // pixel sample data for channel 0 for scanline 1 // pixel sample data for channel 1 for scanline 1 // pixel sample data for channel ... for scanline 1 // pixel sample data for channel n for scanline 1 // ... for (size_t c = 0; c < static_cast(num_channels); c++) { if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { for (size_t v = 0; v < static_cast(num_lines); v++) { const unsigned short *line_ptr = reinterpret_cast( &outBuf.at(v * static_cast(pixel_data_size) * static_cast(width) + channel_offset_list[c] * static_cast(width))); for (size_t u = 0; u < static_cast(width); u++) { tinyexr::FP16 hf; hf.u = line_ptr[u]; tinyexr::swap2(reinterpret_cast(&hf.u)); if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { unsigned short *image = reinterpret_cast(out_images)[c]; if (line_order == 0) { image += (static_cast(line_no) + v) * static_cast(x_stride) + u; } else { image += (static_cast(height) - 1U - (static_cast(line_no) + v)) * static_cast(x_stride) + u; } *image = hf.u; } else { // HALF -> FLOAT tinyexr::FP32 f32 = half_to_float(hf); float *image = reinterpret_cast(out_images)[c]; if (line_order == 0) { image += (static_cast(line_no) + v) * static_cast(x_stride) + u; } else { image += (static_cast(height) - 1U - (static_cast(line_no) + v)) * static_cast(x_stride) + u; } *image = f32.f; } } } } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) { assert(requested_pixel_types[c] == TINYEXR_PIXELTYPE_UINT); for (size_t v = 0; v < static_cast(num_lines); v++) { const unsigned int *line_ptr = reinterpret_cast( &outBuf.at(v * pixel_data_size * static_cast(width) + channel_offset_list[c] * static_cast(width))); for (size_t u = 0; u < static_cast(width); u++) { unsigned int val = line_ptr[u]; tinyexr::swap4(&val); unsigned int *image = reinterpret_cast(out_images)[c]; if (line_order == 0) { image += (static_cast(line_no) + v) * static_cast(x_stride) + u; } else { image += (static_cast(height) - 1U - (static_cast(line_no) + v)) * static_cast(x_stride) + u; } *image = val; } } } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { assert(requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT); for (size_t v = 0; v < static_cast(num_lines); v++) { const float *line_ptr = reinterpret_cast( &outBuf.at(v * pixel_data_size * static_cast(width) + channel_offset_list[c] * static_cast(width))); for (size_t u = 0; u < static_cast(width); u++) { float val = line_ptr[u]; tinyexr::swap4(reinterpret_cast(&val)); float *image = reinterpret_cast(out_images)[c]; if (line_order == 0) { image += (static_cast(line_no) + v) * static_cast(x_stride) + u; } else { image += (static_cast(height) - 1U - (static_cast(line_no) + v)) * static_cast(x_stride) + u; } *image = val; } } } else { assert(0); } } } else if (compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { #if TINYEXR_USE_ZFP tinyexr::ZFPCompressionParam zfp_compression_param; if (!FindZFPCompressionParam(&zfp_compression_param, attributes, num_attributes)) { assert(0); return; } // Allocate original data size. std::vector outBuf(static_cast(width) * static_cast(num_lines) * pixel_data_size); unsigned long dstLen = outBuf.size(); assert(dstLen > 0); tinyexr::DecompressZfp(reinterpret_cast(&outBuf.at(0)), width, num_lines, num_channels, data_ptr, static_cast(data_len), zfp_compression_param); // For ZFP_COMPRESSION: // pixel sample data for channel 0 for scanline 0 // pixel sample data for channel 1 for scanline 0 // pixel sample data for channel ... for scanline 0 // pixel sample data for channel n for scanline 0 // pixel sample data for channel 0 for scanline 1 // pixel sample data for channel 1 for scanline 1 // pixel sample data for channel ... for scanline 1 // pixel sample data for channel n for scanline 1 // ... for (size_t c = 0; c < static_cast(num_channels); c++) { assert(channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT); if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { assert(requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT); for (size_t v = 0; v < static_cast(num_lines); v++) { const float *line_ptr = reinterpret_cast( &outBuf.at(v * pixel_data_size * static_cast(width) + channel_offset_list[c] * static_cast(width))); for (size_t u = 0; u < static_cast(width); u++) { float val = line_ptr[u]; tinyexr::swap4(reinterpret_cast(&val)); float *image = reinterpret_cast(out_images)[c]; if (line_order == 0) { image += (static_cast(line_no) + v) * static_cast(x_stride) + u; } else { image += (static_cast(height) - 1U - (static_cast(line_no) + v)) * static_cast(x_stride) + u; } *image = val; } } } else { assert(0); } } #else (void)attributes; (void)num_attributes; (void)num_channels; assert(0); #endif } else if (compression_type == TINYEXR_COMPRESSIONTYPE_NONE) { for (size_t c = 0; c < num_channels; c++) { if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { const unsigned short *line_ptr = reinterpret_cast( data_ptr + c * static_cast(width) * sizeof(unsigned short)); if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { unsigned short *outLine = reinterpret_cast(out_images[c]); if (line_order == 0) { outLine += y * x_stride; } else { outLine += (height - 1 - y) * x_stride; } for (int u = 0; u < width; u++) { tinyexr::FP16 hf; hf.u = line_ptr[u]; tinyexr::swap2(reinterpret_cast(&hf.u)); outLine[u] = hf.u; } } else if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) { float *outLine = reinterpret_cast(out_images[c]); if (line_order == 0) { outLine += y * x_stride; } else { outLine += (height - 1 - y) * x_stride; } for (int u = 0; u < width; u++) { tinyexr::FP16 hf; hf.u = line_ptr[u]; tinyexr::swap2(reinterpret_cast(&hf.u)); tinyexr::FP32 f32 = half_to_float(hf); outLine[u] = f32.f; } } else { assert(0); } } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { const float *line_ptr = reinterpret_cast( data_ptr + c * static_cast(width) * sizeof(float)); float *outLine = reinterpret_cast(out_images[c]); if (line_order == 0) { outLine += y * x_stride; } else { outLine += (height - 1 - y) * x_stride; } for (int u = 0; u < width; u++) { float val = line_ptr[u]; tinyexr::swap4(reinterpret_cast(&val)); outLine[u] = val; } } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) { const unsigned int *line_ptr = reinterpret_cast( data_ptr + c * static_cast(width) * sizeof(unsigned int)); unsigned int *outLine = reinterpret_cast(out_images[c]); if (line_order == 0) { outLine += y * x_stride; } else { outLine += (height - 1 - y) * x_stride; } for (int u = 0; u < width; u++) { unsigned int val = line_ptr[u]; tinyexr::swap4(reinterpret_cast(&val)); outLine[u] = val; } } } } } static void DecodeTiledPixelData( unsigned char **out_images, int *width, int *height, const int *requested_pixel_types, const unsigned char *data_ptr, size_t data_len, int compression_type, int line_order, int data_width, int data_height, int tile_offset_x, int tile_offset_y, int tile_size_x, int tile_size_y, size_t pixel_data_size, size_t num_attributes, const EXRAttribute *attributes, size_t num_channels, const EXRChannelInfo *channels, const std::vector &channel_offset_list) { assert(tile_offset_x * tile_size_x < data_width); assert(tile_offset_y * tile_size_y < data_height); // Compute actual image size in a tile. if ((tile_offset_x + 1) * tile_size_x >= data_width) { (*width) = data_width - (tile_offset_x * tile_size_x); } else { (*width) = tile_size_x; } if ((tile_offset_y + 1) * tile_size_y >= data_height) { (*height) = data_height - (tile_offset_y * tile_size_y); } else { (*height) = tile_size_y; } // Image size = tile size. DecodePixelData(out_images, requested_pixel_types, data_ptr, data_len, compression_type, line_order, (*width), tile_size_y, /* stride */ tile_size_x, /* y */ 0, /* line_no */ 0, (*height), pixel_data_size, num_attributes, attributes, num_channels, channels, channel_offset_list); } static void ComputeChannelLayout(std::vector *channel_offset_list, int *pixel_data_size, size_t *channel_offset, int num_channels, const EXRChannelInfo *channels) { channel_offset_list->resize(static_cast(num_channels)); (*pixel_data_size) = 0; (*channel_offset) = 0; for (size_t c = 0; c < static_cast(num_channels); c++) { (*channel_offset_list)[c] = (*channel_offset); if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { (*pixel_data_size) += sizeof(unsigned short); (*channel_offset) += sizeof(unsigned short); } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { (*pixel_data_size) += sizeof(float); (*channel_offset) += sizeof(float); } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) { (*pixel_data_size) += sizeof(unsigned int); (*channel_offset) += sizeof(unsigned int); } else { assert(0); } } } static unsigned char **AllocateImage(int num_channels, const EXRChannelInfo *channels, const int *requested_pixel_types, int data_width, int data_height) { unsigned char **images = reinterpret_cast(static_cast( malloc(sizeof(float *) * static_cast(num_channels)))); for (size_t c = 0; c < static_cast(num_channels); c++) { size_t data_len = static_cast(data_width) * static_cast(data_height); if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { // pixel_data_size += sizeof(unsigned short); // channel_offset += sizeof(unsigned short); // Alloc internal image for half type. if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { images[c] = reinterpret_cast(static_cast( malloc(sizeof(unsigned short) * data_len))); } else if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) { images[c] = reinterpret_cast( static_cast(malloc(sizeof(float) * data_len))); } else { assert(0); } } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { // pixel_data_size += sizeof(float); // channel_offset += sizeof(float); images[c] = reinterpret_cast( static_cast(malloc(sizeof(float) * data_len))); } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) { // pixel_data_size += sizeof(unsigned int); // channel_offset += sizeof(unsigned int); images[c] = reinterpret_cast( static_cast(malloc(sizeof(unsigned int) * data_len))); } else { assert(0); } } return images; } static int ParseEXRHeader(HeaderInfo *info, bool *empty_header, const EXRVersion *version, std::string *err, const unsigned char *buf, size_t size) { const char *marker = reinterpret_cast(&buf[0]); if (empty_header) { (*empty_header) = false; } if (version->multipart) { if (size > 0 && marker[0] == '\0') { // End of header list. if (empty_header) { (*empty_header) = true; } return TINYEXR_SUCCESS; } } // According to the spec, the header of every OpenEXR file must contain at // least the following attributes: // // channels chlist // compression compression // dataWindow box2i // displayWindow box2i // lineOrder lineOrder // pixelAspectRatio float // screenWindowCenter v2f // screenWindowWidth float bool has_channels = false; bool has_compression = false; bool has_data_window = false; bool has_display_window = false; bool has_line_order = false; bool has_pixel_aspect_ratio = false; bool has_screen_window_center = false; bool has_screen_window_width = false; info->data_window[0] = 0; info->data_window[1] = 0; info->data_window[2] = 0; info->data_window[3] = 0; info->line_order = 0; // @fixme info->display_window[0] = 0; info->display_window[1] = 0; info->display_window[2] = 0; info->display_window[3] = 0; info->screen_window_center[0] = 0.0f; info->screen_window_center[1] = 0.0f; info->screen_window_width = -1.0f; info->pixel_aspect_ratio = -1.0f; info->tile_size_x = -1; info->tile_size_y = -1; info->tile_level_mode = -1; info->tile_rounding_mode = -1; info->attributes.clear(); // Read attributes size_t orig_size = size; for (;;) { if (0 == size) { return TINYEXR_ERROR_INVALID_DATA; } else if (marker[0] == '\0') { size--; break; } std::string attr_name; std::string attr_type; std::vector data; size_t marker_size; if (!tinyexr::ReadAttribute(&attr_name, &attr_type, &data, &marker_size, marker, size)) { return TINYEXR_ERROR_INVALID_DATA; } marker += marker_size; size -= marker_size; if (version->tiled && attr_name.compare("tiles") == 0) { unsigned int x_size, y_size; unsigned char tile_mode; assert(data.size() == 9); memcpy(&x_size, &data.at(0), sizeof(int)); memcpy(&y_size, &data.at(4), sizeof(int)); tile_mode = data[8]; tinyexr::swap4(&x_size); tinyexr::swap4(&y_size); info->tile_size_x = static_cast(x_size); info->tile_size_y = static_cast(y_size); // mode = levelMode + roundingMode * 16 info->tile_level_mode = tile_mode & 0x3; info->tile_rounding_mode = (tile_mode >> 4) & 0x1; } else if (attr_name.compare("compression") == 0) { bool ok = false; if (data[0] < TINYEXR_COMPRESSIONTYPE_PIZ) { ok = true; } if (data[0] == TINYEXR_COMPRESSIONTYPE_PIZ) { #if TINYEXR_USE_PIZ ok = true; #else if (err) { (*err) = "PIZ compression is not supported."; } return TINYEXR_ERROR_UNSUPPORTED_FORMAT; #endif } if (data[0] == TINYEXR_COMPRESSIONTYPE_ZFP) { #if TINYEXR_USE_ZFP ok = true; #else if (err) { (*err) = "ZFP compression is not supported."; } return TINYEXR_ERROR_UNSUPPORTED_FORMAT; #endif } if (!ok) { if (err) { (*err) = "Unknown compression type."; } return TINYEXR_ERROR_UNSUPPORTED_FORMAT; } info->compression_type = static_cast(data[0]); has_compression = true; } else if (attr_name.compare("channels") == 0) { // name: zero-terminated string, from 1 to 255 bytes long // pixel type: int, possible values are: UINT = 0 HALF = 1 FLOAT = 2 // pLinear: unsigned char, possible values are 0 and 1 // reserved: three chars, should be zero // xSampling: int // ySampling: int ReadChannelInfo(info->channels, data); if (info->channels.size() < 1) { if (err) { (*err) = "# of channels is zero."; } return TINYEXR_ERROR_INVALID_DATA; } has_channels = true; } else if (attr_name.compare("dataWindow") == 0) { memcpy(&info->data_window[0], &data.at(0), sizeof(int)); memcpy(&info->data_window[1], &data.at(4), sizeof(int)); memcpy(&info->data_window[2], &data.at(8), sizeof(int)); memcpy(&info->data_window[3], &data.at(12), sizeof(int)); tinyexr::swap4(reinterpret_cast(&info->data_window[0])); tinyexr::swap4(reinterpret_cast(&info->data_window[1])); tinyexr::swap4(reinterpret_cast(&info->data_window[2])); tinyexr::swap4(reinterpret_cast(&info->data_window[3])); has_data_window = true; } else if (attr_name.compare("displayWindow") == 0) { memcpy(&info->display_window[0], &data.at(0), sizeof(int)); memcpy(&info->display_window[1], &data.at(4), sizeof(int)); memcpy(&info->display_window[2], &data.at(8), sizeof(int)); memcpy(&info->display_window[3], &data.at(12), sizeof(int)); tinyexr::swap4( reinterpret_cast(&info->display_window[0])); tinyexr::swap4( reinterpret_cast(&info->display_window[1])); tinyexr::swap4( reinterpret_cast(&info->display_window[2])); tinyexr::swap4( reinterpret_cast(&info->display_window[3])); has_display_window = true; } else if (attr_name.compare("lineOrder") == 0) { info->line_order = static_cast(data[0]); has_line_order = true; } else if (attr_name.compare("pixelAspectRatio") == 0) { memcpy(&info->pixel_aspect_ratio, &data.at(0), sizeof(float)); tinyexr::swap4( reinterpret_cast(&info->pixel_aspect_ratio)); has_pixel_aspect_ratio = true; } else if (attr_name.compare("screenWindowCenter") == 0) { memcpy(&info->screen_window_center[0], &data.at(0), sizeof(float)); memcpy(&info->screen_window_center[1], &data.at(4), sizeof(float)); tinyexr::swap4( reinterpret_cast(&info->screen_window_center[0])); tinyexr::swap4( reinterpret_cast(&info->screen_window_center[1])); has_screen_window_center = true; } else if (attr_name.compare("screenWindowWidth") == 0) { memcpy(&info->screen_window_width, &data.at(0), sizeof(float)); tinyexr::swap4( reinterpret_cast(&info->screen_window_width)); has_screen_window_width = true; } else if (attr_name.compare("chunkCount") == 0) { memcpy(&info->chunk_count, &data.at(0), sizeof(int)); tinyexr::swap4(reinterpret_cast(&info->chunk_count)); } else { // Custom attribute(up to TINYEXR_MAX_ATTRIBUTES) if (info->attributes.size() < TINYEXR_MAX_ATTRIBUTES) { EXRAttribute attrib; strncpy(attrib.name, attr_name.c_str(), 255); attrib.name[255] = '\0'; strncpy(attrib.type, attr_type.c_str(), 255); attrib.type[255] = '\0'; attrib.size = static_cast(data.size()); attrib.value = static_cast(malloc(data.size())); memcpy(reinterpret_cast(attrib.value), &data.at(0), data.size()); info->attributes.push_back(attrib); } } } // Check if required attributes exist { std::stringstream ss_err; if (!has_compression) { ss_err << "\"compression\" attribute not found in the header." << std::endl; } if (!has_channels) { ss_err << "\"channels\" attribute not found in the header." << std::endl; } if (!has_line_order) { ss_err << "\"lineOrder\" attribute not found in the header." << std::endl; } if (!has_display_window) { ss_err << "\"displayWindow\" attribute not found in the header." << std::endl; } if (!has_data_window) { ss_err << "\"dataWindow\" attribute not found in the header." << std::endl; } if (!has_pixel_aspect_ratio) { ss_err << "\"pixelAspectRatio\" attribute not found in the header." << std::endl; } if (!has_screen_window_width) { ss_err << "\"screenWindowWidth\" attribute not found in the header." << std::endl; } if (!has_screen_window_center) { ss_err << "\"screenWindowCenter\" attribute not found in the header." << std::endl; } if (!(ss_err.str().empty())) { if (err) { (*err) += ss_err.str(); } return TINYEXR_ERROR_INVALID_HEADER; } } info->header_len = static_cast(orig_size - size); return TINYEXR_SUCCESS; } // C++ HeaderInfo to C EXRHeader conversion. static void ConvertHeader(EXRHeader *exr_header, const HeaderInfo &info) { exr_header->pixel_aspect_ratio = info.pixel_aspect_ratio; exr_header->screen_window_center[0] = info.screen_window_center[0]; exr_header->screen_window_center[1] = info.screen_window_center[1]; exr_header->screen_window_width = info.screen_window_width; exr_header->chunk_count = info.chunk_count; exr_header->display_window[0] = info.display_window[0]; exr_header->display_window[1] = info.display_window[1]; exr_header->display_window[2] = info.display_window[2]; exr_header->display_window[3] = info.display_window[3]; exr_header->data_window[0] = info.data_window[0]; exr_header->data_window[1] = info.data_window[1]; exr_header->data_window[2] = info.data_window[2]; exr_header->data_window[3] = info.data_window[3]; exr_header->line_order = info.line_order; exr_header->compression_type = info.compression_type; exr_header->tile_size_x = info.tile_size_x; exr_header->tile_size_y = info.tile_size_y; exr_header->tile_level_mode = info.tile_level_mode; exr_header->tile_rounding_mode = info.tile_rounding_mode; exr_header->num_channels = static_cast(info.channels.size()); exr_header->channels = static_cast(malloc( sizeof(EXRChannelInfo) * static_cast(exr_header->num_channels))); for (size_t c = 0; c < static_cast(exr_header->num_channels); c++) { strncpy(exr_header->channels[c].name, info.channels[c].name.c_str(), 255); // manually add '\0' for safety. exr_header->channels[c].name[255] = '\0'; exr_header->channels[c].pixel_type = info.channels[c].pixel_type; exr_header->channels[c].p_linear = info.channels[c].p_linear; exr_header->channels[c].x_sampling = info.channels[c].x_sampling; exr_header->channels[c].y_sampling = info.channels[c].y_sampling; } exr_header->pixel_types = static_cast( malloc(sizeof(int) * static_cast(exr_header->num_channels))); for (size_t c = 0; c < static_cast(exr_header->num_channels); c++) { exr_header->pixel_types[c] = info.channels[c].pixel_type; } // Initially fill with values of `pixel_types` exr_header->requested_pixel_types = static_cast( malloc(sizeof(int) * static_cast(exr_header->num_channels))); for (size_t c = 0; c < static_cast(exr_header->num_channels); c++) { exr_header->requested_pixel_types[c] = info.channels[c].pixel_type; } assert(info.attributes.size() < TINYEXR_MAX_ATTRIBUTES); exr_header->num_custom_attributes = static_cast(info.attributes.size()); for (size_t i = 0; i < info.attributes.size(); i++) { memcpy(exr_header->custom_attributes[i].name, info.attributes[i].name, 256); memcpy(exr_header->custom_attributes[i].type, info.attributes[i].type, 256); exr_header->custom_attributes[i].size = info.attributes[i].size; // Just copy poiner exr_header->custom_attributes[i].value = info.attributes[i].value; } exr_header->header_len = info.header_len; } static int DecodeChunk(EXRImage *exr_image, const EXRHeader *exr_header, const std::vector &offsets, const unsigned char *head) { int num_channels = exr_header->num_channels; int num_scanline_blocks = 1; if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) { num_scanline_blocks = 16; } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { num_scanline_blocks = 32; } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { num_scanline_blocks = 16; } int data_width = exr_header->data_window[2] - exr_header->data_window[0] + 1; int data_height = exr_header->data_window[3] - exr_header->data_window[1] + 1; size_t num_blocks = offsets.size(); std::vector channel_offset_list; int pixel_data_size = 0; size_t channel_offset = 0; tinyexr::ComputeChannelLayout(&channel_offset_list, &pixel_data_size, &channel_offset, num_channels, exr_header->channels); if (exr_header->tiled) { size_t num_tiles = offsets.size(); // = # of blocks exr_image->tiles = static_cast( malloc(sizeof(EXRTile) * static_cast(num_tiles))); for (size_t tile_idx = 0; tile_idx < num_tiles; tile_idx++) { // Allocate memory for each tile. exr_image->tiles[tile_idx].images = tinyexr::AllocateImage( num_channels, exr_header->channels, exr_header->requested_pixel_types, data_width, data_height); // 16 byte: tile coordinates // 4 byte : data size // ~ : data(uncompressed or compressed) const unsigned char *data_ptr = reinterpret_cast(head + offsets[tile_idx]); int tile_coordinates[4]; memcpy(tile_coordinates, data_ptr, sizeof(int) * 4); tinyexr::swap4(reinterpret_cast(&tile_coordinates[0])); tinyexr::swap4(reinterpret_cast(&tile_coordinates[1])); tinyexr::swap4(reinterpret_cast(&tile_coordinates[2])); tinyexr::swap4(reinterpret_cast(&tile_coordinates[3])); // @todo{ LoD } assert(tile_coordinates[2] == 0); assert(tile_coordinates[3] == 0); int data_len; memcpy(&data_len, data_ptr + 16, sizeof(int)); // 16 = sizeof(tile_coordinates) tinyexr::swap4(reinterpret_cast(&data_len)); assert(data_len >= 4); // Move to data addr: 20 = 16 + 4; data_ptr += 20; tinyexr::DecodeTiledPixelData( exr_image->tiles[tile_idx].images, &(exr_image->tiles[tile_idx].width), &(exr_image->tiles[tile_idx].height), exr_header->requested_pixel_types, data_ptr, static_cast(data_len), exr_header->compression_type, exr_header->line_order, data_width, data_height, tile_coordinates[0], tile_coordinates[1], exr_header->tile_size_x, exr_header->tile_size_y, static_cast(pixel_data_size), static_cast(exr_header->num_custom_attributes), exr_header->custom_attributes, static_cast(exr_header->num_channels), exr_header->channels, channel_offset_list); exr_image->tiles[tile_idx].offset_x = tile_coordinates[0]; exr_image->tiles[tile_idx].offset_y = tile_coordinates[1]; exr_image->tiles[tile_idx].level_x = tile_coordinates[2]; exr_image->tiles[tile_idx].level_y = tile_coordinates[3]; exr_image->num_tiles = static_cast(num_tiles); } } else { // scanline format exr_image->images = tinyexr::AllocateImage( num_channels, exr_header->channels, exr_header->requested_pixel_types, data_width, data_height); #ifdef _OPENMP #pragma omp parallel for #endif for (int y = 0; y < static_cast(num_blocks); y++) { size_t y_idx = static_cast(y); const unsigned char *data_ptr = reinterpret_cast(head + offsets[y_idx]); // 4 byte: scan line // 4 byte: data size // ~ : pixel data(uncompressed or compressed) int line_no; memcpy(&line_no, data_ptr, sizeof(int)); int data_len; memcpy(&data_len, data_ptr + 4, sizeof(int)); tinyexr::swap4(reinterpret_cast(&line_no)); tinyexr::swap4(reinterpret_cast(&data_len)); int end_line_no = (std::min)(line_no + num_scanline_blocks, (exr_header->data_window[3] + 1)); int num_lines = end_line_no - line_no; assert(num_lines > 0); // Move to data addr: 8 = 4 + 4; data_ptr += 8; // Adjust line_no with data_window.bmin.y line_no -= exr_header->data_window[1]; tinyexr::DecodePixelData( exr_image->images, exr_header->requested_pixel_types, data_ptr, static_cast(data_len), exr_header->compression_type, exr_header->line_order, data_width, data_height, data_width, y, line_no, num_lines, static_cast(pixel_data_size), static_cast(exr_header->num_custom_attributes), exr_header->custom_attributes, static_cast(exr_header->num_channels), exr_header->channels, channel_offset_list); } // omp parallel } // Overwrite `pixel_type` with `requested_pixel_type`. { for (int c = 0; c < exr_header->num_channels; c++) { exr_header->pixel_types[c] = exr_header->requested_pixel_types[c]; } } { exr_image->num_channels = num_channels; exr_image->width = data_width; exr_image->height = data_height; } return TINYEXR_SUCCESS; } static bool ReconstructLineOffsets( std::vector *offsets, size_t n, const unsigned char *head, const unsigned char *marker, const size_t size) { assert(head < marker); assert(offsets->size() == n); for (size_t i = 0; i < n; i++) { size_t offset = static_cast(marker - head); // Offset should not exceed whole EXR file/data size. if (offset >= size) { return false; } int y; unsigned int data_len; memcpy(&y, marker, sizeof(int)); memcpy(&data_len, marker + 4, sizeof(unsigned int)); if (data_len >= size) { return false; } tinyexr::swap4(reinterpret_cast(&y)); tinyexr::swap4(reinterpret_cast(&data_len)); (*offsets)[i] = offset; marker += data_len + 8; // 8 = 4 bytes(y) + 4 bytes(data_len) } return true; } static int DecodeEXRImage(EXRImage *exr_image, const EXRHeader *exr_header, const unsigned char *head, const unsigned char *marker, const size_t size, const char **err) { if (exr_image == NULL || exr_header == NULL || head == NULL || marker == NULL || (size <= tinyexr::kEXRVersionSize)) { if (err) { (*err) = "Invalid argument."; } return TINYEXR_ERROR_INVALID_ARGUMENT; } int num_scanline_blocks = 1; if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) { num_scanline_blocks = 16; } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { num_scanline_blocks = 32; } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { num_scanline_blocks = 16; } int data_width = exr_header->data_window[2] - exr_header->data_window[0] + 1; int data_height = exr_header->data_window[3] - exr_header->data_window[1] + 1; // Read offset tables. size_t num_blocks; if (exr_header->chunk_count > 0) { // Use `chunkCount` attribute. num_blocks = static_cast(exr_header->chunk_count); } else if (exr_header->tiled) { // @todo { LoD } size_t num_x_tiles = static_cast(data_width) / static_cast(exr_header->tile_size_x); if (num_x_tiles * static_cast(exr_header->tile_size_x) < static_cast(data_width)) { num_x_tiles++; } size_t num_y_tiles = static_cast(data_height) / static_cast(exr_header->tile_size_y); if (num_y_tiles * static_cast(exr_header->tile_size_y) < static_cast(data_height)) { num_y_tiles++; } num_blocks = num_x_tiles * num_y_tiles; } else { num_blocks = static_cast(data_height) / static_cast(num_scanline_blocks); if (num_blocks * static_cast(num_scanline_blocks) < static_cast(data_height)) { num_blocks++; } } std::vector offsets(num_blocks); for (size_t y = 0; y < num_blocks; y++) { tinyexr::tinyexr_uint64 offset; memcpy(&offset, marker, sizeof(tinyexr::tinyexr_uint64)); tinyexr::swap8(&offset); if (offset >= size) { if (err) { (*err) = "Invalid offset value."; } return TINYEXR_ERROR_INVALID_DATA; } marker += sizeof(tinyexr::tinyexr_uint64); // = 8 offsets[y] = offset; } // If line offsets are invalid, we try to reconstruct it. // See OpenEXR/IlmImf/ImfScanLineInputFile.cpp::readLineOffsets() for details. for (size_t y = 0; y < num_blocks; y++) { if (offsets[y] <= 0) { // TODO(syoyo) Report as warning? // if (err) { // stringstream ss; // ss << "Incomplete lineOffsets." << std::endl; // (*err) += ss.str(); //} bool ret = ReconstructLineOffsets(&offsets, num_blocks, head, marker, size); if (ret) { // OK break; } else { if (err) { (*err) = "Cannot reconstruct lineOffset table."; } return TINYEXR_ERROR_INVALID_DATA; } } } return DecodeChunk(exr_image, exr_header, offsets, head); } } // namespace tinyexr int LoadEXR(float **out_rgba, int *width, int *height, const char *filename, const char **err) { if (out_rgba == NULL) { if (err) { (*err) = "Invalid argument.\n"; } return TINYEXR_ERROR_INVALID_ARGUMENT; } EXRVersion exr_version; EXRImage exr_image; EXRHeader exr_header; InitEXRHeader(&exr_header); InitEXRImage(&exr_image); { int ret = ParseEXRVersionFromFile(&exr_version, filename); if (ret != TINYEXR_SUCCESS) { return ret; } if (exr_version.multipart || exr_version.non_image) { if (err) { (*err) = "Loading multipart or DeepImage is not supported yet.\n"; } return TINYEXR_ERROR_INVALID_DATA; // @fixme. } } { int ret = ParseEXRHeaderFromFile(&exr_header, &exr_version, filename, err); if (ret != TINYEXR_SUCCESS) { return ret; } } // Read HALF channel as FLOAT. for (int i = 0; i < exr_header.num_channels; i++) { if (exr_header.pixel_types[i] == TINYEXR_PIXELTYPE_HALF) { exr_header.requested_pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT; } } { int ret = LoadEXRImageFromFile(&exr_image, &exr_header, filename, err); if (ret != TINYEXR_SUCCESS) { return ret; } } // RGBA int idxR = -1; int idxG = -1; int idxB = -1; int idxA = -1; for (int c = 0; c < exr_header.num_channels; c++) { if (strcmp(exr_header.channels[c].name, "R") == 0) { idxR = c; } else if (strcmp(exr_header.channels[c].name, "G") == 0) { idxG = c; } else if (strcmp(exr_header.channels[c].name, "B") == 0) { idxB = c; } else if (strcmp(exr_header.channels[c].name, "A") == 0) { idxA = c; } } if (idxR == -1) { if (err) { (*err) = "R channel not found\n"; } // @todo { free exr_image } return TINYEXR_ERROR_INVALID_DATA; } if (idxG == -1) { if (err) { (*err) = "G channel not found\n"; } // @todo { free exr_image } return TINYEXR_ERROR_INVALID_DATA; } if (idxB == -1) { if (err) { (*err) = "B channel not found\n"; } // @todo { free exr_image } return TINYEXR_ERROR_INVALID_DATA; } (*out_rgba) = reinterpret_cast( malloc(4 * sizeof(float) * static_cast(exr_image.width) * static_cast(exr_image.height))); for (int i = 0; i < exr_image.width * exr_image.height; i++) { (*out_rgba)[4 * i + 0] = reinterpret_cast(exr_image.images)[idxR][i]; (*out_rgba)[4 * i + 1] = reinterpret_cast(exr_image.images)[idxG][i]; (*out_rgba)[4 * i + 2] = reinterpret_cast(exr_image.images)[idxB][i]; if (idxA != -1) { (*out_rgba)[4 * i + 3] = reinterpret_cast(exr_image.images)[idxA][i]; } else { (*out_rgba)[4 * i + 3] = 1.0; } } (*width) = exr_image.width; (*height) = exr_image.height; FreeEXRHeader(&exr_header); FreeEXRImage(&exr_image); return TINYEXR_SUCCESS; } int ParseEXRHeaderFromMemory(EXRHeader *exr_header, const EXRVersion *version, const unsigned char *memory, size_t size, const char **err) { if (memory == NULL || exr_header == NULL) { if (err) { (*err) = "Invalid argument.\n"; } // Invalid argument return TINYEXR_ERROR_INVALID_ARGUMENT; } if (size < tinyexr::kEXRVersionSize) { return TINYEXR_ERROR_INVALID_DATA; } const unsigned char *marker = memory + tinyexr::kEXRVersionSize; size_t marker_size = size - tinyexr::kEXRVersionSize; tinyexr::HeaderInfo info; info.clear(); std::string err_str; int ret = ParseEXRHeader(&info, NULL, version, &err_str, marker, marker_size); if (ret != TINYEXR_SUCCESS) { if (err && !err_str.empty()) { #ifdef _WIN32 (*err) = _strdup(err_str.c_str()); // May leak #else (*err) = strdup(err_str.c_str()); // May leak #endif } } ConvertHeader(exr_header, info); // transfoer `tiled` from version. exr_header->tiled = version->tiled; return ret; } int LoadEXRFromMemory(float *out_rgba, const unsigned char *memory, size_t size, const char **err) { if (out_rgba == NULL || memory == NULL) { if (err) { (*err) = "Invalid argument.\n"; } return TINYEXR_ERROR_INVALID_ARGUMENT; } EXRVersion exr_version; EXRImage exr_image; EXRHeader exr_header; InitEXRHeader(&exr_header); int ret = ParseEXRVersionFromMemory(&exr_version, memory, size); if (ret != TINYEXR_SUCCESS) { return ret; } ret = ParseEXRHeaderFromMemory(&exr_header, &exr_version, memory, size, err); if (ret != TINYEXR_SUCCESS) { return ret; } InitEXRImage(&exr_image); ret = LoadEXRImageFromMemory(&exr_image, &exr_header, memory, size, err); if (ret != TINYEXR_SUCCESS) { return ret; } // RGBA int idxR = -1; int idxG = -1; int idxB = -1; int idxA = -1; for (int c = 0; c < exr_header.num_channels; c++) { if (strcmp(exr_header.channels[c].name, "R") == 0) { idxR = c; } else if (strcmp(exr_header.channels[c].name, "G") == 0) { idxG = c; } else if (strcmp(exr_header.channels[c].name, "B") == 0) { idxB = c; } else if (strcmp(exr_header.channels[c].name, "A") == 0) { idxA = c; } } if (idxR == -1) { if (err) { (*err) = "R channel not found\n"; } // @todo { free exr_image } return TINYEXR_ERROR_INVALID_DATA; } if (idxG == -1) { if (err) { (*err) = "G channel not found\n"; } // @todo { free exr_image } return TINYEXR_ERROR_INVALID_DATA; } if (idxB == -1) { if (err) { (*err) = "B channel not found\n"; } // @todo { free exr_image } return TINYEXR_ERROR_INVALID_DATA; } // Assume `out_rgba` have enough memory allocated. for (int i = 0; i < exr_image.width * exr_image.height; i++) { out_rgba[4 * i + 0] = reinterpret_cast(exr_image.images)[idxR][i]; out_rgba[4 * i + 1] = reinterpret_cast(exr_image.images)[idxG][i]; out_rgba[4 * i + 2] = reinterpret_cast(exr_image.images)[idxB][i]; if (idxA > 0) { out_rgba[4 * i + 3] = reinterpret_cast(exr_image.images)[idxA][i]; } else { out_rgba[4 * i + 3] = 1.0; } } return TINYEXR_SUCCESS; } int LoadEXRImageFromFile(EXRImage *exr_image, const EXRHeader *exr_header, const char *filename, const char **err) { if (exr_image == NULL) { if (err) { (*err) = "Invalid argument."; } return TINYEXR_ERROR_INVALID_ARGUMENT; } #ifdef _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else FILE *fp = fopen(filename, "rb"); #endif if (!fp) { if (err) { (*err) = "Cannot read file."; } return TINYEXR_ERROR_CANT_OPEN_FILE; } size_t filesize; // Compute size fseek(fp, 0, SEEK_END); filesize = static_cast(ftell(fp)); fseek(fp, 0, SEEK_SET); std::vector buf(filesize); // @todo { use mmap } { size_t ret; ret = fread(&buf[0], 1, filesize, fp); assert(ret == filesize); fclose(fp); (void)ret; } return LoadEXRImageFromMemory(exr_image, exr_header, &buf.at(0), filesize, err); } int LoadEXRImageFromMemory(EXRImage *exr_image, const EXRHeader *exr_header, const unsigned char *memory, const size_t size, const char **err) { if (exr_image == NULL || memory == NULL || (size < tinyexr::kEXRVersionSize)) { if (err) { (*err) = "Invalid argument."; } return TINYEXR_ERROR_INVALID_ARGUMENT; } if (exr_header->header_len == 0) { if (err) { (*err) = "EXRHeader is not initialized."; } return TINYEXR_ERROR_INVALID_ARGUMENT; } const unsigned char *head = memory; const unsigned char *marker = reinterpret_cast( memory + exr_header->header_len + 8); // +8 for magic number + version header. return tinyexr::DecodeEXRImage(exr_image, exr_header, head, marker, size, err); } size_t SaveEXRImageToMemory(const EXRImage *exr_image, const EXRHeader *exr_header, unsigned char **memory_out, const char **err) { if (exr_image == NULL || memory_out == NULL || exr_header->compression_type < 0) { if (err) { (*err) = "Invalid argument."; } return 0; // @fixme } #if !TINYEXR_USE_PIZ if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { if (err) { (*err) = "PIZ compression is not supported in this build."; } return 0; } #endif #if !TINYEXR_USE_ZFP if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { if (err) { (*err) = "ZFP compression is not supported in this build."; } return 0; } #endif #if TINYEXR_USE_ZFP for (size_t i = 0; i < static_cast(exr_header->num_channels); i++) { if (exr_header->requested_pixel_types[i] != TINYEXR_PIXELTYPE_FLOAT) { if (err) { (*err) = "Pixel type must be FLOAT for ZFP compression."; } return 0; } } #endif std::vector memory; // Header { const char header[] = {0x76, 0x2f, 0x31, 0x01}; memory.insert(memory.end(), header, header + 4); } // Version, scanline. { char marker[] = {2, 0, 0, 0}; /* @todo if (exr_header->tiled) { marker[1] |= 0x2; } if (exr_header->long_name) { marker[1] |= 0x4; } if (exr_header->non_image) { marker[1] |= 0x8; } if (exr_header->multipart) { marker[1] |= 0x10; } */ memory.insert(memory.end(), marker, marker + 4); } int num_scanlines = 1; if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) { num_scanlines = 16; } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { num_scanlines = 32; } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { num_scanlines = 16; } // Write attributes. std::vector channels; { std::vector data; for (int c = 0; c < exr_header->num_channels; c++) { tinyexr::ChannelInfo info; info.p_linear = 0; info.pixel_type = exr_header->requested_pixel_types[c]; info.x_sampling = 1; info.y_sampling = 1; info.name = std::string(exr_header->channels[c].name); channels.push_back(info); } tinyexr::WriteChannelInfo(data, channels); tinyexr::WriteAttributeToMemory(&memory, "channels", "chlist", &data.at(0), static_cast(data.size())); } { int comp = exr_header->compression_type; tinyexr::swap4(reinterpret_cast(&comp)); tinyexr::WriteAttributeToMemory( &memory, "compression", "compression", reinterpret_cast(&comp), 1); } { int data[4] = {0, 0, exr_image->width - 1, exr_image->height - 1}; tinyexr::swap4(reinterpret_cast(&data[0])); tinyexr::swap4(reinterpret_cast(&data[1])); tinyexr::swap4(reinterpret_cast(&data[2])); tinyexr::swap4(reinterpret_cast(&data[3])); tinyexr::WriteAttributeToMemory( &memory, "dataWindow", "box2i", reinterpret_cast(data), sizeof(int) * 4); tinyexr::WriteAttributeToMemory( &memory, "displayWindow", "box2i", reinterpret_cast(data), sizeof(int) * 4); } { unsigned char line_order = 0; // @fixme { read line_order from EXRHeader } tinyexr::WriteAttributeToMemory(&memory, "lineOrder", "lineOrder", &line_order, 1); } { float aspectRatio = 1.0f; tinyexr::swap4(reinterpret_cast(&aspectRatio)); tinyexr::WriteAttributeToMemory( &memory, "pixelAspectRatio", "float", reinterpret_cast(&aspectRatio), sizeof(float)); } { float center[2] = {0.0f, 0.0f}; tinyexr::swap4(reinterpret_cast(¢er[0])); tinyexr::swap4(reinterpret_cast(¢er[1])); tinyexr::WriteAttributeToMemory( &memory, "screenWindowCenter", "v2f", reinterpret_cast(center), 2 * sizeof(float)); } { float w = static_cast(exr_image->width); tinyexr::swap4(reinterpret_cast(&w)); tinyexr::WriteAttributeToMemory(&memory, "screenWindowWidth", "float", reinterpret_cast(&w), sizeof(float)); } // Custom attributes if (exr_header->num_custom_attributes > 0) { for (int i = 0; i < exr_header->num_custom_attributes; i++) { tinyexr::WriteAttributeToMemory( &memory, exr_header->custom_attributes[i].name, exr_header->custom_attributes[i].type, reinterpret_cast( exr_header->custom_attributes[i].value), exr_header->custom_attributes[i].size); } } { // end of header unsigned char e = 0; memory.push_back(e); } int num_blocks = exr_image->height / num_scanlines; if (num_blocks * num_scanlines < exr_image->height) { num_blocks++; } std::vector offsets(static_cast(num_blocks)); size_t headerSize = memory.size(); tinyexr::tinyexr_uint64 offset = headerSize + static_cast(num_blocks) * sizeof( tinyexr::tinyexr_int64); // sizeof(header) + sizeof(offsetTable) std::vector data; std::vector > data_list( static_cast(num_blocks)); std::vector channel_offset_list( static_cast(exr_header->num_channels)); int pixel_data_size = 0; size_t channel_offset = 0; for (size_t c = 0; c < static_cast(exr_header->num_channels); c++) { channel_offset_list[c] = channel_offset; if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { pixel_data_size += sizeof(unsigned short); channel_offset += sizeof(unsigned short); } else if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) { pixel_data_size += sizeof(float); channel_offset += sizeof(float); } else if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_UINT) { pixel_data_size += sizeof(unsigned int); channel_offset += sizeof(unsigned int); } else { assert(0); } } #if TINYEXR_USE_ZFP tinyexr::ZFPCompressionParam zfp_compression_param; // Use ZFP compression parameter from custom attributes(if such a parameter // exists) { bool ret = tinyexr::FindZFPCompressionParam( &zfp_compression_param, exr_header->custom_attributes, exr_header->num_custom_attributes); if (!ret) { // Use predefined compression parameter. zfp_compression_param.type = 0; zfp_compression_param.rate = 2; } } #endif // Use signed int since some OpenMP compiler doesn't allow unsigned type for // `parallel for` #ifdef _OPENMP #pragma omp parallel for #endif for (int i = 0; i < num_blocks; i++) { size_t ii = static_cast(i); int start_y = num_scanlines * i; int endY = (std::min)(num_scanlines * (i + 1), exr_image->height); int h = endY - start_y; std::vector buf( static_cast(exr_image->width * h * pixel_data_size)); for (size_t c = 0; c < static_cast(exr_header->num_channels); c++) { if (exr_header->pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) { for (int y = 0; y < h; y++) { for (int x = 0; x < exr_image->width; x++) { tinyexr::FP16 h16; h16.u = reinterpret_cast( exr_image->images)[c][(y + start_y) * exr_image->width + x]; tinyexr::FP32 f32 = half_to_float(h16); tinyexr::swap4(reinterpret_cast(&f32.f)); // Assume increasing Y float *line_ptr = reinterpret_cast(&buf.at( static_cast(pixel_data_size * y * exr_image->width) + channel_offset_list[c] * static_cast(exr_image->width))); line_ptr[x] = f32.f; } } } else if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { for (int y = 0; y < h; y++) { for (int x = 0; x < exr_image->width; x++) { unsigned short val = reinterpret_cast( exr_image->images)[c][(y + start_y) * exr_image->width + x]; tinyexr::swap2(&val); // Assume increasing Y unsigned short *line_ptr = reinterpret_cast( &buf.at(static_cast(pixel_data_size * y * exr_image->width) + channel_offset_list[c] * static_cast(exr_image->width))); line_ptr[x] = val; } } } else { assert(0); } } else if (exr_header->pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) { if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { for (int y = 0; y < h; y++) { for (int x = 0; x < exr_image->width; x++) { tinyexr::FP32 f32; f32.f = reinterpret_cast( exr_image->images)[c][(y + start_y) * exr_image->width + x]; tinyexr::FP16 h16; h16 = float_to_half_full(f32); tinyexr::swap2(reinterpret_cast(&h16.u)); // Assume increasing Y unsigned short *line_ptr = reinterpret_cast( &buf.at(static_cast(pixel_data_size * y * exr_image->width) + channel_offset_list[c] * static_cast(exr_image->width))); line_ptr[x] = h16.u; } } } else if (exr_header->requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) { for (int y = 0; y < h; y++) { for (int x = 0; x < exr_image->width; x++) { float val = reinterpret_cast( exr_image->images)[c][(y + start_y) * exr_image->width + x]; tinyexr::swap4(reinterpret_cast(&val)); // Assume increasing Y float *line_ptr = reinterpret_cast(&buf.at( static_cast(pixel_data_size * y * exr_image->width) + channel_offset_list[c] * static_cast(exr_image->width))); line_ptr[x] = val; } } } else { assert(0); } } else if (exr_header->pixel_types[c] == TINYEXR_PIXELTYPE_UINT) { for (int y = 0; y < h; y++) { for (int x = 0; x < exr_image->width; x++) { unsigned int val = reinterpret_cast( exr_image->images)[c][(y + start_y) * exr_image->width + x]; tinyexr::swap4(&val); // Assume increasing Y unsigned int *line_ptr = reinterpret_cast(&buf.at( static_cast(pixel_data_size * y * exr_image->width) + channel_offset_list[c] * static_cast(exr_image->width))); line_ptr[x] = val; } } } } if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_NONE) { // 4 byte: scan line // 4 byte: data size // ~ : pixel data(uncompressed) std::vector header(8); unsigned int data_len = static_cast(buf.size()); memcpy(&header.at(0), &start_y, sizeof(int)); memcpy(&header.at(4), &data_len, sizeof(unsigned int)); tinyexr::swap4(reinterpret_cast(&header.at(0))); tinyexr::swap4(reinterpret_cast(&header.at(4))); data_list[ii].insert(data_list[ii].end(), header.begin(), header.end()); data_list[ii].insert(data_list[ii].end(), buf.begin(), buf.begin() + data_len); } else if ((exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIPS) || (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIP)) { #if TINYEXR_USE_MINIZ std::vector block(tinyexr::miniz::mz_compressBound( static_cast(buf.size()))); #else std::vector block( compressBound(static_cast(buf.size()))); #endif tinyexr::tinyexr_uint64 outSize = block.size(); tinyexr::CompressZip(&block.at(0), outSize, reinterpret_cast(&buf.at(0)), static_cast(buf.size())); // 4 byte: scan line // 4 byte: data size // ~ : pixel data(compressed) std::vector header(8); unsigned int data_len = static_cast(outSize); // truncate memcpy(&header.at(0), &start_y, sizeof(int)); memcpy(&header.at(4), &data_len, sizeof(unsigned int)); tinyexr::swap4(reinterpret_cast(&header.at(0))); tinyexr::swap4(reinterpret_cast(&header.at(4))); data_list[ii].insert(data_list[ii].end(), header.begin(), header.end()); data_list[ii].insert(data_list[ii].end(), block.begin(), block.begin() + data_len); } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_RLE) { // (buf.size() * 3) / 2 would be enough. std::vector block((buf.size() * 3) / 2); tinyexr::tinyexr_uint64 outSize = block.size(); tinyexr::CompressRle(&block.at(0), outSize, reinterpret_cast(&buf.at(0)), static_cast(buf.size())); // 4 byte: scan line // 4 byte: data size // ~ : pixel data(compressed) std::vector header(8); unsigned int data_len = static_cast(outSize); // truncate memcpy(&header.at(0), &start_y, sizeof(int)); memcpy(&header.at(4), &data_len, sizeof(unsigned int)); tinyexr::swap4(reinterpret_cast(&header.at(0))); tinyexr::swap4(reinterpret_cast(&header.at(4))); data_list[ii].insert(data_list[ii].end(), header.begin(), header.end()); data_list[ii].insert(data_list[ii].end(), block.begin(), block.begin() + data_len); } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { #if TINYEXR_USE_PIZ unsigned int bufLen = 1024 + static_cast( 1.2 * static_cast( buf.size())); // @fixme { compute good bound. } std::vector block(bufLen); unsigned int outSize = static_cast(block.size()); CompressPiz(&block.at(0), &outSize, reinterpret_cast(&buf.at(0)), buf.size(), channels, exr_image->width, h); // 4 byte: scan line // 4 byte: data size // ~ : pixel data(compressed) std::vector header(8); unsigned int data_len = outSize; memcpy(&header.at(0), &start_y, sizeof(int)); memcpy(&header.at(4), &data_len, sizeof(unsigned int)); tinyexr::swap4(reinterpret_cast(&header.at(0))); tinyexr::swap4(reinterpret_cast(&header.at(4))); data_list[ii].insert(data_list[ii].end(), header.begin(), header.end()); data_list[ii].insert(data_list[ii].end(), block.begin(), block.begin() + data_len); #else assert(0); #endif } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { #if TINYEXR_USE_ZFP std::vector block; unsigned int outSize; tinyexr::CompressZfp( &block, &outSize, reinterpret_cast(&buf.at(0)), exr_image->width, h, exr_header->num_channels, zfp_compression_param); // 4 byte: scan line // 4 byte: data size // ~ : pixel data(compressed) std::vector header(8); unsigned int data_len = outSize; memcpy(&header.at(0), &start_y, sizeof(int)); memcpy(&header.at(4), &data_len, sizeof(unsigned int)); tinyexr::swap4(reinterpret_cast(&header.at(0))); tinyexr::swap4(reinterpret_cast(&header.at(4))); data_list[ii].insert(data_list[ii].end(), header.begin(), header.end()); data_list[ii].insert(data_list[ii].end(), block.begin(), block.begin() + data_len); #else assert(0); #endif } else { assert(0); } } // omp parallel for (size_t i = 0; i < static_cast(num_blocks); i++) { data.insert(data.end(), data_list[i].begin(), data_list[i].end()); offsets[i] = offset; tinyexr::swap8(reinterpret_cast(&offsets[i])); offset += data_list[i].size(); } { memory.insert( memory.end(), reinterpret_cast(&offsets.at(0)), reinterpret_cast(&offsets.at(0)) + sizeof(tinyexr::tinyexr_uint64) * static_cast(num_blocks)); } { memory.insert(memory.end(), data.begin(), data.end()); } assert(memory.size() > 0); (*memory_out) = static_cast(malloc(memory.size())); memcpy((*memory_out), &memory.at(0), memory.size()); return memory.size(); // OK } int SaveEXRImageToFile(const EXRImage *exr_image, const EXRHeader *exr_header, const char *filename, const char **err) { if (exr_image == NULL || filename == NULL || exr_header->compression_type < 0) { if (err) { (*err) = "Invalid argument."; } return TINYEXR_ERROR_INVALID_ARGUMENT; } #if !TINYEXR_USE_PIZ if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { if (err) { (*err) = "PIZ compression is not supported in this build."; } return 0; } #endif #if !TINYEXR_USE_ZFP if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { if (err) { (*err) = "ZFP compression is not supported in this build."; } return 0; } #endif #ifdef _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "wb"); #else FILE *fp = fopen(filename, "wb"); #endif if (!fp) { if (err) { (*err) = "Cannot write a file."; } return TINYEXR_ERROR_CANT_OPEN_FILE; } unsigned char *mem = NULL; size_t mem_size = SaveEXRImageToMemory(exr_image, exr_header, &mem, err); if ((mem_size > 0) && mem) { fwrite(mem, 1, mem_size, fp); } free(mem); fclose(fp); return TINYEXR_SUCCESS; } int LoadDeepEXR(DeepImage *deep_image, const char *filename, const char **err) { if (deep_image == NULL) { if (err) { (*err) = "Invalid argument."; } return TINYEXR_ERROR_INVALID_ARGUMENT; } FILE *fp = fopen(filename, "rb"); if (!fp) { if (err) { (*err) = "Cannot read file."; } return TINYEXR_ERROR_CANT_OPEN_FILE; } size_t filesize; // Compute size fseek(fp, 0, SEEK_END); filesize = static_cast(ftell(fp)); fseek(fp, 0, SEEK_SET); if (filesize == 0) { fclose(fp); if (err) { (*err) = "File size is zero."; } return TINYEXR_ERROR_INVALID_FILE; } std::vector buf(filesize); // @todo { use mmap } { size_t ret; ret = fread(&buf[0], 1, filesize, fp); assert(ret == filesize); (void)ret; } fclose(fp); const char *head = &buf[0]; const char *marker = &buf[0]; // Header check. { const char header[] = {0x76, 0x2f, 0x31, 0x01}; if (memcmp(marker, header, 4) != 0) { if (err) { (*err) = "Invalid magic number."; } return TINYEXR_ERROR_INVALID_MAGIC_NUMBER; } marker += 4; } // Version, scanline. { // ver 2.0, scanline, deep bit on(0x800) // must be [2, 0, 0, 0] if (marker[0] != 2 || marker[1] != 8 || marker[2] != 0 || marker[3] != 0) { if (err) { (*err) = "Unsupported version or scanline."; } return TINYEXR_ERROR_UNSUPPORTED_FORMAT; } marker += 4; } int dx = -1; int dy = -1; int dw = -1; int dh = -1; int num_scanline_blocks = 1; // 16 for ZIP compression. int compression_type = -1; int num_channels = -1; std::vector channels; // Read attributes size_t size = filesize - tinyexr::kEXRVersionSize; for (;;) { if (0 == size) { return TINYEXR_ERROR_INVALID_DATA; } else if (marker[0] == '\0') { size--; break; } std::string attr_name; std::string attr_type; std::vector data; size_t marker_size; if (!tinyexr::ReadAttribute(&attr_name, &attr_type, &data, &marker_size, marker, size)) { return TINYEXR_ERROR_INVALID_DATA; } marker += marker_size; size -= marker_size; if (attr_name.compare("compression") == 0) { compression_type = data[0]; if (compression_type > TINYEXR_COMPRESSIONTYPE_PIZ) { if (err) { (*err) = "Unsupported compression type."; } return TINYEXR_ERROR_UNSUPPORTED_FORMAT; } if (compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) { num_scanline_blocks = 16; } } else if (attr_name.compare("channels") == 0) { // name: zero-terminated string, from 1 to 255 bytes long // pixel type: int, possible values are: UINT = 0 HALF = 1 FLOAT = 2 // pLinear: unsigned char, possible values are 0 and 1 // reserved: three chars, should be zero // xSampling: int // ySampling: int tinyexr::ReadChannelInfo(channels, data); num_channels = static_cast(channels.size()); if (num_channels < 1) { if (err) { (*err) = "Invalid channels format."; } return TINYEXR_ERROR_INVALID_DATA; } } else if (attr_name.compare("dataWindow") == 0) { memcpy(&dx, &data.at(0), sizeof(int)); memcpy(&dy, &data.at(4), sizeof(int)); memcpy(&dw, &data.at(8), sizeof(int)); memcpy(&dh, &data.at(12), sizeof(int)); tinyexr::swap4(reinterpret_cast(&dx)); tinyexr::swap4(reinterpret_cast(&dy)); tinyexr::swap4(reinterpret_cast(&dw)); tinyexr::swap4(reinterpret_cast(&dh)); } else if (attr_name.compare("displayWindow") == 0) { int x; int y; int w; int h; memcpy(&x, &data.at(0), sizeof(int)); memcpy(&y, &data.at(4), sizeof(int)); memcpy(&w, &data.at(8), sizeof(int)); memcpy(&h, &data.at(12), sizeof(int)); tinyexr::swap4(reinterpret_cast(&x)); tinyexr::swap4(reinterpret_cast(&y)); tinyexr::swap4(reinterpret_cast(&w)); tinyexr::swap4(reinterpret_cast(&h)); } } assert(dx >= 0); assert(dy >= 0); assert(dw >= 0); assert(dh >= 0); assert(num_channels >= 1); int data_width = dw - dx + 1; int data_height = dh - dy + 1; std::vector image( static_cast(data_width * data_height * 4)); // 4 = RGBA // Read offset tables. int num_blocks = data_height / num_scanline_blocks; if (num_blocks * num_scanline_blocks < data_height) { num_blocks++; } std::vector offsets(static_cast(num_blocks)); for (size_t y = 0; y < static_cast(num_blocks); y++) { tinyexr::tinyexr_int64 offset; memcpy(&offset, marker, sizeof(tinyexr::tinyexr_int64)); tinyexr::swap8(reinterpret_cast(&offset)); marker += sizeof(tinyexr::tinyexr_int64); // = 8 offsets[y] = offset; } #if TINYEXR_USE_PIZ if ((compression_type == TINYEXR_COMPRESSIONTYPE_NONE) || (compression_type == TINYEXR_COMPRESSIONTYPE_RLE) || (compression_type == TINYEXR_COMPRESSIONTYPE_ZIPS) || (compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) || (compression_type == TINYEXR_COMPRESSIONTYPE_PIZ)) { #else if ((compression_type == TINYEXR_COMPRESSIONTYPE_NONE) || (compression_type == TINYEXR_COMPRESSIONTYPE_RLE) || (compression_type == TINYEXR_COMPRESSIONTYPE_ZIPS) || (compression_type == TINYEXR_COMPRESSIONTYPE_ZIP)) { #endif // OK } else { if (err) { (*err) = "Unsupported format."; } return TINYEXR_ERROR_UNSUPPORTED_FORMAT; } deep_image->image = static_cast( malloc(sizeof(float **) * static_cast(num_channels))); for (int c = 0; c < num_channels; c++) { deep_image->image[c] = static_cast( malloc(sizeof(float *) * static_cast(data_height))); for (int y = 0; y < data_height; y++) { } } deep_image->offset_table = static_cast( malloc(sizeof(int *) * static_cast(data_height))); for (int y = 0; y < data_height; y++) { deep_image->offset_table[y] = static_cast( malloc(sizeof(int) * static_cast(data_width))); } for (size_t y = 0; y < static_cast(num_blocks); y++) { const unsigned char *data_ptr = reinterpret_cast(head + offsets[y]); // int: y coordinate // int64: packed size of pixel offset table // int64: packed size of sample data // int64: unpacked size of sample data // compressed pixel offset table // compressed sample data int line_no; tinyexr::tinyexr_int64 packedOffsetTableSize; tinyexr::tinyexr_int64 packedSampleDataSize; tinyexr::tinyexr_int64 unpackedSampleDataSize; memcpy(&line_no, data_ptr, sizeof(int)); memcpy(&packedOffsetTableSize, data_ptr + 4, sizeof(tinyexr::tinyexr_int64)); memcpy(&packedSampleDataSize, data_ptr + 12, sizeof(tinyexr::tinyexr_int64)); memcpy(&unpackedSampleDataSize, data_ptr + 20, sizeof(tinyexr::tinyexr_int64)); tinyexr::swap4(reinterpret_cast(&line_no)); tinyexr::swap8( reinterpret_cast(&packedOffsetTableSize)); tinyexr::swap8( reinterpret_cast(&packedSampleDataSize)); tinyexr::swap8( reinterpret_cast(&unpackedSampleDataSize)); std::vector pixelOffsetTable(static_cast(data_width)); // decode pixel offset table. { unsigned long dstLen = static_cast(pixelOffsetTable.size() * sizeof(int)); tinyexr::DecompressZip( reinterpret_cast(&pixelOffsetTable.at(0)), &dstLen, data_ptr + 28, static_cast(packedOffsetTableSize)); assert(dstLen == pixelOffsetTable.size() * sizeof(int)); for (size_t i = 0; i < static_cast(data_width); i++) { deep_image->offset_table[y][i] = pixelOffsetTable[i]; } } std::vector sample_data( static_cast(unpackedSampleDataSize)); // decode sample data. { unsigned long dstLen = static_cast(unpackedSampleDataSize); tinyexr::DecompressZip( reinterpret_cast(&sample_data.at(0)), &dstLen, data_ptr + 28 + packedOffsetTableSize, static_cast(packedSampleDataSize)); assert(dstLen == static_cast(unpackedSampleDataSize)); } // decode sample int sampleSize = -1; std::vector channel_offset_list(static_cast(num_channels)); { int channel_offset = 0; for (size_t i = 0; i < static_cast(num_channels); i++) { channel_offset_list[i] = channel_offset; if (channels[i].pixel_type == TINYEXR_PIXELTYPE_UINT) { // UINT channel_offset += 4; } else if (channels[i].pixel_type == TINYEXR_PIXELTYPE_HALF) { // half channel_offset += 2; } else if (channels[i].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { // float channel_offset += 4; } else { assert(0); } } sampleSize = channel_offset; } assert(sampleSize >= 2); assert(static_cast( pixelOffsetTable[static_cast(data_width - 1)] * sampleSize) == sample_data.size()); int samples_per_line = static_cast(sample_data.size()) / sampleSize; // // Alloc memory // // // pixel data is stored as image[channels][pixel_samples] // { tinyexr::tinyexr_uint64 data_offset = 0; for (size_t c = 0; c < static_cast(num_channels); c++) { deep_image->image[c][y] = static_cast( malloc(sizeof(float) * static_cast(samples_per_line))); if (channels[c].pixel_type == 0) { // UINT for (size_t x = 0; x < static_cast(samples_per_line); x++) { unsigned int ui = *reinterpret_cast( &sample_data.at(data_offset + x * sizeof(int))); deep_image->image[c][y][x] = static_cast(ui); // @fixme } data_offset += sizeof(unsigned int) * static_cast(samples_per_line); } else if (channels[c].pixel_type == 1) { // half for (size_t x = 0; x < static_cast(samples_per_line); x++) { tinyexr::FP16 f16; f16.u = *reinterpret_cast( &sample_data.at(data_offset + x * sizeof(short))); tinyexr::FP32 f32 = half_to_float(f16); deep_image->image[c][y][x] = f32.f; } data_offset += sizeof(short) * static_cast(samples_per_line); } else { // float for (size_t x = 0; x < static_cast(samples_per_line); x++) { float f = *reinterpret_cast( &sample_data.at(data_offset + x * sizeof(float))); deep_image->image[c][y][x] = f; } data_offset += sizeof(float) * static_cast(samples_per_line); } } } } // y deep_image->width = data_width; deep_image->height = data_height; deep_image->channel_names = static_cast( malloc(sizeof(const char *) * static_cast(num_channels))); for (size_t c = 0; c < static_cast(num_channels); c++) { #ifdef _WIN32 deep_image->channel_names[c] = _strdup(channels[c].name.c_str()); #else deep_image->channel_names[c] = strdup(channels[c].name.c_str()); #endif } deep_image->num_channels = num_channels; return TINYEXR_SUCCESS; } void InitEXRImage(EXRImage *exr_image) { if (exr_image == NULL) { return; } exr_image->width = 0; exr_image->height = 0; exr_image->num_channels = 0; exr_image->images = NULL; exr_image->tiles = NULL; exr_image->num_tiles = 0; } void InitEXRHeader(EXRHeader *exr_header) { if (exr_header == NULL) { return; } memset(exr_header, 0, sizeof(EXRHeader)); } int FreeEXRHeader(EXRHeader *exr_header) { if (exr_header == NULL) { return TINYEXR_ERROR_INVALID_ARGUMENT; } if (exr_header->channels) { free(exr_header->channels); } if (exr_header->pixel_types) { free(exr_header->pixel_types); } if (exr_header->requested_pixel_types) { free(exr_header->requested_pixel_types); } for (int i = 0; i < exr_header->num_custom_attributes; i++) { if (exr_header->custom_attributes[i].value) { free(exr_header->custom_attributes[i].value); } } return TINYEXR_SUCCESS; } int FreeEXRImage(EXRImage *exr_image) { if (exr_image == NULL) { return TINYEXR_ERROR_INVALID_ARGUMENT; } for (int i = 0; i < exr_image->num_channels; i++) { if (exr_image->images && exr_image->images[i]) { free(exr_image->images[i]); } } if (exr_image->images) { free(exr_image->images); } if (exr_image->tiles) { for (int tid = 0; tid < exr_image->num_tiles; tid++) { for (int i = 0; i < exr_image->num_channels; i++) { if (exr_image->tiles[tid].images && exr_image->tiles[tid].images[i]) { free(exr_image->tiles[tid].images[i]); } } if (exr_image->tiles[tid].images) { free(exr_image->tiles[tid].images); } } } return TINYEXR_SUCCESS; } int ParseEXRHeaderFromFile(EXRHeader *exr_header, const EXRVersion *exr_version, const char *filename, const char **err) { if (exr_header == NULL || exr_version == NULL || filename == NULL) { if (err) { (*err) = "Invalid argument."; } return TINYEXR_ERROR_INVALID_ARGUMENT; } #ifdef _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else FILE *fp = fopen(filename, "rb"); #endif if (!fp) { if (err) { (*err) = "Cannot read file."; } return TINYEXR_ERROR_CANT_OPEN_FILE; } size_t filesize; // Compute size fseek(fp, 0, SEEK_END); filesize = static_cast(ftell(fp)); fseek(fp, 0, SEEK_SET); std::vector buf(filesize); // @todo { use mmap } { size_t ret; ret = fread(&buf[0], 1, filesize, fp); assert(ret == filesize); fclose(fp); if (ret != filesize) { if (err) { (*err) = "fread error."; } return TINYEXR_ERROR_INVALID_FILE; } } return ParseEXRHeaderFromMemory(exr_header, exr_version, &buf.at(0), filesize, err); } int ParseEXRMultipartHeaderFromMemory(EXRHeader ***exr_headers, int *num_headers, const EXRVersion *exr_version, const unsigned char *memory, size_t size, const char **err) { if (memory == NULL || exr_headers == NULL || num_headers == NULL || exr_version == NULL) { // Invalid argument return TINYEXR_ERROR_INVALID_ARGUMENT; } if (size < tinyexr::kEXRVersionSize) { return TINYEXR_ERROR_INVALID_DATA; } const unsigned char *marker = memory + tinyexr::kEXRVersionSize; size_t marker_size = size - tinyexr::kEXRVersionSize; std::vector infos; for (;;) { tinyexr::HeaderInfo info; info.clear(); std::string err_str; bool empty_header = false; int ret = ParseEXRHeader(&info, &empty_header, exr_version, &err_str, marker, marker_size); if (ret != TINYEXR_SUCCESS) { if (err) { #ifdef _WIN32 (*err) = _strdup(err_str.c_str()); // may leak #else (*err) = strdup(err_str.c_str()); // may leak #endif } return ret; } if (empty_header) { marker += 1; // skip '\0' break; } // `chunkCount` must exist in the header. if (info.chunk_count == 0) { if (err) { (*err) = "`chunkCount' attribute is not found in the header."; } return TINYEXR_ERROR_INVALID_DATA; } infos.push_back(info); // move to next header. marker += info.header_len; size -= info.header_len; } // allocate memory for EXRHeader and create array of EXRHeader pointers. (*exr_headers) = static_cast(malloc(sizeof(EXRHeader *) * infos.size())); for (size_t i = 0; i < infos.size(); i++) { EXRHeader *exr_header = static_cast(malloc(sizeof(EXRHeader))); ConvertHeader(exr_header, infos[i]); // transfoer `tiled` from version. exr_header->tiled = exr_version->tiled; (*exr_headers)[i] = exr_header; } (*num_headers) = static_cast(infos.size()); return TINYEXR_SUCCESS; } int ParseEXRMultipartHeaderFromFile(EXRHeader ***exr_headers, int *num_headers, const EXRVersion *exr_version, const char *filename, const char **err) { if (exr_headers == NULL || num_headers == NULL || exr_version == NULL || filename == NULL) { if (err) { (*err) = "Invalid argument."; } return TINYEXR_ERROR_INVALID_ARGUMENT; } #ifdef _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else FILE *fp = fopen(filename, "rb"); #endif if (!fp) { if (err) { (*err) = "Cannot read file."; } return TINYEXR_ERROR_CANT_OPEN_FILE; } size_t filesize; // Compute size fseek(fp, 0, SEEK_END); filesize = static_cast(ftell(fp)); fseek(fp, 0, SEEK_SET); std::vector buf(filesize); // @todo { use mmap } { size_t ret; ret = fread(&buf[0], 1, filesize, fp); assert(ret == filesize); fclose(fp); if (ret != filesize) { if (err) { (*err) = "fread error."; } return TINYEXR_ERROR_INVALID_FILE; } } return ParseEXRMultipartHeaderFromMemory( exr_headers, num_headers, exr_version, &buf.at(0), filesize, err); } int ParseEXRVersionFromMemory(EXRVersion *version, const unsigned char *memory, size_t size) { if (version == NULL || memory == NULL) { return TINYEXR_ERROR_INVALID_ARGUMENT; } if (size < tinyexr::kEXRVersionSize) { return TINYEXR_ERROR_INVALID_DATA; } const unsigned char *marker = memory; // Header check. { const char header[] = {0x76, 0x2f, 0x31, 0x01}; if (memcmp(marker, header, 4) != 0) { return TINYEXR_ERROR_INVALID_MAGIC_NUMBER; } marker += 4; } version->tiled = false; version->long_name = false; version->non_image = false; version->multipart = false; // Parse version header. { // must be 2 if (marker[0] != 2) { return TINYEXR_ERROR_INVALID_EXR_VERSION; } if (version == NULL) { return TINYEXR_SUCCESS; // May OK } version->version = 2; if (marker[1] & 0x2) { // 9th bit version->tiled = true; } if (marker[1] & 0x4) { // 10th bit version->long_name = true; } if (marker[1] & 0x8) { // 11th bit version->non_image = true; // (deep image) } if (marker[1] & 0x10) { // 12th bit version->multipart = true; } } return TINYEXR_SUCCESS; } int ParseEXRVersionFromFile(EXRVersion *version, const char *filename) { if (filename == NULL) { return TINYEXR_ERROR_INVALID_ARGUMENT; } #ifdef _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else FILE *fp = fopen(filename, "rb"); #endif if (!fp) { return TINYEXR_ERROR_CANT_OPEN_FILE; } size_t file_size; // Compute size fseek(fp, 0, SEEK_END); file_size = static_cast(ftell(fp)); fseek(fp, 0, SEEK_SET); if (file_size < tinyexr::kEXRVersionSize) { return TINYEXR_ERROR_INVALID_FILE; } unsigned char buf[tinyexr::kEXRVersionSize]; size_t ret = fread(&buf[0], 1, tinyexr::kEXRVersionSize, fp); fclose(fp); if (ret != tinyexr::kEXRVersionSize) { return TINYEXR_ERROR_INVALID_FILE; } return ParseEXRVersionFromMemory(version, buf, tinyexr::kEXRVersionSize); } int LoadEXRMultipartImageFromMemory(EXRImage *exr_images, const EXRHeader **exr_headers, unsigned int num_parts, const unsigned char *memory, const size_t size, const char **err) { if (exr_images == NULL || exr_headers == NULL || num_parts == 0 || memory == NULL || (size <= tinyexr::kEXRVersionSize)) { if (err) { (*err) = "Invalid argument."; } return TINYEXR_ERROR_INVALID_ARGUMENT; } // compute total header size. size_t total_header_size = 0; for (unsigned int i = 0; i < num_parts; i++) { if (exr_headers[i]->header_len == 0) { if (err) { (*err) = "EXRHeader is not initialized."; } return TINYEXR_ERROR_INVALID_ARGUMENT; } total_header_size += exr_headers[i]->header_len; } const char *marker = reinterpret_cast( memory + total_header_size + 4 + 4); // +8 for magic number and version header. marker += 1; // Skip empty header. // NOTE 1: // In multipart image, There is 'part number' before chunk data. // 4 byte : part number // 4+ : chunk // // NOTE 2: // EXR spec says 'part number' is 'unsigned long' but actually this is // 'unsigned int(4 bytes)' in OpenEXR implementation... // http://www.openexr.com/openexrfilelayout.pdf // Load chunk offset table. std::vector > chunk_offset_table_list; for (size_t i = 0; i < static_cast(num_parts); i++) { std::vector offset_table( static_cast(exr_headers[i]->chunk_count)); for (size_t c = 0; c < offset_table.size(); c++) { tinyexr::tinyexr_uint64 offset; memcpy(&offset, marker, 8); tinyexr::swap8(&offset); if (offset >= size) { if (err) { (*err) = "Invalid offset size."; } return TINYEXR_ERROR_INVALID_DATA; } offset_table[c] = offset + 4; // +4 to skip 'part number' marker += 8; } chunk_offset_table_list.push_back(offset_table); } // Decode image. for (size_t i = 0; i < static_cast(num_parts); i++) { std::vector &offset_table = chunk_offset_table_list[i]; // First check 'part number' is identitical to 'i' for (size_t c = 0; c < offset_table.size(); c++) { const unsigned char *part_number_addr = memory + offset_table[c] - 4; // -4 to move to 'part number' field. unsigned int part_no; memcpy(&part_no, part_number_addr, sizeof(unsigned int)); // 4 tinyexr::swap4(&part_no); if (part_no != i) { assert(0); return TINYEXR_ERROR_INVALID_DATA; } } int ret = tinyexr::DecodeChunk(&exr_images[i], exr_headers[i], offset_table, memory); if (ret != TINYEXR_SUCCESS) { return ret; } } return TINYEXR_SUCCESS; } int LoadEXRMultipartImageFromFile(EXRImage *exr_images, const EXRHeader **exr_headers, unsigned int num_parts, const char *filename, const char **err) { if (exr_images == NULL || exr_headers == NULL || num_parts == 0) { if (err) { (*err) = "Invalid argument."; } return TINYEXR_ERROR_INVALID_ARGUMENT; } #ifdef _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else FILE *fp = fopen(filename, "rb"); #endif if (!fp) { if (err) { (*err) = "Cannot read file."; } return TINYEXR_ERROR_CANT_OPEN_FILE; } size_t filesize; // Compute size fseek(fp, 0, SEEK_END); filesize = static_cast(ftell(fp)); fseek(fp, 0, SEEK_SET); std::vector buf(filesize); // @todo { use mmap } { size_t ret; ret = fread(&buf[0], 1, filesize, fp); assert(ret == filesize); fclose(fp); (void)ret; } return LoadEXRMultipartImageFromMemory(exr_images, exr_headers, num_parts, &buf.at(0), filesize, err); } int SaveEXR(const float *data, int width, int height, int components, const char *outfilename) { if (components == 3 || components == 4) { // OK } else { return TINYEXR_ERROR_INVALID_ARGUMENT; } // Assume at least 16x16 pixels. if (width < 16) return TINYEXR_ERROR_INVALID_ARGUMENT; if (height < 16) return TINYEXR_ERROR_INVALID_ARGUMENT; EXRHeader header; InitEXRHeader(&header); EXRImage image; InitEXRImage(&image); image.num_channels = components; std::vector images[4]; images[0].resize(static_cast(width * height)); images[1].resize(static_cast(width * height)); images[2].resize(static_cast(width * height)); images[3].resize(static_cast(width * height)); // Split RGB(A)RGB(A)RGB(A)... into R, G and B(and A) layers for (size_t i = 0; i < static_cast(width * height); i++) { images[0][i] = data[static_cast(components) * i + 0]; images[1][i] = data[static_cast(components) * i + 1]; images[2][i] = data[static_cast(components) * i + 2]; if (components == 4) { images[3][i] = data[static_cast(components) * i + 3]; } } float *image_ptr[4] = {0, 0, 0, 0}; if (components == 4) { image_ptr[0] = &(images[3].at(0)); // A image_ptr[1] = &(images[2].at(0)); // B image_ptr[2] = &(images[1].at(0)); // G image_ptr[3] = &(images[0].at(0)); // R } else { image_ptr[0] = &(images[2].at(0)); // B image_ptr[1] = &(images[1].at(0)); // G image_ptr[2] = &(images[0].at(0)); // R } image.images = reinterpret_cast(image_ptr); image.width = width; image.height = height; header.num_channels = components; header.channels = static_cast(malloc( sizeof(EXRChannelInfo) * static_cast(header.num_channels))); // Must be (A)BGR order, since most of EXR viewers expect this channel order. if (components == 4) { strncpy(header.channels[0].name, "A", 255); header.channels[0].name[strlen("A")] = '\0'; strncpy(header.channels[1].name, "B", 255); header.channels[1].name[strlen("B")] = '\0'; strncpy(header.channels[2].name, "G", 255); header.channels[2].name[strlen("G")] = '\0'; strncpy(header.channels[3].name, "R", 255); header.channels[3].name[strlen("R")] = '\0'; } else { strncpy(header.channels[0].name, "B", 255); header.channels[0].name[strlen("B")] = '\0'; strncpy(header.channels[1].name, "G", 255); header.channels[1].name[strlen("G")] = '\0'; strncpy(header.channels[2].name, "R", 255); header.channels[2].name[strlen("R")] = '\0'; } header.pixel_types = static_cast( malloc(sizeof(int) * static_cast(header.num_channels))); header.requested_pixel_types = static_cast( malloc(sizeof(int) * static_cast(header.num_channels))); for (int i = 0; i < header.num_channels; i++) { header.pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT; // pixel type of input image header.requested_pixel_types[i] = TINYEXR_PIXELTYPE_HALF; // pixel type of output image to be stored in // .EXR } const char *err; int ret = SaveEXRImageToFile(&image, &header, outfilename, &err); if (ret != TINYEXR_SUCCESS) { return ret; } free(header.channels); free(header.pixel_types); free(header.requested_pixel_types); return ret; } #ifdef _MSC_VER #pragma warning(pop) #endif #endif // TINYEXR_IMPLEMENTATION_DEIFNED #endif // TINYEXR_IMPLEMENTATION goxel-0.11.0/ext_src/yocto/yocto_bvh.cpp000066400000000000000000001651111435762723100202320ustar00rootroot00000000000000// // Implementation for Yocto/BVH // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include "yocto_bvh.h" #include #include #include #include #include #if YOCTO_EMBREE #include #endif // ----------------------------------------------------------------------------- // IMPLEMENRTATION OF RAY-PRIMITIVE INTERSECTION FUNCTIONS // ----------------------------------------------------------------------------- namespace yocto { // Intersect a ray with a point (approximate) bool intersect_point( const ray3f& ray, const vec3f& p, float r, vec2f& uv, float& dist) { // find parameter for line-point minimum distance auto w = p - ray.o; auto t = dot(w, ray.d) / dot(ray.d, ray.d); // exit if not within bounds if (t < ray.tmin || t > ray.tmax) return false; // test for line-point distance vs point radius auto rp = ray.o + ray.d * t; auto prp = p - rp; if (dot(prp, prp) > r * r) return false; // intersection occurred: set params and exit uv = {0, 0}; dist = t; return true; } // Intersect a ray with a line bool intersect_line(const ray3f& ray, const vec3f& p0, const vec3f& p1, float r0, float r1, vec2f& uv, float& dist) { // setup intersection params auto u = ray.d; auto v = p1 - p0; auto w = ray.o - p0; // compute values to solve a linear system auto a = dot(u, u); auto b = dot(u, v); auto c = dot(v, v); auto d = dot(u, w); auto e = dot(v, w); auto det = a * c - b * b; // check determinant and exit if lines are parallel // (could use EPSILONS if desired) if (det == 0) return false; // compute Parameters on both ray and segment auto t = (b * e - c * d) / det; auto s = (a * e - b * d) / det; // exit if not within bounds if (t < ray.tmin || t > ray.tmax) return false; // clamp segment param to segment corners s = clamp(s, (float)0, (float)1); // compute segment-segment distance on the closest points auto pr = ray.o + ray.d * t; auto pl = p0 + (p1 - p0) * s; auto prl = pr - pl; // check with the line radius at the same point auto d2 = dot(prl, prl); auto r = r0 * (1 - s) + r1 * s; if (d2 > r * r) return {}; // intersection occurred: set params and exit uv = {s, sqrt(d2) / r}; dist = t; return true; } // Intersect a ray with a triangle bool intersect_triangle(const ray3f& ray, const vec3f& p0, const vec3f& p1, const vec3f& p2, vec2f& uv, float& dist) { // compute triangle edges auto edge1 = p1 - p0; auto edge2 = p2 - p0; // compute determinant to solve a linear system auto pvec = cross(ray.d, edge2); auto det = dot(edge1, pvec); // check determinant and exit if triangle and ray are parallel // (could use EPSILONS if desired) if (det == 0) return false; auto inv_det = 1.0f / det; // compute and check first bricentric coordinated auto tvec = ray.o - p0; auto u = dot(tvec, pvec) * inv_det; if (u < 0 || u > 1) return false; // compute and check second bricentric coordinated auto qvec = cross(tvec, edge1); auto v = dot(ray.d, qvec) * inv_det; if (v < 0 || u + v > 1) return false; // compute and check ray parameter auto t = dot(edge2, qvec) * inv_det; if (t < ray.tmin || t > ray.tmax) return false; // intersection occurred: set params and exit uv = {u, v}; dist = t; return true; } // Intersect a ray with a quad. bool intersect_quad(const ray3f& ray, const vec3f& p0, const vec3f& p1, const vec3f& p2, const vec3f& p3, vec2f& uv, float& dist) { if (p2 == p3) { return intersect_triangle(ray, p0, p1, p3, uv, dist); } auto hit = false; auto tray = ray; if (intersect_triangle(tray, p0, p1, p3, uv, dist)) { hit = true; tray.tmax = dist; } if (intersect_triangle(tray, p2, p3, p1, uv, dist)) { hit = true; uv = 1 - uv; tray.tmax = dist; } return hit; } // Intersect a ray with a axis-aligned bounding box inline bool intersect_bbox(const ray3f& ray, const bbox3f& bbox) { // determine intersection ranges auto invd = 1.0f / ray.d; auto t0 = (bbox.min - ray.o) * invd; auto t1 = (bbox.max - ray.o) * invd; // flip based on range directions if (invd.x < 0.0f) swap(t0.x, t1.x); if (invd.y < 0.0f) swap(t0.y, t1.y); if (invd.z < 0.0f) swap(t0.z, t1.z); auto tmin = max(t0.z, max(t0.y, max(t0.x, ray.tmin))); auto tmax = min(t1.z, min(t1.y, min(t1.x, ray.tmax))); tmax *= 1.00000024f; // for double: 1.0000000000000004 return tmin <= tmax; } // Intersect a ray with a axis-aligned bounding box inline bool intersect_bbox( const ray3f& ray, const vec3f& ray_dinv, const bbox3f& bbox) { auto it_min = (bbox.min - ray.o) * ray_dinv; auto it_max = (bbox.max - ray.o) * ray_dinv; auto tmin = min(it_min, it_max); auto tmax = max(it_min, it_max); auto t0 = max(max(tmin), ray.tmin); auto t1 = min(min(tmax), ray.tmax); t1 *= 1.00000024f; // for double: 1.0000000000000004 return t0 <= t1; } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENRTATION OF POINT-PRIMITIVE DISTANCE FUNCTIONS // ----------------------------------------------------------------------------- namespace yocto { // TODO: documentation bool overlap_point(const vec3f& pos, float dist_max, const vec3f& p, float r, vec2f& uv, float& dist) { auto d2 = dot(pos - p, pos - p); if (d2 > (dist_max + r) * (dist_max + r)) return false; uv = {0, 0}; dist = sqrt(d2); return true; } // TODO: documentation float closestuv_line(const vec3f& pos, const vec3f& p0, const vec3f& p1) { auto ab = p1 - p0; auto d = dot(ab, ab); // Project c onto ab, computing parameterized position d(t) = a + t*(b – // a) auto u = dot(pos - p0, ab) / d; u = clamp(u, (float)0, (float)1); return u; } // TODO: documentation bool overlap_line(const vec3f& pos, float dist_max, const vec3f& p0, const vec3f& p1, float r0, float r1, vec2f& uv, float& dist) { auto u = closestuv_line(pos, p0, p1); // Compute projected position from the clamped t d = a + t * ab; auto p = p0 + (p1 - p0) * u; auto r = r0 + (r1 - r0) * u; auto d2 = dot(pos - p, pos - p); // check distance if (d2 > (dist_max + r) * (dist_max + r)) return false; // done uv = {u, 0}; dist = sqrt(d2); return true; } // TODO: documentation // this is a complicated test -> I probably "--"+prefix to use a sequence of // test (triangle body, and 3 edges) vec2f closestuv_triangle( const vec3f& pos, const vec3f& p0, const vec3f& p1, const vec3f& p2) { auto ab = p1 - p0; auto ac = p2 - p0; auto ap = pos - p0; auto d1 = dot(ab, ap); auto d2 = dot(ac, ap); // corner and edge cases if (d1 <= 0 && d2 <= 0) return {0, 0}; auto bp = pos - p1; auto d3 = dot(ab, bp); auto d4 = dot(ac, bp); if (d3 >= 0 && d4 <= d3) return {1, 0}; auto vc = d1 * d4 - d3 * d2; if ((vc <= 0) && (d1 >= 0) && (d3 <= 0)) return {d1 / (d1 - d3), 0}; auto cp = pos - p2; auto d5 = dot(ab, cp); auto d6 = dot(ac, cp); if (d6 >= 0 && d5 <= d6) return {0, 1}; auto vb = d5 * d2 - d1 * d6; if ((vb <= 0) && (d2 >= 0) && (d6 <= 0)) return {0, d2 / (d2 - d6)}; auto va = d3 * d6 - d5 * d4; if ((va <= 0) && (d4 - d3 >= 0) && (d5 - d6 >= 0)) { auto w = (d4 - d3) / ((d4 - d3) + (d5 - d6)); return {1 - w, w}; } // face case auto denom = 1 / (va + vb + vc); auto u = vb * denom; auto v = vc * denom; return {u, v}; } // TODO: documentation bool overlap_triangle(const vec3f& pos, float dist_max, const vec3f& p0, const vec3f& p1, const vec3f& p2, float r0, float r1, float r2, vec2f& uv, float& dist) { auto cuv = closestuv_triangle(pos, p0, p1, p2); auto p = p0 * (1 - cuv.x - cuv.y) + p1 * cuv.x + p2 * cuv.y; auto r = r0 * (1 - cuv.x - cuv.y) + r1 * cuv.x + r2 * cuv.y; auto dd = dot(p - pos, p - pos); if (dd > (dist_max + r) * (dist_max + r)) return false; uv = cuv; dist = sqrt(dd); return true; } // TODO: documentation bool overlap_quad(const vec3f& pos, float dist_max, const vec3f& p0, const vec3f& p1, const vec3f& p2, const vec3f& p3, float r0, float r1, float r2, float r3, vec2f& uv, float& dist) { if (p2 == p3) { return overlap_triangle(pos, dist_max, p0, p1, p3, r0, r1, r2, uv, dist); } auto hit = false; if (overlap_triangle(pos, dist_max, p0, p1, p3, r0, r1, r2, uv, dist)) { hit = true; dist_max = dist; } if (!overlap_triangle(pos, dist_max, p2, p3, p1, r2, r3, r1, uv, dist)) { hit = true; uv = 1 - uv; // dist_max = dist; } return hit; } // TODO: documentation inline bool distance_check_bbox( const vec3f& pos, float dist_max, const bbox3f& bbox) { // computing distance auto dd = 0.0f; // For each axis count any excess distance outside box extents if (pos.x < bbox.min.x) dd += (bbox.min.x - pos.x) * (bbox.min.x - pos.x); if (pos.x > bbox.max.x) dd += (pos.x - bbox.max.x) * (pos.x - bbox.max.x); if (pos.y < bbox.min.y) dd += (bbox.min.y - pos.y) * (bbox.min.y - pos.y); if (pos.y > bbox.max.y) dd += (pos.y - bbox.max.y) * (pos.y - bbox.max.y); if (pos.z < bbox.min.z) dd += (bbox.min.z - pos.z) * (bbox.min.z - pos.z); if (pos.z > bbox.max.z) dd += (pos.z - bbox.max.z) * (pos.z - bbox.max.z); // check distance return dd < dist_max * dist_max; } // TODO: doc inline bool overlap_bbox(const bbox3f& bbox1, const bbox3f& bbox2) { if (bbox1.max.x < bbox2.min.x || bbox1.min.x > bbox2.max.x) return false; if (bbox1.max.y < bbox2.min.y || bbox1.min.y > bbox2.max.y) return false; if (bbox1.max.z < bbox2.min.z || bbox1.min.z > bbox2.max.z) return false; return true; } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION FOR BVH // ----------------------------------------------------------------------------- namespace yocto { #if YOCTO_EMBREE // Cleanup bvh_shape::~bvh_shape() { if (embree_bvh) { rtcReleaseScene((RTCScene)embree_bvh); } } // Cleanup bvh_scene::~bvh_scene() { if (embree_bvh) { rtcReleaseScene((RTCScene)embree_bvh); } } static void embree_error(void* ctx, RTCError code, const char* str) { switch (code) { case RTC_ERROR_UNKNOWN: throw std::runtime_error("RTC_ERROR_UNKNOWN: "s + str); break; case RTC_ERROR_INVALID_ARGUMENT: throw std::runtime_error("RTC_ERROR_INVALID_ARGUMENT: "s + str); break; case RTC_ERROR_INVALID_OPERATION: throw std::runtime_error("RTC_ERROR_INVALID_OPERATION: "s + str); break; case RTC_ERROR_OUT_OF_MEMORY: throw std::runtime_error("RTC_ERROR_OUT_OF_MEMORY: "s + str); break; case RTC_ERROR_UNSUPPORTED_CPU: throw std::runtime_error("RTC_ERROR_UNSUPPORTED_CPU: "s + str); break; case RTC_ERROR_CANCELLED: throw std::runtime_error("RTC_ERROR_CANCELLED: "s + str); break; default: throw std::runtime_error("invalid error code"); break; } } // Embree memory std::atomic embree_memory = 0; static bool embree_memory_monitor(void* userPtr, ssize_t bytes, bool post) { embree_memory += bytes; return true; } // Get Embree device static RTCDevice get_embree_device() { static RTCDevice device = nullptr; if (!device) { device = rtcNewDevice(""); rtcSetDeviceErrorFunction(device, embree_error, nullptr); rtcSetDeviceMemoryMonitorFunction(device, embree_memory_monitor, nullptr); } return device; } // Initialize Embree BVH static void build_embree_bvh(bvh_shape& shape, const bvh_params& params) { auto embree_device = get_embree_device(); auto embree_scene = rtcNewScene(embree_device); if (params.embree_compact) { rtcSetSceneFlags(embree_scene, RTC_SCENE_FLAG_COMPACT); } if (params.high_quality) { rtcSetSceneBuildQuality(embree_scene, RTC_BUILD_QUALITY_HIGH); } shape.embree_bvh = embree_scene; auto embree_geom = (RTCGeometry) nullptr; if (!shape.points.empty()) { throw std::runtime_error("embree does not support points"); } else if (!shape.lines.empty()) { auto elines = vector{}; auto epositions = vector{}; auto last_index = -1; for (auto& l : shape.lines) { if (last_index == l.x) { elines.push_back((int)epositions.size() - 1); epositions.push_back({shape.positions[l.y], shape.radius[l.y]}); } else { elines.push_back((int)epositions.size()); epositions.push_back({shape.positions[l.x], shape.radius[l.x]}); epositions.push_back({shape.positions[l.y], shape.radius[l.y]}); } last_index = l.y; } embree_geom = rtcNewGeometry( get_embree_device(), RTC_GEOMETRY_TYPE_FLAT_LINEAR_CURVE); rtcSetGeometryVertexAttributeCount(embree_geom, 1); auto embree_positions = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT4, 4 * 4, epositions.size()); auto embree_lines = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT, 4, elines.size()); memcpy(embree_positions, epositions.data(), epositions.size() * 16); memcpy(embree_lines, elines.data(), elines.size() * 4); } else if (!shape.triangles.empty()) { embree_geom = rtcNewGeometry( get_embree_device(), RTC_GEOMETRY_TYPE_TRIANGLE); rtcSetGeometryVertexAttributeCount(embree_geom, 1); if (params.embree_compact) { rtcSetSharedGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, shape.positions.data(), 0, 3 * 4, shape.positions.size()); rtcSetSharedGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, shape.triangles.data(), 0, 3 * 4, shape.triangles.size()); } else { auto embree_positions = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, 3 * 4, shape.positions.size()); auto embree_triangles = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, 3 * 4, shape.triangles.size()); memcpy(embree_positions, shape.positions.data(), shape.positions.size() * 12); memcpy(embree_triangles, shape.triangles.data(), shape.triangles.size() * 12); } } else if (!shape.quads.empty()) { embree_geom = rtcNewGeometry(get_embree_device(), RTC_GEOMETRY_TYPE_QUAD); rtcSetGeometryVertexAttributeCount(embree_geom, 1); if (params.embree_compact) { rtcSetSharedGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, shape.positions.data(), 0, 3 * 4, shape.positions.size()); rtcSetSharedGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT4, shape.quads.data(), 0, 4 * 4, shape.quads.size()); } else { auto embree_positions = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, 3 * 4, shape.positions.size()); auto embree_quads = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT4, 4 * 4, shape.quads.size()); memcpy(embree_positions, shape.positions.data(), shape.positions.size() * 12); memcpy(embree_quads, shape.quads.data(), shape.quads.size() * 16); } } else if (!shape.quadspos.empty()) { embree_geom = rtcNewGeometry(get_embree_device(), RTC_GEOMETRY_TYPE_QUAD); rtcSetGeometryVertexAttributeCount(embree_geom, 1); if (params.embree_compact) { rtcSetSharedGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, shape.positions.data(), 0, 3 * 4, shape.positions.size()); rtcSetSharedGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT4, shape.quadspos.data(), 0, 4 * 4, shape.quadspos.size()); } else { auto embree_positions = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, 3 * 4, shape.positions.size()); auto embree_quads = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT4, 4 * 4, shape.quadspos.size()); memcpy(embree_positions, shape.positions.data(), shape.positions.size() * 12); memcpy(embree_quads, shape.quadspos.data(), shape.quadspos.size() * 16); } } rtcCommitGeometry(embree_geom); rtcAttachGeometryByID(embree_scene, embree_geom, 0); rtcCommitScene(embree_scene); shape.embree_flattened = false; } // Build a BVH using Embree. static void build_embree_bvh(bvh_scene& scene, const bvh_params& params) { // scene bvh auto embree_device = get_embree_device(); auto embree_scene = rtcNewScene(embree_device); if (params.embree_compact) { rtcSetSceneFlags(embree_scene, RTC_SCENE_FLAG_COMPACT); } if (params.high_quality) { rtcSetSceneBuildQuality(embree_scene, RTC_BUILD_QUALITY_HIGH); } scene.embree_bvh = embree_scene; if (scene.instances.empty()) { rtcCommitScene(embree_scene); return; } for (auto instance_id = 0; instance_id < scene.instances.size(); instance_id++) { auto& instance = scene.instances[instance_id]; if (instance.shape < 0) throw std::runtime_error("empty instance"); auto& shape = scene.shapes[instance.shape]; if (!shape.embree_bvh) throw std::runtime_error("bvh not built"); auto embree_geom = rtcNewGeometry( embree_device, RTC_GEOMETRY_TYPE_INSTANCE); rtcSetGeometryInstancedScene(embree_geom, (RTCScene)shape.embree_bvh); rtcSetGeometryTransform( embree_geom, 0, RTC_FORMAT_FLOAT3X4_COLUMN_MAJOR, &instance.frame); rtcCommitGeometry(embree_geom); rtcAttachGeometryByID(embree_scene, embree_geom, instance_id); } rtcCommitScene(embree_scene); scene.embree_flattened = false; } // Initialize Embree BVH static void build_embree_flattened_bvh( bvh_scene& scene, const bvh_params& params) { // scene bvh auto embree_device = get_embree_device(); auto embree_scene = rtcNewScene(embree_device); if (params.embree_compact) { rtcSetSceneFlags(embree_scene, RTC_SCENE_FLAG_COMPACT); } if (params.high_quality) { rtcSetSceneBuildQuality(embree_scene, RTC_BUILD_QUALITY_HIGH); } scene.embree_bvh = embree_scene; if (scene.instances.empty()) { rtcCommitScene(embree_scene); return; } for (auto instance_id = 0; instance_id < scene.instances.size(); instance_id++) { auto& instance = scene.instances[instance_id]; auto& shape = scene.shapes[instance.shape]; auto embree_geom = (RTCGeometry) nullptr; if (shape.positions.empty()) continue; auto transformed_positions = vector{ shape.positions.begin(), shape.positions.end()}; if (instance.frame != identity3x4f) { for (auto& p : transformed_positions) p = transform_point(instance.frame, p); } if (!shape.points.empty()) { throw std::runtime_error("embree does not support points"); } else if (!shape.lines.empty()) { auto elines = vector{}; auto epositions = vector{}; auto last_index = -1; for (auto& l : shape.lines) { if (last_index == l.x) { elines.push_back((int)transformed_positions.size() - 1); epositions.push_back({transformed_positions[l.y], shape.radius[l.y]}); } else { elines.push_back((int)transformed_positions.size()); epositions.push_back({transformed_positions[l.x], shape.radius[l.x]}); epositions.push_back({transformed_positions[l.y], shape.radius[l.y]}); } last_index = l.y; } embree_geom = rtcNewGeometry( get_embree_device(), RTC_GEOMETRY_TYPE_FLAT_LINEAR_CURVE); rtcSetGeometryVertexAttributeCount(embree_geom, 1); auto embree_positions = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT4, 4 * 4, epositions.size()); auto embree_lines = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT, 4, elines.size()); memcpy(embree_positions, epositions.data(), epositions.size() * 16); memcpy(embree_lines, elines.data(), elines.size() * 4); } else if (!shape.triangles.empty()) { embree_geom = rtcNewGeometry( get_embree_device(), RTC_GEOMETRY_TYPE_TRIANGLE); rtcSetGeometryVertexAttributeCount(embree_geom, 1); auto embree_positions = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, 3 * 4, transformed_positions.size()); auto embree_triangles = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, 3 * 4, shape.triangles.size()); memcpy(embree_positions, transformed_positions.data(), transformed_positions.size() * 12); memcpy(embree_triangles, shape.triangles.data(), shape.triangles.size() * 12); } else if (!shape.quads.empty()) { embree_geom = rtcNewGeometry(get_embree_device(), RTC_GEOMETRY_TYPE_QUAD); rtcSetGeometryVertexAttributeCount(embree_geom, 1); auto embree_positions = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, 3 * 4, transformed_positions.size()); auto embree_quads = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT4, 4 * 4, shape.quads.size()); memcpy(embree_positions, transformed_positions.data(), transformed_positions.size() * 12); memcpy(embree_quads, shape.quads.data(), shape.quads.size() * 16); } else if (!shape.quadspos.empty()) { embree_geom = rtcNewGeometry(get_embree_device(), RTC_GEOMETRY_TYPE_QUAD); rtcSetGeometryVertexAttributeCount(embree_geom, 1); auto embree_positions = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, 3 * 4, transformed_positions.size()); auto embree_quads = rtcSetNewGeometryBuffer(embree_geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT4, 4 * 4, shape.quadspos.size()); memcpy(embree_positions, transformed_positions.data(), transformed_positions.size() * 12); memcpy(embree_quads, shape.quadspos.data(), shape.quadspos.size() * 16); } else { throw std::runtime_error("empty bvh"); } rtcCommitGeometry(embree_geom); rtcAttachGeometryByID(embree_scene, embree_geom, instance_id); } rtcCommitScene(embree_scene); scene.embree_flattened = true; } // Refit a BVH using Embree. Calls `refit_bvh()` if Embree is not // available. static void refit_embree_bvh(bvh_shape& bvh) { throw std::runtime_error("not yet implemented"); } static bool intersect_embree_bvh(const bvh_shape& shape, const ray3f& ray, int& element, vec2f& uv, float& distance, bool find_any) { RTCRayHit embree_ray; embree_ray.ray.org_x = ray.o.x; embree_ray.ray.org_y = ray.o.y; embree_ray.ray.org_z = ray.o.z; embree_ray.ray.dir_x = ray.d.x; embree_ray.ray.dir_y = ray.d.y; embree_ray.ray.dir_z = ray.d.z; embree_ray.ray.tnear = ray.tmin; embree_ray.ray.tfar = ray.tmax; embree_ray.ray.flags = 0; embree_ray.hit.geomID = RTC_INVALID_GEOMETRY_ID; embree_ray.hit.instID[0] = RTC_INVALID_GEOMETRY_ID; RTCIntersectContext embree_ctx; rtcInitIntersectContext(&embree_ctx); rtcIntersect1((RTCScene)shape.embree_bvh, &embree_ctx, &embree_ray); if (embree_ray.hit.geomID == RTC_INVALID_GEOMETRY_ID) return false; element = (int)embree_ray.hit.primID; uv = {embree_ray.hit.u, embree_ray.hit.v}; distance = embree_ray.ray.tfar; return true; } static bool intersect_embree_bvh(const bvh_scene& scene, const ray3f& ray, int& instance, int& element, vec2f& uv, float& distance, bool find_any) { RTCRayHit embree_ray; embree_ray.ray.org_x = ray.o.x; embree_ray.ray.org_y = ray.o.y; embree_ray.ray.org_z = ray.o.z; embree_ray.ray.dir_x = ray.d.x; embree_ray.ray.dir_y = ray.d.y; embree_ray.ray.dir_z = ray.d.z; embree_ray.ray.tnear = ray.tmin; embree_ray.ray.tfar = ray.tmax; embree_ray.ray.flags = 0; embree_ray.hit.geomID = RTC_INVALID_GEOMETRY_ID; embree_ray.hit.instID[0] = RTC_INVALID_GEOMETRY_ID; RTCIntersectContext embree_ctx; rtcInitIntersectContext(&embree_ctx); rtcIntersect1((RTCScene)scene.embree_bvh, &embree_ctx, &embree_ray); if (embree_ray.hit.geomID == RTC_INVALID_GEOMETRY_ID) return false; instance = scene.embree_flattened ? (int)embree_ray.hit.geomID : (int)embree_ray.hit.instID[0]; element = (int)embree_ray.hit.primID; uv = {embree_ray.hit.u, embree_ray.hit.v}; distance = embree_ray.ray.tfar; return true; } #endif // BVH primitive with its bbox, its center and the index to the primitive struct bvh_prim { bbox3f bbox = invalidb3f; vec3f center = zero3f; int primid = 0; }; // Splits a BVH node using the SAH heuristic. Returns split position and axis. static pair split_sah(vector& prims, int start, int end) { // initialize split axis and position auto split_axis = 0; auto mid = (start + end) / 2; // compute primintive bounds and size auto cbbox = invalidb3f; for (auto i = start; i < end; i++) cbbox = merge(cbbox, prims[i].center); auto csize = cbbox.max - cbbox.min; if (csize == zero3f) return {mid, split_axis}; // consider N bins, compute their cost and keep the minimum const int nbins = 16; auto middle = 0.0f; auto min_cost = flt_max; auto area = [](auto& b) { auto size = b.max - b.min; return 1e-12f + 2 * size.x * size.y + 2 * size.x * size.z + 2 * size.y * size.z; }; for (auto saxis = 0; saxis < 3; saxis++) { for (auto b = 1; b < nbins; b++) { auto split = cbbox.min[saxis] + b * csize[saxis] / nbins; auto left_bbox = invalidb3f, right_bbox = invalidb3f; auto left_nprims = 0, right_nprims = 0; for (auto i = start; i < end; i++) { if (prims[i].center[saxis] < split) { left_bbox = merge(left_bbox, prims[i].bbox); left_nprims += 1; } else { right_bbox = merge(right_bbox, prims[i].bbox); right_nprims += 1; } } auto cost = 1 + left_nprims * area(left_bbox) / area(cbbox) + right_nprims * area(right_bbox) / area(cbbox); if (cost < min_cost) { min_cost = cost; middle = split; split_axis = saxis; } } } // split mid = (int)(std::partition(prims.data() + start, prims.data() + end, [split_axis, middle]( auto& a) { return a.center[split_axis] < middle; }) - prims.data()); // if we were not able to split, just break the primitives in half if (mid == start || mid == end) { throw std::runtime_error("bad bvh split"); split_axis = 0; mid = (start + end) / 2; } return {mid, split_axis}; } // Splits a BVH node using the balance heuristic. Returns split position and // axis. static pair split_balanced( vector& prims, int start, int end) { // initialize split axis and position auto axis = 0; auto mid = (start + end) / 2; // compute primintive bounds and size auto cbbox = invalidb3f; for (auto i = start; i < end; i++) cbbox = merge(cbbox, prims[i].center); auto csize = cbbox.max - cbbox.min; if (csize == zero3f) return {mid, axis}; // split along largest if (csize.x >= csize.y && csize.x >= csize.z) axis = 0; if (csize.y >= csize.x && csize.y >= csize.z) axis = 1; if (csize.z >= csize.x && csize.z >= csize.y) axis = 2; // balanced tree split: find the largest axis of the // bounding box and split along this one right in the middle mid = (start + end) / 2; std::nth_element(prims.data() + start, prims.data() + mid, prims.data() + end, [axis](auto& a, auto& b) { return a.center[axis] < b.center[axis]; }); // if we were not able to split, just break the primitives in half if (mid == start || mid == end) { throw std::runtime_error("bad bvh split"); axis = 0; mid = (start + end) / 2; } return {mid, axis}; } // Splits a BVH node using the middle heutirtic. Returns split position and // axis. static pair split_middle( vector& prims, int start, int end) { // initialize split axis and position auto axis = 0; auto mid = (start + end) / 2; // compute primintive bounds and size auto cbbox = invalidb3f; for (auto i = start; i < end; i++) cbbox = merge(cbbox, prims[i].center); auto csize = cbbox.max - cbbox.min; if (csize == zero3f) return {mid, axis}; // split along largest if (csize.x >= csize.y && csize.x >= csize.z) axis = 0; if (csize.y >= csize.x && csize.y >= csize.z) axis = 1; if (csize.z >= csize.x && csize.z >= csize.y) axis = 2; // split the space in the middle along the largest axis auto cmiddle = (cbbox.max + cbbox.min) / 2; auto middle = cmiddle[axis]; mid = (int)(std::partition(prims.data() + start, prims.data() + end, [axis, middle](auto& a) { return a.center[axis] < middle; }) - prims.data()); // if we were not able to split, just break the primitives in half if (mid == start || mid == end) { throw std::runtime_error("bad bvh split"); axis = 0; mid = (start + end) / 2; } return {mid, axis}; } // Build BVH nodes static void build_bvh_serial(vector& nodes, vector& prims, const bvh_params& params) { // prepare to build nodes nodes.clear(); nodes.reserve(prims.size() * 2); // queue up first node auto queue = std::deque{{0, 0, (int)prims.size()}}; nodes.emplace_back(); // create nodes until the queue is empty while (!queue.empty()) { // exit if needed if (params.cancel && *params.cancel) return; // grab node to work on auto next = queue.front(); queue.pop_front(); auto nodeid = next.x, start = next.y, end = next.z; // grab node auto& node = nodes[nodeid]; // compute bounds node.bbox = invalidb3f; for (auto i = start; i < end; i++) node.bbox = merge(node.bbox, prims[i].bbox); // split into two children if (end - start > bvh_max_prims) { // get split auto [mid, axis] = (params.high_quality) ? split_sah(prims, start, end) : split_balanced(prims, start, end); // make an internal node node.internal = true; node.axis = axis; node.num = 2; node.prims[0] = (int)nodes.size() + 0; node.prims[1] = (int)nodes.size() + 1; nodes.emplace_back(); nodes.emplace_back(); queue.push_back({node.prims[0], start, mid}); queue.push_back({node.prims[1], mid, end}); } else { // Make a leaf node node.internal = false; node.num = end - start; for (auto i = 0; i < node.num; i++) node.prims[i] = prims[start + i].primid; } } // cleanup nodes.shrink_to_fit(); } // Build BVH nodes static void build_bvh_parallel(vector& nodes, vector& prims, const bvh_params& params) { // prepare to build nodes nodes.clear(); nodes.reserve(prims.size() * 2); // queue up first node auto queue = std::deque{{0, 0, (int)prims.size()}}; nodes.emplace_back(); // synchronization std::atomic num_processed_prims(0); std::mutex queue_mutex; vector> futures; auto nthreads = std::thread::hardware_concurrency(); // create nodes until the queue is empty for (auto thread_id = 0; thread_id < nthreads; thread_id++) { futures.emplace_back(std::async(std::launch::async, [&nodes, &prims, ¶ms, &num_processed_prims, &queue_mutex, &queue] { while (true) { // exit if needed if (num_processed_prims >= prims.size()) return; if (params.cancel && *params.cancel) return; // grab node to work on auto next = zero3i; { std::lock_guard lock{queue_mutex}; if (!queue.empty()) { next = queue.front(); queue.pop_front(); } } // wait a bit if needed if (next == zero3i) { std::this_thread::sleep_for(std::chrono::microseconds(10)); continue; } // grab node auto nodeid = next.x, start = next.y, end = next.z; auto& node = nodes[nodeid]; // compute bounds node.bbox = invalidb3f; for (auto i = start; i < end; i++) node.bbox = merge(node.bbox, prims[i].bbox); // split into two children if (end - start > bvh_max_prims) { // get split auto [mid, axis] = (params.high_quality) ? split_sah(prims, start, end) : split_balanced(prims, start, end); // make an internal node { std::lock_guard lock{queue_mutex}; node.internal = true; node.axis = axis; node.num = 2; node.prims[0] = (int)nodes.size() + 0; node.prims[1] = (int)nodes.size() + 1; nodes.emplace_back(); nodes.emplace_back(); queue.push_back({node.prims[0], start, mid}); queue.push_back({node.prims[1], mid, end}); } } else { // Make a leaf node node.internal = false; node.num = end - start; for (auto i = 0; i < node.num; i++) node.prims[i] = prims[start + i].primid; num_processed_prims += node.num; } } })); } for (auto& f : futures) f.get(); // cleanup nodes.shrink_to_fit(); } void build_bvh(bvh_shape& shape, const bvh_params& params) { #if YOCTO_EMBREE // call Embree if needed if (params.use_embree) { return build_embree_bvh(shape, params); } #endif // build primitives auto prims = vector{}; if (!shape.points.empty()) { prims = vector(shape.points.size()); for (auto idx = 0; idx < prims.size(); idx++) { auto& p = shape.points[idx]; auto bbox = point_bounds(shape.positions[p], shape.radius[p]); prims[idx] = {bbox, center(bbox), idx}; } } else if (!shape.lines.empty()) { prims = vector(shape.lines.size()); for (auto idx = 0; idx < prims.size(); idx++) { auto& l = shape.lines[idx]; auto bbox = line_bounds(shape.positions[l.x], shape.positions[l.y], shape.radius[l.x], shape.radius[l.y]); prims[idx] = {bbox, center(bbox), idx}; } } else if (!shape.triangles.empty()) { prims = vector(shape.triangles.size()); for (auto idx = 0; idx < prims.size(); idx++) { auto& t = shape.triangles[idx]; auto bbox = triangle_bounds( shape.positions[t.x], shape.positions[t.y], shape.positions[t.z]); prims[idx] = {bbox, center(bbox), idx}; } } else if (!shape.quads.empty()) { prims = vector(shape.quads.size()); for (auto idx = 0; idx < prims.size(); idx++) { auto& q = shape.quads[idx]; auto bbox = quad_bounds(shape.positions[q.x], shape.positions[q.y], shape.positions[q.z], shape.positions[q.w]); prims[idx] = {bbox, center(bbox), idx}; } } else if (!shape.quadspos.empty()) { prims = vector(shape.quadspos.size()); for (auto idx = 0; idx < prims.size(); idx++) { auto& q = shape.quadspos[idx]; auto bbox = quad_bounds(shape.positions[q.x], shape.positions[q.y], shape.positions[q.z], shape.positions[q.w]); prims[idx] = {bbox, center(bbox), idx}; } } else { } // build nodes if (params.noparallel) { build_bvh_serial(shape.nodes, prims, params); } else { build_bvh_parallel(shape.nodes, prims, params); } } void build_bvh(bvh_scene& scene, const bvh_params& params) { for (auto idx = 0; idx < scene.shapes.size(); idx++) { build_bvh(scene.shapes[idx], params); } // embree #if YOCTO_EMBREE if (params.use_embree) { if (params.embree_flatten) { return build_embree_flattened_bvh(scene, params); } else { return build_embree_bvh(scene, params); } } #endif // build primitives auto prims = vector(scene.instances.size()); for (auto idx = 0; idx < prims.size(); idx++) { auto& instance = scene.instances[idx]; auto& sbvh = scene.shapes[instance.shape]; auto bbox = sbvh.nodes.empty() ? invalidb3f : transform_bbox(instance.frame, sbvh.nodes[0].bbox); prims[idx] = {bbox, center(bbox), idx}; } // build nodes if (params.noparallel) { build_bvh_serial(scene.nodes, prims, params); } else { build_bvh_parallel(scene.nodes, prims, params); } } void refit_bvh(bvh_shape& shape, const bvh_params& params) { #if YOCTO_EMBREE if (shape.embree_bvh) throw std::runtime_error("Embree reftting disabled"); #endif // refit for (auto nodeid = (int)shape.nodes.size() - 1; nodeid >= 0; nodeid--) { auto& node = shape.nodes[nodeid]; node.bbox = invalidb3f; if (node.internal) { for (auto i = 0; i < 2; i++) { node.bbox = merge(node.bbox, shape.nodes[node.prims[i]].bbox); } } else if (!shape.points.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& p = shape.points[node.prims[idx]]; node.bbox = merge( node.bbox, point_bounds(shape.positions[p], shape.radius[p])); } } else if (!shape.lines.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& l = shape.lines[node.prims[idx]]; node.bbox = merge( node.bbox, line_bounds(shape.positions[l.x], shape.positions[l.y], shape.radius[l.x], shape.radius[l.y])); } } else if (!shape.triangles.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& t = shape.triangles[node.prims[idx]]; node.bbox = merge( node.bbox, triangle_bounds(shape.positions[t.x], shape.positions[t.y], shape.positions[t.z])); } } else if (!shape.quads.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& q = shape.quads[node.prims[idx]]; node.bbox = merge( node.bbox, quad_bounds(shape.positions[q.x], shape.positions[q.y], shape.positions[q.z], shape.positions[q.w])); } } else if (!shape.quadspos.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& q = shape.quadspos[node.prims[idx]]; node.bbox = merge( node.bbox, quad_bounds(shape.positions[q.x], shape.positions[q.y], shape.positions[q.z], shape.positions[q.w])); } } } } void refit_bvh(bvh_scene& scene, const vector& updated_shapes, const bvh_params& params) { // update shapes for (auto shape : updated_shapes) refit_bvh(scene.shapes[shape], params); #if YOCTO_EMBREE if (scene.embree_bvh) throw std::runtime_error("Embree reftting disabled"); #endif // refit for (auto nodeid = (int)scene.nodes.size() - 1; nodeid >= 0; nodeid--) { auto& node = scene.nodes[nodeid]; node.bbox = invalidb3f; if (node.internal) { for (auto i = 0; i < 2; i++) { node.bbox = merge(node.bbox, scene.nodes[node.prims[i]].bbox); } } else { for (auto idx = 0; idx < node.num; idx++) { auto& instance = scene.instances[idx]; auto& sbvh = scene.shapes[instance.shape]; auto bbox = sbvh.nodes.empty() ? invalidb3f : transform_bbox(instance.frame, sbvh.nodes[0].bbox); node.bbox = merge(node.bbox, bbox); } } } } // Intersect ray with a bvh. bool intersect_bvh(const bvh_shape& shape, const ray3f& ray_, int& element, vec2f& uv, float& distance, bool find_any) { #if YOCTO_EMBREE // call Embree if needed if (shape.embree_bvh) { return intersect_embree_bvh(shape, ray_, element, uv, distance, find_any); } #endif // check empty if (shape.nodes.empty()) return false; // node stack int node_stack[128]; auto node_cur = 0; node_stack[node_cur++] = 0; // shared variables auto hit = false; // copy ray to modify it auto ray = ray_; // prepare ray for fast queries auto ray_dinv = vec3f{1 / ray.d.x, 1 / ray.d.y, 1 / ray.d.z}; auto ray_dsign = vec3i{(ray_dinv.x < 0) ? 1 : 0, (ray_dinv.y < 0) ? 1 : 0, (ray_dinv.z < 0) ? 1 : 0}; // walking stack while (node_cur) { // grab node auto& node = shape.nodes[node_stack[--node_cur]]; // intersect bbox // if (!intersect_bbox(ray, ray_dinv, ray_dsign, node.bbox)) continue; if (!intersect_bbox(ray, ray_dinv, node.bbox)) continue; // intersect node, switching based on node type // for each type, iterate over the the primitive list if (node.internal) { // for internal nodes, attempts to proceed along the // split axis from smallest to largest nodes if (ray_dsign[node.axis]) { node_stack[node_cur++] = node.prims[0]; node_stack[node_cur++] = node.prims[1]; } else { node_stack[node_cur++] = node.prims[1]; node_stack[node_cur++] = node.prims[0]; } } else if (!shape.points.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& p = shape.points[node.prims[idx]]; if (intersect_point( ray, shape.positions[p], shape.radius[p], uv, distance)) { hit = true; element = node.prims[idx]; ray.tmax = distance; } } } else if (!shape.lines.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& l = shape.lines[node.prims[idx]]; if (intersect_line(ray, shape.positions[l.x], shape.positions[l.y], shape.radius[l.x], shape.radius[l.y], uv, distance)) { hit = true; element = node.prims[idx]; ray.tmax = distance; } } } else if (!shape.triangles.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& t = shape.triangles[node.prims[idx]]; if (intersect_triangle(ray, shape.positions[t.x], shape.positions[t.y], shape.positions[t.z], uv, distance)) { hit = true; element = node.prims[idx]; ray.tmax = distance; } } } else if (!shape.quads.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& q = shape.quads[node.prims[idx]]; if (intersect_quad(ray, shape.positions[q.x], shape.positions[q.y], shape.positions[q.z], shape.positions[q.w], uv, distance)) { hit = true; element = node.prims[idx]; ray.tmax = distance; } } } else if (!shape.quadspos.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& q = shape.quadspos[node.prims[idx]]; if (intersect_quad(ray, shape.positions[q.x], shape.positions[q.y], shape.positions[q.z], shape.positions[q.w], uv, distance)) { hit = true; element = node.prims[idx]; ray.tmax = distance; } } } // check for early exit if (find_any && hit) return hit; } return hit; } // Intersect ray with a bvh. bool intersect_bvh(const bvh_scene& scene, const ray3f& ray_, int& instance, int& element, vec2f& uv, float& distance, bool find_any, bool non_rigid_frames) { #if YOCTO_EMBREE // call Embree if needed if (scene.embree_bvh) { return intersect_embree_bvh( scene, ray_, instance, element, uv, distance, find_any); } #endif // check empty if (scene.nodes.empty()) return false; // node stack int node_stack[128]; auto node_cur = 0; node_stack[node_cur++] = 0; // shared variables auto hit = false; // copy ray to modify it auto ray = ray_; // prepare ray for fast queries auto ray_dinv = vec3f{1 / ray.d.x, 1 / ray.d.y, 1 / ray.d.z}; auto ray_dsign = vec3i{(ray_dinv.x < 0) ? 1 : 0, (ray_dinv.y < 0) ? 1 : 0, (ray_dinv.z < 0) ? 1 : 0}; // walking stack while (node_cur) { // grab node auto& node = scene.nodes[node_stack[--node_cur]]; // intersect bbox // if (!intersect_bbox(ray, ray_dinv, ray_dsign, node.bbox)) continue; if (!intersect_bbox(ray, ray_dinv, node.bbox)) continue; // intersect node, switching based on node type // for each type, iterate over the the primitive list if (node.internal) { // for internal nodes, attempts to proceed along the // split axis from smallest to largest nodes if (ray_dsign[node.axis]) { node_stack[node_cur++] = node.prims[0]; node_stack[node_cur++] = node.prims[1]; } else { node_stack[node_cur++] = node.prims[1]; node_stack[node_cur++] = node.prims[0]; } } else { for (auto i = 0; i < node.num; i++) { auto& instance_ = scene.instances[node.prims[i]]; auto inv_ray = transform_ray( inverse(instance_.frame, non_rigid_frames), ray); if (intersect_bvh(scene.shapes[instance_.shape], inv_ray, element, uv, distance, find_any)) { hit = true; instance = node.prims[i]; ray.tmax = distance; } } } // check for early exit if (find_any && hit) return hit; } return hit; } // Intersect ray with a bvh. bool intersect_bvh(const bvh_scene& scene, int instance, const ray3f& ray, int& element, vec2f& uv, float& distance, bool find_any, bool non_rigid_frames) { auto& instance_ = scene.instances[instance]; auto inv_ray = transform_ray(inverse(instance_.frame, non_rigid_frames), ray); return intersect_bvh( scene.shapes[instance_.shape], inv_ray, element, uv, distance, find_any); } // Intersect ray with a bvh. bool overlap_bvh(const bvh_shape& shape, const vec3f& pos, float max_distance, int& element, vec2f& uv, float& distance, bool find_any) { // check if empty if (shape.nodes.empty()) return false; // node stack int node_stack[64]; auto node_cur = 0; node_stack[node_cur++] = 0; // hit auto hit = false; // walking stack while (node_cur) { // grab node auto& node = shape.nodes[node_stack[--node_cur]]; // intersect bbox if (!distance_check_bbox(pos, max_distance, node.bbox)) continue; // intersect node, switching based on node type // for each type, iterate over the the primitive list if (node.internal) { // internal node node_stack[node_cur++] = node.prims[0]; node_stack[node_cur++] = node.prims[1]; } else if (!shape.points.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& p = shape.points[node.prims[idx]]; if (overlap_point(pos, max_distance, shape.positions[p], shape.radius[p], uv, distance)) { hit = true; element = node.prims[idx]; max_distance = distance; } } } else if (!shape.lines.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& l = shape.lines[node.prims[idx]]; if (overlap_line(pos, max_distance, shape.positions[l.x], shape.positions[l.y], shape.radius[l.x], shape.radius[l.y], uv, distance)) { hit = true; element = node.prims[idx]; max_distance = distance; } } } else if (!shape.triangles.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& t = shape.triangles[node.prims[idx]]; if (overlap_triangle(pos, max_distance, shape.positions[t.x], shape.positions[t.y], shape.positions[t.z], shape.radius[t.x], shape.radius[t.y], shape.radius[t.z], uv, distance)) { hit = true; element = node.prims[idx]; max_distance = distance; } } } else if (!shape.quads.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& q = shape.quads[node.prims[idx]]; if (overlap_quad(pos, max_distance, shape.positions[q.x], shape.positions[q.y], shape.positions[q.z], shape.positions[q.w], shape.radius[q.x], shape.radius[q.y], shape.radius[q.z], shape.radius[q.w], uv, distance)) { hit = true; element = node.prims[idx]; max_distance = distance; } } } else if (!shape.quadspos.empty()) { for (auto idx = 0; idx < node.num; idx++) { auto& q = shape.quadspos[node.prims[idx]]; if (overlap_quad(pos, max_distance, shape.positions[q.x], shape.positions[q.y], shape.positions[q.z], shape.positions[q.w], shape.radius[q.x], shape.radius[q.y], shape.radius[q.z], shape.radius[q.w], uv, distance)) { hit = true; element = node.prims[idx]; max_distance = distance; } } } // check for early exit if (find_any && hit) return hit; } return hit; } // Intersect ray with a bvh. bool overlap_bvh(const bvh_scene& scene, const vec3f& pos, float max_distance, int& instance, int& element, vec2f& uv, float& distance, bool find_any, bool non_rigid_frames) { // check if empty if (scene.nodes.empty()) return false; // node stack int node_stack[64]; auto node_cur = 0; node_stack[node_cur++] = 0; // hit auto hit = false; // walking stack while (node_cur) { // grab node auto& node = scene.nodes[node_stack[--node_cur]]; // intersect bbox if (!distance_check_bbox(pos, max_distance, node.bbox)) continue; // intersect node, switching based on node type // for each type, iterate over the the primitive list if (node.internal) { // internal node node_stack[node_cur++] = node.prims[0]; node_stack[node_cur++] = node.prims[1]; } else { for (auto i = 0; i < node.num; i++) { auto instance_ = scene.instances[node.prims[i]]; auto inv_pos = transform_point( inverse(instance_.frame, non_rigid_frames), pos); if (overlap_bvh(scene.shapes[instance_.shape], inv_pos, max_distance, element, uv, distance, find_any)) { hit = true; instance = node.prims[i]; max_distance = distance; } } } // check for early exit if (find_any && hit) return hit; } return hit; } #if 0 // Finds the overlap between BVH leaf nodes. template void overlap_bvh_elems(const bvh_scene_data& bvh1, const bvh_scene_data& bvh2, bool skip_duplicates, bool skip_self, vector& overlaps, const OverlapElem& overlap_elems) { // node stack vec2i node_stack[128]; auto node_cur = 0; node_stack[node_cur++] = {0, 0}; // walking stack while (node_cur) { // grab node auto node_idx = node_stack[--node_cur]; const auto node1 = bvh1->nodes[node_idx.x]; const auto node2 = bvh2->nodes[node_idx.y]; // intersect bbox if (!overlap_bbox(node1.bbox, node2.bbox)) continue; // check for leaves if (node1.isleaf && node2.isleaf) { // collide primitives for (auto i1 = node1.start; i1 < node1.start + node1.count; i1++) { for (auto i2 = node2.start; i2 < node2.start + node2.count; i2++) { auto idx1 = bvh1->sorted_prim[i1]; auto idx2 = bvh2->sorted_prim[i2]; if (skip_duplicates && idx1 > idx2) continue; if (skip_self && idx1 == idx2) continue; if (overlap_elems(idx1, idx2)) overlaps.push_back({idx1, idx2}); } } } else { // descend if (node1.isleaf) { for (auto idx2 = node2.start; idx2 < node2.start + node2.count; idx2++) { node_stack[node_cur++] = {node_idx.x, (int)idx2}; } } else if (node2.isleaf) { for (auto idx1 = node1.start; idx1 < node1.start + node1.count; idx1++) { node_stack[node_cur++] = {(int)idx1, node_idx.y}; } } else { for (auto idx2 = node2.start; idx2 < node2.start + node2.count; idx2++) { for (auto idx1 = node1.start; idx1 < node1.start + node1.count; idx1++) { node_stack[node_cur++] = {(int)idx1, (int)idx2}; } } } } } } #endif bvh_intersection intersect_bvh( const bvh_shape& shape, const ray3f& ray, bool find_any) { auto intersection = bvh_intersection{}; intersection.hit = intersect_bvh(shape, ray, intersection.element, intersection.uv, intersection.distance, find_any); return intersection; } bvh_intersection intersect_bvh(const bvh_scene& scene, const ray3f& ray, bool find_any, bool non_rigid_frames) { auto intersection = bvh_intersection{}; intersection.hit = intersect_bvh(scene, ray, intersection.instance, intersection.element, intersection.uv, intersection.distance, find_any); return intersection; } bvh_intersection intersect_bvh(const bvh_scene& scene, int instance, const ray3f& ray, bool find_any, bool non_rigid_frames) { auto intersection = bvh_intersection{}; intersection.hit = intersect_bvh(scene, instance, ray, intersection.element, intersection.uv, intersection.distance, find_any); intersection.instance = instance; return intersection; } bvh_intersection overlap_bvh(const bvh_shape& shape, const vec3f& pos, float max_distance, bool find_any) { auto intersection = bvh_intersection{}; intersection.hit = overlap_bvh(shape, pos, max_distance, intersection.element, intersection.uv, intersection.distance, find_any); return intersection; } bvh_intersection overlap_bvh(const bvh_scene& scene, const vec3f& pos, float max_distance, bool find_any, bool non_rigid_frames) { auto intersection = bvh_intersection{}; intersection.hit = overlap_bvh(scene, pos, max_distance, intersection.instance, intersection.element, intersection.uv, intersection.distance, find_any); return intersection; } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION OF BVH UTILITIES // ----------------------------------------------------------------------------- namespace yocto { // Print bvh statistics. string format_stats(const bvh_shape& bvh) { // TODO auto str = ""s; return str; } string format_stats(const bvh_scene& bvh) { #if 0 auto num_shapes = (size_t)0; auto num_instances = (size_t)0; auto elem_points = (size_t)0; auto elem_lines = (size_t)0; auto elem_triangles = (size_t)0; auto elem_quads = (size_t)0; auto vert_pos = (size_t)0; auto vert_radius = (size_t)0; auto shape_nodes = (size_t)0; auto scene_nodes = (size_t)0; auto stored_elem_points = (size_t)0; auto stored_elem_lines = (size_t)0; auto stored_elem_triangles = (size_t)0; auto stored_elem_quads = (size_t)0; auto stored_vert_pos = (size_t)0; auto stored_vert_radius = (size_t)0; auto memory_elems = (size_t)0; auto memory_verts = (size_t)0; auto memory_ists = (size_t)0; auto memory_shape_nodes = (size_t)0; auto memory_scene_nodes = (size_t)0; for (auto& sbvh : bvh.shapes) { shape_nodes += sbvh.nodes.size(); } num_shapes = bvh.shapes.size(); num_instances = bvh.instances.size(); scene_nodes = bvh.bvh_.nodes.size(); memory_elems = stored_elem_points * sizeof(int) + stored_elem_lines * sizeof(vec2i) + stored_elem_triangles * sizeof(vec3i) + stored_elem_quads * sizeof(vec4i); memory_verts = stored_vert_pos * sizeof(vec3f) + stored_vert_radius * sizeof(float); memory_ists = num_instances * sizeof(bvh_instance); memory_shape_nodes = shape_nodes * sizeof(bvh_node); memory_scene_nodes = scene_nodes * sizeof(bvh_node); auto str = ""s; str += "num_shapes: " + std::to_string(num_shapes) + "\n"; str += "num_instances: " + std::to_string(num_instances) + "\n"; str += "elem_points: " + std::to_string(elem_points) + "\n"; str += "elem_lines: " + std::to_string(elem_lines) + "\n"; str += "elem_triangles: " + std::to_string(elem_triangles) + "\n"; str += "elem_quads: " + std::to_string(elem_quads) + "\n"; str += "vert_pos: " + std::to_string(vert_pos) + "\n"; str += "vert_radius: " + std::to_string(vert_radius) + "\n"; str += "shape_nodes: " + std::to_string(shape_nodes) + "\n"; str += "scene_nodes: " + std::to_string(scene_nodes) + "\n"; str += "memory_elems: " + std::to_string(memory_elems) + "\n"; str += "memory_verts: " + std::to_string(memory_verts) + "\n"; str += "memory_ists: " + std::to_string(memory_ists) + "\n"; str += "memory_shape_nodes: " + std::to_string(memory_shape_nodes) + "\n"; str += "memory_scene_nodes: " + std::to_string(memory_scene_nodes) + "\n"; #if YOCTO_EMBREE str += "memory_embree: " + std::to_string(embree_memory) + "\n"; #endif #endif // TODO auto str = ""s; return str; } } // namespace yocto goxel-0.11.0/ext_src/yocto/yocto_bvh.h000066400000000000000000000352171435762723100177020ustar00rootroot00000000000000// // # Yocto/BVH: Tiny library for ray-object intersection using a BVH // // // Yocto/BVH is a simple implementation of ray intersection and // closest queries using a two-level BVH data structure. We also include // low-level intersection and closet point primitives. // Alternatively the library also support wrapping Intel's Embree. // // // ## Ray-Scene and Closest-Point Queries // // Yocto/GL provides ray-scene intersection for points, lines, triangles and // quads accelerated by a two-level BVH data structure. Our BVH is written for // minimal code and not maximum speed, but still gives reasonable results. We // suggest the use of Intel's Embree as a more efficient alternative. // // In Yocto/Bvh, shapes are described as collections of indexed primitives // (points/lines/triangles/quads) like the standard triangle mesh used in // real-time graphics. A scene if represented as transformed instances of // shapes. The internal data structure is a two-level BVH, with a BVH for each // shape and one top-level BVH for the whole scene. This design support // instancing for large scenes and easy BVH refitting for interactive // applications. // // In these functions triangles are parameterized with uv written // w.r.t the (p1-p0) and (p2-p0) axis respectively. Quads are internally handled // as pairs of two triangles p0,p1,p3 and p2,p3,p1, with the u/v coordinates // of the second triangle corrected as 1-u and 1-v to produce a quad // parametrization where u and v go from 0 to 1. Degenerate quads with p2==p3 // represent triangles correctly, an this convention is used throught the // library. This is equivalent to Intel's Embree. // // Shape and scene data is not copied from the application to the BVH to // improve memory footprint at the price of convenience. Shape data is // explixitly passed on evey call, while instance data uses callbacks, // since each application has its own conventions for storing those. // To make usage more convenite, we provide `bvh_XXX_data` to hold application // data and convenience wrappers for all functions. // // We support working either on the whole scene or on a single shape. In the // description below yoi will see this dual API defined. // // 1. build the shape/scene BVH with `build_bvh()`; // 2. perform ray-shape intersection with `intersect_bvh()` // 3. perform point overlap queries with `overlap_bvh()` // 4. refit BVH for dynamic applications with `refit_bvh` // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // #ifndef _YOCTO_BVH_H_ #define _YOCTO_BVH_H_ #ifndef YOCTO_EMBREE #define YOCTO_EMBREE 1 #endif #ifndef YOCTO_QUADS_AS_TRIANGLES #define YOCTO_QUADS_AS_TRIANGLES 1 #endif // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include "yocto_math.h" #include // ----------------------------------------------------------------------------- // BVH FOR RAY INTERSECTION AND CLOSEST ELEMENT // ----------------------------------------------------------------------------- namespace yocto { // Maximum number of primitives per BVH node. const int bvh_max_prims = 4; // BVH array view template struct bvh_span { bvh_span() : ptr{nullptr}, count{0} {} bvh_span(const T* ptr, int count) : ptr{ptr}, count{count} {} bvh_span(const vector& vec) : ptr{vec.data()}, count{(int)vec.size()} {} bool empty() const { return count == 0; } int size() const { return count; } const T& operator[](int idx) const { return ptr[idx]; } const T* data() const { return ptr; } const T* begin() const { return ptr; } const T* end() const { return ptr + count; } private: const T* ptr = nullptr; int count = 0; }; // BVH array view with stride template struct bvh_sspan { bvh_sspan() : ptr{nullptr}, count{0}, stride{0} {} bvh_sspan(const void* ptr, int count, int stride) : ptr{ptr}, count{count}, stride{stride} {} bool empty() const { return count == 0; } int size() const { return count; } const T& operator[](int idx) const { return *(const T*)((const char*)ptr + (size_t)idx * (size_t)stride); } private: const void* ptr = nullptr; int count = 0; int stride = 0; }; // BVH tree node containing its bounds, indices to the BVH arrays of either // primitives or internal nodes, the node element type, // and the split axis. Leaf and internal nodes are identical, except that // indices refer to primitives for leaf nodes or other nodes for internal nodes. struct bvh_node { bbox3f bbox; short num; bool internal; byte axis; int prims[bvh_max_prims]; }; // BVH tree stored as a node array with the tree structure is encoded using // array indices. BVH nodes indices refer to either the node array, // for internal nodes, or the primitive arrays, for leaf nodes. // Applicxation data is not stored explicitly. struct bvh_shape { // elements bvh_span points = {}; bvh_span lines = {}; bvh_span triangles = {}; bvh_span quads = {}; bvh_span quadspos = {}; // vertices bvh_span positions = {}; bvh_span radius = {}; // nodes vector nodes = {}; #if YOCTO_EMBREE // Embree opaque data void* embree_bvh = nullptr; bool embree_flattened = false; // Cleanup for embree data ~bvh_shape(); #endif }; // Instance for a scene BVH. struct bvh_instance { frame3f frame = identity3x4f; int shape = -1; }; struct bvh_scene { // instances and shapes bvh_sspan instances = {}; vector shapes = {}; // nodes vector nodes = {}; #if YOCTO_EMBREE // Embree opaque data void* embree_bvh = nullptr; bool embree_flattened = false; // Cleanup for embree data ~bvh_scene(); #endif }; // bvh build params struct bvh_params { bool high_quality = false; #if YOCTO_EMBREE bool use_embree = false; bool embree_flatten = false; bool embree_compact = false; #endif bool noparallel = false; std::atomic* cancel = nullptr; }; // Initialize bvh data inline bvh_shape make_points_bvh( bvh_span points, bvh_span positions, bvh_span radius) { return bvh_shape{points, {}, {}, {}, {}, positions, radius}; } inline bvh_shape make_lines_bvh( bvh_span lines, bvh_span positions, bvh_span radius) { return bvh_shape{{}, lines, {}, {}, {}, positions, radius}; } inline bvh_shape make_triangles_bvh(bvh_span triangles, bvh_span positions, bvh_span radius) { return bvh_shape{{}, {}, triangles, {}, {}, positions, radius}; } inline bvh_shape make_quads_bvh( bvh_span quads, bvh_span positions, bvh_span radius) { return bvh_shape{{}, {}, {}, quads, {}, positions, radius}; } inline bvh_shape make_quadspos_bvh(bvh_span quadspos, bvh_span positions, bvh_span radius) { return bvh_shape{{}, {}, {}, {}, quadspos, positions, radius}; } inline bvh_scene make_instances_bvh( bvh_sspan instances, const vector& shapes) { return bvh_scene{instances, shapes}; } // Build the bvh acceleration structure. void build_bvh(bvh_shape& bvh, const bvh_params& params); void build_bvh(bvh_scene& bvh, const bvh_params& params); // Refit bvh data void refit_bvh(bvh_shape& bvh, const bvh_params& params); void refit_bvh(bvh_scene& bvh, const vector& updated_shapes, const bvh_params& params); // Intersect ray with a bvh returning either the first or any intersection // depending on `find_any`. Returns the ray distance , the instance id, // the shape element index and the element barycentric coordinates. bool intersect_bvh(const bvh_shape& bvh, const ray3f& ray, int& element, vec2f& uv, float& distance, bool find_any = false); bool intersect_bvh(const bvh_scene& bvh, const ray3f& ray, int& instance, int& element, vec2f& uv, float& distance, bool find_any = false, bool non_rigid_frames = true); // Intersects a single instance. bool intersect_bvh(const bvh_scene& bvh, int instance, const ray3f& ray, int& element, vec2f& uv, float& distance, bool find_any = false, bool non_rigid_frames = true); // Find a shape element that overlaps a point within a given distance // max distance, returning either the closest or any overlap depending on // `find_any`. Returns the point distance, the instance id, the shape element // index and the element barycentric coordinates. bool overlap_bvh(const bvh_shape& bvh, const vec3f& pos, float max_distance, int& element, vec2f& uv, float& distance, bool find_any = false); bool overlap_bvh(const bvh_scene& bvh, const vec3f& pos, float max_distance, int& instance, int& element, vec2f& uv, float& distance, bool find_any = false, bool non_rigid_frames = true); // Results of intersect_xxx and overlap_xxx functions that include hit flag, // instance id, shape element id, shape element uv and intersection distance. // The values are all set for scene intersection. Shape intersection does not // set the instance id and element intersections do not set shape element id // and the instance id. Results values are set only if hit is true. struct bvh_intersection { int instance = -1; int element = -1; vec2f uv = {0, 0}; float distance = 0; bool hit = false; }; bvh_intersection intersect_bvh( const bvh_shape& bvh, const ray3f& ray, bool find_any = false); bvh_intersection intersect_bvh(const bvh_scene& bvh, const ray3f& ray, bool find_any = false, bool non_rigid_frames = true); bvh_intersection intersect_bvh(const bvh_scene& bvh, int instance, const ray3f& ray, bool find_any = false, bool non_rigid_frames = true); bvh_intersection overlap_bvh(const bvh_shape& bvh, const vec3f& pos, float max_distance, bool find_any = false); bvh_intersection overlap_bvh(const bvh_scene& bvh, const vec3f& pos, float max_distance, bool find_any = false, bool non_rigid_frames = true); } // namespace yocto // ----------------------------------------------------------------------------- // BVH UTILITIES // ----------------------------------------------------------------------------- namespace yocto { // Print bvh statistics. string format_stats(const bvh_shape& bvh); string format_stats(const bvh_scene& bvh); } // namespace yocto // ----------------------------------------------------------------------------- // RAY INTERSECTION AND CLOSEST POINT FUNCTIONS // ----------------------------------------------------------------------------- namespace yocto { // Intersect a ray with a point (approximate). // Based on http://geomalgorithms.com/a02-lines.html. bool intersect_point( const ray3f& ray, const vec3f& p, float r, vec2f& uv, float& dist); // Intersect a ray with a line (approximate). // Based on http://geomalgorithms.com/a05-intersect-1.html and // http://geomalgorithms.com/a07-distance.html# // dist3D_Segment_to_Segment bool intersect_line(const ray3f& ray, const vec3f& p0, const vec3f& p1, float r0, float r1, vec2f& uv, float& dist); // Intersect a ray with a triangle. bool intersect_triangle(const ray3f& ray, const vec3f& p0, const vec3f& p1, const vec3f& p2, vec2f& uv, float& dist); // Intersect a ray with a quad represented as two triangles (0,1,3) and // (2,3,1), with the uv coordinates of the second triangle corrected by u = // 1-u' and v = 1-v' to produce a quad parametrization where u and v go from 0 // to 1. This is equivalent to Intel's Embree. bool intersect_quad(const ray3f& ray, const vec3f& p0, const vec3f& p1, const vec3f& p2, const vec3f& p3, vec2f& uv, float& dist); // Intersect a ray with a axis-aligned bounding box. bool intersect_bbox(const ray3f& ray, const bbox3f& bbox); // Intersect a ray with a axis-aligned bounding box, implemented as // "Robust BVH Ray Traversal" by T. Ize published at // http://jcgt.org/published/0002/02/02/paper.pdf bool intersect_bbox(const ray3f& ray, const vec3f& ray_dinv, const vec3i& ray_dsign, const bbox3f& bbox); // Intersect a ray with a axis-aligned bounding box, implemented as // "A Ray-Box Intersection Algorithm and Efficient Dynamic Voxel Rendering" at // http://jcgt.org/published/0007/03/04/ // but using the Wald implementation bool intersect_bbox(const ray3f& ray, const vec3f& ray_dinv, const vec3i& ray_dsign, const bbox3f& bbox); // Check if a point overlaps a position within a max distance. bool overlap_point(const vec3f& pos, float dist_max, const vec3f& p0, float r0, vec2f& uv, float& dist); // Find closest line point to a position. float closestuv_line(const vec3f& pos, const vec3f& p0, const vec3f& p1); // Check if a line overlaps a position within a max distance. bool overlap_line(const vec3f& pos, float dist_max, const vec3f& p0, const vec3f& p1, float r0, float r1, vec2f& uv, float& dist); // Find closest triangle point to a position. vec2f closestuv_triangle( const vec3f& pos, const vec3f& p0, const vec3f& p1, const vec3f& p2); // Check if a triangle overlaps a position within a max distance. bool overlap_triangle(const vec3f& pos, float dist_max, const vec3f& p0, const vec3f& p1, const vec3f& p2, float r0, float r1, float r2, vec2f& uv, float& dist); // Check if a quad overlaps a position within a max distance. bool overlap_quad(const vec3f& pos, float dist_max, const vec3f& p0, const vec3f& p1, const vec3f& p2, const vec3f& p3, float r0, float r1, float r2, float r3, vec2f& uv, float& dist); // Check if a bounding box overlaps a position within a max distance. bool overlap_bbox(const vec3f& pos, float dist_max, const bbox3f& bbox); // Check if two bounding boxes overlap. bool overlap_bbox(const bbox3f& bbox1, const bbox3f& bbox2); } // namespace yocto #endif goxel-0.11.0/ext_src/yocto/yocto_image.cpp000066400000000000000000002703601435762723100205400ustar00rootroot00000000000000// // Implementation for Yocto/Image. // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include "yocto_image.h" #include "yocto_random.h" #if !defined(_WIN32) && !defined(_WIN64) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-variable" #ifndef __clang__ #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif #endif // #ifndef _clang_analyzer__ #define STB_IMAGE_IMPLEMENTATION #include "ext/stb_image.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #include "ext/stb_image_write.h" #define STB_IMAGE_RESIZE_IMPLEMENTATION #include "ext/stb_image_resize.h" #define TINYEXR_IMPLEMENTATION #include "ext/tinyexr.h" // #endif #if !defined(_WIN32) && !defined(_WIN64) #pragma GCC diagnostic pop #endif #include #include "ext/filesystem.hpp" namespace fs = ghc::filesystem; // ----------------------------------------------------------------------------- // IMPLEMENTATION FOR COLOR UTILITIES // ----------------------------------------------------------------------------- namespace yocto { // Approximate color of blackbody radiation from wavelength in nm. vec3f blackbody_to_rgb(float temperature) { // https://github.com/neilbartlett/color-temperature auto rgb = zero3f; if ((temperature / 100) < 66) { rgb.x = 255; } else { // a + b x + c Log[x] /. // {a -> 351.97690566805693`, // b -> 0.114206453784165`, // c -> -40.25366309332127 // x -> (kelvin/100) - 55} rgb.x = (temperature / 100) - 55; rgb.x = 351.97690566805693f + 0.114206453784165f * rgb.x - 40.25366309332127f * log(rgb.x); if (rgb.x < 0) rgb.x = 0; if (rgb.x > 255) rgb.x = 255; } if ((temperature / 100) < 66) { // a + b x + c Log[x] /. // {a -> -155.25485562709179`, // b -> -0.44596950469579133`, // c -> 104.49216199393888`, // x -> (kelvin/100) - 2} rgb.y = (temperature / 100) - 2; rgb.y = -155.25485562709179f - 0.44596950469579133f * rgb.y + 104.49216199393888f * log(rgb.y); if (rgb.y < 0) rgb.y = 0; if (rgb.y > 255) rgb.y = 255; } else { // a + b x + c Log[x] /. // {a -> 325.4494125711974`, // b -> 0.07943456536662342`, // c -> -28.0852963507957`, // x -> (kelvin/100) - 50} rgb.y = (temperature / 100) - 50; rgb.y = 325.4494125711974f + 0.07943456536662342f * rgb.y - 28.0852963507957f * log(rgb.y); if (rgb.y < 0) rgb.y = 0; if (rgb.y > 255) rgb.y = 255; } if ((temperature / 100) >= 66) { rgb.z = 255; } else { if ((temperature / 100) <= 20) { rgb.z = 0; } else { // a + b x + c Log[x] /. // {a -> -254.76935184120902`, // b -> 0.8274096064007395`, // c -> 115.67994401066147`, // x -> kelvin/100 - 10} rgb.z = (temperature / 100) - 10; rgb.z = -254.76935184120902f + 0.8274096064007395f * rgb.z + 115.67994401066147f * log(rgb.z); if (rgb.z < 0) rgb.z = 0; if (rgb.z > 255) rgb.z = 255; } } return srgb_to_rgb(rgb / 255); } // Convert HSV to RGB vec3f hsv_to_rgb(const vec3f& hsv) { // from Imgui.cpp auto h = hsv.x, s = hsv.y, v = hsv.z; if (hsv.y == 0) return {v, v, v}; h = fmod(h, 1.0f) / (60.0f / 360.0f); int i = (int)h; float f = h - (float)i; float p = v * (1 - s); float q = v * (1 - s * f); float t = v * (1 - s * (1 - f)); switch (i) { case 0: return {v, t, p}; case 1: return {q, v, p}; case 2: return {p, v, t}; case 3: return {p, q, v}; case 4: return {t, p, v}; case 5: return {v, p, q}; default: return {v, p, q}; } } vec3f rgb_to_hsv(const vec3f& rgb) { // from Imgui.cpp auto r = rgb.x, g = rgb.y, b = rgb.z; auto K = 0.f; if (g < b) { swap(g, b); K = -1; } if (r < g) { swap(r, g); K = -2 / 6.0f - K; } auto chroma = r - (g < b ? g : b); return {abs(K + (g - b) / (6 * chroma + 1e-20f)), chroma / (r + 1e-20f), r}; } // RGB color space definition. Various predefined color spaces are listed below. struct color_space_params { // Curve type enum struct curve_t { linear, gamma, linear_gamma, aces_cc, aces_cct, pq, hlg }; // primaries vec2f red_chromaticity; // xy chromaticity of the red primary vec2f green_chromaticity; // xy chromaticity of the green primary vec2f blue_chromaticity; // xy chromaticity of the blue primary vec2f white_chromaticity; // xy chromaticity of the white point mat3f rgb_to_xyz_mat; // matrix from rgb to xyz mat3f xyz_to_rgb_mat; // matrix from xyz to rgb // tone curve curve_t curve_type; float curve_gamma; // gamma for power curves vec4f curve_abcd; // tone curve values for linear_gamma curves }; // Compute the rgb -> xyz matrix from the color space definition // Input: red, green, blue, white (x,y) chromoticities // Algorithm from: SMPTE Recommended Practice RP 177-1993 // http://car.france3.mars.free.fr/HD/INA-%2026%20jan%2006/SMPTE%20normes%20et%20confs/rp177.pdf static inline mat3f rgb_to_xyz_mat( const vec2f& rc, const vec2f& gc, const vec2f& bc, const vec2f& wc) { auto rgb = mat3f{ {rc.x, rc.y, 1 - rc.x - rc.y}, {gc.x, gc.y, 1 - gc.x - gc.y}, {bc.x, bc.y, 1 - bc.x - bc.y}, }; auto w = vec3f{wc.x, wc.y, 1 - wc.x - wc.y}; auto c = inverse(rgb) * vec3f{w.x / w.y, 1, w.z / w.y}; return mat3f{c.x * rgb.x, c.y * rgb.y, c.z * rgb.z}; } // Construct an RGB color space. Predefined color spaces below static inline color_space_params get_color_scape_params(color_space space) { static auto make_linear_rgb_space = [](const vec2f& red, const vec2f& green, const vec2f& blue, const vec2f& white) { return color_space_params{red, green, blue, white, rgb_to_xyz_mat(red, green, blue, white), inverse(rgb_to_xyz_mat(red, green, blue, white)), color_space_params::curve_t::linear}; }; static auto make_gamma_rgb_space = [](const vec2f& red, const vec2f& green, const vec2f& blue, const vec2f& white, float gamma, const vec4f& curve_abcd = zero4f) { return color_space_params{red, green, blue, white, rgb_to_xyz_mat(red, green, blue, white), inverse(rgb_to_xyz_mat(red, green, blue, white)), curve_abcd == zero4f ? color_space_params::curve_t::gamma : color_space_params::curve_t::linear_gamma}; }; static auto make_other_rgb_space = [](const vec2f& red, const vec2f& green, const vec2f& blue, const vec2f& white, color_space_params::curve_t curve_type) { return color_space_params{red, green, blue, white, rgb_to_xyz_mat(red, green, blue, white), inverse(rgb_to_xyz_mat(red, green, blue, white)), curve_type}; }; // color space parameters // https://en.wikipedia.org/wiki/Rec._709 static auto rgb_params = make_linear_rgb_space( {0.6400, 0.3300}, {0.3000, 0.6000}, {0.1500, 0.0600}, {0.3127, 0.3290}); // https://en.wikipedia.org/wiki/Rec._709 static auto srgb_params = make_gamma_rgb_space({0.6400, 0.3300}, {0.3000, 0.6000}, {0.1500, 0.0600}, {0.3127, 0.3290}, 2.4, {1.055, 0.055, 12.92, 0.0031308}); // https://en.wikipedia.org/wiki/Academy_Color_Encoding_System static auto aces2065_params = make_linear_rgb_space({0.7347, 0.2653}, {0.0000, 1.0000}, {0.0001, -0.0770}, {0.32168, 0.33767}); // https://en.wikipedia.org/wiki/Academy_Color_Encoding_Systemx static auto acescg_params = make_linear_rgb_space({0.7130, 0.2930}, {0.1650, 0.8300}, {0.1280, +0.0440}, {0.32168, 0.33767}); // https://en.wikipedia.org/wiki/Academy_Color_Encoding_Systemx static auto acescc_params = make_other_rgb_space({0.7130, 0.2930}, {0.1650, 0.8300}, {0.1280, +0.0440}, {0.32168, 0.33767}, color_space_params::curve_t::aces_cc); // https://en.wikipedia.org/wiki/Academy_Color_Encoding_Systemx static auto acescct_params = make_other_rgb_space({0.7130, 0.2930}, {0.1650, 0.8300}, {0.1280, +0.0440}, {0.32168, 0.33767}, color_space_params::curve_t::aces_cct); // https://en.wikipedia.org/wiki/Adobe_RGB_color_space static auto adobe_params = make_gamma_rgb_space({0.6400, 0.3300}, {0.2100, 0.7100}, {0.1500, 0.0600}, {0.3127, 0.3290}, 2.19921875); // https://en.wikipedia.org/wiki/Rec._709 static auto rec709_params = make_gamma_rgb_space({0.6400, 0.3300}, {0.3000, 0.6000}, {0.1500, 0.0600}, {0.3127, 0.3290}, 1 / 0.45, {1.099, 0.099, 4.500, 0.018}); // https://en.wikipedia.org/wiki/Rec._2020 static auto rec2020_params = make_gamma_rgb_space({0.7080, 0.2920}, {0.1700, 0.7970}, {0.1310, 0.0460}, {0.3127, 0.3290}, 1 / 0.45, {1.09929682680944, 0.09929682680944, 4.5, 0.018053968510807}); // https://en.wikipedia.org/wiki/Rec._2020 static auto rec2100pq_params = make_other_rgb_space({0.7080, 0.2920}, {0.1700, 0.7970}, {0.1310, 0.0460}, {0.3127, 0.3290}, color_space_params::curve_t::pq); // https://en.wikipedia.org/wiki/Rec._2020 static auto rec2100hlg_params = make_other_rgb_space({0.7080, 0.2920}, {0.1700, 0.7970}, {0.1310, 0.0460}, {0.3127, 0.3290}, color_space_params::curve_t::hlg); // https://en.wikipedia.org/wiki/DCI-P3 static auto p3dci_params = make_gamma_rgb_space({0.6800, 0.3200}, {0.2650, 0.6900}, {0.1500, 0.0600}, {0.3140, 0.3510}, 1.6); // https://en.wikipedia.org/wiki/DCI-P3 static auto p3d60_params = make_gamma_rgb_space({0.6800, 0.3200}, {0.2650, 0.6900}, {0.1500, 0.0600}, {0.32168, 0.33767}, 1.6); // https://en.wikipedia.org/wiki/DCI-P3 static auto p3d65_params = make_gamma_rgb_space({0.6800, 0.3200}, {0.2650, 0.6900}, {0.1500, 0.0600}, {0.3127, 0.3290}, 1.6); // https://en.wikipedia.org/wiki/DCI-P3 static auto p3display_params = make_gamma_rgb_space({0.6800, 0.3200}, {0.2650, 0.6900}, {0.1500, 0.0600}, {0.3127, 0.3290}, 2.4, {1.055, 0.055, 12.92, 0.0031308}); // https://en.wikipedia.org/wiki/ProPhoto_RGB_color_space static auto prophoto_params = make_gamma_rgb_space({0.7347, 0.2653}, {0.1596, 0.8404}, {0.0366, 0.0001}, {0.3457, 0.3585}, 1.8, {1, 0, 16, 0.001953125}); // return values; switch (space) { case color_space::rgb: return rgb_params; case color_space::srgb: return srgb_params; case color_space::adobe: return adobe_params; case color_space::prophoto: return prophoto_params; case color_space::rec709: return rec709_params; case color_space::rec2020: return rec2020_params; case color_space::rec2100pq: return rec2100pq_params; case color_space::rec2100hlg: return rec2100hlg_params; case color_space::aces2065: return aces2065_params; case color_space::acescg: return acescg_params; case color_space::acescc: return acescc_params; case color_space::acescct: return acescct_params; case color_space::p3dci: return p3dci_params; case color_space::p3d60: return p3d60_params; case color_space::p3d65: return p3d65_params; case color_space::p3display: return p3display_params; } } // gamma to linear static inline float gamma_display_to_linear(float x, float gamma) { return pow(x, gamma); }; static inline float gamma_linear_to_display(float x, float gamma) { return pow(x, 1 / gamma); }; // https://en.wikipedia.org/wiki/Rec._709 static inline float gamma_display_to_linear( float x, float gamma, const vec4f& abcd) { float a = abcd.x; float b = abcd.y; float c = abcd.z; float d = abcd.w; if (x < 1 / d) { return x / c; } else { return pow((x + b) / a, gamma); } }; static inline float gamma_linear_to_display( float x, float gamma, const vec4f& abcd) { float a = abcd.x; float b = abcd.y; float c = abcd.z; float d = abcd.w; if (x < d) { return x * c; } else { return a * pow(x, 1 / gamma) - b; } }; // https://en.wikipedia.org/wiki/Academy_Color_Encoding_Systemx static inline float acescc_display_to_linear(float x) { if (x < -0.3013698630f) { // (9.72-15)/17.52 return (exp2(x * 17.52f - 9.72f) - exp2(-16.0f)) * 2; } else if (x < (log2(65504.0f) + 9.72f) / 17.52f) { return exp2(x * 17.52f - 9.72f); } else { // (in >= (log2(65504)+9.72)/17.52) return 65504.0f; } } // https://en.wikipedia.org/wiki/Academy_Color_Encoding_Systemx static inline float acescct_display_to_linear(float x) { if (x < 0.155251141552511f) { return (x - 0.0729055341958355f) / 10.5402377416545f; } else { return exp2(x * 17.52f - 9.72f); } } // https://en.wikipedia.org/wiki/Academy_Color_Encoding_Systemx static inline float acescc_linear_to_display(float x) { if (x <= 0) { return -0.3584474886f; // =(log2( pow(2.,-16.))+9.72)/17.52 } else if (x < exp2(-15.0f)) { return (log2(exp2(-16.0f) + x * 0.5f) + 9.72f) / 17.52f; } else { // (in >= pow(2.,-15)) return (log2(x) + 9.72f) / 17.52f; } } // https://en.wikipedia.org/wiki/Academy_Color_Encoding_Systemx static inline float acescct_linear_to_display(float x) { if (x <= 0.0078125f) { return 10.5402377416545f * x + 0.0729055341958355f; } else { return (log2(x) + 9.72f) / 17.52f; } } // https://en.wikipedia.org/wiki/High-dynamic-range_video#Perceptual_Quantizer // https://github.com/ampas/aces-dev/blob/master/transforms/ctl/lib/ACESlib.Utilities_Color.ctl // In PQ, we assume that the linear luminance in [0,1] corresponds to // [0,10000] cd m^2 static inline float pq_display_to_linear(float x) { auto Np = pow(x, 1 / 78.84375f); auto L = max(Np - 0.8359375f, 0.0f); L = L / (18.8515625f - 18.6875f * Np); L = pow(L, 1 / 0.1593017578125f); return L; } static inline float pq_linear_to_display(float x) { return pow((0.8359375 + 18.8515625 * pow(x, 0.1593017578125f)) / (1 + 18.6875f * pow(x, 0.1593017578125f)), 78.84375f); } // https://en.wikipedia.org/wiki/High-dynamic-range_video#Perceptual_Quantizer // In HLG, we assume that the linear luminance in [0,1] corresponds to // [0,1000] cd m^2. Note that the version we report here is scaled in [0,1] // range for nominal luminance. But HLG was initially defined in the [0,12] // range where it maps 1 to 0.5 and 12 to 1. For use in HDR tonemapping that is // likely a better range to use. static inline float hlg_display_to_linear(float x) { if (x < 0.5f) { return 3 * 3 * x * x; } else { return (exp((x - 0.55991073f) / 0.17883277f) + 0.28466892f) / 12; } } static inline float hlg_linear_to_display(float x) { if (x < 1 / 12.0f) { return sqrt(3 * x); } else { return 0.17883277f * log(12 * x - 0.28466892f) + 0.55991073f; } } // Conversion to/from xyz vec3f color_to_xyz(const vec3f& col, color_space from) { auto space = get_color_scape_params(from); auto rgb = col; if (space.curve_type == color_space_params::curve_t::linear) { // do nothing } else if (space.curve_type == color_space_params::curve_t::gamma) { rgb = { gamma_linear_to_display(rgb.x, space.curve_gamma), gamma_linear_to_display(rgb.y, space.curve_gamma), gamma_linear_to_display(rgb.z, space.curve_gamma), }; } else if (space.curve_type == color_space_params::curve_t::linear_gamma) { rgb = { gamma_linear_to_display(rgb.x, space.curve_gamma, space.curve_abcd), gamma_linear_to_display(rgb.y, space.curve_gamma, space.curve_abcd), gamma_linear_to_display(rgb.z, space.curve_gamma, space.curve_abcd), }; } else if (space.curve_type == color_space_params::curve_t::aces_cc) { rgb = { acescc_linear_to_display(rgb.x), acescc_linear_to_display(rgb.y), acescc_linear_to_display(rgb.z), }; } else if (space.curve_type == color_space_params::curve_t::aces_cct) { rgb = { acescct_linear_to_display(rgb.x), acescct_linear_to_display(rgb.y), acescct_linear_to_display(rgb.z), }; } else if (space.curve_type == color_space_params::curve_t::pq) { rgb = { pq_linear_to_display(rgb.x), pq_linear_to_display(rgb.y), pq_linear_to_display(rgb.z), }; } else if (space.curve_type == color_space_params::curve_t::hlg) { rgb = { hlg_linear_to_display(rgb.x), hlg_linear_to_display(rgb.y), hlg_linear_to_display(rgb.z), }; } else { throw std::runtime_error("should not have gotten here"); } return space.rgb_to_xyz_mat * rgb; } vec3f xyz_to_color(const vec3f& xyz, color_space to) { auto space = get_color_scape_params(to); auto rgb = space.xyz_to_rgb_mat * xyz; if (space.curve_type == color_space_params::curve_t::linear) { // nothing } else if (space.curve_type == color_space_params::curve_t::gamma) { rgb = { gamma_display_to_linear(rgb.x, space.curve_gamma), gamma_display_to_linear(rgb.y, space.curve_gamma), gamma_display_to_linear(rgb.z, space.curve_gamma), }; } else if (space.curve_type == color_space_params::curve_t::linear_gamma) { rgb = { gamma_display_to_linear(rgb.x, space.curve_gamma, space.curve_abcd), gamma_display_to_linear(rgb.y, space.curve_gamma, space.curve_abcd), gamma_display_to_linear(rgb.z, space.curve_gamma, space.curve_abcd), }; } else if (space.curve_type == color_space_params::curve_t::aces_cc) { rgb = { acescc_display_to_linear(rgb.x), acescc_display_to_linear(rgb.y), acescc_display_to_linear(rgb.z), }; } else if (space.curve_type == color_space_params::curve_t::aces_cct) { rgb = { acescct_display_to_linear(rgb.x), acescct_display_to_linear(rgb.y), acescct_display_to_linear(rgb.z), }; } else if (space.curve_type == color_space_params::curve_t::pq) { rgb = { pq_display_to_linear(rgb.x), pq_display_to_linear(rgb.y), pq_display_to_linear(rgb.z), }; } else if (space.curve_type == color_space_params::curve_t::hlg) { rgb = { hlg_display_to_linear(rgb.x), hlg_display_to_linear(rgb.y), hlg_display_to_linear(rgb.z), }; } else { throw std::runtime_error("should not have gotten here"); } return rgb; } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION FOR IMAGE UTILITIES // ----------------------------------------------------------------------------- namespace yocto { // Splits an image into an array of regions void make_regions(vector& regions, const vec2i& size, int region_size, bool shuffled) { regions.clear(); for (auto y = 0; y < size.y; y += region_size) { for (auto x = 0; x < size.x; x += region_size) { regions.push_back({{x, y}, {min(x + region_size, size.x), min(y + region_size, size.y)}}); } } if (shuffled) { auto rng = rng_state{}; shuffle(regions, rng); } } vector make_regions( const vec2i& size, int region_size, bool shuffled) { auto regions = vector{}; for (auto y = 0; y < size.y; y += region_size) { for (auto x = 0; x < size.x; x += region_size) { regions.push_back({{x, y}, {min(x + region_size, size.x), min(y + region_size, size.y)}}); } } if (shuffled) { auto rng = rng_state{}; shuffle(regions, rng); } return regions; } // Conversion from/to floats. void byte_to_float(image& fl, const image& bt) { fl.resize(bt.size()); for (auto i = 0ull; i < fl.count(); i++) fl[i] = byte_to_float(bt[i]); } void float_to_byte(image& bt, const image& fl) { bt.resize(fl.size()); for (auto i = 0ull; i < bt.count(); i++) bt[i] = float_to_byte(fl[i]); } image byte_to_float(const image& bt) { auto fl = image{bt.size()}; for (auto i = 0ull; i < fl.count(); i++) fl[i] = byte_to_float(bt[i]); return fl; } image float_to_byte(const image& fl) { auto bt = image{fl.size()}; for (auto i = 0ull; i < bt.count(); i++) bt[i] = float_to_byte(fl[i]); return bt; } // Conversion between linear and gamma-encoded images. image srgb_to_rgb(const image& srgb) { auto rgb = image{srgb.size()}; for (auto i = 0ull; i < rgb.count(); i++) rgb[i] = srgb_to_rgb(srgb[i]); return rgb; } image rgb_to_srgb(const image& rgb) { auto srgb = image{rgb.size()}; for (auto i = 0ull; i < srgb.count(); i++) srgb[i] = rgb_to_srgb(rgb[i]); return srgb; } image srgb_to_rgb(const image& srgb) { auto rgb = image{srgb.size()}; for (auto i = 0ull; i < rgb.count(); i++) rgb[i] = srgb_to_rgb(byte_to_float(srgb[i])); return rgb; } image rgb_to_srgbb(const image& rgb) { auto srgb = image{rgb.size()}; for (auto i = 0ull; i < srgb.count(); i++) srgb[i] = float_to_byte(rgb_to_srgb(rgb[i])); return srgb; } void srgb_to_rgb(image& rgb, const image& srgb) { rgb.resize(srgb.size()); for (auto i = 0ull; i < rgb.count(); i++) rgb[i] = srgb_to_rgb(srgb[i]); } void rgb_to_srgb(image& srgb, const image& rgb) { srgb.resize(rgb.size()); for (auto i = 0ull; i < srgb.count(); i++) srgb[i] = rgb_to_srgb(rgb[i]); } void srgb_to_rgb(image& rgb, const image& srgb) { rgb.resize(srgb.size()); for (auto i = 0ull; i < rgb.count(); i++) rgb[i] = srgb_to_rgb(byte_to_float(srgb[i])); } void rgb_to_srgb(image& srgb, const image& rgb) { srgb.resize(rgb.size()); for (auto i = 0ull; i < srgb.count(); i++) srgb[i] = float_to_byte(rgb_to_srgb(rgb[i])); } // Filmic tonemapping static vec3f tonemap_filmic(const vec3f& hdr_, bool accurate_fit = false) { if (!accurate_fit) { // https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/ auto hdr = hdr_ * 0.6f; // brings it back to ACES range auto ldr = (hdr * hdr * 2.51f + hdr * 0.03f) / (hdr * hdr * 2.43f + hdr * 0.59f + 0.14f); return max(zero3f, ldr); } else { // https://github.com/TheRealMJP/BakingLab/blob/master/BakingLab/ACES.hlsl // sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT static const auto ACESInputMat = transpose(mat3f{ {0.59719, 0.35458, 0.04823}, {0.07600, 0.90834, 0.01566}, {0.02840, 0.13383, 0.83777}, }); // ODT_SAT => XYZ => D60_2_D65 => sRGB static const auto ACESOutputMat = transpose(mat3f{ {1.60475, -0.53108, -0.07367}, {-0.10208, 1.10813, -0.00605}, {-0.00327, -0.07276, 1.07602}, }); // RRT => ODT auto RRTAndODTFit = [](const vec3f& v) -> vec3f { return (v * v + v * 0.0245786f - 0.000090537f) / (v * v * 0.983729f + v * 0.4329510f + 0.238081f); }; auto ldr = ACESOutputMat * RRTAndODTFit(ACESInputMat * hdr_); return max(zero3f, ldr); } } static vec3f tonemap(const vec3f& hdr, const tonemap_params& params) { auto rgb = hdr; if (params.exposure != 0) rgb *= exp2(params.exposure); if (params.tint != vec3f{1, 1, 1}) rgb *= params.tint; if (params.contrast != 0.5f) rgb = contrast(rgb, params.contrast, 0.18f); if (params.logcontrast != 0.5f) rgb = logcontrast(rgb, params.logcontrast, 0.18f); if (params.saturation != 0.5f) rgb = saturate(rgb, params.saturation); if (params.filmic) rgb = tonemap_filmic(rgb); if (params.srgb) rgb = rgb_to_srgb(rgb); return rgb; } static vec4f tonemap(const vec4f& hdr, const tonemap_params& params) { return {tonemap(xyz(hdr), params), hdr.w}; } // Apply exposure and filmic tone mapping image tonemap(const image& hdr, const tonemap_params& params) { auto ldr = image{hdr.size()}; for (auto i = 0ull; i < hdr.count(); i++) ldr[i] = tonemap(hdr[i], params); return ldr; } image tonemapb(const image& hdr, const tonemap_params& params) { auto ldr = image{hdr.size()}; for (auto i = 0ull; i < hdr.count(); i++) ldr[i] = float_to_byte(tonemap(hdr[i], params)); return ldr; } void tonemap(image& ldr, const image& hdr, const image_region& region, const tonemap_params& params) { for (auto j = region.min.y; j < region.max.y; j++) for (auto i = region.min.x; i < region.max.x; i++) ldr[{i, j}] = tonemap(hdr[{i, j}], params); } static vec3f colorgrade(const vec3f& ldr, const colorgrade_params& params) { auto rgb = ldr; if (params.contrast != 0.5f) { rgb = gain(ldr, 1 - params.contrast); } if (params.shadows != 0.5f || params.midtones != 0.5f || params.highlights != 0.5f || params.shadows_color != vec3f{1, 1, 1} || params.midtones_color != vec3f{1, 1, 1} || params.highlights_color != vec3f{1, 1, 1}) { auto lift = params.shadows_color; auto gamma = params.midtones_color; auto gain = params.highlights_color; lift = lift - mean(lift) + params.shadows - (float)0.5; gain = gain - mean(gain) + params.highlights + (float)0.5; auto grey = gamma - mean(gamma) + params.midtones; gamma = log(((float)0.5 - lift) / (gain - lift)) / log(grey); // apply_image auto lerp_value = clamp(pow(rgb, 1 / gamma), 0, 1); rgb = gain * lerp_value + lift * (1 - lerp_value); } return rgb; } static vec4f colorgrade(const vec4f& ldr, const colorgrade_params& params) { return {colorgrade(xyz(ldr), params), ldr.w}; } // Apply exposure and filmic tone mapping image colorgrade( const image& ldr, const colorgrade_params& params) { auto corrected = image{ldr.size()}; for (auto i = 0ull; i < ldr.count(); i++) corrected[i] = colorgrade(ldr[i], params); return corrected; } void colorgrade(image& corrected, const image& ldr, const image_region& region, const colorgrade_params& params) { for (auto j = region.min.y; j < region.max.y; j++) for (auto i = region.min.x; i < region.max.x; i++) corrected[{i, j}] = colorgrade(ldr[{i, j}], params); } // compute white balance vec3f compute_white_balance(const image& img) { auto rgb = zero3f; for (auto& p : img) rgb += xyz(p); if (rgb == zero3f) return zero3f; return rgb / max(rgb); } static vec2i resize_size(const vec2i& img_size, const vec2i& size_) { auto size = size_; if (size == zero2i) { throw std::invalid_argument("bad image size in resize"); } if (size.y == 0) { size.y = (int)round(size.x * (float)img_size.y / (float)img_size.x); } else if (size.x == 0) { size.x = (int)round(size.y * (float)img_size.x / (float)img_size.y); } return size; } image resize(const image& img, const vec2i& size_) { auto size = resize_size(img.size(), size_); auto res_img = image{size}; stbir_resize_float_generic((float*)img.data(), img.size().x, img.size().y, sizeof(vec4f) * img.size().x, (float*)res_img.data(), res_img.size().x, res_img.size().y, sizeof(vec4f) * res_img.size().x, 4, 3, 0, STBIR_EDGE_CLAMP, STBIR_FILTER_DEFAULT, STBIR_COLORSPACE_LINEAR, nullptr); return res_img; } image resize(const image& img, const vec2i& size_) { auto size = resize_size(img.size(), size_); auto res_img = image{size}; stbir_resize_uint8_generic((byte*)img.data(), img.size().x, img.size().y, sizeof(vec4b) * img.size().x, (byte*)res_img.data(), res_img.size().x, res_img.size().y, sizeof(vec4b) * res_img.size().x, 4, 3, 0, STBIR_EDGE_CLAMP, STBIR_FILTER_DEFAULT, STBIR_COLORSPACE_LINEAR, nullptr); return res_img; } void resize( image& res_img, const image& img, const vec2i& size_) { auto size = resize_size(img.size(), size_); res_img = {size}; stbir_resize_float_generic((float*)img.data(), img.size().x, img.size().y, sizeof(vec4f) * img.size().x, (float*)res_img.data(), res_img.size().x, res_img.size().y, sizeof(vec4f) * res_img.size().x, 4, 3, 0, STBIR_EDGE_CLAMP, STBIR_FILTER_DEFAULT, STBIR_COLORSPACE_LINEAR, nullptr); } void resize( image& res_img, const image& img, const vec2i& size_) { auto size = resize_size(img.size(), size_); res_img = {size}; stbir_resize_uint8_generic((byte*)img.data(), img.size().x, img.size().y, sizeof(vec4b) * img.size().x, (byte*)res_img.data(), res_img.size().x, res_img.size().y, sizeof(vec4b) * res_img.size().x, 4, 3, 0, STBIR_EDGE_CLAMP, STBIR_FILTER_DEFAULT, STBIR_COLORSPACE_LINEAR, nullptr); } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION FOR IMAGE EXAMPLES // ----------------------------------------------------------------------------- namespace yocto { // Comvert a bump map to a normal map. void bump_to_normal(image& norm, const image& img, float scale) { norm.resize(img.size()); auto dx = 1.0f / img.size().x, dy = 1.0f / img.size().y; for (int j = 0; j < img.size().y; j++) { for (int i = 0; i < img.size().x; i++) { auto i1 = (i + 1) % img.size().x, j1 = (j + 1) % img.size().y; auto p00 = img[{i, j}], p10 = img[{i1, j}], p01 = img[{i, j1}]; auto g00 = (p00.x + p00.y + p00.z) / 3; auto g01 = (p01.x + p01.y + p01.z) / 3; auto g10 = (p10.x + p10.y + p10.z) / 3; auto normal = vec3f{ scale * (g00 - g10) / dx, scale * (g00 - g01) / dy, 1.0f}; normal.y = -normal.y; // make green pointing up, even if y axis // points down normal = normalize(normal) * 0.5f + vec3f{0.5f, 0.5f, 0.5f}; norm[{i, j}] = {normal.x, normal.y, normal.z, 1}; } } } image bump_to_normal(const image& img, float scale) { auto norm = image{img.size()}; bump_to_normal(norm, img, scale); return norm; } // Make an image void make_proc_image(image& img, const proc_image_params& params) { auto make_img = [&](const auto& shader) { img.resize(params.size); auto scale = 1.0f / max(params.size); for (auto j = 0; j < img.size().y; j++) { for (auto i = 0; i < img.size().x; i++) { auto uv = vec2f{i * scale, j * scale}; img[{i, j}] = shader(uv * params.scale); if (uv.x < params.borderw || uv.y < params.borderw || uv.x > img.size().x * scale - params.borderw || uv.y > img.size().y * scale - params.borderw) { img[{i, j}] = params.borderc; } } } }; switch (params.type) { case proc_image_params::type_t::grid: { make_img([¶ms](vec2f uv) { uv *= 4; uv -= vec2f{(float)(int)uv.x, (float)(int)uv.y}; auto thick = 0.01f / 2; auto c = uv.x <= thick || uv.x >= 1 - thick || uv.y <= thick || uv.y >= 1 - thick || (uv.x >= 0.5f - thick && uv.x <= 0.5f + thick) || (uv.y >= 0.5f - thick && uv.y <= 0.5f + thick); return c ? params.color0 : params.color1; }); } break; case proc_image_params::type_t::checker: { make_img([¶ms](vec2f uv) { uv *= 4; uv -= vec2f{(float)(int)uv.x, (float)(int)uv.y}; auto c = uv.x <= 0.5f != uv.y <= 0.5f; return c ? params.color0 : params.color1; }); } break; case proc_image_params::type_t::bumps: { make_img([¶ms](vec2f uv) { uv *= 4; uv -= vec2f{(float)(int)uv.x, (float)(int)uv.y}; auto thick = 0.125f; auto center = vec2f{ uv.x <= 0.5f ? 0.25f : 0.75f, uv.y <= 0.5f ? 0.25f : 0.75f, }; auto dist = clamp(length(uv - center), 0.0f, thick) / thick; auto val = uv.x <= 0.5f != uv.y <= 0.5f ? (1 + sqrt(1 - dist)) / 2 : (dist * dist) / 2; return lerp(params.color0, params.color1, val); }); } break; case proc_image_params::type_t::ramp: { make_img([¶ms](vec2f uv) { uv -= vec2f{(float)(int)uv.x, (float)(int)uv.y}; return lerp(params.color0, params.color1, uv.x); }); } break; case proc_image_params::type_t::gammaramp: { make_img([¶ms](vec2f uv) { uv -= vec2f{(float)(int)uv.x, (float)(int)uv.y}; if (uv.y < 1 / 3.0f) { return lerp(params.color0, params.color1, pow(uv.x, 2.2f)); } else if (uv.y < 2 / 3.0f) { return lerp(params.color0, params.color1, uv.x); } else { return lerp(params.color0, params.color1, pow(uv.x, 1 / 2.2f)); } }); } break; case proc_image_params::type_t::uvramp: { make_img([](vec2f uv) { uv -= vec2f{(float)(int)uv.x, (float)(int)uv.y}; return vec4f{uv.x, uv.y, 0, 1}; }); } break; case proc_image_params::type_t::uvgrid: { make_img([](vec2f uv) { auto colored = true; uv -= vec2f{(float)(int)uv.x, (float)(int)uv.y}; uv.y = 1 - uv.y; auto hsv = zero3f; hsv.x = (clamp((int)(uv.x * 8), 0, 7) + (clamp((int)(uv.y * 8), 0, 7) + 5) % 8 * 8) / 64.0f; auto vuv = uv * 4; vuv -= vec2f{(float)(int)vuv.x, (float)(int)vuv.y}; auto vc = vuv.x <= 0.5f != vuv.y <= 0.5f; hsv.z = vc ? 0.5f - 0.05f : 0.5f + 0.05f; auto suv = uv * 16; suv -= vec2f{(float)(int)suv.x, (float)(int)suv.y}; auto st = 0.01f / 2; auto sc = suv.x <= st || suv.x >= 1 - st || suv.y <= st || suv.y >= 1 - st; if (sc) { hsv.y = 0.2f; hsv.z = 0.8f; } else { hsv.y = 0.8f; } auto rgb = (colored) ? hsv_to_rgb(hsv) : vec3f{hsv.z}; return vec4f{rgb, 1}; }); } break; case proc_image_params::type_t::blackbody: { make_img([](vec2f uv) { uv -= vec2f{(float)(int)uv.x, (float)(int)uv.y}; return vec4f{blackbody_to_rgb(lerp(1000, 12000, uv.x)), 1}; }); } break; case proc_image_params::type_t::noise: { make_img([¶ms](vec2f uv) { uv *= 8; auto v = perlin_noise({uv.x, uv.y, 0.5f}); v = clamp(0.5f + 0.5f * v, 0.0f, 1.0f); return lerp(params.color0, params.color1, v); }); } break; case proc_image_params::type_t::turbulence: { make_img([¶ms](vec2f uv) { uv *= 8; auto v = perlin_turbulence({uv.x, uv.y, 0.5f}, params.noise.x, params.noise.y, (int)params.noise.z); v = clamp(0.5f + 0.5f * v, 0.0f, 1.0f); return lerp(params.color0, params.color1, v); }); } break; case proc_image_params::type_t::fbm: { make_img([¶ms](vec2f uv) { uv *= 8; auto v = perlin_fbm({uv.x, uv.y, 0.5f}, params.noise.x, params.noise.y, (int)params.noise.z); v = clamp(0.5f + 0.5f * v, 0.0f, 1.0f); return lerp(params.color0, params.color1, v); }); } break; case proc_image_params::type_t::ridge: { make_img([¶ms](vec2f uv) { uv *= 8; auto v = perlin_ridge({uv.x, uv.y, 0.5f}, params.noise.x, params.noise.y, (int)params.noise.z, params.noise.w); v = clamp(0.5f + 0.5f * v, 0.0f, 1.0f); return lerp(params.color0, params.color1, v); }); } break; } } image make_proc_image(const proc_image_params& params) { auto img = image{params.size}; make_proc_image(img, params); return img; } // Add a border to an image image add_border(image& img, int width, const vec4f& color) { auto bordered = img; for (auto j = 0; j < img.size().y; j++) { for (auto b = 0; b < width; b++) { bordered[{b, j}] = color; bordered[{img.size().x - 1 - b, j}] = color; } } for (auto i = 0; i < img.size().x; i++) { for (auto b = 0; b < width; b++) { bordered[{i, b}] = color; bordered[{i, img.size().y - 1 - b}] = color; } } return bordered; } void add_border( image& bordered, image& img, int width, const vec4f& color) { bordered = img; for (auto j = 0; j < img.size().y; j++) { for (auto b = 0; b < width; b++) { bordered[{b, j}] = color; bordered[{img.size().x - 1 - b, j}] = color; } } for (auto i = 0; i < img.size().x; i++) { for (auto b = 0; b < width; b++) { bordered[{i, b}] = color; bordered[{i, img.size().y - 1 - b}] = color; } } } #if 0 // Implementation of sunsky modified heavily from pbrt void make_sunsky(image& img, const vec2i& size, float theta_sun, float turbidity, bool has_sun, float sun_intensity, float sun_temperature, const vec3f& ground_albedo) { // idea adapted from pbrt // initialize model double wavelengths[9] = {630, 680, 710, 500, 530, 560, 460, 480, 490}; ArHosekSkyModelState* skymodel_state[9]; if (sun_temperature) { sun_temperature = clamp(sun_temperature, 2000.0f, 14000.0f); for (int i = 0; i < 9; ++i) { skymodel_state[i] = arhosekskymodelstate_alienworld_alloc_init(theta_sun, sun_intensity, sun_temperature, turbidity, ground_albedo[i / 3]); } } else { for (int i = 0; i < 9; ++i) { skymodel_state[i] = arhosekskymodelstate_alloc_init( theta_sun, turbidity, ground_albedo[i / 3]); } } // clear image img.resize(size); for (auto& p : img) p = {0, 0, 0, 1}; // sun-sky auto sun_direction = vec3f{0, sin(theta_sun), cos(theta_sun)}; auto integral = zero3f; for (auto j = 0; j < img.size().y / 2; j++) { auto theta = (j + 0.5f) * pif / img.size().y; if (theta > pif / 2) continue; for (auto i = 0; i < img.size().x; i++) { auto phi = (i + 0.5f) * 2 * pif / img.size().x; auto direction = vec3f{ cos(phi) * sin(theta), cos(theta), sin(phi) * sin(theta)}; auto gamma = acos(clamp(dot(direction, sun_direction), -1.0f, 1.0f)); for (int c = 0; c < 9; ++c) { auto val = (has_sun) ? arhosekskymodel_solar_radiance(skymodel_state[c], theta, gamma, wavelengths[c]) : arhosekskymodel_radiance(skymodel_state[c], theta, gamma, wavelengths[c]); // average channel over wavelengths img[{i, j}][c / 3] += (float)val / 3; } integral += xyz(img[{i, j}]) * sin(theta) / (img.size().x * img.size().y / 2); } } // ground auto ground = ground_albedo * integral; for (auto j = img.size().y / 2; j < img.size().y; j++) { for (auto i = 0; i < img.size().x; i++) { img[{i, j}] = {ground.x, ground.y, ground.z, 1}; } } // cleanup for (auto i = 0; i < 9; i++) arhosekskymodelstate_free(skymodel_state[i]); } image make_sunsky(const vec2i& size, float theta_sun, float turbidity, bool has_sun, float sun_intensity, float sun_temperature, const vec3f& ground_albedo) { auto img = image{size}; make_sunsky(img, size, theta_sun, turbidity, has_sun, sun_intensity, sun_temperature, ground_albedo); return img; } #else // Implementation of sunsky modified heavily from pbrt void make_sunsky(image& img, const vec2i& size, float theta_sun, float turbidity, bool has_sun, float sun_intensity, float sun_radius, const vec3f& ground_albedo) { auto zenith_xyY = vec3f{ (+0.00165f * pow(theta_sun, 3.f) - 0.00374f * pow(theta_sun, 2.f) + 0.00208f * theta_sun + 0.00000f) * pow(turbidity, 2.f) + (-0.02902f * pow(theta_sun, 3.f) + 0.06377f * pow(theta_sun, 2.f) - 0.03202f * theta_sun + 0.00394f) * turbidity + (+0.11693f * pow(theta_sun, 3.f) - 0.21196f * pow(theta_sun, 2.f) + 0.06052f * theta_sun + 0.25885f), (+0.00275f * pow(theta_sun, 3.f) - 0.00610f * pow(theta_sun, 2.f) + 0.00316f * theta_sun + 0.00000f) * pow(turbidity, 2.f) + (-0.04214f * pow(theta_sun, 3.f) + 0.08970f * pow(theta_sun, 2.f) - 0.04153f * theta_sun + 0.00515f) * turbidity + (+0.15346f * pow(theta_sun, 3.f) - 0.26756f * pow(theta_sun, 2.f) + 0.06669f * theta_sun + 0.26688f), 1000 * (4.0453f * turbidity - 4.9710f) * tan((4.0f / 9.0f - turbidity / 120.0f) * (pif - 2 * theta_sun)) - .2155f * turbidity + 2.4192f, }; auto perez_A_xyY = vec3f{-0.01925f * turbidity - 0.25922f, -0.01669f * turbidity - 0.26078f, +0.17872f * turbidity - 1.46303f}; auto perez_B_xyY = vec3f{-0.06651f * turbidity + 0.00081f, -0.09495f * turbidity + 0.00921f, -0.35540f * turbidity + 0.42749f}; auto perez_C_xyY = vec3f{-0.00041f * turbidity + 0.21247f, -0.00792f * turbidity + 0.21023f, -0.02266f * turbidity + 5.32505f}; auto perez_D_xyY = vec3f{-0.06409f * turbidity - 0.89887f, -0.04405f * turbidity - 1.65369f, +0.12064f * turbidity - 2.57705f}; auto perez_E_xyY = vec3f{-0.00325f * turbidity + 0.04517f, -0.01092f * turbidity + 0.05291f, -0.06696f * turbidity + 0.37027f}; auto perez_f = [](vec3f A, vec3f B, vec3f C, vec3f D, vec3f E, float theta, float gamma, float theta_sun, vec3f zenith) -> vec3f { auto num = ((1 + A * exp(B / cos(theta))) * (1 + C * exp(D * gamma) + E * cos(gamma) * cos(gamma))); auto den = ((1 + A * exp(B)) * (1 + C * exp(D * theta_sun) + E * cos(theta_sun) * cos(theta_sun))); return zenith * num / den; }; auto sky = [&perez_f, perez_A_xyY, perez_B_xyY, perez_C_xyY, perez_D_xyY, perez_E_xyY, zenith_xyY]( float theta, float gamma, float theta_sun) -> vec3f { return xyz_to_rgb(xyY_to_xyz( perez_f(perez_A_xyY, perez_B_xyY, perez_C_xyY, perez_D_xyY, perez_E_xyY, theta, gamma, theta_sun, zenith_xyY))) / 10000; }; // compute sun luminance // TODO: how this relates to zenith intensity? auto sun_ko = vec3f{0.48f, 0.75f, 0.14f}; auto sun_kg = vec3f{0.1f, 0.0f, 0.0f}; auto sun_kwa = vec3f{0.02f, 0.0f, 0.0f}; auto sun_sol = vec3f{20000.0f, 27000.0f, 30000.0f}; auto sun_lambda = vec3f{680, 530, 480}; auto sun_beta = 0.04608365822050f * turbidity - 0.04586025928522f; auto sun_m = 1.0f / (cos(theta_sun) + 0.000940f * pow(1.6386f - theta_sun, -1.253f)); auto tauR = exp(-sun_m * 0.008735f * pow(sun_lambda / 1000, -4.08f)); auto tauA = exp(-sun_m * sun_beta * pow(sun_lambda / 1000, -1.3f)); auto tauO = exp(-sun_m * sun_ko * .35f); auto tauG = exp( -1.41f * sun_kg * sun_m / pow(1 + 118.93f * sun_kg * sun_m, 0.45f)); auto tauWA = exp(-0.2385f * sun_kwa * 2.0f * sun_m / pow(1 + 20.07f * sun_kwa * 2.0f * sun_m, 0.45f)); auto sun_le = sun_sol * tauR * tauA * tauO * tauG * tauWA * 10000; // rescale by user sun_le *= sun_intensity; // sun scale from Wikipedia scaled by user quantity and rescaled to at // the minimum 5 pixel diamater auto sun_angular_radius = 9.35e-03f / 2; // Wikipedia sun_angular_radius *= sun_radius; sun_angular_radius = max(sun_angular_radius, 2 * pif / size.y); // sun direction auto sun_direction = vec3f{0, cos(theta_sun), sin(theta_sun)}; auto sun = [has_sun, sun_angular_radius, sun_le](auto theta, auto gamma) { return (has_sun && gamma < sun_angular_radius) ? sun_le / 10000 : zero3f; }; // Make the sun sky image img.resize(size); auto sky_integral = 0.0f, sun_integral = 0.0f; for (auto j = 0; j < img.size().y / 2; j++) { auto theta = pif * ((j + 0.5f) / img.size().y); theta = clamp(theta, 0.0f, pif / 2 - flt_eps); for (int i = 0; i < img.size().x; i++) { auto phi = 2 * pif * (float(i + 0.5f) / img.size().x); auto w = vec3f{cos(phi) * sin(theta), cos(theta), sin(phi) * sin(theta)}; auto gamma = acos(clamp(dot(w, sun_direction), -1.0f, 1.0f)); auto sky_col = sky(theta, gamma, theta_sun); auto sun_col = sun(theta, gamma); sky_integral += mean(sky_col) * sin(theta); sun_integral += mean(sun_col) * sin(theta); auto col = sky_col + sun_col; img[{i, j}] = {col.x, col.y, col.z, 1}; } } if (ground_albedo != zero3f) { auto ground = zero3f; for (auto j = 0; j < img.size().y / 2; j++) { auto theta = pif * ((j + 0.5f) / img.size().y); for (int i = 0; i < img.size().x; i++) { auto pxl = img[{i, j}]; auto le = vec3f{pxl.x, pxl.y, pxl.z}; auto angle = sin(theta) * 4 * pif / (img.size().x * img.size().y); ground += le * (ground_albedo / pif) * cos(theta) * angle; } } for (auto j = img.size().y / 2; j < img.size().y; j++) { for (int i = 0; i < img.size().x; i++) { img[{i, j}] = {ground.x, ground.y, ground.z, 1}; } } } else { for (auto j = img.size().y / 2; j < img.size().y; j++) { for (int i = 0; i < img.size().x; i++) { img[{i, j}] = {0, 0, 0, 1}; } } } } image make_sunsky(const vec2i& size, float theta_sun, float turbidity, bool has_sun, float sun_intensity, float sun_radius, const vec3f& ground_albedo) { auto img = image{size}; make_sunsky(img, size, theta_sun, turbidity, has_sun, sun_intensity, sun_radius, ground_albedo); return img; } #endif // Make an image of multiple lights. void make_lights(image& img, const vec2i& size, const vec3f& le, int nlights, float langle, float lwidth, float lheight) { img.resize(size); for (auto j = 0; j < img.size().y / 2; j++) { auto theta = pif * ((j + 0.5f) / img.size().y); theta = clamp(theta, 0.0f, pif / 2 - 0.00001f); if (fabs(theta - langle) > lheight / 2) continue; for (int i = 0; i < img.size().x; i++) { auto phi = 2 * pif * (float(i + 0.5f) / img.size().x); auto inlight = false; for (auto l = 0; l < nlights; l++) { auto lphi = 2 * pif * (l + 0.5f) / nlights; inlight = inlight || fabs(phi - lphi) < lwidth / 2; } img[{i, j}] = {le, 1}; } } } image make_lights(const vec2i& size, const vec3f& le, int nlights, float langle, float lwidth, float lheight) { auto img = image{size}; make_lights(img, size, le, nlights, langle, lwidth, lheight); return img; } void make_logo(image& img, const string& type) { static const auto logo_medium_size = vec2i{102, 36}; static const auto logo_small_size = vec2i{72, 28}; // clang-format off static const auto logo_medium = vector{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 139, 193, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 209, 255, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 253, 239, 1, 0, 0, 0, 0, 0, 0, 0, 0, 30, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 167, 234, 190, 0, 0, 0, 0, 0, 0, 59, 234, 233, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 69, 255, 183, 0, 0, 0, 0, 0, 0, 31, 169, 230, 255, 255, 224, 152, 15, 0, 0, 0, 0, 203, 234, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 255, 255, 52, 0, 0, 0, 0, 0, 164, 255, 189, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 228, 253, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 255, 125, 0, 0, 0, 0, 0, 66, 235, 255, 252, 206, 217, 254, 255, 225, 45, 0, 0, 0, 222, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 213, 255, 157, 0, 0, 0, 0, 20, 248, 255, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 255, 255, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 185, 255, 66, 0, 0, 0, 0, 43, 251, 255, 182, 15, 0, 0, 22, 166, 188, 8, 0, 0, 0, 222, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 255, 245, 16, 0, 0, 0, 117, 255, 213, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 255, 255, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 241, 252, 12, 0, 0, 0, 0, 174, 255, 198, 4, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 222, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 232, 255, 111, 0, 0, 1, 219, 255, 99, 0, 0, 0, 29, 152, 206, 238, 193, 128, 6, 0, 0, 0, 0, 0, 0, 25, 149, 207, 239, 199, 118, 4, 43, 179, 199, 255, 255, 181, 179, 136, 0, 0, 0, 0, 61, 166, 220, 231, 180, 95, 0, 0, 0, 0, 0, 0, 0, 0, 45, 255, 206, 0, 0, 0, 0, 52, 255, 255, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 222, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 125, 255, 215, 0, 0, 69, 255, 232, 7, 0, 0, 56, 232, 255, 254, 235, 255, 255, 198, 21, 0, 0, 0, 0, 46, 226, 255, 254, 234, 255, 255, 170, 61, 255, 255, 255, 255, 255, 255, 166, 0, 0, 0, 101, 250, 255, 248, 241, 255, 255, 153, 3, 0, 0, 0, 0, 0, 0, 104, 255, 148, 0, 0, 0, 0, 137, 255, 232, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 222, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 246, 255, 65, 0, 173, 255, 124, 0, 0, 3, 221, 255, 183, 17, 0, 49, 232, 255, 151, 0, 0, 0, 1, 213, 255, 198, 22, 0, 26, 153, 46, 5, 23, 84, 255, 255, 29, 23, 13, 0, 0, 36, 253, 255, 129, 7, 2, 90, 251, 255, 87, 0, 0, 0, 0, 0, 0, 162, 255, 90, 0, 0, 0, 0, 173, 255, 194, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 222, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 255, 170, 26, 251, 245, 19, 0, 0, 89, 255, 248, 15, 0, 0, 0, 91, 255, 247, 23, 0, 0, 77, 255, 253, 27, 0, 0, 0, 0, 0, 0, 0, 67, 255, 255, 6, 0, 0, 0, 0, 153, 255, 199, 0, 0, 0, 0, 155, 255, 206, 0, 0, 0, 0, 0, 0, 220, 255, 32, 0, 0, 0, 0, 208, 255, 167, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 222, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 38, 254, 250, 150, 255, 149, 0, 0, 0, 174, 255, 177, 0, 0, 0, 0, 13, 250, 255, 95, 0, 0, 168, 255, 191, 0, 0, 0, 0, 0, 0, 0, 0, 67, 255, 255, 6, 0, 0, 0, 0, 238, 255, 113, 0, 0, 0, 0, 71, 255, 255, 31, 0, 0, 0, 0, 22, 255, 230, 0, 0, 0, 0, 0, 243, 255, 140, 0, 0, 0, 108, 231, 231, 231, 231, 149, 0, 0, 0, 222, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 177, 255, 255, 253, 36, 0, 0, 0, 205, 255, 140, 0, 0, 0, 0, 0, 227, 255, 125, 0, 0, 201, 255, 149, 0, 0, 0, 0, 0, 0, 0, 0, 67, 255, 255, 6, 0, 0, 0, 14, 255, 255, 76, 0, 0, 0, 0, 35, 255, 255, 61, 0, 0, 0, 0, 80, 255, 172, 0, 0, 0, 0, 1, 248, 255, 135, 0, 0, 0, 86, 255, 255, 255, 255, 165, 0, 0, 0, 222, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 255, 255, 175, 0, 0, 0, 0, 236, 255, 119, 0, 0, 0, 0, 0, 207, 255, 156, 0, 0, 232, 255, 128, 0, 0, 0, 0, 0, 0, 0, 0, 67, 255, 255, 6, 0, 0, 0, 44, 255, 255, 55, 0, 0, 0, 0, 15, 255, 255, 92, 0, 0, 0, 0, 138, 255, 113, 0, 0, 0, 0, 0, 222, 255, 155, 0, 0, 0, 1, 4, 4, 166, 255, 165, 0, 0, 0, 222, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 245, 255, 105, 0, 0, 0, 0, 245, 255, 113, 0, 0, 0, 0, 0, 202, 255, 163, 0, 0, 246, 255, 120, 0, 0, 0, 0, 0, 0, 0, 0, 67, 255, 255, 6, 0, 0, 0, 53, 255, 255, 49, 0, 0, 0, 0, 10, 255, 255, 99, 0, 0, 0, 0, 196, 255, 55, 0, 0, 0, 0, 0, 194, 255, 175, 0, 0, 0, 0, 0, 0, 164, 255, 165, 0, 0, 0, 222, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 255, 104, 0, 0, 0, 0, 215, 255, 133, 0, 0, 0, 0, 0, 221, 255, 132, 0, 0, 218, 255, 141, 0, 0, 0, 0, 0, 0, 0, 0, 67, 255, 255, 6, 0, 0, 0, 23, 255, 255, 69, 0, 0, 0, 0, 29, 255, 255, 68, 0, 0, 0, 6, 248, 247, 6, 0, 0, 0, 0, 0, 166, 255, 206, 0, 0, 0, 0, 0, 0, 164, 255, 165, 0, 0, 0, 222, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 255, 104, 0, 0, 0, 0, 185, 255, 159, 0, 0, 0, 0, 3, 243, 255, 100, 0, 0, 187, 255, 167, 0, 0, 0, 0, 0, 0, 0, 0, 67, 255, 255, 6, 0, 0, 0, 1, 247, 255, 95, 0, 0, 0, 0, 54, 255, 255, 36, 0, 0, 0, 57, 255, 195, 0, 0, 0, 0, 0, 0, 103, 255, 255, 32, 0, 0, 0, 0, 0, 164, 255, 165, 0, 0, 0, 222, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 255, 104, 0, 0, 0, 0, 123, 255, 232, 2, 0, 0, 0, 65, 255, 253, 36, 0, 0, 133, 255, 239, 7, 0, 0, 0, 0, 0, 0, 0, 67, 255, 255, 7, 0, 0, 0, 0, 187, 255, 170, 0, 0, 0, 0, 129, 255, 222, 3, 0, 0, 0, 115, 255, 137, 0, 0, 0, 0, 0, 0, 9, 236, 255, 127, 0, 0, 0, 0, 0, 164, 255, 165, 0, 0, 0, 222, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 255, 104, 0, 0, 0, 0, 17, 243, 255, 113, 0, 0, 8, 191, 255, 170, 0, 0, 0, 23, 247, 255, 135, 0, 0, 1, 91, 18, 0, 0, 42, 255, 255, 51, 0, 1, 0, 0, 69, 255, 247, 58, 0, 0, 32, 231, 255, 106, 0, 0, 0, 0, 173, 255, 79, 0, 0, 0, 0, 0, 0, 0, 132, 255, 252, 91, 0, 0, 0, 21, 197, 255, 165, 0, 0, 0, 222, 255, 137, 20, 20, 20, 20, 20, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 255, 104, 0, 0, 0, 0, 0, 111, 254, 255, 187, 153, 216, 255, 230, 39, 0, 0, 0, 0, 124, 255, 255, 208, 170, 219, 255, 170, 0, 0, 5, 226, 255, 233, 172, 234, 59, 0, 0, 174, 255, 244, 171, 162, 234, 255, 197, 9, 0, 0, 0, 0, 231, 255, 21, 0, 0, 0, 0, 0, 0, 0, 9, 169, 255, 255, 224, 176, 195, 246, 255, 255, 145, 0, 0, 0, 222, 255, 255, 255, 255, 255, 255, 255, 176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 255, 104, 0, 0, 0, 0, 0, 0, 87, 233, 255, 255, 253, 196, 29, 0, 0, 0, 0, 0, 0, 94, 237, 255, 255, 255, 188, 34, 0, 0, 0, 65, 233, 255, 255, 246, 103, 0, 0, 2, 138, 244, 255, 255, 247, 160, 7, 0, 0, 0, 0, 33, 255, 219, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 126, 227, 255, 255, 255, 250, 194, 73, 0, 0, 0, 0, 222, 255, 255, 255, 255, 255, 255, 255, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 63, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 36, 64, 18, 0, 0, 0, 0, 0, 0, 11, 56, 60, 15, 0, 0, 0, 0, 0, 3, 47, 55, 6, 0, 0, 0, 0, 0, 0, 91, 255, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 67, 40, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 149, 255, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 69, 140, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; static const auto logo_small = vector { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 221, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 223, 255, 139, 0, 0, 0, 0, 7, 55, 39, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 236, 255, 241, 6, 0, 0, 132, 255, 255, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 84, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 255, 255, 81, 0, 0, 10, 160, 249, 255, 255, 242, 120, 3, 0, 213, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 138, 255, 255, 72, 0, 0, 214, 255, 226, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 235, 255, 204, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 255, 255, 24, 0, 9, 207, 255, 255, 247, 249, 255, 253, 57, 0, 213, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 254, 255, 153, 0, 40, 255, 255, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 235, 255, 204, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 140, 255, 222, 0, 0, 115, 255, 255, 160, 9, 9, 129, 129, 0, 0, 213, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 182, 255, 232, 2, 122, 255, 250, 23, 0, 90, 199, 242, 214, 135, 6, 0, 0, 0, 36, 175, 231, 229, 164, 24, 173, 249, 255, 239, 176, 112, 0, 4, 130, 212, 243, 202, 95, 0, 0, 0, 0, 0, 198, 255, 165, 0, 7, 234, 255, 243, 9, 0, 0, 0, 0, 0, 0, 213, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, 255, 255, 60, 204, 255, 168, 0, 111, 255, 255, 255, 255, 255, 182, 0, 0, 41, 239, 255, 255, 255, 255, 135, 251, 255, 255, 255, 255, 130, 0, 175, 255, 255, 255, 255, 255, 118, 0, 0, 0, 7, 248, 255, 107, 0, 42, 255, 255, 172, 0, 0, 0, 0, 0, 0, 0, 213, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 224, 255, 172, 255, 255, 61, 14, 237, 255, 208, 31, 152, 255, 255, 65, 0, 170, 255, 254, 90, 63, 143, 7, 58, 240, 255, 216, 59, 24, 60, 255, 255, 157, 31, 204, 255, 240, 16, 0, 0, 57, 255, 255, 50, 0, 77, 255, 255, 141, 0, 43, 61, 61, 61, 30, 0, 213, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 121, 255, 255, 255, 211, 0, 72, 255, 255, 116, 0, 47, 255, 255, 137, 5, 252, 255, 200, 0, 0, 0, 0, 0, 235, 255, 204, 0, 0, 136, 255, 255, 52, 0, 111, 255, 255, 73, 0, 0, 115, 255, 244, 3, 0, 108, 255, 255, 122, 0, 160, 255, 255, 255, 129, 0, 213, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 249, 255, 255, 105, 0, 105, 255, 255, 89, 0, 20, 255, 255, 169, 37, 255, 255, 166, 0, 0, 0, 0, 0, 235, 255, 204, 0, 0, 169, 255, 255, 25, 0, 84, 255, 255, 105, 0, 0, 172, 255, 191, 0, 0, 94, 255, 255, 129, 0, 103, 211, 255, 255, 129, 0, 213, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 193, 255, 255, 29, 0, 115, 255, 255, 84, 0, 15, 255, 255, 179, 52, 255, 255, 159, 0, 0, 0, 0, 0, 235, 255, 204, 0, 0, 179, 255, 255, 20, 0, 79, 255, 255, 115, 0, 0, 230, 255, 133, 0, 0, 67, 255, 255, 145, 0, 0, 40, 255, 255, 129, 0, 213, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 189, 255, 255, 26, 0, 83, 255, 255, 101, 0, 33, 255, 255, 147, 19, 255, 255, 182, 0, 0, 0, 0, 0, 235, 255, 204, 0, 0, 147, 255, 255, 37, 0, 97, 255, 255, 83, 0, 32, 255, 255, 76, 0, 0, 32, 255, 255, 195, 0, 0, 40, 255, 255, 129, 0, 213, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 189, 255, 255, 26, 0, 36, 254, 255, 164, 0, 98, 255, 255, 94, 0, 221, 255, 245, 28, 8, 61, 0, 0, 214, 255, 224, 2, 6, 98, 255, 255, 100, 0, 162, 255, 253, 33, 0, 89, 255, 255, 19, 0, 0, 0, 185, 255, 251, 56, 0, 58, 255, 255, 129, 0, 213, 255, 254, 63, 63, 63, 63, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 189, 255, 255, 26, 0, 0, 168, 255, 255, 197, 244, 255, 222, 5, 0, 93, 255, 255, 244, 239, 255, 77, 0, 136, 255, 255, 242, 178, 6, 225, 255, 244, 197, 255, 255, 163, 0, 0, 147, 255, 217, 0, 0, 0, 0, 61, 248, 255, 251, 216, 254, 255, 255, 129, 0, 213, 255, 255, 255, 255, 255, 254, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 189, 255, 255, 26, 0, 0, 17, 174, 255, 255, 255, 208, 36, 0, 0, 0, 110, 248, 255, 255, 239, 90, 0, 41, 231, 255, 255, 230, 21, 43, 212, 255, 255, 255, 168, 12, 0, 0, 204, 255, 159, 0, 0, 0, 0, 0, 55, 219, 255, 255, 255, 241, 131, 17, 0, 213, 255, 255, 255, 255, 255, 229, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 65, 34, 0, 0, 0, 0, 0, 0, 8, 54, 52, 8, 0, 0, 0, 11, 59, 56, 8, 0, 0, 1, 36, 65, 21, 0, 0, 0, 11, 251, 255, 102, 0, 0, 0, 0, 0, 0, 0, 21, 61, 35, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 161, 221, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; // clang-format on if (type == "logo-medium") { img.resize(logo_medium_size); for (auto i = 0; i < img.count(); i++) img[i] = vec4b{logo_medium[i], logo_medium[i], logo_medium[i], (byte)255}; } else if (type == "logo-small") { img.resize(logo_small_size); for (auto i = 0; i < img.count(); i++) img[i] = vec4b{logo_small[i], logo_small[i], logo_small[i], (byte)255}; } else { throw std::runtime_error("unknown builtin image " + type); } } image make_logo(const string& type) { auto img = image{}; make_logo(img, type); return img; } void make_logo(image& img, const string& type) { auto img8 = image(); make_logo(img8, type); img.resize(img8.size()); srgb_to_rgb(img, img8); } image add_logo(const image& img, const string& type) { auto logo = srgb_to_rgb(make_logo(type)); auto offset = img.size() - logo.size() - 8; auto wlogo = img; set_region(wlogo, logo, offset); return wlogo; } image add_logo(const image& img, const string& type) { auto logo = make_logo(type); auto offset = img.size() - logo.size() - 8; auto wlogo = img; set_region(wlogo, logo, offset); return wlogo; } void add_logo( image& wlogo, const image& img, const string& type) { auto logo = srgb_to_rgb(make_logo(type)); auto offset = img.size() - logo.size() - 8; wlogo = img; set_region(wlogo, logo, offset); } void add_logo( image& wlogo, const image& img, const string& type) { auto logo = make_logo(type); auto offset = img.size() - logo.size() - 8; wlogo = img; set_region(wlogo, logo, offset); } void make_image_preset(image& img, const string& type) { auto size = vec2i{1024, 1024}; if (type.find("sky") != type.npos) size = {2048, 1024}; if (type == "grid") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::grid; params.color0 = vec4f{0.2, 0.2, 0.2, 1}; params.color1 = vec4f{0.7, 0.7, 0.7, 1}; make_proc_image(img, params); } else if (type == "checker") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::checker; params.color0 = vec4f{0.2, 0.2, 0.2, 1}; params.color1 = vec4f{0.7, 0.7, 0.7, 1}; make_proc_image(img, params); } else if (type == "bumps") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::bumps; make_proc_image(img, params); } else if (type == "uvramp") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::uvramp; make_proc_image(img, params); } else if (type == "gammaramp") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::gammaramp; make_proc_image(img, params); } else if (type == "blackbodyramp") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::blackbody; make_proc_image(img, params); } else if (type == "uvgrid") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::uvgrid; make_proc_image(img, params); } else if (type == "sky") { make_sunsky( img, size, pif / 4, 3.0f, false, 1.0f, 1.0f, vec3f{0.7f, 0.7f, 0.7f}); } else if (type == "sunsky") { make_sunsky( img, size, pif / 4, 3.0f, true, 1.0f, 1.0f, vec3f{0.7f, 0.7f, 0.7f}); } else if (type == "noise") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::noise; make_proc_image(img, params); } else if (type == "fbm") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::fbm; make_proc_image(img, params); } else if (type == "ridge") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::ridge; make_proc_image(img, params); } else if (type == "turbulence") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::turbulence; make_proc_image(img, params); } else if (type == "bump-normal") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::bumps; make_proc_image(img, params); auto bump = img; bump_to_normal(img, bump, 0.05f); } else if (type == "logo-medium") { make_logo(img, "logo-medium"); } else if (type == "images1") { auto sub_types = vector{"grid", "uvgrid", "checker", "gammaramp", "bumps", "bump-normal", "noise", "fbm", "blackbodyramp"}; auto sub_imgs = vector>(sub_types.size()); for (auto i = 0; i < sub_imgs.size(); i++) { sub_imgs.at(i).resize(img.size()); make_image_preset(sub_imgs.at(i), sub_types.at(i)); } auto montage_size = zero2i; for (auto& sub_img : sub_imgs) { montage_size.x += sub_img.size().x; montage_size.y = max(montage_size.y, sub_img.size().y); } img.resize(montage_size); auto pos = 0; for (auto& sub_img : sub_imgs) { set_region(img, sub_img, {pos, 0}); pos += sub_img.size().x; } } else if (type == "images2") { auto sub_types = vector{"sky", "sunsky"}; auto sub_imgs = vector>(sub_types.size()); for (auto i = 0; i < sub_imgs.size(); i++) { make_image_preset(sub_imgs.at(i), sub_types.at(i)); } auto montage_size = zero2i; for (auto& sub_img : sub_imgs) { montage_size.x += sub_img.size().x; montage_size.y = max(montage_size.y, sub_img.size().y); } img.resize(montage_size); auto pos = 0; for (auto& sub_img : sub_imgs) { set_region(img, sub_img, {pos, 0}); pos += sub_img.size().x; } } else if (type == "test-floor") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::grid; params.color0 = vec4f{0.2, 0.2, 0.2, 1}; params.color1 = vec4f{0.5, 0.5, 0.5, 1}; params.borderw = 0.0025; make_proc_image(img, params); } else if (type == "test-grid") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::grid; params.color0 = vec4f{0.2, 0.2, 0.2, 1}; params.color1 = vec4f{0.5, 0.5, 0.5, 1}; make_proc_image(img, params); } else if (type == "test-checker") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::checker; params.color0 = vec4f{0.2, 0.2, 0.2, 1}; params.color1 = vec4f{0.5, 0.5, 0.5, 1}; make_proc_image(img, params); } else if (type == "test-bumps") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::bumps; make_proc_image(img, params); } else if (type == "test-uvramp") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::uvramp; make_proc_image(img, params); } else if (type == "test-gammaramp") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::gammaramp; make_proc_image(img, params); } else if (type == "test-blackbodyramp") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::blackbody; make_proc_image(img, params); } else if (type == "test-uvgrid") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::uvgrid; make_proc_image(img, params); } else if (type == "test-sky") { make_sunsky( img, size, pif / 4, 3.0f, false, 1.0f, 1.0f, vec3f{0.7f, 0.7f, 0.7f}); } else if (type == "test-sunsky") { make_sunsky( img, size, pif / 4, 3.0f, true, 1.0f, 1.0f, vec3f{0.7f, 0.7f, 0.7f}); } else if (type == "test-noise") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::noise; make_proc_image(img, params); } else if (type == "test-fbm") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::fbm; make_proc_image(img, params); } else if (type == "test-bumps-normal") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::bumps; make_proc_image(img, params); auto bump = img; bump_to_normal(img, bump, 0.05f); } else if (type == "test-bumps-displacement") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::bumps; make_proc_image(img, params); } else if (type == "test-fbm-displacement") { auto params = proc_image_params{}; params.type = proc_image_params::type_t::fbm; make_proc_image(img, params); } else { throw std::invalid_argument("unknown image preset " + type); } } image make_image_preset(const string& type) { auto img = image{}; make_image_preset(img, type); return img; } void make_image_preset(image& img, const string& type) { auto imgf = image{}; make_image_preset(imgf, type); if (type.find("-normal") == type.npos && type.find("-displacement") == type.npos) { rgb_to_srgb(img, imgf); } else { float_to_byte(img, imgf); } } void make_image_preset( image& hdr, image& ldr, const string& type) { if (type.find("sky") == type.npos) { auto imgf = image{}; make_image_preset(imgf, type); if (type.find("-normal") == type.npos) { rgb_to_srgb(ldr, imgf); } else { float_to_byte(ldr, imgf); } } else { make_image_preset(hdr, type); } } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION FOR VOLUME // ----------------------------------------------------------------------------- namespace yocto { // make a simple example volume void make_test( volume& vol, const vec3i& size, float scale, float exponent) { vol.resize(size); for (auto k = 0; k < vol.size().z; k++) { for (auto j = 0; j < vol.size().y; j++) { for (auto i = 0; i < vol.size().x; i++) { auto p = vec3f{i / (float)vol.size().x, j / (float)vol.size().y, k / (float)vol.size().z}; auto value = pow( max(max(cos(scale * p.x), cos(scale * p.y)), 0.0f), exponent); vol[{i, j, k}] = clamp(value, 0.0f, 1.0f); } } } } volume make_test(const vec3i& size, float scale, float exponent) { auto vol = volume{}; make_test(vol, size, scale, exponent); return vol; } void make_volpreset(volume& vol, const string& type) { auto size = vec3i{256, 256, 256}; if (type == "test-volume") { make_test(vol, size, 6, 10); } else { throw std::runtime_error("unknown volume preset " + type); } } volume make_volpreset(const string& type) { auto vol = volume{}; make_volpreset(vol, type); return vol; } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION FOR IMAGEIO // ----------------------------------------------------------------------------- namespace yocto { // Split a string static inline vector split_string(const string& str) { auto ret = vector(); if (str.empty()) return ret; auto lpos = (size_t)0; while (lpos != str.npos) { auto pos = str.find_first_of(" \t\n\r", lpos); if (pos != str.npos) { if (pos > lpos) ret.push_back(str.substr(lpos, pos - lpos)); lpos = pos + 1; } else { if (lpos < str.size()) ret.push_back(str.substr(lpos)); lpos = pos; } } return ret; } // Pfm load static inline float* load_pfm( const char* filename, int* w, int* h, int* nc, int req) { auto fs = fopen(filename, "rb"); if (!fs) return nullptr; auto fs_guard = std::unique_ptr{ fs, [](FILE* f) { fclose(f); }}; // buffer char buffer[4096]; auto toks = vector(); // read magic if (!fgets(buffer, sizeof(buffer), fs)) return nullptr; toks = split_string(buffer); if (toks[0] == "Pf") *nc = 1; else if (toks[0] == "PF") *nc = 3; else return nullptr; // read w, h if (!fgets(buffer, sizeof(buffer), fs)) return nullptr; toks = split_string(buffer); *w = atoi(toks[0].c_str()); *h = atoi(toks[1].c_str()); // read scale if (!fgets(buffer, sizeof(buffer), fs)) return nullptr; toks = split_string(buffer); auto s = atof(toks[0].c_str()); // read the data (flip y) auto npixels = (size_t)(*w) * (size_t)(*h); auto nvalues = npixels * (size_t)(*nc); auto nrow = (size_t)(*w) * (size_t)(*nc); auto pixels = std::unique_ptr(new float[nvalues]); for (auto j = *h - 1; j >= 0; j--) { if (fread(pixels.get() + j * nrow, sizeof(float), nrow, fs) != nrow) return nullptr; } // endian conversion if (s > 0) { for (auto i = 0; i < nvalues; ++i) { auto dta = (uint8_t*)(pixels.get() + i); std::swap(dta[0], dta[3]); std::swap(dta[1], dta[2]); } } // scale auto scl = (s > 0) ? s : -s; if (scl != 1) { for (auto i = 0; i < nvalues; i++) pixels[i] *= scl; } // proper number of channels if (!req || *nc == req) return pixels.release(); // pack into channels if (req < 0 || req > 4) { return nullptr; } auto cpixels = std::unique_ptr(new float[req * npixels]); for (auto i = 0ull; i < npixels; i++) { auto vp = pixels.get() + i * (*nc); auto cp = cpixels.get() + i * req; if (*nc == 1) { switch (req) { case 1: cp[0] = vp[0]; break; case 2: cp[0] = vp[0]; cp[1] = vp[0]; break; case 3: cp[0] = vp[0]; cp[1] = vp[0]; cp[2] = vp[0]; break; case 4: cp[0] = vp[0]; cp[1] = vp[0]; cp[2] = vp[0]; cp[3] = 1; break; } } else { switch (req) { case 1: cp[0] = vp[0]; break; case 2: cp[0] = vp[0]; cp[1] = vp[1]; break; case 3: cp[0] = vp[0]; cp[1] = vp[1]; cp[2] = vp[2]; break; case 4: cp[0] = vp[0]; cp[1] = vp[1]; cp[2] = vp[2]; cp[3] = 1; break; } } } return cpixels.release(); } // save pfm static inline bool save_pfm( const char* filename, int w, int h, int nc, const float* pixels) { auto fs = fopen(filename, "wb"); if (!fs) return false; auto fs_guard = std::unique_ptr{ fs, [](FILE* f) { fclose(f); }}; if (fprintf(fs, "%s\n", (nc == 1) ? "Pf" : "PF") < 0) return false; if (fprintf(fs, "%d %d\n", w, h) < 0) return false; if (fprintf(fs, "-1\n") < 0) return false; if (nc == 1 || nc == 3) { if (fwrite(pixels, sizeof(float), w * h * nc, fs) != w * h * nc) return false; } else { for (auto i = 0; i < w * h; i++) { auto vz = 0.0f; auto v = pixels + i * nc; if (fwrite(v + 0, sizeof(float), 1, fs) != 1) return false; if (fwrite(v + 1, sizeof(float), 1, fs) != 1) return false; if (nc == 2) { if (fwrite(&vz, sizeof(float), 1, fs) != 1) return false; } else { if (fwrite(v + 2, sizeof(float), 1, fs) != 1) return false; } } } return true; } // load exr image weith tiny exr static inline const char* get_tinyexr_error(int error) { switch (error) { case TINYEXR_ERROR_INVALID_MAGIC_NUMBER: return "INVALID_MAGIC_NUMBER"; case TINYEXR_ERROR_INVALID_EXR_VERSION: return "INVALID_EXR_VERSION"; case TINYEXR_ERROR_INVALID_ARGUMENT: return "INVALID_ARGUMENT"; case TINYEXR_ERROR_INVALID_DATA: return "INVALID_DATA"; case TINYEXR_ERROR_INVALID_FILE: return "INVALID_FILE"; // case TINYEXR_ERROR_INVALID_PARAMETER: return "INVALID_PARAMETER"; case TINYEXR_ERROR_CANT_OPEN_FILE: return "CANT_OPEN_FILE"; case TINYEXR_ERROR_UNSUPPORTED_FORMAT: return "UNSUPPORTED_FORMAT"; case TINYEXR_ERROR_INVALID_HEADER: return "INVALID_HEADER"; default: throw std::runtime_error("unknown tinyexr error"); } } // Return the preset type and the remaining filename static inline bool is_preset_filename(const string& filename) { return filename.find("::yocto::") == 0; } // Return the preset type and the filename. Call only if this is a preset. static inline pair get_preset_type(const string& filename) { if (filename.find("::yocto::") == 0) { auto aux = filename.substr(string("::yocto::").size()); auto pos = aux.find("::"); if (pos == aux.npos) throw std::runtime_error("bad preset name" + filename); return {aux.substr(0, pos), aux.substr(pos + 2)}; } else { return {"", filename}; } } static inline void load_image_preset( const string& filename, image& img) { auto [type, nfilename] = get_preset_type(filename); img.resize({1024, 1024}); if (type == "images2") img.resize({2048, 1024}); make_image_preset(img, type); } static inline void load_image_preset( const string& filename, image& img) { auto imgf = image{}; load_image_preset(filename, imgf); img.resize(imgf.size()); rgb_to_srgb(img, imgf); } // Check if an image is HDR based on filename. bool is_hdr_filename(const string& filename) { auto ext = fs::path(filename).extension().string(); return ext == ".hdr" || ext == ".exr" || ext == ".pfm"; } // Loads an hdr image. image load_image(const string& filename) { auto img = image{}; load_image(filename, img); return img; } // Loads an hdr image. void load_image(const string& filename, image& img) { if (is_preset_filename(filename)) return load_image_preset(filename, img); auto ext = fs::path(filename).extension().string(); if (ext == ".exr" || ext == ".EXR") { auto width = 0, height = 0; auto pixels = (float*)nullptr; if (auto error = LoadEXR( &pixels, &width, &height, filename.c_str(), nullptr); error < 0) throw std::runtime_error("error loading image " + filename + "("s + get_tinyexr_error(error) + ")"s); if (!pixels) throw std::runtime_error("error loading image " + filename); img = image{{width, height}, (const vec4f*)pixels}; free(pixels); } else if (ext == ".pfm" || ext == ".PFM") { auto width = 0, height = 0, ncomp = 0; auto pixels = load_pfm(filename.c_str(), &width, &height, &ncomp, 4); if (!pixels) throw std::runtime_error("error loading image " + filename); img = image{{width, height}, (const vec4f*)pixels}; delete[] pixels; } else if (ext == ".hdr" || ext == ".HDR") { auto width = 0, height = 0, ncomp = 0; auto pixels = stbi_loadf(filename.c_str(), &width, &height, &ncomp, 4); if (!pixels) throw std::runtime_error("error loading image " + filename); img = image{{width, height}, (const vec4f*)pixels}; free(pixels); } else if (!is_hdr_filename(filename)) { img = srgb_to_rgb(load_imageb(filename)); } else { throw std::runtime_error("unsupported image format " + ext); } } // Saves an hdr image. void save_image(const string& filename, const image& img) { auto ext = fs::path(filename).extension().string(); if (ext == ".hdr" || ext == ".HDR") { if (!stbi_write_hdr(filename.c_str(), img.size().x, img.size().y, 4, (float*)img.data())) throw std::runtime_error("error saving image " + filename); } else if (ext == ".pfm" || ext == ".PFM") { if (!save_pfm(filename.c_str(), img.size().x, img.size().y, 4, (float*)img.data())) throw std::runtime_error("error saving image " + filename); } else if (ext == ".exr" || ext == ".EXR") { if (SaveEXR((float*)img.data(), img.size().x, img.size().y, 4, filename.c_str()) < 0) throw std::runtime_error("error saving image " + filename); } else if (!is_hdr_filename(filename)) { save_imageb(filename, rgb_to_srgbb(img)); } else { throw std::runtime_error("unsupported image format " + ext); } } // Loads an ldr image. image load_imageb(const string& filename) { auto img = image{}; load_imageb(filename, img); return img; } // Loads an ldr image. void load_imageb(const string& filename, image& img) { if (is_preset_filename(filename)) return load_image_preset(filename, img); auto ext = fs::path(filename).extension().string(); if (ext == ".png" || ext == ".PNG" || ext == ".jpg" || ext == ".JPG" || ext == ".tga" || ext == ".TGA" || ext == ".bmp" || ext == ".BMP") { auto width = 0, height = 0, ncomp = 0; auto pixels = stbi_load(filename.c_str(), &width, &height, &ncomp, 4); if (!pixels) throw std::runtime_error("error loading image " + filename); img = image{{width, height}, (const vec4b*)pixels}; free(pixels); } else if (is_hdr_filename(filename)) { img = rgb_to_srgbb(load_image(filename)); } else { throw std::runtime_error("unsupported image format " + ext); } } // Saves an ldr image. void save_imageb(const string& filename, const image& img) { auto ext = fs::path(filename).extension().string(); if (ext == ".png" || ext == ".PNG") { if (!stbi_write_png(filename.c_str(), img.size().x, img.size().y, 4, img.data(), img.size().x * 4)) throw std::runtime_error("error saving image " + filename); } else if (ext == ".jpg" || ext == ".JPG") { if (!stbi_write_jpg( filename.c_str(), img.size().x, img.size().y, 4, img.data(), 75)) throw std::runtime_error("error saving image " + filename); } else if (ext == ".tga" || ext == ".TGA") { if (!stbi_write_tga( filename.c_str(), img.size().x, img.size().y, 4, img.data())) throw std::runtime_error("error saving image " + filename); } else if (ext == ".bmp" || ext == ".BMP") { if (!stbi_write_bmp( filename.c_str(), img.size().x, img.size().y, 4, img.data())) throw std::runtime_error("error saving image " + filename); } else if (is_hdr_filename(filename)) { save_image(filename, srgb_to_rgb(img)); } else { throw std::runtime_error("unsupported image format " + ext); } } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION FOR VOLUME IMAGE IO // ----------------------------------------------------------------------------- namespace yocto { namespace impl { // Volume load static inline float* load_yvol( const char* filename, int* w, int* h, int* d, int* nc, int req) { auto fs = fopen(filename, "rb"); if (!fs) return nullptr; auto fs_guard = std::unique_ptr{ fs, [](FILE* f) { fclose(f); }}; // buffer char buffer[4096]; auto toks = vector(); // read magic if (!fgets(buffer, sizeof(buffer), fs)) return nullptr; toks = split_string(buffer); if (toks[0] != "YVOL") return nullptr; // read w, h if (!fgets(buffer, sizeof(buffer), fs)) return nullptr; toks = split_string(buffer); *w = atoi(toks[0].c_str()); *h = atoi(toks[1].c_str()); *d = atoi(toks[2].c_str()); *nc = atoi(toks[3].c_str()); // read data auto nvoxels = (size_t)(*w) * (size_t)(*h) * (size_t)(*d); auto nvalues = nvoxels * (size_t)(*nc); auto voxels = std::unique_ptr(new float[nvalues]); if (fread(voxels.get(), sizeof(float), nvalues, fs) != nvalues) return nullptr; // proper number of channels if (!req || *nc == req) return voxels.release(); // pack into channels if (req < 0 || req > 4) { return nullptr; } auto cvoxels = std::unique_ptr(new float[req * nvoxels]); for (auto i = 0; i < nvoxels; i++) { auto vp = voxels.get() + i * (*nc); auto cp = cvoxels.get() + i * req; if (*nc == 1) { switch (req) { case 1: cp[0] = vp[0]; break; case 2: cp[0] = vp[0]; cp[1] = vp[0]; break; case 3: cp[0] = vp[0]; cp[1] = vp[0]; cp[2] = vp[0]; break; case 4: cp[0] = vp[0]; cp[1] = vp[0]; cp[2] = vp[0]; cp[3] = 1; break; } } else if (*nc == 2) { switch (req) { case 1: cp[0] = vp[0]; break; case 2: cp[0] = vp[0]; cp[1] = vp[1]; break; case 3: cp[0] = vp[0]; cp[1] = vp[1]; break; case 4: cp[0] = vp[0]; cp[1] = vp[1]; break; } } else if (*nc == 3) { switch (req) { case 1: cp[0] = vp[0]; break; case 2: cp[0] = vp[0]; cp[1] = vp[1]; break; case 3: cp[0] = vp[0]; cp[1] = vp[1]; cp[2] = vp[2]; break; case 4: cp[0] = vp[0]; cp[1] = vp[1]; cp[2] = vp[2]; cp[3] = 1; break; } } else if (*nc == 4) { switch (req) { case 1: cp[0] = vp[0]; break; case 2: cp[0] = vp[0]; cp[1] = vp[1]; break; case 3: cp[0] = vp[0]; cp[1] = vp[1]; cp[2] = vp[2]; break; case 4: cp[0] = vp[0]; cp[1] = vp[1]; cp[2] = vp[2]; cp[3] = vp[3]; break; } } } return cvoxels.release(); } // save pfm static inline bool save_yvol( const char* filename, int w, int h, int d, int nc, const float* voxels) { auto fs = fopen(filename, "wb"); if (!fs) return false; auto fs_guard = std::unique_ptr{ fs, [](FILE* f) { fclose(f); }}; if (fprintf(fs, "YVOL\n") < 0) return false; if (fprintf(fs, "%d %d %d %d\n", w, h, d, nc) < 0) return false; auto nvalues = (size_t)w * (size_t)h * (size_t)d * (size_t)nc; if (fwrite(voxels, sizeof(float), nvalues, fs) != nvalues) return false; return true; } // Loads volume data from binary format. void load_volume(const string& filename, volume& vol) { auto width = 0, height = 0, depth = 0, ncomp = 0; auto voxels = load_yvol(filename.c_str(), &width, &height, &depth, &ncomp, 1); if (!voxels) { throw std::runtime_error("error loading volume " + filename); } vol = volume{{width, height, depth}, (const float*)voxels}; delete[] voxels; } // Saves volume data in binary format. void save_volume(const string& filename, const volume& vol) { if (!save_yvol(filename.c_str(), vol.size().x, vol.size().y, vol.size().z, 1, vol.data())) { throw std::runtime_error("error saving volume " + filename); } } } // namespace impl // Loads volume data from binary format. void load_volume(const string& filename, volume& vol) { impl::load_volume(filename, vol); } // Saves volume data in binary format. void save_volume(const string& filename, const volume& vol) { impl::save_volume(filename, vol); } } // namespace yocto goxel-0.11.0/ext_src/yocto/yocto_image.h000066400000000000000000000540211435762723100201770ustar00rootroot00000000000000// // # Yocto/Image: Tiny imaging Library mostly for rendering and color support // // // Yocto/Image is a collection of image utilities useful when writing rendering // algorithms. These include a simple image data structure, color conversion // utilities and tone mapping. We provinde loading and saving functionality for // images and support PNG, JPG, TGA, BMP, HDR, EXR formats. // // This library depends on stb_image.h, stb_image_write.h, stb_image_resize.h, // tinyexr.h for the IO features. If thoese are not needed, it can be safely // used without dependencies. // // // ## Image Utilities // // Yocto/Image supports a very small set of color and image utilities including // color utilities, example image creation, tone mapping, image resizing, and // sunsky procedural images. Yocto/Image is written to support the need of a // global illumination renderer, rather than the need of generic image editing. // We support 4-channels float images (assumed to be in linear color) and // 4-channels byte images (assumed to be in sRGB). // // // 1. store images using the image structure // 2. load and save images with `load_image()` and `save_image()` // 3. resize images with `resize()` // 4. tonemap images with `tonemap()` that convert from linear HDR to // sRGB LDR with exposure and an optional filmic curve // 5. make various image examples with the `make_proc_image()` functions // 6. create procedural sun-sky images with `make_sunsky()` // 7. many color conversion functions are available in the code below // // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // // // LICENSE for blackbody code // // Copyright (c) 2015 Neil Bartlett // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // // #ifndef _YOCTO_IMAGE_H_ #define _YOCTO_IMAGE_H_ // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include "yocto_math.h" // ----------------------------------------------------------------------------- // IMAGE DATA AND UTILITIES // ----------------------------------------------------------------------------- namespace yocto { // Image container. template struct image { // constructors image() : extent{0, 0}, pixels{} {} image(const vec2i& size, const T& value = {}) : extent{size}, pixels((size_t)size.x * (size_t)size.y, value) {} image(const vec2i& size, const T* value) : extent{size}, pixels(value, value + (size_t)size.x * (size_t)size.y) {} // size bool empty() const { return pixels.empty(); } vec2i size() const { return extent; } size_t count() const { return pixels.size(); } bool contains(const vec2i& ij) const { return ij.x > 0 && ij.x < extent.x && ij.y > 0 && ij.y < extent.y; } void resize(const vec2i& size) { if (size == extent) return; extent = size; pixels.resize((size_t)size.x * (size_t)size.y); } void assign(const vec2i& size, const T& value = {}) { extent = size; pixels.assign((size_t)size.x * (size_t)size.y, value); } void shrink_to_fit() { pixels.shrink_to_fit(); } // element access T& operator[](int i) { return pixels[i]; } const T& operator[](int i) const { return pixels[i]; } T& operator[](const vec2i& ij) { return pixels[ij.y * extent.x + ij.x]; } const T& operator[](const vec2i& ij) const { return pixels[ij.y * extent.x + ij.x]; } // data access T* data() { return pixels.data(); } const T* data() const { return pixels.data(); } // iteration T* begin() { return pixels.data(); } T* end() { return pixels.data() + pixels.size(); } const T* begin() const { return pixels.data(); } const T* end() const { return pixels.data() + pixels.size(); } private: // data vec2i extent = zero2i; vector pixels = {}; }; // equality template inline bool operator==(const image& a, const image& b) { return a.size() == b.size() && a.pixels == b.pixels; } template inline bool operator!=(const image& a, const image& b) { return a.size() != b.size() || a.pixels != b.pixels; } } // namespace yocto // ----------------------------------------------------------------------------- // IMAGE UTILITIES // ----------------------------------------------------------------------------- namespace yocto { // Image region struct image_region { vec2i min = zero2i; vec2i max = zero2i; image_region() {} image_region(const vec2i& min, const vec2i& max) : min{min}, max{max} {} vec2i size() const { return max - min; } }; // Splits an image into an array of regions vector make_regions( const vec2i& size, int region_size = 32, bool shuffled = false); // Gets pixels in an image region template inline image get_region(const image& img, const image_region& region) { auto clipped = image{region.size()}; for (auto j = 0; j < region.size().y; j++) { for (auto i = 0; i < region.size().x; i++) { clipped[{i, j}] = img[{i + region.min.x, j + region.min.y}]; } } return clipped; } template inline void set_region( image& img, const image& region, const vec2i& offset) { for (auto j = 0; j < region.size().y; j++) { for (auto i = 0; i < region.size().x; i++) { if (!img.contains({i, j})) continue; img[vec2i{i, j} + offset] = region[{i, j}]; } } } template inline void get_region( image& clipped, const image& img, const image_region& region) { clipped.resize(region.size()); for (auto j = 0; j < region.size().y; j++) { for (auto i = 0; i < region.size().x; i++) { clipped[{i, j}] = img[{i + region.min.x, j + region.min.y}]; } } } // Conversion from/to floats. image byte_to_float(const image& bt); image float_to_byte(const image& fl); void byte_to_float(image& fl, const image& bt); void float_to_byte(image& bt, const image& fl); // Conversion between linear and gamma-encoded images. image srgb_to_rgb(const image& srgb); image rgb_to_srgb(const image& rgb); image srgb_to_rgb(const image& srgb); image rgb_to_srgbb(const image& rgb); void srgb_to_rgb(image& rgb, const image& srgb); void rgb_to_srgb(image& srgb, const image& rgb); // Tone mapping params struct tonemap_params { float exposure = 0; vec3f tint = {1, 1, 1}; float contrast = 0.5; float logcontrast = 0.5; float saturation = 0.5; bool filmic = false; bool srgb = true; }; // Equality operators inline bool operator==(const tonemap_params& a, const tonemap_params& b) { return memcmp(&a, &b, sizeof(a)) == 0; } inline bool operator!=(const tonemap_params& a, const tonemap_params& b) { return memcmp(&a, &b, sizeof(a)) != 0; } // Apply exposure and filmic tone mapping image tonemap(const image& hdr, const tonemap_params& params); image tonemapb(const image& hdr, const tonemap_params& params); void tonemap(image& ldr, const image& hdr, const image_region& region, const tonemap_params& params); // minimal color grading struct colorgrade_params { float contrast = 0.5; float shadows = 0.5; float midtones = 0.5; float highlights = 0.5; vec3f shadows_color = {1, 1, 1}; vec3f midtones_color = {1, 1, 1}; vec3f highlights_color = {1, 1, 1}; }; // Equality operators inline bool operator==(const colorgrade_params& a, const colorgrade_params& b) { return memcmp(&a, &b, sizeof(a)) == 0; } inline bool operator!=(const colorgrade_params& a, const colorgrade_params& b) { return memcmp(&a, &b, sizeof(a)) != 0; } // color grade an image region image colorgrade( const image& img, const colorgrade_params& params); void colorgrade(image& corrected, const image& img, const image_region& region, const colorgrade_params& params); // determine white balance colors vec3f compute_white_balance(const image& img); // Resize an image. image resize(const image& img, const vec2i& size); image resize(const image& img, const vec2i& size); void resize(image& res, const image& img, const vec2i& size); void resize(image& res, const image& img, const vec2i& size); } // namespace yocto // ----------------------------------------------------------------------------- // IMAGE IO // ----------------------------------------------------------------------------- namespace yocto { // Check if an image is HDR based on filename. bool is_hdr_filename(const string& filename); // Loads/saves a 4 channels float/byte image in linear color space. image load_image(const string& filename); void load_image(const string& filename, image& img); void save_image(const string& filename, const image& img); image load_imageb(const string& filename); void load_imageb(const string& filename, image& img); void save_imageb(const string& filename, const image& img); } // namespace yocto // ----------------------------------------------------------------------------- // EXAMPLE IMAGES // ----------------------------------------------------------------------------- namespace yocto { // Parameters for make_proc_image struct proc_image_params { // clang-format off enum struct type_t { grid, checker, bumps, ramp, gammaramp, uvramp, uvgrid, blackbody, noise, turbulence, fbm, ridge }; // clang-format on type_t type = type_t::grid; vec2i size = {1024, 1024}; float scale = 1; vec4f color0 = {0, 0, 0, 1}; vec4f color1 = {1, 1, 1, 1}; vec4f noise = {2, 0.5, 8, 1}; // lacunarity, gain, octaves, offset float borderw = 0; vec4f borderc = {0, 0, 0, 1}; }; // Make an image image make_proc_image(const proc_image_params& params); void make_proc_image(image& img, const proc_image_params& params); // Make a sunsky HDR model with sun at sun_angle elevation in [0,pif/2], // turbidity in [1.7,10] with or without sun. The sun can be enabled or // disabled with has_sun. The sun parameters can be slightly modified by // changing the sun intensity and temperature. Has a convention, a temperature // of 0 sets the eath sun defaults (ignoring intensity too). image make_sunsky(const vec2i& size, float sun_angle, float turbidity = 3, bool has_sun = false, float sun_intensity = 1, float sun_radius = 1, const vec3f& ground_albedo = {0.2, 0.2, 0.2}); void make_sunsky(image& img, const vec2i& size, float sun_angle, float turbidity = 3, bool has_sun = false, float sun_intensity = 1, float sun_radius = 1, const vec3f& ground_albedo = {0.2, 0.2, 0.2}); // Make an image of multiple lights. image make_lights(const vec2i& size, const vec3f& le = {1, 1, 1}, int nlights = 4, float langle = pif / 4, float lwidth = pif / 16, float lheight = pif / 16); void make_lights(image& img, const vec2i& size, const vec3f& le = {1, 1, 1}, int nlights = 4, float langle = pif / 4, float lwidth = pif / 16, float lheight = pif / 16); // Comvert a bump map to a normal map. All linear color spaces. image bump_to_normal(const image& img, float scale = 1); void bump_to_normal( image& norm, const image& img, float scale = 1); // Add a border to an image image add_border(const image& img, int width, const vec4f& color); void add_border( image& bordered, image& img, int width, const vec4f& color); // Make logo images. Image is resized to proper size. image make_logo(const string& name); void make_logo(image& img, const string& name); void make_logo(image& img, const string& name); image add_logo( const image& img, const string& name = "logo-medium"); image add_logo( const image& img, const string& name = "logo-medium"); void add_logo(image& with_logo, const image& img, const string& name = "logo-medium"); void add_logo(image& with_logo, const image& img, const string& name = "logo-medium"); // Make an image preset, useful for testing. See implementation for types. image make_image_preset(const string& type); void make_image_preset(image& img, const string& type); void make_image_preset(image& img, const string& type); void make_image_preset( image& hdr, image& ldr, const string& type); } // namespace yocto // ----------------------------------------------------------------------------- // VOLUME TYPE AND UTILITIES // ----------------------------------------------------------------------------- namespace yocto { // Volume container. template struct volume { // constructors volume() : extent{0, 0, 0}, voxels{} {} volume(const vec3i& size, const T& value) : extent{size} , voxels((size_t)size.x * (size_t)size.y * (size_t)size.z, value) {} volume(const vec3i& size, const T* value) : extent{size} , voxels( value, value + (size_t)size.x * (size_t)size.y * (size_t)size.z) {} // size bool empty() const { return voxels.empty(); } vec3i size() const { return extent; } size_t count() const { return voxels.size(); } void resize(const vec3i& size) { if (size == extent) return; extent = size; voxels.resize((size_t)size.x * (size_t)size.y * (size_t)size.z); } void assign(const vec3i& size, const T& value) { extent = size; voxels.assign((size_t)size.x * (size_t)size.y * (size_t)size.z, value); } void shrink_to_fit() { voxels.shrink_to_fit(); } // element access T& operator[](size_t i) { return voxels[i]; } const T& operator[](size_t i) const { return voxels[i]; } T& operator[](const vec3i& ijk) { return voxels[ijk.z * extent.x * extent.y + ijk.y * extent.x + ijk.x]; } const T& operator[](const vec3i& ijk) const { return voxels[ijk.z * extent.x * extent.y + ijk.y * extent.x + ijk.x]; } // data access T* data() { return voxels.data(); } const T* data() const { return voxels.data(); } // iteration T* begin() { return voxels.data(); } T* end() { return voxels.data() + voxels.size(); } const T* begin() const { return voxels.data(); } const T* end() const { return voxels.data() + voxels.size(); } private: // data vec3i extent = zero3i; vector voxels = {}; }; // equality template inline bool operator==(const volume& a, const volume& b) { return a.size() == b.size() && a.voxels == b.voxels; } template inline bool operator!=(const volume& a, const volume& b) { return a.size() != b.size() || a.voxels != b.voxels; } // make a simple example volume void make_voltest(volume& vol, const vec3i& size, float scale = 10, float exponent = 6); void make_volpreset(volume& vol, const string& type); } // namespace yocto // ----------------------------------------------------------------------------- // VOLUME IMAGE IO // ----------------------------------------------------------------------------- namespace yocto { // Loads/saves a 1 channel volume. void load_volume(const string& filename, volume& vol); void save_volume(const string& filename, const volume& vol); } // namespace yocto // ----------------------------------------------------------------------------- // COLOR CONVERSION UTILITIES // ----------------------------------------------------------------------------- namespace yocto { // Conversion between flots and bytes inline vec4b float_to_byte(const vec4f& a) { return {(byte)clamp(int(a.x * 256), 0, 255), (byte)clamp(int(a.y * 256), 0, 255), (byte)clamp(int(a.z * 256), 0, 255), (byte)clamp(int(a.w * 256), 0, 255)}; } inline vec4f byte_to_float(const vec4b& a) { return {a.x / 255.0f, a.y / 255.0f, a.z / 255.0f, a.w / 255.0f}; } // Luminance inline float luminance(const vec3f& a) { return (0.2126f * a.x + 0.7152f * a.y + 0.0722f * a.z); } // sRGB non-linear curve inline float srgb_to_rgb(float srgb) { return (srgb <= 0.04045) ? srgb / 12.92f : pow((srgb + 0.055f) / (1.0f + 0.055f), 2.4f); } inline float rgb_to_srgb(float rgb) { return (rgb <= 0.0031308f) ? 12.92f * rgb : (1 + 0.055f) * pow(rgb, 1 / 2.4f) - 0.055f; } inline vec3f srgb_to_rgb(const vec3f& srgb) { return {srgb_to_rgb(srgb.x), srgb_to_rgb(srgb.y), srgb_to_rgb(srgb.z)}; } inline vec4f srgb_to_rgb(const vec4f& srgb) { return { srgb_to_rgb(srgb.x), srgb_to_rgb(srgb.y), srgb_to_rgb(srgb.z), srgb.w}; } inline vec3f rgb_to_srgb(const vec3f& rgb) { return {rgb_to_srgb(rgb.x), rgb_to_srgb(rgb.y), rgb_to_srgb(rgb.z)}; } inline vec4f rgb_to_srgb(const vec4f& rgb) { return {rgb_to_srgb(rgb.x), rgb_to_srgb(rgb.y), rgb_to_srgb(rgb.z), rgb.w}; } // Apply contrast. Grey should be 0.18 for linear and 0.5 for gamma. inline vec3f contrast(const vec3f& rgb, float contrast, float grey) { return max(zero3f, grey + (rgb - grey) * (contrast * 2)); } // Apply contrast in log2. Grey should be 0.18 for linear and 0.5 for gamma. inline vec3f logcontrast(const vec3f& rgb, float logcontrast, float grey) { auto epsilon = (float)0.0001; auto log_grey = log2(grey); auto log_ldr = log2(rgb + epsilon); auto adjusted = log_grey + (log_ldr - log_grey) * (logcontrast * 2); return max(zero3f, exp2(adjusted) - epsilon); } // Apply saturation. inline vec3f saturate(const vec3f& rgb, float saturation, const vec3f& weights = vec3f{0.333333f}) { auto grey = dot(weights, rgb); return max(zero3f, grey + (rgb - grey) * (saturation * 2)); } // Convert between CIE XYZ and RGB inline vec3f rgb_to_xyz(const vec3f& rgb) { // https://en.wikipedia.org/wiki/SRGB static const auto mat = mat3f{ {0.4124, 0.2126, 0.0193}, {0.3576, 0.7152, 0.1192}, {0.1805, 0.0722, 0.9504}, }; return mat * rgb; } inline vec3f xyz_to_rgb(const vec3f& xyz) { // https://en.wikipedia.org/wiki/SRGB static const auto mat = mat3f{ {+3.2406, -0.9689, +0.0557}, {-1.5372, +1.8758, -0.2040}, {-0.4986, +0.0415, +1.0570}, }; return mat * xyz; } // Convert between CIE XYZ and xyY inline vec3f xyz_to_xyY(const vec3f& xyz) { if (xyz == zero3f) return zero3f; return { xyz.x / (xyz.x + xyz.y + xyz.z), xyz.y / (xyz.x + xyz.y + xyz.z), xyz.y}; } inline vec3f xyY_to_xyz(const vec3f& xyY) { if (xyY.y == 0) return zero3f; return {xyY.x * xyY.z / xyY.y, xyY.z, (1 - xyY.x - xyY.y) * xyY.z / xyY.y}; } // Approximate color of blackbody radiation from wavelength in nm. vec3f blackbody_to_rgb(float temperature); // Converts between HSV and RGB color spaces. vec3f hsv_to_rgb(const vec3f& hsv); vec3f rgb_to_hsv(const vec3f& rgb); // RGB color spaces enum struct color_space { rgb, // default linear space (srgb linear) srgb, // srgb color space (non-linear) adobe, // Adobe rgb color space (non-linear) prophoto, // ProPhoto Kodak rgb color space (non-linear) rec709, // hdtv color space (non-linear) rec2020, // uhtv color space (non-linear) rec2100pq, // hdr color space with perceptual quantizer (non-linear) rec2100hlg, // hdr color space with hybrid log gamma (non-linear) aces2065, // ACES storage format (linear) acescg, // ACES CG computation (linear) acescc, // ACES color correction (non-linear) acescct, // ACES color correction 2 (non-linear) p3dci, // P3 DCI (non-linear) p3d60, // P3 variation for D60 (non-linear) p3d65, // P3 variation for D65 (non-linear) p3display, // Apple display P3 }; // Conversion between rgb color spaces vec3f color_to_xyz(const vec3f& col, color_space from); vec3f xyz_to_color(const vec3f& xyz, color_space to); inline vec3f convert_color(const vec3f& col, color_space from, color_space to) { if (from == to) return col; return xyz_to_color(color_to_xyz(col, from), to); } } // namespace yocto #endif goxel-0.11.0/ext_src/yocto/yocto_math.h000066400000000000000000002003771435762723100200550ustar00rootroot00000000000000// // # Yocto/Math: Tiny library for math support in graphics applications. // // Yocto/Math provides the basic math primitives used in grahics, including // small-sized vectors and matrixes, frames, bounding boxes and transforms. // // We provide common operations for small vectors and matrices typically used // in graphics. In particular, we support 1-4 dimensional vectors // coordinates in float and int coordinates (`vec1f`, `vec2f`, `vec3f`, `vec4f`, // `vec1i`, `vec2i`, `vec3i`, `vec4i`). // // We support 2-4 dimensional matrices (`mat2f`, `mat3f`, `mat4f`) with // matrix-matrix and matrix-vector products, transposes and inverses. // Matrices are stored in column-major order and are accessed and // constructed by column. The one dimensional version is for completeness only. // // To represent transformations, most of the library facilities prefer the use // coordinate frames, aka rigid transforms, represented as `frame2f` and // `frame3f`. The structure store three coordinate axes and the origin. // This is equivalent to a rigid transform written as a column-major affine // matrix. Transform operations are fater with this representation. // // We represent bounding boxes in 2-3 dimensions with `bbox2f`, `bbox3f` // Each bounding box support construction from points and other bounding box. // We provide operations to compute bounds for points, lines, triangles and // quads. // // For both matrices and frames we support transform operations for points, // vectors and directions (`transform_point()`, `transform_vector()`, // `transform_direction()`). Transform matrices and frames can be // constructed from basic translation, rotation and scaling, e.g. with // `translation_mat()` or `translation_frame()` respectively, etc. // For rotation we support axis-angle and quaternions, with slerp. // // Finally, we include a `timer` for benchmarking with high precision and // a few common path manipulations ghat will be remove once C++ filesystem // support will be more common. // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // #ifndef _YOCTO_MATH_H_ #define _YOCTO_MATH_H_ // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include #include #include #include #include #include #include #include #include #include #include // ----------------------------------------------------------------------------- // MATH CONSTANTS AND FUNCTIONS // ----------------------------------------------------------------------------- namespace yocto { // Aliased typenames for readability using std::pair; using std::string; using std::unordered_map; using std::vector; using namespace std::literals::string_literals; using byte = unsigned char; using uint = unsigned int; static const double pi = 3.14159265358979323846; static const float pif = (float)pi; static const auto int_max = INT_MAX; static const auto int_min = INT_MIN; static const auto flt_max = FLT_MAX; static const auto flt_min = -FLT_MAX; static const auto flt_eps = FLT_EPSILON; inline float abs(float a) { return a < 0 ? -a : a; } inline float min(float a, float b) { return (a < b) ? a : b; } inline float max(float a, float b) { return (a > b) ? a : b; } inline float clamp(float a, float min_, float max_) { return min(max(a, min_), max_); } inline float lerp(float a, float b, float u) { return a * (1 - u) + b * u; } inline float radians(float a) { return a * pif / 180; } inline float degrees(float a) { return a * 180 / pif; } inline float bias(float a, float bias) { return a / ((1 / bias - 2) * (1 - a) + 1); } inline float gain(float a, float gain) { return (a < 0.5f) ? bias(a * 2, gain) / 2 : bias(a * 2 - 1, 1 - gain) / 2 + 0.5f; } inline float sqrt(float a) { return sqrtf(a); } inline float sin(float a) { return sinf(a); } inline float cos(float a) { return cosf(a); } inline float tan(float a) { return tanf(a); } inline float asin(float a) { return asinf(a); } inline float acos(float a) { return acosf(a); } inline float atan(float a) { return atanf(a); } inline float log(float a) { return logf(a); } inline float exp(float a) { return expf(a); } inline float log2(float a) { return log2f(a); } inline float exp2(float a) { return exp2f(a); } inline float pow(float a, float b) { return powf(a, b); } inline float is_finite(float a) { return isfinite(a); } inline void swap(float& a, float& b) { std::swap(a, b); } inline int abs(int a) { return a < 0 ? -a : a; } inline int min(int a, int b) { return (a < b) ? a : b; } inline int max(int a, int b) { return (a > b) ? a : b; } inline int clamp(int a, int min_, int max_) { return min(max(a, min_), max_); } inline int pow2(int a) { return 1 << a; } inline void swap(int& a, int& b) { std::swap(a, b); } } // namespace yocto // ----------------------------------------------------------------------------- // VECTORS // ----------------------------------------------------------------------------- namespace yocto { struct vec2f { float x = 0; float y = 0; vec2f() {} vec2f(float x, float y) : x{x}, y{y} {} explicit vec2f(float v) : x{v}, y{v} {} float& operator[](int i) { return (&x)[i]; } const float& operator[](int i) const { return (&x)[i]; } }; struct vec3f { float x = 0; float y = 0; float z = 0; vec3f() {} vec3f(float x, float y, float z) : x{x}, y{y}, z{z} {} vec3f(const vec2f& v, float z) : x{v.x}, y{v.y}, z{z} {} explicit vec3f(float v) : x{v}, y{v}, z{v} {} float& operator[](int i) { return (&x)[i]; } const float& operator[](int i) const { return (&x)[i]; } }; struct vec4f { float x = 0; float y = 0; float z = 0; float w = 0; vec4f() {} vec4f(float x, float y, float z, float w) : x{x}, y{y}, z{z}, w{w} {} vec4f(const vec3f& v, float w) : x{v.x}, y{v.y}, z{v.z}, w{w} {} explicit vec4f(float v) : x{v}, y{v}, z{v}, w{v} {} float& operator[](int i) { return (&x)[i]; } const float& operator[](int i) const { return (&x)[i]; } }; // Zero vector constants. static const auto zero2f = vec2f{0, 0}; static const auto zero3f = vec3f{0, 0, 0}; static const auto zero4f = vec4f{0, 0, 0, 0}; // Element access inline vec3f& xyz(vec4f& a) { return (vec3f&)a; } inline const vec3f& xyz(const vec4f& a) { return (const vec3f&)a; } // Vector comparison operations. inline bool operator==(const vec2f& a, const vec2f& b) { return a.x == b.x && a.y == b.y; } inline bool operator!=(const vec2f& a, const vec2f& b) { return a.x != b.x || a.y != b.y; } // Vector operations. inline vec2f operator+(const vec2f& a) { return a; } inline vec2f operator-(const vec2f& a) { return {-a.x, -a.y}; } inline vec2f operator+(const vec2f& a, const vec2f& b) { return {a.x + b.x, a.y + b.y}; } inline vec2f operator+(const vec2f& a, float b) { return {a.x + b, a.y + b}; } inline vec2f operator+(float a, const vec2f& b) { return {a + b.x, a + b.y}; } inline vec2f operator-(const vec2f& a, const vec2f& b) { return {a.x - b.x, a.y - b.y}; } inline vec2f operator-(const vec2f& a, float b) { return {a.x - b, a.y - b}; } inline vec2f operator-(float a, const vec2f& b) { return {a - b.x, a - b.y}; } inline vec2f operator*(const vec2f& a, const vec2f& b) { return {a.x * b.x, a.y * b.y}; } inline vec2f operator*(const vec2f& a, float b) { return {a.x * b, a.y * b}; } inline vec2f operator*(float a, const vec2f& b) { return {a * b.x, a * b.y}; } inline vec2f operator/(const vec2f& a, const vec2f& b) { return {a.x / b.x, a.y / b.y}; } inline vec2f operator/(const vec2f& a, float b) { return {a.x / b, a.y / b}; } inline vec2f operator/(float a, const vec2f& b) { return {a / b.x, a / b.y}; } // Vector assignments inline vec2f& operator+=(vec2f& a, const vec2f& b) { return a = a + b; } inline vec2f& operator+=(vec2f& a, float b) { return a = a + b; } inline vec2f& operator-=(vec2f& a, const vec2f& b) { return a = a - b; } inline vec2f& operator-=(vec2f& a, float b) { return a = a - b; } inline vec2f& operator*=(vec2f& a, const vec2f& b) { return a = a * b; } inline vec2f& operator*=(vec2f& a, float b) { return a = a * b; } inline vec2f& operator/=(vec2f& a, const vec2f& b) { return a = a / b; } inline vec2f& operator/=(vec2f& a, float b) { return a = a / b; } // Vector products and lengths. inline float dot(const vec2f& a, const vec2f& b) { return a.x * b.x + a.y * b.y; } inline float cross(const vec2f& a, const vec2f& b) { return a.x * b.y - a.y * b.x; } inline float length(const vec2f& a) { return sqrt(dot(a, a)); } inline vec2f normalize(const vec2f& a) { auto l = length(a); return (l != 0) ? a / l : a; } inline float distance(const vec2f& a, const vec2f& b) { return length(a - b); } inline float distance_squared(const vec2f& a, const vec2f& b) { return dot(a - b, a - b); } // Max element and clamp. inline vec2f max(const vec2f& a, float b) { return {max(a.x, b), max(a.y, b)}; } inline vec2f min(const vec2f& a, float b) { return {min(a.x, b), min(a.y, b)}; } inline vec2f max(const vec2f& a, const vec2f& b) { return {max(a.x, b.x), max(a.y, b.y)}; } inline vec2f min(const vec2f& a, const vec2f& b) { return {min(a.x, b.x), min(a.y, b.y)}; } inline vec2f clamp(const vec2f& x, float min, float max) { return {clamp(x.x, min, max), clamp(x.y, min, max)}; } inline vec2f lerp(const vec2f& a, const vec2f& b, float u) { return a * (1 - u) + b * u; } inline vec2f lerp(const vec2f& a, const vec2f& b, const vec2f& u) { return a * (1 - u) + b * u; } inline float max(const vec2f& a) { return max(a.x, a.y); } inline float min(const vec2f& a) { return min(a.x, a.y); } inline float sum(const vec2f& a) { return a.x + a.y; } inline float mean(const vec2f& a) { return sum(a) / 2; } // Functions applied to vector elements inline vec2f abs(const vec2f& a) { return {abs(a.x), abs(a.y)}; }; inline vec2f sqrt(const vec2f& a) { return {sqrt(a.x), sqrt(a.y)}; }; inline vec2f exp(const vec2f& a) { return {exp(a.x), exp(a.y)}; }; inline vec2f log(const vec2f& a) { return {log(a.x), log(a.y)}; }; inline vec2f exp2(const vec2f& a) { return {exp2(a.x), exp2(a.y)}; }; inline vec2f log2(const vec2f& a) { return {log2(a.x), log2(a.y)}; }; inline bool is_finite(const vec2f& a) { return is_finite(a.x) && is_finite(a.y); }; inline vec2f pow(const vec2f& a, float b) { return {pow(a.x, b), pow(a.y, b)}; }; inline vec2f pow(const vec2f& a, const vec2f& b) { return {pow(a.x, b.x), pow(a.y, b.y)}; }; inline vec2f gain(const vec2f& a, float b) { return {gain(a.x, b), gain(a.y, b)}; }; inline void swap(vec2f& a, vec2f& b) { std::swap(a, b); } // Vector comparison operations. inline bool operator==(const vec3f& a, const vec3f& b) { return a.x == b.x && a.y == b.y && a.z == b.z; } inline bool operator!=(const vec3f& a, const vec3f& b) { return a.x != b.x || a.y != b.y || a.z != b.z; } // Vector operations. inline vec3f operator+(const vec3f& a) { return a; } inline vec3f operator-(const vec3f& a) { return {-a.x, -a.y, -a.z}; } inline vec3f operator+(const vec3f& a, const vec3f& b) { return {a.x + b.x, a.y + b.y, a.z + b.z}; } inline vec3f operator+(const vec3f& a, float b) { return {a.x + b, a.y + b, a.z + b}; } inline vec3f operator+(float a, const vec3f& b) { return {a + b.x, a + b.y, a + b.z}; } inline vec3f operator-(const vec3f& a, const vec3f& b) { return {a.x - b.x, a.y - b.y, a.z - b.z}; } inline vec3f operator-(const vec3f& a, float b) { return {a.x - b, a.y - b, a.z - b}; } inline vec3f operator-(float a, const vec3f& b) { return {a - b.x, a - b.y, a - b.z}; } inline vec3f operator*(const vec3f& a, const vec3f& b) { return {a.x * b.x, a.y * b.y, a.z * b.z}; } inline vec3f operator*(const vec3f& a, float b) { return {a.x * b, a.y * b, a.z * b}; } inline vec3f operator*(float a, const vec3f& b) { return {a * b.x, a * b.y, a * b.z}; } inline vec3f operator/(const vec3f& a, const vec3f& b) { return {a.x / b.x, a.y / b.y, a.z / b.z}; } inline vec3f operator/(const vec3f& a, float b) { return {a.x / b, a.y / b, a.z / b}; } inline vec3f operator/(float a, const vec3f& b) { return {a / b.x, a / b.y, a / b.z}; } // Vector assignments inline vec3f& operator+=(vec3f& a, const vec3f& b) { return a = a + b; } inline vec3f& operator+=(vec3f& a, float b) { return a = a + b; } inline vec3f& operator-=(vec3f& a, const vec3f& b) { return a = a - b; } inline vec3f& operator-=(vec3f& a, float b) { return a = a - b; } inline vec3f& operator*=(vec3f& a, const vec3f& b) { return a = a * b; } inline vec3f& operator*=(vec3f& a, float b) { return a = a * b; } inline vec3f& operator/=(vec3f& a, const vec3f& b) { return a = a / b; } inline vec3f& operator/=(vec3f& a, float b) { return a = a / b; } // Vector products and lengths. inline float dot(const vec3f& a, const vec3f& b) { return a.x * b.x + a.y * b.y + a.z * b.z; } inline vec3f cross(const vec3f& a, const vec3f& b) { return {a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x}; } inline float length(const vec3f& a) { return sqrt(dot(a, a)); } inline vec3f normalize(const vec3f& a) { auto l = length(a); return (l != 0) ? a / l : a; } inline float distance(const vec3f& a, const vec3f& b) { return length(a - b); } inline float distance_squared(const vec3f& a, const vec3f& b) { return dot(a - b, a - b); } inline float angle(const vec3f& a, const vec3f& b) { return acos(clamp(dot(normalize(a), normalize(b)), (float)-1, (float)1)); } // Orthogonal vectors. inline vec3f orthogonal(const vec3f& v) { // http://lolengine.net/blog/2013/09/21/picking-orthogonal-vector-combing-coconuts) return abs(v.x) > abs(v.z) ? vec3f{-v.y, v.x, 0} : vec3f{0, -v.z, v.y}; } inline vec3f orthonormalize(const vec3f& a, const vec3f& b) { return normalize(a - b * dot(a, b)); } // Reflected and refracted vector. inline vec3f reflect(const vec3f& w, const vec3f& n) { return -w + 2 * dot(n, w) * n; } inline vec3f refract(const vec3f& w, const vec3f& n, float eta) { auto k = 1 - eta * eta * max((float)0, 1 - dot(n, w) * dot(n, w)); if (k < 0) return {0, 0, 0}; // tir return -w * eta + (eta * dot(n, w) - sqrt(k)) * n; } inline vec3f refract_notir(const vec3f& w, const vec3f& n, float eta) { auto k = 1 - eta * eta * max((float)0, 1 - dot(n, w) * dot(n, w)); k = max(k, 0.001f); return -w * eta + (eta * dot(n, w) - sqrt(k)) * n; } // Max element and clamp. inline vec3f max(const vec3f& a, float b) { return {max(a.x, b), max(a.y, b), max(a.z, b)}; } inline vec3f min(const vec3f& a, float b) { return {min(a.x, b), min(a.y, b), min(a.z, b)}; } inline vec3f max(const vec3f& a, const vec3f& b) { return {max(a.x, b.x), max(a.y, b.y), max(a.z, b.z)}; } inline vec3f min(const vec3f& a, const vec3f& b) { return {min(a.x, b.x), min(a.y, b.y), min(a.z, b.z)}; } inline vec3f clamp(const vec3f& x, float min, float max) { return {clamp(x.x, min, max), clamp(x.y, min, max), clamp(x.z, min, max)}; } inline vec3f lerp(const vec3f& a, const vec3f& b, float u) { return a * (1 - u) + b * u; } inline vec3f lerp(const vec3f& a, const vec3f& b, const vec3f& u) { return a * (1 - u) + b * u; } inline float max(const vec3f& a) { return max(max(a.x, a.y), a.z); } inline float min(const vec3f& a) { return min(min(a.x, a.y), a.z); } inline float sum(const vec3f& a) { return a.x + a.y + a.z; } inline float mean(const vec3f& a) { return sum(a) / 3; } // Functions applied to vector elements inline vec3f abs(const vec3f& a) { return {abs(a.x), abs(a.y), abs(a.z)}; }; inline vec3f sqrt(const vec3f& a) { return {sqrt(a.x), sqrt(a.y), sqrt(a.z)}; }; inline vec3f exp(const vec3f& a) { return {exp(a.x), exp(a.y), exp(a.z)}; }; inline vec3f log(const vec3f& a) { return {log(a.x), log(a.y), log(a.z)}; }; inline vec3f exp2(const vec3f& a) { return {exp2(a.x), exp2(a.y), exp2(a.z)}; }; inline vec3f log2(const vec3f& a) { return {log2(a.x), log2(a.y), log2(a.z)}; }; inline vec3f pow(const vec3f& a, float b) { return {pow(a.x, b), pow(a.y, b), pow(a.z, b)}; }; inline vec3f pow(const vec3f& a, const vec3f& b) { return {pow(a.x, b.x), pow(a.y, b.y), pow(a.z, b.z)}; }; inline vec3f gain(const vec3f& a, float b) { return {gain(a.x, b), gain(a.y, b), gain(a.z, b)}; }; inline bool is_finite(const vec3f& a) { return is_finite(a.x) && is_finite(a.y) && is_finite(a.z); }; inline void swap(vec3f& a, vec3f& b) { std::swap(a, b); } // Vector comparison operations. inline bool operator==(const vec4f& a, const vec4f& b) { return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w; } inline bool operator!=(const vec4f& a, const vec4f& b) { return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w; } // Vector operations. inline vec4f operator+(const vec4f& a) { return a; } inline vec4f operator-(const vec4f& a) { return {-a.x, -a.y, -a.z, -a.w}; } inline vec4f operator+(const vec4f& a, const vec4f& b) { return {a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w}; } inline vec4f operator+(const vec4f& a, float b) { return {a.x + b, a.y + b, a.z + b, a.w + b}; } inline vec4f operator+(float a, const vec4f& b) { return {a + b.x, a + b.y, a + b.z, a + b.w}; } inline vec4f operator-(const vec4f& a, const vec4f& b) { return {a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w}; } inline vec4f operator-(const vec4f& a, float b) { return {a.x - b, a.y - b, a.z - b, a.w - b}; } inline vec4f operator-(float a, const vec4f& b) { return {a - b.x, a - b.y, a - b.z, a - b.w}; } inline vec4f operator*(const vec4f& a, const vec4f& b) { return {a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w}; } inline vec4f operator*(const vec4f& a, float b) { return {a.x * b, a.y * b, a.z * b, a.w * b}; } inline vec4f operator*(float a, const vec4f& b) { return {a * b.x, a * b.y, a * b.z, a * b.w}; } inline vec4f operator/(const vec4f& a, const vec4f& b) { return {a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w}; } inline vec4f operator/(const vec4f& a, float b) { return {a.x / b, a.y / b, a.z / b, a.w / b}; } inline vec4f operator/(float a, const vec4f& b) { return {a / b.x, a / b.y, a / b.z, a / b.w}; } // Vector assignments inline vec4f& operator+=(vec4f& a, const vec4f& b) { return a = a + b; } inline vec4f& operator+=(vec4f& a, float b) { return a = a + b; } inline vec4f& operator-=(vec4f& a, const vec4f& b) { return a = a - b; } inline vec4f& operator-=(vec4f& a, float b) { return a = a - b; } inline vec4f& operator*=(vec4f& a, const vec4f& b) { return a = a * b; } inline vec4f& operator*=(vec4f& a, float b) { return a = a * b; } inline vec4f& operator/=(vec4f& a, const vec4f& b) { return a = a / b; } inline vec4f& operator/=(vec4f& a, float b) { return a = a / b; } // Vector products and lengths. inline float dot(const vec4f& a, const vec4f& b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } inline float length(const vec4f& a) { return sqrt(dot(a, a)); } inline vec4f normalize(const vec4f& a) { auto l = length(a); return (l != 0) ? a / l : a; } inline float distance(const vec4f& a, const vec4f& b) { return length(a - b); } inline float distance_squared(const vec4f& a, const vec4f& b) { return dot(a - b, a - b); } inline vec4f slerp(const vec4f& a, const vec4f& b, float u) { // https://en.wikipedia.org/wiki/Slerp auto an = normalize(a), bn = normalize(b); auto d = dot(an, bn); if (d < 0) { bn = -bn; d = -d; } if (d > (float)0.9995) return normalize(an + u * (bn - an)); auto th = acos(clamp(d, (float)-1, (float)1)); if (!th) return an; return an * (sin(th * (1 - u)) / sin(th)) + bn * (sin(th * u) / sin(th)); } // Max element and clamp. inline vec4f max(const vec4f& a, float b) { return {max(a.x, b), max(a.y, b), max(a.z, b), max(a.w, b)}; } inline vec4f min(const vec4f& a, float b) { return {min(a.x, b), min(a.y, b), min(a.z, b), min(a.w, b)}; } inline vec4f max(const vec4f& a, const vec4f& b) { return {max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w)}; } inline vec4f min(const vec4f& a, const vec4f& b) { return {min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w)}; } inline vec4f clamp(const vec4f& x, float min, float max) { return {clamp(x.x, min, max), clamp(x.y, min, max), clamp(x.z, min, max), clamp(x.w, min, max)}; } inline vec4f lerp(const vec4f& a, const vec4f& b, float u) { return a * (1 - u) + b * u; } inline vec4f lerp(const vec4f& a, const vec4f& b, const vec4f& u) { return a * (1 - u) + b * u; } inline float max(const vec4f& a) { return max(max(max(a.x, a.y), a.z), a.w); } inline float min(const vec4f& a) { return min(min(min(a.x, a.y), a.z), a.w); } inline float sum(const vec4f& a) { return a.x + a.y + a.z + a.w; } inline float mean(const vec4f& a) { return sum(a) / 4; } // Functions applied to vector elements inline vec4f abs(const vec4f& a) { return {abs(a.x), abs(a.y), abs(a.z), abs(a.w)}; }; inline vec4f sqrt(const vec4f& a) { return {sqrt(a.x), sqrt(a.y), sqrt(a.z), sqrt(a.w)}; }; inline vec4f exp(const vec4f& a) { return {exp(a.x), exp(a.y), exp(a.z), exp(a.w)}; }; inline vec4f log(const vec4f& a) { return {log(a.x), log(a.y), log(a.z), log(a.w)}; }; inline vec4f exp2(const vec4f& a) { return {exp2(a.x), exp2(a.y), exp2(a.z), exp2(a.w)}; }; inline vec4f log2(const vec4f& a) { return {log2(a.x), log2(a.y), log2(a.z), log2(a.w)}; }; inline vec4f pow(const vec4f& a, float b) { return {pow(a.x, b), pow(a.y, b), pow(a.z, b), pow(a.w, b)}; }; inline vec4f pow(const vec4f& a, const vec4f& b) { return {pow(a.x, b.x), pow(a.y, b.y), pow(a.z, b.z), pow(a.w, b.w)}; }; inline vec4f gain(const vec4f& a, float b) { return {gain(a.x, b), gain(a.y, b), gain(a.z, b), gain(a.w, b)}; }; inline bool is_finite(const vec4f& a) { return is_finite(a.x) && is_finite(a.y) && is_finite(a.z) && is_finite(a.w); }; inline void swap(vec4f& a, vec4f& b) { std::swap(a, b); } // Quaternion operatons represented as xi + yj + zk + w // const auto identity_quat4f = vec4f{0, 0, 0, 1}; inline vec4f quat_mul(const vec4f& a, float b) { return {a.x * b, a.y * b, a.z * b, a.w * b}; } inline vec4f quat_mul(const vec4f& a, const vec4f& b) { return {a.x * b.w + a.w * b.x + a.y * b.w - a.z * b.y, a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z, a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x, a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z}; } inline vec4f quat_conjugate(const vec4f& a) { return {-a.x, -a.y, -a.z, a.w}; } inline vec4f quat_inverse(const vec4f& a) { return quat_conjugate(a) / dot(a, a); } } // namespace yocto // ----------------------------------------------------------------------------- // INTEGER VECTORS // ----------------------------------------------------------------------------- namespace yocto { struct vec2i { int x = 0; int y = 0; vec2i() {} vec2i(int x, int y) : x{x}, y{y} {} explicit vec2i(int v) : x{v}, y{v} {} int& operator[](int i) { return (&x)[i]; } const int& operator[](int i) const { return (&x)[i]; } }; struct vec3i { int x = 0; int y = 0; int z = 0; vec3i() {} vec3i(int x, int y, int z) : x{x}, y{y}, z{z} {} vec3i(const vec2i& v, int z) : x{v.x}, y{v.y}, z{z} {} explicit vec3i(int v) : x{v}, y{v}, z{v} {} int& operator[](int i) { return (&x)[i]; } const int& operator[](int i) const { return (&x)[i]; } }; struct vec4i { int x = 0; int y = 0; int z = 0; int w = 0; vec4i() {} vec4i(int x, int y, int z, int w) : x{x}, y{y}, z{z}, w{w} {} vec4i(const vec3i& v, int w) : x{v.x}, y{v.y}, z{v.z}, w{w} {} explicit vec4i(int v) : x{v}, y{v}, z{v}, w{v} {} int& operator[](int i) { return (&x)[i]; } const int& operator[](int i) const { return (&x)[i]; } }; struct vec4b { byte x = 0; byte y = 0; byte z = 0; byte w = 0; vec4b() {} vec4b(byte x, byte y, byte z, byte w) : x{x}, y{y}, z{z}, w{w} {} explicit vec4b(byte v) : x{v}, y{v}, z{v}, w{v} {} byte& operator[](int i) { return (&x)[i]; } const byte& operator[](int i) const { return (&x)[i]; } }; // Zero vector constants. static const auto zero2i = vec2i{0, 0}; static const auto zero3i = vec3i{0, 0, 0}; static const auto zero4i = vec4i{0, 0, 0, 0}; static const auto zero4b = vec4b{0, 0, 0, 0}; // Element access inline vec3i& xyz(vec4i& a) { return (vec3i&)a; } inline const vec3i& xyz(const vec4i& a) { return (const vec3i&)a; } // Vector comparison operations. inline bool operator==(const vec2i& a, const vec2i& b) { return a.x == b.x && a.y == b.y; } inline bool operator!=(const vec2i& a, const vec2i& b) { return a.x != b.x || a.y != b.y; } // Vector operations. inline vec2i operator+(const vec2i& a) { return a; } inline vec2i operator-(const vec2i& a) { return {-a.x, -a.y}; } inline vec2i operator+(const vec2i& a, const vec2i& b) { return {a.x + b.x, a.y + b.y}; } inline vec2i operator+(const vec2i& a, int b) { return {a.x + b, a.y + b}; } inline vec2i operator+(int a, const vec2i& b) { return {a + b.x, a + b.y}; } inline vec2i operator-(const vec2i& a, const vec2i& b) { return {a.x - b.x, a.y - b.y}; } inline vec2i operator-(const vec2i& a, int b) { return {a.x - b, a.y - b}; } inline vec2i operator-(int a, const vec2i& b) { return {a - b.x, a - b.y}; } inline vec2i operator*(const vec2i& a, const vec2i& b) { return {a.x * b.x, a.y * b.y}; } inline vec2i operator*(const vec2i& a, int b) { return {a.x * b, a.y * b}; } inline vec2i operator*(int a, const vec2i& b) { return {a * b.x, a * b.y}; } inline vec2i operator/(const vec2i& a, const vec2i& b) { return {a.x / b.x, a.y / b.y}; } inline vec2i operator/(const vec2i& a, int b) { return {a.x / b, a.y / b}; } inline vec2i operator/(int a, const vec2i& b) { return {a / b.x, a / b.y}; } // Vector assignments inline vec2i& operator+=(vec2i& a, const vec2i& b) { return a = a + b; } inline vec2i& operator+=(vec2i& a, int b) { return a = a + b; } inline vec2i& operator-=(vec2i& a, const vec2i& b) { return a = a - b; } inline vec2i& operator-=(vec2i& a, int b) { return a = a - b; } inline vec2i& operator*=(vec2i& a, const vec2i& b) { return a = a * b; } inline vec2i& operator*=(vec2i& a, int b) { return a = a * b; } inline vec2i& operator/=(vec2i& a, const vec2i& b) { return a = a / b; } inline vec2i& operator/=(vec2i& a, int b) { return a = a / b; } // Max element and clamp. inline vec2i max(const vec2i& a, int b) { return {max(a.x, b), max(a.y, b)}; } inline vec2i min(const vec2i& a, int b) { return {min(a.x, b), min(a.y, b)}; } inline vec2i max(const vec2i& a, const vec2i& b) { return {max(a.x, b.x), max(a.y, b.y)}; } inline vec2i min(const vec2i& a, const vec2i& b) { return {min(a.x, b.x), min(a.y, b.y)}; } inline vec2i clamp(const vec2i& x, int min, int max) { return {clamp(x.x, min, max), clamp(x.y, min, max)}; } inline int max(const vec2i& a) { return max(a.x, a.y); } inline int min(const vec2i& a) { return min(a.x, a.y); } inline int sum(const vec2i& a) { return a.x + a.y; } // Functions applied to vector elements inline vec2i abs(const vec2i& a) { return {abs(a.x), abs(a.y)}; }; inline void swap(vec2i& a, vec2i& b) { std::swap(a, b); } // Vector comparison operations. inline bool operator==(const vec3i& a, const vec3i& b) { return a.x == b.x && a.y == b.y && a.z == b.z; } inline bool operator!=(const vec3i& a, const vec3i& b) { return a.x != b.x || a.y != b.y || a.z != b.z; } // Vector operations. inline vec3i operator+(const vec3i& a) { return a; } inline vec3i operator-(const vec3i& a) { return {-a.x, -a.y, -a.z}; } inline vec3i operator+(const vec3i& a, const vec3i& b) { return {a.x + b.x, a.y + b.y, a.z + b.z}; } inline vec3i operator+(const vec3i& a, int b) { return {a.x + b, a.y + b, a.z + b}; } inline vec3i operator+(int a, const vec3i& b) { return {a + b.x, a + b.y, a + b.z}; } inline vec3i operator-(const vec3i& a, const vec3i& b) { return {a.x - b.x, a.y - b.y, a.z - b.z}; } inline vec3i operator-(const vec3i& a, int b) { return {a.x - b, a.y - b, a.z - b}; } inline vec3i operator-(int a, const vec3i& b) { return {a - b.x, a - b.y, a - b.z}; } inline vec3i operator*(const vec3i& a, const vec3i& b) { return {a.x * b.x, a.y * b.y, a.z * b.z}; } inline vec3i operator*(const vec3i& a, int b) { return {a.x * b, a.y * b, a.z * b}; } inline vec3i operator*(int a, const vec3i& b) { return {a * b.x, a * b.y, a * b.z}; } inline vec3i operator/(const vec3i& a, const vec3i& b) { return {a.x / b.x, a.y / b.y, a.z / b.z}; } inline vec3i operator/(const vec3i& a, int b) { return {a.x / b, a.y / b, a.z / b}; } inline vec3i operator/(int a, const vec3i& b) { return {a / b.x, a / b.y, a / b.z}; } // Vector assignments inline vec3i& operator+=(vec3i& a, const vec3i& b) { return a = a + b; } inline vec3i& operator+=(vec3i& a, int b) { return a = a + b; } inline vec3i& operator-=(vec3i& a, const vec3i& b) { return a = a - b; } inline vec3i& operator-=(vec3i& a, int b) { return a = a - b; } inline vec3i& operator*=(vec3i& a, const vec3i& b) { return a = a * b; } inline vec3i& operator*=(vec3i& a, int b) { return a = a * b; } inline vec3i& operator/=(vec3i& a, const vec3i& b) { return a = a / b; } inline vec3i& operator/=(vec3i& a, int b) { return a = a / b; } // Max element and clamp. inline vec3i max(const vec3i& a, int b) { return {max(a.x, b), max(a.y, b), max(a.z, b)}; } inline vec3i min(const vec3i& a, int b) { return {min(a.x, b), min(a.y, b), min(a.z, b)}; } inline vec3i max(const vec3i& a, const vec3i& b) { return {max(a.x, b.x), max(a.y, b.y), max(a.z, b.z)}; } inline vec3i min(const vec3i& a, const vec3i& b) { return {min(a.x, b.x), min(a.y, b.y), min(a.z, b.z)}; } inline vec3i clamp(const vec3i& x, int min, int max) { return {clamp(x.x, min, max), clamp(x.y, min, max), clamp(x.z, min, max)}; } inline int max(const vec3i& a) { return max(max(a.x, a.y), a.z); } inline int min(const vec3i& a) { return min(min(a.x, a.y), a.z); } inline int sum(const vec3i& a) { return a.x + a.y + a.z; } // Functions applied to vector elements inline vec3i abs(const vec3i& a) { return {abs(a.x), abs(a.y), abs(a.z)}; }; inline void swap(vec3i& a, vec3i& b) { std::swap(a, b); } // Vector comparison operations. inline bool operator==(const vec4i& a, const vec4i& b) { return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w; } inline bool operator!=(const vec4i& a, const vec4i& b) { return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w; } // Vector operations. inline vec4i operator+(const vec4i& a) { return a; } inline vec4i operator-(const vec4i& a) { return {-a.x, -a.y, -a.z, -a.w}; } inline vec4i operator+(const vec4i& a, const vec4i& b) { return {a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w}; } inline vec4i operator+(const vec4i& a, int b) { return {a.x + b, a.y + b, a.z + b, a.w + b}; } inline vec4i operator+(int a, const vec4i& b) { return {a + b.x, a + b.y, a + b.z, a + b.w}; } inline vec4i operator-(const vec4i& a, const vec4i& b) { return {a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w}; } inline vec4i operator-(const vec4i& a, int b) { return {a.x - b, a.y - b, a.z - b, a.w - b}; } inline vec4i operator-(int a, const vec4i& b) { return {a - b.x, a - b.y, a - b.z, a - b.w}; } inline vec4i operator*(const vec4i& a, const vec4i& b) { return {a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w}; } inline vec4i operator*(const vec4i& a, int b) { return {a.x * b, a.y * b, a.z * b, a.w * b}; } inline vec4i operator*(int a, const vec4i& b) { return {a * b.x, a * b.y, a * b.z, a * b.w}; } inline vec4i operator/(const vec4i& a, const vec4i& b) { return {a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w}; } inline vec4i operator/(const vec4i& a, int b) { return {a.x / b, a.y / b, a.z / b, a.w / b}; } inline vec4i operator/(int a, const vec4i& b) { return {a / b.x, a / b.y, a / b.z, a / b.w}; } // Vector assignments inline vec4i& operator+=(vec4i& a, const vec4i& b) { return a = a + b; } inline vec4i& operator+=(vec4i& a, int b) { return a = a + b; } inline vec4i& operator-=(vec4i& a, const vec4i& b) { return a = a - b; } inline vec4i& operator-=(vec4i& a, int b) { return a = a - b; } inline vec4i& operator*=(vec4i& a, const vec4i& b) { return a = a * b; } inline vec4i& operator*=(vec4i& a, int b) { return a = a * b; } inline vec4i& operator/=(vec4i& a, const vec4i& b) { return a = a / b; } inline vec4i& operator/=(vec4i& a, int b) { return a = a / b; } // Max element and clamp. inline vec4i max(const vec4i& a, int b) { return {max(a.x, b), max(a.y, b), max(a.z, b), max(a.w, b)}; } inline vec4i min(const vec4i& a, int b) { return {min(a.x, b), min(a.y, b), min(a.z, b), min(a.w, b)}; } inline vec4i max(const vec4i& a, const vec4i& b) { return {max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w)}; } inline vec4i min(const vec4i& a, const vec4i& b) { return {min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w)}; } inline vec4i clamp(const vec4i& x, int min, int max) { return {clamp(x.x, min, max), clamp(x.y, min, max), clamp(x.z, min, max), clamp(x.w, min, max)}; } inline int max(const vec4i& a) { return max(max(max(a.x, a.y), a.z), a.w); } inline int min(const vec4i& a) { return min(min(min(a.x, a.y), a.z), a.w); } inline int sum(const vec4i& a) { return a.x + a.y + a.z + a.w; } // Functions applied to vector elements inline vec4i abs(const vec4i& a) { return {abs(a.x), abs(a.y), abs(a.z), abs(a.w)}; }; inline void swap(vec4i& a, vec4i& b) { std::swap(a, b); } } // namespace yocto namespace std { // Hash functor for vector for use with unordered_map template <> struct hash { size_t operator()(const yocto::vec2i& v) const { static const auto hasher = std::hash(); auto h = (size_t)0; h ^= hasher(v.x) + 0x9e3779b9 + (h << 6) + (h >> 2); h ^= hasher(v.y) + 0x9e3779b9 + (h << 6) + (h >> 2); return h; } }; template <> struct hash { size_t operator()(const yocto::vec3i& v) const { static const auto hasher = std::hash(); auto h = (size_t)0; h ^= hasher(v.x) + 0x9e3779b9 + (h << 6) + (h >> 2); h ^= hasher(v.y) + 0x9e3779b9 + (h << 6) + (h >> 2); h ^= hasher(v.z) + 0x9e3779b9 + (h << 6) + (h >> 2); return h; } }; template <> struct hash { size_t operator()(const yocto::vec4i& v) const { static const auto hasher = std::hash(); auto h = (size_t)0; h ^= hasher(v.x) + 0x9e3779b9 + (h << 6) + (h >> 2); h ^= hasher(v.y) + 0x9e3779b9 + (h << 6) + (h >> 2); h ^= hasher(v.z) + 0x9e3779b9 + (h << 6) + (h >> 2); h ^= hasher(v.w) + 0x9e3779b9 + (h << 6) + (h >> 2); return h; } }; } // namespace std // ----------------------------------------------------------------------------- // MATRICES // ----------------------------------------------------------------------------- namespace yocto { // Small Fixed-size matrices stored in column major format. struct mat2f { vec2f x = {1, 0}; vec2f y = {0, 1}; mat2f() {} mat2f(const vec2f& x, const vec2f& y) : x{x}, y{y} {} vec2f& operator[](int i) { return (&x)[i]; } const vec2f& operator[](int i) const { return (&x)[i]; } }; // Small Fixed-size matrices stored in column major format. struct mat3f { vec3f x = {1, 0, 0}; vec3f y = {0, 1, 0}; vec3f z = {0, 0, 1}; mat3f() {} mat3f(const vec3f& x, const vec3f& y, const vec3f& z) : x{x}, y{y}, z{z} {} vec3f& operator[](int i) { return (&x)[i]; } const vec3f& operator[](int i) const { return (&x)[i]; } }; // Small Fixed-size matrices stored in column major format. struct mat4f { vec4f x = {1, 0, 0, 0}; vec4f y = {0, 1, 0, 0}; vec4f z = {0, 0, 1, 0}; vec4f w = {0, 0, 0, 1}; mat4f() {} mat4f(const vec4f& x, const vec4f& y, const vec4f& z, const vec4f& w) : x{x}, y{y}, z{z}, w{w} {} vec4f& operator[](int i) { return (&x)[i]; } const vec4f& operator[](int i) const { return (&x)[i]; } }; // Identity matrices constants. static const auto identity2x2f = mat2f{{1, 0}, {0, 1}}; static const auto identity3x3f = mat3f{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; static const auto identity4x4f = mat4f{ {1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}; // Matrix comparisons. inline bool operator==(const mat2f& a, const mat2f& b) { return a.x == b.x && a.y == b.y; } inline bool operator!=(const mat2f& a, const mat2f& b) { return !(a == b); } // Matrix operations. inline mat2f operator+(const mat2f& a, const mat2f& b) { return {a.x + b.x, a.y + b.y}; } inline mat2f operator*(const mat2f& a, float b) { return {a.x * b, a.y * b}; } inline vec2f operator*(const mat2f& a, const vec2f& b) { return a.x * b.x + a.y * b.y; } inline vec2f operator*(const vec2f& a, const mat2f& b) { return {dot(a, b.x), dot(a, b.y)}; } inline mat2f operator*(const mat2f& a, const mat2f& b) { return {a * b.x, a * b.y}; } // Matrix assignments. inline mat2f& operator+=(mat2f& a, const mat2f& b) { return a = a + b; } inline mat2f& operator*=(mat2f& a, const mat2f& b) { return a = a * b; } inline mat2f& operator*=(mat2f& a, float b) { return a = a * b; } // Matrix diagonals and transposes. inline vec2f diagonal(const mat2f& a) { return {a.x.x, a.y.y}; } inline mat2f transpose(const mat2f& a) { return {{a.x.x, a.y.x}, {a.x.y, a.y.y}}; } // Matrix adjoints, determinants and inverses. inline float determinant(const mat2f& a) { return cross(a.x, a.y); } inline mat2f adjoint(const mat2f& a) { return {{a.y.y, -a.x.y}, {-a.y.x, a.x.x}}; } inline mat2f inverse(const mat2f& a) { return adjoint(a) * (1 / determinant(a)); } // Matrix comparisons. inline bool operator==(const mat3f& a, const mat3f& b) { return a.x == b.x && a.y == b.y && a.z == b.z; } inline bool operator!=(const mat3f& a, const mat3f& b) { return !(a == b); } // Matrix operations. inline mat3f operator+(const mat3f& a, const mat3f& b) { return {a.x + b.x, a.y + b.y, a.z + b.z}; } inline mat3f operator*(const mat3f& a, float b) { return {a.x * b, a.y * b, a.z * b}; } inline vec3f operator*(const mat3f& a, const vec3f& b) { return a.x * b.x + a.y * b.y + a.z * b.z; } inline vec3f operator*(const vec3f& a, const mat3f& b) { return {dot(a, b.x), dot(a, b.y), dot(a, b.z)}; } inline mat3f operator*(const mat3f& a, const mat3f& b) { return {a * b.x, a * b.y, a * b.z}; } // Matrix assignments. inline mat3f& operator+=(mat3f& a, const mat3f& b) { return a = a + b; } inline mat3f& operator*=(mat3f& a, const mat3f& b) { return a = a * b; } inline mat3f& operator*=(mat3f& a, float b) { return a = a * b; } // Matrix diagonals and transposes. inline vec3f diagonal(const mat3f& a) { return {a.x.x, a.y.y, a.z.z}; } inline mat3f transpose(const mat3f& a) { return { {a.x.x, a.y.x, a.z.x}, {a.x.y, a.y.y, a.z.y}, {a.x.z, a.y.z, a.z.z}, }; } // Matrix adjoints, determinants and inverses. inline float determinant(const mat3f& a) { return dot(a.x, cross(a.y, a.z)); } inline mat3f adjoint(const mat3f& a) { return transpose(mat3f{cross(a.y, a.z), cross(a.z, a.x), cross(a.x, a.y)}); } inline mat3f inverse(const mat3f& a) { return adjoint(a) * (1 / determinant(a)); } // Constructs a basis from a direction inline mat3f basis_fromz(const vec3f& v) { // https://graphics.pixar.com/library/OrthonormalB/paper.pdf auto z = normalize(v); auto sign = copysignf(1.0f, z.z); auto a = -1.0f / (sign + z.z); auto b = z.x * z.y * a; auto x = vec3f{1.0f + sign * z.x * z.x * a, sign * b, -sign * z.x}; auto y = vec3f{b, sign + z.y * z.y * a, -z.y}; return {x, y, z}; } // Matrix comparisons. inline bool operator==(const mat4f& a, const mat4f& b) { return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w; } inline bool operator!=(const mat4f& a, const mat4f& b) { return !(a == b); } // Matrix operations. inline mat4f operator+(const mat4f& a, const mat4f& b) { return {a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w}; } inline mat4f operator*(const mat4f& a, float b) { return {a.x * b, a.y * b, a.z * b, a.w * b}; } inline vec4f operator*(const mat4f& a, const vec4f& b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } inline vec4f operator*(const vec4f& a, const mat4f& b) { return {dot(a, b.x), dot(a, b.y), dot(a, b.z), dot(a, b.w)}; } inline mat4f operator*(const mat4f& a, const mat4f& b) { return {a * b.x, a * b.y, a * b.z, a * b.w}; } // Matrix assignments. inline mat4f& operator+=(mat4f& a, const mat4f& b) { return a = a + b; } inline mat4f& operator*=(mat4f& a, const mat4f& b) { return a = a * b; } inline mat4f& operator*=(mat4f& a, float b) { return a = a * b; } // Matrix diagonals and transposes. inline vec4f diagonal(const mat4f& a) { return {a.x.x, a.y.y, a.z.z, a.w.w}; } inline mat4f transpose(const mat4f& a) { return { {a.x.x, a.y.x, a.z.x, a.w.x}, {a.x.y, a.y.y, a.z.y, a.w.y}, {a.x.z, a.y.z, a.z.z, a.w.z}, {a.x.w, a.y.w, a.z.w, a.w.w}, }; } } // namespace yocto // ----------------------------------------------------------------------------- // RIGID BODY TRANSFORMS/FRAMES // ----------------------------------------------------------------------------- namespace yocto { // Rigid frames stored as a column-major affine transform matrix. struct frame2f { vec2f x = {1, 0}; vec2f y = {0, 1}; vec2f o = {0, 0}; frame2f() : x{}, y{}, o{} {} frame2f(const vec2f& x, const vec2f& y, const vec2f& o) : x{x}, y{y}, o{o} {} explicit frame2f(const vec2f& o) : x{1, 0}, y{0, 1}, o{o} {} frame2f(const mat2f& m, const vec2f& t) : x{m.x}, y{m.y}, o{t} {} explicit frame2f(const mat3f& m) : x{m.x.x, m.x.y}, y{m.y.x, m.y.y}, o{m.z.x, m.z.y} {} operator mat3f() const { return {{x, 0}, {y, 0}, {o, 1}}; } vec2f& operator[](int i) { return (&x)[i]; } const vec2f& operator[](int i) const { return (&x)[i]; } }; // Rigid frames stored as a column-major affine transform matrix. struct frame3f { vec3f x = {1, 0, 0}; vec3f y = {0, 1, 0}; vec3f z = {0, 0, 1}; vec3f o = {0, 0, 0}; frame3f() : x{}, y{}, z{}, o{} {} frame3f(const vec3f& x, const vec3f& y, const vec3f& z, const vec3f& o) : x{x}, y{y}, z{z}, o{o} {} explicit frame3f(const vec3f& o) : x{1, 0, 0}, y{0, 1, 0}, z{0, 0, 1}, o{o} {} frame3f(const mat3f& m, const vec3f& t) : x{m.x}, y{m.y}, z{m.z}, o{t} {} explicit frame3f(const mat4f& m) : x{m.x.x, m.x.y, m.x.z} , y{m.y.x, m.y.y, m.y.z} , z{m.z.x, m.z.y, m.z.z} , o{m.w.x, m.w.y, m.w.z} {} operator mat4f() const { return {{x, 0}, {y, 0}, {z, 0}, {o, 1}}; } vec3f& operator[](int i) { return (&x)[i]; } const vec3f& operator[](int i) const { return (&x)[i]; } }; // Indentity frames. static const auto identity2x3f = frame2f{{1, 0}, {0, 1}, {0, 0}}; static const auto identity3x4f = frame3f{ {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}}; // Frame properties inline const mat2f& rotation(const frame2f& a) { return (const mat2f&)a; } // Frame comparisons. inline bool operator==(const frame2f& a, const frame2f& b) { return a.x == b.x && a.y == b.y && a.o == b.o; } inline bool operator!=(const frame2f& a, const frame2f& b) { return !(a == b); } // Frame composition, equivalent to affine matrix product. inline frame2f operator*(const frame2f& a, const frame2f& b) { return {rotation(a) * rotation(b), rotation(a) * b.o + a.o}; } inline frame2f& operator*=(frame2f& a, const frame2f& b) { return a = a * b; } // Frame inverse, equivalent to rigid affine inverse. inline frame2f inverse(const frame2f& a, bool non_rigid = false) { if (non_rigid) { auto minv = inverse(rotation(a)); return {minv, -(minv * a.o)}; } else { auto minv = transpose(rotation(a)); return {minv, -(minv * a.o)}; } } // Frame properties inline const mat3f& rotation(const frame3f& a) { return (const mat3f&)a; } // Frame comparisons. inline bool operator==(const frame3f& a, const frame3f& b) { return a.x == b.x && a.y == b.y && a.z == b.z && a.o == b.o; } inline bool operator!=(const frame3f& a, const frame3f& b) { return !(a == b); } // Frame composition, equivalent to affine matrix product. inline frame3f operator*(const frame3f& a, const frame3f& b) { return {rotation(a) * rotation(b), rotation(a) * b.o + a.o}; } inline frame3f& operator*=(frame3f& a, const frame3f& b) { return a = a * b; } // Frame inverse, equivalent to rigid affine inverse. inline frame3f inverse(const frame3f& a, bool non_rigid = false) { if (non_rigid) { auto minv = inverse(rotation(a)); return {minv, -(minv * a.o)}; } else { auto minv = transpose(rotation(a)); return {minv, -(minv * a.o)}; } } // Frame construction from axis. inline frame3f frame_fromz(const vec3f& o, const vec3f& v) { // https://graphics.pixar.com/library/OrthonormalB/paper.pdf auto z = normalize(v); auto sign = copysignf(1.0f, z.z); auto a = -1.0f / (sign + z.z); auto b = z.x * z.y * a; auto x = vec3f{1.0f + sign * z.x * z.x * a, sign * b, -sign * z.x}; auto y = vec3f{b, sign + z.y * z.y * a, -z.y}; return {x, y, z, o}; } inline frame3f frame_fromzx(const vec3f& o, const vec3f& z_, const vec3f& x_) { auto z = normalize(z_); auto x = orthonormalize(x_, z); auto y = normalize(cross(z, x)); return {x, y, z, o}; } } // namespace yocto // ----------------------------------------------------------------------------- // QUATERNIONS // ----------------------------------------------------------------------------- namespace yocto { // Quaternions to represent rotations struct quat4f { float x = 0; float y = 0; float z = 0; float w = 0; // constructors quat4f() : x{0}, y{0}, z{0}, w{1} {} quat4f(float x, float y, float z, float w) : x{x}, y{y}, z{z}, w{w} {} }; // Constants static const auto identity_quat4f = quat4f{0, 0, 0, 1}; // Quaternion operatons inline quat4f operator+(const quat4f& a, const quat4f& b) { return {a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w}; } inline quat4f operator*(const quat4f& a, float b) { return {a.x * b, a.y * b, a.z * b, a.w * b}; } inline quat4f operator/(const quat4f& a, float b) { return {a.x / b, a.y / b, a.z / b, a.w / b}; } inline quat4f operator*(const quat4f& a, const quat4f& b) { return {a.x * b.w + a.w * b.x + a.y * b.w - a.z * b.y, a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z, a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x, a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z}; } // Quaterion operations inline float dot(const quat4f& a, const quat4f& b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } inline float length(const quat4f& a) { return sqrt(dot(a, a)); } inline quat4f normalize(const quat4f& a) { auto l = length(a); return (l != 0) ? a / l : a; } inline quat4f conjugate(const quat4f& a) { return {-a.x, -a.y, -a.z, a.w}; } inline quat4f inverse(const quat4f& a) { return conjugate(a) / dot(a, a); } inline float uangle(const quat4f& a, const quat4f& b) { auto d = dot(a, b); return d > 1 ? 0 : acos(d < -1 ? -1 : d); } inline quat4f lerp(const quat4f& a, const quat4f& b, float t) { return a * (1 - t) + b * t; } inline quat4f nlerp(const quat4f& a, const quat4f& b, float t) { return normalize(lerp(a, b, t)); } inline quat4f slerp(const quat4f& a, const quat4f& b, float t) { auto th = uangle(a, b); return th == 0 ? a : a * (sin(th * (1 - t)) / sin(th)) + b * (sin(th * t) / sin(th)); } } // namespace yocto // ----------------------------------------------------------------------------- // AXIS ALIGNED BOUNDING BOXES // ----------------------------------------------------------------------------- namespace yocto { // Axis aligned bounding box represented as a min/max vector pairs. struct bbox2f { vec2f min = {flt_max, flt_max}; vec2f max = {flt_min, flt_min}; bbox2f() {} bbox2f(const vec2f& min, const vec2f& max) : min{min}, max{max} {} vec2f& operator[](int i) { return (&min)[i]; } const vec2f& operator[](int i) const { return (&min)[i]; } }; // Axis aligned bounding box represented as a min/max vector pairs. struct bbox3f { vec3f min = {flt_max, flt_max, flt_max}; vec3f max = {flt_min, flt_min, flt_min}; bbox3f() {} bbox3f(const vec3f& min, const vec3f& max) : min{min}, max{max} {} vec3f& operator[](int i) { return (&min)[i]; } const vec3f& operator[](int i) const { return (&min)[i]; } }; // Empty bbox constant. static const auto invalidb2f = bbox2f{}; static const auto invalidb3f = bbox3f{}; // Bounding box properties inline vec2f center(const bbox2f& a) { return (a.min + a.max) / 2; } inline vec2f size(const bbox2f& a) { return a.max - a.min; } // Bounding box comparisons. inline bool operator==(const bbox2f& a, const bbox2f& b) { return a.min == b.min && a.max == b.max; } inline bool operator!=(const bbox2f& a, const bbox2f& b) { return a.min != b.min || a.max != b.max; } // Bounding box expansions with points and other boxes. inline bbox2f merge(const bbox2f& a, const vec2f& b) { return {min(a.min, b), max(a.max, b)}; } inline bbox2f merge(const bbox2f& a, const bbox2f& b) { return {min(a.min, b.min), max(a.max, b.max)}; } inline void expand(bbox2f& a, const vec2f& b) { a = merge(a, b); } inline void expand(bbox2f& a, const bbox2f& b) { a = merge(a, b); } // Bounding box properties inline vec3f center(const bbox3f& a) { return (a.min + a.max) / 2; } inline vec3f size(const bbox3f& a) { return a.max - a.min; } // Bounding box comparisons. inline bool operator==(const bbox3f& a, const bbox3f& b) { return a.min == b.min && a.max == b.max; } inline bool operator!=(const bbox3f& a, const bbox3f& b) { return a.min != b.min || a.max != b.max; } // Bounding box expansions with points and other boxes. inline bbox3f merge(const bbox3f& a, const vec3f& b) { return {min(a.min, b), max(a.max, b)}; } inline bbox3f merge(const bbox3f& a, const bbox3f& b) { return {min(a.min, b.min), max(a.max, b.max)}; } inline void expand(bbox3f& a, const vec3f& b) { a = merge(a, b); } inline void expand(bbox3f& a, const bbox3f& b) { a = merge(a, b); } // Primitive bounds. inline bbox3f point_bounds(const vec3f& p) { return {p, p}; } inline bbox3f point_bounds(const vec3f& p, float r) { return {min(p - r, p + r), max(p - r, p + r)}; } inline bbox3f line_bounds(const vec3f& p0, const vec3f& p1) { return {min(p0, p1), max(p0, p1)}; } inline bbox3f line_bounds( const vec3f& p0, const vec3f& p1, float r0, float r1) { return {min(p0 - r0, p1 - r1), max(p0 + r0, p1 + r1)}; } inline bbox3f triangle_bounds( const vec3f& p0, const vec3f& p1, const vec3f& p2) { return {min(p0, min(p1, p2)), max(p0, max(p1, p2))}; } inline bbox3f quad_bounds( const vec3f& p0, const vec3f& p1, const vec3f& p2, const vec3f& p3) { return {min(p0, min(p1, min(p2, p3))), max(p0, max(p1, max(p2, p3)))}; } } // namespace yocto // ----------------------------------------------------------------------------- // RAYS // ----------------------------------------------------------------------------- namespace yocto { // Ray esplison static const auto ray_eps = 1e-4f; struct ray2f { vec2f o = {0, 0}; vec2f d = {0, 1}; float tmin = ray_eps; float tmax = flt_max; ray2f() {} ray2f(const vec2f& o, const vec2f& d, float tmin = ray_eps, float tmax = flt_max) : o{o}, d{d}, tmin{tmin}, tmax{tmax} {} }; // Rays with origin, direction and min/max t value. struct ray3f { vec3f o = {0, 0, 0}; vec3f d = {0, 0, 1}; float tmin = ray_eps; float tmax = flt_max; ray3f() {} ray3f(const vec3f& o, const vec3f& d, float tmin = ray_eps, float tmax = flt_max) : o{o}, d{d}, tmin{tmin}, tmax{tmax} {} }; } // namespace yocto // ----------------------------------------------------------------------------- // TRANSFORMS // ----------------------------------------------------------------------------- namespace yocto { // Transforms points, vectors and directions by matrices. inline vec2f transform_point(const mat3f& a, const vec2f& b) { auto tvb = a * vec3f{b.x, b.y, 1}; return vec2f{tvb.x, tvb.y} / tvb.z; } inline vec2f transform_vector(const mat3f& a, const vec2f& b) { auto tvb = a * vec3f{b.x, b.y, 0}; return vec2f{tvb.x, tvb.y} / tvb.z; } inline vec2f transform_direction(const mat3f& a, const vec2f& b) { return normalize(transform_vector(a, b)); } inline vec2f transform_normal(const mat3f& a, const vec2f& b) { return normalize(transform_vector(transpose(inverse(a)), b)); } inline vec2f transform_vector(const mat2f& a, const vec2f& b) { return a * b; } inline vec2f transform_direction(const mat2f& a, const vec2f& b) { return normalize(transform_vector(a, b)); } inline vec2f transform_normal(const mat2f& a, const vec2f& b) { return normalize(transform_vector(transpose(inverse(a)), b)); } inline vec3f transform_point(const mat4f& a, const vec3f& b) { auto tvb = a * vec4f{b.x, b.y, b.z, 1}; return vec3f{tvb.x, tvb.y, tvb.z} / tvb.w; } inline vec3f transform_vector(const mat4f& a, const vec3f& b) { auto tvb = a * vec4f{b.x, b.y, b.z, 0}; return vec3f{tvb.x, tvb.y, tvb.z}; } inline vec3f transform_direction(const mat4f& a, const vec3f& b) { return normalize(transform_vector(a, b)); } inline vec3f transform_vector(const mat3f& a, const vec3f& b) { return a * b; } inline vec3f transform_direction(const mat3f& a, const vec3f& b) { return normalize(transform_vector(a, b)); } inline vec3f transform_normal(const mat3f& a, const vec3f& b) { return normalize(transform_vector(transpose(inverse(a)), b)); } // Transforms points, vectors and directions by frames. inline vec2f transform_point(const frame2f& a, const vec2f& b) { return a.x * b.x + a.y * b.y + a.o; } inline vec2f transform_vector(const frame2f& a, const vec2f& b) { return a.x * b.x + a.y * b.y; } inline vec2f transform_direction(const frame2f& a, const vec2f& b) { return normalize(transform_vector(a, b)); } inline vec2f transform_normal( const frame2f& a, const vec2f& b, bool non_rigid = false) { if (non_rigid) { return transform_normal(rotation(a), b); } else { return normalize(transform_vector(a, b)); } } // Transforms points, vectors and directions by frames. inline vec3f transform_point(const frame3f& a, const vec3f& b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.o; } inline vec3f transform_vector(const frame3f& a, const vec3f& b) { return a.x * b.x + a.y * b.y + a.z * b.z; } inline vec3f transform_direction(const frame3f& a, const vec3f& b) { return normalize(transform_vector(a, b)); } inline vec3f transform_normal( const frame3f& a, const vec3f& b, bool non_rigid = false) { if (non_rigid) { return transform_normal(rotation(a), b); } else { return normalize(transform_vector(a, b)); } } // Transforms rays and bounding boxes by matrices. inline ray3f transform_ray(const mat4f& a, const ray3f& b) { return {transform_point(a, b.o), transform_vector(a, b.d), b.tmin, b.tmax}; } inline ray3f transform_ray(const frame3f& a, const ray3f& b) { return {transform_point(a, b.o), transform_vector(a, b.d), b.tmin, b.tmax}; } inline bbox3f transform_bbox(const mat4f& a, const bbox3f& b) { auto corners = {vec3f{b.min.x, b.min.y, b.min.z}, vec3f{b.min.x, b.min.y, b.max.z}, vec3f{b.min.x, b.max.y, b.min.z}, vec3f{b.min.x, b.max.y, b.max.z}, vec3f{b.max.x, b.min.y, b.min.z}, vec3f{b.max.x, b.min.y, b.max.z}, vec3f{b.max.x, b.max.y, b.min.z}, vec3f{b.max.x, b.max.y, b.max.z}}; auto xformed = bbox3f(); for (auto& corner : corners) xformed = merge(xformed, transform_point(a, corner)); return xformed; } inline bbox3f transform_bbox(const frame3f& a, const bbox3f& b) { auto corners = {vec3f{b.min.x, b.min.y, b.min.z}, vec3f{b.min.x, b.min.y, b.max.z}, vec3f{b.min.x, b.max.y, b.min.z}, vec3f{b.min.x, b.max.y, b.max.z}, vec3f{b.max.x, b.min.y, b.min.z}, vec3f{b.max.x, b.min.y, b.max.z}, vec3f{b.max.x, b.max.y, b.min.z}, vec3f{b.max.x, b.max.y, b.max.z}}; auto xformed = bbox3f(); for (auto& corner : corners) xformed = merge(xformed, transform_point(a, corner)); return xformed; } // Translation, scaling and rotations transforms. inline frame3f translation_frame(const vec3f& a) { return {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, a}; } inline frame3f scaling_frame(const vec3f& a) { return {{a.x, 0, 0}, {0, a.y, 0}, {0, 0, a.z}, {0, 0, 0}}; } inline frame3f rotation_frame(const vec3f& axis, float angle) { auto s = sin(angle), c = cos(angle); auto vv = normalize(axis); return {{c + (1 - c) * vv.x * vv.x, (1 - c) * vv.x * vv.y + s * vv.z, (1 - c) * vv.x * vv.z - s * vv.y}, {(1 - c) * vv.x * vv.y - s * vv.z, c + (1 - c) * vv.y * vv.y, (1 - c) * vv.y * vv.z + s * vv.x}, {(1 - c) * vv.x * vv.z + s * vv.y, (1 - c) * vv.y * vv.z - s * vv.x, c + (1 - c) * vv.z * vv.z}, {0, 0, 0}}; } inline frame3f rotation_frame(const vec4f& quat) { auto v = quat; return {{v.w * v.w + v.x * v.x - v.y * v.y - v.z * v.z, (v.x * v.y + v.z * v.w) * 2, (v.z * v.x - v.y * v.w) * 2}, {(v.x * v.y - v.z * v.w) * 2, v.w * v.w - v.x * v.x + v.y * v.y - v.z * v.z, (v.y * v.z + v.x * v.w) * 2}, {(v.z * v.x + v.y * v.w) * 2, (v.y * v.z - v.x * v.w) * 2, v.w * v.w - v.x * v.x - v.y * v.y + v.z * v.z}, {0, 0, 0}}; } inline frame3f rotation_frame(const quat4f& quat) { auto v = quat; return {{v.w * v.w + v.x * v.x - v.y * v.y - v.z * v.z, (v.x * v.y + v.z * v.w) * 2, (v.z * v.x - v.y * v.w) * 2}, {(v.x * v.y - v.z * v.w) * 2, v.w * v.w - v.x * v.x + v.y * v.y - v.z * v.z, (v.y * v.z + v.x * v.w) * 2}, {(v.z * v.x + v.y * v.w) * 2, (v.y * v.z - v.x * v.w) * 2, v.w * v.w - v.x * v.x - v.y * v.y + v.z * v.z}, {0, 0, 0}}; } inline frame3f rotation_frame(const mat3f& rot) { return {rot.x, rot.y, rot.z, {0, 0, 0}}; } // Lookat frame. Z-axis can be inverted with inv_xz. inline frame3f lookat_frame(const vec3f& eye, const vec3f& center, const vec3f& up, bool inv_xz = false) { auto w = normalize(eye - center); auto u = normalize(cross(up, w)); auto v = normalize(cross(w, u)); if (inv_xz) { w = -w; u = -u; } return {u, v, w, eye}; } // OpenGL frustum, ortho and perspecgive matrices. inline mat4f frustum_mat(float l, float r, float b, float t, float n, float f) { return {{2 * n / (r - l), 0, 0, 0}, {0, 2 * n / (t - b), 0, 0}, {(r + l) / (r - l), (t + b) / (t - b), -(f + n) / (f - n), -1}, {0, 0, -2 * f * n / (f - n), 0}}; } inline mat4f ortho_mat(float l, float r, float b, float t, float n, float f) { return {{2 / (r - l), 0, 0, 0}, {0, 2 / (t - b), 0, 0}, {0, 0, -2 / (f - n), 0}, {-(r + l) / (r - l), -(t + b) / (t - b), -(f + n) / (f - n), 1}}; } inline mat4f ortho2d_mat(float left, float right, float bottom, float top) { return ortho_mat(left, right, bottom, top, -1, 1); } inline mat4f ortho_mat(float xmag, float ymag, float near, float far) { return {{1 / xmag, 0, 0, 0}, {0, 1 / ymag, 0, 0}, {0, 0, 2 / (near - far), 0}, {0, 0, (far + near) / (near - far), 1}}; } inline mat4f perspective_mat(float fovy, float aspect, float near, float far) { auto tg = tan(fovy / 2); return {{1 / (aspect * tg), 0, 0, 0}, {0, 1 / tg, 0, 0}, {0, 0, (far + near) / (near - far), -1}, {0, 0, 2 * far * near / (near - far), 0}}; } inline mat4f perspective_mat(float fovy, float aspect, float near) { auto tg = tan(fovy / 2); return {{1 / (aspect * tg), 0, 0, 0}, {0, 1 / tg, 0, 0}, {0, 0, -1, -1}, {0, 0, 2 * near, 0}}; } // Rotation conversions. inline pair rotation_axisangle(const vec4f& quat) { return {normalize(vec3f{quat.x, quat.y, quat.z}), 2 * acos(quat.w)}; } inline vec4f rotation_quat(const vec3f& axis, float angle) { auto len = length(axis); if (!len) return {0, 0, 0, 1}; return vec4f{sin(angle / 2) * axis.x / len, sin(angle / 2) * axis.y / len, sin(angle / 2) * axis.z / len, cos(angle / 2)}; } inline vec4f rotation_quat(const vec4f& axisangle) { return rotation_quat( vec3f{axisangle.x, axisangle.y, axisangle.z}, axisangle.w); } // Computes the image uv coordinates corresponding to the view parameters. // Returns negative coordinates if out of the image. inline vec2i get_image_coords(const vec2f& mouse_pos, const vec2f& center, float scale, const vec2i& txt_size) { auto xyf = (mouse_pos - center) / scale; return vec2i{(int)round(xyf.x + txt_size.x / 2.0f), (int)round(xyf.y + txt_size.y / 2.0f)}; } // Center image and autofit. inline void update_imview(vec2f& center, float& scale, const vec2i& imsize, const vec2i& winsize, bool zoom_to_fit) { if (zoom_to_fit) { scale = min(winsize.x / (float)imsize.x, winsize.y / (float)imsize.y); center = {(float)winsize.x / 2, (float)winsize.y / 2}; } else { if (winsize.x >= imsize.x * scale) center.x = winsize.x / 2; if (winsize.y >= imsize.y * scale) center.y = winsize.y / 2; } } // Turntable for UI navigation. inline void update_turntable(vec3f& from, vec3f& to, vec3f& up, const vec2f& rotate, float dolly, const vec2f& pan) { // rotate if necessary if (rotate.x || rotate.y) { auto z = normalize(to - from); auto lz = length(to - from); auto phi = atan2(z.z, z.x) + rotate.x; auto theta = acos(z.y) + rotate.y; theta = clamp(theta, 0.001f, pif - 0.001f); auto nz = vec3f{sin(theta) * cos(phi) * lz, cos(theta) * lz, sin(theta) * sin(phi) * lz}; from = to - nz; } // dolly if necessary if (dolly) { auto z = normalize(to - from); auto lz = max(0.001f, length(to - from) * (1 + dolly)); z *= lz; from = to - z; } // pan if necessary if (pan.x || pan.y) { auto z = normalize(to - from); auto x = normalize(cross(up, z)); auto y = normalize(cross(z, x)); auto t = vec3f{pan.x * x.x + pan.y * y.x, pan.x * x.y + pan.y * y.y, pan.x * x.z + pan.y * y.z}; from += t; to += t; } } // Turntable for UI navigation. inline void update_turntable(frame3f& frame, float& focus, const vec2f& rotate, float dolly, const vec2f& pan) { // rotate if necessary if (rotate != zero2f) { auto phi = atan2(frame.z.z, frame.z.x) + rotate.x; auto theta = acos(frame.z.y) + rotate.y; theta = clamp(theta, 0.001f, pif - 0.001f); auto new_z = vec3f{ sin(theta) * cos(phi), cos(theta), sin(theta) * sin(phi)}; auto new_center = frame.o - frame.z * focus; auto new_o = new_center + new_z * focus; frame = lookat_frame(new_o, new_center, {0, 1, 0}); focus = length(new_o - new_center); } // pan if necessary if (dolly) { auto c = frame.o - frame.z * focus; focus = max(focus * (1 + dolly), 0.001f); frame.o = c + frame.z * focus; } // pan if necessary if (pan.x || pan.y) { frame.o += frame.x * pan.x + frame.y * pan.y; } } // FPS camera for UI navigation for a frame parametrization. inline void update_fpscam( frame3f& frame, const vec3f& transl, const vec2f& rotate) { // https://gamedev.stackexchange.com/questions/30644/how-to-keep-my-quaternion-using-fps-camera-from-tilting-and-messing-up auto y = vec3f{0, 1, 0}; auto z = orthonormalize(frame.z, y); auto x = cross(y, z); auto rot = rotation_frame(vec3f{1, 0, 0}, rotate.y) * yocto::frame3f{frame.x, frame.y, frame.z, vec3f{0, 0, 0}} * rotation_frame(vec3f{0, 1, 0}, rotate.x); auto pos = frame.o + transl.x * x + transl.y * y + transl.z * z; frame = {rot.x, rot.y, rot.z, pos}; } } // namespace yocto // ----------------------------------------------------------------------------- // TIMER // ----------------------------------------------------------------------------- namespace yocto { // print information and returns a timer that will print the time when // destroyed. Use with RIIA for scoped timing. struct timer { timer() : start{get_time()} {} int64_t elapsed() { return get_time() - start; } string elapsedf() { auto duration = get_time() - start; auto elapsed = duration / 1000000; // milliseconds auto hours = (int)(elapsed / 3600000); elapsed %= 3600000; auto mins = (int)(elapsed / 60000); elapsed %= 60000; auto secs = (int)(elapsed / 1000); auto msecs = (int)(elapsed % 1000); char buffer[256]; sprintf(buffer, "%02d:%02d:%02d.%03d", hours, mins, secs, msecs); return buffer; } static int64_t get_time() { return std::chrono::high_resolution_clock::now().time_since_epoch().count(); } private: int64_t start = 0; }; } // namespace yocto #endif goxel-0.11.0/ext_src/yocto/yocto_obj.cpp000066400000000000000000000375501435762723100202320ustar00rootroot00000000000000// // Implementation for Yocto/OBJ. // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include "yocto_obj.h" #include #include #include "ext/filesystem.hpp" namespace fs = ghc::filesystem; // ----------------------------------------------------------------------------- // OBJ CONVERSION // ----------------------------------------------------------------------------- namespace yocto { using std::string_view; using namespace std::literals::string_view_literals; // Check if a file can be opened for reading. static inline bool exists_file(const string& filename) { auto f = fopen(filename.c_str(), "r"); if (!f) return false; fclose(f); return true; } // A file holder that closes a file when destructed. Useful for RIIA struct file_holder { FILE* fs = nullptr; string filename = ""; file_holder(const file_holder&) = delete; file_holder& operator=(const file_holder&) = delete; ~file_holder() { if (fs) fclose(fs); } }; // Opens a file returing a handle with RIIA static inline file_holder open_input_file( const string& filename, bool binary = false) { auto fs = fopen(filename.c_str(), !binary ? "rt" : "rb"); if (!fs) throw std::runtime_error("could not open file " + filename); return {fs, filename}; } // Read a line static inline bool read_line(FILE* fs, char* buffer, size_t size) { return fgets(buffer, size, fs) != nullptr; } static inline bool is_obj_space(char c) { return c == ' ' || c == '\t' || c == '\r' || c == '\n'; } static inline bool is_obj_newline(char c) { return c == '\r' || c == '\n'; } static inline void skip_obj_whitespace(string_view& str) { while (!str.empty() && is_obj_space(str.front())) str.remove_prefix(1); } static inline void remove_obj_comment( string_view& str, char comment_char = '#') { while (!str.empty() && is_obj_newline(str.back())) str.remove_suffix(1); auto cpy = str; while (!cpy.empty() && cpy.front() != comment_char) cpy.remove_prefix(1); str.remove_suffix(cpy.size()); } // Parse values from a string static inline void parse_obj_value(string_view& str, string_view& value) { skip_obj_whitespace(str); if (str.empty()) throw std::runtime_error("cannot parse value"); if (str.front() != '"') { auto cpy = str; while (!cpy.empty() && !is_obj_space(cpy.front())) cpy.remove_prefix(1); value = str; value.remove_suffix(cpy.size()); str.remove_prefix(str.size() - cpy.size()); } else { if (str.front() != '"') throw std::runtime_error("cannot parse value"); str.remove_prefix(1); if (str.empty()) throw std::runtime_error("cannot parse value"); auto cpy = str; while (!cpy.empty() && cpy.front() != '"') cpy.remove_prefix(1); if (cpy.empty()) throw std::runtime_error("cannot parse value"); value = str; value.remove_suffix(cpy.size()); str.remove_prefix(str.size() - cpy.size()); str.remove_prefix(1); } } static inline void parse_obj_value(string_view& str, string& value) { auto valuev = ""sv; parse_obj_value(str, valuev); value = string{valuev}; } static inline void parse_obj_value(string_view& str, int& value) { char* end = nullptr; value = (int)strtol(str.data(), &end, 10); if (str == end) throw std::runtime_error("cannot parse value"); str.remove_prefix(end - str.data()); } static inline void parse_obj_value(string_view& str, bool& value) { auto valuei = 0; parse_obj_value(str, valuei); value = (bool)valuei; } static inline void parse_obj_value(string_view& str, float& value) { char* end = nullptr; value = strtof(str.data(), &end); if (str == end) throw std::runtime_error("cannot parse value"); str.remove_prefix(end - str.data()); } template static inline void parse_obj_value(string_view& str, T* values, int num) { for (auto i = 0; i < num; i++) parse_obj_value(str, values[i]); } static inline void parse_obj_value(string_view& str, vec2f& value) { parse_obj_value(str, &value.x, 2); } static inline void parse_obj_value(string_view& str, vec3f& value) { parse_obj_value(str, &value.x, 3); } static inline void parse_obj_value(string_view& str, frame3f& value) { parse_obj_value(str, &value.x.x, 12); } template static inline void parse_obj_value_or_empty(string_view& str, T& value) { skip_obj_whitespace(str); if (str.empty()) { value = T{}; } else { parse_obj_value(str, value); } } static inline void parse_obj_value(string_view& str, obj_vertex& value) { value = obj_vertex{0, 0, 0}; parse_obj_value(str, value.position); if (!str.empty() && str.front() == '/') { str.remove_prefix(1); if (!str.empty() && str.front() == '/') { str.remove_prefix(1); parse_obj_value(str, value.normal); } else { parse_obj_value(str, value.texcoord); if (!str.empty() && str.front() == '/') { str.remove_prefix(1); parse_obj_value(str, value.normal); } } } } // Input for OBJ textures static inline void parse_obj_value(string_view& str, obj_texture_info& info) { // initialize info = obj_texture_info(); // get tokens auto tokens = vector(); skip_obj_whitespace(str); while (!str.empty()) { auto token = ""s; parse_obj_value(str, token); tokens.push_back(token); skip_obj_whitespace(str); } if (tokens.empty()) throw std::runtime_error("cannot parse value"); // texture name info.path = fs::path(tokens.back()).generic_string(); // texture params auto last = string(); for (auto i = 0; i < tokens.size() - 1; i++) { if (tokens[i] == "-bm") info.scale = atof(tokens[i + 1].c_str()); if (tokens[i] == "-clamp") info.clamp = true; } } // Load obj materials void load_mtl(const string& filename, obj_callbacks& cb, bool fliptr) { // open file auto fs_ = open_input_file(filename); auto fs = fs_.fs; // currently parsed material auto material = obj_material(); auto first = true; // read the file line by line char buffer[4096]; while (read_line(fs, buffer, sizeof(buffer))) { // line auto line = string_view{buffer}; remove_obj_comment(line); skip_obj_whitespace(line); if (line.empty()) continue; // get command auto cmd = ""s; parse_obj_value(line, cmd); if (cmd == "") continue; // possible token values if (cmd == "newmtl") { if (!first) cb.material(material); first = false; material = obj_material(); parse_obj_value(line, material.name); } else if (cmd == "illum") { parse_obj_value(line, material.illum); } else if (cmd == "Ke") { parse_obj_value(line, material.ke); } else if (cmd == "Kd") { parse_obj_value(line, material.kd); } else if (cmd == "Ks") { parse_obj_value(line, material.ks); } else if (cmd == "Kt") { parse_obj_value(line, material.kt); } else if (cmd == "Tf") { material.kt = {-1, -1, -1}; parse_obj_value(line, material.kt); if (material.kt.y < 0) material.kt = {material.kt.x, material.kt.x, material.kt.x}; if (fliptr) material.kt = vec3f{1, 1, 1} - material.kt; } else if (cmd == "Tr") { parse_obj_value(line, material.op); if (fliptr) material.op = 1 - material.op; } else if (cmd == "Ns") { parse_obj_value(line, material.ns); material.pr = pow(2 / (material.ns + 2), 1 / 4.0f); if (material.pr < 0.01f) material.pr = 0; if (material.pr > 0.99f) material.pr = 1; } else if (cmd == "d") { parse_obj_value(line, material.op); } else if (cmd == "map_Ke") { parse_obj_value(line, material.ke_map); } else if (cmd == "map_Kd") { parse_obj_value(line, material.kd_map); } else if (cmd == "map_Ks") { parse_obj_value(line, material.ks_map); } else if (cmd == "map_Tr") { parse_obj_value(line, material.kt_map); } else if (cmd == "map_d" || cmd == "map_Tr") { parse_obj_value(line, material.op_map); } else if (cmd == "map_bump" || cmd == "bump") { parse_obj_value(line, material.bump_map); } else if (cmd == "Pm") { material.has_pbr = true; parse_obj_value(line, material.pm); } else if (cmd == "Pr") { material.has_pbr = true; parse_obj_value(line, material.pr); } else if (cmd == "Ps") { material.has_pbr = true; parse_obj_value(line, material.ps); } else if (cmd == "Pc") { material.has_pbr = true; parse_obj_value(line, material.pc); } else if (cmd == "Pcr") { material.has_pbr = true; parse_obj_value(line, material.pcr); } else if (cmd == "map_Pm") { material.has_pbr = true; parse_obj_value(line, material.pm_map); } else if (cmd == "map_Pr") { material.has_pbr = true; parse_obj_value(line, material.pr_map); } else if (cmd == "map_Ps") { material.has_pbr = true; parse_obj_value(line, material.ps_map); } else if (cmd == "map_occ" || cmd == "occ") { parse_obj_value(line, material.occ_map); } else if (cmd == "map_disp" || cmd == "disp") { parse_obj_value(line, material.disp_map); } else if (cmd == "map_norm" || cmd == "norm") { parse_obj_value(line, material.norm_map); } else if (cmd == "Vt") { parse_obj_value(line, material.vt); } else if (cmd == "Vp") { parse_obj_value(line, material.vp); } else if (cmd == "Ve") { parse_obj_value(line, material.ve); } else if (cmd == "Vs") { parse_obj_value(line, material.vs); } else if (cmd == "Vg") { parse_obj_value(line, material.vg); } else if (cmd == "Vr") { parse_obj_value(line, material.vr); } else if (cmd == "map_Vs") { parse_obj_value(line, material.vs_map); } } // issue current material if (!first) cb.material(material); } // Load obj extensions void load_objx(const string& filename, obj_callbacks& cb) { // open file auto fs_ = open_input_file(filename); auto fs = fs_.fs; // read the file line by line char buffer[4096]; while (read_line(fs, buffer, sizeof(buffer))) { // line auto line = string_view{buffer}; remove_obj_comment(line); skip_obj_whitespace(line); if (line.empty()) continue; // get command auto cmd = ""s; parse_obj_value(line, cmd); if (cmd == "") continue; // possible token values if (cmd == "c") { auto camera = obj_camera(); parse_obj_value(line, camera.name); parse_obj_value(line, camera.ortho); parse_obj_value(line, camera.width); parse_obj_value(line, camera.height); parse_obj_value(line, camera.lens); parse_obj_value(line, camera.focus); parse_obj_value(line, camera.aperture); parse_obj_value(line, camera.frame); cb.camera(camera); } else if (cmd == "e") { auto environment = obj_environment(); parse_obj_value(line, environment.name); parse_obj_value(line, environment.ke); parse_obj_value(line, environment.ke_txt.path); parse_obj_value(line, environment.frame); if (environment.ke_txt.path == "\"\"") environment.ke_txt.path = ""; cb.environmnet(environment); } else if (cmd == "i") { auto instance = obj_instance(); parse_obj_value(line, instance.name); parse_obj_value(line, instance.object); parse_obj_value(line, instance.material); parse_obj_value(line, instance.frame); cb.instance(instance); } else if (cmd == "po") { auto procedural = obj_procedural(); parse_obj_value(line, procedural.name); parse_obj_value(line, procedural.type); parse_obj_value(line, procedural.material); parse_obj_value(line, procedural.size); parse_obj_value(line, procedural.level); parse_obj_value(line, procedural.frame); cb.procedural(procedural); } else { // unused } } } // Load obj scene void load_obj(const string& filename, obj_callbacks& cb, bool nomaterials, bool flipv, bool fliptr) { // open file auto fs_ = open_input_file(filename); auto fs = fs_.fs; // track vertex size auto vert_size = obj_vertex(); auto verts = vector(); // buffer to avoid reallocation // material libraries read already auto mlibs = vector{}; // read the file line by line char buffer[4096]; while (read_line(fs, buffer, sizeof(buffer))) { // line auto line = string_view{buffer}; remove_obj_comment(line); skip_obj_whitespace(line); if (line.empty()) continue; // get command auto cmd = ""s; parse_obj_value(line, cmd); if (cmd == "") continue; // possible token values if (cmd == "v") { auto vert = zero3f; parse_obj_value(line, vert); cb.vert(vert); vert_size.position += 1; } else if (cmd == "vn") { auto vert = zero3f; parse_obj_value(line, vert); cb.norm(vert); vert_size.normal += 1; } else if (cmd == "vt") { auto vert = zero2f; parse_obj_value(line, vert); if (flipv) vert.y = 1 - vert.y; cb.texcoord(vert); vert_size.texcoord += 1; } else if (cmd == "f" || cmd == "l" || cmd == "p") { verts.clear(); skip_obj_whitespace(line); while (!line.empty()) { auto vert = obj_vertex{}; parse_obj_value(line, vert); if (!vert.position) break; if (vert.position < 0) vert.position = vert_size.position + vert.position + 1; if (vert.texcoord < 0) vert.texcoord = vert_size.texcoord + vert.texcoord + 1; if (vert.normal < 0) vert.normal = vert_size.normal + vert.normal + 1; verts.push_back(vert); skip_obj_whitespace(line); } if (cmd == "f") cb.face(verts); if (cmd == "l") cb.line(verts); if (cmd == "p") cb.point(verts); } else if (cmd == "o") { auto name = ""s; parse_obj_value_or_empty(line, name); cb.object(name); } else if (cmd == "usemtl") { auto name = ""s; parse_obj_value_or_empty(line, name); cb.usemtl(name); } else if (cmd == "g") { auto name = ""s; parse_obj_value_or_empty(line, name); cb.group(name); } else if (cmd == "s") { auto name = ""s; parse_obj_value_or_empty(line, name); cb.smoothing(name); } else if (cmd == "mtllib") { if (nomaterials) continue; auto mtlname = ""s; parse_obj_value(line, mtlname); cb.mtllib(mtlname); if (std::find(mlibs.begin(), mlibs.end(), mtlname) != mlibs.end()) continue; mlibs.push_back(mtlname); auto mtlpath = fs::path(filename).parent_path() / mtlname; load_mtl(mtlpath, cb, fliptr); } else { // unused } } // parse extensions if presents if (!nomaterials) { auto extname = fs::path(filename).replace_extension(".objx"); auto ext_exists = exists_file(extname); if (ext_exists) { load_objx(extname, cb); } } } } // namespace yocto goxel-0.11.0/ext_src/yocto/yocto_obj.h000066400000000000000000000175441435762723100177000ustar00rootroot00000000000000// // # Yocto/OBJ: Tiny library for OBJ parsing // // Yocto/OBJ is a simple Wavefront OBJ parser that works with callbacks. // We make no attempt to provide a simple interface for OBJ but just the // low level parsing code. We support a few extensions such as camera and // environment map loading. // // Error reporting is done through exceptions using the `io_error` exception. // // ## Parse an OBJ file // // 1. define callbacks in `obj_callback` structure using lambda with capture // if desired // 2. run the parse with `load_obj()` // // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // #ifndef _YOCTO_OBJ_H_ #define _YOCTO_OBJ_H_ // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include "yocto_math.h" // ----------------------------------------------------------------------------- // SIMPLE OBJ LOADER // ----------------------------------------------------------------------------- namespace yocto { // OBJ vertex struct obj_vertex { int position = 0; int texcoord = 0; int normal = 0; }; inline bool operator==(const obj_vertex& a, const obj_vertex& b) { return a.position == b.position && a.texcoord == b.texcoord && a.normal == b.normal; } // Obj texture information. struct obj_texture_info { string path = ""; // file path bool clamp = false; // clamp to edge float scale = 1; // scale for bump/displacement // Properties not explicitly handled. unordered_map> props; obj_texture_info() {} obj_texture_info(const char* path) : path{path} {} obj_texture_info(const string& path) : path{path} {} }; // Obj material. struct obj_material { string name = ""; // name int illum = 0; // MTL illum mode // base values vec3f ke = {0, 0, 0}; // emission color vec3f ka = {0, 0, 0}; // ambient color vec3f kd = {0, 0, 0}; // diffuse color vec3f ks = {0, 0, 0}; // specular color vec3f kr = {0, 0, 0}; // reflection color vec3f kt = {0, 0, 0}; // transmission color float ns = 0; // Phong exponent color float ior = 1; // index of refraction float op = 1; // opacity // textures obj_texture_info ke_map = ""; // emission texture obj_texture_info ka_map = ""; // ambient texture obj_texture_info kd_map = ""; // diffuse texture obj_texture_info ks_map = ""; // specular texture obj_texture_info kr_map = ""; // reflection texture obj_texture_info kt_map = ""; // transmission texture obj_texture_info ns_map = ""; // Phong exponent texture obj_texture_info op_map = ""; // opacity texture obj_texture_info ior_map = ""; // ior texture obj_texture_info bump_map = ""; // bump map // pbr values bool has_pbr = false; // whether pbr values are defined float pr = 0; // roughness float pm = 0; // metallic float ps = 0; // sheen float pc = 0; // coat float pcr = 0; // coat roughness // textures obj_texture_info pr_map = ""; // roughness texture obj_texture_info pm_map = ""; // metallic texture obj_texture_info ps_map = ""; // sheen texture obj_texture_info norm_map = ""; // normal map obj_texture_info disp_map = ""; // displacement map obj_texture_info occ_map = ""; // occlusion map // volume values vec3f vt = {0, 0, 0}; // volumetric transmission vec3f vp = {0, 0, 0}; // volumetric mean-free-path vec3f ve = {0, 0, 0}; // volumetric emission vec3f vs = {0, 0, 0}; // volumetric scattering float vg = 0; // volumetric anisotropy (phase g) float vr = 0.01; // volumetric scale // textures obj_texture_info vs_map = ""; // scattering texture // Properties not explicitly handled. unordered_map> props; }; // Obj camera [extension]. struct obj_camera { string name = ""; // name frame3f frame = identity3x4f; // transform bool ortho = false; // orthographic float width = 0.036f; // film size (default to 35mm) float height = 0.024f; // film size (default to 35mm) float lens = 0.050f; // focal length float aperture = 0; // lens aperture float focus = flt_max; // focus distance }; // Obj environment [extension]. struct obj_environment { string name = ""; // name frame3f frame = identity3x4f; // transform vec3f ke = zero3f; // emission color obj_texture_info ke_txt; // emission texture }; // Obj procedural object [extension]. struct obj_procedural { string name = ""; // name frame3f frame = identity3x4f; // transform string type = ""; // type string material = ""; // material float size = 2; // size int level = -1; // level of subdivision (-1 default) }; // Obj instance [extension] struct obj_instance { string name = ""; // name frame3f frame = identity3x4f; // transform string object = ""; // object name string material = ""; // material name }; // Obj callbacks struct obj_callbacks { virtual void vert(const vec3f&) {} virtual void norm(const vec3f&) {} virtual void texcoord(const vec2f&) {} virtual void face(const vector&) {} virtual void line(const vector&) {} virtual void point(const vector&) {} virtual void object(const string&) {} virtual void group(const string&) {} virtual void usemtl(const string&) {} virtual void smoothing(const string&) {} virtual void mtllib(const string&) {} virtual void material(const obj_material&) {} virtual void camera(const obj_camera&) {} virtual void environmnet(const obj_environment&) {} virtual void instance(const obj_instance&) {} virtual void procedural(const obj_procedural&) {} }; // Load obj scene void load_obj(const string& filename, obj_callbacks& cb, bool nomaterials = false, bool flipv = true, bool fliptr = true); } // namespace yocto // ----------------------------------------------------------------------------- // HELPER FOR DICTIONARIES // ----------------------------------------------------------------------------- namespace std { // Hash functor for vector for use with unordered_map template <> struct hash { size_t operator()(const yocto::obj_vertex& v) const { static const std::hash hasher = std::hash(); auto h = (size_t)0; h ^= hasher(v.position) + 0x9e3779b9 + (h << 6) + (h >> 2); h ^= hasher(v.normal) + 0x9e3779b9 + (h << 6) + (h >> 2); h ^= hasher(v.texcoord) + 0x9e3779b9 + (h << 6) + (h >> 2); return h; } }; } // namespace std #endif goxel-0.11.0/ext_src/yocto/yocto_pbrt.cpp000066400000000000000000003270421435762723100204250ustar00rootroot00000000000000// // Implementation for Yocto/Pbrt // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include "yocto_pbrt.h" #include "yocto_image.h" #include #include #include "ext/filesystem.hpp" namespace fs = ghc::filesystem; // ----------------------------------------------------------------------------- // IMPLEMENTATION OF LOW LEVEL PARSING // ----------------------------------------------------------------------------- namespace yocto { // Type aliases for readability using string_view = std::string_view; using namespace std::literals::string_view_literals; // Token stream struct pbrt_stream { string buffer; string_view str; string_view saved; }; // skip white space or comment static inline void skip_whitespace_or_comment(pbrt_stream& stream) { auto& str = stream.str; if (str.empty()) return; while (!str.empty() && (isspace(str.front()) || str.front() == '#' || str.front() == ',')) { if (str.front() == '#') { auto pos = str.find('\n'); if (pos != string_view::npos) { str.remove_prefix(pos); } else { str.remove_prefix(str.length()); } } else { auto pos = str.find_first_not_of(" \t\n\r,"); if (pos == string_view::npos) { str.remove_prefix(str.length()); } else { str.remove_prefix(pos); } } } } // parse a quoted string static inline void parse_value(pbrt_stream& stream, string& value) { skip_whitespace_or_comment(stream); auto& str = stream.str; if (str.front() != '"') { throw std::runtime_error("bad string"); } str.remove_prefix(1); auto pos = str.find('"'); if (pos == string_view::npos) { throw std::runtime_error("bad string"); } value.assign(str.substr(0, pos)); str.remove_prefix(pos + 1); } // parse a quoted string static inline void parse_command(pbrt_stream& stream, string& value) { skip_whitespace_or_comment(stream); auto& str = stream.str; if (!isalpha((int)str.front())) { throw std::runtime_error("bad command"); } auto pos = str.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); if (pos == string_view::npos) { value.assign(str); str.remove_prefix(str.size()); } else { value.assign(str.substr(0, pos)); str.remove_prefix(pos + 1); } } // parse a number static inline void parse_value(pbrt_stream& stream, float& value) { skip_whitespace_or_comment(stream); auto& str = stream.str; if (str.empty()) throw std::runtime_error("number expected"); auto next = (char*)nullptr; value = strtof(str.data(), &next); if (str.data() == next) throw std::runtime_error("number expected"); str.remove_prefix(next - str.data()); } // parse a number static inline void parse_value(pbrt_stream& stream, int& value) { skip_whitespace_or_comment(stream); auto& str = stream.str; if (str.empty()) throw std::runtime_error("number expected"); auto next = (char*)nullptr; value = strtol(str.data(), &next, 10); if (str.data() == next) throw std::runtime_error("number expected"); str.remove_prefix(next - str.data()); } static inline void parse_value(pbrt_stream& stream, bool& value) { auto value_name = ""s; parse_value(stream, value_name); if (value_name == "true") { value = true; } else if (value_name == "false") { value = false; } else { throw std::runtime_error("expected boolean"); } } template static inline void parse_value( pbrt_stream& stream, T& value, unordered_map& value_names) { auto value_name = ""s; parse_value(stream, value_name); try { value = value_names.at(value_name); } catch (std::out_of_range&) { throw std::runtime_error("expected enum value"); } } static inline void parse_value( pbrt_stream& stream, pbrt_texture::bilerp_t::mapping_type& value) { static auto value_names = unordered_map{ {"uv", pbrt_texture::bilerp_t::mapping_type::uv}, {"spherical", pbrt_texture::bilerp_t::mapping_type::spherical}, {"cylindrical", pbrt_texture::bilerp_t::mapping_type::cylindrical}, {"planar", pbrt_texture::bilerp_t::mapping_type::planar}, }; return parse_value(stream, value, value_names); } static inline void parse_value( pbrt_stream& stream, pbrt_texture::checkerboard_t::mapping_type& value) { return parse_value(stream, (pbrt_texture::bilerp_t::mapping_type&)value); } static inline void parse_value( pbrt_stream& stream, pbrt_texture::dots_t::mapping_type& value) { return parse_value(stream, (pbrt_texture::bilerp_t::mapping_type&)value); } static inline void parse_value( pbrt_stream& stream, pbrt_texture::imagemap_t::mapping_type& value) { return parse_value(stream, (pbrt_texture::bilerp_t::mapping_type&)value); } static inline void parse_value( pbrt_stream& stream, pbrt_texture::uv_t::mapping_type& value) { return parse_value(stream, (pbrt_texture::bilerp_t::mapping_type&)value); } static inline void parse_value( pbrt_stream& stream, pbrt_texture::checkerboard_t::aamode_type& value) { static auto value_names = unordered_map{ {"closedform", pbrt_texture::checkerboard_t::aamode_type::closedform}, {"none", pbrt_texture::checkerboard_t::aamode_type::none}, }; return parse_value(stream, value, value_names); } static inline void parse_value( pbrt_stream& stream, pbrt_texture::imagemap_t::wrap_type& value) { static auto value_names = unordered_map{ {"repeat", pbrt_texture::imagemap_t::wrap_type::repeat}, {"clamp", pbrt_texture::imagemap_t::wrap_type::clamp}, {"black", pbrt_texture::imagemap_t::wrap_type::black}, }; return parse_value(stream, value, value_names); } static inline void parse_value( pbrt_stream& stream, pbrt_shape::curve_t::basis_t& value) { static auto value_names = unordered_map{ {"bezier", pbrt_shape::curve_t::basis_t::bezier}, {"bspline", pbrt_shape::curve_t::basis_t::bspline}, }; return parse_value(stream, value, value_names); } static inline void parse_value( pbrt_stream& stream, pbrt_shape::curve_t::type_t& value) { static auto value_names = unordered_map{ {"flat", pbrt_shape::curve_t::type_t::flat}, {"cylinder", pbrt_shape::curve_t::type_t::cylinder}, {"ribbon", pbrt_shape::curve_t::type_t::ribbon}, }; return parse_value(stream, value, value_names); } static inline void parse_value( pbrt_stream& stream, pbrt_accelerator::bvh_t::splitmethod_t& value) { static auto value_names = unordered_map{ {"sah", pbrt_accelerator::bvh_t::splitmethod_t::sah}, {"equal", pbrt_accelerator::bvh_t::splitmethod_t::equal}, {"middle", pbrt_accelerator::bvh_t::splitmethod_t::middle}, {"hlbvh", pbrt_accelerator::bvh_t::splitmethod_t::hlbvh}, }; return parse_value(stream, value, value_names); } static inline void parse_value(pbrt_stream& stream, pbrt_integrator::path_t::lightsamplestrategy_t& value) { static auto value_names = unordered_map{ {"power", pbrt_integrator::path_t::lightsamplestrategy_t::power}, {"spatial", pbrt_integrator::path_t::lightsamplestrategy_t::spatial}, {"uniform", pbrt_integrator::path_t::lightsamplestrategy_t::uniform}, }; return parse_value(stream, value, value_names); } static inline void parse_value(pbrt_stream& stream, pbrt_integrator::volpath_t::lightsamplestrategy_t& value) { return parse_value( stream, (pbrt_integrator::path_t::lightsamplestrategy_t&)value); } static inline void parse_value(pbrt_stream& stream, pbrt_integrator::bdpt_t::lightsamplestrategy_t& value) { return parse_value( stream, (pbrt_integrator::path_t::lightsamplestrategy_t&)value); } static inline void parse_value( pbrt_stream& stream, pbrt_integrator::directlighting_t::strategy_t& value) { static auto value_names = unordered_map{ {"all", pbrt_integrator::directlighting_t::strategy_t::all}, {"one", pbrt_integrator::directlighting_t::strategy_t::one}, }; return parse_value(stream, value, value_names); } // parse a vec type static inline void parse_value(pbrt_stream& stream, vec2f& value) { for (auto i = 0; i < 2; i++) parse_value(stream, value[i]); } static inline void parse_value(pbrt_stream& stream, vec3f& value) { for (auto i = 0; i < 3; i++) parse_value(stream, value[i]); } static inline void parse_value(pbrt_stream& stream, vec4f& value) { for (auto i = 0; i < 4; i++) parse_value(stream, value[i]); } static inline void parse_value(pbrt_stream& stream, vec3i& value) { for (auto i = 0; i < 3; i++) parse_value(stream, value[i]); } static inline void parse_value(pbrt_stream& stream, vec4i& value) { for (auto i = 0; i < 4; i++) parse_value(stream, value[i]); } static inline void parse_value(pbrt_stream& stream, mat4f& value) { for (auto i = 0; i < 4; i++) parse_value(stream, value[i]); } static inline void parse_value(pbrt_stream& stream, pbrt_spectrum3f& value) { for (auto i = 0; i < 3; i++) parse_value(stream, value[i]); } // Check next static inline bool is_empty(pbrt_stream& stream) { skip_whitespace_or_comment(stream); return stream.str.empty(); } static inline bool is_string(pbrt_stream& stream) { skip_whitespace_or_comment(stream); return !stream.str.empty() && stream.str.front() == '"'; } static inline bool is_open_bracket(pbrt_stream& stream) { skip_whitespace_or_comment(stream); return !stream.str.empty() && stream.str.front() == '['; } static inline bool is_close_bracket(pbrt_stream& stream) { skip_whitespace_or_comment(stream); return !stream.str.empty() && stream.str.front() == ']'; } static inline bool is_param(pbrt_stream& stream) { skip_whitespace_or_comment(stream); return is_string(stream); } // parse a quoted string static inline void parse_nametype( pbrt_stream& stream, string& name, string& type) { auto value = ""s; parse_value(stream, value); auto str = string_view{value}; auto pos1 = str.find(' '); if (pos1 == string_view::npos) { throw std::runtime_error("bad type " + value); } type = string(str.substr(0, pos1)); str.remove_prefix(pos1); auto pos2 = str.find_first_not_of(' '); if (pos2 == string_view::npos) { throw std::runtime_error("bad type " + value); } str.remove_prefix(pos2); name = string(str); } static inline void skip_open_bracket(pbrt_stream& stream) { if (!is_open_bracket(stream)) throw std::runtime_error("expected bracket"); stream.str.remove_prefix(1); skip_whitespace_or_comment(stream); } static inline void skip_close_bracket(pbrt_stream& stream) { if (!is_close_bracket(stream)) throw std::runtime_error("expected bracket"); stream.str.remove_prefix(1); skip_whitespace_or_comment(stream); } template static inline void parse_param(pbrt_stream& stream, T& value) { auto has_brackets = is_open_bracket(stream); if (has_brackets) skip_open_bracket(stream); parse_value(stream, value); if (has_brackets) skip_close_bracket(stream); } template static inline void parse_param(pbrt_stream& stream, vector& values) { skip_open_bracket(stream); values.clear(); while (!is_close_bracket(stream)) { values.push_back({}); parse_value(stream, values.back()); } skip_close_bracket(stream); } template static inline bool is_type_compatible(const string& type) { if constexpr (std::is_same::value) { return type == "integer"; } else if constexpr (std::is_same::value) { return type == "float"; } else if constexpr (std::is_same::value) { return type == "bool"; } else if constexpr (std::is_same::value) { return type == "string"; } else if constexpr (std::is_same::value) { return type == "point2" || type == "vector2" || type == "float"; } else if constexpr (std::is_same::value) { return type == "point3" || type == "vector3" || type == "normal3" || type == "point" || type == "vector" || type == "normal" || type == "float"; } else if constexpr (std::is_same::value) { return type == "float"; } else if constexpr (std::is_same::value) { return type == "rgb" || type == "pbrt_spectrum" || type == "blackbody"; } else if constexpr (std::is_same::value) { return type == "integer"; } else if constexpr (std::is_same::value) { return type == "integer"; } else if constexpr (std::is_same::value) { return type == "float"; } else if constexpr (std::is_enum::value) { return type == "string"; } else { return false; } } template static inline void parse_param( pbrt_stream& stream, const string& type, T& value) { if (!is_type_compatible(type)) { throw std::runtime_error("incompatible type " + type); } parse_param(stream, value); } static inline pair get_pbrt_etak(const string& name) { static const unordered_map> metal_ior_table = { {"a-C", {{2.9440999183f, 2.2271502925f, 1.9681668794f}, {0.8874329109f, 0.7993216383f, 0.8152862927f}}}, {"Ag", {{0.1552646489f, 0.1167232965f, 0.1383806959f}, {4.8283433224f, 3.1222459278f, 2.1469504455f}}}, {"Al", {{1.6574599595f, 0.8803689579f, 0.5212287346f}, {9.2238691996f, 6.2695232477f, 4.8370012281f}}}, {"AlAs", {{3.6051023902f, 3.2329365777f, 2.2175611545f}, {0.0006670247f, -0.0004999400f, 0.0074261204f}}}, {"AlSb", {{-0.0485225705f, 4.1427547893f, 4.6697691348f}, {-0.0363741915f, 0.0937665154f, 1.3007390124f}}}, {"Au", {{0.1431189557f, 0.3749570432f, 1.4424785571f}, {3.9831604247f, 2.3857207478f, 1.6032152899f}}}, {"Be", {{4.1850592788f, 3.1850604423f, 2.7840913457f}, {3.8354398268f, 3.0101260162f, 2.8690088743f}}}, {"Cr", {{4.3696828663f, 2.9167024892f, 1.6547005413f}, {5.2064337956f, 4.2313645277f, 3.7549467933f}}}, {"CsI", {{2.1449030413f, 1.7023164587f, 1.6624194173f}, {0.0000000000f, 0.0000000000f, 0.0000000000f}}}, {"Cu", {{0.2004376970f, 0.9240334304f, 1.1022119527f}, {3.9129485033f, 2.4528477015f, 2.1421879552f}}}, {"Cu2O", {{3.5492833755f, 2.9520622449f, 2.7369202137f}, {0.1132179294f, 0.1946659670f, 0.6001681264f}}}, {"CuO", {{3.2453822204f, 2.4496293965f, 2.1974114493f}, {0.5202739621f, 0.5707372756f, 0.7172250613f}}}, {"d-C", {{2.7112524747f, 2.3185812849f, 2.2288565009f}, {0.0000000000f, 0.0000000000f, 0.0000000000f}}}, {"Hg", {{2.3989314904f, 1.4400254917f, 0.9095512090f}, {6.3276269444f, 4.3719414152f, 3.4217899270f}}}, {"HgTe", {{4.7795267752f, 3.2309984581f, 2.6600252401f}, {1.6319827058f, 1.5808189339f, 1.7295753852f}}}, {"Ir", {{3.0864098394f, 2.0821938440f, 1.6178866805f}, {5.5921510077f, 4.0671757150f, 3.2672611269f}}}, {"K", {{0.0640493070f, 0.0464100621f, 0.0381842017f}, {2.1042155920f, 1.3489364357f, 0.9132113889f}}}, {"Li", {{0.2657871942f, 0.1956102432f, 0.2209198538f}, {3.5401743407f, 2.3111306542f, 1.6685930000f}}}, {"MgO", {{2.0895885542f, 1.6507224525f, 1.5948759692f}, {0.0000000000f, -0.0000000000f, 0.0000000000f}}}, {"Mo", {{4.4837010280f, 3.5254578255f, 2.7760769438f}, {4.1111307988f, 3.4208716252f, 3.1506031404f}}}, {"Na", {{0.0602665320f, 0.0561412435f, 0.0619909494f}, {3.1792906496f, 2.1124800781f, 1.5790940266f}}}, {"Nb", {{3.4201353595f, 2.7901921379f, 2.3955856658f}, {3.4413817900f, 2.7376437930f, 2.5799132708f}}}, {"Ni", {{2.3672753521f, 1.6633583302f, 1.4670554172f}, {4.4988329911f, 3.0501643957f, 2.3454274399f}}}, {"Rh", {{2.5857954933f, 1.8601866068f, 1.5544279524f}, {6.7822927110f, 4.7029501026f, 3.9760892461f}}}, {"Se-e", {{5.7242724833f, 4.1653992967f, 4.0816099264f}, {0.8713747439f, 1.1052845009f, 1.5647788766f}}}, {"Se", {{4.0592611085f, 2.8426947380f, 2.8207582835f}, {0.7543791750f, 0.6385150558f, 0.5215872029f}}}, {"SiC", {{3.1723450205f, 2.5259677964f, 2.4793623897f}, {0.0000007284f, -0.0000006859f, 0.0000100150f}}}, {"SnTe", {{4.5251865890f, 1.9811525984f, 1.2816819226f}, {0.0000000000f, 0.0000000000f, 0.0000000000f}}}, {"Ta", {{2.0625846607f, 2.3930915569f, 2.6280684948f}, {2.4080467973f, 1.7413705864f, 1.9470377016f}}}, {"Te-e", {{7.5090397678f, 4.2964603080f, 2.3698732430f}, {5.5842076830f, 4.9476231084f, 3.9975145063f}}}, {"Te", {{7.3908396088f, 4.4821028985f, 2.6370708478f}, {3.2561412892f, 3.5273908133f, 3.2921683116f}}}, {"ThF4", {{1.8307187117f, 1.4422274283f, 1.3876488528f}, {0.0000000000f, 0.0000000000f, 0.0000000000f}}}, {"TiC", {{3.7004673762f, 2.8374356509f, 2.5823030278f}, {3.2656905818f, 2.3515586388f, 2.1727857800f}}}, {"TiN", {{1.6484691607f, 1.1504482522f, 1.3797795097f}, {3.3684596226f, 1.9434888540f, 1.1020123347f}}}, {"TiO2-e", {{3.1065574823f, 2.5131551146f, 2.5823844157f}, {0.0000289537f, -0.0000251484f, 0.0001775555f}}}, {"TiO2", {{3.4566203131f, 2.8017076558f, 2.9051485020f}, {0.0001026662f, -0.0000897534f, 0.0006356902f}}}, {"VC", {{3.6575665991f, 2.7527298065f, 2.5326814570f}, {3.0683516659f, 2.1986687713f, 1.9631816252f}}}, {"VN", {{2.8656011588f, 2.1191817791f, 1.9400767149f}, {3.0323264950f, 2.0561075580f, 1.6162930914f}}}, {"V", {{4.2775126218f, 3.5131538236f, 2.7611257461f}, {3.4911844504f, 2.8893580874f, 3.1116965117f}}}, {"W", {{4.3707029924f, 3.3002972445f, 2.9982666528f}, {3.5006778591f, 2.6048652781f, 2.2731930614f}}}, }; return metal_ior_table.at(name); } static inline void parse_param( pbrt_stream& stream, const string& type, pbrt_spectrum3f& value) { bool verbose = false; if (type == "rgb") { parse_param(stream, value); } else if (type == "color") { parse_param(stream, value); } else if (type == "float") { auto valuef = 0.0f; parse_param(stream, valuef); value = {valuef, valuef, valuef}; } else if (type == "blackbody") { auto blackbody = zero2f; parse_param(stream, blackbody); (vec3f&)value = blackbody_to_rgb(blackbody.x) * blackbody.y; } else if (type == "spectrum" && is_string(stream)) { if (verbose) printf("spectrum not well supported\n"); auto filename = ""s; parse_param(stream, filename); auto filenamep = fs::path(filename).filename(); if (filenamep.extension() == ".spd") { filenamep = filenamep.replace_extension(""); if (filenamep == "SHPS") { value = {1, 1, 1}; } else if (filenamep.extension() == ".eta") { auto eta = get_pbrt_etak(filenamep.replace_extension("")).first; value = {eta.x, eta.y, eta.z}; } else if (filenamep.extension() == ".k") { auto k = get_pbrt_etak(filenamep.replace_extension("")).second; value = {k.x, k.y, k.z}; } else { throw std::runtime_error("unknown spectrum file " + filename); } } else { throw std::runtime_error("unsupported spectrum format"); // value = {1, 0, 0}; } } else if (type == "spectrum" && !is_string(stream)) { if (verbose) printf("spectrum not well supported\n"); auto values = vector{}; parse_param(stream, values); value = {1, 0, 0}; } else { throw std::runtime_error("unsupported spectrum type"); } } template static inline void parse_param( pbrt_stream& stream, const string& type, vector& value) { if (!is_type_compatible(type)) { throw std::runtime_error("incompatible type " + type); } parse_param(stream, value); } static inline void parse_param( pbrt_stream& stream, const string& type, pbrt_textured3f& value) { if (type == "texture") { parse_param(stream, value.texture); } else { parse_param(stream, type, value.value); } } static inline void parse_param( pbrt_stream& stream, const string& type, pbrt_textured1f& value) { if (type == "texture") { parse_param(stream, value.texture); } else { parse_param(stream, type, value.value); } } static inline void skip_value(pbrt_stream& stream) { skip_whitespace_or_comment(stream); auto& str = stream.str; if (str.front() == '"') { str.remove_prefix(1); str.remove_prefix(str.find('"') + 1); } else { str.remove_prefix(str.find_first_of(" \n\t\r],\"")); } skip_whitespace_or_comment(stream); } static inline void skip_param(pbrt_stream& stream) { if (is_open_bracket(stream)) { skip_open_bracket(stream); while (!is_close_bracket(stream)) skip_value(stream); skip_close_bracket(stream); } else { skip_value(stream); } } static inline void save_stream_position(pbrt_stream& stream) { stream.saved = stream.str; } static inline void restore_stream_position(pbrt_stream& stream) { stream.str = stream.saved; } // Load a text file static inline void load_text(const string& filename, string& str) { // https://stackoverflow.com/questions/174531/how-to-read-the-content-of-a-file-to-a-string-in-c auto fs = fopen(filename.c_str(), "rt"); if (!fs) throw std::runtime_error("cannot open file " + filename); fseek(fs, 0, SEEK_END); auto length = ftell(fs); fseek(fs, 0, SEEK_SET); str.resize(length); if (fread(str.data(), 1, length, fs) != length) { fclose(fs); throw std::runtime_error("cannot read file " + filename); } fclose(fs); } // Load a token stream static inline void load_stream(const string& filename, pbrt_stream& stream) { load_text(filename, stream.buffer); stream.str = stream.buffer; } // operations on token stacks static inline void init_stream(vector& stream) { stream.reserve(100); } static inline void load_stream( const string& filename, vector& stream) { stream.emplace_back(); load_stream(filename, stream.back()); } // Skip whitespace static inline void skip_whitespace_or_comment_to_next_file( vector& stream) { if (stream.empty()) return; while (!stream.empty()) { skip_whitespace_or_comment(stream.back()); if (is_empty(stream.back())) { stream.pop_back(); } else { break; } } } } // namespace yocto // ----------------------------------------------------------------------------- // PBRT CONVERSION // ----------------------------------------------------------------------------- namespace yocto { // Parse Accelerator static inline void parse_accelerator( pbrt_stream& stream, const string& type, pbrt_accelerator& value) { auto pname = ""s, ptype = ""s; if (type == "bvh") { auto tvalue = pbrt_accelerator::bvh_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "maxnodeprims") { parse_param(stream, ptype, tvalue.maxnodeprims); } else if (pname == "splitmethod") { parse_param(stream, ptype, tvalue.splitmethod); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_accelerator::type_t::bvh; value.bvh = tvalue; } else if (type == "kdtree") { auto tvalue = pbrt_accelerator::kdtree_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "intersectcost") { parse_param(stream, ptype, tvalue.intersectcost); } else if (pname == "traversalcost") { parse_param(stream, ptype, tvalue.traversalcost); } else if (pname == "emptybonus") { parse_param(stream, ptype, tvalue.emptybonus); } else if (pname == "maxprims") { parse_param(stream, ptype, tvalue.maxprims); } else if (pname == "maxdepth") { parse_param(stream, ptype, tvalue.maxdepth); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_accelerator::type_t::kdtree; value.kdtree = tvalue; } else { throw std::runtime_error("unknown Accelerator " + type); } } // Parse Integrator static inline void parse_integrator( pbrt_stream& stream, const string& type, pbrt_integrator& value) { auto pname = ""s, ptype = ""s; if (type == "path") { auto tvalue = pbrt_integrator::path_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "maxdepth") { parse_param(stream, ptype, tvalue.maxdepth); } else if (pname == "pixelbounds") { parse_param(stream, ptype, tvalue.pixelbounds); } else if (pname == "rrthreshold") { parse_param(stream, ptype, tvalue.rrthreshold); } else if (pname == "lightsamplestrategy") { parse_param(stream, ptype, tvalue.lightsamplestrategy); } else { throw std::runtime_error("unknown parameter " + pname); } // parse_optional_param(stream, "lightsamplestrategy", // tvalue.lightsamplestrategy); // TODO: enums } value.type = pbrt_integrator::type_t::path; value.path = tvalue; } else if (type == "volpath") { auto tvalue = pbrt_integrator::volpath_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "maxdepth") { parse_param(stream, ptype, tvalue.maxdepth); } else if (pname == "pixelbounds") { parse_param(stream, ptype, tvalue.pixelbounds); } else if (pname == "rrthreshold") { parse_param(stream, ptype, tvalue.rrthreshold); } else if (pname == "lightsamplestrategy") { parse_param(stream, ptype, tvalue.lightsamplestrategy); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_integrator::type_t::volpath; value.volpath = tvalue; } else if (type == "directlighting") { auto tvalue = pbrt_integrator::directlighting_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "maxdepth") { parse_param(stream, ptype, tvalue.maxdepth); } else if (pname == "pixelbounds") { parse_param(stream, ptype, tvalue.pixelbounds); } else if (pname == "strategy") { parse_param(stream, ptype, tvalue.strategy); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_integrator::type_t::directlighting; value.directlighting = tvalue; } else if (type == "bdpt") { auto tvalue = pbrt_integrator::bdpt_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "maxdepth") { parse_param(stream, ptype, tvalue.maxdepth); } else if (pname == "pixelbounds") { parse_param(stream, ptype, tvalue.pixelbounds); } else if (pname == "lightsamplestrategy") { parse_param(stream, ptype, tvalue.lightsamplestrategy); } else if (pname == "visualizestrategies") { parse_param(stream, ptype, tvalue.visualizestrategies); } else if (pname == "visualizeweights") { parse_param(stream, ptype, tvalue.visualizeweights); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_integrator::type_t::bdpt; value.bdpt = tvalue; } else if (type == "mlt") { auto tvalue = pbrt_integrator::mlt_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "maxdepth") { parse_param(stream, ptype, tvalue.maxdepth); } else if (pname == "pixelbounds") { parse_param(stream, ptype, tvalue.pixelbounds); } else if (pname == "bootstrapsamples") { parse_param(stream, ptype, tvalue.bootstrapsamples); } else if (pname == "chains") { parse_param(stream, ptype, tvalue.chains); } else if (pname == "mutationsperpixel") { parse_param(stream, ptype, tvalue.mutationsperpixel); } else if (pname == "largestepprobability") { parse_param(stream, ptype, tvalue.largestepprobability); } else if (pname == "sigma") { parse_param(stream, ptype, tvalue.sigma); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_integrator::type_t::mlt; value.mlt = tvalue; } else if (type == "sppm") { auto tvalue = pbrt_integrator::sppm_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "maxdepth") { parse_param(stream, ptype, tvalue.maxdepth); } else if (pname == "pixelbounds") { parse_param(stream, ptype, tvalue.pixelbounds); } else if (pname == "iterations") { parse_param(stream, ptype, tvalue.iterations); } else if (pname == "numiterations") { parse_param(stream, ptype, tvalue.iterations); } else if (pname == "photonsperiteration") { parse_param(stream, ptype, tvalue.photonsperiteration); } else if (pname == "imagewritefrequency") { parse_param(stream, ptype, tvalue.imagewritefrequency); } else if (pname == "radius") { parse_param(stream, ptype, tvalue.radius); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_integrator::type_t::sppm; value.sppm = tvalue; } else if (type == "whitted") { auto tvalue = pbrt_integrator::whitted_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "maxdepth") { parse_param(stream, ptype, tvalue.maxdepth); } else if (pname == "pixelbounds") { parse_param(stream, ptype, tvalue.pixelbounds); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_integrator::type_t::whitted; value.whitted = tvalue; } else { throw std::runtime_error("unknown Integrator " + type); } } // Parse Sampler static inline void parse_sampler( pbrt_stream& stream, const string& type, pbrt_sampler& value) { auto pname = ""s, ptype = ""s; if (type == "random") { auto tvalue = pbrt_sampler::random_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "pixelsamples") { parse_param(stream, ptype, tvalue.pixelsamples); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_sampler::type_t::random; value.random = tvalue; } else if (type == "halton") { auto tvalue = pbrt_sampler::halton_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "pixelsamples") { parse_param(stream, ptype, tvalue.pixelsamples); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_sampler::type_t::halton; value.halton = tvalue; } else if (type == "sobol") { auto tvalue = pbrt_sampler::sobol_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "pixelsamples") { parse_param(stream, ptype, tvalue.pixelsamples); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_sampler::type_t::sobol; value.sobol = tvalue; } else if (type == "02sequence") { auto tvalue = pbrt_sampler::zerotwosequence_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "pixelsamples") { parse_param(stream, ptype, tvalue.pixelsamples); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_sampler::type_t::zerotwosequence; value.zerotwosequence = tvalue; } else if (type == "lowdiscrepancy") { auto tvalue = pbrt_sampler::zerotwosequence_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "pixelsamples") { parse_param(stream, ptype, tvalue.pixelsamples); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_sampler::type_t::zerotwosequence; value.zerotwosequence = tvalue; } else if (type == "maxmindist") { auto tvalue = pbrt_sampler::maxmindist_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "pixelsamples") { parse_param(stream, ptype, tvalue.pixelsamples); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_sampler::type_t::maxmindist; value.maxmindist = tvalue; } else if (type == "stratified") { auto tvalue = pbrt_sampler::stratified_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "xsamples") { parse_param(stream, ptype, tvalue.xsamples); } else if (pname == "ysamples") { parse_param(stream, ptype, tvalue.ysamples); } else if (pname == "jitter") { parse_param(stream, ptype, tvalue.jitter); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_sampler::type_t::stratified; value.stratified = tvalue; } else { throw std::runtime_error("unknown Sampler " + type); } } // Parse Filter static inline void parse_filter( pbrt_stream& stream, const string& type, pbrt_filter& value) { auto pname = ""s, ptype = ""s; if (type == "box") { auto tvalue = pbrt_filter::box_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "xwidth") { parse_param(stream, ptype, tvalue.xwidth); } else if (pname == "ywidth") { parse_param(stream, ptype, tvalue.ywidth); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_filter::type_t::box; value.box = tvalue; } else if (type == "gaussian") { auto tvalue = pbrt_filter::gaussian_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "xwidth") { parse_param(stream, ptype, tvalue.xwidth); } else if (pname == "ywidth") { parse_param(stream, ptype, tvalue.ywidth); } else if (pname == "alpha") { parse_param(stream, ptype, tvalue.alpha); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_filter::type_t::gaussian; value.gaussian = tvalue; } else if (type == "mitchell") { auto tvalue = pbrt_filter::mitchell_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "xwidth") { parse_param(stream, ptype, tvalue.xwidth); } else if (pname == "ywidth") { parse_param(stream, ptype, tvalue.ywidth); } else if (pname == "B") { parse_param(stream, ptype, tvalue.B); } else if (pname == "C") { parse_param(stream, ptype, tvalue.C); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_filter::type_t::mitchell; value.mitchell = tvalue; } else if (type == "sinc") { auto tvalue = pbrt_filter::sinc_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "xwidth") { parse_param(stream, ptype, tvalue.xwidth); } else if (pname == "ywidth") { parse_param(stream, ptype, tvalue.ywidth); } else if (pname == "tau") { parse_param(stream, ptype, tvalue.tau); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_filter::type_t::sinc; value.sinc = tvalue; } else if (type == "triangle") { auto tvalue = pbrt_filter::triangle_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "xwidth") { parse_param(stream, ptype, tvalue.xwidth); } else if (pname == "ywidth") { parse_param(stream, ptype, tvalue.ywidth); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_filter::type_t::triangle; value.triangle = tvalue; } else { throw std::runtime_error("unknown PixelFilter " + type); } } // Parse Filter static inline void parse_film( pbrt_stream& stream, const string& type, pbrt_film& value) { auto pname = ""s, ptype = ""s; if (type == "image") { auto tvalue = pbrt_film::image_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "xresolution") { parse_param(stream, ptype, tvalue.xresolution); } else if (pname == "yresolution") { parse_param(stream, ptype, tvalue.yresolution); } else if (pname == "yresolution") { parse_param(stream, ptype, tvalue.yresolution); } else if (pname == "cropwindow") { parse_param(stream, ptype, tvalue.cropwindow); } else if (pname == "scale") { parse_param(stream, ptype, tvalue.scale); } else if (pname == "maxsampleluminance") { parse_param(stream, ptype, tvalue.maxsampleluminance); } else if (pname == "diagonal") { parse_param(stream, ptype, tvalue.diagonal); } else if (pname == "filename") { parse_param(stream, ptype, tvalue.filename); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_film::type_t::image; value.image = tvalue; } else { throw std::runtime_error("unknown Film " + type); } } // Parse Camera static inline void parse_camera( pbrt_stream& stream, const string& type, pbrt_camera& value) { auto pname = ""s, ptype = ""s; if (type == "perspective") { auto tvalue = pbrt_camera::perspective_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "fov") { parse_param(stream, ptype, tvalue.fov); } else if (pname == "frameaspectratio") { parse_param(stream, ptype, tvalue.frameaspectratio); } else if (pname == "lensradius") { parse_param(stream, ptype, tvalue.lensradius); } else if (pname == "focaldistance") { parse_param(stream, ptype, tvalue.focaldistance); } else if (pname == "screenwindow") { parse_param(stream, ptype, tvalue.screenwindow); } else if (pname == "shutteropen") { parse_param(stream, ptype, tvalue.shutteropen); } else if (pname == "shutterclose") { parse_param(stream, ptype, tvalue.shutterclose); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_camera::type_t::perspective; value.perspective = tvalue; } else if (type == "orthographic") { auto tvalue = pbrt_camera::orthographic_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "frameaspectratio") { parse_param(stream, ptype, tvalue.frameaspectratio); } else if (pname == "lensradius") { parse_param(stream, ptype, tvalue.lensradius); } else if (pname == "focaldistance") { parse_param(stream, ptype, tvalue.focaldistance); } else if (pname == "screenwindow") { parse_param(stream, ptype, tvalue.screenwindow); } else if (pname == "shutteropen") { parse_param(stream, ptype, tvalue.shutteropen); } else if (pname == "shutterclose") { parse_param(stream, ptype, tvalue.shutterclose); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_camera::type_t::orthographic; value.orthographic = tvalue; } else if (type == "environment") { auto tvalue = pbrt_camera::environment_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "shutteropen") { parse_param(stream, ptype, tvalue.shutteropen); } else if (pname == "shutterclose") { parse_param(stream, ptype, tvalue.shutterclose); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_camera::type_t::environment; value.environment = tvalue; } else if (type == "realistic") { auto tvalue = pbrt_camera::realistic_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "lensfile") { parse_param(stream, ptype, tvalue.lensfile); // example: wide.22mm.dat auto lensfile = fs::path(tvalue.lensfile).filename().string(); lensfile = lensfile.substr(0, lensfile.size() - 4); lensfile = lensfile.substr(lensfile.find('.') + 1); lensfile = lensfile.substr(0, lensfile.size() - 2); tvalue.approx_focallength = std::atof(lensfile.c_str()); } else if (pname == "aperturediameter") { parse_param(stream, ptype, tvalue.aperturediameter); } else if (pname == "focusdistance") { parse_param(stream, ptype, tvalue.focusdistance); } else if (pname == "simpleweighting") { parse_param(stream, ptype, tvalue.simpleweighting); } else if (pname == "shutteropen") { parse_param(stream, ptype, tvalue.shutteropen); } else if (pname == "shutterclose") { parse_param(stream, ptype, tvalue.shutterclose); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_camera::type_t::realistic; value.realistic = tvalue; } else { throw std::runtime_error("unknown Film " + type); } } // Parse Texture static inline void parse_texture( pbrt_stream& stream, const string& type, pbrt_texture& value) { auto pname = ""s, ptype = ""s; if (type == "constant") { auto tvalue = pbrt_texture::constant_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "value") { parse_param(stream, ptype, tvalue.value); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_texture::type_t::constant; value.constant = tvalue; } else if (type == "bilerp") { auto tvalue = pbrt_texture::bilerp_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "v00") { parse_param(stream, ptype, tvalue.v00); } else if (pname == "v01") { parse_param(stream, ptype, tvalue.v01); } else if (pname == "v10") { parse_param(stream, ptype, tvalue.v10); } else if (pname == "v11") { parse_param(stream, ptype, tvalue.v11); } else if (pname == "mapping") { parse_param(stream, ptype, tvalue.mapping); } else if (pname == "uscale") { parse_param(stream, ptype, tvalue.uscale); } else if (pname == "vscale") { parse_param(stream, ptype, tvalue.vscale); } else if (pname == "udelta") { parse_param(stream, ptype, tvalue.udelta); } else if (pname == "vdelta") { parse_param(stream, ptype, tvalue.vdelta); } else if (pname == "v1") { parse_param(stream, ptype, tvalue.v1); } else if (pname == "v2") { parse_param(stream, ptype, tvalue.v2); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_texture::type_t::bilerp; value.bilerp = tvalue; } else if (type == "checkerboard") { auto tvalue = pbrt_texture::checkerboard_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "dimension") { parse_param(stream, ptype, tvalue.dimension); } else if (pname == "tex1") { parse_param(stream, ptype, tvalue.tex1); } else if (pname == "tex2") { parse_param(stream, ptype, tvalue.tex2); } else if (pname == "aamode") { parse_param(stream, ptype, tvalue.aamode); } else if (pname == "mapping") { parse_param(stream, ptype, tvalue.mapping); } else if (pname == "uscale") { parse_param(stream, ptype, tvalue.uscale); } else if (pname == "vscale") { parse_param(stream, ptype, tvalue.vscale); } else if (pname == "udelta") { parse_param(stream, ptype, tvalue.udelta); } else if (pname == "vdelta") { parse_param(stream, ptype, tvalue.vdelta); } else if (pname == "v1") { parse_param(stream, ptype, tvalue.v1); } else if (pname == "v2") { parse_param(stream, ptype, tvalue.v2); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_texture::type_t::checkerboard; value.checkerboard = tvalue; } else if (type == "dots") { auto tvalue = pbrt_texture::dots_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "inside") { parse_param(stream, ptype, tvalue.inside); } else if (pname == "outside") { parse_param(stream, ptype, tvalue.outside); } else if (pname == "mapping") { parse_param(stream, ptype, tvalue.mapping); } else if (pname == "uscale") { parse_param(stream, ptype, tvalue.uscale); } else if (pname == "vscale") { parse_param(stream, ptype, tvalue.vscale); } else if (pname == "udelta") { parse_param(stream, ptype, tvalue.udelta); } else if (pname == "vdelta") { parse_param(stream, ptype, tvalue.vdelta); } else if (pname == "v1") { parse_param(stream, ptype, tvalue.v1); } else if (pname == "v2") { parse_param(stream, ptype, tvalue.v2); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_texture::type_t::dots; value.dots = tvalue; } else if (type == "imagemap") { auto tvalue = pbrt_texture::imagemap_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "filename") { parse_param(stream, ptype, tvalue.filename); } else if (pname == "wrap") { parse_param(stream, ptype, tvalue.wrap); } else if (pname == "maxanisotropy") { parse_param(stream, ptype, tvalue.maxanisotropy); } else if (pname == "trilinear") { parse_param(stream, ptype, tvalue.trilinear); } else if (pname == "scale") { parse_param(stream, ptype, tvalue.scale); } else if (pname == "gamma") { parse_param(stream, ptype, tvalue.gamma); } else if (pname == "mapping") { parse_param(stream, ptype, tvalue.mapping); } else if (pname == "uscale") { parse_param(stream, ptype, tvalue.uscale); } else if (pname == "vscale") { parse_param(stream, ptype, tvalue.vscale); } else if (pname == "udelta") { parse_param(stream, ptype, tvalue.udelta); } else if (pname == "vdelta") { parse_param(stream, ptype, tvalue.vdelta); } else if (pname == "v1") { parse_param(stream, ptype, tvalue.v1); } else if (pname == "v2") { parse_param(stream, ptype, tvalue.v2); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_texture::type_t::imagemap; value.imagemap = tvalue; } else if (type == "mix") { auto tvalue = pbrt_texture::mix_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "tex1") { parse_param(stream, ptype, tvalue.tex1); } else if (pname == "tex2") { parse_param(stream, ptype, tvalue.tex2); } else if (pname == "amount") { parse_param(stream, ptype, tvalue.amount); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_texture::type_t::mix; value.mix = tvalue; } else if (type == "scale") { auto tvalue = pbrt_texture::scale_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "tex1") { parse_param(stream, ptype, tvalue.tex1); } else if (pname == "tex2") { parse_param(stream, ptype, tvalue.tex2); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_texture::type_t::scale; value.scale = tvalue; } else if (type == "fbm") { auto tvalue = pbrt_texture::fbm_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "octaves") { parse_param(stream, ptype, tvalue.octaves); } else if (pname == "roughness") { parse_param(stream, ptype, tvalue.roughness); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_texture::type_t::fbm; value.fbm = tvalue; } else if (type == "wrinkled") { auto tvalue = pbrt_texture::wrinkled_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "octaves") { parse_param(stream, ptype, tvalue.octaves); } else if (pname == "roughness") { parse_param(stream, ptype, tvalue.roughness); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_texture::type_t::wrinkled; value.wrinkled = tvalue; } else if (type == "windy") { auto tvalue = pbrt_texture::windy_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "") { // TODO: missing params } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_texture::type_t::windy; value.windy = tvalue; } else if (type == "marble") { auto tvalue = pbrt_texture::marble_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "octaves") { parse_param(stream, ptype, tvalue.octaves); } else if (pname == "roughness") { parse_param(stream, ptype, tvalue.roughness); } else if (pname == "scale") { parse_param(stream, ptype, tvalue.scale); } else if (pname == "variation") { parse_param(stream, ptype, tvalue.variation); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_texture::type_t::marble; value.marble = tvalue; } else if (type == "uv") { auto tvalue = pbrt_texture::uv_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "mapping") { parse_param(stream, ptype, tvalue.mapping); } else if (pname == "uscale") { parse_param(stream, ptype, tvalue.uscale); } else if (pname == "vscale") { parse_param(stream, ptype, tvalue.vscale); } else if (pname == "udelta") { parse_param(stream, ptype, tvalue.udelta); } else if (pname == "vdelta") { parse_param(stream, ptype, tvalue.vdelta); } else if (pname == "v1") { parse_param(stream, ptype, tvalue.v1); } else if (pname == "v2") { parse_param(stream, ptype, tvalue.v2); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_texture::type_t::uv; value.uv = tvalue; } else { throw std::runtime_error("unknown Texture " + type); } } void approximate_fourier_material(pbrt_material::fourier_t& fourier) { auto filename = fs::path(fourier.bsdffile).filename().string(); if (filename == "paint.bsdf") { fourier.approx_type = pbrt_material::fourier_t::approx_type_t::plastic; auto& plastic = fourier.approx_plastic; plastic.Kd = {0.6f, 0.6f, 0.6f}; // plastic.Ks = {0.4f, 0.4f, 0.4f}; plastic.Ks = {1.0f, 1.0f, 1.0f}; plastic.uroughness = 0.2f; plastic.vroughness = 0.2f; } else if (filename == "ceramic.bsdf") { fourier.approx_type = pbrt_material::fourier_t::approx_type_t::plastic; auto& plastic = fourier.approx_plastic; plastic.Kd = {0.6f, 0.6f, 0.6f}; // plastic.Ks = {0.1f, 0.1f, 0.1f}; plastic.Ks = {1.0f, 1.0f, 1.0f}; plastic.uroughness = 0.025f; plastic.vroughness = 0.025f; } else if (filename == "leather.bsdf") { fourier.approx_type = pbrt_material::fourier_t::approx_type_t::plastic; auto& plastic = fourier.approx_plastic; plastic.Kd = {0.6f, 0.57f, 0.48f}; // plastic.Ks = {0.1f, 0.1f, 0.1f}; plastic.Ks = {1.0f, 1.0f, 1.0f}; plastic.uroughness = 0.3f; plastic.vroughness = 0.3f; } else if (filename == "coated_copper.bsdf") { fourier.approx_type = pbrt_material::fourier_t::approx_type_t::metal; auto& metal = fourier.approx_metal; auto etak = get_pbrt_etak("Cu"); metal.eta = {etak.first.x, etak.first.y, etak.first.z}; metal.k = {etak.second.x, etak.second.y, etak.second.z}; metal.uroughness = 0.01f; metal.vroughness = 0.01f; } else if (filename == "roughglass_alpha_0.2.bsdf") { fourier.approx_type = pbrt_material::fourier_t::approx_type_t::glass; auto& glass = fourier.approx_glass; glass.uroughness = 0.2f; glass.vroughness = 0.2f; glass.Kr = {1, 1, 1}; glass.Kt = {1, 1, 1}; } else if (filename == "roughgold_alpha_0.2.bsdf") { fourier.approx_type = pbrt_material::fourier_t::approx_type_t::metal; auto& metal = fourier.approx_metal; auto etak = get_pbrt_etak("Au"); metal.eta = {etak.first.x, etak.first.y, etak.first.z}; metal.k = {etak.second.x, etak.second.y, etak.second.z}; metal.uroughness = 0.2f; metal.vroughness = 0.2f; } else { throw std::runtime_error("unknown pbrt bsdf filename " + fourier.bsdffile); } } // Pbrt measure subsurface parameters (sigma_prime_s, sigma_a in mm^-1) // from pbrt code at pbrt/code/medium.cpp static inline pair parse_subsurface(const string& name) { static const unordered_map> params = { // From "A Practical Model for Subsurface Light Transport" // Jensen, Marschner, Levoy, Hanrahan // Proc SIGGRAPH 2001 {"Apple", {{2.29, 2.39, 1.97}, {0.0030, 0.0034, 0.046}}}, {"Chicken1", {{0.15, 0.21, 0.38}, {0.015, 0.077, 0.19}}}, {"Chicken2", {{0.19, 0.25, 0.32}, {0.018, 0.088, 0.20}}}, {"Cream", {{7.38, 5.47, 3.15}, {0.0002, 0.0028, 0.0163}}}, {"Ketchup", {{0.18, 0.07, 0.03}, {0.061, 0.97, 1.45}}}, {"Marble", {{2.19, 2.62, 3.00}, {0.0021, 0.0041, 0.0071}}}, {"Potato", {{0.68, 0.70, 0.55}, {0.0024, 0.0090, 0.12}}}, {"Skimmilk", {{0.70, 1.22, 1.90}, {0.0014, 0.0025, 0.0142}}}, {"Skin1", {{0.74, 0.88, 1.01}, {0.032, 0.17, 0.48}}}, {"Skin2", {{1.09, 1.59, 1.79}, {0.013, 0.070, 0.145}}}, {"Spectralon", {{11.6, 20.4, 14.9}, {0.00, 0.00, 0.00}}}, {"Wholemilk", {{2.55, 3.21, 3.77}, {0.0011, 0.0024, 0.014}}}, // From "Acquiring Scattering Properties of Participating Media by // Dilution", // Narasimhan, Gupta, Donner, Ramamoorthi, Nayar, Jensen // Proc SIGGRAPH 2006 {"Lowfat Milk", {{0.89187, 1.5136, 2.532}, {0.002875, 0.00575, 0.0115}}}, {"Reduced Milk", {{2.4858, 3.1669, 4.5214}, {0.0025556, 0.0051111, 0.012778}}}, {"Regular Milk", {{4.5513, 5.8294, 7.136}, {0.0015333, 0.0046, 0.019933}}}, {"Espresso", {{0.72378, 0.84557, 1.0247}, {4.7984, 6.5751, 8.8493}}}, {"Mint Mocha Coffee", {{0.31602, 0.38538, 0.48131}, {3.772, 5.8228, 7.82}}}, {"Lowfat Soy Milk", {{0.30576, 0.34233, 0.61664}, {0.0014375, 0.0071875, 0.035937}}}, {"Regular Soy Milk", {{0.59223, 0.73866, 1.4693}, {0.0019167, 0.0095833, 0.065167}}}, {"Lowfat Chocolate Milk", {{0.64925, 0.83916, 1.1057}, {0.0115, 0.0368, 0.1564}}}, {"Regular Chocolate Milk", {{1.4585, 2.1289, 2.9527}, {0.010063, 0.043125, 0.14375}}}, {"Coke", {{8.9053e-05, 8.372e-05, 0}, {0.10014, 0.16503, 0.2468}}}, {"Pepsi", {{6.1697e-05, 4.2564e-05, 0}, {0.091641, 0.14158, 0.20729}}}, {"Sprite", {{6.0306e-06, 6.4139e-06, 6.5504e-06}, {0.001886, 0.0018308, 0.0020025}}}, {"Gatorade", {{0.0024574, 0.003007, 0.0037325}, {0.024794, 0.019289, 0.008878}}}, {"Chardonnay", {{1.7982e-05, 1.3758e-05, 1.2023e-05}, {0.010782, 0.011855, 0.023997}}}, {"White Zinfandel", {{1.7501e-05, 1.9069e-05, 1.288e-05}, {0.012072, 0.016184, 0.019843}}}, {"Merlot", {{2.1129e-05, 0, 0}, {0.11632, 0.25191, 0.29434}}}, {"Budweiser Beer", {{2.4356e-05, 2.4079e-05, 1.0564e-05}, {0.011492, 0.024911, 0.057786}}}, {"Coors Light Beer", {{5.0922e-05, 4.301e-05, 0}, {0.006164, 0.013984, 0.034983}}}, {"Clorox", {{0.0024035, 0.0031373, 0.003991}, {0.0033542, 0.014892, 0.026297}}}, {"Apple Juice", {{0.00013612, 0.00015836, 0.000227}, {0.012957, 0.023741, 0.052184}}}, {"Cranberry Juice", {{0.00010402, 0.00011646, 7.8139e-05}, {0.039437, 0.094223, 0.12426}}}, {"Grape Juice", {{5.382e-05, 0, 0}, {0.10404, 0.23958, 0.29325}}}, {"Ruby Grapefruit Juice", {{0.011002, 0.010927, 0.011036}, {0.085867, 0.18314, 0.25262}}}, {"White Grapefruit Juice", {{0.22826, 0.23998, 0.32748}, {0.0138, 0.018831, 0.056781}}}, {"Shampoo", {{0.0007176, 0.0008303, 0.0009016}, {0.014107, 0.045693, 0.061717}}}, {"Strawberry Shampoo", {{0.00015671, 0.00015947, 1.518e-05}, {0.01449, 0.05796, 0.075823}}}, {"Head & Shoulders Shampoo", {{0.023805, 0.028804, 0.034306}, {0.084621, 0.15688, 0.20365}}}, {"Lemon Tea Powder", {{0.040224, 0.045264, 0.051081}, {2.4288, 4.5757, 7.2127}}}, {"Orange Powder", {{0.00015617, 0.00017482, 0.0001762}, {0.001449, 0.003441, 0.007863}}}, {"Pink Lemonade Powder", {{0.00012103, 0.00013073, 0.00012528}, {0.001165, 0.002366, 0.003195}}}, {"Cappuccino Powder", {{1.8436, 2.5851, 2.1662}, {35.844, 49.547, 61.084}}}, {"Salt Powder", {{0.027333, 0.032451, 0.031979}, {0.28415, 0.3257, 0.34148}}}, {"Sugar Powder", {{0.00022272, 0.00025513, 0.000271}, {0.012638, 0.031051, 0.050124}}}, {"Suisse Mocha Powder", {{2.7979, 3.5452, 4.3365}, {17.502, 27.004, 35.433}}}, {"Pacific Ocean Surface Water", {{0.0001764, 0.00032095, 0.00019617}, {0.031845, 0.031324, 0.030147}}}, }; return params.at(name); } // Get typename static inline void parse_typeparam(pbrt_stream& stream, string& value) { save_stream_position(stream); value = ""; auto pname = ""s, ptype = ""s; while (is_param(stream) && value == "") { parse_nametype(stream, pname, ptype); if (pname == "type") { parse_param(stream, ptype, value); } else { skip_param(stream); } } if (value == "") throw std::runtime_error("type not found"); restore_stream_position(stream); } // Parse param and resolve constant textures static inline void parse_texture(pbrt_stream& stream, const string& ptype, pbrt_textured3f& value, const unordered_map& constant_values) { parse_param(stream, ptype, value); if (value.texture == "") return; if (constant_values.find(value.texture) == constant_values.end()) return; value.value = constant_values.at(value.texture); value.texture = ""; } static inline void parse_texture(pbrt_stream& stream, const string& ptype, pbrt_textured1f& value, const unordered_map& constant_values) { parse_param(stream, ptype, value); if (value.texture == "") return; if (constant_values.find(value.texture) == constant_values.end()) return; auto col = constant_values.at(value.texture); value.value = (col.x + col.y + col.z) / 3; value.texture = ""; } // Parse Material static inline void parse_material(pbrt_stream& stream, const string& type, pbrt_material& value, const unordered_map& constant_values) { auto pname = ""s, ptype = ""s; if (type == "matte") { auto tvalue = pbrt_material::matte_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "Kd") { parse_texture(stream, ptype, tvalue.Kd, constant_values); } else if (pname == "sigma") { parse_param(stream, ptype, tvalue.sigma); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_material::type_t::matte; value.matte = tvalue; } else if (type == "mirror") { auto tvalue = pbrt_material::mirror_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "Kr") { parse_texture(stream, ptype, tvalue.Kr, constant_values); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_material::type_t::mirror; value.mirror = tvalue; } else if (type == "plastic") { auto tvalue = pbrt_material::plastic_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "Kd") { parse_texture(stream, ptype, tvalue.Kd, constant_values); } else if (pname == "Ks") { parse_texture(stream, ptype, tvalue.Ks, constant_values); } else if (pname == "roughness") { pbrt_textured1f roughness = 0.01f; parse_param(stream, ptype, roughness); tvalue.uroughness = roughness; tvalue.vroughness = roughness; } else if (pname == "uroughness") { parse_texture(stream, ptype, tvalue.uroughness, constant_values); } else if (pname == "vroughness") { parse_texture(stream, ptype, tvalue.vroughness, constant_values); } else if (pname == "remaproughness") { parse_param(stream, ptype, tvalue.remaproughness); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_material::type_t::plastic; value.plastic = tvalue; } else if (type == "metal") { auto tvalue = pbrt_material::metal_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "eta") { parse_texture(stream, ptype, tvalue.eta, constant_values); } else if (pname == "k") { parse_texture(stream, ptype, tvalue.k, constant_values); } else if (pname == "index") { parse_texture(stream, ptype, tvalue.eta, constant_values); } else if (pname == "roughness") { pbrt_textured1f roughness = 0.01f; parse_param(stream, ptype, roughness); tvalue.uroughness = roughness; tvalue.vroughness = roughness; } else if (pname == "uroughness") { parse_texture(stream, ptype, tvalue.uroughness, constant_values); } else if (pname == "vroughness") { parse_texture(stream, ptype, tvalue.vroughness, constant_values); } else if (pname == "remaproughness") { parse_param(stream, ptype, tvalue.remaproughness); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_material::type_t::metal; value.metal = tvalue; } else if (type == "glass") { auto tvalue = pbrt_material::glass_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "Kr") { parse_texture(stream, ptype, tvalue.Kr, constant_values); } else if (pname == "Kt") { parse_texture(stream, ptype, tvalue.Kt, constant_values); } else if (pname == "eta") { parse_texture(stream, ptype, tvalue.eta, constant_values); } else if (pname == "index") { parse_texture(stream, ptype, tvalue.eta, constant_values); } else if (pname == "roughness") { pbrt_textured1f roughness = 0.01f; parse_param(stream, ptype, roughness); tvalue.uroughness = roughness; tvalue.vroughness = roughness; } else if (pname == "uroughness") { parse_texture(stream, ptype, tvalue.uroughness, constant_values); } else if (pname == "vroughness") { parse_texture(stream, ptype, tvalue.vroughness, constant_values); } else if (pname == "remaproughness") { parse_param(stream, ptype, tvalue.remaproughness); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_material::type_t::glass; value.glass = tvalue; } else if (type == "translucent") { auto tvalue = pbrt_material::translucent_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "Kd") { parse_texture(stream, ptype, tvalue.Kd, constant_values); } else if (pname == "Ks") { parse_texture(stream, ptype, tvalue.Ks, constant_values); } else if (pname == "reflect") { parse_texture(stream, ptype, tvalue.reflect, constant_values); } else if (pname == "transmit") { parse_texture(stream, ptype, tvalue.transmit, constant_values); } else if (pname == "roughness") { pbrt_textured1f roughness = 0.01f; parse_param(stream, ptype, roughness); tvalue.uroughness = roughness; tvalue.vroughness = roughness; } else if (pname == "uroughness") { parse_texture(stream, ptype, tvalue.uroughness, constant_values); } else if (pname == "vroughness") { parse_texture(stream, ptype, tvalue.vroughness, constant_values); } else if (pname == "remaproughness") { parse_param(stream, ptype, tvalue.remaproughness); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_material::type_t::translucent; value.translucent = tvalue; } else if (type == "uber") { auto tvalue = pbrt_material::uber_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "Kd") { parse_texture(stream, ptype, tvalue.Kd, constant_values); } else if (pname == "Ks") { parse_texture(stream, ptype, tvalue.Ks, constant_values); } else if (pname == "Kr") { parse_texture(stream, ptype, tvalue.Kr, constant_values); } else if (pname == "Kt") { parse_texture(stream, ptype, tvalue.Kt, constant_values); } else if (pname == "eta") { parse_texture(stream, ptype, tvalue.eta, constant_values); } else if (pname == "index") { parse_texture(stream, ptype, tvalue.eta, constant_values); } else if (pname == "opacity") { parse_texture(stream, ptype, tvalue.opacity, constant_values); } else if (pname == "roughness") { pbrt_textured1f roughness = 0.01f; parse_param(stream, ptype, roughness); tvalue.uroughness = roughness; tvalue.vroughness = roughness; } else if (pname == "uroughness") { parse_texture(stream, ptype, tvalue.uroughness, constant_values); } else if (pname == "vroughness") { parse_texture(stream, ptype, tvalue.vroughness, constant_values); } else if (pname == "remaproughness") { parse_param(stream, ptype, tvalue.remaproughness); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_material::type_t::uber; value.uber = tvalue; } else if (type == "disney") { auto tvalue = pbrt_material::disney_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "color") { parse_texture(stream, ptype, tvalue.color, constant_values); } else if (pname == "anisotropic") { parse_texture(stream, ptype, tvalue.anisotropic, constant_values); } else if (pname == "clearcoat") { parse_texture(stream, ptype, tvalue.clearcoat, constant_values); } else if (pname == "clearcoatgloss") { parse_texture(stream, ptype, tvalue.clearcoatgloss, constant_values); } else if (pname == "eta") { parse_texture(stream, ptype, tvalue.eta, constant_values); } else if (pname == "index") { parse_texture(stream, ptype, tvalue.eta, constant_values); } else if (pname == "metallic") { parse_texture(stream, ptype, tvalue.metallic, constant_values); } else if (pname == "roughness") { pbrt_textured1f roughness = 0.01f; parse_param(stream, ptype, roughness); tvalue.uroughness = roughness; tvalue.vroughness = roughness; } else if (pname == "uroughness") { parse_texture(stream, ptype, tvalue.uroughness, constant_values); } else if (pname == "vroughness") { parse_texture(stream, ptype, tvalue.vroughness, constant_values); } else if (pname == "remaproughness") { parse_param(stream, ptype, tvalue.remaproughness); } else if (pname == "scatterdistance") { parse_texture(stream, ptype, tvalue.scatterdistance, constant_values); } else if (pname == "sheen") { parse_texture(stream, ptype, tvalue.sheen, constant_values); } else if (pname == "sheentint") { parse_texture(stream, ptype, tvalue.sheentint, constant_values); } else if (pname == "spectrans") { parse_texture(stream, ptype, tvalue.spectrans, constant_values); } else if (pname == "thin") { parse_param(stream, ptype, tvalue.thin); } else if (pname == "difftrans") { parse_texture(stream, ptype, tvalue.difftrans, constant_values); } else if (pname == "flatness") { parse_texture(stream, ptype, tvalue.flatness, constant_values); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_material::type_t::disney; value.disney = tvalue; } else if (type == "hair") { auto tvalue = pbrt_material::hair_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "color") { parse_texture(stream, ptype, tvalue.color, constant_values); } else if (pname == "sigma_a") { parse_texture(stream, ptype, tvalue.sigma_a, constant_values); } else if (pname == "eumelanin") { parse_texture(stream, ptype, tvalue.eumelanin, constant_values); } else if (pname == "pheomelanin") { parse_texture(stream, ptype, tvalue.pheomelanin, constant_values); } else if (pname == "eta") { parse_texture(stream, ptype, tvalue.eta, constant_values); } else if (pname == "index") { parse_texture(stream, ptype, tvalue.eta, constant_values); } else if (pname == "beta_m") { parse_texture(stream, ptype, tvalue.beta_m, constant_values); } else if (pname == "beta_n") { parse_texture(stream, ptype, tvalue.beta_n, constant_values); } else if (pname == "alpha") { parse_texture(stream, ptype, tvalue.alpha, constant_values); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_material::type_t::hair; value.hair = tvalue; } else if (type == "kdsubsurface") { auto tvalue = pbrt_material::kdsubsurface_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "Kd") { parse_texture(stream, ptype, tvalue.Kd, constant_values); } else if (pname == "Kr") { parse_texture(stream, ptype, tvalue.Kr, constant_values); } else if (pname == "Kt") { parse_texture(stream, ptype, tvalue.Kt, constant_values); } else if (pname == "mfp") { parse_texture(stream, ptype, tvalue.mfp, constant_values); } else if (pname == "eta") { parse_texture(stream, ptype, tvalue.eta, constant_values); } else if (pname == "index") { parse_texture(stream, ptype, tvalue.eta, constant_values); } else if (pname == "roughness") { pbrt_textured1f roughness = 0.01f; parse_param(stream, ptype, roughness); tvalue.uroughness = roughness; tvalue.vroughness = roughness; } else if (pname == "uroughness") { parse_texture(stream, ptype, tvalue.uroughness, constant_values); } else if (pname == "vroughness") { parse_texture(stream, ptype, tvalue.vroughness, constant_values); } else if (pname == "remaproughness") { parse_param(stream, ptype, tvalue.remaproughness); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_material::type_t::kdsubsurface; value.kdsubsurface = tvalue; } else if (type == "mix") { auto tvalue = pbrt_material::mix_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "amount") { parse_texture(stream, ptype, tvalue.amount, constant_values); } else if (pname == "namedmaterial1") { parse_param(stream, ptype, tvalue.namedmaterial1); } else if (pname == "namedmaterial2") { parse_param(stream, ptype, tvalue.namedmaterial2); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_material::type_t::mix; value.mix = tvalue; } else if (type == "fourier") { auto tvalue = pbrt_material::fourier_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "bsdffile") { parse_param(stream, ptype, tvalue.bsdffile); approximate_fourier_material(tvalue); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_material::type_t::fourier; value.fourier = tvalue; } else if (type == "substrate") { auto tvalue = pbrt_material::substrate_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "Kd") { parse_texture(stream, ptype, tvalue.Kd, constant_values); } else if (pname == "Ks") { parse_texture(stream, ptype, tvalue.Ks, constant_values); } else if (pname == "roughness") { pbrt_textured1f roughness = 0.01f; parse_param(stream, ptype, roughness); tvalue.uroughness = roughness; tvalue.vroughness = roughness; } else if (pname == "uroughness") { parse_texture(stream, ptype, tvalue.uroughness, constant_values); } else if (pname == "vroughness") { parse_texture(stream, ptype, tvalue.vroughness, constant_values); } else if (pname == "remaproughness") { parse_param(stream, ptype, tvalue.remaproughness); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_material::type_t::substrate; value.substrate = tvalue; } else if (type == "subsurface") { auto tvalue = pbrt_material::subsurface_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "name") { parse_param(stream, ptype, tvalue.name); auto params = parse_subsurface(tvalue.name); tvalue.sigma_a = {params.second.x, params.second.y, params.second.z}; tvalue.sigma_prime_s = {params.first.x, params.first.y, params.first.z}; } else if (pname == "sigma_a") { parse_texture(stream, ptype, tvalue.sigma_a, constant_values); } else if (pname == "sigma_prime_s") { parse_texture(stream, ptype, tvalue.sigma_prime_s, constant_values); } else if (pname == "scale") { parse_param(stream, ptype, tvalue.scale); } else if (pname == "eta") { parse_texture(stream, ptype, tvalue.eta, constant_values); } else if (pname == "index") { parse_texture(stream, ptype, tvalue.eta, constant_values); } else if (pname == "Kr") { parse_texture(stream, ptype, tvalue.Kr, constant_values); } else if (pname == "Kt") { parse_texture(stream, ptype, tvalue.Kt, constant_values); } else if (pname == "roughness") { pbrt_textured1f roughness = 0.01f; parse_param(stream, ptype, roughness); tvalue.uroughness = roughness; tvalue.vroughness = roughness; } else if (pname == "uroughness") { parse_texture(stream, ptype, tvalue.uroughness, constant_values); } else if (pname == "vroughness") { parse_texture(stream, ptype, tvalue.vroughness, constant_values); } else if (pname == "remaproughness") { parse_param(stream, ptype, tvalue.remaproughness); } else if (pname == "bumpmap") { parse_texture(stream, ptype, tvalue.bumpmap, constant_values); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_material::type_t::subsurface; value.subsurface = tvalue; } else { throw std::runtime_error("unknown Material " + type); } } // Parse Shape static inline void parse_shape( pbrt_stream& stream, const string& type, pbrt_shape& value) { auto pname = ""s, ptype = ""s; if (type == "trianglemesh") { auto tvalue = pbrt_shape::trianglemesh_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "indices") { parse_param(stream, ptype, tvalue.indices); } else if (pname == "P") { parse_param(stream, ptype, tvalue.P); } else if (pname == "N") { parse_param(stream, ptype, tvalue.N); } else if (pname == "S") { parse_param(stream, ptype, tvalue.S); } else if (pname == "uv") { parse_param(stream, ptype, tvalue.uv); } else if (pname == "st") { parse_param(stream, ptype, tvalue.uv); } else if (pname == "alpha") { parse_param(stream, ptype, tvalue.alpha); } else if (pname == "shadowalpha") { parse_param(stream, ptype, tvalue.shadowalpha); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_shape::type_t::trianglemesh; value.trianglemesh = tvalue; } else if (type == "plymesh") { auto tvalue = pbrt_shape::plymesh_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "filename") { parse_param(stream, ptype, tvalue.filename); } else if (pname == "alpha") { parse_param(stream, ptype, tvalue.alpha); } else if (pname == "shadowalpha") { parse_param(stream, ptype, tvalue.shadowalpha); } else if (pname == "discarddegenerateUVs") { // hack for some files auto value = false; parse_param(stream, ptype, value); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_shape::type_t::plymesh; value.plymesh = tvalue; } else if (type == "curve") { auto tvalue = pbrt_shape::curve_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "P") { parse_param(stream, ptype, tvalue.P); } else if (pname == "N") { parse_param(stream, ptype, tvalue.N); } else if (pname == "basis") { parse_param(stream, ptype, tvalue.basis); } else if (pname == "degree") { parse_param(stream, ptype, tvalue.degree); } else if (pname == "type") { parse_param(stream, ptype, tvalue.type); } else if (pname == "width") { auto width = 1.0f; parse_param(stream, ptype, width); tvalue.width0 = width; tvalue.width1 = width; } else if (pname == "width0") { parse_param(stream, ptype, tvalue.width0); } else if (pname == "width1") { parse_param(stream, ptype, tvalue.width1); } else if (pname == "splitdepth") { parse_param(stream, ptype, tvalue.splitdepth); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_shape::type_t::curve; value.curve = tvalue; } else if (type == "loopsubdiv") { auto tvalue = pbrt_shape::loopsubdiv_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "indices") { parse_param(stream, ptype, tvalue.indices); } else if (pname == "P") { parse_param(stream, ptype, tvalue.P); } else if (pname == "levels") { parse_param(stream, ptype, tvalue.levels); } else if (pname == "nlevels") { parse_param(stream, ptype, tvalue.levels); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_shape::type_t::loopsubdiv; value.loopsubdiv = tvalue; } else if (type == "nurbs") { auto tvalue = pbrt_shape::nurbs_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "nu") { parse_param(stream, ptype, tvalue.nu); } else if (pname == "nv") { parse_param(stream, ptype, tvalue.nv); } else if (pname == "uknots") { parse_param(stream, ptype, tvalue.uknots); } else if (pname == "vknots") { parse_param(stream, ptype, tvalue.vknots); } else if (pname == "u0") { parse_param(stream, ptype, tvalue.u0); } else if (pname == "v0") { parse_param(stream, ptype, tvalue.v0); } else if (pname == "u1") { parse_param(stream, ptype, tvalue.u1); } else if (pname == "v1") { parse_param(stream, ptype, tvalue.v1); } else if (pname == "P") { parse_param(stream, ptype, tvalue.P); } else if (pname == "Pw") { parse_param(stream, ptype, tvalue.Pw); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_shape::type_t::nurbs; value.nurbs = tvalue; } else if (type == "sphere") { auto tvalue = pbrt_shape::sphere_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "radius") { parse_param(stream, ptype, tvalue.radius); } else if (pname == "zmin") { parse_param(stream, ptype, tvalue.zmin); } else if (pname == "zmax") { parse_param(stream, ptype, tvalue.zmax); } else if (pname == "phimax") { parse_param(stream, ptype, tvalue.phimax); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_shape::type_t::sphere; value.sphere = tvalue; } else if (type == "disk") { auto tvalue = pbrt_shape::disk_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "radius") { parse_param(stream, ptype, tvalue.radius); } else if (pname == "height") { parse_param(stream, ptype, tvalue.height); } else if (pname == "innerradius") { parse_param(stream, ptype, tvalue.innerradius); } else if (pname == "phimax") { parse_param(stream, ptype, tvalue.phimax); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_shape::type_t::disk; value.disk = tvalue; } else if (type == "cone") { auto tvalue = pbrt_shape::cone_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "radius") { parse_param(stream, ptype, tvalue.radius); } else if (pname == "height") { parse_param(stream, ptype, tvalue.height); } else if (pname == "phimax") { parse_param(stream, ptype, tvalue.phimax); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_shape::type_t::cone; value.cone = tvalue; } else if (type == "cylinder") { auto tvalue = pbrt_shape::cylinder_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "radius") { parse_param(stream, ptype, tvalue.radius); } else if (pname == "zmin") { parse_param(stream, ptype, tvalue.zmin); } else if (pname == "zmax") { parse_param(stream, ptype, tvalue.zmax); } else if (pname == "phimax") { parse_param(stream, ptype, tvalue.phimax); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_shape::type_t::cylinder; value.cylinder = tvalue; } else if (type == "hyperboloid") { auto tvalue = pbrt_shape::hyperboloid_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "p1") { parse_param(stream, ptype, tvalue.p1); } else if (pname == "p2") { parse_param(stream, ptype, tvalue.p2); } else if (pname == "phimax") { parse_param(stream, ptype, tvalue.phimax); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_shape::type_t::hyperboloid; value.hyperboloid = tvalue; } else if (type == "paraboloid") { auto tvalue = pbrt_shape::paraboloid_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "radius") { parse_param(stream, ptype, tvalue.radius); } else if (pname == "zmin") { parse_param(stream, ptype, tvalue.zmin); } else if (pname == "zmax") { parse_param(stream, ptype, tvalue.zmax); } else if (pname == "phimax") { parse_param(stream, ptype, tvalue.phimax); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_shape::type_t::paraboloid; value.paraboloid = tvalue; } else if (type == "heightfield") { auto tvalue = pbrt_shape::heightfield_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "nu") { parse_param(stream, ptype, tvalue.nu); } else if (pname == "nv") { parse_param(stream, ptype, tvalue.nv); } else if (pname == "Pz") { parse_param(stream, ptype, tvalue.Pz); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_shape::type_t::heightfield; value.heightfield = tvalue; } else { throw std::runtime_error("unknown Shape " + type); } } // Parse AreaLightSource static inline void parse_arealight( pbrt_stream& stream, const string& type, pbrt_arealight& value) { auto pname = ""s, ptype = ""s; if (type == "diffuse") { auto tvalue = pbrt_arealight::diffuse_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "L") { parse_param(stream, ptype, tvalue.L); } else if (pname == "scale") { parse_param(stream, ptype, tvalue.scale); } else if (pname == "twosided") { parse_param(stream, ptype, tvalue.twosided); } else if (pname == "samples") { parse_param(stream, ptype, tvalue.samples); } else if (pname == "nsamples") { parse_param(stream, ptype, tvalue.samples); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_arealight::type_t::diffuse; value.diffuse = tvalue; } else { throw std::runtime_error("unknown Film " + type); } } // Parse LightSource static inline void parse_light( pbrt_stream& stream, const string& type, pbrt_light& value) { auto pname = ""s, ptype = ""s; if (type == "distant") { auto tvalue = pbrt_light::distant_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "scale") { parse_param(stream, ptype, tvalue.scale); } else if (pname == "L") { parse_param(stream, ptype, tvalue.L); } else if (pname == "from") { parse_param(stream, ptype, tvalue.from); } else if (pname == "to") { parse_param(stream, ptype, tvalue.to); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_light::type_t::distant; value.distant = tvalue; } else if (type == "goniometric") { auto tvalue = pbrt_light::goniometric_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "scale") { parse_param(stream, ptype, tvalue.scale); } else if (pname == "I") { parse_param(stream, ptype, tvalue.I); } else if (pname == "mapname") { parse_param(stream, ptype, tvalue.mapname); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_light::type_t::goniometric; value.goniometric = tvalue; } else if (type == "infinite") { auto tvalue = pbrt_light::infinite_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "scale") { parse_param(stream, ptype, tvalue.scale); } else if (pname == "L") { parse_param(stream, ptype, tvalue.L); } else if (pname == "samples") { parse_param(stream, ptype, tvalue.samples); } else if (pname == "nsamples") { parse_param(stream, ptype, tvalue.samples); } else if (pname == "mapname") { parse_param(stream, ptype, tvalue.mapname); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_light::type_t::infinite; value.infinite = tvalue; } else if (type == "distant") { auto tvalue = pbrt_light::distant_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "scale") { parse_param(stream, ptype, tvalue.scale); } else if (pname == "L") { parse_param(stream, ptype, tvalue.L); } else if (pname == "from") { parse_param(stream, ptype, tvalue.from); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_light::type_t::distant; value.distant = tvalue; } else if (type == "projection") { auto tvalue = pbrt_light::projection_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "scale") { parse_param(stream, ptype, tvalue.scale); } else if (pname == "I") { parse_param(stream, ptype, tvalue.I); } else if (pname == "fov") { parse_param(stream, ptype, tvalue.fov); } else if (pname == "mapname") { parse_param(stream, ptype, tvalue.mapname); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_light::type_t::projection; value.projection = tvalue; } else if (type == "spot") { auto tvalue = pbrt_light::spot_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "scale") { parse_param(stream, ptype, tvalue.scale); } else if (pname == "I") { parse_param(stream, ptype, tvalue.I); } else if (pname == "from") { parse_param(stream, ptype, tvalue.from); } else if (pname == "to") { parse_param(stream, ptype, tvalue.to); } else if (pname == "coneangle") { parse_param(stream, ptype, tvalue.coneangle); } else if (pname == "conedeltaangle") { parse_param(stream, ptype, tvalue.conedeltaangle); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_light::type_t::spot; value.spot = tvalue; } else if (type == "point") { auto tvalue = pbrt_light::point_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "scale") { parse_param(stream, ptype, tvalue.scale); } else if (pname == "I") { parse_param(stream, ptype, tvalue.I); } else if (pname == "from") { parse_param(stream, ptype, tvalue.from); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_light::type_t::point; value.point = tvalue; } else { throw std::runtime_error("unknown LightSource " + type); } } // Parse Medium static inline void parse_pbrt_medium( pbrt_stream& stream, const string& type, pbrt_medium& value) { auto pname = ""s, ptype = ""s; if (type == "homogeneous") { auto tvalue = pbrt_medium::homogeneous_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "sigma_a") { parse_param(stream, ptype, tvalue.sigma_a); } else if (pname == "sigma_s") { parse_param(stream, ptype, tvalue.sigma_s); } else if (pname == "preset") { parse_param(stream, ptype, tvalue.preset); } else if (pname == "g") { parse_param(stream, ptype, tvalue.g); } else if (pname == "scale") { parse_param(stream, ptype, tvalue.scale); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_medium::type_t::homogeneous; value.homogeneous = tvalue; } else if (type == "heterogeneous") { auto tvalue = pbrt_medium::heterogeneous_t{}; while (is_param(stream)) { parse_nametype(stream, pname, ptype); if (pname == "sigma_a") { parse_param(stream, ptype, tvalue.scale); } else if (pname == "sigma_s") { parse_param(stream, ptype, tvalue.sigma_s); } else if (pname == "preset") { parse_param(stream, ptype, tvalue.preset); } else if (pname == "g") { parse_param(stream, ptype, tvalue.g); } else if (pname == "p0") { parse_param(stream, ptype, tvalue.p0); } else if (pname == "p1") { parse_param(stream, ptype, tvalue.p1); } else if (pname == "nx") { parse_param(stream, ptype, tvalue.nx); } else if (pname == "ny") { parse_param(stream, ptype, tvalue.ny); } else if (pname == "nz") { parse_param(stream, ptype, tvalue.nz); } else if (pname == "density") { parse_param(stream, ptype, tvalue.density); } else if (pname == "type") { auto ttype = ""s; parse_param(stream, ptype, ttype); if (ttype != type) throw std::runtime_error("inconsistent types"); } else { throw std::runtime_error("unknown parameter " + pname); } } value.type = pbrt_medium::type_t::heterogeneous; value.heterogeneous = tvalue; } else { throw std::runtime_error("unknown Medium " + type); } } // Load pbrt scene void load_pbrt(const string& filename, pbrt_callbacks& cb, bool flipv) { // start laoding files auto streams = vector{}; init_stream(streams); load_stream(filename, streams); // parsing stack auto stack = vector{{}}; auto object = pbrt_object{}; auto coordsys = unordered_map>{}; // helpders auto set_transform = [](pbrt_context& ctx, const mat4f& xform) { if (ctx.active_transform_start) ctx.transform_start = (frame3f)xform; if (ctx.active_transform_end) ctx.transform_end = (frame3f)xform; }; auto concat_transform = [](pbrt_context& ctx, const mat4f& xform) { if (ctx.active_transform_start) ctx.transform_start *= (frame3f)xform; if (ctx.active_transform_end) ctx.transform_end *= (frame3f)xform; }; // constant values unordered_map constant_values = {}; // parse command by command auto cmd = ""s; while (!streams.empty() && !is_empty(streams.back())) { // get command auto& stream = streams.back(); parse_command(stream, cmd); if (cmd == "WorldBegin") { stack.push_back({}); } else if (cmd == "WorldEnd") { stack.pop_back(); if (stack.size() != 1) throw std::runtime_error("bad stack"); } else if (cmd == "AttributeBegin") { stack.push_back(stack.back()); } else if (cmd == "AttributeEnd") { stack.pop_back(); } else if (cmd == "TransformBegin") { stack.push_back(stack.back()); } else if (cmd == "TransformEnd") { stack.pop_back(); } else if (cmd == "ObjectBegin") { parse_value(stream, object.name); stack.push_back(stack.back()); cb.begin_object(object, stack.back()); } else if (cmd == "ObjectEnd") { cb.end_object(object, stack.back()); stack.pop_back(); object = {}; } else if (cmd == "ObjectInstance") { auto value = pbrt_object{}; parse_value(stream, value.name); cb.object_instance(value, stack.back()); } else if (cmd == "ActiveTransform") { auto value = ""s; parse_command(stream, value); if (value == "StartTime") { stack.back().active_transform_start = true; stack.back().active_transform_end = false; } else if (value == "EndTime") { stack.back().active_transform_start = false; stack.back().active_transform_end = true; } else if (value == "All") { stack.back().active_transform_start = true; stack.back().active_transform_end = true; } else { throw std::runtime_error("bad active transform"); } } else if (cmd == "Transform") { auto xf = identity4x4f; parse_param(stream, xf); set_transform(stack.back(), xf); } else if (cmd == "ConcatTransform") { auto xf = identity4x4f; parse_param(stream, xf); concat_transform(stack.back(), xf); } else if (cmd == "Scale") { auto v = zero3f; parse_param(stream, v); concat_transform(stack.back(), (mat4f)scaling_frame(v)); } else if (cmd == "Translate") { auto v = zero3f; parse_param(stream, v); concat_transform(stack.back(), (mat4f)translation_frame(v)); } else if (cmd == "Rotate") { auto v = zero4f; parse_param(stream, v); concat_transform(stack.back(), (mat4f)rotation_frame(vec3f{v.y, v.z, v.w}, radians(v.x))); } else if (cmd == "LookAt") { auto from = zero3f, to = zero3f, up = zero3f; parse_param(stream, from); parse_param(stream, to); parse_param(stream, up); // from pbrt parser auto frame = lookat_frame(from, to, up, true); // frame.z = normalize(to-from); // frame.x = normalize(cross(frame.z,up)); // frame.y = cross(frame.x,frame.z); // frame.o = from; concat_transform(stack.back(), (mat4f)inverse(frame)); stack.back().last_lookat_distance = length(from - to); // stack.back().focus = length(m.x - m.y); } else if (cmd == "ReverseOrientation") { stack.back().reverse = !stack.back().reverse; } else if (cmd == "CoordinateSystem") { auto name = ""s; parse_value(stream, name); coordsys[name] = { stack.back().transform_start, stack.back().transform_end}; } else if (cmd == "CoordSysTransform") { auto name = ""s; parse_value(stream, name); if (coordsys.find(name) != coordsys.end()) { stack.back().transform_start = coordsys.at(name).first; stack.back().transform_end = coordsys.at(name).second; } } else if (cmd == "Integrator") { auto type = ""s; parse_value(stream, type); auto value = pbrt_integrator{}; parse_integrator(stream, type, value); cb.integrator(value, stack.back()); } else if (cmd == "Sampler") { auto type = ""s; parse_value(stream, type); auto value = pbrt_sampler{}; parse_sampler(stream, type, value); cb.sampler(value, stack.back()); } else if (cmd == "PixelFilter") { auto type = ""s; parse_value(stream, type); auto value = pbrt_filter{}; parse_filter(stream, type, value); cb.filter(value, stack.back()); } else if (cmd == "Film") { auto type = ""s; parse_value(stream, type); auto value = pbrt_film{}; parse_film(stream, type, value); cb.film(value, stack.back()); } else if (cmd == "Accelerator") { auto type = ""s; parse_value(stream, type); auto value = pbrt_accelerator{}; parse_accelerator(stream, type, value); cb.accelerator(value, stack.back()); } else if (cmd == "Camera") { auto type = ""s; parse_value(stream, type); auto value = pbrt_camera{}; parse_camera(stream, type, value); cb.camera(value, stack.back()); } else if (cmd == "Texture") { auto name = ""s, comptype = ""s, type = ""s; parse_value(stream, name); parse_value(stream, comptype); parse_value(stream, type); auto value = pbrt_texture{}; parse_texture(stream, type, value); if (type == "constant") { constant_values[name] = value.constant.value.value; } cb.texture(value, name, stack.back()); } else if (cmd == "Material") { static auto material_id = 0; auto type = ""s; parse_value(stream, type); if (type == "") { stack.back().material = ""; } else { auto value = pbrt_material{}; auto name = "unnamed_material_" + std::to_string(material_id++); parse_material(stream, type, value, constant_values); stack.back().material = name; cb.material(value, name, stack.back()); } } else if (cmd == "MakeNamedMaterial") { auto name = ""s, type = ""s; parse_value(stream, name); parse_typeparam(stream, type); auto value = pbrt_material{}; parse_material(stream, type, value, constant_values); cb.material(value, name, stack.back()); } else if (cmd == "NamedMaterial") { auto name = ""s; parse_value(stream, name); stack.back().material = name; } else if (cmd == "Shape") { auto type = ""s; parse_value(stream, type); auto value = pbrt_shape{}; parse_shape(stream, type, value); cb.shape(value, stack.back()); } else if (cmd == "AreaLightSource") { auto type = ""s; parse_value(stream, type); static auto material_id = 0; auto name = "unnamed_arealight_" + std::to_string(material_id++); auto value = pbrt_arealight{}; parse_arealight(stream, type, value); stack.back().arealight = name; cb.arealight(value, name, stack.back()); } else if (cmd == "LightSource") { auto type = ""s; parse_value(stream, type); auto value = pbrt_light{}; parse_light(stream, type, value); cb.light(value, stack.back()); } else if (cmd == "MakeNamedMedium") { auto name = ""s, type = ""s; parse_value(stream, name); parse_typeparam(stream, type); auto value = pbrt_medium{}; parse_pbrt_medium(stream, type, value); cb.medium(value, name, stack.back()); } else if (cmd == "MediumInterface") { auto interior = ""s, exterior = ""s; parse_value(stream, interior); parse_value(stream, exterior); stack.back().medium_interior = interior; stack.back().medium_exterior = exterior; } else if (cmd == "Include") { auto inputname = ""s; parse_value(stream, inputname); load_stream(fs::path(filename).parent_path() / inputname, streams); } else { throw std::runtime_error("unknown command " + cmd); } // go to next file if needed skip_whitespace_or_comment_to_next_file(streams); } } } // namespace yocto goxel-0.11.0/ext_src/yocto/yocto_pbrt.h000066400000000000000000000641171435762723100200730ustar00rootroot00000000000000// // # Yocto/Pbrt: Tiny library for Pbrt parsing // // Yocto/Pbrt is a simple pbrt parser that works with callbacks. // We make no attempt to provide a simple interface for pbrt but just the // low level parsing code. // // Error reporting is done through exceptions using the `io_error` // exception. // // ## Parse an pbrt file // // 1. define callbacks in `pbrt_callback` structure using lambda with capture // if desired // 2. run the parse with `load_pbrt()` // // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // #ifndef _YOCTO_PBRT_H_ #define _YOCTO_PBRT_H_ // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include "yocto_math.h" // ----------------------------------------------------------------------------- // SIMPLE PBRT LOADER // ----------------------------------------------------------------------------- namespace yocto { // pbrt pbrt_spectrum as rgb color struct pbrt_spectrum3f { float x = 0; float y = 0; float z = 0; pbrt_spectrum3f() : x{0}, y{0}, z{0} {} pbrt_spectrum3f(float x, float y, float z) : x{x}, y{y}, z{z} {} explicit pbrt_spectrum3f(float v) : x{v}, y{v}, z{v} {} explicit operator vec3f() const { return {x, y, z}; }; float& operator[](int i) { return (&x)[i]; } const float& operator[](int i) const { return (&x)[i]; } }; // pbrt cameras struct pbrt_camera { struct perspective_t { float fov = 90; float frameaspectratio = -1; // or computed from film float lensradius = 0; float focaldistance = 1e30; vec4f screenwindow = {-1, 1, -1, 1}; float shutteropen = 0; float shutterclose = 1; }; struct orthographic_t { float frameaspectratio = -1; // or computed from film float lensradius = 0; float focaldistance = 1e30; vec4f screenwindow = {-1, 1, -1, 1}; float shutteropen = 0; float shutterclose = 1; }; struct environment_t { float shutteropen = 0; float shutterclose = 1; }; struct realistic_t { string lensfile = ""; float aperturediameter = 1; float focusdistance = 10; bool simpleweighting = true; float shutteropen = 0; float shutterclose = 1; float approx_focallength = 0; }; enum struct type_t { perspective, orthographic, environment, realistic }; type_t type = type_t::perspective; perspective_t perspective = {}; orthographic_t orthographic = {}; environment_t environment = {}; realistic_t realistic = {}; }; // pbrt samplers struct pbrt_sampler { struct random_t { int pixelsamples = 16; }; struct halton_t { int pixelsamples = 16; }; struct sobol_t { int pixelsamples = 16; }; struct zerotwosequence_t { int pixelsamples = 16; }; struct maxmindist_t { int pixelsamples = 16; }; struct stratified_t { bool jitter = true; int xsamples = 2; int ysamples = 2; }; enum struct type_t { random, halton, sobol, zerotwosequence, maxmindist, stratified }; type_t type = type_t::random; random_t random = {}; halton_t halton = {}; sobol_t sobol = {}; zerotwosequence_t zerotwosequence = {}; maxmindist_t maxmindist = {}; stratified_t stratified = {}; }; // pbrt film struct pbrt_film { struct image_t { int xresolution = 640; int yresolution = 480; vec4f cropwindow = {0, 1, 0, 1}; float scale = 1; float maxsampleluminance = flt_max; float diagonal = 35; string filename = "pbrt.exr"; }; enum struct type_t { image }; type_t type = type_t::image; image_t image = {}; }; // pbrt filters struct pbrt_filter { struct box_t { float xwidth = 0.5; float ywidth = 0.5; }; struct gaussian_t { float xwidth = 2; float ywidth = 2; float alpha = 2; }; struct mitchell_t { float xwidth = 2; float ywidth = 2; float B = 1.0f / 3.0f; float C = 1.0f / 3.0f; }; struct sinc_t { float xwidth = 4; float ywidth = 4; float tau = 3; }; struct triangle_t { float xwidth = 2; float ywidth = 2; }; enum struct type_t { box, gaussian, mitchell, sinc, triangle }; type_t type = type_t::box; box_t box = {}; gaussian_t gaussian = {}; mitchell_t mitchell = {}; sinc_t sinc = {}; triangle_t triangle = {}; }; // pbrt integrators struct pbrt_integrator { struct path_t { enum struct lightsamplestrategy_t { uniform, power, spatial }; int maxdepth = 5; vec4i pixelbounds = {0, 0, int_max, int_max}; float rrthreshold = 1; lightsamplestrategy_t lightsamplestrategy = lightsamplestrategy_t::spatial; }; struct volpath_t { enum struct lightsamplestrategy_t { uniform, power, spatial }; int maxdepth = 5; vec4i pixelbounds = {0, 0, int_max, int_max}; float rrthreshold = 1; lightsamplestrategy_t lightsamplestrategy = lightsamplestrategy_t::spatial; }; struct bdpt_t { enum struct lightsamplestrategy_t { uniform, power, spatial }; int maxdepth = 5; vec4i pixelbounds = {0, 0, int_max, int_max}; lightsamplestrategy_t lightsamplestrategy = lightsamplestrategy_t::power; bool visualizestrategies = false; bool visualizeweights = false; }; struct directlighting_t { enum struct strategy_t { all, one }; strategy_t strategy = strategy_t::all; int maxdepth = 5; vec4i pixelbounds = {0, 0, int_max, int_max}; }; struct mlt_t { int maxdepth = 5; vec4i pixelbounds = {0, 0, int_max, int_max}; int bootstrapsamples = 100000; int chains = 1000; int mutationsperpixel = 100; float largestepprobability = 0.3; float sigma = 0.01; }; struct sppm_t { int maxdepth = 5; vec4i pixelbounds = {0, 0, int_max, int_max}; int iterations = 64; int photonsperiteration = -1; int imagewritefrequency = pow2(31); float radius = 5; }; struct whitted_t { int maxdepth = 5; vec4i pixelbounds = {0, 0, int_max, int_max}; }; enum struct type_t { path, volpath, bdpt, directlighting, mlt, sppm, whitted }; type_t type = type_t::path; path_t path = {}; volpath_t volpath = {}; bdpt_t bdpt = {}; directlighting_t directlighting = {}; mlt_t mlt = {}; sppm_t sppm = {}; whitted_t whitted = {}; }; // pbrt accellerators struct pbrt_accelerator { struct bvh_t { enum struct splitmethod_t { sah, equal, middle, hlbvh }; int maxnodeprims = 4; splitmethod_t splitmethod = splitmethod_t::sah; }; struct kdtree_t { int intersectcost = 80; int traversalcost = 1; float emptybonus = 0.2; int maxprims = 1; int maxdepth = -1; }; enum struct type_t { bvh, kdtree }; type_t type = type_t::bvh; bvh_t bvh = {}; kdtree_t kdtree = {}; }; // pbrt texture or value struct pbrt_textured1f { float value = 0; string texture = ""; pbrt_textured1f() : value{0}, texture{} {} pbrt_textured1f(float v) : value{v}, texture{} {} }; struct pbrt_textured3f { pbrt_spectrum3f value = {0, 0, 0}; string texture = ""; pbrt_textured3f() : value{0, 0, 0}, texture{} {} pbrt_textured3f(float x, float y, float z) : value{x, y, z}, texture{} {} }; // pbrt textures struct pbrt_texture { struct constant_t { pbrt_textured3f value = {1, 1, 1}; }; struct bilerp_t { pbrt_textured3f v00 = {0, 0, 0}; pbrt_textured3f v01 = {1, 1, 1}; pbrt_textured3f v10 = {0, 0, 0}; pbrt_textured3f v11 = {1, 1, 1}; enum struct mapping_type { uv, spherical, cylindrical, planar }; mapping_type mapping = mapping_type::uv; float uscale = 1; float vscale = 1; float udelta = 0; float vdelta = 0; vec3f v1 = {1, 0, 0}; vec3f v2 = {0, 1, 0}; }; struct checkerboard_t { enum struct aamode_type { closedform, none }; int dimension = 2; pbrt_textured3f tex1 = {1, 1, 1}; pbrt_textured3f tex2 = {0, 0, 0}; aamode_type aamode = aamode_type::closedform; enum struct mapping_type { uv, spherical, cylindrical, planar }; mapping_type mapping = mapping_type::uv; float uscale = 1; float vscale = 1; float udelta = 0; float vdelta = 0; vec3f v1 = {1, 0, 0}; vec3f v2 = {0, 1, 0}; }; struct dots_t { pbrt_textured3f inside = {1, 1, 1}; pbrt_textured3f outside = {0, 0, 0}; enum struct mapping_type { uv, spherical, cylindrical, planar }; mapping_type mapping = mapping_type::uv; float uscale = 1; float vscale = 1; float udelta = 0; float vdelta = 0; vec3f v1 = {1, 0, 0}; vec3f v2 = {0, 1, 0}; }; struct fbm_t { int octaves = 8; float roughness = 0.5; }; struct imagemap_t { enum wrap_type { repeat, black, clamp }; string filename = ""; wrap_type wrap = wrap_type::repeat; float maxanisotropy = 8; bool trilinear = false; float scale = 1; bool gamma = true; enum struct mapping_type { uv, spherical, cylindrical, planar }; mapping_type mapping = mapping_type::uv; float uscale = 1; float vscale = 1; float udelta = 0; float vdelta = 0; vec3f v1 = {1, 0, 0}; vec3f v2 = {0, 1, 0}; }; struct marble_t { int octaves = 8; float roughness = 0.5; float scale = 1; float variation = 0.2; }; struct mix_t { pbrt_textured3f tex1 = {1, 1, 1}; pbrt_textured3f tex2 = {1, 1, 1}; pbrt_textured1f amount = 0.5; }; struct scale_t { pbrt_textured3f tex1 = {1, 1, 1}; pbrt_textured3f tex2 = {1, 1, 1}; }; struct uv_t { enum struct mapping_type { uv, spherical, cylindrical, planar }; mapping_type mapping = mapping_type::uv; float uscale = 1; float vscale = 1; float udelta = 0; float vdelta = 0; vec3f v1 = {1, 0, 0}; vec3f v2 = {0, 1, 0}; }; struct windy_t { // TODO: missing parameters }; struct wrinkled_t { int octaves = 8; float roughness = 0.5; }; enum struct type_t { constant, bilerp, checkerboard, dots, fbm, imagemap, marble, mix, scale, uv, windy, wrinkled }; type_t type = type_t::constant; constant_t constant = {}; bilerp_t bilerp = {}; checkerboard_t checkerboard = {}; dots_t dots = {}; fbm_t fbm = {}; imagemap_t imagemap = {}; marble_t marble = {}; mix_t mix = {}; scale_t scale = {}; uv_t uv = {}; windy_t windy = {}; wrinkled_t wrinkled = {}; }; // pbrt materials struct pbrt_material { struct matte_t { pbrt_textured3f Kd = {0.5, 0.5, 0.5}; pbrt_textured1f sigma = 0; pbrt_textured1f bumpmap = 0; }; struct mirror_t { pbrt_textured3f Kr = {0.9, 0.9, 0.9}; pbrt_textured1f bumpmap = 0; }; struct plastic_t { pbrt_textured3f Kd = {0.25, 0.25, 0.25}; pbrt_textured3f Ks = {0.25, 0.25, 0.25}; pbrt_textured1f uroughness = 0.1; pbrt_textured1f vroughness = 0.1; bool remaproughness = true; pbrt_textured1f bumpmap = 0; }; struct metal_t { pbrt_textured3f eta = {0.2004376970f, 0.9240334304f, 1.1022119527f}; pbrt_textured3f k = {3.9129485033f, 2.4528477015f, 2.1421879552f}; pbrt_textured1f uroughness = 0.01; pbrt_textured1f vroughness = 0.01; bool remaproughness = true; pbrt_textured1f bumpmap = 0; }; struct glass_t { pbrt_textured3f Kr = {1, 1, 1}; pbrt_textured3f Kt = {1, 1, 1}; pbrt_textured1f eta = 1.5; pbrt_textured1f uroughness = 0; pbrt_textured1f vroughness = 0; bool remaproughness = true; pbrt_textured1f bumpmap = 0; }; struct translucent_t { pbrt_textured3f Kd = {0.25, 0.25, 0.25}; pbrt_textured3f Ks = {0.25, 0.25, 0.25}; pbrt_textured3f reflect = {0.5, 0.5, 0.5}; pbrt_textured3f transmit = {0.5, 0.5, 0.5}; pbrt_textured1f uroughness = 0.1; pbrt_textured1f vroughness = 0.1; bool remaproughness = true; pbrt_textured1f bumpmap = 0; }; struct uber_t { pbrt_textured3f Kd = {0.25, 0.25, 0.25}; pbrt_textured3f Ks = {0.25, 0.25, 0.25}; pbrt_textured3f Kr = {0, 0, 0}; pbrt_textured3f Kt = {0, 0, 0}; pbrt_textured1f uroughness = 0.1; pbrt_textured1f vroughness = 0.1; pbrt_textured1f eta = 1.5; pbrt_textured3f opacity = {1, 1, 1}; bool remaproughness = true; pbrt_textured1f bumpmap = 0; }; struct disney_t { pbrt_textured3f color = {0.5, 0.5, 0.5}; pbrt_textured1f anisotropic = 0; pbrt_textured1f clearcoat = 0; pbrt_textured1f clearcoatgloss = 1; pbrt_textured1f eta = 1.5; pbrt_textured1f metallic = 0; pbrt_textured1f uroughness = 0.5; pbrt_textured1f vroughness = 0.5; pbrt_textured3f scatterdistance = {0, 0, 0}; pbrt_textured1f sheen = 0; pbrt_textured1f sheentint = 0.5; pbrt_textured1f spectrans = 0; pbrt_textured1f speculartint = 0; bool thin = false; pbrt_textured3f difftrans = {1, 1, 1}; pbrt_textured3f flatness = {0, 0, 0}; bool remaproughness = true; pbrt_textured1f bumpmap = 0; }; struct fourier_t { string bsdffile = ""; pbrt_textured1f bumpmap = 0; enum struct approx_type_t { plastic, metal, glass }; approx_type_t approx_type = approx_type_t::plastic; plastic_t approx_plastic = {}; metal_t approx_metal = {}; glass_t approx_glass = {}; }; struct hair_t { pbrt_textured3f color = {0, 0, 0}; // TODO: missing default pbrt_textured3f sigma_a = {0, 0, 0}; // TODO: missing default pbrt_textured1f eumelanin = 0; // TODO: missing default pbrt_textured1f pheomelanin = 0; // TODO: missing default pbrt_textured1f eta = 1.55f; pbrt_textured1f beta_m = 0.3f; pbrt_textured1f beta_n = 0.3f; pbrt_textured1f alpha = 2; pbrt_textured1f bumpmap = 0; }; struct kdsubsurface_t { pbrt_textured3f Kd = {0.5, 0.5, 0.5}; pbrt_textured3f mfp = {1, 1, 1}; pbrt_textured1f eta = 1.3; pbrt_textured3f Kr = {1, 1, 1}; pbrt_textured3f Kt = {1, 1, 1}; pbrt_textured1f uroughness = 0; pbrt_textured1f vroughness = 0; bool remaproughness = true; pbrt_textured1f bumpmap = 0; }; struct mix_t { pbrt_textured3f amount = {0, 0, 0}; string namedmaterial1 = ""; string namedmaterial2 = ""; pbrt_textured1f bumpmap = 0; }; struct substrate_t { pbrt_textured3f Kd = {0.5, 0.5, 0.5}; pbrt_textured3f Ks = {0.5, 0.5, 0.5}; pbrt_textured1f uroughness = 0.1; pbrt_textured1f vroughness = 0.1; bool remaproughness = true; pbrt_textured1f bumpmap = 0; }; struct subsurface_t { string name = ""; pbrt_textured3f sigma_a = {.0011, .0024, .014}; pbrt_textured3f sigma_prime_s = {2.55, 3.12, 3.77}; float scale = 1; pbrt_textured1f eta = 1; pbrt_textured3f Kr = {1, 1, 1}; pbrt_textured3f Kt = {1, 1, 1}; pbrt_textured1f uroughness = 0; pbrt_textured1f vroughness = 0; bool remaproughness = true; pbrt_textured1f bumpmap = 0; }; enum struct type_t { matte, mirror, plastic, metal, glass, translucent, uber, disney, fourier, hair, kdsubsurface, mix, substrate, subsurface }; type_t type = type_t::matte; matte_t matte = {}; mirror_t mirror = {}; plastic_t plastic = {}; metal_t metal = {}; glass_t glass = {}; translucent_t translucent = {}; uber_t uber = {}; disney_t disney = {}; fourier_t fourier = {}; hair_t hair = {}; kdsubsurface_t kdsubsurface = {}; mix_t mix = {}; substrate_t substrate = {}; subsurface_t subsurface{}; }; // pbrt shapes struct pbrt_shape { struct trianglemesh_t { vector indices = {}; vector P = {}; vector N = {}; vector S = {}; vector uv = {}; pbrt_textured1f alpha = 1; pbrt_textured1f shadowalpha = 1; }; struct plymesh_t { string filename = {}; pbrt_textured1f alpha = 1; pbrt_textured1f shadowalpha = 1; }; struct curve_t { enum struct type_t { flat, ribbon, cylinder }; enum struct basis_t { bezier, bspline }; vector P = {}; basis_t basis = basis_t::bezier; int degree = 3; type_t type = type_t::flat; vector N = {}; float width0 = 1; float width1 = 1; int splitdepth = 3; }; struct loopsubdiv_t { int levels = 3; vector indices = {}; vector P = {}; }; struct nurbs_t { int nu = -1; int nv = -1; vector uknots = {}; vector vknots = {}; float u0 = -1; float v0 = -1; float u1 = -1; float v1 = -1; vector P = {}; vector Pw = {}; }; struct sphere_t { float radius = 1; float zmin = -radius; float zmax = radius; float phimax = 360; }; struct disk_t { float height = 0; float radius = 1; float innerradius = 0; float phimax = 360; }; struct cone_t { float radius = 1; float height = 1; float phimax = 360; }; struct cylinder_t { float radius = 1; float zmin = -1; float zmax = 1; float phimax = 360; }; struct hyperboloid_t { vec3f p1 = {0, 0, 0}; vec3f p2 = {1, 1, 1}; float phimax = 360; }; struct paraboloid_t { float radius = 1; float zmin = 0; float zmax = 1; float phimax = 360; }; struct heightfield_t { int nu = 0; int nv = 0; vector Pz = {}; }; enum struct type_t { trianglemesh, plymesh, curve, loopsubdiv, nurbs, sphere, disk, cone, cylinder, hyperboloid, paraboloid, heightfield }; type_t type = type_t::trianglemesh; trianglemesh_t trianglemesh = {}; plymesh_t plymesh = {}; curve_t curve = {}; loopsubdiv_t loopsubdiv = {}; nurbs_t nurbs = {}; sphere_t sphere = {}; disk_t disk = {}; cone_t cone = {}; cylinder_t cylinder = {}; hyperboloid_t hyperboloid = {}; paraboloid_t paraboloid = {}; heightfield_t heightfield = {}; }; // pbrt lights struct pbrt_light { struct distant_t { pbrt_spectrum3f scale = {1, 1, 1}; pbrt_spectrum3f L = {1, 1, 1}; vec3f from = {0, 0, 0}; vec3f to = {0, 0, 1}; }; struct goniometric_t { pbrt_spectrum3f scale = {1, 1, 1}; pbrt_spectrum3f I = {1, 1, 1}; string mapname = ""; }; struct infinite_t { pbrt_spectrum3f scale = {1, 1, 1}; pbrt_spectrum3f L = {1, 1, 1}; int samples = 1; string mapname = ""; }; struct point_t { pbrt_spectrum3f scale = {1, 1, 1}; pbrt_spectrum3f I = {1, 1, 1}; vec3f from = {0, 0, 0}; }; struct projection_t { pbrt_spectrum3f scale = {1, 1, 1}; pbrt_spectrum3f I = {1, 1, 1}; float fov = 45; string mapname = ""; }; struct spot_t { pbrt_spectrum3f scale = {1, 1, 1}; pbrt_spectrum3f I = {1, 1, 1}; vec3f from = {0, 0, 0}; vec3f to = {0, 0, 1}; float coneangle = 30; float conedeltaangle = 5; }; enum struct type_t { distant, goniometric, infinite, point, projection, spot }; type_t type = type_t::distant; distant_t distant = {}; goniometric_t goniometric = {}; infinite_t infinite = {}; point_t point = {}; projection_t projection = {}; spot_t spot = {}; }; // pbrt area lights struct pbrt_arealight { struct none_t {}; struct diffuse_t { pbrt_spectrum3f scale = {1, 1, 1}; pbrt_spectrum3f L = {1, 1, 1}; bool twosided = false; int samples = 1; }; enum struct type_t { none, diffuse }; type_t type = type_t::none; none_t none = {}; diffuse_t diffuse = {}; }; // pbrt mediums struct pbrt_medium { struct homogeneous_t { pbrt_spectrum3f sigma_a = {0.0011, 0.0024, 0.014}; pbrt_spectrum3f sigma_s = {2.55, 3.21, 3.77}; string preset = ""; float g = 0; float scale = 1; }; struct heterogeneous_t { pbrt_spectrum3f sigma_a = {0.0011f, 0.0024f, 0.014f}; pbrt_spectrum3f sigma_s = {2.55f, 3.21f, 3.77f}; string preset = ""; float g = 0; float scale = 1; vec3f p0 = {0, 0, 0}; vec3f p1 = {1, 1, 1}; int nx = 1; int ny = 1; int nz = 1; vector density = {}; }; enum struct type_t { homogeneous, heterogeneous }; type_t type = type_t::homogeneous; homogeneous_t homogeneous = {}; heterogeneous_t heterogeneous = {}; }; // pbrt medium interface struct pbrt_mediuminterface { string interior = ""; string exterior = ""; }; // pbrt insstance struct pbrt_object { string name = ""; }; // pbrt stack ctm struct pbrt_context { frame3f transform_start = identity3x4f; frame3f transform_end = identity3x4f; string material = ""; string arealight = ""; string medium_interior = ""; string medium_exterior = ""; bool reverse = false; bool active_transform_start = true; bool active_transform_end = true; float last_lookat_distance = 0; }; // pbrt callbacks struct pbrt_callbacks { virtual void sampler(const pbrt_sampler& value, const pbrt_context& ctx) {} virtual void integrator( const pbrt_integrator& value, const pbrt_context& ctx) {} virtual void accelerator( const pbrt_accelerator& value, const pbrt_context& ctx) {} virtual void film(const pbrt_film& value, const pbrt_context& ctx) {} virtual void filter(const pbrt_filter& value, const pbrt_context& ctx) {} virtual void camera(const pbrt_camera& value, const pbrt_context& ctx) {} virtual void texture( const pbrt_texture& value, const string& name, const pbrt_context& ctx) {} virtual void material(const pbrt_material& value, const string& name, const pbrt_context& ctx) {} virtual void medium( const pbrt_medium& value, const string& name, const pbrt_context& ctx) {} virtual void shape(const pbrt_shape& value, const pbrt_context& ctx) {} virtual void light(const pbrt_light& value, const pbrt_context& ctx) {} virtual void arealight(const pbrt_arealight& value, const string& name, const pbrt_context& ctx) {} virtual void object_instance( const pbrt_object& value, const pbrt_context& ctx) {} virtual void begin_object(const pbrt_object& value, const pbrt_context& ctx) { } virtual void end_object(const pbrt_object& value, const pbrt_context& ctx) {} }; // Load pbrt scene void load_pbrt(const string& filename, pbrt_callbacks& cb, bool flipv = true); } // namespace yocto #endif goxel-0.11.0/ext_src/yocto/yocto_random.h000066400000000000000000000522641435762723100204040ustar00rootroot00000000000000// // # Yocto/Random: Tiny library for random number generatio and Monte Carlo. // // Yocto/Random provides utilities for random number generation, hasing, // Monte Carlo integration and sampling and Perloin noise. // // // ## Random Number Generation, Noise, and Monte Carlo support // // This library supports many facilities helpful in writing sampling // functions targeting path tracing and shape generations. Implementation of // Perlin noise is include based on stb libraries. // // 1. Random number generation with PCG32: // 1. initialize the random number generator with `make_rng()` // 2. advance the random number state with `advance_rng()` // 3. if necessary, you can reseed the rng with `seed_rng()` // 4. generate random integers in an interval with `rand1i()` // 5. generate random floats and double in the [0,1) range with // `rand1f()`, `rand2f()`, `rand3f()`, // `next_rand1d()` // 2. Perlin noise: `perlin_noise()` to generate Perlin noise with optional // wrapping, with fractal variations `perlin_ridge()`, // `perlin_fbm()`, `perlin_turbulence()` // 3. Monte Carlo support: warp functions from [0,1)^k domains to domains // commonly used in path tracing. In particular, use // `sample_hemisphere()`, `sample_sphere()`, // `sample_hemisphere_cos()`, // `sample_hemisphere_cospower()`. `sample_disk()`. // `sample_cylinder()`. `sample_triangle()`, // `sample_discrete()`. For each warp, you can compute // the PDF with `sample_xxx_pdf()`. // // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // // LICENSE OF INCLUDED SOFTWARE for Pcg random number generator // // This code also includes a small exerpt from http://www.pcg-random.org/ // licensed as follows // *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / pcg-random.org // Licensed under Apache License 2.0 (NO WARRANTY, etc. see website) // // // LICENCE OF INCLUDED SOFTWARE FOR PERLIN NOISE // https://github.com/nothings/stb/blob/master/stb_perlin.h // // ------------------------------------------------------------------------------ // ALTERNATIVE B - Public Domain (www.unlicense.org) // This is free and unencumbered software released into the public domain. // Anyone is free to copy, modify, publish, use, compile, sell, or distribute // this software, either in source code form or as a compiled binary, for any // purpose, commercial or non-commercial, and by any means. In jurisdictions // that recognize copyright laws, the author or authors of this software // dedicate any and all copyright interest in the software to the public domain. // We make this dedication for the benefit of the public at large and to the // detriment of our heirs and successors. We intend this dedication to be an // overt act of relinquishment in perpetuity of all present and future rights to // this software under copyright law. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // ------------------------------------------------------------------------------ // // #ifndef _YOCTO_RANDOM_H_ #define _YOCTO_RANDOM_H_ // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include "yocto_math.h" #include // ----------------------------------------------------------------------------- // RANDOM NUMBER GENERATION // ----------------------------------------------------------------------------- namespace yocto { // PCG random numbers from http://www.pcg-random.org/ struct rng_state { uint64_t state = 0x853c49e6748fea9bULL; uint64_t inc = 0xda3e39cb94b95bdbULL; rng_state() : state{0x853c49e6748fea9bULL}, inc{0xda3e39cb94b95bdbULL} {} rng_state(uint64_t state, uint64_t inc) : state{state}, inc{inc} {} }; // Next random number, used internally only. inline uint32_t _advance_rng(rng_state& rng) { uint64_t oldstate = rng.state; rng.state = oldstate * 6364136223846793005ULL + rng.inc; uint32_t xorshifted = (uint32_t)(((oldstate >> 18u) ^ oldstate) >> 27u); uint32_t rot = (uint32_t)(oldstate >> 59u); return (xorshifted >> rot) | (xorshifted << ((-rot) & 31)); } // Init a random number generator with a state state from the sequence seq. inline rng_state make_rng(uint64_t seed, uint64_t seq = 1) { auto rng = rng_state(); rng.state = 0U; rng.inc = (seq << 1u) | 1u; _advance_rng(rng); rng.state += seed; _advance_rng(rng); return rng; } // Next random numbers: floats in [0,1), ints in [0,n). inline int rand1i(rng_state& rng, int n) { return _advance_rng(rng) % n; } inline float rand1f(rng_state& rng) { union { uint32_t u; float f; } x; x.u = (_advance_rng(rng) >> 9) | 0x3f800000u; return x.f - 1.0f; // alternate implementation // const static auto scale = (float)(1.0 / numeric_limits::max()); // return advance_rng(rng) * scale; } inline vec2f rand2f(rng_state& rng) { // force order of evaluation by using separate assignments. auto x = rand1f(rng); auto y = rand1f(rng); return {x, y}; } inline vec3f rand3f(rng_state& rng) { // force order of evaluation by using separate assignments. auto x = rand1f(rng); auto y = rand1f(rng); auto z = rand1f(rng); return {x, y, z}; } // Shuffles a sequence of elements template inline void shuffle(vector& vals, rng_state& rng) { // https://en.wikipedia.org/wiki/Fisher–Yates_shuffle for (auto i = (int)vals.size() - 1; i > 0; i--) { auto j = rand1i(rng, i + 1); std::swap(vals[j], vals[i]); } } } // namespace yocto // ----------------------------------------------------------------------------- // MONETACARLO SAMPLING FUNCTIONS // ----------------------------------------------------------------------------- namespace yocto { // Sample an hemispherical direction with uniform distribution. inline vec3f sample_hemisphere(const vec2f& ruv) { auto z = ruv.y; auto r = sqrt(clamp(1 - z * z, 0.0f, 1.0f)); auto phi = 2 * pif * ruv.x; return {r * cos(phi), r * sin(phi), z}; } inline float sample_hemisphere_pdf(const vec3f& direction) { return (direction.z <= 0) ? 0 : 1 / (2 * pif); } // Sample an hemispherical direction with uniform distribution. inline vec3f sample_hemisphere(const vec3f& normal, const vec2f& ruv) { auto z = ruv.y; auto r = sqrt(clamp(1 - z * z, 0.0f, 1.0f)); auto phi = 2 * pif * ruv.x; auto local_direction = vec3f{r * cos(phi), r * sin(phi), z}; return transform_direction(basis_fromz(normal), local_direction); } inline float sample_hemisphere_pdf( const vec3f& normal, const vec3f& direction) { return (dot(normal, direction) <= 0) ? 0 : 1 / (2 * pif); } // Sample a spherical direction with uniform distribution. inline vec3f sample_sphere(const vec2f& ruv) { auto z = 2 * ruv.y - 1; auto r = sqrt(clamp(1 - z * z, 0.0f, 1.0f)); auto phi = 2 * pif * ruv.x; return {r * cos(phi), r * sin(phi), z}; } inline float sample_sphere_pdf(const vec3f& w) { return 1 / (4 * pif); } // Sample an hemispherical direction with cosine distribution. inline vec3f sample_hemisphere_cos(const vec2f& ruv) { auto z = sqrt(ruv.y); auto r = sqrt(1 - z * z); auto phi = 2 * pif * ruv.x; return {r * cos(phi), r * sin(phi), z}; } inline float sample_hemisphere_cos_pdf(const vec3f& direction) { return (direction.z <= 0) ? 0 : direction.z / pif; } // Sample an hemispherical direction with cosine power distribution. inline vec3f sample_hemisphere_cospower(float exponent, const vec2f& ruv) { auto z = pow(ruv.y, 1 / (exponent + 1)); auto r = sqrt(1 - z * z); auto phi = 2 * pif * ruv.x; return {r * cos(phi), r * sin(phi), z}; } inline float sample_hemisphere_cospower_pdf( float exponent, const vec3f& direction) { return (direction.z <= 0) ? 0 : pow(direction.z, exponent) * (exponent + 1) / (2 * pif); } // Sample a point uniformly on a disk. inline vec2f sample_disk(const vec2f& ruv) { auto r = sqrt(ruv.y); auto phi = 2 * pif * ruv.x; return {cos(phi) * r, sin(phi) * r}; } inline float sample_disk_pdf() { return 1 / pif; } // Sample a point uniformly on a cylinder, without caps. inline vec3f sample_cylinder(const vec2f& ruv) { auto phi = 2 * pif * ruv.x; return {sin(phi), cos(phi), ruv.y * 2 - 1}; } inline float sample_cylinder_pdf() { return 1 / pif; } // Sample a point uniformly on a triangle returning the baricentric coordinates. inline vec2f sample_triangle(const vec2f& ruv) { return {1 - sqrt(ruv.x), ruv.y * sqrt(ruv.x)}; } // Sample a point uniformly on a triangle. inline vec3f sample_triangle( const vec3f& p0, const vec3f& p1, const vec3f& p2, const vec2f& ruv) { auto uv = sample_triangle(ruv); return p0 * (1 - uv.x - uv.y) + p1 * uv.x + p2 * uv.y; } // Pdf for uniform triangle sampling, i.e. triangle area. inline float sample_triangle_pdf( const vec3f& p0, const vec3f& p1, const vec3f& p2) { return 2 / length(cross(p1 - p0, p2 - p0)); } // Sample an index with uniform distribution. inline int sample_uniform(int size, float r) { return clamp((int)(r * size), 0, size - 1); } inline float sample_uniform_pdf(int size) { return (float)1 / (float)size; } // Sample an index with uniform distribution. inline float sample_uniform(const vector& elements, float r) { if (elements.empty()) return {}; auto size = (int)elements.size(); return elements[clamp((int)(r * size), 0, size - 1)]; } inline float sample_uniform_pdf(const vector& elements) { if (elements.empty()) return 0; return 1.0f / (int)elements.size(); } // Sample a discrete distribution represented by its cdf. inline int sample_discrete(const vector& cdf, float r) { r = clamp(r * cdf.back(), (float)0, cdf.back() - (float)0.00001); auto idx = (int)(std::upper_bound(cdf.data(), cdf.data() + cdf.size(), r) - cdf.data()); return clamp(idx, 0, (int)cdf.size() - 1); } // Pdf for uniform discrete distribution sampling. inline float sample_discrete_pdf(const vector& cdf, int idx) { if (idx == 0) return cdf.at(0); return cdf.at(idx) - cdf.at(idx - 1); } } // namespace yocto // ----------------------------------------------------------------------------- // PERLIN NOISE FUNCTION // ----------------------------------------------------------------------------- namespace yocto { // Compute the revised Perlin noise function. Wrap provides a wrapping noise // but must be power of two (wraps at 256 anyway). For octave based noise, // good values are obtained with octaves=6 (numerber of noise calls), // lacunarity=~2.0 (spacing between successive octaves: 2.0 for warpping // output), gain=0.5 (relative weighting applied to each successive octave), // offset=1.0 (used to invert the ridges). inline float perlin_noise(const vec3f& p, const vec3i& wrap = zero3i); inline float perlin_ridge(const vec3f& p, float lacunarity = 2, float gain = 0.5, int octaves = 6, float offset = 1, const vec3i& wrap = zero3i); inline float perlin_fbm(const vec3f& p, float lacunarity = 2, float gain = 0.5, int octaves = 6, const vec3i& wrap = zero3i); inline float perlin_turbulence(const vec3f& p, float lacunarity = 2, float gain = 0.5, int octaves = 6, const vec3i& wrap = zero3i); } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION FOR PERLIN NOISE // ----------------------------------------------------------------------------- namespace yocto { // clang-format off inline float _stb__perlin_lerp(float a, float b, float t) { return a + (b-a) * t; } inline int _stb__perlin_fastfloor(float a) { int ai = (int) a; return (a < ai) ? ai-1 : ai; } // different grad function from Perlin's, but easy to modify to match reference inline float _stb__perlin_grad(int hash, float x, float y, float z) { static float basis[12][4] = { { 1, 1, 0 }, { -1, 1, 0 }, { 1,-1, 0 }, { -1,-1, 0 }, { 1, 0, 1 }, { -1, 0, 1 }, { 1, 0,-1 }, { -1, 0,-1 }, { 0, 1, 1 }, { 0,-1, 1 }, { 0, 1,-1 }, { 0,-1,-1 }, }; // perlin's gradient has 12 cases so some get used 1/16th of the time // and some 2/16ths. We reduce bias by changing those fractions // to 5/64ths and 6/64ths, and the same 4 cases get the extra weight. static unsigned char indices[64] = { 0,1,2,3,4,5,6,7,8,9,10,11, 0,9,1,11, 0,1,2,3,4,5,6,7,8,9,10,11, 0,1,2,3,4,5,6,7,8,9,10,11, 0,1,2,3,4,5,6,7,8,9,10,11, 0,1,2,3,4,5,6,7,8,9,10,11, }; // if you use reference permutation table, change 63 below to 15 to match reference // (this is why the ordering of the table above is funky) float *grad = basis[indices[hash & 63]]; return grad[0]*x + grad[1]*y + grad[2]*z; } inline float _stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap) { // not same permutation table as Perlin's reference to avoid copyright issues; // Perlin's table can be found at http://mrl.nyu.edu/~perlin/noise/ // @OPTIMIZE: should this be unsigned char instead of int for cache? static unsigned char _stb__perlin_randtab[512] = { 23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123, 152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72, 175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240, 8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57, 225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233, 94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172, 165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243, 65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122, 26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76, 250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246, 132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3, 91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231, 38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221, 131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62, 27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135, 61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5, // and a second copy so we don't need an extra mask or static initializer 23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123, 152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72, 175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240, 8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57, 225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233, 94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172, 165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243, 65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122, 26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76, 250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246, 132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3, 91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231, 38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221, 131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62, 27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135, 61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5, }; float u,v,w; float n000,n001,n010,n011,n100,n101,n110,n111; float n00,n01,n10,n11; float n0,n1; unsigned int x_mask = (x_wrap-1) & 255; unsigned int y_mask = (y_wrap-1) & 255; unsigned int z_mask = (z_wrap-1) & 255; int px = _stb__perlin_fastfloor(x); int py = _stb__perlin_fastfloor(y); int pz = _stb__perlin_fastfloor(z); int x0 = px & x_mask, x1 = (px+1) & x_mask; int y0 = py & y_mask, y1 = (py+1) & y_mask; int z0 = pz & z_mask, z1 = (pz+1) & z_mask; int r0,r1, r00,r01,r10,r11; #define _stb__perlin_ease(a) (((a*6-15)*a + 10) * a * a * a) x -= px; u = _stb__perlin_ease(x); y -= py; v = _stb__perlin_ease(y); z -= pz; w = _stb__perlin_ease(z); r0 = _stb__perlin_randtab[x0]; r1 = _stb__perlin_randtab[x1]; r00 = _stb__perlin_randtab[r0+y0]; r01 = _stb__perlin_randtab[r0+y1]; r10 = _stb__perlin_randtab[r1+y0]; r11 = _stb__perlin_randtab[r1+y1]; n000 = _stb__perlin_grad(_stb__perlin_randtab[r00+z0], x , y , z ); n001 = _stb__perlin_grad(_stb__perlin_randtab[r00+z1], x , y , z-1 ); n010 = _stb__perlin_grad(_stb__perlin_randtab[r01+z0], x , y-1, z ); n011 = _stb__perlin_grad(_stb__perlin_randtab[r01+z1], x , y-1, z-1 ); n100 = _stb__perlin_grad(_stb__perlin_randtab[r10+z0], x-1, y , z ); n101 = _stb__perlin_grad(_stb__perlin_randtab[r10+z1], x-1, y , z-1 ); n110 = _stb__perlin_grad(_stb__perlin_randtab[r11+z0], x-1, y-1, z ); n111 = _stb__perlin_grad(_stb__perlin_randtab[r11+z1], x-1, y-1, z-1 ); n00 = _stb__perlin_lerp(n000,n001,w); n01 = _stb__perlin_lerp(n010,n011,w); n10 = _stb__perlin_lerp(n100,n101,w); n11 = _stb__perlin_lerp(n110,n111,w); n0 = _stb__perlin_lerp(n00,n01,v); n1 = _stb__perlin_lerp(n10,n11,v); return _stb__perlin_lerp(n0,n1,u); } inline float _stb_perlin_ridge_noise3(float x, float y, float z,float lacunarity, float gain, float offset, int octaves,int x_wrap, int y_wrap, int z_wrap) { int i; float frequency = 1.0f; float prev = 1.0f; float amplitude = 0.5f; float sum = 0.0f; for (i = 0; i < octaves; i++) { float r = (float)(_stb_perlin_noise3(x*frequency,y*frequency,z*frequency,x_wrap,y_wrap,z_wrap)); r = r<0 ? -r : r; // fabs() r = offset - r; r = r*r; sum += r*amplitude*prev; prev = r; frequency *= lacunarity; amplitude *= gain; } return sum; } inline float _stb_perlin_fbm_noise3(float x, float y, float z,float lacunarity, float gain, int octaves,int x_wrap, int y_wrap, int z_wrap) { int i; float frequency = 1.0f; float amplitude = 1.0f; float sum = 0.0f; for (i = 0; i < octaves; i++) { sum += _stb_perlin_noise3(x*frequency,y*frequency,z*frequency,x_wrap,y_wrap,z_wrap)*amplitude; frequency *= lacunarity; amplitude *= gain; } return sum; } inline float _stb_perlin_turbulence_noise3(float x, float y, float z, float lacunarity, float gain, int octaves,int x_wrap, int y_wrap, int z_wrap) { int i; float frequency = 1.0f; float amplitude = 1.0f; float sum = 0.0f; for (i = 0; i < octaves; i++) { float r = _stb_perlin_noise3(x*frequency,y*frequency,z*frequency,x_wrap,y_wrap,z_wrap)*amplitude; r = r<0 ? -r : r; // fabs() sum += r; frequency *= lacunarity; amplitude *= gain; } return sum; } // clang-format on // adapeted stb_perlin.h inline float perlin_noise(const vec3f& p, const vec3i& wrap) { return _stb_perlin_noise3(p.x, p.y, p.z, wrap.x, wrap.y, wrap.z); } // adapeted stb_perlin.h inline float perlin_ridge(const vec3f& p, float lacunarity, float gain, int octaves, float offset, const vec3i& wrap) { return _stb_perlin_ridge_noise3( p.x, p.y, p.z, lacunarity, gain, offset, octaves, wrap.x, wrap.y, wrap.z); } // adapeted stb_perlin.h inline float perlin_fbm(const vec3f& p, float lacunarity, float gain, int octaves, const vec3i& wrap) { return _stb_perlin_fbm_noise3( p.x, p.y, p.z, lacunarity, gain, octaves, wrap.x, wrap.y, wrap.z); } // adapeted stb_perlin.h inline float perlin_turbulence(const vec3f& p, float lacunarity, float gain, int octaves, const vec3i& wrap) { return _stb_perlin_turbulence_noise3( p.x, p.y, p.z, lacunarity, gain, octaves, wrap.x, wrap.y, wrap.z); } } // namespace yocto #endif goxel-0.11.0/ext_src/yocto/yocto_scene.cpp000066400000000000000000001644541435762723100205610ustar00rootroot00000000000000// // Implementation for Yocto/Scene. // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // #include "yocto_scene.h" #include "yocto_random.h" #include "yocto_shape.h" #include #include #include "ext/filesystem.hpp" namespace fs = ghc::filesystem; // ----------------------------------------------------------------------------- // IMPLEMENTATION OF SCENE UTILITIES // ----------------------------------------------------------------------------- namespace yocto { // Computes a shape bounding box. bbox3f compute_bounds(const yocto_shape& shape) { auto bbox = invalidb3f; for (auto p : shape.positions) bbox = merge(bbox, p); return bbox; } // Updates the scene and scene's instances bounding boxes bbox3f compute_bounds(const yocto_scene& scene) { auto shape_bbox = vector(scene.shapes.size()); for (auto shape_id = 0; shape_id < scene.shapes.size(); shape_id++) shape_bbox[shape_id] = compute_bounds(scene.shapes[shape_id]); auto bbox = invalidb3f; for (auto& instance : scene.instances) { bbox = merge( bbox, transform_bbox(instance.frame, shape_bbox[instance.shape])); } return bbox; } // Compute vertex normals vector compute_normals(const yocto_shape& shape) { if (!shape.points.empty()) { return vector{ shape.positions.size(), }; } else if (!shape.lines.empty()) { return compute_tangents(shape.lines, shape.positions); } else if (!shape.triangles.empty()) { return compute_normals(shape.triangles, shape.positions); } else if (!shape.quads.empty()) { return compute_normals(shape.quads, shape.positions); } else if (!shape.quadspos.empty()) { return compute_normals(shape.quadspos, shape.positions); } else { throw std::runtime_error("unknown element type"); } } void compute_normals(const yocto_shape& shape, vector& normals) { normals.assign(shape.positions.size(), {0, 0, 1}); if (!shape.points.empty()) { } else if (!shape.lines.empty()) { compute_tangents(normals, shape.lines, shape.positions); } else if (!shape.triangles.empty()) { compute_normals(normals, shape.triangles, shape.positions); } else if (!shape.quads.empty()) { compute_normals(normals, shape.quads, shape.positions); } else if (!shape.quadspos.empty()) { compute_normals(normals, shape.quadspos, shape.positions); } else { throw std::runtime_error("unknown element type"); } } // Apply subdivision and displacement rules. void subdivide_shape(yocto_shape& shape, int subdivisions, bool catmullclark, bool update_normals) { if (!subdivisions) return; if (!shape.points.empty()) { throw std::runtime_error("point subdivision not supported"); } else if (!shape.lines.empty()) { subdivide_lines(shape.lines, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius, shape.lines, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius, subdivisions); } else if (!shape.triangles.empty()) { subdivide_triangles(shape.triangles, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius, shape.triangles, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius, subdivisions); } else if (!shape.quads.empty() && !catmullclark) { subdivide_quads(shape.quads, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius, shape.quads, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius, subdivisions); } else if (!shape.quads.empty() && catmullclark) { subdivide_catmullclark(shape.quads, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius, shape.quads, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius, subdivisions); } else if (!shape.quadspos.empty() && !catmullclark) { subdivide_quads(shape.quadspos, shape.positions, shape.quadspos, shape.positions, subdivisions); subdivide_quads(shape.quadsnorm, shape.normals, shape.quadsnorm, shape.normals, subdivisions); subdivide_quads(shape.quadstexcoord, shape.texcoords, shape.quadstexcoord, shape.texcoords, subdivisions); } else if (!shape.quadspos.empty() && catmullclark) { subdivide_catmullclark(shape.quadspos, shape.positions, shape.quadspos, shape.positions, subdivisions); subdivide_catmullclark(shape.quadstexcoord, shape.texcoords, shape.quadstexcoord, shape.texcoords, subdivisions, true); } else { throw std::runtime_error("empty shape"); } if (update_normals) { if (!shape.quadspos.empty()) { shape.quadsnorm = shape.quadspos; } compute_normals(shape, shape.normals); } } // Apply displacement to a shape void displace_shape(yocto_shape& shape, const yocto_texture& displacement, float scale, bool update_normals) { if (shape.texcoords.empty()) { throw std::runtime_error("missing texture coordinates"); return; } // simple case if (shape.quadspos.empty()) { auto normals = shape.normals; if (shape.normals.empty()) compute_normals(shape, normals); for (auto vid = 0; vid < shape.positions.size(); vid++) { auto disp = mean( xyz(eval_texture(displacement, shape.texcoords[vid], true))); if (!is_hdr_filename(displacement.uri)) disp -= 0.5f; shape.positions[vid] += normals[vid] * scale * disp; } if (update_normals || !shape.normals.empty()) { compute_normals(shape, shape.normals); } } else { // facevarying case auto offset = vector(shape.positions.size(), 0); auto count = vector(shape.positions.size(), 0); for (auto fid = 0; fid < shape.quadspos.size(); fid++) { auto qpos = shape.quadspos[fid]; auto qtxt = shape.quadstexcoord[fid]; for (auto i = 0; i < 4; i++) { auto disp = mean( xyz(eval_texture(displacement, shape.texcoords[qtxt[i]], true))); if (!is_hdr_filename(displacement.uri)) disp -= 0.5f; offset[qpos[i]] += scale * disp; count[qpos[i]] += 1; } } auto normals = vector{shape.positions.size()}; compute_normals(normals, shape.quadspos, shape.positions); for (auto vid = 0; vid < shape.positions.size(); vid++) { shape.positions[vid] += normals[vid] * offset[vid] / count[vid]; } if (update_normals || !shape.normals.empty()) { shape.quadsnorm = shape.quadspos; compute_normals(shape, shape.normals); } } } void tesselate_subdiv(yocto_scene& scene, yocto_subdiv& subdiv) { auto& shape = scene.shapes[subdiv.shape]; shape.positions = subdiv.positions; shape.normals = subdiv.normals; shape.texcoords = subdiv.texcoords; shape.colors = subdiv.colors; shape.radius = subdiv.radius; shape.points = subdiv.points; shape.lines = subdiv.lines; shape.triangles = subdiv.triangles; shape.quads = subdiv.quads; shape.quadspos = subdiv.quadspos; shape.quadsnorm = subdiv.quadsnorm; shape.quadstexcoord = subdiv.quadstexcoord; shape.lines = subdiv.lines; if (subdiv.subdivisions) { subdivide_shape( shape, subdiv.subdivisions, subdiv.catmullclark, subdiv.smooth); } if (subdiv.displacement_tex >= 0) { displace_shape(shape, scene.textures[subdiv.displacement_tex], subdiv.displacement, subdiv.smooth); } } // Updates tesselation. void tesselate_subdivs(yocto_scene& scene) { for (auto& subdiv : scene.subdivs) tesselate_subdiv(scene, subdiv); } // Update animation transforms void update_transforms(yocto_scene& scene, yocto_animation& animation, float time, const string& anim_group) { if (anim_group != "" && anim_group != animation.group) return; if (!animation.translations.empty()) { auto value = vec3f{0, 0, 0}; switch (animation.interpolation) { case yocto_animation::interpolation_type::step: value = keyframe_step(animation.times, animation.translations, time); break; case yocto_animation::interpolation_type::linear: value = keyframe_linear(animation.times, animation.translations, time); break; case yocto_animation::interpolation_type::bezier: value = keyframe_bezier(animation.times, animation.translations, time); break; default: throw std::runtime_error("should not have been here"); } for (auto target : animation.targets) scene.nodes[target].translation = value; } if (!animation.rotations.empty()) { auto value = vec4f{0, 0, 0, 1}; switch (animation.interpolation) { case yocto_animation::interpolation_type::step: value = keyframe_step(animation.times, animation.rotations, time); break; case yocto_animation::interpolation_type::linear: value = keyframe_linear(animation.times, animation.rotations, time); break; case yocto_animation::interpolation_type::bezier: value = keyframe_bezier(animation.times, animation.rotations, time); break; } for (auto target : animation.targets) scene.nodes[target].rotation = value; } if (!animation.scales.empty()) { auto value = vec3f{1, 1, 1}; switch (animation.interpolation) { case yocto_animation::interpolation_type::step: value = keyframe_step(animation.times, animation.scales, time); break; case yocto_animation::interpolation_type::linear: value = keyframe_linear(animation.times, animation.scales, time); break; case yocto_animation::interpolation_type::bezier: value = keyframe_bezier(animation.times, animation.scales, time); break; } for (auto target : animation.targets) scene.nodes[target].scale = value; } } // Update node transforms void update_transforms(yocto_scene& scene, yocto_scene_node& node, const frame3f& parent = identity3x4f) { auto frame = parent * node.local * translation_frame(node.translation) * rotation_frame(node.rotation) * scaling_frame(node.scale); if (node.instance >= 0) scene.instances[node.instance].frame = frame; if (node.camera >= 0) scene.cameras[node.camera].frame = frame; if (node.environment >= 0) scene.environments[node.environment].frame = frame; for (auto child : node.children) update_transforms(scene, scene.nodes[child], frame); } // Update node transforms void update_transforms( yocto_scene& scene, float time, const string& anim_group) { for (auto& agr : scene.animations) update_transforms(scene, agr, time, anim_group); for (auto& node : scene.nodes) node.children.clear(); for (auto node_id = 0; node_id < scene.nodes.size(); node_id++) { auto& node = scene.nodes[node_id]; if (node.parent >= 0) scene.nodes[node.parent].children.push_back(node_id); } for (auto& node : scene.nodes) if (node.parent < 0) update_transforms(scene, node); } // Compute animation range vec2f compute_animation_range( const yocto_scene& scene, const string& anim_group) { if (scene.animations.empty()) return zero2f; auto range = vec2f{+flt_max, -flt_max}; for (auto& animation : scene.animations) { if (anim_group != "" && animation.group != anim_group) continue; range.x = min(range.x, animation.times.front()); range.y = max(range.y, animation.times.back()); } if (range.y < range.x) return zero2f; return range; } // Generate a distribution for sampling a shape uniformly based on area/length. void sample_shape_cdf(const yocto_shape& shape, vector& cdf) { cdf.clear(); if (!shape.triangles.empty()) { sample_triangles_cdf(cdf, shape.triangles, shape.positions); } else if (!shape.quads.empty()) { sample_quads_cdf(cdf, shape.quads, shape.positions); } else if (!shape.lines.empty()) { sample_lines_cdf(cdf, shape.lines, shape.positions); } else if (!shape.points.empty()) { sample_points_cdf(cdf, shape.points.size()); } else if (!shape.quadspos.empty()) { sample_quads_cdf(cdf, shape.quadspos, shape.positions); } else { throw std::runtime_error("empty shape"); } } vector sample_shape_cdf(const yocto_shape& shape) { if (!shape.triangles.empty()) { return sample_triangles_cdf(shape.triangles, shape.positions); } else if (!shape.quads.empty()) { return sample_quads_cdf(shape.quads, shape.positions); } else if (!shape.lines.empty()) { return sample_lines_cdf(shape.lines, shape.positions); } else if (!shape.points.empty()) { return sample_points_cdf(shape.points.size()); } else if (!shape.quadspos.empty()) { return sample_quads_cdf(shape.quadspos, shape.positions); } else { throw std::runtime_error("empty shape"); return {}; } } // Sample a shape based on a distribution. pair sample_shape(const yocto_shape& shape, const vector& cdf, float re, const vec2f& ruv) { // TODO: implement sampling without cdf if (cdf.empty()) return {}; if (!shape.triangles.empty()) { return sample_triangles(cdf, re, ruv); } else if (!shape.quads.empty()) { return sample_quads(cdf, re, ruv); } else if (!shape.lines.empty()) { return {sample_lines(cdf, re, ruv.x).first, ruv}; } else if (!shape.points.empty()) { return {sample_points(cdf, re), ruv}; } else if (!shape.quadspos.empty()) { return sample_quads(cdf, re, ruv); } else { return {0, zero2f}; } } float sample_shape_pdf(const yocto_shape& shape, const vector& cdf, int element, const vec2f& uv) { // prob triangle * area triangle = area triangle mesh return 1 / cdf.back(); } // Update environment CDF for sampling. vector sample_environment_cdf( const yocto_scene& scene, const yocto_environment& environment) { if (environment.emission_tex < 0) return {}; auto& texture = scene.textures[environment.emission_tex]; auto size = texture_size(texture); auto texels_cdf = vector(size.x * size.y); if (size != zero2i) { for (auto i = 0; i < texels_cdf.size(); i++) { auto ij = vec2i{i % size.x, i / size.x}; auto th = (ij.y + 0.5f) * pif / size.y; auto value = lookup_texture(texture, ij.x, ij.y); texels_cdf[i] = max(xyz(value)) * sin(th); if (i) texels_cdf[i] += texels_cdf[i - 1]; } } else { throw std::runtime_error("empty texture"); } return texels_cdf; } void sample_environment_cdf(const yocto_scene& scene, const yocto_environment& environment, vector& texels_cdf) { if (environment.emission_tex < 0) { texels_cdf.clear(); return; } auto& texture = scene.textures[environment.emission_tex]; auto size = texture_size(texture); texels_cdf.resize(size.x * size.y); if (size != zero2i) { for (auto i = 0; i < texels_cdf.size(); i++) { auto ij = vec2i{i % size.x, i / size.x}; auto th = (ij.y + 0.5f) * pif / size.y; auto value = lookup_texture(texture, ij.x, ij.y); texels_cdf[i] = max(xyz(value)) * sin(th); if (i) texels_cdf[i] += texels_cdf[i - 1]; } } else { throw std::runtime_error("empty texture"); } } // Sample an environment based on texels vec3f sample_environment(const yocto_scene& scene, const yocto_environment& environment, const vector& texels_cdf, float re, const vec2f& ruv) { if (!texels_cdf.empty() && environment.emission_tex >= 0) { auto& texture = scene.textures[environment.emission_tex]; auto idx = sample_discrete(texels_cdf, re); auto size = texture_size(texture); auto u = (idx % size.x + 0.5f) / size.x; auto v = (idx / size.x + 0.5f) / size.y; return eval_direction(environment, {u, v}); } else { return sample_sphere(ruv); } } // Sample an environment based on texels float sample_environment_pdf(const yocto_scene& scene, const yocto_environment& environment, const vector& texels_cdf, const vec3f& direction) { if (!texels_cdf.empty() && environment.emission_tex >= 0) { auto& texture = scene.textures[environment.emission_tex]; auto size = texture_size(texture); auto texcoord = eval_texcoord(environment, direction); auto i = (int)(texcoord.x * size.x); auto j = (int)(texcoord.y * size.y); auto idx = j * size.x + i; auto prob = sample_discrete_pdf(texels_cdf, idx) / texels_cdf.back(); auto angle = (2 * pif / size.x) * (pif / size.y) * sin(pif * (j + 0.5f) / size.y); return prob / angle; } else { return sample_sphere_pdf(direction); } } bvh_scene make_bvh(const yocto_scene& scene, const bvh_params& params) { auto sbvhs = vector{scene.shapes.size()}; for (auto idx = 0; idx < scene.shapes.size(); idx++) { auto& shape = scene.shapes[idx]; auto& sbvh = sbvhs[idx]; #if YOCTO_EMBREE // call Embree if needed if (params.use_embree) { if (params.embree_compact && shape.positions.size() == shape.positions.capacity()) { ((yocto_shape&)shape).positions.reserve(shape.positions.size() + 1); } } #endif if (!shape.points.empty()) { sbvh = make_points_bvh(shape.points, shape.positions, shape.radius); } else if (!shape.lines.empty()) { sbvh = make_lines_bvh(shape.lines, shape.positions, shape.radius); } else if (!shape.triangles.empty()) { sbvh = make_triangles_bvh(shape.triangles, shape.positions, shape.radius); } else if (!shape.quads.empty()) { sbvh = make_quads_bvh(shape.quads, shape.positions, shape.radius); } else if (!shape.quadspos.empty()) { sbvh = make_quadspos_bvh(shape.quadspos, shape.positions, shape.radius); } else { throw std::runtime_error("empty shape"); } } auto bvh = make_instances_bvh( {&scene.instances[0].frame, (int)scene.instances.size(), sizeof(scene.instances[0])}, sbvhs); build_bvh(bvh, params); return bvh; } void make_bvh( bvh_scene& bvh, const yocto_scene& scene, const bvh_params& params) { auto sbvhs = vector{scene.shapes.size()}; for (auto idx = 0; idx < scene.shapes.size(); idx++) { auto& shape = scene.shapes[idx]; auto& sbvh = sbvhs[idx]; #if YOCTO_EMBREE // call Embree if needed if (params.use_embree) { if (params.embree_compact && shape.positions.size() == shape.positions.capacity()) { ((yocto_shape&)shape).positions.reserve(shape.positions.size() + 1); } } #endif if (!shape.points.empty()) { sbvh = make_points_bvh(shape.points, shape.positions, shape.radius); } else if (!shape.lines.empty()) { sbvh = make_lines_bvh(shape.lines, shape.positions, shape.radius); } else if (!shape.triangles.empty()) { sbvh = make_triangles_bvh(shape.triangles, shape.positions, shape.radius); } else if (!shape.quads.empty()) { sbvh = make_quads_bvh(shape.quads, shape.positions, shape.radius); } else if (!shape.quadspos.empty()) { sbvh = make_quadspos_bvh(shape.quadspos, shape.positions, shape.radius); } else { throw std::runtime_error("empty shape"); } } bvh = {{&scene.instances[0].frame, (int)scene.instances.size(), sizeof(scene.instances[0])}, sbvhs}; build_bvh(bvh, params); } void refit_bvh(bvh_scene& bvh, const yocto_scene& scene, const vector& updated_shapes, const bvh_params& params) { for (auto idx : updated_shapes) { auto& shape = scene.shapes[idx]; auto& sbvh = bvh.shapes[idx]; #if YOCTO_EMBREE // call Embree if needed if (params.use_embree) { if (params.embree_compact && shape.positions.size() == shape.positions.capacity()) { ((yocto_shape&)shape).positions.reserve(shape.positions.size() + 1); } } #endif sbvh.points = shape.points; sbvh.lines = shape.lines; sbvh.triangles = shape.triangles; sbvh.quads = shape.quads; sbvh.quadspos = shape.quadspos; sbvh.positions = shape.positions; sbvh.radius = shape.radius; } if (!scene.instances.empty()) { bvh.instances = {&scene.instances[0].frame, (int)scene.instances.size(), sizeof(scene.instances[0])}; } else { bvh.instances = {}; } refit_bvh(bvh, updated_shapes, params); } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION FOR EVAL AND SAMPLING FUNCTIONS // ----------------------------------------------------------------------------- namespace yocto { // Shape element normal. vec3f eval_element_normal(const yocto_shape& shape, int element) { auto norm = zero3f; if (!shape.triangles.empty()) { auto t = shape.triangles[element]; norm = triangle_normal( shape.positions[t.x], shape.positions[t.y], shape.positions[t.z]); } else if (!shape.quads.empty()) { auto q = shape.quads[element]; norm = quad_normal(shape.positions[q.x], shape.positions[q.y], shape.positions[q.z], shape.positions[q.w]); } else if (!shape.lines.empty()) { auto l = shape.lines[element]; norm = line_tangent(shape.positions[l.x], shape.positions[l.y]); } else if (!shape.quadspos.empty()) { auto q = shape.quadspos[element]; norm = quad_normal(shape.positions[q.x], shape.positions[q.y], shape.positions[q.z], shape.positions[q.w]); } else { throw std::runtime_error("empty shape"); norm = {0, 0, 1}; } return norm; } // Shape element normal. pair eval_element_tangents( const yocto_shape& shape, int element, const vec2f& uv) { if (!shape.triangles.empty()) { auto t = shape.triangles[element]; if (shape.texcoords.empty()) { return triangle_tangents_fromuv(shape.positions[t.x], shape.positions[t.y], shape.positions[t.z], {0, 0}, {1, 0}, {0, 1}); } else { return triangle_tangents_fromuv(shape.positions[t.x], shape.positions[t.y], shape.positions[t.z], shape.texcoords[t.x], shape.texcoords[t.y], shape.texcoords[t.z]); } } else if (!shape.quads.empty()) { auto q = shape.quads[element]; if (shape.texcoords.empty()) { return quad_tangents_fromuv(shape.positions[q.x], shape.positions[q.y], shape.positions[q.z], shape.positions[q.w], {0, 0}, {1, 0}, {0, 1}, {1, 1}, uv); } else { return quad_tangents_fromuv(shape.positions[q.x], shape.positions[q.y], shape.positions[q.z], shape.positions[q.w], shape.texcoords[q.x], shape.texcoords[q.y], shape.texcoords[q.z], shape.texcoords[q.w], uv); } } else if (!shape.quadspos.empty()) { auto q = shape.quadspos[element]; if (shape.texcoords.empty()) { return quad_tangents_fromuv(shape.positions[q.x], shape.positions[q.y], shape.positions[q.z], shape.positions[q.w], {0, 0}, {1, 0}, {0, 1}, {1, 1}, uv); } else { auto qt = shape.quadstexcoord[element]; return quad_tangents_fromuv(shape.positions[q.x], shape.positions[q.y], shape.positions[q.z], shape.positions[q.w], shape.texcoords[qt.x], shape.texcoords[qt.y], shape.texcoords[qt.z], shape.texcoords[qt.w], uv); } } else { return {zero3f, zero3f}; } } pair eval_element_tangent_basis( const yocto_shape& shape, int element, const vec2f& uv) { auto z = eval_element_normal(shape, element); auto tangents = eval_element_tangents(shape, element, uv); auto x = orthonormalize(tangents.first, z); auto y = normalize(cross(z, x)); return {{x, y, z}, dot(y, tangents.second) < 0}; } // Shape value interpolated using barycentric coordinates template T eval_shape_elem(const yocto_shape& shape, const vector& facevarying_quads, const vector& vals, int element, const vec2f& uv) { if (vals.empty()) return {}; if (!shape.triangles.empty()) { auto t = shape.triangles[element]; return interpolate_triangle(vals[t.x], vals[t.y], vals[t.z], uv); } else if (!shape.quads.empty()) { auto q = shape.quads[element]; if (q.w == q.z) return interpolate_triangle(vals[q.x], vals[q.y], vals[q.z], uv); return interpolate_quad(vals[q.x], vals[q.y], vals[q.z], vals[q.w], uv); } else if (!shape.lines.empty()) { auto l = shape.lines[element]; return interpolate_line(vals[l.x], vals[l.y], uv.x); } else if (!shape.points.empty()) { return vals[shape.points[element]]; } else if (!shape.quadspos.empty()) { auto q = facevarying_quads[element]; if (q.w == q.z) return interpolate_triangle(vals[q.x], vals[q.y], vals[q.z], uv); return interpolate_quad(vals[q.x], vals[q.y], vals[q.z], vals[q.w], uv); } else { return {}; } } // Shape values interpolated using barycentric coordinates vec3f eval_position(const yocto_shape& shape, int element, const vec2f& uv) { return eval_shape_elem(shape, shape.quadspos, shape.positions, element, uv); } vec3f eval_normal(const yocto_shape& shape, int element, const vec2f& uv) { if (shape.normals.empty()) return eval_element_normal(shape, element); return normalize( eval_shape_elem(shape, shape.quadsnorm, shape.normals, element, uv)); } vec2f eval_texcoord(const yocto_shape& shape, int element, const vec2f& uv) { if (shape.texcoords.empty()) return uv; return eval_shape_elem( shape, shape.quadstexcoord, shape.texcoords, element, uv); } vec4f eval_color(const yocto_shape& shape, int element, const vec2f& uv) { if (shape.colors.empty()) return {1, 1, 1, 1}; return eval_shape_elem(shape, {}, shape.colors, element, uv); } float eval_radius(const yocto_shape& shape, int element, const vec2f& uv) { if (shape.radius.empty()) return 0.001f; return eval_shape_elem(shape, {}, shape.radius, element, uv); } vec4f eval_tangent_space( const yocto_shape& shape, int element, const vec2f& uv) { if (shape.tangents.empty()) return zero4f; return eval_shape_elem(shape, {}, shape.tangents, element, uv); } pair eval_tangent_basis( const yocto_shape& shape, int element, const vec2f& uv) { auto z = eval_normal(shape, element, uv); if (shape.tangents.empty()) { auto tangents = eval_element_tangents(shape, element, uv); auto x = orthonormalize(tangents.first, z); auto y = normalize(cross(z, x)); return {{x, y, z}, dot(y, tangents.second) < 0}; } else { auto tangsp = eval_shape_elem(shape, {}, shape.tangents, element, uv); auto x = orthonormalize(xyz(tangsp), z); auto y = normalize(cross(z, x)); return {{x, y, z}, tangsp.w < 0}; } } // Instance values interpolated using barycentric coordinates. vec3f eval_position(const yocto_scene& scene, const yocto_instance& instance, int element, const vec2f& uv) { return transform_point( instance.frame, eval_position(scene.shapes[instance.shape], element, uv)); } vec3f eval_normal(const yocto_scene& scene, const yocto_instance& instance, int element, const vec2f& uv, bool non_rigid_frame) { auto normal = eval_normal(scene.shapes[instance.shape], element, uv); return transform_normal(instance.frame, normal, non_rigid_frame); } vec3f eval_shading_normal(const yocto_scene& scene, const yocto_instance& instance, int element, const vec2f& uv, const vec3f& direction, bool non_rigid_frame) { auto& shape = scene.shapes[instance.shape]; auto& material = scene.materials[instance.material]; if (!shape.points.empty()) { return -direction; } else if (!shape.lines.empty()) { auto normal = eval_normal(scene, instance, element, uv, non_rigid_frame); return orthonormalize(-direction, normal); } else if (material.normal_tex < 0) { return eval_normal(scene, instance, element, uv, non_rigid_frame); } else { auto& normal_tex = scene.textures[material.normal_tex]; auto normalmap = -1 + 2 * xyz(eval_texture(normal_tex, eval_texcoord(shape, element, uv), true)); auto basis = eval_tangent_basis(shape, element, uv); normalmap.y *= basis.second ? 1 : -1; // flip vertical axis auto normal = normalize(basis.first * normalmap); return transform_normal(instance.frame, normal, non_rigid_frame); } } // Instance element values. vec3f eval_element_normal(const yocto_scene& scene, const yocto_instance& instance, int element, bool non_rigid_frame) { auto normal = eval_element_normal(scene.shapes[instance.shape], element); return transform_normal(instance.frame, normal, non_rigid_frame); } // Instance material material_point eval_material(const yocto_scene& scene, const yocto_instance& instance, int element, const vec2f& uv) { auto& shape = scene.shapes[instance.shape]; auto& material = scene.materials[instance.material]; auto texcoords = eval_texcoord(shape, element, uv); auto color = eval_color(shape, element, uv); return eval_material(scene, material, texcoords, color); } // Environment texture coordinates from the direction. vec2f eval_texcoord( const yocto_environment& environment, const vec3f& direction) { auto wl = transform_direction(inverse(environment.frame), direction); auto environment_uv = vec2f{ atan2(wl.z, wl.x) / (2 * pif), acos(clamp(wl.y, -1.0f, 1.0f)) / pif}; if (environment_uv.x < 0) environment_uv.x += 1; return environment_uv; } // Evaluate the environment direction. vec3f eval_direction( const yocto_environment& environment, const vec2f& environment_uv) { return transform_direction(environment.frame, {cos(environment_uv.x * 2 * pif) * sin(environment_uv.y * pif), cos(environment_uv.y * pif), sin(environment_uv.x * 2 * pif) * sin(environment_uv.y * pif)}); } // Evaluate the environment color. vec3f eval_environment(const yocto_scene& scene, const yocto_environment& environment, const vec3f& direction) { auto emission = environment.emission; if (environment.emission_tex >= 0) { auto& emission_tex = scene.textures[environment.emission_tex]; emission *= xyz( eval_texture(emission_tex, eval_texcoord(environment, direction))); } return emission; } // Evaluate all environment color. vec3f eval_environment(const yocto_scene& scene, const vec3f& direction) { auto emission = zero3f; for (auto& environment : scene.environments) emission += eval_environment(scene, environment, direction); return emission; } // Check texture size vec2i texture_size(const yocto_texture& texture) { if (!texture.hdr.empty()) { return texture.hdr.size(); } else if (!texture.ldr.empty()) { return texture.ldr.size(); } else { return zero2i; } } // Lookup a texture value vec4f lookup_texture( const yocto_texture& texture, int i, int j, bool ldr_as_linear) { if (!texture.hdr.empty()) { return texture.hdr[{i, j}]; } else if (!texture.ldr.empty() && !ldr_as_linear) { return srgb_to_rgb(byte_to_float(texture.ldr[{i, j}])); } else if (!texture.ldr.empty() && ldr_as_linear) { return byte_to_float(texture.ldr[{i, j}]); } else { return zero4f; } } // Evaluate a texture vec4f eval_texture(const yocto_texture& texture, const vec2f& texcoord, bool ldr_as_linear, bool no_interpolation, bool clamp_to_edge) { if (texture.hdr.empty() && texture.ldr.empty()) return {1, 1, 1, 1}; // get image width/height auto size = texture_size(texture); auto width = size.x, height = size.y; // get coordinates normalized for tiling auto s = 0.0f, t = 0.0f; if (clamp_to_edge) { s = clamp(texcoord.x, 0.0f, 1.0f) * width; t = clamp(texcoord.y, 0.0f, 1.0f) * height; } else { s = fmod(texcoord.x, 1.0f) * width; if (s < 0) s += width; t = fmod(texcoord.y, 1.0f) * height; if (t < 0) t += height; } // get image coordinates and residuals auto i = clamp((int)s, 0, width - 1), j = clamp((int)t, 0, height - 1); auto ii = (i + 1) % width, jj = (j + 1) % height; auto u = s - i, v = t - j; if (no_interpolation) return lookup_texture(texture, i, j, ldr_as_linear); // handle interpolation return lookup_texture(texture, i, j, ldr_as_linear) * (1 - u) * (1 - v) + lookup_texture(texture, i, jj, ldr_as_linear) * (1 - u) * v + lookup_texture(texture, ii, j, ldr_as_linear) * u * (1 - v) + lookup_texture(texture, ii, jj, ldr_as_linear) * u * v; } // Lookup a texture value float lookup_voltexture( const yocto_voltexture& texture, int i, int j, int k, bool ldr_as_linear) { if (!texture.vol.empty()) { return texture.vol[{i, j, k}]; } else { return 0; } } // Evaluate a volume texture float eval_voltexture(const yocto_voltexture& texture, const vec3f& texcoord, bool ldr_as_linear, bool no_interpolation, bool clamp_to_edge) { if (texture.vol.empty()) return 1; // get image width/height auto width = texture.vol.size().x; auto height = texture.vol.size().y; auto depth = texture.vol.size().z; // get coordinates normalized for tiling auto s = clamp((texcoord.x + 1.0f) * 0.5f, 0.0f, 1.0f) * width; auto t = clamp((texcoord.y + 1.0f) * 0.5f, 0.0f, 1.0f) * height; auto r = clamp((texcoord.z + 1.0f) * 0.5f, 0.0f, 1.0f) * depth; // get image coordinates and residuals auto i = clamp((int)s, 0, width - 1); auto j = clamp((int)t, 0, height - 1); auto k = clamp((int)r, 0, depth - 1); auto ii = (i + 1) % width, jj = (j + 1) % height, kk = (k + 1) % depth; auto u = s - i, v = t - j, w = r - k; // nearest-neighbor interpolation if (no_interpolation) { i = u < 0.5 ? i : min(i + 1, width - 1); j = v < 0.5 ? j : min(j + 1, height - 1); k = w < 0.5 ? k : min(k + 1, depth - 1); return lookup_voltexture(texture, i, j, k, ldr_as_linear); } // trilinear interpolation return lookup_voltexture(texture, i, j, k, ldr_as_linear) * (1 - u) * (1 - v) * (1 - w) + lookup_voltexture(texture, ii, j, k, ldr_as_linear) * u * (1 - v) * (1 - w) + lookup_voltexture(texture, i, jj, k, ldr_as_linear) * (1 - u) * v * (1 - w) + lookup_voltexture(texture, i, j, kk, ldr_as_linear) * (1 - u) * (1 - v) * w + lookup_voltexture(texture, i, jj, kk, ldr_as_linear) * (1 - u) * v * w + lookup_voltexture(texture, ii, j, kk, ldr_as_linear) * u * (1 - v) * w + lookup_voltexture(texture, ii, jj, k, ldr_as_linear) * u * v * (1 - w) + lookup_voltexture(texture, ii, jj, kk, ldr_as_linear) * u * v * w; } // Set and evaluate camera parameters. Setters take zeros as default values. vec2f camera_fov(const yocto_camera& camera) { assert(!camera.orthographic); return {2 * atan(camera.film.x / (2 * camera.lens)), 2 * atan(camera.film.y / (2 * camera.lens))}; } float camera_yfov(const yocto_camera& camera) { assert(!camera.orthographic); return 2 * atan(camera.film.y / (2 * camera.lens)); } float camera_aspect(const yocto_camera& camera) { return camera.film.x / camera.film.y; } vec2i camera_resolution(const yocto_camera& camera, int resolution) { if (camera.film.x > camera.film.y) { return {resolution, (int)round(resolution * camera.film.y / camera.film.x)}; } else { return {(int)round(resolution * camera.film.x / camera.film.y), resolution}; } } void set_yperspective( yocto_camera& camera, float fov, float aspect, float focus, float film) { camera.orthographic = false; camera.film = {film, film / aspect}; camera.focus = focus; auto distance = camera.film.y / (2 * tan(fov / 2)); if (focus < flt_max) { camera.lens = camera.focus * distance / (camera.focus + distance); } else { camera.lens = distance; } } // add missing camera void set_view( yocto_camera& camera, const bbox3f& bbox, const vec3f& view_direction) { camera.orthographic = false; auto center = (bbox.max + bbox.min) / 2; auto bbox_radius = length(bbox.max - bbox.min) / 2; auto camera_dir = (view_direction == zero3f) ? camera.frame.o - center : view_direction; if (camera_dir == zero3f) camera_dir = {0, 0, 1}; auto fov = min(camera_fov(camera)); if (fov == 0) fov = 45 * pif / 180; auto camera_dist = bbox_radius / sin(fov / 2); auto from = camera_dir * (camera_dist * 1) + center; auto to = center; auto up = vec3f{0, 1, 0}; camera.frame = lookat_frame(from, to, up); camera.focus = length(from - to); camera.aperture = 0; } // Generates a ray from a camera for image plane coordinate uv and // the lens coordinates luv. ray3f eval_perspective_camera( const yocto_camera& camera, const vec2f& image_uv, const vec2f& lens_uv) { auto distance = camera.lens; if (camera.focus < flt_max) { distance = camera.lens * camera.focus / (camera.focus - camera.lens); } if (camera.aperture) { auto e = vec3f{(lens_uv.x - 0.5f) * camera.aperture, (lens_uv.y - 0.5f) * camera.aperture, 0}; auto q = vec3f{camera.film.x * (0.5f - image_uv.x), camera.film.y * (image_uv.y - 0.5f), distance}; // distance of the image of the point auto distance1 = camera.lens * distance / (distance - camera.lens); auto q1 = -q * distance1 / distance; auto d = normalize(q1 - e); // auto q1 = - normalize(q) * camera.focus / normalize(q).z; auto ray = ray3f{ transform_point(camera.frame, e), transform_direction(camera.frame, d)}; return ray; } else { auto e = zero3f; auto q = vec3f{camera.film.x * (0.5f - image_uv.x), camera.film.y * (image_uv.y - 0.5f), distance}; auto q1 = -q; auto d = normalize(q1 - e); auto ray = ray3f{ transform_point(camera.frame, e), transform_direction(camera.frame, d)}; return ray; } } // Generates a ray from a camera for image plane coordinate uv and // the lens coordinates luv. ray3f eval_orthographic_camera( const yocto_camera& camera, const vec2f& image_uv, const vec2f& lens_uv) { if (camera.aperture) { auto scale = 1 / camera.lens; auto q = vec3f{camera.film.x * (0.5f - image_uv.x) * scale, camera.film.y * (image_uv.y - 0.5f) * scale, scale}; auto q1 = vec3f{-q.x, -q.y, -camera.focus}; auto e = vec3f{-q.x, -q.y, 0} + vec3f{(lens_uv.x - 0.5f) * camera.aperture, (lens_uv.y - 0.5f) * camera.aperture, 0}; auto d = normalize(q1 - e); auto ray = ray3f{ transform_point(camera.frame, e), transform_direction(camera.frame, d)}; return ray; } else { auto scale = 1 / camera.lens; auto q = vec3f{camera.film.x * (0.5f - image_uv.x) * scale, camera.film.y * (image_uv.y - 0.5f) * scale, scale}; auto q1 = -q; auto e = vec3f{-q.x, -q.y, 0}; auto d = normalize(q1 - e); auto ray = ray3f{ transform_point(camera.frame, e), transform_direction(camera.frame, d)}; return ray; } } // Generates a ray from a camera for image plane coordinate uv and // the lens coordinates luv. ray3f eval_camera( const yocto_camera& camera, const vec2f& uv, const vec2f& luv) { if (camera.orthographic) return eval_orthographic_camera(camera, uv, luv); else return eval_perspective_camera(camera, uv, luv); } // Generates a ray from a camera. ray3f eval_camera(const yocto_camera& camera, const vec2i& image_ij, const vec2i& image_size, const vec2f& pixel_uv, const vec2f& lens_uv) { auto image_uv = vec2f{(image_ij.x + pixel_uv.x) / image_size.x, (image_ij.y + pixel_uv.y) / image_size.y}; return eval_camera(camera, image_uv, lens_uv); } // Generates a ray from a camera. ray3f eval_camera(const yocto_camera& camera, int idx, const vec2i& image_size, const vec2f& pixel_uv, const vec2f& lens_uv) { auto image_ij = vec2i{idx % image_size.x, idx / image_size.x}; auto image_uv = vec2f{(image_ij.x + pixel_uv.x) / image_size.x, (image_ij.y + pixel_uv.y) / image_size.y}; return eval_camera(camera, image_uv, lens_uv); } // Evaluates the microfacet_brdf at a location. material_point eval_material(const yocto_scene& scene, const yocto_material& material, const vec2f& texcoord, const vec4f& shape_color) { auto point = material_point{}; // factors point.emission = material.emission * xyz(shape_color); point.diffuse = material.diffuse * xyz(shape_color); point.specular = material.specular; auto metallic = material.metallic; point.roughness = material.roughness; point.coat = material.coat; point.transmission = material.transmission; auto voltransmission = material.voltransmission; auto volmeanfreepath = material.volmeanfreepath; point.volemission = material.volemission; point.volscatter = material.volscatter; point.volanisotropy = material.volanisotropy; auto volscale = material.volscale; point.opacity = material.opacity * shape_color.w; point.thin = material.thin; // textures if (material.emission_tex >= 0) { auto& emission_tex = scene.textures[material.emission_tex]; point.emission *= xyz(eval_texture(emission_tex, texcoord)); } if (material.diffuse_tex >= 0) { auto& diffuse_tex = scene.textures[material.diffuse_tex]; auto base_txt = eval_texture(diffuse_tex, texcoord); point.diffuse *= xyz(base_txt); point.opacity *= base_txt.w; } if (material.metallic_tex >= 0) { auto& metallic_tex = scene.textures[material.metallic_tex]; auto metallic_txt = eval_texture(metallic_tex, texcoord); metallic *= metallic_txt.z; if (material.gltf_textures) { point.roughness *= metallic_txt.x; } } if (material.specular_tex >= 0) { auto& specular_tex = scene.textures[material.specular_tex]; auto specular_txt = eval_texture(specular_tex, texcoord); point.specular *= xyz(specular_txt); if (material.gltf_textures) { auto glossiness = 1 - point.roughness; glossiness *= specular_txt.w; point.roughness = 1 - glossiness; } } if (material.roughness_tex >= 0) { auto& roughness_tex = scene.textures[material.roughness_tex]; point.roughness *= eval_texture(roughness_tex, texcoord).x; } if (material.transmission_tex >= 0) { auto& transmission_tex = scene.textures[material.transmission_tex]; point.transmission *= xyz(eval_texture(transmission_tex, texcoord)); } if (material.subsurface_tex >= 0) { auto& subsurface_tex = scene.textures[material.subsurface_tex]; point.volscatter *= xyz(eval_texture(subsurface_tex, texcoord)); } if (material.opacity_tex >= 0) { auto& opacity_tex = scene.textures[material.opacity_tex]; point.opacity *= mean(xyz(eval_texture(opacity_tex, texcoord))); } if (material.coat_tex >= 0) { auto& coat_tex = scene.textures[material.coat_tex]; point.coat *= xyz(eval_texture(coat_tex, texcoord)); } if (metallic) { point.specular = point.specular * (1 - metallic) + metallic * point.diffuse; point.diffuse = /* metallic * */ point.diffuse * (1 - metallic); } if (point.diffuse != zero3f || point.roughness) { point.roughness = point.roughness * point.roughness; point.roughness = clamp(point.roughness, 0.03f * 0.03f, 1.0f); } if (point.opacity > 0.999f) point.opacity = 1; if (voltransmission != zero3f || volmeanfreepath != zero3f) { if (voltransmission != zero3f) { point.voldensity = -log(clamp(voltransmission, 0.0001f, 1.0f)) / volscale; } else { point.voldensity = 1 / (volmeanfreepath * volscale); } } else { point.voldensity = zero3f; } return point; } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION OF SCENE UTILITIES // ----------------------------------------------------------------------------- namespace yocto { void merge_scene(yocto_scene& scene, const yocto_scene& merge) { auto offset_cameras = scene.cameras.size(); auto offset_textures = scene.textures.size(); auto offset_voltextures = scene.voltextures.size(); auto offset_materials = scene.materials.size(); auto offset_shapes = scene.shapes.size(); auto offset_subdivs = scene.subdivs.size(); auto offset_instances = scene.instances.size(); auto offset_environments = scene.environments.size(); auto offset_nodes = scene.nodes.size(); auto offset_animations = scene.animations.size(); scene.cameras.insert( scene.cameras.end(), merge.cameras.begin(), merge.cameras.end()); scene.textures.insert( scene.textures.end(), merge.textures.begin(), merge.textures.end()); scene.voltextures.insert(scene.voltextures.end(), merge.voltextures.begin(), merge.voltextures.end()); scene.materials.insert( scene.materials.end(), merge.materials.begin(), merge.materials.end()); scene.shapes.insert( scene.shapes.end(), merge.shapes.begin(), merge.shapes.end()); scene.subdivs.insert( scene.subdivs.end(), merge.subdivs.begin(), merge.subdivs.end()); scene.instances.insert( scene.instances.end(), merge.instances.begin(), merge.instances.end()); scene.environments.insert(scene.environments.end(), merge.environments.begin(), merge.environments.end()); scene.nodes.insert(scene.nodes.end(), merge.nodes.begin(), merge.nodes.end()); scene.animations.insert( scene.animations.end(), merge.animations.begin(), merge.animations.end()); for (auto material_id = offset_materials; material_id < scene.materials.size(); material_id++) { auto& material = scene.materials[material_id]; if (material.emission_tex >= 0) material.emission_tex += offset_textures; if (material.diffuse_tex >= 0) material.diffuse_tex += offset_textures; if (material.metallic_tex >= 0) material.metallic_tex += offset_textures; if (material.specular_tex >= 0) material.specular_tex += offset_textures; if (material.transmission_tex >= 0) material.transmission_tex += offset_textures; if (material.roughness_tex >= 0) material.roughness_tex += offset_textures; if (material.normal_tex >= 0) material.normal_tex += offset_textures; if (material.voldensity_tex >= 0) material.voldensity_tex += offset_voltextures; } for (auto subdiv_id = offset_subdivs; subdiv_id < scene.subdivs.size(); subdiv_id++) { auto& subdiv = scene.subdivs[subdiv_id]; if (subdiv.shape >= 0) subdiv.shape += offset_shapes; if (subdiv.displacement_tex >= 0) subdiv.displacement_tex += offset_textures; } for (auto instance_id = offset_instances; instance_id < scene.instances.size(); instance_id++) { auto& instance = scene.instances[instance_id]; if (instance.shape >= 0) instance.shape += offset_shapes; if (instance.material >= 0) instance.material += offset_materials; } for (auto environment_id = offset_environments; environment_id < scene.environments.size(); environment_id++) { auto& environment = scene.environments[environment_id]; if (environment.emission_tex >= 0) environment.emission_tex += offset_textures; } for (auto node_id = offset_nodes; node_id < scene.nodes.size(); node_id++) { auto& node = scene.nodes[node_id]; if (node.parent >= 0) node.parent += offset_nodes; if (node.camera >= 0) node.camera += offset_cameras; if (node.instance >= 0) node.instance += offset_instances; if (node.environment >= 0) node.environment += offset_environments; } for (auto animation_id = offset_animations; animation_id < scene.animations.size(); animation_id++) { auto& animation = scene.animations[animation_id]; for (auto& target : animation.targets) if (target >= 0) target += offset_nodes; } } string format_stats( const yocto_scene& scene, const string& prefix, bool verbose) { auto accumulate = [](const auto& values, const auto& func) -> size_t { auto sum = (size_t)0; for (auto& value : values) sum += func(value); return sum; }; auto format = [](auto num) { auto str = std::to_string(num); while (str.size() < 13) str = " " + str; return str; }; auto format3 = [](auto num) { auto str = std::to_string(num.x) + " " + std::to_string(num.y) + " " + std::to_string(num.z); while (str.size() < 13) str = " " + str; return str; }; auto bbox = compute_bounds(scene); auto stats = ""s; stats += prefix + "cameras: " + format(scene.cameras.size()) + "\n"; stats += prefix + "shapes: " + format(scene.shapes.size()) + "\n"; stats += prefix + "subdivs: " + format(scene.subdivs.size()) + "\n"; stats += prefix + "instances: " + format(scene.instances.size()) + "\n"; stats += prefix + "environments: " + format(scene.environments.size()) + "\n"; stats += prefix + "textures: " + format(scene.textures.size()) + "\n"; stats += prefix + "voltextures: " + format(scene.voltextures.size()) + "\n"; stats += prefix + "materials: " + format(scene.materials.size()) + "\n"; stats += prefix + "nodes: " + format(scene.nodes.size()) + "\n"; stats += prefix + "animations: " + format(scene.animations.size()) + "\n"; stats += prefix + "points: " + format(accumulate( scene.shapes, [](auto& shape) { return shape.points.size(); })) + "\n"; stats += prefix + "lines: " + format(accumulate( scene.shapes, [](auto& shape) { return shape.lines.size(); })) + "\n"; stats += prefix + "triangles: " + format(accumulate(scene.shapes, [](auto& shape) { return shape.triangles.size(); })) + "\n"; stats += prefix + "quads: " + format(accumulate( scene.shapes, [](auto& shape) { return shape.quads.size(); })) + "\n"; stats += prefix + "fvquads: " + format(accumulate(scene.shapes, [](auto& shape) { return shape.quadspos.size(); })) + "\n"; stats += prefix + "texels4b: " + format(accumulate(scene.textures, [](auto& texture) { return (size_t)texture.ldr.size().x * (size_t)texture.ldr.size().x; })) + "\n"; stats += prefix + "texels4f: " + format(accumulate(scene.textures, [](auto& texture) { return (size_t)texture.hdr.size().x * (size_t)texture.hdr.size().y; })) + "\n"; stats += prefix + "volxels1f: " + format(accumulate(scene.voltextures, [](auto& texture) { return (size_t)texture.vol.size().x * (size_t)texture.vol.size().y * (size_t)texture.vol.size().z; })) + "\n"; stats += prefix + "center: " + format3(center(bbox)) + "\n"; stats += prefix + "size: " + format3(size(bbox)) + "\n"; return stats; } // Add missing names and resolve duplicated names. void normalize_uris(yocto_scene& scene) { auto normalize = [](string& name, const string& base, const string& ext, int num) { for (auto& c : name) { if (c == ':' || c == ' ') c = '_'; } if (name.empty()) name = base + "_" + std::to_string(num); if (fs::path(name).parent_path().empty()) name = base + "s/" + name; if (fs::path(name).extension().empty()) name = name + "." + ext; }; for (auto id = 0; id < scene.cameras.size(); id++) normalize(scene.cameras[id].uri, "camera", "yaml", id); for (auto id = 0; id < scene.textures.size(); id++) normalize(scene.textures[id].uri, "texture", "png", id); for (auto id = 0; id < scene.voltextures.size(); id++) normalize(scene.voltextures[id].uri, "volume", "yvol", id); for (auto id = 0; id < scene.materials.size(); id++) normalize(scene.materials[id].uri, "material", "yaml", id); for (auto id = 0; id < scene.shapes.size(); id++) normalize(scene.shapes[id].uri, "shape", "ply", id); for (auto id = 0; id < scene.instances.size(); id++) normalize(scene.instances[id].uri, "instance", "yaml", id); for (auto id = 0; id < scene.animations.size(); id++) normalize(scene.animations[id].uri, "animation", "yaml", id); for (auto id = 0; id < scene.nodes.size(); id++) normalize(scene.nodes[id].uri, "node", "yaml", id); } void rename_instances(yocto_scene& scene) { auto shape_names = vector(scene.shapes.size()); for (auto sid = 0; sid < scene.shapes.size(); sid++) { shape_names[sid] = fs::path(scene.shapes[sid].uri).stem(); } auto shape_count = vector(scene.shapes.size(), vec2i{0, 0}); for (auto& instance : scene.instances) shape_count[instance.shape].y += 1; for (auto& instance : scene.instances) { if (shape_count[instance.shape].y == 1) { instance.uri = "instances/" + shape_names[instance.shape] + ".yaml"; } else { auto num = std::to_string(shape_count[instance.shape].x++); while (num.size() < (int)ceil(log10(shape_count[instance.shape].y))) num = '0' + num; instance.uri = "instances/" + shape_names[instance.shape] + "-" + num + ".yaml"; } } } // Normalized a scaled color in a material void normalize_scaled_color(float& scale, vec3f& color) { auto scaled = scale * color; if (max(scaled) == 0) { scale = 0; color = {1, 1, 1}; } else { scale = max(scaled); color = scaled / max(scaled); } } // Add missing tangent space if needed. void add_tangent_spaces(yocto_scene& scene) { for (auto& instance : scene.instances) { auto& material = scene.materials[instance.material]; if (material.normal_tex < 0) continue; auto& shape = scene.shapes[instance.shape]; if (!shape.tangents.empty() || shape.texcoords.empty()) continue; if (!shape.triangles.empty()) { if (shape.normals.empty()) { shape.normals.resize(shape.positions.size()); compute_normals(shape.normals, shape.triangles, shape.positions); } shape.tangents.resize(shape.positions.size()); compute_tangent_spaces(shape.tangents, shape.triangles, shape.positions, shape.normals, shape.texcoords); } else { throw std::runtime_error("type not supported"); } } } // Add missing materials. void add_materials(yocto_scene& scene) { auto material_id = -1; for (auto& instance : scene.instances) { if (instance.material >= 0) continue; if (material_id < 0) { auto material = yocto_material{}; material.uri = "materails/default.yaml"; material.diffuse = {0.2f, 0.2f, 0.2f}; scene.materials.push_back(material); material_id = (int)scene.materials.size() - 1; } instance.material = material_id; } } // Add missing radius. void add_radius(yocto_scene& scene, float radius) { for (auto& shape : scene.shapes) { if (shape.points.empty() && shape.lines.empty()) continue; if (!shape.radius.empty()) continue; shape.radius.assign(shape.positions.size(), radius); } } // Add missing cameras. void add_cameras(yocto_scene& scene) { if (scene.cameras.empty()) { auto camera = yocto_camera{}; camera.uri = "cameras/default.yaml"; set_view(camera, compute_bounds(scene), {0, 0, 1}); scene.cameras.push_back(camera); } } // Add a sky environment void add_sky(yocto_scene& scene, float sun_angle) { auto texture = yocto_texture{}; texture.uri = "textures/sky.hdr"; make_sunsky(texture.hdr, {1024, 512}, sun_angle); scene.textures.push_back(texture); auto environment = yocto_environment{}; environment.uri = "environments/default.yaml"; environment.emission = {1, 1, 1}; environment.emission_tex = (int)scene.textures.size() - 1; scene.environments.push_back(environment); } // Reduce memory usage void trim_memory(yocto_scene& scene) { for (auto& shape : scene.shapes) { shape.points.shrink_to_fit(); shape.lines.shrink_to_fit(); shape.triangles.shrink_to_fit(); shape.quads.shrink_to_fit(); shape.quadspos.shrink_to_fit(); shape.quadsnorm.shrink_to_fit(); shape.quadstexcoord.shrink_to_fit(); shape.positions.shrink_to_fit(); shape.normals.shrink_to_fit(); shape.texcoords.shrink_to_fit(); shape.colors.shrink_to_fit(); shape.radius.shrink_to_fit(); shape.tangents.shrink_to_fit(); } for (auto& texture : scene.textures) { texture.ldr.shrink_to_fit(); texture.hdr.shrink_to_fit(); } scene.cameras.shrink_to_fit(); scene.shapes.shrink_to_fit(); scene.instances.shrink_to_fit(); scene.materials.shrink_to_fit(); scene.textures.shrink_to_fit(); scene.environments.shrink_to_fit(); scene.voltextures.shrink_to_fit(); scene.nodes.shrink_to_fit(); scene.animations.shrink_to_fit(); } // Checks for validity of the scene. vector validate_scene(const yocto_scene& scene, bool notextures) { auto errs = vector(); auto check_names = [&errs](const auto& vals, const string& base) { auto used = unordered_map(); used.reserve(vals.size()); for (auto& value : vals) used[value.uri] += 1; for (auto& [name, used] : used) { if (name == "") { errs.push_back("empty " + base + " name"); } else if (used > 1) { errs.push_back("duplicated " + base + " name " + name); } } }; auto check_empty_textures = [&errs](const vector& vals) { for (auto& value : vals) { if (value.hdr.empty() && value.ldr.empty()) { errs.push_back("empty texture " + value.uri); } } }; check_names(scene.cameras, "camera"); check_names(scene.shapes, "shape"); check_names(scene.textures, "texture"); check_names(scene.voltextures, "voltexture"); check_names(scene.materials, "material"); check_names(scene.instances, "instance"); check_names(scene.environments, "environment"); check_names(scene.nodes, "node"); check_names(scene.animations, "animation"); if (!notextures) check_empty_textures(scene.textures); return errs; } // Logs validations errors void print_validation(const yocto_scene& scene, bool notextures) { for (auto err : validate_scene(scene, notextures)) printf("%s [validation]\n", err.c_str()); } } // namespace yocto goxel-0.11.0/ext_src/yocto/yocto_scene.h000066400000000000000000000535051435762723100202200ustar00rootroot00000000000000// // # Yocto/Scene: Tiny library for scene representation // // // Yocto/Scene is a library to represent 3D scenes using a simple data-driven // and value oriented design. // // // ## Simple scene representation // // Yocto/Scene define a simple scene data structure useful to create quick demos // and as the repsetnation upon which the path tracer works. // // In Yocto scenes, shapes are represented as indexed collections of points, // lines, triangles, quads and bezier segments. Each shape may contain // only one element type. Shapes are organized into a scene by creating shape // instances, each its own transform. Materials are specified like in OBJ and // glTF and include emission, base-metallic and diffuse-specular // parametrization, normal, occlusion and displacement mapping. Finally, the // scene containers cameras and environment maps. Quad support in shapes is // experimental and mostly supported for loading and saving. Lights in // Yocto/Scene are pointers to either instances or environments. The scene // supports an optional node hierarchy with animation modeled on the glTF model. // // 1. load a scene with Yocto/SceneIO, // 2. use `compute_shape_box()/compute_scene_box()` to compute element bounds // 3. compute interpolated values over scene elements with `evaluate_XXX()` // functions // 4. for ray-intersection and closest point queries, use // 'make_bvh()`/`refit_bvh()` // // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // #ifndef _YOCTO_SCENE_H_ #define _YOCTO_SCENE_H_ // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include "yocto_bvh.h" #include "yocto_image.h" #include "yocto_math.h" // ----------------------------------------------------------------------------- // SCENE DATA // ----------------------------------------------------------------------------- namespace yocto { // Camera based on a simple lens model. The camera is placed using a frame. // Camera projection is described in photorgaphics terms. In particular, // we specify fil size (35mm by default), the lens' focal length, the focus // distance and the lens aperture. All values are in meters. // Here are some common aspect ratios used in video and still photography. // 3:2 on 35 mm: 0.036 x 0.024 // 16:9 on 35 mm: 0.036 x 0.02025 or 0.04267 x 0.024 // 2.35:1 on 35 mm: 0.036 x 0.01532 or 0.05640 x 0.024 // 2.39:1 on 35 mm: 0.036 x 0.01506 or 0.05736 x 0.024 // 2.4:1 on 35 mm: 0.036 x 0.015 or 0.05760 x 0.024 (approx. 2.39 : 1) // To compute good apertures, one can use the F-stop number from phostography // and set the aperture to focal_leangth/f_stop. struct yocto_camera { string uri = ""; frame3f frame = identity3x4f; bool orthographic = false; float lens = 0.050; vec2f film = {0.036, 0.024}; float focus = flt_max; float aperture = 0; }; // Texture containing either an LDR or HDR image. Textures are rendered // using linear interpolation (unless `no_interoilation` is set) and // weith tiling (unless `clamp_to_edge` is set). HdR images are encoded // in linear color space, while LDRs are encoded as sRGB. The latter // conversion can be disabled with `ldr_as_linear` for example to render // normal maps. struct yocto_texture { string uri = ""; image hdr = {}; image ldr = {}; }; // Volumetric texture containing a float only volume data. See texture // above for other propoerties. struct yocto_voltexture { string uri = ""; volume vol = {}; }; // Material for surfaces, lines and triangles. // For surfaces, uses a microfacet model with thin sheet transmission. // The model is based on OBJ, but contains glTF compatibility. // For the documentation on the values, please see the OBJ format. struct yocto_material { string uri = ""; // lobes vec3f emission = {0, 0, 0}; vec3f diffuse = {0, 0, 0}; vec3f specular = {0, 0, 0}; float roughness = 0; float metallic = 0; vec3f coat = {0, 0, 0}; vec3f transmission = {0, 0, 0}; vec3f voltransmission = {0, 0, 0}; vec3f volmeanfreepath = {0, 0, 0}; vec3f volemission = {0, 0, 0}; vec3f volscatter = {0, 0, 0}; float volanisotropy = 0; float volscale = 0.01; float opacity = 1; bool thin = false; // textures int emission_tex = -1; int diffuse_tex = -1; int specular_tex = -1; int metallic_tex = -1; int roughness_tex = -1; int transmission_tex = -1; int subsurface_tex = -1; int coat_tex = -1; int opacity_tex = -1; int normal_tex = -1; bool gltf_textures = false; // glTF packed textures // volume textures int voldensity_tex = -1; }; // Shape data represented as an indexed meshes of elements. // May contain either points, lines, triangles and quads. // Additionally, we support faceavarying primitives where each verftex data // has its own topology. struct yocto_shape { // shape data string uri = ""; // primitives vector points = {}; vector lines = {}; vector triangles = {}; vector quads = {}; // face-varying primitives vector quadspos = {}; vector quadsnorm = {}; vector quadstexcoord = {}; // vertex data vector positions = {}; vector normals = {}; vector texcoords = {}; vector colors = {}; vector radius = {}; vector tangents = {}; }; // Shape data represented as an indexed meshes of elements. // This object exists only to allow for further subdivision. The current // subdiviion data is stored in the pointed to shape, so the rest of the system // does not need to known about subdivs. While this is mostly helpful for // subdivision surfaces, we store here all data that we possibly may want to // subdivide, for later use. struct yocto_subdiv { // shape data string uri = ""; // tesselated shape int shape = -1; // subdision properties int subdivisions = 0; bool catmullclark = false; bool smooth = false; bool facevarying = false; // displacement information float displacement = 0; int displacement_tex = -1; // primitives vector points = {}; vector lines = {}; vector triangles = {}; vector quads = {}; // face-varying primitives vector quadspos = {}; vector quadsnorm = {}; vector quadstexcoord = {}; // vertex data vector positions = {}; vector normals = {}; vector texcoords = {}; vector colors = {}; vector radius = {}; }; // Instance of a visible shape in the scene. struct yocto_instance { string uri = ""; frame3f frame = identity3x4f; int shape = -1; int material = -1; }; // Environment map. struct yocto_environment { string uri = ""; frame3f frame = identity3x4f; vec3f emission = {0, 0, 0}; int emission_tex = -1; }; // Node in a transform hierarchy. struct yocto_scene_node { string uri = ""; int parent = -1; frame3f local = identity3x4f; vec3f translation = {0, 0, 0}; vec4f rotation = {0, 0, 0, 1}; vec3f scale = {1, 1, 1}; vector weights = {}; int camera = -1; int instance = -1; int environment = -1; // compute properties vector children = {}; }; // Keyframe data. struct yocto_animation { enum struct interpolation_type { linear, step, bezier }; string uri = ""; string filename = ""; string group = ""; interpolation_type interpolation = interpolation_type::linear; vector times = {}; vector translations = {}; vector rotations = {}; vector scales = {}; vector> morphs = {}; vector targets = {}; }; // Scene comprised an array of objects whose memory is owened by the scene. // All members are optional,Scene objects (camera, instances, environments) // have transforms defined internally. A scene can optionally contain a // node hierarchy where each node might point to a camera, instance or // environment. In that case, the element transforms are computed from // the hierarchy. Animation is also optional, with keyframe data that // updates node transformations only if defined. struct yocto_scene { string uri = ""; vector cameras = {}; vector shapes = {}; vector instances = {}; vector materials = {}; vector textures = {}; vector environments = {}; vector subdivs = {}; vector voltextures = {}; vector nodes = {}; vector animations = {}; }; } // namespace yocto // ----------------------------------------------------------------------------- // SCENE UTILITIES // ----------------------------------------------------------------------------- namespace yocto { // Merge a scene into another void merge_scene(yocto_scene& scene, const yocto_scene& merge); // Print scene statistics. string format_stats( const yocto_scene& scene, const string& prefix = "", bool verbose = false); // Add missing names, normals, tangents and hierarchy. void add_normals(yocto_scene& scene); void add_tangent_spaces(yocto_scene& scene); void add_materials(yocto_scene& scene); void add_cameras(yocto_scene& scene); void add_radius(yocto_scene& scene, float radius = 0.001f); // Normalize URIs and add missing ones. Assumes names are unique. void normalize_uris(yocto_scene& sceme); void rename_instances(yocto_scene& scene); // Add a sky environment void add_sky(yocto_scene& scene, float sun_angle = pif / 4); // Reduce memory usage void trim_memory(yocto_scene& scene); // Checks for validity of the scene. void print_validation(const yocto_scene& scene, bool notextures = false); } // namespace yocto // ----------------------------------------------------------------------------- // EVALUATION OF SCENE PROPERTIES // ----------------------------------------------------------------------------- namespace yocto { // Update node transforms. void update_transforms( yocto_scene& scene, float time = 0, const string& anim_group = ""); // Compute animation range. vec2f compute_animation_range( const yocto_scene& scene, const string& anim_group = ""); // Computes shape/scene approximate bounds. bbox3f compute_bounds(const yocto_shape& shape); bbox3f compute_bounds(const yocto_scene& scene); // Compute shape vertex normals vector compute_normals(const yocto_shape& shape); void compute_normals(const yocto_shape& shape, vector& normals); // Apply subdivision and displacement rules. void subdivide_shape(yocto_shape& shape, int subdivisions, bool catmullclark, bool compute_normals); void displace_shape(yocto_shape& shape, const yocto_texture& displacement, float scale, bool compute_normals); void tesselate_subdiv(yocto_scene& scene, yocto_subdiv& subdiv); void tesselate_subdivs(yocto_scene& scene); // Build/refit the bvh acceleration structure. bvh_scene make_bvh(const yocto_scene& scene, const bvh_params& params); void make_bvh( bvh_scene& bvh, const yocto_scene& scene, const bvh_params& params); void refit_bvh(bvh_scene& bvh, const yocto_scene& scene, const vector& updated_shapes, const bvh_params& params); // Shape values interpolated by interpoalting vertex values of the `eid` element // with its barycentric coordinates `euv`. vec3f eval_position(const yocto_shape& shape, int element, const vec2f& uv); vec3f eval_normal(const yocto_shape& shape, int element, const vec2f& uv); vec2f eval_texcoord(const yocto_shape& shape, int element, const vec2f& uv); vec4f eval_color(const yocto_shape& shape, int element, const vec2f& uv); float eval_radius(const yocto_shape& shape, int element, const vec2f& uv); pair eval_tangent_basis( const yocto_shape& shape, int element, const vec2f& uv); // Shape element values. vec3f eval_element_normal(const yocto_shape& shape, int element); pair eval_element_tangents( const yocto_shape& shape, int element, const vec2f& uv = zero2f); pair eval_element_tangent_basis( const yocto_shape& shape, int element, const vec2f& uv = zero2f); // Sample a shape element based on area/length. pair sample_shape(const yocto_shape& shape, const vector& cdf, float re, const vec2f& ruv); vector sample_shape_cdf(const yocto_shape& shape); void sample_shape_cdf(const yocto_shape& shape, vector& cdf); float sample_shape_pdf(const yocto_shape& shape, const vector& cdf, int element, const vec2f& uv); // Evaluate a texture. vec2i texture_size(const yocto_texture& texture); vec4f lookup_texture( const yocto_texture& texture, int i, int j, bool ldr_as_linear = false); vec4f eval_texture(const yocto_texture& texture, const vec2f& texcoord, bool ldr_as_linear = false, bool no_interpolation = false, bool clamp_to_edge = false); float lookup_voltexture( const yocto_voltexture& texture, int i, int j, int k, bool ldr_as_linear); float eval_voltexture(const yocto_voltexture& texture, const vec3f& texcoord, bool ldr_as_linear = false, bool no_interpolation = false, bool clamp_to_edge = false); // Set and evaluate camera parameters. Setters take zeros as default values. vec2f camera_fov(const yocto_camera& camera); float camera_yfov(const yocto_camera& camera); float camera_aspect(const yocto_camera& camera); vec2i camera_resolution(const yocto_camera& camera, int resolution); void set_yperspective(yocto_camera& camera, float yfov, float aspect, float focus, float film = 0.036f); // Sets camera field of view to enclose all the bbox. Camera view direction // fiom size and forcal lemgth can be overridden if we pass non zero values. void set_view(yocto_camera& camera, const bbox3f& bbox, const vec3f& view_direction = zero3f); // Generates a ray from the image coordinates `uv` and lens coordinates `luv`. ray3f eval_camera( const yocto_camera& camera, const vec2f& uv, const vec2f& luv); // Generates a ray from a camera for pixel `ij`, the image size `resolution`, // the sub-pixel coordinates `puv` and the lens coordinates `luv`. ray3f eval_camera(const yocto_camera& camera, const vec2i& ij, const vec2i& resolution, const vec2f& puv, const vec2f& luv); // Material values packed into a convenience structure. struct material_point { vec3f emission = {0, 0, 0}; vec3f diffuse = {0, 0, 0}; vec3f specular = {0, 0, 0}; vec3f coat = {0, 0, 0}; vec3f transmission = {0, 0, 0}; float roughness = 0; vec3f voldensity = {0, 0, 0}; vec3f volemission = {0, 0, 0}; vec3f volscatter = {0, 0, 0}; float volanisotropy = 0; float opacity = 1; bool thin = false; }; material_point eval_material(const yocto_scene& scene, const yocto_material& material, const vec2f& texcoord, const vec4f& shape_color); // Instance values interpolated using barycentric coordinates. // Handles defaults if data is missing. vec3f eval_position(const yocto_scene& scene, const yocto_instance& instance, int element, const vec2f& uv); vec3f eval_normal(const yocto_scene& scene, const yocto_instance& instance, int element, const vec2f& uv, bool non_rigid_frame = false); vec3f eval_shading_normal(const yocto_scene& scene, const yocto_instance& instance, int element, const vec2f& uv, const vec3f& direction, bool non_rigid_frame = false); vec3f eval_element_normal(const yocto_scene& scene, const yocto_instance& instance, int element, bool non_rigid_frame = false); material_point eval_material(const yocto_scene& scene, const yocto_instance& instance, int element, const vec2f& uv); // Environment texture coordinates from the incoming direction. vec2f eval_texcoord( const yocto_environment& environment, const vec3f& direction); // Evaluate the incoming direction from the uv. vec3f eval_direction( const yocto_environment& environment, const vec2f& environment_uv); // Evaluate the environment emission. vec3f eval_environment(const yocto_scene& scene, const yocto_environment& environment, const vec3f& direction); // Evaluate all environment emission. vec3f eval_environment(const yocto_scene& scene, const vec3f& direction); // Sample an environment based on either texel values of uniform vec3f sample_environment(const yocto_scene& scene, const yocto_environment& environment, const vector& texels_cdf, float re, const vec2f& ruv); vector sample_environment_cdf( const yocto_scene& scene, const yocto_environment& environment); void sample_environment_cdf(const yocto_scene& scene, const yocto_environment& environment, vector& texels_cdf); float sample_environment_pdf(const yocto_scene& scene, const yocto_environment& environment, const vector& texels_cdf, const vec3f& direction); } // namespace yocto // ----------------------------------------------------------------------------- // ANIMATION UTILITIES // ----------------------------------------------------------------------------- namespace yocto { // Find the first keyframe value that is greater than the argument. inline int keyframe_index(const vector& times, const float& time); // Evaluates a keyframed value using step interpolation. template inline T keyframe_step( const vector& times, const vector& vals, float time); // Evaluates a keyframed value using linear interpolation. template inline vec4f keyframe_slerp( const vector& times, const vector& vals, float time); // Evaluates a keyframed value using linear interpolation. template inline T keyframe_linear( const vector& times, const vector& vals, float time); // Evaluates a keyframed value using Bezier interpolation. template inline T keyframe_bezier( const vector& times, const vector& vals, float time); } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION OF ANIMATION UTILITIES // ----------------------------------------------------------------------------- namespace yocto { // Find the first keyframe value that is greater than the argument. inline int keyframe_index(const vector& times, const float& time) { for (auto i = 0; i < times.size(); i++) if (times[i] > time) return i; return (int)times.size(); } // Evaluates a keyframed value using step interpolation. template inline T keyframe_step( const vector& times, const vector& vals, float time) { if (time <= times.front()) return vals.front(); if (time >= times.back()) return vals.back(); time = clamp(time, times.front(), times.back() - 0.001f); auto idx = keyframe_index(times, time); return vals.at(idx - 1); } // Evaluates a keyframed value using linear interpolation. template inline vec4f keyframe_slerp( const vector& times, const vector& vals, float time) { if (time <= times.front()) return vals.front(); if (time >= times.back()) return vals.back(); time = clamp(time, times.front(), times.back() - 0.001f); auto idx = keyframe_index(times, time); auto t = (time - times.at(idx - 1)) / (times.at(idx) - times.at(idx - 1)); return slerp(vals.at(idx - 1), vals.at(idx), t); } // Evaluates a keyframed value using linear interpolation. template inline T keyframe_linear( const vector& times, const vector& vals, float time) { if (time <= times.front()) return vals.front(); if (time >= times.back()) return vals.back(); time = clamp(time, times.front(), times.back() - 0.001f); auto idx = keyframe_index(times, time); auto t = (time - times.at(idx - 1)) / (times.at(idx) - times.at(idx - 1)); return vals.at(idx - 1) * (1 - t) + vals.at(idx) * t; } // Evaluates a keyframed value using Bezier interpolation. template inline T keyframe_bezier( const vector& times, const vector& vals, float time) { if (time <= times.front()) return vals.front(); if (time >= times.back()) return vals.back(); time = clamp(time, times.front(), times.back() - 0.001f); auto idx = keyframe_index(times, time); auto t = (time - times.at(idx - 1)) / (times.at(idx) - times.at(idx - 1)); return interpolate_bezier( vals.at(idx - 3), vals.at(idx - 2), vals.at(idx - 1), vals.at(idx), t); } } // namespace yocto #endif goxel-0.11.0/ext_src/yocto/yocto_sceneio.cpp000066400000000000000000004622041435762723100211030ustar00rootroot00000000000000// // Implementation for Yocto/GL Input and Output functions. // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // #include "yocto_sceneio.h" #include "yocto_obj.h" #include "yocto_pbrt.h" #include "yocto_random.h" #include "yocto_shape.h" #include "ext/happly.h" #define CGLTF_IMPLEMENTATION #include "ext/cgltf.h" #include #include #include #include #include #include #include #include #include #include #include "ext/filesystem.hpp" namespace fs = ghc::filesystem; // ----------------------------------------------------------------------------- // USING DIRECTIVES // ----------------------------------------------------------------------------- namespace yocto { // Type aliases for readability using string_view = std::string_view; using namespace std::literals::string_view_literals; } // namespace yocto // ----------------------------------------------------------------------------- // CONCURRENCY // ----------------------------------------------------------------------------- namespace yocto { // Simple parallel for used since our target platforms do not yet support // parallel algorithms. `Func` takes a reference to a `T`. template static inline void parallel_foreach( vector& values, const Func& func, std::atomic* cancel = nullptr) { auto futures = vector>{}; auto nthreads = std::thread::hardware_concurrency(); std::atomic next_idx(0); for (auto thread_id = 0; thread_id < nthreads; thread_id++) { futures.emplace_back( std::async(std::launch::async, [&func, &next_idx, cancel, &values]() { while (true) { if (cancel && *cancel) break; auto idx = next_idx.fetch_add(1); if (idx >= values.size()) break; func(values[idx]); } })); } for (auto& f : futures) f.get(); } template static inline void parallel_foreach(const vector& values, const Func& func, std::atomic* cancel = nullptr) { auto futures = vector>{}; auto nthreads = std::thread::hardware_concurrency(); std::atomic next_idx(0); for (auto thread_id = 0; thread_id < nthreads; thread_id++) { futures.emplace_back( std::async(std::launch::async, [&func, &next_idx, cancel, &values]() { while (true) { if (cancel && *cancel) break; auto idx = next_idx.fetch_add(1); if (idx >= values.size()) break; func(values[idx]); } })); } for (auto& f : futures) f.get(); } } // namespace yocto // ----------------------------------------------------------------------------- // FILE IO // ----------------------------------------------------------------------------- namespace yocto { // Load a text file inline void load_text(const string& filename, string& str) { // https://stackoverflow.com/questions/174531/how-to-read-the-content-of-a-file-to-a-string-in-c auto fs = fopen(filename.c_str(), "rt"); if (!fs) throw std::runtime_error("cannot open file " + filename); fseek(fs, 0, SEEK_END); auto length = ftell(fs); fseek(fs, 0, SEEK_SET); str.resize(length); if (fread(str.data(), 1, length, fs) != length) { fclose(fs); throw std::runtime_error("cannot read file " + filename); } fclose(fs); } // Save a text file inline void save_text(const string& filename, const string& str) { auto fs = fopen(filename.c_str(), "wt"); if (!fs) throw std::runtime_error("cannot open file " + filename); if (fprintf(fs, "%s", str.c_str()) < 0) { fclose(fs); throw std::runtime_error("cannot write file " + filename); } fclose(fs); } // Load a binary file inline void load_binary(const string& filename, vector& data) { // https://stackoverflow.com/questions/174531/how-to-read-the-content-of-a-file-to-a-string-in-c auto fs = fopen(filename.c_str(), "rb"); if (!fs) throw std::runtime_error("cannot open file " + filename); fseek(fs, 0, SEEK_END); auto length = ftell(fs); fseek(fs, 0, SEEK_SET); data.resize(length); if (fread(data.data(), 1, length, fs) != length) { fclose(fs); throw std::runtime_error("cannot read file " + filename); } fclose(fs); } // Save a binary file inline void save_binary(const string& filename, const vector& data) { auto fs = fopen(filename.c_str(), "wb"); if (!fs) throw std::runtime_error("cannot open file " + filename); if (fwrite(data.data(), 1, data.size(), fs) != data.size()) { fclose(fs); throw std::runtime_error("cannot write file " + filename); } fclose(fs); } } // namespace yocto // ----------------------------------------------------------------------------- // FILE UTILITIES // ----------------------------------------------------------------------------- namespace yocto { // A file holder that closes a file when destructed. Useful for RIIA struct file_holder { FILE* fs = nullptr; string filename = ""; file_holder(const file_holder&) = delete; file_holder& operator=(const file_holder&) = delete; ~file_holder() { if (fs) fclose(fs); } }; // Opens a file returing a handle with RIIA static inline file_holder open_input_file( const string& filename, bool binary = false) { auto fs = fopen(filename.c_str(), !binary ? "rt" : "rb"); if (!fs) throw std::runtime_error("could not open file " + filename); return {fs, filename}; } static inline file_holder open_output_file( const string& filename, bool binary = false) { auto fs = fopen(filename.c_str(), !binary ? "wt" : "wb"); if (!fs) throw std::runtime_error("could not open file " + filename); return {fs, filename}; } // Read a line static inline bool read_line(FILE* fs, char* buffer, size_t size) { return fgets(buffer, size, fs) != nullptr; } } // namespace yocto // ----------------------------------------------------------------------------- // GENERIC SCENE LOADING // ----------------------------------------------------------------------------- namespace yocto { // Load/save a scene in the builtin YAML format. static void load_yaml_scene( const string& filename, yocto_scene& scene, const load_params& params); static void save_yaml_scene(const string& filename, const yocto_scene& scene, const save_params& params); // Load/save a scene from/to OBJ. static void load_obj_scene( const string& filename, yocto_scene& scene, const load_params& params); static void save_obj_scene(const string& filename, const yocto_scene& scene, const save_params& params); // Load/save a scene from/to PLY. Loads/saves only one mesh with no other data. static void load_ply_scene( const string& filename, yocto_scene& scene, const load_params& params); static void save_ply_scene(const string& filename, const yocto_scene& scene, const save_params& params); // Load/save a scene from/to glTF. static void load_gltf_scene( const string& filename, yocto_scene& scene, const load_params& params); static void save_gltf_scene(const string& filename, const yocto_scene& scene, const save_params& params); // Load/save a scene from/to pbrt. This is not robust at all and only // works on scene that have been previously adapted since the two renderers // are too different to match. static void load_pbrt_scene( const string& filename, yocto_scene& scene, const load_params& params); static void save_pbrt_scene(const string& filename, const yocto_scene& scene, const save_params& params); // Load a scene void load_scene( const string& filename, yocto_scene& scene, const load_params& params) { auto ext = fs::path(filename).extension().string(); if (ext == ".yaml" || ext == ".YAML") { load_yaml_scene(filename, scene, params); } else if (ext == ".obj" || ext == ".OBJ") { load_obj_scene(filename, scene, params); } else if (ext == ".gltf" || ext == ".GLTF") { load_gltf_scene(filename, scene, params); } else if (ext == ".pbrt" || ext == ".PBRT") { load_pbrt_scene(filename, scene, params); } else if (ext == ".ply" || ext == ".PLY") { load_ply_scene(filename, scene, params); } else { scene = {}; throw std::runtime_error("unsupported scene format " + ext); } } // Save a scene void save_scene(const string& filename, const yocto_scene& scene, const save_params& params) { auto ext = fs::path(filename).extension().string(); if (ext == ".yaml" || ext == ".YAML") { save_yaml_scene(filename, scene, params); } else if (ext == ".obj" || ext == ".OBJ") { save_obj_scene(filename, scene, params); } else if (ext == ".gltf" || ext == ".GLTF") { save_gltf_scene(filename, scene, params); } else if (ext == ".pbrt" || ext == ".PBRT") { save_pbrt_scene(filename, scene, params); } else if (ext == ".ply" || ext == ".PLY") { save_ply_scene(filename, scene, params); } else { throw std::runtime_error("unsupported scene format " + ext); } } static string get_save_scene_message(const yocto_scene& scene) { auto str = ""s; str += "# \n"; str += "# Written by Yocto/GL\n"; str += "# https://github.com/xelatihy/yocto-gl\n"; str += "# \n"; str += format_stats(scene, "# "); str += "# \n"; return str; } // Return the preset type and the remaining filename static inline bool is_preset_filename(const string& filename) { return filename.find("::yocto::") == 0; } // Return the preset type and the filename. Call only if this is a preset. static inline pair get_preset_type(const string& filename) { if (filename.find("::yocto::") == 0) { auto aux = filename.substr(string("::yocto::").size()); auto pos = aux.find("::"); if (pos == aux.npos) throw std::runtime_error("bad preset name" + filename); return {aux.substr(0, pos), aux.substr(pos + 2)}; } else { return {"", filename}; } } void load_texture(yocto_texture& texture, const string& dirname) { if (is_preset_filename(texture.uri)) { auto [type, nfilename] = get_preset_type(texture.uri); make_image_preset(texture.hdr, texture.ldr, type); texture.uri = nfilename; } else { if (is_hdr_filename(texture.uri)) { load_image(fs::path(dirname) / texture.uri, texture.hdr); } else { load_imageb(fs::path(dirname) / texture.uri, texture.ldr); } } } void load_voltexture(yocto_voltexture& texture, const string& dirname) { if (is_preset_filename(texture.uri)) { auto [type, nfilename] = get_preset_type(texture.uri); make_volpreset(texture.vol, type); texture.uri = nfilename; } else { load_volume(fs::path(dirname) / texture.uri, texture.vol); } } void load_textures( yocto_scene& scene, const string& dirname, const load_params& params) { if (params.notextures) return; // load images if (params.noparallel) { for (auto& texture : scene.textures) { if (params.cancel && *params.cancel) break; if (!texture.hdr.empty() || !texture.ldr.empty()) return; load_texture(texture, dirname); } } else { parallel_foreach( scene.textures, [&dirname](yocto_texture& texture) { if (!texture.hdr.empty() || !texture.ldr.empty()) return; load_texture(texture, dirname); }, params.cancel); } // load volumes if (params.noparallel) { for (auto& texture : scene.voltextures) { if (params.cancel && *params.cancel) break; if (!texture.vol.empty()) return; load_voltexture(texture, dirname); } } else { parallel_foreach( scene.voltextures, [&dirname](yocto_voltexture& texture) { if (!texture.vol.empty()) return; load_voltexture(texture, dirname); }, params.cancel); } } void save_texture(const yocto_texture& texture, const string& dirname) { if (!texture.hdr.empty()) { save_image(fs::path(dirname) / texture.uri, texture.hdr); } else { save_imageb(fs::path(dirname) / texture.uri, texture.ldr); } } void save_voltexture(const yocto_voltexture& texture, const string& dirname) { save_volume(fs::path(dirname) / texture.uri, texture.vol); } // helper to save textures void save_textures(const yocto_scene& scene, const string& dirname, const save_params& params) { if (params.notextures) return; // save images if (params.noparallel) { for (auto& texture : scene.textures) { if (params.cancel && *params.cancel) break; save_texture(texture, dirname); } } else { parallel_foreach( scene.textures, [&dirname]( const yocto_texture& texture) { save_texture(texture, dirname); }, params.cancel); } // save volumes if (params.noparallel) { for (auto& texture : scene.voltextures) { if (params.cancel && *params.cancel) break; save_voltexture(texture, dirname); } } else { parallel_foreach( scene.voltextures, [&dirname](const yocto_voltexture& texture) { save_voltexture(texture, dirname); }, params.cancel); } } void load_shape(yocto_shape& shape, const string& dirname) { if (is_preset_filename(shape.uri)) { auto [type, nfilename] = get_preset_type(shape.uri); make_shape_preset(shape.points, shape.lines, shape.triangles, shape.quads, shape.quadspos, shape.quadsnorm, shape.quadstexcoord, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius, type); shape.uri = nfilename; } else { load_shape(fs::path(dirname) / shape.uri, shape.points, shape.lines, shape.triangles, shape.quads, shape.quadspos, shape.quadsnorm, shape.quadstexcoord, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius, false); } } void save_shape(const yocto_shape& shape, const string& dirname) { save_shape(fs::path(dirname) / shape.uri, shape.points, shape.lines, shape.triangles, shape.quads, shape.quadspos, shape.quadsnorm, shape.quadstexcoord, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius); } void load_subdiv(yocto_subdiv& subdiv, const string& dirname) { if (is_preset_filename(subdiv.uri)) { auto [type, nfilename] = get_preset_type(subdiv.uri); make_shape_preset(subdiv.points, subdiv.lines, subdiv.triangles, subdiv.quads, subdiv.quadspos, subdiv.quadsnorm, subdiv.quadstexcoord, subdiv.positions, subdiv.normals, subdiv.texcoords, subdiv.colors, subdiv.radius, type); subdiv.uri = nfilename; } else { load_shape(fs::path(dirname) / subdiv.uri, subdiv.points, subdiv.lines, subdiv.triangles, subdiv.quads, subdiv.quadspos, subdiv.quadsnorm, subdiv.quadstexcoord, subdiv.positions, subdiv.normals, subdiv.texcoords, subdiv.colors, subdiv.radius, subdiv.facevarying); } } void save_subdiv(const yocto_subdiv& subdiv, const string& dirname) { save_shape(fs::path(dirname) / subdiv.uri, subdiv.points, subdiv.lines, subdiv.triangles, subdiv.quads, subdiv.quadspos, subdiv.quadsnorm, subdiv.quadstexcoord, subdiv.positions, subdiv.normals, subdiv.texcoords, subdiv.colors, subdiv.radius); } // Load json meshes void load_shapes( yocto_scene& scene, const string& dirname, const load_params& params) { // load shapes if (params.noparallel) { for (auto& shape : scene.shapes) { if (params.cancel && *params.cancel) break; load_shape(shape, dirname); } } else { parallel_foreach( scene.shapes, [&dirname](yocto_shape& shape) { load_shape(shape, dirname); }, params.cancel); } // load subdivs if (params.noparallel) { for (auto& subdiv : scene.subdivs) { if (params.cancel && *params.cancel) break; load_subdiv(subdiv, dirname); } } else { parallel_foreach( scene.subdivs, [&dirname](yocto_subdiv& subdiv) { load_subdiv(subdiv, dirname); }, params.cancel); } } // Save json meshes void save_shapes(const yocto_scene& scene, const string& dirname, const save_params& params) { // save shapes if (params.noparallel) { for (auto& shape : scene.shapes) { if (params.cancel && *params.cancel) break; save_shape(shape, dirname); } } else { parallel_foreach( scene.shapes, [&dirname](const yocto_shape& shape) { save_shape(shape, dirname); }, params.cancel); } // save subdivs if (params.noparallel) { for (auto& subdiv : scene.subdivs) { if (params.cancel && *params.cancel) break; save_subdiv(subdiv, dirname); } } else { parallel_foreach( scene.subdivs, [&dirname]( const yocto_subdiv& subdiv) { save_subdiv(subdiv, dirname); }, params.cancel); } } } // namespace yocto // ----------------------------------------------------------------------------- // YAML SUPPORT // ----------------------------------------------------------------------------- namespace yocto { struct yaml_callbacks { virtual void group(string_view name) {} virtual void object(string_view name) {} virtual void property(string_view key, string_view value) {} virtual void property(string_view name, string_view key, string_view value) {} }; static inline bool is_yaml_space(char c) { return c == ' ' || c == '\t' || c == '\r' || c == '\n'; } static inline bool is_yaml_newline(char c) { return c == '\r' || c == '\n'; } static inline bool is_yaml_alpha(char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); } static inline bool is_yaml_digit(char c) { return c >= '0' && c <= '9'; } static inline bool is_yaml_whitespace(string_view str) { while (!str.empty()) { if (!is_yaml_space(str.front())) return false; str.remove_prefix(1); } return true; } static inline void skip_yaml_whitespace(string_view& str) { while (!str.empty() && is_yaml_space(str.front())) str.remove_prefix(1); } static inline void trim_yaml_whitespace(string_view& str) { while (!str.empty() && is_yaml_space(str.front())) str.remove_prefix(1); while (!str.empty() && is_yaml_space(str.back())) str.remove_suffix(1); } static inline void remove_yaml_comment( string_view& str, char comment_char = '#') { while (!str.empty() && is_yaml_newline(str.back())) str.remove_suffix(1); auto cpy = str; while (!cpy.empty() && cpy.front() != comment_char) cpy.remove_prefix(1); str.remove_suffix(cpy.size()); } static inline void parse_yaml_varname(string_view& str, string_view& value) { skip_yaml_whitespace(str); if (str.empty()) throw std::runtime_error("cannot parse value"); if (!is_yaml_alpha(str.front())) throw std::runtime_error("cannot parse value"); auto pos = 0; while ( is_yaml_alpha(str[pos]) || str[pos] == '_' || is_yaml_digit(str[pos])) { pos += 1; if (pos >= str.size()) break; } value = str.substr(0, pos); str.remove_prefix(pos); } inline void parse_yaml_value(string_view& str, string_view& value) { skip_yaml_whitespace(str); if (str.empty()) throw std::runtime_error("cannot parse value"); if (str.front() != '"') { auto cpy = str; while (!cpy.empty() && !is_yaml_space(cpy.front())) cpy.remove_prefix(1); value = str; value.remove_suffix(cpy.size()); str.remove_prefix(str.size() - cpy.size()); } else { if (str.front() != '"') throw std::runtime_error("cannot parse value"); str.remove_prefix(1); if (str.empty()) throw std::runtime_error("cannot parse value"); auto cpy = str; while (!cpy.empty() && cpy.front() != '"') cpy.remove_prefix(1); if (cpy.empty()) throw std::runtime_error("cannot parse value"); value = str; value.remove_suffix(cpy.size()); str.remove_prefix(str.size() - cpy.size()); str.remove_prefix(1); } } inline void parse_yaml_value(string_view& str, string& value) { auto valuev = ""sv; parse_yaml_value(str, valuev); value = string{valuev}; } inline void parse_yaml_value(string_view& str, int& value) { skip_yaml_whitespace(str); char* end = nullptr; value = (int)strtol(str.data(), &end, 10); if (str == end) throw std::runtime_error("cannot parse value"); str.remove_prefix(end - str.data()); } inline void parse_yaml_value(string_view& str, float& value) { skip_yaml_whitespace(str); char* end = nullptr; value = strtof(str.data(), &end); if (str == end) throw std::runtime_error("cannot parse value"); str.remove_prefix(end - str.data()); } inline void parse_yaml_value(string_view& str, bool& value) { auto values = ""sv; parse_yaml_value(str, values); if (values == "true" || values == "True") { value = true; } else if (values == "false" || values == "False") { value = false; } else { throw std::runtime_error("expected bool"); } } template inline void parse_yaml_value(string_view& str, T* values, int N) { skip_yaml_whitespace(str); if (str.empty() || str.front() != '[') throw std::runtime_error("expected array"); str.remove_prefix(1); for (auto i = 0; i < N; i++) { skip_yaml_whitespace(str); if (str.empty()) throw std::runtime_error("expected array"); parse_yaml_value(str, values[i]); skip_yaml_whitespace(str); if (i != N - 1) { if (str.empty() || str.front() != ',') throw std::runtime_error("expected array"); str.remove_prefix(1); skip_yaml_whitespace(str); } } skip_yaml_whitespace(str); if (str.empty() || str.front() != ']') throw std::runtime_error("expected array"); str.remove_prefix(1); } inline void parse_yaml_value(string_view& str, vec2f& value) { return parse_yaml_value(str, &value.x, 2); } inline void parse_yaml_value(string_view& str, vec3f& value) { return parse_yaml_value(str, &value.x, 3); } inline void parse_yaml_value(string_view& str, vec4f& value) { return parse_yaml_value(str, &value.x, 4); } inline void parse_yaml_value(string_view& str, vec2i& value) { return parse_yaml_value(str, &value.x, 2); } inline void parse_yaml_value(string_view str, vec3i& value) { return parse_yaml_value(str, &value.x, 3); } inline void parse_yaml_value(string_view& str, vec4i& value) { return parse_yaml_value(str, &value.x, 4); } inline void parse_yaml_value(string_view& str, frame2f& value) { return parse_yaml_value(str, &value.x.x, 6); } inline void parse_yaml_value(string_view& str, frame3f& value) { return parse_yaml_value(str, &value.x.x, 12); } inline void parse_yaml_value(string_view& str, mat2f& value) { return parse_yaml_value(str, &value.x.x, 4); } inline void parse_yaml_value(string_view& str, mat3f& value) { return parse_yaml_value(str, &value.x.x, 9); } inline void parse_yaml_value(string_view& str, mat4f& value) { return parse_yaml_value(str, &value.x.x, 16); } inline void load_yaml(const string& filename, yaml_callbacks& callbacks) { // open file auto fs_ = open_input_file(filename); auto fs = fs_.fs; // parsing state auto group = ""s; auto in_object = false; // read the file line by line char buffer[4096]; while (read_line(fs, buffer, sizeof(buffer))) { // line auto line = string_view{buffer}; remove_yaml_comment(line); if (line.empty()) continue; if (is_yaml_whitespace(line)) continue; // peek commands if (is_yaml_space(line.front())) { // indented property if (group == "") throw std::runtime_error("bad yaml"); skip_yaml_whitespace(line); if (line.empty()) throw std::runtime_error("bad yaml"); if (line.front() == '-') { if (!in_object) callbacks.group(group); callbacks.object(group); line.remove_prefix(1); skip_yaml_whitespace(line); in_object = true; } else if (!in_object) { callbacks.object(group); line.remove_prefix(1); skip_yaml_whitespace(line); in_object = true; } auto key = ""sv; parse_yaml_varname(line, key); skip_yaml_whitespace(line); if (line.empty() || line.front() != ':') throw std::runtime_error("bad yaml"); line.remove_prefix(1); trim_yaml_whitespace(line); callbacks.property(group, key, line); } else if (is_yaml_alpha(line.front())) { // new group if (group != "" && !in_object) throw std::runtime_error("bad yaml"); auto key = ""sv; parse_yaml_varname(line, key); skip_yaml_whitespace(line); if (line.empty() || line.front() != ':') throw std::runtime_error("bad yaml"); line.remove_prefix(1); if (!line.empty() && !is_yaml_whitespace(line)) { group = ""; trim_yaml_whitespace(line); callbacks.property(key, line); } else { group = key; in_object = false; } } else { throw std::runtime_error("bad yaml"); } } } struct load_yaml_scene_cb : yaml_callbacks { yocto_scene& scene; const load_params& params; string ply_instances = ""; enum struct parsing_type { none, camera, texture, voltexture, material, shape, subdiv, instance, environment }; parsing_type type = parsing_type::none; unordered_map tmap = {{"", -1}}; unordered_map vmap = {{"", -1}}; unordered_map mmap = {{"", -1}}; unordered_map smap = {{"", -1}}; load_yaml_scene_cb(yocto_scene& scene, const load_params& params) : scene{scene}, params{params} { auto reserve_size = 1024 * 32; tmap.reserve(reserve_size); mmap.reserve(reserve_size); smap.reserve(reserve_size); scene.textures.reserve(reserve_size); scene.materials.reserve(reserve_size); scene.shapes.reserve(reserve_size); scene.instances.reserve(reserve_size); } void get_yaml_ref( string_view yml, int& value, unordered_map& refs) { auto name = ""s; parse_yaml_value(yml, name); if (name == "") return; try { value = refs.at(name); } catch (...) { throw std::runtime_error("reference not found " + name); } } void get_yaml_ref(string_view yml, int& value, size_t nrefs) { parse_yaml_value(yml, value); if (value < 0) return; if (value >= nrefs) { throw std::runtime_error("reference not found " + std::to_string(value)); } } template void update_texture_refs( const vector& elems, unordered_map& emap) { if (emap.size() == elems.size()) return; emap.reserve(elems.size()); for (auto id = 0; id < elems.size(); id++) { emap[elems[id].uri] = id; } } void object(string_view name) override { if (name == "cameras") { type = parsing_type::camera; scene.cameras.push_back({}); } else if (name == "textures") { type = parsing_type::texture; scene.textures.push_back({}); } else if (name == "voltextures") { type = parsing_type::voltexture; scene.voltextures.push_back({}); } else if (name == "materials") { type = parsing_type::material; scene.materials.push_back({}); } else if (name == "shapes") { type = parsing_type::shape; scene.shapes.push_back({}); } else if (name == "subdivs") { type = parsing_type::subdiv; scene.subdivs.push_back({}); } else if (name == "instances") { type = parsing_type::instance; scene.instances.push_back({}); } else if (name == "environments") { type = parsing_type::environment; scene.environments.push_back({}); } else { type = parsing_type::none; throw std::runtime_error("unknown object type " + string(name)); } } void property(string_view key, string_view value) override { throw std::runtime_error("unknown property " + string(key)); } void property(string_view name, string_view key, string_view value) override { switch (type) { case parsing_type::camera: { auto& camera = scene.cameras.back(); if (key == "uri") { parse_yaml_value(value, camera.uri); } else if (key == "frame") { parse_yaml_value(value, camera.frame); } else if (key == "orthographic") { parse_yaml_value(value, camera.orthographic); } else if (key == "lens") { parse_yaml_value(value, camera.lens); } else if (key == "film") { parse_yaml_value(value, camera.film); } else if (key == "focus") { parse_yaml_value(value, camera.focus); } else if (key == "aperture") { parse_yaml_value(value, camera.aperture); } else if (key == "lookat") { auto lookat = identity3x3f; parse_yaml_value(value, lookat); camera.frame = lookat_frame(lookat.x, lookat.y, lookat.z); camera.focus = length(lookat.x - lookat.y); } else { throw std::runtime_error("unknown property " + string(key)); } } break; case parsing_type::texture: { auto& texture = scene.textures.back(); if (key == "uri") { parse_yaml_value(value, texture.uri); auto refname = texture.uri; if (is_preset_filename(refname)) { refname = get_preset_type(refname).second; } tmap[refname] = (int)scene.textures.size() - 1; } else if (key == "filename") { parse_yaml_value(value, texture.uri); } else { throw std::runtime_error("unknown property " + string(key)); } } break; case parsing_type::voltexture: { auto& texture = scene.voltextures.back(); if (key == "uri") { parse_yaml_value(value, texture.uri); auto refname = texture.uri; if (is_preset_filename(refname)) { refname = get_preset_type(refname).second; } vmap[refname] = (int)scene.voltextures.size() - 1; } else { throw std::runtime_error("unknown property " + string(key)); } } break; case parsing_type::material: { auto& material = scene.materials.back(); if (key == "uri") { parse_yaml_value(value, material.uri); mmap[material.uri] = (int)scene.materials.size() - 1; } else if (key == "emission") { parse_yaml_value(value, material.emission); } else if (key == "diffuse") { parse_yaml_value(value, material.diffuse); } else if (key == "metallic") { parse_yaml_value(value, material.metallic); } else if (key == "specular") { parse_yaml_value(value, material.specular); } else if (key == "roughness") { parse_yaml_value(value, material.roughness); } else if (key == "coat") { parse_yaml_value(value, material.coat); } else if (key == "transmission") { parse_yaml_value(value, material.transmission); } else if (key == "voltransmission") { parse_yaml_value(value, material.voltransmission); } else if (key == "volmeanfreepath") { parse_yaml_value(value, material.volmeanfreepath); } else if (key == "volscatter") { parse_yaml_value(value, material.volscatter); } else if (key == "volemission") { parse_yaml_value(value, material.volemission); } else if (key == "volanisotropy") { parse_yaml_value(value, material.volanisotropy); } else if (key == "volscale") { parse_yaml_value(value, material.volscale); } else if (key == "opacity") { parse_yaml_value(value, material.opacity); } else if (key == "coat") { parse_yaml_value(value, material.coat); } else if (key == "thin") { parse_yaml_value(value, material.thin); } else if (key == "emission_tex") { get_yaml_ref(value, material.emission_tex, tmap); } else if (key == "diffuse_tex") { get_yaml_ref(value, material.diffuse_tex, tmap); } else if (key == "metallic_tex") { get_yaml_ref(value, material.metallic_tex, tmap); } else if (key == "specular_tex") { get_yaml_ref(value, material.specular_tex, tmap); } else if (key == "transmission_tex") { get_yaml_ref(value, material.transmission_tex, tmap); } else if (key == "roughness_tex") { get_yaml_ref(value, material.roughness_tex, tmap); } else if (key == "subsurface_tex") { get_yaml_ref(value, material.subsurface_tex, tmap); } else if (key == "opacity_tex") { get_yaml_ref(value, material.normal_tex, tmap); } else if (key == "normal_tex") { get_yaml_ref(value, material.normal_tex, tmap); } else if (key == "voldensity_tex") { get_yaml_ref(value, material.voldensity_tex, vmap); } else if (key == "gltf_textures") { parse_yaml_value(value, material.gltf_textures); } else { throw std::runtime_error("unknown property " + string(key)); } } break; case parsing_type::shape: { auto& shape = scene.shapes.back(); if (key == "uri") { parse_yaml_value(value, shape.uri); auto refname = shape.uri; if (is_preset_filename(refname)) { refname = get_preset_type(refname).second; } smap[refname] = (int)scene.shapes.size() - 1; } else { throw std::runtime_error("unknown property " + string(key)); } } break; case parsing_type::subdiv: { auto& subdiv = scene.subdivs.back(); if (key == "uri") { parse_yaml_value(value, subdiv.uri); } else if (key == "shape") { get_yaml_ref(value, subdiv.shape, smap); } else if (key == "subdivisions") { parse_yaml_value(value, subdiv.subdivisions); } else if (key == "catmullclark") { parse_yaml_value(value, subdiv.catmullclark); } else if (key == "smooth") { parse_yaml_value(value, subdiv.smooth); } else if (key == "facevarying") { parse_yaml_value(value, subdiv.facevarying); } else if (key == "displacement_tex") { get_yaml_ref(value, subdiv.displacement_tex, tmap); } else if (key == "displacement") { parse_yaml_value(value, subdiv.displacement); } else { throw std::runtime_error("unknown property " + string(key)); } } break; case parsing_type::instance: { auto& instance = scene.instances.back(); if (key == "uri") { parse_yaml_value(value, instance.uri); } else if (key == "frame") { parse_yaml_value(value, instance.frame); } else if (key == "shape") { get_yaml_ref(value, instance.shape, smap); } else if (key == "material") { get_yaml_ref(value, instance.material, mmap); } else if (key == "lookat") { auto lookat = identity3x3f; parse_yaml_value(value, lookat); instance.frame = lookat_frame(lookat.x, lookat.y, lookat.z, true); } else { throw std::runtime_error("unknown property " + string(key)); } } break; case parsing_type::environment: { auto& environment = scene.environments.back(); if (key == "uri") { parse_yaml_value(value, environment.uri); } else if (key == "frame") { parse_yaml_value(value, environment.frame); } else if (key == "emission") { parse_yaml_value(value, environment.emission); } else if (key == "emission_tex") { get_yaml_ref(value, environment.emission_tex, tmap); } else if (key == "lookat") { auto lookat = identity3x3f; parse_yaml_value(value, lookat); environment.frame = lookat_frame(lookat.x, lookat.y, lookat.z, true); } else { throw std::runtime_error("unknown property " + string(key)); } } break; default: throw std::runtime_error("unknown object type"); } } }; // Save a scene in the builtin YAML format. static void load_yaml_scene( const string& filename, yocto_scene& scene, const load_params& params) { scene = {}; try { // Parse obj auto cb = load_yaml_scene_cb{scene, params}; load_yaml(filename, cb); // load shape and textures auto dirname = fs::path(filename).parent_path(); load_shapes(scene, dirname, params); load_textures(scene, dirname, params); } catch (const std::exception& e) { throw std::runtime_error("cannot load scene " + filename + "\n" + e.what()); } // fix scene scene.uri = fs::path(filename).filename(); add_cameras(scene); add_materials(scene); add_radius(scene); normalize_uris(scene); trim_memory(scene); update_transforms(scene); } #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" #endif // Write text to file static inline void write_yaml_value(FILE* fs, int value) { if (fprintf(fs, "%d", value) < 0) throw std::runtime_error("cannot print value"); } static inline void write_yaml_value(FILE* fs, float value) { if (fprintf(fs, "%g", value) < 0) throw std::runtime_error("cannot print value"); } static inline void write_yaml_value(FILE* fs, bool value) { if (fprintf(fs, "%s", value ? "true" : "false") < 0) throw std::runtime_error("cannot print value"); } static inline void write_yaml_value(FILE* fs, const char* value) { if (fprintf(fs, "%s", value) < 0) throw std::runtime_error("cannot print value"); } static inline void write_yaml_text(FILE* fs, const char* value) { if (fprintf(fs, "%s", value) < 0) throw std::runtime_error("cannot print value"); } static inline void write_yaml_text(FILE* fs, const string& value) { if (fprintf(fs, "%s", value.c_str()) < 0) throw std::runtime_error("cannot print value"); } static inline void write_yaml_value(FILE* fs, const string& value) { if (fprintf(fs, "%s", value.c_str()) < 0) throw std::runtime_error("cannot print value"); } static inline void write_yaml_value(FILE* fs, const vec2f& value) { if (fprintf(fs, "[%g,%g]", value.x, value.y) < 0) throw std::runtime_error("cannot print value"); } static inline void write_yaml_value(FILE* fs, const vec3f& value) { if (fprintf(fs, "[%g,%g,%g]", value.x, value.y, value.z) < 0) throw std::runtime_error("cannot print value"); } static inline void write_yaml_value(FILE* fs, const frame3f& value) { if (fprintf(fs, "[") < 0) throw std::runtime_error("cannot print value"); for (auto i = 0; i < 12; i++) if (fprintf(fs, i ? ",%g" : "%g", (&value.x.x)[i]) < 0) throw std::runtime_error("cannot print value"); if (fprintf(fs, "]") < 0) throw std::runtime_error("cannot print value"); } template static inline void write_yaml_line(FILE* fs, const T& arg, const Ts&... args) { write_yaml_value(fs, arg); if constexpr (sizeof...(Ts) != 0) { write_yaml_text(fs, " "); write_yaml_line(fs, args...); } else { write_yaml_value(fs, "\n"); } } #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif // Save yaml static void save_yaml(const string& filename, const yocto_scene& scene, bool ply_instances = false, const string& instances_name = "") { // open file auto fs_ = open_output_file(filename); auto fs = fs_.fs; write_yaml_text(fs, get_save_scene_message(scene)); static const auto def_camera = yocto_camera{}; static const auto def_texture = yocto_texture{}; static const auto def_voltexture = yocto_voltexture{}; static const auto def_material = yocto_material{}; static const auto def_shape = yocto_shape{}; static const auto def_subdiv = yocto_subdiv{}; static const auto def_instance = yocto_instance{}; static const auto def_environment = yocto_environment{}; auto write_yaml_opt = [](FILE* fs, const char* name, auto& value, auto& def) { if (value == def) return; write_yaml_text(fs, " "); write_yaml_text(fs, name); write_yaml_text(fs, ": "); write_yaml_line(fs, value); }; auto write_yaml_ref = [](FILE* fs, const char* name, int value, auto& refs) { if (value < 0) return; write_yaml_text(fs, " "); write_yaml_text(fs, name); write_yaml_text(fs, ": "); write_yaml_line(fs, refs[value].uri); }; if (!scene.cameras.empty()) write_yaml_text(fs, "\n\ncameras:\n"); for (auto& camera : scene.cameras) { write_yaml_line(fs, " - uri:", camera.uri); write_yaml_opt(fs, "frame", camera.frame, def_camera.frame); write_yaml_opt( fs, "orthographic", camera.orthographic, def_camera.orthographic); write_yaml_opt(fs, "lens", camera.lens, def_camera.lens); write_yaml_opt(fs, "film", camera.film, def_camera.film); write_yaml_opt(fs, "focus", camera.focus, def_camera.focus); write_yaml_opt(fs, "aperture", camera.aperture, def_camera.aperture); } if (!scene.textures.empty()) write_yaml_text(fs, "\n\ntextures:\n"); for (auto& texture : scene.textures) { write_yaml_line(fs, " - uri:", texture.uri); } if (!scene.voltextures.empty()) write_yaml_text(fs, "\n\nvoltextures:\n"); for (auto& texture : scene.voltextures) { write_yaml_line(fs, " - uri:", texture.uri); } if (!scene.materials.empty()) write_yaml_text(fs, "\n\nmaterials:\n"); for (auto& material : scene.materials) { write_yaml_line(fs, " - uri:", material.uri); write_yaml_opt(fs, "emission", material.emission, def_material.emission); write_yaml_opt(fs, "diffuse", material.diffuse, def_material.diffuse); write_yaml_opt(fs, "specular", material.specular, def_material.specular); write_yaml_opt(fs, "metallic", material.metallic, def_material.metallic); write_yaml_opt( fs, "transmission", material.transmission, def_material.transmission); write_yaml_opt(fs, "roughness", material.roughness, def_material.roughness); write_yaml_opt(fs, "voltransmission", material.voltransmission, def_material.voltransmission); write_yaml_opt(fs, "volmeanfreepath", material.volmeanfreepath, def_material.volmeanfreepath); write_yaml_opt( fs, "volscatter", material.volscatter, def_material.volscatter); write_yaml_opt( fs, "volemission", material.volemission, def_material.volemission); write_yaml_opt(fs, "volanisotropy", material.volanisotropy, def_material.volanisotropy); write_yaml_opt(fs, "volscale", material.volscale, def_material.volscale); write_yaml_opt(fs, "coat", material.coat, def_material.coat); write_yaml_opt(fs, "opacity", material.opacity, def_material.opacity); write_yaml_opt(fs, "thin", material.thin, def_material.thin); write_yaml_ref(fs, "emission_tex", material.emission_tex, scene.textures); write_yaml_ref(fs, "diffuse_tex", material.diffuse_tex, scene.textures); write_yaml_ref(fs, "metallic_tex", material.metallic_tex, scene.textures); write_yaml_ref(fs, "specular_tex", material.specular_tex, scene.textures); write_yaml_ref(fs, "roughness_tex", material.roughness_tex, scene.textures); write_yaml_ref( fs, "transmission_tex", material.transmission_tex, scene.textures); write_yaml_ref( fs, "subsurface_tex", material.subsurface_tex, scene.textures); write_yaml_ref(fs, "coat_tex", material.coat_tex, scene.textures); write_yaml_ref(fs, "opacity_tex", material.opacity_tex, scene.textures); write_yaml_ref(fs, "normal_tex", material.normal_tex, scene.textures); write_yaml_opt(fs, "gltf_textures", material.gltf_textures, def_material.gltf_textures); write_yaml_ref( fs, "voldensity_tex", material.voldensity_tex, scene.voltextures); } if (!scene.shapes.empty()) write_yaml_text(fs, "\n\nshapes:\n"); for (auto& shape : scene.shapes) { write_yaml_line(fs, " - uri:", shape.uri); } if (!scene.subdivs.empty()) write_yaml_text(fs, "\n\nsubdivs:\n"); for (auto& subdiv : scene.subdivs) { write_yaml_line(fs, " - uri:", subdiv.uri); write_yaml_ref(fs, "shape", subdiv.shape, scene.shapes); write_yaml_opt( fs, "subdivisions", subdiv.subdivisions, def_subdiv.subdivisions); write_yaml_opt( fs, "catmullclark", subdiv.catmullclark, def_subdiv.catmullclark); write_yaml_opt(fs, "smooth", subdiv.smooth, def_subdiv.smooth); write_yaml_opt( fs, "facevarying", subdiv.facevarying, def_subdiv.facevarying); write_yaml_ref( fs, "displacement_tex", subdiv.displacement_tex, scene.textures); write_yaml_opt( fs, "displacement", subdiv.displacement, def_subdiv.displacement); } if (!ply_instances) { if (!scene.instances.empty()) write_yaml_text(fs, "\n\ninstances:\n"); for (auto& instance : scene.instances) { write_yaml_line(fs, " - uri:", instance.uri); write_yaml_opt(fs, "frame", instance.frame, def_instance.frame); write_yaml_ref(fs, "shape", instance.shape, scene.shapes); write_yaml_ref(fs, "material", instance.material, scene.materials); } } else { if (!scene.instances.empty()) write_yaml_text(fs, "\n\nply_instances:\n"); write_yaml_line(fs, " - uri:", instances_name); } if (!scene.environments.empty()) write_yaml_text(fs, "\n\nenvironments:\n"); for (auto& environment : scene.environments) { write_yaml_line(fs, " - uri:", environment.uri); write_yaml_opt(fs, "frame", environment.frame, def_environment.frame); write_yaml_opt( fs, "emission", environment.emission, def_environment.emission); write_yaml_ref( fs, "emission_tex", environment.emission_tex, scene.textures); } } // Save a scene in the builtin YAML format. static void save_yaml_scene(const string& filename, const yocto_scene& scene, const save_params& params) { try { // save yaml file save_yaml(filename, scene); // save meshes and textures auto dirname = fs::path(filename).parent_path(); save_shapes(scene, dirname, params); save_textures(scene, dirname, params); } catch (const std::exception& e) { throw std::runtime_error("cannot save scene " + filename + "\n" + e.what()); } } } // namespace yocto // ----------------------------------------------------------------------------- // OBJ CONVERSION // ----------------------------------------------------------------------------- namespace yocto { struct load_obj_scene_cb : obj_callbacks { yocto_scene& scene; const load_params& params; // current parsing values string mname = ""s; string oname = ""s; string gname = ""s; // vertices std::deque opos = {}; std::deque onorm = {}; std::deque otexcoord = {}; // object maps unordered_map tmap = unordered_map{{"", -1}}; unordered_map vmap = unordered_map{{"", -1}}; unordered_map mmap = unordered_map{{"", -1}}; // vertex maps unordered_map vertex_map = unordered_map(); unordered_map pos_map = unordered_map(); unordered_map norm_map = unordered_map(); unordered_map texcoord_map = unordered_map(); // parsed geometry and materials unordered_map> object_shapes = {}; bool first_instance = true; // current parse state bool facevarying_now = false; load_obj_scene_cb(yocto_scene& scene, const load_params& params) : scene{scene}, params{params} {} // add object if needed void add_shape() { auto shape = yocto_shape{}; shape.uri = oname + gname; facevarying_now = params.facevarying || shape.uri.find("[yocto::facevarying]") != string::npos; scene.shapes.push_back(shape); auto instance = yocto_instance{}; instance.uri = shape.uri; instance.shape = (int)scene.shapes.size() - 1; instance.material = mmap.at(mname); scene.instances.push_back(instance); object_shapes[oname].push_back((int)scene.shapes.size() - 1); vertex_map.clear(); pos_map.clear(); norm_map.clear(); texcoord_map.clear(); } // Parse texture params and name int add_texture(const obj_texture_info& info, bool force_linear) { if (info.path == "") return -1; if (tmap.find(info.path) != tmap.end()) { return tmap.at(info.path); } // create texture auto texture = yocto_texture{}; texture.uri = info.path; for (auto& c : texture.uri) if (c == '\\') c = '/'; scene.textures.push_back(texture); auto index = (int)scene.textures.size() - 1; tmap[info.path] = index; return index; } // Parse texture params and name int add_voltexture(const obj_texture_info& info, bool srgb) { if (info.path == "") return -1; if (vmap.find(info.path) != vmap.end()) { return vmap.at(info.path); } // create texture auto texture = yocto_voltexture{}; texture.uri = info.path; scene.voltextures.push_back(texture); auto index = (int)scene.voltextures.size() - 1; vmap[info.path] = index; return index; } // Add vertices to the current shape void add_verts(const vector& verts, yocto_shape& shape) { for (auto& vert : verts) { auto it = vertex_map.find(vert); if (it != vertex_map.end()) continue; auto& shape = scene.shapes.back(); auto nverts = (int)shape.positions.size(); vertex_map.insert(it, {vert, nverts}); if (vert.position) shape.positions.push_back(opos.at(vert.position - 1)); if (vert.texcoord) shape.texcoords.push_back(otexcoord.at(vert.texcoord - 1)); if (vert.normal) shape.normals.push_back(onorm.at(vert.normal - 1)); if (shape.normals.size() != 0 && shape.normals.size() != shape.positions.size()) { while (shape.normals.size() != shape.positions.size()) shape.normals.push_back({0, 0, 1}); } if (shape.texcoords.size() != 0 && shape.texcoords.size() != shape.positions.size()) { while (shape.texcoords.size() != shape.positions.size()) shape.texcoords.push_back({0, 0}); } } } // add vertex void add_fvverts(const vector& verts, yocto_shape& shape) { for (auto& vert : verts) { if (!vert.position) continue; auto pos_it = pos_map.find(vert.position); if (pos_it != pos_map.end()) continue; auto nverts = (int)shape.positions.size(); pos_map.insert(pos_it, {vert.position, nverts}); shape.positions.push_back(opos.at(vert.position - 1)); } for (auto& vert : verts) { if (!vert.texcoord) continue; auto texcoord_it = texcoord_map.find(vert.texcoord); if (texcoord_it != texcoord_map.end()) continue; auto nverts = (int)shape.texcoords.size(); texcoord_map.insert(texcoord_it, {vert.texcoord, nverts}); shape.texcoords.push_back(otexcoord.at(vert.texcoord - 1)); } for (auto& vert : verts) { if (!vert.normal) continue; auto norm_it = norm_map.find(vert.normal); if (norm_it != norm_map.end()) continue; auto nverts = (int)shape.normals.size(); norm_map.insert(norm_it, {vert.normal, nverts}); shape.normals.push_back(onorm.at(vert.normal - 1)); } } // callbacks void vert(const vec3f& v) override { opos.push_back(v); } void norm(const vec3f& v) override { onorm.push_back(v); } void texcoord(const vec2f& v) override { otexcoord.push_back(v); } void face(const vector& verts) override { if (scene.shapes.empty()) add_shape(); if (!scene.shapes.back().positions.empty() && (!scene.shapes.back().lines.empty() || !scene.shapes.back().points.empty())) { add_shape(); } auto& shape = scene.shapes.back(); if (!facevarying_now) { add_verts(verts, shape); if (verts.size() == 4) { shape.quads.push_back({vertex_map.at(verts[0]), vertex_map.at(verts[1]), vertex_map.at(verts[2]), vertex_map.at(verts[3])}); } else { for (auto i = 2; i < verts.size(); i++) shape.triangles.push_back({vertex_map.at(verts[0]), vertex_map.at(verts[i - 1]), vertex_map.at(verts[i])}); } } else { add_fvverts(verts, shape); if (verts.size() == 4) { if (verts[0].position) { shape.quadspos.push_back({pos_map.at(verts[0].position), pos_map.at(verts[1].position), pos_map.at(verts[2].position), pos_map.at(verts[3].position)}); } if (verts[0].texcoord) { shape.quadstexcoord.push_back({texcoord_map.at(verts[0].texcoord), texcoord_map.at(verts[1].texcoord), texcoord_map.at(verts[2].texcoord), texcoord_map.at(verts[3].texcoord)}); } if (verts[0].normal) { shape.quadsnorm.push_back( {norm_map.at(verts[0].normal), norm_map.at(verts[1].normal), norm_map.at(verts[2].normal), norm_map.at(verts[3].normal)}); } } else { if (verts[0].position) { for (auto i = 2; i < verts.size(); i++) shape.quadspos.push_back({pos_map.at(verts[0].position), pos_map.at(verts[i - 1].position), pos_map.at(verts[i].position), pos_map.at(verts[i].position)}); } if (verts[0].texcoord) { for (auto i = 2; i < verts.size(); i++) shape.quadstexcoord.push_back({texcoord_map.at(verts[0].texcoord), texcoord_map.at(verts[i - 1].texcoord), texcoord_map.at(verts[i].texcoord), texcoord_map.at(verts[i].texcoord)}); } if (verts[0].normal) { for (auto i = 2; i < verts.size(); i++) shape.quadsnorm.push_back({norm_map.at(verts[0].normal), norm_map.at(verts[i - 1].normal), norm_map.at(verts[i].normal), norm_map.at(verts[i].normal)}); } } } } void line(const vector& verts) override { if (scene.shapes.empty()) add_shape(); if (!scene.shapes.back().positions.empty() && scene.shapes.back().lines.empty()) { add_shape(); } auto& shape = scene.shapes.back(); add_verts(verts, shape); for (auto i = 1; i < verts.size(); i++) shape.lines.push_back( {vertex_map.at(verts[i - 1]), vertex_map.at(verts[i])}); } void point(const vector& verts) override { if (scene.shapes.empty()) add_shape(); if (!scene.shapes.back().positions.empty() && scene.shapes.back().points.empty()) { add_shape(); } auto& shape = scene.shapes.back(); add_verts(verts, shape); for (auto i = 0; i < verts.size(); i++) shape.points.push_back(vertex_map.at(verts[i])); } void object(const string& name) override { oname = name; gname = ""; mname = ""; add_shape(); } void group(const string& name) override { gname = name; add_shape(); } void usemtl(const string& name) override { mname = name; add_shape(); } void material(const obj_material& omat) override { auto material = yocto_material{}; material.uri = omat.name; material.emission = omat.ke; material.diffuse = omat.kd; material.specular = omat.ks; material.metallic = omat.pm; material.transmission = omat.kt; material.roughness = omat.pr; material.opacity = omat.op; material.emission_tex = add_texture(omat.ke_map, false); material.diffuse_tex = add_texture(omat.kd_map, false); material.metallic_tex = add_texture(omat.pm_map, false); material.specular_tex = add_texture(omat.ks_map, false); material.transmission_tex = add_texture(omat.kt_map, false); material.roughness_tex = add_texture(omat.pr_map, true); material.opacity_tex = add_texture(omat.op_map, true); material.normal_tex = add_texture(omat.norm_map, true); material.voltransmission = omat.vt; material.volmeanfreepath = omat.vp; material.volemission = omat.ve; material.volscatter = omat.vs; material.volanisotropy = omat.vg; material.volscale = omat.vr; material.subsurface_tex = add_texture(omat.vs_map, false); if (material.transmission != zero3f) material.thin = true; scene.materials.push_back(material); mmap[material.uri] = (int)scene.materials.size() - 1; } void camera(const obj_camera& ocam) override { auto camera = yocto_camera(); camera.uri = ocam.name; camera.frame = ocam.frame; camera.orthographic = ocam.ortho; camera.lens = ocam.lens; camera.film = {ocam.width, ocam.height}; camera.focus = ocam.focus; camera.aperture = ocam.aperture; scene.cameras.push_back(camera); } void environmnet(const obj_environment& oenv) override { auto environment = yocto_environment(); environment.uri = oenv.name; environment.frame = oenv.frame; environment.emission = oenv.ke; environment.emission_tex = add_texture(oenv.ke_txt, true); scene.environments.push_back(environment); } void instance(const obj_instance& oist) override { if (first_instance) { scene.instances.clear(); first_instance = false; } for (auto& shape : object_shapes[oist.object]) { auto instance = yocto_instance{}; instance.uri = oist.name; instance.frame = oist.frame; instance.shape = shape; instance.material = mmap.at(oist.material); scene.instances.push_back(instance); } } void procedural(const obj_procedural& oproc) override { auto shape = yocto_shape(); shape.uri = oproc.name; if (oproc.type == "floor") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::floor; params.subdivisions = oproc.level < 0 ? 0 : oproc.level; params.scale = oproc.size / 2; params.uvscale = oproc.size; make_proc_shape(shape.triangles, shape.quads, shape.positions, shape.normals, shape.texcoords, params); } else { throw std::runtime_error("unknown obj procedural"); } scene.shapes.push_back(shape); auto instance = yocto_instance{}; instance.uri = shape.uri; instance.shape = (int)scene.shapes.size() - 1; if (mmap.find(oproc.material) == mmap.end()) { throw std::runtime_error("missing material " + oproc.material); } else { instance.material = mmap.find(oproc.material)->second; } scene.instances.push_back(instance); } }; // Loads an OBJ static void load_obj_scene( const string& filename, yocto_scene& scene, const load_params& params) { scene = {}; try { // Parse obj auto cb = load_obj_scene_cb{scene, params}; load_obj(filename, cb, {}); // cleanup empty for (auto shape = 0; shape < scene.shapes.size(); shape++) { if (!scene.shapes[shape].positions.empty()) continue; for (auto instance = 0; instance < scene.instances.size(); instance++) { if (scene.instances[instance].shape < shape) { continue; } else if (scene.instances[instance].shape > shape) { scene.instances[instance].shape -= 1; } else { scene.instances.erase(scene.instances.begin() + instance); instance--; } } scene.shapes.erase(scene.shapes.begin() + shape); shape--; } // check if any empty shape is left for (auto& shape : scene.shapes) { if (shape.positions.empty()) throw std::runtime_error("empty shapes not supported"); } // merging quads and triangles for (auto& shape : scene.shapes) { if (shape.triangles.empty() || shape.quads.empty()) continue; merge_triangles_and_quads(shape.triangles, shape.quads, false); } // load textures auto dirname = fs::path(filename).parent_path(); load_textures(scene, dirname, params); } catch (const std::exception& e) { throw std::runtime_error("cannot load scene " + filename + "\n" + e.what()); } // fix scene scene.uri = fs::path(filename).filename(); add_cameras(scene); add_materials(scene); add_radius(scene); normalize_uris(scene); trim_memory(scene); update_transforms(scene); } // Write text to file static inline void write_obj_value(FILE* fs, int value) { if (fprintf(fs, "%d", value) < 0) throw std::runtime_error("cannot print value"); } static inline void write_obj_value(FILE* fs, float value) { if (fprintf(fs, "%g", value) < 0) throw std::runtime_error("cannot print value"); } static inline void write_obj_text(FILE* fs, const char* value) { if (fprintf(fs, "%s", value) < 0) throw std::runtime_error("cannot print value"); } static inline void write_obj_text(FILE* fs, const string& value) { if (fprintf(fs, "%s", value.c_str()) < 0) throw std::runtime_error("cannot print value"); } static inline void write_obj_value(FILE* fs, const char* value) { if (fprintf(fs, "%s", value) < 0) throw std::runtime_error("cannot print value"); } static inline void write_obj_value(FILE* fs, const string& value) { if (fprintf(fs, "%s", value.c_str()) < 0) throw std::runtime_error("cannot print value"); } static inline void write_obj_value(FILE* fs, const vec2f& value) { if (fprintf(fs, "%g %g", value.x, value.y) < 0) throw std::runtime_error("cannot print value"); } static inline void write_obj_value(FILE* fs, const vec3f& value) { if (fprintf(fs, "%g %g %g", value.x, value.y, value.z) < 0) throw std::runtime_error("cannot print value"); } static inline void write_obj_value(FILE* fs, const frame3f& value) { for (auto i = 0; i < 12; i++) if (fprintf(fs, i ? " %g" : "%g", (&value.x.x)[i]) < 0) throw std::runtime_error("cannot print value"); } static void write_obj_value(FILE* fs, const obj_vertex& value) { if (fprintf(fs, "%d", value.position) < 0) throw std::runtime_error("cannot write value"); if (value.texcoord) { if (fprintf(fs, "/%d", value.texcoord) < 0) throw std::runtime_error("cannot write value"); if (value.normal) { if (fprintf(fs, "/%d", value.normal) < 0) throw std::runtime_error("cannot write value"); } } else if (value.normal) { if (fprintf(fs, "//%d", value.normal) < 0) throw std::runtime_error("cannot write value"); } } template static inline void write_obj_line( FILE* fs, const T& value, const Ts... values) { write_obj_value(fs, value); if constexpr (sizeof...(values) == 0) { write_obj_text(fs, "\n"); } else { write_obj_text(fs, " "); write_obj_line(fs, values...); } } static void save_mtl( const string& filename, const yocto_scene& scene, bool flip_tr = true) { // open file auto fs_ = open_output_file(filename); auto fs = fs_.fs; // embed data write_obj_text(fs, get_save_scene_message(scene)); // for each material, dump all the values for (auto& material : scene.materials) { write_obj_line(fs, "newmtl", fs::path(material.uri).stem().string()); write_obj_line(fs, " illum", 2); write_obj_line(fs, " Ke", material.emission); write_obj_line(fs, " Kd", material.diffuse * (1 - material.metallic)); write_obj_line(fs, " Ks", material.specular * (1 - material.metallic) + material.metallic * material.diffuse); write_obj_line(fs, " Kt", material.transmission); write_obj_line(fs, " Ns", (int)clamp( 2 / pow(clamp(material.roughness, 0.0f, 0.99f) + 1e-10f, 4.0f) - 2, 0.0f, 1.0e9f)); write_obj_line(fs, " d", material.opacity); if (material.emission_tex >= 0) write_obj_line(fs, " map_Ke", scene.textures[material.emission_tex].uri); if (material.diffuse_tex >= 0) write_obj_line(fs, " map_Kd", scene.textures[material.diffuse_tex].uri); if (material.specular_tex >= 0) write_obj_line(fs, " map_Ks", scene.textures[material.specular_tex].uri); if (material.transmission_tex >= 0) write_obj_line( fs, " map_Kt", scene.textures[material.transmission_tex].uri); if (material.normal_tex >= 0) write_obj_line(fs, " map_norm", scene.textures[material.normal_tex].uri); if (material.voltransmission != zero3f) { write_obj_line(fs, " Vt", material.voltransmission); write_obj_line(fs, " Ve", material.volemission); write_obj_line(fs, " Vs", material.volscatter); write_obj_line(fs, " Vg", material.volanisotropy); write_obj_line(fs, " Vr", material.volscale); } write_obj_text(fs, "\n"); } } static void save_objx( const string& filename, const yocto_scene& scene, bool preserve_instances) { // open file auto fs_ = open_output_file(filename); auto fs = fs_.fs; // embed data write_obj_text(fs, get_save_scene_message(scene)); // cameras for (auto& camera : scene.cameras) { write_obj_line(fs, "c", fs::path(camera.uri).stem().string(), (int)camera.orthographic, camera.film.x, camera.film.y, camera.lens, camera.focus, camera.aperture, camera.frame); } // environments for (auto& environment : scene.environments) { write_obj_line(fs, "e", fs::path(environment.uri).stem().string(), environment.emission, environment.emission_tex >= 0 ? scene.textures[environment.emission_tex].uri : "\"\" "s, environment.frame); } // instances if (preserve_instances) { for (auto& instance : scene.instances) { write_obj_line(fs, "i", fs::path(instance.uri).stem().string(), fs::path(scene.shapes[instance.shape].uri).stem().string(), fs::path(scene.materials[instance.material].uri).stem().string(), instance.frame); } } } static void save_obj(const string& filename, const yocto_scene& scene, bool preserve_instances, bool flip_texcoord = true) { // open file auto fs_ = open_output_file(filename); auto fs = fs_.fs; // embed data write_obj_text(fs, get_save_scene_message(scene)); // material library if (!scene.materials.empty()) { auto mtlname = fs::path(filename).filename().replace_extension(".mtl"); write_obj_line(fs, "mtllib", mtlname); } // shapes auto offset = obj_vertex{0, 0, 0}; auto instances = vector{}; if (preserve_instances) { instances.reserve(scene.shapes.size()); for (auto shape = 0; shape < scene.shapes.size(); shape++) { instances.push_back({scene.shapes[shape].uri, identity3x4f, shape, -1}); } } for (auto& instance : preserve_instances ? instances : scene.instances) { auto& shape = scene.shapes[instance.shape]; write_obj_line(fs, "o", fs::path(instance.uri).stem().string()); if (instance.material >= 0) write_obj_line(fs, "usemtl", fs::path(scene.materials[instance.material].uri).stem().string()); if (instance.frame == identity3x4f) { for (auto& p : shape.positions) write_obj_line(fs, "v", p); for (auto& n : shape.normals) write_obj_line(fs, "vn", n); for (auto& t : shape.texcoords) write_obj_line(fs, "vt", vec2f{t.x, (flip_texcoord) ? 1 - t.y : t.y}); } else { for (auto& pp : shape.positions) { write_obj_line(fs, "v", transform_point(instance.frame, pp)); } for (auto& nn : shape.normals) { write_obj_line(fs, "vn", transform_direction(instance.frame, nn)); } for (auto& t : shape.texcoords) write_obj_line(fs, "vt", vec2f{t.x, (flip_texcoord) ? 1 - t.y : t.y}); } auto mask = obj_vertex{ 1, shape.texcoords.empty() ? 0 : 1, shape.normals.empty() ? 0 : 1}; auto vert = [mask, offset](int i) { return obj_vertex{(i + offset.position + 1) * mask.position, (i + offset.texcoord + 1) * mask.texcoord, (i + offset.normal + 1) * mask.normal}; }; for (auto& p : shape.points) { write_obj_line(fs, "p", vert(p)); } for (auto& l : shape.lines) { write_obj_line(fs, "l", vert(l.x), vert(l.y)); } for (auto& t : shape.triangles) { write_obj_line(fs, "f", vert(t.x), vert(t.y), vert(t.z)); } for (auto& q : shape.quads) { if (q.z == q.w) { write_obj_line(fs, "f", vert(q.x), vert(q.y), vert(q.z)); } else { write_obj_line(fs, "f", vert(q.x), vert(q.y), vert(q.z), vert(q.w)); } } for (auto i = 0; i < shape.quadspos.size(); i++) { if (!shape.texcoords.empty() && shape.normals.empty()) { auto vert = [offset](int ip, int it) { return obj_vertex{ ip + offset.position + 1, it + offset.texcoord + 1, 0}; }; auto qp = shape.quadspos[i]; auto qt = shape.quadstexcoord[i]; if (qp.z == qp.w) { write_obj_line( fs, "f", vert(qp.x, qt.x), vert(qp.y, qt.y), vert(qp.z, qt.z)); } else { write_obj_line(fs, "f", vert(qp.x, qt.x), vert(qp.y, qt.y), vert(qp.z, qt.z), vert(qp.w, qt.w)); } } else if (!shape.texcoords.empty() && !shape.normals.empty()) { auto vert = [offset](int ip, int it, int in) { return obj_vertex{ip + offset.position + 1, it + offset.texcoord + 1, in + offset.normal + 1}; }; auto qp = shape.quadspos[i]; auto qt = shape.quadstexcoord[i]; auto qn = shape.quadsnorm[i]; if (qp.z == qp.w) { write_obj_line(fs, "f", vert(qp.x, qt.x, qn.x), vert(qp.y, qt.y, qn.y), vert(qp.z, qt.z, qn.z)); } else { write_obj_line(fs, "f", vert(qp.x, qt.x, qn.x), vert(qp.y, qt.y, qn.y), vert(qp.z, qt.z, qn.z), vert(qp.w, qt.w, qn.w)); } } else if (!shape.normals.empty()) { auto vert = [offset](int ip, int in) { return obj_vertex{ ip + offset.position + 1, 0, in + offset.normal + 1}; }; auto qp = shape.quadspos[i]; auto qn = shape.quadsnorm[i]; if (qp.z == qp.w) { write_obj_line( fs, "f", vert(qp.x, qn.x), vert(qp.y, qn.y), vert(qp.z, qn.z)); } else { write_obj_line(fs, "f", vert(qp.x, qn.x), vert(qp.y, qn.y), vert(qp.z, qn.z), vert(qp.w, qn.w)); } } else { auto vert = [offset](int ip) { return obj_vertex{ip + offset.position + 1, 0, 0}; }; auto q = shape.quadspos[i]; if (q.z == q.w) { write_obj_line(fs, "f", vert(q.x), vert(q.y), vert(q.z)); } else { write_obj_line(fs, "f", vert(q.x), vert(q.y), vert(q.z), vert(q.w)); } } } offset.position += shape.positions.size(); offset.texcoord += shape.texcoords.size(); offset.normal += shape.normals.size(); } } static void save_obj_scene(const string& filename, const yocto_scene& scene, const save_params& params) { try { save_obj(filename, scene, params.objinstances, true); if (!scene.materials.empty()) { save_mtl(fs::path(filename).replace_extension(".mtl"), scene, true); } if (!scene.cameras.empty() || !scene.environments.empty() || params.objinstances) { save_objx(fs::path(filename).replace_extension(".objx"), scene, params.objinstances); } // skip textures if needed auto dirname = fs::path(filename).parent_path(); save_textures(scene, dirname, params); } catch (const std::exception& e) { throw std::runtime_error("cannot save scene " + filename + "\n" + e.what()); } } void print_obj_camera(const yocto_camera& camera) { write_obj_line(stdout, "c", fs::path(camera.uri).stem().string(), (int)camera.orthographic, camera.film.x, camera.film.y, camera.lens, camera.focus, camera.aperture, camera.frame); } } // namespace yocto // ----------------------------------------------------------------------------- // PLY CONVERSION // ----------------------------------------------------------------------------- namespace yocto { static void load_ply_scene( const string& filename, yocto_scene& scene, const load_params& params) { scene = {}; try { // load ply mesh scene.shapes.push_back({}); auto& shape = scene.shapes.back(); load_shape(filename, shape.points, shape.lines, shape.triangles, shape.quads, shape.quadspos, shape.quadsnorm, shape.quadstexcoord, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius, false); // add instance auto instance = yocto_instance{}; instance.uri = shape.uri; instance.shape = 0; scene.instances.push_back(instance); } catch (const std::exception& e) { throw std::runtime_error("cannot load scene " + filename + "\n" + e.what()); } // fix scene scene.uri = fs::path(filename).filename(); add_cameras(scene); add_materials(scene); add_radius(scene); normalize_uris(scene); trim_memory(scene); update_transforms(scene); } static void save_ply_scene(const string& filename, const yocto_scene& scene, const save_params& params) { if (scene.shapes.empty()) { throw std::runtime_error("cannot save empty scene " + filename); } try { auto& shape = scene.shapes.front(); save_shape(filename, shape.points, shape.lines, shape.triangles, shape.quads, shape.quadspos, shape.quadsnorm, shape.quadstexcoord, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius); } catch (const std::exception& e) { throw std::runtime_error("cannot save scene " + filename + "\n" + e.what()); } } } // namespace yocto // ----------------------------------------------------------------------------- // GLTF CONVESION // ----------------------------------------------------------------------------- namespace yocto { // convert gltf to scene static void gltf_to_scene(const string& filename, yocto_scene& scene) { // load gltf auto params = cgltf_options{}; memset(¶ms, 0, sizeof(params)); auto data = (cgltf_data*)nullptr; auto result = cgltf_parse_file(¶ms, filename.c_str(), &data); if (result != cgltf_result_success) { throw std::runtime_error("could not load gltf " + filename); } auto gltf = std::unique_ptr{ data, cgltf_free}; auto dirname = fs::path(filename).parent_path().string(); if (dirname != "") dirname += "/"; if (cgltf_load_buffers(¶ms, data, dirname.c_str()) != cgltf_result_success) { throw std::runtime_error("could not load gltf buffers " + filename); } // convert textures auto _startswith = [](string_view str, string_view substr) { if (str.size() < substr.size()) return false; return str.substr(0, substr.size()) == substr; }; auto imap = unordered_map{}; for (auto tid = 0; tid < gltf->images_count; tid++) { auto gimg = &gltf->images[tid]; auto texture = yocto_texture{}; texture.uri = (_startswith(gimg->uri, "data:")) ? string("[glTF-static inline].png") : gimg->uri; scene.textures.push_back(texture); imap[gimg] = tid; } // add a texture auto add_texture = [&imap]( const cgltf_texture_view& ginfo, bool force_linear) { if (!ginfo.texture || !ginfo.texture->image) return -1; auto gtxt = ginfo.texture; return imap.at(gtxt->image); }; // convert materials auto mmap = unordered_map{{nullptr, -1}}; for (auto mid = 0; mid < gltf->materials_count; mid++) { auto gmat = &gltf->materials[mid]; auto material = yocto_material(); material.uri = gmat->name ? gmat->name : ""; material.emission = {gmat->emissive_factor[0], gmat->emissive_factor[1], gmat->emissive_factor[2]}; material.emission_tex = add_texture(gmat->emissive_texture, false); if (gmat->has_pbr_specular_glossiness) { material.gltf_textures = true; auto gsg = &gmat->pbr_specular_glossiness; auto kb = vec4f{gsg->diffuse_factor[0], gsg->diffuse_factor[1], gsg->diffuse_factor[2], gsg->diffuse_factor[3]}; material.diffuse = {kb.x, kb.y, kb.z}; material.opacity = kb.w; material.specular = {gsg->specular_factor[0], gsg->specular_factor[1], gsg->specular_factor[2]}; material.roughness = 1 - gsg->glossiness_factor; material.diffuse_tex = add_texture(gsg->diffuse_texture, false); material.specular_tex = add_texture( gsg->specular_glossiness_texture, false); material.roughness_tex = material.specular_tex; } else if (gmat->has_pbr_metallic_roughness) { material.gltf_textures = true; auto gmr = &gmat->pbr_metallic_roughness; auto kb = vec4f{gmr->base_color_factor[0], gmr->base_color_factor[1], gmr->base_color_factor[2], gmr->base_color_factor[3]}; material.diffuse = {kb.x, kb.y, kb.z}; material.opacity = kb.w; material.specular = {0.04, 0.04, 0.04}; material.metallic = gmr->metallic_factor; material.roughness = gmr->roughness_factor; material.diffuse_tex = add_texture(gmr->base_color_texture, false); material.metallic_tex = add_texture( gmr->metallic_roughness_texture, true); material.roughness_tex = material.specular_tex; } material.normal_tex = add_texture(gmat->normal_texture, true); scene.materials.push_back(material); mmap[gmat] = (int)scene.materials.size() - 1; } // get values from accessors auto accessor_values = [](const cgltf_accessor* gacc, bool normalize = false) -> vector> { auto gview = gacc->buffer_view; auto data = (byte*)gview->buffer->data; auto offset = gacc->offset + gview->offset; auto stride = gview->stride; auto compTypeNum = gacc->component_type; auto count = gacc->count; auto type = gacc->type; auto ncomp = 0; if (type == cgltf_type_scalar) ncomp = 1; if (type == cgltf_type_vec2) ncomp = 2; if (type == cgltf_type_vec3) ncomp = 3; if (type == cgltf_type_vec4) ncomp = 4; auto compSize = 1; if (compTypeNum == cgltf_component_type_r_16 || compTypeNum == cgltf_component_type_r_16u) { compSize = 2; } if (compTypeNum == cgltf_component_type_r_32u || compTypeNum == cgltf_component_type_r_32f) { compSize = 4; } if (!stride) stride = compSize * ncomp; auto vals = vector>(count, {{0.0, 0.0, 0.0, 1.0}}); for (auto i = 0; i < count; i++) { auto d = data + offset + i * stride; for (auto c = 0; c < ncomp; c++) { if (compTypeNum == cgltf_component_type_r_8) { // char vals[i][c] = (double)(*(char*)d); if (normalize) vals[i][c] /= SCHAR_MAX; } else if (compTypeNum == cgltf_component_type_r_8u) { // byte vals[i][c] = (double)(*(byte*)d); if (normalize) vals[i][c] /= UCHAR_MAX; } else if (compTypeNum == cgltf_component_type_r_16) { // short vals[i][c] = (double)(*(short*)d); if (normalize) vals[i][c] /= SHRT_MAX; } else if (compTypeNum == cgltf_component_type_r_16u) { // unsigned short vals[i][c] = (double)(*(unsigned short*)d); if (normalize) vals[i][c] /= USHRT_MAX; } else if (compTypeNum == cgltf_component_type_r_32u) { // unsigned int vals[i][c] = (double)(*(unsigned int*)d); if (normalize) vals[i][c] /= UINT_MAX; } else if (compTypeNum == cgltf_component_type_r_32f) { // float vals[i][c] = (*(float*)d); } d += compSize; } } return vals; }; // convert meshes auto meshes = unordered_map>{{nullptr, {}}}; for (auto mid = 0; mid < gltf->meshes_count; mid++) { auto gmesh = &gltf->meshes[mid]; meshes[gmesh] = {}; for (auto sid = 0; sid < gmesh->primitives_count; sid++) { auto gprim = &gmesh->primitives[sid]; if (!gprim->attributes_count) continue; auto shape = yocto_shape(); shape.uri = (gmesh->name ? gmesh->name : "") + ((sid) ? std::to_string(sid) : string()); for (auto aid = 0; aid < gprim->attributes_count; aid++) { auto gattr = &gprim->attributes[aid]; auto semantic = string(gattr->name ? gattr->name : ""); auto gacc = gattr->data; auto vals = accessor_values(gacc); if (semantic == "POSITION") { shape.positions.reserve(vals.size()); for (auto i = 0; i < vals.size(); i++) shape.positions.push_back( {(float)vals[i][0], (float)vals[i][1], (float)vals[i][2]}); } else if (semantic == "NORMAL") { shape.normals.reserve(vals.size()); for (auto i = 0; i < vals.size(); i++) shape.normals.push_back( {(float)vals[i][0], (float)vals[i][1], (float)vals[i][2]}); } else if (semantic == "TEXCOORD" || semantic == "TEXCOORD_0") { shape.texcoords.reserve(vals.size()); for (auto i = 0; i < vals.size(); i++) shape.texcoords.push_back({(float)vals[i][0], (float)vals[i][1]}); } else if (semantic == "COLOR" || semantic == "COLOR_0") { shape.colors.reserve(vals.size()); for (auto i = 0; i < vals.size(); i++) shape.colors.push_back({(float)vals[i][0], (float)vals[i][1], (float)vals[i][2], (float)vals[i][3]}); } else if (semantic == "TANGENT") { shape.tangents.reserve(vals.size()); for (auto i = 0; i < vals.size(); i++) shape.tangents.push_back({(float)vals[i][0], (float)vals[i][1], (float)vals[i][2], (float)vals[i][3]}); for (auto& t : shape.tangents) t.w = -t.w; } else if (semantic == "RADIUS") { shape.radius.reserve(vals.size()); for (auto i = 0; i < vals.size(); i++) shape.radius.push_back((float)vals[i][0]); } else { // ignore } } // indices if (!gprim->indices) { if (gprim->type == cgltf_primitive_type_triangles) { shape.triangles.reserve(shape.positions.size() / 3); for (auto i = 0; i < shape.positions.size() / 3; i++) shape.triangles.push_back({i * 3 + 0, i * 3 + 1, i * 3 + 2}); } else if (gprim->type == cgltf_primitive_type_triangle_fan) { shape.triangles.reserve(shape.positions.size() - 2); for (auto i = 2; i < shape.positions.size(); i++) shape.triangles.push_back({0, i - 1, i}); } else if (gprim->type == cgltf_primitive_type_triangle_strip) { shape.triangles.reserve(shape.positions.size() - 2); for (auto i = 2; i < shape.positions.size(); i++) shape.triangles.push_back({i - 2, i - 1, i}); } else if (gprim->type == cgltf_primitive_type_lines) { shape.lines.reserve(shape.positions.size() / 2); for (auto i = 0; i < shape.positions.size() / 2; i++) shape.lines.push_back({i * 2 + 0, i * 2 + 1}); } else if (gprim->type == cgltf_primitive_type_line_loop) { shape.lines.reserve(shape.positions.size()); for (auto i = 1; i < shape.positions.size(); i++) shape.lines.push_back({i - 1, i}); shape.lines.back() = {(int)shape.positions.size() - 1, 0}; } else if (gprim->type == cgltf_primitive_type_line_strip) { shape.lines.reserve(shape.positions.size() - 1); for (auto i = 1; i < shape.positions.size(); i++) shape.lines.push_back({i - 1, i}); } else if (gprim->type == cgltf_primitive_type_points) { // points throw std::runtime_error("points not supported"); } else { throw std::runtime_error("unknown primitive type"); } } else { auto indices = accessor_values(gprim->indices); if (gprim->type == cgltf_primitive_type_triangles) { shape.triangles.reserve(indices.size() / 3); for (auto i = 0; i < indices.size() / 3; i++) shape.triangles.push_back({(int)indices[i * 3 + 0][0], (int)indices[i * 3 + 1][0], (int)indices[i * 3 + 2][0]}); } else if (gprim->type == cgltf_primitive_type_triangle_fan) { shape.triangles.reserve(indices.size() - 2); for (auto i = 2; i < indices.size(); i++) shape.triangles.push_back({(int)indices[0][0], (int)indices[i - 1][0], (int)indices[i][0]}); } else if (gprim->type == cgltf_primitive_type_triangle_strip) { shape.triangles.reserve(indices.size() - 2); for (auto i = 2; i < indices.size(); i++) shape.triangles.push_back({(int)indices[i - 2][0], (int)indices[i - 1][0], (int)indices[i][0]}); } else if (gprim->type == cgltf_primitive_type_lines) { shape.lines.reserve(indices.size() / 2); for (auto i = 0; i < indices.size() / 2; i++) shape.lines.push_back( {(int)indices[i * 2 + 0][0], (int)indices[i * 2 + 1][0]}); } else if (gprim->type == cgltf_primitive_type_line_loop) { shape.lines.reserve(indices.size()); for (auto i = 1; i < indices.size(); i++) shape.lines.push_back({(int)indices[i - 1][0], (int)indices[i][0]}); shape.lines.back() = { (int)indices[indices.size() - 1][0], (int)indices[0][0]}; } else if (gprim->type == cgltf_primitive_type_line_strip) { shape.lines.reserve(indices.size() - 1); for (auto i = 1; i < indices.size(); i++) shape.lines.push_back({(int)indices[i - 1][0], (int)indices[i][0]}); } else if (gprim->type == cgltf_primitive_type_points) { throw std::runtime_error("points not supported"); } else { throw std::runtime_error("unknown primitive type"); } } scene.shapes.push_back(shape); meshes[gmesh].push_back( {(int)scene.shapes.size() - 1, mmap.at(gprim->material)}); } } // convert cameras auto cmap = unordered_map{{nullptr, -1}}; for (auto cid = 0; cid < gltf->cameras_count; cid++) { auto gcam = &gltf->cameras[cid]; auto camera = yocto_camera{}; camera.uri = gcam->name ? gcam->name : ""; camera.orthographic = gcam->type == cgltf_camera_type_orthographic; if (camera.orthographic) { // throw std::runtime_error("orthographic not supported well"); auto ortho = &gcam->orthographic; camera.aperture = 0; camera.orthographic = true; camera.film = {ortho->xmag, ortho->ymag}; } else { auto persp = &gcam->perspective; camera.aperture = 0; set_yperspective(camera, persp->yfov, persp->aspect_ratio, flt_max); } scene.cameras.push_back(camera); cmap[gcam] = (int)scene.cameras.size() - 1; } // convert nodes auto nmap = unordered_map{{nullptr, -1}}; for (auto nid = 0; nid < gltf->nodes_count; nid++) { auto gnde = &gltf->nodes[nid]; auto node = yocto_scene_node{}; node.uri = gnde->name ? gnde->name : ""; if (gnde->camera) node.camera = cmap.at(gnde->camera); if (gnde->has_translation) { node.translation = { gnde->translation[0], gnde->translation[1], gnde->translation[2]}; } if (gnde->has_rotation) { node.rotation = {gnde->rotation[0], gnde->rotation[1], gnde->rotation[2], gnde->rotation[3]}; } if (gnde->has_scale) { node.scale = {gnde->scale[0], gnde->scale[1], gnde->scale[2]}; } if (gnde->has_matrix) { auto m = gnde->matrix; node.local = frame3f( mat4f{{m[0], m[1], m[2], m[3]}, {m[4], m[5], m[6], m[7]}, {m[8], m[9], m[10], m[11]}, {m[12], m[13], m[14], m[15]}}); } scene.nodes.push_back(node); nmap[gnde] = (int)scene.nodes.size(); } // set up parent pointers for (auto nid = 0; nid < gltf->nodes_count; nid++) { auto gnde = &gltf->nodes[nid]; if (!gnde->children_count) continue; for (auto cid = 0; cid < gnde->children_count; cid++) { scene.nodes[nmap.at(gnde->children[cid])].parent = nid; } } // set up instances for (auto nid = 0; nid < gltf->nodes_count; nid++) { auto gnde = &gltf->nodes[nid]; if (!gnde->mesh) continue; auto& node = scene.nodes[nid]; auto& shps = meshes.at(gnde->mesh); if (shps.empty()) continue; if (shps.size() == 1) { auto instance = yocto_instance(); instance.uri = node.uri; instance.shape = shps[0].x; instance.material = shps[0].y; scene.instances.push_back(instance); node.instance = (int)scene.instances.size() - 1; } else { for (auto shp : shps) { auto& shape = scene.shapes[shp.x]; auto instance = yocto_instance(); instance.uri = node.uri + "_" + shape.uri; instance.shape = shp.x; instance.material = shp.y; scene.instances.push_back(instance); auto child = yocto_scene_node{}; child.uri = node.uri + "_" + shape.uri; child.parent = nid; child.instance = (int)scene.instances.size() - 1; scene.nodes.push_back(child); } } } // hasher for later struct sampler_map_hash { size_t operator()( const pair& value) const { auto hasher1 = std::hash(); auto hasher2 = std::hash(); auto h = (size_t)0; h ^= hasher1(value.first) + 0x9e3779b9 + (h << 6) + (h >> 2); h ^= hasher2(value.second) + 0x9e3779b9 + (h << 6) + (h >> 2); return h; } }; // convert animations for (auto gid = 0; gid < gltf->animations_count; gid++) { auto ganm = &gltf->animations[gid]; auto aid = 0; auto sampler_map = unordered_map, int, sampler_map_hash>(); for (auto cid = 0; cid < ganm->channels_count; cid++) { auto gchannel = &ganm->channels[cid]; auto path = gchannel->target_path; if (sampler_map.find({gchannel->sampler, path}) == sampler_map.end()) { auto gsampler = gchannel->sampler; auto animation = yocto_animation{}; animation.uri = (ganm->name ? ganm->name : "anim") + std::to_string(aid++); animation.group = ganm->name ? ganm->name : ""; auto input_view = accessor_values(gsampler->input); animation.times.resize(input_view.size()); for (auto i = 0; i < input_view.size(); i++) animation.times[i] = input_view[i][0]; switch (gsampler->interpolation) { case cgltf_interpolation_type_linear: animation.interpolation = yocto_animation::interpolation_type::linear; break; case cgltf_interpolation_type_step: animation.interpolation = yocto_animation::interpolation_type::step; break; case cgltf_interpolation_type_cubic_spline: animation.interpolation = yocto_animation::interpolation_type::bezier; break; } auto output_view = accessor_values(gsampler->output); switch (path) { case cgltf_animation_path_type_translation: { animation.translations.reserve(output_view.size()); for (auto i = 0; i < output_view.size(); i++) animation.translations.push_back({(float)output_view[i][0], (float)output_view[i][1], (float)output_view[i][2]}); } break; case cgltf_animation_path_type_rotation: { animation.rotations.reserve(output_view.size()); for (auto i = 0; i < output_view.size(); i++) animation.rotations.push_back( {(float)output_view[i][0], (float)output_view[i][1], (float)output_view[i][2], (float)output_view[i][3]}); } break; case cgltf_animation_path_type_scale: { animation.scales.reserve(output_view.size()); for (auto i = 0; i < output_view.size(); i++) animation.scales.push_back({(float)output_view[i][0], (float)output_view[i][1], (float)output_view[i][2]}); } break; case cgltf_animation_path_type_weights: { throw std::runtime_error("weights not supported for now"); #if 0 // get a node that it refers to auto ncomp = 0; auto gnode = gltf->get(gchannel->target->node); auto gmesh = gltf->get(gnode->mesh); if (gmesh) { for (auto gshp : gmesh->primitives) { ncomp = max((int)gshp->targets.size(), ncomp); } } if (ncomp) { auto values = vector(); values.reserve(output_view.size()); for (auto i = 0; i < output_view.size(); i++) values.push_back(output_view.get(i)); animation.weights.resize(values.size() / ncomp); for (auto i = 0; i < animation.weights.size(); i++) { animation.weights[i].resize(ncomp); for (auto j = 0; j < ncomp; j++) animation.weights[i][j] = values[i * ncomp + j]; } } #endif } break; default: { throw std::runtime_error("bad gltf animation"); } } sampler_map[{gchannel->sampler, path}] = (int)scene.animations.size(); scene.animations.push_back(animation); } scene.animations[sampler_map.at({gchannel->sampler, path})] .targets.push_back(nmap.at(gchannel->target_node)); } } } // Load a scene static void load_gltf_scene( const string& filename, yocto_scene& scene, const load_params& params) { // initialization scene = {}; try { // load gltf gltf_to_scene(filename, scene); // load textures auto dirname = fs::path(filename).parent_path(); load_textures(scene, dirname, params); } catch (const std::exception& e) { throw std::runtime_error("cannot load scene " + filename + "\n" + e.what()); } // fix scene scene.uri = fs::path(filename).filename(); add_cameras(scene); add_materials(scene); add_radius(scene); normalize_uris(scene); trim_memory(scene); update_transforms(scene); // fix cameras auto bbox = compute_bounds(scene); for (auto& camera : scene.cameras) { auto center = (bbox.min + bbox.max) / 2; auto distance = dot(-camera.frame.z, center - camera.frame.o); if (distance > 0) camera.focus = distance; } } // begin/end objects and arrays struct write_json_state { FILE* fs = nullptr; vector> stack; }; static inline void write_json_text(write_json_state& state, const char* text) { if (fprintf(state.fs, "%s", text) < 0) throw std::runtime_error("cannot write json"); } static inline void write_json_text( write_json_state& state, const string& text) { if (fprintf(state.fs, "%s", text.c_str()) < 0) throw std::runtime_error("cannot write json"); } static inline void _write_json_next( write_json_state& state, bool dedent = false) { static const char* indents[7] = { "", " ", " ", " ", " ", " ", " "}; if (state.stack.empty()) return; write_json_text(state, state.stack.back().second ? ",\n" : "\n"); write_json_text( state, indents[clamp((int)state.stack.size() + (dedent ? -1 : 0), 0, 6)]); state.stack.back().second = true; } static inline void _write_json_value(write_json_state& state, int value) { if (fprintf(state.fs, "%d", value) < 0) throw std::runtime_error("cannot write json"); } static inline void _write_json_value(write_json_state& state, size_t value) { if (fprintf(state.fs, "%llu", (unsigned long long)value) < 0) throw std::runtime_error("cannot write json"); } static inline void _write_json_value(write_json_state& state, float value) { if (fprintf(state.fs, "%g", value) < 0) throw std::runtime_error("cannot write json"); } static inline void _write_json_value(write_json_state& state, bool value) { if (fprintf(state.fs, "%s", value ? "true" : "false") < 0) throw std::runtime_error("cannot write json"); } static inline void _write_json_value( write_json_state& state, const string& value) { if (fprintf(state.fs, "\"%s\"", value.c_str()) < 0) throw std::runtime_error("cannot write json"); } static inline void _write_json_value( write_json_state& state, const char* value) { if (fprintf(state.fs, "\"%s\"", value) < 0) throw std::runtime_error("cannot write json"); } static inline void _write_json_value( write_json_state& state, const vec2f& value) { if (fprintf(state.fs, "[%g, %g]", value.x, value.y) < 0) throw std::runtime_error("cannot write json"); } static inline void _write_json_value( write_json_state& state, const vec3f& value) { if (fprintf(state.fs, "[%g, %g, %g]", value.x, value.y, value.z) < 0) throw std::runtime_error("cannot write json"); } static inline void _write_json_value( write_json_state& state, const vec4f& value) { if (fprintf( state.fs, "[%g, %g, %g, %g]", value.x, value.y, value.z, value.w) < 0) throw std::runtime_error("cannot write json"); } static inline void _write_json_value( write_json_state& state, const mat4f& value) { if (fprintf(state.fs, "[ ") < 0) throw std::runtime_error("cannot write json"); for (auto i = 0; i < 16; i++) { if (fprintf(state.fs, i ? ", %g" : "%g", (&value.x.x)[i]) < 0) throw std::runtime_error("cannot write json"); } if (fprintf(state.fs, " ]") < 0) throw std::runtime_error("cannot write json"); } static inline void _write_json_value( write_json_state& state, const vector& value) { write_json_text(state, "[ "); for (auto i = 0; i < value.size(); i++) { if (i) write_json_text(state, ", "); _write_json_value(state, value[i]); } write_json_text(state, " ]"); } static inline void write_json_object(write_json_state& state) { _write_json_next(state); write_json_text(state, "{ "); state.stack.push_back({true, false}); } static inline void write_json_object(write_json_state& state, const char* key) { _write_json_next(state); _write_json_value(state, key); write_json_text(state, ": {"); state.stack.push_back({true, false}); } static inline void write_json_array(write_json_state& state) { _write_json_next(state); write_json_text(state, "[ "); state.stack.push_back({false, false}); } static inline void write_json_array(write_json_state& state, const char* key) { _write_json_next(state); _write_json_value(state, key); write_json_text(state, ": ["); state.stack.push_back({false, false}); } static inline void write_json_pop(write_json_state& state) { _write_json_next(state, true); write_json_text(state, state.stack.back().first ? "}" : "]"); state.stack.pop_back(); } template static inline void write_json_value(write_json_state& state, const T& value) { _write_json_next(state); _write_json_value(state, value); } template static inline void write_json_value( write_json_state& state, const char* key, const T& value) { _write_json_next(state); _write_json_value(state, key); write_json_text(state, ": "); _write_json_value(state, value); } static inline void write_json_begin(write_json_state& state) { state.stack.clear(); write_json_object(state); } static inline void write_json_end(write_json_state& state) { write_json_pop(state); if (state.stack.empty()) throw std::runtime_error("bad json stack"); } // convert gltf scene to json static void save_gltf(const string& filename, const yocto_scene& scene) { // shapes struct gltf_shape { string uri = ""; int material = -1; int mode = 0; vector indices = {}; vector positions = {}; vector normals = {}; vector texcoords = {}; vector colors = {}; vector radius = {}; vector tangents = {}; }; // json writer auto fs_ = open_output_file(filename); auto fs = fs_.fs; auto state = write_json_state{fs}; // begin writing write_json_begin(state); // start creating json write_json_object(state, "asset"); write_json_value(state, "version", "2.0"); write_json_value( state, "generator", "Yocto/GL - https://github.com/xelatihy/yocto-gl"); write_json_pop(state); // convert cameras write_json_array(state, "cameras"); for (auto& camera : scene.cameras) { write_json_object(state); write_json_value(state, "name", camera.uri); if (!camera.orthographic) { write_json_value(state, "type", "perspective"); write_json_object(state, "perspective"); write_json_value(state, "yfov", camera_yfov(camera)); write_json_value(state, "aspectRatio", camera.film.x / camera.film.y); write_json_value(state, "znear", 0.01f); write_json_pop(state); } else { write_json_value(state, "type", "orthographic"); write_json_object(state, "orthographic"); write_json_value(state, "xmag", camera.film.x / 2); write_json_value(state, "ymag", camera.film.y / 2); write_json_value(state, "znear", 0.01f); write_json_pop(state); } write_json_pop(state); } write_json_pop(state); // textures write_json_array(state, "images"); for (auto& texture : scene.textures) { write_json_object(state); write_json_value(state, "uri", texture.uri); write_json_pop(state); } write_json_pop(state); auto tid = 0; write_json_array(state, "textures"); for (auto& texture : scene.textures) { write_json_object(state); write_json_value(state, "source", tid++); write_json_pop(state); } write_json_pop(state); // material auto write_json_texture = [](write_json_state& state, const char* key, int tid) { write_json_object(state, key); write_json_value(state, "index", tid); write_json_pop(state); }; write_json_array(state, "materials"); for (auto& material : scene.materials) { write_json_object(state); write_json_value(state, "name", material.uri); if (material.emission != zero3f) write_json_value(state, "emissiveFactor", material.emission); if (material.emission_tex >= 0) write_json_texture(state, "emissiveTexture", material.emission_tex); auto kd = vec4f{material.diffuse.x, material.diffuse.y, material.diffuse.z, material.opacity}; if (material.metallic || material.metallic_tex >= 0) { write_json_object(state, "pbrMetallicRoughness"); write_json_value(state, "baseColorFactor", kd); write_json_value(state, "metallicFactor", material.metallic); write_json_value(state, "roughnessFactor", material.roughness); if (material.diffuse_tex >= 0) write_json_texture(state, "baseColorTexture", material.diffuse_tex); if (material.metallic_tex >= 0) write_json_texture( state, "metallicRoughnessTexture", material.metallic_tex); write_json_pop(state); } else { write_json_object(state, "extensions"); write_json_object(state, "KHR_materials_pbrSpecularGlossiness"); write_json_value(state, "diffuseFactor", kd); write_json_value(state, "specularFactor", material.specular); write_json_value(state, "glossinessFactor", 1 - material.roughness); if (material.diffuse_tex >= 0) write_json_texture(state, "diffuseTexture", material.diffuse_tex); if (material.specular_tex >= 0) write_json_texture( state, "specularGlossinessTexture", material.specular_tex); write_json_pop(state); write_json_pop(state); } if (material.normal_tex >= 0) write_json_texture(state, "normalTexture", material.normal_tex); write_json_pop(state); } write_json_pop(state); auto shapes = vector(scene.shapes.size()); auto sid = 0; for (auto& shape : scene.shapes) { auto& split = shapes[sid++]; split.uri = fs::path(shape.uri).replace_extension(".bin"); split.mode = 4; if (!shape.points.empty()) split.mode = 1; if (!shape.lines.empty()) split.mode = 1; if (shape.quadspos.empty()) { split.positions = shape.positions; split.normals = shape.normals; split.texcoords = shape.texcoords; split.colors = shape.colors; split.radius = shape.radius; split.indices.insert(split.indices.end(), shape.points.data(), shape.points.data() + shape.points.size()); split.indices.insert(split.indices.end(), (int*)shape.lines.data(), (int*)shape.lines.data() + shape.lines.size() * 2); split.indices.insert(split.indices.end(), (int*)shape.triangles.data(), (int*)shape.triangles.data() + shape.triangles.size() * 3); if (!shape.quads.empty()) { auto triangles = quads_to_triangles(shape.quads); split.indices.insert(split.indices.end(), (int*)triangles.data(), (int*)triangles.data() + triangles.size() * 3); } } else { auto quads = vector{}; split_facevarying(quads, split.positions, split.normals, split.texcoords, shape.quadspos, shape.quadsnorm, shape.quadstexcoord, shape.positions, shape.normals, shape.texcoords); auto triangles = quads_to_triangles(quads); split.indices.insert(split.indices.end(), (int*)triangles.data(), (int*)triangles.data() + triangles.size() * 3); } } for (auto& instance : scene.instances) { shapes[instance.shape].material = instance.material; } // buffers write_json_array(state, "buffers"); for (auto& shape : shapes) { auto buffer_size = sizeof(int) * shape.indices.size() + sizeof(vec3f) * shape.positions.size() + sizeof(vec3f) * shape.normals.size() + sizeof(vec2f) * shape.texcoords.size() + sizeof(vec4f) * shape.colors.size() + sizeof(float) * shape.radius.size(); write_json_object(state); write_json_value(state, "name", shape.uri); write_json_value(state, "uri", shape.uri); write_json_value(state, "byteLength", buffer_size); write_json_pop(state); } write_json_pop(state); // buffer views auto write_json_bufferview = [](write_json_state& state, auto& values, size_t& offset, int bid, bool indices) { if (values.empty()) return; auto bytes = values.size() * sizeof(values[0]); write_json_object(state); write_json_value(state, "buffer", bid); write_json_value(state, "byteLength", bytes); write_json_value(state, "byteOffset", offset); write_json_value(state, "target", (!indices) ? 34962 : 34963); write_json_pop(state); offset += bytes; }; write_json_array(state, "bufferViews"); auto bid = 0; for (auto& shape : shapes) { auto offset = (size_t)0; write_json_bufferview(state, shape.indices, offset, bid, true); write_json_bufferview(state, shape.positions, offset, bid, false); write_json_bufferview(state, shape.normals, offset, bid, false); write_json_bufferview(state, shape.texcoords, offset, bid, false); write_json_bufferview(state, shape.colors, offset, bid, false); write_json_bufferview(state, shape.radius, offset, bid, false); bid++; } write_json_pop(state); // accessors auto write_json_accessor = [](write_json_state& state, auto& values, int& vid, bool indices) { if (values.empty()) return; auto count = values.size(); auto type = "SCALAR"; if (!indices) { if (sizeof(values[0]) / sizeof(float) == 2) type = "VEC2"; if (sizeof(values[0]) / sizeof(float) == 3) type = "VEC3"; if (sizeof(values[0]) / sizeof(float) == 4) type = "VEC4"; } write_json_object(state); write_json_value(state, "bufferView", vid++); write_json_value(state, "byteOffset", 0); write_json_value(state, "componentType", (!indices) ? 5126 : 5125); write_json_value(state, "count", count); write_json_value(state, "type", type); write_json_pop(state); }; auto vid = 0; write_json_array(state, "accessors"); for (auto& shape : shapes) { write_json_accessor(state, shape.indices, vid, true); write_json_accessor(state, shape.positions, vid, false); write_json_accessor(state, shape.normals, vid, false); write_json_accessor(state, shape.texcoords, vid, false); write_json_accessor(state, shape.colors, vid, false); write_json_accessor(state, shape.radius, vid, false); } write_json_pop(state); // meshes auto aid = 0; write_json_array(state, "meshes"); for (auto& shape : shapes) { write_json_object(state); write_json_value(state, "name", shape.uri); write_json_array(state, "primitives"); write_json_value(state, "material", shape.material); if (!shape.indices.empty()) write_json_value(state, "indices", aid++); write_json_object(state, "attributes"); if (!shape.positions.empty()) write_json_value(state, "POSITION", aid++); if (!shape.normals.empty()) write_json_value(state, "NORMAL", aid++); if (!shape.texcoords.empty()) write_json_value(state, "indices", aid++); if (!shape.colors.empty()) write_json_value(state, "TEXCOORD_0", aid++); if (!shape.radius.empty()) write_json_value(state, "RADIUS", aid++); write_json_accessor(state, shape.positions, vid, false); write_json_accessor(state, shape.normals, vid, false); write_json_accessor(state, shape.texcoords, vid, false); write_json_accessor(state, shape.colors, vid, false); write_json_accessor(state, shape.radius, vid, false); write_json_pop(state); write_json_pop(state); } write_json_pop(state); // nodes write_json_array(state, "nodes"); if (scene.nodes.empty()) { auto camera_id = 0; for (auto& camera : scene.cameras) { write_json_object(state); write_json_value(state, "name", camera.uri); write_json_value(state, "camera", camera_id++); write_json_value(state, "matrix", mat4f(camera.frame)); write_json_pop(state); } for (auto& instance : scene.instances) { write_json_object(state); write_json_value(state, "name", instance.uri); write_json_value(state, "mesh", instance.shape); write_json_value(state, "matrix", mat4f(instance.frame)); write_json_pop(state); } } else { for (auto& node : scene.nodes) { write_json_object(state); write_json_value(state, "name", node.uri); write_json_value(state, "matrix", mat4f(node.local)); write_json_value(state, "translation", node.translation); write_json_value(state, "rotation", node.rotation); write_json_value(state, "scale", node.scale); if (node.camera >= 0) write_json_value(state, "camera", node.camera); if (node.instance >= 0) { auto& instance = scene.instances[node.instance]; write_json_value(state, "mesh", instance.shape); } if (!node.children.empty()) { write_json_value(state, "children", node.children); } write_json_pop(state); } } write_json_pop(state); // animations not supported yet if (!scene.animations.empty()) throw std::runtime_error("animation not supported yet"); // end writing write_json_end(state); // meshes auto write_values = [](FILE* fs, const auto& values) { if (values.empty()) return; if (fwrite(values.data(), sizeof(values.front()), values.size(), fs) != values.size()) throw std::runtime_error("cannot write to file"); }; auto dirname = fs::path(filename).parent_path(); for (auto& shape : shapes) { auto fs_ = open_output_file(dirname / shape.uri); auto fs = fs_.fs; write_values(fs, shape.indices); write_values(fs, shape.positions); write_values(fs, shape.normals); write_values(fs, shape.texcoords); write_values(fs, shape.colors); write_values(fs, shape.radius); } } // Save gltf json static void save_gltf_scene(const string& filename, const yocto_scene& scene, const save_params& params) { try { // save json save_gltf(filename, scene); // save textures auto dirname = fs::path(filename).parent_path(); save_textures(scene, dirname, params); } catch (const std::exception& e) { throw std::runtime_error("cannot save scene " + filename + "\n" + e.what()); } } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION OF PBRT // ----------------------------------------------------------------------------- namespace yocto { // Compute the fresnel term for dielectrics. Implementation from // https://seblagarde.wordpress.com/2013/04/29/memo-on-fresnel-equations/ static vec3f pbrt_fresnel_dielectric(float cosw, const vec3f& eta_) { auto eta = eta_; if (cosw < 0) { eta = vec3f{1, 1, 1} / eta; cosw = -cosw; } auto sin2 = 1 - cosw * cosw; auto eta2 = eta * eta; auto cos2t = vec3f{1, 1, 1} - vec3f{sin2, sin2, sin2} / eta2; if (cos2t.x < 0 || cos2t.y < 0 || cos2t.z < 0) return vec3f{1, 1, 1}; // tir auto t0 = vec3f{sqrt(cos2t.x), sqrt(cos2t.y), sqrt(cos2t.z)}; auto t1 = eta * t0; auto t2 = eta * cosw; auto rs = (vec3f{cosw, cosw, cosw} - t1) / (vec3f{cosw, cosw, cosw} + t1); auto rp = (t0 - t2) / (t0 + t2); return (rs * rs + rp * rp) / 2.0f; } // Compute the fresnel term for metals. Implementation from // https://seblagarde.wordpress.com/2013/04/29/memo-on-fresnel-equations/ static vec3f pbrt_fresnel_metal( float cosw, const vec3f& eta, const vec3f& etak) { if (etak == zero3f) return pbrt_fresnel_dielectric(cosw, eta); cosw = clamp(cosw, (float)-1, (float)1); auto cos2 = cosw * cosw; auto sin2 = clamp(1 - cos2, (float)0, (float)1); auto eta2 = eta * eta; auto etak2 = etak * etak; auto t0 = eta2 - etak2 - vec3f{sin2, sin2, sin2}; auto a2plusb2_2 = t0 * t0 + 4.0f * eta2 * etak2; auto a2plusb2 = vec3f{ sqrt(a2plusb2_2.x), sqrt(a2plusb2_2.y), sqrt(a2plusb2_2.z)}; auto t1 = a2plusb2 + vec3f{cos2, cos2, cos2}; auto a_2 = (a2plusb2 + t0) / 2.0f; auto a = vec3f{sqrt(a_2.x), sqrt(a_2.y), sqrt(a_2.z)}; auto t2 = 2.0f * a * cosw; auto rs = (t1 - t2) / (t1 + t2); auto t3 = vec3f{cos2, cos2, cos2} * a2plusb2 + vec3f{sin2, sin2, sin2} * vec3f{sin2, sin2, sin2}; auto t4 = t2 * sin2; auto rp = rs * (t3 - t4) / (t3 + t4); return (rp + rs) / 2.0f; } struct load_pbrt_scene_cb : pbrt_callbacks { yocto_scene& scene; const load_params& params; const string& filename; load_pbrt_scene_cb( yocto_scene& scene, const load_params& params, const string& filename) : scene{scene}, params{params}, filename{filename} {} bool verbose = false; bool remove_contant_textures = true; unordered_map mmap = unordered_map{{"", {}}}; unordered_map amap = unordered_map{ {"", zero3f}}; unordered_map ammap = unordered_map{}; unordered_map tmap = unordered_map{{"", -1}}; unordered_map ctmap = unordered_map{ {"", zero3f}}; unordered_map timap = unordered_map{{"", false}}; unordered_map> omap = unordered_map>{}; string cur_object = ""s; float last_film_aspect = -1.0f; bool is_constant_texture(const string& name) { return ctmap.find(name) != ctmap.end(); } vec3f get_constant_texture_color(const string& name) { return ctmap.at(name); } int get_material(const pbrt_context& ctx) { static auto light_id = 0; auto lookup_name = ctx.material + "_______" + ctx.arealight; if (ammap.find(lookup_name) != ammap.end()) return ammap.at(lookup_name); auto material = mmap.at(ctx.material); if (amap.at(ctx.arealight) != zero3f) { material.emission = amap.at(ctx.arealight); material.uri += "_arealight_" + std::to_string(light_id++); } scene.materials.push_back(material); ammap[lookup_name] = (int)scene.materials.size() - 1; return (int)scene.materials.size() - 1; } void get_scaled_texture3f(const pbrt_textured3f& textured, float& factor, vec3f& color, int& texture) { if (textured.texture == "") { color = {textured.value.x, textured.value.y, textured.value.z}; factor = color == zero3f ? 0 : 1; if (!factor) color = {1, 1, 1}; texture = -1; } else if (is_constant_texture(textured.texture)) { color = get_constant_texture_color(textured.texture); factor = color == zero3f ? 0 : 1; if (!factor) color = {1, 1, 1}; texture = -1; } else { color = {1, 1, 1}; factor = 1; texture = tmap.at(textured.texture); } } void get_scaled_texture3f( const pbrt_textured3f& textured, vec3f& color, int& texture) { if (textured.texture == "") { color = {textured.value.x, textured.value.y, textured.value.z}; texture = -1; } else if (is_constant_texture(textured.texture)) { color = get_constant_texture_color(textured.texture); texture = -1; } else { color = {1, 1, 1}; texture = tmap.at(textured.texture); } } float get_pbrt_roughness(float uroughness, float vroughness, bool remap) { if (uroughness == 0 && vroughness == 0) return 0; auto roughness = (uroughness + vroughness) / 2; // from pbrt code if (remap) { roughness = max(roughness, 1e-3f); auto x = log(roughness); roughness = 1.62142f + 0.819955f * x + 0.1734f * x * x + 0.0171201f * x * x * x + 0.000640711f * x * x * x * x; } return sqrt(roughness); } void camera(const pbrt_camera& pcamera, const pbrt_context& ctx) override { auto camera = yocto_camera{}; camera.frame = inverse((frame3f)ctx.transform_start); camera.frame.z = -camera.frame.z; switch (pcamera.type) { case pbrt_camera::type_t::perspective: { auto& perspective = pcamera.perspective; auto aspect = perspective.frameaspectratio; if (aspect < 0) aspect = last_film_aspect; if (aspect < 0) aspect = 1; if (aspect >= 1) { set_yperspective(camera, radians(perspective.fov), aspect, clamp(perspective.focaldistance, 1.0e-2f, 1.0e4f)); } else { auto yfov = 2 * atan(tan(radians(perspective.fov) / 2) / aspect); set_yperspective(camera, yfov, aspect, clamp(perspective.focaldistance, 1.0e-2f, 1.0e4f)); } } break; case pbrt_camera::type_t::orthographic: { throw std::runtime_error("unsupported Camera type"); } break; case pbrt_camera::type_t::environment: { throw std::runtime_error("unsupported Camera type"); } break; case pbrt_camera::type_t::realistic: { auto& realistic = pcamera.realistic; camera.lens = max(realistic.approx_focallength, 35.0f) * 0.001f; auto aspect = 1.0f; if (aspect < 0) aspect = last_film_aspect; if (aspect < 0) aspect = 1; if (aspect >= 1) { camera.film.y = camera.film.x / aspect; } else { camera.film.x = camera.film.y * aspect; } camera.focus = realistic.focusdistance; camera.aperture = realistic.aperturediameter / 2; } break; } scene.cameras.push_back(camera); } void film(const pbrt_film& pfilm, const pbrt_context& ctx) override { switch (pfilm.type) { case pbrt_film::type_t::image: { auto& image = pfilm.image; last_film_aspect = (float)image.xresolution / (float)image.yresolution; for (auto& camera : scene.cameras) { camera.film.x = camera.film.y * last_film_aspect; } } break; } } void shape(const pbrt_shape& pshape, const pbrt_context& ctx) override { static auto shape_id = 0; auto shape = yocto_shape{}; shape.uri = "shapes/shape__" + std::to_string(shape_id++) + ".ply"; switch (pshape.type) { case pbrt_shape::type_t::trianglemesh: { auto& mesh = pshape.trianglemesh; shape.positions = mesh.P; shape.normals = mesh.N; shape.texcoords = mesh.uv; for (auto& uv : shape.texcoords) uv.y = (1 - uv.y); shape.triangles = mesh.indices; } break; case pbrt_shape::type_t::loopsubdiv: { auto& mesh = pshape.loopsubdiv; shape.positions = mesh.P; shape.triangles = mesh.indices; shape.normals.resize(shape.positions.size()); compute_normals(shape.normals, shape.triangles, shape.positions); } break; case pbrt_shape::type_t::plymesh: { auto& mesh = pshape.plymesh; shape.uri = mesh.filename; load_shape(fs::path(filename).parent_path() / mesh.filename, shape.points, shape.lines, shape.triangles, shape.quads, shape.quadspos, shape.quadsnorm, shape.quadstexcoord, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius, false); } break; case pbrt_shape::type_t::sphere: { auto& sphere = pshape.sphere; auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::uvsphere; params.subdivisions = 5; params.scale = sphere.radius; make_proc_shape(shape.triangles, shape.quads, shape.positions, shape.normals, shape.texcoords, params); } break; case pbrt_shape::type_t::disk: { auto& disk = pshape.disk; auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::uvdisk; params.subdivisions = 4; params.scale = disk.radius; make_proc_shape(shape.triangles, shape.quads, shape.positions, shape.normals, shape.texcoords, params); } break; default: { throw std::runtime_error( "unsupported shape type " + std::to_string((int)pshape.type)); } } scene.shapes.push_back(shape); auto instance = yocto_instance{}; instance.frame = (frame3f)ctx.transform_start; instance.shape = (int)scene.shapes.size() - 1; instance.material = get_material(ctx); if (cur_object == "") { scene.instances.push_back(instance); } else { omap[cur_object].push_back(instance); } } void texture(const pbrt_texture& ptexture, const string& name, const pbrt_context& ctx) override { if (remove_contant_textures && ptexture.type == pbrt_texture::type_t::constant) { auto& constant = ptexture.constant; ctmap[name] = (vec3f)constant.value.value; timap[name] = false; return; } auto texture = yocto_texture{}; texture.uri = "textures/" + name + ".png"; switch (ptexture.type) { case pbrt_texture::type_t::imagemap: { auto& imagemap = ptexture.imagemap; texture.uri = imagemap.filename; } break; case pbrt_texture::type_t::constant: { auto& constant = ptexture.constant; texture.ldr.resize({1, 1}); texture.ldr[{0, 0}] = float_to_byte( vec4f{(vec3f)constant.value.value, 1}); } break; case pbrt_texture::type_t::bilerp: { // auto& bilerp = get(ptexture); texture.ldr.resize({1, 1}); texture.ldr[{0, 0}] = {255, 0, 0, 255}; if (verbose) printf("texture bilerp not supported well"); } break; case pbrt_texture::type_t::checkerboard: { auto& checkerboard = ptexture.checkerboard; auto rgb1 = checkerboard.tex1.texture == "" ? checkerboard.tex1.value : pbrt_spectrum3f{0.4f, 0.4f, 0.4f}; auto rgb2 = checkerboard.tex1.texture == "" ? checkerboard.tex2.value : pbrt_spectrum3f{0.6f, 0.6f, 0.6f}; auto params = proc_image_params{}; params.type = proc_image_params::type_t::checker; params.color0 = {rgb1.x, rgb1.y, rgb1.z, 1}; params.color1 = {rgb2.x, rgb2.y, rgb2.z, 1}; params.scale = 2; make_proc_image(texture.hdr, params); float_to_byte(texture.ldr, texture.hdr); texture.hdr = {}; if (verbose) printf("texture checkerboard not supported well"); } break; case pbrt_texture::type_t::dots: { // auto& dots = get(ptexture); texture.ldr.resize({1, 1}); texture.ldr[{0, 0}] = {255, 0, 0, 255}; if (verbose) printf("texture dots not supported well"); } break; case pbrt_texture::type_t::fbm: { // auto& fbm = ptexture.fbm; auto params = proc_image_params{}; params.type = proc_image_params::type_t::fbm; make_proc_image(texture.hdr, params); float_to_byte(texture.ldr, texture.hdr); texture.hdr = {}; if (verbose) printf("texture fbm not supported well"); } break; case pbrt_texture::type_t::marble: { // auto& marble = ptexture.marble; auto params = proc_image_params{}; params.type = proc_image_params::type_t::fbm; make_proc_image(texture.hdr, params); float_to_byte(texture.ldr, texture.hdr); texture.hdr = {}; if (verbose) printf("texture marble not supported well"); } break; case pbrt_texture::type_t::mix: { auto& mix = ptexture.mix; if (timap.at(mix.tex1.texture)) { texture.uri = scene.textures.at(tmap.at(mix.tex1.texture)).uri; } else if (timap.at(mix.tex2.texture)) { texture.uri = scene.textures.at(tmap.at(mix.tex2.texture)).uri; } else { texture.ldr.resize({1, 1}); texture.ldr[{0, 0}] = {255, 0, 0, 255}; } if (verbose) printf("texture mix not supported well"); } break; case pbrt_texture::type_t::scale: { auto& scale = ptexture.scale; if (timap.at(scale.tex1.texture)) { texture.uri = scene.textures.at(tmap.at(scale.tex1.texture)).uri; } else if (timap.at(scale.tex2.texture)) { texture.uri = scene.textures.at(tmap.at(scale.tex2.texture)).uri; } else { texture.ldr.resize({1, 1}); texture.ldr[{0, 0}] = {255, 0, 0, 255}; } if (verbose) printf("texture scale not supported well"); } break; case pbrt_texture::type_t::uv: { // auto& uv = get(ptexture); texture.ldr.resize({1, 1}); texture.ldr[{0, 0}] = {255, 0, 0, 255}; if (verbose) printf("texture uv not supported well"); } break; case pbrt_texture::type_t::windy: { // auto& uv = get(ptexture); texture.ldr.resize({1, 1}); texture.ldr[{0, 0}] = {255, 0, 0, 255}; if (verbose) printf("texture windy not supported well"); } break; case pbrt_texture::type_t::wrinkled: { // auto& uv = get(ptexture); texture.ldr.resize({1, 1}); texture.ldr[{0, 0}] = {255, 0, 0, 255}; if (verbose) printf("texture wrinkled not supported well"); } break; } scene.textures.push_back(texture); tmap[name] = (int)scene.textures.size() - 1; timap[name] = ptexture.type == pbrt_texture::type_t::imagemap; } void material(const pbrt_material& pmaterial, const string& name, const pbrt_context& ctx) override { auto material = yocto_material{}; material.uri = name; switch (pmaterial.type) { case pbrt_material::type_t::uber: { auto& uber = pmaterial.uber; get_scaled_texture3f(uber.Kd, material.diffuse, material.diffuse_tex); get_scaled_texture3f(uber.Ks, material.specular, material.specular_tex); get_scaled_texture3f( uber.Kt, material.transmission, material.transmission_tex); float op_f = 1; auto op = vec3f{0, 0, 0}; get_scaled_texture3f(uber.opacity, op_f, op, material.opacity_tex); material.opacity = (op.x + op.y + op.z) / 3; material.roughness = get_pbrt_roughness( uber.uroughness.value, uber.vroughness.value, uber.remaproughness); material.thin = true; } break; case pbrt_material::type_t::plastic: { auto& plastic = pmaterial.plastic; get_scaled_texture3f( plastic.Kd, material.diffuse, material.diffuse_tex); get_scaled_texture3f( plastic.Ks, material.specular, material.specular_tex); material.specular *= 0.04f; material.roughness = get_pbrt_roughness(plastic.uroughness.value, plastic.vroughness.value, plastic.remaproughness); } break; case pbrt_material::type_t::translucent: { auto& translucent = pmaterial.translucent; get_scaled_texture3f( translucent.Kd, material.diffuse, material.diffuse_tex); get_scaled_texture3f( translucent.Ks, material.specular, material.specular_tex); material.specular *= 0.04f; material.roughness = get_pbrt_roughness(translucent.uroughness.value, translucent.vroughness.value, translucent.remaproughness); } break; case pbrt_material::type_t::matte: { auto& matte = pmaterial.matte; get_scaled_texture3f(matte.Kd, material.diffuse, material.diffuse_tex); material.roughness = 1; } break; case pbrt_material::type_t::mirror: { auto& mirror = pmaterial.mirror; get_scaled_texture3f(mirror.Kr, material.metallic, material.diffuse, material.diffuse_tex); material.roughness = 0; } break; case pbrt_material::type_t::metal: { auto& metal = pmaterial.metal; float eta_f = 0, etak_f = 0; auto eta = zero3f, k = zero3f; auto eta_texture = -1, k_texture = -1; get_scaled_texture3f(metal.eta, eta_f, eta, eta_texture); get_scaled_texture3f(metal.k, etak_f, k, k_texture); material.specular = pbrt_fresnel_metal(1, eta, k); material.roughness = get_pbrt_roughness(metal.uroughness.value, metal.vroughness.value, metal.remaproughness); } break; case pbrt_material::type_t::substrate: { auto& substrate = pmaterial.substrate; get_scaled_texture3f( substrate.Kd, material.diffuse, material.diffuse_tex); get_scaled_texture3f( substrate.Ks, material.specular, material.specular_tex); material.roughness = get_pbrt_roughness(substrate.uroughness.value, substrate.vroughness.value, substrate.remaproughness); } break; case pbrt_material::type_t::glass: { auto& glass = pmaterial.glass; get_scaled_texture3f( glass.Kr, material.specular, material.specular_tex); material.specular *= 0.04f; get_scaled_texture3f( glass.Kt, material.transmission, material.transmission_tex); material.roughness = get_pbrt_roughness(glass.uroughness.value, glass.vroughness.value, glass.remaproughness); material.thin = true; } break; case pbrt_material::type_t::hair: { auto& hair = pmaterial.hair; get_scaled_texture3f( hair.color, material.diffuse, material.diffuse_tex); material.roughness = 1; if (verbose) printf("hair material not properly supported\n"); } break; case pbrt_material::type_t::disney: { auto& disney = pmaterial.disney; get_scaled_texture3f( disney.color, material.diffuse, material.diffuse_tex); material.roughness = 1; if (verbose) printf("disney material not properly supported\n"); } break; case pbrt_material::type_t::kdsubsurface: { auto& kdsubsurface = pmaterial.kdsubsurface; get_scaled_texture3f( kdsubsurface.Kd, material.diffuse, material.diffuse_tex); get_scaled_texture3f( kdsubsurface.Kr, material.specular, material.specular_tex); material.specular *= 0.04f; material.roughness = get_pbrt_roughness(kdsubsurface.uroughness.value, kdsubsurface.vroughness.value, kdsubsurface.remaproughness); if (verbose) printf("kdsubsurface material not properly supported\n"); } break; case pbrt_material::type_t::subsurface: { auto& subsurface = pmaterial.subsurface; get_scaled_texture3f( subsurface.Kr, material.specular, material.specular_tex); material.specular *= 0.04f; get_scaled_texture3f( subsurface.Kt, material.transmission, material.transmission_tex); material.roughness = get_pbrt_roughness(subsurface.uroughness.value, subsurface.vroughness.value, subsurface.remaproughness); material.volscale = 1 / subsurface.scale; auto sigma_a = zero3f, sigma_s = zero3f; auto sigma_a_tex = -1, sigma_s_tex = -1; get_scaled_texture3f(subsurface.sigma_a, sigma_a, sigma_a_tex); get_scaled_texture3f(subsurface.sigma_prime_s, sigma_s, sigma_s_tex); material.volmeanfreepath = 1 / (sigma_a + sigma_s); material.volscatter = sigma_s / (sigma_a + sigma_s); if (verbose) printf("subsurface material not properly supported\n"); } break; case pbrt_material::type_t::mix: { auto& mix = pmaterial.mix; auto matname = (!mix.namedmaterial1.empty()) ? mix.namedmaterial1 : mix.namedmaterial2; material = mmap.at(matname); if (verbose) printf("mix material not properly supported\n"); } break; case pbrt_material::type_t::fourier: { auto& fourier = pmaterial.fourier; if (fourier.approx_type == pbrt_material::fourier_t::approx_type_t::plastic) { auto& plastic = fourier.approx_plastic; get_scaled_texture3f( plastic.Kd, material.diffuse, material.diffuse_tex); get_scaled_texture3f( plastic.Ks, material.specular, material.specular_tex); material.specular *= 0.04f; material.roughness = get_pbrt_roughness(plastic.uroughness.value, plastic.vroughness.value, plastic.remaproughness); } else if (fourier.approx_type == pbrt_material::fourier_t::approx_type_t::metal) { auto& metal = fourier.approx_metal; float eta_f = 0, etak_f = 0; auto eta = zero3f, k = zero3f; auto eta_texture = -1, k_texture = -1; get_scaled_texture3f(metal.eta, eta_f, eta, eta_texture); get_scaled_texture3f(metal.k, etak_f, k, k_texture); material.specular = pbrt_fresnel_metal(1, eta, k); material.roughness = get_pbrt_roughness(metal.uroughness.value, metal.vroughness.value, metal.remaproughness); } else if (fourier.approx_type == pbrt_material::fourier_t::approx_type_t::glass) { auto& glass = fourier.approx_glass; get_scaled_texture3f( glass.Kr, material.specular, material.specular_tex); material.specular *= 0.04f; get_scaled_texture3f( glass.Kt, material.transmission, material.transmission_tex); } } break; } mmap[name] = material; } void arealight(const pbrt_arealight& plight, const string& name, const pbrt_context& ctx) override { auto emission = zero3f; switch (plight.type) { case pbrt_arealight::type_t::diffuse: { auto& diffuse = plight.diffuse; emission = (vec3f)diffuse.L * (vec3f)diffuse.scale; } break; case pbrt_arealight::type_t::none: { throw std::runtime_error("should not have gotten here"); } break; } amap[name] = emission; } void light(const pbrt_light& plight, const pbrt_context& ctx) override { static auto light_id = 0; auto name = "light_" + std::to_string(light_id++); switch (plight.type) { case pbrt_light::type_t::infinite: { auto& infinite = plight.infinite; auto environment = yocto_environment(); environment.uri = name; // environment.frame = // frame3f{{1,0,0},{0,0,-1},{0,-1,0},{0,0,0}} // * stack.back().frame; environment.frame = (frame3f)ctx.transform_start * frame3f{{1, 0, 0}, {0, 0, 1}, {0, 1, 0}, {0, 0, 0}}; environment.emission = (vec3f)infinite.scale * (vec3f)infinite.L; if (infinite.mapname != "") { auto texture = yocto_texture{}; texture.uri = infinite.mapname; scene.textures.push_back(texture); environment.emission_tex = (int)scene.textures.size() - 1; } scene.environments.push_back(environment); } break; case pbrt_light::type_t::distant: { auto& distant = plight.distant; auto distant_dist = 100; scene.shapes.push_back({}); auto& shape = scene.shapes.back(); shape.uri = name; auto dir = normalize(distant.from - distant.to); auto size = distant_dist * sin(5 * pif / 180); auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::quad; params.scale = size / 2; make_proc_shape(shape.triangles, shape.quads, shape.positions, shape.normals, shape.texcoords, params); scene.materials.push_back({}); auto& material = scene.materials.back(); material.uri = shape.uri; material.emission = (vec3f)distant.L * (vec3f)distant.scale; material.emission *= (distant_dist * distant_dist) / (size * size); auto instance = yocto_instance(); instance.uri = shape.uri; instance.shape = (int)scene.shapes.size() - 1; instance.material = (int)scene.materials.size() - 1; instance.frame = (frame3f)ctx.transform_start * lookat_frame( dir * distant_dist, zero3f, {0, 1, 0}, true); scene.instances.push_back(instance); } break; case pbrt_light::type_t::point: { auto& point = plight.point; scene.shapes.push_back({}); auto& shape = scene.shapes.back(); shape.uri = name; auto size = 0.005f; auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::sphere; params.scale = size; params.subdivisions = 2; make_proc_shape(shape.triangles, shape.quads, shape.positions, shape.normals, shape.texcoords, params); scene.materials.push_back({}); auto& material = scene.materials.back(); material.uri = shape.uri; material.emission = (vec3f)point.I * (vec3f)point.scale; // TODO: fix emission auto instance = yocto_instance(); instance.uri = shape.uri; instance.shape = (int)scene.shapes.size() - 1; instance.material = (int)scene.materials.size() - 1; instance.frame = (frame3f)ctx.transform_start * translation_frame(point.from); scene.instances.push_back(instance); } break; case pbrt_light::type_t::goniometric: { auto& goniometric = plight.goniometric; scene.shapes.push_back({}); auto& shape = scene.shapes.back(); shape.uri = name; auto size = 0.005f; auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::sphere; params.scale = size; params.subdivisions = 2; make_proc_shape(shape.triangles, shape.quads, shape.positions, shape.normals, shape.texcoords, params); scene.materials.push_back({}); auto& material = scene.materials.back(); material.uri = shape.uri; material.emission = (vec3f)goniometric.I * (vec3f)goniometric.scale; // TODO: fix emission auto instance = yocto_instance(); instance.uri = shape.uri; instance.shape = (int)scene.shapes.size() - 1; instance.material = (int)scene.materials.size() - 1; instance.frame = (frame3f)ctx.transform_start; scene.instances.push_back(instance); } break; case pbrt_light::type_t::spot: { auto& spot = plight.spot; scene.shapes.push_back({}); auto& shape = scene.shapes.back(); shape.uri = name; auto size = 0.005f; auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::sphere; params.scale = size; params.subdivisions = 2; make_proc_shape(shape.triangles, shape.quads, shape.positions, shape.normals, shape.texcoords, params); scene.materials.push_back({}); auto& material = scene.materials.back(); material.uri = shape.uri; material.emission = (vec3f)spot.I * (vec3f)spot.scale; // TODO: fix emission auto instance = yocto_instance(); instance.uri = shape.uri; instance.shape = (int)scene.shapes.size() - 1; instance.material = (int)scene.materials.size() - 1; instance.frame = (frame3f)ctx.transform_start; scene.instances.push_back(instance); } break; default: { throw std::runtime_error( "light type not supported " + std::to_string((int)plight.type)); } } } void begin_object( const pbrt_object& pobject, const pbrt_context& ctx) override { cur_object = pobject.name; omap[cur_object] = {}; } void end_object( const pbrt_object& pobject, const pbrt_context& ctx) override { cur_object = ""; } void object_instance( const pbrt_object& pobject, const pbrt_context& ctx) override { auto& pinstances = omap.at(pobject.name); for (auto& pinstance : pinstances) { auto instance = yocto_instance(); instance.frame = (frame3f)ctx.transform_start * pinstance.frame; instance.shape = pinstance.shape; instance.material = pinstance.material; scene.instances.push_back(instance); } } }; // namespace yocto // load pbrt scenes static void load_pbrt_scene( const string& filename, yocto_scene& scene, const load_params& params) { scene = yocto_scene{}; try { // Parse pbrt auto cb = load_pbrt_scene_cb{scene, params, filename}; load_pbrt(filename, cb); // load textures auto dirname = fs::path(filename).parent_path(); load_textures(scene, dirname, params); } catch (const std::exception& e) { throw std::runtime_error("cannot load scene " + filename + "\n" + e.what()); } // fix scene scene.uri = fs::path(filename).filename(); add_cameras(scene); add_materials(scene); add_radius(scene); normalize_uris(scene); trim_memory(scene); update_transforms(scene); } // Write text to file static inline void write_pbrt_value(FILE* fs, int value) { if (fprintf(fs, "%d", value) < 0) throw std::runtime_error("cannot print value"); } static inline void write_pbrt_value(FILE* fs, float value) { if (fprintf(fs, "%g", value) < 0) throw std::runtime_error("cannot print value"); } static inline void write_pbrt_text(FILE* fs, const char* value) { if (fprintf(fs, "%s", value) < 0) throw std::runtime_error("cannot print value"); } static inline void write_pbrt_text(FILE* fs, const string& value) { if (fprintf(fs, "\"%s\"", value.c_str()) < 0) throw std::runtime_error("cannot print value"); } static inline void write_pbrt_value(FILE* fs, const char* value) { if (fprintf(fs, "%s", value) < 0) throw std::runtime_error("cannot print value"); } static inline void write_pbrt_value(FILE* fs, const string& value) { if (fprintf(fs, "%s", value.c_str()) < 0) throw std::runtime_error("cannot print value"); } static inline void write_pbrt_value(FILE* fs, const vec3f& value) { if (fprintf(fs, "%g %g %g", value.x, value.y, value.z) < 0) throw std::runtime_error("cannot print value"); } static inline void write_pbrt_value(FILE* fs, const frame3f& value) { for (auto i = 0; i < 12; i++) if (fprintf(fs, i ? " %g" : "%g", (&value.x.x)[i]) < 0) throw std::runtime_error("cannot print value"); } template static inline void write_pbrt_line( FILE* fs, const T& value, const Ts... values) { write_pbrt_value(fs, value); if constexpr (sizeof...(values) == 0) { write_pbrt_text(fs, "\n"); } else { write_pbrt_text(fs, " "); write_pbrt_line(fs, values...); } } // Convert a scene to pbrt format static void save_pbrt(const string& filename, const yocto_scene& scene) { // open file auto fs_ = open_output_file(filename); auto fs = fs_.fs; // embed data write_pbrt_text(fs, get_save_scene_message(scene)); // convert camera and settings auto& camera = scene.cameras.front(); auto from = camera.frame.o; auto to = camera.frame.o - camera.frame.z; auto up = camera.frame.y; auto image_size = camera_resolution(camera, 1280); write_pbrt_line(fs, "LookAt", from, to, up); write_pbrt_line(fs, "Camera \"perspective\" \"float fov\"", camera_fov(camera).x * 180 / pif); // save renderer write_pbrt_text(fs, "Sampler \"random\" \"integer pixelsamples\" [64]\n"); write_pbrt_text(fs, "Integrator \"path\"\n"); write_pbrt_line(fs, "Film \"image\" \"string filename\"", fs::path(filename).stem().string() + ".exr", "\"integer xresolution\"", image_size.x, "\"integer yresolution\"", image_size.y); // convert textures for (auto& texture : scene.textures) { write_pbrt_line(fs, "Texture", fs::path(texture.uri).stem().string(), "\"spectrum\" \"imagemap\" \"string filename\"", texture.uri); } // convert materials for (auto& material : scene.materials) { write_pbrt_line(fs, "MakeNamedMaterial \"{}\" \"string type\" \"uber\"\n", fs::path(material.uri).stem().string()); if (material.diffuse_tex >= 0) { write_pbrt_line(fs, " \"texture Kd\"", fs::path(scene.textures[material.diffuse_tex].uri).stem().string()); } else { write_pbrt_line(fs, " \"rgb Kd\" [", material.diffuse, "]"); } if (material.specular_tex >= 0) { write_pbrt_line(fs, " \"texture Ks\"", fs::path(scene.textures[material.specular_tex].uri).stem().string()); } else { auto specular = vec3f{1}; write_pbrt_line(fs, " \"rgb Ks\" [", specular, "]"); } write_pbrt_line(fs, " \"float roughness\" ", material.roughness * material.roughness); } // start world write_pbrt_text(fs, "WorldBegin\n"); // convert instances for (auto& instance : scene.instances) { auto& shape = scene.shapes[instance.shape]; auto& material = scene.materials[instance.material]; write_pbrt_text(fs, "AttributeBegin\n"); write_pbrt_text(fs, " TransformBegin\n"); write_pbrt_line(fs, " Transform [", instance.frame, "]"); write_pbrt_line( fs, " NamedMaterial", fs::path(material.uri).stem().string()); if (material.emission != zero3f) { write_pbrt_line(fs, " AreaLightSource \"diffuse\" \"rgb L\" [", material.emission, "]"); } write_pbrt_line(fs, " Shape \"plymesh\" \"string filename\"", fs::path(shape.uri).replace_extension(".ply").string()); write_pbrt_text(fs, " TransformEnd\n"); write_pbrt_text(fs, "AttributeEnd\n"); } // end world write_pbrt_text(fs, "WorldEnd\n"); } // Save a pbrt scene void save_pbrt_scene(const string& filename, const yocto_scene& scene, const save_params& params) { try { // save json save_pbrt(filename, scene); // save meshes auto dirname = fs::path(filename).parent_path(); for (auto& shape : scene.shapes) { save_shape((dirname / shape.uri).replace_extension(".ply"), shape.points, shape.lines, shape.triangles, shape.quads, shape.quadspos, shape.quadsnorm, shape.quadstexcoord, shape.positions, shape.normals, shape.texcoords, shape.colors, shape.radius); } // skip textures save_textures(scene, dirname, params); } catch (const std::exception& e) { throw std::runtime_error("cannot save scene " + filename + "\n" + e.what()); } } } // namespace yocto // ----------------------------------------------------------------------------- // EXAMPLE SCENES // ----------------------------------------------------------------------------- namespace yocto { void make_cornellbox_scene(yocto_scene& scene) { scene.uri = "cornellbox"; auto& camera = scene.cameras.emplace_back(); camera.uri = "cam"; camera.frame = frame3f{{0, 1, 3.9}}; camera.lens = 0.035; camera.aperture = 0.0; camera.film = {0.024, 0.024}; auto& floor_mat = scene.materials.emplace_back(); floor_mat.uri = "floor"; floor_mat.diffuse = {0.725, 0.71, 0.68}; auto& ceiling_mat = scene.materials.emplace_back(); ceiling_mat.uri = "ceiling"; ceiling_mat.diffuse = {0.725, 0.71, 0.68}; auto& backwall_mat = scene.materials.emplace_back(); backwall_mat.uri = "backwall"; backwall_mat.diffuse = {0.725, 0.71, 0.68}; auto& rightwall_mat = scene.materials.emplace_back(); rightwall_mat.uri = "rightwall"; rightwall_mat.diffuse = {0.14, 0.45, 0.091}; auto& leftwall_mat = scene.materials.emplace_back(); leftwall_mat.uri = "leftwall"; leftwall_mat.diffuse = {0.63, 0.065, 0.05}; auto& shortbox_mat = scene.materials.emplace_back(); shortbox_mat.uri = "shortbox"; shortbox_mat.diffuse = {0.725, 0.71, 0.68}; auto& tallbox_mat = scene.materials.emplace_back(); tallbox_mat.uri = "tallbox"; tallbox_mat.diffuse = {0.725, 0.71, 0.68}; auto& light_mat = scene.materials.emplace_back(); light_mat.uri = "light"; light_mat.emission = {17, 12, 4}; auto& floor_shp = scene.shapes.emplace_back(); floor_shp.uri = "floor"; floor_shp.positions = {{-1, 0, 1}, {1, 0, 1}, {1, 0, -1}, {-1, 0, -1}}; floor_shp.triangles = {{0, 1, 2}, {2, 3, 0}}; auto& ceiling_shp = scene.shapes.emplace_back(); ceiling_shp.uri = "ceiling"; ceiling_shp.positions = {{-1, 2, 1}, {-1, 2, -1}, {1, 2, -1}, {1, 2, 1}}; ceiling_shp.triangles = {{0, 1, 2}, {2, 3, 0}}; auto& backwall_shp = scene.shapes.emplace_back(); backwall_shp.uri = "backwall"; backwall_shp.positions = {{-1, 0, -1}, {1, 0, -1}, {1, 2, -1}, {-1, 2, -1}}; backwall_shp.triangles = {{0, 1, 2}, {2, 3, 0}}; auto& rightwall_shp = scene.shapes.emplace_back(); rightwall_shp.uri = "rightwall"; rightwall_shp.positions = {{1, 0, -1}, {1, 0, 1}, {1, 2, 1}, {1, 2, -1}}; rightwall_shp.triangles = {{0, 1, 2}, {2, 3, 0}}; auto& leftwall_shp = scene.shapes.emplace_back(); leftwall_shp.uri = "leftwall"; leftwall_shp.positions = {{-1, 0, 1}, {-1, 0, -1}, {-1, 2, -1}, {-1, 2, 1}}; leftwall_shp.triangles = {{0, 1, 2}, {2, 3, 0}}; auto& shortbox_shp = scene.shapes.emplace_back(); shortbox_shp.uri = "shortbox"; shortbox_shp.positions = {{0.53, 0.6, 0.75}, {0.7, 0.6, 0.17}, {0.13, 0.6, 0.0}, {-0.05, 0.6, 0.57}, {-0.05, 0.0, 0.57}, {-0.05, 0.6, 0.57}, {0.13, 0.6, 0.0}, {0.13, 0.0, 0.0}, {0.53, 0.0, 0.75}, {0.53, 0.6, 0.75}, {-0.05, 0.6, 0.57}, {-0.05, 0.0, 0.57}, {0.7, 0.0, 0.17}, {0.7, 0.6, 0.17}, {0.53, 0.6, 0.75}, {0.53, 0.0, 0.75}, {0.13, 0.0, 0.0}, {0.13, 0.6, 0.0}, {0.7, 0.6, 0.17}, {0.7, 0.0, 0.17}, {0.53, 0.0, 0.75}, {0.7, 0.0, 0.17}, {0.13, 0.0, 0.0}, {-0.05, 0.0, 0.57}}; shortbox_shp.triangles = {{0, 1, 2}, {2, 3, 0}, {4, 5, 6}, {6, 7, 4}, {8, 9, 10}, {10, 11, 8}, {12, 13, 14}, {14, 15, 12}, {16, 17, 18}, {18, 19, 16}, {20, 21, 22}, {22, 23, 20}}; auto& tallbox_shp = scene.shapes.emplace_back(); tallbox_shp.uri = "tallbox"; tallbox_shp.positions = {{-0.53, 1.2, 0.09}, {0.04, 1.2, -0.09}, {-0.14, 1.2, -0.67}, {-0.71, 1.2, -0.49}, {-0.53, 0.0, 0.09}, {-0.53, 1.2, 0.09}, {-0.71, 1.2, -0.49}, {-0.71, 0.0, -0.49}, {-0.71, 0.0, -0.49}, {-0.71, 1.2, -0.49}, {-0.14, 1.2, -0.67}, {-0.14, 0.0, -0.67}, {-0.14, 0.0, -0.67}, {-0.14, 1.2, -0.67}, {0.04, 1.2, -0.09}, {0.04, 0.0, -0.09}, {0.04, 0.0, -0.09}, {0.04, 1.2, -0.09}, {-0.53, 1.2, 0.09}, {-0.53, 0.0, 0.09}, {-0.53, 0.0, 0.09}, {0.04, 0.0, -0.09}, {-0.14, 0.0, -0.67}, {-0.71, 0.0, -0.49}}; tallbox_shp.triangles = {{0, 1, 2}, {2, 3, 0}, {4, 5, 6}, {6, 7, 4}, {8, 9, 10}, {10, 11, 8}, {12, 13, 14}, {14, 15, 12}, {16, 17, 18}, {18, 19, 16}, {20, 21, 22}, {22, 23, 20}}; auto& light_shp = scene.shapes.emplace_back(); light_shp.uri = "light"; light_shp.positions = {{-0.25, 1.99, 0.25}, {-0.25, 1.99, -0.25}, {0.25, 1.99, -0.25}, {0.25, 1.99, 0.25}}; light_shp.triangles = {{0, 1, 2}, {2, 3, 0}}; scene.instances.push_back({"floor", identity3x4f, 0, 0}); scene.instances.push_back({"ceiling", identity3x4f, 1, 1}); scene.instances.push_back({"backwall", identity3x4f, 2, 2}); scene.instances.push_back({"rightwall", identity3x4f, 3, 3}); scene.instances.push_back({"leftwall", identity3x4f, 4, 4}); scene.instances.push_back({"shortbox", identity3x4f, 5, 5}); scene.instances.push_back({"tallbox", identity3x4f, 6, 6}); scene.instances.push_back({"light", identity3x4f, 7, 7}); } } // namespace yocto goxel-0.11.0/ext_src/yocto/yocto_sceneio.h000066400000000000000000000075661435762723100205560ustar00rootroot00000000000000// // # Yocto/SceneIO: Tiny library for Yocto/Scene input and output // // Yocto/SceneIO provides loading and saving functionality for scenes // in Yocto/GL. We support a simple to use YAML format, PLY, OBJ and glTF. // The YAML serialization is a straight copy of the in-memory scene data. // To speed up testing, we also support a binary format that is a dump of // the current scene. This format should not be use for archival though. // // Error reporting is done through exceptions using the `io_error` exception. // // ## Scene Loading and Saving // // 1. load a scene with `load_scene()` and save it with `save_scene()` // // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // #ifndef _YOCTO_SCENEIO_H_ #define _YOCTO_SCENEIO_H_ // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include #include "yocto_scene.h" // ----------------------------------------------------------------------------- // SCENE IO FUNCTIONS // ----------------------------------------------------------------------------- namespace yocto { // Scene load params struct load_params { bool notextures = false; bool facevarying = false; std::atomic* cancel = nullptr; bool noparallel = false; }; // Scene save params struct save_params { bool notextures = false; bool objinstances = false; std::atomic* cancel = nullptr; bool noparallel = false; }; // Load/save a scene in the supported formats. void load_scene( const string& filename, yocto_scene& scene, const load_params& params = {}); void save_scene(const string& filename, const yocto_scene& scene, const save_params& params = {}); // Load/save scene textures void load_texture(yocto_texture& texture, const string& dirname); void save_texture(const yocto_texture& texture, const string& dirname); void load_voltexture(yocto_voltexture& texture, const string& dirname); void save_voltexture(const yocto_voltexture& texture, const string& dirname); void load_textures( yocto_scene& scene, const string& dirname, const load_params& params); void save_textures( const yocto_scene& scene, const string& dirname, const save_params& params); // Load/save scene shapes void load_shape(yocto_shape& shape, const string& dirname); void save_shape(const yocto_shape& shape, const string& dirname); void load_subdiv(yocto_subdiv& subdiv, const string& dirname); void save_subdiv(const yocto_subdiv& subdiv, const string& dirname); void load_shapes( yocto_scene& scene, const string& dirname, const load_params& params); void save_shapes( const yocto_scene& scene, const string& dirname, const save_params& params); } // namespace yocto #endif goxel-0.11.0/ext_src/yocto/yocto_shape.cpp000066400000000000000000005404601435762723100205570ustar00rootroot00000000000000// // Implementation for Yocto/Shape // // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include "yocto_shape.h" #include "ext/happly.h" #include "yocto_obj.h" #include "yocto_random.h" #include #include "ext/filesystem.hpp" namespace fs = ghc::filesystem; // ----------------------------------------------------------------------------- // IMPLEMENTATION OF COMPUTATION OF PER_VERTEX PROPETIES // ----------------------------------------------------------------------------- namespace yocto { // Compute per-vertex tangents for lines. void compute_tangents(vector& tangents, const vector& lines, const vector& positions) { if (tangents.size() != positions.size()) { throw std::out_of_range("array should be the same length"); } for (auto& tangent : tangents) tangent = zero3f; for (auto& l : lines) { auto tangent = line_tangent(positions[l.x], positions[l.y]); auto length = line_length(positions[l.x], positions[l.y]); tangents[l.x] += tangent * length; tangents[l.y] += tangent * length; } for (auto& tangent : tangents) tangent = normalize(tangent); } // Compute per-vertex normals for triangles. void compute_normals(vector& normals, const vector& triangles, const vector& positions) { if (normals.size() != positions.size()) { throw std::out_of_range("array should be the same length"); } for (auto& normal : normals) normal = zero3f; for (auto& t : triangles) { auto normal = triangle_normal( positions[t.x], positions[t.y], positions[t.z]); auto area = triangle_area(positions[t.x], positions[t.y], positions[t.z]); normals[t.x] += normal * area; normals[t.y] += normal * area; normals[t.z] += normal * area; } for (auto& normal : normals) normal = normalize(normal); } // Compute per-vertex normals for quads. void compute_normals(vector& normals, const vector& quads, const vector& positions) { if (normals.size() != positions.size()) { throw std::out_of_range("array should be the same length"); } for (auto& normal : normals) normal = zero3f; for (auto& q : quads) { auto normal = quad_normal( positions[q.x], positions[q.y], positions[q.z], positions[q.w]); auto area = quad_area( positions[q.x], positions[q.y], positions[q.z], positions[q.w]); normals[q.x] += normal * area; normals[q.y] += normal * area; normals[q.z] += normal * area; if (q.z != q.w) normals[q.w] += normal * area; } for (auto& normal : normals) normal = normalize(normal); } // Shortcuts vector compute_tangents( const vector& lines, const vector& positions) { auto tangents = vector{positions.size()}; compute_tangents(tangents, lines, positions); return tangents; } vector compute_normals( const vector& triangles, const vector& positions) { auto normals = vector{positions.size()}; compute_normals(normals, triangles, positions); return normals; } vector compute_normals( const vector& quads, const vector& positions) { auto normals = vector{positions.size()}; compute_normals(normals, quads, positions); return normals; } // Compute per-vertex tangent frame for triangle meshes. // Tangent space is defined by a four component vector. // The first three components are the tangent with respect to the U texcoord. // The fourth component is the sign of the tangent wrt the V texcoord. // Tangent frame is useful in normal mapping. void compute_tangent_spaces(vector& tangent_spaces, const vector& triangles, const vector& positions, const vector& normals, const vector& texcoords) { auto tangu = vector(positions.size(), zero3f); auto tangv = vector(positions.size(), zero3f); for (auto t : triangles) { auto tutv = triangle_tangents_fromuv(positions[t.x], positions[t.y], positions[t.z], texcoords[t.x], texcoords[t.y], texcoords[t.z]); for (auto vid : {t.x, t.y, t.z}) tangu[vid] += normalize(tutv.first); for (auto vid : {t.x, t.y, t.z}) tangv[vid] += normalize(tutv.second); } for (auto& t : tangu) t = normalize(t); for (auto& t : tangv) t = normalize(t); for (auto& tangent : tangent_spaces) tangent = zero4f; for (auto i = 0; i < positions.size(); i++) { tangu[i] = orthonormalize(tangu[i], normals[i]); auto s = (dot(cross(normals[i], tangu[i]), tangv[i]) < 0) ? -1.0f : 1.0f; tangent_spaces[i] = {tangu[i].x, tangu[i].y, tangu[i].z, s}; } } vector compute_tangent_spaces(const vector& triangles, const vector& positions, const vector& normals, const vector& texcoords) { auto tangent_spaces = vector(positions.size()); compute_tangent_spaces( tangent_spaces, triangles, positions, normals, texcoords); return tangent_spaces; } // Apply skinning void compute_skinning(vector& skinned_positions, vector& skinned_normals, const vector& positions, const vector& normals, const vector& weights, const vector& joints, const vector& xforms) { if (skinned_positions.size() != positions.size() || skinned_normals.size() != normals.size()) { throw std::out_of_range("arrays should be the same size"); } for (auto i = 0; i < positions.size(); i++) { skinned_positions[i] = transform_point(xforms[joints[i].x], positions[i]) * weights[i].x + transform_point(xforms[joints[i].y], positions[i]) * weights[i].y + transform_point(xforms[joints[i].z], positions[i]) * weights[i].z + transform_point(xforms[joints[i].w], positions[i]) * weights[i].w; } for (auto i = 0; i < normals.size(); i++) { skinned_normals[i] = normalize( transform_direction(xforms[joints[i].x], normals[i]) * weights[i].x + transform_direction(xforms[joints[i].y], normals[i]) * weights[i].y + transform_direction(xforms[joints[i].z], normals[i]) * weights[i].z + transform_direction(xforms[joints[i].w], normals[i]) * weights[i].w); } } pair, vector> compute_skinning( const vector& positions, const vector& normals, const vector& weights, const vector& joints, const vector& xforms) { auto skinned = pair, vector>{ vector{positions.size()}, vector{normals.size()}}; compute_skinning(skinned.first, skinned.second, positions, normals, weights, joints, xforms); return skinned; } // Apply skinning as specified in Khronos glTF void compute_matrix_skinning(vector& skinned_positions, vector& skinned_normals, const vector& positions, const vector& normals, const vector& weights, const vector& joints, const vector& xforms) { if (skinned_positions.size() != positions.size() || skinned_normals.size() != normals.size()) { throw std::out_of_range("arrays should be the same size"); } for (auto i = 0; i < positions.size(); i++) { auto xform = xforms[joints[i].x] * weights[i].x + xforms[joints[i].y] * weights[i].y + xforms[joints[i].z] * weights[i].z + xforms[joints[i].w] * weights[i].w; skinned_positions[i] = transform_point(xform, positions[i]); skinned_normals[i] = normalize(transform_direction(xform, normals[i])); } } pair, vector> compute_matrix_skinning( const vector& positions, const vector& normals, const vector& weights, const vector& joints, const vector& xforms) { auto skinned = pair, vector>{ vector{positions.size()}, vector{normals.size()}}; compute_matrix_skinning(skinned.first, skinned.second, positions, normals, weights, joints, xforms); return skinned; } } // namespace yocto // ----------------------------------------------------------------------------- // COMPUTATION OF PER_VERTEX PROPETIES // ----------------------------------------------------------------------------- namespace yocto { // Flip vertex normals void flip_normals(vector& flipped, const vector& normals) { flipped = normals; for (auto& n : flipped) n = -n; } vector flip_normals(const vector& normals) { auto flipped = normals; for (auto& n : flipped) n = -n; return flipped; } // Flip face orientation void flip_triangles(vector& flipped, const vector& triangles) { flipped = triangles; for (auto& t : flipped) swap(t.y, t.z); } vector flip_triangles(const vector& triangles) { auto flipped = triangles; for (auto& t : flipped) swap(t.y, t.z); return flipped; } void flip_quads(vector& flipped, const vector& quads) { flipped = quads; for (auto& q : flipped) { if (q.z != q.w) { swap(q.y, q.w); } else { swap(q.y, q.z); q.w = q.z; } } } vector flip_quads(const vector& quads) { auto flipped = quads; for (auto& q : flipped) { if (q.z != q.w) { swap(q.y, q.w); } else { swap(q.y, q.z); q.w = q.z; } } return flipped; } // Align vertex positions. Alignment is 0: none, 1: min, 2: max, 3: center. void align_vertices(vector& aligned, const vector& positions, const vec3i& alignment) { auto bounds = invalidb3f; for (auto& p : positions) bounds = merge(bounds, p); auto offset = vec3f{0, 0, 0}; switch (alignment.x) { case 1: offset.x = bounds.min.x; break; case 2: offset.x = (bounds.min.x + bounds.max.x) / 2; break; case 3: offset.x = bounds.max.x; break; } switch (alignment.y) { case 1: offset.y = bounds.min.y; break; case 2: offset.y = (bounds.min.y + bounds.max.y) / 2; break; case 3: offset.y = bounds.max.y; break; } switch (alignment.z) { case 1: offset.z = bounds.min.z; break; case 2: offset.z = (bounds.min.z + bounds.max.z) / 2; break; case 3: offset.z = bounds.max.z; break; } aligned = positions; for (auto& p : aligned) p -= offset; } vector align_vertices( const vector& positions, const vec3i& alignment) { auto aligned = vector(positions.size()); align_vertices(aligned, positions, alignment); return aligned; } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION OF EDGE AND GRID DATA STRUCTURES // ----------------------------------------------------------------------------- namespace yocto { // Initialize an edge map with elements. edge_map make_edge_map(const vector& triangles) { auto emap = edge_map{}; for (auto& t : triangles) { insert_edge(emap, {t.x, t.y}); insert_edge(emap, {t.y, t.z}); insert_edge(emap, {t.z, t.x}); } return emap; } edge_map make_edge_map(const vector& quads) { auto emap = edge_map{}; for (auto& q : quads) { insert_edge(emap, {q.x, q.y}); insert_edge(emap, {q.y, q.z}); if (q.z != q.w) insert_edge(emap, {q.z, q.w}); insert_edge(emap, {q.w, q.x}); } return emap; } void insert_edges(edge_map& emap, const vector& triangles) { for (auto& t : triangles) { insert_edge(emap, {t.x, t.y}); insert_edge(emap, {t.y, t.z}); insert_edge(emap, {t.z, t.x}); } } void insert_edges(edge_map& emap, const vector& quads) { for (auto& q : quads) { insert_edge(emap, {q.x, q.y}); insert_edge(emap, {q.y, q.z}); if (q.z != q.w) insert_edge(emap, {q.z, q.w}); insert_edge(emap, {q.w, q.x}); } } // Insert an edge and return its index int insert_edge(edge_map& emap, const vec2i& edge) { auto es = edge.x < edge.y ? edge : vec2i{edge.y, edge.x}; auto it = emap.index.find(es); if (it == emap.index.end()) { auto idx = (int)emap.edges.size(); emap.index.insert(it, {es, idx}); emap.edges.push_back(es); emap.nfaces.push_back(1); return idx; } else { auto idx = it->second; emap.nfaces[idx] += 1; return idx; } } // Get number of edges int num_edges(const edge_map& emap) { return emap.edges.size(); } // Get the edge index int edge_index(const edge_map& emap, const vec2i& edge) { auto es = edge.x < edge.y ? edge : vec2i{edge.y, edge.x}; auto iterator = emap.index.find(es); if (iterator == emap.index.end()) return -1; return iterator->second; } // Get a list of edges, boundary edges, boundary vertices vector get_edges(const edge_map& emap) { return emap.edges; } vector get_boundary(const edge_map& emap) { auto boundary = vector{}; for (auto idx = 0; idx < emap.edges.size(); idx++) { if (emap.nfaces[idx] < 2) boundary.push_back(emap.edges[idx]); } return boundary; } void get_edges(const edge_map& emap, vector& edges) { edges = emap.edges; } void get_boundary(const edge_map& emap, vector& boundary) { boundary.clear(); for (auto idx = 0; idx < emap.edges.size(); idx++) { if (emap.nfaces[idx] < 2) boundary.push_back(emap.edges[idx]); } } vector get_edges(const vector& triangles) { return get_edges(make_edge_map(triangles)); } vector get_edges(const vector& quads) { return get_edges(make_edge_map(quads)); } // Gets the cell index vec3i get_cell_index(const hash_grid& grid, const vec3f& position) { auto scaledpos = position * grid.cell_inv_size; return vec3i{(int)scaledpos.x, (int)scaledpos.y, (int)scaledpos.z}; } // Create a hash_grid hash_grid make_hash_grid(float cell_size) { auto grid = hash_grid{}; grid.cell_size = cell_size; grid.cell_inv_size = 1 / cell_size; return grid; } hash_grid make_hash_grid(const vector& positions, float cell_size) { auto grid = hash_grid{}; grid.cell_size = cell_size; grid.cell_inv_size = 1 / cell_size; for (auto& position : positions) insert_vertex(grid, position); return grid; } // Inserts a point into the grid int insert_vertex(hash_grid& grid, const vec3f& position) { auto vertex_id = (int)grid.positions.size(); auto cell = get_cell_index(grid, position); grid.cells[cell].push_back(vertex_id); grid.positions.push_back(position); return vertex_id; } // Finds the nearest neighboors within a given radius void find_neightbors(const hash_grid& grid, vector& neighboors, const vec3f& position, float max_radius, int skip_id) { auto cell = get_cell_index(grid, position); auto cell_radius = (int)(max_radius * grid.cell_inv_size) + 1; neighboors.clear(); auto max_radius_squared = max_radius * max_radius; for (auto k = -cell_radius; k <= cell_radius; k++) { for (auto j = -cell_radius; j <= cell_radius; j++) { for (auto i = -cell_radius; i <= cell_radius; i++) { auto ncell = cell + vec3i{i, j, k}; auto cell_iterator = grid.cells.find(ncell); if (cell_iterator == grid.cells.end()) continue; auto& ncell_vertices = cell_iterator->second; for (auto vertex_id : ncell_vertices) { if (distance_squared(grid.positions[vertex_id], position) > max_radius_squared) continue; if (vertex_id == skip_id) continue; neighboors.push_back(vertex_id); } } } } } void find_neightbors(const hash_grid& grid, vector& neighboors, const vec3f& position, float max_radius) { find_neightbors(grid, neighboors, position, max_radius, -1); } void find_neightbors(const hash_grid& grid, vector& neighboors, int vertex, float max_radius) { find_neightbors(grid, neighboors, grid.positions[vertex], max_radius, vertex); } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION OF SHAPE ELEMENT CONVERSION AND GROUPING // ----------------------------------------------------------------------------- namespace yocto { // Convert quads to triangles vector quads_to_triangles(const vector& quads) { auto triangles = vector{}; triangles.reserve(quads.size() * 2); for (auto& q : quads) { triangles.push_back({q.x, q.y, q.w}); if (q.z != q.w) triangles.push_back({q.z, q.w, q.y}); } return triangles; } void quads_to_triangles(vector& triangles, const vector& quads) { triangles.clear(); triangles.reserve(quads.size() * 2); for (auto& q : quads) { triangles.push_back({q.x, q.y, q.w}); if (q.z != q.w) triangles.push_back({q.z, q.w, q.y}); } } // Convert triangles to quads by creating degenerate quads vector triangles_to_quads(const vector& triangles) { auto quads = vector{}; quads.reserve(triangles.size()); for (auto& t : triangles) quads.push_back({t.x, t.y, t.z, t.z}); return quads; } void triangles_to_quads(vector& quads, const vector& triangles) { quads.clear(); quads.reserve(triangles.size()); for (auto& t : triangles) quads.push_back({t.x, t.y, t.z, t.z}); } // Convert beziers to lines using 3 lines for each bezier. vector bezier_to_lines(const vector& beziers) { auto lines = vector{}; lines.reserve(beziers.size() * 3); for (auto b : beziers) { lines.push_back({b.x, b.y}); lines.push_back({b.y, b.z}); lines.push_back({b.z, b.w}); } return lines; } void bezier_to_lines(vector& lines, const vector& beziers) { lines.clear(); lines.reserve(beziers.size() * 3); for (auto b : beziers) { lines.push_back({b.x, b.y}); lines.push_back({b.y, b.z}); lines.push_back({b.z, b.w}); } } // Convert face varying data to single primitives. Returns the quads indices // and filled vectors for pos, norm and texcoord. void split_facevarying(vector& split_quads, vector& split_positions, vector& split_normals, vector& split_texcoords, const vector& quadspos, const vector& quadsnorm, const vector& quadstexcoord, const vector& positions, const vector& normals, const vector& texcoords) { // make faces unique unordered_map vert_map; split_quads.resize(quadspos.size()); for (auto fid = 0; fid < quadspos.size(); fid++) { for (auto c = 0; c < 4; c++) { auto v = vec3i{ (&quadspos[fid].x)[c], (!quadsnorm.empty()) ? (&quadsnorm[fid].x)[c] : -1, (!quadstexcoord.empty()) ? (&quadstexcoord[fid].x)[c] : -1, }; auto it = vert_map.find(v); if (it == vert_map.end()) { auto s = (int)vert_map.size(); vert_map.insert(it, {v, s}); (&split_quads[fid].x)[c] = s; } else { (&split_quads[fid].x)[c] = it->second; } } } // fill vert data split_positions.clear(); if (!positions.empty()) { split_positions.resize(vert_map.size()); for (auto& [vert, index] : vert_map) { split_positions[index] = positions[vert.x]; } } split_normals.clear(); if (!normals.empty()) { split_normals.resize(vert_map.size()); for (auto& [vert, index] : vert_map) { split_normals[index] = normals[vert.y]; } } split_texcoords.clear(); if (!texcoords.empty()) { split_texcoords.resize(vert_map.size()); for (auto& [vert, index] : vert_map) { split_texcoords[index] = texcoords[vert.z]; } } } // Split primitives per id template vector> ungroup_elems_impl( const vector& elems, const vector& ids) { auto max_id = *max_element(ids.begin(), ids.end()); auto split_elems = vector>(max_id + 1); for (auto elem_id = 0; elem_id < elems.size(); elem_id++) { split_elems[ids[elem_id]].push_back(elems[elem_id]); } return split_elems; } vector> ungroup_lines( const vector& lines, const vector& ids) { return ungroup_elems_impl(lines, ids); } vector> ungroup_triangles( const vector& triangles, const vector& ids) { return ungroup_elems_impl(triangles, ids); } vector> ungroup_quads( const vector& quads, const vector& ids) { return ungroup_elems_impl(quads, ids); } template void ungroup_elems_impl(vector>& split_elems, const vector& elems, const vector& ids) { auto max_id = *max_element(ids.begin(), ids.end()); split_elems.resize(max_id + 1); for (auto elem_id = 0; elem_id < elems.size(); elem_id++) { split_elems[ids[elem_id]].push_back(elems[elem_id]); } } void ungroup_lines(vector>& split_lines, const vector& lines, const vector& ids) { ungroup_elems_impl(split_lines, lines, ids); } void ungroup_triangles(vector>& split_triangles, const vector& triangles, const vector& ids) { ungroup_elems_impl(split_triangles, triangles, ids); } void ungroup_quads(vector>& split_quads, const vector& quads, const vector& ids) { ungroup_elems_impl(split_quads, quads, ids); } // Weld vertices within a threshold. pair, vector> weld_vertices( const vector& positions, float threshold) { auto indices = vector(positions.size()); auto welded = vector{}; auto grid = make_hash_grid(threshold); auto neighboors = vector{}; for (auto vertex = 0; vertex < positions.size(); vertex++) { auto& position = positions[vertex]; find_neightbors(grid, neighboors, position, threshold); if (neighboors.empty()) { welded.push_back(position); indices[vertex] = (int)welded.size() - 1; insert_vertex(grid, position); } else { indices[vertex] = neighboors.front(); } } return {welded, indices}; } pair, vector> weld_triangles( const vector& triangles, const vector& positions, float threshold) { auto [wpositions, indices] = weld_vertices(positions, threshold); auto wtriangles = triangles; for (auto& t : wtriangles) t = {indices[t.x], indices[t.y], indices[t.z]}; return {wtriangles, wpositions}; } pair, vector> weld_quads(const vector& quads, const vector& positions, float threshold) { auto [wpositions, indices] = weld_vertices(positions, threshold); auto wquads = quads; for (auto& q : wquads) q = { indices[q.x], indices[q.y], indices[q.z], indices[q.w], }; return {wquads, wpositions}; } void weld_vertices(vector& wpositions, vector& indices, const vector& positions, float threshold) { indices.resize(positions.size()); wpositions.clear(); auto grid = make_hash_grid(threshold); auto neighboors = vector{}; for (auto vertex = 0; vertex < positions.size(); vertex++) { auto& position = positions[vertex]; find_neightbors(grid, neighboors, position, threshold); if (neighboors.empty()) { wpositions.push_back(position); indices[vertex] = (int)wpositions.size() - 1; insert_vertex(grid, position); } else { indices[vertex] = neighboors.front(); } } } void weld_triangles_inplace(vector& wtriangles, vector& wpositions, const vector& triangles, const vector& positions, float threshold) { auto indices = vector{}; weld_vertices(wpositions, indices, positions, threshold); wtriangles = triangles; for (auto& t : wtriangles) t = {indices[t.x], indices[t.y], indices[t.z]}; } void weld_quads_inplace(vector& wquads, vector& wpositions, const vector& quads, const vector& positions, float threshold) { auto indices = vector{}; weld_vertices(wpositions, indices, positions, threshold); wquads = quads; for (auto& q : wquads) q = { indices[q.x], indices[q.y], indices[q.z], indices[q.w], }; } // Merge shape elements void merge_lines( vector& lines, const vector& merge_lines, int num_verts) { for (auto& l : merge_lines) lines.push_back({l.x + num_verts, l.y + num_verts}); } void merge_triangles(vector& triangles, const vector& merge_triangles, int num_verts) { for (auto& t : merge_triangles) triangles.push_back({t.x + num_verts, t.y + num_verts, t.z + num_verts}); } void merge_quads( vector& quads, const vector& merge_quads, int num_verts) { for (auto& q : merge_quads) quads.push_back( {q.x + num_verts, q.y + num_verts, q.z + num_verts, q.w + num_verts}); } void merge_lines(vector& lines, vector& positions, vector& tangents, vector& texcoords, vector& radius, const vector& merge_lines, const vector& merge_positions, const vector& merge_tangents, const vector& merge_texturecoords, const vector& merge_radius) { auto merge_verts = (int)positions.size(); for (auto& l : merge_lines) lines.push_back({l.x + merge_verts, l.y + merge_verts}); positions.insert( positions.end(), merge_positions.begin(), merge_positions.end()); tangents.insert(tangents.end(), merge_tangents.begin(), merge_tangents.end()); texcoords.insert( texcoords.end(), merge_texturecoords.begin(), merge_texturecoords.end()); radius.insert(radius.end(), merge_radius.begin(), merge_radius.end()); } void merge_triangles(vector& triangles, vector& positions, vector& normals, vector& texcoords, const vector& merge_triangles, const vector& merge_positions, const vector& merge_normals, const vector& merge_texturecoords) { auto merge_verts = (int)positions.size(); for (auto& t : merge_triangles) triangles.push_back( {t.x + merge_verts, t.y + merge_verts, t.z + merge_verts}); positions.insert( positions.end(), merge_positions.begin(), merge_positions.end()); normals.insert(normals.end(), merge_normals.begin(), merge_normals.end()); texcoords.insert( texcoords.end(), merge_texturecoords.begin(), merge_texturecoords.end()); } void merge_quads(vector& quads, vector& positions, vector& normals, vector& texcoords, const vector& merge_quads, const vector& merge_positions, const vector& merge_normals, const vector& merge_texturecoords) { auto merge_verts = (int)positions.size(); for (auto& q : merge_quads) quads.push_back({q.x + merge_verts, q.y + merge_verts, q.z + merge_verts, q.w + merge_verts}); positions.insert( positions.end(), merge_positions.begin(), merge_positions.end()); normals.insert(normals.end(), merge_normals.begin(), merge_normals.end()); texcoords.insert( texcoords.end(), merge_texturecoords.begin(), merge_texturecoords.end()); } void merge_triangles_and_quads( vector& triangles, vector& quads, bool force_triangles) { if (quads.empty()) return; if (force_triangles) { auto qtriangles = quads_to_triangles(quads); triangles.insert(triangles.end(), qtriangles.begin(), qtriangles.end()); quads = {}; } else { auto tquads = triangles_to_quads(triangles); quads.insert(quads.end(), tquads.begin(), tquads.end()); triangles = {}; } } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION OF SHAPE SUBDIVISION // ----------------------------------------------------------------------------- namespace yocto { // Subdivide lines. template void subdivide_lines_impl(vector& lines, vector& vert, const vector& lines_, const vector& vert_, int level) { // initialization lines = lines_; vert = vert_; // early exit if (lines.empty() || vert.empty()) return; // loop over levels for (auto l = 0; l < level; l++) { // sizes auto nverts = (int)vert.size(); auto nlines = (int)lines.size(); // create vertices auto tvert = vector(nverts + nlines); for (auto i = 0; i < nverts; i++) tvert[i] = vert[i]; for (auto i = 0; i < nlines; i++) { auto l = lines[i]; tvert[nverts + i] = (vert[l.x] + vert[l.y]) / 2; } // create lines auto tlines = vector(nlines * 2); for (auto i = 0; i < nlines; i++) { auto l = lines[i]; tlines[i * 2 + 0] = {l.x, nverts + i}; tlines[i * 2 + 0] = {nverts + i, l.y}; } swap(tlines, lines); swap(tvert, vert); } } template pair, vector> subdivide_lines_impl( const vector& lines, const vector& vert, int level) { auto tess = pair, vector>{}; subdivide_lines_impl(tess.first, tess.second, lines, vert, level); return tess; } // Subdivide triangle. template void subdivide_triangles_impl(vector& triangles, vector& vert, const vector& triangles_, const vector& vert_, int level) { // initialization triangles = triangles_; vert = vert_; // early exit if (triangles.empty() || vert.empty()) return; // loop over levels for (auto l = 0; l < level; l++) { // get edges auto emap = make_edge_map(triangles); auto edges = get_edges(emap); // number of elements auto nverts = (int)vert.size(); auto nedges = (int)edges.size(); auto nfaces = (int)triangles.size(); // create vertices auto tvert = vector(nverts + nedges); for (auto i = 0; i < nverts; i++) tvert[i] = vert[i]; for (auto i = 0; i < nedges; i++) { auto e = edges[i]; tvert[nverts + i] = (vert[e.x] + vert[e.y]) / 2; } // create triangles auto ttriangles = vector(nfaces * 4); for (auto i = 0; i < nfaces; i++) { auto t = triangles[i]; ttriangles[i * 4 + 0] = {t.x, nverts + edge_index(emap, {t.x, t.y}), nverts + edge_index(emap, {t.z, t.x})}; ttriangles[i * 4 + 1] = {t.y, nverts + edge_index(emap, {t.y, t.z}), nverts + edge_index(emap, {t.x, t.y})}; ttriangles[i * 4 + 2] = {t.z, nverts + edge_index(emap, {t.z, t.x}), nverts + edge_index(emap, {t.y, t.z})}; ttriangles[i * 4 + 3] = {nverts + edge_index(emap, {t.x, t.y}), nverts + edge_index(emap, {t.y, t.z}), nverts + edge_index(emap, {t.z, t.x})}; } swap(ttriangles, triangles); swap(tvert, vert); } } template pair, vector> subdivide_triangles_impl( const vector& triangles, const vector& vert, int level) { auto tess = pair, vector>{}; subdivide_triangles_impl(tess.first, tess.second, triangles, vert, level); return tess; } // Subdivide quads. template void subdivide_quads_impl(vector& quads, vector& vert, const vector& quads_, const vector& vert_, int level) { // initialization quads = quads_; vert = vert_; // early exit if (quads.empty() || vert.empty()) return; // loop over levels for (auto l = 0; l < level; l++) { // get edges auto emap = make_edge_map(quads); auto edges = get_edges(emap); // number of elements auto nverts = (int)vert.size(); auto nedges = (int)edges.size(); auto nfaces = (int)quads.size(); // create vertices auto tvert = vector(nverts + nedges + nfaces); for (auto i = 0; i < nverts; i++) tvert[i] = vert[i]; for (auto i = 0; i < nedges; i++) { auto e = edges[i]; tvert[nverts + i] = (vert[e.x] + vert[e.y]) / 2; } for (auto i = 0; i < nfaces; i++) { auto q = quads[i]; if (q.z != q.w) { tvert[nverts + nedges + i] = (vert[q.x] + vert[q.y] + vert[q.z] + vert[q.w]) / 4; } else { tvert[nverts + nedges + i] = (vert[q.x] + vert[q.y] + vert[q.y]) / 3; } } // create quads auto tquads = vector(nfaces * 4); // conservative allocation auto qi = 0; for (auto i = 0; i < nfaces; i++) { auto q = quads[i]; if (q.z != q.w) { tquads[qi++] = {q.x, nverts + edge_index(emap, {q.x, q.y}), nverts + nedges + i, nverts + edge_index(emap, {q.w, q.x})}; tquads[qi++] = {q.y, nverts + edge_index(emap, {q.y, q.z}), nverts + nedges + i, nverts + edge_index(emap, {q.x, q.y})}; tquads[qi++] = {q.z, nverts + edge_index(emap, {q.z, q.w}), nverts + nedges + i, nverts + edge_index(emap, {q.y, q.z})}; tquads[qi++] = {q.w, nverts + edge_index(emap, {q.w, q.x}), nverts + nedges + i, nverts + edge_index(emap, {q.z, q.w})}; } else { tquads[qi++] = {q.x, nverts + edge_index(emap, {q.x, q.y}), nverts + nedges + i, nverts + edge_index(emap, {q.z, q.x})}; tquads[qi++] = {q.y, nverts + edge_index(emap, {q.y, q.z}), nverts + nedges + i, nverts + edge_index(emap, {q.x, q.y})}; tquads[qi++] = {q.z, nverts + edge_index(emap, {q.z, q.x}), nverts + nedges + i, nverts + edge_index(emap, {q.y, q.z})}; } } tquads.resize(qi); // done swap(tquads, quads); swap(tvert, vert); } } template pair, vector> subdivide_quads_impl( const vector& quads, const vector& vert, int level) { auto tess = pair, vector>{}; subdivide_quads_impl(tess.first, tess.second, quads, vert, level); return tess; } // Subdivide beziers. template void subdivide_beziers_impl(vector& beziers, vector& vert, const vector& beziers_, const vector& vert_, int level) { // initialization beziers = beziers_; vert = vert_; // early exit if (beziers.empty() || vert.empty()) return; // loop over levels for (auto l = 0; l < level; l++) { // get edges auto vmap = unordered_map(); auto tvert = vector(); auto tbeziers = vector(); for (auto b : beziers) { if (vmap.find(b.x) == vmap.end()) { vmap[b.x] = (int)tvert.size(); tvert.push_back(vert[b.x]); } if (vmap.find(b.w) == vmap.end()) { vmap[b.w] = (int)tvert.size(); tvert.push_back(vert[b.w]); } auto bo = (int)tvert.size(); tbeziers.push_back({vmap.at(b.x), bo + 0, bo + 1, bo + 2}); tbeziers.push_back({bo + 2, bo + 3, bo + 4, vmap.at(b.w)}); tvert.push_back(vert[b.x] / 2 + vert[b.y] / 2); tvert.push_back(vert[b.x] / 4 + vert[b.y] / 2 + vert[b.z] / 4); tvert.push_back(vert[b.x] / 8 + vert[b.y] * ((float)3 / (float)8) + vert[b.z] * ((float)3 / (float)8) + vert[b.w] / 8); tvert.push_back(vert[b.y] / 4 + vert[b.z] / 2 + vert[b.w] / 4); tvert.push_back(vert[b.z] / 2 + vert[b.w] / 2); } // done swap(tbeziers, beziers); swap(tvert, vert); } } template pair, vector> subdivide_beziers_impl( const vector& beziers, const vector& vert, int level) { auto tess = pair, vector>{}; subdivide_beziers_impl(tess.first, tess.second, beziers, vert, level); return tess; } // Subdivide catmullclark. template void subdivide_catmullclark_impl(vector& quads, vector& vert, const vector& quads_, const vector& vert_, int level, bool lock_boundary) { // initialization quads = quads_; vert = vert_; // early exit if (quads.empty() || vert.empty()) return; // loop over levels for (auto l = 0; l < level; l++) { // get edges auto emap = make_edge_map(quads); auto edges = get_edges(emap); auto boundary = get_boundary(emap); // number of elements auto nverts = (int)vert.size(); auto nedges = (int)edges.size(); auto nboundary = (int)boundary.size(); auto nfaces = (int)quads.size(); // split elements ------------------------------------ // create vertices auto tvert = vector(nverts + nedges + nfaces); for (auto i = 0; i < nverts; i++) tvert[i] = vert[i]; for (auto i = 0; i < nedges; i++) { auto e = edges[i]; tvert[nverts + i] = (vert[e.x] + vert[e.y]) / 2; } for (auto i = 0; i < nfaces; i++) { auto q = quads[i]; if (q.z != q.w) { tvert[nverts + nedges + i] = (vert[q.x] + vert[q.y] + vert[q.z] + vert[q.w]) / 4; } else { tvert[nverts + nedges + i] = (vert[q.x] + vert[q.y] + vert[q.y]) / 3; } } // create quads auto tquads = vector(nfaces * 4); // conservative allocation auto qi = 0; for (auto i = 0; i < nfaces; i++) { auto q = quads[i]; if (q.z != q.w) { tquads[qi++] = {q.x, nverts + edge_index(emap, {q.x, q.y}), nverts + nedges + i, nverts + edge_index(emap, {q.w, q.x})}; tquads[qi++] = {q.y, nverts + edge_index(emap, {q.y, q.z}), nverts + nedges + i, nverts + edge_index(emap, {q.x, q.y})}; tquads[qi++] = {q.z, nverts + edge_index(emap, {q.z, q.w}), nverts + nedges + i, nverts + edge_index(emap, {q.y, q.z})}; tquads[qi++] = {q.w, nverts + edge_index(emap, {q.w, q.x}), nverts + nedges + i, nverts + edge_index(emap, {q.z, q.w})}; } else { tquads[qi++] = {q.x, nverts + edge_index(emap, {q.x, q.y}), nverts + nedges + i, nverts + edge_index(emap, {q.z, q.x})}; tquads[qi++] = {q.y, nverts + edge_index(emap, {q.y, q.z}), nverts + nedges + i, nverts + edge_index(emap, {q.x, q.y})}; tquads[qi++] = {q.z, nverts + edge_index(emap, {q.z, q.x}), nverts + nedges + i, nverts + edge_index(emap, {q.y, q.z})}; } } tquads.resize(qi); // split boundary auto tboundary = vector(nboundary * 2); for (auto i = 0; i < nboundary; i++) { auto e = boundary[i]; tboundary.push_back({e.x, nverts + edge_index(emap, e)}); tboundary.push_back({nverts + edge_index(emap, e), e.y}); } // setup creases ----------------------------------- auto tcrease_edges = vector(); auto tcrease_verts = vector(); if (lock_boundary) { for (auto& b : tboundary) { tcrease_verts.push_back(b.x); tcrease_verts.push_back(b.y); } } else { for (auto& b : tboundary) tcrease_edges.push_back(b); } // define vertex valence --------------------------- auto tvert_val = vector(tvert.size(), 2); for (auto& e : tboundary) { tvert_val[e.x] = (lock_boundary) ? 0 : 1; tvert_val[e.y] = (lock_boundary) ? 0 : 1; } // averaging pass ---------------------------------- auto avert = vector(tvert.size(), T()); auto acount = vector(tvert.size(), 0); for (auto p : tcrease_verts) { if (tvert_val[p] != 0) continue; avert[p] += tvert[p]; acount[p] += 1; } for (auto& e : tcrease_edges) { auto c = (tvert[e.x] + tvert[e.y]) / 2; for (auto vid : {e.x, e.y}) { if (tvert_val[vid] != 1) continue; avert[vid] += c; acount[vid] += 1; } } for (auto& q : tquads) { auto c = (tvert[q.x] + tvert[q.y] + tvert[q.z] + tvert[q.w]) / 4; for (auto vid : {q.x, q.y, q.z, q.w}) { if (tvert_val[vid] != 2) continue; avert[vid] += c; acount[vid] += 1; } } for (auto i = 0; i < tvert.size(); i++) avert[i] /= (float)acount[i]; // correction pass ---------------------------------- // p = p + (avg_p - p) * (4/avg_count) for (auto i = 0; i < tvert.size(); i++) { if (tvert_val[i] != 2) continue; avert[i] = tvert[i] + (avert[i] - tvert[i]) * (4 / (float)acount[i]); } tvert = avert; // done swap(tquads, quads); swap(tvert, vert); } } template pair, vector> subdivide_catmullclark_impl( const vector& quads, const vector& vert, int level, bool lock_boundary) { auto tess = pair, vector>{}; subdivide_catmullclark_impl( tess.first, tess.second, quads, vert, level, lock_boundary); return tess; } template void subdivide_elems_impl(vector& selems, vector& spositions, vector& snormals, vector& stexcoords, vector& scolors, vector& sradius, const vector& elems, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, int level, const SubdivideFunc&& subdivide_func) { struct vertex { vec3f position = zero3f; vec3f normal = zero3f; vec2f texcoord = zero2f; vec4f color = zero4f; float radius = 0; vertex& operator+=(const vertex& a) { return *this = *this + a; }; vertex& operator/=(float s) { return *this = *this / s; }; vertex operator+(const vertex& a) const { return {position + a.position, normal + a.normal, texcoord + a.texcoord, color + a.color, radius + a.radius}; }; vertex operator-(const vertex& a) const { return {position - a.position, normal - a.normal, texcoord - a.texcoord, color - a.color, radius - a.radius}; }; vertex operator*(float s) const { return {position * s, normal * s, texcoord * s, color * s, radius * s}; }; vertex operator/(float s) const { return operator*(1 / s); }; }; auto vertices = vector(positions.size()); if (!positions.empty()) { for (auto i = 0; i < vertices.size(); i++) vertices[i].position = positions[i]; } if (!normals.empty()) { for (auto i = 0; i < vertices.size(); i++) vertices[i].normal = normals[i]; } if (!texcoords.empty()) { for (auto i = 0; i < vertices.size(); i++) vertices[i].texcoord = texcoords[i]; } if (!colors.empty()) { for (auto i = 0; i < vertices.size(); i++) vertices[i].color = colors[i]; } if (!radius.empty()) { for (auto i = 0; i < vertices.size(); i++) vertices[i].radius = radius[i]; } subdivide_func(selems, vertices, elems, vertices, level); if (!positions.empty()) { spositions.resize(vertices.size()); for (auto i = 0; i < vertices.size(); i++) spositions[i] = vertices[i].position; } if (!normals.empty()) { snormals.resize(vertices.size()); for (auto i = 0; i < vertices.size(); i++) snormals[i] = vertices[i].normal; } if (!texcoords.empty()) { stexcoords.resize(vertices.size()); for (auto i = 0; i < vertices.size(); i++) stexcoords[i] = vertices[i].texcoord; } if (!colors.empty()) { scolors.resize(vertices.size()); for (auto i = 0; i < vertices.size(); i++) scolors[i] = vertices[i].color; } if (!radius.empty()) { sradius.resize(vertices.size()); for (auto i = 0; i < vertices.size(); i++) sradius[i] = vertices[i].radius; } } pair, vector> subdivide_lines( const vector& lines, const vector& vert, int level) { return subdivide_lines_impl(lines, vert, level); } pair, vector> subdivide_lines( const vector& lines, const vector& vert, int level) { return subdivide_lines_impl(lines, vert, level); } pair, vector> subdivide_lines( const vector& lines, const vector& vert, int level) { return subdivide_lines_impl(lines, vert, level); } pair, vector> subdivide_lines( const vector& lines, const vector& vert, int level) { return subdivide_lines_impl(lines, vert, level); } void subdivide_lines(vector& slines, vector& svert, const vector& lines, const vector& vert, int level) { subdivide_lines_impl(slines, svert, lines, vert, level); } void subdivide_lines(vector& slines, vector& svert, const vector& lines, const vector& vert, int level) { subdivide_lines_impl(slines, svert, lines, vert, level); } void subdivide_lines(vector& slines, vector& svert, const vector& lines, const vector& vert, int level) { subdivide_lines_impl(slines, svert, lines, vert, level); } void subdivide_lines(vector& slines, vector& svert, const vector& lines, const vector& vert, int level) { subdivide_lines_impl(slines, svert, lines, vert, level); } void subdivide_lines(vector& slines, vector& spositions, vector& snormals, vector& stexcoords, vector& scolors, vector& sradius, const vector& lines, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, int level) { subdivide_elems_impl(slines, spositions, snormals, stexcoords, scolors, sradius, lines, positions, normals, texcoords, colors, radius, level, [](auto& slines, auto& svert, auto& lines, auto& vert, int level) { subdivide_lines_impl(slines, svert, lines, vert, level); }); } pair, vector> subdivide_triangles( const vector& triangles, const vector& vert, int level) { return subdivide_triangles_impl(triangles, vert, level); } pair, vector> subdivide_triangles( const vector& triangles, const vector& vert, int level) { return subdivide_triangles_impl(triangles, vert, level); } pair, vector> subdivide_triangles( const vector& triangles, const vector& vert, int level) { return subdivide_triangles_impl(triangles, vert, level); } pair, vector> subdivide_triangles( const vector& triangles, const vector& vert, int level) { return subdivide_triangles_impl(triangles, vert, level); } void subdivide_triangles(vector& striangles, vector& svert, const vector& triangles, const vector& vert, int level) { subdivide_triangles_impl(striangles, svert, triangles, vert, level); } void subdivide_triangles(vector& striangles, vector& svert, const vector& triangles, const vector& vert, int level) { subdivide_triangles_impl(striangles, svert, triangles, vert, level); } void subdivide_triangles(vector& striangles, vector& svert, const vector& triangles, const vector& vert, int level) { subdivide_triangles_impl(striangles, svert, triangles, vert, level); } void subdivide_triangles(vector& striangles, vector& svert, const vector& triangles, const vector& vert, int level) { subdivide_triangles_impl(striangles, svert, triangles, vert, level); } void subdivide_triangles(vector& striangles, vector& spositions, vector& snormals, vector& stexcoords, vector& scolors, vector& sradius, const vector& triangles, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, int level) { subdivide_elems_impl(striangles, spositions, snormals, stexcoords, scolors, sradius, triangles, positions, normals, texcoords, colors, radius, level, [](auto& striangles, auto& svert, auto& triangles, auto& vert, int level) { subdivide_triangles_impl(striangles, svert, triangles, vert, level); }); } pair, vector> subdivide_quads( const vector& quads, const vector& vert, int level) { return subdivide_quads_impl(quads, vert, level); } pair, vector> subdivide_quads( const vector& quads, const vector& vert, int level) { return subdivide_quads_impl(quads, vert, level); } pair, vector> subdivide_quads( const vector& quads, const vector& vert, int level) { return subdivide_quads_impl(quads, vert, level); } pair, vector> subdivide_quads( const vector& quads, const vector& vert, int level) { return subdivide_quads_impl(quads, vert, level); } void subdivide_quads(vector& squads, vector& svert, const vector& quads, const vector& vert, int level) { subdivide_quads_impl(squads, svert, quads, vert, level); } void subdivide_quads(vector& squads, vector& svert, const vector& quads, const vector& vert, int level) { subdivide_quads_impl(squads, svert, quads, vert, level); } void subdivide_quads(vector& squads, vector& svert, const vector& quads, const vector& vert, int level) { subdivide_quads_impl(squads, svert, quads, vert, level); } void subdivide_quads(vector& squads, vector& svert, const vector& quads, const vector& vert, int level) { subdivide_quads_impl(squads, svert, quads, vert, level); } void subdivide_quads(vector& squads, vector& spositions, vector& snormals, vector& stexcoords, vector& scolors, vector& sradius, const vector& quads, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, int level) { subdivide_elems_impl(squads, spositions, snormals, stexcoords, scolors, sradius, quads, positions, normals, texcoords, colors, radius, level, [](auto& squads, auto& svert, auto& quads, auto& vert, int level) { subdivide_quads_impl(squads, svert, quads, vert, level); }); } pair, vector> subdivide_beziers( const vector& beziers, const vector& vert, int level) { return subdivide_beziers_impl(beziers, vert, level); } pair, vector> subdivide_beziers( const vector& beziers, const vector& vert, int level) { return subdivide_beziers_impl(beziers, vert, level); } pair, vector> subdivide_beziers( const vector& beziers, const vector& vert, int level) { return subdivide_beziers_impl(beziers, vert, level); } pair, vector> subdivide_beziers( const vector& beziers, const vector& vert, int level) { return subdivide_beziers_impl(beziers, vert, level); } void subdivide_beziers(vector& sbeziers, vector& svert, const vector& beziers, const vector& vert, int level) { subdivide_beziers_impl(sbeziers, svert, beziers, vert, level); } void subdivide_beziers(vector& sbeziers, vector& svert, const vector& beziers, const vector& vert, int level) { subdivide_beziers_impl(sbeziers, svert, beziers, vert, level); } void subdivide_beziers(vector& sbeziers, vector& svert, const vector& beziers, const vector& vert, int level) { subdivide_beziers_impl(sbeziers, svert, beziers, vert, level); } void subdivide_beziers(vector& sbeziers, vector& svert, const vector& beziers, const vector& vert, int level) { subdivide_beziers_impl(sbeziers, svert, beziers, vert, level); } void subdivide_beziers(vector& sbeziers, vector& spositions, vector& snormals, vector& stexcoords, vector& scolors, vector& sradius, const vector& beziers, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, int level) { subdivide_elems_impl(sbeziers, spositions, snormals, stexcoords, scolors, sradius, beziers, positions, normals, texcoords, colors, radius, level, [](auto& sbeziers, auto& svert, auto& beziers, auto& vert, int level) { subdivide_beziers_impl(sbeziers, svert, beziers, vert, level); }); } pair, vector> subdivide_catmullclark( const vector& quads, const vector& vert, int level, bool lock_boundary) { return subdivide_catmullclark_impl(quads, vert, level, lock_boundary); } pair, vector> subdivide_catmullclark( const vector& quads, const vector& vert, int level, bool lock_boundary) { return subdivide_catmullclark_impl(quads, vert, level, lock_boundary); } pair, vector> subdivide_catmullclark( const vector& quads, const vector& vert, int level, bool lock_boundary) { return subdivide_catmullclark_impl(quads, vert, level, lock_boundary); } pair, vector> subdivide_catmullclark( const vector& quads, const vector& vert, int level, bool lock_boundary) { return subdivide_catmullclark_impl(quads, vert, level, lock_boundary); } void subdivide_catmullclark(vector& squads, vector& svert, const vector& quads, const vector& vert, int level, bool lock_boundary) { subdivide_catmullclark_impl(squads, svert, quads, vert, level, lock_boundary); } void subdivide_catmullclark(vector& squads, vector& svert, const vector& quads, const vector& vert, int level, bool lock_boundary) { subdivide_catmullclark_impl(squads, svert, quads, vert, level, lock_boundary); } void subdivide_catmullclark(vector& squads, vector& svert, const vector& quads, const vector& vert, int level, bool lock_boundary) { subdivide_catmullclark_impl(squads, svert, quads, vert, level, lock_boundary); } void subdivide_catmullclark(vector& squads, vector& svert, const vector& quads, const vector& vert, int level, bool lock_boundary) { subdivide_catmullclark_impl(squads, svert, quads, vert, level, lock_boundary); } void subdivide_catmullclark(vector& squads, vector& spositions, vector& snormals, vector& stexcoords, vector& scolors, vector& sradius, const vector& quads, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, int level) { subdivide_elems_impl(squads, spositions, snormals, stexcoords, scolors, sradius, quads, positions, normals, texcoords, colors, radius, level, [](auto& squads, auto& svert, auto& quads, auto& vert, int level) { subdivide_catmullclark_impl(squads, svert, quads, vert, level, true); }); } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION OF SHAPE SAMPLING // ----------------------------------------------------------------------------- namespace yocto { // Pick a point in a point set uniformly. int sample_points(int npoints, float re) { return sample_uniform(npoints, re); } int sample_points(const vector& cdf, float re) { return sample_discrete(cdf, re); } vector sample_points_cdf(int npoints) { auto cdf = vector(npoints); for (auto i = 0; i < cdf.size(); i++) cdf[i] = 1 + (i ? cdf[i - 1] : 0); return cdf; } void sample_points_cdf(vector& cdf, int npoints) { cdf.resize(npoints); for (auto i = 0; i < cdf.size(); i++) cdf[i] = 1 + (i ? cdf[i - 1] : 0); } // Pick a point on lines uniformly. pair sample_lines(const vector& cdf, float re, float ru) { return {sample_discrete(cdf, re), ru}; } vector sample_lines_cdf( const vector& lines, const vector& positions) { auto cdf = vector(lines.size()); for (auto i = 0; i < cdf.size(); i++) { auto l = lines[i]; auto w = line_length(positions[l.x], positions[l.y]); cdf[i] = w + (i ? cdf[i - 1] : 0); } return cdf; } void sample_lines_cdf(vector& cdf, const vector& lines, const vector& positions) { cdf.resize(lines.size()); for (auto i = 0; i < cdf.size(); i++) { auto l = lines[i]; auto w = line_length(positions[l.x], positions[l.y]); cdf[i] = w + (i ? cdf[i - 1] : 0); } } // Pick a point on a triangle mesh uniformly. pair sample_triangles( const vector& cdf, float re, const vec2f& ruv) { return {sample_discrete(cdf, re), sample_triangle(ruv)}; } vector sample_triangles_cdf( const vector& triangles, const vector& positions) { auto cdf = vector(triangles.size()); for (auto i = 0; i < cdf.size(); i++) { auto t = triangles[i]; auto w = triangle_area(positions[t.x], positions[t.y], positions[t.z]); cdf[i] = w + (i ? cdf[i - 1] : 0); } return cdf; } void sample_triangles_cdf(vector& cdf, const vector& triangles, const vector& positions) { cdf.resize(triangles.size()); for (auto i = 0; i < cdf.size(); i++) { auto t = triangles[i]; auto w = triangle_area(positions[t.x], positions[t.y], positions[t.z]); cdf[i] = w + (i ? cdf[i - 1] : 0); } } // Pick a point on a quad mesh uniformly. pair sample_quads( const vector& cdf, float re, const vec2f& ruv) { return {sample_discrete(cdf, re), ruv}; } pair sample_quads(const vector& quads, const vector& cdf, float re, const vec2f& ruv) { auto element = sample_discrete(cdf, re); if (quads[element].z == quads[element].w) { return {element, sample_triangle(ruv)}; } else { return {element, ruv}; } } vector sample_quads_cdf( const vector& quads, const vector& positions) { auto cdf = vector(quads.size()); for (auto i = 0; i < cdf.size(); i++) { auto q = quads[i]; auto w = quad_area( positions[q.x], positions[q.y], positions[q.z], positions[q.w]); cdf[i] = w + (i ? cdf[i - 1] : 0); } return cdf; } void sample_quads_cdf(vector& cdf, const vector& quads, const vector& positions) { cdf.resize(quads.size()); for (auto i = 0; i < cdf.size(); i++) { auto q = quads[i]; auto w = quad_area( positions[q.x], positions[q.y], positions[q.z], positions[q.w]); cdf[i] = w + (i ? cdf[i - 1] : 0); } } // Samples a set of points over a triangle mesh uniformly. The rng function // takes the point index and returns vec3f numbers uniform directibuted in // [0,1]^3. unorm and texcoord are optional. void sample_triangles(vector& sampled_positions, vector& sampled_normals, vector& sampled_texturecoords, const vector& triangles, const vector& positions, const vector& normals, const vector& texcoords, int npoints, int seed) { sampled_positions.resize(npoints); sampled_normals.resize(npoints); sampled_texturecoords.resize(npoints); auto cdf = vector{}; sample_triangles_cdf(cdf, triangles, positions); auto rng = make_rng(seed); for (auto i = 0; i < npoints; i++) { auto sample = sample_triangles(cdf, rand1f(rng), rand2f(rng)); auto& t = triangles[sample.first]; auto uv = sample.second; sampled_positions[i] = interpolate_triangle( positions[t.x], positions[t.y], positions[t.z], uv); if (!sampled_normals.empty()) { sampled_normals[i] = normalize( interpolate_triangle(normals[t.x], normals[t.y], normals[t.z], uv)); } else { sampled_normals[i] = triangle_normal( positions[t.x], positions[t.y], positions[t.z]); } if (!sampled_texturecoords.empty()) { sampled_texturecoords[i] = interpolate_triangle( texcoords[t.x], texcoords[t.y], texcoords[t.z], uv); } else { sampled_texturecoords[i] = zero2f; } } } // Samples a set of points over a triangle mesh uniformly. The rng function // takes the point index and returns vec3f numbers uniform directibuted in // [0,1]^3. unorm and texcoord are optional. void sample_quads(vector& sampled_positions, vector& sampled_normals, vector& sampled_texturecoords, const vector& quads, const vector& positions, const vector& normals, const vector& texcoords, int npoints, int seed) { sampled_positions.resize(npoints); sampled_normals.resize(npoints); sampled_texturecoords.resize(npoints); auto cdf = vector{}; sample_quads_cdf(cdf, quads, positions); auto rng = make_rng(seed); for (auto i = 0; i < npoints; i++) { auto sample = sample_quads(cdf, rand1f(rng), rand2f(rng)); auto& q = quads[sample.first]; auto uv = sample.second; sampled_positions[i] = interpolate_quad( positions[q.x], positions[q.y], positions[q.z], positions[q.w], uv); if (!sampled_normals.empty()) { sampled_normals[i] = normalize(interpolate_quad( normals[q.x], normals[q.y], normals[q.z], normals[q.w], uv)); } else { sampled_normals[i] = quad_normal( positions[q.x], positions[q.y], positions[q.z], positions[q.w]); } if (!sampled_texturecoords.empty()) { sampled_texturecoords[i] = interpolate_quad( texcoords[q.x], texcoords[q.y], texcoords[q.z], texcoords[q.w], uv); } else { sampled_texturecoords[i] = zero2f; } } } } // namespace yocto // ----------------------------------------------------------------------------- // SHAPE GEODESICS // ----------------------------------------------------------------------------- namespace yocto { void add_node(geodesic_solver& solver, const vec3f& position) { solver.positions.push_back(position); solver.graph.push_back({}); solver.graph.back().reserve(8); } void add_directed_arc(geodesic_solver& solver, int from, int to) { // assert(from >= 0 && from < solver.graph.size()); // assert(to >= 0 && to < solver.graph.size()); auto len = length(solver.positions[from] - solver.positions[to]); solver.graph[from].push_back({to, len}); } void add_undirected_arc(geodesic_solver& solver, int na, int nb) { add_directed_arc(solver, na, nb); add_directed_arc(solver, nb, na); } void make_edge_solver_slow(geodesic_solver& solver, const vector& triangles, const vector& positions, bool use_steiner_points) { solver.graph.reserve(positions.size()); for (int i = 0; i < positions.size(); i++) add_node(solver, positions[i]); auto emap = make_edge_map(triangles); auto edges = get_edges(emap); for (auto& edge : edges) { add_undirected_arc(solver, edge.x, edge.y); } if (!use_steiner_points) return; solver.graph.reserve(positions.size() + edges.size()); auto steiner_per_edge = vector(num_edges(emap)); // On each edge, connect the mid vertex with the vertices on th same edge. for (auto edge_index = 0; edge_index < edges.size(); edge_index++) { auto& edge = edges[edge_index]; auto steiner_idx = solver.graph.size(); steiner_per_edge[edge_index] = steiner_idx; add_node(solver, (positions[edge.x] + positions[edge.y]) * 0.5f); add_directed_arc(solver, steiner_idx, edge.x); add_directed_arc(solver, steiner_idx, edge.y); } // Make connection for each face for (int face = 0; face < triangles.size(); ++face) { int steiner_idx[3]; for (int k : {0, 1, 2}) { int a = triangles[face][k]; int b = triangles[face][(k + 1) % 3]; steiner_idx[k] = steiner_per_edge[edge_index(emap, {a, b})]; } // Connect each mid-vertex to the opposite mesh vertex in the triangle int opp[3] = {triangles[face].z, triangles[face].x, triangles[face].y}; add_undirected_arc(solver, steiner_idx[0], opp[0]); add_undirected_arc(solver, steiner_idx[1], opp[1]); add_undirected_arc(solver, steiner_idx[2], opp[2]); // Connect mid-verts of the face between them add_undirected_arc(solver, steiner_idx[0], steiner_idx[1]); add_undirected_arc(solver, steiner_idx[0], steiner_idx[2]); add_undirected_arc(solver, steiner_idx[1], steiner_idx[2]); } } void add_half_edge(geodesic_solver& solver, const vec2i& edge) { // check if edge exists already for (auto [vert, _] : solver.graph[edge.x]) { if (vert == edge.y) return; } auto len = length(solver.positions[edge.x] - solver.positions[edge.y]); auto edge_index = (int)solver.edges.size(); solver.graph[edge.x].push_back({edge.y, len}); solver.edge_index[edge.x].push_back({edge.y, edge_index}); solver.edges.push_back(edge); } void add_edge(geodesic_solver& solver, const vec2i& edge) { // check if edge exists already for (auto [vert, _] : solver.graph[edge.x]) { if (vert == edge.y) return; } auto len = length(solver.positions[edge.x] - solver.positions[edge.y]); solver.graph[edge.x].push_back({edge.y, len}); solver.graph[edge.y].push_back({edge.x, len}); auto edge_index = (int)solver.edges.size(); solver.edge_index[edge.x].push_back({edge.y, edge_index}); solver.edge_index[edge.y].push_back({edge.x, edge_index}); solver.edges.push_back(edge); } int edge_index(const geodesic_solver& solver, const vec2i& edge) { for (auto [node, index] : solver.edge_index[edge.x]) if (edge.y == node) return index; return -1; } void make_edge_solver_fast(geodesic_solver& solver, const vector& triangles, const vector& positions, bool use_steiner_points) { solver.positions = positions; solver.graph.resize(positions.size()); solver.edge_index.resize(positions.size()); // fast construction assuming edges are not repeated for (auto t : triangles) { add_edge(solver, {t.x, t.y}); add_edge(solver, {t.y, t.z}); add_edge(solver, {t.z, t.x}); } if (!use_steiner_points) return; auto edges = solver.edges; solver.graph.resize(positions.size() + edges.size()); solver.edge_index.resize(positions.size() + edges.size()); solver.positions.resize(positions.size() + edges.size()); auto steiner_per_edge = vector(edges.size()); // On each edge, connect the mid vertex with the vertices on th same edge. auto edge_offset = (int)positions.size(); for (auto edge_index = 0; edge_index < edges.size(); edge_index++) { auto& edge = edges[edge_index]; auto steiner_idx = edge_offset + edge_index; steiner_per_edge[edge_index] = steiner_idx; solver.positions[steiner_idx] = (positions[edge.x] + positions[edge.y]) * 0.5f; add_half_edge(solver, {steiner_idx, edge.x}); add_half_edge(solver, {steiner_idx, edge.y}); } // Make connection for each face for (int face = 0; face < triangles.size(); ++face) { int steiner_idx[3]; for (int k : {0, 1, 2}) { int a = triangles[face][k]; int b = triangles[face][(k + 1) % 3]; steiner_idx[k] = steiner_per_edge[edge_index(solver, {a, b})]; } // Connect each mid-vertex to the opposite mesh vertex in the triangle int opp[3] = {triangles[face].z, triangles[face].x, triangles[face].y}; add_edge(solver, {steiner_idx[0], opp[0]}); add_edge(solver, {steiner_idx[1], opp[1]}); add_edge(solver, {steiner_idx[2], opp[2]}); // Connect mid-verts of the face between them add_edge(solver, {steiner_idx[0], steiner_idx[1]}); add_edge(solver, {steiner_idx[1], steiner_idx[2]}); add_edge(solver, {steiner_idx[2], steiner_idx[0]}); } } void log_geodesic_solver_stats(const geodesic_solver& solver) { // stats auto num_edges = 0; auto min_adjacents = int_max, max_adjacents = int_min; auto min_length = flt_max, max_length = flt_min; auto avg_adjacents = 0.0, avg_length = 0.0; for (auto& adj : solver.graph) { num_edges += (int)adj.size(); min_adjacents = min(min_adjacents, (int)adj.size()); max_adjacents = max(max_adjacents, (int)adj.size()); avg_adjacents += adj.size() / (double)solver.graph.size(); for (auto& edge : adj) { min_length = min(min_length, edge.length); max_length = max(max_length, edge.length); avg_length += edge.length; } } avg_length /= num_edges; } void update_edge_distances(geodesic_solver& solver) { for (auto node = 0; node < solver.graph.size(); node++) { for (auto& edge : solver.graph[node]) edge.length = length( solver.positions[node] - solver.positions[edge.node]); } } void init_geodesic_solver(geodesic_solver& solver, const vector& triangles, const vector& positions) { make_edge_solver_fast(solver, triangles, positions, true); // auto solver = make_edge_solver_slow(triangles, positions, true); log_geodesic_solver_stats(solver); } void compute_geodesic_distances(geodesic_solver& graph, vector& distances, const vector& sources) { // preallocated distances.resize(graph.positions.size()); for (auto& d : distances) d = flt_max; // Small Label Fisrt + Large Label Last // https://en.wikipedia.org/wiki/Shortest_Path_Faster_Algorithm auto num_nodes = (int)graph.graph.size(); // assert(distances.size() == num_nodes); auto visited = vector(num_nodes, false); // setup queue auto queue = std::deque{}; for (auto source : sources) { distances[source] = 0.0f; visited[source] = true; queue.push_back(source); } // Cumulative weights of elements in queue. auto cumulative_weight = 0.0f; while (!queue.empty()) { auto node = queue.front(); auto average_weight = (double)cumulative_weight / queue.size(); // Large Label Last: until front node weights more than the average, put // it on back. Sometimes average_weight is less than envery value due to // Ting point errors (doesn't happen with double precision). for (auto tries = 0; tries < queue.size() + 1; tries++) { if (distances[node] <= average_weight) break; queue.pop_front(); queue.push_back(node); node = queue.front(); } queue.pop_front(); visited[node] = false; // out of queue cumulative_weight -= distances[node]; // update average const auto offset_distance = distances[node]; const auto num_neighbors = (int)graph.graph[node].size(); for (int neighbor_idx = 0; neighbor_idx < num_neighbors; neighbor_idx++) { // distance and id to neightbor through this node auto new_distance = offset_distance + graph.graph[node][neighbor_idx].length; auto neighbor = graph.graph[node][neighbor_idx].node; auto old_distance = distances[neighbor]; if (new_distance >= old_distance) continue; if (visited[neighbor]) { // if neighbor already in queue, update cumulative weights. cumulative_weight = cumulative_weight - old_distance + new_distance; } else { // if neighbor not in queue, Small Label first. if (queue.empty() || (new_distance < distances[queue.front()])) queue.push_front(neighbor); else queue.push_back(neighbor); visited[neighbor] = true; cumulative_weight = cumulative_weight + new_distance; } distances[neighbor] = new_distance; } } } void convert_distance_to_color( vector& colors, const vector& distances) { colors.resize(distances.size()); for (auto idx = 0; idx < distances.size(); idx++) { auto distance = fmod(distances[idx] * 10, 1.0f); colors[idx] = {distance, distance, distance, 1}; } } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION OF SHAPE EXAMPLES // ----------------------------------------------------------------------------- namespace yocto { // Make a quad. static void make_rect(vector& quads, vector& positions, vector& normals, vector& texcoords, const vec2i& steps, const vec2f& size, const vec2f& uvsize) { positions.resize((steps.x + 1) * (steps.y + 1)); normals.resize((steps.x + 1) * (steps.y + 1)); texcoords.resize((steps.x + 1) * (steps.y + 1)); for (auto j = 0; j <= steps.y; j++) { for (auto i = 0; i <= steps.x; i++) { auto uv = vec2f{i / (float)steps.x, j / (float)steps.y}; positions[j * (steps.x + 1) + i] = { (uv.x - 0.5f) * size.x, (uv.y - 0.5f) * size.y, 0}; normals[j * (steps.x + 1) + i] = {0, 0, 1}; texcoords[j * (steps.x + 1) + i] = 1 - uv * uvsize; } } quads.resize(steps.x * steps.y); for (auto j = 0; j < steps.y; j++) { for (auto i = 0; i < steps.x; i++) { quads[j * steps.x + i] = {j * (steps.x + 1) + i, j * (steps.x + 1) + i + 1, (j + 1) * (steps.x + 1) + i + 1, (j + 1) * (steps.x + 1) + i}; } } } // Make a cube. void make_box(vector& quads, vector& positions, vector& normals, vector& texcoords, const vec3i& steps, const vec3f& size, const vec3f& uvsize) { quads.clear(); positions.clear(); normals.clear(); texcoords.clear(); auto qquads = vector{}; auto qpositions = vector{}; auto qnormals = vector{}; auto qtexturecoords = vector{}; // + z make_rect(qquads, qpositions, qnormals, qtexturecoords, {steps.x, steps.y}, {size.x, size.y}, {uvsize.x, uvsize.y}); for (auto& p : qpositions) p = {p.x, p.y, size.z / 2}; for (auto& n : qnormals) n = {0, 0, 1}; merge_quads(quads, positions, normals, texcoords, qquads, qpositions, qnormals, qtexturecoords); // - z make_rect(qquads, qpositions, qnormals, qtexturecoords, {steps.x, steps.y}, {size.x, size.y}, {uvsize.x, uvsize.y}); for (auto& p : qpositions) p = {-p.x, p.y, -size.z / 2}; for (auto& n : qnormals) n = {0, 0, -1}; merge_quads(quads, positions, normals, texcoords, qquads, qpositions, qnormals, qtexturecoords); // + x make_rect(qquads, qpositions, qnormals, qtexturecoords, {steps.z, steps.y}, {size.z, size.y}, {uvsize.z, uvsize.y}); for (auto& p : qpositions) p = {size.x / 2, p.y, -p.x}; for (auto& n : qnormals) n = {1, 0, 0}; merge_quads(quads, positions, normals, texcoords, qquads, qpositions, qnormals, qtexturecoords); // - x make_rect(qquads, qpositions, qnormals, qtexturecoords, {steps.z, steps.y}, {size.z, size.y}, {uvsize.z, uvsize.y}); for (auto& p : qpositions) p = {-size.x / 2, p.y, p.x}; for (auto& n : qnormals) n = {-1, 0, 0}; merge_quads(quads, positions, normals, texcoords, qquads, qpositions, qnormals, qtexturecoords); // + y make_rect(qquads, qpositions, qnormals, qtexturecoords, {steps.x, steps.z}, {size.x, size.z}, {uvsize.x, uvsize.z}); for (auto i = 0; i < qpositions.size(); i++) { qpositions[i] = {qpositions[i].x, size.y / 2, -qpositions[i].y}; qnormals[i] = {0, 1, 0}; } merge_quads(quads, positions, normals, texcoords, qquads, qpositions, qnormals, qtexturecoords); // - y make_rect(qquads, qpositions, qnormals, qtexturecoords, {steps.x, steps.z}, {size.x, size.z}, {uvsize.x, uvsize.z}); for (auto i = 0; i < qpositions.size(); i++) { qpositions[i] = {qpositions[i].x, -size.y / 2, qpositions[i].y}; qnormals[i] = {0, -1, 0}; } merge_quads(quads, positions, normals, texcoords, qquads, qpositions, qnormals, qtexturecoords); } // Generate lines set along a quad. void make_lines(vector& lines, vector& positions, vector& normals, vector& texcoords, vector& radius, int num, int subdivisions, const vec2f& size, const vec2f& uvsize, const vec2f& line_radius) { auto steps = vec2i{pow2(subdivisions), num}; auto nverts = (steps.x + 1) * steps.y; auto nlines = steps.x * steps.y; auto vid = [steps](int i, int j) { return j * (steps.x + 1) + i; }; auto fid = [steps](int i, int j) { return j * steps.x + i; }; positions.resize(nverts); normals.resize(nverts); texcoords.resize(nverts); radius.resize(nverts); if (steps.y > 1) { for (auto j = 0; j < steps.y; j++) { for (auto i = 0; i <= steps.x; i++) { auto uv = vec2f{ i / (float)steps.x, j / (float)(steps.y > 1 ? steps.y - 1 : 1)}; positions[vid(i, j)] = { (uv.x - 0.5f) * size.x, (uv.y - 0.5f) * size.y, 0}; normals[vid(i, j)] = {1, 0, 0}; texcoords[vid(i, j)] = uv * uvsize; } } } else { for (auto i = 0; i <= steps.x; i++) { auto uv = vec2f{i / (float)steps.x, 0}; positions[vid(i, 0)] = {(uv.x - 0.5f) * size.x, 0, 0}; normals[vid(i, 0)] = {1, 0, 0}; texcoords[vid(i, 0)] = uv * uvsize; } } lines.resize(nlines); for (int j = 0; j < steps.y; j++) { for (int i = 0; i < steps.x; i++) { lines[fid(i, j)] = {vid(i, j), vid(i + 1, j)}; } } } // Generate a point set with points placed at the origin with texcoords // varying along u. void make_points(vector& points, vector& positions, vector& normals, vector& texcoords, vector& radius, int num, float uvsize, float point_radius) { points.resize(num); for (auto i = 0; i < num; i++) points[i] = i; positions.assign(num, {0, 0, 0}); normals.assign(num, {0, 0, 1}); texcoords.assign(num, {0, 0}); radius.assign(num, point_radius); for (auto i = 0; i < texcoords.size(); i++) texcoords[i] = {(float)i / (float)num, 0}; } // Generate a point set. void make_random_points(vector& points, vector& positions, vector& normals, vector& texcoords, vector& radius, int num, const vec3f& size, float uvsize, float point_radius, uint64_t seed) { make_points( points, positions, normals, texcoords, radius, num, uvsize, point_radius); auto rng = make_rng(seed); for (auto i = 0; i < positions.size(); i++) { positions[i] = (rand3f(rng) - vec3f{0.5f, 0.5f, 0.5f}) * size; } } // Make a point. void make_point(vector& points, vector& positions, vector& normals, vector& texcoords, vector& radius, float point_radius) { points = {0}; positions = {{0, 0, 0}}; normals = {{0, 0, 1}}; texcoords = {{0, 0}}; radius = {point_radius}; } // Make a bezier circle. Returns bezier, pos. void make_bezier_circle( vector& beziers, vector& positions, float size) { // constant from http://spencermortensen.com/articles/bezier-circle/ const auto c = 0.551915024494f; static auto circle_pos = vector{{1, 0, 0}, {1, c, 0}, {c, 1, 0}, {0, 1, 0}, {-c, 1, 0}, {-1, c, 0}, {-1, 0, 0}, {-1, -c, 0}, {-c, -1, 0}, {0, -1, 0}, {c, -1, 0}, {1, -c, 0}}; static auto circle_beziers = vector{ {0, 1, 2, 3}, {3, 4, 5, 6}, {6, 7, 8, 9}, {9, 10, 11, 0}}; positions = circle_pos; beziers = circle_beziers; for (auto& p : positions) p *= size; } // Make a procedural shape extern const vector quad_positions; extern const vector quad_normals; extern const vector quad_texcoords; extern const vector quad_quads; extern const vector quady_positions; extern const vector quady_normals; extern const vector quady_texcoords; extern const vector quady_quads; extern const vector cube_positions; extern const vector cube_normals; extern const vector cube_texcoords; extern const vector cube_quads; extern const vector fvcube_positions; extern const vector fvcube_quads; extern const vector suzanne_positions; extern const vector suzanne_quads; // Make a procedural shape void make_proc_shape(vector& triangles, vector& quads, vector& positions, vector& normals, vector& texcoords, const proc_shape_params& params) { auto subdivide_quads_pnt = [&](auto& qquads, auto& qpositions, auto& qnormals, auto& qtexcoords) { struct vertex { vec3f position = zero3f; vec3f normal = zero3f; vec2f texcoord = zero2f; vertex& operator+=(const vertex& a) { return *this = *this + a; }; vertex& operator/=(float s) { return *this = *this / s; }; vertex operator+(const vertex& a) const { return { position + a.position, normal + a.normal, texcoord + a.texcoord}; }; vertex operator-(const vertex& a) const { return { position - a.position, normal - a.normal, texcoord - a.texcoord}; }; vertex operator*(float s) const { return {position * s, normal * s, texcoord * s}; }; vertex operator/(float s) const { return operator*(1 / s); }; }; auto vertices = vector(qpositions.size()); for (auto i = 0; i < vertices.size(); i++) { vertices[i].position = qpositions[i]; vertices[i].normal = qnormals[i]; vertices[i].texcoord = qtexcoords[i]; } subdivide_quads_impl( quads, vertices, qquads, vertices, params.subdivisions); positions.resize(vertices.size()); normals.resize(vertices.size()); texcoords.resize(vertices.size()); for (auto i = 0; i < vertices.size(); i++) { positions[i] = vertices[i].position; normals[i] = vertices[i].normal; texcoords[i] = vertices[i].texcoord; } }; auto subdivide_quads_p = [&](auto& qquads, auto& qpositions) { subdivide_quads_impl( quads, positions, qquads, qpositions, params.subdivisions); }; triangles.clear(); quads.clear(); positions.clear(); normals.clear(); texcoords.clear(); switch (params.type) { case proc_shape_params::type_t::quad: { subdivide_quads_pnt( quad_quads, quad_positions, quad_normals, quad_texcoords); if (params.rounded) { auto height = params.rounded; auto radius = (1 + height * height) / (2 * height); auto center = vec3f{0, 0, -radius + height}; for (auto i = 0; i < positions.size(); i++) { auto pn = normalize(positions[i] - center); positions[i] = center + pn * radius; normals[i] = pn; } } } break; case proc_shape_params::type_t::floor: { subdivide_quads_pnt( quady_quads, quady_positions, quady_normals, quady_texcoords); if (params.rounded) { auto radius = params.rounded; auto start = (1 - radius) / 2; auto end = start + radius; for (auto i = 0; i < positions.size(); i++) { if (positions[i].z < -end) { positions[i] = { positions[i].x, -positions[i].z - end + radius, -end}; normals[i] = {0, 0, 1}; } else if (positions[i].z < -start && positions[i].z >= -end) { auto phi = (pif / 2) * (-positions[i].z - start) / radius; positions[i] = {positions[i].x, -cos(phi) * radius + radius, -sin(phi) * radius - start}; normals[i] = {0, cos(phi), sin(phi)}; } else { } } } } break; case proc_shape_params::type_t::cube: { subdivide_quads_pnt( cube_quads, cube_positions, cube_normals, cube_texcoords); auto steps = vec3i{pow2(params.subdivisions)}; auto uvsize = vec3f{1}; auto size = vec3f{2}; make_box(quads, positions, normals, texcoords, steps, size, uvsize); if (params.rounded) { auto radius = params.rounded; auto c = vec3f{1 - radius}; for (auto i = 0; i < positions.size(); i++) { auto pc = vec3f{ abs(positions[i].x), abs(positions[i].y), abs(positions[i].z)}; auto ps = vec3f{positions[i].x < 0 ? -1.0f : 1.0f, positions[i].y < 0 ? -1.0f : 1.0f, positions[i].z < 0 ? -1.0f : 1.0f}; if (pc.x >= c.x && pc.y >= c.y && pc.z >= c.z) { auto pn = normalize(pc - c); positions[i] = c + radius * pn; normals[i] = pn; } else if (pc.x >= c.x && pc.y >= c.y) { auto pn = normalize((pc - c) * vec3f{1, 1, 0}); positions[i] = {c.x + radius * pn.x, c.y + radius * pn.y, pc.z}; normals[i] = pn; } else if (pc.x >= c.x && pc.z >= c.z) { auto pn = normalize((pc - c) * vec3f{1, 0, 1}); positions[i] = {c.x + radius * pn.x, pc.y, c.z + radius * pn.z}; normals[i] = pn; } else if (pc.y >= c.y && pc.z >= c.z) { auto pn = normalize((pc - c) * vec3f{0, 1, 1}); positions[i] = {pc.x, c.y + radius * pn.y, c.z + radius * pn.z}; normals[i] = pn; } else { continue; } positions[i] *= ps; normals[i] *= ps; } } } break; case proc_shape_params::type_t::sphere: { subdivide_quads_pnt( cube_quads, cube_positions, cube_normals, cube_texcoords); for (auto& p : positions) p = normalize(p); normals = positions; } break; case proc_shape_params::type_t::uvsphere: { subdivide_quads_pnt( quad_quads, quad_positions, quad_normals, quad_texcoords); for (auto i = 0; i < positions.size(); i++) { auto uv = texcoords[i]; auto a = vec2f{2 * pif * uv.x, pif * (1 - uv.y)}; auto p = vec3f{cos(a.x) * sin(a.y), sin(a.x) * sin(a.y), cos(a.y)}; positions[i] = p; normals[i] = normalize(p); texcoords[i] = uv; } if (params.rounded) { auto zflip = (1 - params.rounded); for (auto i = 0; i < positions.size(); i++) { if (positions[i].z > zflip) { positions[i].z = 2 * zflip - positions[i].z; normals[i].x = -normals[i].x; normals[i].y = -normals[i].y; } else if (positions[i].z < -zflip) { positions[i].z = 2 * (-zflip) - positions[i].z; normals[i].x = -normals[i].x; normals[i].y = -normals[i].y; } } } } break; case proc_shape_params::type_t::disk: { subdivide_quads_pnt( quad_quads, quad_positions, quad_normals, quad_texcoords); for (auto i = 0; i < positions.size(); i++) { // Analytical Methods for Squaring the Disc, by C. Fong // https://arxiv.org/abs/1509.06344 auto xy = vec2f{positions[i].x, positions[i].y}; auto uv = vec2f{ xy.x * sqrt(1 - xy.y * xy.y / 2), xy.y * sqrt(1 - xy.x * xy.x / 2)}; positions[i] = {uv.x, uv.y, 0}; } if (params.rounded) { auto height = params.rounded; auto radius = (1 + height * height) / (2 * height); auto center = vec3f{0, 0, -radius + height}; for (auto i = 0; i < positions.size(); i++) { auto pn = normalize(positions[i] - center); positions[i] = center + pn * radius; normals[i] = pn; } } } break; case proc_shape_params::type_t::matball: { subdivide_quads_pnt( cube_quads, cube_positions, cube_normals, cube_texcoords); for (auto i = 0; i < positions.size(); i++) { auto p = positions[i]; positions[i] = normalize(p); normals[i] = normalize(p); } } break; case proc_shape_params::type_t::suzanne: { subdivide_quads_p(suzanne_quads, suzanne_positions); } break; case proc_shape_params::type_t::box: { auto steps = vec3i{ (int)round(pow2(params.subdivisions) * params.aspect.x), (int)round(pow2(params.subdivisions) * params.aspect.y), (int)round(pow2(params.subdivisions) * params.aspect.z)}; auto uvsize = params.aspect; auto size = 2 * params.aspect; make_box(quads, positions, normals, texcoords, steps, size, uvsize); if (params.rounded) { auto radius = params.rounded * min(size) / 2; auto c = size / 2 - radius; for (auto i = 0; i < positions.size(); i++) { auto pc = vec3f{ abs(positions[i].x), abs(positions[i].y), abs(positions[i].z)}; auto ps = vec3f{positions[i].x < 0 ? -1.0f : 1.0f, positions[i].y < 0 ? -1.0f : 1.0f, positions[i].z < 0 ? -1.0f : 1.0f}; if (pc.x >= c.x && pc.y >= c.y && pc.z >= c.z) { auto pn = normalize(pc - c); positions[i] = c + radius * pn; normals[i] = pn; } else if (pc.x >= c.x && pc.y >= c.y) { auto pn = normalize((pc - c) * vec3f{1, 1, 0}); positions[i] = {c.x + radius * pn.x, c.y + radius * pn.y, pc.z}; normals[i] = pn; } else if (pc.x >= c.x && pc.z >= c.z) { auto pn = normalize((pc - c) * vec3f{1, 0, 1}); positions[i] = {c.x + radius * pn.x, pc.y, c.z + radius * pn.z}; normals[i] = pn; } else if (pc.y >= c.y && pc.z >= c.z) { auto pn = normalize((pc - c) * vec3f{0, 1, 1}); positions[i] = {pc.x, c.y + radius * pn.y, c.z + radius * pn.z}; normals[i] = pn; } else { continue; } positions[i] *= ps; normals[i] *= ps; } } } break; case proc_shape_params::type_t::rect: { auto steps = vec2i{ (int)round(pow2(params.subdivisions) * params.aspect.x), (int)round(pow2(params.subdivisions) * params.aspect.y)}; auto uvsize = vec2f{params.aspect.x, params.aspect.y}; auto size = 2 * vec2f{params.aspect.x, params.aspect.y}; make_rect(quads, positions, normals, texcoords, steps, size, uvsize); } break; case proc_shape_params::type_t::rect_stack: { auto steps = vec3i{ (int)round(pow2(params.subdivisions) * params.aspect.x), (int)round(pow2(params.subdivisions) * params.aspect.y), (int)round(pow2(params.subdivisions) * params.aspect.z)}; auto uvsize = vec2f{params.aspect.x, params.aspect.y}; auto size = params.aspect; auto qquads = vector{}; auto qpositions = vector{}; auto qnormals = vector{}; auto qtexturecoords = vector{}; for (auto i = 0; i <= steps.z; i++) { make_rect(qquads, qpositions, qnormals, qtexturecoords, {steps.x, steps.y}, {size.x, size.y}, uvsize); for (auto& p : qpositions) p.z = (-0.5f + (float)i / steps.z) * size.z; merge_quads(quads, positions, normals, texcoords, qquads, qpositions, qnormals, qtexturecoords); } } break; case proc_shape_params::type_t::uvdisk: { subdivide_quads_pnt( quad_quads, quad_positions, quad_normals, quad_texcoords); for (auto i = 0; i < positions.size(); i++) { auto uv = texcoords[i]; auto phi = 2 * pif * uv.x; positions[i] = {cos(phi) * uv.y, sin(phi) * uv.y, 0}; normals[i] = {0, 0, 1}; } } break; case proc_shape_params::type_t::uvcylinder: { auto steps = vec3i{ (int)round(pow2(params.subdivisions + 1) * params.aspect.x), (int)round(pow2(params.subdivisions + 0) * params.aspect.y), (int)round(pow2(params.subdivisions - 1) * params.aspect.z)}; auto uvsize = params.aspect; auto size = 2 * vec2f{params.aspect.x, params.aspect.y}; auto qquads = vector{}; auto qpositions = vector{}; auto qnormals = vector{}; auto qtexcoords = vector{}; // side make_rect(qquads, qpositions, qnormals, qtexcoords, {steps.x, steps.y}, {1, 1}, {1, 1}); for (auto i = 0; i < qpositions.size(); i++) { auto uv = qtexcoords[i]; auto phi = 2 * pif * uv.x; qpositions[i] = {cos(phi) * size.x / 2, sin(phi) * size.x / 2, (uv.y - 0.5f) * size.y}; qnormals[i] = {cos(phi), sin(phi), 0}; qtexcoords[i] = uv * vec2f{uvsize.x, uvsize.y}; } merge_quads(quads, positions, normals, texcoords, qquads, qpositions, qnormals, qtexcoords); // top make_rect(qquads, qpositions, qnormals, qtexcoords, {steps.x, steps.z}, {1, 1}, {1, 1}); for (auto i = 0; i < qpositions.size(); i++) { auto uv = qtexcoords[i]; auto phi = 2 * pif * uv.x; qpositions[i] = { cos(phi) * uv.y * size.x / 2, sin(phi) * uv.y * size.x / 2, 0}; qnormals[i] = {0, 0, 1}; qtexcoords[i] = uv * vec2f{uvsize.x, uvsize.z}; qpositions[i].z = size.y / 2; } merge_quads(quads, positions, normals, texcoords, qquads, qpositions, qnormals, qtexcoords); // bottom make_rect(qquads, qpositions, qnormals, qtexcoords, {steps.x, steps.z}, {1, 1}, {1, 1}); for (auto i = 0; i < qpositions.size(); i++) { auto uv = qtexcoords[i]; auto phi = 2 * pif * uv.x; qpositions[i] = { cos(phi) * uv.y * size.x / 2, sin(phi) * uv.y * size.x / 2, 0}; qnormals[i] = {0, 0, 1}; qtexcoords[i] = uv * vec2f{uvsize.x, uvsize.z}; qpositions[i].z = -size.y / 2; qnormals[i] = -qnormals[i]; } for (auto i = 0; i < qquads.size(); i++) swap(qquads[i].x, qquads[i].z); merge_quads(quads, positions, normals, texcoords, qquads, qpositions, qnormals, qtexcoords); if (params.rounded) { auto radius = params.rounded * min(size) / 2; auto c = size / 2 - vec2f{radius, radius}; for (auto i = 0; i < positions.size(); i++) { auto phi = atan2(positions[i].y, positions[i].x); auto r = length(vec2f{positions[i].x, positions[i].y}); auto z = positions[i].z; auto pc = vec2f{r, fabs(z)}; auto ps = (z < 0) ? -1.0f : 1.0f; if (pc.x >= c.x && pc.y >= c.y) { auto pn = normalize(pc - c); positions[i] = {cos(phi) * (c.x + radius * pn.x), sin(phi) * (c.x + radius * pn.x), ps * (c.y + radius * pn.y)}; normals[i] = {cos(phi) * pn.x, sin(phi) * pn.x, ps * pn.y}; } else { continue; } } } } break; case proc_shape_params::type_t::geosphere: { // https://stackoverflow.com/questions/17705621/algorithm-for-a-geodesic-sphere const float X = 0.525731112119133606f; const float Z = 0.850650808352039932f; static auto sphere_positions = vector{{-X, 0.0, Z}, {X, 0.0, Z}, {-X, 0.0, -Z}, {X, 0.0, -Z}, {0.0, Z, X}, {0.0, Z, -X}, {0.0, -Z, X}, {0.0, -Z, -X}, {Z, X, 0.0}, {-Z, X, 0.0}, {Z, -X, 0.0}, {-Z, -X, 0.0}}; static auto sphere_triangles = vector{{0, 1, 4}, {0, 4, 9}, {9, 4, 5}, {4, 8, 5}, {4, 1, 8}, {8, 1, 10}, {8, 10, 3}, {5, 8, 3}, {5, 3, 2}, {2, 3, 7}, {7, 3, 10}, {7, 10, 6}, {7, 6, 11}, {11, 6, 0}, {0, 6, 1}, {6, 10, 1}, {9, 11, 0}, {9, 2, 11}, {9, 5, 2}, {7, 11, 2}}; subdivide_triangles(triangles, positions, sphere_triangles, sphere_positions, params.subdivisions); for (auto& p : positions) p = normalize(p); normals = positions; } break; } if (params.scale != 1) { for (auto& p : positions) p *= params.scale; } if (params.uvscale != 1) { for (auto& uv : texcoords) uv *= params.uvscale; } if (params.frame != identity3x4f) { for (auto& p : positions) p = transform_point(params.frame, p); } } // Make face-varying quads void make_proc_fvshape(vector& quadspos, vector& quadsnorm, vector& quadstexcoord, vector& positions, vector& normals, vector& texcoords, const proc_shape_params& params) { switch (params.type) { case proc_shape_params::type_t::quad: { subdivide_quads( quadspos, positions, quad_quads, quad_positions, params.subdivisions); subdivide_quads( quadsnorm, normals, quad_quads, quad_normals, params.subdivisions); subdivide_quads(quadstexcoord, texcoords, quad_quads, quad_texcoords, params.subdivisions); } break; case proc_shape_params::type_t::cube: { subdivide_quads(quadspos, positions, fvcube_quads, fvcube_positions, params.subdivisions); subdivide_quads( quadsnorm, normals, cube_quads, cube_normals, params.subdivisions); subdivide_quads(quadstexcoord, texcoords, cube_quads, cube_texcoords, params.subdivisions); } break; case proc_shape_params::type_t::sphere: { subdivide_quads(quadspos, positions, fvcube_quads, fvcube_positions, params.subdivisions); subdivide_quads(quadstexcoord, texcoords, cube_quads, cube_texcoords, params.subdivisions); for (auto& p : positions) p = normalize(p); normals = positions; quadsnorm = quadspos; } break; case proc_shape_params::type_t::suzanne: { subdivide_quads(quadspos, positions, suzanne_quads, suzanne_positions, params.subdivisions); } break; default: { throw std::runtime_error( "shape type not supported " + std::to_string((int)params.type)); } break; } if (params.scale != 1) { for (auto& p : positions) p *= params.scale; } if (params.uvscale != 1) { for (auto& uv : texcoords) uv *= params.uvscale; } if (params.frame != identity3x4f) { for (auto& p : positions) p = transform_point(params.frame, p); } } // Make a hair ball around a shape void make_hair(vector& lines, vector& positions, vector& normals, vector& texcoords, vector& radius, const vector& striangles, const vector& squads, const vector& spos, const vector& snorm, const vector& stexcoord, const hair_params& params) { auto alltriangles = striangles; auto quads_triangles = vector{}; quads_to_triangles(quads_triangles, squads); alltriangles.insert( alltriangles.end(), quads_triangles.begin(), quads_triangles.end()); auto bpos = vector{}; auto bnorm = vector{}; auto btexcoord = vector{}; sample_triangles(bpos, bnorm, btexcoord, alltriangles, spos, snorm, stexcoord, params.num, params.seed); auto rng = make_rng(params.seed, 3); auto blen = vector(bpos.size()); for (auto& l : blen) { l = lerp(params.length_min, params.length_max, rand1f(rng)); } auto cidx = vector(); if (params.clump_strength > 0) { for (auto bidx = 0; bidx < bpos.size(); bidx++) { cidx.push_back(0); auto cdist = flt_max; for (auto c = 0; c < params.clump_num; c++) { auto d = length(bpos[bidx] - bpos[c]); if (d < cdist) { cdist = d; cidx.back() = c; } } } } auto steps = pow2(params.subdivisions); make_lines(lines, positions, normals, texcoords, radius, params.num, params.subdivisions, {1, 1}, {1, 1}, {1, 1}); for (auto i = 0; i < positions.size(); i++) { auto u = texcoords[i].x; auto bidx = i / (steps + 1); positions[i] = bpos[bidx] + bnorm[bidx] * u * blen[bidx]; normals[i] = bnorm[bidx]; radius[i] = lerp(params.radius_base, params.radius_tip, u); if (params.clump_strength > 0) { positions[i] = positions[i] + (positions[i + (cidx[bidx] - bidx) * (steps + 1)] - positions[i]) * u * params.clump_strength; } if (params.noise_strength > 0) { auto nx = perlin_noise( positions[i] * params.noise_scale + vec3f{0, 0, 0}) * params.noise_strength; auto ny = perlin_noise( positions[i] * params.noise_scale + vec3f{3, 7, 11}) * params.noise_strength; auto nz = perlin_noise( positions[i] * params.noise_scale + vec3f{13, 17, 19}) * params.noise_strength; positions[i] += {nx, ny, nz}; } } if (params.clump_strength > 0 || params.noise_strength > 0 || params.rotation_strength > 0) { compute_tangents(normals, lines, positions); } } // Thickens a shape by copy9ing the shape content, rescaling it and flipping // its normals. Note that this is very much not robust and only useful for // trivial cases. void make_shell(vector& quads, vector& positions, vector& normals, vector& texcoords, float thickness) { auto bbox = invalidb3f; for (auto p : positions) bbox = merge(bbox, p); auto center = yocto::center(bbox); auto inner_quads = quads; auto inner_positions = positions; auto inner_normals = normals; auto inner_texturecoords = texcoords; for (auto& p : inner_positions) p = (1 - thickness) * (p - center) + center; for (auto& n : inner_normals) n = -n; merge_quads(quads, positions, normals, texcoords, inner_quads, inner_positions, inner_normals, inner_texturecoords); } // Shape presets used ofr testing. void make_shape_preset(vector& points, vector& lines, vector& triangles, vector& quads, vector& quadspos, vector& quadsnorm, vector& quadstexcoord, vector& positions, vector& normals, vector& texcoords, vector& colors, vector& radius, const string& type) { if (type == "default-quad") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::quad; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-quady") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::quad; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-cube") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::cube; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-cube-rounded") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::cube; params.rounded = 0.15; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-sphere") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::sphere; params.subdivisions = 5; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-disk") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::disk; params.subdivisions = 5; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-disk-bulged") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::disk; params.subdivisions = 5; params.rounded = 0.25; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-quad-bulged") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::quad; params.subdivisions = 5; params.rounded = 0.25; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-uvsphere") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::uvsphere; params.subdivisions = 5; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-uvsphere-flipcap") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::uvsphere; params.subdivisions = 5; params.rounded = 0.75; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-uvdisk") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::uvdisk; params.subdivisions = 4; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-uvcylinder") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::uvcylinder; params.subdivisions = 5; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-uvcylinder-rounded") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::uvcylinder; params.subdivisions = 5; params.rounded = 0.075; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-geosphere") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::geosphere; params.subdivisions = 5; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-floor") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::floor; params.scale = 20; params.uvscale = 20; params.subdivisions = 1; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-floor-bent") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::floor; params.scale = 20; params.uvscale = 20; params.subdivisions = 5; params.rounded = 0.5; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-matball") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::matball; params.subdivisions = 5; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-hairball") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::sphere; params.subdivisions = 5; params.scale = 0.8f; auto base_triangles = vector{}; auto base_quads = vector{}; auto base_positions = vector{}; auto base_normals = vector{}; auto base_texcoords = vector{}; make_proc_shape(base_triangles, base_quads, base_positions, base_normals, base_texcoords, params); auto hparams = hair_params{}; hparams.subdivisions = 2; hparams.num = 65536; hparams.length_min = 0.2; hparams.length_max = 0.2; hparams.radius_base = 0.002; hparams.radius_tip = 0.001; make_hair(lines, positions, normals, texcoords, radius, base_triangles, base_quads, base_positions, base_normals, base_texcoords, hparams); } else if (type == "default-hairball-interior") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::sphere; params.subdivisions = 5; params.scale = 0.8f; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-suzanne") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::suzanne; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "default-cube-facevarying") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::cube; make_proc_fvshape(quadspos, quadsnorm, quadstexcoord, positions, normals, texcoords, params); } else if (type == "default-sphere-facevarying") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::sphere; params.subdivisions = 5; make_proc_fvshape(quadspos, quadsnorm, quadstexcoord, positions, normals, texcoords, params); } else if (type == "test-cube") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::cube; params.subdivisions = 5; params.scale = 0.075; params.rounded = 0.3; params.frame = frame3f{{0, 0.075, 0}}; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "test-uvsphere") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::uvsphere; params.subdivisions = 5; params.scale = 0.075; params.frame = frame3f{{0, 0.075, 0}}; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "test-uvsphere-flipcap") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::uvsphere; params.subdivisions = 5; params.scale = 0.075; params.rounded = 0.3; params.frame = frame3f{{0, 0.075, 0}}; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "test-sphere") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::sphere; params.subdivisions = 5; params.scale = 0.075; params.frame = frame3f{{0, 0.075, 0}}; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "test-sphere-displaced") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::sphere; params.subdivisions = 7; params.scale = 0.075; params.frame = frame3f{{0, 0.075, 0}}; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "test-disk") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::disk; params.subdivisions = 5; params.scale = 0.075; params.frame = frame3f{{0, 0.075, 0}}; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "test-uvcylinder") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::uvcylinder; params.subdivisions = 5; params.scale = 0.075; params.rounded = 0.3; params.frame = frame3f{{0, 0.075, 0}}; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "test-floor") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::floor; params.subdivisions = 0; params.scale = 2; params.uvscale = 20; params.frame = identity3x4f; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "test-matball") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::matball; params.subdivisions = 5; params.scale = 0.075; params.frame = frame3f{{0, 0.075, 0}}; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "test-hairball1") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::sphere; params.subdivisions = 5; params.scale = 0.075f * 0.8f; params.frame = frame3f{{0, 0.075, 0}}; auto base_triangles = vector{}; auto base_quads = vector{}; auto base_positions = vector{}; auto base_normals = vector{}; auto base_texcoords = vector{}; make_proc_shape(base_triangles, base_quads, base_positions, base_normals, base_texcoords, params); auto hparams = hair_params{}; hparams.num = 65536; hparams.subdivisions = 2; hparams.length_min = 0.1f * 0.15f; hparams.length_max = 0.1f * 0.15f; hparams.radius_base = 0.001f * 0.15f; hparams.radius_tip = 0.0005f * 0.15f; hparams.noise_strength = 0.03f; hparams.noise_scale = 100; make_hair(lines, positions, normals, texcoords, radius, base_triangles, base_quads, base_positions, base_normals, base_texcoords, hparams); } else if (type == "test-hairball2") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::sphere; params.subdivisions = 5; params.scale = 0.075f * 0.8f; params.frame = frame3f{{0, 0.075, 0}}; auto base_triangles = vector{}; auto base_quads = vector{}; auto base_positions = vector{}; auto base_normals = vector{}; auto base_texcoords = vector{}; make_proc_shape(base_triangles, base_quads, base_positions, base_normals, base_texcoords, params); auto hparams = hair_params{}; hparams.num = 65536; hparams.subdivisions = 2; hparams.length_min = 0.1f * 0.15f; hparams.length_max = 0.1f * 0.15f; hparams.radius_base = 0.001f * 0.15f; hparams.radius_tip = 0.0005f * 0.15f; make_hair(lines, positions, normals, texcoords, radius, base_triangles, base_quads, base_positions, base_normals, base_texcoords, hparams); } else if (type == "test-hairball3") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::sphere; params.subdivisions = 5; params.scale = 0.075f * 0.8f; params.frame = frame3f{{0, 0.075, 0}}; auto base_triangles = vector{}; auto base_quads = vector{}; auto base_positions = vector{}; auto base_normals = vector{}; auto base_texcoords = vector{}; make_proc_shape(base_triangles, base_quads, base_positions, base_normals, base_texcoords, params); auto hparams = hair_params{}; hparams.num = 65536; hparams.subdivisions = 2; hparams.length_min = 0.1f * 0.15f; hparams.length_max = 0.1f * 0.15f; hparams.radius_base = 0.001f * 0.15f; hparams.radius_tip = 0.0005f * 0.15f; hparams.clump_strength = 0.5f; hparams.clump_num = 128; make_hair(lines, positions, normals, texcoords, radius, base_triangles, base_quads, base_positions, base_normals, base_texcoords, hparams); } else if (type == "test-hairball-interior") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::sphere; params.subdivisions = 5; params.scale = 0.075f * 0.8f; params.frame = frame3f{{0, 0.075, 0}}; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "test-suzanne-subdiv") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::suzanne; params.scale = 0.075f * 0.8f; params.frame = frame3f{{0, 0.075, 0}}; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "test-cube-subdiv") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::cube; params.scale = 0.075; params.frame = frame3f{{0, 0.075, 0}}; make_proc_fvshape(quadspos, quadsnorm, quadstexcoord, positions, normals, texcoords, params); } else if (type == "test-arealight1") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::quad; params.scale = 0.2; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "test-arealight2") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::quad; params.scale = 0.2; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "test-largearealight1") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::quad; params.scale = 0.4; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else if (type == "test-largearealight2") { auto params = proc_shape_params{}; params.type = proc_shape_params::type_t::quad; params.scale = 0.4; make_proc_shape(triangles, quads, positions, normals, texcoords, params); } else { throw std::invalid_argument("unknown shape preset " + type); } } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION OF SHAPE IO // ----------------------------------------------------------------------------- #if 0 namespace yocto { // hack for CyHair data static void load_cyhair_shape(const string& filename, vector& lines, vector& positions, vector& normals, vector& texcoords, vector& color, vector& radius, bool flip_texcoord = true); // Load/Save a ply mesh static void load_ply_shape(const string& filename, vector& points, vector& lines, vector& triangles, vector& quads, vector& quadspos, vector& quadsnorm, vector& quadstexcoord, vector& positions, vector& normals, vector& texcoords, vector& color, vector& radius, bool flip_texcoord = true); static void save_ply_shape(const string& filename, const vector& points, const vector& lines, const vector& triangles, const vector& quads, const vector& quadspos, const vector& quadsnorm, const vector& quadstexcoord, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, bool ascii = false, bool flip_texcoord = true); // Load/Save an OBJ mesh static void load_obj_shape(const string& filename, vector& points, vector& lines, vector& triangles, vector& quads, vector& quadspos, vector& quadsnorm, vector& quadstexcoord, vector& positions, vector& normals, vector& texcoords, bool facevarying, bool flip_texcoord = true); static void save_obj_shape(const string& filename, const vector& points, const vector& lines, const vector& triangles, const vector& quads, const vector& quadspos, const vector& quadsnorm, const vector& quadstexcoord, const vector& positions, const vector& normals, const vector& texcoords, bool flip_texcoord = true); // Load ply mesh void load_shape(const string& filename, vector& points, vector& lines, vector& triangles, vector& quads, vector& quadspos, vector& quadsnorm, vector& quadstexcoord, vector& positions, vector& normals, vector& texcoords, vector& colors, vector& radius, bool preserve_facevarrying) { points = {}; lines = {}; triangles = {}; quads = {}; quadspos = {}; quadsnorm = {}; quadstexcoord = {}; positions = {}; normals = {}; texcoords = {}; colors = {}; radius = {}; auto ext = fs::path(filename).extension().string(); if (ext == ".ply" || ext == ".PLY") { load_ply_shape(filename, points, lines, triangles, quads, quadspos, quadsnorm, quadstexcoord, positions, normals, texcoords, colors, radius); } else if (ext == ".obj" || ext == ".OBJ") { load_obj_shape(filename, points, lines, triangles, quads, quadspos, quadsnorm, quadstexcoord, positions, normals, texcoords, preserve_facevarrying); } else if (ext == ".hair" || ext == ".HAIR") { load_cyhair_shape( filename, lines, positions, normals, texcoords, colors, radius); } else { throw std::runtime_error("unsupported mesh type " + ext); } } // Save ply mesh void save_shape(const string& filename, const vector& points, const vector& lines, const vector& triangles, const vector& quads, const vector& quadspos, const vector& quadsnorm, const vector& quadstexcoord, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, bool ascii) { auto ext = fs::path(filename).extension().string(); if (ext == ".ply" || ext == ".PLY") { return save_ply_shape(filename, points, lines, triangles, quads, quadspos, quadsnorm, quadstexcoord, positions, normals, texcoords, colors, radius, ascii); } else if (ext == ".obj" || ext == ".OBJ") { return save_obj_shape(filename, points, lines, triangles, quads, quadspos, quadsnorm, quadstexcoord, positions, normals, texcoords); } else { throw std::runtime_error("unsupported mesh type " + ext); } } static void load_ply_shape(const string& filename, vector& points, vector& lines, vector& triangles, vector& quads, vector& quadspos, vector& quadsnorm, vector& quadstexcoord, vector& positions, vector& normals, vector& texcoords, vector& colors, vector& radius, bool flip_texcoord) { try { // load ply happly::PLYData ply(filename); // copy vertex data if (ply.hasElement("vertex")) { auto& vertex = ply.getElement("vertex"); if (vertex.hasProperty("x") && vertex.hasProperty("y") && vertex.hasProperty("z")) { auto x = vertex.getProperty("x"); auto y = vertex.getProperty("y"); auto z = vertex.getProperty("z"); positions.resize(x.size()); for (auto i = 0; i < positions.size(); i++) { positions[i] = {x[i], y[i], z[i]}; } } else { throw std::runtime_error("vertex positions not present"); } if (vertex.hasProperty("nx") && vertex.hasProperty("ny") && vertex.hasProperty("nz")) { auto x = vertex.getProperty("nx"); auto y = vertex.getProperty("ny"); auto z = vertex.getProperty("nz"); normals.resize(x.size()); for (auto i = 0; i < normals.size(); i++) { normals[i] = {x[i], y[i], z[i]}; } } if (vertex.hasProperty("u") && vertex.hasProperty("v")) { auto x = vertex.getProperty("u"); auto y = vertex.getProperty("v"); texcoords.resize(x.size()); for (auto i = 0; i < texcoords.size(); i++) { texcoords[i] = {x[i], y[i]}; } } if (vertex.hasProperty("s") && vertex.hasProperty("t")) { auto x = vertex.getProperty("s"); auto y = vertex.getProperty("t"); texcoords.resize(x.size()); for (auto i = 0; i < texcoords.size(); i++) { texcoords[i] = {x[i], y[i]}; } } if (vertex.hasProperty("red") && vertex.hasProperty("green") && vertex.hasProperty("blue")) { auto x = vertex.getProperty("red"); auto y = vertex.getProperty("green"); auto z = vertex.getProperty("blue"); colors.resize(x.size()); for (auto i = 0; i < colors.size(); i++) { colors[i] = {x[i], y[i], z[i], 1}; } if (vertex.hasProperty("alpha")) { auto w = vertex.getProperty("alpha"); for (auto i = 0; i < colors.size(); i++) { colors[i].w = w[i]; } } } if (vertex.hasProperty("radius")) { radius = vertex.getProperty("radius"); } } // fix texture coordinated if (flip_texcoord && !texcoords.empty()) { for (auto& uv : texcoords) uv.y = 1 - uv.y; } // copy face data if (ply.hasElement("face")) { auto& elements = ply.getElement("face"); if (!elements.hasProperty("vertex_indices")) throw std::runtime_error("bad ply faces"); auto indices = vector>{}; try { indices = elements.getListProperty("vertex_indices"); } catch (...) { (vector>&)indices = elements.getListProperty("vertex_indices"); } for (auto& face : indices) { if (face.size() == 4) { quads.push_back({face[0], face[1], face[2], face[3]}); } else { for (auto i = 2; i < face.size(); i++) triangles.push_back({face[0], face[i - 1], face[i]}); } } } // copy face data if (ply.hasElement("line")) { auto& elements = ply.getElement("line"); if (!elements.hasProperty("vertex_indices")) throw std::runtime_error("bad ply lines"); auto indices = vector>{}; try { indices = elements.getListProperty("vertex_indices"); } catch (...) { (vector>&)indices = elements.getListProperty("vertex_indices"); } for (auto& line : indices) { for (auto i = 1; i < line.size(); i++) lines.push_back({line[i], line[i - 1]}); } } merge_triangles_and_quads(triangles, quads, false); } catch (const std::exception& e) { throw std::runtime_error("cannot load mesh " + filename + "\n" + e.what()); } } // Save ply mesh static void save_ply_shape(const string& filename, const vector& points, const vector& lines, const vector& triangles, const vector& quads, const vector& quadspos, const vector& quadsnorm, const vector& quadstexcoord, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, bool ascii, bool flip_texcoord) { if (!quadspos.empty()) { auto split_quads = vector{}; auto split_positions = vector{}; auto split_normals = vector{}; auto split_texturecoords = vector{}; split_facevarying(split_quads, split_positions, split_normals, split_texturecoords, quadspos, quadsnorm, quadstexcoord, positions, normals, texcoords); return save_ply_shape(filename, {}, {}, {}, split_quads, {}, {}, {}, split_positions, split_normals, split_texturecoords, {}, {}, ascii, flip_texcoord); } // empty data happly::PLYData ply; ply.comments.push_back("Written by Yocto/GL"); ply.comments.push_back("https://github.com/xelatihy/yocto-gl"); // add elements ply.addElement("vertex", positions.size()); if (!positions.empty()) { auto& vertex = ply.getElement("vertex"); auto x = vector{}; auto y = vector{}; auto z = vector{}; for (auto& p : positions) { x.push_back(p.x); y.push_back(p.y); z.push_back(p.z); } vertex.addProperty("x", x); vertex.addProperty("y", y); vertex.addProperty("z", z); } if (!normals.empty()) { auto& vertex = ply.getElement("vertex"); auto x = vector{}; auto y = vector{}; auto z = vector{}; for (auto& n : normals) { x.push_back(n.x); y.push_back(n.y); z.push_back(n.z); } vertex.addProperty("nx", x); vertex.addProperty("ny", y); vertex.addProperty("nz", z); } if (!texcoords.empty()) { auto& vertex = ply.getElement("vertex"); auto x = vector{}; auto y = vector{}; for (auto& t : texcoords) { x.push_back(t.x); y.push_back(flip_texcoord ? 1 - t.y : t.y); } vertex.addProperty("u", x); vertex.addProperty("v", y); } if (!colors.empty()) { auto& vertex = ply.getElement("vertex"); auto x = vector{}; auto y = vector{}; auto z = vector{}; auto w = vector{}; for (auto& c : colors) { x.push_back(c.x); y.push_back(c.y); z.push_back(c.z); w.push_back(c.w); } vertex.addProperty("red", x); vertex.addProperty("green", y); vertex.addProperty("blue", z); vertex.addProperty("alpha", w); } if (!radius.empty()) { auto& vertex = ply.getElement("vertex"); vertex.addProperty("radius", radius); } // face date if (!triangles.empty() || !quads.empty()) { ply.addElement("face", triangles.size() + quads.size()); auto elements = vector>{}; for (auto& t : triangles) { elements.push_back({t.x, t.y, t.z}); } for (auto& q : quads) { if (q.z == q.w) { elements.push_back({q.x, q.y, q.z}); } else { elements.push_back({q.x, q.y, q.z, q.w}); } } ply.getElement("face").addListProperty("vertex_indices", elements); } if (!lines.empty()) { ply.addElement("line", lines.size()); auto elements = vector>{}; for (auto& l : lines) { elements.push_back({l.x, l.y}); } ply.getElement("line").addListProperty("vertex_indices", elements); } if (!points.empty() || !quads.empty()) { ply.addElement("point", points.size()); auto elements = vector>{}; for (auto& p : points) { elements.push_back({p}); } ply.getElement("point").addListProperty("vertex_indices", elements); } // Write our data try { ply.write(filename, ascii ? happly::DataFormat::ASCII : happly::DataFormat::Binary); } catch (const std::exception& e) { throw std::runtime_error("cannot save mesh " + filename + "\n" + e.what()); } } struct load_obj_shape_cb : obj_callbacks { vector& points; vector& lines; vector& triangles; vector& quads; vector& quadspos; vector& quadsnorm; vector& quadstexcoord; vector& positions; vector& normals; vector& texcoords; bool facevarying = false; // TODO: implement me // obj vertices std::deque opos = std::deque(); std::deque onorm = std::deque(); std::deque otexcoord = std::deque(); // vertex maps unordered_map vertex_map = unordered_map(); // vertex maps unordered_map pos_map = unordered_map(); unordered_map texcoord_map = unordered_map(); unordered_map norm_map = unordered_map(); load_obj_shape_cb(vector& points, vector& lines, vector& triangles, vector& quads, vector& quadspos, vector& quadsnorm, vector& quadstexcoord, vector& positions, vector& normals, vector& texcoords, bool facevarying) : points{points} , lines{lines} , triangles{triangles} , quads{quads} , quadspos{quadspos} , quadsnorm{quadsnorm} , quadstexcoord{quadstexcoord} , positions{positions} , normals{normals} , texcoords{texcoords} , facevarying{facevarying} {} // Add vertices to the current shape void add_verts(const vector& verts) { for (auto& vert : verts) { auto it = vertex_map.find(vert); if (it != vertex_map.end()) continue; auto nverts = (int)positions.size(); vertex_map.insert(it, {vert, nverts}); if (vert.position) positions.push_back(opos.at(vert.position - 1)); if (vert.texcoord) texcoords.push_back(otexcoord.at(vert.texcoord - 1)); if (vert.normal) normals.push_back(onorm.at(vert.normal - 1)); } } // add vertex void add_fvverts(const vector& verts) { for (auto& vert : verts) { if (!vert.position) continue; auto pos_it = pos_map.find(vert.position); if (pos_it != pos_map.end()) continue; auto nverts = (int)positions.size(); pos_map.insert(pos_it, {vert.position, nverts}); positions.push_back(opos.at(vert.position - 1)); } for (auto& vert : verts) { if (!vert.texcoord) continue; auto texcoord_it = texcoord_map.find(vert.texcoord); if (texcoord_it != texcoord_map.end()) continue; auto nverts = (int)texcoords.size(); texcoord_map.insert(texcoord_it, {vert.texcoord, nverts}); texcoords.push_back(otexcoord.at(vert.texcoord - 1)); } for (auto& vert : verts) { if (!vert.normal) continue; auto norm_it = norm_map.find(vert.normal); if (norm_it != norm_map.end()) continue; auto nverts = (int)normals.size(); norm_map.insert(norm_it, {vert.normal, nverts}); normals.push_back(onorm.at(vert.normal - 1)); } } void vert(const vec3f& v) override { opos.push_back(v); } void norm(const vec3f& v) override { onorm.push_back(v); } void texcoord(const vec2f& v) override { otexcoord.push_back(v); } void face(const vector& verts) override { if (!facevarying) { add_verts(verts); if (verts.size() == 4) { quads.push_back({vertex_map.at(verts[0]), vertex_map.at(verts[1]), vertex_map.at(verts[2]), vertex_map.at(verts[3])}); } else { for (auto i = 2; i < verts.size(); i++) triangles.push_back({vertex_map.at(verts[0]), vertex_map.at(verts[i - 1]), vertex_map.at(verts[i])}); } } else { add_fvverts(verts); if (verts.size() == 4) { if (verts[0].position) { quadspos.push_back({pos_map.at(verts[0].position), pos_map.at(verts[1].position), pos_map.at(verts[2].position), pos_map.at(verts[3].position)}); } if (verts[0].texcoord) { quadstexcoord.push_back({texcoord_map.at(verts[0].texcoord), texcoord_map.at(verts[1].texcoord), texcoord_map.at(verts[2].texcoord), texcoord_map.at(verts[3].texcoord)}); } if (verts[0].normal) { quadsnorm.push_back( {norm_map.at(verts[0].normal), norm_map.at(verts[1].normal), norm_map.at(verts[2].normal), norm_map.at(verts[3].normal)}); } // quads_materials.push_back(current_material_id); } else { if (verts[0].position) { for (auto i = 2; i < verts.size(); i++) quadspos.push_back({pos_map.at(verts[0].position), pos_map.at(verts[1].position), pos_map.at(verts[i].position), pos_map.at(verts[i].position)}); } if (verts[0].texcoord) { for (auto i = 2; i < verts.size(); i++) quadstexcoord.push_back({texcoord_map.at(verts[0].texcoord), texcoord_map.at(verts[1].texcoord), texcoord_map.at(verts[i].texcoord), texcoord_map.at(verts[i].texcoord)}); } if (verts[0].normal) { for (auto i = 2; i < verts.size(); i++) quadsnorm.push_back({norm_map.at(verts[0].normal), norm_map.at(verts[1].normal), norm_map.at(verts[i].normal), norm_map.at(verts[i].normal)}); } // for (auto i = 2; i < verts.size(); // i++) // quads_materials.push_back(current_material_id); } } } void line(const vector& verts) override { add_verts(verts); for (auto i = 1; i < verts.size(); i++) lines.push_back({vertex_map.at(verts[i - 1]), vertex_map.at(verts[i])}); } void point(const vector& verts) override { add_verts(verts); for (auto i = 0; i < verts.size(); i++) points.push_back(vertex_map.at(verts[i])); } // void usemtl(const string& name) { // auto pos = std::find( // material_group.begin(), // material_group.end(), name); // if (pos == material_group.end()) { // material_group.push_back(name); // current_material_id = (int)material_group.size() - 1; // } else { // current_material_id = (int)(pos - // material_group.begin()); // } // } }; // Load ply mesh static void load_obj_shape(const string& filename, vector& points, vector& lines, vector& triangles, vector& quads, vector& quadspos, vector& quadsnorm, vector& quadstexcoord, vector& positions, vector& normals, vector& texcoords, bool facevarying, bool flip_texcoord) { try { // load obj auto cb = load_obj_shape_cb{points, lines, triangles, quads, quadspos, quadsnorm, quadstexcoord, positions, normals, texcoords, facevarying}; load_obj(filename, cb, true, flip_texcoord); // merging quads and triangles if (!facevarying) { merge_triangles_and_quads(triangles, quads, false); } } catch (const std::exception& e) { throw std::runtime_error("cannot load mesh " + filename + "\n" + e.what()); } } // A file holder that closes a file when destructed. Useful for RIIA struct file_holder { FILE* fs = nullptr; string filename = ""; file_holder(const file_holder&) = delete; file_holder& operator=(const file_holder&) = delete; ~file_holder() { if (fs) fclose(fs); } }; // Opens a file returing a handle with RIIA static inline file_holder open_input_file( const string& filename, bool binary = false) { auto fs = fopen(filename.c_str(), !binary ? "rt" : "rb"); if (!fs) throw std::runtime_error("could not open file " + filename); return {fs, filename}; } static inline file_holder open_output_file( const string& filename, bool binary = false) { auto fs = fopen(filename.c_str(), !binary ? "wt" : "wb"); if (!fs) throw std::runtime_error("could not open file " + filename); return {fs, filename}; } // Write text to file static inline void write_obj_value(FILE* fs, float value) { if (fprintf(fs, "%g", value) < 0) throw std::runtime_error("cannot print value"); } static inline void write_obj_text(FILE* fs, const char* value) { if (fprintf(fs, "%s", value) < 0) throw std::runtime_error("cannot print value"); } static inline void write_obj_value(FILE* fs, const char* value) { if (fprintf(fs, "%s", value) < 0) throw std::runtime_error("cannot print value"); } static void write_obj_value(FILE* fs, const obj_vertex& value) { if (fprintf(fs, "%d", value.position) < 0) throw std::runtime_error("cannot write value"); if (value.texcoord) { if (fprintf(fs, "/%d", value.texcoord) < 0) throw std::runtime_error("cannot write value"); if (value.normal) { if (fprintf(fs, "/%d", value.normal) < 0) throw std::runtime_error("cannot write value"); } } else if (value.normal) { if (fprintf(fs, "//%d", value.normal) < 0) throw std::runtime_error("cannot write value"); } } template static inline void write_obj_line( FILE* fs, const T& value, const Ts... values) { write_obj_value(fs, value); if constexpr (sizeof...(values) == 0) { write_obj_text(fs, "\n"); } else { write_obj_text(fs, " "); write_obj_line(fs, values...); } } // Load ply mesh static void save_obj_shape(const string& filename, const vector& points, const vector& lines, const vector& triangles, const vector& quads, const vector& quadspos, const vector& quadsnorm, const vector& quadstexcoord, const vector& positions, const vector& normals, const vector& texcoords, bool flip_texcoord) { // open file auto fs_ = open_output_file(filename); auto fs = fs_.fs; write_obj_text(fs, "#\n"); write_obj_text(fs, "# Written by Yocto/GL\n"); write_obj_text(fs, "# https://github.com/xelatihy/yocto-gl\n"); write_obj_text(fs, "#\n"); for (auto& p : positions) write_obj_line(fs, "v", p.x, p.y, p.z); for (auto& n : normals) write_obj_line(fs, "vn", n.x, n.y, n.z); for (auto& t : texcoords) write_obj_line(fs, "vt", t.x, (flip_texcoord) ? 1 - t.y : t.y); auto mask = obj_vertex{1, texcoords.empty() ? 0 : 1, normals.empty() ? 0 : 1}; auto vert = [mask](int i) { return obj_vertex{(i + 1) * mask.position, (i + 1) * mask.texcoord, (i + 1) * mask.normal}; }; for (auto& p : points) { write_obj_line(fs, "p", vert(p)); } for (auto& l : lines) { write_obj_line(fs, "l", vert(l.x), vert(l.y)); } for (auto& t : triangles) { write_obj_line(fs, "f", vert(t.x), vert(t.y), vert(t.z)); } for (auto& q : quads) { if (q.z == q.w) { write_obj_line(fs, "f", vert(q.x), vert(q.y), vert(q.z)); } else { write_obj_line(fs, "f", vert(q.x), vert(q.y), vert(q.z), vert(q.w)); } } auto fvmask = obj_vertex{ 1, texcoords.empty() ? 0 : 1, normals.empty() ? 0 : 1}; auto fvvert = [fvmask](int pi, int ti, int ni) { return obj_vertex{(pi + 1) * fvmask.position, (ti + 1) * fvmask.texcoord, (ni + 1) * fvmask.normal}; }; // auto last_material_id = -1; for (auto i = 0; i < quadspos.size(); i++) { // if (!quads_materials.empty() && // quads_materials[i] != last_material_id) { // last_material_id = quads_materials[i]; // println_values(fs, "usemtl material_{}\n", // last_material_id); // } auto qp = quadspos.at(i); auto qt = !quadstexcoord.empty() ? quadstexcoord.at(i) : vec4i{-1, -1, -1, -1}; auto qn = !quadsnorm.empty() ? quadsnorm.at(i) : vec4i{-1, -1, -1, -1}; if (qp.z != qp.w) { write_obj_line(fs, "f", fvvert(qp.x, qt.x, qn.x), fvvert(qp.y, qt.y, qn.y), fvvert(qp.z, qt.z, qn.z), fvvert(qp.w, qt.w, qn.w)); } else { write_obj_line(fs, "f", fvvert(qp.x, qt.x, qn.x), fvvert(qp.y, qt.y, qn.y), fvvert(qp.z, qt.z, qn.z)); } } } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION OF CYHAIR // ----------------------------------------------------------------------------- namespace yocto { struct cyhair_strand { vector positions; vector radius; vector transparency; vector color; }; struct cyhair_data { vector strands = {}; float default_thickness = 0; float default_transparency = 0; vec3f default_color = zero3f; }; static void load_cyhair(const string& filename, cyhair_data& hair) { // open file hair = {}; auto fs_ = open_input_file(filename, true); auto fs = fs_.fs; // Bytes 0-3 Must be "HAIR" in ascii code (48 41 49 52) // Bytes 4-7 Number of hair strands as unsigned int // Bytes 8-11 Total number of points of all strands as unsigned int // Bytes 12-15 Bit array of data in the file // Bit-0 is 1 if the file has segments array. // Bit-1 is 1 if the file has points array (this bit must be 1). // Bit-2 is 1 if the file has radius array. // Bit-3 is 1 if the file has transparency array. // Bit-4 is 1 if the file has color array. // Bit-5 to Bit-31 are reserved for future extension (must be 0). // Bytes 16-19 Default number of segments of hair strands as unsigned int // If the file does not have a segments array, this default value is used. // Bytes 20-23 Default radius hair strands as float // If the file does not have a radius array, this default value is used. // Bytes 24-27 Default transparency hair strands as float // If the file does not have a transparency array, this default value is // used. Bytes 28-39 Default color hair strands as float array of size 3 // If the file does not have a radius array, this default value is used. // Bytes 40-127 File information as char array of size 88 in ascii auto read_value = [](FILE* fs, auto& value) { if (fread(&value, sizeof(value), 1, fs) != 1) { throw std::runtime_error("cannot read from file"); } }; auto read_values = [](FILE* fs, auto& values) { if (values.empty()) return; if (fread(values.data(), sizeof(values[0]), values.size(), fs) != values.size()) { throw std::runtime_error("cannot read from file"); } }; // parse header hair = cyhair_data{}; struct cyhair_header { char magic[4] = {0}; unsigned int num_strands = 0; unsigned int num_points = 0; unsigned int flags = 0; unsigned int default_segments = 0; float default_thickness = 0; float default_transparency = 0; vec3f default_color = zero3f; char info[88] = {0}; }; static_assert(sizeof(cyhair_header) == 128); auto header = cyhair_header{}; read_value(fs, header); if (header.magic[0] != 'H' || header.magic[1] != 'A' || header.magic[2] != 'I' || header.magic[3] != 'R') throw std::runtime_error("bad cyhair header"); // set up data hair.default_thickness = header.default_thickness; hair.default_transparency = header.default_transparency; hair.default_color = header.default_color; hair.strands.resize(header.num_strands); // get segments length auto segments = vector(); if (header.flags & 1) { segments.resize(header.num_strands); read_values(fs, segments); } else { segments.assign(header.num_strands, header.default_segments); } // check segment length auto total_length = 0; for (auto segment : segments) total_length += segment + 1; if (total_length != header.num_points) { throw std::runtime_error("bad cyhair file"); } // read positions data if (header.flags & 2) { for (auto strand_id = 0; strand_id < header.num_strands; strand_id++) { auto strand_size = (int)segments[strand_id] + 1; hair.strands[strand_id].positions.resize(strand_size); read_values(fs, hair.strands[strand_id].positions); } } // read radius data if (header.flags & 4) { for (auto strand_id = 0; strand_id < header.num_strands; strand_id++) { auto strand_size = (int)segments[strand_id] + 1; hair.strands[strand_id].radius.resize(strand_size); read_values(fs, hair.strands[strand_id].radius); } } // read transparency data if (header.flags & 8) { for (auto strand_id = 0; strand_id < header.num_strands; strand_id++) { auto strand_size = (int)segments[strand_id] + 1; hair.strands[strand_id].transparency.resize(strand_size); read_values(fs, hair.strands[strand_id].transparency); } } // read color data if (header.flags & 16) { for (auto strand_id = 0; strand_id < header.num_strands; strand_id++) { auto strand_size = (int)segments[strand_id] + 1; hair.strands[strand_id].color.resize(strand_size); read_values(fs, hair.strands[strand_id].color); } } } static void load_cyhair_shape(const string& filename, vector& lines, vector& positions, vector& normals, vector& texcoords, vector& color, vector& radius, bool flip_texcoord) { // load hair file auto hair = cyhair_data(); load_cyhair(filename, hair); // generate curve data for (auto& strand : hair.strands) { auto offset = (int)positions.size(); for (auto segment = 0; segment < (int)strand.positions.size() - 1; segment++) { lines.push_back({offset + segment, offset + segment + 1}); } positions.insert( positions.end(), strand.positions.begin(), strand.positions.end()); if (strand.radius.empty()) { radius.insert( radius.end(), strand.positions.size(), hair.default_thickness); } else { radius.insert(radius.end(), strand.radius.begin(), strand.radius.end()); } if (strand.color.empty()) { color.insert(color.end(), strand.positions.size(), {hair.default_color.x, hair.default_color.y, hair.default_color.z, 1}); } else { for (auto i = 0; i < strand.color.size(); i++) { auto scolor = strand.color[i]; color.push_back({scolor.x, scolor.y, scolor.z, 1}); } } } // flip yz for (auto& p : positions) std::swap(p.y, p.z); // compute tangents normals.resize(positions.size()); compute_tangents(normals, lines, positions); // fix colors for (auto& c : color) c = {pow(xyz(c), 2.2f), c.w}; } } // namespace yocto #endif // ----------------------------------------------------------------------------- // EMBEDDED SHAPE DATA // ----------------------------------------------------------------------------- namespace yocto { const vector quad_positions = vector{ {-1, -1, 0}, {+1, -1, 0}, {+1, +1, 0}, {-1, +1, 0}}; const vector quad_normals = vector{ {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}}; const vector quad_texcoords = vector{ {0, 1}, {1, 1}, {1, 0}, {0, 0}}; const vector quad_quads = vector{{0, 1, 2, 3}}; const vector quady_positions = vector{ {-1, 0, -1}, {-1, 0, +1}, {+1, 0, +1}, {+1, 0, -1}}; const vector quady_normals = vector{ {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}; const vector quady_texcoords = vector{ {0, 0}, {1, 0}, {1, 1}, {0, 1}}; const vector quady_quads = vector{{0, 1, 2, 3}}; const vector cube_positions = vector{{-1, -1, +1}, {+1, -1, +1}, {+1, +1, +1}, {-1, +1, +1}, {+1, -1, -1}, {-1, -1, -1}, {-1, +1, -1}, {+1, +1, -1}, {+1, -1, +1}, {+1, -1, -1}, {+1, +1, -1}, {+1, +1, +1}, {-1, -1, -1}, {-1, -1, +1}, {-1, +1, +1}, {-1, +1, -1}, {-1, +1, +1}, {+1, +1, +1}, {+1, +1, -1}, {-1, +1, -1}, {+1, -1, +1}, {-1, -1, +1}, {-1, -1, -1}, {+1, -1, -1}}; const vector cube_normals = vector{{0, 0, +1}, {0, 0, +1}, {0, 0, +1}, {0, 0, +1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {+1, 0, 0}, {+1, 0, 0}, {+1, 0, 0}, {+1, 0, 0}, {-1, 0, 0}, {-1, 0, 0}, {-1, 0, 0}, {-1, 0, 0}, {0, +1, 0}, {0, +1, 0}, {0, +1, 0}, {0, +1, 0}, {0, -1, 0}, {0, -1, 0}, {0, -1, 0}, {0, -1, 0}}; const vector cube_texcoords = vector{{0, 1}, {1, 1}, {1, 0}, {0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}}; const vector cube_quads = vector{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, 14, 15}, {16, 17, 18, 19}, {20, 21, 22, 23}}; const vector fvcube_positions = vector{{-1, -1, +1}, {+1, -1, +1}, {+1, +1, +1}, {-1, +1, +1}, {+1, -1, -1}, {-1, -1, -1}, {-1, +1, -1}, {+1, +1, -1}}; const vector fvcube_quads = vector{{0, 1, 2, 3}, {4, 5, 6, 7}, {1, 4, 7, 2}, {5, 0, 3, 6}, {3, 2, 7, 6}, {1, 0, 5, 4}}; const vector suzanne_positions = vector{ {0.4375, 0.1640625, 0.765625}, {-0.4375, 0.1640625, 0.765625}, {0.5, 0.09375, 0.6875}, {-0.5, 0.09375, 0.6875}, {0.546875, 0.0546875, 0.578125}, {-0.546875, 0.0546875, 0.578125}, {0.3515625, -0.0234375, 0.6171875}, {-0.3515625, -0.0234375, 0.6171875}, {0.3515625, 0.03125, 0.71875}, {-0.3515625, 0.03125, 0.71875}, {0.3515625, 0.1328125, 0.78125}, {-0.3515625, 0.1328125, 0.78125}, {0.2734375, 0.1640625, 0.796875}, {-0.2734375, 0.1640625, 0.796875}, {0.203125, 0.09375, 0.7421875}, {-0.203125, 0.09375, 0.7421875}, {0.15625, 0.0546875, 0.6484375}, {-0.15625, 0.0546875, 0.6484375}, {0.078125, 0.2421875, 0.65625}, {-0.078125, 0.2421875, 0.65625}, {0.140625, 0.2421875, 0.7421875}, {-0.140625, 0.2421875, 0.7421875}, {0.2421875, 0.2421875, 0.796875}, {-0.2421875, 0.2421875, 0.796875}, {0.2734375, 0.328125, 0.796875}, {-0.2734375, 0.328125, 0.796875}, {0.203125, 0.390625, 0.7421875}, {-0.203125, 0.390625, 0.7421875}, {0.15625, 0.4375, 0.6484375}, {-0.15625, 0.4375, 0.6484375}, {0.3515625, 0.515625, 0.6171875}, {-0.3515625, 0.515625, 0.6171875}, {0.3515625, 0.453125, 0.71875}, {-0.3515625, 0.453125, 0.71875}, {0.3515625, 0.359375, 0.78125}, {-0.3515625, 0.359375, 0.78125}, {0.4375, 0.328125, 0.765625}, {-0.4375, 0.328125, 0.765625}, {0.5, 0.390625, 0.6875}, {-0.5, 0.390625, 0.6875}, {0.546875, 0.4375, 0.578125}, {-0.546875, 0.4375, 0.578125}, {0.625, 0.2421875, 0.5625}, {-0.625, 0.2421875, 0.5625}, {0.5625, 0.2421875, 0.671875}, {-0.5625, 0.2421875, 0.671875}, {0.46875, 0.2421875, 0.7578125}, {-0.46875, 0.2421875, 0.7578125}, {0.4765625, 0.2421875, 0.7734375}, {-0.4765625, 0.2421875, 0.7734375}, {0.4453125, 0.3359375, 0.78125}, {-0.4453125, 0.3359375, 0.78125}, {0.3515625, 0.375, 0.8046875}, {-0.3515625, 0.375, 0.8046875}, {0.265625, 0.3359375, 0.8203125}, {-0.265625, 0.3359375, 0.8203125}, {0.2265625, 0.2421875, 0.8203125}, {-0.2265625, 0.2421875, 0.8203125}, {0.265625, 0.15625, 0.8203125}, {-0.265625, 0.15625, 0.8203125}, {0.3515625, 0.2421875, 0.828125}, {-0.3515625, 0.2421875, 0.828125}, {0.3515625, 0.1171875, 0.8046875}, {-0.3515625, 0.1171875, 0.8046875}, {0.4453125, 0.15625, 0.78125}, {-0.4453125, 0.15625, 0.78125}, {0.0, 0.4296875, 0.7421875}, {0.0, 0.3515625, 0.8203125}, {0.0, -0.6796875, 0.734375}, {0.0, -0.3203125, 0.78125}, {0.0, -0.1875, 0.796875}, {0.0, -0.7734375, 0.71875}, {0.0, 0.40625, 0.6015625}, {0.0, 0.5703125, 0.5703125}, {0.0, 0.8984375, -0.546875}, {0.0, 0.5625, -0.8515625}, {0.0, 0.0703125, -0.828125}, {0.0, -0.3828125, -0.3515625}, {0.203125, -0.1875, 0.5625}, {-0.203125, -0.1875, 0.5625}, {0.3125, -0.4375, 0.5703125}, {-0.3125, -0.4375, 0.5703125}, {0.3515625, -0.6953125, 0.5703125}, {-0.3515625, -0.6953125, 0.5703125}, {0.3671875, -0.890625, 0.53125}, {-0.3671875, -0.890625, 0.53125}, {0.328125, -0.9453125, 0.5234375}, {-0.328125, -0.9453125, 0.5234375}, {0.1796875, -0.96875, 0.5546875}, {-0.1796875, -0.96875, 0.5546875}, {0.0, -0.984375, 0.578125}, {0.4375, -0.140625, 0.53125}, {-0.4375, -0.140625, 0.53125}, {0.6328125, -0.0390625, 0.5390625}, {-0.6328125, -0.0390625, 0.5390625}, {0.828125, 0.1484375, 0.4453125}, {-0.828125, 0.1484375, 0.4453125}, {0.859375, 0.4296875, 0.59375}, {-0.859375, 0.4296875, 0.59375}, {0.7109375, 0.484375, 0.625}, {-0.7109375, 0.484375, 0.625}, {0.4921875, 0.6015625, 0.6875}, {-0.4921875, 0.6015625, 0.6875}, {0.3203125, 0.7578125, 0.734375}, {-0.3203125, 0.7578125, 0.734375}, {0.15625, 0.71875, 0.7578125}, {-0.15625, 0.71875, 0.7578125}, {0.0625, 0.4921875, 0.75}, {-0.0625, 0.4921875, 0.75}, {0.1640625, 0.4140625, 0.7734375}, {-0.1640625, 0.4140625, 0.7734375}, {0.125, 0.3046875, 0.765625}, {-0.125, 0.3046875, 0.765625}, {0.203125, 0.09375, 0.7421875}, {-0.203125, 0.09375, 0.7421875}, {0.375, 0.015625, 0.703125}, {-0.375, 0.015625, 0.703125}, {0.4921875, 0.0625, 0.671875}, {-0.4921875, 0.0625, 0.671875}, {0.625, 0.1875, 0.6484375}, {-0.625, 0.1875, 0.6484375}, {0.640625, 0.296875, 0.6484375}, {-0.640625, 0.296875, 0.6484375}, {0.6015625, 0.375, 0.6640625}, {-0.6015625, 0.375, 0.6640625}, {0.4296875, 0.4375, 0.71875}, {-0.4296875, 0.4375, 0.71875}, {0.25, 0.46875, 0.7578125}, {-0.25, 0.46875, 0.7578125}, {0.0, -0.765625, 0.734375}, {0.109375, -0.71875, 0.734375}, {-0.109375, -0.71875, 0.734375}, {0.1171875, -0.8359375, 0.7109375}, {-0.1171875, -0.8359375, 0.7109375}, {0.0625, -0.8828125, 0.6953125}, {-0.0625, -0.8828125, 0.6953125}, {0.0, -0.890625, 0.6875}, {0.0, -0.1953125, 0.75}, {0.0, -0.140625, 0.7421875}, {0.1015625, -0.1484375, 0.7421875}, {-0.1015625, -0.1484375, 0.7421875}, {0.125, -0.2265625, 0.75}, {-0.125, -0.2265625, 0.75}, {0.0859375, -0.2890625, 0.7421875}, {-0.0859375, -0.2890625, 0.7421875}, {0.3984375, -0.046875, 0.671875}, {-0.3984375, -0.046875, 0.671875}, {0.6171875, 0.0546875, 0.625}, {-0.6171875, 0.0546875, 0.625}, {0.7265625, 0.203125, 0.6015625}, {-0.7265625, 0.203125, 0.6015625}, {0.7421875, 0.375, 0.65625}, {-0.7421875, 0.375, 0.65625}, {0.6875, 0.4140625, 0.7265625}, {-0.6875, 0.4140625, 0.7265625}, {0.4375, 0.546875, 0.796875}, {-0.4375, 0.546875, 0.796875}, {0.3125, 0.640625, 0.8359375}, {-0.3125, 0.640625, 0.8359375}, {0.203125, 0.6171875, 0.8515625}, {-0.203125, 0.6171875, 0.8515625}, {0.1015625, 0.4296875, 0.84375}, {-0.1015625, 0.4296875, 0.84375}, {0.125, -0.1015625, 0.8125}, {-0.125, -0.1015625, 0.8125}, {0.2109375, -0.4453125, 0.7109375}, {-0.2109375, -0.4453125, 0.7109375}, {0.25, -0.703125, 0.6875}, {-0.25, -0.703125, 0.6875}, {0.265625, -0.8203125, 0.6640625}, {-0.265625, -0.8203125, 0.6640625}, {0.234375, -0.9140625, 0.6328125}, {-0.234375, -0.9140625, 0.6328125}, {0.1640625, -0.9296875, 0.6328125}, {-0.1640625, -0.9296875, 0.6328125}, {0.0, -0.9453125, 0.640625}, {0.0, 0.046875, 0.7265625}, {0.0, 0.2109375, 0.765625}, {0.328125, 0.4765625, 0.7421875}, {-0.328125, 0.4765625, 0.7421875}, {0.1640625, 0.140625, 0.75}, {-0.1640625, 0.140625, 0.75}, {0.1328125, 0.2109375, 0.7578125}, {-0.1328125, 0.2109375, 0.7578125}, {0.1171875, -0.6875, 0.734375}, {-0.1171875, -0.6875, 0.734375}, {0.078125, -0.4453125, 0.75}, {-0.078125, -0.4453125, 0.75}, {0.0, -0.4453125, 0.75}, {0.0, -0.328125, 0.7421875}, {0.09375, -0.2734375, 0.78125}, {-0.09375, -0.2734375, 0.78125}, {0.1328125, -0.2265625, 0.796875}, {-0.1328125, -0.2265625, 0.796875}, {0.109375, -0.1328125, 0.78125}, {-0.109375, -0.1328125, 0.78125}, {0.0390625, -0.125, 0.78125}, {-0.0390625, -0.125, 0.78125}, {0.0, -0.203125, 0.828125}, {0.046875, -0.1484375, 0.8125}, {-0.046875, -0.1484375, 0.8125}, {0.09375, -0.15625, 0.8125}, {-0.09375, -0.15625, 0.8125}, {0.109375, -0.2265625, 0.828125}, {-0.109375, -0.2265625, 0.828125}, {0.078125, -0.25, 0.8046875}, {-0.078125, -0.25, 0.8046875}, {0.0, -0.2890625, 0.8046875}, {0.2578125, -0.3125, 0.5546875}, {-0.2578125, -0.3125, 0.5546875}, {0.1640625, -0.2421875, 0.7109375}, {-0.1640625, -0.2421875, 0.7109375}, {0.1796875, -0.3125, 0.7109375}, {-0.1796875, -0.3125, 0.7109375}, {0.234375, -0.25, 0.5546875}, {-0.234375, -0.25, 0.5546875}, {0.0, -0.875, 0.6875}, {0.046875, -0.8671875, 0.6875}, {-0.046875, -0.8671875, 0.6875}, {0.09375, -0.8203125, 0.7109375}, {-0.09375, -0.8203125, 0.7109375}, {0.09375, -0.7421875, 0.7265625}, {-0.09375, -0.7421875, 0.7265625}, {0.0, -0.78125, 0.65625}, {0.09375, -0.75, 0.6640625}, {-0.09375, -0.75, 0.6640625}, {0.09375, -0.8125, 0.640625}, {-0.09375, -0.8125, 0.640625}, {0.046875, -0.8515625, 0.6328125}, {-0.046875, -0.8515625, 0.6328125}, {0.0, -0.859375, 0.6328125}, {0.171875, 0.21875, 0.78125}, {-0.171875, 0.21875, 0.78125}, {0.1875, 0.15625, 0.7734375}, {-0.1875, 0.15625, 0.7734375}, {0.3359375, 0.4296875, 0.7578125}, {-0.3359375, 0.4296875, 0.7578125}, {0.2734375, 0.421875, 0.7734375}, {-0.2734375, 0.421875, 0.7734375}, {0.421875, 0.3984375, 0.7734375}, {-0.421875, 0.3984375, 0.7734375}, {0.5625, 0.3515625, 0.6953125}, {-0.5625, 0.3515625, 0.6953125}, {0.5859375, 0.2890625, 0.6875}, {-0.5859375, 0.2890625, 0.6875}, {0.578125, 0.1953125, 0.6796875}, {-0.578125, 0.1953125, 0.6796875}, {0.4765625, 0.1015625, 0.71875}, {-0.4765625, 0.1015625, 0.71875}, {0.375, 0.0625, 0.7421875}, {-0.375, 0.0625, 0.7421875}, {0.2265625, 0.109375, 0.78125}, {-0.2265625, 0.109375, 0.78125}, {0.1796875, 0.296875, 0.78125}, {-0.1796875, 0.296875, 0.78125}, {0.2109375, 0.375, 0.78125}, {-0.2109375, 0.375, 0.78125}, {0.234375, 0.359375, 0.7578125}, {-0.234375, 0.359375, 0.7578125}, {0.1953125, 0.296875, 0.7578125}, {-0.1953125, 0.296875, 0.7578125}, {0.2421875, 0.125, 0.7578125}, {-0.2421875, 0.125, 0.7578125}, {0.375, 0.0859375, 0.7265625}, {-0.375, 0.0859375, 0.7265625}, {0.4609375, 0.1171875, 0.703125}, {-0.4609375, 0.1171875, 0.703125}, {0.546875, 0.2109375, 0.671875}, {-0.546875, 0.2109375, 0.671875}, {0.5546875, 0.28125, 0.671875}, {-0.5546875, 0.28125, 0.671875}, {0.53125, 0.3359375, 0.6796875}, {-0.53125, 0.3359375, 0.6796875}, {0.4140625, 0.390625, 0.75}, {-0.4140625, 0.390625, 0.75}, {0.28125, 0.3984375, 0.765625}, {-0.28125, 0.3984375, 0.765625}, {0.3359375, 0.40625, 0.75}, {-0.3359375, 0.40625, 0.75}, {0.203125, 0.171875, 0.75}, {-0.203125, 0.171875, 0.75}, {0.1953125, 0.2265625, 0.75}, {-0.1953125, 0.2265625, 0.75}, {0.109375, 0.4609375, 0.609375}, {-0.109375, 0.4609375, 0.609375}, {0.1953125, 0.6640625, 0.6171875}, {-0.1953125, 0.6640625, 0.6171875}, {0.3359375, 0.6875, 0.59375}, {-0.3359375, 0.6875, 0.59375}, {0.484375, 0.5546875, 0.5546875}, {-0.484375, 0.5546875, 0.5546875}, {0.6796875, 0.453125, 0.4921875}, {-0.6796875, 0.453125, 0.4921875}, {0.796875, 0.40625, 0.4609375}, {-0.796875, 0.40625, 0.4609375}, {0.7734375, 0.1640625, 0.375}, {-0.7734375, 0.1640625, 0.375}, {0.6015625, 0.0, 0.4140625}, {-0.6015625, 0.0, 0.4140625}, {0.4375, -0.09375, 0.46875}, {-0.4375, -0.09375, 0.46875}, {0.0, 0.8984375, 0.2890625}, {0.0, 0.984375, -0.078125}, {0.0, -0.1953125, -0.671875}, {0.0, -0.4609375, 0.1875}, {0.0, -0.9765625, 0.4609375}, {0.0, -0.8046875, 0.34375}, {0.0, -0.5703125, 0.3203125}, {0.0, -0.484375, 0.28125}, {0.8515625, 0.234375, 0.0546875}, {-0.8515625, 0.234375, 0.0546875}, {0.859375, 0.3203125, -0.046875}, {-0.859375, 0.3203125, -0.046875}, {0.7734375, 0.265625, -0.4375}, {-0.7734375, 0.265625, -0.4375}, {0.4609375, 0.4375, -0.703125}, {-0.4609375, 0.4375, -0.703125}, {0.734375, -0.046875, 0.0703125}, {-0.734375, -0.046875, 0.0703125}, {0.59375, -0.125, -0.1640625}, {-0.59375, -0.125, -0.1640625}, {0.640625, -0.0078125, -0.4296875}, {-0.640625, -0.0078125, -0.4296875}, {0.3359375, 0.0546875, -0.6640625}, {-0.3359375, 0.0546875, -0.6640625}, {0.234375, -0.3515625, 0.40625}, {-0.234375, -0.3515625, 0.40625}, {0.1796875, -0.4140625, 0.2578125}, {-0.1796875, -0.4140625, 0.2578125}, {0.2890625, -0.7109375, 0.3828125}, {-0.2890625, -0.7109375, 0.3828125}, {0.25, -0.5, 0.390625}, {-0.25, -0.5, 0.390625}, {0.328125, -0.9140625, 0.3984375}, {-0.328125, -0.9140625, 0.3984375}, {0.140625, -0.7578125, 0.3671875}, {-0.140625, -0.7578125, 0.3671875}, {0.125, -0.5390625, 0.359375}, {-0.125, -0.5390625, 0.359375}, {0.1640625, -0.9453125, 0.4375}, {-0.1640625, -0.9453125, 0.4375}, {0.21875, -0.28125, 0.4296875}, {-0.21875, -0.28125, 0.4296875}, {0.2109375, -0.2265625, 0.46875}, {-0.2109375, -0.2265625, 0.46875}, {0.203125, -0.171875, 0.5}, {-0.203125, -0.171875, 0.5}, {0.2109375, -0.390625, 0.1640625}, {-0.2109375, -0.390625, 0.1640625}, {0.296875, -0.3125, -0.265625}, {-0.296875, -0.3125, -0.265625}, {0.34375, -0.1484375, -0.5390625}, {-0.34375, -0.1484375, -0.5390625}, {0.453125, 0.8671875, -0.3828125}, {-0.453125, 0.8671875, -0.3828125}, {0.453125, 0.9296875, -0.0703125}, {-0.453125, 0.9296875, -0.0703125}, {0.453125, 0.8515625, 0.234375}, {-0.453125, 0.8515625, 0.234375}, {0.4609375, 0.5234375, 0.4296875}, {-0.4609375, 0.5234375, 0.4296875}, {0.7265625, 0.40625, 0.3359375}, {-0.7265625, 0.40625, 0.3359375}, {0.6328125, 0.453125, 0.28125}, {-0.6328125, 0.453125, 0.28125}, {0.640625, 0.703125, 0.0546875}, {-0.640625, 0.703125, 0.0546875}, {0.796875, 0.5625, 0.125}, {-0.796875, 0.5625, 0.125}, {0.796875, 0.6171875, -0.1171875}, {-0.796875, 0.6171875, -0.1171875}, {0.640625, 0.75, -0.1953125}, {-0.640625, 0.75, -0.1953125}, {0.640625, 0.6796875, -0.4453125}, {-0.640625, 0.6796875, -0.4453125}, {0.796875, 0.5390625, -0.359375}, {-0.796875, 0.5390625, -0.359375}, {0.6171875, 0.328125, -0.5859375}, {-0.6171875, 0.328125, -0.5859375}, {0.484375, 0.0234375, -0.546875}, {-0.484375, 0.0234375, -0.546875}, {0.8203125, 0.328125, -0.203125}, {-0.8203125, 0.328125, -0.203125}, {0.40625, -0.171875, 0.1484375}, {-0.40625, -0.171875, 0.1484375}, {0.4296875, -0.1953125, -0.2109375}, {-0.4296875, -0.1953125, -0.2109375}, {0.890625, 0.40625, -0.234375}, {-0.890625, 0.40625, -0.234375}, {0.7734375, -0.140625, -0.125}, {-0.7734375, -0.140625, -0.125}, {1.0390625, -0.1015625, -0.328125}, {-1.0390625, -0.1015625, -0.328125}, {1.28125, 0.0546875, -0.4296875}, {-1.28125, 0.0546875, -0.4296875}, {1.3515625, 0.3203125, -0.421875}, {-1.3515625, 0.3203125, -0.421875}, {1.234375, 0.5078125, -0.421875}, {-1.234375, 0.5078125, -0.421875}, {1.0234375, 0.4765625, -0.3125}, {-1.0234375, 0.4765625, -0.3125}, {1.015625, 0.4140625, -0.2890625}, {-1.015625, 0.4140625, -0.2890625}, {1.1875, 0.4375, -0.390625}, {-1.1875, 0.4375, -0.390625}, {1.265625, 0.2890625, -0.40625}, {-1.265625, 0.2890625, -0.40625}, {1.2109375, 0.078125, -0.40625}, {-1.2109375, 0.078125, -0.40625}, {1.03125, -0.0390625, -0.3046875}, {-1.03125, -0.0390625, -0.3046875}, {0.828125, -0.0703125, -0.1328125}, {-0.828125, -0.0703125, -0.1328125}, {0.921875, 0.359375, -0.21875}, {-0.921875, 0.359375, -0.21875}, {0.9453125, 0.3046875, -0.2890625}, {-0.9453125, 0.3046875, -0.2890625}, {0.8828125, -0.0234375, -0.2109375}, {-0.8828125, -0.0234375, -0.2109375}, {1.0390625, 0.0, -0.3671875}, {-1.0390625, 0.0, -0.3671875}, {1.1875, 0.09375, -0.4453125}, {-1.1875, 0.09375, -0.4453125}, {1.234375, 0.25, -0.4453125}, {-1.234375, 0.25, -0.4453125}, {1.171875, 0.359375, -0.4375}, {-1.171875, 0.359375, -0.4375}, {1.0234375, 0.34375, -0.359375}, {-1.0234375, 0.34375, -0.359375}, {0.84375, 0.2890625, -0.2109375}, {-0.84375, 0.2890625, -0.2109375}, {0.8359375, 0.171875, -0.2734375}, {-0.8359375, 0.171875, -0.2734375}, {0.7578125, 0.09375, -0.2734375}, {-0.7578125, 0.09375, -0.2734375}, {0.8203125, 0.0859375, -0.2734375}, {-0.8203125, 0.0859375, -0.2734375}, {0.84375, 0.015625, -0.2734375}, {-0.84375, 0.015625, -0.2734375}, {0.8125, -0.015625, -0.2734375}, {-0.8125, -0.015625, -0.2734375}, {0.7265625, 0.0, -0.0703125}, {-0.7265625, 0.0, -0.0703125}, {0.71875, -0.0234375, -0.171875}, {-0.71875, -0.0234375, -0.171875}, {0.71875, 0.0390625, -0.1875}, {-0.71875, 0.0390625, -0.1875}, {0.796875, 0.203125, -0.2109375}, {-0.796875, 0.203125, -0.2109375}, {0.890625, 0.2421875, -0.265625}, {-0.890625, 0.2421875, -0.265625}, {0.890625, 0.234375, -0.3203125}, {-0.890625, 0.234375, -0.3203125}, {0.8125, -0.015625, -0.3203125}, {-0.8125, -0.015625, -0.3203125}, {0.8515625, 0.015625, -0.3203125}, {-0.8515625, 0.015625, -0.3203125}, {0.828125, 0.078125, -0.3203125}, {-0.828125, 0.078125, -0.3203125}, {0.765625, 0.09375, -0.3203125}, {-0.765625, 0.09375, -0.3203125}, {0.84375, 0.171875, -0.3203125}, {-0.84375, 0.171875, -0.3203125}, {1.0390625, 0.328125, -0.4140625}, {-1.0390625, 0.328125, -0.4140625}, {1.1875, 0.34375, -0.484375}, {-1.1875, 0.34375, -0.484375}, {1.2578125, 0.2421875, -0.4921875}, {-1.2578125, 0.2421875, -0.4921875}, {1.2109375, 0.0859375, -0.484375}, {-1.2109375, 0.0859375, -0.484375}, {1.046875, 0.0, -0.421875}, {-1.046875, 0.0, -0.421875}, {0.8828125, -0.015625, -0.265625}, {-0.8828125, -0.015625, -0.265625}, {0.953125, 0.2890625, -0.34375}, {-0.953125, 0.2890625, -0.34375}, {0.890625, 0.109375, -0.328125}, {-0.890625, 0.109375, -0.328125}, {0.9375, 0.0625, -0.3359375}, {-0.9375, 0.0625, -0.3359375}, {1.0, 0.125, -0.3671875}, {-1.0, 0.125, -0.3671875}, {0.9609375, 0.171875, -0.3515625}, {-0.9609375, 0.171875, -0.3515625}, {1.015625, 0.234375, -0.375}, {-1.015625, 0.234375, -0.375}, {1.0546875, 0.1875, -0.3828125}, {-1.0546875, 0.1875, -0.3828125}, {1.109375, 0.2109375, -0.390625}, {-1.109375, 0.2109375, -0.390625}, {1.0859375, 0.2734375, -0.390625}, {-1.0859375, 0.2734375, -0.390625}, {1.0234375, 0.4375, -0.484375}, {-1.0234375, 0.4375, -0.484375}, {1.25, 0.46875, -0.546875}, {-1.25, 0.46875, -0.546875}, {1.3671875, 0.296875, -0.5}, {-1.3671875, 0.296875, -0.5}, {1.3125, 0.0546875, -0.53125}, {-1.3125, 0.0546875, -0.53125}, {1.0390625, -0.0859375, -0.4921875}, {-1.0390625, -0.0859375, -0.4921875}, {0.7890625, -0.125, -0.328125}, {-0.7890625, -0.125, -0.328125}, {0.859375, 0.3828125, -0.3828125}, {-0.859375, 0.3828125, -0.3828125}}; const vector suzanne_quads = vector{{46, 0, 2, 44}, {3, 1, 47, 45}, {44, 2, 4, 42}, {5, 3, 45, 43}, {2, 8, 6, 4}, {7, 9, 3, 5}, {0, 10, 8, 2}, {9, 11, 1, 3}, {10, 12, 14, 8}, {15, 13, 11, 9}, {8, 14, 16, 6}, {17, 15, 9, 7}, {14, 20, 18, 16}, {19, 21, 15, 17}, {12, 22, 20, 14}, {21, 23, 13, 15}, {22, 24, 26, 20}, {27, 25, 23, 21}, {20, 26, 28, 18}, {29, 27, 21, 19}, {26, 32, 30, 28}, {31, 33, 27, 29}, {24, 34, 32, 26}, {33, 35, 25, 27}, {34, 36, 38, 32}, {39, 37, 35, 33}, {32, 38, 40, 30}, {41, 39, 33, 31}, {38, 44, 42, 40}, {43, 45, 39, 41}, {36, 46, 44, 38}, {45, 47, 37, 39}, {46, 36, 50, 48}, {51, 37, 47, 49}, {36, 34, 52, 50}, {53, 35, 37, 51}, {34, 24, 54, 52}, {55, 25, 35, 53}, {24, 22, 56, 54}, {57, 23, 25, 55}, {22, 12, 58, 56}, {59, 13, 23, 57}, {12, 10, 62, 58}, {63, 11, 13, 59}, {10, 0, 64, 62}, {65, 1, 11, 63}, {0, 46, 48, 64}, {49, 47, 1, 65}, {88, 173, 175, 90}, {175, 174, 89, 90}, {86, 171, 173, 88}, {174, 172, 87, 89}, {84, 169, 171, 86}, {172, 170, 85, 87}, {82, 167, 169, 84}, {170, 168, 83, 85}, {80, 165, 167, 82}, {168, 166, 81, 83}, {78, 91, 145, 163}, {146, 92, 79, 164}, {91, 93, 147, 145}, {148, 94, 92, 146}, {93, 95, 149, 147}, {150, 96, 94, 148}, {95, 97, 151, 149}, {152, 98, 96, 150}, {97, 99, 153, 151}, {154, 100, 98, 152}, {99, 101, 155, 153}, {156, 102, 100, 154}, {101, 103, 157, 155}, {158, 104, 102, 156}, {103, 105, 159, 157}, {160, 106, 104, 158}, {105, 107, 161, 159}, {162, 108, 106, 160}, {107, 66, 67, 161}, {67, 66, 108, 162}, {109, 127, 159, 161}, {160, 128, 110, 162}, {127, 178, 157, 159}, {158, 179, 128, 160}, {125, 155, 157, 178}, {158, 156, 126, 179}, {123, 153, 155, 125}, {156, 154, 124, 126}, {121, 151, 153, 123}, {154, 152, 122, 124}, {119, 149, 151, 121}, {152, 150, 120, 122}, {117, 147, 149, 119}, {150, 148, 118, 120}, {115, 145, 147, 117}, {148, 146, 116, 118}, {113, 163, 145, 115}, {146, 164, 114, 116}, {113, 180, 176, 163}, {176, 181, 114, 164}, {109, 161, 67, 111}, {67, 162, 110, 112}, {111, 67, 177, 182}, {177, 67, 112, 183}, {176, 180, 182, 177}, {183, 181, 176, 177}, {134, 136, 175, 173}, {175, 136, 135, 174}, {132, 134, 173, 171}, {174, 135, 133, 172}, {130, 132, 171, 169}, {172, 133, 131, 170}, {165, 186, 184, 167}, {185, 187, 166, 168}, {130, 169, 167, 184}, {168, 170, 131, 185}, {143, 189, 188, 186}, {188, 189, 144, 187}, {184, 186, 188, 68}, {188, 187, 185, 68}, {129, 130, 184, 68}, {185, 131, 129, 68}, {141, 192, 190, 143}, {191, 193, 142, 144}, {139, 194, 192, 141}, {193, 195, 140, 142}, {138, 196, 194, 139}, {195, 197, 138, 140}, {137, 70, 196, 138}, {197, 70, 137, 138}, {189, 143, 190, 69}, {191, 144, 189, 69}, {69, 190, 205, 207}, {206, 191, 69, 207}, {70, 198, 199, 196}, {200, 198, 70, 197}, {196, 199, 201, 194}, {202, 200, 197, 195}, {194, 201, 203, 192}, {204, 202, 195, 193}, {192, 203, 205, 190}, {206, 204, 193, 191}, {198, 203, 201, 199}, {202, 204, 198, 200}, {198, 207, 205, 203}, {206, 207, 198, 204}, {138, 139, 163, 176}, {164, 140, 138, 176}, {139, 141, 210, 163}, {211, 142, 140, 164}, {141, 143, 212, 210}, {213, 144, 142, 211}, {143, 186, 165, 212}, {166, 187, 144, 213}, {80, 208, 212, 165}, {213, 209, 81, 166}, {208, 214, 210, 212}, {211, 215, 209, 213}, {78, 163, 210, 214}, {211, 164, 79, 215}, {130, 129, 71, 221}, {71, 129, 131, 222}, {132, 130, 221, 219}, {222, 131, 133, 220}, {134, 132, 219, 217}, {220, 133, 135, 218}, {136, 134, 217, 216}, {218, 135, 136, 216}, {216, 217, 228, 230}, {229, 218, 216, 230}, {217, 219, 226, 228}, {227, 220, 218, 229}, {219, 221, 224, 226}, {225, 222, 220, 227}, {221, 71, 223, 224}, {223, 71, 222, 225}, {223, 230, 228, 224}, {229, 230, 223, 225}, {182, 180, 233, 231}, {234, 181, 183, 232}, {111, 182, 231, 253}, {232, 183, 112, 254}, {109, 111, 253, 255}, {254, 112, 110, 256}, {180, 113, 251, 233}, {252, 114, 181, 234}, {113, 115, 249, 251}, {250, 116, 114, 252}, {115, 117, 247, 249}, {248, 118, 116, 250}, {117, 119, 245, 247}, {246, 120, 118, 248}, {119, 121, 243, 245}, {244, 122, 120, 246}, {121, 123, 241, 243}, {242, 124, 122, 244}, {123, 125, 239, 241}, {240, 126, 124, 242}, {125, 178, 235, 239}, {236, 179, 126, 240}, {178, 127, 237, 235}, {238, 128, 179, 236}, {127, 109, 255, 237}, {256, 110, 128, 238}, {237, 255, 257, 275}, {258, 256, 238, 276}, {235, 237, 275, 277}, {276, 238, 236, 278}, {239, 235, 277, 273}, {278, 236, 240, 274}, {241, 239, 273, 271}, {274, 240, 242, 272}, {243, 241, 271, 269}, {272, 242, 244, 270}, {245, 243, 269, 267}, {270, 244, 246, 268}, {247, 245, 267, 265}, {268, 246, 248, 266}, {249, 247, 265, 263}, {266, 248, 250, 264}, {251, 249, 263, 261}, {264, 250, 252, 262}, {233, 251, 261, 279}, {262, 252, 234, 280}, {255, 253, 259, 257}, {260, 254, 256, 258}, {253, 231, 281, 259}, {282, 232, 254, 260}, {231, 233, 279, 281}, {280, 234, 232, 282}, {66, 107, 283, 72}, {284, 108, 66, 72}, {107, 105, 285, 283}, {286, 106, 108, 284}, {105, 103, 287, 285}, {288, 104, 106, 286}, {103, 101, 289, 287}, {290, 102, 104, 288}, {101, 99, 291, 289}, {292, 100, 102, 290}, {99, 97, 293, 291}, {294, 98, 100, 292}, {97, 95, 295, 293}, {296, 96, 98, 294}, {95, 93, 297, 295}, {298, 94, 96, 296}, {93, 91, 299, 297}, {300, 92, 94, 298}, {307, 308, 327, 337}, {328, 308, 307, 338}, {306, 307, 337, 335}, {338, 307, 306, 336}, {305, 306, 335, 339}, {336, 306, 305, 340}, {88, 90, 305, 339}, {305, 90, 89, 340}, {86, 88, 339, 333}, {340, 89, 87, 334}, {84, 86, 333, 329}, {334, 87, 85, 330}, {82, 84, 329, 331}, {330, 85, 83, 332}, {329, 335, 337, 331}, {338, 336, 330, 332}, {329, 333, 339, 335}, {340, 334, 330, 336}, {325, 331, 337, 327}, {338, 332, 326, 328}, {80, 82, 331, 325}, {332, 83, 81, 326}, {208, 341, 343, 214}, {344, 342, 209, 215}, {80, 325, 341, 208}, {342, 326, 81, 209}, {78, 214, 343, 345}, {344, 215, 79, 346}, {78, 345, 299, 91}, {300, 346, 79, 92}, {76, 323, 351, 303}, {352, 324, 76, 303}, {303, 351, 349, 77}, {350, 352, 303, 77}, {77, 349, 347, 304}, {348, 350, 77, 304}, {304, 347, 327, 308}, {328, 348, 304, 308}, {325, 327, 347, 341}, {348, 328, 326, 342}, {295, 297, 317, 309}, {318, 298, 296, 310}, {75, 315, 323, 76}, {324, 316, 75, 76}, {301, 357, 355, 302}, {356, 358, 301, 302}, {302, 355, 353, 74}, {354, 356, 302, 74}, {74, 353, 315, 75}, {316, 354, 74, 75}, {291, 293, 361, 363}, {362, 294, 292, 364}, {363, 361, 367, 365}, {368, 362, 364, 366}, {365, 367, 369, 371}, {370, 368, 366, 372}, {371, 369, 375, 373}, {376, 370, 372, 374}, {313, 377, 373, 375}, {374, 378, 314, 376}, {315, 353, 373, 377}, {374, 354, 316, 378}, {353, 355, 371, 373}, {372, 356, 354, 374}, {355, 357, 365, 371}, {366, 358, 356, 372}, {357, 359, 363, 365}, {364, 360, 358, 366}, {289, 291, 363, 359}, {364, 292, 290, 360}, {73, 359, 357, 301}, {358, 360, 73, 301}, {283, 285, 287, 289}, {288, 286, 284, 290}, {283, 289, 359, 73}, {360, 290, 284, 73}, {293, 295, 309, 361}, {310, 296, 294, 362}, {309, 311, 367, 361}, {368, 312, 310, 362}, {311, 381, 369, 367}, {370, 382, 312, 368}, {313, 375, 369, 381}, {370, 376, 314, 382}, {347, 349, 385, 383}, {386, 350, 348, 384}, {317, 383, 385, 319}, {386, 384, 318, 320}, {297, 299, 383, 317}, {384, 300, 298, 318}, {299, 343, 341, 383}, {342, 344, 300, 384}, {313, 321, 379, 377}, {380, 322, 314, 378}, {315, 377, 379, 323}, {380, 378, 316, 324}, {319, 385, 379, 321}, {380, 386, 320, 322}, {349, 351, 379, 385}, {380, 352, 350, 386}, {399, 387, 413, 401}, {414, 388, 400, 402}, {399, 401, 403, 397}, {404, 402, 400, 398}, {397, 403, 405, 395}, {406, 404, 398, 396}, {395, 405, 407, 393}, {408, 406, 396, 394}, {393, 407, 409, 391}, {410, 408, 394, 392}, {391, 409, 411, 389}, {412, 410, 392, 390}, {409, 419, 417, 411}, {418, 420, 410, 412}, {407, 421, 419, 409}, {420, 422, 408, 410}, {405, 423, 421, 407}, {422, 424, 406, 408}, {403, 425, 423, 405}, {424, 426, 404, 406}, {401, 427, 425, 403}, {426, 428, 402, 404}, {401, 413, 415, 427}, {416, 414, 402, 428}, {317, 319, 443, 441}, {444, 320, 318, 442}, {319, 389, 411, 443}, {412, 390, 320, 444}, {309, 317, 441, 311}, {442, 318, 310, 312}, {381, 429, 413, 387}, {414, 430, 382, 388}, {411, 417, 439, 443}, {440, 418, 412, 444}, {437, 445, 443, 439}, {444, 446, 438, 440}, {433, 445, 437, 435}, {438, 446, 434, 436}, {431, 447, 445, 433}, {446, 448, 432, 434}, {429, 447, 431, 449}, {432, 448, 430, 450}, {413, 429, 449, 415}, {450, 430, 414, 416}, {311, 447, 429, 381}, {430, 448, 312, 382}, {311, 441, 445, 447}, {446, 442, 312, 448}, {415, 449, 451, 475}, {452, 450, 416, 476}, {449, 431, 461, 451}, {462, 432, 450, 452}, {431, 433, 459, 461}, {460, 434, 432, 462}, {433, 435, 457, 459}, {458, 436, 434, 460}, {435, 437, 455, 457}, {456, 438, 436, 458}, {437, 439, 453, 455}, {454, 440, 438, 456}, {439, 417, 473, 453}, {474, 418, 440, 454}, {427, 415, 475, 463}, {476, 416, 428, 464}, {425, 427, 463, 465}, {464, 428, 426, 466}, {423, 425, 465, 467}, {466, 426, 424, 468}, {421, 423, 467, 469}, {468, 424, 422, 470}, {419, 421, 469, 471}, {470, 422, 420, 472}, {417, 419, 471, 473}, {472, 420, 418, 474}, {457, 455, 479, 477}, {480, 456, 458, 478}, {477, 479, 481, 483}, {482, 480, 478, 484}, {483, 481, 487, 485}, {488, 482, 484, 486}, {485, 487, 489, 491}, {490, 488, 486, 492}, {463, 475, 485, 491}, {486, 476, 464, 492}, {451, 483, 485, 475}, {486, 484, 452, 476}, {451, 461, 477, 483}, {478, 462, 452, 484}, {457, 477, 461, 459}, {462, 478, 458, 460}, {453, 473, 479, 455}, {480, 474, 454, 456}, {471, 481, 479, 473}, {480, 482, 472, 474}, {469, 487, 481, 471}, {482, 488, 470, 472}, {467, 489, 487, 469}, {488, 490, 468, 470}, {465, 491, 489, 467}, {490, 492, 466, 468}, {391, 389, 503, 501}, {504, 390, 392, 502}, {393, 391, 501, 499}, {502, 392, 394, 500}, {395, 393, 499, 497}, {500, 394, 396, 498}, {397, 395, 497, 495}, {498, 396, 398, 496}, {399, 397, 495, 493}, {496, 398, 400, 494}, {387, 399, 493, 505}, {494, 400, 388, 506}, {493, 501, 503, 505}, {504, 502, 494, 506}, {493, 495, 499, 501}, {500, 496, 494, 502}, {313, 381, 387, 505}, {388, 382, 314, 506}, {313, 505, 503, 321}, {504, 506, 314, 322}, {319, 321, 503, 389}, {504, 322, 320, 390}, // ttriangles {60, 64, 48, 48}, {49, 65, 61, 61}, {62, 64, 60, 60}, {61, 65, 63, 63}, {60, 58, 62, 62}, {63, 59, 61, 61}, {60, 56, 58, 58}, {59, 57, 61, 61}, {60, 54, 56, 56}, {57, 55, 61, 61}, {60, 52, 54, 54}, {55, 53, 61, 61}, {60, 50, 52, 52}, {53, 51, 61, 61}, {60, 48, 50, 50}, {51, 49, 61, 61}, {224, 228, 226, 226}, {227, 229, 225, 255}, {72, 283, 73, 73}, {73, 284, 72, 72}, {341, 347, 383, 383}, {384, 348, 342, 342}, {299, 345, 343, 343}, {344, 346, 300, 300}, {323, 379, 351, 351}, {352, 380, 324, 324}, {441, 443, 445, 445}, {446, 444, 442, 442}, {463, 491, 465, 465}, {466, 492, 464, 464}, {495, 497, 499, 499}, {500, 498, 496, 496}}; } // namespace yocto goxel-0.11.0/ext_src/yocto/yocto_shape.h000066400000000000000000001067711435762723100202270ustar00rootroot00000000000000// // # Yocto/Shape: Tiny Library for shape operations for graphics // // // Yocto/Shape is a collection of utilities for manipulating shapes in 3D // graphics, with a focus on triangle and quad meshes. We support both low-level // geometry operation and whole shape operations. // // // ## Geometry functions // // The library supports basic geomtry functions such as computing // line/triangle/quad normals and areas, picking points on triangles // and the like. In these functions triangles are parameterized with us written // w.r.t the (p1-p0) and (p2-p0) axis respectively. Quads are internally handled // as pairs of two triangles p0,p1,p3 and p2,p3,p1, with the u/v coordinates // of the second triangle corrected as 1-u and 1-v to produce a quad // parametrization where u and v go from 0 to 1. Degenerate quads with p2==p3 // represent triangles correctly, an this convention is used throught the // library. This is equivalent to Intel's Embree. // // // ## Shape functions // // We provide a small number of utilities for shape manipulation for index // triangle and quad meshes, indexed line and point sets and indexed beziers. // The utliities collected here are written to support a global illumination // rendering and not for generic geometry processing. We support operation for // shape smoothing, shape subdivision (including Catmull-Clark subdivs), and // example shape creation. // // 1. compute line tangents, and triangle and quad areas and normals with // `line_tangent()`, `triamgle_normal()`, `quad_normal()` and // `line_length()`, `triangle_area()` and `quad_normal()` // 2. interpolate values over primitives with `interpolate_line()`, // `interpolate_triangle()` and `interpolate_quad()` // 3. evaluate Bezier curves and derivatives with `interpolate_bezier()` and // `interpolate_bezier_derivative()` // 4. compute smooth normals and tangents with `compute_normals()` // `compute_tangents()` // 5. compute tangent frames from texture coordinates with // `compute_tangent_spaces()` // 6. compute skinning with `compute_skinning()` and // `compute_matrix_skinning()` // 6. create shapes with `make_proc_image()`, `make_hair()`, // `make_points()` // 7. merge element with `marge_lines()`, `marge_triangles()`, `marge_quads()` // 8. shape sampling with `sample_points()`, `sample_lines()`, // `sample_triangles()`; initialize the sampling CDFs with // `sample_points_cdf()`, `sample_lines_cdf()`, // `sample_triangles_cdf()` // 9. sample a could of point over a surface with `sample_triangles()` // 10. get edges and boundaries with `get_edges()` // 11. convert quads to triangles with `quads_to_triangles()` // 12. convert face varying to vertex shared representations with // `convert_face_varying()` // 13. subdivide elements by edge splits with `subdivide_lines()`, // `subdivide_triangles()`, `subdivide_quads()`, `subdivide_beziers()` // 14. Catmull-Clark subdivision surface with `subdivide_catmullclark()` // // // ## Shape IO // // We support reading and writing shapes in OBJ and PLY. // // 1. load/save shapes with `load_shape()`/`save_shape()` // // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // #ifndef _YOCTO_SHAPE_H_ #define _YOCTO_SHAPE_H_ #ifndef YOCTO_QUADS_AS_TRIANGLES #define YOCTO_QUADS_AS_TRIANGLES 1 #endif // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include "yocto_math.h" // ----------------------------------------------------------------------------- // COMPUTATION OF PER_VERTEX PROPETIES // ----------------------------------------------------------------------------- namespace yocto { // Compute per-vertex normals/tangents for lines/triangles/quads. vector compute_tangents( const vector& lines, const vector& positions); vector compute_normals( const vector& triangles, const vector& positions); vector compute_normals( const vector& quads, const vector& positions); void compute_tangents(vector& tangents, const vector& lines, const vector& positions); void compute_normals(vector& normals, const vector& triangles, const vector& positions); void compute_normals(vector& normals, const vector& quads, const vector& positions); // Compute per-vertex tangent space for triangle meshes. // Tangent space is defined by a four component vector. // The first three components are the tangent with respect to the u texcoord. // The fourth component is the sign of the tangent wrt the v texcoord. // Tangent frame is useful in normal mapping. vector compute_tangent_spaces(const vector& triangles, const vector& positions, const vector& normals, const vector& texcoords); void compute_tangent_spaces(vector& tangents, const vector& triangles, const vector& positions, const vector& normals, const vector& texcoords); // Apply skinning to vertex position and normals. pair, vector> compute_skinning( const vector& positions, const vector& normals, const vector& weights, const vector& joints, const vector& xforms); void compute_skinning(vector& skinned_positions, vector& skinned_normals, const vector& positions, const vector& normals, const vector& weights, const vector& joints, const vector& xforms); // Apply skinning as specified in Khronos glTF. pair, vector> compute_matrix_skinning( const vector& positions, const vector& normals, const vector& weights, const vector& joints, const vector& xforms); void compute_matrix_skinning(vector& skinned_positions, vector& skinned_normals, const vector& positions, const vector& normals, const vector& weights, const vector& joints, const vector& xforms); } // namespace yocto // ----------------------------------------------------------------------------- // COMPUTATION OF PER_VERTEX PROPETIES // ----------------------------------------------------------------------------- namespace yocto { // Flip vertex normals vector flip_normals(const vector& normals); void flip_normals(vector& flipped, const vector& normals); // Flip face orientation vector flip_triangles(const vector& triangles); vector flip_quads(const vector& quads); void flip_triangles(vector& flipped, const vector& triangles); void flip_quads(vector& flipped, const vector& quads); // Align vertex positions. Alignment is 0: none, 1: min, 2: max, 3: center. vector align_vertices( const vector& positions, const vec3i& alignment); void align_vertices(vector& aligned, const vector& positions, const vec3i& alignment); } // namespace yocto // ----------------------------------------------------------------------------- // EDGE AND GRID DATA STRUCTURES // ----------------------------------------------------------------------------- namespace yocto { // Dictionary to store edge information. `index` is the index to the edge // array, `edges` the array of edges and `nfaces` the number of adjacent faces. // We store only bidirectional edges to keep the dictionary small. Use the // functions below to access this data. struct edge_map { unordered_map index = {}; vector edges = {}; vector nfaces = {}; }; // Initialize an edge map with elements. edge_map make_edge_map(const vector& triangles); edge_map make_edge_map(const vector& quads); void insert_edges(edge_map& emap, const vector& triangles); void insert_edges(edge_map& emap, const vector& quads); // Insert an edge and return its index int insert_edge(edge_map& emap, const vec2i& edge); // Get the edge index / insertion count int edge_index(const edge_map& emap, const vec2i& edge); // Get list of edges / boundary edges int num_edges(const edge_map& emap); vector get_edges(const edge_map& emap); vector get_boundary(const edge_map& emap); void get_edges(const edge_map& emap, vector& edges); void get_boundary(const edge_map& emap, vector& edges); vector get_edges(const vector& triangles); vector get_edges(const vector& quads); // A sparse grid of cells, containing list of points. Cells are stored in // a dictionary to get sparsity. Helpful for nearest neighboor lookups. struct hash_grid { float cell_size = 0; float cell_inv_size = 0; vector positions = {}; unordered_map> cells = {}; }; // Create a hash_grid hash_grid make_hash_grid(float cell_size); hash_grid make_hash_grid(const vector& positions, float cell_size); // Inserts a point into the grid int insert_vertex(hash_grid& grid, const vec3f& position); // Finds the nearest neighboors within a given radius void find_neightbors(const hash_grid& grid, vector& neighboors, const vec3f& position, float max_radius); void find_neightbors(const hash_grid& grid, vector& neighboors, int vertex, float max_radius); } // namespace yocto // ----------------------------------------------------------------------------- // SHAPE ELEMENT CONVERSION AND GROUPING // ----------------------------------------------------------------------------- namespace yocto { // Convert quads to triangles vector quads_to_triangles(const vector& quads); void quads_to_triangles(vector& triangles, const vector& quads); // Convert triangles to quads by creating degenerate quads vector triangles_to_quads(const vector& triangles); void triangles_to_quads(vector& quads, const vector& triangles); // Convert beziers to lines using 3 lines for each bezier. vector bezier_to_lines(vector& lines); void bezier_to_lines(vector& lines, const vector& beziers); // Convert face-varying data to single primitives. Returns the quads indices // and face ids and filled vectors for pos, norm, texcoord and colors. void split_facevarying(vector& split_quads, vector& split_positions, vector& split_normals, vector& split_texcoords, const vector& quadspos, const vector& quadsnorm, const vector& quadstexcoord, const vector& positions, const vector& normals, const vector& texcoords); // Split primitives per id vector> ungroup_lines( const vector& lines, const vector& ids); vector> ungroup_triangles( const vector& triangles, const vector& ids); vector> ungroup_quads( const vector& quads, const vector& ids); void ungroup_lines(vector>& split_lines, const vector& lines, const vector& ids); void ungroup_triangles(vector>& split_triangles, const vector& triangles, const vector& ids); void ungroup_quads(vector>& split_quads, const vector& quads, const vector& ids); // Weld vertices within a threshold. pair, vector> weld_vertices( const vector& positions, float threshold); pair, vector> weld_triangles( const vector& triangles, const vector& positions, float threshold); pair, vector> weld_quads(const vector& quads, const vector& positions, float threshold); // Weld vertices within a threshold. void weld_vertices(vector& welded_positions, vector& indices, const vector& positions, float threshold); void weld_triangles(vector& welded_triangles, vector& welded_positions, const vector& triangles, const vector& positions, float threshold); void weld_quads(vector& welded_quads, vector& welded_positions, const vector& quads, const vector& positions, float threshold); // Merge shape elements void merge_lines( vector& lines, const vector& merge_lines, int num_verts); void merge_triangles(vector& triangles, const vector& merge_triangles, int num_verts); void merge_quads( vector& quads, const vector& merge_quads, int num_verts); void merge_lines(vector& lines, vector& positions, vector& tangents, vector& texcoords, vector& radius, const vector& merge_lines, const vector& merge_positions, const vector& merge_tangents, const vector& merge_texturecoords, const vector& merge_radius); void merge_triangles(vector& triangles, vector& positions, vector& normals, vector& texcoords, const vector& merge_triangles, const vector& merge_positions, const vector& merge_normals, const vector& merge_texturecoords); void merge_quads(vector& quads, vector& positions, vector& normals, vector& texcoords, const vector& merge_quads, const vector& merge_positions, const vector& merge_normals, const vector& merge_texturecoords); // Merge quads and triangles void merge_triangles_and_quads( vector& triangles, vector& quads, bool force_triangles); } // namespace yocto // ----------------------------------------------------------------------------- // SHAPE SUBDIVISION // ----------------------------------------------------------------------------- namespace yocto { // Subdivide lines by splitting each line in half. pair, vector> subdivide_lines( const vector& lines, const vector& vert, int level); pair, vector> subdivide_lines( const vector& lines, const vector& vert, int level); pair, vector> subdivide_lines( const vector& lines, const vector& vert, int level); pair, vector> subdivide_lines( const vector& lines, const vector& vert, int level); void subdivide_lines(vector& slines, vector& svert, const vector& lines, const vector& vert, int level); void subdivide_lines(vector& slines, vector& svert, const vector& lines, const vector& vert, int level); void subdivide_lines(vector& slines, vector& svert, const vector& lines, const vector& vert, int level); void subdivide_lines(vector& slines, vector& svert, const vector& lines, const vector& vert, int level); void subdivide_lines(vector& slines, vector& spositions, vector& snormals, vector& stexcoords, vector& scolors, vector& sradius, const vector& lines, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, int level); // Subdivide triangle by splitting each triangle in four, creating new // vertices for each edge. pair, vector> subdivide_triangles( const vector& triangles, const vector& vert, int level); pair, vector> subdivide_triangles( const vector& triangles, const vector& vert, int level); pair, vector> subdivide_triangles( const vector& triangles, const vector& vert, int level); pair, vector> subdivide_triangles( const vector& triangles, const vector& vert, int level); void subdivide_triangles(vector& striangles, vector& svert, const vector& triangles, const vector& vert, int level); void subdivide_triangles(vector& striangles, vector& svert, const vector& triangles, const vector& vert, int level); void subdivide_triangles(vector& striangles, vector& svert, const vector& triangles, const vector& vert, int level); void subdivide_triangles(vector& striangles, vector& svert, const vector& triangles, const vector& vert, int level); void subdivide_triangles(vector& striangles, vector& spositions, vector& snormals, vector& stexcoords, vector& scolors, vector& sradius, const vector& triangles, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, int level); // Subdivide quads by splitting each quads in four, creating new // vertices for each edge and for each face. pair, vector> subdivide_quads( const vector& quads, const vector& vert, int level); pair, vector> subdivide_quads( const vector& quads, const vector& vert, int level); pair, vector> subdivide_quads( const vector& quads, const vector& vert, int level); pair, vector> subdivide_quads( const vector& quads, const vector& vert, int level); void subdivide_quads(vector& squads, vector& svert, const vector& quads, const vector& vert, int level); void subdivide_quads(vector& squads, vector& svert, const vector& quads, const vector& vert, int level); void subdivide_quads(vector& squads, vector& svert, const vector& quads, const vector& vert, int level); void subdivide_quads(vector& squads, vector& svert, const vector& quads, const vector& vert, int level); void subdivide_quads(vector& squads, vector& spositions, vector& snormals, vector& stexcoords, vector& scolors, vector& sradius, const vector& quads, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, int level); // Subdivide beziers by splitting each segment in two. pair, vector> subdivide_beziers( const vector& beziers, const vector& vert, int level); pair, vector> subdivide_beziers( const vector& beziers, const vector& vert, int level); pair, vector> subdivide_beziers( const vector& beziers, const vector& vert, int level); pair, vector> subdivide_beziers( const vector& beziers, const vector& vert, int level); void subdivide_beziers(vector& sbeziers, vector& svert, const vector& beziers, const vector& vert, int level); void subdivide_beziers(vector& sbeziers, vector& svert, const vector& beziers, const vector& vert, int level); void subdivide_beziers(vector& sbeziers, vector& svert, const vector& beziers, const vector& vert, int level); void subdivide_beziers(vector& sbeziers, vector& svert, const vector& beziers, const vector& vert, int level); void subdivide_beziers(vector& sbeziers, vector& spositions, vector& snormals, vector& stexcoords, vector& scolors, vector& sradius, const vector& beziers, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, int level); // Subdivide quads using Carmull-Clark subdivision rules. pair, vector> subdivide_catmullclark( const vector& quads, const vector& vert, int level, bool lock_boundary = false); pair, vector> subdivide_catmullclark( const vector& quads, const vector& vert, int level, bool lock_boundary = false); pair, vector> subdivide_catmullclark( const vector& quads, const vector& vert, int level, bool lock_boundary = false); pair, vector> subdivide_catmullclark( const vector& quads, const vector& vert, int level, bool lock_boundary = false); void subdivide_catmullclark(vector& squads, vector& svert, const vector& quads, const vector& vert, int level, bool lock_boundary = false); void subdivide_catmullclark(vector& squads, vector& svert, const vector& quads, const vector& vert, int level, bool lock_boundary = false); void subdivide_catmullclark(vector& squads, vector& svert, const vector& quads, const vector& vert, int level, bool lock_boundary = false); void subdivide_catmullclark(vector& squads, vector& svert, const vector& quads, const vector& vert, int level, bool lock_boundary = false); void subdivide_catmullclark(vector& squads, vector& spositions, vector& snormals, vector& stexcoords, vector& scolors, vector& sradius, const vector& quads, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, int level); } // namespace yocto // ----------------------------------------------------------------------------- // SHAPE SAMPLING // ----------------------------------------------------------------------------- namespace yocto { // Pick a point in a point set uniformly. int sample_points(int npoints, float re); int sample_points(const vector& cdf, float re); vector sample_points_cdf(int npoints); void sample_points_cdf(vector& cdf, int npoints); // Pick a point on lines uniformly. pair sample_lines(const vector& cdf, float re, float ru); vector sample_lines_cdf( const vector& lines, const vector& positions); void sample_lines_cdf(vector& cdf, const vector& lines, const vector& positions); // Pick a point on a triangle mesh uniformly. pair sample_triangles( const vector& cdf, float re, const vec2f& ruv); vector sample_triangles_cdf( const vector& triangles, const vector& positions); void sample_triangles_cdf(vector& cdf, const vector& triangles, const vector& positions); // Pick a point on a quad mesh uniformly. pair sample_quads( const vector& cdf, float re, const vec2f& ruv); pair sample_quads(const vector& quads, const vector& cdf, float re, const vec2f& ruv); vector sample_quads_cdf( const vector& quads, const vector& positions); void sample_quads_cdf(vector& cdf, const vector& quads, const vector& positions); // Samples a set of points over a triangle/quad mesh uniformly. Returns pos, // norm and texcoord of the sampled points. void sample_triangles(vector& sampled_positions, vector& sampled_normals, vector& sampled_texturecoords, const vector& triangles, const vector& positions, const vector& normals, const vector& texcoords, int npoints, int seed = 7); void sample_quads(vector& sampled_positions, vector& sampled_normals, vector& sampled_texturecoords, const vector& quads, const vector& positions, const vector& normals, const vector& texcoords, int npoints, int seed = 7); } // namespace yocto // ----------------------------------------------------------------------------- // SHAPE GEODESICS // ----------------------------------------------------------------------------- namespace yocto { // Data structure used for geodesic computation struct geodesic_solver { struct arc_ { int node = 0; float length = 0; }; struct index_ { int node = 0; int index = 0; }; vector> graph = {}; vector> edge_index = {}; vector positions = {}; vector edges = {}; }; // Construct an edge graph void init_geodesic_solver(geodesic_solver& solver, const vector& triangles, const vector& positions); void compute_geodesic_distances(geodesic_solver& solver, vector& distances, const vector& sources); void convert_distance_to_color( vector& colors, const vector& distances); } // namespace yocto // ----------------------------------------------------------------------------- // SHAPE IO FUNCTIONS // ----------------------------------------------------------------------------- namespace yocto { // Load/Save a shape void load_shape(const string& filename, vector& points, vector& lines, vector& triangles, vector& quads, vector& quadspos, vector& quadsnorm, vector& quadstexcoord, vector& positions, vector& normals, vector& texcoords, vector& colors, vector& radius, bool facevarying); void save_shape(const string& filename, const vector& points, const vector& lines, const vector& triangles, const vector& quads, const vector& quadspos, const vector& quadsnorm, const vector& quadstexcoord, const vector& positions, const vector& normals, const vector& texcoords, const vector& colors, const vector& radius, bool ascii = false); } // namespace yocto // ----------------------------------------------------------------------------- // SHAPE EXAMPLES // ----------------------------------------------------------------------------- namespace yocto { // Parameters for make shape function struct proc_shape_params { // clang-format off enum struct type_t { quad, floor, cube, sphere, disk, matball, suzanne, box, rect, rect_stack, uvsphere, uvdisk, uvcylinder, geosphere }; // clang-format on type_t type = type_t::quad; int subdivisions = 0; float scale = 1; float uvscale = 1; float rounded = 0; vec3f aspect = {1, 1, 1}; // for rect, box, cylinder frame3f frame = identity3x4f; }; // Make a procedural shape void make_proc_shape(vector& triangles, vector& quads, vector& positions, vector& normals, vector& texcoords, const proc_shape_params& params); // Make face-varying quads. For now supports only quad, cube, suzanne, sphere, // rect, box. Rounding not supported for now. void make_proc_fvshape(vector& quadspos, vector& quadsnorm, vector& quadstexcoord, vector& positions, vector& normals, vector& texcoords, const proc_shape_params& params); // Generate lines set along a quad. Returns lines, pos, norm, texcoord, radius. void make_lines(vector& lines, vector& positions, vector& normals, vector& texcoords, vector& radius, int num, int subdivisions, const vec2f& size, const vec2f& uvsize, const vec2f& line_radius); // Make point primitives. Returns points, pos, norm, texcoord, radius. void make_points(vector& points, vector& positions, vector& normals, vector& texcoords, vector& radius, int num, float uvsize, float point_radius); void make_random_points(vector& points, vector& positions, vector& normals, vector& texcoords, vector& radius, int num, const vec3f& size, float uvsize, float point_radius, uint64_t seed); // Make fair params struct hair_params { int num = 0; int subdivisions = 0; float length_min = 0.1; float length_max = 0.1; float radius_base = 0.001; float radius_tip = 0.001; float noise_strength = 0; float noise_scale = 10; float clump_strength = 0; int clump_num = 0; float rotation_strength = 0; float rotation_minchia = 0; int seed = 7; }; // Make a hair ball around a shape. Returns lines, pos, norm, texcoord, radius. // length: minimum and maximum length // rad: minimum and maximum radius from base to tip // noise: noise added to hair (strength/scale) // clump: clump added to hair (number/strength) // rotation: rotation added to hair (angle/strength) void make_hair(vector& lines, vector& positions, vector& normals, vector& texcoords, vector& radius, const vector& striangles, const vector& squads, const vector& spos, const vector& snorm, const vector& stexcoord, const hair_params& params); // Thickens a shape by copying the shape content, rescaling it and flipping its // normals. Note that this is very much not robust and only useful for trivial // cases. void make_shell(vector& quads, vector& positions, vector& normals, vector& texcoords, float thickness); // Shape presets used ofr testing. void make_shape_preset(vector& points, vector& lines, vector& triangles, vector& quads, vector& quadspos, vector& quadsnorm, vector& quadstexcoord, vector& positions, vector& normals, vector& texcoords, vector& colors, vector& radius, const string& type); } // namespace yocto // ----------------------------------------------------------------------------- // GEOMETRY UTILITIES // ----------------------------------------------------------------------------- namespace yocto { // Line properties. inline vec3f line_tangent(const vec3f& p0, const vec3f& p1) { return normalize(p1 - p0); } inline float line_length(const vec3f& p0, const vec3f& p1) { return length(p1 - p0); } // Triangle properties. inline vec3f triangle_normal( const vec3f& p0, const vec3f& p1, const vec3f& p2) { return normalize(cross(p1 - p0, p2 - p0)); } inline float triangle_area(const vec3f& p0, const vec3f& p1, const vec3f& p2) { return length(cross(p1 - p0, p2 - p0)) / 2; } // Quad propeties. inline vec3f quad_normal( const vec3f& p0, const vec3f& p1, const vec3f& p2, const vec3f& p3) { return normalize(triangle_normal(p0, p1, p3) + triangle_normal(p2, p3, p1)); } inline float quad_area( const vec3f& p0, const vec3f& p1, const vec3f& p2, const vec3f& p3) { return triangle_area(p0, p1, p3) + triangle_area(p2, p3, p1); } // Triangle tangent and bitangent from uv inline pair triangle_tangents_fromuv(const vec3f& p0, const vec3f& p1, const vec3f& p2, const vec2f& uv0, const vec2f& uv1, const vec2f& uv2); // Quad tangent and bitangent from uv. Note that we pass a current_uv since // internally we may want to split the quad in two and we need to known where // to do it. If not interested in the split, just pass zero2f here. inline pair quad_tangents_fromuv(const vec3f& p0, const vec3f& p1, const vec3f& p2, const vec3f& p3, const vec2f& uv0, const vec2f& uv1, const vec2f& uv2, const vec2f& uv3, const vec2f& current_uv); // Interpolates values over a line parameterized from a to b by u. Same as lerp. template inline T interpolate_line(const T& p0, const T& p1, float u) { return p0 * (1 - u) + p1 * u; } // Interpolates values over a triangle parameterized by u and v along the // (p1-p0) and (p2-p0) directions. Same as barycentric interpolation. template inline T interpolate_triangle( const T& p0, const T& p1, const T& p2, const vec2f& uv) { return p0 * (1 - uv.x - uv.y) + p1 * uv.x + p2 * uv.y; } // Interpolates values over a quad parameterized by u and v along the // (p1-p0) and (p2-p1) directions. Same as bilinear interpolation. template inline T interpolate_quad( const T& p0, const T& p1, const T& p2, const T& p3, const vec2f& uv) { #if YOCTO_QUADS_AS_TRIANGLES if (uv.x + uv.y <= 1) { return interpolate_triangle(p0, p1, p3, uv); } else { return interpolate_triangle(p2, p3, p1, 1 - uv); } #else return p0 * (1 - uv.x) * (1 - uv.y) + p1 * uv.x * (1 - uv.y) + p2 * uv.x * uv.y + p3 * (1 - uv.x) * uv.y; #endif } // Interpolates values along a cubic Bezier segment parametrized by u. template inline T interpolate_bezier( const T& p0, const T& p1, const T& p2, const T& p3, float u) { return p0 * (1 - u) * (1 - u) * (1 - u) + p1 * 3 * u * (1 - u) * (1 - u) + p2 * 3 * u * u * (1 - u) + p3 * u * u * u; } // Computes the derivative of a cubic Bezier segment parametrized by u. template inline T interpolate_bezier_derivative( const T& p0, const T& p1, const T& p2, const T& p3, float u) { return (p1 - p0) * 3 * (1 - u) * (1 - u) + (p2 - p1) * 6 * u * (1 - u) + (p3 - p2) * 3 * u * u; } // Triangle tangent and bitangent from uv inline pair triangle_tangents_fromuv(const vec3f& p0, const vec3f& p1, const vec3f& p2, const vec2f& uv0, const vec2f& uv1, const vec2f& uv2) { // Follows the definition in http://www.terathon.com/code/tangent.html and // https://gist.github.com/aras-p/2843984 // normal points up from texture space auto p = p1 - p0; auto q = p2 - p0; auto s = vec2f{uv1.x - uv0.x, uv2.x - uv0.x}; auto t = vec2f{uv1.y - uv0.y, uv2.y - uv0.y}; auto div = s.x * t.y - s.y * t.x; if (div != 0) { auto tu = vec3f{t.y * p.x - t.x * q.x, t.y * p.y - t.x * q.y, t.y * p.z - t.x * q.z} / div; auto tv = vec3f{s.x * q.x - s.y * p.x, s.x * q.y - s.y * p.y, s.x * q.z - s.y * p.z} / div; return {tu, tv}; } else { return {{1, 0, 0}, {0, 1, 0}}; } } // Quad tangent and bitangent from uv. inline pair quad_tangents_fromuv(const vec3f& p0, const vec3f& p1, const vec3f& p2, const vec3f& p3, const vec2f& uv0, const vec2f& uv1, const vec2f& uv2, const vec2f& uv3, const vec2f& current_uv) { #if YOCTO_QUADS_AS_TRIANGLES if (current_uv.x + current_uv.y <= 1) { return triangle_tangents_fromuv(p0, p1, p3, uv0, uv1, uv3); } else { return triangle_tangents_fromuv(p2, p3, p1, uv2, uv3, uv1); } #else return triangle_tangents_fromuv(p0, p1, p3, uv0, uv1, uv3); #endif } } // namespace yocto #endif goxel-0.11.0/ext_src/yocto/yocto_trace.cpp000066400000000000000000002567501435762723100205630ustar00rootroot00000000000000// // Implementation for Yocto/Trace. // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // #include "yocto_trace.h" #include #include // ----------------------------------------------------------------------------- // IMPLEMENTATION FOR PATH TRACING SUPPORT FUNCTIONS // ----------------------------------------------------------------------------- namespace yocto { // Schlick approximation of the Fresnel term vec3f fresnel_schlick(const vec3f& specular, float direction_cosine) { if (specular == zero3f) return zero3f; return specular + (1 - specular) * pow(clamp(1 - abs(direction_cosine), 0.0f, 1.0f), 5.0f); } // Evaluates the GGX distribution and geometric term float eval_microfacetD( float roughness, const vec3f& normal, const vec3f& half_vector, bool ggx) { auto cosine = dot(normal, half_vector); if (cosine <= 0) return 0; auto roughness_square = roughness * roughness; auto cosine_square = cosine * cosine; auto tangent_square = clamp(1 - cosine_square, 0.0f, 1.0f) / cosine_square; if (ggx) { return roughness_square / (pif * cosine_square * cosine_square * (roughness_square + tangent_square) * (roughness_square + tangent_square)); } else { return exp(-tangent_square / roughness_square) / (pif * roughness_square * cosine_square * cosine_square); } } float evaluate_microfacetG1(float roughness, const vec3f& normal, const vec3f& half_vector, const vec3f& direction, bool ggx) { auto cosine = dot(normal, direction); if (dot(half_vector, direction) * cosine <= 0) return 0; auto roughness_square = roughness * roughness; auto cosine_square = cosine * cosine; auto tangent_square = clamp(1 - cosine_square, 0.0f, 1.0f) / cosine_square; if (ggx) { return 2 / (1 + sqrt(1.0f + roughness_square * tangent_square)); } else { auto tangent = sqrt(tangent_square); auto inv_rt = 1 / (roughness * tangent); auto inv_rt_square = 1 / (roughness_square * tangent_square); if (inv_rt < 1.6f) { return (3.535f * inv_rt + 2.181f * inv_rt_square) / (1.0f + 2.276f * inv_rt + 2.577f * inv_rt_square); } else { return 1.0f; } } } float eval_microfacetG(float roughness, const vec3f& normal, const vec3f& half_vector, const vec3f& outgoing, const vec3f& incoming, bool ggx) { return evaluate_microfacetG1(roughness, normal, half_vector, outgoing, ggx) * evaluate_microfacetG1(roughness, normal, half_vector, incoming, ggx); } vec3f sample_microfacet( float roughness, const vec3f& normal, const vec2f& rn, bool ggx) { auto phi = 2 * pif * rn.x; auto roughness_square = roughness * roughness; auto tangent_square = 0.0f; if (ggx) { tangent_square = -roughness_square * log(1 - rn.y); } else { tangent_square = roughness_square * rn.y / (1 - rn.y); } auto cosine_square = 1 / (1 + tangent_square); auto cosine = 1 / sqrt(1 + tangent_square); auto radius = sqrt(clamp(1 - cosine_square, 0.0f, 1.0f)); auto local_half_vector = vec3f{cos(phi) * radius, sin(phi) * radius, cosine}; return transform_direction(basis_fromz(normal), local_half_vector); } float sample_microfacet_pdf( float roughness, const vec3f& normal, const vec3f& half_vector, bool ggx) { auto cosine = dot(normal, half_vector); if (cosine < 0) return 0; return eval_microfacetD(roughness, normal, half_vector, ggx) * cosine; } // Phong exponent to roughness. float exponent_to_roughness(float exponent) { return sqrtf(2 / (exponent + 2)); } // Specular to eta. vec3f reflectivity_to_eta(const vec3f& reflectivity) { return (1 + sqrt(reflectivity)) / (1 - sqrt(reflectivity)); } // Specular to fresnel eta. pair reflectivity_to_eta( const vec3f& reflectivity, const vec3f& edge_tint) { auto r = clamp(reflectivity, 0.0f, 0.99f); auto g = edge_tint; auto r_sqrt = sqrt(r); auto n_min = (1 - r) / (1 + r); auto n_max = (1 + r_sqrt) / (1 - r_sqrt); auto n = lerp(n_max, n_min, g); auto k2 = ((n + 1) * (n + 1) * r - (n - 1) * (n - 1)) / (1 - r); k2 = max(k2, 0.0f); auto k = sqrt(k2); return {n, k}; } vec3f eta_to_reflectivity(const vec3f& eta) { return ((eta - 1) * (eta - 1)) / ((eta + 1) * (eta + 1)); } vec3f eta_to_reflectivity(const vec3f& eta, const vec3f& etak) { return ((eta - 1) * (eta - 1) + etak * etak) / ((eta + 1) * (eta + 1) + etak * etak); } vec3f eta_to_edge_tint(const vec3f& eta, const vec3f& etak) { auto r = eta_to_reflectivity(eta, etak); auto numer = (1 + sqrt(r)) / (1 - sqrt(r)) - eta; auto denom = (1 + sqrt(r)) / (1 - sqrt(r)) - (1 - r) / (1 + r); return numer / denom; } // Compute the fresnel term for dielectrics. Implementation from // https://seblagarde.wordpress.com/2013/04/29/memo-on-fresnel-equations/ vec3f fresnel_dielectric(const vec3f& eta_, float cosw) { auto eta = eta_; if (cosw < 0) { eta = 1 / eta; cosw = -cosw; } auto sin2 = 1 - cosw * cosw; auto eta2 = eta * eta; auto cos2t = 1 - sin2 / eta2; if (cos2t.x < 0 || cos2t.y < 0 || cos2t.z < 0) return {1, 1, 1}; // tir auto t0 = sqrt(cos2t); auto t1 = eta * t0; auto t2 = eta * cosw; auto rs = (cosw - t1) / (cosw + t1); auto rp = (t0 - t2) / (t0 + t2); return (rs * rs + rp * rp) / 2; } // Compute the fresnel term for metals. Implementation from // https://seblagarde.wordpress.com/2013/04/29/memo-on-fresnel-equations/ vec3f fresnel_conductor(const vec3f& eta, const vec3f& etak, float cosw) { if (etak == zero3f) return fresnel_dielectric(eta, cosw); cosw = clamp(cosw, (float)-1, (float)1); auto cos2 = cosw * cosw; auto sin2 = clamp(1 - cos2, (float)0, (float)1); auto eta2 = eta * eta; auto etak2 = etak * etak; auto t0 = eta2 - etak2 - sin2; auto a2plusb2 = sqrt(t0 * t0 + 4 * eta2 * etak2); auto t1 = a2plusb2 + cos2; auto a = sqrt((a2plusb2 + t0) / 2); auto t2 = 2 * a * cosw; auto rs = (t1 - t2) / (t1 + t2); auto t3 = cos2 * a2plusb2 + sin2 * sin2; auto t4 = t2 * sin2; auto rp = rs * (t3 - t4) / (t3 + t4); return (rp + rs) / 2; } pair sample_distance(const vec3f& density, float rl, float rd) { auto channel = clamp((int)(rl * 3), 0, 2); auto density_channel = density[channel]; if (density_channel == 0 || rd == 0) return {flt_max, channel}; else return {-log(rd) / density_channel, channel}; } float sample_distance_pdf(const vec3f& density, float distance, int channel) { auto density_channel = density[channel]; return exp(-density_channel * distance); } vec3f eval_transmission(const vec3f& density, float distance) { return exp(-density * distance); } vec3f sample_phasefunction(float g, const vec2f& u) { auto cos_theta = 0.0f; if (abs(g) < 1e-3f) { cos_theta = 1 - 2 * u.x; } else { float square = (1 - g * g) / (1 - g + 2 * g * u.x); cos_theta = (1 + g * g - square * square) / (2 * g); } auto sin_theta = sqrt(max(0.0f, 1 - cos_theta * cos_theta)); auto phi = 2 * pif * u.y; return {sin_theta * cos(phi), sin_theta * sin(phi), cos_theta}; } float eval_phasefunction(float cos_theta, float g) { auto denom = 1 + g * g + 2 * g * cos_theta; return (1 - g * g) / (4 * pif * denom * sqrt(denom)); } // Tabulated ior for metals // https://github.com/tunabrain/tungsten const unordered_map> metal_ior_table = { {"a-C", {{2.9440999183f, 2.2271502925f, 1.9681668794f}, {0.8874329109f, 0.7993216383f, 0.8152862927f}}}, {"Ag", {{0.1552646489f, 0.1167232965f, 0.1383806959f}, {4.8283433224f, 3.1222459278f, 2.1469504455f}}}, {"Al", {{1.6574599595f, 0.8803689579f, 0.5212287346f}, {9.2238691996f, 6.2695232477f, 4.8370012281f}}}, {"AlAs", {{3.6051023902f, 3.2329365777f, 2.2175611545f}, {0.0006670247f, -0.0004999400f, 0.0074261204f}}}, {"AlSb", {{-0.0485225705f, 4.1427547893f, 4.6697691348f}, {-0.0363741915f, 0.0937665154f, 1.3007390124f}}}, {"Au", {{0.1431189557f, 0.3749570432f, 1.4424785571f}, {3.9831604247f, 2.3857207478f, 1.6032152899f}}}, {"Be", {{4.1850592788f, 3.1850604423f, 2.7840913457f}, {3.8354398268f, 3.0101260162f, 2.8690088743f}}}, {"Cr", {{4.3696828663f, 2.9167024892f, 1.6547005413f}, {5.2064337956f, 4.2313645277f, 3.7549467933f}}}, {"CsI", {{2.1449030413f, 1.7023164587f, 1.6624194173f}, {0.0000000000f, 0.0000000000f, 0.0000000000f}}}, {"Cu", {{0.2004376970f, 0.9240334304f, 1.1022119527f}, {3.9129485033f, 2.4528477015f, 2.1421879552f}}}, {"Cu2O", {{3.5492833755f, 2.9520622449f, 2.7369202137f}, {0.1132179294f, 0.1946659670f, 0.6001681264f}}}, {"CuO", {{3.2453822204f, 2.4496293965f, 2.1974114493f}, {0.5202739621f, 0.5707372756f, 0.7172250613f}}}, {"d-C", {{2.7112524747f, 2.3185812849f, 2.2288565009f}, {0.0000000000f, 0.0000000000f, 0.0000000000f}}}, {"Hg", {{2.3989314904f, 1.4400254917f, 0.9095512090f}, {6.3276269444f, 4.3719414152f, 3.4217899270f}}}, {"HgTe", {{4.7795267752f, 3.2309984581f, 2.6600252401f}, {1.6319827058f, 1.5808189339f, 1.7295753852f}}}, {"Ir", {{3.0864098394f, 2.0821938440f, 1.6178866805f}, {5.5921510077f, 4.0671757150f, 3.2672611269f}}}, {"K", {{0.0640493070f, 0.0464100621f, 0.0381842017f}, {2.1042155920f, 1.3489364357f, 0.9132113889f}}}, {"Li", {{0.2657871942f, 0.1956102432f, 0.2209198538f}, {3.5401743407f, 2.3111306542f, 1.6685930000f}}}, {"MgO", {{2.0895885542f, 1.6507224525f, 1.5948759692f}, {0.0000000000f, -0.0000000000f, 0.0000000000f}}}, {"Mo", {{4.4837010280f, 3.5254578255f, 2.7760769438f}, {4.1111307988f, 3.4208716252f, 3.1506031404f}}}, {"Na", {{0.0602665320f, 0.0561412435f, 0.0619909494f}, {3.1792906496f, 2.1124800781f, 1.5790940266f}}}, {"Nb", {{3.4201353595f, 2.7901921379f, 2.3955856658f}, {3.4413817900f, 2.7376437930f, 2.5799132708f}}}, {"Ni", {{2.3672753521f, 1.6633583302f, 1.4670554172f}, {4.4988329911f, 3.0501643957f, 2.3454274399f}}}, {"Rh", {{2.5857954933f, 1.8601866068f, 1.5544279524f}, {6.7822927110f, 4.7029501026f, 3.9760892461f}}}, {"Se-e", {{5.7242724833f, 4.1653992967f, 4.0816099264f}, {0.8713747439f, 1.1052845009f, 1.5647788766f}}}, {"Se", {{4.0592611085f, 2.8426947380f, 2.8207582835f}, {0.7543791750f, 0.6385150558f, 0.5215872029f}}}, {"SiC", {{3.1723450205f, 2.5259677964f, 2.4793623897f}, {0.0000007284f, -0.0000006859f, 0.0000100150f}}}, {"SnTe", {{4.5251865890f, 1.9811525984f, 1.2816819226f}, {0.0000000000f, 0.0000000000f, 0.0000000000f}}}, {"Ta", {{2.0625846607f, 2.3930915569f, 2.6280684948f}, {2.4080467973f, 1.7413705864f, 1.9470377016f}}}, {"Te-e", {{7.5090397678f, 4.2964603080f, 2.3698732430f}, {5.5842076830f, 4.9476231084f, 3.9975145063f}}}, {"Te", {{7.3908396088f, 4.4821028985f, 2.6370708478f}, {3.2561412892f, 3.5273908133f, 3.2921683116f}}}, {"ThF4", {{1.8307187117f, 1.4422274283f, 1.3876488528f}, {0.0000000000f, 0.0000000000f, 0.0000000000f}}}, {"TiC", {{3.7004673762f, 2.8374356509f, 2.5823030278f}, {3.2656905818f, 2.3515586388f, 2.1727857800f}}}, {"TiN", {{1.6484691607f, 1.1504482522f, 1.3797795097f}, {3.3684596226f, 1.9434888540f, 1.1020123347f}}}, {"TiO2-e", {{3.1065574823f, 2.5131551146f, 2.5823844157f}, {0.0000289537f, -0.0000251484f, 0.0001775555f}}}, {"TiO2", {{3.4566203131f, 2.8017076558f, 2.9051485020f}, {0.0001026662f, -0.0000897534f, 0.0006356902f}}}, {"VC", {{3.6575665991f, 2.7527298065f, 2.5326814570f}, {3.0683516659f, 2.1986687713f, 1.9631816252f}}}, {"VN", {{2.8656011588f, 2.1191817791f, 1.9400767149f}, {3.0323264950f, 2.0561075580f, 1.6162930914f}}}, {"V", {{4.2775126218f, 3.5131538236f, 2.7611257461f}, {3.4911844504f, 2.8893580874f, 3.1116965117f}}}, {"W", {{4.3707029924f, 3.3002972445f, 2.9982666528f}, {3.5006778591f, 2.6048652781f, 2.2731930614f}}}, }; // Get a complex ior table with keys the metal name and values (eta, etak) pair get_conductor_eta(const string& name) { if (metal_ior_table.find(name) == metal_ior_table.end()) return {zero3f, zero3f}; return metal_ior_table.at(name); } // Stores sigma_prime_s, sigma_a static unordered_map> subsurface_params_table = { // From "A Practical Model for Subsurface Light Transport" // Jensen, Marschner, Levoy, Hanrahan // Proc SIGGRAPH 2001 {"Apple", {{2.29, 2.39, 1.97}, {0.0030, 0.0034, 0.046}}}, {"Chicken1", {{0.15, 0.21, 0.38}, {0.015, 0.077, 0.19}}}, {"Chicken2", {{0.19, 0.25, 0.32}, {0.018, 0.088, 0.20}}}, {"Cream", {{7.38, 5.47, 3.15}, {0.0002, 0.0028, 0.0163}}}, {"Ketchup", {{0.18, 0.07, 0.03}, {0.061, 0.97, 1.45}}}, {"Marble", {{2.19, 2.62, 3.00}, {0.0021, 0.0041, 0.0071}}}, {"Potato", {{0.68, 0.70, 0.55}, {0.0024, 0.0090, 0.12}}}, {"Skimmilk", {{0.70, 1.22, 1.90}, {0.0014, 0.0025, 0.0142}}}, {"Skin1", {{0.74, 0.88, 1.01}, {0.032, 0.17, 0.48}}}, {"Skin2", {{1.09, 1.59, 1.79}, {0.013, 0.070, 0.145}}}, {"Spectralon", {{11.6, 20.4, 14.9}, {0.00, 0.00, 0.00}}}, {"Wholemilk", {{2.55, 3.21, 3.77}, {0.0011, 0.0024, 0.014}}}, // From "Acquiring Scattering Properties of Participating Media by // Dilution", // Narasimhan, Gupta, Donner, Ramamoorthi, Nayar, Jensen // Proc SIGGRAPH 2006 {"Lowfat Milk", {{0.89187, 1.5136, 2.532}, {0.002875, 0.00575, 0.0115}}}, {"Reduced Milk", {{2.4858, 3.1669, 4.5214}, {0.0025556, 0.0051111, 0.012778}}}, {"Regular Milk", {{4.5513, 5.8294, 7.136}, {0.0015333, 0.0046, 0.019933}}}, {"Espresso", {{0.72378, 0.84557, 1.0247}, {4.7984, 6.5751, 8.8493}}}, {"Mint Mocha Coffee", {{0.31602, 0.38538, 0.48131}, {3.772, 5.8228, 7.82}}}, {"Lowfat Soy Milk", {{0.30576, 0.34233, 0.61664}, {0.0014375, 0.0071875, 0.035937}}}, {"Regular Soy Milk", {{0.59223, 0.73866, 1.4693}, {0.0019167, 0.0095833, 0.065167}}}, {"Lowfat Chocolate Milk", {{0.64925, 0.83916, 1.1057}, {0.0115, 0.0368, 0.1564}}}, {"Regular Chocolate Milk", {{1.4585, 2.1289, 2.9527}, {0.010063, 0.043125, 0.14375}}}, {"Coke", {{8.9053e-05, 8.372e-05, 0}, {0.10014, 0.16503, 0.2468}}}, {"Pepsi", {{6.1697e-05, 4.2564e-05, 0}, {0.091641, 0.14158, 0.20729}}}, {"Sprite", {{6.0306e-06, 6.4139e-06, 6.5504e-06}, {0.001886, 0.0018308, 0.0020025}}}, {"Gatorade", {{0.0024574, 0.003007, 0.0037325}, {0.024794, 0.019289, 0.008878}}}, {"Chardonnay", {{1.7982e-05, 1.3758e-05, 1.2023e-05}, {0.010782, 0.011855, 0.023997}}}, {"White Zinfandel", {{1.7501e-05, 1.9069e-05, 1.288e-05}, {0.012072, 0.016184, 0.019843}}}, {"Merlot", {{2.1129e-05, 0, 0}, {0.11632, 0.25191, 0.29434}}}, {"Budweiser Beer", {{2.4356e-05, 2.4079e-05, 1.0564e-05}, {0.011492, 0.024911, 0.057786}}}, {"Coors Light Beer", {{5.0922e-05, 4.301e-05, 0}, {0.006164, 0.013984, 0.034983}}}, {"Clorox", {{0.0024035, 0.0031373, 0.003991}, {0.0033542, 0.014892, 0.026297}}}, {"Apple Juice", {{0.00013612, 0.00015836, 0.000227}, {0.012957, 0.023741, 0.052184}}}, {"Cranberry Juice", {{0.00010402, 0.00011646, 7.8139e-05}, {0.039437, 0.094223, 0.12426}}}, {"Grape Juice", {{5.382e-05, 0, 0}, {0.10404, 0.23958, 0.29325}}}, {"Ruby Grapefruit Juice", {{0.011002, 0.010927, 0.011036}, {0.085867, 0.18314, 0.25262}}}, {"White Grapefruit Juice", {{0.22826, 0.23998, 0.32748}, {0.0138, 0.018831, 0.056781}}}, {"Shampoo", {{0.0007176, 0.0008303, 0.0009016}, {0.014107, 0.045693, 0.061717}}}, {"Strawberry Shampoo", {{0.00015671, 0.00015947, 1.518e-05}, {0.01449, 0.05796, 0.075823}}}, {"Head & Shoulders Shampoo", {{0.023805, 0.028804, 0.034306}, {0.084621, 0.15688, 0.20365}}}, {"Lemon Tea Powder", {{0.040224, 0.045264, 0.051081}, {2.4288, 4.5757, 7.2127}}}, {"Orange Powder", {{0.00015617, 0.00017482, 0.0001762}, {0.001449, 0.003441, 0.007863}}}, {"Pink Lemonade Powder", {{0.00012103, 0.00013073, 0.00012528}, {0.001165, 0.002366, 0.003195}}}, {"Cappuccino Powder", {{1.8436, 2.5851, 2.1662}, {35.844, 49.547, 61.084}}}, {"Salt Powder", {{0.027333, 0.032451, 0.031979}, {0.28415, 0.3257, 0.34148}}}, {"Sugar Powder", {{0.00022272, 0.00025513, 0.000271}, {0.012638, 0.031051, 0.050124}}}, {"Suisse Mocha Powder", {{2.7979, 3.5452, 4.3365}, {17.502, 27.004, 35.433}}}, {"Pacific Ocean Surface Water", {{0.0001764, 0.00032095, 0.00019617}, {0.031845, 0.031324, 0.030147}}}}; // Get subsurface params pair get_subsurface_params(const string& name) { if (subsurface_params_table.find(name) == subsurface_params_table.end()) return {zero3f, zero3f}; return subsurface_params_table.at(name); } // Check if we are on the same side of the hemisphere bool same_hemisphere( const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { return dot(normal, outgoing) * dot(normal, incoming) > 0; } bool other_hemisphere( const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { return dot(normal, outgoing) * dot(normal, incoming) < 0; } // Minimum roughness for GGX static const auto trace_min_roughness = 0.03f * 0.03f; // Evaluates/sample the BRDF scaled by the cosine of the incoming direction. vec3f eval_diffuse_reflection(float roughness, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!same_hemisphere(normal, outgoing, incoming)) return zero3f; return vec3f{abs(dot(normal, incoming)) / pif}; } vec3f eval_diffuse_translucency(float roughness, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!other_hemisphere(normal, outgoing, incoming)) return zero3f; return vec3f{abs(dot(normal, incoming)) / pif}; } vec3f eval_microfacet_reflection(float roughness, const vec3f& eta, const vec3f& etak, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!same_hemisphere(normal, outgoing, incoming)) return zero3f; roughness = clamp(roughness, trace_min_roughness, 1.0f); auto up_normal = dot(normal, outgoing) > 0 ? normal : -normal; auto halfway = normalize(incoming + outgoing); auto F = etak == zero3f ? fresnel_dielectric(eta, abs(dot(halfway, outgoing))) : fresnel_conductor(eta, etak, abs(dot(halfway, outgoing))); auto D = eval_microfacetD(roughness, up_normal, halfway); auto G = eval_microfacetG(roughness, up_normal, halfway, outgoing, incoming); return F * D * G / abs(4 * dot(normal, outgoing) * dot(normal, incoming)) * abs(dot(normal, incoming)); } vec3f eval_delta_reflection(const vec3f& eta, const vec3f& etak, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!same_hemisphere(normal, outgoing, incoming)) return zero3f; auto F = etak == zero3f ? fresnel_dielectric(eta, abs(dot(normal, outgoing))) : fresnel_conductor(eta, etak, abs(dot(normal, outgoing))); return F; } vec3f eval_microfacet_transmission(float roughness, const vec3f& eta, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!other_hemisphere(normal, outgoing, incoming)) return zero3f; roughness = clamp(roughness, trace_min_roughness, 1.0f); auto up_normal = dot(outgoing, normal) > 0 ? normal : -normal; auto halfway_vector = dot(outgoing, normal) > 0 ? -(outgoing + eta * incoming) : (eta * outgoing + incoming); auto halfway = normalize(halfway_vector); auto F = fresnel_dielectric(eta, abs(dot(halfway, outgoing))); auto D = eval_microfacetD(roughness, up_normal, halfway); auto G = eval_microfacetG(roughness, up_normal, halfway, outgoing, incoming); auto dot_terms = (dot(outgoing, halfway) * dot(incoming, halfway)) / (dot(outgoing, normal) * dot(incoming, normal)); auto numerator = (1 - F) * D * G; auto denominator = dot(halfway_vector, halfway_vector); // [Walter 2007] equation 21 return abs(dot_terms) * numerator / denominator * abs(dot(normal, incoming)); } vec3f eval_delta_transmission(const vec3f& eta, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!other_hemisphere(normal, outgoing, incoming)) return zero3f; auto F = fresnel_dielectric(eta, abs(dot(normal, outgoing))); return (1 - F); } vec3f eval_microfacet_transparency(float roughness, const vec3f& eta, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!other_hemisphere(normal, outgoing, incoming)) return zero3f; roughness = clamp(roughness, trace_min_roughness, 1.0f); auto up_normal = dot(outgoing, normal) > 0 ? normal : -normal; auto ir = reflect(-incoming, up_normal); auto halfway = normalize(ir + outgoing); auto F = fresnel_dielectric(eta, abs(dot(halfway, outgoing))); auto D = eval_microfacetD(roughness, up_normal, halfway); auto G = eval_microfacetG(roughness, up_normal, halfway, outgoing, ir); return (1 - F) * D * G / abs(4 * dot(normal, outgoing) * dot(normal, incoming)) * abs(dot(normal, incoming)); } vec3f eval_delta_transparency(const vec3f& eta, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!other_hemisphere(normal, outgoing, incoming)) return zero3f; if (eta == zero3f || eta == vec3f{1, 1, 1}) { return {1, 1, 1}; } else { auto F = fresnel_dielectric(eta, abs(dot(normal, outgoing))); return (1 - F); } } vec3f eval_delta_passthrough( const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!other_hemisphere(normal, outgoing, incoming)) return zero3f; return {1, 1, 1}; } vec3f eval_volume_scattering(const vec3f& albedo, float phaseg, const vec3f& outgoing, const vec3f& incoming) { return albedo * eval_phasefunction(dot(outgoing, incoming), phaseg); } // Picks a direction based on the BRDF vec3f sample_diffuse_reflection(float roughness, const vec3f& normal, const vec3f& outgoing, const vec2f& rn) { auto up_normal = dot(normal, outgoing) > 0 ? normal : -normal; return sample_hemisphere(up_normal, rn); } vec3f sample_diffuse_translucency(float roughness, const vec3f& normal, const vec3f& outgoing, const vec2f& rn) { auto up_normal = dot(normal, outgoing) > 0 ? normal : -normal; return sample_hemisphere(-up_normal, rn); } vec3f sample_microfacet_reflection(float roughness, const vec3f& eta, const vec3f& normal, const vec3f& outgoing, const vec2f& rn) { roughness = clamp(roughness, trace_min_roughness, 1.0f); auto up_normal = dot(normal, outgoing) > 0 ? normal : -normal; auto halfway = sample_microfacet(roughness, up_normal, rn); return reflect(outgoing, halfway); } vec3f sample_delta_reflection( const vec3f& eta, const vec3f& normal, const vec3f& outgoing) { auto up_normal = dot(normal, outgoing) > 0 ? normal : -normal; return reflect(outgoing, up_normal); } vec3f sample_microfacet_transmission(float roughness, const vec3f& eta, const vec3f& normal, const vec3f& outgoing, const vec2f& rn) { roughness = clamp(roughness, trace_min_roughness, 1.0f); auto up_normal = dot(normal, outgoing) > 0 ? normal : -normal; auto halfway = sample_microfacet(roughness, up_normal, rn); return refract( outgoing, halfway, dot(normal, outgoing) > 0 ? 1 / mean(eta) : mean(eta)); } vec3f sample_delta_transmission( const vec3f& eta, const vec3f& normal, const vec3f& outgoing) { auto up_normal = dot(normal, outgoing) > 0 ? normal : -normal; return refract(outgoing, up_normal, dot(normal, outgoing) > 0 ? 1 / mean(eta) : mean(eta)); } vec3f sample_microfacet_transparency(float roughness, const vec3f& eta, const vec3f& normal, const vec3f& outgoing, const vec2f& rn) { roughness = clamp(roughness, trace_min_roughness, 1.0f); auto up_normal = dot(normal, outgoing) > 0 ? normal : -normal; auto halfway = sample_microfacet(roughness, up_normal, rn); auto ir = reflect(outgoing, halfway); return -reflect(ir, up_normal); } vec3f sample_delta_transparency( const vec3f& eta, const vec3f& normal, const vec3f& outgoing) { return -outgoing; } vec3f sample_delta_passthrough(const vec3f& normal, const vec3f& outgoing) { return -outgoing; } vec3f sample_volume_scattering( const vec3f& albedo, float phaseg, const vec3f& outgoing, const vec2f& rn) { auto direction = sample_phasefunction(phaseg, rn); return basis_fromz(-outgoing) * direction; } // Compute the weight for sampling the BRDF float sample_diffuse_reflection_pdf(float roughness, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!same_hemisphere(normal, outgoing, incoming)) return 0; return abs(dot(normal, incoming)) / pif; } float sample_diffuse_translucency_pdf(float roughness, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!other_hemisphere(normal, outgoing, incoming)) return 0; return abs(dot(normal, incoming)) / pif; } float sample_microfacet_reflection_pdf(float roughness, const vec3f& eta, const vec3f& etak, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!same_hemisphere(normal, outgoing, incoming)) return 0; roughness = clamp(roughness, trace_min_roughness, 1.0f); auto up_normal = dot(normal, outgoing) >= 0 ? normal : -normal; auto halfway = normalize(incoming + outgoing); return sample_microfacet_pdf(roughness, up_normal, halfway) / (4 * abs(dot(outgoing, halfway))); } float sample_delta_reflection_pdf(const vec3f& eta, const vec3f& etak, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!same_hemisphere(normal, outgoing, incoming)) return 0; return 1; } float sample_microfacet_transmission_pdf(float roughness, const vec3f& eta, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!other_hemisphere(normal, outgoing, incoming)) return 0; roughness = clamp(roughness, trace_min_roughness, 1.0f); auto up_normal = dot(outgoing, normal) > 0 ? normal : -normal; auto halfway_vector = dot(outgoing, normal) > 0 ? -(outgoing + eta * incoming) : (eta * outgoing + incoming); auto halfway = normalize(halfway_vector); // [Walter 2007] equation 17 return sample_microfacet_pdf(roughness, up_normal, halfway) * abs(dot(halfway, incoming)) / dot(halfway_vector, halfway_vector); } float sample_delta_transmission_pdf(const vec3f& eta, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!other_hemisphere(normal, outgoing, incoming)) return 0; return 1; } float sample_microfacet_transparency_pdf(float roughness, const vec3f& eta, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!other_hemisphere(normal, outgoing, incoming)) return 0; roughness = clamp(roughness, trace_min_roughness, 1.0f); auto up_normal = dot(outgoing, normal) > 0 ? normal : -normal; auto ir = reflect(-incoming, up_normal); auto halfway = normalize(ir + outgoing); auto d = sample_microfacet_pdf(roughness, up_normal, halfway); return d / (4 * abs(dot(outgoing, halfway))); } float sample_delta_transparency_pdf(const vec3f& eta, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!other_hemisphere(normal, outgoing, incoming)) return 0; return 1; } float sample_delta_passthrough_pdf( const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!other_hemisphere(normal, outgoing, incoming)) return 0; return 1; } float sample_volume_scattering_pdf(const vec3f& albedo, float phaseg, const vec3f& outgoing, const vec3f& incoming) { return eval_phasefunction(dot(outgoing, incoming), phaseg); } } // namespace yocto // ----------------------------------------------------------------------------- // IMPLEMENTATION FOR PATH TRACING // ----------------------------------------------------------------------------- namespace yocto { // Set non-rigid frames as default static const bool trace_non_rigid_frames = true; // defaults static const auto coat_roughness = 0.03f * 0.03f; bool has_brdf(const material_point& material) { return material.coat != zero3f || material.specular != zero3f || material.diffuse != zero3f || material.transmission != zero3f; } bool has_volume(const material_point& material) { return material.voldensity != zero3f; } bool is_delta(const material_point& material) { return material.roughness == 0; } vec3f eval_emission(const material_point& material, const vec3f& normal, const vec3f& outgoing) { return material.emission; } vec3f eval_volemission(const material_point& material, const vec3f& outgoing) { return material.volemission; } // Evaluates/sample the BRDF scaled by the cosine of the incoming direction. vec3f eval_brdfcos(const material_point& material, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (is_delta(material)) return zero3f; auto up_normal = dot(normal, outgoing) > 0 ? normal : -normal; auto ceta = reflectivity_to_eta(material.coat); auto eta = reflectivity_to_eta(material.specular); if (!material.thin && material.transmission != zero3f && dot(normal, outgoing) < 0) { ceta = 1 / ceta; eta = 1 / eta; } auto brdfcos = zero3f; if (material.coat != zero3f && same_hemisphere(normal, outgoing, incoming)) { auto halfway = normalize(incoming + outgoing); auto fresnel = fresnel_dielectric(ceta, abs(dot(halfway, outgoing))); auto D = eval_microfacetD(coat_roughness, up_normal, halfway); auto G = eval_microfacetG( coat_roughness, up_normal, halfway, outgoing, incoming); brdfcos += fresnel * D * G / abs(4 * dot(normal, outgoing) * dot(normal, incoming)) * abs(dot(normal, incoming)); } if (material.specular != zero3f && same_hemisphere(normal, outgoing, incoming)) { auto halfway = normalize(incoming + outgoing); auto coat = fresnel_dielectric(ceta, abs(dot(halfway, outgoing))); auto fresnel = fresnel_dielectric(eta, abs(dot(halfway, outgoing))); auto D = eval_microfacetD(material.roughness, up_normal, halfway); auto G = eval_microfacetG( material.roughness, up_normal, halfway, outgoing, incoming); brdfcos += (1 - coat) * fresnel * D * G / abs(4 * dot(normal, outgoing) * dot(normal, incoming)) * abs(dot(normal, incoming)); } if (material.diffuse != zero3f && same_hemisphere(normal, outgoing, incoming)) { auto halfway = normalize(incoming + outgoing); auto coat = fresnel_dielectric(ceta, abs(dot(halfway, outgoing))); auto specular = fresnel_dielectric(eta, abs(dot(halfway, outgoing))); brdfcos += (1 - coat) * (1 - specular) * material.diffuse / pif * abs(dot(normal, incoming)); } if (material.transmission != zero3f && other_hemisphere(normal, outgoing, incoming) && !material.thin) { auto eta = mean(reflectivity_to_eta(material.specular)); auto halfway_vector = dot(outgoing, normal) > 0 ? -(outgoing + eta * incoming) : (eta * outgoing + incoming); auto halfway = normalize(halfway_vector); auto coat = fresnel_dielectric(ceta, abs(dot(halfway, outgoing))); auto fresnel = fresnel_dielectric( dot(outgoing, normal) > 0 ? vec3f{eta} : vec3f{1 / eta}, abs(dot(halfway, outgoing))); auto D = eval_microfacetD(material.roughness, up_normal, halfway); auto G = eval_microfacetG( material.roughness, up_normal, halfway, outgoing, incoming); auto dot_terms = (dot(outgoing, halfway) * dot(incoming, halfway)) / (dot(outgoing, normal) * dot(incoming, normal)); // [Walter 2007] equation 21 brdfcos += (1 - coat) * material.transmission * abs(dot_terms) * (1 - fresnel) * D * G / dot(halfway_vector, halfway_vector) * abs(dot(normal, incoming)); } if (material.transmission != zero3f && other_hemisphere(normal, outgoing, incoming) && material.thin) { auto ir = reflect(-incoming, up_normal); auto halfway = normalize(ir + outgoing); auto fresnel = fresnel_dielectric(ceta, abs(dot(halfway, outgoing))); auto D = eval_microfacetD(material.roughness, up_normal, halfway); auto G = eval_microfacetG( material.roughness, up_normal, halfway, outgoing, ir); brdfcos += material.transmission * (1 - fresnel) * D * G / abs(4 * dot(normal, outgoing) * dot(normal, incoming)) * abs(dot(normal, incoming)); } return brdfcos; } vec3f eval_delta(const material_point& material, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!is_delta(material)) return zero3f; auto brdfcos = zero3f; auto ceta = reflectivity_to_eta(material.coat); auto eta = reflectivity_to_eta(material.specular); if (!material.thin && material.transmission != zero3f && dot(normal, outgoing) < 0) { ceta = 1 / ceta; eta = 1 / eta; } if (material.coat != zero3f && same_hemisphere(normal, outgoing, incoming)) { brdfcos += fresnel_dielectric(ceta, abs(dot(normal, outgoing))); } if (material.specular != zero3f && same_hemisphere(normal, outgoing, incoming)) { auto coat = fresnel_dielectric(ceta, abs(dot(normal, outgoing))); brdfcos += (1 - coat) * fresnel_dielectric(eta, abs(dot(normal, outgoing))); } if (material.transmission != zero3f && other_hemisphere(normal, outgoing, incoming)) { auto coat = fresnel_dielectric(ceta, abs(dot(normal, outgoing))); auto specular = fresnel_dielectric(eta, abs(dot(normal, outgoing))); brdfcos += (1 - coat) * (1 - specular) * material.transmission; } return brdfcos; } vec4f compute_brdf_pdfs(const material_point& material, const vec3f& normal, const vec3f& outgoing) { auto ceta = reflectivity_to_eta(material.coat); auto eta = reflectivity_to_eta(material.specular); if (!material.thin && material.transmission != zero3f && dot(normal, outgoing) < 0) { ceta = 1 / ceta; eta = 1 / eta; } auto ndo = abs(dot(outgoing, normal)); auto coat = fresnel_dielectric(ceta, ndo); auto specular = fresnel_dielectric(eta, ndo); auto weights = zero4f; weights[0] = max(coat); weights[1] = max((1 - coat) * specular); weights[2] = max((1 - coat) * (1 - specular) * material.diffuse); weights[3] = max((1 - coat) * (1 - specular) * material.transmission); weights /= sum(weights); return weights; } // Picks a direction based on the BRDF vec3f sample_brdf(const material_point& material, const vec3f& normal, const vec3f& outgoing, float rnl, const vec2f& rn) { if (is_delta(material)) return zero3f; auto pdfs = compute_brdf_pdfs(material, normal, outgoing); auto up_normal = dot(normal, outgoing) > 0 ? normal : -normal; // keep a weight sum to pick a lobe auto weight_sum = 0.0f; weight_sum += pdfs[0]; if (rnl < weight_sum) { auto halfway = sample_microfacet(coat_roughness, up_normal, rn); return reflect(outgoing, halfway); } weight_sum += pdfs[1]; if (rnl < weight_sum) { auto halfway = sample_microfacet(material.roughness, up_normal, rn); return reflect(outgoing, halfway); } weight_sum += pdfs[2]; if (rnl < weight_sum) { return sample_hemisphere(up_normal, rn); } weight_sum += pdfs[3]; if (rnl < weight_sum && !material.thin) { auto halfway = sample_microfacet(material.roughness, up_normal, rn); auto eta = mean(reflectivity_to_eta(material.specular)); return refract_notir( outgoing, halfway, dot(normal, outgoing) > 0 ? 1 / eta : eta); } if (rnl < weight_sum && material.thin) { auto halfway = sample_microfacet(material.roughness, up_normal, rn); auto ir = reflect(outgoing, halfway); return -reflect(ir, up_normal); } // something went wrong if we got here return zero3f; } vec3f sample_delta(const material_point& material, const vec3f& normal, const vec3f& outgoing, float rnl) { if (!is_delta(material)) return zero3f; auto up_normal = dot(normal, outgoing) > 0 ? normal : -normal; auto pdfs = compute_brdf_pdfs(material, normal, outgoing); // keep a weight sum to pick a lobe auto weight_sum = 0.0f; weight_sum += pdfs[0]; if (rnl < weight_sum) { return reflect(outgoing, up_normal); } weight_sum += pdfs[1]; if (rnl < weight_sum) { return reflect(outgoing, up_normal); } weight_sum += pdfs[2]; // skip diffuse weight_sum += pdfs[3]; if (rnl < weight_sum && !material.thin) { auto eta = mean(reflectivity_to_eta(material.specular)); return refract_notir( outgoing, up_normal, dot(normal, outgoing) > 0 ? 1 / eta : eta); } if (rnl < weight_sum && material.thin) { return -outgoing; } // something went wrong if we got here return zero3f; } // Compute the weight for sampling the BRDF float sample_brdf_pdf(const material_point& material, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (is_delta(material)) return 0; auto up_normal = dot(normal, outgoing) >= 0 ? normal : -normal; auto pdfs = compute_brdf_pdfs(material, normal, outgoing); auto pdf = 0.0f; if (pdfs[0] && same_hemisphere(normal, outgoing, incoming)) { auto halfway = normalize(incoming + outgoing); pdf += pdfs[0] * sample_microfacet_pdf(coat_roughness, up_normal, halfway) / (4 * abs(dot(outgoing, halfway))); } if (pdfs[1] && same_hemisphere(normal, outgoing, incoming)) { auto halfway = normalize(incoming + outgoing); pdf += pdfs[1] * sample_microfacet_pdf(material.roughness, up_normal, halfway) / (4 * abs(dot(outgoing, halfway))); } if (pdfs[2] && same_hemisphere(normal, outgoing, incoming)) { pdf += pdfs[2] * sample_hemisphere_pdf(up_normal, incoming); } if (pdfs[3] && other_hemisphere(normal, outgoing, incoming) && !material.thin) { auto eta = mean(reflectivity_to_eta(material.specular)); auto halfway_vector = dot(outgoing, normal) > 0 ? -(outgoing + eta * incoming) : (eta * outgoing + incoming); auto halfway = normalize(halfway_vector); // [Walter 2007] equation 17 pdf += pdfs[3] * sample_microfacet_pdf(material.roughness, up_normal, halfway) * abs(dot(halfway, incoming)) / dot(halfway_vector, halfway_vector); } if (pdfs[3] && other_hemisphere(normal, outgoing, incoming) && material.thin) { auto up_normal = dot(outgoing, normal) > 0 ? normal : -normal; auto ir = reflect(-incoming, up_normal); auto halfway = normalize(ir + outgoing); auto d = sample_microfacet_pdf(material.roughness, up_normal, halfway); pdf += pdfs[3] * d / (4 * abs(dot(outgoing, halfway))); } return pdf; } float sample_delta_pdf(const material_point& material, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!is_delta(material)) return 0; auto pdfs = compute_brdf_pdfs(material, normal, outgoing); auto pdf = 0.0f; if (pdfs[0] && same_hemisphere(normal, outgoing, incoming)) pdf += pdfs[0]; if (pdfs[1] && same_hemisphere(normal, outgoing, incoming)) pdf += pdfs[1]; if (pdfs[3] && other_hemisphere(normal, outgoing, incoming)) pdf += pdfs[3]; return pdf; } vec3f eval_volscattering(const material_point& material, const vec3f& outgoing, const vec3f& incoming) { if (!has_volume(material)) return zero3f; auto scattering = zero3f; if (material.voldensity != zero3f) { scattering += eval_volume_scattering( material.volscatter, material.volanisotropy, outgoing, incoming); } return scattering; } vec3f sample_volscattering(const material_point& material, const vec3f& outgoing, float rnl, const vec2f& rn) { if (!has_volume(material)) return zero3f; auto weights = vec2f{max(material.voldensity), 0}; if (weights == zero2f) return zero3f; weights /= sum(weights); // keep a weight sum to pick a lobe auto weight_sum = 0.0f; weight_sum += weights[0]; if (rnl < weight_sum) { return sample_volume_scattering( material.volscatter, material.volanisotropy, outgoing, rn); } // something went wrong if we got here return zero3f; } float sample_volscattering_pdf(const material_point& material, const vec3f& outgoing, const vec3f& incoming) { if (!has_volume(material)) return 0; auto weights = vec2f{max(material.voldensity), 0}; if (weights == zero2f) return 0; weights /= sum(weights); // commpute pdf auto pdf = 0.0f; if (weights[0]) { pdf += weights[0] * sample_volume_scattering_pdf(material.volscatter, material.volanisotropy, outgoing, incoming); } return pdf; } // Sample pdf for an environment. float sample_environment_pdf(const yocto_scene& scene, const trace_lights& lights, int environment_id, const vec3f& incoming) { auto& environment = scene.environments[environment_id]; if (environment.emission_tex >= 0) { auto& cdf = lights.environment_cdfs[environment.emission_tex]; auto& emission_tex = scene.textures[environment.emission_tex]; auto size = texture_size(emission_tex); auto texcoord = eval_texcoord(environment, incoming); auto i = clamp((int)(texcoord.x * size.x), 0, size.x - 1); auto j = clamp((int)(texcoord.y * size.y), 0, size.y - 1); auto prob = sample_discrete_pdf(cdf, j * size.x + i) / cdf.back(); auto angle = (2 * pif / size.x) * (pif / size.y) * sin(pif * (j + 0.5f) / size.y); return prob / angle; } else { return 1 / (4 * pif); } } // Picks a point on an environment. vec3f sample_environment(const yocto_scene& scene, const trace_lights& lights, int environment_id, float rel, const vec2f& ruv) { auto& environment = scene.environments[environment_id]; if (environment.emission_tex >= 0) { auto& cdf = lights.environment_cdfs[environment.emission_tex]; auto& emission_tex = scene.textures[environment.emission_tex]; auto idx = sample_discrete(cdf, rel); auto size = texture_size(emission_tex); auto u = (idx % size.x + 0.5f) / size.x; auto v = (idx / size.x + 0.5f) / size.y; return eval_direction(environment, {u, v}); } else { return sample_sphere(ruv); } } // Picks a point on a light. vec3f sample_light(const yocto_scene& scene, const trace_lights& lights, int instance_id, const vec3f& p, float rel, const vec2f& ruv) { auto& instance = scene.instances[instance_id]; auto& shape = scene.shapes[instance.shape]; auto& cdf = lights.shape_cdfs[instance.shape]; auto sample = sample_shape(shape, cdf, rel, ruv); auto element = sample.first; auto uv = sample.second; return normalize(eval_position(scene, instance, element, uv) - p); } // Sample pdf for a light point. float sample_light_pdf(const yocto_scene& scene, const trace_lights& lights, int instance_id, const bvh_scene& bvh, const vec3f& position, const vec3f& direction) { auto& instance = scene.instances[instance_id]; auto& material = scene.materials[instance.material]; if (material.emission == zero3f) return 0; auto& cdf = lights.shape_cdfs[instance.shape]; // check all intersection auto pdf = 0.0f; auto next_position = position; for (auto bounce = 0; bounce < 100; bounce++) { auto isec = intersect_bvh(bvh, instance_id, {next_position, direction}); if (!isec.hit) break; // accumulate pdf auto& instance = scene.instances[isec.instance]; auto light_position = eval_position(scene, instance, isec.element, isec.uv); auto light_normal = eval_normal( scene, instance, isec.element, isec.uv, trace_non_rigid_frames); // prob triangle * area triangle = area triangle mesh auto area = cdf.back(); pdf += distance_squared(light_position, position) / (abs(dot(light_normal, direction)) * area); // continue next_position = light_position + direction * 1e-3f; } return pdf; } // Sample lights wrt solid angle vec3f sample_lights(const yocto_scene& scene, const trace_lights& lights, const bvh_scene& bvh, const vec3f& position, float rl, float rel, const vec2f& ruv) { auto light_id = sample_uniform( lights.instances.size() + lights.environments.size(), rl); if (light_id < lights.instances.size()) { auto instance = lights.instances[light_id]; return sample_light(scene, lights, instance, position, rel, ruv); } else { auto environment = lights.environments[light_id - (int)lights.instances.size()]; return sample_environment(scene, lights, environment, rel, ruv); } } // Sample lights pdf float sample_lights_pdf(const yocto_scene& scene, const trace_lights& lights, const bvh_scene& bvh, const vec3f& position, const vec3f& direction) { auto pdf = 0.0f; for (auto instance : lights.instances) { pdf += sample_light_pdf(scene, lights, instance, bvh, position, direction); } for (auto environment : lights.environments) { pdf += sample_environment_pdf(scene, lights, environment, direction); } pdf *= sample_uniform_pdf( lights.instances.size() + lights.environments.size()); return pdf; } // Trace stats. std::atomic _trace_npaths{0}; std::atomic _trace_nrays{0}; // Sample camera ray3f sample_camera(const yocto_camera& camera, const vec2i& ij, const vec2i& image_size, const vec2f& puv, const vec2f& luv) { return eval_camera(camera, ij, image_size, puv, sample_disk(luv)); } ray3f sample_camera_tent(const yocto_camera& camera, const vec2i& ij, const vec2i& image_size, const vec2f& puv, const vec2f& luv) { const auto width = 2.0f; const auto offset = 0.5f; auto fuv = width * vec2f{ puv.x < 0.5f ? sqrt(2 * puv.x) - 1 : 1 - sqrt(2 - 2 * puv.x), puv.y - 0.5f ? sqrt(2 * puv.y) - 1 : 1 - sqrt(2 - 2 * puv.y), } + offset; return eval_camera(camera, ij, image_size, fuv, sample_disk(luv)); } // Recursive path tracing. pair trace_path(const yocto_scene& scene, const bvh_scene& bvh, const trace_lights& lights, const vec3f& origin_, const vec3f& direction_, rng_state& rng, const trace_params& params) { // initialize auto radiance = zero3f; auto weight = vec3f{1, 1, 1}; auto origin = origin_; auto direction = direction_; auto volume_stack = vector>{}; auto hit = false; // trace path for (auto bounce = 0; bounce < params.bounces; bounce++) { // intersect next point _trace_nrays += 1; auto intersection = intersect_bvh(bvh, {origin, direction}); if (!intersection.hit) { radiance += weight * eval_environment(scene, direction); break; } // handle transmission if inside a volume auto in_volume = false; if (!volume_stack.empty()) { auto medium = volume_stack.back().first; auto [distance, channel] = sample_distance( medium.voldensity, rand1f(rng), rand1f(rng)); distance = min(distance, intersection.distance); weight *= eval_transmission(medium.voldensity, distance) / sample_distance_pdf(medium.voldensity, distance, channel); in_volume = distance < intersection.distance; intersection.distance = distance; } // switch between surface and volume if (!in_volume) { // prepare shading point auto outgoing = -direction; auto& instance = scene.instances[intersection.instance]; auto position = eval_position( scene, instance, intersection.element, intersection.uv); auto normal = eval_shading_normal(scene, instance, intersection.element, intersection.uv, direction, trace_non_rigid_frames); auto material = eval_material( scene, instance, intersection.element, intersection.uv); // handle opacity if (material.opacity < 1 && rand1f(rng) >= material.opacity) { origin = position + direction * 1e-2f; bounce -= 1; continue; } hit = true; // accumulate emission radiance += weight * eval_emission(material, normal, outgoing); // next direction auto incoming = zero3f; if (!is_delta(material)) { if (rand1f(rng) < 0.5f) { incoming = sample_brdf( material, normal, outgoing, rand1f(rng), rand2f(rng)); } else { incoming = sample_lights(scene, lights, bvh, position, rand1f(rng), rand1f(rng), rand2f(rng)); } weight *= eval_brdfcos(material, normal, outgoing, incoming) / (0.5f * sample_brdf_pdf(material, normal, outgoing, incoming) + 0.5f * sample_lights_pdf(scene, lights, bvh, position, incoming)); } else { incoming = sample_delta(material, normal, outgoing, rand1f(rng)); weight *= eval_delta(material, normal, outgoing, incoming) / sample_delta_pdf(material, normal, outgoing, incoming); } // update volume stack if (material.voldensity != zero3f && other_hemisphere(normal, outgoing, incoming)) { if (volume_stack.empty()) { volume_stack.push_back({material, intersection.instance}); } else { volume_stack.pop_back(); } } // setup next iteration origin = position; direction = incoming; } else { // prepare shading point auto outgoing = -direction; auto position = origin + direction * intersection.distance; auto material = volume_stack.back().first; // handle opacity hit = true; // accumulate emission radiance += weight * eval_volemission(material, outgoing); // next direction auto incoming = zero3f; if (rand1f(rng) < 0.5f) { incoming = sample_volscattering( material, outgoing, rand1f(rng), rand2f(rng)); } else { incoming = sample_lights(scene, lights, bvh, position, rand1f(rng), rand1f(rng), rand2f(rng)); } weight *= eval_volscattering(material, outgoing, incoming) / (0.5f * sample_volscattering_pdf(material, outgoing, incoming) + 0.5f * sample_lights_pdf(scene, lights, bvh, position, incoming)); // setup next iteration origin = position; direction = incoming; } // check weight if (weight == zero3f || !is_finite(weight)) break; // russian roulette if (max(weight) < 1 && bounce > 6) { auto rr_prob = max((float)0.05, 1 - max(weight)); if (rand1f(rng) > rr_prob) break; weight *= 1 / rr_prob; } } return {radiance, hit}; } // Recursive path tracing. pair trace_naive(const yocto_scene& scene, const bvh_scene& bvh, const trace_lights& lights, const vec3f& origin_, const vec3f& direction_, rng_state& rng, const trace_params& params) { // initialize auto radiance = zero3f; auto weight = vec3f{1, 1, 1}; auto origin = origin_; auto direction = direction_; auto hit = false; // trace path for (auto bounce = 0; bounce < params.bounces; bounce++) { // intersect next point _trace_nrays += 1; auto intersection = intersect_bvh(bvh, {origin, direction}); if (!intersection.hit) { radiance += weight * eval_environment(scene, direction); break; } // prepare shading point auto outgoing = -direction; auto incoming = outgoing; auto& instance = scene.instances[intersection.instance]; auto position = eval_position( scene, instance, intersection.element, intersection.uv); auto normal = eval_shading_normal(scene, instance, intersection.element, intersection.uv, direction, trace_non_rigid_frames); auto material = eval_material( scene, instance, intersection.element, intersection.uv); // handle opacity if (material.opacity < 1 && rand1f(rng) >= material.opacity) { origin = position + direction * 1e-2f; bounce -= 1; continue; } hit = true; // accumulate emission radiance += weight * eval_emission(material, normal, outgoing); // next direction if (!is_delta(material)) { incoming = sample_brdf( material, normal, outgoing, rand1f(rng), rand2f(rng)); weight *= eval_brdfcos(material, normal, outgoing, incoming) / sample_brdf_pdf(material, normal, outgoing, incoming); } else { incoming = sample_delta(material, normal, outgoing, rand1f(rng)); weight *= eval_delta(material, normal, outgoing, incoming) / sample_delta_pdf(material, normal, outgoing, incoming); } // check weight if (weight == zero3f || !is_finite(weight)) break; // russian roulette if (max(weight) < 1 && bounce > 3) { auto rr_prob = max((float)0.05, 1 - max(weight)); if (rand1f(rng) > rr_prob) break; weight *= 1 / rr_prob; } // setup next iteration origin = position; direction = incoming; } return {radiance, hit}; } // Eyelight for quick previewing. pair trace_eyelight(const yocto_scene& scene, const bvh_scene& bvh, const trace_lights& lights, const vec3f& origin_, const vec3f& direction_, rng_state& rng, const trace_params& params) { // initialize auto radiance = zero3f; auto weight = vec3f{1, 1, 1}; auto origin = origin_; auto direction = direction_; auto hit = false; // trace path for (auto bounce = 0; bounce < max(params.bounces, 4); bounce++) { // intersect next point _trace_nrays += 1; auto intersection = intersect_bvh(bvh, {origin, direction}); if (!intersection.hit) { radiance += weight * eval_environment(scene, direction); break; } // prepare shading point auto outgoing = -direction; auto& instance = scene.instances[intersection.instance]; auto position = eval_position( scene, instance, intersection.element, intersection.uv); auto normal = eval_shading_normal(scene, instance, intersection.element, intersection.uv, direction, trace_non_rigid_frames); auto material = eval_material( scene, instance, intersection.element, intersection.uv); // handle opacity if (material.opacity < 1 && rand1f(rng) >= material.opacity) { origin = position + direction * 1e-2f; bounce -= 1; continue; } hit = true; // accumulate emission radiance += weight * eval_emission(material, normal, outgoing); // brdf * light radiance += weight * pif * eval_brdfcos(material, normal, outgoing, outgoing); // continue path if (!is_delta(material)) break; auto incoming = sample_delta(material, normal, outgoing, rand1f(rng)); weight *= eval_delta(material, normal, outgoing, incoming) / sample_delta_pdf(material, normal, outgoing, incoming); if (weight == zero3f || !is_finite(weight)) break; // setup next iteration origin = position; direction = incoming; } return {radiance, hit}; } // False color rendering pair trace_falsecolor(const yocto_scene& scene, const bvh_scene& bvh, const trace_lights& lights, const vec3f& origin, const vec3f& direction, rng_state& rng, const trace_params& params) { // intersect next point auto intersection = intersect_bvh(bvh, ray3f{origin, direction}); if (!intersection.hit) { return {zero3f, false}; } // get scene elements auto& instance = scene.instances[intersection.instance]; auto& shape = scene.shapes[instance.shape]; // auto& material = scene.materials[instance.material]; // prepare shading point auto outgoing = -direction; // auto position = eval_position( // scene, instance, intersection.element, intersection.uv); auto normal = eval_shading_normal(scene, instance, intersection.element, intersection.uv, direction, trace_non_rigid_frames); auto material = eval_material( scene, instance, intersection.element, intersection.uv); switch (params.falsecolor) { case trace_params::falsecolor_type::normal: { return {normal * 0.5f + 0.5f, 1}; } case trace_params::falsecolor_type::frontfacing: { auto frontfacing = dot(normal, outgoing) > 0 ? vec3f{0, 1, 0} : vec3f{1, 0, 0}; return {frontfacing, 1}; } case trace_params::falsecolor_type::gnormal: { auto normal = eval_element_normal( scene, instance, intersection.element, true); return {normal * 0.5f + 0.5f, 1}; } case trace_params::falsecolor_type::gfrontfacing: { auto normal = eval_element_normal( scene, instance, intersection.element, true); auto frontfacing = dot(normal, outgoing) > 0 ? vec3f{0, 1, 0} : vec3f{1, 0, 0}; return {frontfacing, 1}; } case trace_params::falsecolor_type::texcoord: { auto texcoord = eval_texcoord( shape, intersection.element, intersection.uv); return {{texcoord.x, texcoord.y, 0}, 1}; } case trace_params::falsecolor_type::color: { auto color = eval_color(shape, intersection.element, intersection.uv); return {xyz(color), 1}; } case trace_params::falsecolor_type::emission: { return {material.emission, 1}; } case trace_params::falsecolor_type::diffuse: { return {material.diffuse, 1}; } case trace_params::falsecolor_type::specular: { return {material.specular, 1}; } case trace_params::falsecolor_type::transmission: { return {material.transmission, 1}; } case trace_params::falsecolor_type::roughness: { return {vec3f{material.roughness}, 1}; } case trace_params::falsecolor_type::material: { auto hashed = std::hash()(instance.material); auto rng_ = make_rng(trace_default_seed, hashed); return {pow(0.5f + 0.5f * rand3f(rng_), 2.2f), 1}; } case trace_params::falsecolor_type::element: { auto hashed = std::hash()(intersection.element); auto rng_ = make_rng(trace_default_seed, hashed); return {pow(0.5f + 0.5f * rand3f(rng_), 2.2f), 1}; } case trace_params::falsecolor_type::shape: { auto hashed = std::hash()(instance.shape); auto rng_ = make_rng(trace_default_seed, hashed); return {pow(0.5f + 0.5f * rand3f(rng_), 2.2f), 1}; } case trace_params::falsecolor_type::instance: { auto hashed = std::hash()(intersection.instance); auto rng_ = make_rng(trace_default_seed, hashed); return {pow(0.5f + 0.5f * rand3f(rng_), 2.2f), 1}; } case trace_params::falsecolor_type::highlight: { auto emission = material.emission; auto outgoing = -direction; if (emission == zero3f) emission = {0.2f, 0.2f, 0.2f}; return {emission * abs(dot(outgoing, normal)), 1}; } default: { return {zero3f, false}; } } } // Trace a single ray from the camera using the given algorithm. using trace_sampler_func = pair (*)(const yocto_scene& scene, const bvh_scene& bvh, const trace_lights& lights, const vec3f& position, const vec3f& direction, rng_state& rng, const trace_params& params); trace_sampler_func get_trace_sampler_func(const trace_params& params) { switch (params.sampler) { case trace_params::sampler_type::path: return trace_path; case trace_params::sampler_type::naive: return trace_naive; case trace_params::sampler_type::eyelight: return trace_eyelight; case trace_params::sampler_type::falsecolor: return trace_falsecolor; default: { throw std::runtime_error("sampler unknown"); return nullptr; } } } // Check is a sampler requires lights bool is_sampler_lit(const trace_params& params) { switch (params.sampler) { case trace_params::sampler_type::path: return true; case trace_params::sampler_type::naive: return true; case trace_params::sampler_type::eyelight: return false; case trace_params::sampler_type::falsecolor: return false; default: { throw std::runtime_error("sampler unknown"); return false; } } } // Get trace pixel trace_pixel& get_trace_pixel(trace_state& state, int i, int j) { return state.pixels[j * state.image_size.x + i]; } // Trace a block of samples void trace_region(image& image, trace_state& state, const yocto_scene& scene, const bvh_scene& bvh, const trace_lights& lights, const image_region& region, int num_samples, const trace_params& params) { auto& camera = scene.cameras.at(params.camera); auto sampler = get_trace_sampler_func(params); for (auto j = region.min.y; j < region.max.y; j++) { for (auto i = region.min.x; i < region.max.x; i++) { auto& pixel = get_trace_pixel(state, i, j); for (auto s = 0; s < num_samples; s++) { if (params.cancel && *params.cancel) return; _trace_npaths += 1; auto ray = params.tentfilter ? sample_camera_tent(camera, {i, j}, image.size(), rand2f(pixel.rng), rand2f(pixel.rng)) : sample_camera(camera, {i, j}, image.size(), rand2f(pixel.rng), rand2f(pixel.rng)); auto [radiance, hit] = sampler( scene, bvh, lights, ray.o, ray.d, pixel.rng, params); if (!hit) { if (params.envhidden || scene.environments.empty()) { radiance = zero3f; hit = false; } else { hit = true; } } if (!is_finite(radiance)) { // printf("NaN detected\n"); radiance = zero3f; } if (max(radiance) > params.clamp) radiance = radiance * (params.clamp / max(radiance)); pixel.radiance += radiance; pixel.hits += hit ? 1 : 0; pixel.samples += 1; } auto radiance = pixel.hits ? pixel.radiance / pixel.hits : zero3f; auto coverage = (float)pixel.hits / (float)pixel.samples; image[{i, j}] = {radiance.x, radiance.y, radiance.z, coverage}; } } } // Init a sequence of random number generators. trace_state make_trace_state(const vec2i& image_size, uint64_t seed) { auto state = trace_state{image_size, vector(image_size.x * image_size.y, trace_pixel{})}; auto rng = make_rng(1301081); for (auto j = 0; j < state.image_size.y; j++) { for (auto i = 0; i < state.image_size.x; i++) { auto& pixel = get_trace_pixel(state, i, j); pixel.rng = make_rng(seed, rand1i(rng, 1 << 31) / 2 + 1); } } return state; } void make_trace_state( trace_state& state, const vec2i& image_size, uint64_t seed) { state = trace_state{image_size, vector(image_size.x * image_size.y, trace_pixel{})}; auto rng = make_rng(1301081); for (auto j = 0; j < state.image_size.y; j++) { for (auto i = 0; i < state.image_size.x; i++) { auto& pixel = get_trace_pixel(state, i, j); pixel.rng = make_rng(seed, rand1i(rng, 1 << 31) / 2 + 1); } } } // Init trace lights trace_lights make_trace_lights(const yocto_scene& scene) { auto lights = trace_lights{}; lights.shape_cdfs.resize(scene.shapes.size()); lights.environment_cdfs.resize(scene.textures.size()); for (auto idx = 0; idx < scene.instances.size(); idx++) { auto& instance = scene.instances[idx]; auto& shape = scene.shapes[instance.shape]; auto& material = scene.materials[instance.material]; if (material.emission == zero3f) continue; if (shape.triangles.empty() && shape.quads.empty()) continue; lights.instances.push_back(idx); lights.shape_cdfs[instance.shape] = sample_shape_cdf(shape); } for (auto idx = 0; idx < scene.environments.size(); idx++) { auto& environment = scene.environments[idx]; if (environment.emission == zero3f) continue; lights.environments.push_back(idx); if (environment.emission_tex >= 0) { lights.environment_cdfs[environment.emission_tex] = sample_environment_cdf(scene, environment); } } return lights; } void make_trace_lights(trace_lights& lights, const yocto_scene& scene) { lights = {}; lights.shape_cdfs.resize(scene.shapes.size()); lights.environment_cdfs.resize(scene.textures.size()); for (auto idx = 0; idx < scene.instances.size(); idx++) { auto& instance = scene.instances[idx]; auto& shape = scene.shapes[instance.shape]; auto& material = scene.materials[instance.material]; if (material.emission == zero3f) continue; if (shape.triangles.empty() && shape.quads.empty()) continue; lights.instances.push_back(idx); sample_shape_cdf(shape, lights.shape_cdfs[instance.shape]); } for (auto idx = 0; idx < scene.environments.size(); idx++) { auto& environment = scene.environments[idx]; if (environment.emission == zero3f) continue; lights.environments.push_back(idx); if (environment.emission_tex >= 0) { sample_environment_cdf(scene, environment, lights.environment_cdfs[environment.emission_tex]); } } } // Progressively compute an image by calling trace_samples multiple times. image trace_image(const yocto_scene& scene, const bvh_scene& bvh, const trace_lights& lights, const trace_params& params) { auto image_size = camera_resolution( scene.cameras.at(params.camera), params.resolution); auto render = image{image_size, zero4f}; auto state = make_trace_state(render.size(), params.seed); auto regions = make_regions(render.size(), params.region, true); if (params.noparallel) { for (auto& region : regions) { if (params.cancel && *params.cancel) break; trace_region( render, state, scene, bvh, lights, region, params.samples, params); } } else { auto futures = vector>{}; auto nthreads = std::thread::hardware_concurrency(); std::atomic next_idx(0); for (auto thread_id = 0; thread_id < nthreads; thread_id++) { futures.emplace_back(std::async( std::launch::async, [&render, &state, &scene, &bvh, &lights, ¶ms, ®ions, &next_idx]() { while (true) { if (params.cancel && *params.cancel) break; auto idx = next_idx.fetch_add(1); if (idx >= regions.size()) break; trace_region(render, state, scene, bvh, lights, regions[idx], params.samples, params); } })); } for (auto& f : futures) f.get(); } return render; } // Progressively compute an image by calling trace_samples multiple times. int trace_samples(image& render, trace_state& state, const yocto_scene& scene, const bvh_scene& bvh, const trace_lights& lights, int current_sample, const trace_params& params) { auto regions = make_regions(render.size(), params.region, true); auto num_samples = min(params.batch, params.samples - current_sample); if (params.noparallel) { for (auto& region : regions) { if (params.cancel && *params.cancel) break; trace_region( render, state, scene, bvh, lights, region, params.samples, params); } } else { auto futures = vector>{}; auto nthreads = std::thread::hardware_concurrency(); std::atomic next_idx(0); for (auto thread_id = 0; thread_id < nthreads; thread_id++) { futures.emplace_back(std::async( std::launch::async, [&render, &state, &scene, &bvh, &lights, ¶ms, ®ions, &next_idx, num_samples]() { while (true) { if (params.cancel && *params.cancel) break; auto idx = next_idx.fetch_add(1); if (idx >= regions.size()) break; trace_region(render, state, scene, bvh, lights, regions[idx], num_samples, params); } })); } for (auto& f : futures) f.get(); } return current_sample + num_samples; } // Trace statistics for last run used for fine tuning implementation. // For now returns number of paths and number of rays. pair get_trace_stats() { return {_trace_nrays, _trace_npaths}; } void reset_trace_stats() { _trace_nrays = 0; _trace_npaths = 0; } } // namespace yocto // ----------------------------------------------------------------------------- // UNUSED CODE KEPT FOR REFERENCE // ----------------------------------------------------------------------------- namespace yocto { #if YOCTO_TRACE_THINSHEET // Schlick approximation of the Fresnel term vec3f fresnel_schlick( const vec3f& specular, const vec3f& half_vector, const vec3f& incoming) { if (specular == zero3f) return zero3f; return specular + (vec3f{1, 1, 1} - specular) * pow(clamp(1.0f - fabs(dot(half_vector, incoming)), 0.0f, 1.0f), 5.0f); } vec3f fresnel_schlick(const vec3f& specular, const vec3f& half_vector, const vec3f& incoming, float roughness) { if (specular == zero3f) return zero3f; auto fks = fresnel_schlick(specular, half_vector, incoming); return specular + (fks - specular) * (1 - sqrt(clamp(roughness, 0.0f, 1.0f))); } // Evaluates the GGX distribution and geometric term float evaluate_ggx_distribution( float roughness, const vec3f& normal, const vec3f& half_vector) { auto di = (dot(normal, half_vector) * dot(normal, half_vector)) * (roughness * roughness - 1) + 1; return roughness * roughness / (pif * di * di); } float evaluate_ggx_shadowing(float roughness, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { #if 0 // evaluate G from Heitz auto lambda_o = (-1 + sqrt(1 + alpha2 * (1 - ndo * ndo) / (ndo * ndo))) / 2; auto lambda_i = (-1 + sqrt(1 + alpha2 * (1 - ndi * ndi) / (ndi * ndi))) / 2; auto g = 1 / (1 + lambda_o + lambda_i); #else auto Go = (2 * fabs(dot(normal, outgoing))) / (fabs(dot(normal, outgoing)) + sqrt(roughness * roughness + (1 - roughness * roughness) * dot(normal, outgoing) * dot(normal, outgoing))); auto Gi = (2 * fabs(dot(normal, incoming))) / (fabs(dot(normal, incoming)) + sqrt(roughness * roughness + (1 - roughness * roughness) * dot(normal, incoming) * dot(normal, incoming))); return Go * Gi; #endif } // Evaluates the GGX pdf float sample_ggx_pdf(float rs, float ndh) { auto alpha2 = rs * rs; auto di = (ndh * ndh) * (alpha2 - 1) + 1; auto d = alpha2 / (pif * di * di); return d * ndh; } // Sample the GGX distribution vec3f sample_ggx(float rs, const vec2f& rn) { auto tan2 = rs * rs * rn.y / (1 - rn.y); auto rz = sqrt(1 / (tan2 + 1)); auto rr = sqrt(1 - rz * rz); auto rphi = 2 * pif * rn.x; // set to wh auto wh_local = vec3f{rr * cos(rphi), rr * sin(rphi), rz}; return wh_local; } // Evaluates the BRDF scaled by the cosine of the incoming direction. // - ggx from [Heitz 2014] and [Walter 2007] and [Lagarde 2014] // "Understanding the Masking-Shadowing Function in Microfacet-Based // BRDFs" http://jcgt.org/published/0003/02/03/ // - "Microfacet Models for Refraction through Rough Surfaces" EGSR 07 // https://www.cs.cornell.edu/~srm/publications/EGSR07-btdf.pdf vec3f evaluate_brdf_cosine(const microfacet_brdf& brdf, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (is_brdf_delta(brdf)) return zero3f; auto brdf_cosine = zero3f; // diffuse if (brdf.diffuse != zero3f && dot(normal, outgoing) * dot(normal, incoming) > 0) { auto half_vector = normalize(incoming + outgoing); auto fresnel = (brdf.fresnel) ? fresnel_schlick(brdf.specular, half_vector, outgoing) : brdf.specular; brdf_cosine += brdf.diffuse * (1 - fresnel) / pif; } // specular if (brdf.specular != zero3f && dot(normal, outgoing) * dot(normal, incoming) > 0) { auto half_vector = normalize(incoming + outgoing); auto fresnel = (brdf.fresnel) ? fresnel_schlick(brdf.specular, half_vector, outgoing) : brdf.specular; auto D = evaluate_ggx_distribution(brdf.roughness, normal, half_vector); auto G = evaluate_ggx_shadowing(brdf.roughness, normal, outgoing, incoming); brdf_cosine += fresnel * D * G / (4 * fabs(dot(normal, outgoing)) * fabs(dot(normal, incoming))); } // transmission (thin sheet) if (brdf.transmission != zero3f && !brdf.refract && dot(normal, outgoing) * dot(normal, incoming) < 0) { auto ir = (dot(normal, outgoing) >= 0) ? reflect(-incoming, normal) : reflect(-incoming, -normal); auto half_vector = normalize(ir + outgoing); auto fresnel = (brdf.fresnel) ? fresnel_schlick(brdf.specular, half_vector, outgoing) : brdf.specular; auto D = evaluate_ggx_distribution(brdf.roughness, normal, half_vector); auto G = evaluate_ggx_shadowing(brdf.roughness, normal, outgoing, ir); brdf_cosine += brdf.transmission * (1 - fresnel) * D * G / (4 * fabs(dot(normal, outgoing)) * fabs(dot(normal, ir))); } // refraction through rough surface if (brdf.transmission != zero3f && brdf.refract && dot(normal, outgoing) * dot(normal, incoming) < 0) { auto eta = specular_to_eta(brdf.specular); auto halfway_vector = dot(normal, outgoing) > 0 ? -(outgoing + eta * incoming) : (eta * outgoing + incoming); auto halfway = normalize(halfway_vector); auto fresnel = fresnel_schlick(brdf.specular, halfway, outgoing); auto D = evaluate_ggx_distribution(brdf.roughness, normal, halfway); auto G = evaluate_ggx_shadowing(brdf.roughness, normal, outgoing, incoming); auto dots = dot(outgoing, halfway) * dot(incoming, halfway) / (dot(outgoing, normal) * dot(incoming, normal)); auto numerator = (1 - fresnel) * D * G; auto denominator = dot(halfway_vector, halfway_vector); brdf_cosine += abs(dots) * numerator / denominator; } return brdf_cosine * abs(dot(normal, incoming)); } // Evaluates the BRDF assuming that it is called only from the directions // generated by sample_brdf_direction. vec3f evaluate_delta_brdf_cosine(const microfacet_brdf& brdf, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!is_brdf_delta(brdf)) return zero3f; auto microfacet_brdf = zero3f; // specular if (brdf.specular != zero3f && dot(normal, outgoing) * dot(normal, incoming) > 0) { auto fresnel = (brdf.fresnel) ? fresnel_schlick(brdf.specular, normal, outgoing) : brdf.specular; microfacet_brdf += fresnel; } // transmission (thin sheet) if (brdf.transmission != zero3f && dot(normal, outgoing) * dot(normal, incoming) < 0) { auto fresnel = (brdf.fresnel) ? fresnel_schlick(brdf.specular, normal, outgoing) : brdf.specular; microfacet_brdf += brdf.transmission * (1 - fresnel); } return microfacet_brdf; } // Picks a direction based on the BRDF vec3f sample_brdf_direction(const microfacet_brdf& brdf, const vec3f& normal, const vec3f& outgoing, float rnl, const vec2f& rn) { if (is_brdf_delta(brdf)) return zero3f; auto fresnel = (brdf.fresnel) ? fresnel_schlick(brdf.specular, normal, outgoing) : brdf.specular; auto prob = vec3f{max(brdf.diffuse * (1 - fresnel)), max(fresnel), max(brdf.transmission * (1 - fresnel))}; if (prob == zero3f) return zero3f; prob /= prob.x + prob.y + prob.z; // sample according to diffuse if (brdf.diffuse != zero3f && rnl < prob.x) { auto rz = sqrtf(rn.y), rr = sqrtf(1 - rz * rz), rphi = 2 * pif * rn.x; auto il = vec3f{rr * cosf(rphi), rr * sinf(rphi), rz}; auto fp = dot(normal, outgoing) >= 0 ? frame_fromz(zero3f, normal) : frame_fromz(zero3f, -normal); return transform_direction(fp, il); } // sample according to specular GGX else if (brdf.specular != zero3f && rnl < prob.x + prob.y) { auto hl = sample_ggx(brdf.roughness, rn); auto fp = dot(normal, outgoing) >= 0 ? frame_fromz(zero3f, normal) : frame_fromz(zero3f, -normal); auto half_vector = transform_direction(fp, hl); return reflect(outgoing, half_vector); } // transmission hack else if (brdf.transmission != zero3f && !brdf.refract && rnl < prob.x + prob.y + prob.z) { auto hl = sample_ggx(brdf.roughness, rn); auto fp = dot(normal, outgoing) >= 0 ? frame_fromz(zero3f, normal) : frame_fromz(zero3f, -normal); auto half_vector = transform_direction(fp, hl); auto ir = reflect(outgoing, half_vector); return dot(normal, outgoing) >= 0 ? reflect(-ir, -normal) : reflect(-ir, normal); } // sample according to rough refraction else if (brdf.transmission != zero3f && brdf.refract && rnl < prob.x + prob.y + prob.z) { auto hl = sample_ggx(brdf.roughness, rn); auto fp = dot(normal, outgoing) >= 0 ? frame_fromz(zero3f, normal) : frame_fromz(zero3f, -normal); auto halfway = transform_direction(fp, hl); auto eta = specular_to_eta(brdf.specular); return refract( outgoing, halfway, dot(normal, outgoing) >= 0 ? 1 / eta : eta); } else { return zero3f; } } // Picks a direction based on the BRDF vec3f sample_delta_brdf_direction(const microfacet_brdf& brdf, const vec3f& normal, const vec3f& outgoing, float rnl, const vec2f& rn) { if (!is_brdf_delta(brdf)) return zero3f; auto fresnel = (brdf.fresnel) ? fresnel_schlick(brdf.specular, normal, outgoing) : brdf.specular; auto prob = vec3f{0, max(fresnel), max(brdf.transmission * (1 - fresnel))}; if (prob == zero3f) return zero3f; prob /= prob.x + prob.y + prob.z; // sample according to specular mirror if (brdf.specular != zero3f && rnl < prob.x + prob.y) { return reflect(outgoing, dot(normal, outgoing) >= 0 ? normal : -normal); } // sample according to transmission else if (brdf.transmission != zero3f && !brdf.refract && rnl < prob.x + prob.y + prob.z) { return -outgoing; } // sample according to transmission else if (brdf.transmission != zero3f && brdf.refract && rnl < prob.x + prob.y + prob.z) { if (dot(normal, outgoing) >= 0) { return refract(outgoing, normal, 1 / specular_to_eta(brdf.specular)); } else { return refract(outgoing, -normal, specular_to_eta(brdf.specular)); } } // no sampling else { return zero3f; } } // Compute the weight for sampling the BRDF float sample_brdf_direction_pdf(const microfacet_brdf& brdf, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (is_brdf_delta(brdf)) return 0; auto fresnel = (brdf.fresnel) ? fresnel_schlick(brdf.specular, normal, outgoing) : brdf.specular; auto prob = vec3f{max(brdf.diffuse * (1 - fresnel)), max(fresnel), max(brdf.transmission * (1 - fresnel))}; if (prob == zero3f) return 0; prob /= prob.x + prob.y + prob.z; auto pdf = 0.0f; if (brdf.diffuse != zero3f && dot(normal, outgoing) * dot(normal, incoming) > 0) { pdf += prob.x * fabs(dot(normal, incoming)) / pif; } if (brdf.specular != zero3f && dot(normal, outgoing) * dot(normal, incoming) > 0) { auto half_vector = normalize(incoming + outgoing); auto d = sample_ggx_pdf(brdf.roughness, fabs(dot(normal, half_vector))); pdf += prob.y * d / (4 * fabs(dot(outgoing, half_vector))); } if (brdf.transmission != zero3f && !brdf.refract && dot(normal, outgoing) * dot(normal, incoming) < 0) { auto ir = (dot(normal, outgoing) >= 0) ? reflect(-incoming, normal) : reflect(-incoming, -normal); auto half_vector = normalize(ir + outgoing); auto d = sample_ggx_pdf(brdf.roughness, fabs(dot(normal, half_vector))); pdf += prob.z * d / (4 * fabs(dot(outgoing, half_vector))); } // refraction through rough surface if (brdf.transmission != zero3f && brdf.refract && dot(normal, outgoing) * dot(normal, incoming) < 0) { auto eta = specular_to_eta(brdf.specular); auto outgoing_up = dot(normal, outgoing) > 0; auto halfway_vector = outgoing_up ? -(outgoing + eta * incoming) : (eta * outgoing + incoming); auto halfway = normalize(halfway_vector); auto d = sample_ggx_pdf(brdf.roughness, fabs(dot(normal, halfway))); auto jacobian = fabs(dot(halfway, incoming)) / dot(halfway_vector, halfway_vector); pdf += prob.z * d * jacobian; } return pdf; } // Compute the weight for sampling the BRDF float sample_delta_brdf_direction_pdf(const microfacet_brdf& brdf, const vec3f& normal, const vec3f& outgoing, const vec3f& incoming) { if (!is_brdf_delta(brdf)) return 0; auto fresnel = (brdf.fresnel) ? fresnel_schlick(brdf.specular, normal, outgoing) : brdf.specular; auto prob = vec3f{0, max(fresnel), max(brdf.transmission * (1 - fresnel))}; if (prob == zero3f) return 0; prob /= prob.x + prob.y + prob.z; auto pdf = 0.0f; if (brdf.specular != zero3f && dot(normal, outgoing) * dot(normal, incoming) > 0) { return prob.y; } if (brdf.transmission != zero3f && dot(normal, outgoing) * dot(normal, incoming) < 0) { return prob.z; } return pdf; } #endif } // namespace yocto // ----------------------------------------------------------------------------- // NUMERICAL TESTS FOR MONTE CARLO INTEGRATION // ----------------------------------------------------------------------------- namespace yocto { template float integrate_func_base( const Func& f, float a, float b, int nsamples, rng_state& rng) { auto integral = 0.0f; for (auto i = 0; i < nsamples; i++) { auto r = rand1f(rng); auto x = a + r * (b - a); integral += f(x) * (b - a); } integral /= nsamples; return integral; } template float integrate_func_stratified( const Func& f, float a, float b, int nsamples, rng_state& rng) { auto integral = 0.0f; for (auto i = 0; i < nsamples; i++) { auto r = (i + rand1f(rng)) / nsamples; auto x = a + r * (b - a); integral += f(x) * (b - a); } integral /= nsamples; return integral; } template float integrate_func_importance(const Func& f, const Func& pdf, const Func& warp, int nsamples, rng_state& rng) { auto integral = 0.0f; for (auto i = 0; i < nsamples; i++) { auto r = rand1f(rng); auto x = warp(r); integral += f(x) / pdf(x); } integral /= nsamples; return integral; } // compute the integral and error using different Monte Carlo scehems // example 1: --------- // auto f = [](double x) { return 1.0 - (3.0 / 4.0) * x * x; }; // auto a = 0.0, b = 1.0; // auto expected = 3.0 / 4.0; // auto nsamples = 10000 // example 2: --------- // auto f = [](double x) { return sin(x); } // auto a = 0.0, b = (double)M_PI; // auto expected = (double)M_PI; template void print_integrate_func_test(const Func& f, float a, float b, float expected, int nsamples, const Func& pdf, const Func& warp) { auto rng = rng_state(); printf("nsamples base base-err stratified-err importance-err\n"); for (auto ns = 10; ns < nsamples; ns += 10) { auto integral_base = integrate_func_base(f, a, b, ns, rng); auto integral_stratified = integrate_func_stratified(f, a, b, ns, rng); auto integral_importance = integrate_func_importance(f, pdf, warp, ns, rng); auto error_base = fabs(integral_base - expected) / expected; auto error_stratified = fabs(integral_stratified - expected) / expected; auto error_importance = fabs(integral_importance - expected) / expected; printf("%d %g %g %g %g\n", ns, integral_base, error_base, error_stratified, error_importance); } } template float integrate_func2_base( const Func& f, vec2f a, vec2f b, int nsamples, rng_state& rng) { auto integral = 0.0f; for (auto i = 0; i < nsamples; i++) { auto r = rand2f(rng); auto x = a + r * (b - a); integral += f(x) * (b.x - a.x) * (b.y - a.y); } integral /= nsamples; return integral; } template float integrate_func2_stratified( const Func& f, vec2f a, vec2f b, int nsamples, rng_state& rng) { auto integral = 0.0f; auto nsamples2 = (int)sqrt(nsamples); for (auto i = 0; i < nsamples2; i++) { for (auto j = 0; j < nsamples2; j++) { auto r = vec2f{ (i + rand1f(rng)) / nsamples2, (j + rand1f(rng)) / nsamples2}; auto x = a + r * (b - a); integral += f(x) * (b.x - a.x) * (b.y - a.y); } } integral /= nsamples2 * nsamples2; return integral; } template float integrate_func2_importance(const Func& f, const Func& pdf, const Func2& warp, int nsamples, rng_state& rng) { auto integral = 0.0f; for (auto i = 0; i < nsamples; i++) { auto r = rand2f(rng); auto x = warp(r); integral += f(x) / pdf(x); } integral /= nsamples; return integral; } // compute the integral and error using different Monte Carlo scehems // example 1: --------- // auto f = [](double x) { return 1.0 - (3.0 / 4.0) * x * x; }; // auto a = 0.0, b = 1.0; // auto expected = 3.0 / 4.0; // auto nsamples = 10000 template void print_integrate_func2_test(const Func& f, vec2f a, vec2f b, float expected, int nsamples, const Func& pdf, const Func2& warp) { auto rng = rng_state(); printf("nsamples base base-err stratified-err importance-err\n"); for (auto ns = 10; ns < nsamples; ns += 10) { auto integral_base = integrate_func2_base(f, a, b, ns, rng); auto integral_stratified = integrate_func2_stratified(f, a, b, ns, rng); auto integral_importance = integrate_func2_importance( f, pdf, warp, ns, rng); auto error_base = fabs(integral_base - expected) / expected; auto error_stratified = fabs(integral_stratified - expected) / expected; auto error_importance = fabs(integral_importance - expected) / expected; printf("%d %g %g %g %g\n", ns, integral_base, error_base, error_stratified, error_importance); } } } // namespace yocto goxel-0.11.0/ext_src/yocto/yocto_trace.h000066400000000000000000000225141435762723100202150ustar00rootroot00000000000000// // # Yocto/Trace: Tiny path tracer // // // Yocto/Trace is a simple path tracing library with support for microfacet // materials, area and environment lights, and advacned sampling. // // // ## Physically-based Path Tracing // // Yocto/Trace includes a tiny, but fully featured, path tracer with support for // textured mesh area lights, GGX materials, environment mapping. The algorithm // makes heavy use of MIS for fast convergence. // The interface supports progressive parallel execution both synchronously, // for CLI applications, and asynchronously for interactive viewing. // // Materials are represented as sums of an emission term, a diffuse term and // a specular microfacet term (GGX or Phong), and a transmission term for // this sheet glass. // Lights are defined as any shape with a material emission term. Additionally // one can also add environment maps. But even if you can, you might want to // add a large triangle mesh with inward normals instead. The latter is more // general (you can even more an arbitrary shape sun). For now only the first // environment is used. // // 1. prepare the ray-tracing acceleration structure with `build_bvh()` // 2. prepare lights for rendering with `init_trace_lights()` // 3. create the random number generators with `init_trace_state()` // 4. render blocks of samples with `trace_samples()` // 5. you can also start an asynchronous renderer with `trace_asynch_start()` // // // // LICENSE: // // Copyright (c) 2016 -- 2019 Fabio Pellacini // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // #ifndef _YOCTO_TRACE_H_ #define _YOCTO_TRACE_H_ #ifndef YOCTO_QUADS_AS_TRIANGLES #define YOCTO_QUADS_AS_TRIANGLES 1 #endif #ifndef YOCTO_TRACE_THINSHEET #define YOCTO_TRACE_THINSHEET 0 #endif // ----------------------------------------------------------------------------- // INCLUDES // ----------------------------------------------------------------------------- #include "yocto_bvh.h" #include "yocto_math.h" #include "yocto_random.h" #include "yocto_scene.h" #include // ----------------------------------------------------------------------------- // PATH TRACING // ----------------------------------------------------------------------------- namespace yocto { // Default trace seed const auto trace_default_seed = 961748941ull; // Trace lights used during rendering. struct trace_lights { vector instances = {}; vector environments = {}; vector> shape_cdfs = {}; vector> environment_cdfs = {}; bool empty() const { return instances.empty() && environments.empty(); } }; // Initialize lights. trace_lights make_trace_lights(const yocto_scene& scene); void make_trace_lights(trace_lights& lights, const yocto_scene& scene); // State of a pixel during tracing struct trace_pixel { vec3f radiance = zero3f; int hits = 0; int samples = 0; rng_state rng = {}; }; struct trace_state { vec2i image_size = {0, 0}; vector pixels = {}; }; // Initialize state of the renderer. trace_state make_trace_state( const vec2i& image_size, uint64_t random_seed = trace_default_seed); void make_trace_state(trace_state& state, const vec2i& image_size, uint64_t random_seed = trace_default_seed); // Options for trace functions struct trace_params { // clang-format off // Type of tracing algorithm to use enum struct sampler_type { path, // path tracing naive, // naive path tracing eyelight, // eyelight rendering falsecolor, // false color rendering }; enum struct falsecolor_type { normal, frontfacing, gnormal, gfrontfacing, texcoord, color, emission, diffuse, specular, transmission, roughness, material, shape, instance, element, highlight }; // clang-format on int camera = 0; int resolution = 1280; sampler_type sampler = sampler_type::path; falsecolor_type falsecolor = falsecolor_type::diffuse; int samples = 512; int bounces = 8; int batch = 16; int region = 16; float clamp = 10; bool envhidden = false; bool tentfilter = false; uint64_t seed = trace_default_seed; std::atomic* cancel = nullptr; bool noparallel = false; }; const auto trace_sampler_names = vector{ "path", "naive", "eyelight", "falsecolor"}; const auto trace_falsecolor_names = vector{"normal", "frontfacing", "gnormal", "gfrontfacing", "texcoord", "color", "emission", "diffuse", "specular", "transmission", "roughness", "material", "shape", "instance", "element", "highlight"}; // Equality operators inline bool operator==(const trace_params& a, const trace_params& b) { return memcmp(&a, &b, sizeof(a)) == 0; } inline bool operator!=(const trace_params& a, const trace_params& b) { return memcmp(&a, &b, sizeof(a)) != 0; } // Progressively compute an image by calling trace_samples multiple times. image trace_image(const yocto_scene& scene, const bvh_scene& bvh, const trace_lights& lights, const trace_params& params); // Progressively compute an image by calling trace_samples multiple times. // Start with an empty state and then successively call this function to // render the next batch of samples. int trace_samples(image& image, trace_state& state, const yocto_scene& scene, const bvh_scene& bvh, const trace_lights& lights, int current_sample, const trace_params& params); // Progressively compute an image by calling trace_region multiple times. // Compared to `trace_samples` this always runs serially and is helpful // when building async applications. void trace_region(image& image, trace_state& state, const yocto_scene& scene, const bvh_scene& bvh, const trace_lights& lights, const image_region& region, int num_samples, const trace_params& params); // Check is a sampler requires lights bool is_sampler_lit(const trace_params& params); // Trace statistics for last run used for fine tuning implementation. // For now returns number of paths and number of rays. pair get_trace_stats(); void reset_trace_stats(); } // namespace yocto // ----------------------------------------------------------------------------- // PATH TRACING SUPPORT FUNCTION // ----------------------------------------------------------------------------- namespace yocto { // Phong exponent to roughness. float exponent_to_roughness(float n); // Specular to fresnel eta. vec3f reflectivity_to_eta(const vec3f& reflectivity); vec3f eta_to_reflectivity(const vec3f& eta); pair reflectivity_to_eta( const vec3f& reflectivity, const vec3f& edge_tint); vec3f eta_to_reflectivity(const vec3f& eta, const vec3f& etak); vec3f eta_to_edge_tint(const vec3f& eta, const vec3f& etak); // Compute the fresnel term for dielectrics. vec3f fresnel_dielectric(const vec3f& eta, float direction_cosine); // Compute the fresnel term for metals. vec3f fresnel_conductor( const vec3f& eta, const vec3f& etak, float direction_cosine); // Schlick approximation of Fresnel term, optionally weighted by roughness; vec3f fresnel_schlick(const vec3f& specular, float direction_cosine); vec3f fresnel_schlick( const vec3f& specular, float direction_cosine, float roughness); // Evaluates the microfacet distribution and geometric term (ggx or beckman). float eval_microfacetD(float roughness, const vec3f& normal, const vec3f& half_vector, bool ggx = true); float eval_microfacetG(float roughness, const vec3f& normal, const vec3f& half_vector, const vec3f& outgoing, const vec3f& incoming, bool ggx = true); vec3f sample_microfacet( float roughness, const vec3f& normal, const vec2f& rn, bool ggx = true); float sample_microfacet_pdf(float roughness, const vec3f& normal, const vec3f& half_vector, bool ggx = true); // Evaluate and sample volume phase function. vec3f sample_phasefunction(float vg, const vec2f& u); float eval_phasefunction(float cos_theta, float vg); // Get complex ior from metal names (eta, etak). // Return zeros if not available. pair get_conductor_eta(const string& element); // Get subsurface params pair get_subsurface_params(const string& name); } // namespace yocto #endif goxel-0.11.0/icon.png000066400000000000000000003503271435762723100143710ustar00rootroot00000000000000PNG  IHDR+bKGD pHYs  tIME 5'HP IDATx铝}9繷ll,$H M & A)۩G&š5'Amfj*f&؞D^&N21ږDZ]DJNI$Ab!5n3/y{oOYFl4`1yjf[`8?y rߙ9~gM9+ؽ7'?{g^TlM:Mwsw>|{opk@ G~♗f>3Dki,6iK%Mڒ-n5sD`Нg/?_5Q]DH6y`cI,6mKw$MZm񽹻׾MW$ *WJRJ9qΊˎشt TEտ&BZҢD޷x8t@ s|6+`0='?[o\]/z#Iܔ^tr_HVTW+?[. *H‹_9tTH>ے-I㦼WgCkDdUmbz.H6͓_|kƄAo|4-IQ}sw A+5QosL]lԱӧ,/U}].q#6KqSf~I A +5{+\zmVnYoֻ)]zWIbi'\mIظ-w=[4{R}`~WuTW(eBޮ `ySNgtT9S[-sYgC7@;XҤ#t< [[0{[OL>vZ_=@W$'/ŗ_h^!qq H˳B"g~ׯT}螮8V+0򦎝>sCYWʪyyv,Jڒ&E Cف/G6A?jޚ *>C!Uߍ.qhˉNqDptl!Tq?0 cg}Pg{&oKr14jW@C"!CO]V]V H:!AEW$`H\x+N<3coKrCvi`K y?$~ve]K hg?Lvλ+ \(\+7hC5t$mNW$`}q3&o߹*V5E2_"}@WoJ&Hz˗O_zmքFDq Xnh`ޛzvC8ocH@UWg]0 >g|t?lC]KZi^{{7hGV V+>0ZjWރ Ibŝޜs}_ *yWS߬PZp򓟽ħ~)<F&}G8h=Ԓ 2SNg?C;R`+?"$MU[34?DD&?"6^z|Zq&zޚ AW.kNl_]R=>CV7mh UhLUʣ9g a4uKȯSZ2KgRΆ`:4Ц< [WUM}'Z㓮 >C'v_TO?(҄k@5p ,a@ԭV_IW cg}9Dz C]`˅U?/)+ < zƯw;O8y5tؤ- [‹_9t}&;m7Le`+IZ*bhC~b򜩍|A+@vԱ~͙0oVo^ , t66ao%%y36!> |"VD7$`}q3foL2 Yi%MZiޗGZ-=Ӳȓ>">P6 4HX+Ⴎ ؘ'/|7SMW>^ݫ2/ ]}4I7%n/JmlD='e|{yGIL6?ZW@[lҢ+@VUg3TG+K@qO~iGҸ%I{IK%1I1Ѹ QJ&˞c>0sE(a7;|sݯ,]lG?rXoĉkߕv? $4$nK4>Q-l~|Dc{JYw ) X;dںҸ%?O7KW]kӗ^=|jR?UzZ߼/7+6MĥiGNSt2DcbjEĘ(mIm|LxDu!M380{& eU?O!y_i^F]j?Ns^lA64nKiHu_Z ˾C|6.6.:ȰR7J%c{D@@Rcz2 7tu)VԲU'qA0 ma rS'}? k̔BfJI4W&="Q}X?誃mx]f' ]x+N<3h]mLh6y7/kԷ/> яӼ/..DҸ)I{IΒnU#Y@o"@5aw8 $nA$SN?7|Vܵ MޔV/­gm0 Hi0>$THJ3="Qm*g C7ϠDZr烷 0\.comB4#nԿ/".[Jܼ68'i=MDJ,{4H:)Q29*+9@Wd]Fęt<_W 񞡁 XQ$ M?_=ąmŐx9^$wVo'qkpv%z^w`1t7P$$KtwsL}Bڄ'>\ I+-?OKWWr﬿&In|V'%Y~[Ϋ&}ZFwH (nH}bJJY;8вJ U& 0|6/ʫYM&p/__{UR1?^p$/EEIiNRbqM n$ 3/w:g+Z,+`Pߧ?Б0.k r J,3/{[fh`v<`7D]v?Zu/x*"qVKx_H|E<$ %P\8@b~ё_m).;'`w  1}+W!&ʃɂ%Y{5_dCKw$,=%|֟h/J{x&.P1 PǸRJt4&:Kml8#;ȠJ+=sӗ^QWּ,q<`'^w_1/-u'?PJx5(V 0ֳJ#t$Rd]@6ɥ_ʕç1[Ap)眤qSڍ?_l5@_N]765Qi`up`uuPDj]IC" oYdYאwt8Z*Nĉ@M۔ϓ= PJah&\*.-m%@W5~ufQX)bxfE[9/Iw1/; h@oEߖY!XMM ZחAN @;xS#Y=a Y=I 6}gBP(ΆX~S+PSuB@wL5+B0 (~qogm%\"^ {5oz2 `[UbU6HVSKUuD@e~VDGuJ~m__"lL "3Må];x<`ժ{Q\Wտg߯.匈"w8]$)qJD9{qZ+ڥbTt$ͻ\xlr-k~RF6\$ԋףڸ$[]?̡4| ~@<d {+-Il&;$ąz߹tb v$4,UdY} F:3;})%vz>OI8(J\v柚'2oʯԾ@ks@q%+MdjlUbbG"@T C˷[i"I_^Я8\-6?s~⿲3"wȀ-yJ shh. t{-$6vUג]Z=\ɇ(ߑ.Z&XiCiVZ4qi~)*=?S &vPKffK4' V IDAT=ϻ'ʧG'ZV<* XgE0T:{;R_{.YVt̡/s:|>Du1QVOfU%Svks6پ5IE9 P&ĕ#J+qNI)68gDg& eVVL]0/vڥ_ʕç!)8>>-Umlv:-җ>ޜSH@qpK^ :*[JvXe=${Uy ŗ˻l10eh vCM_z|ghb˿M$[=^/٠miť~RZM}v%@DD+1bi-FLX!GΠYBW U픭;ą}6&?Us<`4+q/|K+t>[6PSVvH}홪*f _K\>V?xN :Qu/]~/S k+Шl{@tWmKvۄAQ+ER~XQ[])$_Z9%#qslwG@yp ]a[p+ps~WL4&3yEhSSYt|q}Q6޳dHƒv2a^I0ݧ@&wtU緪=*MH흳EFc#5k T>40lZtXA}e¬y"ѣӸ'ۻ5S5J8&Q]LT>)>=`vrљNxVt#_ _QhsSi]Ɩ,6.Z$Ci_cJ6W`Anz?'J+:uJ+ ]s@[#Y?/bM*@V n4nIqod[\W@4.&]#`<~n/꟭3Q^UD*#tꫢ8럝[sYvdZ{;uPyU|;f*]NՕHd\uhVE@k+ |y׋kjWW+r}_9Dگ&JW#xڧ sWsYkuJȻR ufR]]"Zubu$ڥbSX%@FyߦVj!BW@k^n`H<~n~{)S gJE^#խVP1/i-5kn{m}Hi߀+TW"kXyBM1|'@RG@q~;'[^E\? 0 Х/|'.,֚i-Je蚫i'ylwMosc眸*[t/*A>T\-1O]1] 9tS~eEl';z_TƷatڜ~ɓ\]%. 0 irit^tC/SΘȟT)__8آs4E4t;@)QZU.9gD;tх)^ޟ`G 3_}N2ј?B!LVTG-\@&DD.wߚ>`F2c+;2]Zu P]rĻbݯdz 0(禟̯ g3-E,U\S?͇:MnǻX=?3XE+t5u7ttl} \#OW@#pj;'{dϽ! H4}H`^ 0xHQvX|]@h\&_H&#=1'jZey -"NF9ӽE`:{ EWF0 w)_UӬFpKC0߮2ou :z[P' *ON699qJXȶ(XTe˝s,Zbi@4oHY%u(^U1gծ33> vԱϾ[s:.M*-Q]U/baWI8:THH8" _[#Y?/9<' <ÿ5HA:ts_9̚h\LT?YA'5OQz-9ի|ؖtc*;P(yW?+;c{!8[t_Cz[(%* , x9=i/%uDpzѧl U7ptE@pX/V|zdDlsh[|y-04)%"+l`w"~X+`w%M:r䉋3 7~߿BW o^9t|M&*L6)Dk GUTxdJ?K`c(#c]|a 4>@d-:@CiMJL$:rE" t$K' 4;У$Ա~9czVy-6_I eZ6sث-.K&rd@1dUi34) 8p}vKLߝtWGMHD 61qI008{c?E*l*i)6Yx`Z+Wmi?U!GC>4ЪRG@Z$Bw@>sΈ' nRW@ӸGn|%T-ZSt$n/ʻ_}H;ɋ/_>}Y_ 7a_^bN@^eˇV3v40 tJDṜΞX%Ƞ6RsY?g%ٜZ" ؾk>-Sj6nW՟;XL8 \fh2J3m#q&bpL"GI+8MŦI:M Zd$:vvWg8?M UiKsHlM9UG<0WmbO,!P #:ڵ[%H?#[Ifi`l,iґӐbSEH^r_+UVגHEYlW;年du3(ks.P"JW#qU{$4wIF(>9ΊMIFϱ4nKiHqOqC lcg}tTmj`TWS@"`cAڪid"-*ZDU5[%tD'gr -__Ji?MJbMafHcW??+*+?xDx/ؖۮ~TFS@%Ju%Vv:蜕_Qe?F[KŦw4:vvϿ1k~ʷRY_9k ] Z 7uf| &>PzZ/{8bs@{GWhA6/%,K{H>4V[y̅ʡg5Ʒ2C|1Μe.׆ꏁzNb&`@uďТ#;\Mؐ ~/Yf_7%[#Cx˗O_zmdC U_ s|֪~.\; ;R+ Ԣ)/)Z5qP('V^%! C"9i/]57&M|'+!S "@4SN~OJGa_  :'@/JVS搞&*CciH0V^ck^k8m`_TY#X^%|7YaşM;zcq'}ޜgH(G✿6G쮙?F+6qyNkR\~_~\e였*w +Ҥ#IkߦCk &:vvWg8?Et4;0s_ mO KMpWmN&440{R:$$:MTh@dCw6_y_ 6ic?yXԓ_|ӯf6!VjFgNƫ I4kuW~_ SEl +f;JsCߦmI I|l,M3ASN?oiS~P@"@i3TUW#T8znh-;bl5\%NR'XtCm)$ wVIG|6nF_wmnr$ׯ CvU %DdHTw]UTOem\ I"ܗfdANy6lm,9Qʈ651ڈa548D&/n/J^=5Hv{_@X_cNG?5Skb`fTRTTweo_@S߱T ]G\ p\*i8+.Ι04'c]Ibn]*ݼߥiu~zn]x7:q~&k&kmÆΦ5'Boc;o_? | !Iu444ZL4o.Vr<`#ϓVIK:tj]OŬH:vvϿ1gL]֦T7咪V9+VfmVKaZ\ /:p7,uyQ ΕWli8':Sg(%986eຟ[n=qCUߣ}wH졓g5Ʒ2%.' szᢺRO{Go1I8(tV<1eED!ԕU~`Z Hڒ&-1ѸOFcai$@W:S'ۋw$[E7Y$ `YO^|K͚l  5 PP+WYG[㝵~*-%*GU~@IK9?1Ձ] ,u\K&-%[Eտo#OR%f8[ ""Ҙ>ǽ Egfui.W;؊93_cO8ʓ twVl>JPg8KjcI:MjbtTP$lط_qKZJ+idjw{љќg<W.^ ͙u5Uݘ8n FT@[̳R^\1tM$>)iEUU4Ӝ/UӞ1}Wm98^=||| , 9+bZ_`udn]>z]?q+o (٬PV"~{@s^9CY#8]k-|$i,%K\Z@څϽ~?kץ)\%piNʉ5T]ڻ?F%e )|N@ U]k^;E$4$i/25SZ%р,!`+ Qʊ)7!M*:)vvcg}|MtOHϜX6ȜlqqVl^CUeSvݸ[M]j{EY[. vȇ/4|_K<' n/H.sׯ:q~F? :X+V6M:ɍH$l ȎJb8*qkAjDG5J0hK[Ju1CNsC/_.߇.2uc.k: (%bӎXuUgťi?[dd្C>){~4qCa-Zjnl`+ }q͘&Y5;'fzp-I!]I:RſtDӓ%.W.]mi-DOu,gp%`WYtҸw-AHzge?T7aH`wx˗O_zmdCL|JbWӬPqWU8McΫY'?o}_n_֊s[r7cdrߣ2!x\t?g6uFsb+>I㒸9/qhLU@T_wx_*+Zt3R+<Ż $%FԱӧ^ZD_Uz.WgU A~/2 YRո%w?wn_{SndrQ9u$xIƢm{sy´:+@LSJҸ%ژh\r0+`W qI:K-V du< sb6O"$03^+R?3oc6kcqi;l*9mv3+4Tه> 7LT&=*=c[hkK<@Hsb]0R@*/ $4tGL1*ʪÞ)k:>wD$023~m??U$I8cDGh-ݒl~?n]ܺ ySg1nt L _ڭ9+Tۡ:>ޖp]dr1y G IDATg)*Ukzqj-ݖ-2D qږfD]xG+ڋ\HHʓ-o-jb!H;^rd_+U~TG:Xq¿4nvUg2aͥGYנL4˭V<~ADF)hߚK wE·}W帵( "g}}[tIV1#kMwEe&ƍ0kry slN N#|LL~Ysm6'ߢ]U<ԕHkci.|$HT#Q}2_%l*Et-?4p XBSI8[M~ ߼YۋҸw}*^+O>3Oς~#\iRk0ɝ-ŏ{kܿ&~竲gc` P3x LP۞jXw[@8`%`G"I4GIH@?Օ Xm?'[KoT<]Zy1O N_4g1Xa W#V%4뢲#d~2׸o+%r|g[ӧdŜ(qkA7drѐTTV>m![G+W<.>, `C_5>.X$0$N?v&Բ&Jk*E6ޮ#_/V֒X8/L?ҮO7Vk>>o&t<`uHn~]o"}dnA콅-0`O#[\>+ {Nւ7sV&:&{sa` K-n|Ow~v;T+Z@&o_SJDEȿ2W6OL=.bED9q4+~u.6y_'[Wi ?Pr'F(z  IJZ`%8'(68Yy6Λfc^Ҥӳ˹GC?ȅ.0h.ޔEe剀տGN\''P^P SQڈRZ:!HyOKw&5?sզ<W0H`xSY`Uki5KcIҎhSh]QFP pl?\ E~0R uFT%$OAIHycOW1@{_ 鲣ry%6d@1g흈2bh] t9`-,-ZӥQ>Goɝ`"`U_#'>jnx;\'-g<1qsPjD/h#Jb~P4&&v$M:bD=2-ےMqi9ϋ @C{g(d|-`wG@.SI: QڈlNKCdU'ے ? mr[\ɍ nR8.GO}FN Bi~3[o}c6.{zL6(]e|]?Dv8W tLLMcI[I[ւ$$Ub{_m34fpm@C,fD2o֥d$R". $%"?,PgLe@sXuU i_JH)Qv[r[;YSsdq.{: @kxn>u|#RߛWDiWGap$ڤl'BW@v&۾1/I{qOjl@Ûpkdt,ҧ#@a(✘ڸxB0_herH4Kܺ??A\_y_GO}Fzhy?6~`b#E˿D( 3 a7Ws.ЦtLl-bmI{|b$Ikѯ(WV]BX$0l|?uifo@y`ZlH$D 1b`I)H͵7_7Ӻ_TC߽9Wb6zI6_} 7 7_ȍw"tS'Q faV6(PGuTLTgS}_i;8]Q8"P&~V@T#I˭iZ߹\Z;}:o[>[?8N@'Kj7}">N4TԱ9TNsO_= ]4opC @"@/dI9zٷD3o}~KUjkda#NDT0+ id؞tVyGƣ iw˼3yK7_N@iHY>mpI>,pnXߜW9:WN͹H uMx}yMDDzA}g 8$a=?0(?ﯴ-=/$t$. C qA vCҤm&_ $0i|z"&'$np~v"⬴ӸV+[>l1iӸ%6Slߺܾ no5?+:)NqW hP2ԅ6uO( }PC4jq6nKY&}G!_F~7e"Rۧ# @M;nEz^YpNҦ+Z#N]ߐv㞤fu_א?DŽ]x]n]{S Tɍ|MndIy%0ی/[뿷Š?S}ӡ_mI_P"ʈ1'LMNcXdo!i[$qKbXMx a}A й|(`~> tJ|CXjs&}as@BG@ p9`ժ4O` WG"޼\Pbޓ~'`[mYSMv{zVmdyh`$ڥyWN%:)6]Oi~&mI6w$0+E C0_s4i~Km|X! InMיYU] 4n" R)ċD;#fF }X]ۧ5_E#1ۡDQiPȑ( }-g=#2"ou>C"2"#<9߇?P7X7<Ґj|u>.Hl7/~ _S<MiP6O-CXMY 2jX/;"`F ;d4|1 &sWY}N%.HDxi $%` }S_jl%Ǹޟq~{X=;U7Ըv*4RN>b4Oo:kh HT)L@V&h mt: wu8 `1 vrGb?BT0&#ԋ:h,$>vc:›m"6'BA{1nVݧb4qb,hpMN\+2Fd}Q!Tc -wOu]RBR 4I-Pq&Mu]'="BAu,2`0`5@v3˝ *hK;{݀h,B cHmGho?.&_}./5?1[xtǜ{xDMl<9|_s_bnh6Zk=d,wV b0:Rvd#ɾ 0vV8M#> ELRW20BHdV:uI[<]f9gտGH;y?UU)a;L(Loc'p/%>,S-HP T-wϕV𥊝h`2Jati@҆Nyua@c/h#P~R.=nY"`$TwЙp`aLG0._ b/+'>s?Qnã{? 5d.fQxHͅ\>~ӻErn&jAN5V`}tvZw thU֏`1 @vx$0btZdQ9]x QBig!h JS"zWi{;hw 'dS agsg^ÞSJt [Ǡ⥙ !! N4P&w+hNz=贓;0 yÓ;w_:`c:"[ Z[<<ѝ]u%t \@I:by[ʿ'O8$bz1ݭ{| ]X:}uxm_/~++`u!j?S# s,De,c pwUºRMqyZ5JoCTmkQB\/ uyg.>;h4hWu-:w3}tQ_Y_1WNC)NT1C. ̢ Zgvի͕W6- o\={ W3ߞ C dsBʐD.dɾ[O' 1,n_QH헽 Zk7srFCU0][GÍm8tu4Gw3Ɩ8V/<0lI5ŭj?J"@P4*v:)n Thʯޛ:mݟ^~sϹ+`0W` Mc pD@ *V6[+XZ"u5 l7"*WUM<>2n!azIw~]fL]jﯿ t$zmi{e+KojWu)h`at Rݴ6q&싿v7d7?y'N <8\ =Aႊbp4!@;R6 #*XP߼sl;UkC H{ix.<0#m;ei7 =k; Jw.6饧2^?uIgHE`6&B!nX !UkޟaE!ݚ)D 5p׮^~\;Gx(;tx1dC `l5=wB&@| a@Rl {M%M<=Xycp^ {xcJd+zg.vfl#; V6,F8r]) tf%h;AW~K_{z6vO] #KCooQX2vs"'ªz_P'|g}]vL_XGw?EA0*!'0|X9y)HԃĿDlzF*);2 7R@vdv#t4{::;a_꘭RO]U&grTkD`{2HwAhf"ߜzS -xkU{=0uB=:);UWY+Q/~5t N`tatچXv`02qط}?.-BR,vX9uDrB0ZVxn`cgul_L 38líD'`pjg.>ʱO%  !KV^~~$0iR @A@@$GluTLBTW00UlotnۗXxK u\33!moOǙ驄Tv\/j1D, ]׆TֱCN &# lz)Q=3AxLjP7 )te0`0J2+˞g4+vJ5X:u$7߷BR7>;OmOm3rJFCj'Tt@r՟~OA2v/(>C 3/|jVU9}V"jXu ,Eʿ  ))Km\XJňˈ[Hp0AalK1)t4K䅔ϾO ߣ+s=RԬ]mDz'v(ls@t *SU]<}|[wh\OQSM'ﻃ_/e԰O'G3W}O4,' :@'l?[|`w09Vk%q ,|R5/!nvW&3[tYBN'u`t*@gk:tݿ]U;{@ ?>'%B xIYYDgk<BHDeG>d,rqtd׏ -dRԷBFD c\'`2\! d< 'X*[,gO`!( FP5 #;`x z M}C ]B0dUO5~Fd?,j BXrDWE&ƅC*ov.w;\?Ryݼ?ҿ#B|֟s# ^ &L ORňZ+NTɶ lW:&j@- h!n!mo ПPm2+Cwu ND 18 0{ z7[q~O Nґ܏\/<`18c.ʠw`0` x фy*S{4VX:^*e Ai"o!hbHD (݄;bK$[o"^͂Ҭ?#4L~5_ K]LUU:b:#v#I:#  (ezUI.`2BVV'B`[p<%0Q *mC-KkH;Hݞa/ }2iFw AN;t&gN_%1buV0qIOlj{ @!3219:'LuXo\ñ/_fQ#qFtO![י5jv&˒>I}>:@5`0`Jdpء3Q@t/n}"T@jL0Q6!Tvmm$0&D&E+#EHd ?&zmЀ E'Blo/~؉z\xk/%{S_jfm<XP7:Nf;yg1g0`0F ׈ִL? |U#WTտ?-xT P HDB&mco!tn- .Op"xl`'02~{X=;pkX=|}JE!- _y<`yul΄6}+5U?c`0`Q3 dƒ[+sG"-MlB @0r G~r N_cE ɟ8ټw~TJs1Ϟ4605B`d$@7nopװz|-$K<0ɿj:ؼ=`]g0`09jNԈd!%UJU?C8.n" T`R%B5Zhž#dJńvt@ x~[ǖЋm@ZQc@;T}Ò񭿮~ Y~!02!XqI羙a7-"3+;?NAD*nܻ1P|~/g^U1_ZRf׵JKC8v @F^LDEFW"3c/]iKƣw mcK,ldqn8J کn75"Nj?זKY}CkmL &1,ꏫdt6@^P O([.h:B0mԥ_g~ctƫB쉀'gյqmma2 %0E28}Jn%\xX;D-I5rMW{؟NaLJzaKÏxqP>t;&%Yq`BdڄSx:l?pDû?D{ mdz.c:._&WN=Pqb ʿvֿos*qiBɺ   0} Q#2*TV2A#Nvcd wT ۼ9k὿훠WMj^'.8(!_r+)wfZ9` 2.CVÆB?:y1Yd0`0Ɇ7n!"We?*YqX*jB ۺcl?9$nN?n ,屁4Lҁi6yO?pN1.:yͰoB@H1{.'/cΈ1|UUfW;"kQ#"nGxB8?Ӻ  ƁC"rm !KUU\qBhZ@F ݀J[q %;}ۏobw.{O[ǜOK {-¤I>Kxb<+ Jń4 /} YMg?==rD< @ @^4 &q[_w*DJ\_4"B(K]$VO_GC#B@KPO1:B%k!_D.! Fݖ"V. ڵsy?v{4G3[d0`0l&׶Tr!* ANtN=8~X7nإwYM(; vVЄ;KW^BZMXb6&b+ n` & &!Tbilw*{{2' O,M)` 0QqNw#<6v71ͱWeɇcD >E&o @Ephk+WpYd7"wS%"/Ny8oϹ[6tFo7c0\T?@us՟Q'BA H)# MFu&L܁N۸U{xpyv[s|^d.r2@nCJ Gtc wٓ-%?6O!מ^(AAh1O7c0`0ƕ7P ! 3Fg| G!3A.ctFPFMϽ 褍7Е^om~վfN\&@ĞՌ 8J Z;D"0jK]I%Օ勃Ld  )܍W}@V!> C. *sEHaLb&@m`ӏuoB6]W:xx (/>H:CSϠf]s|I;e"0zjI弿 г xf 319KUY!`XU"`TƎNat&j@E-贍v%l=1#as] t9oAc@tk LB gN~Us>%o&OixMk?K;?c'}qgr1F BFA*=GG“A}6[)" LڪxFQJ'i'^N0eZ X.@:!C|jпhLM` '-x@F"˓;$DUe7rd;o`0`ɯBFPQR5!#'(&s՟QPola@H`TSZ괅/_~Gw9"G@yP`fXUAAh X w_`E!5KUu C" UעoI`0`g'7W!j26kFqatM.8 I2S©PQ:j¤-<7p᝿=rI!YG0?FN O+(F0VBau NbQ埙$F1tg%#u!PW`; {]V &1ﮩi}3d-ݍYA,-Cx)݄;7pͿ $d;4N(s ` l-V\ m~ '?Gt<As? ZM2(n8!r {l`0`*n"n![QIHHW70ڶam#Lx A2 BՀ(IϽ_Aml=8 KJ_4.Y Pj^~]n!шOKXjcF9HGqN׼? P`H?P7@]@aw5>3 &1$&%anC0ZG Ƥu׵3Ӯ s AL4mn@OoZ⇟&NU8l& ʂyOFv5D$ ;A48wWXq$ȀxW#o_kbA>jmnJe$Nl-> &d@`ilX@j7& ì% rBPy $ 8["` lo£?*.(~ߦ S/H)U#`Z"@nWݸ)+ }:z32>  Ƹb~mF>@ icǯ DV:4x瀨h!huDAGp/,w[2EB`D9+ AN-=Jfɱm*i_Uvz2@ @\UE* clhCHSe  "@k@j c";o k^1 {ćŽx A FLԁt:n㹗 _[?BY/`ꈾ~Vcw!JsDV109IhNl(6=NuI_'AL=8qe5d @`Xp18җrEJf) =+{)l/-Svc:{ϠΜNJ"s5tN~XN\ƙO*@ 3}( ,$AnTU%'mm[hVQ˹,T| v_͒CQ K(=*JVT|+?ʊDocWԚrO~ֺ{?'##}t?_StAD@,j  =2@3]y  Ƭq^IF;/DT AD.8"@*AZ;"?lTJ,cĢ ?7uK|4:eէMm N``[RO4`Z"h穫Q MD2^+M}9 s^AFn.݁\7ȇ\DES{ԫ_hu NZvyϡME rĥb8ağЗ #' KAq5H;"3l??䋃Xpc2@`|G B#@ݧh-׀%\L\5.JX)#C*;-u# iϽ 褍p䗣LOն/ԩ )d` ihc D'`^pm˿?sߕIF 官OO /#6LKv9"h`0`0pj |k$t>D$2A%JhOhiWvYZ2Se]@O?[?| GYi>?\I-([1O)W-~+/x6:c('ʆqDqK"& &Gڹ XF GFT"2rDf&EY& ݀Q *Dک||㯰qNA{`L ˕u1z@R5pPcYH{ ovN`Lp)`oO_OX=AI H>dG7y c72*8G̈nӛ@I,P{2 *^#@LHMԐ:v (݂N8yX; t%|}>#SK?1x` ]Dxju#hUgյbii?U?j^ϐE@92 P޾rH P.o`0`9 (N 1* 0: F*' J<Zj p-RY7>_?K'8| uIƸ» _5$-x,Z% ݱ#U%P2 ]Oj@(@D`, x138җyJ6)@.CyG[?À( PyK)D& &Zl+dT"r^3 WO] Yрdܘ>.%yQd_Ү& g|Ÿ\gP~~.K/gj&a(F ,?'"'G szOiRC֯ik:m#acgXp13xxk}W)ƉuuO `ʮR  `,4R f 0s A:0Qq>p:Aim1dbT eU6:W?8q8}/,܈@$Yf2̊s?7i oG?j̿P5-臮M{YfL>1B`/牀J"kpBM߬e A݀Ȏ}޷DS&FZ[| :,׏ tu,(.^ ,/_di3_Wqӎ$`f,"wT~s޿ gje3~1rIm}O( cwA%'0A? fD)hO(;,BsYo!&TqZ"yt3x``/1@@m<'_ʊM ]7%K]Ph:m3ż,XfS1j^wʉ?me ܅݃ :KUg"06=`PZΊ:bj/oJD"ȑk@HHc)Xo0#ZvR;pgqx}l?u'b'# TT"+߫h๋_ʿ'<u1୹ : 2y leT^9pcyz "@ExszU T&-V/}w՟FM$*aއ8r2`dߤgfCП %"h% d,"rU)]2j (݂۸\o^rA8?` ץ3W٠DHKA 1(DzN\.f=)D\pЖ6Љ I `V{c0lȘ<÷>O7ʎtGhh*t uTNP@zUj x| ڻlбsr@g!(z _|zkQV/@ѝWv}[_Mr=Q%;ly~Bֶd#!7K62r_~!U5 rj\ _V/KUҺ:=_F9;{YV[۔AQ|?yz-w0f ]J7CE)?O4P 90c]e.RUGv4 1qbaGϽ l>؞;Yl;J0,kx@zt9ؚ@tlf `YOk4Hw=oIo$.]_)B'@y%P`T dM!I(QkX@5@[ѰC$X菉d% A(m3 cÿ-> bH@KYЛXD x!bIufwJ5tiFiyOgBw'TMTƨU-(}~O< c2.UyS gP{T@'C'!c;@2 rmM(݁۸k?.X PاJ'|@ob:M&JLouBvn&埌AUB}#{^H":O8%"#H'{  Bf>vC&ɾP9kh}`$c[ A:5av>)J@5Tƕ7pp]&F_`0C #%" !7]#ƒ_k&n7-"L2GX0i26a_'A\D9>w$+Z2' P~^brX`, 1s7 լ{@@f#j AJ6{c151%^NRzVq/'if{:$al/Eգ蒷; }ױrӪфv@QkdiXM Pq3#Z#]5bI+L 0GpğF눀8@ݺU u3Nm->w0f0cc>"p (H-X1V\}WMlKKP 0 A4s ut]贍?c m^\O-P C  8+ IDATb"[B)_ѠL\Ҁe"4(`8`_EЩM{vBK,JcXBXysʿ=?c+Hpqkxz:nzQ''#"#0`,ZM0lC/JIJQ=i/ꔿa~)* @ |#n&  DN,_I`" p0N,PjP#@\0Dh,AD$!i*qg.Y"`Ͼ#ALf+!-BR&oZD:}{9C;P, MR;W$'ɿ5+叔@%Z}ޑ_40|n2L0ME H vI9a)ۓV dvF7 Uu N\ t OHU lR&Dik&U< x5?ix?Y俔_.ԕOc@]D@u_&x @vd0`0&]#gD@UW@ aE) ,D@J@6H <cEa% %0*qHmq;י8"C:98Q1~Dsk~QK;>YvۑA>_7*0z_D64Q>j`0`0&7޾Fe65྆D<g{H:mȨzoa aZ3k7!m70Jatl}ՀQZ~wqܾ]`F^d HS:׮IT\z`eBXMGR'߼ }ҟyIXvBz/UA@P3~]#/  b.|)j,C-AHqdа/U= vֆ0YL,o$dԖBN켴i56LچNxz:wR,zSb΁lEYR{Pލ|:f_|͂`hBstIk!v _L_߶ʔszmjvM(VjVrJb'΄j-~ y%sMXmE:{yNco=WrA7ЀH{6d1.R+t0HտoB0s hT. 2e&p].+Xp8ܯ ICPb$@_d-CQ9!E{Tceel?0Z ` `Yuwp REJ鄿 }UŎʻG7шSOѱL@X N^ ;G9`rD`Et{B|_Gosw@elߤPe?L_0*VPРG?YGd@/!0G0 &dTu#gdDv35:n pU\OG9f@D@ AZy_ƃwq ,7nZ8kO;Ȓa75"s*u}Ta.7y !WL>z_~Ǣ+y(Mjw͓0dX4`Riב1,FkWqu'`pfqhKd,0? Po!-N_诰k[|U1`b*ߌgF1b  ! \H$X@Zp(Z bE1Wr9&FiH'DV'.tqce.aǎ?W>l7Ø WIIv*{4}T=(Jٺ?6_@  ƔF7Gd@BBvIUWD@gDIa}!@̘iSD Tm)V (9s8q5lܿ;?slMKWoC `ޟ\}?u+l߭YTLw_ȣKد{8@ >0$/ySh &3nx꩗oN[63-WN}b>5fu i&テ~dݭk|0L0SHQd`<@vBJ>D<H. E5,JPD@Աu pqkIwwO|Ҕr2^}'s7'Gt##m&TM쯻Bn3f\O`Ǒe"Hu;`t?z{ c @dA䉀9Hd6ldHHd0)Hh4وx /wTQFр`J6;o6~ot[ ?ﯻ٤j:ʹR_z#MDɁq/C5Wftn'Zk`8<|.]{=O@Y,wU!@fYyOMZjZjrGx N/ӆ':4yat~FZf[?&usI)#Uā}Gw " ^ (k `͌VI &1t2hi,>p\D1l#\}<1|B@ ox{D jB@=ygf#Ia*%lE|^f\"gm–"PӴ41=xr?5/0  *-*Yn4DV9?!\ VP|/@Ulm@'l4" *%Ra1EH:݀򛿂^}~?ýO?׸ڷ%Ox]Q:6"lSWoZ쯕BcN2<UZOq~O~xJB|υn} U"9!@@#9fӀ_qST%|>k~q. K{@ @D _` S8353JyUTIE}Qʌ.5>B0E@ h3 w~?5v[?HglarG?OTRJ|X/Ǟ*p^*k`ZŭG+ՎRb~2@W}hAA  y;@ƾ@p6!Epq'Kl @*3HPP%k*4 t^S -b uJa>لIx{ o'aٗ+=׿#)A~kH0!Oǰv\w ~pIfE. ̍gɺ]/9"rueO8.] @ X2ȭ:d*fMB !@Y kRJ% mq!hhEZB%}X 7?KG'gKv[oD :N~4/OGGfӔnfM6W,]+ 0n<贋i\KpD.- +&67LW2tI Jl6=7 #B'xB;x{SCğ*윓4xz.#t2f] !oT lL?:;ǟu08|0*@`?ؠXń+ dB!`y%s_|5ZZA[^x ^< ߶JD &gFc3MǮ?-1fM68vHVKWԾ% '͖d@` r%eX[!--p\(-VYzDk,B&`e9>нQ{|?mӴp??3seU}afHߑcD @ X9̢!z ʗ.;?B Z)+P2 , oAX00_q9B0 do|^""/|/>tϷԨ{Iɿ;Fٟq\b!f+I0Xω\郿aM>uBеZFPi*ŵ[߂5#G|tRgg>6SЅ{1/t_X<׮ $"@eWw!E 4Um6nfҿg؁~"+Arq:wO Pڴ#VU )?O@wq W+"25@iGC>L:ě x;ظpKZ y?a v?UHi϶04cٟFψ_Ͽ/wj+c0dC_BSfYN Ihս_!KwK^]%Wp|y9,,f?yB3^ǟ';Q; E6 # C ^A^`azf@plMФZ|E A]H@i4çHcX3RR~+ ƛūпxհF kXk܌oFv'u?ُN8fhnhA w~>L3l: R9rO JEM`vϳMu))0Hɿ`*F!as@P`/}]t3:5]ϗ̌oyѿp h/XXt63J~kǍ3wff 3俥55[3?C ͙7'R=3 B!րar_{vJ)0Qa+G\йWYT?+.b.r6<| &¦#1i]K`k!6.]՛2 Ͱyٷ`}1;Ùx&s/$4_l7?D?WW^(;{Cw  y$pz|Ofa5) E#5yU{bs`ʙQ{H L-|/`vA>ؓZ3x2/ce\~/J+րd߈*0 _:.EqaQ;9_r}}s0 w IDATc\K=uN-D^Ews+Dp! 3 l(' u@B "-%xv+ni3jŲQ3v+@OqM\~ Z5& P)M|>oaփt̿srgF}E":4.Rĵ4?GY`b(+@9_ml$G ,ri?,B҉ #%s{ѻpoۀJPR'. E j-u) q.5ֵO!`5fv M m(/Hs#gv!Φ_2)-v-g?vfX>>%_w|,L ^K{#d gR Xm|pK`!UTl(P*Dy4Y f`LNHFot,t0<|V&vmz=NN K1k ({c Jk@g8EE\z: ' Lr*E_:al5 m!D_#޵ph6H`rF+6g=*"9y.A\ 3 l@ &0,MakظxX'TAw=pk vߤA~"q|VXHuP\ i mnKoM'@yA t^"EC?[1YO/fƁ8sfUUT4#ǥYYvǺV[@`X )*2PV;nBoâᖵ>JM*]qOd?;G,mL"׽YfPf ֶ P`/>tBkH66a5Ԯ"S/~IX2gۈ_&EiL~ڥ҅eU"/G\8`78x_xf⿰{ 9\!k%8"dA_)b(zKWUOZ<& Hչ&-wq{D3}|xbBӏ{kJĕBpD Wի5eXauH∿u84*仺zG"K<[?夿lW{_"DKY6ۖL @ X6K+]1DN kB$=@)'("O6qV`Lfpy֟b%&z^jf_Hwk ċ(yr իؼr^٘w1!8UoSi9AVFNL#mm䟹C ! *&bGHie$ }vx׷)vGP;!:MiE0==$%w< !+_` y1@yb$B"-{zv0럗iNlam ȰbPU\`^PٸǺ13"Tip"_9h_((aGy?z__3o$|BK"T|&ʜ ;5r=DV;o-T!jV *aRRB*@Ee{! e!CgDxђnI2dBQbeʛfBcp2t+ѰVU,ٟ5FV#kmMf5FQV/\kU\S vTs_p"+EOpt`nB`RB*G=WʽD)?*U!@ip?J/`e).N &yK@Z RH6zظ| Iր 25' \LKYx_Vo+C&isM "A;ǟ˜87>/d:徟1N @ X5&U4W MPMBֹqkNV?<`'\?B * ؋&q"}k[i :Vq.~O{rQ^E;L2 Łz,`(dB1=/:#tE+ǟ@ @tJL &EYZW&tW xtx4lS["%p,vO'*a03$[To M5HQtwIKHz<9@0&c^ ?MJxXYfUtz+s^}1?(hh;.iA@`?  XҘdGzRo=B)`x]Q@>S])ܼDeOE37d2wK~6̽ pQT*YRHGcq a&7a3˴QoȒ) ]r$?S_&p3ɫNG+Ѝ.N:\q/~㣧ž,@}P  / ؛[Td!"(.Rl)5 B"8?'~< bVgOZNR|Okbx $A  F_@Fc]rkI`u ʪaUr@{?{4BT'f?J"f1?_?L)43l:C$3@peV{>bIi\>M"p# 1G(݃ҽPeX@GA)"<ܨW RŎ J!}3>.;ۂÑ0}Kǰf WnA?7fEO*X ,|MQD3R"z:n+rD[U_'77џ{(MG9󰘒Oc2HE@`GO`!X\To(XT‚re)ft 0c|3|@p!q7/ VoնJ{@(hGS|VA",=T=  5 5>wq{6K[#;ЩPGfm?WPElc Ɇ 3!(c3oȶs^`W}P9AcSu*Q{MXm?8UDaxlYev( $P'H LXPfa~1D#2?/1;<138)C'Xkt59 1`SxhH* WqrTE4KbLٴ qp: @俛TNMxt?`x<&L;}6E5H<I<.|s0/q zE@gMWR-9 HCeR 0 #  #hnFh>a\ĴI1!\:…d Hɒ_!_1+ Ųy6hR@:J\b8Ú\; Yz=i@Qdߟ(^c؆v.[D~?>Vq~(oDc@Wh$皝qc %D(PK T^CZ@0-%Wr}lݝ˯ُ"@*YM>Tlh)ٚM 69`w?:omo3IApD L X%35}kJ`u.xCt0#d`u0Xkr&B#+WŤkqW D}P"ٟb8ó' JWjن nlq&ks u>Sk@ @ȫq竢mFg.BP0-o=p7wP)I1s ٻeC "T;:k.-Cg)xSWq$%kD?Zzw俩x+G Aג <1Is?|\UNv!@p- 2_.{ /a<vDžI a */`U3O#9 ( Osh\K+0$TmLPڼ<< ? JãHG~ݷ߬w-(x(ſ[cA]N P0cEǨJk@ZPQ( 6X߭?R0o?_B'HGGflUeD7E3bF5 `*T,:eR{N kV cJEv03&Oh54FjxEƀ;_Q6,6jGR`j`R@s?ٵ+1@\Bb+{?IeV*pr| {)p<.j%n$`@y|;T~|vG{|4'jgR10ϭ <*C y|]:G0X~JlbjZ50X.?԰̤̰ ~N"rTp"#f> 'f_usØho.oրDbXy}әaNǛ~T>iF!u@@+[N ~E4"=#7),Y~>`'D9M X o(0 5@CV@Ad?o#ʐ {AJÃQ[9qZVRJ6qiJCqV+l T0 ,B0bԗND!VZ:Q;GKc-FzIW@H5:o1}wPSd7u#W2_ Pj 0wO"ߘ%-+ XÂ]sfHj@"]T?>>hoƮ4ܜW"8;/Znz߰bzɥnfQ i@8^_&XC#\ piZviϦ`y^?]M'L,(*&8w6ci,?8dcj)5 *d?/]ۂaeߕ+@ @ A!>*jJ BVi#4k3uoKe@@,ϐK){Dsr::ihv8B,Hk=ƿr1:PyE1 ȗ~T[_6YJ};#eH庙M`}S_r{(-(ZZ\H֌1/)+Dև>DaA6޺;!>0H>>M7[j-,u'P_B@=yiM̡}kXCRB''ǀ/86OHNPߍyk]GYam D0T+yHUB8@_.K޳f%aN]bU5qJ˽EU\` ^IJ֛FRzf:kƮy"+Mp~㻄UB@[|`P,R2'պlfL:p7g7k{ދlfc,O PEJG; ?.*f&O#NAf˿[`WCN60Cns4ߙ-@$(OڽЪ &~/\%Dfѓ;_-ri3!ՙK 1많B@C{@MY`&1jgEW!9(t쀨q#! ZǚK0Tfh5Dh-W"h b6۟m)_ "Bu,pG5):X2wRDStqwb$<:d7t`L|J v.֪ݘ\.|"V/N@Ҋt#ԗqcIa\Ϟ0 Wo{y{R Zʇpfh`fJ%0:^ǐJ'HGii>dnn7Yhym8>W=^_v j4GXA"ѫ>ڏ^0T`Vx!zzo[J9q IDATR|ya1`KIj2}R1 KυYujN ,?hЎ36=EC,>Ѳ8ҊcB5 }WP'CǕNZX3I`f7/c<H}O߲  ]#(R 7lc#_A  $Ya/  djB@X J[3JVOP*LKGRmvmJa+e4^ ?"o|o VF:t&i%&äòе߿.jL8Qj}Y&j,f'wn"*I?\@=`@j GQx@ @ X0 fB+:#U!X h97 K}_󄧸Lxi> S%]ۊ*H%57&с#vLMrdWGiů仉w5 ?SaP4f%~y.B`[6*Oұ3'D;ʴV:2`*WXU ݘjBĒ3F::kF֌)"nyF3HOAk97qF27=Uߝs2o+_~o1X|L,[ X'PIl#qES "+ymkE,မ;!>0*RktRل5#ʤ?ht "==i}]4Vv#kO0{(Fǩ?&`B\.gqol /lsKwr-;%&79e̡k # to 8w)D.'v;%B@X`|Jj@n}Tk5Sy_ߺ^tcҺ!m_P%EtN ysW`ka0ckvUM$O?;,3)o_MyHwo5O6LƳmם+,F qX ^Bz|3u?f~7Ugs_ӓnuʝoA @PP_;;Ow-B@ @>7"CeA&B/0@luW!#ѱsf)"LVÊ D #l 3¤zɿI3G] :=FAğ]% RBNQy<#+CXv7儤#|uK§X.3<) :ᮂSƙ&g@Nr%[*bN/>*cF6OO$!T^WŃ9 8R N)(&q3"@ @ XM*݄ES`ZpSr!x0"P h]Npu_vmjQuT!@.8cH9@yqԜ0I(\4XE :S[A4q"ѩ2:]`h WU-3enҡ?Nf2' B1_cEރj{.#-4̳M8Oī`7u__eF/+ "b. T4v<GD* o%I)',>aZZ{ÿc7%M fOlf^A6ѿx ʓ:jn%1e%d!lZS2!UX9n.b&f0C7AB; 4[n_16S_~ 2ߏ7A{e@* K^|]~i E@F1 9s&[ u%>0 6Ma!ކ7`lG6h4mn'BZвh'DK'1mĿw^ Z. ( Kv _<9+i^zۿfמ&Z`'z~<^B.N1xǭ-ikA>yfŖZEZm(GO2z-DU?M @].F1WSyQ5a`Oxmqf=F8w#8>,k"E;L#Y<"@.9 l@`&nr+ZJDȄ^2z˲QFX-)Ƶ#pȿ7[T$k=L@I$#T#OOV_[ CEFhhwٽͳz?<_~<[oc7'VUU>OfzOb*{ze͇ShcYt`uq+s`EV X7Us? {_bK\^}|-(>MMSάm4Kݢ!;_J@tzQA9?7/?cƶu>7:Iqă6p>*h_칦cvf]^sRq_Y?MXAgHXR{h5 ;o_}[{Ov\|io>Dv'S ޯj:1_ݾʅ ?Z f32nǔ8~znGӿ^c6_O 䟂KO//"DLe\4˹J a`tnҭ';/l[w"  _)r%JCG}<6Ȍ~% jԇK?3Zg8?[_'6ʟ{8@[T $[o1ؿ{a@pJP w#,Bgl `%PʲIaNi)ԁϺwF-8?DuKȿ % &4GWtoooKӿrȕA X $@f \z-6JՂ ;@&cSg(Ts&53>G)Y^E5#\r J@*Q\yq'Eh @`V=*Β0uR)܌a"mm?֜+fI~ىf96߽߭dL8K_7Oӓ1Y@@Zcͭ7k7K3lȵu?&Hl *B(4:/|Cq_?LgA|A`V D5V06PGխ9}3}'@ @ED  X^7]n,9" w'غ3*χߑcjszvN d՝i;F ԕ_fP(Iz}/^s> \֍o~|'@ 8!@VxͭK"r2iX$5 3*Ӷ&1w!2N6] @ kW\ONZ^,OZʥӵD 6P": -x @|]*hƥ6cdZG G!$7i[ 22 wg0L^vh?ch1D "E Ծ K켣17.B͗^ݺ{Y=@ V6`-͓pӁq. lHT!:Z{Du?!ZPgkľzw*Ef@I NMOւvmʂ|{ m6;{_}=|'rDQ/%")EI[T3Ji߉*zEœb^l-G 4?쯅Ot).>-D͛)lW ւBںp㵝gwp{'B@ Lݝ["dVөhy{+^m+ƀGg>_@}6_OHFv)_!! XU` 21 [omm{_~'A#PV<!'YNxRd/~fD6}Vƈwˈ|܀Q]\9vw?*yEt"穥ߟ?yu'R*J뛏 A%=l@{@ۄ_0}1 D{_.MR B@pvzržN*OڇZJ;G#z@08wwN;xq&N]^3'4gt?B&5I 1/Ā&oɯ|x W2AZ7&ҼjB1˕iMEE8ugaōTAXo> KkRC}f9{G^Nmw 99f'3wW(boHg\|H|"&`Y;'py"m-g:3Γ$`_|p?n7 / & < DNgS#_e '31nu;ǻvv^OBZk|,Bp`6+#ٸ$igЩEfjsbqUKx{?Gj|N{񓛶JSyBcJ!ȿҽ!"P' h H\kou# xO|Z6`p_o8H^BZuN|3 [R;0l-L:5ccS5B*`/y* |H\,y:3X7vwq.-K#.sY>|E9IdtA޶ߖdkamc:rcwP#Miڎ0a8z?ozi?"f7Ec+O7_dᗮ%ʟUGc[yo;pܱ DV\z-v'pjR",Y` "x l;cWT!*@7 m~1@Nn*ccX31#-7ryd3Uj*apOT_#6* KsfOh~?_9Bq\Ss;,?W+[_}6}iG",@`@<&?ͩ6sL}]xJ)Ot 1(Ry~Nu5Ň>Ni7,= f<8>zq&o@( `@'r!?3; o誫 Hk1t'Wa@`n)".!@ 8h*)q3y5xsLף-(=9`ƃǃYUQ(:+ tӌOW"qV`|ri7ڼv{ Pw`21 \)#X dV3/an&&vF٥?\ "FZR{K|8>z|d y=(2#]O6H72E?a~1%@i9H!ٸ2>d 7YmB7q30Pp& f( R ݤi6u84y1sP2X߰"37sǖAd.(/ 0W?-CTyMA@fS5k?ZC689_BL'U(0Y vBu2)`Wm_H{@yw!yum{I  IDATvzI46s\xpPU / ?mI(zք4%]|f$'5,N?&OB@i'K\օ?{D'wwnI Ս3Oo>-9( '57 l6['x/z@bktխǷ("㿝@kI Ƃ\Z"Ą_Ecы+nwN*:/(Vp-/>Bp47?fc0} U !/W5@ EGs҂)9-ۗ`sK'/Y92Z8+8AIX]RIG#Hή%N`z2$G@(BO=|J7 d[2 t뭭 7^9}3}#>UM X{m{ow +dDNm{&F>tEۄo/~|E,r {w@?B'8O^`8ؿU7=Ε )7S^w\šl?G8< nO2ϓL<^Ўr?wߥ$|??9% [q]*p5f ٚG?*\`ޗJ{c06jBƹlCjj@ɕbtI*4-o#?5DJ -@m243__mRjх6_ze;mo\}y+=>R "-xͭK, ?!@&PxZ=£4t&=ޗ=cJ@b U@bU fgeR`F`6v%7_n\-uCYcHf) Yr@’㖖%)KUI P1#8?+G'p! *at*+^~yV:<!@p `o)/hAp[xY N{޳OƛC쇸p z+uX9ˤp?,fmT:xK ٣:,3lH 0ʕNԂ3 CSb&I9 _mD ") ' Ox뭭͗_ana`Q Z7.Aɫ6̳"V,Wu /ݥ3if܌S:>g8:xWZ*T?k`ƾ4| W #Z_7wOE#HG'֦TQZTyz# ǍY@E$Tu2ȗSې9\2Y*E Dڥ  /u`'@*Fp:B _[xԗWRs<@ok (|Ui }^ MG0l~^_/Jh>/~607m\M/r6;L< G`M'O qրt4@ҿ q\XD< FGp/[Wt xĝL';Nk( mXGgfx%v =ybT)A"k ʭ7KF) S:ecz-H9um)}TDCК, d}%g x !sץ B}7py|NqqX~m?}?%: |܏Wid&>.;bO73/IBZZٵX :"mFҭ.x}x`юfA~z'v^&ȶ̎i[}x8(.N*&T{)cX<`%!Jn E?7O&Rн%^Nk>Y O•w/\}X|"nkۅ D8}=oǃ' IT UA6xtxr/.]ys@HG@kưLM9y=a!B:>.P(ǽ!F(-i`CBb #BÉɿwSKy96PEv>/u3O X_$ 51H]F-GOpO*W (ofwJ]sA+@ v*.̆1g!n68|d+q7{ ٸj 4u'v=<\E+fO QUZ0.m[fyu1KJ;щ"}_)BRki8bmT"Tطy[=1o?!P6_M R+^~y޻5KrWbۙUn$H\83=ء%γ#dxa9=8uF YFlQGD\F&tWUyۙZ<8뒕Ν{}zc:y0XZqvliaqO _/}W'%u?4?sQwKƌʷ/;TyQƏ.ORN@Xt9 r p5O?G! <" UEz@޸okwY0bx;xqa1∀/>gnڗN|UfVO -\ǁˋك=.~sP_J?Qp[^@X/t0&wbxoqy}c =\={bmC' . `TEq%$ {%6}ĭC(,89}O.=R^,0))hV_b`L9@k_7_Λg/~KP ya_+o *ټN@ ;ɧxpv3+/2?>~GyIE~^ ] ]+GmGfˋOp\-<Ӗ$>}[1&Vp`rɿH6N@"Z%Q^F{/)P Y_{  $(RXz?O4Eo#,6t ۠-'b@cq[Xk8WC} jx{VevShR$hrMA@JĄ8BU L@/=zׯͯ᭟{b^  ;tbV O{r~=zOn$@AIKrE%O|/n@82/Ϧ$W#L9)2_/o&?5!u&8D?n~޸/ UP@ BD% WO~k\]vԞI !!^ Egwp=nA:$L"(b F l(_ڻN?x`nʁסؠ@`@ wڳ*I2@fܸq=#WW("%SeEڑҿ ą  ?$xv􀅁6|,Ա!;6^:oQ9)e;᤾{_~[5nj?PSI;9S:eD GaIVl07HW 9 5jL4 N̟+L/QBPҿa }:ߪ'tc7t4mb=X mv×ҚALlʆ (L<_ 8:'1j߉Opoo7+c{; Zv=O~܎O8@k wـWDW $ 0P:ͮ]H#X(65XDGo+NRw~>`I?>dg2=w⋏ cr {Wq?';isSQMߨ8ߪakJtКϋ~¿C.6$Dqi}+gPk`1ErÑ.J䛿O_\=2tpo5ܸh~WsHo7G(ˋ?qjぬZNB/_uܸJs)GnC\گ0ף??nM;RsAHaCQQ' S\024ȥ ;M#>&n')=@ ׿7K.'r흟PqWpWW~}d)#r G/ڽU&yMˈ@Ҁ hp`jÆX蝚FrQPbtvA l: 1uA?e=_S}-wi>Z,N!#<>CʯWw皺ͤ;%Gh>wWONb7^zJ9ei0fHr%b"d"B/PF$)9-w)bY">Cy:+]qrĀ䟠0S}CL%{?{_5|0DĴ=^,)# ;\^|v#Tǽv:REX<5@4 HE8U@!!P^+ 3䟨R4ɿ;` @;o )p/9'O8d8E]i>W_|ʹ` YC|L~jЇOCT4 EB' xQEAMѸ3N}0*_I; Pl6,`@h!7Os //|:QB|ч~HTtC~xv=ԋB5Hm5l>:0}zr\Mc2sC7no SV8FN>./q ǀ;n>8x>W#Ae`?DNbd\T Ժ5fZHdwɤhdD 1&K!+TF$E3H]mȿ cs/}/.˄ Cǀo}{HE`m66`܁+]^|>ۋQDO5.[]_$!N1ǜj{㸯s`˥[5}2wJ7>OQj@B6"v5>!"s`5G'|rc"qzBt[p3dR|vyba%)2D*힎(}8;%S*gAoCQ@mٝ߱ݗ Fo7TeF(NѤ"W_!?o?(\R,22"U$ 8 N  d(LT# L\\ɱA fH un=L.0}\^<쟴e=m÷?7^UĴO=?:'?G:= _4v#@~,ð,  i&n~mO DkcHkUsm<6~pه{m EٞP?~ l`RBZBpulGg@\p f% t^^|?a%Ѣy?_7pn78~Ymg;$ Y AD# " ZqP%OMH b&B@Q/ڹcÃo;LG\OHB[:Qb@[Vq4@6J v3Almx1[!G|qy`aH ;SFvLds.L[F,L}wLo/& #NVqd!7Oή?qyr~scR;$~ MwmD?Mw!1x0><㭢xB!Ͱ?NiM 7F Z2-A[5"cWtB23R>uaINx^~i NRBBٷT Os!6vAH3%Pt& _|oypD7Ϛ0͑c=0n,֮ڹҾ J:E(.L B?¶uC @ 1K ]P c;6^BCky4.ۿze2:B0)h!ל cKO ?bnw-6AO%`:r"sZl㛨#![ -G"a g 'EK?{scSs;_-$F* jch*;!]5&0\:%4'Un:?HAnF /\^~}5ER(vI ؑ/˹,B B0N(Ls9aF{or%B fx#"9  7_#`ˆYdVu5֭`kռB 8OB"?.7xb?ԟ !|]6,o/ZE3G= Q2bj XɈ,PB5A0 ٝ@r淩̲E„)̷ f.Q^,];^AC=b_ݖA ߦ)A MCr"CJ&1ƚ?u"c snڏ2 PB -ӨY#Abw47bs\-P Y3 4 KG20_ek bJCUFB P1 &$&tHPPE5'"";&}MO f}oQtAbV%'cSg$y-S PΔvK-QBЦ@b!(GMS!j=" X X* >M[:kӜ*,%,IJ-v('iȿs~j@Xؐmshw=piJK{UtޑiL뜸7VcbbR@BC8MJc Y2?DF"&IqP:!9`HS8Q -8t-KȿjL'IL&@e3A' rT&oDmzK+%MO %H Y AvbUGTȿPK aKM N!?#+ϡR|0DGl)9Χp0 DDRMvέ `lwmDfH$ ƃ|߇a<&z  MGj$ɿRhxz`rh"?A.=rD|8>XJOhoj!(qt@BPm`!Xیş vk\@ `w@|hf768\wPVbڕ6yzPh>2dcIxLCTHbɉjH"gDos`Q eUiH&'8 oL3(48&Psf2 4k^B@ k)Xb!cBT z!jIx9)ZA3~8BNSumH t,6Q1f\vqj)Xl!(LwXㄠmBP -1;RDm,(S)˪ "l_4"@z8fL0>Y&* w;[MR40ciAOݿU*AqBJzv8nG5Z`'atFVkCF$!`(@Pk!9Й`oqP _Hqd{_UGh*smhx^ocߑHiF@>@"A .h⢁s@&`U! sĻs! @ 1AĢ;Ӈi}uE}v,yKF}Cy FCDC0CM{Q`"x0 pB Q =s:H$5K @|svě򇭈k\? _x>D}cTcFÊ EcGgZw,^3,mb|ymbsyB<v;suv|A @ WA̛_e|Hs>Jc?;v㯠cM$NŹ7bdn1M81Ua(wkhbRI$RNs=$X)_B"! 0QjQ Dց $đ,)4=320A,i{K}!'OK=r/!#Ė}Q"#6}Rm`k!fc}uS`cv ,{10Əw#i&}KM3 kσ1`,4V&Es@,tVA,QvT, #,6 mYH#.B֟WcwO/POx  Ʈ5P,0GNsǟ+%-+^ sZR`^A,UH@U&ULZ+Zi/TEڴ)h@3_nfz+X/`#E$"`!91l$)8祱 e lb A߁)M@|p[1EE9"jN ZW66l`VkvD`Ftc* EܛT o '&ãMNnA,7DLBFӇkҮc nj'R$E?ɿOՑ1T-gW]cB݄m.6H|ι zbX b+fG,@lOj0_E`;W^pW\{gQ#1(}9 jC!n`uhsh:} /$j%-V}y.6rOEos W3oA 0n uq"ҟ<]%-̀kM,\:sB81`!cf!wqx_bvhG1B@Bg-&XΧfψ`#}o gWΞuÈC<EMQa=l) u8b *0hPO,bї|'= 7؟[@9?*`wkW5OQO/< n@  ɿzPPsqGJȳ.QB0%BXWo+ `ClX=BqIoXLh(ު j~L~wV[}79_93gxO v` v~PBb jĬkؤ;o F ],kfD|VA%b~oQ3)Z H7W>TJ~ߒ U^,Rж# ~9@]g ._/ic@h( _jA@ĴQB`B *AP fN[ 1w>|JYݒOijzQlz@'!8*dk3Q"q@b{o|o_B1Fd)]ՇՍ6A~o+k^(pƈ:}/-cXVX߸HTX"ПַŀPv[ZCb}(=@L$Hl:5 KEo.>@,j?6_$P A#NX^71-@1gj/e7 0Xi1"󽵺)促e~u!Վ-ĭ~%6 PM]nn Vk ^ %aQ `l=m٥=b)$zkЊ*cz0 2#))ҁX4XJ; $ 0QD@,KS0=`Ym+d?-j5CX'tĝoE3/A8B^׸t |Q 'SC2̹5kPTE+^D/mلk?3t U 1a@[a4H "](fULo@* v|M*AX>^D $bl®"!-I )]ѿ"0ުpT($$Z`7 :1E0|_5j" `w&XCou <D-DDt ;}k*uiaE8 f88 AOabؠSDb\s&gun4LkBo܄WjqSP I 0xH/QJ1#1~5U(FS"& G[Pӟ/T 8 2>n#Q`< biwumMJ[whrR'.m#ڑK}/iHX"j}Zì ƃm۫ .맰gH.*Db/~u Ό'?Tal/oo 8 !`/ %*{`%('n` 10A3$ho-" bL\q?- ڈ+5͔Ɨ̮~?ۆ&|jc!VBM(l.k@=` /sѱWUZ[=h:~LOoΈkؾSڴ{7 "-ºEօҜE.G!λ5},KK3acJ@`k It@@'x>gWVg=$W[Nc(O {ҹc} b|*z>'D}ֽi[֖gre)l"QLA&\WaؿY¯dw=_< q9SN"@ @qZ{sI]A*$c?5 QGMF ` vNSX#iu%- in\,S  O~((>"a_D3@@VhzOu_l'|VBuɿ"Q"L H {!q ]5]Jd4E0.wϟ9܌Ą  $"/䧣)xGX`մDvB@D-xFu}]_俢_ 'T "By0BN?l\o) PY1 Ngj>4_E/o$j_tcf׿/:a8;BB@fx?_%@P Nn}=_L! NyfW':%*Mc ![CH/cJЃN-/Y%NIT a|Tv9%` rbx_.:tBBB95 cD݇>p/?^DGm_pI7_T(Ԇr'.G'cs57BzӬN"--U;+QF Ћ,:f@8iK?\ [,pWsD[ZN1xƒtVX߸};C?GKBh}m/%L /Rz_o [rY p[Yq3?XVsOmsp)J͐YM\?^"@!.$'u!kwlPiA1ȿFQZ X;YRr2aTOT1ILMx_,WWơǜ_x>5H uW} ׯҥIk*!:4/#w+s`vff9r@0< qE~psg$=!@W-wS]Uҽ+tUG[_? ?%҂=^-:^j\Rtq 0"\$(-f @SYRiᯟ_A! E!}SB͟$'iMea_NإKw_|=wPh:=I$('O.stBA_EAbC!ZH]:6?Zন-W T:@.pl,W7n$hMOх;E.^KQw,% @S BO@ɯDAΛY뻮(Mۺp-z$/jpS ?#ҞKM/CioRB(euc?U-41(]͏g2,bjT_[%932inrjf~2'E/Z_rlW$&G?dזq; :wnC.`u ?T6mv.Qn  @ynNDI߻\ ݄xGoiW/|'Eħ;צ_N1/oFDZ?`P_18F'&E]SXV;1&REN$@֒dǥ ]? _:w wb ҴxrIo^9Ǖi7"4@S@=*ڭYJEYSHK z<VX߸};*__A5'R?D䍟PAN/Yh^1?UA8մrM! ̕SyC^v(/"c_B?CTJq?.E R1pÓ̀9L&G[lB q>Y:Hf bGJ17[xQç ~1ɿ6w#ӍO`s?idåAkQmorp0 yA 6 7d{A9Rwi: 6 &6yȿ!5d]sM ^zO h<ԞH_#` -5?85EÓ_]1 ̟_>R"NۙPG= 9/>i o"Q?9wZU 8uhDCrBFAM\&:w=Uwׂ9ۨ5NlȆl("GulJ?Z_1R!ŒHx ⼮EVkht q Nز .wxV,&qB:`z_B3дUȀ]g S!>'҅ˤf/Bftd9_/#v%n f{uuQb:`@,\'x00$ք;,sU~i@*Gq´w' lSHB7nbίIbOgM~:!a?~ ͞]pbs4R)8'|`ۼ["ܹ@@z=B^D+E볻w8tх^Q (.?ɰ-Z7|?X( ^L=oLIJ G+ "=#W . J?%#CO#B/[(qp ? LΟ (pE#1@!h1yq*h[W5w9UG ɿ~_PS_AluOfN e,>ɿ{pmE\ ZK+S;!_]1,YN׶쳀|3@j%R/y/&Tu, Im`sHz8?Bm@ @'Nn?" H۞౦1r&Sjw}_ߍvRPgɱ/~9TBI%OrC9a?P_KpMRC-"dPI}ɵkRt8iThq74!=~+=!EEUoA*Mgϙ:q |9Zbu ,Hne&5Π/Z,GlVE599ѱh#HRBI Kc8B@:Uu/g6hH'G7.Ԉ#LL,H#0QfZNK?P?jϤCt2tALa5wd&^-&_Ie$_.I9wIhU,Ps)# Q\]h):8kY]}"ڹ `T(sI^D)89l[0-:% m:biEE @B@,\%<9U-41@"Ri/$&݆o}&/x\|n埠Qj辷@f_s|fqH/Qx@z:5ϴȘj_BT\h ,/pYGN @AMo1U"Lr: ZĿk҃a@XK(i:R9.k@N*B5)W#bL+#p9rċ]gAP @,Z Pe:L#jZy ^HRWQ Qj@w{t)Fo$?U^̼$(Dl.;Ud-ĘE @̋ ĘhTÃNRl1;O@kn__To IDAT}:YEc"&OqJA  +w뤠YYQ}*lBF#5Of)$ð SwҢiM|u P%&h=犘:Slki}_d *ND,:?p\/oGS1 CADN: y0@)D pK|?\/b8!d BS%G"xͷ64l_cNLA਍R4$ @!k@H " {*6mRU //5Z" @L^  z끪U׽;fOiFUJ\ 0$li80\1$8?OM8+4Ddx[aAs7I/@] Pnu! w?8MGB+_٤n˚;Kϊ4]5B1/!噶, #L%_[]AW|G]A G={N.,T;Jy\s *aiǜ.5 L5 P$u]ptNMrGiz\IC X8*x KϳAj!_l b$+N|wF3`߂wW-%h?"УP|>mBPbOPI%:uۆ#C+Sl/oC`q2 ^_~? FBoP т}x^hC[M!~2np_,Vkh54|=hhoFS@mD+8wрb~Ou?wA JVս|/X'/ɖ E0ˇzMbh_!5IyųsrhBQHPրF@nI 0CMz.\Nk?@gMw%tc5]lN^HJ! mwdr6S!ݛk'=zD!OEk~)6r\#HtEHh&MEq!CD6]>+RUl *hCF;kd)NCfu mȔC?.$`qb_M},Ha},4^kЉPaQJ47$ WnCo2wh}Ub>0 $1Wkɤ@%| lð?$ƝssuyNYM] (đX `"g%*qr ^^IG"1@fĀ}}|O5Ev1J ӭ] Gȿ 3h4K<Qntd,Xƽ&G[h=;l?5l94-n`*qR_ٛ_7+6&Q>z>YT8eX#Poq<-^ɭZP~ckuRQj[M< _%5 Nj@& "Qj@|ڀkWT1.qѠSq- Qtֶ'X`}Bqxt Q^D^Ixp oKU+X;[]_*QME\RsCDHĀ'-:X毀G(Pr |Z|SR}KS}>DP1pj OvXR/( \{K 0TQ 4vmnMX"v ou;S 8:0Ig)^WIw?c} b@ KhofJ@|&1eGKxJO)qEX@b"nVĸ8D2]&(Ds[xta@v7Dj) LU1bäw=t=ʭ]B;}?~cI=56rP(Ҽx fu}` &MuGb$J-p!}E\ĐSB?K @庁@m'!X^PyD;X:,SCfDmt&uŁjq~g,UOKQJGDVgVglFD # ?[2 d{]Wkhwd"E#:?BT[x>Y xbrOS\Rd"ڕjzJr}25OUAš H-1VL&Eb67n?{nX4%x5(׏3~45B d?V&` y:~WJRPRx6!f"Shﻮܝҩ!ݏ!/Lk$%X "s1q̋:/}ItShAiay:^b}(^"!x>݆y~ssσ l~<αgrjڂFfT5;x}j & *P0D__ ]Eqn;y?1n$(Dt7V= x1Bt?%'Zc3A!@ꜳ ZO*Pk1l%ng:cM*.,EXF@(&3 v%4!]اPHR.qq"IοL=G#PI7W=M-iHP #} }@ bb:&lZ"S-,-3m> 3(֎!=W K :F`w^"=(j c@1qa` <#IW|/Dq_'ҍ5b < [aEjcF1:ʀWv?-=uv$}~tn%U jD_c}n|fuY"a-N>8e#Qɺ䂘WByO!z#$V^|y:~ Kv|sKi)2-K c\cwwt9t+4\ӓS nD2*QD _F`wu`, 3,02 쬤1}d ?NQ;ֲ@߽svBuKx:&V=ұ3m2ԬGlb@g9LHC_L,chdžu*g/~g/ou-vȀt(sU1 Rџhw?дT>- D<֒^duĎok;%!{iXz3Du[}8h&= Vk| g 1 GToLX ǪPV ly8GaRp_Ph&)(d$ Sٵu8)Ԫ Fgv뫸vkע(0yc3RfGY@M XKt Hk Um=gD8M>Pj :VӵC5(>s_Bygmq4G]C'Pob]m DER;/_oW@c#ڮ Qv-Dv~d-֒Ivn0XĂy@mSs9>ǯՖa;QJ쭯ṯuE-YPs9 1 ߢ%MMY_nOzjij;fPb_eڭK Ʀt|S Eub84V$#zSE7xtO^-;CX0O:K}c Ld穪D4-ydlz!nZ$@f}iXg߽wo/o DVpBtDZ=?y߅x~򛁦+ \qkRrm}$cs/" 6@ۧO`=UӋZn(wd7< $86ݻɴ&e"T+h$ ݯA$O)Qe EH찻x>i2ΆϔvOP ׎ݓVxƊiϬ2i3mmt/EnpucrUw~Aja7PO3BA 3/rc(4 }=e!@[aJ |_/t=NRZ"T7'X zcSD` DNda7:ti#bKZ:tȿ?n#qL|ntno. ߙmwX'Ǿg6GB5:ws qǰA$%`%/X~ R8) _(PLC7|atAfl'Ҭȿ1|zQΑB@wDM#mZ ߽s[Ow^^ iwcXcxތBk#Fц $K@D6u*,y]2(ԑI 7ir#K9H`2:+$Lv뚮HimWIfҊmDgm+-2Iw!5rNL 8ňهspxF 9߷kiWG-Spۨ`wis-AB"`-?gvl,dϲ|EL-TbglvoJ5744F`wԓ )Pel,rwm5ԢPjJiFv@+>a+_Vb=({y61(D k/"[mzqV0l $ )B1UUSr%iۮvEpnzbfcda  lc;"3bB~/?<',i'D@,nJlA9&#BSY qRB~-=4i" @ ` )P @#RY()iYS#:dDƖ|T/ԍt{D?<)8=Zy/Fcb,EQR#E7 |) %^.o)qsYg,-kƝ(F1 zYxG @0#0$|k>1  nib,HdցLͥ<)| ]wͰ#,zn/$ŢGfxھ3}}w/aHHQڬ*6Ȓr KSMz6힑0STGBS~ޯSBz~ rbt ⓫EO/B,Hl΅]ȫ,2[eHۋdY> P) il|ei1Rs% Rlw=kva%4S-DXj]3/ב@ @@Be(8UA}HE@Ya/Ɛ)ꗞF~~}En$g_,sCKn|" {4ih] g$$lVry+GGb,Quyb#%ôԧqw 9@jO &Hw^_}d"`:>D'`?:Vݗu$T"O3EHnKz&tX4ˁHW~ [ZcYft$+˯`Qw1 TĭX?]ɷa&:WeelCdrn+$y_,9  H$@}HqPsRsyb246 =E˝m GHt ?[آs NŞ!fq^ne`c'ZlPpV!EEӊ8Zdtkt#%22&ݙ3E-lA ow (}eNOw#a?5s}9_"& 6lQN0FDj0 V$k¿=+bDmm.BVa< &Y8'MbhlY"gF@5IS"l% ; @$1sMi0 [lƯJS-f^gS?άb$zɖ18w_ gwȌF-`$LS Vr@#u:0# 3-A « RnUP ,G/-;Qt@8$@vɾ.(528'戩ĄjWT"E!F f\b-Xߊi\`j=R %R .uS+w (H( [:&)tK9K9:D7epu9"2\!EB)zG\?G{ (2Z,+O_[BI!G ch_DܓYbNj s|QeYQ0)'tFЉ]#@ZfDC, `Z?*Oο) -``X"+ۗ擫Ej~yߧ_.K3vɏJ`^۹S8+zhyF\j0v*Q)'\3x#ED*f(:)D,jFtM6q8 ]$=#!\ ۵0`ECbKVDFEŲf!tfaúfnߕDthHtMj#pMUeI㊀I li<_ﶰ|?C>Kl"*i_,l-B b9%:1+Kbѥ"z#HHDJBQ1a d 1HvsF0G IDATÿ<3A4L]nd)$ItKqXoXD?A_\_ ̬]I%GLX3HQ]%)&n`y|E qb @V 00 P|0&dCݧQ(0Q ܧsf\<[skǼQ_EF\ dZXU0Pp0Infslþ4oX`hqL`9m}"d L`K%|,s[w/xkqfYw vbhhh N[VL~k]J`yZOs9F=Ci_p՚u 1%GfKJ@1;^, t+˺k=}4 C'9.!\-}z6**6FJ$~/.Rj6v[q"ֺJk̭Bޒ R*B˂ BhnnV眊*!zuR h~]4 #bMyڨuu\.4KoL vcRڭ=#X/ҭk21ƨvbNow'BoV* Q$g㥩}XHF(}!1ezo釆˞8u ,z[J"@~3 EF%Un­:t `F!;臆q3d?3N 9ׂ}^` i5lIoԸ8SCW>2 "J^H>飫X+BD)tKi\fR)q0M 9QNu"EolpoNk 򻼢*0L2LATtQH3|dEk΂`x^9kt$i7([CB4m9`o燯qZ\T;qT2;XvDn܏noBAu?_,cN1ҵ yXRID)l -q'=ΉyU/(nws c;Fi&?Ngҿ* LD02y g |!F0I~M~b `<h`o^,Zթ&_.XY'W fA y+z!OJ*i=# 4`,d*2L7TՁ}}_n=/WJY!' b0y f,"FD .@qz{KROMom! j6?y{U~;wEֲL0@,yF0G f'RNqgom aYSCku' l/B%̩ m!?;Cw]-Bۓ{ )$ZNȘ0 irK7tzFBXU`]>3ZAO(&9K`@5<4n@νqNLhǬn~4l mvI׵?4_r9*;T#cPq7N]7Lg|a:{? How}筍jJjM !]c,Xe& sb%fc/9 b  }pH<"c#OM)_pC [㜳`끺&@Ȟ"˟m ! >4{ Gt!HԳkdtOmjKR\YŤi-|;" ܛ_TPZk޴J\.:paP06i<ۗՁ;3/=FMif_\9Е#;#y-=N7csǜyT Q8Hu0 n5ۨߺ}[xƽ$Qg0Ʋu"(0- 6&^ѥJ}SP'va ["*Xc?#F+iAGT6 u馽Ԏ3 G|Ic;!#q ާMzy-87H: "7_nUk(M_" l|RX\.7R0&z[T)tb`{3!B{‡-[/tcMVư70*a?Nl.*4$2`#[Bdk3.j -YzT+@>ZA, (0oBQjn2NP<]*\`u ,4Of5qxl0G6<;UkK)'H7k_!VC8^H]=ieH Xme>,iuE@EPTJ-8pr+޵)@X~<B'` '%!|t96!|snY(" vHgFoZ"wN߿ U5_pϩ  PF` ZB:чk kK(~u)O& af`+@{FCa" k6C01#!gtJy%(wJI n4q@9z2|$ew HY3e]3:2 g4M^;QY6&iAk,B_GP-%Um)L#3+F7/5>wzZe 'p@}rgU/y-F8S Y,"=exboaC#]5-]?/?(3.j bn}>!R/]0 ^=?`Eo^nʼn "ފ ihPA4P08 `r[6op Cy)1_5{?MtfP` X3"5 lXh"_#L`8BWAD#KS`ZRʅ{E 2/dbQW n7`Ti#[= <tw?d s]4K9S_TS Ū!W##/i:Y/Pp'vbZUBΔypXBY ŵ2sq@,Z8\eP`3lxSa)n/HgtgC 1 dXxKt]#]tgJPUpƂX0.Nz| aH2:S`U~;wU93"FL%,V>@ŢB^/joUrX`@A8u)O*t[Dy  <}pk$q|ЭuuAjXX K?[`jF` UP}_7 Z_cv&?-nxmJb 'UdE\,*;I'!V\)Ky\D@%`f!N{|sERԱWl ulK' x?=9?ynPtoU{F+ A %""s!v,Hžcu)l 7F 6ow}筍j%mr"J>b@XBY3/R(" ;juӘ`!7 SsE `dg\@}a3o릶٠(U/-{9X7p 7=~@GRT-W֪N@>@|",T"`]|zDY/$=`^OY W](T0cg7|:-B+QjVEx_Wa5Ð351عΩBH'?vxFܕ gJ@0TM\XgS(]KE 8myi/O%prnoi 3 A`0'WVW&%@c,tjSB/"%7#UyQ70N=>k |V}m4u?> :%TTo(\  1_O)?tz"`HDN{Ɩ&Waw9% 0_0xLoS liܤ…Sǹ,0EiLk?{9^@H;vRZTm i@WeP ORqIA憷^x 89\JY:pNK  q˰ᄊo)wߦPǞ0Y៖>h/[TX\sI@+I"\V mSlAS~!CEQI\,B|.E OL-;Ky~})O9pZr>^7L9!`pH0<ev)ng1?[. *\Xq?. pEʹMJ ARAODg6t6mk ȊHXT7JR1bUCKp\:\)kp[Jpo ;s!k9*lT֏6"tgm,,SO+"|-nh(Qk$ < `'ŷAf@Ã{|Y [ (^(p@XT. r^_B !ߚ0*4\(0d#7x] F G,:Y㢷v:QX1Ƽn %yB-:޸6 {VȽ0ȦpH{}E ix~@b߅bq@DOH'?W*9Y$bNV nJuc~o6_kFJZ]96<~nsՖlk;9DY nBZ"@j}Q/JeZ _(p`}p0?s#~<^J%Gm)\/4%p!#Z g9M[!"@Q5U(l>@}abk[ @fD\@n, `! /dLoL.TtjN:FP`Hi8 @fBSTf-A4?"3imk:q^eZe $ &A#^ N}j]2 (J4 \}P|00^/Еrzn8@KnmrZ&4)κYgizt?4 ?uH4OjY Ȓsg k(ܻ| XmJՒ7]1?AOE[|v}? Sg#BW*tu )7DXE"CE3Bذ/`PbD'Mu c%5W% @2 f)"R u]l; G0F$Y.@0/pН)0R8?WyRQOҵ¾#=pBqkȿF6ioCR  򓋀~NW|ʘUT!myxpmyKyjxT6ra"`!.f..B@H;qrAحOf #3)"SjNy IDATlYVCDS 6^GO8?cUEW;[]ow]4F!ܛ"Txʕɉsn_ k/d0*r^T!}qQ Bc?F%Gw6K`D)-h>bQD C>P/n~QO0?y? "- Uwޭ-n4F2@G{zTʕ*7Mmu" a^g).)_D ;O\,mmg07/(1~?n/:^gCB \u1 |sDH!fU(N_s yf(e\p vuk__ZzxƜ?SB< ,*3k+9߽Y"d\z038t Ż;jZRr.<`2&XND- HZ|vD<xn@_ 1u<])+t}MyAaiW<,^ 0v@ aǷSCO(Ԅ;Ξ' Ҙ_?0Hp$M{@῍ @ۇ{bTu  ,pH> >˛唆1 R` p_~%/|| K9"4t2&a¿a==#"B@ޏj7P䊕1@.(/XB EV-Y@AjqZ ny›Rj`@Pki/ HbB_]9@ vQ T g YD !q 2 Z0x pȣ$@GJCXgĨ5a@wLwI|4Y6 n!>F@H޽>y[Ƶ5:r{rX%0M}iJuL2mS `  AiaY)CSX|*=`THt\(jTŝ ";?X<ON v^ェKj\ . ^RUD F8?"COG}X,a>` `R02cJA $0%EK64aJ rV]sN4Ϗi82E,&D8s w_ rH ? 鴭er}. l (Ty 0\A~jПb`!!qfq2Qw)4olD ~4pCkDVS*$:dOLű;pӚ0@\66j> 'C)-7 }L *_(R0KN7 #$골Y" x?tQ@@bkk,"iEU)vfdSǷ-'?#H>59q6KY`P [0_W |?]Sf[.hj6QG?`xTLFD'MF~9N)͓:q^UŪ5 `^, m(ܻ|f;{RZTܞ ;Ҁe 0Զ('#KnU0T 9Xw%?K>*GLVHZ_sk 8?cUEW:vC]o>nT*WK4@Z@Q = &q7[obn?g _!4>&|"|,0bu!t׿` Y56 5gl@U%W:e< m"@0 VGQm>;JgxoR)REf @_ABLppWþ< {-8(ϵ]D蟽FjXsZ"G~#9v @n @"p\ټZsZ{B BP.ËP"bt"?ܪPqs_8O)IG,@h;пHd!d&-Qߙ53(#:;9n6w:|">;R-~F -" mvWZ@X0 WJY I 3`Y1sU/?TL>sg A-ؐ;a1J?X ֳς6`r7!E@PcM) "n7D޽>yW;e0šZ0ؿ0XkY%C5,~rH%8]ߡ?ZZrJ1!BZn{Q5<dN}R R^`]0q@0^X^`F|Z0JXY I_ i 4M!EW[1U2E8f(p3 8v뿭~tKm$ ,= VY"`@ W=?\!i>\t/4`vϏi82EZ&"OdZ-iCyڭVw_oN׮׼Ҳ,`S0K #/_ [0 P'C70 `,"xk'?,!ny<|8$U2س1PS}oI[@}}ۯJs{Z,Q( 1"BDT'@:qE@hĒ)nCs+mKE@fZɈy綟>/8K-,9/ZR\Y 18 ]9ȏ!> #@DO({9@ )i ,(,qǎ^ u]_?;9qS'`Jx ӈ7Bp_@V>qZM`C|@@L`kg+:ws6xmu $Ɔgn X LJ !A:EcU%ZM;n;0`M{iϏ`yp_{E)\Э3 b"`ԴA0rqw nT*WKm$@@H>փ8V@u✓(҅%`x蟅P$]& k< $@0ijA?b@`3LC !֣\Rc_cRgw66?0hϟ<ڎjh݈`ҀIqXm020t z.Z\Njc),;,HY0sx@oͫ5m4>E}EQ "HZ9X$Cuu;ao]X+U_ !|?e,Dp `X)Z< ?XGZNWsr)%9qS#ݤG@t|dpUX,UK6^ (G@,H1+V(5tt]^K߼xs"wO|P,V·v](c q- $@ xSЙWs뢰X 5|isZ|$Cm`q@$!%_2 t]']שno/~zGBZ,,E@@ `rgIe@|Bpn#1FIx9vWhiVS5GuXkU"Ӥ?sMo!ɋfK7ttpA\տح0|6 IaXwg5oA.ȩYA^ f Op |Za|xV N?)?ww\iwG$r`(7[ZTBHBr<)*\&V6NQߣ~G~~m bc R5Ϲ_4^~8)4 utM3zZ5޴[}/ S)Mk8 ͹iSץ~׋:vM??=!  >@T o_ L,.k5?˧O.^T+KUau ,PvBad q`iépAr@9a `@uҵ>5vsVo߿jXw ?p@_] 0Z k]pp~Ix}RNl[Ƶ½W)   szӃZyȚ~x}}U(X h5mH L1DjhD ûFit }}zOjh t#!HQURU5v@Q̭pە{5藇?&Dm0z A$=%@ ×% 9 s\ P'4c N@@[Oo֋R\YmHa bV^C_gx/LàK/ל6x^@wI,PzBjh7 clFq+~π"Mv:Dv}CilbJhF/:냽GNv?yuzX,U$M =clk0)  4&\Nbs8v@R΃2t>VvTݍO }_YjdrX"X: v B eǩPT ]Wglm @g8O^8>z^("[K!p"gZ080Mz65@2i^*W1m&>rAVy F9{sXSznW~f/c`~dK8'Cw@Xo<'= `i7~u^Ys> بq 8;;9Oh<{wz|v+5N^K! gIKX"sӚoX5hI 47_ohV7;?|-]ڍ_{ ?9 stvvB_;~6γ-U&!3 -qp^'g ӡֹNwp+)vvRb 䜸|U+@Z}_ke.n/RKg /{"`z0TL+șgcf ̞vxw>9 _ _Ev$@2sV5N3o_ BX*{E,I[fM(|g @@AaP@h6?|-Ci͚S@̞z3@"M)yvF}nc0tZ|pƥ\%@QoЏ; xҭ%5kY^Yk"/wj7w撄;O=2 /oԸSwi2߬Iy3k@ g޶mWP`:r;wm:ۭZXyr~痟ں~V,r` 7 %4ǂatz|D#0>[mIq1G] 14[m4vt[Wi|jl/RʥN} A|~q Ч^@"@pi(lw\*Tk8+<0IDAT V}؅%PpDw;atycf t0/K80.7r0t:;>&@]6dob " IHU 鮭5{^y+WHZN^:4Y9n}:;9wGGƯS /SN͑ˑ(W"  KiQk%>?U3 cӖat͚V@_] ; =3←60Fc8 Ū1@nH F;[@0տ^W`oga/ Df$'q ?w{Ǡ4/߽>jT:8J~96v0H,Nۯ0n5[mKrv tÖ+<뺵ߧz"mð J)t`BNi+ H4nNW* . ӿ5:?=}-Pp riھP. Ȁ5-Ns@FE@x'>͚SͻjǨ! "4bu:Vx{vۆӕ+5MߒB0LW4Mut~vJD@qNn+ȥBlVZl!6zߚYBWk}3y`cA`YEUT8y5hAF 4'/Gd¿SӦWѻ;~~yV*'3V$ [An;Lι[4 7w;j"̴[Vݗ|rKKes0[`=6PH>@2@5:;E_V޿}(1R[@Bv?#xsWڼvVU[*pe `xw>zR^^UtMnM!FW/RZ^`gO>6|^o?z z+ ˧O^?gw՚ @Di}W;~vS]7TM.x:i>u:-{ߢJw-!Qm^!Xy6I?b-\.Gj.GTld k߳4}?pi}:7^D6|xo/ S`o`Q/^@!b,  C*wmE~NV챵,T.W+>ց"`<uM#MS^lE]@7tzFm  ;[mNGxOWxsW2 ޸Y J b cοn>_6<>@\-W֪g40JtfxHڭf#>@eP_%@04z};X @D@xm]5!Dc(0t:tvr 8t]k7~ dD;S{]:?=F `(+reJHQRś9NZGNv?i`6Er׿ /QF|9u;mjӇ?[ `r0Bi7ik($ ]'w)  ȇ}7- 'NPIENDB`goxel-0.11.0/osx/000077500000000000000000000000001435762723100135325ustar00rootroot00000000000000goxel-0.11.0/osx/goxel/000077500000000000000000000000001435762723100146505ustar00rootroot00000000000000goxel-0.11.0/osx/goxel/goxel.xcodeproj/000077500000000000000000000000001435762723100177625ustar00rootroot00000000000000goxel-0.11.0/osx/goxel/goxel.xcodeproj/project.pbxproj000066400000000000000000001511231435762723100230410ustar00rootroot00000000000000// !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ F00FC312226B2F7C0002F251 /* ini.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC2FC226B2F7B0002F251 /* ini.c */; }; F00FC313226B2F7C0002F251 /* gl.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC2FD226B2F7B0002F251 /* gl.c */; }; F00FC314226B2F7C0002F251 /* sound_openal.inl in Resources */ = {isa = PBXBuildFile; fileRef = F00FC2FE226B2F7B0002F251 /* sound_openal.inl */; }; F00FC315226B2F7C0002F251 /* texture.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC301226B2F7B0002F251 /* texture.c */; }; F00FC316226B2F7C0002F251 /* mustache.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC308226B2F7B0002F251 /* mustache.c */; }; F00FC317226B2F7C0002F251 /* sound.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC309226B2F7B0002F251 /* sound.c */; }; F00FC318226B2F7C0002F251 /* vec.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC30A226B2F7B0002F251 /* vec.c */; }; F00FC319226B2F7C0002F251 /* b64.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC30D226B2F7B0002F251 /* b64.c */; }; F00FC31A226B2F7C0002F251 /* cache.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC30E226B2F7B0002F251 /* cache.c */; }; F00FC31C226B2F7C0002F251 /* img.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC310226B2F7B0002F251 /* img.c */; }; F00FC31D226B2F7C0002F251 /* color.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC311226B2F7B0002F251 /* color.c */; }; F00FC32D226B2FCF0002F251 /* cameras_panel.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC31F226B2FCF0002F251 /* cameras_panel.c */; }; F00FC32E226B2FCF0002F251 /* material_panel.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC320226B2FCF0002F251 /* material_panel.c */; }; F00FC32F226B2FCF0002F251 /* palette_panel.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC321226B2FCF0002F251 /* palette_panel.c */; }; F00FC330226B2FCF0002F251 /* menu.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC322226B2FCF0002F251 /* menu.c */; }; F00FC331226B2FCF0002F251 /* layers_panel.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC323226B2FCF0002F251 /* layers_panel.c */; }; F00FC332226B2FCF0002F251 /* about.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC324226B2FCF0002F251 /* about.c */; }; F00FC333226B2FCF0002F251 /* settings.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC325226B2FCF0002F251 /* settings.c */; }; F00FC334226B2FCF0002F251 /* render_panel.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC326226B2FCF0002F251 /* render_panel.c */; }; F00FC335226B2FCF0002F251 /* topbar.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC327226B2FCF0002F251 /* topbar.c */; }; F00FC336226B2FCF0002F251 /* debug_panel.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC328226B2FCF0002F251 /* debug_panel.c */; }; F00FC337226B2FCF0002F251 /* view_panel.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC329226B2FCF0002F251 /* view_panel.c */; }; F00FC338226B2FCF0002F251 /* image_panel.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC32A226B2FCF0002F251 /* image_panel.c */; }; F00FC339226B2FCF0002F251 /* export_panel.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC32B226B2FCF0002F251 /* export_panel.c */; }; F00FC33A226B2FCF0002F251 /* tools_panel.c in Sources */ = {isa = PBXBuildFile; fileRef = F00FC32C226B2FCF0002F251 /* tools_panel.c */; }; F025C7DB1F33239000C52709 /* png_slices.c in Sources */ = {isa = PBXBuildFile; fileRef = F025C7DA1F33239000C52709 /* png_slices.c */; }; F037D5C31EA6061F00C96D10 /* gox.c in Sources */ = {isa = PBXBuildFile; fileRef = F037D5C21EA6061F00C96D10 /* gox.c */; }; F037D5CF1EA6069A00C96D10 /* brush.c in Sources */ = {isa = PBXBuildFile; fileRef = F037D5C71EA6069A00C96D10 /* brush.c */; }; F037D5D01EA6069A00C96D10 /* color_picker.c in Sources */ = {isa = PBXBuildFile; fileRef = F037D5C81EA6069A00C96D10 /* color_picker.c */; }; F037D5D11EA6069A00C96D10 /* laser.c in Sources */ = {isa = PBXBuildFile; fileRef = F037D5C91EA6069A00C96D10 /* laser.c */; }; F037D5D21EA6069A00C96D10 /* move.c in Sources */ = {isa = PBXBuildFile; fileRef = F037D5CA1EA6069A00C96D10 /* move.c */; }; F037D5D31EA6069A00C96D10 /* plane.c in Sources */ = {isa = PBXBuildFile; fileRef = F037D5CB1EA6069A00C96D10 /* plane.c */; }; F037D5D51EA6069A00C96D10 /* selection.c in Sources */ = {isa = PBXBuildFile; fileRef = F037D5CD1EA6069A00C96D10 /* selection.c */; }; F037D5D61EA6069A00C96D10 /* shape.c in Sources */ = {isa = PBXBuildFile; fileRef = F037D5CE1EA6069A00C96D10 /* shape.c */; }; F03B4387224CCDDF00798CAB /* pathtracer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F03B4385224CCDDF00798CAB /* pathtracer.cpp */; }; F03B4388224CCDDF00798CAB /* yocto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F03B4386224CCDDF00798CAB /* yocto.cpp */; }; F05E2DD9268F451D00E47D33 /* quit.c in Sources */ = {isa = PBXBuildFile; fileRef = F05E2DD8268F451D00E47D33 /* quit.c */; }; F06C683C1D2EAECC00887FCE /* camera.c in Sources */ = {isa = PBXBuildFile; fileRef = F06C68391D2EAECC00887FCE /* camera.c */; }; F06C683D1D2EAECC00887FCE /* quantization.c in Sources */ = {isa = PBXBuildFile; fileRef = F06C683A1D2EAECC00887FCE /* quantization.c */; }; F076EA362284162400B74F0C /* light_panel.c in Sources */ = {isa = PBXBuildFile; fileRef = F076EA352284162400B74F0C /* light_panel.c */; }; F07DE9D31BD0F03900BAA1AD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F07DE9D21BD0F03900BAA1AD /* AppDelegate.swift */; }; F07DE9D51BD0F03900BAA1AD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F07DE9D41BD0F03900BAA1AD /* Assets.xcassets */; }; F07DE9D81BD0F03900BAA1AD /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F07DE9D61BD0F03900BAA1AD /* MainMenu.xib */; }; F07DE9E01BD0F16300BAA1AD /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F07DE9DF1BD0F16300BAA1AD /* OpenGL.framework */; }; F07DEA041BD0F31500BAA1AD /* goxel.c in Sources */ = {isa = PBXBuildFile; fileRef = F07DE9EA1BD0F31500BAA1AD /* goxel.c */; }; F07DEA051BD0F31500BAA1AD /* gui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F07DE9EC1BD0F31500BAA1AD /* gui.cpp */; }; F07DEA061BD0F31500BAA1AD /* image.c in Sources */ = {isa = PBXBuildFile; fileRef = F07DE9ED1BD0F31500BAA1AD /* image.c */; }; F07DEA091BD0F31500BAA1AD /* mesh.c in Sources */ = {isa = PBXBuildFile; fileRef = F07DE9F11BD0F31500BAA1AD /* mesh.c */; }; F07DEA0A1BD0F31500BAA1AD /* model3d.c in Sources */ = {isa = PBXBuildFile; fileRef = F07DE9F21BD0F31500BAA1AD /* model3d.c */; }; F07DEA0B1BD0F31500BAA1AD /* palette.c in Sources */ = {isa = PBXBuildFile; fileRef = F07DE9F31BD0F31500BAA1AD /* palette.c */; }; F07DEA0D1BD0F31500BAA1AD /* render.c in Sources */ = {isa = PBXBuildFile; fileRef = F07DE9F61BD0F31500BAA1AD /* render.c */; }; F07DEA0F1BD0F31500BAA1AD /* shape.c in Sources */ = {isa = PBXBuildFile; fileRef = F07DE9F81BD0F31500BAA1AD /* shape.c */; }; F07DEA101BD0F31500BAA1AD /* system.c in Sources */ = {isa = PBXBuildFile; fileRef = F07DE9F91BD0F31500BAA1AD /* system.c */; }; F07DEA121BD0F31500BAA1AD /* tools.c in Sources */ = {isa = PBXBuildFile; fileRef = F07DE9FB1BD0F31500BAA1AD /* tools.c */; }; F07DEA131BD0F31500BAA1AD /* utils.c in Sources */ = {isa = PBXBuildFile; fileRef = F07DE9FC1BD0F31500BAA1AD /* utils.c */; }; F07DEA331BD1014800BAA1AD /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F07DEA321BD1014800BAA1AD /* CoreFoundation.framework */; }; F09482FE22994752005DE2C5 /* layer.c in Sources */ = {isa = PBXBuildFile; fileRef = F09482FD22994752005DE2C5 /* layer.c */; }; F094830022994765005DE2C5 /* material.c in Sources */ = {isa = PBXBuildFile; fileRef = F09482FF22994765005DE2C5 /* material.c */; }; F097B3F31F0C97DB00A3622B /* gesture.c in Sources */ = {isa = PBXBuildFile; fileRef = F097B3F11F0C97DB00A3622B /* gesture.c */; }; F097B3F41F0C97DB00A3622B /* gesture3d.c in Sources */ = {isa = PBXBuildFile; fileRef = F097B3F21F0C97DB00A3622B /* gesture3d.c */; }; F09FFC5721CE161400B6976A /* box_edit.c in Sources */ = {isa = PBXBuildFile; fileRef = F09FFC5621CE161400B6976A /* box_edit.c */; }; F0A15FFD1E962F1300C6EF33 /* png.c in Sources */ = {isa = PBXBuildFile; fileRef = F0A15FF31E962F1300C6EF33 /* png.c */; }; F0A15FFE1E962F1300C6EF33 /* povray.c in Sources */ = {isa = PBXBuildFile; fileRef = F0A15FF41E962F1300C6EF33 /* povray.c */; }; F0A15FFF1E962F1300C6EF33 /* qubicle.c in Sources */ = {isa = PBXBuildFile; fileRef = F0A15FF51E962F1300C6EF33 /* qubicle.c */; }; F0A160011E962F1300C6EF33 /* txt.c in Sources */ = {isa = PBXBuildFile; fileRef = F0A15FF71E962F1300C6EF33 /* txt.c */; }; F0A160021E962F1300C6EF33 /* vox.c in Sources */ = {isa = PBXBuildFile; fileRef = F0A15FF81E962F1300C6EF33 /* vox.c */; }; F0A160031E962F1300C6EF33 /* voxlap.c in Sources */ = {isa = PBXBuildFile; fileRef = F0A15FF91E962F1300C6EF33 /* voxlap.c */; }; F0A160041E962F1300C6EF33 /* vxl.c in Sources */ = {isa = PBXBuildFile; fileRef = F0A15FFA1E962F1300C6EF33 /* vxl.c */; }; F0A160051E962F1300C6EF33 /* wavefront.c in Sources */ = {isa = PBXBuildFile; fileRef = F0A15FFB1E962F1300C6EF33 /* wavefront.c */; }; F0A160081E962F4600C6EF33 /* marchingcube.c in Sources */ = {isa = PBXBuildFile; fileRef = F0A160061E962F4600C6EF33 /* marchingcube.c */; }; F0ACA2A12271ACD400376C82 /* gltf.c in Sources */ = {isa = PBXBuildFile; fileRef = F0ACA2A02271ACD300376C82 /* gltf.c */; }; F0ACA2A42271ACEA00376C82 /* json.c in Sources */ = {isa = PBXBuildFile; fileRef = F0ACA2A32271ACEA00376C82 /* json.c */; }; F0ACA2A8227BF2A300376C82 /* shader_cache.c in Sources */ = {isa = PBXBuildFile; fileRef = F0ACA2A7227BF2A300376C82 /* shader_cache.c */; }; F0AE90F71C8EE01300C29080 /* assets.c in Sources */ = {isa = PBXBuildFile; fileRef = F0AE90F51C8EE01200C29080 /* assets.c */; }; F0BC9B362315550500B2A56A /* app.c in Sources */ = {isa = PBXBuildFile; fileRef = F0BC9B352315550500B2A56A /* app.c */; }; F0C37C8C2317CBDE000EF45F /* xxhash.c in Sources */ = {isa = PBXBuildFile; fileRef = F0C37C8B2317CBDE000EF45F /* xxhash.c */; }; F0C5368B1F42EE43003A0DCA /* extrude.c in Sources */ = {isa = PBXBuildFile; fileRef = F0C5368A1F42EE43003A0DCA /* extrude.c */; }; F0DC02A122EEE267007E2F17 /* line.c in Sources */ = {isa = PBXBuildFile; fileRef = F0DC02A022EEE267007E2F17 /* line.c */; }; F0DC02A322EEE274007E2F17 /* box.c in Sources */ = {isa = PBXBuildFile; fileRef = F0DC02A222EEE274007E2F17 /* box.c */; }; F0DE97101E6FEA1F000354AF /* dialogs_osx.m in Sources */ = {isa = PBXBuildFile; fileRef = F0DE970F1E6FEA1F000354AF /* dialogs_osx.m */; }; F0E5DB2824FBB0D600010FDD /* file_format.c in Sources */ = {isa = PBXBuildFile; fileRef = F0E5DB2624FBB0D600010FDD /* file_format.c */; }; F0E71BAC1F1DA30D00D20C7C /* theme.c in Sources */ = {isa = PBXBuildFile; fileRef = F0E71BAB1F1DA30D00D20C7C /* theme.c */; }; F0EC57FF22CB268C009A42A2 /* fuzzy_select.c in Sources */ = {isa = PBXBuildFile; fileRef = F0EC57FE22CB268B009A42A2 /* fuzzy_select.c */; }; F0ED3C641F98B03300FB50DE /* mesh_utils.c in Sources */ = {isa = PBXBuildFile; fileRef = F0ED3C611F98B03200FB50DE /* mesh_utils.c */; }; F0ED3C651F98B03300FB50DE /* mesh_to_vertices.c in Sources */ = {isa = PBXBuildFile; fileRef = F0ED3C621F98B03200FB50DE /* mesh_to_vertices.c */; }; F0EEB7E41C8EC27C004AB676 /* action.c in Sources */ = {isa = PBXBuildFile; fileRef = F0EEB7E31C8EC27C004AB676 /* action.c */; }; F0EEB7E81C8EC4D1004AB676 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = F0EEB7E71C8EC4D1004AB676 /* libz.tbd */; }; F0F14C6720AF282E0006E575 /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F0F14C6620AF282E0006E575 /* imgui.cpp */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ F00FC2F9226B2F7B0002F251 /* sound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sound.h; sourceTree = ""; }; F00FC2FA226B2F7B0002F251 /* box.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = box.h; sourceTree = ""; }; F00FC2FB226B2F7B0002F251 /* mustache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mustache.h; sourceTree = ""; }; F00FC2FC226B2F7B0002F251 /* ini.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ini.c; sourceTree = ""; }; F00FC2FD226B2F7B0002F251 /* gl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gl.c; sourceTree = ""; }; F00FC2FE226B2F7B0002F251 /* sound_openal.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = sound_openal.inl; sourceTree = ""; }; F00FC2FF226B2F7B0002F251 /* vec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vec.h; sourceTree = ""; }; F00FC301226B2F7B0002F251 /* texture.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = texture.c; sourceTree = ""; }; F00FC302226B2F7B0002F251 /* cache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cache.h; sourceTree = ""; }; F00FC303226B2F7B0002F251 /* b64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b64.h; sourceTree = ""; }; F00FC304226B2F7B0002F251 /* color.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = color.h; sourceTree = ""; }; F00FC305226B2F7B0002F251 /* plane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = plane.h; sourceTree = ""; }; F00FC306226B2F7B0002F251 /* img.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = img.h; sourceTree = ""; }; F00FC307226B2F7B0002F251 /* ini.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ini.h; sourceTree = ""; }; F00FC308226B2F7B0002F251 /* mustache.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mustache.c; sourceTree = ""; }; F00FC309226B2F7B0002F251 /* sound.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sound.c; sourceTree = ""; }; F00FC30A226B2F7B0002F251 /* vec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vec.c; sourceTree = ""; }; F00FC30B226B2F7B0002F251 /* gl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gl.h; sourceTree = ""; }; F00FC30C226B2F7B0002F251 /* texture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = texture.h; sourceTree = ""; }; F00FC30D226B2F7B0002F251 /* b64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = b64.c; sourceTree = ""; }; F00FC30E226B2F7B0002F251 /* cache.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cache.c; sourceTree = ""; }; F00FC310226B2F7B0002F251 /* img.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = img.c; sourceTree = ""; }; F00FC311226B2F7B0002F251 /* color.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = color.c; sourceTree = ""; }; F00FC31F226B2FCF0002F251 /* cameras_panel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cameras_panel.c; sourceTree = ""; }; F00FC320226B2FCF0002F251 /* material_panel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = material_panel.c; sourceTree = ""; }; F00FC321226B2FCF0002F251 /* palette_panel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = palette_panel.c; sourceTree = ""; }; F00FC322226B2FCF0002F251 /* menu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = menu.c; sourceTree = ""; }; F00FC323226B2FCF0002F251 /* layers_panel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = layers_panel.c; sourceTree = ""; }; F00FC324226B2FCF0002F251 /* about.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = about.c; sourceTree = ""; }; F00FC325226B2FCF0002F251 /* settings.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = settings.c; sourceTree = ""; }; F00FC326226B2FCF0002F251 /* render_panel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = render_panel.c; sourceTree = ""; }; F00FC327226B2FCF0002F251 /* topbar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = topbar.c; sourceTree = ""; }; F00FC328226B2FCF0002F251 /* debug_panel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = debug_panel.c; sourceTree = ""; }; F00FC329226B2FCF0002F251 /* view_panel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = view_panel.c; sourceTree = ""; }; F00FC32A226B2FCF0002F251 /* image_panel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = image_panel.c; sourceTree = ""; }; F00FC32B226B2FCF0002F251 /* export_panel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = export_panel.c; sourceTree = ""; }; F00FC32C226B2FCF0002F251 /* tools_panel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tools_panel.c; sourceTree = ""; }; F025C7DA1F33239000C52709 /* png_slices.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = png_slices.c; sourceTree = ""; }; F037D5C21EA6061F00C96D10 /* gox.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gox.c; sourceTree = ""; }; F037D5C71EA6069A00C96D10 /* brush.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = brush.c; sourceTree = ""; }; F037D5C81EA6069A00C96D10 /* color_picker.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = color_picker.c; sourceTree = ""; }; F037D5C91EA6069A00C96D10 /* laser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = laser.c; sourceTree = ""; }; F037D5CA1EA6069A00C96D10 /* move.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = move.c; sourceTree = ""; }; F037D5CB1EA6069A00C96D10 /* plane.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = plane.c; sourceTree = ""; }; F037D5CD1EA6069A00C96D10 /* selection.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = selection.c; sourceTree = ""; }; F037D5CE1EA6069A00C96D10 /* shape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = shape.c; sourceTree = ""; }; F03B4385224CCDDF00798CAB /* pathtracer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pathtracer.cpp; sourceTree = ""; }; F03B4386224CCDDF00798CAB /* yocto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = yocto.cpp; sourceTree = ""; }; F05E2DD8268F451D00E47D33 /* quit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = quit.c; path = gui/quit.c; sourceTree = ""; }; F06C68391D2EAECC00887FCE /* camera.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = camera.c; sourceTree = ""; }; F06C683A1D2EAECC00887FCE /* quantization.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = quantization.c; sourceTree = ""; }; F076EA352284162400B74F0C /* light_panel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = light_panel.c; sourceTree = ""; }; F07DE9CF1BD0F03900BAA1AD /* goxel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = goxel.app; sourceTree = BUILT_PRODUCTS_DIR; }; F07DE9D21BD0F03900BAA1AD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; F07DE9D41BD0F03900BAA1AD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; F07DE9D71BD0F03900BAA1AD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; F07DE9D91BD0F03900BAA1AD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; F07DE9DF1BD0F16300BAA1AD /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; F07DE9EA1BD0F31500BAA1AD /* goxel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = goxel.c; sourceTree = ""; }; F07DE9EB1BD0F31500BAA1AD /* goxel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = goxel.h; sourceTree = ""; }; F07DE9EC1BD0F31500BAA1AD /* gui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gui.cpp; sourceTree = ""; }; F07DE9ED1BD0F31500BAA1AD /* image.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = image.c; sourceTree = ""; }; F07DE9F11BD0F31500BAA1AD /* mesh.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mesh.c; sourceTree = ""; }; F07DE9F21BD0F31500BAA1AD /* model3d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = model3d.c; sourceTree = ""; }; F07DE9F31BD0F31500BAA1AD /* palette.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = palette.c; sourceTree = ""; }; F07DE9F61BD0F31500BAA1AD /* render.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = render.c; sourceTree = ""; }; F07DE9F81BD0F31500BAA1AD /* shape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = shape.c; sourceTree = ""; }; F07DE9F91BD0F31500BAA1AD /* system.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = system.c; sourceTree = ""; }; F07DE9FB1BD0F31500BAA1AD /* tools.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tools.c; sourceTree = ""; }; F07DE9FC1BD0F31500BAA1AD /* utils.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = utils.c; sourceTree = ""; }; F07DEA221BD0F33A00BAA1AD /* stb_image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stb_image.h; sourceTree = ""; }; F07DEA231BD0F33A00BAA1AD /* stb_image_write.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stb_image_write.h; sourceTree = ""; }; F07DEA241BD0F33A00BAA1AD /* stb_rect_pack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stb_rect_pack.h; sourceTree = ""; }; F07DEA251BD0F33A00BAA1AD /* stb_textedit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stb_textedit.h; sourceTree = ""; }; F07DEA261BD0F33A00BAA1AD /* stb_truetype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stb_truetype.h; sourceTree = ""; }; F07DEA281BD0F33A00BAA1AD /* utarray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utarray.h; sourceTree = ""; }; F07DEA291BD0F33A00BAA1AD /* uthash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uthash.h; sourceTree = ""; }; F07DEA2A1BD0F33A00BAA1AD /* utlist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utlist.h; sourceTree = ""; }; F07DEA2E1BD0F3D000BAA1AD /* goxel.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = goxel.pch; sourceTree = ""; }; F07DEA2F1BD0FB5F00BAA1AD /* goxel-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "goxel-Bridging-Header.h"; sourceTree = ""; }; F07DEA321BD1014800BAA1AD /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; F09482FD22994752005DE2C5 /* layer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = layer.c; sourceTree = ""; }; F09482FF22994765005DE2C5 /* material.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = material.c; sourceTree = ""; }; F097B3F11F0C97DB00A3622B /* gesture.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gesture.c; sourceTree = ""; }; F097B3F21F0C97DB00A3622B /* gesture3d.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gesture3d.c; sourceTree = ""; }; F09FFC5621CE161400B6976A /* box_edit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = box_edit.c; sourceTree = ""; }; F0A15FF31E962F1300C6EF33 /* png.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = png.c; sourceTree = ""; }; F0A15FF41E962F1300C6EF33 /* povray.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = povray.c; sourceTree = ""; }; F0A15FF51E962F1300C6EF33 /* qubicle.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = qubicle.c; sourceTree = ""; }; F0A15FF71E962F1300C6EF33 /* txt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = txt.c; sourceTree = ""; }; F0A15FF81E962F1300C6EF33 /* vox.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vox.c; sourceTree = ""; }; F0A15FF91E962F1300C6EF33 /* voxlap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = voxlap.c; sourceTree = ""; }; F0A15FFA1E962F1300C6EF33 /* vxl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vxl.c; sourceTree = ""; }; F0A15FFB1E962F1300C6EF33 /* wavefront.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = wavefront.c; sourceTree = ""; }; F0A160061E962F4600C6EF33 /* marchingcube.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = marchingcube.c; sourceTree = ""; }; F0ACA2A02271ACD300376C82 /* gltf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gltf.c; sourceTree = ""; }; F0ACA2A22271ACEA00376C82 /* json.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = json.h; sourceTree = ""; }; F0ACA2A32271ACEA00376C82 /* json.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = json.c; sourceTree = ""; }; F0ACA2A6227BF2A300376C82 /* shader_cache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shader_cache.h; sourceTree = ""; }; F0ACA2A7227BF2A300376C82 /* shader_cache.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = shader_cache.c; sourceTree = ""; }; F0AE90F51C8EE01200C29080 /* assets.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = assets.c; sourceTree = ""; }; F0BC9B352315550500B2A56A /* app.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = app.c; sourceTree = ""; }; F0C37C8B2317CBDE000EF45F /* xxhash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xxhash.c; sourceTree = ""; }; F0C37C8E2317CBF2000EF45F /* xxhash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xxhash.h; sourceTree = ""; }; F0C5368A1F42EE43003A0DCA /* extrude.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = extrude.c; sourceTree = ""; }; F0DC02A022EEE267007E2F17 /* line.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = line.c; sourceTree = ""; }; F0DC02A222EEE274007E2F17 /* box.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = box.c; sourceTree = ""; }; F0DE970E1E6FE8BF000354AF /* noc_file_dialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = noc_file_dialog.h; sourceTree = ""; }; F0DE970F1E6FEA1F000354AF /* dialogs_osx.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = dialogs_osx.m; sourceTree = ""; }; F0E5DB2624FBB0D600010FDD /* file_format.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = file_format.c; sourceTree = ""; }; F0E5DB2724FBB0D600010FDD /* file_format.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = file_format.h; sourceTree = ""; }; F0E71BAB1F1DA30D00D20C7C /* theme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = theme.c; sourceTree = ""; }; F0EC57FE22CB268B009A42A2 /* fuzzy_select.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fuzzy_select.c; sourceTree = ""; }; F0ED3C611F98B03200FB50DE /* mesh_utils.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mesh_utils.c; sourceTree = ""; }; F0ED3C621F98B03200FB50DE /* mesh_to_vertices.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mesh_to_vertices.c; sourceTree = ""; }; F0ED3C631F98B03300FB50DE /* mesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mesh.h; sourceTree = ""; }; F0EEB7E31C8EC27C004AB676 /* action.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = action.c; sourceTree = ""; }; F0EEB7E71C8EC4D1004AB676 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; F0F14C6620AF282E0006E575 /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = imgui.cpp; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ F07DE9CC1BD0F03900BAA1AD /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( F0EEB7E81C8EC4D1004AB676 /* libz.tbd in Frameworks */, F07DEA331BD1014800BAA1AD /* CoreFoundation.framework in Frameworks */, F07DE9E01BD0F16300BAA1AD /* OpenGL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ F00FC2F8226B2F7B0002F251 /* utils */ = { isa = PBXGroup; children = ( F0DC02A222EEE274007E2F17 /* box.c */, F0ACA2A32271ACEA00376C82 /* json.c */, F0ACA2A22271ACEA00376C82 /* json.h */, F00FC2F9226B2F7B0002F251 /* sound.h */, F00FC2FA226B2F7B0002F251 /* box.h */, F00FC2FB226B2F7B0002F251 /* mustache.h */, F00FC2FC226B2F7B0002F251 /* ini.c */, F00FC2FD226B2F7B0002F251 /* gl.c */, F00FC2FE226B2F7B0002F251 /* sound_openal.inl */, F00FC2FF226B2F7B0002F251 /* vec.h */, F00FC301226B2F7B0002F251 /* texture.c */, F00FC302226B2F7B0002F251 /* cache.h */, F00FC303226B2F7B0002F251 /* b64.h */, F00FC304226B2F7B0002F251 /* color.h */, F00FC305226B2F7B0002F251 /* plane.h */, F00FC306226B2F7B0002F251 /* img.h */, F00FC307226B2F7B0002F251 /* ini.h */, F00FC308226B2F7B0002F251 /* mustache.c */, F00FC309226B2F7B0002F251 /* sound.c */, F00FC30A226B2F7B0002F251 /* vec.c */, F00FC30B226B2F7B0002F251 /* gl.h */, F00FC30C226B2F7B0002F251 /* texture.h */, F00FC30D226B2F7B0002F251 /* b64.c */, F00FC30E226B2F7B0002F251 /* cache.c */, F00FC310226B2F7B0002F251 /* img.c */, F00FC311226B2F7B0002F251 /* color.c */, ); path = utils; sourceTree = ""; }; F00FC31E226B2FCF0002F251 /* gui */ = { isa = PBXGroup; children = ( F0BC9B352315550500B2A56A /* app.c */, F076EA352284162400B74F0C /* light_panel.c */, F00FC31F226B2FCF0002F251 /* cameras_panel.c */, F00FC320226B2FCF0002F251 /* material_panel.c */, F00FC321226B2FCF0002F251 /* palette_panel.c */, F00FC322226B2FCF0002F251 /* menu.c */, F00FC323226B2FCF0002F251 /* layers_panel.c */, F00FC324226B2FCF0002F251 /* about.c */, F00FC325226B2FCF0002F251 /* settings.c */, F00FC326226B2FCF0002F251 /* render_panel.c */, F00FC327226B2FCF0002F251 /* topbar.c */, F00FC328226B2FCF0002F251 /* debug_panel.c */, F00FC329226B2FCF0002F251 /* view_panel.c */, F00FC32A226B2FCF0002F251 /* image_panel.c */, F00FC32B226B2FCF0002F251 /* export_panel.c */, F00FC32C226B2FCF0002F251 /* tools_panel.c */, ); path = gui; sourceTree = ""; }; F037D5C61EA6069A00C96D10 /* tools */ = { isa = PBXGroup; children = ( F0DC02A022EEE267007E2F17 /* line.c */, F0EC57FE22CB268B009A42A2 /* fuzzy_select.c */, F0C5368A1F42EE43003A0DCA /* extrude.c */, F037D5C71EA6069A00C96D10 /* brush.c */, F037D5C81EA6069A00C96D10 /* color_picker.c */, F037D5C91EA6069A00C96D10 /* laser.c */, F037D5CA1EA6069A00C96D10 /* move.c */, F037D5CB1EA6069A00C96D10 /* plane.c */, F037D5CD1EA6069A00C96D10 /* selection.c */, F037D5CE1EA6069A00C96D10 /* shape.c */, ); path = tools; sourceTree = ""; }; F07DE9C61BD0F03900BAA1AD = { isa = PBXGroup; children = ( F0EEB7E71C8EC4D1004AB676 /* libz.tbd */, F07DEA321BD1014800BAA1AD /* CoreFoundation.framework */, F07DE9DF1BD0F16300BAA1AD /* OpenGL.framework */, F07DE9D11BD0F03900BAA1AD /* goxel */, F07DE9D01BD0F03900BAA1AD /* Products */, ); sourceTree = ""; }; F07DE9D01BD0F03900BAA1AD /* Products */ = { isa = PBXGroup; children = ( F07DE9CF1BD0F03900BAA1AD /* goxel.app */, ); name = Products; sourceTree = ""; }; F07DE9D11BD0F03900BAA1AD /* goxel */ = { isa = PBXGroup; children = ( F07DEA151BD0F33A00BAA1AD /* ext_src */, F07DE9E31BD0F31500BAA1AD /* src */, F07DE9D21BD0F03900BAA1AD /* AppDelegate.swift */, F07DE9D41BD0F03900BAA1AD /* Assets.xcassets */, F07DE9D61BD0F03900BAA1AD /* MainMenu.xib */, F07DE9D91BD0F03900BAA1AD /* Info.plist */, F07DEA2E1BD0F3D000BAA1AD /* goxel.pch */, F07DEA2F1BD0FB5F00BAA1AD /* goxel-Bridging-Header.h */, ); path = goxel; sourceTree = ""; }; F07DE9E31BD0F31500BAA1AD /* src */ = { isa = PBXGroup; children = ( F05E2DD8268F451D00E47D33 /* quit.c */, F0E5DB2624FBB0D600010FDD /* file_format.c */, F0E5DB2724FBB0D600010FDD /* file_format.h */, F0C37C8B2317CBDE000EF45F /* xxhash.c */, F09482FF22994765005DE2C5 /* material.c */, F09482FD22994752005DE2C5 /* layer.c */, F0ACA2A7227BF2A300376C82 /* shader_cache.c */, F0ACA2A6227BF2A300376C82 /* shader_cache.h */, F00FC31E226B2FCF0002F251 /* gui */, F00FC2F8226B2F7B0002F251 /* utils */, F03B4385224CCDDF00798CAB /* pathtracer.cpp */, F03B4386224CCDDF00798CAB /* yocto.cpp */, F09FFC5621CE161400B6976A /* box_edit.c */, F0F14C6620AF282E0006E575 /* imgui.cpp */, F0ED3C621F98B03200FB50DE /* mesh_to_vertices.c */, F0ED3C611F98B03200FB50DE /* mesh_utils.c */, F0ED3C631F98B03300FB50DE /* mesh.h */, F0E71BAB1F1DA30D00D20C7C /* theme.c */, F097B3F11F0C97DB00A3622B /* gesture.c */, F097B3F21F0C97DB00A3622B /* gesture3d.c */, F037D5C61EA6069A00C96D10 /* tools */, F0A160061E962F4600C6EF33 /* marchingcube.c */, F0A15FF11E962F1300C6EF33 /* formats */, F0DE970F1E6FEA1F000354AF /* dialogs_osx.m */, F06C68391D2EAECC00887FCE /* camera.c */, F06C683A1D2EAECC00887FCE /* quantization.c */, F0AE90F51C8EE01200C29080 /* assets.c */, F0EEB7E31C8EC27C004AB676 /* action.c */, F07DE9EA1BD0F31500BAA1AD /* goxel.c */, F07DE9EB1BD0F31500BAA1AD /* goxel.h */, F07DE9EC1BD0F31500BAA1AD /* gui.cpp */, F07DE9ED1BD0F31500BAA1AD /* image.c */, F07DE9F11BD0F31500BAA1AD /* mesh.c */, F07DE9F21BD0F31500BAA1AD /* model3d.c */, F07DE9F31BD0F31500BAA1AD /* palette.c */, F07DE9F61BD0F31500BAA1AD /* render.c */, F07DE9F81BD0F31500BAA1AD /* shape.c */, F07DE9F91BD0F31500BAA1AD /* system.c */, F07DE9FB1BD0F31500BAA1AD /* tools.c */, F07DE9FC1BD0F31500BAA1AD /* utils.c */, ); name = src; path = ../../../src; sourceTree = ""; }; F07DEA151BD0F33A00BAA1AD /* ext_src */ = { isa = PBXGroup; children = ( F0C37C8D2317CBF2000EF45F /* xxhash */, F0DE970D1E6FE8BF000354AF /* noc */, F07DEA211BD0F33A00BAA1AD /* stb */, F07DEA271BD0F33A00BAA1AD /* uthash */, ); name = ext_src; path = ../../../ext_src; sourceTree = ""; }; F07DEA211BD0F33A00BAA1AD /* stb */ = { isa = PBXGroup; children = ( F07DEA221BD0F33A00BAA1AD /* stb_image.h */, F07DEA231BD0F33A00BAA1AD /* stb_image_write.h */, F07DEA241BD0F33A00BAA1AD /* stb_rect_pack.h */, F07DEA251BD0F33A00BAA1AD /* stb_textedit.h */, F07DEA261BD0F33A00BAA1AD /* stb_truetype.h */, ); path = stb; sourceTree = ""; }; F07DEA271BD0F33A00BAA1AD /* uthash */ = { isa = PBXGroup; children = ( F07DEA281BD0F33A00BAA1AD /* utarray.h */, F07DEA291BD0F33A00BAA1AD /* uthash.h */, F07DEA2A1BD0F33A00BAA1AD /* utlist.h */, ); path = uthash; sourceTree = ""; }; F0A15FF11E962F1300C6EF33 /* formats */ = { isa = PBXGroup; children = ( F0ACA2A02271ACD300376C82 /* gltf.c */, F025C7DA1F33239000C52709 /* png_slices.c */, F037D5C21EA6061F00C96D10 /* gox.c */, F0A15FF31E962F1300C6EF33 /* png.c */, F0A15FF41E962F1300C6EF33 /* povray.c */, F0A15FF51E962F1300C6EF33 /* qubicle.c */, F0A15FF71E962F1300C6EF33 /* txt.c */, F0A15FF81E962F1300C6EF33 /* vox.c */, F0A15FF91E962F1300C6EF33 /* voxlap.c */, F0A15FFA1E962F1300C6EF33 /* vxl.c */, F0A15FFB1E962F1300C6EF33 /* wavefront.c */, ); path = formats; sourceTree = ""; }; F0C37C8D2317CBF2000EF45F /* xxhash */ = { isa = PBXGroup; children = ( F0C37C8E2317CBF2000EF45F /* xxhash.h */, ); path = xxhash; sourceTree = ""; }; F0DE970D1E6FE8BF000354AF /* noc */ = { isa = PBXGroup; children = ( F0DE970E1E6FE8BF000354AF /* noc_file_dialog.h */, ); path = noc; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ F07DE9CE1BD0F03900BAA1AD /* goxel */ = { isa = PBXNativeTarget; buildConfigurationList = F07DE9DC1BD0F03900BAA1AD /* Build configuration list for PBXNativeTarget "goxel" */; buildPhases = ( F07DE9CB1BD0F03900BAA1AD /* Sources */, F07DE9CC1BD0F03900BAA1AD /* Frameworks */, F07DE9CD1BD0F03900BAA1AD /* Resources */, ); buildRules = ( ); dependencies = ( ); name = goxel; productName = goxel; productReference = F07DE9CF1BD0F03900BAA1AD /* goxel.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ F07DE9C71BD0F03900BAA1AD /* Project object */ = { isa = PBXProject; attributes = { LastUpgradeCheck = 1010; ORGANIZATIONNAME = "Noctua Software Limited"; TargetAttributes = { F07DE9CE1BD0F03900BAA1AD = { CreatedOnToolsVersion = 7.0.1; DevelopmentTeam = VH4XTANA7R; LastSwiftMigration = 1010; }; }; }; buildConfigurationList = F07DE9CA1BD0F03900BAA1AD /* Build configuration list for PBXProject "goxel" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( English, en, Base, ); mainGroup = F07DE9C61BD0F03900BAA1AD; productRefGroup = F07DE9D01BD0F03900BAA1AD /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( F07DE9CE1BD0F03900BAA1AD /* goxel */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ F07DE9CD1BD0F03900BAA1AD /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( F00FC314226B2F7C0002F251 /* sound_openal.inl in Resources */, F07DE9D51BD0F03900BAA1AD /* Assets.xcassets in Resources */, F07DE9D81BD0F03900BAA1AD /* MainMenu.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ F07DE9CB1BD0F03900BAA1AD /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( F025C7DB1F33239000C52709 /* png_slices.c in Sources */, F037D5D31EA6069A00C96D10 /* plane.c in Sources */, F0C5368B1F42EE43003A0DCA /* extrude.c in Sources */, F037D5CF1EA6069A00C96D10 /* brush.c in Sources */, F00FC32E226B2FCF0002F251 /* material_panel.c in Sources */, F00FC339226B2FCF0002F251 /* export_panel.c in Sources */, F00FC333226B2FCF0002F251 /* settings.c in Sources */, F0A160041E962F1300C6EF33 /* vxl.c in Sources */, F00FC31C226B2F7C0002F251 /* img.c in Sources */, F094830022994765005DE2C5 /* material.c in Sources */, F00FC319226B2F7C0002F251 /* b64.c in Sources */, F0C37C8C2317CBDE000EF45F /* xxhash.c in Sources */, F00FC332226B2FCF0002F251 /* about.c in Sources */, F0ACA2A42271ACEA00376C82 /* json.c in Sources */, F05E2DD9268F451D00E47D33 /* quit.c in Sources */, F0A160031E962F1300C6EF33 /* voxlap.c in Sources */, F07DEA101BD0F31500BAA1AD /* system.c in Sources */, F09482FE22994752005DE2C5 /* layer.c in Sources */, F07DEA061BD0F31500BAA1AD /* image.c in Sources */, F00FC32F226B2FCF0002F251 /* palette_panel.c in Sources */, F06C683C1D2EAECC00887FCE /* camera.c in Sources */, F09FFC5721CE161400B6976A /* box_edit.c in Sources */, F00FC330226B2FCF0002F251 /* menu.c in Sources */, F037D5D11EA6069A00C96D10 /* laser.c in Sources */, F00FC318226B2F7C0002F251 /* vec.c in Sources */, F0BC9B362315550500B2A56A /* app.c in Sources */, F0A160081E962F4600C6EF33 /* marchingcube.c in Sources */, F00FC312226B2F7C0002F251 /* ini.c in Sources */, F0EEB7E41C8EC27C004AB676 /* action.c in Sources */, F037D5D61EA6069A00C96D10 /* shape.c in Sources */, F03B4387224CCDDF00798CAB /* pathtracer.cpp in Sources */, F00FC334226B2FCF0002F251 /* render_panel.c in Sources */, F07DEA0A1BD0F31500BAA1AD /* model3d.c in Sources */, F00FC315226B2F7C0002F251 /* texture.c in Sources */, F0A160051E962F1300C6EF33 /* wavefront.c in Sources */, F00FC338226B2FCF0002F251 /* image_panel.c in Sources */, F00FC316226B2F7C0002F251 /* mustache.c in Sources */, F00FC335226B2FCF0002F251 /* topbar.c in Sources */, F00FC32D226B2FCF0002F251 /* cameras_panel.c in Sources */, F07DEA0F1BD0F31500BAA1AD /* shape.c in Sources */, F0A160011E962F1300C6EF33 /* txt.c in Sources */, F07DEA091BD0F31500BAA1AD /* mesh.c in Sources */, F076EA362284162400B74F0C /* light_panel.c in Sources */, F0AE90F71C8EE01300C29080 /* assets.c in Sources */, F00FC331226B2FCF0002F251 /* layers_panel.c in Sources */, F00FC33A226B2FCF0002F251 /* tools_panel.c in Sources */, F0A15FFD1E962F1300C6EF33 /* png.c in Sources */, F037D5D01EA6069A00C96D10 /* color_picker.c in Sources */, F0E71BAC1F1DA30D00D20C7C /* theme.c in Sources */, F0DC02A322EEE274007E2F17 /* box.c in Sources */, F07DE9D31BD0F03900BAA1AD /* AppDelegate.swift in Sources */, F00FC313226B2F7C0002F251 /* gl.c in Sources */, F00FC31D226B2F7C0002F251 /* color.c in Sources */, F0DE97101E6FEA1F000354AF /* dialogs_osx.m in Sources */, F0A160021E962F1300C6EF33 /* vox.c in Sources */, F07DEA121BD0F31500BAA1AD /* tools.c in Sources */, F0ED3C641F98B03300FB50DE /* mesh_utils.c in Sources */, F0ED3C651F98B03300FB50DE /* mesh_to_vertices.c in Sources */, F03B4388224CCDDF00798CAB /* yocto.cpp in Sources */, F00FC317226B2F7C0002F251 /* sound.c in Sources */, F00FC31A226B2F7C0002F251 /* cache.c in Sources */, F037D5D51EA6069A00C96D10 /* selection.c in Sources */, F0ACA2A12271ACD400376C82 /* gltf.c in Sources */, F097B3F41F0C97DB00A3622B /* gesture3d.c in Sources */, F0EC57FF22CB268C009A42A2 /* fuzzy_select.c in Sources */, F097B3F31F0C97DB00A3622B /* gesture.c in Sources */, F0DC02A122EEE267007E2F17 /* line.c in Sources */, F00FC337226B2FCF0002F251 /* view_panel.c in Sources */, F07DEA0B1BD0F31500BAA1AD /* palette.c in Sources */, F07DEA131BD0F31500BAA1AD /* utils.c in Sources */, F07DEA041BD0F31500BAA1AD /* goxel.c in Sources */, F0A15FFF1E962F1300C6EF33 /* qubicle.c in Sources */, F0ACA2A8227BF2A300376C82 /* shader_cache.c in Sources */, F037D5D21EA6069A00C96D10 /* move.c in Sources */, F06C683D1D2EAECC00887FCE /* quantization.c in Sources */, F00FC336226B2FCF0002F251 /* debug_panel.c in Sources */, F07DEA051BD0F31500BAA1AD /* gui.cpp in Sources */, F0F14C6720AF282E0006E575 /* imgui.cpp in Sources */, F0E5DB2824FBB0D600010FDD /* file_format.c in Sources */, F07DEA0D1BD0F31500BAA1AD /* render.c in Sources */, F037D5C31EA6061F00C96D10 /* gox.c in Sources */, F0A15FFE1E962F1300C6EF33 /* povray.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ F07DE9D61BD0F03900BAA1AD /* MainMenu.xib */ = { isa = PBXVariantGroup; children = ( F07DE9D71BD0F03900BAA1AD /* Base */, ); name = MainMenu.xib; sourceTree = ""; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ F07DE9DA1BD0F03900BAA1AD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "c++17"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "-"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; name = Debug; }; F07DE9DB1BD0F03900BAA1AD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "c++17"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "-"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; F07DE9DD1BD0F03900BAA1AD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "$(SRCROOT)/goxel/goxel.pch"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src"; INFOPLIST_FILE = goxel/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; PRODUCT_BUNDLE_IDENTIFIER = com.noctuasoftware.goxel; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/goxel/goxel-Bridging-Header.h"; SWIFT_SWIFT3_OBJC_INFERENCE = On; SWIFT_VERSION = 4.2; }; name = Debug; }; F07DE9DE1BD0F03900BAA1AD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "$(SRCROOT)/goxel/goxel.pch"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src"; INFOPLIST_FILE = goxel/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; PRODUCT_BUNDLE_IDENTIFIER = com.noctuasoftware.goxel; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/goxel/goxel-Bridging-Header.h"; SWIFT_SWIFT3_OBJC_INFERENCE = On; SWIFT_VERSION = 4.2; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ F07DE9CA1BD0F03900BAA1AD /* Build configuration list for PBXProject "goxel" */ = { isa = XCConfigurationList; buildConfigurations = ( F07DE9DA1BD0F03900BAA1AD /* Debug */, F07DE9DB1BD0F03900BAA1AD /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; F07DE9DC1BD0F03900BAA1AD /* Build configuration list for PBXNativeTarget "goxel" */ = { isa = XCConfigurationList; buildConfigurations = ( F07DE9DD1BD0F03900BAA1AD /* Debug */, F07DE9DE1BD0F03900BAA1AD /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = F07DE9C71BD0F03900BAA1AD /* Project object */; } goxel-0.11.0/osx/goxel/goxel.xcodeproj/project.xcworkspace/000077500000000000000000000000001435762723100237605ustar00rootroot00000000000000goxel-0.11.0/osx/goxel/goxel.xcodeproj/project.xcworkspace/contents.xcworkspacedata000066400000000000000000000002261435762723100307220ustar00rootroot00000000000000 goxel-0.11.0/osx/goxel/goxel/000077500000000000000000000000001435762723100157665ustar00rootroot00000000000000goxel-0.11.0/osx/goxel/goxel/AppDelegate.swift000066400000000000000000000270051435762723100212230ustar00rootroot00000000000000// // AppDelegate.swift // goxel // // Created by Guillaume Chereau on 10/16/15. // Copyright © 2015 Noctua Software Limited. All rights reserved. // import Cocoa import OpenGL import GLKit import AppKit import Foundation import Carbon.HIToolbox // Set as the main application in the plist. // Used so that we get key up event event with the command key pressed. @objc(GoxNSApplication) class GoxNSApplication: NSApplication { override func sendEvent(_ event: NSEvent) { if (event.type == .keyUp && event.modifierFlags.contains(.command)) { self.keyWindow?.sendEvent(event) } else { super.sendEvent(event) } } } class GoxNSOpenGLView: NSOpenGLView, NSWindowDelegate { override func awakeFromNib() { let attr = [ NSOpenGLPixelFormatAttribute(NSOpenGLPFAOpenGLProfile), NSOpenGLPixelFormatAttribute(NSOpenGLProfileVersionLegacy), NSOpenGLPixelFormatAttribute(NSOpenGLPFAColorSize), 24, NSOpenGLPixelFormatAttribute(NSOpenGLPFAAlphaSize), 8, NSOpenGLPixelFormatAttribute(NSOpenGLPFADoubleBuffer), NSOpenGLPixelFormatAttribute(NSOpenGLPFADepthSize), 32, NSOpenGLPixelFormatAttribute(NSOpenGLPFAStencilSize), 8, 0 ] self.wantsBestResolutionOpenGLSurface = true let format = NSOpenGLPixelFormat(attributes: attr) let context = NSOpenGLContext(format: format!, share: nil) self.openGLContext = context self.openGLContext?.makeCurrentContext() self.window?.acceptsMouseMovedEvents = true self.window?.delegate = self } func appDelegate () -> AppDelegate { return NSApplication.shared.delegate as! AppDelegate } override var acceptsFirstResponder: Bool { return true } func mouseEvent(_ id: Int, _ state: Int, _ event: NSEvent) { appDelegate().inputs.touches.0.pos.0 = Float(event.locationInWindow.x); appDelegate().inputs.touches.0.pos.1 = Float(self.frame.height - event.locationInWindow.y); // XXX: find a way to make it work with unsage memory. switch (id) { case 0: appDelegate().inputs.touches.0.down.0 = (state != 0); case 1: appDelegate().inputs.touches.0.down.1 = (state != 0); case 2: appDelegate().inputs.touches.0.down.2 = (state != 0); default: break; } // Force an update after a mousedown event to make sure that it will // be recognised even if we release the mouse immediately. if state == 1 { goxel_iter(&appDelegate().inputs) } } override func mouseDown(with event: NSEvent) { mouseEvent(0, 1, event) } override func mouseUp(with event: NSEvent) { mouseEvent(0, 0, event) } override func mouseDragged(with event: NSEvent) { mouseEvent(0, 2, event) } override func mouseMoved(with event: NSEvent) { mouseEvent(0, 0, event) } override func rightMouseDown(with event: NSEvent) { mouseEvent(2, 1, event) } override func rightMouseUp(with event: NSEvent) { mouseEvent(2, 0, event) } override func rightMouseDragged(with event: NSEvent) { mouseEvent(2, 1, event) } override func otherMouseDown(with event: NSEvent) { mouseEvent(1, 1, event) } override func otherMouseUp(with event: NSEvent) { mouseEvent(1, 0, event) } override func otherMouseDragged(with event: NSEvent) { mouseEvent(1, 1, event) } override func scrollWheel(with event: NSEvent) { var delta = Float(event.scrollingDeltaY) if event.hasPreciseScrollingDeltas { delta /= 8.0; } appDelegate().inputs.mouse_wheel = delta } override func keyDown(with event: NSEvent) { switch (event.keyCode) { case 36: appDelegate().inputs.keys.257 = true case 49: appDelegate().inputs.keys.32 = true case 51: appDelegate().inputs.keys.259 = true case 123: appDelegate().inputs.keys.263 = true case 124: appDelegate().inputs.keys.262 = true case 125: appDelegate().inputs.keys.264 = true case 126: appDelegate().inputs.keys.265 = true case UInt16(kVK_ANSI_A): appDelegate().inputs.keys.65 = true case UInt16(kVK_ANSI_B): appDelegate().inputs.keys.66 = true case UInt16(kVK_ANSI_C): appDelegate().inputs.keys.67 = true case UInt16(kVK_ANSI_D): appDelegate().inputs.keys.68 = true case UInt16(kVK_ANSI_E): appDelegate().inputs.keys.69 = true case UInt16(kVK_ANSI_F): appDelegate().inputs.keys.70 = true case UInt16(kVK_ANSI_G): appDelegate().inputs.keys.72 = true case UInt16(kVK_ANSI_H): appDelegate().inputs.keys.72 = true case UInt16(kVK_ANSI_I): appDelegate().inputs.keys.73 = true case UInt16(kVK_ANSI_J): appDelegate().inputs.keys.74 = true case UInt16(kVK_ANSI_K): appDelegate().inputs.keys.75 = true case UInt16(kVK_ANSI_L): appDelegate().inputs.keys.76 = true case UInt16(kVK_ANSI_M): appDelegate().inputs.keys.77 = true case UInt16(kVK_ANSI_N): appDelegate().inputs.keys.78 = true case UInt16(kVK_ANSI_O): appDelegate().inputs.keys.79 = true case UInt16(kVK_ANSI_P): appDelegate().inputs.keys.80 = true case UInt16(kVK_ANSI_Q): appDelegate().inputs.keys.81 = true case UInt16(kVK_ANSI_R): appDelegate().inputs.keys.82 = true case UInt16(kVK_ANSI_S): appDelegate().inputs.keys.83 = true case UInt16(kVK_ANSI_T): appDelegate().inputs.keys.84 = true case UInt16(kVK_ANSI_U): appDelegate().inputs.keys.85 = true case UInt16(kVK_ANSI_V): appDelegate().inputs.keys.86 = true case UInt16(kVK_ANSI_W): appDelegate().inputs.keys.87 = true case UInt16(kVK_ANSI_X): appDelegate().inputs.keys.88 = true case UInt16(kVK_ANSI_Y): appDelegate().inputs.keys.89 = true case UInt16(kVK_ANSI_Z): appDelegate().inputs.keys.90 = true default: break } let scalars = event.characters!.unicodeScalars let c = scalars[scalars.startIndex].value if (c < 256) { appDelegate().inputs.chars.0 = c } } override func keyUp(with event: NSEvent) { switch (event.keyCode) { case 36: appDelegate().inputs.keys.257 = false case 49: appDelegate().inputs.keys.32 = false case 51: appDelegate().inputs.keys.259 = false case 123: appDelegate().inputs.keys.263 = false case 124: appDelegate().inputs.keys.262 = false case 125: appDelegate().inputs.keys.264 = false case 126: appDelegate().inputs.keys.265 = false case UInt16(kVK_ANSI_A): appDelegate().inputs.keys.65 = false case UInt16(kVK_ANSI_B): appDelegate().inputs.keys.66 = false case UInt16(kVK_ANSI_C): appDelegate().inputs.keys.67 = false case UInt16(kVK_ANSI_D): appDelegate().inputs.keys.68 = false case UInt16(kVK_ANSI_E): appDelegate().inputs.keys.69 = false case UInt16(kVK_ANSI_F): appDelegate().inputs.keys.70 = false case UInt16(kVK_ANSI_G): appDelegate().inputs.keys.72 = false case UInt16(kVK_ANSI_H): appDelegate().inputs.keys.72 = false case UInt16(kVK_ANSI_I): appDelegate().inputs.keys.73 = false case UInt16(kVK_ANSI_J): appDelegate().inputs.keys.74 = false case UInt16(kVK_ANSI_K): appDelegate().inputs.keys.75 = false case UInt16(kVK_ANSI_L): appDelegate().inputs.keys.76 = false case UInt16(kVK_ANSI_M): appDelegate().inputs.keys.77 = false case UInt16(kVK_ANSI_N): appDelegate().inputs.keys.78 = false case UInt16(kVK_ANSI_O): appDelegate().inputs.keys.79 = false case UInt16(kVK_ANSI_P): appDelegate().inputs.keys.80 = false case UInt16(kVK_ANSI_Q): appDelegate().inputs.keys.81 = false case UInt16(kVK_ANSI_R): appDelegate().inputs.keys.82 = false case UInt16(kVK_ANSI_S): appDelegate().inputs.keys.83 = false case UInt16(kVK_ANSI_T): appDelegate().inputs.keys.84 = false case UInt16(kVK_ANSI_U): appDelegate().inputs.keys.85 = false case UInt16(kVK_ANSI_V): appDelegate().inputs.keys.86 = false case UInt16(kVK_ANSI_W): appDelegate().inputs.keys.87 = false case UInt16(kVK_ANSI_X): appDelegate().inputs.keys.88 = false case UInt16(kVK_ANSI_Y): appDelegate().inputs.keys.89 = false case UInt16(kVK_ANSI_Z): appDelegate().inputs.keys.90 = false default: break } } override func flagsChanged(with event: NSEvent) { appDelegate().inputs.keys.340 = event.modifierFlags.contains(.shift) appDelegate().inputs.keys.341 = event.modifierFlags.contains(.command) } func windowShouldClose(_ sender: NSWindow) -> Bool { gui_query_quit() return false } } @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak var window: NSWindow! @IBOutlet weak var view: GoxNSOpenGLView! fileprivate var timer: Timer! open var inputs = inputs_t() var userDirectory: [CChar]? = nil; func applicationDidFinishLaunching(_ aNotification: Notification) { // Set fullscreen. if let screen = NSScreen.main { window.setFrame(screen.visibleFrame, display: true, animate: true) } timer = Timer(timeInterval: 1.0 / 60.0, target: self, selector: #selector(AppDelegate.onTimer(_:)), userInfo: nil, repeats: true) RunLoop.current.add(timer, forMode: RunLoop.Mode.default) sys_callbacks.user = Unmanaged.passUnretained(self).toOpaque() sys_callbacks.set_window_title = { (user, title) in let mySelf = Unmanaged.fromOpaque(user!).takeUnretainedValue() let title = String(cString: title!) mySelf.window.title = title } sys_callbacks.get_user_dir = { (user) in let mySelf = Unmanaged.fromOpaque(user!).takeUnretainedValue() if mySelf.userDirectory == nil { let paths = NSSearchPathForDirectoriesInDomains( .applicationSupportDirectory, .userDomainMask, true) if paths.count > 0 { mySelf.userDirectory = (paths[0] + "/Goxel").cString(using: .utf8); } } return UnsafePointer(mySelf.userDirectory) } goxel_init() } func applicationWillTerminate(_ aNotification: Notification) { // Insert code here to tear down your application } func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { return true } @objc func onTimer(_ sender: Timer!) { var r : Int32 if (!window.isVisible) { return } glClear(GLbitfield(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) self.inputs.window_size = (Int32(self.view.frame.size.width), Int32(self.view.frame.size.height)) self.inputs.scale = Float(window.backingScaleFactor) r = goxel_iter(&self.inputs) goxel_render() self.inputs.mouse_wheel = 0 self.inputs.chars.0 = 0 glFlush() view.openGLContext?.flushBuffer() if r == 1 { NSApplication.shared.terminate(nil) } } } goxel-0.11.0/osx/goxel/goxel/Assets.xcassets/000077500000000000000000000000001435762723100210645ustar00rootroot00000000000000goxel-0.11.0/osx/goxel/goxel/Assets.xcassets/AppIcon.appiconset/000077500000000000000000000000001435762723100245615ustar00rootroot00000000000000goxel-0.11.0/osx/goxel/goxel/Assets.xcassets/AppIcon.appiconset/1024.png000066400000000000000000003560271435762723100256720ustar00rootroot00000000000000PNG  IHDR+IDATxdu'}97M92$P$ ()2S^]RrqRh.J{mpQ" X&jBM 6pGq뻛7X@DD4' ""b>מ_]SAR2* m aF7tԀؼ?bU`h eRBBX k l@G0Z ""# M4_T5 ZXa@ DDDS_o_?*)*h.1@DD4~߅i}Ь/ "" U ߼.d{aUc~W~og?m1]seuA(a R7zUDDDS"Z=>u<(;kWG\tͰl_ XO׷QE1@DTA/}˯8E>+l" .}|gC1 DDrϿ_ZS7zS @<]hf_47n~EK5YǜUDDDSgDDz ~NE/3Ylա[0Q 4=\W׮"Uª""R "9s/ܫ_Z~[x7!%}5D~_p5Lă?\?Z{x'̾V 2A&Y !fUTZ=g_ɳ/^A/?Kߪ55 r:Z0:lvk; /CwUqrρf{aUQuMߙ 8^{_ZӬ/o˾I0@g{@Vyx.!`?۪¤ZUDDD1gDDe{k'2p g}y{x54M]?֓q LaֿVUeUK'2Mڳ.Yk]@ -٪[o*}>{%3UDDD5gDDz /+>[Ozux?i55} 5|pMSY:W}̗UQX@DD4JwAD4F/}˯8*6}ڳ~iM R'S@ߩwm&= OgYQaULh\k'Ͻx17ڭY^⦁&?= 4 (A^k¯%|G cUѾlhοמ藺,f‚K'#iW׮.Y;#0 ""Jz Ͼŵg_L溗/fm6%D0"5`&_\4 dֿX@DD4 (&o2P&o4 ,t}Z6p{_QIO'V3">y˟ʺ j=F[ky-]l?XۼL4 ,f Vuij">/~/ʠ)k*)k7j*Ui n[4^xßqsYcUQVX=?uP2e{pui`W@y?Xۼ5ϽמdcU>ۯ8E^7nI0UMM~{O*b6 Rhf̅+WT 2f|㬿| %Yl6 LTi}\G%=Tm 6ηkh}[ T g/DD/<__;yn{cJZBJ~4Q͒bU¡B U:?KT g1DDd3sݙq53= jMTpC|_U``IaвԒUDD4x&CDsm}k'ϾxQxWϛo6 l_l%[t<,y |ﶮ@U[U\h*WsR2=nt|OE/T[4-?Xۼ6 _[WR5s?FUDD4 xCD3k^|Υ|+.i@ktazQ5w>J"00vFlY^X@DDUų^"9gG~}Ĺ/ 8|0/nM訁C4n}~Yy jD.5u_20 2K窀̄ V었fW>ڳ~5xSnҿo [o!lnpA}A}Ox$3~P'D#7~Z婢&L`U(L'~ofg8=>k?-谁k5 j +Pe`U'z-l2s{tt8 RpοZcU τh =/ R*YR~oaay 4waQka!T`eU}C#X>vJfqV Di*k%*@ yUDD_<&z Ͼŵg_(?/SϬ{͛oVGк&V#XX-#-BTBS Dacc~{ 1FĪ""TJɟM|j]ͿEkoF &.ZhlOm,@57ҏX:zoXI-Q{*`b)  ̘/KO~!'8oVt[ؼxoto)wp{ԗ]?c{dBfB X8Ï!/mqn`ULsֿVA2M>OE e R)_ƭ2ǹNY?Ek!_[$:CAAsn.PqU$skX<|7 4AhTxLDz /+nVsܥɬ ݟ&{ϊ&_ jAv{TfqsIU@} AP[,%5dѩxq*WǪ""jóe"W3?5m /Иw=L&g&>]5 : ,:F FcKŪ""Ϛo [L~kֿ{& }?.~c`aJwp{ [\5@8C'|ŶX0Yj7J "A̙*/\x/G~Tɟ_xY^(~ul߻f8 ۾`@@ (Vd>L@SRQ`ֿW4η%DTI?.;:jD 1 [?j`L/dLZn3pjzW0B0J/|40K+,`8 "N sYq ɶ{a_MUW d; lK\3~?n"`@" 39@Jd,t*4 ,6tAy6ύFUDDMsrMn/,/XPM{۝;d-^i@:Da @~@.h' [n/Empm{<'VM'_37/-c'oCc^?WT%>.nSi}{@:F- hKX o(0MY?Uk_*hF0@Dc_ד&*HK,>p{dusQktp _;x]=> d?U ! Ƞ 򊀴 bd ^[ۼ&D46'|«-B-q{u>@s~xџ+v6w<oHG 06JX`WD4~w_?e{-=4w j&\Ϛ,6V `T5 +2Ȍ7OfwU@ X@D4} u.s{㬿>j&-@sg#KӅAJ9> M# H[P%4V+o:*h0@D'k'~Ru~9~m4!nؿ^Y&ni_%Ƞw ]D #G:9 [jKR,Lz'T M'V͎ɟyyc{>kJ~wOK5hm;?@P \c⯋  [ 0UU[0J0*1JY"V3p"Jq_(UgG֣nk?j {W?ٿn_k $Htdb\+6 (A6= "N? '~~7\¿Yn'\Ya6{, reIz`_hI@*Ꙧdr@x|Ry'?_ ";'J9 S/]t?no"llA{~;'(7ݎ%ؾc>EȠV@TqMN(6 Ou \e@~r@ćdt {m 訉W~'__۾.h6ʉh">ki--ϚyЖ ln#llegJ3lҡ3IUM B7 M*HؾQ]E0a"13s":pǟ|G?]7Yne{@Z[aK()9g`@r_00: )o>I`@QL v7^- "?C'z~O?Y|sbVgQsas; <:J), ^&-G@*ߖTqL0H@f)K = 5]UDDf҉h('|«uҬ "Clfe{@׬n!jq ,.qVO , ~^@||Tdnd[@16=(ko&tzX@DtxND=}S/_TIn?Yny{@׬kQs'+dhl" NIBɱG ,T^hm*hxND=x=5m"ݲnCY&Yg@c {@I0L? mf\0@=Q4 ש "QOp=O\y4e?E!k\B!P[p]e% 2~e r#ʀqwL?Bpùm ̯~JŪ"ów"IAvᯐcߪ=kQc.]3Y\ *c2xRivȦ4-F/Q5Y/JUT+7?)d} d7a Y~2{W 0VUX+aC'1j!K%H7~ ='~h?o*LQhoޏkq![1+Vg2`@ (+nxrIe; lmaM-iȪr%`Uh ?[wB֟ qPAo70:BJ;g%MUֺ@XVUdˀ aLV7FF5@fםG R+KZ Y@D4>!n>kzOn{r{@Ϭk2MtZotX]OKKCV3#d'RЩWf"Wcr X@D?V͙Opz\Acֿ2TP +ý>LX w=Ɨ^=נ!JDaB X+F҉*ȸ"@E0: $o`U@M "ȫO>6ew1x{@i&o†e|38Kz4$WUHjȼ(d ure¡X\9 *XWhfGK"r<'ahOtQ{O][0&t\U?=M_ӥ@~+Y.m|} }fP_>EĀҪ? Bi/}r@5L4UDD Y}7^{sM)?/ϬLfk[w&r0o:W٘^]/ 0&72R I X+Z 0Ŋl@VôUDD 9q^ſ[,')" 5a¦ψäÿk3W4X G[PT@*Dr iⶀUWFf XQeJŪ"7 !}7^{sM_?G͢b`ꐲ!lnrL 0#ٲk}?{_R"bM+qBBHh*UH`qQq G hnl?VPUVьi 8 S/%LK]VK~r{ؾg6D@saWkIϦˤm\گ[rb-ч5䓪+ vA* ;B4FVh +N(rQh >+] ) /\Ԓf>ϗl/tVw3 x_nzm =ZhnP*d{UGf\_}m@"-L>e4UD4+X@4^}/]tA#%EguZC_0">]4J9 )6 V@YYaKi`%ӹ* dUMMOp޺ \[2ZfgOY8+%{hwWw@hn \f@*2t@}yuDe'M-~1X"F ~w_?Uم ͌?,;f3-E_^?v}#!*E@@H X>Y "`_` _oVDto5i?7S,Iݲ6]$Nod]`9 Lb٨(!Df+*TۜJ]h.2U , j`QE /dI/=e%Y9.u.ҭI #~@ a d$ P*X)!M4 | |fX?9UUDT)\9U j~ 7EsW` LJ*v\ɧ~W,dzg+d!_^ Vҳ¿KU(Sǖ h#8UWJX@T!iR|?Hb`2P?H_ n5-/i9I)a` |)NƪQՔW.hxAT_k}KkC`YGf0Yu}2iՊUX k;Tԗ)okDea*FP_B$OdI40~ %uOQ,>U4hX@4agg~g]w)$͖O9WqE Mu~rIpfJ X+)! l:U%,^ I"zS_~Ĺ/JUTe/>åf{;eMfig?Wq򩗠K#H8T$$ ϓ_sg0-C*_`a%6XocX?{6o/Y@DcWePK$*HO\ nD-Ƞ@7I{gBbH﷾Wq~)H=ƯIdl^jQ ?MZU:1405r\ 4P.P cǴ%%U %aU4tm:l@՗K|4~A"1Y=?uI4}nS*Ƞ@@T_*, 0T$V6 H )\N_%gd-"o"x0MY?ߞ@*BȨ,@`YBDa耭y³^T"K hTRq{@%OlrT!ihD"@A_P4-¬UƶDqt@kw%skT &j!ln+f/ |g_ҚRnH~;N2PP 8YFO$0YڿQ;@'AiMcMF٪]R` `* #5l2'}LӒlQcIGژ,)7ӡoW3?e$z JjiQ*e %Fs*;y$+`-vFG0oOxh0@4b_kϽ5?KMֿ 46+]lߌ+? ւZG3Qڨi`,C@URBVi8PMq`@KW15X@ [Z{[hlߛ1ahDV<WvMƐ&'0L?Y; jt?j(irc@7J0җkd*2%p/06ZZ{x F3XDDch^ԗ_?qE__dXā O 5KN'H].I@. !sMQ>@quD݉>^|FGn۶16vƍ="6 /YAR e5d00~?]yYtW]^CJ@ " Rd=QT-J:4u'&j1&D?ҧLOB"wU)?O.Du_G0ҦB] H+/Tm1n{'̢ncB [ϑUY| y˟z\/e W !*}1Dֿg e; {O@yC4v6 8 |tr@>F RՈ70:Dځ:4uJ*^o~܋Ar Bw`ZO'tgɩk"Aԥi`&0Plj} HW`@{@`T6 Y?O{FHvD+hp +W&qw> Yd_fn;~d}Ue]郛;ݛJҦ~At[zzs}Lac {` bȯ< ~qy 'j>۳YڟɾH/㬮5>({&YdfG Rtgt ac=쿆/KXv{76GBDPOK3r&O6f{PITKVh5{6?wi?e 5GɸbB&5 ih2$˪}ğZ6Ѱ:?=~5ܿ0h1@sO}_\/Zϩ-o Y43VMekqI]4V~87lLk-P% mԀL@F׈SR=]>ߤ|-ܽx8D4_Y+Oy/0PHUݲȔQ>K!/Q;]žI5 [l rVCGko6B@1׈j3nD4h.~/Rn_%|4$T>m'jmY3??#s[?]"?h2:ZRB $`u2F08}ğh>|#F=hx \Y=?u)U&|%a}fa}&Ύ|g椙OU`h@|?6⊣2fGιl j @8i`m'9k_@s>m t FU ?`4V<ُډs/^T!kʕCÓ4>Y?dUct =˛M/>~M^Q:j@.,&Q#Uܾ(ldYk +h?wϿ_ZSh?; 3l7 Wt$oMYu\U Pyv8=O}~J DnK@l>Q4 &6!T} Vi@bi?a<O+.i=GӴŷ5J' {+ j"j@j 2L. 0KM{ V3{v=_vLDcM3_x3kq?3#hOngƣ*y:o|8 {hv `u UQ[<aLi(A_>=FE]=LD[`@"4^_?qŋRϬOs O4u{w8zn҇BT~~o @5 #wj!%4 LIvzݼ m~FP@o"4V<~e=.2pd݂1i]*[˲: 0? l[> NV)\Te\8nM6hTxBԖq5(`n\׽?jQk7l!IJ8&"4u^o~܋YƁde qF*srfuHGn_5wƓq9eعE;'N>< [wMfk _gwӪ&[ ZԖt*8-q`=FE]n\}쿵xѰqϿ_ZSq?$ >!T:g3[fZ~H܍9Ǖb'4rw½?z77ç|1p->ʨrnZv{Apodұ\@l{uؾνtcE闥?A "a1@z ~Ns{P.+43$g?5~6?ؽDcn׹w'çp}G{^8x6 {H3S:l`/ U[ Q_>*̹k (|I5oUDXc~mxGuzhp MDDJ;_{/pA&gou cBX !IQfhfAƝ7q獡M\yO|43谑'~_ewi5|ԺՀns +PE`m30"j9p_o`$1Z+wNuMnu?.緆7"s P%y³~q/FtYW/3\ϜYϗBMfgwN6oau8mn ܽ78yE_?'gfLBYf@c.n}=^^,>G)N \َߴ]Z  damwr NJ40`Ɓq@8}2vfa2{mD Pey˟uH*i~3sW֯FLeBr3x/ع3ݺo!<#g/~$eߟf곣k =4"/aI%Xi2=SB~#ۺ d+ Xq|]nbd"_ P%/~\\_d~ϲ tW#r{2C1۹EO@v`^FM,9}!}q{}a!~;]l3w$nؤa!z#_|vMՖj!% @75c’ԞaL0\ƃ>\kܹ׾"0 O}?U81i)v7oCX>zCAM-ϙݍݼQgKWGM&0WW iDDA}CP%쿏nUSY}Las+5j`;m>W \k=G~ p>;Fv[CzË7:{HؤW@|=ͽ`~`R jII7n8ݶX@D#UR& k2p|nv{g `o{@ELۓ>yx _{#xܫCR' U~x%[-l=i'@Mn\΃+-- 9Z->ۿWT`O"o e$.PV*ƋA+KTuIUD˹?Lno-ooѳʱ'p _S |RYqfnSd/ Q[< t:Bkoo 5at$ Aa;YIV~7X?aDM1hව m/rcUG5s0M# }ESL{@n_pX9$;*{r҇DUq௃I4 >ݞ}cn p?mbUGm#X& 'zsvP"aWs݅ngLL+4 U=4Q.sj<7^jVdtko{:{ͫ%V>CGc>:#kmye~u.(v% [O節F`-VV!U&o XWPjE눒o}a҃3o#!!2,a-u!HJ kc[8?'gw:jrΖAT{۷pJwy;Wq7Wqy|̆I>Fs݊-|gc4 ;2cq5p<[KWсNr60M;hƿ|7Bhk&@&!%#M?@{ ǥ[_GM6\7+ \'ͪko[m_ֿg[*8tl}h* o- 3@X!Q_:ұ$j ʉX<Z{h܇Z}y?hF\_DDbem Јw쟙@Vt R 5@(XY peΆL(ۅ`w΄%M`wo4l^Ͼѳ8$N*ib/J}ᅝs&%GQ[8yFPCG 4w0^"cw/}gmND6k !4`@ڬE- TP|@[>5F{ֿ΃̬*^N'R\τ{77?ØJ;W n]Oxp:mZwץ?≆E-T5 Bt5nPat :jDM,n}QÒ{Q/" hIp_d,`" !T#eM 0qE?D=oܹ;bߞlݺ{7+?.Gܺp8/jq{_Q@{_gjK"V=*5DX@Z haF0tDP_;QU}I,Fl5gZ A!E pe-@&;-Q XMڽýV3.lo^б.>SEw>.x1%Y)|!Tot 5uUZ` MWŶ`2_C~Ε]hD{SкiT,4kjPd`22DCYi=DxضO;c?M?7؝F޼?8/S!сԾvz?wґҒ@7,.yT55@GzBE!L PvsQcۍ(ޗm}W3^ҾŘ5nQ j6vԖKQfעYp4i ֚$3(*vnOl҇1n_s8zn҇D2~+n(: jrY˿/DR)`e 2cEDW@P_^: Unox}^ݼ> +w;<[8aLC_fj@@}L?89 ;뿉fɢ?=*smߜa̽%ġs8q@gI_ߎ`ay2g-\a hHU5+ j`J`Z :ߋi _a¶ܗ}w/~WdN.jPRQ,p^'m"j%Pߛ4vnr_1w_SO}kFxA.xVgwRIŕJIX^i`e`.,OK7.mM n4Z~ 컂0SѸ{;kh^0@c7o㿹pU˻9Q5S{[h=D}jKG`Cx;͝~o6PEx}nĕIv㝿wmxԨEэ+6~o||$#!4n>B: B(4 tI&LԀZc2FC 6$Qb&"'لsy!J"&  !ߑZM6P[:QHa`e?t^"jsQs7gI#nrTs1ǐ4c#?pS8ONf=.q-gU_B}GKR %( i" "Z & -Tꨙoߎ Bb" h2؇Y:9L5rko `c!7l(TTIc. ?tO35?vnp?izlo\%ll-da}\xG2yf߸G *H[U}E@Ssa 06jZ{iyݚC$M-Y'<k` kE2^G nހ-bay*XHGtP]4v"j%,?IgP8hwwGŭʡ3x'&}Pi _nŲ~Pj1X!F|"6;*< D4" Dظ NdtH#6s< i<awcVVEXOI6dA=3N Acwd /$28juܽnT;׈5oc1gEm^~BXX>:Rl(?7uPT&;u RJ ]oMaєc&́s#}_qL@Wu(9E]"#M?ɎYmmAΔ&9'b̹z7p?a)xM!Ư8~6 --Uj8cj4DP&Wr:jbo6סV:h돞ўl R>jx+.tkX/zZrxk?ƁImGxd2BJS`'t[k}q?L! McWޭ'㺻_9G-o@ZF0z*atS[UX<({7~~̭D4h"M躢܏0X k#+Ɓ̹Kc[xQe+ ғ1? ,-O2ľףmr\6^cvLStdǙi oN棝 ~"ؚR\`}<5= `c՗_CU&/8YoY k /*o ܽ-Fs[OޟOX>?Ҧ R|R/B(nz/~MGMxaMdlq?AmFm 0QIo-Z-WЖq߁?cL5 C>d֟JkvOp{@%6b Bmay.FKvѐ  0:t?A+_{O=Q4!6`G0.NX5bi,;+ TAvk!6o7Šss>@2ZCQQ;[wB ;װ}-@s2X-݈q)6 V']e@ #O|XplHDY|k6/C\g`):~?2?|\۸@rq}&c\o'>n>Yg @|?ox# *73ITdOĿ: ߗ,G2q\|L%]?9Fty]zݺΆAHuH^kil-''{}[\{k㱙[9 Pdq\ s0C!&2_>Oo#$wyv rⱖO8܇:V7Z;?C{0sP̲~g 2%e#r+4*>!#j7A@Gͤ2m 6 ${ ,ی:퟽N_x3Q8֦-';be>OZ92h kCkw7~qv?~E,l]p҇1-nԤ+/A)XQ*4#*rο56XV##uWA!r+l=pf=3VUwlbgCrUe,˞eƈ#8t,j}TFBlx͝~Gn_>3,߹/K*ʮSw`$\Vx?V@`@wßf \>dzo^;ח-|@|_W+PPEߟ#*#=?wEnQ4h]&2-[gG@@@ܝd`-jK| T}Gy-Dank@6k}|b>].@jg:^vn=Pz Cժ([xb wC mtZ'U *Xh'$ 8 P1\}u-n u@'n^V& '2[p{HY|EMn͝ e,b;۰05&mp|N'gZUP;,?h.f%pp:} Br40["E iz<Ozck|Ł/b_'\Hk>2cOΤ_q *V OF7U(V*H(OTm& -/n?vo5 hb_?zq31D w1{p#l.k 'ԖXԗ -aa8]I@R_6*ph'\wOH|duOLEU@qQGx[R#*@A)c4&M?f@M_W/w~W(|}S wla^A-‘OgWWpY,~ Xg.ܻ_ǭ2Z0rRq:7[7 Tlac҇0jP?n'S+޲!n{P \a{<?^ڥ͛o*h1@m7~ҞnMeGΣ|̕ZAw[`G;8t\f? [O^F7Ge Ѿ~{^zDndmJ[A#f`!@J hX]wJ`jMh_ k@a& G L_˒;%7pW^+ȣhd˴0*u78-hMD0bl~4oft0Ӹ= oQR8oM65H:^  u ք8ԇ/Uh0@Q$VFЉQ_>-q1E匮 Pt؄-baZy@Ԯק{:ج?ѤkwTBR\ֿ눿43 aav[t57:X:MuOO:,\~x{>aGUh <+/V_%%Umڍ1t DP_q4wNMfw=8ޏ&i1d:Ą irTs%sFi!$4 AՖj [>R"4A.kO)JW̓a_-: 3Lg[ MTO>U7YpM|jM(?5@M=?M[*lt:پk g]#HID@5)e)6wݘAѰH8x?u!T} A}H椫XjٻB2Q5XDuU BhBP[S>po#a$0? foC'!Ncw=Xk4C,~̮Ƅ0t(l=@Db&Eb2!v/][:ŕ]w{,ԑST!Tch56ܾ3(pDЭ%0Zwq0@H[aA6ɿоL!Xl?Уٟ UXkkq}}MMGUӾvWR /CmPx=Azt@s >AFClEP y;d֟Fm~l; V?1~ e~77J3ɂ?^GV yGCg"h?_{'oaLmP[0sg RCc-ӭ_%?(L>@F'f7 h$5&oMnæL^ADӈx|_SH2(_JUGmj YdN&m T!^ZI*:|peJ렪h=fB"/3Bi 8ͼf+.&Qrt%`aD4mrf2!,,K,iֿPbY7RRi:d08p! Gr.YO@nRA+l`]?l$d;U x}yTbR%~ w]wn#h{sl1UT6m}-Gxw U aV|SR)avֿ!-B՚PE jnFHOFB\ֿ߿?5_d4}.;iR%4Ph`?U%u0 ݌n{,, ` e ;σ|?y_I5w/}kmlF({B7ռD|?OP_A}hDRųGJ#M RE0AJ/@Zj.6j<($nrR' ߫Z4_VJ=>e@_T_CjYUj ?F'\{nܧR>Ϻ*)f&w=\ɿN$p`-֘ 4q FGv`쇅 .2@}0_\_(@Noֿ+?BPH 4u &Tm#Э]DnǛYe5_0: w-踰Q|#QhꗎeM\}ߤmR& PʋZT3@7u'8~Ho.?W F0H7V̈߸r]fdM'Dݿ `ě~b>/x8ɲbֿA݂[\ u7B0r:lBGM6vK0ZD?@N]yTu(|Ŧ~~U0J[m 9ܐI0&tv_óAhop㝯;8tN?}W 63guTptğI%t@|FDӈW؁W 2]Rֿ:?B0aZ *l2&† %e"S&B˜ČF6(KW% 3{wqww.$ Jh4޸|C9z7fYkB[)ӵ_?\[rIDT=<㤉&i=Kr?;!k/Ygw!HC !&jbot F{/'#;/U%663J*C>!U9`K޸N=qN]X $gd_e;)s5Q?ny6[x@ *`R/a% &;BM!Ï{[|U@jL4Ђx'vns>P6pnS[>¶2Ft+8t,N= >v/爿\)[jȚ艳Q 퉦4qI}FUH뒲N-~)<>BPeF!UG.BךX<>ؾ tO=[@ܽM77/%eE<)װ}60@%ē1}A޸_}߿爿1 ?ާ\_}l+g3DS P[AHAnz 0"x谉tm^ -h*ӸoР@c.n^凐dQدJ $4hMg`xϥ70o5~o"/TI Zn\_!!Mk6tVo%ʪ,L?^Ÿp/ʏt  at*XpkM?<>wOuK q m}w6ﶁ?1G:{qTX9$]Pz#ƅƠg?žnԟX`}>"h?_p!,@eVVkVt!( F#WxGN@ݟ@J7.ӲlMXr]!UtL8?Ƒό|8d00B]|]u jnQ0@#{*jB.돸2cQ>BOZ>~`'\Eퟠ}v![Wl ؤ2ےɉ߁< 4C` r+GsǑO舿q=`?:BƄIuV CDӉt?}@ʏcֿG~k15ؠ-Tg>5uw~6@kfNx-m*ⶁ ?m ~w{TҟŷҕO~> Jc߸$NRO2F.FG[/e%/ 1IM/2 A=i'ſ6cRUc$##W "ւjKX>r {oaO{8}7?y7tߦr%\GоT/cg_ũ?1 ~kLٿo a@)M^:ϝ?:]EgϮ0_Ym##L'@I@U[ґSۺ=l߿4}ӏ 6aL \f!η 2S| _=t? t6/&*޿yk#"h_z.Y.~X2Y4¬GBB ?BW U- y<_7+?V :mc7L*|F(eCu*sO?j7.PP+|5f=&rdTSuh1@wGGJ(3?m#M 6èV:B0ZǖpYl߿\xxm<|Ӄ=1W t#P_3[_>44l=f!t5{}Ͼ7s=c?O ]} ʪ28tU7!BB_\1?F ##+@AFסE"֖pSؾw ܻDY%ܗ`0K>55C ]M|[  `ȉg Х_ޚ⿕4Ԕ/‰S~@†Ɗ `J)}%fgGF`-„Mރ'ݟ`omUȫr() 2qmsݦBV30o\b{@f?_we⑃6$v PEC]ܿcI%AS5wꐾOǟG nt'2{Fh@ 0@W`w3VQ\ V>g?73=k?ض&L~/-[wY1@`s!zT<ޯE 6B2!Xu е[+ 'i|- >t`-,|fB3_oָ$ B`xɼ<f~8qe3xFFrD4 P5Xw줫CRU<3#@j7B0j mepulo\kߚCmF#=a^B3xbA|;3/Y2O3?ӱM_?z߭.H Ӊ;UTnLc VGV҆p>> =ܾƸm 7s |0C'D_zLM0X:t1X#'^0U߿l<}ʞ M=_ϼzZRk"D]jF?!dkM<~";*n_\_&}CnpeQ9ݾOmԻ@uX({Wx!Pq5:Xã'?cV][~0DdAx[uw/}zUT 6PT[?YEoPBRAOZPL5qE6]F@jN~_G6s~FDӋ/L?{RŬ?uw& `u0A*X8V{[ߩ(Nf0GG c5~Fk#X){ ;|?|NIld*>'Vnğ1>z"kQ\?MNz;TqTw ȔQʕqSU!Y L+k0* P:Z8p3Q/s& m@ !q۷$DDzdEb=k_ ʃc5{[k8<"ƿ|7ׄ :Z |%!SlQQ0*#!E>n]^@@&KQ`2>N;]X 5JNHAMa#Эٟ+ok۾u @BAknݲacc"*c*Sp| ÐHhz{Fnߠ%B* AnծO L;QܾWS;Bp?rud@2P-KPmUȷj,b~#@~(SoBXs ?yE4F<]LT E $O ʰ.@߈GZ Pu݂ Bt]訉}H3]:{k4t_ -o|˿Mz~Krߜ=~t-7&J2@}UtW2n\_ࠉJ ’Dλp֑ DtחlwֿARi]s%B' 0p;=#G}>~HN]7ɼktSՀprZã'~Lj?.A~{ڗGZose,_l4e{H1鰁_ Yi\Ƹ Ԁљ@tQyct\͜If dr@vGրc5غ7.oOT%Wr2RkYxR.q.LfgY08$@k3qoW4⿼`^3mKm:g@G%iU,hl i_FZAD ̘q4tr@!hBWѳo'|lr@}S⪀k}fGQG{d8v%T@9>*EY\E&SoB UBajcEVHH@>p aL%5b8!ܶx NZν[jF/4@_l|Ɲ Qo|ݫ10OTptJ&>RB7`u ]uY Lʖ ?B@RE0V!5+0B0y-k-DP@h Pyx@ ppZU?g]a[?n!&jvqX񆩴 kAq KՐFCGd$| &`@ن T^H#Pzg (;Ö kۯmW ]OF& kGQgwf;~C訕vΑr"m:,Xѭ ,٢iu4MT Iy|H8⯓F*7 ߟ@@%Bֿ2#CLcu]ܹ͡sOXO> 0,j?*o[~ocӉӍnthpw/.mKBDGODӃ w҅;6> .+] @@TFj᥃0YB;y I]ܾM>axT}WE} g˂,6 MGQWŒ7V&%. :]#2)`eAVNU\hV0@m0O&(`@6`})3 tK}xL`vka*5ִF0qu}ߘ0?Y~a_k :g׹ yƲ a!p@@@v{J̟I `@$`Z+L@Fܕ ;BFAR`T\cg_ߘ4pj2-^h5 ?{B%eu/J褏P@@i~Oa7&'UƯԗjifF~& {=|l06;>0: >4F-i䟏FGI)t&t؄}鯰ya`؍oӖ}v^Dktʔ͚eo; HA}Ê"?Y' 2_t /W ܖIA>Eɗ˳c.fC%3܈ Y#߿ąf_/NKm/|+ @eE撀 fF6} ~o~/ \WmQ,]'?5Zf~@~1?xrOA*7wZz5@GMwmoS49j8z*m7:ϳӿ wm /eSa;@DHضM+:]A:X@@Iր{#[-e:`D6;]G!E7Kl\#Nq_xc`L5+ 40M)oy]fq?.UX˜-NYSdt LУGE5IuKZф0@o|3ko! %U@ u  րG`CRԀ:^X=8rY訉?:nW~SG>:p ۧ &c#~ ȏkf˚E*׼li@Je[__ /_ HBzn>nm@\ƨlh`"w@!aU*7=@μ?~On|:w/]g{dE~|㯯^tDZrʗgGm%ѪVܖBlz(&,mqC+9:(f2n돿^L~0G@^K& qU@:p9]9dFZa #uhO?pg_íw:ܞfSo5<:^7ŅxO$]}KT~x{|?j^]/+?,(,]gf Twq4I|0fF>0 S\ @Gg o qèLBZ O؊l^CJ$P/*`ڧ 䮯N;ϡcG߃'~/k~@ `1I~d2?;O~;m(AǒZ~% _f1f T]-4`3rSo`ֿGj?9U ր?#نpw֤ |O"Odf_vyd&7O:w_[_M1_`>FJ=nMq.}:d"R)}@1A mLaj Ƥf-FSA aT sM䀊>_!JӶ'.3cU '~ſP_wK*2U[&~37⯰~?eɝeJ-{ pk80+S@Tc STAa|E!؂րGywwpS d)na`ONĝM0%OӟTudҀG6I@ r{ hLG{F٬ Ra_RL6{΂JvY"EH݂De/&{NFDxױ9{ I @i`@v| @r^51 (4~{!hT[0dN?T1x0=AY0Pv!h3[<payX򯺖KPA=i$3?Qv_3fݳg1}.K|yn]&[%`Lj@0@aJ|L?ٹO}0ZAk c`S>B015?5ա"t'pًӯ;q҇?׆"a`1x`m 0OD GK7aE0I?/Jqq?䢿kK5Vd=0ٸ>'=͝_+6/C O5?} B i740"Whm`}*o~X$*QĹ0ˎ갉?]ǭezWm' sYղ]BI"7/ ZV})?)K"J,^O=m,{L Riz|w|G03=܇:u+'%e~1?X 5,V~+J#'3QZb@ d]:,l 0偀"@J:nj LfTi.8Bm `t fي}߉f T)6Ь?:M- 75@a |G*k6nٸ<0| @ )l2sd>y?r=aw'bښY_}7*wc9Mwe&/h>ʢb%'On@<ƌv MT-ɇ۳WVh G fR4dxN6΄]9C&#y;~l^7 [w6G07S}|\/ei@e +`ZM@JȠ6@(FCOۗO-/n֥늤D?{:XD" blm.qc@P~kn 8P 79@jH\@ X{Z,y6q?ŵݤJ>'똸a`ADP jy}G)U,7q }Ƥ~H?4klb%{fՑ@@y*AΧұ7qDT1 P$exSZn:l %%ϓPH@ #@L /m#XAՖ :lt S$|/ʏI?wGrn)`jQx7> Na}Ұ_@>{ӌӮ| a;ҭC\EۼW#UM>M@0n"|p sW> }wv% #!A ~r@ܪVס:t5} ?7ZOf!dfASr3@}(w/vA=`g& a[l_ O'w@Ko(-,(Xp-D]X+L瀊S+ `tb+ `֟tR OR/@Zx .غ ?)Uh׵:"&j!jL|lB>q#_l3QǬ1f]6r[fI4W*ߕ^2cܳ T1~/EU"tr@I aq~Ht43! k%^ Znt/|:jbƟa7; ^P e "P>CJ˛?߬/ӕ~.3GE{gJ}^.iBjKM;ZJ>/Z@Gnm|`[ m} @I_ hr J a \@G0O8䇰zxp \b.+7 }_' m[5a@kX>/m_zz?J"oϊ7:n(MK̦[^Z UL*I*^ı?6qko?`tMEUvz 6 \Z~lF52i/ Yd\C龿MF,ܭ]}_ t},&o*f\[ * p1H״WmH5w7NF1K~ŋ;%Ak]0@J B_rL?)_1@=F@(/zgzU&j+w[iץ%;m~_"l)UD2a>b69<T)wznݜm fRO CjBdo<}M &&T}U  !§\:'j>]Vk Og3~b&F\ ?ONj(J3\/\n}$Ы `X;DT9;WlP_-ӧg@26\,q Tn?%pt9Q&jBM<OqeRN歎\_pƛ˳~f_hߘ.J,^OJQzюWr?? X8r";Bbx_:ϕOq1ڽ{Og]}.\0s@{_|Om4& )yO^6{9Dk_D3T9qg~o@h@}T>@n*LvcJAX19]G&S0z7 џdsNmS:_ϸ%}N~+)_![^ffi*gS䯢>V\$󓶷'kj<zD4-EՁϹ?A,2Mp722*_`ӪORc_g0G!"VO1drpɚnBt_m{9;w#!002t[xڤ/o"č*/m}_s@az@mŸo @z66MD4{ J?dUq @=)|fUk> j%!(#Nuo`Ɵoq"cYZZR3x t|U[”6 L>ʛegf,/n}E=Ma r0 h:0@ln`!`7eߋkvl0@lD#k-xC8v8s˜0V@I38s䈿6 >}43?}.e%^eK^ UpK@ κ V,Ⓔ?&]@HJJ ݖ8`AcY43P߯A6t&j>?q_3Яë忰&l~ߧpS7AS'"cխƟ/ ڪ n7+ d~o-mv@wCD `1ѿݵ|ie!r'N&`1xaH) jPAAP ꮼ4X A5Ru׼fB\? :KUs2jC-Bm0jKGQ_>?Y| >|1@ ~k"DmY߿BJo1Ooo˷$1Lvҏ:"jb' OH{5BBXIzHf'+0Q= :?*mJ6BJU2at<9;~lzWgk `=vcx7%&'/u??3jN=2q~D skNU_qd=ٸ2٥L]εooA/ZNh0@~p X k@G q WXWi U3+%F)j ht.okמ^f:2Yz<]db h>^vCmh;hok*UT=ɇwFVƁdr@>aeV4L& L+44MVo^GJau(4>'˸@@ѳx_爿F'}?vwB?ߛ(MEt?{,)/_w_Uu*o6E.ݺ.a*;Xw . P.3RCX6  D5 4:an/dq oJKE&r_ `ua"'|Oo'qv?9i+爿Y0T /o߿?R^wߧl[e~<7ݭ=f T9wk_rVᇫpz af* ?M (L7o%}Pq'D0i.  >e\ݟb;~crI~~@ xāo_iTˮuߡZKc}Qɯ_υW}xc URv 4 df{3Kw`י@@:>PwH{ H鞯nr@-?BP?5qM\{ga GgN|`e|?|j8SlY(.BOu&h];.;Gzvnu-LD(?a7ym ~[@y . L h4X?dr@ta?BqM\}sP?SGG>~^[Z:.[պ.3ˌ_qXAem|tgϞfINqZFsjbih  lH4IąnHf8۹ɤ[R&Q9# A2 s=3_]{GddfdfDNfFxxxfFDܿΒ1 3PFsN r HARHr&PR 2R|`Ά%ż%vWKNd{G|՟dz_yO}?Mo3ޚ ^ _?p?fZ$ESdSdgſ=Iʹʌh[`v@)yٍ9A>:Û?Oշ!=G|v?q{  =1#GN̿_?"jiCE+3O튈!ŏmÈgzO;Gǫd:6䦇5(N|Z'壝1 ")rC\cy/9?f9^Mr321y6t´<;?޸V= ]^5A፟[> Vo3<2cfM b?IeAμY߁% #"| _#lM߂ n9 LgF913DP 'Q` $H߬ $@k/j@t_5A*-d>%3]BȳZG'xK13q @αP$3aW^?wֿʳ.ώˉ]fo-o)C[0-O5%0 CPh $BYY-IH7dl,ۛlk/!t `?+_~ O}?~G/k dXw)73sϋY)ȸJeN-og;g^g@ۉoJ!JoOFu!]=-;P^&wazB m3Q/!@e$H x }C@gBx ԗy [B0W~WSG@`xg1 $#ddBjddOran;:Cﶙ죕 ..[&+9pnFӛ ?;oU,f7qp8bf-쐻}"=2?HR<!5$EH@Y- 4(3{YC)!(l +?+/$T>.n}o^9$d:.tƬZ3VJf?FSphŒfmfYx}'ץ7Z#Wew6;辖r ì60zq-ti`!@H!SJ RYPF( o#{ y)Fe $uhLW2#O`]4P @N@Jyb *I;l}sfKgs(5Ŀʧ&1F2&m 7,,͍~'Gw#uuR'a׸vXχL T=I@J "a`Z^ )r, 3me. vv * "Ý%*gG| /a|T 1L U}3C$_x4scHs-gx t϶ fk!* &L~>|vrx7>>&lߔu%Y!0Y-pyI& * BJi1!@ ȋ0̨LFHv;`ß7 'L1άb!| w.}DЀԄdP=s6 ȱ8l2H/z(bX'7_P1 |Yi@AEKdwWtwP Ô-V ?dL"U Zt PR>3P'L&N;3 t|f_r Ύ099{//' S+@adr@ߙx_{F1Asſ/]%+8(5&ު /z_nۜb7av 60ʼnU73j 6a`!@(ҽ.L[fO-@6`"mR \&  .NQ @Y2SL_w_P:dtN*?L=7=#4?.!h}/HP%Xn 2IiMu gǏ_y_69!#?KϿd!2I#겙I )H@$9A_群揠a-l<1Ԕy1_3T!pZORLVh%[ fΒU=a0W rӗo4*ۉ '޶¼| d1̖L),Ώ541sPza5+BB% 2!y^(h"Ԍ\xt==􅿚jw|m#> S2R9:Di`RIHHp!=\|9{M`Z^ A>71ٟ'g2ld8m]Y]obS0{a^S$)3Y"!5€T*uޅHr yƆ&j_G3''ݻ]  Yѯ00L`zr'gg; >H A=\7d*HlEfʋ@E0Ii-+L=NWSw}HT<9Ml]Ey0~c,eq PB*@IўhOU9L)5 %2_@MsYڬ%G6 LAdDDFx )޹ W ;27%9TW"*D Ig Ҧ_Kev޲ElvmeָK@wLQTfû;XTOW)Wee7D$qRBPRk.>#8$IRHծ2ѣ8zt@?~a2HA)@Xq 4脙ӳ3!p+83:4@PyN.!fj_ۘ'2M]U׊y&A_^D7ܡ TGAY~@PpՕaxaV BRQC#@Jme=u vVyB5Sߟ'Rxrǘ?5*\J~5djI AgwHJRcPBJ**<}Ӄ|T2`y]F0\2[7W(7 $U O0)ӫk_I$,I3)a{y@ ؏g?6`1 3h+ol3<ɦ1 @\gO/J O, 4^y.1@aĆ]aVS{̸Aav60ƺ+ C:tJC@ dB~)&RY%' 3-D1On.T܆y$Nh!HFػthJI@ T`,@4'ye˿-iug5v]vRG7mӮx0|k}ݬ8r61̮yfXC! L'v{NJ@!@HƆ"!N6I}XH[c HAI)+Lv6E6yxKW24*A0eV&E鿨 6v1q3ZYA,9̥kSg 1~z s /pr|?=X ]A1  'a6ΰ2|cezC@-`'&yZbZl.}Z׵؍})ʢE'RG7i`!$Cx琎FE)9rOgdy]ddGx/ΧgA`/\(5+dsa2#PKCN?$l`zM9S DZ eD2_yە^TO d^fVl3?9OnZk޻WFrPNG )`Jl2E>!wAI\D&d=1JWa1)TAXo29CK뿻Exv ?mWrӚ&Qo]œ܏(J{ pz| {2l`z?~W_~įmz8 S3"nKЀj5zQ8 evvkv7#*?0x+jl! :G6@ i*hw11%Uo J)lg8ſxHԏ4<=;f~̠G h#6ΚeE?7mdB@pzOӓX5`۞+l`zpÝ^گⵯ1 p YFѪF%q΍GڬY.pnZmkjӰ.z]u"g:a@gQj&e AdI`t~t@%G rWEy̿wJߝ/k328F`[xKCvӣ}oiԯm3ab>n}7q )5|V74jr Х C3+BHB 8zx[v,.{ hl z$; 9 Yu!\$ML MaH'̋ 6}$HWlT-u-1I 6b;60C*"yP 2RpeC@_Oȧ8;~l([Na&!iC@_BxhcD\IF@:rc\On#sC@4Oq_EĿ~w@C" Dc6F'"j[#As9&gOpxx=.,0 =W56.@_עh0] C!@8XfGYxr_B05eGo!`VӃ&ǵ(_ zX=u9 TH!I' 3$-=hrKgPI^xbZ$ZDcO#d?B9~Em,sguG@(Z5Cz_t2[9xTW $ @4*z^`fĖL9+̊31.3EXuޟwb&ᬺ*]I[o'}ߺ$`$޿}u&_(u݀5?GvNg)'GBt'@Dzjg 0('̓!D&ЊN:CU\n?==i5?jCde@gUsRtIr)@&QH|lDo\%1@de{hﯲx¿x /ܮ~8Iԛ~C_k yT oG!msǘ@:<U &K!^<Ong;e`m! Z ̆! .ҙ4묣$Mz)Ύ"DĿqjTbV%ńvF3$s-n&,@3@_tGN2lyBE As7a -hV#=!x8v}L~ѶYjzy`2?l_0d%F NX6W( 2|ZEKU<Y/l`f^CW t "A7@iIgK6~y e{s_f Cӓğоxk+(B"aܮu6#DRV i xr'W 1Tl~2:[Y:ڈʡYOa|u+\%kxԈJ6b^z5ܥMz@R I4#ʡLH dvTy?XbWhdbfa3 ܛ<  M A j1l&~Hٰ<;Q<ߺgz,f_Kc#ֳy (7%ID&y1J*e+E~%`ĚhCF\mT$Ŀ;&*>UMM? &#L&e5m$~Ko$c&Y )FC,Plc~]Yl`^Di!oo̳_ %r>j*`Đ5Y7C)mM I5&j1/O7x\yM5Hr\HGeh94"s Be߾&&_9s_7$Z8m ߶_ޖ ,_N3_yY(Ȅ%I'O a)*8X pqx^Eifz~cfeo_zͷvcK\&^}l`zK+C1ŐP` *joƲğvϧۿWݪPy[.ǸJt24#Hd LM@20S]cmœ?т,LRd£+&_9Ȳp=lj[w.яk5T!@% (܄@y)l "%Lώgl{̓CUSAxr m`,;geŸW@`gC5:MdQ>T J~xy)dKy l`C&+#lzL'AXpfD*M* r\!`VlrȋzEz[Vz=+E A P (P&Q`5%h)l<; m,ꨧ@plm1G>k 5VfV?<ۉo*վ%M(6 0!Xⳤ_؟IaV?]}50;œuyHh], *7DQ=R9ȦUx.es2a+ IQLCs),i_ wpMضV<un_a"R|G[pԔp]oMKW+Vpv) @<((I6Չ) 060 l`"@ PG@hHj8٭!`>E69F>=$ST'e[קb "&uSBP)}]A% 7$Ȅ 'd7?wU[jy}?\DĿ!׀3.@ ߍw8y& $cе[rPB#|* 95=>د,dfa3|af,l~QC@jrIZ] *`zzljJe+5MߴbkUEDMUo]Q4Wy>̑׋$`r.YP6Ofmu+g"t:q5,SI *4xDۆlVHfJ"G9d"iCt|zZ^; av 60?7% ̐P@{Fa!AՀ"Y S(@IS5`C@Q/tv<Ϫ TM*.'\T,Y/;?{6Ke''cjPEemƁ0~?: 1.o{<\VM[#ۧ״S >NLHt~AVpT9"cg 0nf0(Da#zT ` F Ii B$V nacg LyU3+K"ʑ JBpt^}];ߴY^1*8o߮1 [GfQIGY⟈2%q٦&3]'eO *$:Qa݃ p&)]Oklku֋6H0(mi;tmI|þa!pwk4 AÀ+ue퍨wƸl3ەy Yԥ !*`|oMa ̀,[!AŻRF7 dPxhC o"ܰW]l|zئer6}\{FYҖw2K^t?E~K$k+Ofd-$;DB Mh@00HS|>ʆ 3l`V e*Xx#x (r +K#,w'VF쮿[V=uŗܟfw70>fX&_t?0 2=GV3jQNm1X) %I Ds/} J8۟~70gaCtd_O;S&lcV5dM>2^1*T{ssQh0pĺ[* °~l"30.ſ}8Ak>¶<؋E5$ 2L11$=wW^뿢g0 `FoUx0̪ hC@62kp|@"{YRdJeH M9Ib%BC-gT+Ev]+o,V:bnPBy'[wTVORW o P׷-ey(c|vA_UA _,5 )$ Fchx/ɿņ/K؛~#,>q־\B$n$F*ːggHG{&6[&/{q6 e^r,A.u ׁk< /( |xYהr?۞ \DWH$ОeAmt%</SG'a {0Âj_  kpl' 0󗁋WH!GߊOᵩU/w2mtnUH в("+1F GW?yEſ;On ,Le&/vuߙGL(+=m݉yOHL&4 ա`Bφ\z'S3az Q/aC3>aZY`<ӕ/ #Ϧ]Ć8lyX ^\u(~]S P$T8;{G+]ku[<wAC$_@lN6aLp]z' 38 cfH`{a$HP7,L;PY<9*cb}vow ߪ&p 0ÃIl6+2?X6 Q,#lh 7R_>zf 60!ab! 7Z5r4PL]%6tk2y/ӝ.{[ ״"kW@7ia @pF֟׋XDQ0/죶m6Qnh@Y&Rc!P B& '>O=}xw0&f0߿M84`|!l # Rx/9uUw_ f v/O]UDκ_a٦XZ0ƘᶱR*g3w3U\S "+iY{pZR;Ex@Z H2G@jrt7< ca6pա! 0ST?'L>&[/W#W|\g.zQoI\kG5/Ezk; zy a2߽G*w6KBΚWJD9ӱ23tMD#LBedtN߸t!az0 F'gx5|_˯mzH S Q(0h=\ ^ëw;B U*|]r-01 Dgl?>ƃr_~?HarIG[9_,ų cU%#fkm(@I)!TPpo\}浟z8Ol60S:>aC3'}YbAm^>#"][Y/ÙHMm_jwGCh08KW }8T<~>Lxl?nLU5mgdq/E@ j#DWu9o{  n ڻ%l`,ڝeC>Ziw΅{;{H{kXz?2T&s. fed6l?\e]XÍ:a* t˝[;_yW~aaV _l&C:kY6xX%o `F?a|Cg?źk`a1/ Ž/XxG8LKNGwZ?=DB*"4 UJrHc|/GO߭ 0afDgD`,67a_l[51@׺w= w׻IP b:;̟}3b Y|kՈg|=2Gt,eOſh+Y4c|Jp~߼/S[ߩ0`fxX+ (>=g%͂O5_nT}]#ዕ<R;G*دC v %#㪌~.{vA pP" HBr (*"IOg?뫧=}n fPy4{ÆflѰ0yi^'~?ZR>)fg9mu&"J~߹DV:3ڶ~"۬[7 q6ku'"@ @#T&<@}W)q߻z>%l`Eql 6l!0 \W\g$D趻eiz_\2E׬L嵳k\QrĿ+ 33JDtxn/7%#}m@ChB&@ "H% ʍ! 9.i~t fl`/I.K\{:lOD_񳶬B7xb@O%/@]z(8N`8`|r.X :Ejl4ۨbC=#?gs! @؄$m‹}K/Sg?2L-'n.-?Ff) `DއGVg@8?1߁q?p7(C]ߍ(Cd{(͓?NQᮊ %1eĿCѶCņ W!4e)!{Hl 9$xH4 av60CAb6mf}Wy_"}mZ7Ow@Gu(c>~u}ު1 6_z }ر)lpxpo 2٦|OA=z$=ށ!5!@B&Nk Kc7+N__~gzG p3L50ЀçSist *ۄ7)gC7}Ȍ?:kHw]+ _7gy{NOe) ]q\#f37zCGM_cHzq(¾w@@jc 0P THR\xA 8yx{ɵ8O !03kNk0, 3㍢y (6 h:2<1gp y3eG:Aپdn{?{?ӺkSſםD!DNƀ"Ay/~ϿɣO9Op3 9l`Hą=f&'T/kVt|_E3vwsنv>g3f'!~,? RJxvpL{i2BVM1{98ݾt|p()t]k(&&ONX7~3_J0= fl!`+#: Y߆ny}o3PX;e{}LQe]p*b>_m0=ܿIV}@$t4hLOpWc{q-#={ϢnѪ|YWR& I ߞc __焁.9.2s0LH(׸q4s9z?&V WXO~l}kW]Sp;ւ>N#;o4+l1J?>/QEY㌌ڒ,<DVdD6O@s\|"O  )53Ø^ÆYʦ5ŗr?f^BnT7w;01s@_>NOy-x(t\ufnco'kT~6-]c$a*`*$Dž^{/S}5Nl xKfph@Sl4ܰ雴 w3DqR̦ ƃ,vny=o/~!8Іc+ H Tx-/__Ķq[i>h?n=s_>BH{z#] H!00:~& w6=~`LyœM;{0Cf5vxhW1.3yWGڻd4.sQ4Jﮫ݀pz|>H($<#[_a }^|7}BG?F ?K}K1IDATG_Fރ]xz,&W! 0^-$H*C %)DṯoՓGw|ճ 60#,l%l]r\F(luU!+ b?UfqNu]|~jQ߮'n]țȈb@Q`?&jg["}\aֿQ aShC)@1$^JR\xᵷ?;qfxGo!;0kHgwA ̗T [پ[*<Ahd@"=9۞mc=_za3π;(,*T >ڈxu]Y¦+ G ' I  D6OQ@*ŅMg?   7՝c!YѮ# ܦf=@4=zqu^>M̶P;`eiW o}ܾVu/zR "Ix"yW~n)!)!!Q$m+ݮ7JӺ`S_TT _u/]9V2I<:Wm3, ">av60C{[&_b.?]{u]xo$#p1ZRqy8=2Y2_9߾F;V#ZMdIGGl MF_[*$A~5HI X' t }篾+NW^wy[~ CMd6YF[T,[fuP/n7az*%~Oѽ!B6)š !!29#Bk7O}$D7w_w,ՋnW1*%I@@p!uo^<ɣۜ0l` 3ku\ڦ,&9"c]˟Yvb.6q<Ȉ[~:#d:+dUBāN0@oh6f_۪2.?Oǣ$ $% koGO<LffU|Me;٦SmƋq}c1a*}`_'uyԎaMmN`k!N^ZB= a:g^_/# /G!j6->wU ms<^xs'l`J0!ru'mS}f1(+k)w84u T_ʈ~藳Zv 6Po HD`ED{@Wy?k?ҿ?M Uhx/BH{v^XCe9:7nlznfW 0lX;}r(9;}wO}[~[ۥٸ,\^jz ?F[- s\ cth]J0UdHSgvtwGU{VWoSUPHRԩP$ ڏ=ᄁja3X?7 S:d#,0`'G;89/_Ҭ5>KP;c).6[prtNb0_V?Y68.&,@?7p<('@o.j/쯦{' $Ic JL%Bs_zi ?UNȬ `K14[=9k}8>5u5j8bѵ+ؒ7uMsX]rr|y}Y a"W@1o\%B")mſ2,,p N_Iya3p"& Oi0o8=yP>6}ѿQ jADBTc?9n6dՉߌ7<e00V (p o QC̼XCX"!y! 7yf{0Lh@69A:> ǣ>n_Zז۸ѿÅK"G@{M7%/R\Xm5Hw_Z+ \ ^|oWkۮk]э;<Y};-w?e"@ɢ[R0R80pH%_'# ;]L7mY?Oǣ$ $' Ay/_?}t{},B/nfߒLG,$L'5FS:<ߤă0aJt!gΎMOgMU<*qٱ65Q6VmqeӖTM)l$ctv¸7E p\ A9*S,̲(۹jgub6|c }3I@H+6̜3L''!C9.P9V*aoccf}qrx TƠR^\|}.s>w>}H}c8.|?aA8˜}'EeUE/(u( LG,7=Ԇ(e<_Tx__}r L{,JLGG3=n]=oecsnOx񕿍_;Kge=#! cMꊛ}?nw:nE^D(5˗<$A 0?E)A+ % Ȋsk|[ՇVXg!ɜ⟓kEdB#rPC)D㹟+o'wϞ>xw7l`wV{0rK &\<9[ޭN|onGܻ'xm<v&UP̘էJ v fϲ\}nb}o=!P88Ac[2;E' saT:/JLIA#@ }W)p `a3`fa[tCzurt`- ܻ _~o˯NldHh yÌ=յ Kƽ b/Ƨ߯g5׻tČG@ @N"DĬ+B7Y $ tByC[DG",J&@ d :i$1‹}O|GWϞ!a3\jof5l*~ӣ+Ӽܽqċ]|+CJE:qckUcBY|Z0.|Pm^WIC'9d;=W9 D@O8_jc6H%&L P!ܗ^ڧ<Ó~t ' d r`af3XC{/ 2[ wou⫥[:]@Ǩ-A>||4{?41voMGW?gnsR:Nţ/$RIYK!]gPQ/LI 1t$݃s_ҕ׿Mѿ rW?΍?P@S̶OW<7 c'߯)1ӦhP*]0B_& DNנ:(8KsαB#td4qixW~3/|k  7/sֺ#3._ym<6=$f.㶻n^_xp4Qtݛwo_y˯BMъUto*c|\h }a:!zA e^hZIrq/mM[K0:O/B&ty4 :Oۜ0pa3hOv0d l|k὿ƣ{e^-jXo7!˯x5\aRC||,y; \Z$<>ΌvLl! ]bA'B÷.a #( M"?.Y3 Bd$9(Op>n<l`MƩw ӆڂ\cϼ tk |.X/^iipDDuc?90^a-@Љ琺[=lA?a`)+^0{s Ak6DTXޱK$l@ «o{}o^儁3;fG9C2`KC +t@*eֵ!Ȉn!y [>0)C%Ŀp}v,fKǫL,@PMY! [yh lGNʵ9wb;.{Iڬ!3~]2+~mayCNQ=s,7&Ĉ}ruynX Ÿ_{QPPjMFYw{z`3l(l`2'Gwpw7y-hC*^ߛQ5F`n콊B)P5tXǼVԎ'" 2 /vل~<WpMD8 jy*`Me,J/SȦ'8sdZY3^}xooz8˱#w׼=>!|y/uej|{#*˸}[89D?.JM.Ḱѩ M[A̖TzY * @ Yl`2L n|n|v`\y`E*&U\_uܹx髿Kfq>Lu]"3&N/>nƕMZ,^Cv_ a­Ea(=P Uzekkgnu Ry9?=C>9|ea↋a Xݵ__ν}qxy)CT?+Ͳ -|o.v' ӽu=.[(\trA34PQl΀\~m?Ӏ3[SASo Yl`^ł ;oo`ϱ^a1_!|x髿^{so*2*6:h{͊)dZ,`= 6B_B(e;^韙M/Wn9HeP RR4& 3hgYrwoqw6=lx|x?Q CAH5/nu17p|x _|mR'Ueyj!H[,H9^@,^r]LgN `-E*af';؄Ecӿ n९^~W/>vvD[Ek;,E-v364aX N@)hl dfj lmĿ6HiC噙/N̺`3|KϾW^9CRΗQ7Ϥ^o1hcQe]¶Ͻt#v>.h$ &eH H#wf.ZEZ5|T q2C@8>/>~7OG%V\|OpxomB)fuUk:k`6iWfc ޲HEuV|B13::@B@2))LE9f4"!7MD9(ϡT{_v^m 1ck7l !޿]eQ+3-kfu|}^y[퉬?wOp͜kAC dV}"/ B@yF pJjcq/O.!frfTdF .kxo7o[/~ammJ49d:'\Cz)udirHT^\9`S^0 l&[FYmo忓۵Fxn}.n]^yxk!Optpc!.̚n};:#y wt4zؒDݔ$&&"?wrp3 vPLЦfX!`.C7>w0:{+?sq}ƷЀǟ'kxSsKWvqy™:HhТR %"?3Ivw60[Bx#VUz=>k{mK7 }5~hp\{; }O8;ךF]VGoIa~ A,+)!nq=Y|_&RI˜̶fP>0lVp|x >ڔml"5*J7?/؇ЇD%,.5h R&$KvǼ?s/l`{Y/}GÛKu]j2cbn Sޯy{*-!X& /!TK .!5+K]7fMa?lX? þg5.fGK^d yd>EْH8/*g͟]V3R&II:LFf^'dDbӒb 7{0[AQyn_t0|tx > o@V.\#TV'n<<՟#EU ARZBHq XQ]Unf^׬ l3կ,7>OW6yk+M\7Veunv̮&iWmkS]l2v}EG>gKo&VUBH%i#WO,;lM[f< +oهv]k5FOƶ0 n WE{r % &)0(Gknſݫl C0d?wTX鋒8=Rf7@a A%d^]W"].v60U0 #44?W;¡7-|\]WySvzUm㣫,G+H8!R?ߩtzצ) 760[[.f,k8>k  W"ʧjiibD f6mg vX"(!yq_/Og\UkG2Vp^4 kxj~?H'׊.:tԬnHj2juAlERXǚZ _e A%[ſ#+520}=-PK< {|_gķq7>y8. s ku4ʍ=죹!Gݕ4^y7 b,!(KFq=Ŀ&[&^3! f(uScf0< ?;yMqʛzkqxp}Ap7-+gڈeo!rV7x"}:<u%!zXq|o}ru ;dz큂e/qx5|oCM_:'YE>Ad M A! coh.!b x6&[5cXf;pcY3y3&? _<9x0 vp@azyK M|gKӸ[5c KY6X/,nIR' A AR !rN;ŸTkog8ae10bQ| ږkl}֬@+m D9 AacaMٹC{Kpcم#˒A6^, l`{Yչw\lݬcx zߟca(ct| SN87n AB/]BT@6Gſ|V- l+ yvսY=G/@+j/3-($l鐀2VU~of;t3t Am4 DR )Q)P+ C!pfk8ypӔ1a# :gհr*苨8wH9G)GSIZ]Xɦ#:0,Pڤ/ rPD0 M.Y `gaUq;s0̰4cu3A/3/+ ARj$@H`20~KŎcZw'px% C@ s_BHٙ#3@ 侳(h Nf +0 3} =f' br|A$ t31>TK*l` F+nV2gs]8{N:ޱo'AeZtJRH@$)@ $ElJ㱶CbV߻L8Jq pK "I:E)%F{1;'tn/0?HK*l`]a@!]B+`@$yigQBg Ϡdd4 b$A@B@ XE.;L)!h%lK29=612[6qg ̖3 l v <@ݸ2䟖ddf rJ|!;!22kJ?B:ji>-8L (ėR&5v r þ1 7=*_f;إS֗h zHF2)QŃ 3SlMAe,2IN~KacʵWy<ː)GXg\pGaf0$`f[ %|q[}֨K-()SO8?kxpͶ2gDұ@exds8%>D|{LG~B*%1rRu%h% f먔d#0& \8\/ Gcg5y܇YmC*G>9THL"G% c.!^͒t SN t2Lx)X0; ~3 ,wϹ΋۬} B;ϐe@dBzFs&<ͅp#0=9+pQ P0&Dl,0Gr<#HyN)AHLiB@9||իIE {+Ӱ (&7=fs*N|W?a^αA-9ЙذzL-> 7D&)w k'@3(@&#$PRC,Z1ymmZc (Nw7=fs:_ af@Tk!$"ha]vޫt?nd_?y:{> T>ՆtdR{3l:0>a!w}Lw>y [/7p'25ә̳pT:Xw c4Ն$ 6Wďn` B0 BHTYUuܧHL9 fz0A_*h"g#Pb9ұc0 ePlH`<ۏL9 ƨ|7"E20q^0[1BHBt^ ;-wEs ±}?<_t/1c)g'NMNO':T gşRyQopU%`V8 ì֗m!HG# _/1r#"IMH1 * <nm?AiCA ӱ.s(@&YHt!!OFc'ɝk@p%60[R3 x,~=9D3 5Bhsx_G,c@y=&/!TrJ,Fz T<۲D8w7=fs`R! DYP! ]Љ\$ $ BU NXALs ˆA5b0fK}fC0á[ # U X<+d22 "gg髆wu}P/8{JhN/&65@JRN LG23%WrR{?Kڈ1y% &k&1q( M h%ќnsԯ)ւ?D`j-t]9>!h!|r JRhOұ6$| TIf_B.<Ϝ  awo3:?@YRY\bV\W)H]5`#uw8VB զAjNllu\F.arC|񟞿X@@JHMN 8ڃC2Ch#d HW@m`6tz+ =0f+9w}?wml`OP0 C"ʰu a2ƒ>_ʖ4&?>OmEq?x2 @ H&U F{HFcL!R(N,e`6J[sA_$*6='J_߿^t=?c},n0RA=uR@&ss2Ph Q#œ3+"a| l!LJ`"I e~ m E6H=*4BCL Lh0˄P9W.k i_Y lc!ſ7n7+sO~!:bUT~cbEaC Yk-OWYأG~Cd2>.h\nw^NWҵ,"#CQzpc[!`'c}b)ș{]Zs)b:` 6.Bdef0&:1<[ `:-'OEY^3.Y_lZ} g-_keVbWq/*zwl#l7TtOyw̉fw!`KW}Ӻ5ü.Or/Ѹfe=dQh'Pw"a| !Zg5i?"#]Zv\#{#8H8yp l?$6!aEo>Wwky׹;nP& Pj_ yԨg;GgQ0﫢[ZFSG[0RTuh5LKmJO=e?vg`bfW#)ª0e2mEvId|Eu!d:Zr،fP61`FhUuw=%]1wfvl*t6 ga͆/0 V ? a*lt߮k5Ȋ!тub~fMF!`^g©?CSTw&|]Ոm)Ջ?XTcC *YCkѝq @60[n:j)!a*>;r ٳq4E:>d:r5Bmbn=Y̿I咰Ϩ7:w|U{iՅ?v6ſ?8 -E>?L_%Zl5W [o`ft爺*35pN!}YoUԤp8{as1K'y]@eѥ+3ſ~wVU dpw2PWG!jnſ°rj_?DR.0 zyV+G/nbv^^5/5Xtաq`zu}ЂW"2~sR;3bM<64S])$y!L-\nbn;W `>ug;]DP|좻{|N|3_a+GW|fflV0EG|sl}mb+߄kZN*mſNp=^1_ ?{0;_- 7. 3yv>@13oiݢ'ݙW9B!}|_nw-#cڇ/c׾~ iwF) dsf  lbP5p5&hmXhKRk݇kbٸ!0loﱦ' 3l=oz Cݺ[C' d%0Zn^m ʙ CW^h~Q ۚ^/4B(/EBW(븆!?Q!ׅ~??ô s|ƻM{0@g.^|[#껚ڟE<ܨp[w}O")Sfe؊R+> >2p%󚟹QLlv1yVT_W(W.=[n}_M_E;/q #ѝwy`b-b֟0< r.ȴ 2I!黴.c+o]=ynƻkLsJC ӳ3l/^4ȭOC8="6I갆<S*\k>/2L3+W[Ebeo%"lDdulATg?v }I:ܲ+zO)Vtn4<,s{aB?7O^f<d4s_Q *6QZIF/9c;ї3mھ:`A/֛'3Cgq{o!.z0u7Ps\+ncluڈ9}9_G7& T,g ,78Qy^X#dI{t[i2:`aj!s~fh, Y$#jBJaM)6Ҿҟol*]H<":cODžX*Y`IG)0Cﮙݠpk@yҁnSwRB,"o>-~PLʇmRV(Oa G4vN?јi j|?]0@GDUyi\[9@7+`1Oƕ~8 g PG7zXC@M8?3|YVm ^U1|ᕿlvJ O 0L?Š}K#Y73)sy rl!F6%K" 3 ՟.o~H$)' dJ?Z[Z3C%zUPVFeac [X)0R ~ o+]o <Z`Deu3Cɨ4|+BT6) hX^zД!K2fG?6\1afWvc\P_ꢚ+ncSH/BMRPdk&wf% l"`v5 œkGeS|zggǠ|a&tAeMl`v{?l! 'ìOSA4kN3v;cAMNj\<')Z`=PͅV[ kQr2fl<@&#$@ώAfK@ͫ 3NH9Nt&/BjY񿤋{uɖCM1Q6[g0f+UE5H;"0o_Njdžp :sVT?jʐؙf'8$F)oDfpf}fM|P3^ v[Y.uK[ $nId11(I@@;_@ dƯ+)WS]QOkC|*o2I,Q?96l#l`nr׻K<Hԋ`qS;M8`]!eF &`t,d& tr8 rodd#ڰN.r uݜOj:\-oEndBɉ`tR͚XZ(.R 4jXk[p27о<@U !uAۗpSu;!^>8ưʛ >[wLRgJ!|<<[v P5Yݠz9X5yN?ڦeb}n5sh7}QBREhX (wt2oAcmq#( @=9vf/;.bgD@%"A3m2\*v'Nގj؀Z:>.HP2^ jR&V '4\1"I@y;C,)LGP8ڇ;+XNZioyfյ}WU$"R ajOD V N8Sas*??m! `Ư -]o3/5M[*on<C V 9\ã<֧' 3H 7]n[/] Fx1M78Bpf%ҽ;m" dd߼56RMjΥ'=V]~!$D[}!S/5:( c kHV9xζگMTGVWv4;R*R(dBHDn!@H@(eܼMę?l#&KX:o*Bp@fv.O"' dqJD0h~ ؚt};@mf!Og]ì|i%TR $T@'W#Ɠ % ,C WF@,`ڨ|T&daf ototDL=tR0 fM)-6RºE*1Ξv5e ]-kl>J:(X<h1m?)̄   b ϼ8V[ ` Ngvp@ ! tr+)6~yjfEV+Hŀ(Y$ElojfZ h=;FX`qI|o!҈#h%&6ڬFkaſgXF=9$\Or*S~pճq|hcHF{&!!%.(,AsߦIDKѷתLJ&4M&x29 & $0vvv-Ŀ3W6py{K2fSXC`fF$IÊu fQj\3?u*mNhX1RBmkFx @t|sC@a e<#D⟬7-mY`84^lz$̐fǠo8? !9?g◛>*MzkB(Zm:pxi,8` H'ݔ*BeL[I&(OFjϧB?*Kr(l`v =Ea_ks~;\os YStpb؝q~B 6[dLTzQ PC*@M'pg B 2Gvq 1fx79`TM&l`v=k~o<N4HeAdIfO'b<;[x\36 t83 όڵϖּ_zm^Hi!K* G{=B@HaB |s9`#x.!C] 60;*-:?x"qcPAqŀBp {-"ݢeںf TX([ `z7߿<k܄8OϐON+ 0@Jmſy. wLq9TNن^bE ޒ)M^uٺ6D"-PB@&ԭgbrM:Yp!|ȋAtje1ҨY+d/&&jMg,H$ T1a|Y{J:q17ϲ1pc0|g"]ͫ 3\]`z"7_!Y  DȤS߰Úij=+7cug)l BC땴د)Xd'cd:.rPTIQZGϛ>zLWK@+#Pmz fTy+ୗ.KA0ѧ`BII@raDQ%ks>iYrK2fX,\C|dsaz5Jx-=yB:1 bz藴m_Z`rEBhf߸_m2M͉C+G-d:ޥg cDPL+@Hs0y.l7nǰ•&'.,`vr6 ƜśI:F666p-Gݕ覈_2 |ƺ,.96oڢE=W<&GI(1Ɨޥ!G{ژ%  Jc5*_'T ] &˄mKK#|px)=(.+aSo]hFտ7ffqGB|_+ׂ)r=y0G> ;9@>=3n榄 О@Hg7WZܙ87}_Iz"ׯKy)\1`/ӿKff6ʙ"7M{Y\P36\;VԉйJ7GQΟt {| {ϼdt,hf]πr pQߣj ?џK2fy}zdeCQw!`=ĔZ7ЬmFX^}0!( 'ҼfфkeXy:ޝ=Kr_?Tf;z_4@RzTТ%ya?8/3a{"x²--[ $ zkU:ge[fhܪUYu̺,7^F~zY>fOЛ`Fy`F:vSIE:ԏS @%5gT=t4I@Hu2c)JX+2s;)'Uqf+=^h<Ƣg':z(+aU0e8-k8V3u3 ` FCzl+ܼyY5|/o]=ɰ=n3P0"Eu.g KQ*N.5KeZ dJ>f=_PFQJ" >uY9~FV:+n&J-|}3 ,!?:ZE iNS1UUB|d /TAV*+F| '},!H4 ?< ¾Qs?7/aVo9lDO bג/7yd+L8`.EOT%OS2tanLHKit|Go*L %g[⻮)*HV% 9mlNw y~)n [1nreƀM/}?N z On{KYw m)̤L@$_Ꮐ^N,:;cj"@PrqhhF\Î.#u§LgyKɏ{k XRP4b'1{ VUufu? IpYlVƿ CRߡ{ KxpH"B=o3` @L ,P{ЙKRꍱ(0gL g? M\+e#"~/f44ږ<Ȕcf X<8PE4XLI[BS07A-tXys-t" Z_{g}$ߚbQ<q hZ0Nyr{K/H&,߃qzAO$ܷt| /9o8K ̺)1I$Fq|Uu>h{w0!! ob3(N̍~d4&y/ȳ륐ߓ^8.S^^zy_D0UGG! 0:̴ hzYO%%V2f9ȷ[(w*?Zd"U8(E-!z*OcH`i]8E(p]%j _d'w’a~vzfia*)W3c3[D@:؏=M,nR%g7w6gX M /yHL'L,Y#4MvjHb"Ya)WؿICֺ'`Cnrlvx` yN3eX$3ROZ?[_Xrkޘ1x-fe<:? _ōE&IM3!<md~0ړˆKl]K|#*rP;_*kLaf\?Sb@y**f}J6锈.gvӉkg~鷣%牢h(/?UMDUEU|C9N7f:ʛijfE3x-f$@(zo Qgw7`ZVtE.'by:ض&hpU$L(Ep^7.ڱ:鳷Țj" '/ewQC~7nd@#Fղ說~[ALMuqi<=/xԢ]q0oj7}pEmlK<ϵ70e{ - 3> XrA@$ӗv S?a[_/8RfFG_ ˌb1fJM ^*9*bj"uݗmˑ]EtQUODU TT[E@7;ZQ . iT$=8 煽0eEK-/ ew SZPrE$ J+TƝuFL߻-laS#ȶȎ튯(ӴpX/A谉A ́F${qy$<;F-}]{xOfI*Ccf鳛x88{O(AJHOQ)r h&`xXTD*͝++͹ ,9?QMD>h{wP`$"LW>#v/!^,i̿~x%NRp{p)r4Nx.T|xh8 CpM 9 Op+ I*""p;qW ibP~Wu(*t~u-r:sJMGuL$e%L(r!׶r^8zRSLvs]_l ,9f{]U`VR"D*FC&lsV+vVF3:ԣ"'VU9W2?fg4GWDQD1f[+jY`fh*& uH'PΤ3YXj?|KeDhXfýŖ Ѳ2vSo‡{f+UVkJ8$PJaF=>ݳŊv Pf LJ6RR<_s* SbvH`y+y"EB.z;D>F+E;?9ɊQ +G`>WR 郊_ڶ"@|K)j뺨&j1OrI2*r]vڞ\߶e=/ YKeY)rH\"J{E}n`zɱMnr⹢j(^8}SA@EQ26c,c'+X@ݸn2,nmYP ?a2,3u]4;<|jE:U/Ti~3Z6WS$&Xs_3OM=ɑ+/a#^,?0!S+j*S O?k_nf]LӔUDuQt@/cKlFU+=,EQDQ/XxX6,~x,t#Y:q V)0s/ rq#gyrI㸕۶|egϥ),ym /*pmk;7u=E [|t Hz[n[]n/*)G@ "xsO<,=+3Oxz/Nޮ4wwG~Ѳт[-Ol@$@7UQr['.. D[\ʽˍf!vݷ~ hK f EHɌq_:D@!`8`r9}߃KS .1{ȅ#s>VQ՚"@rAyna|=LVUqkQDZޣ՝[|q滞ѝaP7􌙋TF,D-{P 0n\?{;۹i1m N0I`, -91Na^_ S S+]n~%J P .$gVT&ؙ=Zc'/U=ω/3 f0n|ʿO{lD6jv[lF F(~qS0YU _^1&YGSJD;;o%PC~C%?<,EAٿ%].H `?BiA"J~z6 >PT5~Ot Wd࿸`NL-vr޼ucӵ$Q`րQ`8B:\+QtN3*+ `ſ[筟oa 0b̘mt*P O+z]+ei E44k+7|ŭVrضcqxPU~TAz , }v+'{0m~4m`)V-&*ƠDg{W0EMM0 X46UhUyl*Pe3?#Y85j{,Jr1x&W'AtT! voJ Ɓv;ԁfX,Q_6= 0+$9_rhKjmYni(*Tr<|֓H,kQJK:ϣ+\=*OT8еJ* ;XSc"J.Εw=ߘx{?SUi7yYg jM> p؂}`IȋgZ_\_sz̖c Ƿz`^/?wᴁ;ۓVs_vKlˢ?@E :#J0,`1s&9th(.h&Z> 0{WˢL%yڕ>|siL}DH%xڗfLhzP5mް 绖|;ݙ (u`m>pҔC*o@K$7x%ܱd 4o6r PUD @Uj;UK#0{~xױrr!GJskWyq{ 4a&JMD%PASO%O.ŷu$rʒQNӑo[r}VL2P\;8c/c&w6Y%3?yڒ!Ҩ=jЀ( V(aE+"2;_b}z^!sl.7 N=oiփ$ .:3 M* 8d(zG?@abWJt$fiޭ0s>d Pr!L$(rkg^IbE|@_oN_|f:vSJВa$f.=0`u@LHm|ڗY0$7@dUIq濴 \?@tN+HlxYG8@Q/><NJ&d }'q9vsz| \VWyQ?-O5=# ߩK`Vz&y#n{?Ny#T׾/_ty=0V3D>$7@dV!pTgJtI5K HJdJ:!:m}49`()OY±}jݾ_?n_׾bNLx $@24@R$f%??=/ii[{JHu칵'}qҽiu]UD͗+}\M3YeO;},60)WVf|ە0_~>{d=/Z2` c%RAcw-޲)},@[<ۖxڰ!`MIn0\\=Z鍏c$NU5O 4VZWph@"w]\G5zzz 53`>w6?z,>H L uQ@`8LT?@Y2尩 t?V0H!D@z;]o@&&OwoYmk 9!N;m}49ث?0 d՜Ut{扐Oo|<(񐬷ڡsW6@Cjf =W|E$@"`ji^NO9Vltȩ3֮>{qF4c@jX8H g HU(%c4'p h;}IL-K4]ImL;//;@15^(бn ߱uE> +:ldO?Cl`Cjacc)L8 G,? a찀?:' +Z2%<|.~q:D lПv )'l+6l?_Z IOȧ?3n{,[?+G~{A)БDDϣ/L&Ck繎-H{Kn<6V6BÙw RD@YLU>]OMV$'.XY]V"/ID4]yV;VױJ\K'u&Բ^=:{6VihhF=jɬԁB"`|E IM87T Dx6z+ 4A"`$S@E\d@i%,"wuV8xrC7W&CH'&>3V[\-;)>%xqx@ffDt4= ?H l rw#)%R KT%`~@&O_./-K޹%Q%ܸ-:]_֔.YOd/vaΧDݖ誤/OOXM'H +HzZyLH*X2Ξ[{ws0j5jA"[)c %yμw#c GNP]K?T",dY'يqx$1Þ㈄Q\`FVp?z.vw\z=L ZxGZQM{U'iaQ)s RJ<|:/D@EC.O2|=P6nG=-g!z&g/%:&/ّ6xerA+Vkda5j"Q2D /IXK׾^OX3ji<^eQ" ʐGSu9\Wʔ"+0@%( "r{?hx;:p繩ACcm@jg?x"[Y -{;B?q"u< PH ]ǚ\eM:>at0LCj5CZTЂY'8HO#Ht$2Ay$US+JؖxN;HD|?1H D)@lN)lq׾u+}wQ"~亖z8m 7qgESzyL?,bΞ[oQK(V^3CU@y%f8lr!M5@٠VӕwnvO H4Dg *L9كjvO/\6 `*]@4D]g5LM} h @׉ƕm7MK$T291J&k:"w=}lezSHۂ۔ZJ&/1}ځSw7GNkF=H5 pw=ڏg G-' ~|=ͺ)6D׃iT@dV8lz@g@G@O /wKtI{vK {ulrėC>t%^/^'ϭߛR#{{mO?"DSZ-P$L+ t%7?̲}ҩAw_Zji uM4MO%,J 2D4LU=-*%JA4 \5@/o[v\q ;Ɠ>߈g 0LՂDi-b 2D4ˑsIO+(Nx{h EQ־+%71W.-qt@x!ޥ" ^m*̕Qa^eJ=JW6POUDsqqR8=,E0ex=֍ԴA""LrXQ/" PßJA4""=KlۖUŖv)VK\w@3 !PAR#y2>#љH%4-TS,'fь,0+'Ϝ]{nᰀ!Z!D"@FO+/WΎJsOڭXX%7y(z8X~3s1IwS\x\lHؾ/ar edsiV\K-L.*% >WZ>(wak߃)- (v]G|ϝ|Y|U4It (=`{ꙍ>0F5HhX Q[pc_|gZ?X@q@TIg@|־O@̿?#ߣ l+wa&|ntH?f^\-+.oZ⥾qp-AA%@oMj>oYm _6X뫩jt`X@+Rx96 ⹓˂ _/6vw'X`.Y Ƀc+Wά"p]ά8ʡ6ó}|[ЉwYq u8nJ =ˬv; i7_{~im'TNXGRII 2)n4 {Ve?fR37u??@뿡Oݖ EGrƁw74sE4L &}<3s8y{[G~|ˊ s_ًO`+{ߗv%Ƕ;,wTNZ3MAG=Pw =B Ytƿ~Ino+J/})aVeIE+Iy 넉Н~IeUSj3g׾1m`-i(9*=_>i˧w#j<_T*r.Qn TxR3 TgŇU^=r+5LWCunIVV%.뵼cQ׵:(fs=D"0l@0Lhij(MXZT(?nHsoWZ}i7j۲uXtS+ލbƉms NM.G%[ >z87J~J?)%Bfө ?eJ:T"`V+lp*lTN=Z׃i CZ5P0lyؖRVtT\eU*ݓH9 Z/X$*Rg2gs3RɄ,-^=`ێϾ{6 L'%?sq[@7$Tgx7Q?@)۶u>!sOuŮ1tD@(_ Ly%O%K|?N3K![4?ksi0bF@EX}x[={ѸlE$Z3FU)VqR)Z\奯Z;pFuf&4MpXFUt8!F '?|?\ɴXؖ4 t6Rns~0]HunPԢjKH/q(G9͝W~ѰvؖxN0k:aU+ߣ"I3[3g׮>\=F5CZMt]MSgV' a,K@v`abWVP:܏\S+v<qlij%=ϓD~JaR;Ǒmi5`UrƁw74sE]TM%lZX49E}=}O@Ց4~W_VǴv۶9 ǵ|ek:N5a-m 9@nO9ﱟtu@&'\&-3{sqaJ4VDxq`{m+ ^ֵtw]ql[lEQeeuUZMt]-?i(Z`8^2녫 @ɍ6=TE a۲jJj׳WO;CQ/ ~ gg.7tsE&hp-| giK{"`=ӅFUS@bE s]#X3D'MEU5QդyV<\4L61@rQxjIJک&8舌=DZe-,|;T"]<OF StÔZMOD 0j&'z'< ˲dg?^f6.`0 kٞ%:*&Jĝ]WvRt/}zSsz ~ˏ5nF{s`H@֍zZԐxX aL+P/O3%?}}?W6}Ff+c.1 t, ː0PЀhz"@TML߹t2g\Zx;b ^#Z"}޺#"B90Ϯ=gi͎Al,R ߋ-ےl?{n SZMt#;c@(P%DL]7s)Jxr]7<L+= 2H;Q?`V c\z4mQ"Y.Kx5哏?|o,t偍+=҈ tᐕT"@dA[pVX;)wߗm&'޸̵QiR_= ?@TzT*|+{ ~:k_~I Q`4J$1Id+50p) 7R@3 IfP|  8(g]Z-,ւ3H_O4@p ڽ<8y&H,z-DU;pq `%<PF|)8yS^h\Jn@CtM3,  ?knۖVzͷ~}G:vGD@͔QK*vId˝p=W\'hj†~';[["B(y>w~K׾ҸQiQ3DD4Ī} 'oewg[ͷ(Ov7,}wmciHiU O%_(~pT<\Ogz^~ GZ8ѫ[ߺ}땉?#Xگ0W}~~aԓik5#Ѿt³˶mnmyG?\ުT _}ԙs1%xXV"2b sQJ@QD|&!;)Qߗm@9-Lgϯ=uˍ ]7MSjӾtӮ| <8u\(j&ZQ$=J'eI+lhMb]@>w~;Y4%]D5T=Sʼf&<ύږlݑ*;~bm:{>f HMQ5@p LDC&}_\ǑfP~J36WYÌau҈mQU'~.o֖[Y?x5 zW4]MMSaOd^-i7!58@,I_ԃ$@T:G޾4v2O7|F0MjJP/O=,0n8 -k@߹8-"[oPIQh@LʯDb(=\7o[ۓ}O^qjOKsm̴jzlQGyJd8p͟hc'N=cίa" P0lEe xX&&| Tr4ma쪦ت^@ݶ-.{𑍇{XDȈ tOVXvhm}Oۑ; UoTN;s_n}u3-`Q/y^*oKs_n|L_Cnwa;iӥ0fL$v[nߒ[7?'_yί-5c@*Q5h2 6(T aERo> _mf] = TMT*Ixnguo@w8#RSj5Cp`@ЀdQT8έ}@ʪ7C@Sgϯ= V?dp q$sK~wɵ{q܅ttJT 2LhjǓ;@ :nGٿp}q}a]Ϝb; v[ܖ'Ïnc?`i%tl0mKfj!zdͶ?@e#y^[4l#+/3/gf3ZJj@_S n{e;%Bs׾񛿳Mh̶?tέrKz<`fQ`smFj~vMfW0QmEpYY= ia'VKvO~e"׿_ 4`~}/ɇウ{4Sמxƥ_J0D Zu{R#sמzˍ/߷n0n =w6}ɜ>wa?4+AʟٍF0.}~g4A7h~v=Id@:mߕ{=_(wׯ?`oB8m`?jhZa'<qıN{{nEH&kO]r Ӕ9,{Qo[XV[vȧ?_%`xaԴF<,? O} y?o|/_/ P$Sw jghQߖ;n}L Ԝ>{~k/4ti֓j&M[M,Kl-v[nݔ~[!ί}WFICt]PhޮXV& 0u1 Cj)zVDU5LlnoK/[o`>3/J0iM.FL8-fS{-7?LnB~ F@0^tꪬ4EtEui6ewGܖ&`N;na)KIDATx}ydWyZz].d&,!o`C Nr/矜c$qv,ab0aI6, kUo˗?{U]3]3#\95]}~.0c1c1c1c1c1c1cp]4 9;u_dRѥK[^{¥Я[={0A\elV 櫧5۾l"p]g2|e& 8ws"; TItLƍvsY{TxIG>`Or BZm)O8lrGz Y{wSn1.]&'eC*\ bwbE.A-$j>r}o?(N| RAa8sqT}?tR%?Xg8npovq]%oa!~q}\xs>xoxp bU)OYU/?NHˎOn[nam jj 97@0F0ExA L82:_ɸ9fg~`F/S\Vx˧8-_~qv-l &KGX>08}$/"i "3.\\_O+dNZ[GԑOeAS :O /)Ν 10ZmB"V$v2l np< @D0*R0M;ސwNZIUJX=<{HKN~+; axW0? H+@j!#/@%mCFMp ;> 7%D"--AT[kIm7>KIqvKKF>mwq'Wob\l>&d <bh!^\`w<8n\i\ *d2 zJNI_a%V*\ {? ZoF%h!j,AF+@+ "Ȩ.܍ \p (DP-c$ɆSI %Áe+uJJ 7w]O9^uqgeUFX1H>$) )は" .u10VPIZ {I w/Q?|9xϫb?q&~1>MFa~+FCF $a F%Ct]2 J/W@* U !ƺĠks<^`m1o-j-C57kk* @MQ &[ #hT^Da kۂ%B>R( [H*ljR0Fތ![IsK8"l+D3Xjwэ,!$"/@`|KB^hVN5t4*ѪFNLӻoA~rpW"3$t…_E0 #n-]_DZ7[xȑa[ k)"r0c \xµ!D2@dg0Q[V~qX.'6Q^xarNpuiսu/AqnPQRmV/ k,NB0!켼Nױx TXy5,?fx>L܈b 8N}YQwgxAy$ 3^sۃxX%soey { s`O֡uFvgQ>0n*BvI9LN_5h#1'a>rroԅ̗鳟y7^P"PkD`#("?^PB~jsh,UF/hJmTAeYhaks0cH[ XYJWcjUd pjpV8q1",w 3$[0Gaf?r]Zejk]Sch7ϡQ=c0.ax,Ft#@ X(-\ƟF~rD9DdcRbGN"]E֠eI^H/& xs#w<'w#(ar tIgaӶ8Xqf-QuI[ܮW#?Y9 8Yкb c dLBj%q m+j\pCTVe\6ORahmP"D΁˽C8 v]㘹V‹O,L:祢4S C{}fe.2m?`j嘚6.uA H5f%Q pIm%M8Z5j}9q$!# 4&ɜ1/(aǕczͨ/ѯaa$6zVd"#Yb A0WPػ(čeDw1y@}ƶ?,T%.8%B)$LDH%ᚼu};pX0mȀDЖe8Nӳ7cnve 8w:B-E@2Q! 0d[|mögi2+DdXdA|YI ppa7󥝘u#0qٯt]^Faz?v&goXk2T! kK6ch-jisb1 @l;Ȩ 1heD\xPIhWdP`wLM.gĵ}X<8#-<A7 P܇+{ &mH#aTw!UF*C뤓DFg#P q4Sqe{,=l 1"YFS'\/%Cxs"0xy`1./ƁW {O}{OC&]Op͸֟Cˮ!.\֐qa}IXIw]h,YD}(|VW*C_x1 nʜwFCmAJk:mXx3Mۚ{o;z*gշ¾ٙqhJ5+=^wľIؘ8`Tҳ* }Z7(m;Kytj;gܻ&`~fKǿ%w;t ؑ$w=Fw0%CAv `\@X-6XooM8"(6Bw& &dhWd+Q /h4$YϞҎVijf@A& TA^1 D] m'@+ö͌ ϹiJ>4Jn^/=V4!n&6J!(N#(rPJ1VklщlԛVI*FZDedҴfg 8ۆm' GMsmκ^l@g4d c ZiDm G4WNr*iF0݀V ^nAa+BZ$ uS@3Fub_)ĢcLJNz4nEabvy@"ί@H"@ru %5ⶄ'NhGX_퇷 cmhm"CUlУWJԫЬJ{foDLlq9ra}eW܍U/@DRēU;Zth(QJxnp 1?aR$zXL_7νҕ߰5~GN%!ݹv1=D3Jݔ?]eFIҼŴӳџ':>tբs+#%p 1t!|0d;_1y;I;4<x<[Kp_xw:Ak]ȴv(H狑1¦^%W8T =_1i\I`a*פzJZX.SA lRNt~/ 2)Bf)`3z3qߡupW?}ם'd$F@bt:b L(/>zkPZ(td:dH*|+qƻeehJXI!\oLco2#\&'? 6<) X@1 kl~zJGXgU!Fq*ɯVy_ə ,V- [ X<-zbNSWpaG\8+,ܯ^#s7Wꅇ47#!C~۹ jգh6Ncb*ZLL]ݿ$k]3F8BV;~2 9D'VPYy_&W5F7'xHJA%J_`Nkɹw-.B\%\Hon! h C-ZǨRr*iKWPY;^ 7YjDu9,= )AݶV{Jd`t%4R`iR6; @N`$V*GP'BG /U&M,j壝!Fͳ h 奧1՘u TwP^*^t:f9t| N@x} Vݫ1Pq&LR6 Ŵی j @ۋX8wh7Vb+'FGakg?PY6}(l&$`B 6BZ70D cMW'3yINH"9eDhTarzj/"* l/A>Ҧ6fLMER 1p.9v}\^S &:׃RVFuKH!ŚP NX]lϪi658^vG`@Zu%:)x>#l2$ZET [բ{ 2n[q3b *I`w}u.qnv>U +ysai *_`VzE}l3WoO{L=FC:]ą |{2'7y 1bR#b[I%zkl6\zF 0aHI$[(j(;斍6 t ^7i8`.8Hf%W>ΊYfNBCyMI"ؚRo-f"Y1.T `CHݰqZ`pnH =7K0%S (ݮApKױVMsB.CI g[L`Q= :}t;:BV0Q+Z:h I>oDbY:J:<. M SOM>\X2$$" 8-Dq )7m I%1NhQ;7`U.{Xp#S@`ƀcn:\i绩tQ! Amw*Qm_0&! F,.3\gy%QuLO.ak/x=@G[7 nh`=޻ͬ}La hSGw7'(e'0|[ Kneׯt$@oj|1FHULy@qCXȐtʓut>Ҵp Y Ȍ~W0i._K0Sm{Y\udjWTgνh1/ILbt;֓Lu^"0љHz7l.YpVhaAC"MXFDB:W'r׳;1։fɞR$IlwI%}.` C/ n`d?s+MJ m7wXM˖2r 2 -+ܾ·1[tY0h3 "Cd1lΡtr8^PԖ:cBpO UZuC %dmyUb֝uM/Mֱ>CevƧ%8YNnd^"5Lo:π.zpSVm \aZ1^n{ݪEJBSb L↝yp|9™ZD0guݭCӚ:p ]YL:D0s8~Vg{a$D*lU"]ߖgG'S%@{*nWJ3\A1x}oxtĪz7 :I51S R-IdAU-WjdVY\Tb=t`t$|V\}>kPi^K`%|6fHZX+(-85@ˠ;a٢3' ZْZk}:6<:9 ZMz6suP\Qv WB2i!͈k:DޖmFJ$JT0+}S53uHe:D s7 CX4bk* ALtm1p q0c M+WK-Iޞ=3"T/5D&P-p5[) mҥfu, 8n`o[x%J[C t ݽAz­ F-$J#FpsDW'`ؽKccq "unZ{&&Fߵͯ+5sW pnS9-Sy(`&@!U=&uv9frsxDŽ0&rA."@ [L,6X׿?ѝ/'zWM)¹ɚD+N~ @T[ [%[m9f4`. s9AX  &:]:\0$h͍ZRJ?"[{ w8:7+}RC0շ.9-]d=ـ~wyij8Z-}?z$ۙGng]rz0qGw(n oB`0vg2Ɩ?=6UOZ&d=1)7KGnޖőpUsrt]7s]0TGC>Eqp`13[O& u8.#!P mN"HT[K ȊD؟Z uS,hߒ>|XM7j3]7/csl7:E:I߮;(w[73bc90S2#@' .XiɎK\Qr0Z+(%Ds98q B!Ŗ|Sh eBzc䃏(r Hxqg6Sjf*2F$O7ʖ p]}=RݾW5A@z^7g1-E tWN ]c(K\B?1t}4cH0FZ^>wnmRqm{pq?K4DQN2H?[\j:$&\BarϹ?#@P(8YԖqE^"Z)UHyKׅp8w/JI,; )nLֱBee{gYbMnY ?x3NdU>euo__|72}nc|cA>X+,/0F3DUN) 829l/bG/TWc?W[m;'}tw<`BT[*jttO=eE yǦۋ=~.w ΢Y \A.S:}:Kf Ig[Ƈ翆 \~dPq/QrO'GeI콿v{|?8J*h ql7\;119A.7# }$Hˋ 鮡QEO7{K=[l Josn+~O/p8t=Raɩ@FZJ$n5_l7+ g0QP(AQ8+KYn>aZk_v~/mdq áCtXD˽u݁UH Ibj6V_>ڙORavb _x^r(//Cq>٨V>_S]_tdL1?GΪtH8n7P?/2[v sBp[-,-RQ7ᇨ ,=qUqf}b:r{ $qYo|&,ǿm=N^UįVAO,k_.6^8xMMd\6&`YT+F;gydzt]-RCRʹS^_F/idϻ3PX޸8p̿ ,|e|mz1CA ᄍl4jÏrQ41./3c1c1c1c1c1c1c18&\IENDB`goxel-0.11.0/osx/goxel/goxel/Assets.xcassets/AppIcon.appiconset/16.png000066400000000000000000000012561435762723100255210ustar00rootroot00000000000000PNG  IHDRauIDATxkSaƟ|Ӝ1)mvAtt JqpSDDpPq pq$(TtQZRJmM/19\rs؂> }x9tU[Ì3݉䯀;U]09E2Sԫޑ!@[oeP{( _B?ל\_x<I$^ۮ UEm#DERJJA{Gύ/l3 B:?3$QD3Z~?W PSyEVe'1?i-O<IfO@Sp+_`K΢X] \n~iAJVZ2BφBNgSTR%1;e`Y;Q5wxu0F` I7 e~+'쪐KmMVJEBA@(bAoGpZVWC170ĝDA@y A!E~2ϮP}&OeVdJM}a2i X172<,nj7;jYsj|xrtLR)9'srԡ_ /m_IENDB`goxel-0.11.0/osx/goxel/goxel/Assets.xcassets/AppIcon.appiconset/256.png000066400000000000000000000607231435762723100256130ustar00rootroot00000000000000PNG  IHDR\rfaIDATxydW}&XsM,h ؍lWŲoݶnhgzO=c{zfi/2㥍X$*T[n2^ȌǪ̏z*#cyラo2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C @zaq?k-.JkF念*z W ]jӧA3!#}S]-u3S~䣿cM5οQMC%gCAVp #)˹V<׮|*t6<ǚ齿sڅ2ң'T>)xkTNA ?]j> ad0%|w7sGʕު%ГoUNIGngwjO]zϟ 7V_NM]'dZ& Of8z}B00ϡ_Ӡ^晿|:z]'h^A+ 5d0A͂S__ɴAF>F:џ73GlaR@0_^wj_;}/ZӏWbGt3w#զf0")BU /zOڧO~, 12^,!)n4cNP-A5^ Zx\[S<@0s'qnm<u62##1p)mKGr~@3!R/x9X{>(,fn"T o+hәfZR/ _ 柇ы/fZAF#B)w]E5#;hWΣ"N[`a8eX9h r.!@>ڇ" A5_Onς'?SOʰ=2'O>j,rKۨn-^vV~ (,C-hpЌ HBʽkT3`:efu2FZ V5tk_'XVpp`<ǜ/a&H)j]CЮTBĴ8P B#_-t :D؍p7 ,h#p|&4̴ $SNi/i~X3TzJBSU>S?=!"@`Xyon0 u0ylL+;x8g{]݀"M2y$LD+UU إ}]!ň%]M{b~Ŵt!K|N k&BFtw{)%$!84q T% *G_Й? (T_w2pmsqHq g?gX꦳L*/J0=D0 KhwGY# ~9Ǩe\pjf0s0LU xGd 对CkT_?yY\/T]vʶՌHUޝd}ןРS hR@xr@֔y5=^V0{hfnݻb'x~h<訒`] #JR2mBBjLGu.̋2 JЃ߮"*R:/0e`f uRr _n9G ."?A3@M-^ ط]GzݍɫRЈ$IpvRBL&xMUW᷒"iY80SݩR@2IXð+$*7돡)IRoj__6töiRu 9{PU{gHnoU} hV_D\(Kw0 LuLP{$z#% 9dd͜t̃"knW^W?1bkơ%SNiG&;WW6/~@U]ܨ#_ygxXeUXkϠtJw-xB? tO!zx j@7hM7Э2X]äy "lէta3CKX|,?w)S %BJvfG^o 4k"ڤT_ s`ː/Nz)$dԿCU)!%R&UKU[4Ԕ' Yؘ0- [.Ter)O!ۚ*pE*~i!RrPYy ~gska:TM4/ WGCqVV1}L%.1s=ɔV02x&*=2I۽ORʶMs¡%<蒐6XHTb_=-Asm{#y~ ;\}o1o'GsKK[~/Dj7iJ[ؠ@` {5Y"kUJ¡%g>#r7?T5" !y$(ͰU"ICSoovUT~K)VP5tZ+#(kmkoʋwbˑ//|z[^=n.,/(! va B ~E<ݑRBB6B5CKk7+"]Uas`~KW寠, s`(.`iK;µPu3 .%"ŀi#pkZ:S>)% _AP8->};}]F 4H !$ #vCFVN걷 wT yj[|| SƕY r@G )Amw85CMVaaRrCv;v2bTsToU99 tЮ^Azߊ[;ƿ\޻ V!*!Xh6q<J[a%Aix5IXT|= am`]W87o'rɏ?v] < lI/_TE I!8-x 9Hx!lIdꀤ/Eҿ,젺M֞ߩoXP!6iZ6joY{NFt3tH!Tf:|oo@G[鼢]]WY?uCMM- oma VtSV_It>.!7w^sex A;' `Xzޫ\*{~sتqx eX- fE}0D}XAЩ#p,\2|.n5B`Xn$:L..#hWiD-\h' \=@-ɥ <*BcR%^!3ۑ^a7Qm-Ѝ\@SU'']9"f~ ArB 9Xj_Rhl{~tVAۣI*,"pkphmZG赒ɸy!jJQ}Z9^q Qx&/4:wrysy򽰜9FZ4<^[MQcW o"i':WwÇCM7;[FQͰa8%Vq];s4Â3wK>vr@b(ոF#P ?MHAJ}G 4mb瘉 UЅS8܍ {Ñ h$M!n ? uU8*y!󮫖a>~ J9vi׻v':"-h.zhfoY;S?#Vp*T苜%I@ H _7(/ pv6}bJnSI[;XH;wk{?PӧȄRniƞwrMhEN[W8ͫOM~oxO8S(;HDA}QBcdZtvx1(հp8~/T1N1`![ ݞ4B)%8sW/Yo| yݴL _,T3 A7/8pJG0~מ3hTΪtWFT\[<+{@) $T粭0(o=nooa :UtF"GHGB"+8M0B?$T:|!C>|b$!xڂЭGE'`0hl_F}95vGv=],^D6iØqkJw8w #wp3 <TXlzo52$ӱaJ5_:*:Ԥ &aD &4RJ}8j?=*TG?+7<_Au;n`K 2 ])@P TTot<XCp";8Bn-Iqq:#9vDі[ ƙ׺z0 A &ӊ#Cp>yB0g{&yB,.݁#Q5T.͋. H *5ɖ Ph$v9 y_+@TN8HY"1L=LF fthIG@p 4 S 4xG|熠C!%8*XX7K_'Ѯ]LS]DjPS% 4DjC3ǁ٘Qb:eĉ0oW0ᖼ".$i "]Ɂ@{\p\HK6 49|#C6HB78y#?oy-6/?OAH- *% *\,i&D0fKKFiv_2շ߭to)Ꮬ}RHdoC #mOH!:&իz4"$ b"D/鰘;ga۟(*>*@_ ,|/|T|4d;b"R9!@4MU/j\S<M3'F5PBgh规L$LruϯCCONh ȬIA໑F`E/j5x!8c[v*)EѷiRfpѬ'P֥ZK)A)^2aB3C HƔЗgAr,. 3 @J `*TU_SݞU)oRV5WCgjAU0й&0{# t0- _`4."s戛Э2GC}[X9Y]x^smjLtIBA$\ x΢Q-5$ zˢ.; ju`aT8IJqTTzQf_*2B{]__$:rnev `0㽝>mG`)"p,G4[`~琴"tU݂ㆵ N2D P2a( h jOȱעPnW7u5a~yG~{aЎ ej-1HR&2s~* Ɨ0+"T~T5@}7$<CQ>vnx` Cr[F)%,XDi.)tG~M@ЮL'H%ѭHAXRp:#CR"B@ 0"t <3q;j:toJ"K=o GcG"0zANy:c? {C|)K}Ղ/M{MxnVzp `36iB<` 5afAc@52UȢFN Ga&!t/|o !B; nVtE' F*&rr)_v-2U\?Ǜg^1=>rcM#j8A5ns0L, i9[NȡT r8zۃ\:V^Wo'Tܑ{qP%һY}~0mP{tw`^+vIyeЯj~p[>⺜~ "lJ!jwRLVG#`76ՔnJ[9a`擨<>ʥ=D{t3wNţ`G'ЌhoU>^RvP!.J]<͕)xpv%Ah76)KaB娡wC/)vZZ8"N܏Xyظxn{]>)؅e[M=> $Ia~~vvCCKzQ@3 Ǭ8fL+Wn>a4 "ӁnX)"/I5^Tazn2^*߃s_ƅ'i\#w~7rKaUEr +)ONξt0eK! nEXBe)4k QeuF). !`,M6x# :!W *??0{nؾ B\P\'nx5)oET7B@$c.vT؁v~?=B$4"*05t+ѩ'j]0fu#_v!{թQȪKaA3,pG)"hAUET3a-E\N tMe ?(  oE]yx_1Wխ:Rw罂ξ㡭96g )!Wq1P[x-8:" RU ˦`!TOqDn}ϥL59gະr%X"B,d?)8:D]=1/y["@}y4k硦8 OV yp]&3BA]G.dR驓R%`` aT &DB!xE [}] B+Wa `!G{FMDx\զ;$e[39-A @V#һ% ,L%igY,y,0I ۓLSu)="OPKp+fla)8{-0}XN(Dƫ#D `~G :)!}"z)TsNgG>I/Âu ,L|ʚ|#?}'0/.Ec`!Xڛ*`5קԿxC~0_H[bQ?BIUuЃJI   zG;YGun=*+kBk3AϬ{JKUastZ+Xމ`RA1<pOD~v튲y/raׯ|g! a`!|G'h!*uQӕH׾+m'2 ^g_g,Dv"SbR`4z H!갍j h3A8}zUR!^} }aNrLDD $B)$ imE,sƋBp YD ӄQB[ACh#>~&&@"cڍzl?@7&G =H@VȂ[n\+sp2`i"\&} L#}$/|ĦA;ѿ Ic $[ $U B`CungUJ#2 Э c]|rڞ ;YnB\nwq&'ws\m&C*1~ɇi6G:FT2+9WWӎ߮_ z"{.Z |w3bҦ@Ꮖ 4 Sj7II-^KN_mrg 3C=䜉 tګ(nl]L#rʋwoK4gK6{&&wnNgu=M4]ӿž !lyh sQ'ox\=s54h7Rؚ\z5h7/m"?W L"vCb'gr@$ V![EywFاUBS3,oo Kl3g~13 q)զ)DV":'=Y h^\XS׶Go/ ![˹V%k`>#)Սt;  q ]z≙$ȳ&ic@`j&nN0kNq޿L0Gv2${[g_B "߱(tK4üMr?wsnxя[~_< lʇ3Cg]c82vMRG9=N=H(aAz$>tw- p~w СiwK &$R5)yHcv~To߇tӂU<嵥Ļ3vwӯ8@lA +_Gaha " t`O}o~sp)!nM3r--#ě?TN,@MӉSD//mbZ@=RsT}=9>]d)๛ظU$ʡB jx* @WiB> 8z~,7L$FFhfٯa} `Ϟ=CX4Ku$#CtW/ވWL& *6ןFs(-J# -N @lj TJMtĦAo0_/-Jޛ}ʭa<{f[|rӇjLlIUp ڋh7/R+W<AVC0)0B AAJ˯ļy/t}bwkEz,jςmĂ ^UQ<{1tL{8d ̧ByƳS \_pڧw˜J' 'DmcD  PhIn,J~' 57SȽZ%}L&LcDpg|$JP^ =፴;  :~緔0`bn?RJP)![%&Bn07jVuF}|Btr幃H,-]8QXBVLR:Fy_Bq1ɱG=T$Ԕ029¸_o"&M7uӾ_rqa׀3sN9YWUfpkQ*ߪ<ڣ`Zel|[n;WJ߭bm>{12=Rʮ%^'ibP2٣>o$Q' I4M7!u3^F0DӠSG!7]<5h'KE~"&Vwa(oҐB07͵jRGI){U]~Սg1t'hlʪRBUO"js)JS @_~AzC8 @3@c@pzA7<Za62fZ+[h2`SWϢ<hD0B7u-ImcʗQ6‘+I>@ zX93'n^+HI׏|bXtCU9=Z"Rfœ m:Av'{U_2ڍKѸaP4Hä*X%*Byn,{5]"v`=l>/e*O| R@3,Pӂ@pلHwc_EPcmL@QgP%R ߿+_۩lL~D}IE54gQ^^BF赵K_THOm$[;%ɀR("`4 A %8]0M ~@vll3Egݧ}42kؑz̀Sclg_ODFDU6(ݎ>混N Jֶ-Q BMD"Q`0PUARx%ݝ\TO3f-7Ic+DtSO)j Q({ v:lMt Ma" *#RJ0)%y<́491cBӵAb"8ٿB+G^<6מӃ-i'msmw$wM>g8 ` ,aat 0 ,E ?@Hx\y$gK 5N``aWϠVyKȱWX FywgN]%! >_tXrsm~NmMF)%$S4Р4݄4|!Ĥc?A1D~Vթ&7L3G`^ `ֲcCL߻s%̠Bp#U6OzC8 R!Du.)8x Nۙ RP?<ܖ#nvPvW9|կ4$ns t:}w2ӿ-lШBtA OHY-!!8? }-( @Aоb2n4a)8Bn:P &;ك)8 |_En0@K).~#JBzRt@ݹ~cF?;=RpA:DCvaԧX4ƤL@rL]F*`q`E 3tj]0HDU{FS 450ߍrFmRJ"#!) N.Lmq#`4 >(z}DJc6ePd}ίiQv^+5'&,fݾ}ײMGKA٠LcMbp|{àdHȢ:y+I4=*!M'sTn9} >"aN}%Aځ(xwЌh'42#tP$j\@~mRvd@wIAJ1 EvLruڵ-jD̞@n䖖P!&(˜80%TSe"J#`a|. 1@x΀ڞȪ,5S}٬Qx`Gb:oy%G˴" e+o?J^z*p̘~om%6F?0pYW&el7a"ѧ{=G{ n)p_$syb?@Rj?2z;_GL&0D4c)Dr¯)8sfQ i#!N!lr:?O!y#)_/ R0 0/6qáP-gX YJ j(]l@=ockXGS>繮D%DǠ~Ÿ>נ{BB?wBrryaf43A@MQC B!$~IgQJ^, VDP'?9%Ѩl>-8T$Q? DE2/XQy3 ؁Lcv %dtHA@(!>ɓ/a$;逬wNq pO*ŷ7s :gjtPB,h;mki(sGE1F|Fcf  ̻'A vx"@(MDF?Gw/SdͤXRrU +-9|dP!QJx}j3K<*.bG"~ *p, ݱ]Z2% #\pJ(B\DUM <G4_SVEIŵէh%帎wr8^pa MDl:1P- e 5S"gۖώv'?]:u䳤@Ӣ:!X-@ dh~" ܱ j"0`6\]0m5pÜC;L;LL-vGn7֋l5nE{rIv `!Tt+ʁ&@=?"lC㖗K)"[qf5@`1oXo8f&!@F$2aGߠ$/bAS>ΖO>~3 %͟܆^lM(Rw jj~a&9 UN"+246fթ(Se yW>W<4-|] TZ`~wU_\ 8--Lbh "t ?VafM3>V)n]t[Kh9S;B@4 fcLFF8oIC][:(J@AI }Z_ˉJ(2enG੆1 xg`^낒كښ9kD9S=Grxݭ%ܲh]>Qա%xtzHcBر>!2 JK0rm}{2A2S\ؘY8}4,geG' 8yK t@,m;yϲ0dgO;-rPFA"c@ Oe;G8 K&=`f}$6"QJ\00X}}RhqCP=8!=GBsI|\0bھӲz҈e@2tkk"U<=@ !$pBlZV80vA0ga1oJ(l*ҁF;,$4svxo ]$m6oRRM_5D>i4 ōHumKMr# FFÉ =R{tt;awI9ݿa FZـsLa9 ?H.N6E4@%`i{Ѣ!V[ !"ؒ@( IdFNu3۶q =N}'}hk駉 B?#em3($Ä?:gK~L@Zi8 cG5/2\t8+vĠKw4,P%M.$Ht==tmyi @6|نbتatH9&BPÄkC:{K[?1p__ڬBP|r:*njhAǼa9 }>DH`$7u)Y4˝9GhK(rFLo<7G!|01СRf)x'd07!֧=b =W?)?+1MKۏfFpӜKun8]G(Gs: ˶ @×` n^ߩkpޔaCjM#"Н%ؐk_4FڨOqQL"?zBW/^|Vծa(ْBAq碉ntp; DbqCلe- /ZsBN2sK-KJwI&&xLrǹdJhD@vc H.4-XvhTiTD XiqxLBƅG45AYoU}7Y8^ 0HTX<F<'iǾ7VԴ?;5"G753@ UwN@ar~Jkk xԩSYX'77ӅRr#a\PҦ:xKA%n(w"&9 ӄm; h$Dp-C!PՔIY<-!"f 3`엾tlo?Sډ7$܏v=I4pZ=7$ᷪ;F ;BW}PL ?xJP*ϽqrS^ew@ )\Õ`T2P DVDZBTT(hktBj3z#i\\( @"?'?Un" !/Gg?Tcae8^u¡HEq˜[' CsA5'1"`^A10k\x衇^vm'|N>ƞ9*BU7]dļ9D s<Pݰ !\&CkX0*~ &!j pBgIyo>ZnO3s TDammYL2;Ί$8ucޔ+~X*cujy 7=\z®&"9:n*iBd%` A   R!8G!8&)?~2̛vC{XyJuMR"4vӜKw^G/>>udЇw#w͕~:W(ʶm}\`7CH ↋ ! N Nth]O@P0 e;0-  * s]TVa$ ?ս$bXpHtZŸW2yͺUI=YN9I&R  s?k42 Gry'r͆iQz/ f+*(h7pDhASOR$]wP`c})\0ɐ{>*'ˆm=9Ci(ŒRpɼ~ #mCGo;Jw8>B1!9TXh7j0u މ$ cv`&P6*kmOtS.V6> \5meȰsj#ڰZUΔU}˘A2 裹0R,~6_,vrviœ$@9MT77 f*m&EF.t-lnsiOG0z;/@/{BΰZGuݴx!h X ~Gk?\y}tih*KJY=Pi-*`Lr)ELy=;Bff_[ Ǩ}@she. 5!Qo?ݍ;/ ?zת c;痲z] xno=/jVi!~:suWfw8Grw3ׂk|Q䋥-ߟq44Zfeʀi1֦b|m;NL?(z٨V݌&d|׫Uk7C:woLݺ+W~8 >w,obyƒ4MSQ xno֪FjcBreMS @QQFC}$BxL׍a\`a([ӵz|};փ>>/r0Ds1ll͋RZ[7f[7K凝|m`_6/4k_?$ٱz9kvα4MB4L@J67jRs;zu_j0-o/?S(_cٻkK6Ag?}bZ򦷽X8|B˶5-hS)%j ڭ|K)vF~sxC3CL=RybCdð# YVzm}wu}_P*DT\!i٤17 DNQno 2':uJ/+)H._Xu}$NnlTfu_}sS'O7|SbN!hfp!P؀iCJvڨ>67Lg3zFJss?[*r w]׭תV6N9K|S.WhTzK._(%.FZjV~̙3nnG/|gҫ-6T[9<Ӫ6]3;OCxb~BᣅR,]8GeuFn "#GϿT{T4 @pӪת߸ܨgNmJwXBb|/4҅s^Z˄6!jKˋҏE%K VkVxUY>F3/'ŋO߳? !#CSN9.?[*}sM\_GYYW+>~P>jthqޯTy<FF_+-<7RUe \p\e}vOm8} # G~湅//?j4j%T BF>ayEקqdȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2dȐ!C 2v;l_IENDB`goxel-0.11.0/osx/goxel/goxel/Assets.xcassets/AppIcon.appiconset/32.png000066400000000000000000000032601435762723100255140ustar00rootroot00000000000000PNG  IHDR szzwIDATxMl\W7_c;qj'!!BբڢTbXDvQ@dQP`b@B(HHT"- RBTB붉73xƞ7ͼqXӦ'R սϹ8nwSAJ57w=%Vؤ\Mܑ#xع1.xZu:'0)Ȁe04ǴO6F yJ0#~Z qTRz1rb.7pC8yCVlvT G~pf2m(Y@np]=)T"4U2Y궟y#T]ՙWk' B%!n ֤PYEq0. 8`دqpV FO9 Y-`U$1.Aҋ,FܩȀ44)q+- t%5C%mxzu P+])܃Odp|wj6/m{ҏ.Ch-ΟX~*n A=[ռص~8^?@kTޛD;R ۫  h(}ĽX֯G`B1) Os `ii1;~ą %`\@>v&DP;'^[06Ep.aAm!/! א +;0Hi{@c+@%w hAHd-tE,!*h7QOto ^' 2 s>|:Ю-¨Y :2*Z}Cw=rԿvI N.z YrcPI[. Ktu^!kdž/[a0mQQ< ˽~p.[G_Eyu!s>dg2p~Kw#&m=Y>V]qő [C*Yi Kex@}`,BAF'cY@uC,L.]n2] bw .0KE-$#(]YX@Ƭq@p0cpHzt|ZkaT QJV` S,mm\>a= uQd5|?6Y@:bX-k#, KajA܀v֭{3T/bwaεùQ_rR(\Jp ,|I kҤ5PIήnεjj = |LI9 8Xwzw9 "9(i"&Q՛[z6qog{>ѬU~2w򷦧}Cͨ>?[<̌'8W_iq|<IENDB`goxel-0.11.0/osx/goxel/goxel/Assets.xcassets/AppIcon.appiconset/512.png000066400000000000000000001606251435762723100256100ustar00rootroot00000000000000PNG  IHDRx\IDATxY$y 9rnTfY(!`KQC YARI@cqf43P1^f2%5=$IPM^ *T{qc,p{Gx7"nĽTw,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,bX,e!g}e!O~_U^+g}P ry~֯]P[ @qZ,bB>|ϕ7)՞R!bA3urF'_~+`\ `C^x{??K_tj2P(((!xTi4Ns։ X,X,O}W6k~)]) JA))b(@48lXrA 3!:+& /:%1Я8~u3Aԕ7TwXV KK7~ܫmHy Gއ:g}"Yq}Vh+ډZ/o xuXV8/翄׮>9^QRĝN>~/ N(48ګ/:Ή%۵[ZEW  ZŲX<_m?/V7~ѫlVڒq8h8jFGQw~{+mɦV[}qKY+WbYa`Y9^xg+ByuK+!O[16u꯶{G߈?oWƒ}-鏹ֿM\PNmz,U,+ŧSZQ׫x: `<ၠAc'h67;iS_JzRwfo+5v X,U,+sϽ}>ni+_=ի2Mz9y- spGo.S`}Y?>@` XX/t?Wx,zǰGԹ bugT8XX.O/ׯO֮k? eeX $5e i~ٗ/ֻVpXퟫ X,jQ,爗|Gj++ȼC3ݤ1u`hF'{'C~y4xsP[V @eẕՇ X,sU,3bW6%R4YKT)%:Făݰ;}O'OW pK%"idN7WGŲJﻋey>wT^_BS2HcK a>zEtU?J0Vep*W^$Nxhˌw/Y^Bu_*۟un賄V(t)!L; 6:af4?j8>,?pq.崲A[L@RQhF X,3i,K /:>VzWr~e[ڶV2mu-ݰuqHsƵ>>=VBx B:\jz:"@?;ǿo^X,{)O/W\^(sοOR q=Dct{J(][9>(x\qMAh|uhTsK-+Дq؍GE'z,~rF?kW}D[gV?#= 𨃨}qPZǫ90`_[ZS)HCBPJ+H̬Q"uo[[_z3?6_tKk? }fJσCwty5Kp(sAP2W?f.ǯ1rB(jE@$cx峩^e$lY/Dze9^!(`eiZ:/lq2qWs@((e T jB0`N JB BpeS&͘bqpb U,♟'+c/:^٣MH)L {yԬ&)aKGob@( 9&4h`n +1 *řR-hKX~[oZ˷L\ɡ Y~>B G9FG4!/x*'Wh9e3Qt RGO$[[s=mz,UZn?U[/Rlϖ񸃰u} V䀒ZȜJ ڒ*@ A)+D!8s.c\PL^*y6o׿M⸠Ӕ)R^?GDho(%(MÌP6qqC aA;xL@3ULy-\4VWkY_}3?W~泎[b0)|SaqpRl+5v U~q*uŁ^OL@"@17 N4RŁ}W\`sϽo|v/kW՚nKg'WKܲVqBԩI?4V%yP(+BBO!T:O@-B@v?hk/WX2ˇ~KƯny?BwqbR/'VJkf> L0=톡`xx`&}Wqv ǻqql XV XxC?]U-PBv~nbJ}F/d;IҠUL$t#(?@ _}7#$(j܊+lGA88$8^J`K^q?_]E+?,"Y_qDvKDjw?q|5"`=~ "R HG\)y؍W"\_O7X[Q!<% :/@&W  *¯^sK= d i2k? )%ӦByfpQ{V)o 4G+`YJn9LߍRuu+4Qx gKD3UelZMLBl0W71`֤.39+ ݶ^rwx˼?kǫxt̆>4b'V䡎G̸WP0?tR|a新n,$%:Yn8zzcRL/W]236kWW7㢸 1fxq xMSj  #@HFpֶcWq fqp8hsYeIq, |+ި^-Ow!QP~C86YfrJڬ3%,:`Rt P 讃 D(g4`"`s@]_yݏ.}%?c>C+`Y(+~ǷKʣRZ;E" (%qd;fz_O-ExLO}X]UH1S=@JAǺ&<_JԤ.:O=pIV_|y%:6e `v]X[QX?${DdQOq=(>$/iE WaS2ׁ3t X%Xf͓?o<_Gkm|l]w:qG L@4P(ߓ( !L>"3?0{D"!K![yz,z'_y֮>r4YYada J:? '9 [:i$T˔R8.b@TB!μP) Ź!pW2οxxK/U6؏W_ʵ`ne9̉"_q3VV~@o2@xZrJWV BϡdZJGE/?[Q t- 8/>|5xW<ւ6Rg`4{\*7lL8$I28I-R°;x! "uN?+`#$<R~/n\ȋ~u볺7~]Z9{A^zO |#H&vs^L!z4K zCpdϹba=+ /:>Vݸ*W\BHw_ WoNR6Ξ spPF)Sj<I`RM :D0äA)bmGf XfUVO}[/ǘ3B) @jYW'O*Ӯ6֤/0gY^7X$I2J=(ѥnN1@L4|B(>(xexo}:[_ڇS&՗Ye s/xko<[ZW6ůcJ)(Cn8OI0P")w}_?H$e0s(ce`W<`Ln:?.qx[[QQټΫ[_>LraՁ| /]=U7ylƗܶ0Zu4f%֢!d?ӯc,v>6:/$ R *X:?iI"0 % &DC%p&v}I)~3>8b^?ϖ7oX]e'o]*~_'=$,RHBh\wL+s 򴟃MT tDkap&΍$}hyxdK *de?0;.ẉxF(Qs",c`%Bm/V_a \)3<F HS*2irr$ B2^Н `xP.:aPI_-?<NlGflYDt^aJPP2+ M|)|_-c_zw&$X ITz<xIQXob0,/`69 u9%U5tt,HߌrV$ƥ Q1x\(Y2 b3SbI%~<MZ J%Pq߲BX`$ }RWo*( e7Ogh?_,`*`Q. "1`VU0L{1JҦZR:D@P怹:W@TDPb1I%~<}#O糹݄A*L'Pk{F*X>4Z;'AWya](%=RUfK/鵫O|r:{I,@)׏AɃ<0W&NEۺ[p|MN j[7PY׫d7kem*G51^-ߎ#uu1H1AKঔ0>U)a$xDG4LRb J*1׿Zeb0#/ԶbugQ.wiߌ"%SV6oY4h{["̾ pr'wP^Amqm> ׯqj\*%Z_7^ Meqn q+P&J77+%b#}p埄^ ҹ6/sx/caS4n\^e%w̓կ2ȝ Zyw8zZ/o~ʛx@X"_GXR89z L_PJ"8=uԶGmM']f#*V@ے.%Z1[[ZV@]_'1źeGh4alXe Έ."nw{e V''k[[Zc:ݘ ?-Vxm|ydt'OTp>M PceV2 qZq\}k[7~#+s!EAJ1N,v\ (= 1^qp<R WRnAwi܇pHNj#^o`mKI).Je 0qǡWf^B2"ϒDq&N߅;e:~'6.?JSm2)W T,u!y88cEnA=ENT (ծZ2LGzdnY(׃sh`rVlxԆZI|s@Iy(%n4v!<ۨDkWq)Զ_z`i7RWK8~īRm!jAa߆u|Y:cGSFܤqpxuOr@>@}Tϡ0\o ic+]*fS8Fa*_feQnël: V'u`8h"QSF5ZXLI9WR ])=zTX+4010c. MM^dǝ:xN!?8GEԵgZ+8jxm4\ϡ}~e ^)5‹6ʼn`O\ m_ӊ?s=` e~ ^e|8h M~M82d8 Dz)Pm` Έ;J6cJ 3v "縦y xj4 9ʁlw2#Dd%MM&W9u'Bp[ eUN{ۨ]6/?r[!Dfjd`F5 ep5-0o+(!z΀:\ 4'dtޟROKOd~w$@@0%JJ)f&tu"7uZ"NPk!#ao!jmqݔV#}ERr4q:Jl CJNk>vcؼ=UW{d7 \uxu0Gu :LH*++ c}%QRU9I/##05RBBx$U"AHjY9I:Ǧ-i6_vM?j$h;ؘ>}mHf==TGP[[`)3؆l̼D ǫ-?GWI(c+W!Q^[Hӻtr. [^y鶐t+Bg:G o6Wrt"asA@MP:|4yk/Q?|;!dYüwD9AdQ$7^a _O;=Y؎uM.hӾQx ORzfq}8WZ(Jk:l/O,ВbS o>TH b<Qǯ/o05ҕ M:֯?v7%h?އy}'b[߶RQt~||ՙ$HMC^Ww{gFVonŐx [!^yWv8lBiϟ;'?}?>j׶ZNU'p\-G]>GH=u0 ׯ9HuhE9gE{iXHtn&̕8jxu~QpѸr27@mQxu]W@EQ4 y#[UZm_{ >ݷmz-V8o/ ax6$,V$ 7(8^n_"/B-| 2M!Z;w?'P._=eATw6ExN>_xRB2(pK_RA`~|pGl=V8*N_}JK2~ej5W_De2sS;K! 8s41)%i)9>Fuall>CpOưޛTUB0[EAc(Mkt*?#6;_nqZfUNPrDKy8^e.u'QB.=mׯ!h#l iUG)vvvO; w2U⨉78yUo>cp1JKY(` `nYe>XTjnڀʽPgh}2ukk:VId;%CS-D l"h!SNmٛYyptwN^ڋ'j7 *WfPF8 :駱%~s#sP7QA}|;,s*`g 4.nr3ޟ6̌nïnYHz&!-*(.#l"l"Մ)ZO E`V`z}~ېbϣ=cXx|"s- ?ы!Voy49ىU?# @t#+xA}Wep*Bo;c \ RxaH<0MAio J@=b 5)Ep*1V*Qy2fiebv.#>(;7cq 4a%~@7 )!E w 6"jU)V8ȃ;_Q ߿uF2NI[R帩G-TS l:RR !&F:JnFdn0INJvq>1}H`C% R0査Y:F"Gm8GmbS<_53gg P`rl"N눃8~uҸL %B) Juj Q0e:G2@((tZ8::?>Oیu\zܣw;h fO`}#+[wQ/( %ohQ_rcwޠ qhӓb )lo_oc7 B Z+g_BXъ@yq0yGG0f RPPRHӕӤ@@Jf6Nna}(Fl!dy0;h8MԶn`s(W1 shS^7T7ȒxΉW mR@'JLuv7,UNbP%&>kpjV B$ U669Ac(?PRPc*JRϑP⸅4w M8!]ܰQ%E]+,Q sldZ8=T7ՏamQ81Q:rPQ'W?< R\GxX0B,- *DaܲfoJL|)8I[$Bta`D1 %k]чHBj %#]na'HobY"M]h:6`ah174dYe (8ڃ1~aE8U$mǯZ9*Rt E qr:uղAa43VUW3mm?Ns{[q0qa u X}}a(Iޗ] 4$[/R>,3br%R ?ظ I jomz"]9x߸ `#_B虄5x-T֯s}ap4a^aa) uA*؉V܄̇ɸz3Hnf1g|%RƵ:d%~ L}tߘ*PN%%Dx ,Pf PƲd ヺ%P+J&WPZۯ&NRD8a^jETN$)03 IFAHr Aw‡2h%RW?ͧW.MT 6xkB$O) ֭7_e )bRݪzƽLVߨJЃp|R𫗰UNoP2^ Rj "JRy 190Nt 6jZa8^uE0@Oa?~)%:̋F]0V8%7?S[OeqߵSAtA!7BA WsJX|[| D}-tsIӓX%Rp M0U9/IC]c(J.A-g*sv mbT*u[Y-z$ M?W\Y/0Ϳs1V8%VR)toI m !pL5l_8Nh?"H-Ľߓ >T rЏHOr@IJ&jTՈ.*kX~isn%~`&ၢx?7.t_'0:9; %2ԬUN[)7fZ()t2,\@2sRl\y'6#[I&D!H3{Oֻ ?AsBRl=Kzy2c}q-oL  EIAKW$4v&h*r3q@p507CmV5;$IIt  jd ai 6xpG]\gnBD3l_+ Aճjc$*kpKXlz~_*'TJ^6aFBJtwpα )y?}+pK%PF$ b=3F)iJ pBO+ۨ]zp67v"r+?  HAj A(jnR1Z _S(/ w St@Ԇc2IkHY3a)rexss1)b(o|G`j?~wOW906_ 0RlAҖ ծ]EH c GQ[_E MJ)DIZ{x2W) H^~v\@x<Gx, y |%xԁ~BVzλSas }rwH@wl|!(ߍRZЃjPPv f-<%~[\+W7JJ8hOK=P#(X[;wo&@ƻ߉x.@*(I\q PO?w< Sku3}  )!d>TYM8@`?cB(R.PQeT8̾r6At_ZYRd?'ax29))a&&Kzssٲ\X`tuc@8yE@$@#,()Ja#fC W7v.={w_5ÇB,bcB]D3OFÎϫasYll<ǚx$41^6x;)=J5\?fe{E!$%h۲\X`}VuZ Yo LJ"Dxx>D)t ae:$Nn<wpsh^f,{]N P4af2JwT&`&yCEtۗ>JMS[IP҄;i i>xW P;cd3IV̽%pKe`D$Rjt5n[ʼG%@z($<*WB)RɜB@M2 Sӗw}dNuY,33m'KOfI>v*Jh[%y›Jl`"& x}W| a r*̓[qX* 5JvKA!RA^'QT%@Zv7[g\j*4 K e(c:.b w͉|ߌN\QRD dnPvu˟ JCO&1hX`l?qPjTQDK( ım3<#E`&}Wb*(e`nRBXEz +O.ニ#hrׂ$PLWPE3 Jqn,t\V{$S7NBp(bRr"8ô5;"r {o0WzZέ7_%$(I8%A\h@L( _!L20Džt+pJz է>^,, E PŠL4H%t#ZKGroFI&sD x=V!}$DCJAjɧEJz()9_.K!VJΥtdA(tgM T> dgLq2r ͇Ч>_!%K'#d1nR T,pE(H `u! (vã7c>ן3K?}.Ob To+L \d?' DQfqz2@J@I9`=̀Ae~cv}r@O@VE./>C-m=ˏ>ۯ`:qL}StYKƽԃS]90%PRPu˖}[1-}g/0 ܧ?ٯk<]}P/ަPPT+,2'0or&p"E(GB7BE yh!J-L{Cn>7{XE IOHh: * I($ RݡO)@J3ͭЌ yVL$} ~C|f@`()xu`Y!PA$ <( pG G%c/20 xȪs8I@8:>S_0MBR)-hհ8#0P''p8enJ(steł t< l! 7\wK}3!=w3In1%ł?V JAܳ *3@Ąz]=B 9ή1DzߴHżJrE}@v}wzb[,*3;W~y,ݐYELa3x@gUPBPPՊ$VB),&1LJk𫗰yY4D;Z(S~n;0}rgB@Hi%0P栲vW j7t[F8<>AOs1^EUb Z&o/k9@x 9 %s]P Txq!"KRJ}.q+WÇظ$>#/pth)I9$!ߍ+@)]\}QYS͝'4Q}>2]%70s,i?2~JJ(IpA Q),P^ LfN(.#EdM!` +!qt WUP:OWp?E~bB踺<@ׯҵOʃ?5 H$ ΪPqsL$~I?~?|w4T 7=כZ?cɢbO eLj3Z%~3wag3Ы¯l04 ۻ HM\غ 6;Ddy=}ȹus]m }E~IYqcoYe"e7w> *3"R\Z"(R΢^&<r︥3uKC5jW8ⷱ6PTS_µ?Kƙ-nD}}LLo{m@*hTDb ϼ4S;G8-4!e @) ޑax~;" EEeqLՀ ={Zb˿l\A_ [k*6xͣ[ؿ8*ցA cm?Gϱyp%+[D@AvT@k'ya89ϵm/Vz v*ꡥQ@fF0P=SE@'x%ni19&SBGK:*ʣ?7prxL~L qk+[7[HFQ Gߩ1 HJBơ9AtgI׆$%ɼ_(ݿIf2Fq7uguaDZٽSab:x"M|J+9޵M.V!T3hQhE@BlwDpQn/9BJg\(hAd aR9Pch l_8.=x~k?d,m;ɯ詀A_ HC3?P89zG 7 -@)C ˲bk9- $~:м"GGS"^鹛3\O; m< #Ck%(0DZ(L"Г'$2|:WA<4ޟ{mTeF1m"$Q=;"/BI+m Ufʴ4'Ŋ*ҩFw'V?{o\r}|QPtwAT6U8^"c=r8HO_ þI~[JKȭ}S Opt 4uMglvhX`a !-Bt)L"¸G #Jp>]AH&] C=Dca^yRpaBiï -\y~{[8'3COH"pU$ ;z(DS]ˊbRZC 7 +caRTH"i|;X P ~r͒d=DcL:m8U RArӁW Tk(bqzMqWXcѧ JӯB"{ν"? .w(xvHkZr8\[V̐f^\^即>BHT8& 2S  <91C91J84>D>Hئ"U _QJlJ+Bt(Tpuu O*'ޟ&_Ɓ|@'`ِp~XL>QqЬ߂1$w >GNtܲ *3֫}_U޼),e3{x ]0?8.㲌" "qv@ y}w?-7݃7M{!mpK%0߇Sv@zX r ҉";F>Y}?? =Ы OX:@PO>Yf_yf\00CZ}V$yx>F1฀x:ZE{Z9$DȹDi}|aQxi?^]//\^W s{d,pt Q|~cwTK, ̐dNßàv PN"2RC9-WXH]@ u.u xw{˿z $Z`R@ 9\\> L/d?ÜO*R?+ wK/U82 &|ѬѻV|ٜ?H!"M."V)&D{;x[W>KW?jPLU@J]MA@}xbQ<(xDc8nu@8DGZڕ+$1ݓA %9A s8 u L/n;ͱ0/ a$0î@*U ?1(,'|(*%!GqE<'_bؖ^@0cNVQxB+K," DYE|"u{J;=#m'CjSx̶L-{)9B+K88p}6cC"a><0)0|JR뿫 $~L xAh߂TbJ{aXQXboKTU((<{K2Jf%( #"=(Y/񓈃}DjI}TOfi$k!cz 7&8AJ+09 G\ o#y k://vgsJK $⨉wt@D$eT]IK6p a8w|H# ~EyQX{bPbQij$k#j!h--]{URj(J/@ġp=P9Kw{fLXB8}~fQ H^C(쇮UciB+QxVbu}S (!i\@dȼ| <tSܐрdlh%pB ">N̝qZ#Gs=0q)$`c>$XWW~2q wS7 cy[//!ͻt?򄀂BQЃf6WYh$cP eln/VZ6407B@0~EqzC""_ ΄  UfG1P3ϟ=֥gq\QJ Axr O -ϡT<E`BJDb#Xq.46S"λ%D n_tm7U'HM gF.AFRMTD|'饯{r2ٯ7ӿ1o} 4\]9P c7p(΍eilB*͉H˹*6ҩ93 }p( ]jLҼf"N@!ļQ;Oa q+Hl]Mʈ}((@ppθH #|%x6x2}F'}е3{_tnxWH ?}Pxx ODA(Ψr> a-_$R)J+_rRCdPw EwC&iA㟆jfPiEH)\(<B ¿O~Jkׅxh_y[_)"t{h`T_N' Y +@PcH'ơ H6mtA 9+wc*# @X&ⰥcQ`ƽFTxG ! \4+L Ss!Y7ׯ{WcdOr߈EƇ}z_9O7 s{<q(P)+d(HIr X`HEݛ/L_GNGALV:'N7L϶g_ RDR>rĹ%Efy $ |am}MFuax'=1$?.z@Q(Hf8fuΑ|޽Wړ~c*sa1chU! 8F)<@QrciQ ~p_?Gt߄9u xnƼA^˛vֱ rFX`Ø@4''@Ib%^(T2aB )DIut3w<󺀇2zP_.G7<۵B]c+ m}9-7JOׯ } 2]9x_~/7]`HsJc9q**-r640?z Hutۈæqj dLei$5LFF>*Oѹh#/}WM&oGuB3\glny,HxT ~yߕq7ev퓟סhtΰ 8CPEs[%NI$Y0փ 6nk/y],.'>/W"x_KQhgZ= A?0ٯ/?D}=Lo1)Etc!0*]Sz$gQn>?Ж 0u@\l](V>CeX`BfXz5cmշ"r!/|:$ zRde|޽/{BEw1(x-+sʾ>@m0f]P׫(#4.=*lSy0X`mFZ9EX|O/m.mh mע=Q֓}V ]x<1^_eUL8 [`<eEJAҹ/ISq2m}dg*?/T2f$1uP*m8,u{&s'eY<`9_eg~_}ek~m}[ͻFWO.[(t7WzP P$ R)2:~+]؄*s %Ѳ*J 1ҕc} ngL?T'GgLDjʼn0Qg#7Q0rL#4EEoWW:W(KW "*>7m8OnxZ0NYM敟>cVpLJoasX|(g#YZS-4=Qz|_/Mæ?(-]Zw!e eP.\AG@ ¼:<|+,;j́F#KRDy3lyռN>wy07 x<}EkBgdn0@F1@7rۻeM|c ~?Vu@]@ O8z֍ȣ\/4޴yˈUm8\P!S."/h{twD`S2;XEe,7digOr!jE9Iq/v1#MqA(R\G㗾Z ?9%7lc%*sh w{U 72i ^/X^Mj'ϳU~=C@+=~?WAA@S7M( ~2-BC8(ssE(Pǥ-]~N9" _{}_N{6O <FXݯhq?ܰmbRr5@ΥIEeyl>Ȇ# l~8nudB?[;9G0&J?ĥ:Vw?̍QSV #5]75͞U?nz@V®?ߓ+tOVKL3,)y@# !q@eUW4ϱW?S&jz֟4n*s",tV(=$Ǵ*I se]Zv ^Bz?|#GL"eIʗE|A|Vv6ap>X`N(Bd -s<]!cLTR 77=;hX`Nׯ"ϳs/@_üaHXL̀M0 dԚ)WL)H%nkAIBGPɵ z@: BP|៓Cz4-# A1<>.y`  Eb|,DEҫl_sM>䙑wsZSܽècR- Sϥh[FNafJJ$TiE)H 7_Z`P& ae }7 ̉eE 6ZWMtiG6GMe`:I{Uprނ=}yK_jED` `D1fQ2i zF #2d?Ko 5~A/wX`N@E D;h6`mQΔqenE=;;؈ƥA0nɉNqg8h )*Et(6DZ' w_*1^(p5w!%x NG@(u@$4vw^OX/?xyX+Xh<0g'慗)+֖aQoq|Ro(A~*o?BяG>2 i@a/`_%>w_Cʇ|']ŅPjJ)d;z5@O5bIcs_4RyX`NloQwꟃ$Y,me47N{Cx>|a(DZq~2돿5#2r½o.˻ R]|aP97(!U4 eBVHC(F ~Y7y_BvYOo,+W@#w_?^b9/wjǫ-\*fDE+Q~k7yi(W8deOnZ_+?$WЉ'puaܦ{el^oI)h/RZ8n (@uCJ(dA]Fأyh"X)U~RD 7~?P)37q-~E`sr> ׫"=!}hh{hBm.?R0.J<% ֟YLU09z>TH2yPFfyޝMY , 9^G_y^Fo u aΘr7*ԏ| p3, ￁F6jNw"Q׊E` 9`دt'%G/8} w {O?BPJB@Q v0ʀ?EX7Q??﷿DR e$ˋ.:Sǫ7n<;E`nLzQ:m5t8l{]s qh|DZ$*koh?㬜ȗsKwvT?y JL$6BuC!BЕ9o̔ Qlc/2U/|Q ]+J{L8FXM)fCnO C_|иY" aEҖYE "D 8R9XXyw06<#`|BID`x,~@'5On`UQ_܉)o3eIx+L@)z#/BK$/*=[rjWnš>c9?"p^8jh 4ϓVwlغj nx uɀE@p;.i@7f %az2y"ȵFO؉Iӕ!"O/0jKB*sDyՈ"?yE`}q<(]՜^dٻFyԋOʸMN`mll?pr|ÓGM/dLE-ޟo -L{>E&Z$P'ЀI[ wC<s ~V~$ Sa5GOo5ݺ0V#J)"l<ъhgp'Q=8{E`\n_Rjd]{j7ѨBzWpu |?gu쾊$]FPaMQmK{ Du?)!9e@%+g~ }dmH$' 9n-/=qrQ Qx oWNǭe@P"B!:8| O-%i"_!b_/$лd-RJ(Jf: +̒PPXc#8CEL4b 4kk@9֯EfNsW;p{ؾqln=iqgBеRižRh5`_! H˼g^7/}N( E_AJeTVsu!ώIZJvj:\0VXwfdQ:GڍxR0|NkG{cPۼG1n7I<7@IwmD=|N+7O2CvK8bp\RJHɍpw)Cm)bXfC2HYvC}Qp8إ=)s`SE叢TUO2Pnoc[qnN9L|̺1RQnRPBBQ#`Q %H!\G   %&֚6][ e6؁@KĒzx`ʜ]oCpobGu"{sm|!2Ȃq[n \)y721p9$G4|=bB)B$$,58@t=2  yt:C=#0o@bV N;8%lX 4/i!}7yغʕn`a+hoAN߷ d8p`X=trDJ$2=2((s7@@Z9pzGC_"v[;hI9SB`hܞmv4RJt=obGq)Tku:-nb?C{XF<V2$(ZLY J` QH@IY*{7W|>zw0wr,i gq*V.}AE6g HqpUl^z}kPq_i!Ql⟄'[=FR: PRdZ9(PyJ"0HG<.JAjʬ*s&7F{od>8eb D v^A~8ؽgS B|DJ-Lτ{L*?2BBzY90++0w@cRE`LN6~{s3b[a>ڢ:M9{ J,"BۜO Nɂ"@(%` H@1*@V'}E?Adӎ; 9%*s;v *Q\~Ө!=F(Qpoq.\qIo҅ZJaЧg#Nܛui)u2^~E@' ǁ:V3 E˗` U#B Rdp'}9*ǫ>;6fId`{C6~NS25R4Zw W2uJl * I"dA %߄/Xǧ$dBcB%VX EhVqCn"$G'fqf=WE@K!|P D& +@hq LgTB8 r/Bs+UL%Tw8c%:9HKW>%^{oOvVRjA40}ӤD&By|I0pSg]BH"@YZBHM!e R: XX@M?I͛yb9s|qg}(U>"tsOT'u3a\)JxuviqZ}2FaD!\Ȗ&_B4yBHQ0iV$@z$U B2 opVX <(w>8k@l@)_z_/9t#YE@S`́ 9Ǡw.d ``Y\m{x ef*2$%JEK )8#P̄0 d$3 PJQ}Knҩm/ꨌ+o"@Y1i2ȈmBA-gi8CJhK4ZA"@DeϢ`Q]QD#6WYٝ Aq>Ԯz`'7` i+!sD)[&aJLr)"0uH1=s VƒV%~ĐA3@)H)q~a,R16TDMvvsl$L`* P7H .4GIPlcBiecN, e% ,|픪r~q ܟJ)iN[)~7e 2#?yo'@'(4; q 9 8K}H@M/X z 2CTX9Evb%ǁ7I~ *m=|ځX9 YGE$MR0gɂEBi=Af?:–VX2  s[|.7Ӕ2nシҵ?uUL׺l`W̪c%.[ϽQHwNu'a9&SvX`Avo]yI>yƩmV)׾(U('=PSg&$0 ޭJ^9er@5ȽH BGn]UFn 2]2"H*S''@#4 KS y(" \/y%(3~^J=YJ<VX{#3h !H'-Ij_)T[z.Hy?UZzxY0qW2@X#?BH8b:@%E;j5.t `k;9!z$geə%92d=JA@Rk6mf:|OkI!2]7Ll)Y.y c ᔪ`^)SB(q\ !Q PRǡw淓* t IaU,G)M^֮rم zԮ ^OshA)cOG&#+og% P:X!x\SZy0G&PV `J⍚wRE˗m'+UΈn. bY0&edž)2 oRWB?Do2?$ ~z]%|sVT >̼?HG#>$x pRP^ Fќ;3 X`af u]cyoU, [P B è=$O%Cs|_lF?M BWa.PR-==xdI+Jr?&@JJEpn;YIsևmt6jL,oҮkzf`$}aVԘk_Y_\= Ny _s<0+z%ZGG;'Z1HG•P憂9<ٜVXRb{]2=%:i!$:1̿Wcee:IZgk_s|H RJPB@I ǡ `n4rug sGh>B ;‹BaQѸvwX1j OwcDMoهOX$TF}@gLJAI>JԕQ_2W e3Pq zeT(p'+0E܈yq)!qtJw&gH,g 4^2P6vr *U{0S$jg+-r/aC<:~A;LjG A "a&2_$0{\ H{͘s{H$(JۊT*M-#VJB KW%QC9 ;UzyOr_ H~Ÿ27'pCpϠ!Bs@С!P|H jBq'lDo p*^+ZR:NV,ŅPLN&3؊o$TF> (3MP.L?I5 `2OfU* ulxVZWހ,$ )ԲDgRx/C=8'MUbd `@($^ o˧DE)tA $'t$CΘ1)"qn[ J BݽMҶbP=#*&,0R\Ihk$l?[7@u#X@o(}? $ GBstItVJ'rc  Ez& * UvICIʁE—SԀǩ@ŶP@@@A7XJt"d]A{ ,)zc?¿/Be"o.0]z}w-#f,iHr,zR"Nq ,t PzEI 6fR9K)8ͯG IN H7Q=g4Lt' k !M< $N"@U S*;nۼ9NV8s_bo썤|`H(c_*IQTF9ur,D_1IPTT(uC+2}j0NԚj',@ ,l+#~îq9^DPTIHȳBWgIZ}>,C'ݗzͭs! Er){eJJH'[`-@a;lR #RH6z{ĵ+̡$禭10Rv%I'PdPimH1Zp.sn'5Pzz`9haCgޜogyEK0ҿX 3`~((TLc"z=:O,Z(9( (H!O ,t `K1KU‡Y9wFIHgcy%dB|# $#?=1(r,hsoIGN">Mn 6@ҁ@KrN Qtٚ,F*yӬd{*gOIֳJ1Ռ^'IRu0Q%%$ wΟo BI )m `X,z P\KHҰEB a~KXDu-}w~stۃ>AR_Xлe}Wt9bxzF0#AD.# kw*kv `,|xQ `ՖPJ,   Ңg%`ƺ^MCnv+3ggNI}$jvO&@CV]HHcj3X`u %qA(JRfB3g蜹ig\㝫G🤻H J8-'M鸭c_ )Jķd`sLp 8ƁP渠=`K=)%>~A:tkF9݄ZoK(vJBX:9vT()-t3Ûv p8 V*란RE(2eC#09}n6cH/)B }~@c`RO403`dz,@&#|;j~D)WA +AN`auz(bHQbҜDO{u-,L]rQ?գ$(@I [Bj;Y_xD4iRG-7p\@FQLS›3C]Ju-;dbh;еI d 4K{3lEހިud2LjOx0nD bB" *!oF~2@͛on;IG(Uuq?1Eͤth{ F H7e3$[Qg0{=0qV`%d:Ҿx'i<1R7TU} "X†@5:d-˔.և`;{!:bL@_J R` "64C&37cOu|p! ܢMU|B(1 t^<ŎlYnk>ݷm{ Q9c$E:#bC&&F*F3ij>8Y(c LOefQ+yǣ1 }Cv' |xF-% ڥ/c\v)eQ9 3t3n4qa!EeUQ;mܒ%D<S"0,Gp@0c0 pS+&4q"}˒:J>\FR?0|_AA90updQ# 8HPMQ $H2R < mb~eH ܷTaёi8]wX6⌁8uipdLa2#7q 0;Kߵc!e?7Ϻ+wlր`*EbXB(8X+  ;U6\H¹@`-o~u5,::n\D9X]d `UIy)2gKb Ը͘+ڃ9f!0Fxз)!fB⽍" Z B@ iƀ,0V pQU ]L] wZ)Z=ٓ6vd%=Ƶt*{dvv_mu6]9#.ih:lf J&!)t˅s&5w*(q`R jE@)C iXD k؆+~­V8E #fC8fKw~fm%TQb{v{*:蘿G%D6Is)$`L%cBIod~cDNL,@,Ș/ DԪAARi8U}fumu^R!Xsž UUGǭPkM(xcNtli Yٞa> zA{*4XizXk}b;J8SX,[.4Bj@h_ft\8'&lH@%LX&J|6WIiw&88#R Փ_2zl1#RB0oђϋ=`f#  SH,5ĵ9|+ (: /8髥_dw{ $Uk+/ՀOZ6_8i`Y’" 2K-k7`)4>.X@`AQ$a cw<!}ҌIM6dmMuymi`6>7"<5l#0d/(ϰ?#(lGf]9ґhk}q8wF>AZ=ڞa) v Ɣ8{qk:Zz&0' ǒ@,ZZXډ˧08_ףݻ0 ;aFHOӎ۰`QapM0%Qd0%)vk>v5OGsLA9Ț<ΗRt31wv뎤Q"s7aܓ*6<?iN5BxFt+c%y tȓbZk5k+lq"g4lσxzYxri 0p\zU{$F@`A vWCщk+ة#qp0L@#0-qWeN%+~3|67A&nd&u>!#:{Ni .yxU-NR{Mq$;NoVTM&oqP70qsN}c #yphTxnG`. @X;d~?+}J"js f@t*t@98`Aɸi Y c@Y ݖn-|*<ÃLm$Dh8,.<81` U-6&DBk;i7fMYp{MDDvMk`O )?!9ʾvL @ol6o-<uҦ0ʑ(4fմ̉EA*úϩIh!L8ND"O* $82B ! l] yt#4-, b 뎆7ZG/ yV3fK搆ʰn3:CJ1D&\[oɨ,D"P"uҀ r,ߓ`T`LH,2E)/ H 9.-|'Fۡle.VXZϔZ?Cej &fjd aO|Ͱc-&pl k9x'vKIp`r@8qh ` rb֘ KŹ6KQ4g`H-E-(pXdEⷤL (37stwj pQQnC[HhcKsʣ؆iSG uozp8+ Vo4a%o;( t{0gU}~7`_9m0ld?c{ +@TpGZ,> cQ 8b^-jv|Np4%_wgھ}KyR Z&x, irr Ma87qJ9aasŀ+c9ufi&G?6Rn1ȸKϺ?T8xp-'QBhQܯCd72*L`zwAݙRxT ($M^77~޺/vwU+>_4n;a@W6\EGt~ӞS]?u\0Ba`Qact.enz1@a  ~>ȣ/Up6v |=-ٟBKKoŋ᷾O;[Y6Ӵthr:t\ ml]X548J-0)YX.SƟᄥ@U$ $X3=k<?@[Dc#Qz(^t(VZ;b"]hF]PU;~P.$o}[>vg6s^q\1lAԹ4D{Al۵CTq༈g N*Vd3 *XB 'a ky#F.7{TPn5ĻMk"PPQ5K)Ob LZipαӷaʨpSe8a1_%~bje':0z$^ vbk6*, U77T`{IC2${ ) ь(pBH>䷿qV* n~e;nŒ|.I`sDqg;MT[0Β@W6 k am3KWuWbNϽoCZo\r*Ҿ4.w x'k\ӧϿZ/f,TTX**]$ɞsHAx2gP-%6YN?o}+i]P &S4#I
9ڞ8aNp@J$$T\mn5D/!,B5P`@8V1Pj Dm<(ڳ\1`8xѮwgk߾AZKRLolaV+G|+tyQ5 a (QSbQD:5 o5!}Bh<|yoe\βU0*+ !8 %*~n#k|,k*8ip  !֞}#@${M*!jO&6A`R56]Mɠ=.)kր7 Ԫ嶃`׫7oa6'ݶ_Lj䊊n0E 9}2BGf-bs- ?#?Ha28\[Y6t}h|̲0ofq}w} J0Hs*_ёX@aPR?T(}"2K9nMS(@تͶAf\aceǞ'^^4Ww#3{㪝M3Gݴ{CT+N)D#l y1R/B*V~Gd!4G gxP8Zxq\#pT@@͏p^ f: E[iSEK(F~h{ 4B;wYPK@ 3?SCטu 2>O߹zz2k@ 1oE)~nF/2!jPTp~aɣ5a^v v,!O=~]oe?d;&R(5#l[`f+XwTluhJۘ@Hm0g 0 f(pv5Bȓ8RĮ(Hֆ$9 G:ޑh]?7'=2}^VШ:ƿl?"f^TCK@1_Dk2cI?=Q.\tVV ϻY˶8>@)![ [Hh?@W6\--G6=t9JbK>`!+zZ2Vd-pU~?m[JjVC`(ŏ~riaOhe(jZ^-`,Y@ק+"?_SC[[[>Љ?i9b';'TM6 nV|\Bi ]u; KQ  5KIAS2Brr@dْkR\څj70 (A ϩxNϩ9tjFn9@[D:4cϟ%³Ϯsk'6^1um03`yPT@x%U?8SiN{N8*$(59nVCkpp CU GqW y<Τx6Ji(/74[o&D̛-p8Xޯ95gu )AsAJ7 O, /ʯsW,Dβ ]7<@qE4qO(8KXɩmj@OA֭PwjnVBB ! (h~ fb.nv8"{ߎy.@0i~hվo6,-qV1W~]35>{8xq ˃qq0_Ϗf'{NĹ|B~e%vٶzt뛧HBbMA5ܷ#SLb%|r0\n]F%B͏ 5l/suzW:B ~ 8ǽak(Շ}Y5g439EQDtP։% 8cBFQ{32crESv߶]iIA;#V,Z5`01K%:nq@TA#]!&lQCxgwK3.8vs\kfj3>}nYC|AB@s= 9"h!l 1 eZ;_͛>&H쳫{jx5[yv07)޴B1`,'(X_a%9eSF@6?HxhQZ{@:6я$wQ3YR!Y455gRu1Z[ HP.^i b7];k;p E"Q~Z04ܗס?q1 ]7`+q鳌8Th 9G^C\F{x2Ld=鵀!|v%Gg9}ݲc{E˹43W<!~a>A-c?[,^.ێiY`Q EH qm 1uG}+I`hςg!/N?PbK-2~2 8: kNon?"oP.k H.O(cѨqmn܉ z}Q9t**G$`6d b"_dG7zE3g1Mhq0rPN4x`ȿnlC8+s@6&`,?Yr3X>E g?i_Ww+rvAt8иQ\Djb a#$0s99`i03)@zj(=3 ;?#kU*U+2 j(3dnjX/j9+g`? 1SO`V^nm 2ayIC֖qDX|u˶Y6 2e1qCZ+@ހ jhb 87Zd`EWVQ6'F?=!*U*dv"b 852 _Y>,7)q9ix+;j93Xfq&f "HXoRyN?y:8a6H@J'pPV^l9p_t .Px=V|̷c _6de&%I|Eoe睵lW >)$aF>I 7ہ}ٸ@RLHuDmzO)YoR裏zigҲ  S-4Hf]q@32@2T 3lϖ@ƫ523fZ};5 "IIYoRh>S6\vˎ=d;1n| @p4a9(Р@f.$>j ZJ0bS8P-xVR5MD vy"q7}D7MJ Jy˟lgd|  B߇iq- ܛ?H)>2DW^н++Jk+ZpdfęaV.+_yO^,!MJ#BqڮŜe3Mv1~P+8j6eZ*?YSrLMJ7`X~ JF=yȘn;+(P)Fv^=2C\,:o޹Ҩ!Đ ΅g]u미庶ٯaIz(g[9GJZeNkK1.8l3My -jZ)lQ2TF@KZ #^Lm+k|E-#ӷ/1$e˧\gqOXkى %(BQJ΃8ǝ}SZ'.۶el4 3)ʤBQFdR\jfir데] 2[;HualG_jHKs=nZ犫/W /َ{e[8@RG!:U*Wvvv_δ_i_7,=kYD@g @3.EnC ۣ0@R&OSBXJ.^h*vs,ۂ-%p73DQzr{?olmmr6_Xyrfβ8P0^)zտgPhVb==aBGTj4j21%$evxx5[y$Zs7>`q~,"_6o?{v-# f#7? vZM215 JP.^iZ 'Nzv#.^O JQ.[+}ݷ+/\XIq7~u'- L+v fjǾ߽WkJƟ gߜ16[[[ƙ?xDanZ >Br^S޹E|{J㟽O}+' yɶ-1 ӄ{ l@1+8h5'23;J_Ugc@ġҥKSiaMMə\UwTgxʧ C:ٜeHO$ h6먖`صJyN\*oվo6f8q,!@VO|g,/y[ki@6Hp.~ֵnޜ2^ae/e;V;PPk/ L!ѨV.# áו@Ɵ f Ⱓ|un_̯_|@\ڷ.ݫr=y?>O(l\v=%v'Yfѻ c<Y(h6\Wj>z}@E_S/ڮ㞵x*@EhԪU[H)leyw'Aa$#̗|g />WZ2aG$|:vٽ֖~6reoeyq7s5dZ9azZ ;FJ{W\ <$#֖V?8z6e< QׂJi?o?釬ʫ9ێ8,g/vl jZ-e?A$cãw' KjIuv} +jQڹGj.\XUr\oIq=3kGAzz !תV.'q`O=zG.{+]7:aj. r p @V+νv_yCY֖}ӟ^?qz/98f\I4Jz < QVe\jUB8k'OR(de+iɄ^h!viJ{O۵?8?+O?};_tp]帝j2J jJYVʻW[:8`Hǚ/vB-}b.0~@ Q[?[Ã%owݝ|Ģ $|S֚YͿO؎qu,v߹wzQj<^pb[>{Wߖ: 2${N\j%q s4 Y.^-|}?_zut{'g+;??A,1/FqWVVw\,,Ҿ{W+;\;n_͛'wo}o?A,1)Ox7^s+X QY{W:sXHx(/y +oY˵5jjw]ٹ(Ѝ AL֖q=QX{yX|M۲h6(Ν;FRB ҥKVŧ򫫫alέ7mw2A,!$bzO|x=S<_}k__O雇AG_eyQ;goAqŋE_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAiZ{IENDB`goxel-0.11.0/osx/goxel/goxel/Assets.xcassets/AppIcon.appiconset/64.png000066400000000000000000000104551435762723100255250ustar00rootroot00000000000000PNG  IHDR@@iqIDATxkWy23ދk'qB Iq(m(h?$JT *cUQ4mJJ!T`BԸiC`'^_2;;w۹;;{qvױAf=;{3ys9˸˸˸8qǿ:Fhu~ݚX7k<!{is~\t9wI}Zuz;!{냏һePjs6u&?+:JO.·G+I%{TΚԚG&;sr{C;g-0o#ZOu9]Z(uC B|!BU#Ա2VFgP~<55XǏk?$ZGR=k4i/Eu*{ +(? jY댞;OōGSO\ujpRAZCϒt6:PKPށTPaReX1yzey<:{+y=N]_mn?7xz৽rT*\;9K3$yL'CujPA@P"1cBJ@F :H:&OY2bngճ&~ݜWC| 䓻O{ABNb"NI5<2Z52Vg*BHۓƭwn퉻V8jT!ۄ>sgrddq'8зxk2YTX ++sZ1:9 88G7ae ?$+4Hek_xY7%# sB*C) S?Mܜ&O:d8T0@Xynkk f\ڸbd,.@up/^=0*%7dZd R/UBea]U;AcfO}V㥞s8~#G4ig~F&P8@g\qhH |e-`@u8 BTe}w T'5贃3yBCˑ *S:`n4\R{my=C9y謋>ؕigē̟/YhbQBe'R?K4Fm:(%%3T(O>:ӌ<1yjgνobdMO0}^.IgstaM`F o`-(bMfY&nMm3aYd\pH%^kM΁1-t;{ako5wǾɧHy.01VF'ވY19h5Q]Cgq/.pgIڱ}kb.oeW~P`:btNy*/ Vexj3L$3'3#"MN}F8c4"ug4O{ ͌<38U:B,"F #RTaϙ@O9&l0#,rrΑ LM~s>3t̜~3WtZgHy38t /&jO^.8A S+eu4x>E@ǖs;Ϲ'Y=GU= yW3Sݹޚ]_@֖!QACt^fΡ.&Kr}ֹ@h,|j8gs,ԞWYaY!_s(t)8IyA@R\Pi#APVg9"6ϖ^m􈰅9Ak\^i[&={D4Ηl_n+NyÓ g4is9Vp}i i[!u!dQnKI R"='ĉ%O_;K*.WyJ.uL 5,9;u6m=K̵L?}MHT>Rga* zZAD)o9v1ϰFѣX+ a(4hfDݱhF!/%s=3cu35wr/]mxb gݪG{J^ oz5Mp>r,w1x Sbu3 @^e™͖-nڌOSkyUN8YY\q˧F#LV~3v1yu1i|[hY3=?R20\V  ]ͩŜz7a1T\_/ d2'-x',sxJJ W)*Oٓ ˤY?yΚ5<齷] ?܊LΉ箮|~JK9d=fr!! :Эyv8a:80, Z3d(,qKoӿ=fR+ 8vũ56wӦ髺&w~~Qߣ^"@yA;ռ435ȰYdgHg-աJe0Dy>QfiMgsDQg>jhql=r0q+^uv>$%ie&K:-%n>X6;Ka< C學 ),%M1fǎaA8MO9ΘZw?U;}Gntɀѷ54w*!Isi;4q6E+X WT?J7^zdY,%F'$_To/U?2?;Ci|];Ç7udϰ[\=7u?'藥<(ڻ:80~S*G!z}>j7ھ3*GJι63u&Do>_-.}W^r9[Sg&DG{KG ʽR_͜ /G]0\\OIWΞ Default Left to Right Right to Left Default Left to Right Right to Left goxel-0.11.0/osx/goxel/goxel/Info.plist000066400000000000000000000022461435762723100177420ustar00rootroot00000000000000 CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIconFile CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleShortVersionString 0.10.5 CFBundleSignature ???? CFBundleVersion 6 LSApplicationCategoryType public.app-category.productivity LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright Copyright © 2015 Noctua Software Limited. All rights reserved. NSMainNibFile MainMenu NSPrincipalClass GoxNSApplication goxel-0.11.0/osx/goxel/goxel/goxel-Bridging-Header.h000066400000000000000000000005311435762723100221650ustar00rootroot00000000000000// // goxel-Bridging-Header.h // goxel // // Created by Guillaume Chereau on 10/16/15. // Copyright © 2015 Noctua Software Limited. All rights reserved. // #ifndef goxel_Bridging_Header_h #define goxel_Bridging_Header_h #ifndef DEBUG # define DEBUG 0 #endif #include "config.h" #include "goxel.h" #endif /* goxel_Bridging_Header_h */ goxel-0.11.0/osx/goxel/goxel/goxel.pch000066400000000000000000000010741435762723100176020ustar00rootroot00000000000000// // goxel.pch // goxel // // Created by Guillaume Chereau on 10/16/15. // Copyright © 2015 Noctua Software Limited. All rights reserved. // #ifndef goxel_pch #define goxel_pch // Include any system framework and library headers here that should be included in all compilation units. // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file. #define INI_HANDLER_LINENO 1 #ifndef DEBUG # define DEBUG 0 #endif #pragma clang diagnostic ignored "-Wconversion" #include "config.h" #endif /* goxel_pch */ goxel-0.11.0/screenshots/000077500000000000000000000000001435762723100152615ustar00rootroot00000000000000goxel-0.11.0/screenshots/screenshot-castle.png000066400000000000000000002460201435762723100214210ustar00rootroot00000000000000PNG  IHDRd?gAMA asRGBtEXtSoftwaregnome-screenshot>PLTErrr:::N-<<>>ff:kxXzwռz2a5fO3H/yK0@@@MMMvtM2C+eed9jF-{w7h~=&tuӥk(N~A*S ʄ?(p` rvxթmb?{P i] :%V N2jE gAG)[ xN BBB4f]<dcX hnG ehrJ uL fgmKhkyNlo/ZE^zƑ1pQQQô>`9Ɓ7fhHdQpTuDDD'AaYZ8rg_ ,U \}`cWx3S!@hqBzGooo^)))zyy[TSsUUU1^s$:U7jjjNӌ;Tr@qaaatЗɖaUN}:^*QÈ(\\[FGG#XXX*̘6NH_3"""^^^E6(%Ht///lB07DIJJ3J|п\*u444U1܉+2>˻<Ҫ69TNt6>NJpj6F_'`77o@Nɑ,WC1zMaw(XkpGGHR=)zo%xwPvj"NNb`^~W!RA5,,XlL*ddXX^D)nn''b''Ce**}L9)''))++++-  IDATxOk-gslhpٴN <*JQN™\"pA s 5gפNiqі ~όO{%C;,ѢG ~Mš >v(VP#c_ 9@8;/ G=z#h>k{ ޤ;* C) )> hē^uTwv~ns~~//oFqT׊I虿ߞtmT*^"5BAsňu&#PΤ݇ b_+.Ot_:np{>hBNzE1x!rM# .-%nƵ?Fo `0Q=녽 &E1+sPk=?z)QnqjvnG@ )~/LL/3^7hkxiN)vе E:F/Z(PbߜoVi}x Wuռfb)FvJvW -؟ߺxI< # dr1=QxrxsgR%WxbeۨJTj`% UOݖ!VvԬYXԖ!6#05+a53Qwe!--=W0#R<i DQ,/Y 6*qshf<'5tp 0 ~Hiېfb9 ?ͩCՑq~go[ _ `:KY/ aG!b!Y&Bvy39/Bp1f˵l&O 6s \Y=q@'!Wƃij]XK׎% 1k4-pp&`^4)< 4ǒ`O'*0uxO;$AM vPG18hC\&[ l_O}G'E=㿅`JJqϟqNS{Yp'Sl2VܽcB- <NN 92݂4qqb@n7 lJ Q$v`H:{os $ ( -"}= P֋oZ+ D)Ў?z %%r/{/If_%.aP8!n H^ՇcWs/A|j8.R \!8 @J؊Ik'|:zbgW @+_zv-e! ZՇ# ./bbqνr؜%2;zh`m, s9Q9'*, àb %SzThy!= (8f>Gz5 u -cCP7VAc$`r"A X[^%iO2* V `z1Oxq)τ*!gCYGɳE1ps_W p#(<}PZ45J8/q?Gh+ GKΫz1p~%-/8( Ô  J{&j3G1h"pPi-@ȟŀ7@.@=`nZ@3n֙Y{'`;vc j>|z?= * b%hpˀW*#v]~b9Axf!h0JuyM~d͉հxw@<CE|.E֦ZD#&[/kD(zeŕ7 ]@p1*xg0D~H%"yNzq0<P @J>'u18pN%q.P 4x$IMW'}',Z d20BF/ @Fk @7* qTXF:~6IE!o8: r=F7ַ4<8CT&ց-ntF7X^}= -u #*UH:39ha.k\Hv.;|>'ȉ,λ^wm:3H(#QwVꂀ ǢŰeh[gXuD"8lV ~V8L8z$Cb;@Qmx )V^ǴO [R;JmDR@}$QrYcG * ıNiK>lYm{$Lp%azݷKNA(iFBB<Dl5вD_1<@Y m[Vb(Cq`g@<8īVj@@APJqpiЩQB9+4Eiԥ X;p9wz=, @/IYz2+S}VvrվxN@Dހ7G7 ɲ?ӺBzwJ\.Q_ %$8k:50$xȮ7WܞG;)%MGJhAJqNeJx8uNMOL"E g ~ &f^3]@' =֦o?}ƾ 9 PG[~%*q_?^@j`)TMH?5J}e5+p {<75Us#V`wvv`:/IwY|yjFƋdIGg5? 䊀`>Hl.m h/Muܬ 9@5k: #M NHpIBEh4-R}k`6@-eySU&XN1ȸDzP*ؒ⟺.4a`;iN|{; @ґ.dә D}܇J]^)hb@EؒP (E 3K1$n@'9y{7AmUo}sb=*fؑv|P'N@QQV4{wY[WhW{^P$WMĢܗޜ BI+t? [:w pV^eTk@Wzm$`0{i~>ϼz@3Q4КG=,_ߒ* @'2`/_z `xpΫzl5@a=Hyћ pY=*ٍsbU྿t++ٟSO(Y:+v @z#˂#v Lݭ£ GBȡ+^^Vsbbr%uҿ—TU>ho@ա%  \"hT *  @|g !nܒuĦ0lЊ G*a7>}|"Չۀw wC1v05xMÙ2ֲG! $ N/(tN6' @ dçp P4;Nկ+xJ3dڡ/"sHP Хc֨pőBdJ[ Ԑ)  N4 G'a{ZDє&(vr# !b!rVߋx~Gk މ#;Gg} } `-4BD^@]7JȃktN@QGDȠ. 8 _|Av3fr)P`ՌSC Cx H$&&!v'9t`7~u:0L.1E@]@`?~ ItҘq#I+26Zy(0ݴ8!,܆A+5TBZY ZL8EìW_}rj]L5<g@B8eap?H*/=bog9{K`N@q8݇I{{BXrXd&;X=?1)l$ȝÀ͈Df"p~bZbՙX$ǭw@ZG;!)tek)c!;Fml@;_[ %pk-V"Q$:zHA#Rmܬ`; g34{~ ?-З1CF2W 3@n&G@m_| {1ZH镟[Rz?(b醤# v (H$L%5jNU2;@Z^`F$ (jtN<xd1z>I=@8 8Og &VX 2l{bUnaH$FO x{h@[ (9_ȯm~J}` GQ"Ӈ}?b#x,l|K3x] ="Mu& 0 0kbͿQ{fO6 WR |uE8^QN (-ugx]o@Dyޕ<w{~޹<~ӻ3b\@a3:: @m(2_W?~\~탓VW_S7^r5I& Y~ /MxA[LÜ6 @1*ч3s 9(5@g񥀱pf(JƦͿyx`;^Jˀen `s`@Q8ln$" H5?#Wz hf0L?l_ @1%A@!WU/LX,_̟͛)`#< @;sr w?%ْ2NXWPչftgW)>eĭ z,p ;j@jZ.tz52W>@e~q#Wi񧜓>=n?v0<8m@A(q~o٘pyXz@$]f6߃x@3<<;\qYok?Yv4w1BI %̾gp;ΞGS47 GNj!{sO@.#ȷ+K40Dp|\^HD3?ҳ)19|hpmG_=:SRAa.c%$in@y+\hPk=x |C^_\uBX9~{=C{qBi36ʉlՃ_(N8J&)88Ḅg`@RمB'wp ߴٷMro'X<1 ^{c\KZl1*âfOn p6fbm/E{f'Kv`CxE &>dx"p yYL}ŨE`Bd/Lh3 szχBcJOF_|gDE<9~P  %?OKc@xQXDXWZ(#{%~@G` ?2X3Єhڬh83>o&FDbU9b_VeL *$>_ϯ h_}{G[@a@K+,!"^3)f\6l']Alش@^3㧛qߚ C 1 >DZubfd|z߾}#? 0j]a{L; 1z8o 0|H 2 A`4[ɤ ?Ve߀U_no|^u29Gǧ)Ʃn꺀'@(fNk[=fn|Dn _e9'@"9{I'y>㸃W* 6Vk @,/p8 }׀]dP>FO#w  ^ K_(!3K5` ya?}LT*X7Du]`T@)(v 4xx;!`Isp #0a}_FhgC8_Xxu"IJ~P^r0޻wD + DXN!K`><bEQx,fz]Zm@Ԗ)*#Hon`/þFWdA,~ A `}`T>Y#.dO0 l{D6s RYO+/YV ?@4Al)ag h򿺺-~bᵍp"aju( }FؚRZ0@:״< @1Ly92| ϊ~`^QPNZ) 5@|9dڈ9P$̔Go@Cݏ@,R9\Z8x;h\PTT_K2l4~Bw^\D"ؗ!# tp70u݆  Sc*8 #w᠖`4#i޾@eI?@i#=p@&v:I_* l+5?xr 0ڲi9%V9Pd2Oʉ޷_b@,BR6ú_nIRL@: d{B|J@T *yȖ53/U`D`~ɇ2 bsVTm[gXY,Lg!'zHFp?pp_I51O(&ɀr={h^mlg(@Y]侒U N[ѭv^輻opfo--b ' b''~Uvyy`  ~*\(Q$"3&yN?:{qR@e~d qK@7꿁1fx7&;@R#/q{]N uG|x(p(o,y3](`wjFDYm(||v> /7'  ĺbeD 7vQ!vP,/(S8d72#*yHߕP,*^Γ4,Ȼ埊3#9rR#.К,B0 J ;u[n[G|Nz0\=vyz4?ZPS"©-60\'ytd'j`Q-D%}FR<hppYdThC˹Gh hgwXHCz$arL"JF'K[ErYRrMo:)4$߆S`k@^5 Z_H*kg^~ZsvB"RK&WCD 'K'M0% $_$bb$0:59{Ҏ:;QԮ֊J^k} 1 )4q-4We Iwpa_;Q`&v-+ϧ>|ϬW*Zml(h q!he7?aYz ?E >3?`~]47n Fyׯ1O9g(/~F ׻g%å@C,t~(69&fo6@{x^>gTX7`_$-w"+KrԪvZU55+?&'@\6F]_j@ ?K-A8 GvT!?? &'~9RCE.$SI@;^d %@`0 ৪J1ZgaOxI;d ήW}'x"U՚h !.F տy 7;)=Ŀ/p'Y偠b_ `63b[?X!(74 19xDTGrXs?M{ r b i^ oF$`=qB/Jt/M|w0D0E2PР~afh@p_W`btlʓEF@.HF@ds8Sس(@IR㝿Fx%P镻1>0(@G6Nƀh0ѻWmvj `N O~6טhJ~q!s=Άrb:4@2N֠+d}нw Σ `ǥ1@ϷdWk~4\.c|  K>l8C?e@#=).{A-fo ̈́F<> n27ĈPvG™l&cfwx -UӘۭt2%@lZZK h0(TW!kLޕWy}sq @<ZCw\s=7;ާ#/mZ~06`>WM =ngm9 ;^y ]NbG/{(ϛq`Ci<PM %}PkϝFDU+}k 3z0t*oA2ur*zc@%%TD_@ ?nvqq0 o~(џThxRI@ L~n`u- =(*頝^@}G|<حl09m:z}@L<TDaa^?|G =@IhPy7.1i,M[BqફV]8I WMA]@;9!@X+q6FǁDp@c<9/hO0  ~0 R v @= R RiTQ>?$s+o(`F8 `:A< _O [XV%"8` @<v 8 y~/ V)пW>;xLL|)@̨pvC#0ߓ b㯯{=e <PGfXo 4}QѦX8y\WX*A`D%Ȍ}`SE@d [#cU8{ CUY(3og5&*88_ \C`̫%? Ev6p 1'!L ]+2ma.+B׿p,C{|?=U%N b}A)6coܪPū]_on!妸tX@H-xo峛ē(m 47)w,̿RBzO.}`EmAGGlWbhO{ /~“ ݺ kQ@sw:| M`-{1#?`?G p0"u .7Rд'R֬qϒv yˀg2gxilIh@a2˥.5e21Rִ76K:}EAL*1jzYS >vPyEl?}L@-D8 ×}g@})X mPV@86>؊b|l$D,0T .c/_Fs:~{ \~j]-uq_$5,@ ]Uq̳~h @_o CP$(pLj`P` R XiXS|dpy:Q.x 4H0ZlO#-zy틧D(4b6;HPS_yakLzh E[d7ιKLA:ꛕ`#ç\$)lq熍Zw؟n)'i&=?i8t7 @$`6O7Yt`ZpkZn'?~ܣQ "\@d eQ$`ϭ1BHdOT.r9>HWOtOLVyRM{AMvx<Dt.h2fS̄v pC +Бpx%@*Uumі^ }u3X*1B*8K@__ "o ARb(#@uǣ Vf#qxFF3>cW|0#@hյK%"$Zx!gEwh !T[=]*H "` @CT]"TW c rc|8.x@gn T`CzuXOXatROO8,@p-w<2 t\h=ȗvF_ ntw~XX~1p/ lZ @@V3HH a@P(ݛɤRB(bRb@u<5(RO souBP(:@`2qS^%=5m42Q P}8KC|-o` tBR h,BpJGp*O&-dPg2f>_zv6TIQ 86<ƀNWccz|,$Kta>O [E* о<Gk@1xГ zͿZ*Mwe8  (aϟo3a_s+l ߿{\wchP^TV Xze&MVj]U!o?y^&V4@TPQ -`舟e` Mu1|e?Ns [kG› }s?~" S+5WmU%kت}? 0HV3>j);cpDL`@j: &|@ˀ. ިnvR Ħax|=H;R@nk^{de8S.R?hkHh>"@Rx6 Km|o˶zk0;~TP FZٳA@ᠹ,%M2,/nH`nRd0JR)|ٿxÂV6+{frk$ @r" 8MA84%@iE RB'9A S_?1B;{p8)irn 1ԷE$ X$h Ii!)>P0b97N6_JIDu?ez?pIfj%LWK;D!iQ@TDxg,a?b.>_sէ6[,1b?7=>uW*9jdR%a? s_9UC@9wףr&4͝NWwY]f moFhWr?]"1 پtjiw0 +;{P2U5^1Ӻ,/<dfZ #3󷍀&;:p#g?N yB3 x\""^*` ,S斗BQ!OZδxK[;-t޻ $-PN53qr& Iܸ bɦ/Y E׍,Zp)] JpᢋB];̜sf$^,J1Q9>?"Ѹ#r(g<@O8G !? ng?u ,@^﮲W,4n(ἀ 'Egw=NGVIn+~d]iI2D;1@azXJ(R6pPZz?L@ɭgv ^Z{jBm sYSnOe2I??̝D}#ZgqL[nu6X~(3q@o-zv͢_#e fX^mbN%I&?j,/4!FaL2\I ɮVuw8@}D 5z[ c!*(!iϲ`Rk֬9owclX:9¢ 2ncA<?-VO‰!A6[ˁ: #= -@0rm5 TR]JRXF/yUM7  B@fz@֐n $}c6z7@ Upo;OϷ?,4yO?Ö[\2Zz&wvxJĊ鲾rܲlmOۿKGL кJIEB ̃֟m{: [5@Cv?zU8S/>x]z#!Pn!SjȿROn z %.Yt L·4`xb&g@\ z [S=PxSwcF5]o8.O|x*?>fW{(|kV@@tu;E@' ? ϰg' $ Umo_-0x8_#C}A~& pW hTxZVcy3X\N¦[7 ӀWIՃco@@tVM9MԬY*`R"ˬ"`^_1@+ t 4W#|`u 0*\q\]F6ɀhE$Nh xGf ۗ&0<P4bF4#Ǿq?SH;a_ pm ~ɮc q LF-WrW 蕂?Rv7{en25F>JҗbО#4Z |-PLOhaf'ѻCD6BBi u_T} Sv{%`i ܥ @ g Y烙f*g }~Ɵѵ['00AnzV\Gq3FoCOF3l%,Y,"&'58-p@>L tv5ƒ"zA$y5GdgXgy ׃xw׃q?c xyLO~ dD@PIj&M Bp^p^ɂ+Sc‚gRsTw)k9U)'-0 *x$o_' >@np;j|XD_ȕrB/4qY*dR/8l&"a0 #2@ uSsrwu>TRG>#z @݃uW2!~,΢q%JA4`lLg@8TГEy$+T@R :H&g<s>/uWp񼪔' ΰ04 "Ox@1ϖ$i "Ǧx% FMa#K !K`3ETD˒N &FRlvxRX)2/bn U[(rV'86KUt7 W$0B|efF@_k. |En JWfoMw"puT~$HĺP d; d`?nt̒zO,PxUrz? zOQmlITia4& "rK:03!+T0JTG*ӀعHÆ$0ꨤeig 1:/&CjLб8F\"sd_UJ9D=iӳC HWiv.AU`"4JhT̩BWz8Ztc֣G(&1r?t9"G[:e=~hiDཛྷ (F@8'0_ 3ZO(* \*s4RA,n8;`bik<5>F/`ո Ɔl}?~4#;P_C Bj` ]XKJXrweb @oLtsq;sG-v /q[?Bj>xt痍ý!r3 O&5 y=+'[A˿j>Ctd7+ @@MbOscC=Ž@_?/N5߹5 @@ΕJj!p~ kt1(`$a@,^3.ZMU"΀~JxT\  C&A5_+V M Y CFGfXu*<3`K$VtNf6-/$`y?H]Tr<ѳ&e?<?{!hm@K( C~ (}3 ~#,p_u{'}7woZ_ݽ~{FZC$<= 9@oNZY.;(4s(/o_U͠? .\Mjf];$5C]>+b/٪kdp1@ϟ C20:dsB /6Ik-AA5ꓳqN65V{I,&/& К/>'O^tW~]@w},M~+2l.@^}4?`d86*uQ,TY+w| ?AH`ϒ1 `寪.t;1_@L( Ͽ~] "{SxgA~$֚'oTAIhC֯sAޯ>Kb? Ij:{CmjtK1>.::>\`  \#Msqd-؞B {;~'O ^;%."Fs ܷ&߫MG?/K~Gi QC,e$4:Z.OQ§KC?Ts rWA|M@mM;O@%xEp_uڌpc4]ߡbwџ &o]|7(@k7ou3jX8#=Er~`wm-[۞Ox?t{yBh_Re;_.}Ẁ<3nM~KS,@fr3i@;Ȉ&nH}\So7nN_]DFEtns/ q4+DFٻn/lydHN<߃n~?7tGD'N W?4v範>(~!>({P&v}h>pc{1ֹ!%J5O$q IDAT: `b{0f h[pg6Lh!MŠ )پs* kt.c~@Mөr+#@lx4>W֟x@p5~3-l!.cmh0ouS7f(X>(, ,Jk|Ϋ8=C?p@,ا'Fh O"F#=s`17ܕ\d5 #w:at^G T[f%&iaA{om ;w} | @,iOOi`0'R:7;1A c```cp@ b ;kls`.B_W=ij?~+m}%TnMw}{SON˟m[끾k'Wt~R xm}:یMVH֩V¸ArV,V &$wS -Jt.zBJ" .#ܝ}Y{'l8NlboΜ&`9ag'p@] 0R+ @\f4)AQ ZS(X㳝yC6}[,moѧX.^_` ߞc9sخA0ǟB=P< 0tv @ɭ5c0 'P]KF $)`hPY 9~@;܊$Ó~;Q&ns0@/tTFm'^_ P h1GSP5*jQm vps؆FϳVHOu<7,)v> (d5@g:J~Ч)b̘#Kw1@~[`0>lBk#p(Qh&;k͎g>u {$P}T{] UQFU~@OPPGUsD!욠9 pFQPM8n $^Eog$3Zxx~wGT h0F|SJDy,_<_r'dl+`w SvWȞjVEydvP:)@2q?F!&@$AMw)La0%) GE9b{~A *~pJ@  V> ?pH0jG xRԮX(9?d$ޛƒdFM@P + ;R=b^H1`W>0;|$aUˢF\Ο=Kܼ5lB' ڏ\ja`4/A80d_zſ?ǭ\@U`#N kR,Ohߔ,tN"pwB[ }?,Yا>3@. ;:\O {l='+.b (K*/`dc=y vdIjؙ̨ e~M))EE_THb+U&nFdT+0Bͅw3pBDk! m]@.s0GT *NL #*'=Y'yO5~xEQ)S()N@'S)_^aXVQ/tB.k0@x 0#?fT%{gc.YE=yK[#5>|5}ݴ Y'USP`4Ƿ_:37Bcyjvc>w pDo<07>?+HESMZqS^`|u>E0Ou!UR䙵A wRzUP?(Xz`=>6 k^\<s7{f`b+H/xAXsp.$ [{ߟ{.T zH\^N"%oKj*)Q?:AA/T "ˍ;#¿RoW}/ƍZqC͓$pf\#wU%hu@ s9N@m]zQ.nT^oV.z_Ekd? Hz ;KAcѫG`M/{Db)|'G9j`&&_@ N(RpZL&A@? Z,Cv1%s ;8\ݣkAn'ErA=ݨbr`ٓ)v}: 4R$&UPMRĺG8Y/JaƵ~Q|  sg@r&$@:LP6e'$vo(zHԽ? u֟ՑFm#=%!4T g)XAܝر@R@Cocͺ>?ҬN"@T4mai` ҹ=?8V%s R '/6>}ojVuAA qBQSx론?w zQkO |0J%j־.,O.P#ea5? ݡ m9ο8Hph6]NwEQ6ٌ4"-}pb8h 5wc@.A`/IuH5W?wlvXD0I`KB\$!C3EPyA:^$s?^3y_5Z%:i`FԂ^'e>zfh|G`YwƓYtVb`8(v_ʀC  rANnhV M (qXCɽs K #E3EJX! RQQv P/'بjϟ{jZsJ@+X>j"WQy`@@ @4H(;?w 1]q+8oq@f K_oó]HzT5h yw Ҟ-6SvH?+dBedsYs@RW3P߂: pMovPeSphz(T-l )^6JCZ(?ϓzoܩ`W}I'UL@"X<{zi㈅3&<1kz1tԜtL OS_1t#LH./' ;:0~ۆǏu %DQl=d8^CCXwp/K4w˦Q4J=Gqba2W*?=$ xH޿}T9(N'YO Q7.(VsI{fl43KC{wZ4!mEAWipgJ}M/`#M Mh ~|44gUN4|6^/5~֗ jN5 @ 4̏8"(bF J D! kVcVH=.VĠ4)HWvbnCBW駧 z|jG,S$q0~>t>gHqA_ﵘCLqSՇIvh %×K]ן q]Z¿炀ݪ%R!`n$,~įO2x@YCu3"7̓ z*X>$azWx~y\l@ӂ1kg?\[8Y w)( rt/|AePp Y? &gy}J /6_V{U@+?hT`&JP.H9@[t%S]_{sc??__,yYM{$/ו *^ޤ^KJo&aXWkVL,¹N*q_D.@Τ;7lxUb~lsʆ<d@] NK:܁}x0Ο Prc/~ Aog}.dq hӇlQbNҳiu6bOTmӉ[ j2|xz/|qҟQj24v%ڼXٲ r\3&%ng N~ۂL{B4 xbe{\X}x׍Z`"hH@|zqЧM /x6]v+G탽 bP*` zg\o1@eb<a`f4\zHTiV_ t%hk3Z66?-?;/R(&6PPi/ J]!{_ErX8?\6r!#濘3BS:6:PTЀ3^tԩZpF'@@GϓnP r覝_L&|?H$Rwdv42,5A?OLس/.tT^!0DH=-'"L/34usj.=?P>W'6Znjwy [.`_ R>nҨdHt|-CO%|c,>ec-ҟPT7 s4_\ 萹 b.V-ɒ` L@ͻ0|:7מa0W= `~%34GDgf:ql S 7L.[>%op7 W4ńip7ߢMK%MR|&A /9aB~D7rIExǎVs~ *HdmᶞcR@X 1AХB-Щn#spUW6DS&@4M?޽b> D1lnl RN 3o3`皟 z3F m-h`m&4 TCw~$iq!]UP wCeEg}Z.LF]fĔr*LI| PcbJB@145{|y)sTB1@5?} ըZ~G|À`sCa.`Oux []yɬߞA[ {&@u^=M$°蒠TY1ؖ< #@:#_֩CKuZp`HGp#[U;#af_Ey`x@uкtQ_vÌgr}-B/$sPhcp n\WЫ{Qlܡ^΃[4 nxVvܟ soZpcX`w\Lwy|`e6^G鿸 j + -kW[+ g+5-SOOC$ȅׁxTʲvTJ(`մHi IDATYo60nx,&;ڮ?v/#<3\|#wQdo4@%hK~|aQ~01pLZhO!δg+ _Uz'YSS`gP&|U`.@ֿ"7[ $HePB/2D"C䪓]O-J@<)@fi@4@q ioʼ?P( 劺}w "gͻ߇0-oҬ]Y5О`BY,h9+*joz?o_nPMPpÎme6-@:6.pZoد[G;k⮟4r=t0, V} ҧw}&=YB{Z ?+i 2ZhR~A 煖6>dZE.4P<$o9c@1']7ǿGX$,Doі$ϥZjma}XD;l0ל?$w(T#$ϘfHd_U }+ _JáL_ ,[&G0/ Wz0bҚ;{ Ĝ`Y*!p-zv O΀SXWu7"qK *Ѐˏj'(.K;>KVsAhݖuJ aJC k8.`. _ ᷛuCxFE rdԮGd YhV~^ ˊQZ[!&Uk5 >v31Q$~ꮿx'vp艾 w"@az\4J $xJ|xXZǠOЕp aP"@p  dȋv`rE e٘wHU9&뀁nFz)TAf9XY+ dw:\+}lA Rp͎ܲ~] z!!< 3Bc>[0.BtFOG.,#'eYCGv%!pCp L6vOT7i2ڗϛ{*!Ig`Ğ$@Ɖ_;ugS;t:E1#@u4s_5`8fePд>|!Sh1OC(]S` Jh79ugqjY.̒0jWh@r$%E')YHzKgxpy*@gl3 2zoj[ \\_GoE\j`p =0i8K "uWo0Xj]WPkm??=b3iWů=<K{,,Y/^(~ ?J+X8%}gM_de &Er) Er^of{yU `6% OX(/e$t!D=0r < ;h*PG=&%K;ƯwFG0}@RtsuAeZ!1ŜS|ٶ.>`I*!tOgZQPho;@з'y bDZsӸ#:;hX_ o v{DkAU1 S 0s`zX-Ki=upKo2ƿ ".gN1srUBH@%sfGYp ڏEwQ"wAA`hXAٺK岕zj2?^rP@u{Z ==oEa8b qT}+d|-Hw";@\~!  )}5nPhmvg`+0sxXh=Kf{D`e&), T @X' 8m 䀬Cs ?r~ ~O`3/eb+δ9f/N/\kE5Dy{8wf-$ѱZ-]0٫SC_Ol߻Ơ|/,8QHAL>({1:?+(=g.(Z!zx;ʀ \A؟7 J}-1bAe'p~xw\N U_ƻ  "6]Ix-T?h^d-֖;}|Q?wVrI&UdrhL썣?%+rTB/-^A҂A,YB1EX k*?.>y/~K<(蝙c̙{O}3]zz2ozxp}qv@"?43 S@:!  v~r{/'߫* pG፺/V¿TVak\t0 e+y[U. G~:z,W"r ^,XW0 _9a^oZ٣&#Hbbdm񜟨,HM{\u_@k֜x,D`{=+P{5ZϪfm^qL=aĶ0%zۀ.gr E3(=K򓷯O5D?cu*%(dci6˅\~ @֩BZsQn$ֿW7ml+F2_ Cp^L(ϻ:\6Oe6~fHj]b bK5h'8gڑa)85+/&RJsqj9([! #'Yca+$@IV7hq}T'WO+*vմrT:9P`d߱( plT.(5n)yl ѷ|@(wMiS|1GHhi[hWE!o!oF_/k A->{J d qEZJy@]%?j YW^5UM_]zڱ@&!/&^L}KQ銠!]aq.h^ . (jj٧A~eOݧ#Ѳޕn~0e {Qw{JVc|zIdTMZ@,x,ֺ/ i^0Q,#KĿƶ [eS89OھH kdspnzn.% V#7% GukO׌[{S@{oޫ4a,St TK0 \w[@0e-8a^7 M$L="MuT ߓ 1EX`~A |]JhgS4T<XI9;G`rP"lmy e@ 'yPp2g^j?@?"h7,GZ@} ihA{tP3n1ִL"ӛɝdv)<0A5ohPPR*t] `2Ba.w٨RCDO+|p^>1r™\&nc/-Ey ] znˑgѵ?fP% b ږc78`aM˜EfM  !q BV0RqkIpTxߖ'Wpϳ^A @3 %0(Ay& i{=%CBZMchK.V0!,~Z`n)_ x)03t._G ̓7 gZML_:`2f=D PNT8!ٯ ?m c$g=׸ya_[ҏ帎qlYP"5+Jhn$(p? (]kUv Z C*Jd`ca %R]*p%@Kj.nd?'k}ঀ? BBV>p}+D)o+up?Pt%:ɭ]AM<6ӂKyaodb ao^U`˧I7$FI2O I 0Њa b.;(H}o8R8쫳$C۷-SI}`\P q {.Xn!P躷}vi>(KsկŻ=/~ t` nW@XyaoQ Whb`{0W@U @62QC) LM7ڴY,9mK\>15U0ʙ挱_R6$z*@)@ϵD|-J(Dе'\,1-%k$56ϿcVR* A>/.~$_ojKomRI6CX*_Ȓ87&@jQ.~: rk.=7nJ'9$+f6G] GbYSCty}xUmm}8w᝿HBCX,htw>ѯ^0HK| ձZO_ͯ>t b-v<9oJrO9@,m,-X<s{Rͥ  bA,g]BbJXEv|tu$U/Z }俨7}m^ E @`yӎZ:p)Q 0ȒyzB&F?~ͱGZfF@=Z1R<6'Kta)ڄc$5V  ,u58b:2 L!k@e.p)DjZB,% P~W2Wb?aKǀCx씄ؑPޘ] zu<߹?FǸ7f6֣<ܽ||fN5D XXw?VA? gGуhXji4﮾3,?ޚ[˂n Jbξ)EB";W d!X1?AE&pa{ H0TGi4a֝+Yp Ta=UeMzs;kJI}>nrxiP??C_.,pN˳G%ʠM:g@5Zߛ3bo0я7,{7sY?4 PcܷCߙ7z䙷X_L~@,ya&KAh<2t}uͲ'r:4>μQoWsR>H'$RC se'5ЉwS~V ml_|oZYٚ- 9ȕ ^!>e4 T}T}WN0[LkR\ϧ(,rFRO3jPyƂI<^"uE oD@TI_N?˲?Lg wa?jDBD@sM# ?BʂaAWv;5Rn?GMKQX;73pĿ~ k.8@煋V ,_|^~V\su3.X]|3XTP>~,cLm"=`$p0kd`$,i P𑷞oK4 G/nи -y`I{8#P^m /7s}[Xw&tljG<-qԴӮfH'<{lؙs+ ?4 Ff!"b^ن 4?~ֿBM_@ \ɜ%ܠK]=ILއ >>@OP0"MpEǾf< DžHU'L3i"x@Rh}NU-@n۷S+{{pߛ )`pp0Y`@?ߪ1 49Vmad_uEۃgahoWBU*[Gˌd(;ޛK$$zʹ}cc]nYbKP4w𿻫 xWHDJ _Y0&?E{v5AOEH,_xMB` ҤiN;1 U8f%LDYXUaV uamKfA-< е^r^$WO䡡_߷>D*!WT`._0`}XdAqd%&g6iQb9e %X>u]5p=$ ^,);pNN+}'_5I.:ߥƸ:1 @/v2bFkkoWBϱ\^ = _@@ };}-A6o.v/1%ǿeYɂgt-:z&>#mXV J 0BN0z, [vty ,#GSUKSpx2=t7>Qr6&n?~ l~“q ?3* -Հ X,TбiA{gʾ1WN_G:gЩ]uY@/gGuX;W. jN/NN}?~b1TZ! EshʿypsGΜ-x{ڻ,6Ie=eXv4ԵH,DMwoWbLw"i \2_ˇ>ٗ,@MQtWb^gaN گ.)nX|]a+Q-xd*Dp 3?g{zEU, L.bķ/ v#7K5A??a~%29CQLA8#(a@5 v$zQL9E ,~}e@]X}{MjiZ *B  ^4|/D ]PD]ٺ`lwXQ ZTXٯ8?}A|) }cnY%#J 4 w/& #0{úYoSt#C|"yDmbp/:#ďV﮾s \ES$腨 Q8JeAh["5%kпT lw _sݵDt"Pňxr(:US%%)Y F4 aB A&VbD'CabLLN{eS8/H) Y|Z_6Qm+H?@>BUU>'ZX$p: S :|JӍ@24qФebݑ vq@LR]k6F^*옙Wۂ*L6`n f\pVTh=z?J]g@?6am}S[%H.~M|Ϟ:b$>9wj hbAt?r޿t/@.U~n=AS>,6:gu_wL둈>g>;jPHeAeh@K. u{=ƀc%g_0 wVw!T&D .yAGdQ?Bt%:9j mlnѾ !%"_oho%,Ŗ+_~[c{׹.q@%{+Y?%E+h[`u 1EiBn D}~ǹs4[@>.(0h'P#;gwo-$29v T] @_}Av&j`6c~_/ac?E``ϗ>g_A!]}Pn[j7 'AhȬz+PtVuN`]n`ld B!1:JH~JM'qjFX=5!y">j?נ}}W@-h].́\z_~_-h@UOG`*( =~k$mC??VEOʍmNs]4s52y@ 6u5Z[[V0 >, bpAEꝬÈ@4LR8yvؼ) ܺE["k_> V 8E`š_'< ,b@{# ېY[?F-TW~ZTKy*c(y0R 𿶦 'p!pSC?T*؞Fٿ|/d 2ϗ_dTTpc=[l R?n Rkz7ْ ZM"*_y' 5 HC,l ͐.295A?޼~ 1'_3#p&`u8s#;K5a:E Ca`Giq@[h&F0 3?" W`/Jq||݋ LO3/nJJr f},]OЎxWu? \Re5??I֎Pg@@kBA~ݸ@h_ 3\b}xnnm ;w\NOJY1H,*iGЋ^? & ?YR9\+B{حmA c@3S-q6e3.VB*_ !aX$ b?B kԾG@Pdy$7#9n!(*f WI6x<0ZZ>k(aR3x%rfK~bƟv^"C??[O]Z@)ǧf澠jT?rã \EPC U@ \tٲ> l,,{&};3YHߘH@u y>ٴŠ؟&&A$94)mNzT$_~<Dj4nm @m}y.,"*γ" o/ b \jz_r|`a?c9H2UB?}WP ܞc O3I˿D7,T~u_?WɌ/].NPh s> kȤD zPHDOsB9O`qA#J`/P@AXѮ^2.ŲZ+؝(oi g=M|=@׿\'öߊ `*aV!Ƈ5 .]G~{:2Bk&ѡo D-34? _ "GPh}8h|̀;Jmmm3դUdr\` P^NeJ! ?)[ / 2 ]% r۴%hːaK_Ȱ J[?.PBl4y0̽?*=njW /)o*<꟞kT ԗ?-Mk[j=$gco]CJ!gAL|u=K/ML?eWs? 3 HzG Ind)k<ѩa Q O e?iN '  >;zN3%CN(%mFB qw/QkGT2cĶlq~44nc/tqq Ȥl_HAąB7XDr*[v,%]PV9`==AM޿Y`)k O?.Dh7+1$}8T:PFRo.G}uE\\H>t6?U,?5~>0$ېb/ {|r< o5g.7  H\.1eHZҒSCCO @(,m?QE{<{PvD0h釹X_8-(Ňw//xAyxyP`39p4BKJVҀ挸 厣˘LP?__PiQHrT+7П_xv{5CM?g'ЊN/˛ >N??~8?Dz|MQ,xo6PD/:jl9_ (kt8c? `*йůlLA=Ph{_<;Obz5 d~)O@ 3k@򦯑>bbF?<Z?Mk3uWĵ#w}&nP:`Y]zû8q!,u QoT?zL ΍4Ne @bۧ |@5`cH<^z̵̀WdG0?3TuN z ܝ`U~Mdo.N~JS?[&|ij@/ ebn\p@@]2X@n(u| ˠO:ΤhG`:\}cj?㷁Zj*\j ;n}(ʗz}J?E3{u`)@Vo0x:] RڬRzZ= Mhˮ-/@K@)ABٕ~:o%o0\7"Y?^1}u-y /{{h_\[ Џ]rOP^l1?&/k`A!AgIƹ|_#E`/m)a[/nzR!uuŒ@P_x8rEBO$7=1?5h[jYj1薼 *m"/ۀeP0ۂ~@?̀E گLB%b~Qgklc^Ay9q7g Gٚ@cЬE,,hG 4/a*H?^T:Gk?t* V۟-ðxWo*Q^'YOdz{_WzaةOIG|W+P6d F .: #DCVLW?~XI@aj"+GLvZs`+3=m_ڂΩI@_; ȜcڤVbŀ?( < z ΋L~`[@l9"vhZd302`~pʜO@$QOt59U`Ǐy/( UKHZ[CmAX.] (0@; A6xLMr+_8rXg+Sv* xLPh[Pg2,TtF·/LA}ȴa?0D#%wuoW; ?mSϷ{ĕp^`90`lrTg᳀-ti6jލå'yX_moQ€'W^CN@ ]!pYer`@yzf  |"̶%ntd IDAT[=Z2c7neSNf0`#[a$׵Xd}<;la 0^ 컂L0_N: ŭ|(QbD 7[qhX'O0ڱ@+8)F.<Щ8}V7? e`>6}btOEZ4?b7OrşT|Ac:{]nAp;f޽MOP4\P9c@-l6d@,{Ct:R|`@=C#([ kH[F?#:SD$ f& P_8"J@|#E6zǚnw7? ѿk-0X{qVV^8W_j *VU`A=A߫,i>#n5[[<t֟B({8j:Y6m?֥{&ճiǩq(ٛc jP5D?~O? fFnܼ~bypibpE|cX{1wM@kh/_(|JC_ }25\%?Z.Ze~)C)@ wi%m; /s|D6NĈxbX{{Cxv|0X z4yF~olXz0hzCq͋*o:)Y-+| ƃpOn[=!c}?|o0@[2gRƕKh%a@i0`=y3[0 X'=w uxB#+L@VD@CPB8 Й1ϒ2;Ӄ?ʇ-8??M4?Ҽn5k(``}qwMeiǖؐj_,TYtGZu}a6Z-i-Z@S:ov-BA* /;[.vR#%PX'9s9smv~I/(y|Sہ'l0YMݻa+Лثj Pna( {+; ?ߛ=%<;9B< fv &ۿ }аɝ^]A=]LJsK_<6 =Wǿcc`)_C*vo|=x_|Xc|@ /d@@}_NR/J̀!'K $rZd/fPͬe6 *ǿC|,Nnjp;pE-ڌ䭖hOվ&q|Y.|fuꔍI~ ¶k΍K c+a U_ `/R=ѣGWz `H ;߲JD8vzQb m7etD.ڴ"SX%{,v:n:@s,|> #خ6u,wUT}_b7Wc /Y?Hla +7ʂ3 DtCk~_{`ޮf:ܚi P'~L\)@t^+]ghׇyKT؟ˀúgh[UKĿOEЏw_+Š 'D1j(L?UREgxgcx zL x0: wGo>( F5 F~z KeQSaF3z 'L =?e@=L0_,Y& +俬TMT7\ bkr0QPEݙ~ֿ dla`0 x&NyD./J€y:b.<ff_oErt!Z!X(@3`-WAP]wn?8[, /Pe*)+LNJb1Zh_a4ߦoR ?ЇԦ0)\żl&Kjħ?0~M PLov0H( 4y@\ ^-BuD$.W:jQ%EQBѶ[<!YobbJ*OkO? y DR;`$P0uaWD$m@Ycl@9d@\94>0D@M oPw09Lj%fQ}Ec~C>$ Q_'.pPW^ޖ|0/Ȝ?J@O9/߼9D/?Lέ_9X0.0+Py)ZpPؑru=N^/tw`@P1$ i-a~I;JbK []Nf!( M j>>_[@Vh2eZ8tNsb(\J/*?be 7 WƁ=q@ף %Akg&@9ao84<(8A( >L3?EE/ڷaGLGLK@Uv.Y?22z6?[`O*3h@+ovenJ??'fI^۹6l€d@5XUTpc5!px73qAЏ~; x/.B،39L hǿ  LZfkH V2pC5P.%Mlyj >0 1 ++a7KPh[KZ &K0i P?{72g ^1O:1 8Gi9ALcD"4#"@̘P@}eS Qc\ ~\Yt7^#_nyz+|#5ч6ޟYHqg@N|a`)a^ P!,y@m-֔5ćvpHdr)Hv-&&q[p쮁H%k;[ [!*k^7Ѐgi,6vR` 1XJ N#:[T$ԏw 6;^/+kCcP<}SD"p ޱ^l e@Wr)_a/AC( BhHu`@c7<ȸ jtKEx LzY 1lNvb1ƀgϾpO d݋Y'PDsQ|8їy(L͊5aW1u. +׿̀+pIZm4'ux?2 Qz8RX`U,硍z[J-o666bK0 b) "T)4fj&2 `tz{Efja{AJW6 IO]?_?[Mnm0ta@~Ǭ! D ]1[ۛe0€wG@|dG T"! B?gvlc-'wpl!ܨLp P˫_ tFgpP,_H_Te6^O;#@F`R1z~97AҟMVWZ`.:=At{@*A@JPH\z S^oih+)*+ZCؗ1 |p1`^< DoBuI@ra_' |v5?[~[wKಡy1A1Lbo:~5(.]/ {xpABDl vQ  G\ B`J>Cl<@i Rޒ9[a!. M"hڧ)_Uc' ‚*i@ 3_L?_ swFYjDo= @]  xz/}J[V]΀c>H+\C @snD@*LV@)R߳xVh/4L0!:-] 9_ 7&/_g ou Ǥm@"?$1H7] gf?`!΀3X0@->WHap0P;*f>sͭH(nſ?)JK` : M9cVfVbcF>`& *laMsu*_v0GMaccxO5 $Vv\.u4@\Ysf0-ynp¡an`W2TTpLL MX#'ܳVl~ɥKB n>*xNcNxmQ}W@_IܿO߹xN?gƀ i⟱bU!#p2 MW%Styj3-y۹ABD.J€` q24 ٵ@,*ubW^ 9ohw,e 8+Uη:0|81YPڈ؟&6F@@w{ F?:s ^@(7Q@?[=ij`MCX\1 4w`@)i,Fŀ; @qvGMJY`6_@P8y@i)J+;E߿SwW*)DŤry IDAT@ TL\G?  5s<^8p1`gЪs] 16u1 9#ʏHXYV `@H&$NC9I@-%HaD%JVBcI 7쾿=7's7 Ez99- d!SVAOnlH !%WĀT!NQ J._V1O$]?|'PxV `<;+<'oī}w&%OI'lsYn ZZmLk[GFlm>IC3xo9M>:m&oJ6AO  !L-m'bs!҅<u ]Q7)hThM.Kl[) :iϾ}J|Wy>xuW6G3@]8A |?j9-ipWc]?8^~?!LX*H]2@E .5 B-c⻀8i 2pQymC0_L6 v0`s[jpNv?ys\5o&OL`@Ju<`}*q{U,ט?N2\ߢM6@k?O Rf |h/aB,MHig 00x+3 /0 a ÀMs ϻJ8|㇉?"]_C ӤoPWjM|bQ^il:,,̇(9 u jN@A/yz Z荡 FP'00w X.1Hzx^pUzC2> ЇqnS5$/ ~H: V_to(_VK2`"-%$nK os  SA]A JezMUd ud2`LLg)c|ݏƶ왘Xv߮2)OwWr_ >'9#%.g-,/dӀL`hUSeu `dFhi@]0 TaUt?!h7":b9ǒ@j)2 6>N{u{_\{w%Br0`HӷM؈h;<6-dO6Fl=ޜ\|nB P %^SPoW2h/VsFThs8:0$@ra sqlR/ q KdY4V.]xRcyh%jKML 1mTg-@?^ߏ43AxSc%%CŽ jh \` \EZ~Oq #y@m}קh+N:q<?\f6521u + lݿ:::;Os7wu.1_V>?>6-YB,R~}S-{Aa (x. ZAh_l :.g. c@.S~!1TQ|g듍v0Νq%xUJD0QF7` /H;;fOߺzT/ fKǼ%  4p@%LuX !`/H0Cu@mSZĀl!; ^@ IpOŶs~]O`6x|\nO珱::ކQ{Gl7pf8w"WC)C[5Ѕ6UzКD{<9h^  d$X6b!`K 6|vdlN(V->%s7=j}w]ogШ ''_o_:@I< *:;04tN? J?v]_N_eҠwԬZW|*W&0R8 X}oXv; z!C+bwX€ܬ `]1`:CkƭೱZ;\r.t? |'(D9Mjh\5-S%{ިݿg\Y?ŪeVAdG6g!CtC#,<&$B^tc!pݐe(/f 40T`%@(cϙ;5/"w\KcVs/?+"n ΀R+>3!?u E3 #aǀHc UW^\ hZt" y{Yɼls~qV8Kecs/']zկ0 я˙<~@- R&Ce'5]%;0`n.yP6{ `<.d=ਸ਼@"?ܵrp\`soNpG Q ۨ (.^Tbx x?$ݮO ?-]@Bƀ0ks`Boo}w*1@ލ&gRPe 8:-b Z`I 2 U(0`@ 9yZ5 X~c(:'yOkO5{|W= c=Zl-weZU- Z[.5R5Nhzi4=y9dje s_\ۘ$#@V `8JX+5G]!{zZ`Qw Z`m:>"-2`^ 3$c )(2ɉo2AHĕGĥ[+J}P2 ۟R笡g<H7} u_geȔnV Dǿ>Iw@x(7?L WBu`\S~xvip\X"m:0@2Ǖjqy^ep\ . .½[xw#0:ifS+W&S-Z.eXcʀY\*_hrF\lŷ7K5@rjd@W2b:=(>:,Jb l Y蟱߉*RᙯEq** 6AӱӜy3drA P h;;j իa w2Uvpr!(P(ggg;qt4-ܿ*K7մMh~pڿD[Z O }Ǻ\׃cVUe\`ƅڪz/+A3(4Q],\ZMq ~YH|ߗX_ ˯BW.#^n_GrSU 760p$ޯ?'>U|+oc/URUr+?ƀUe9 p {%R_X?ɾEKݿ`\hY3\̀4a+?8dt}1!e:8-]@]*p^@VĿ1@1:pXr@Gp 8o\>+E>}sp䐴 dx\ i[S 7'J#ya_? b>O~2;ȘO^5\+?b~~%>, }#muC",uVdAK)͖"?_q0Խ8-o#ͭ\CR\ )?p}і~b$ ! 3Z׼'t!Q1 #%- ~ iE>9</pUAi+>Q0 `Z(c ؍|Yp0mHo_Ζ[Y9m8D %2A&ܰm4G,ߦXLb ML)%(|BZ '-@n `Udk)( u 2-K1]@c`"C30 bB &03fM~rɰaoI`K'0ݘ}l6{xOj @iQUh]H˓q`ǣ@"+T_D&B`^!=|3(:X1<'H1`|Ъ<303^X^6,),QjF^3ڤa`7- a9hHC # ,( L{He~˼u㮝g6NC8V{ϫrI~6,&hxx5̈Ep@xk#F;cpi@Z^CAin;.y $g4 ڟSm@8=WR.@_^0ʅ$\XLz2yw-C(L[0r`IM|4_iSŏ]~ԭ1A81I`kqI#$3j+Ap# in!-4bO3aK!oP|m>;Qa12 IDATKo^0}Y;̘"],./F[l1rKLJOH[|LmQHY],F,K- /x tOz=7:cq~#wf u ,O6o  `r r?Oq#e K5Wp\-B#s.N>vrOJy?R7'iOvC@9ף>իѸ.5yqN8 GZf473I3lg22".PfJG S/",Jqu!B=;p ySD=J5䀱 M~ɚ%ٝHq&8z釉&P1xhqc onl|-ﯪ /?`c!kE=}L Vnw.H ûppV/i6 iRPln?3oTO}h0!6 *Zn``I3|_._A9&u= GՎ M'XgG0" Zu}⍂X@g=ࢃl&G+dN#AϮ r0mggY P(t.ZyS%'ƕCzgcUY%=h3(Q `^:;d <~%,W%r{ j dDd@G5WcN Ka頥xʳ?'j%j FOH#dá×SW^7?nOep (Q\A@68U4ddsǦD͚U0[ ~L5if uj/z٩Z 8jwM'&<|2 & No|,QhnAX/d@[t @*iO!9I_ #)`@Dže *8WvpPF\1c}F1 /+}$ 8zk?}pOz$cw8&1}P!9!#o_U8( q@H)4l1Ti1rjo C_:|."7l^_NPs']\О;@M8ɇN?vs U~.k2A0pG2 p] \&wBeʴ|O?y_)p X75QZ5(XEٗZ/P\33jw2d6F8ɧF"K\PC^}gm+ۢK^(n/P*ʄ^< L&N ln."Eƕ Cf4'x>j*{'9{T?bWM FX7*`2`W>j.tfF8i2 X6@19 ooHjpf`ISR$O/64o|6⿒j?l`X-7o$ a\e}(ĖپX'{L{8@0ГĮ+쑲 +[sWa3Q>r9GgjTQ߶W 'X攏̉ۇPT_<[ͥ$}nXG\@^$ Hc1!M*;H~dkSeXz*/>K뉟}ZwMH)D$^?4GŖGkC^-$MPjvZ/cn@><ݮmA`pkC u3򯟏v̡|zfE;3rojڇ3sn߀ l#j]^ր/Z@Nס|߰ 0H@oz1Ibh0hu6XWxŸ{ePGF*@ޫV)МWIW[%/lk9ջp5 ANJ(J#iŰhp^#4&Ku zdP%pw;?YPnt6KyJXsQ{UK\SMA/ۍDY1~w|[ǀ<ҿ0i֫0̟jMcP[66S}M3^yFs@6y?DĿ#9`"Fgn(DAsY$t>L ߷ ?!  /#m023 =>4 :/B_W5\nOkh9`F:ռf`_"E?; y1( (+!?5?6o =KG5v2U@DDmG<p3A1 Z5\݌%()IbQ;5̀ i~Ng32O^NnH.*@W@eץЦwZ>}kT;|;?I ʹ|3_"ق\PRag:3%Fq!/9@)|oq@!٦pw ?}: D' 7Icf(d BYlx^ӟoV\OP]w|zaG3>nC\o1^ e0 N}  7>|ӟXz&1x;:7S/9 p嗥o+ĆkAd6X74O‎l. qT8nFƑwSAbRGh2r-4ji??vz KV6׫,c%0S9h CX( ڲ#(-V-m $\ɳ㟞 r>a2ՠ{}; V_sR2#_/ݱ/?[pZ8?GO&6Ux,'f 'm4(`Lj,Ј yGed] ] !=Co>2`s9.όs o / fq/B;)*1/n">+a! p .?Fe8,jpb/ 7{8{f~%%ϵ-#?J+lДS2.@״k(Ʊh'h)jtd 8GQ( ̀^Н&0k#De߽e"MpS'wO^R|E(HebP2;)_ռg{KZk:dO(v2\P CXVKiE(腟|xɠkȥ•rMyzZ238R m7ߛ{vqpe&{h+  ?`Am RC>E?IꏔD+ fp}kv;5]mP WQOv |ZjEù%Nk|P]^0iJ- &b@mѳOg?3<׫⿌0?>iN¼Y?SYfj k?Gv!H8-_H@v15 j@(F]GU*3Lң+Ilj, ;?Kw\=!dq+RV P'y?$)@kP܂xoD4H9`hsep O̐>}?_wO[ҿߕO5^b7X~MAkMkspi0~A0k֫L/ȦN!AIQ6 M%C.3Jg8;KQۿwQ*׀I} U~E p^ C*?qӓxB.RQR+Hg?J_rN]a.@ +( "\峽[ׄZ4.ӺX/D\KZYx!nw.]:M r=pNyHr9{6oq?(HFOe0.l@Vӯ*u=Xf OOӒ Sk+  sw,n%Y!cY AՌW gZW{8_V!"%9rKÈgǿ4]Q(> 8s\M S%>7=AbY IiTȞjp IDAT55hb~="PĀ_~~kY`/` D_ get #QleYi󎏲LH Jm+BTư P>X,&?ߪ/xCK9zv! ߵo3Eq.nal8秒2KncĿTe6%>p,Ek2%{x +3CrIw/MơI H"wrH De)iq: /]©0 BmO`KKƵS{ `= 5R \z ~,'0`{a6|J|d 4#VT8XvSh{UOq_m?5$uBbaSzWLTMzw04Xbھ)j8?߭[8C=6 H_=M6sɗgFҩ($,ל/|'f?\cNV{Z@X f&5\/.bH دG=NK !mT:ʆaz| -EO%H c2bGʸu%fmEc 5AQ?j<}- ƀ'*cOdaE>,{.E҆ NaN/|nԪ/L-@ ?s A N=F 0C RWc~- ?r}&?ٽ9[ -@j_=C - ~w&Vg%F7!JU NfLjPMh2^03/mM, 0#Yn0 b3l{YlĐ57Uh , e_JX d' p/j/Ca@*鬈H @~͹Hq` 'g-?8- HĠ-w`[ HS/[Sbh\20P4Ffp[_ſZcg@䋴$Yk6;@HO,fr7$$Xj ߖaJ ?`ACNjFw0@ۇloMG$Y1hX8[`E-8[GظŸ2 \!N"f0 dSl"À,!i1@ɆXzyHL$ Rkp(ĉY]>hp`! <">4v3^?<؍3\Q3 ({ @o77_Ь+%JCu--V\N@@b)O@&!%XxWcS~mM*<б@dA RS5?1]t =^Zp')Ro V^u! v {"` *P#318}R@o. Pa@ѵ\lTBL &O`@u'YbY5_ќMeUCCa0` SWvU 5\__Og+.!ߜͲr@,??Wo :%_l w'tØJ|y j̠3Lv ,` ߯67E%~q7(8o2kc9[-.,_U: ȏE>u 5q]Odze>Cb0 ZR'>̠LA6@P iPM [Tpowj\Z64Ff}sϏ4 鯊_c?i 1TǠć0 b+a`SYY0' Z*G%̴ BC|7㟅[DAE>Ύ|5YP.]6НC+U4R~i(mB(Jj''E١W~j,@6 cqpO9x]@$"b=G|zV-;e6bWh%~ᄌ1{]yА/ ;@k=#C* ׻AC &!%k0-ƷA;5x[ K-h"|6X:q_fbpؕgi^^>cpl.'"bݎC:0`qgudz=|è?u{]?ח$8SASLD%qD^`Mdbb0Ʈ@lο,I[V-ԿAN)tlT*kvzUzrW kϤ>nK5#й;'Y`z7^- 3(˂ lF!5=n2A 0>r:yc(VO!SV lea"9{&/X6* `"ϲGAzn1lsZL#um:G + B1MOSw;w17beJ(=!@øv'otfA}K#V`` ,[e`dDX`C.jPLP>?2 F[PAe AAʔDâm 4BT.D{u|73=gn`.>L X= `}vo(7C}@LOc5Ǜ4,Kub0qa0V#ZoY*5X͞1O7- hPn}DX5Y 3 +x,Ӏ `i)Pƿ4Vn_4|'D;ROjp*0u+?Jogp0 \:b~.1Z| 1(ׅT̠YoׇK:i`I k#9($2Ӂ^`tׇ=hXY]vWԷ2#^P>r8U2"ދt p>yE @K5S ]@ o&_bbc[. *93A E.j%m0r @ [A NZAUwrR8-?_Eb&1?,RP+V~Տ ?@z ,ϭoJuj >Ls7%9 @/Po* HL/ߛLe:vBHP(6?TAgZ}~n{9) oRa[אIMXO] l(S&`Czٺ<. #Ѷ{Xxxn?Wgߥ=KC0g8| cf%zMȓ]h:Q "d8n[PɴW:m70G6V=Ԡn@/χ_/ZVq]bUX1@$5܅u{ gӧO(?8l !6X7@[窓Tqc;AK6%zlm|7xͅH}C^]څT 2MqO?xu`1IzŴa >w;}"oOkw*p`xحHp(EO-`@5>8Xߜ^s$X>lP) @?tlxBr΁uJv7"E@ )RG' `AvK/{g>b2_ |n  YϜӍWF)I_͝p/ +#'׿aNg3^ڥreal Vv*A%DsP=<5ؐܰr֍`ĿZfT% p8^|•uOswAaxn &<1̠(Ў)xgnȹ^RYur?"uzlggQ? FG%!@)}+G;q` 0Tn8}Lj@i6x+?qP7D?z ͅM;%<9x2 ?G|7>aܦ5 6Ҁ`d Tv( ?C FuNiWJ#=(y`6r|0`4߿_q'F73^,bım0:rs3M*-/+?Dl 1 [ ;ߣndűb%¡r8?l7ᰵ8rq6jyGÿޞԋ bk#Gg_м0):<@q|U)SuHN"FNܴpDp.0qGSҕG%ת4o J;%u"ÍuӁ ;_憋낒ukM>[L% 4j P`(%k(ڠG}@~ԍl hzPx:b^_|M! Qflhf#աu7F d7f9%wȱ@^#XtHX3h]m&ܤ@ 7xQu IӋ7X?*߫unz#]u}"7 $ J 0?aCt0R``(.FR=S#{8Rѐtj fW4ExfA[7 L8ze $ns^c)7VpF-'Jk gW0iF7 CNp_RT½:c*T 3>+H qn›!_;ߏC*[#p0->70O|u r9=)Y}(홟 $|h'|X8o /!aVYp=a0a7 H5~؇SL} g+ )X{V#W0 `D>lݢQp #lEg`),|?wߊ^|l6Iu :&`吔+TC|[WiQMD7` xJf@-—{E,Q+MVC0ͼ􅤙̥/U`EǍMH2o c c3Ee?.83L514|F`cG;݈e(kf%K~]L(1b>^yJ x~TT" _l]:-ʄ;ث+> hO>%!ohUMhЗJ6Fcxzv_{*`G)/& Aέ)@t&%oΆd =ec;o.0{DK+s[ۅMO/\?yՙ[nR7/0}mxhU{pdy*s9l2b:/ٹ緥v3K X?71yGg,33G~,tu>ٿ[/ CA٥saN?OLR֮BuT;gHeήL"'}<pxIU\j1IDAT';k8^4೫жnGi 7[& di ؾxn(LP7$s##'PБ0kpAooS92ؿsf7, Wy$ N㹟LY,s~aoK=̀/w;T8ܻ/tufAv>o3g"We\a3`{.U-]~29K'0?=78H f $H A $ H Zn\~Qqnk%Mx!Gc4j&b*JLQr6y+D!B PL@Ri:NgzjqRZx'AЂ$LLju27l7WL(D4,H _8R…ՠM(jg~/@O)9tZNXmRG:W*bObkT/`ގtÆTE`Jh|iRe@K*Co Uf z.t+wPI$ e@RWx AMah} J|JTrk0+O8g ^Ɋl_R dl4L ]@%uIyGvfpʄepҶ@\), S:sR:zj_Ҥ?rx󞔩.=9.G(ꆻ 9(@C'؀ F5h W&B>@I.3GD[ 4CQ/(i'=@V|#6(VCx' hv/e$-]PW6P>ة5B4 kdcOn@{:=pmDl@8 ҖPzDB{ xSBܔ@@1>Kiv9pd@H0!aTkk-ꁱA9VbHWb >9,@H q> ȱFZR6"ҕ Z LʈR <ȨXϤ:$ * >kxV77`6;hAj]jBQl@caMJbv&X}2/|ogk }{kߒu{V"/oru_Qʯ>Q~+?ty xI}c,9 ?TsOI1Rs胿_*H A $H A $H>E|4IENDB`goxel-0.11.0/screenshots/screenshot-dicom.png000066400000000000000000002342721435762723100212470ustar00rootroot00000000000000PNG  IHDR  ]gAMA asRGBtEXtSoftwaregnome-screenshot>PLTE999MMMGGGhhLT\TY~rrrff222AAA<<>>ZZZ```QQQCCCmmmttt,,,kkkOOOuuu~~~cccgggȋEEEǑͿ000qqq###///VVV\\\***888___bbbNNN666zzzeeeSSSŞ))) }}}oooyyyоpppfff՟@@@LLL|||WWW]]]444%%%III{{{س;;;ܒۭFFFߗ^^^佽֯ބ 凇ݪ:::⚚ᩩ555777..."""vvnn ''BBee__''}}33f++WXXК#ӌOO9Կ''99sQWskkqqzǭ##F.MTaOViڥ葓 IDATxkLkfz^(FCےmŵ.`]IE`(BvY?pIĨADC4 ѐ /GorUH{Bf|73 8ؖt $A aП _:.="|fvl%p3<<}5l/mgf^K'A4>o!;6Ip_doKhz WA<Ҭ fjPeثՂ*C/p?e` `&Yl8*-D235ƣ%Z\{M8Sb3O/V"K,f˷|N N~%X Aw,@9PJ0\?ˏdm/?׳ oمP` PggXA. Ċ 27 Ƨ7X/ì /؅ 뉕ϧ_nA oXAƘR-d~-} (lYr2<<8I֊H.+ N0A0)W־?Y85.ӛ_枎 OphD O ? CYAEް*0A&" 1͂_ M^y 2|hhFl$%+9Rt45h遈SA=PtHm33$ @ĵ $A @ H @Ŀ Iq# դƫ|ک'sOeePOiKdNj@-#wΠUU*CA($ۭH\nonk? x:3S߅ttt|>uXuwaK(%>e(M29J! c/…݀˥ihӟxcw F[#hN<6@n2DbJ*fAkUj~mI@D 38#@R45왎]+^b coHϔUjkS ['JH./kD==ok ŢRd9K5(Xx7H9A.HI2=gW(@Sv0'ORi"h"6Ď { t:j>.+rOOQ$rX+!mm$2RT+b|>, 0net~) AX=lD"I*wm #HnniPXY4xD]@H7JB=Q^ŰEMk(Ț C 8V17LE,aق>+Bas 1@&}kaM@+sGgyH5pXd7 OzgLNNO؛#CɴJ}K;80leN 舛%7ZB"i(s`2a,Ͱ)m7 w&VJ,V$Q!ɲXfNEd"P.m-d۫XW0܅&hlJpxtx |\rr+\]BB@`OD%Ә,Q=>5t9E- Щu`SшǍFkSdpT{ n bFg6 &SA} {_}R=Ѭh‹ TE=*[Wt^o]jge 4 tMR M݈VШjv҂n cD(\"YY4p nwoZxR;@h{B& @NӴ u tYVz@7=N8vhׇFܻ808<R)Z_o/`4pxa!h ^!( ,utR*Td!2z=8v>_g?n_i6 Ry4\cB  . G@^ϕϱ ?}7LV罪Phkf=% ka@8`hhcek;JYs ̶a*P&6C!@...\0Dz-NK{sK/{<< (B>%[م"gD+>iȵ`AKE??e" ?lX GHk4n ;95SqnT֒;e֕vT>Uu=NL{I+y]A[W>ьjUM]VFǍֺkKĘ= %v2IjiU}L[9|U6̂Y $HP_( } dg5nΣd ?@Rl'p d9@cWЌW8WT+ss ~qSV܍ XYA$%2.Am-@JKCx;;u-BS6n\ 1&̡VƀΥ{W@vvNvSF x$~/qv2 ơt9>a ??h˗?ï<@EBUEHXZN"K ;ɾ.}k'kǏq)Ҟ%k x@~Vbr9Q:!v{q{] 55&Y ) %Au djd ]}S7uqrփpIb 3|Cߡд?f /O ?}>J] #'f ӧv<{N*i8RE;4 Ck@Q h4@j ;rqၫ}6 1VY(3՚o8+˹݆KXk:91pS$7@~ TUxzSh)Ձ JpU*"臷@<' v\X3.?j0-=ab0PVP[( FCQƋ'nȅ1l#ù} 0fXtJ` +SяBHwۣ/_}+Ӫ@Pi5[ iȑ4P푕% Y2@6#ÁJL昢i:‹ 8W:!:3dKY)WC\{ ͗,0@8A &"4*1, A&<]99(y2D~=cܾ=44UNBE'Tg-,mm] AB|Y=`PkO_^;5UZU諔_YʇVt)sYUAn7(9_2a 1xp֛nǛ[@x#1u5̺<$[RCu$Z[KSZ: TJѵ1Rv)hd!\sEELowex8 HAdz##J҈oyzzP o0C$RVIMWIQK`o7i'9C ?7ߤ F#,MLBm|]%+뛝=IĶʬ+066WW"6O,BkDaK'bjD]yb}uSm ׻Bш/ipI}K@ (p$>hZ4# (b}2FkLXު_hHOrbigPUv|Qi}::cH4&ź"|篣Ǜ7o^@@ܽ[' N.m{c||d|WPG'_"*gq>e.5#rhltqE߂Y !tTX{:,\ʞO3J+}H FAq4V!h ƨi\81&16*FÔe:3.Ky.=SJo9߳]G^*4WAן!t5D l61+%NHiHrr+<}-e=n4b) _¯쓏/۷V_B@ %-TϾ5HׅF:0z0 biUDoju^ ^Tϛ ?Ѥ,6S5.rL8 #(<^^H@ж8MkAz^ХX *dT7 g)u|ޓ dΕXa9b<0iv;zRK$|FJ_bd V V] Ш$Bp1Dj0hI"#$t-4pu8  syW<ߗ IDATsBO_M! o57 sx@K ##pT"IkB{=0P2tP(Ɔ`P8H[M^.jCCF5 @쀒D/HIJ ;4AbVI$#'8ӏ1-JS''^" OK$9ifw<+//w:! +#|ϳWMWո ;;[Zkχ_PQ[(ܡ[ɔ|N FG-)@A/fTu5}Vq_)Z5^ 9C5bm|8I@Doy<JV&"x 7Q+GO%0A]#ZdGonc8 &c7 [(L,myŮ׽v.P{R~x:;ӳ7_5X[]EH$o"<D O~>7`7l1~Z^QXշʪR>QaIK,/##B"ܖNfj〼}fG2>>m!yPbWN"&V&.(9Fȹs!gٞXy}i/7N޸aו#Ip8Cdpp=}CvOM;(Ѳi|گ]Stư }}ުxPn%Uw0C7ƀhr\&ׇBdG,yI@'9 n=!g/mخQ27xiCmcϳ&o5]y>dxpkx֥KndH-@j@dm$O|Ks&9χdUZj8 6Xt2ɌFL*` ^iߵV')e⎫G Bv壤eB@274F_E:Tϰ+_, 뫦NgNZN$@H FGɄa/~sG@0ZPy,oߜ?szЇ$LKkjq'JHȿ;=amynB@Q$EBLd)Pd2JSQ@EFA)ѣ\M7k p}$]!xY. FّRd0ȍ) YB\Rbټ~CTjc#W`cs@xאg6hi[.^" # 7L̶5ԗ7K˴ kl/x9eKAkhl&Tu%<쬮^W8: eeev{ vãw]Rl}bv6NMKKkՀDzaT(%R>FE(K5lX`cC@0"Eb)o] d(bbx;sHFÊ+Xȁ\b>ǢSf>siCč;'qOC" X?wLLyө]/Wڪ׻57ʇz6V{Nt&SSTE-qln6pÇ_gJ\"5XZF$mQ w`,Efb= m3Yd6O u$*KR${X} U[jIUP,v tyH:riC$(=H <uA&e~9 :;OLW(.7d! u:EWz}\MMvpsp{o)E>7! :)d>(9HL7 vZg8iQ>8 #J`0H <Cȩi# \]"y2%Z>̄GJZc?f /dzzzzQ^?zBe /[6/)A& + ::vw0l I8@r1vDo,n 9 )&qK:+Kshy  jYʁOxr30Z[4{{/āCEtBe| XW'r9bri.μ`lQC,d}# ǥ/3m󺆆tHS[պ>@RUvQ{sUUci##G#,C9BeA(y "UV # JvŰ )UPj5DL&Uj-2"_WB Hc0b8 h(_ $wƸ tL"#IW\CV3˹@~|,_`Bytbe/*/?*|F9@BBE,[+<))X\\L}dƎDxD&M|ei܄-@l, [0F @x ^a`hj5@٧5Rh?z(UA?R,jpU(M?bL~|69W}:S/(hkj .THֹ͌SI@Tnۗ .t((S"?0z^9yg\M; R! /bT DSSr[mgD*oharrֵcGjlt#f/VFb KGO3bpoR.~EiFnl7YtX$$X|&*e8d4GRm/e 1"67#3E\PyL)KN9뫴ڣ,+ D^x׮O/er HSE WO10|9<|spaԘuz Z[B ]d?Y7PсD҄~ҐnwGNrIfZ$ E<6H}!" 4 Ԡ%" cuw!\=? % 9^eXe_<#Zowf^MOw+td,Qc̟ʲ8n(@DAD$F1vW$a1F(5HKĖ6vMJR5oͽ!!Lj)NY^=_{ϹmM7nTWw~ A~t0nĆ[t@Wsq94aM'AȔr9H֓ ]RI[9u8@;vˀE@n)^JR`׮`/̦4GK#I@Z)W`Vz-hl=CAZnn܅73 /p-UR t: ΅VU} &fffB3΅aLYt%Ok LX|@7ZJ Ci_!!Bnf lJ8՟Wj*LL!`d2YnWdivDf/}磻83 8^N N`}訍\ m+yPl! SeS(ŒӣԺNȜw6*&d;w@3ږ>07G4M!C=׮%'+֮N2pCB⊦[F__!Ga+,t0H{.օ[u, څJ}d%~]FALdD63nDc_"% AȈYšQZ q\xtXf^OXD 1ْlI|ylp4 G ˗G;:TDܲh"M?iXj"xrioi\m?rԦk9Ga\=ӒCxJ` +Wpq˃z;]?ߋʠZjIÀO.WDF՗.EGI%My++]‚pАq/d[BZVͣXRB:׷'SlF>F)r:)@@"͎m#@@} ]R h9L\8ZT֡ >'%W=}IdɱccQ0 }s_뵒`'@7q=fxj#YAzHS>}suW)3HCܭ9Ƶ rIV2`At`"ag*񱴬 ꮀZk܄NzxT/wDc{ҏOpV햭 qy4kܛP6!hGO= iL9(dx4*kH@Fcb$(Q$`"@>ݻЪ{[Ʉox 9xpo "@( %.ؿ99kk>) E⁞-BLF]_~ҍ^P{mЯ(!8: ۃ%"FI@LO15 O0 Q8ryjjI3tцNjO'<ܺBP 2cc/C@XC$ \u~d99a&-!_r PS*jq$:82Ŧ:<{ {oPcm BЋXo*@~+:JmТ<@r*22 !#p/NI)H7K^hF|S)@; DH(9{K_h#GԘ+-Сgme$ cJdC 4 ^i@i@O(XJDh w9U?*DXAh i+咺€w=cϐHr:4gNԞ,]g< m fe^+ɤe5$ {qnq/` R9_"I€XG*z ǀ$DS/*# % w}˗Ş Ekj}HLb(`^1a{ƈk;ЧPe-0虙^5@0Bء<TWm+ lF #r.Ǐ u5?pK]=b I,w$ h/@q26^Ȓzil젼*]mx2%G/_\-@*ih7{֕܄DDW5`hU/>Mj|E J!Y42Im3:D3Ӯߚsj&f-|Qqg}aB e4_F O~/1{c#\6G`,Yf^/Ok# TèJ\!7 F'@- ([Vaazc@X σ϶xb3 Ess6#@C@֯o^@ wɪ# t!;$=77. ơ!:]ݻzsUI멩-SIL&C:/>J(,! 0_ W _F $aQA;Q2|YRC8#@UV@% 78Iޜ1{DDfIUpD} DZ}z ;ML D>Wށ+ HQ N0\oyxJ==5vQ^y梉w2X)t?gg=ݾ.) &|ERZ:9ǁjK5? m8 П_98X^6yvVgބLX+үe$j@rQbX\7gqu덍55µ^,='ݺR)o]> EGԸ f (ŋN-GJ9áI9Q/ׄwI[VG5t7zyQx:O@RNnjІ_qZ+`t4482rsug vXW׵wuL \eEpĸ40R9ݮW0gPhl!99^LP WjpUS0lxc;6_ŭ^M+5_RPH_EfgGG*)Kzs%q,DIYE᢬@x~ 72O lɹX! 4ozZ y]ⰽXY^2iޔޕg8 >c/(Bsܩ@bŋNuHcc4lB7 $.qw*#@!*Qor!cb?d/J 5 ϟOXHwa_\ 9s8'ټHZLTt\h|@v%G zda0 !q.7RV&K~@wAm< )` %%k H[TJdpvqƍAֱ%l )46W蓶=h4Zdf3K$&MWQ yyֆcU27\2X5y/07fF~I7V"FѹY|U($vBtPl8A@~Ήlpw:1FD;+IB- f Ey ІXփwK^dB@Zރ%d4Yf` ڌM] @Fx%VB_杙mX C@d9 D@ Uc dj$ @ee~ ԢoyN JBFeV<IS "%Ї׆gB-Jhh6&<y0?F@LggZxIojibFdЗx,.FA{3Ɓ{GNMͷ3$RY0Wu+77E Q|+Rݢ|.KNIapoa*rp/qR 8<V Ƭrv8W3dX%5\+Kjh*2Bai喣 dʜ1b̌kfe滝9%oϫ{?wy3&9{ ȁW?6+XÛnqZ%%*SWL%%U@JV ڦVϿzaLҵ w@L3m傟#u )C3,qRQF !T5S )`jf2LA&&qov5CP `Vk),;@vW|0/P;q dbA72;frxhC7:^+F}#7 }+Ώ#nm}a8tv껝/~.lbc]UU-@bS xDp<> `1  p+;'b  ]rojNt1?LFfR(_q)p*{.x;x5O@m C_r_{gӊ~{vwYy^ߋ٦wi;@J򎎾JC0I:fjh2[F@ל1F Gxd|"J*)rHc,4@@Jk bP1q!^ ,߲_ >6(GPh 5Ƙ`S&ұ70!f-_9"C or?~B ʎG$2os ZÖ!(eLuX?k.T@ L_ yppfO Ê|i [rW"EBZr0*GPʟN¡%_ (s@B k ̀#('Eݝ:?h}9Q$:B$C0ץ(uc ɢStL7@"> )7?8©t{ B*VV{Fԛ[efz EGaqq> vȖ4D2"9/ @1@"(  5S,/'z |t:4?αXU 6`X=)b {u(ǰ,B*@=56H~$S8Y B ?8H㗛I_ p *\Uc0TU}$46aL( OJjD=o ꁹ'2)A-uoRxPh/]6>@(: ^aw4+o@ sW>6;ۥV0qz *IZjKW$]nrN 4&& JOбhA}Q# 2~LA Er ݗ GXA4!(  B!`H]G_-DtNau>@ kkdO҇5) +5+ [NJrr7u=@z{nW8{߷XHIXTSozf<@ 1+,`fFQX;a˗̆ЇQ.W9/ba4j(K` f@fۄl:!\N*B}W6  mH$yry~y䇭#;W߹m*0@^ǁXkS!LKK.UlHoRVL[~}Qm4> dA  @HgT,@UPEϵ[@vZؕnu7xx8wxv8J0 5*+À KE"_ jM0&q"ڵ_^܈0hEX߿WF{APi 7$jsMڭĎ/\c~->o@ޖFG8䡛PcjD,--9󊊊ƮAɨ끥F/@~\W9pw-|9,{MQow"" GEɃY1bb-9лt$) T1'MNϐ L1 u9R'o5l?}hvN0 թ<^17Ly\nؖɴ15@Lk@.H#qq@iZ^:GFP ˱!ԭEW=MQT"9aqa 9`l:m Ek~HEk2 !r`hYɑ9SÃ)jVU@ K Ŭ'*W_o0ؼ@yF/-`}󲬥Q|Aqe;n`@FeY0`U0Iv1f H;!0?]nsb"q8 SS.XQI$b^jڊ?V+E*[@,NhUVH%{cb|Q@~ǧN f45qXT\()j$,&(Tؤ` E5b\F!Ew/ßqt;Nמ53 &Y2q1U=sK^ "I^ /x )ݱ ]]V@NH l.t-&^_v; c1UQ$0ܧ~^CfsXr{:t}  8&6Y~bg WZ:ueІ@TU+b(3)c"Ai%NWFcͽ4`0xfkDVd:Z(\F@6F!>3BC !ѽ@vN qF1(H%wm\c}Ѭg7 _~t gr'P/r W{3̬$$!!'MItfkFl^Tv; Z.K AQaϷZ)i Ԉ(qtaAHĒ*YhsLMΨgrZM|Zqa%^jA@9 da@>5)H?@ ۪U3p! rnjD2K*M&e[Z6_ RZ:"oH:9!}T_LfKB6IZ-@ w#*.7tM etB.]ص,3hyg> a$y|>PQv>8copl@AɓҬ3QJ $1>ʊt!HZppvV^% S4nRFm * et'% !@[B5~`Vyb |_,Կߡ H~ x|߉YK@t'=+$)J<^1\eLNZ*djŗ;dD5  y$$'elͿٻ?~>*I$CJmY&iTf,`䞱Ya7vfg>ebxn__OKffсN׳_&rLɨ= O,8/Px˗:$w%3tg,P.93cuuG` O~<:;= m>R t%No0sрw$|%c9VFxF.hQ|P>㞚5eV.MC 554xci[Tffdрaii2/~MPn; -m3qqb1k/ҚO0f8۷cL#EHTN:g9yIg1J(zF WFHHڼb^!o 2aةGH UtA %cf]bܷƢwhj+rRAVLZs&^UQXa @y8Nе@V@.A + . D <:jE_B+ @\:/|>aS}h0`b|܁'RcnM S;;w )d. 4nj2[<޶饥ab $613-ZW]]4Ҽ 7< c7 I1h b03SYTT11-$㏒nEN$Ȭ_cʠ?-yt%%%9nA_ t/q Ew1a/KaCzua\/r5~ 9Od>w$w67߸ݥj,mɄȃx3Vqv{BHjvvf&f:k jxh o5"Ċv$v~sk$0)!\"DYiS/N]F|`?lhv{#  _ } UA [o޴A l2B ӖF/C7ej`y#, ,7"Uu-LNVmaxqRH'ڞ5>yt99D*@Ȼ@J:'ā- ]g]$%o:z(t9g !1= E Db<$o\9@ܫ>\@6eA/C2!Y*YtwC MۚbcE)@$OrOpVWʴqG )s`)},.9 ch\6Oc,%F:+ĨT $f[CPS!{@PO[?:)Hԝ"?r`\q#}y s'NgUg&X,ZjjR"їb(cmMC&M. D/XDF9],ҏ= Rbw8t~ IDATE$wm>æJOc1g}V1F"/o Ӂ@ҿyդh>w@'/aG[mڪA@J\6uRPd{5kB J%@ DG*K\08I߳ܛ̟]uIItŒ ,mjζB mm^t!.%&4B! K U͆`hp9p Ma N饬 "HLx4yPP0XJ) Y=sѹ1=2 ]| ԇ1@Wq<[ tw? AV#kk5U*. o<\}z&SZ[/3 FTr29`T5kH~aZN@d1@x85@@Eq]]M."2| 5ٻ?];Oݛ=Xl@l%2!b<|NU{mH ͊ g [[Kq&l^~Ռ8 B HI156,\@g|`S'[Z3@X`0a7kM`q-ިc[ċ,$`|-ANHPgf0NȻ@ѥG?}pH$^{|L?9lCc ~rf@ ia/#@xx v\aeie7\/VHVęvm9@ L7,Mhlp!DxMJ,DoGq! R)x%QΫźʉ f{ەطL|켲V Adb"2 H6e|79 STr~bqu|d4yC QUz:gX\i;f]XR(jjm:Fpjk^\(,ӗֺbX!"<: O_Gcgf(':Lǽ\1$74%t+F#r?U$L藚" ]hVҽ@c#\Ջ>PG@O d(GO@oD|'.|p8 J!'U 7etW4QA. \.8AĘL& /vs`0olh gald\7gg^6xACXAk@ @Y 5 /Q<̃V5-5/`ŵ]T C~h=$$6!jտ?{d_#uooyِ  0H 6k/pI)1DRq9{Jc..1# 伢q}x}ADF0-E =FIABVv^Ƽ/?9 Z=@`@I=0DrQ9Sv@ Yvo _"?{}/r2\S_#){/B rAfh}f0ئKK'ha I |@x&wrX /?Ϝ&F,Kt 7 ^ lY\.<.\Qw7`\Cy} ÜEAQft2; @{~90 π .'sC5WH@Jt n1*8w`P@lAA 2Fu>FwjB2bbP댰Ũ23aKFFB Qu+n g **R L,-hEZ[d+7zQmOX) -\$͆]9te~LE, q0B~r4$c[)yޮv40,#҄Ųa<%R1( a7%Ŕv/ ,fb6BSghv<,nW'z!v;=s7ï-bGih7oH 4 !ِ_><@nQGL5 ;ʦaXwjRx$VF?x5 {(S/oKo:֡Uadl-hn;*ɭR 4aڜVW\Ed:]%#PTpv1>r2@ TA|[;*;:?? GrqfR a ~QYJ_E3vl=dTN45!RapA-:o vgP)q3@FjsOb]^:cчc638hV7**zdvg╃eS>Y7f&kA@|Xkޮi(1* JVVb-DVĒ=((B@19%逝N֥nUGf#C^De%gEQ22O< ?}ʜ<<Fp ˰S0Ip"F;K+^Js ;ٿ}MÇo?4#wOIi3?rRT|KExT݂CIr q (!$QoRDM2]K3v|#У;s8'~s]suA :Kx*Z qxA7Ӡtt*U  |PlhM&gD^@Lw 03c4K qp0t>9̸_1NERD/Na E ܾrסkKLj8exL!Տ_Ź=!Swek'#cS1R{C;@ޜr ߃Bz_2Kp #f[B(bVkPMS2팻N" ` .T2y'?fiҵ/@9.gNOWH_JS902@_yK郅MZX.熁\{?ȉ 㷪8kDqJ޿Y܋.z |LX$ǞIh/7Yfg>Ǵ 5*@>`1!\.d"L ~lݮV)7ddgۅ4Zn"iJugIZJ/T|%g$?E:$xy ٳxC`~:}*9;Zy̛uj-e9 s\wTqb" :WOHr ?_r{$c^v`k{{kcc3,^]\d8i:tbdL2!`a ow! E F6.7= HR[V3 ՀLh:;A:zzӮ@f{BτGj{Hb3 <>9H~@P ]ˏC]\OɣJhXA ̀OX_\X:D 3Mb:[ :[HD"NG3a ?[nmuuj#H4Vib=PփH@@V!S4PFyBf4N U衦q!| B? km,{3=KFwe0!5l(!\1T^fPL!Ÿv;K5{23DUF! \0uj¥K37IC=]]k~j KRzNN﹌Č ɥK^VU`]|Hs"~+-Aqs1 % $H}Oi}f~} ӏV_@ ]y޾>c@R(\!ab EEdn Z#h4 VutZm0P(!n ̌Z-6#- S@[JHdAh h M%a 8aJ _i_7 0W~E˄8YkZ=LD.1@z(1eF&nwQȈZ[Y%l6qs<_$! C@h4"Hm]>Gll862: MO&@jd."ם@ךgL@ `xʿY>6֑NO,@!I^OgX CJE# 9 t Dғ VWH#\ ydK/[444CbdT$C`}; r0?z}6oqXw/OMei8G$CMa 6hGb$h(k@V0LK *ѲVGʅuƪY{D]HB}<> Y-)@$CCZBAVF@4'Hꑑ:3b@i nqj0Ozodk}6s}0u6a )~<%#1Q *Jqk9,!@dqBɥC*U# 2+` Q ˡD$㮈n4XA@ur9 555X`n: $zM=DE`py%DeF! h8 D(TͶi~i`,x28lҶXt\ԥCCo\n6j{z>)-Hdr2ln&&uqu^og]bX?"?s^nfov e 'pJ)(P9@&'a`]y O͕8r:1m+/Rj2t6Vڍ]tZ-lɭhx4v` r 4n>hiIJږ}e$554$G\f8WTdFLê@kl5V^n9ȋw߾} ucƁ̌/.?+)io6P@Kd2w.We&k/75X4g\-i4ZCtA@vTD64Z-BEkGt  $&d"aU߁7@e6ݺX݀ 2\q~0 j)r7Ե:|@ i'wמ|^kn1jb2>㹾!(vuMzҽm" z@@?zer4[J6ZU*L>1hGi( 0ho5Zl )|j;9[Yy} $+%w 㦠#"HC\;># @H-~Z @V^t Ey¾7|L[ihii(]6u5 礀Tyy=y4"T/58cD0@6\Y'hָ.]HG fYb::wVRVe71&#`(Gp Jy5TP!dd KwO?\ pEü#xIFY:p~r؇]dő!' VRЯGEqqИbX@f/<))3zjтRFTS@ܦt I) "Dn!T2jVN=z///H=ˊ (zE80@b&N}vD"aȖ@pDv +IH&?߷@^xb>)ҩ\ Da4W 9awgy0d0=":%+E8bGDdO9{#V =WT_Zxd,24.Ffў39!S¬3g<`̴NR3k ^}|td0!FNQlz [%I ZyrB Paj4oq|}Cr||gr quH' Q8w-|>{T@pz ,3$ Kd0W>%]O<#`O@_ +P6QAzrS+yV.j7=O6ՠtkk0~X OPhh 99YY*2G" Z DV @J;(Q\[0nj;"1!#`d^$4USA./tkȪ@^~_|(܃ R__䘸GGe_H@VtVQ7Π!i *EXY̲⚜v įPA 1hL DDAW<@ї `ש|4>~䶁fVvup:jP|~ʵltTȺu4 Tp9>?Ig@s#]-|Z>b߁ۗ:;=VuW8$ Uj ATd:"L*<ˤiH DFUYlRDfS$k " Q@ ;O % i:8+/#ѻlO`ϵ00 CY Lur0Up8MƯ2@(*J?g Phf4p y gA 3e^9GyJ8 @i a tzo7>m߾+xi -ܗ"Q 暑?DMJevE-ЀD4x BS ,p=圦 Rk9T3@QXHIHOja@mމHȋ7ÊY Hdomj 3W &Ce @Dt ! ,( j$2~hqr #(- :+~:clHFFtrS\Jiv'~  ^H-_R?3sѣ@> yV*8;$jKنPY>՞cϞ IoЙ1bK("lGe +vҴDbqd'v.'758@E <&4r LOî* [p_(_Xyg 'vu$APՍ#vRNEv ' d3Bq\yp5@^@O I`0O.oS$ aH8a'tzF28\B :5IB45;TZTb9*~ 2ݟQn^6\rAP G@W H6+AJ)x dOj k/ Ϟxǭ&?gVOG~$",zeuY+p9 }l aVJR@ZA8zr ȩ[hN,P@W$ft,|j56TmkƳplrZ}SCrPj}}Gk%]uS (>w·#uJ&$(fXvBB @]:  u5EPSS[nUBbH"lj ymY(jx8LtvdChB<Σ7ą,"/^?RUu G 7zXׯc 5 U/RG}\lAX^[Aj'`jhJ&s2EXSY&UK #0O}bU"IMql<-&&Pl3{ws4w vL+>?35îׁy^^t$;8ɇ:5*EuͶR@UW;|5S2@ ZNҊ@# ِFFsHTgš3w v@`u"gPZ Ait+(éCۀ{ ~<mo} ^ ^$iQN$hV%%6|}!@$Ad ]p]5tZSŜ Ju0kf@ # Qb A |z$n9 HOLP=G}mm{ϟY@z%)_%ucJ djh4SS(+rN T愇%> D,nh4 qu (`wsh4V5AJ_`Bg SP;yorFAz:TAAD%߳CoTra|c;Pށd2@^զZvǰ _g$˖)_&-c:B yBP@4YZ`jhUgSeZ,F#MoHn΃5 t $4pYhZc7JV%wG@N]-@ \s 8ń*~z' 7ә4Z壉?_p@uWhOx"Irc0+1k6>n,@@FJ{ga!@jlHHhhH#^"%s\hB dMLO˂5(F@MVٓUaɫ@""=P@nޤvPLBU @>%֛WoߣyŇXx_"~"{<2,3;~ktqQch0FKE)9e<"Na-FcWX\WblD@䁀иPp*6rUp.Yhn:>~3=8SEQU$nSu-D^|l"B~d }egl岒VIJr2*F t+U@ $WK!NMPT Hq1׷Bl6MmmG[V $" ~~pUWBu7Z% d׶qdcsG?\n< H)> @@O|rH/2$LJI}Q z $C(AQ? %$H1I :V*., lu  o |w3.-iHXL,FG>??tvDHIA$4>>8~?,o=Y}ö J;gwϞ igt}U!DȔEuêel7ID.D 3"\i2AA#}H"xjɤo<#a z H I& m@hBS 4x:.]vɬ}+p 仙L})-9l@VK,ӳϊ,Azsl ۇ) J9_BDH!W! I&FNAF(AܵXG@$ vá a!є_Tpg'}Fw GBOOO|U槲H|%V('?%{# > Lv %o/%JAA %3QE/=_/W; T `XGjV-1=]%B%e 4)$IxHuedx\84! ddAgg' 'cc1}Q_+%@ȝwGYLxt?Kk#C]; Dq/^{A," S..Ij\.!Ao"!37@AVn7FGYijzK hnxsr!w ^;P?f4q.)HqZTǻH;;AR(tU,!@?G@*kǡ߁~>ddB2a'\PTO /r  @w - ۷ ;Ն_ӟ =ϿN X`j^gڼgd ; cczN ͪ:n::.!R+:\#%FffcQBzznJh xHJ.j ;1DL4!<_nyZ r m&`].0l$"n;DZ$YPQqM [[A $]ŵ%捱> Y)@(= e01B.il6lj2_Ji:2C@ƹ9` O7M^x8F>= H2 7 @Y)ro]ֵ #_nxa6 }}lkld(!=Jj RxXNg4" jT*LHA1HMK099Yƒ s-*8{69s!">XsYU !{~Bty.{/UҒo]#npDRwHχPqz[/ ǻ-byA G߿ЯyV*UjV dDa Ehޮ 4&ԤB@YH&H :) Wg~@̊#/{$ /LR5YA" VW /*R#N'Mn#w1L20H-? o^64fŎ:O$ eew$s'|x8r\6Ko'-L |{gA>HԵ?4Dᛵkލzg6f! ȬЎݲN! "SPK.#)(b  q56u">fJԏ ̖(@yh1bb(l57;w Vb1C܍8rqr3F dsg{۷_# ##lS")*uk5%x5:Pua b 1j P*a]YBԞP*fUŪwOIn{M_,L2o)N%H n@LLAdAG FOvesv3A_3k}巔enN/{$8Vj!U>{<|8a+QO# aؔ 4B~p0@ױJֿs h?YoV5Iu^ )gYbv66r1 ##<^=drb=c)jWx<"!#n@OhiQik/ m@w7y$< @b3@NpLh(; @|P7 "xsu UF:( #PlZ{wuP ʝYYNOc6B Y2$+-H`6955&jckw45};x~|\U!rbZMg.TElTttf6US'Hñ@o $]ړ/d5ĤSt K;:aiGyVdIUQ E= LO(.aD6nJ&hT\ó;Tqݎ&OCg ;ׅ [T/q&Ɔx^ZV@iV1I J@O&#$ 6(0 jbd$0LX*Ā45.U|MCG^m_6E=&7S ] D .N~!H#B ’4$+ Q؍WGQ-E4Uxfz7w x!qW^&74uV:2a"Y `yV!R4s:G'u#$hᤊ4cRR8fF"%waTjXPѴ!]ꙙ-$@r[,dpr t700/GPF^4pPo"1* òp ehBϏpw?r^~&}}sMx0'sy/ dTY{ȣnaZD:k Pڼ;@TsCvԀrrxNH^4&~ɥ&Z-'l4Fg4̓r]k͌F T> <ث*Rq$'iH@h4SeB Q@` gǛ6=6W C d52vvG@P(Z^~~@*HXA PA:*(P~?GPPPYk_}Ht;FxGߋ ^iec9ޏ^t!i"PY_,*гXN}b{J2[^aR (I* 8Hx$A T2ak]j:ٌq֬cӿuިeC']5?|(zy>٤-Q:"Ɔ&)I Y4@@u [0e !0UYB dQ~1@?68"Ձ[PR7#c `ȗ|FiXi%0t)%&74!!6eh~l`T}N}ӯ_^\nyRUUZ5b& $/O*eÜ qw0֑˸W\LJH}sC…\IujaP K S@p~-MB̔\@+rC tWRtA&*t L)cc9SMrkYڄ%t*ȸ ww~X&Kcd ;Xk1+.3+&l\H^4E3liYLgat:KzSByh}B4~.{B&ldEǻ2mR`eu[ApvmFS! YAe@l*<C@f\a%JVZ@KJRcl i6;l^hH|>{C=33T>&H$Yn !:0 %y XD5\SDn׊ qUȩ#ؚ?>|}۳UwkqzzWoE@{AQ-U\SSÖ0h:) Q$5 k@00誨 =@ ]P1=  Du= ɢB wTSOR7o @Gv>Ms|0w Fm J^s ugjzk? ^>߭*+էO(K ~3с(P!KRrdlvL+@$| 4In $z5uH1[AtLםx0_. 1Z"˩C7"0K(PN|Y-t4r|.jpVLszgTF_<ֿ7۟aqz>LO+>dLhB@I$` 9AWBʣjWLk%?5fpŷ d!z&g] /_u:gݛY#zD(8{JK)oHFx#?lkn5&S41# fHƌ h֜a%+V58q> aJnPKtXd}$<at" Ndt&]! MMV`&y[ I 4˴T ~5fJ5hC} 0bsd` Xu㝄@nL@N@  5_>@U@2$jB Z{'vߋ".".Jo`@ݝNYw>)句|`7=S֤c 5|\(>ss/<;B׽sh]MN=_z, $Aaj WSӛĒzġ "(Eh#n"1A%&b @ɬ ے@Q/ 88 ;Y:;@TNڄ8L&is-%@TJV)Q}’}x^@q޽%1$./ ÈοFosR@ lP㲼B(@Э@KNI:|@Q ^EG³ As(w61KpbY_*&8/1sDgPx` :D7VY@xVZZRMM9O}ԡDϰ 1A.u} $%5/N-OUÇӫ s8ULm,{RHY`.Gd" #mm XLbնSUq/UgH΋U24xyĉ8w&1GdJ9ގj $Q*X'@L r)b(9:͛:2G-VL6aBnί> m1fޏ Ĵ/6A[%a/ox #uB A 0\,|C&Bш!))sۏZ&*?8@n_&q`_`  WJ$*"X}EX ?7WWE< @CKS--FSJDoGQsK! HyHR+qь[ 57᭬,ԕ܅k˗Ogc.#qh֐JӵtDKZ pA~~t"jvY[m]M OP\!PsfSϬU3̬s55`p-N@"@*WӞ㷈H~NC~2R@ϣvVĬ?\0/Ur!Q& ,T j5Y땠5iRXD, @Tj` Fc BVD3/ |@Pc$\< (!p IDATzf#ހIV9׵{VU#Ǣr}%ɹ.]&(ʶ;?VUPuoa)Ej&EA%_8@bfY֪1Y`W$ԗ6%@ft:b ,n9 9 @$,J ha#ڔJ}k 9DS3s7R͛Xg?B ^ a-BtHU%X Bl\祰@jN+ȭ [:n`VѺ\rKt]*+;Cm\(T쬩1݄u L &u6"Bן hz"t$9@pѱٖZs2  m[Dq"炠H&g55Hr'j]@. 3/_NN&@2F޵V ő^F '-_{tAQrNпjF^i RD^*5H.TJDt)]҈C : aMNAroz c)0$O@Z2ӒiHӮ <^EE&n@vwi/6$}ț6> 1ODO^[WtF6$s'/c/ZĴ{oF4bB q{q!JN^(PyZ_qϵUƚ  ]jP\~PMOqd܌B}q[mrwOifW1|8^D *|G #V/q CqV͌kX|Idfv2ۙ[=n퇝*|P{/ 2ab q:BQkC/˨Io.X ۷rϿ˻O f fs+)#@Ԋ brtwT'O QWV\[F *oW;H*Ց`Р@HO$*+/ b.HVHD kWo)B\B81@4Y7V+,-3Y:UXEȶ^DP5w_ŸK|| o!+> (2FCvV8Nbq(ZbT[bc z=1@X"@i $@v6sbyolH3" Hf91yL{;n 6v47;|s~JI;Hh r1@.PjWA)Y#~i2w޺S]S}ר4OyAƍ:2=mĹ*J_򔼎k!(݌v͐ɤB؈hh#H/lpO̟x&TmZdv7t&oMS {eA4|}g*}!%l~cH ̘3  @*U1 @b8'*EmX{JV 7qכL̚:H~~N)]+. 0d2DŽ@@ Dm$3E]Gi ͓?WY $݄(D h@z5])&m4wT-"@?KvG|/.*V,Z-nY7#}FbJCP@dUڧXf2`fFGfVPIrʆvXy` qq n\/+sA<{ŠT@\mƞe2E ]lLܗs"5z w&_*Nr:W\~q8ƒ]h4 U yZݿN dL@)r}lB%KtP>'MrҜB1exMWi !&OƺCy%0奓#Yy azat:Y_@xpX81C $mceQ XQ/A XpK6!^Uś9<nՀ{Y7LmYd+\-Hq|6]X@sw{أ}~yrijðb%ZeTwWvţѬ VMF޾_av8< 1tE ȸ6!آGXD JB:$P c( &dKYJucKoCA> {{q$< :ynE"4B=pa0"Vܧ.׀vEW xĔV ˣ^o_?11 c`@yj4@rD u:#;D@`Hvjh M\YЭ#Wo$fU]] )H8\{mi++OݹĹ6\ޣ)?uW[:SR@f&m.ѻ05'~n'0}]劅B/`DrSI4'zcjƿT <Ӡ_qYnjT y@ 6J_~P{DN7Iadn4Ʋ@q_;y D1 Ajm*}6ϮdR,@*!? l.5l<;ll=? 遬@?fݐ1}w Y|ף=zPxz[ Vנ3E' m[59el,$)ɤݻ:BԤSv-2"+V HkP~0BT]I 0%d Iݓ3l9YN"r͜ P֩Zr4ƨb6HW[D@FϰEbI0yx.Q{$6 }<#w6V}#=핳z0 9dF HѢ/r@,l%$8~P'o˛$C ?0 7>Oݏ#K[[>S^:u~z_DKNѶiO@x n 0#Dt17bWlNg ) b1 n8DKP,9B&J,CPIx~ ܅:2jr :_V^)_޹szd. ʌdQ \x`9;-"!.9[pXK)>Ɓ! "zAOͧ~Q{zz vL&VDӕ*\ >GbW! kU%F2EX54$WBnIBX8s%Nxh™*˗F,ಟ)]U@a*Ox88_}8 I"!߀$7+=N GNzq\kI;k NO}yu?Τ ?|@J/mzC_֕j:*"v=RQY& %yxJT}vNQ$M,V0TDR@H#DUvi -@2"< *&4l)!Pw;hJ3HC~;6.铓#@ T \>}b,Z^'wox֤?W @ XiN5R@"z w(Det7] a|7E z,ExUH 0+ z>d+xZNS2i@ /:?|<ey,P@rkN,:;;q,n *|JZub@|l@hw'4ݵz]C8Wjw(  @) ʊHy2b 7$'@Z]@?/_'5ˆR&iB&'gAi@H,VRRdaԵ~E~uxx9l7; 2r,+Qww?ieyk A^W/x/Dc4RT߁JڙSѩi|Tf:nMڱmv2䃘x>| ꒸Xc7\s98@;/]u98zj=&"3JR,$9@v*H J9|=XCh {)ϗj6tF~"r1<;-._>mr7&:XE3ri ^v\;@QY;16\[["5ܸQbv-gBNl@@r25e4®; G hbhh{T fn?5[[VMǁPK~H+[$ƚLϩm>q?Z1Zu ^SJ6W]C){rk993EԅrVN^qm6)ˮ4y9{@iϐ[ji<}}9@TiٚEBaQ H*ROrsP@=}=ӫ˻o*/,,siUwsn7E%c<1r^@%]]W'yC$#GR~/s$tn/PYawbutft tyyMڜ '$|Cƨ)"g= fz8|AL(V5IJ \E/?%pxWA%KHAkXaX]WvfR)来]ujέq:?3 ~<9K$WH#n$d:1?4d..3s֪ !s85"[3HU^^V46>|H~>Sܪ\@τڸr>26$( )AFe?Eta>}|6@m͢-1i4hJE< Iģ4Wz+HP%G!; da5 '^==b*H܊)AjVx7Iț%'H.W4WCiı'ON2 Kѳ\r @4}3X?A¶5O:u oI}nx=8@z&GG+DhdSR٢"|YPZb>6d CijB&lD(k(4qcү` IO%79rb2^T dA/;#O% t+/V R}_-$HWIR~ @)@v]-r7}l_ BDv'PARYʠ皚.smm $al @- :'`bY[ O,Y &ڙ D)9 RShL}aJfHUv|l%4>Cj _|lXpk,D,N([Q{zˣ}(Y} Vr cX@1k# `2HJDTO #P'tHWZaBߙ @ͮ0yb8 @ThT T^J& $"Ƈ۽'U1Hoƒ>sBlen`"dpI%[A@C#$ -6@Ϟ%i O<3n+\M˻t-|DɕcF-rcyy0\5ׁힷ#&P HS oqP0Ay2#qZR@pܽrTH()l,$iM/ё+7B>< j nɂ:066Dk {~>@^}ҜڲR isXkG{^_rZ~ z`lnoCVcKF;0DQS :h2t`d6:GAK?Nj/]r8BґWF1n,g Q_\ @tg1 &>xC@[3HID͸\(.iվd8(J=Zo}Y$6͏Go=~+?[{qS9y2kd7&oy r//NH>$ǻi@E:?+=& @<eԬ SSIB+`:Ub  Dk2kH2*[sY !Q <{H,3A%0趱2'R7\V-Y?NF* /^|7={rڹƎ[1*w@@\w&Eh 覹Z uJ 'srNG :3~%LCDn]Pk| $AOM[D&6MM4GL7:`W[a<8ߩA.L?b#%el;Q=ݪzKǿFFV&'WparYGΙ'.b ͼ{r[sgbkYj5WEYGmN' !6s!rY -ox!g :4HZ3 |>buSAE ۑ\.$!ʗ 617h2! GE)pޱ؊TPWG(!ɹ0/9@PWǗ?ܹ3Gk@ݞ_n>gͼK95 "3|>TҲZ!XzZ/R?SRp^Θ&'@j)]֔RW]/( 7WSSȶttFٙͶv~pqP>' @c]U*efld#$BٗTq egGn;e(K rŠ@,fi;$Qp&E_5pno/q$cxQāj {ʐdM'0W_C_ 7o/Hz[J?qd1ؿl߭O/ |#T@F 6  JJ*N#V?WF Y]G2>gk| çѳ~r,kiHcuZ P@?b^ /@[߾} @BFOхѴhP{\xt>SZmJeƸL@R#6D5Vsrf/~}i|0uM&:YsZ㯜Z@*޸~[*z | jEzC7NHXs'P*dQxD2#ǂնD$KLb P_R2qHnF`Q! D,,D£2H.,> c ]6+'4wgOMfY%EJ @Y2V,P@lL "i  ,.QMQi_x~s?By3UTyι9$G  'yR@R@Xteȷ۶izN{˗]޺Αr4gqe=_O= "Ԣȼ!2Щ kMHdJ>-L:` PC "x ~Ey H 8aadAx݂|}qdL{&1 y ͳgR)]%FQQH7/é47LNRUQԲۨT?9-=_kr=ˍsnC)IJBúb[2㮽N'·RtXθZ-"vSƍ,A!*| P߽ڊ yVk qB"e1ÄB>@ $cq>|JDdSZv6 Ek =] y@3Ъۍ+4тTםu ?d63!k?_..-q4~ֻqXtrsM=ؘs?.[ms9ڜ7Ԛq,mOKݮETEǗ ;cv3Q+$_h |"hUt B@<<i |E @ q(AA'k(AŔm 'kjX4|T;HOKM=@1>;YkP6>{!A6l>@~ȇnD?&[76VjAU>_3nii~Zo&â{ 3+&KȀ\ ExϪ<pNkS"R3 UD0 1_0D.3 x $?!a [AT|p6O6V|#ǫ|I^?Cm)Jj^0_q" X_-t=urVסW4Um˰SSn#έ2p@w/|Td4wbHDf@p@ѧfCj>$7'P"{AOisL2|>~~x ;nℤ*J ` #\.dc{t'd>swĔxL7mAT*J8|xPїoOƦ֌hwa3٦ j% L송ſPvfq$* di $Ya' $]@ <FQ$/ _xFɪz L3qޅ~߿8&DzTLʉ xVBmx\n) щ0b񢾾A @w}c}e\q/JFM&[ kXzSYYy ekG0S^;x#c݂%D  Uy07, eJ4td q0S` W\TqiUx~ xH#&)t [ۢL6~V:Dۖ#m|S=Crٌ윲2i;WvcY .{KvnĢ0Ctqqzעܸ[|D c WHU}m(Zjd0$@Ӎ!H$J¾HA Uz.ӧ \␌u.cIBRwBK|dDvO &C=Sqg'<ϬxS+FlyaRv֞A˲պ{ݢ6c28w⨭4' $)SaATVBa@H+T329R(J Ig Ȳ| %<{tB!@r(3\&Adܛ^E%L#ȷ2^b{[OdN-FD 1C(LN^|[[[+@]\sSVhh5Z .CGzpa--l$.w8Y6 rHUrLW>|g*N 0 HJ>v @²D>ƣD4DNv 3DwAff"S$p.pzpdfѩY~aal6,2r~˜<~|-@v įiS4epn(mPZYKKFcir\rP/8=V|5{{F0h!>VJ B'&)G4" |>ZZ7/j/P?bI@rB~ ~~(1 3SSOB.UVp xz|@#lC#};J3xaQ̞/uW[UI>NA˯h#"ouUCCDVo[KW?k`H29::,wwΐ^gб/B_{/ ;y9dd=`QA "@0E"-SB-H/g IXNXT #l,Ia IDAT BA~.CP] s׬vm4Qӟr!@uM@?}뭵=v@ $tj?_ ׈,d~'z&tT~@@T*/@|D`ybEI#1t&3::!dE, 2J`,GeF-@`9t5`:Jj@ V"JzCxWp>>稙JL/F!")B +4g |F2ڷpp񏤝:q#6/wټdxېH½ ?XQS],F]nA1 5CH~qF" wiX)mH`)4J5gBl.$r9;Y9UPhE"Z č1wzÃy[0}yR]ټ;O.| $sYrk^I1aBuoÃU5a8"ƕc.j' 7dG/ti{Hv|'_4) Yc׀<1Uf| 0VVсXȃ]AE@hf]I:ȍY)bH8łnI|d ||d[N sߚx튰fŲHQ˯2r}Kn mۀkf0z1Suñt؜Ng ki@ /.Lk`pݥJ΢l@A׉g| Jj0CLkxF#޼M s0>ΐ,)^Kx$Sݧ:2*%UX't0bK~%LYDB.R>h)OhȒ[ j0w T!&`SpWF@_M u}Kn 7\.H=%MP0`2Hl/H6 @@Ŀ \aE 豙 :qY!I8N1"6@~S}y}ϙWJ:t yqR@ άgt+B*@"LV=%Ѽv|@"KnS`ܯ5<5Vz]S%bZ1i HU٣K[r{X~Gme018{ta.3O\k!g9|4H(VQ{ βm?s@сQqӕHUؘTFq\r{~rR_am$ ȵ(@{4̗IJ 8#5A.h75=moVnQ:5پ7\$anĄ=o2DFژ( gL0r_w @^׷jt-BoE|H Q ݝϷG ~^F*T-W󪕅%Kz >kVKhQ=^5)W D}+=|k5/z*U<{սj(Ce" /lg Z_\_0,-' im#GmJUH5Lp zlw '?V?RY (7W&^%ۣ1~$@B`po8 w93^wىsݽ6l DzxCE.WՐrۨ12Z4gL#Xg4]Fhl8FG{1)._KȡBbD>>x Zpng'D/=@3W\Eoll8Apq;9S@yk..@DHED 9 B~.&-m@ܛLD"noOLf$xyҸ>ﳿbUs Ωw F1~MMiTO#"P^m'Q=`S,ʈ- : pP!6bGp[@pIH ߺ_ a* =(L~}ܮ8 `peySw {*rOM2 k/wG /p.I#Q@x jzh@V݃ݱb+z0yOJ=t+aj!X]*]Ԗŗ^5y4&@XR DjiU+ؓjUsŕ1jo k9$d7\d;5]'| @X$3M9AK{jQ@a 4ǖ0E @f~^s/,0;kdk}q,2^v 1 f*sHE7.LFمCs]f$eZ-uJYYPr|\C J@LڳRKTP o)ki[r֝S&z H Dw}Ǫ@46@CM#kPqo85U=^zN9zH?fMV;d @6$**1먯ggC9})".2 R~llu^t!/0XR[h$wm Y&AHm՜>7b@6N}D_𦧮nrf5'Tݖ2tadii}z_ϵ4\)20N6l|^]E*q9RPx544h4'k\HdzݝW]i^JZbu%Rk@JPԞ=(Mxפek[r& ċ;uݛ9ғry F{SX.c}xR0AʥGsЮ9Y[p]PI\Zzuke2\ @d`0 D*%0 SD@lWR1 bKbC@o|Y?q~WvCu55 ;ǖܾ^~hF+fg( Z"G: }߷,zDY r$+Gk YdJh:zL>:J`S@( h4Bd&HT$efz\K4.U@2m4ܺظ8yOfH(H,V4o}%,oӊ IoʷA "n^>2: C0t]  @Ra#lo2L E KQb!wu#`:2/~)a /WpYo_y>W*/([75 V {by-k,gx-xkfȪSkSCW-͆@.j DK2QP^0$F _N@ST3B'0xQd4BAN'<˶xdWd݅M! geǧO).]ño_"I"SRh5&eqcΜJ "h̯ =;OT$*C#hUP7%XDY>ph4eZ,ûo[ի_ 3?+u :ő'72r82O/ۇ{oO䣻wyrK&ܠR& `W&.-\X@2=M$dT\sAB[sIɸX^aij =yrsYxdnHБP^$%g-v=o㇃v7qZO>! @$O+&̦0I \h>m FØ{Brs$ r uR-NsX̳V<I^O&пn"UN>G޽>5umOo>!IPl(BD4"$ԑԄi)(VQ NpޙIIFq`{}O$3}]q4qhС!-U& ?6l(_Ae >܄ЃlQ'/G,Lk^x2i(*_}yjќ,{׮9KOOκ6./n0nyt1)  `M#*5Z:UQ̱b LS#fvÊbqb3 syi\iZ j A%f[y/ˤwYU_][#)CRjF6찵X /Sc h f7 y"M*r#fUo-r,HTɭcpdoq[l$HU=^!R33^R{VV@( ` ѝ#0V*@j dl"f`!$,єJ#*#De@oD$EDb$]u pc|vTLB H. ݩb]`d$ 644u}`kϣ^Y{ffrjb {/]@X,é0cD@r]A՝ tX HdP X#|>loNCi)9#@ 2\z܅y*@cR(X HF'&5 BBvBJeZ!Sr8\!7%ˤi~_{L?Ǟږ A IDATϢp)R.baC& :#k@ *DeI0JV[Mc#)Ic A%;X݋(^=*(X;ncRax qJnQx9Yr XTA$zx&g6r;sM\wǪ|׳jwh֥Weus,$R*aJnYTE(a l-k"mYTY<&Ċ[r3@C5S)9Bg]}kŻ\DC2>vqWx(HBŝ/4C09ɞ@㝯*-><{AWO&1ڴ3?S0k/仳16nOԉ dFv LH  ٷ2 EbpX!@ !+*_D5lS1Amd/ܞRKja| XwrC9'>yyUb l.~1eUtZd,|h< UDƉq ~3RRVȋ |vZm xĩKQYjaepvhy_HQQjR啮D*!Fra'DW0ͩ yg la7Rw1:6̠ ݎR+rC {#y6>:@Tb|2}PQNQNu5?J6@q^X>$(x1  xz3p97{eX 2_@Rs&NbY0J8)*w=]vTM_7JW"q- o ę⓻DOTam۔y䀼} S]t$-A Mk Y D5W&ktwXQD!HQ~A"Q@FHG8Mmp,x[xx"v,9瀬9ыJS GPZzs0i65ʺA ;P6{ B]@+*햀hwj; *˪]b.~o:wٳ ÇrH8,_FGaFS4SQbk4XMd<sbdGR'I%HKO7y\ba>01oLJ-Qy]踪.uQ ~JORmrwMD ? "=[AP^t+|WA D@ @(Xkp&IZg * ahiF eFj/F|M9 ?]s8O"^5j3D3>o [7ǹdl;t>K=--8tn@V\4ҕQ4>Hb|2@k$"ĄE2@4.!t+@dw*>7!s]xU^ӈZK!sVSEj+ ig>AgA .rGy1xSE2"mb)ʼn^Xֆ@pDBtגX$qH&pESM?ѥuѢǛe>aPXp-0M G=㨟wl29Xoi:Rr/;x#mT׌QOԲl%Y !)`GD!eHR2)R 6 C "`No;47ӓyHz3n@ 9bwqW2tSMd{>yT@8yI/w4nL$d͢.:WQc6¥R%!"%zW:Ĉ@VcEAAK#T¿4b oL51|,v?ۂc_| 䣋'Np @,FW@G ),L,$xH @NuX0:Xpee1Dnjfr*hUOjL:m/\ↁLN={k(8ϑ~^Q=(sjHVڤM%-4n !11֌b R@0 cA:CōRC=Oxמ@ʐɀ=a^Cj.Ī%[G#W,)p/@X"o-jcw2  D{3NOuy7 ){Q& 5⟡KH(4ܜkL>fo)=-hlZ$brƙ hUfߏSApIH A`3h* @^;KT#[7vSqVehi٩7F`|I}:{bC4$0 >}޿ߏm[J={WDPdMoVH]vV&B{0@ a΁! @ "@ @ BH @ "j` )0 ?LH̸x7U"L"@ MDޞ=QZ^?ލť8q*b:KQFZgө ~5 Xz5&&0z ,YwߏF-[&{}lh}q{{`ҥ`kWqIlٹ140@ cCChYHFJJJKsr JJlmz f312Ǐ&U558s옂BIYx}Bckd"+WHj @ *Q?5.^DUM*I}ro/睪{"fq=qi-_.{oxpe(*.ƹӧ151#bզMKqw06zՅr,Y %@ 9,-69a crll^F:R%=f߅ xt7(>5?b\"ë> Aڊヒd"1`o/ƆE"7%%k…8.og_pѢ"4dhk=.^sp7ǡa8#GuHD]#;ӓơ?u()+Þ^#ٜ8s浴 ^9Ħh@ s-OƥsUU[~~Xu+ 7Hb()++ؠNDٳo_V@Oѹysĕb+(.ǡ{{gɜX|[y\F}t uum?{^x38j0浴`btX ×/QcJ&g-c Ϝފʚ srzURx͆ ccۋE+W* @ c&El]>?+W3d3^%C-|~ͪ7xf_kXAck+H$CHb8p T)1H7?8HL @ B0hu'񑈭V6}ԑ9i<礼"z@ 4G$N @ 4sFXIA @ d !@ @ !$@ B@ @ !$ w@  դ2HZZP]R)\Ù>iP{FjG E(oh%--WUJKLb21hr@ (LDp]G& MRP{&fP]y;Zᷯ[x衇<⧞z60022Gb"GeS:a)`,dph+obixv7@ BA(òEXjL z4}EE @^8c*)Ce<<^a12 I<_^m@ (!_SYcA1֞4*n#I֮ErzZ*%ޞKWUEC @0NQjիQ{'$C)b79ee\oO0ʲ2J4C @0N A>67s=k*!@ !$@ B@ @ ր_|t{/: {eK_ ԰#@ _|/"xǦMq~+Hyw}k/gFFFɕE"1~YYjjiu@ DO}SAhnng>ڵ /AKtwNI<~ 5w~V@ @ܴio:~YR++-KQ~亵dpox1 @ apɠפPۨ$L8]B 2&''zZ@ €AI::zԣ $@ DBӟ&zը]bwbzzshmm GĄjjjIB @P$ vڅ]v~nH"$ .uuux{3N.i:H8l+Mطojj+lrCqO~rvwku?54}@@ 0 a$ MK[[{1{d:<㮐6: v@g۷!QRRb l[ԊGpITWU~ 37fPl /ލG۱QzooǁQ251@ s~^x.F,®] .u]oddhii%0҂>B?t;CE@قdp_}w,㶒'~  b鲥ϾavddЎ6{7>f <֭\?J;@ an\RO @&{?/~T2xWoQ>h OpE\q ;>B?m۶>`$@ !aƍD}3g^‡>>5?_W_ר1f GmX|*++w}'"kkk6{7VX܌֭\4ξ'' @ BuR|G &Y{Q+a$z<} 2"v o0Ն+Wq۝̶&pmLrJ;br!7wun1@ DB `Emm-Iejjj# q >˖i m8qיz ~nhzCWcՍ3ӎA @ BF Aݻ---hnnc}}}p?1Iuuu`dA${ֆY2x [@ j;3V$ƘdZZZpw1orrr$2H @ JI_%ڍd*~u RIm貍 &M%2H @ BH0O|/~QVWW__wv??bmX[ڰy\[lC]#mXdK~~KQp-ZDL @ BH0Ng__1hkk6@ >OC41eBnvqM @ (!L$5&Jc=R$}$bddR9I0p=-|&c10@ QB8d".\X{1> I8|(_uV۳o[@ BN!brT g.jO74+H&{ o`"GyC3ANh+g]9YhJ }d5&@ |E `~M Qg$I L_Rg=CCHNO#Thi)UɠKZZ0 eeg2Õ "@ k@ 8&@ e@p ,M @ BH @ "@ @T3006:xwȃUy=k?;1Q o84?9 x%c%ٽG؆ * `ϜH^q|Sƞ$%+ P9Gl$SsNrjFOσtdM~plttΐJL[]9D)g Z+8s|!ːs;QNt9H0Eޢ-DBw$JK=J/c2(%)A 'bFDߺKjFU?CbC!0De7yAZφ\W3 sv klA Z|s>Eßi_( T8>j}vږ+w^3__Jl귶E*1њFvL͕蕡m 57]BWܩS!LbiĦvY&4:䭓:++ӡ*/+ߴfm2g`]7n%pr$\u5gCv8s8*Ag|02]8 4~z2QB8x_ߏP7 σhXko~tt`ճB{,Z1<0"lؾϣnfP36:/켢gf1BԬΔ#"wdzF@p38 W9?ε17?ZgɔD' %n{nNz-a OC+1n김Ӊ(.)wzz[f܌S z{Q?>>̥(-/P?dӱq#N:˖aIG**hZcYͲP<ce'\}ܜ^0E)1^ L1K14nҶg3"|:[DBLC̽-g:/$Xy# ½pߖZA+xLOL[U55|_lrUUxÚLONξ'ⱘj2y--vmBk SR˸XpM6U󼥠m />g$i-@sb.Û̘㑖|P31ЖpZ0K[pyx,s5XI0KF yA̶gej˔  dq>xB}_咤/VѲhzΜArfdr5NqrCC(+/G !qǢ+J&^5B 6.WN9."`b?*); f /?O8CT4ȏ5"}F^E8@L {~{[.+/ U ļ&~'#P9C΍Tל&j&ĎkzΧ"5; -Clj ochnoǢ+d\DWo݊E2@eM nNRT< y5i JcF*XO".b+1ahT<.)NVSs-jeXlX^F֍n_\qzU+v@Z2y][aXܼa͞Y4sX{Μ* 0 Gڀw-N@O*2eGQVT\-[бq#HDӶ|9ږ/GrfEŲy崓|y1y8I^.Ax7q.[̌+sDfwGrKc D0lG\xvF*_y=BJW7ͽS@i]3mNӓwIeD2f*!)®-xB/zס}cG'A-NNF. `r f3J-&f7D}%~/DX0(n}Α~υjd7c='QQKT9_& D.rj1w#®.v\3!f(\['׌څJfon,ɱ1IL_bͺU/o1tlڄx'l6\b*\J~Vv((Pjbl {Ka98.*> W/-Drs)'fC=f7*X ӄPO0r x'|)S\Ѫ̹yؚ'ȅBؓpUFHk 2O(Hr<8 /\)jziM~Rg?9d'͒+=L;מs9WY7 uudS\2(btd5kH& Ffbʁ>{\dʍpa@,P!W;vI@CC@%(^'ts@Lai>׎Bfׂ_!:!"Nl("E ( L(gf[~eGDgf">s(qr~Tl/XQa M儥[$f]Mͭn"N9?9KpZs] Z/L癒? IDATK-!G_> ډBKC yiѓ^Jdb]/3B9r*-`%;lSQ6tyq1y(H-?~Lh&-F,>b.֑ȆMhC?wEWp=@UM^"/[_*|y?Opah 5 >SPl(AR֍Y:,Ar@ShikOoᡇ O=m`add*p0}S^նBIģEcA#sA!P9\ˀ/S_pY)ƮM}V1HM;ȃ+ۭѮ3>_Xv? gI[+#hZN ;w ~zܱRhi-Wuu[<} /7U퍱?C,=DrDY=LPҝr.J2{ -R_KϝPvǭg71dXGu 4֭]4 eF<Aci3< nЎ %1o\b2B4@NMľ 8.bp{_BDŽ`/J9YmETnyn?͝T.E9 ȞTs}D*J] s*5uť4;9:U97ƶe7:mmzmuˌ% s0}c~ϯ!7m Ksp]LKA93mUO299* s nKYC^ ˨`&AsC_u%ޞv[S+p2\VHg95֟LȟH>`jF*baʀB(LOKh;Yi"-? Tk}1g231fF0 Nzڿ?]7ހV⌌E"1)Nա=y [zZNЂ|ŲưgDy;C:MGyy9ØIb]tfG#Eq}%q>V\"9S߉|:w%?1?+geE?ǻ%Dp'JB88=D!Ie_'f3VL`U9APk7t0~q:S,lu!,wkˊ{A~E~cbIw>Lg &)}埱rJӋ̙u뮻dDzff'N5k5fPwX_MY`&Ɓ%R2O_BqtGN]xL`;53L}ATUu矗~e˗/ @<FJ`ѣ9 O᳘I GOEΞ:Daf|=9$fR\R֬B̔Nμ BzƊ0P a^bDIa#Z `)_ o,~|iu7F99g̺zB;$.3WCe!t -3r`q nC"PX!$O'H̤g`W7X2d!)I1̤̤C27go }7.Ժrs EZG!˅jIPZ¤|7{, F{='lMrEUۉ>8aGz'Ws%I5!t ځT*7|W:;;yfO DuRL&5(xбz183K(귺в 3/kjDmY1B:)Bюs 5>+0X>gjЭ^?*-!f ߻'td6Y+nH:AF2me?VZ1bJiD7wwQfMn2Ç & |xGGLOSS-[w}[lq L20=&9Lfpcl6"S;?$&FqӥQd& V\͍ 'h4;ql̊X?3k̹T*ӂLy*=?g*_ܞ™NoȡWX?k}a| v_\LԐ 7xK,Aii۶mJJJbK162(M<$g< f%_(ͨ[UOWM1xV> ?J;0W GRdH3'Fr:\p뫻9Ϙo37F[X@2?nҽ>p.?L8b.]B42c/```6lxwfGq<;Zw FQ,_ڄxj6hICYi1l6ʒJJѴ`>R1\DuSʋF%آzF7ZMh!REdȍ>竅hs3ɏq8n}b$3?[^u &A\hr#׾}QP8~U鞠}zEI>|X$```@Çc[,"!kuรxh܈nVō qt - ~iUW̡󘿔yaQL<{ru<%EITc'Zx?00-m=Lⶲb}3Hw`Ŋ,H$>x9Qz0XիNLz6hQC<>0Hf-H$x JzF& Z<܄\lO?os-|1Ҷ&2֟l,7]Fjkqh\C |1kn-ڿҙ6r3igGP_?V~U>[F:đаQ4%@MAdf,}j6A;=% Mne9KdG͙CWaItK,Av_(I;(!RЭjnYY:[/0mfel3Q^mPyɗ-x<.q׆J.`z#Gbdd=::]<σya͢V\y#._^uN,^o 7b4&ZVģO'QrqUM (QT\APZE$B9 NP\H,`<໩ ',z,Aagd N k|Io2d!M̑[-{,^}b,]O$Zqρ;k%W)D,( !ܻw/>= K»E(]oeee.N?ꉂпIcms!/Y2JsX(؛#Sq>˝sC$L~Tl8*OMe8`"//UjR@*"Eb|YQH6z'OFPvZ 0w="ւSP'Hg~Z-;]}1|S𥊱:QUb̞r̵cܹ| ?59sh ubDXP|ic8 ~%KJ >xTK/-a$R +mR䎬l|I5L7Qyqzb=`_MX=79ߏ伨;T.Je!@pE9*[zeŲʳ"#e⎩7KWDh~zT3k+om/-|"()Ϡzi=Ii}2ho{`6_8{Q'{1gn</(aID å ]1yޓ\1>4GogA5!Aul!<98.ˠ?"'YbJ O> )/G-&8_ЍV+[| SO=}kΏ_@gTe=0ak2=@O{`j,$ WS^5dYL̠ Y t~_r33f,q=Jx~1wKNw̡`_MKa)c , H(zSSy|V @)tQ?%@pR9JƂJY>ܬ^ڦ\*-qvDž#ڵcZw8Z᳙L] ˈ[2t̡_F.ívfg'ΡqV444^Eimޱ> H5G楮!ʮDUT!qs)j4n6_UL: &$=ZW҄] 1;{'DC.#ˡ>#Krx'!GPUUzCCZ[ZUPRRg!+KI;R.!b2b")+m=égDTJdrK̨j:*2jqqW1|] `L<B[s r>$y\ IDAT ơɭԊ5eAnB(iLLL>44x}hhHhnjNbxx}5ppnBccc(^z X =ztM={˱fs=pw:1TUUS|EsS(LE_ *GVYAhf#uKL)b\p"duB}< nEI 4܉ hD]K@Liy ?[ Nb9ZN8w< 2JI9`_22"\"ťx{ֻU /s$XZy& .wS/^[-bѢvυ'NZ .}?ؖg?s cͦϡaq;V/50feY:<ʺA\HA6n*bw x^dPjqhqk״fSKz=f@篴_KcNcڒ߽ؾB Ȓ.BX؈XN8q;: 7~k8ꓘ:N6_Xv-v܉_FII }QK.75b~SvׯX){N|a~cyc#輦?7q`rT ajjK&b{\΢k\P>.afMY'AP9SʴTp~ݳ&̍{SXkxcSOn!-[o<9"_aGV{'ݜf/ 7z[|nRrhw"W*F v1L âsX{Ny)LLmۮum*~aTUUɓtAѣGꫯCݸq#`7X#jǻg) ]o%+, R} .KP*M1ɧH)㡸:07NH~BdYE3W! h/w8XNENyboυPPi'Mo~_q>-vY8gd:9ӅZ ޱ78f}d`C8::Z;Dfdttt>4~ VD"P;޿FU!ݼWN0'[{󍃶ϱ(Xs٨"`؞*OWIb7POpjgT~ƾz;~YkΒ?) ZĚgQTYu|@͡COn'sPNO" :1#ۭGrΌCo;qFj3允9P*(H]%9Եz +X{GM?S=#w/Ñ#GdpΝ[I'),4afv:G|[?ws3W8+,GQfI BAfpL%=WK(ƔhA/mʑ(sjNm1xΐL72v~r\d 8~wqgP3 <3|h=DE5M2u"^nք3"؈~hnn7M0ưd|ł ,j\DS\B)|6t RT*Tol8_/fbrņ w&gݤ%2VV+cfP nD7iR_;jY)s˟ mԷ'fJ-Zq{ίmszxa XL<%"$7pr S\|& m/ 029~~!⟦&l߾{Ņ ,A{mW;+ vt\G1`rbϿ$>|Ƞ$qkHOm>[1B 4N]\[{srzzfD&7+eB)]2:2k r[wYVlrшKMuuT/=aӴih,?-L%xqF>33-?GqqEXr'PUMȗq>|mϜWNsnf:s|+YSs *gεqjRuٽʉ,+Y_ mZub\i񺺜l!Fe%>ҥKP@.BQ˗/܎3g`hhHA_z9Kv R$9Bdgo!I<W0r+1õ=?Q 1\ Ay;ZYNsxdlLfb̂6r5W^yYllsxOhs"4?}w?k!a,^s# N­ު nȠEeoH;sˆ:2!oD:x5 uëOYv[oc ׯ>,8dJ8=zYg /_>K^{9hWi~KxL37О>΁ղ m5w~:Ĝ/ \vn3==˭nB86H{*͞7,V?Y(hKORguHU#Fd=?]e7"0&e?yq8:]:|eee% wy5k֨jrEBplaWoos̽]U)dAaa&ʾ5M8]z9ruW:e[{HxCNG6N/z -%VH tgc ]||Z32LgC}Mv'w;'03!a)Bik$7j ~0D0,Ysb,~:fiaD>1d]qg}H t *XVN5=ɍ~HkY X%$z|'ti;n,UaDr 9fЩ?xr}n>l>ݼgO'͞@0<:Q7{=Э+&b܂W89~ˋn \A&5.\:*܂"Z"i?se猙:tOgqo4,g*Z2r%V794FB86<˗.w\_\^bN;Zo-PW]qd9\ U\xGd? 3P'ʵB$DKczٷI7f?YسX\ګ-lI#l{e=r`&8֡17%,(@0Vf7hc=1}r?c~r?(V1;:\O?ՎpOJ.Z/nn.Ni1|U#\s+݋!+0;3v9 D !@0~;,q&_1s&(V% B:0F{[8,FVũ=W.$]`"˹KGxCku\nb;0q4'2ip! `s*u:ȡ@M,Rmfl؞lޒ}+#%NrP\xp-PWʟd,roFc#W/B87B2ti1|hee9sZO%G(@*a/"mo||F"5EP|s2[(е2=V/SiE6Z촗͕SNv5RoI@fP0}ӊ7dEȂٺC9ź*/^сy(&oZK!b(++***L&CII &&&P[[ dHi"J xHhD)s:ږӪ|m>WXY8?-S9 (cYx -s\Ccg]6YNAg)SM8c63ň-p~/!=JccbӒ 7kLSaDvpiG~w|>0`qC8==~w˿;v ###?|.nfi۷_wz MMMXb~QV\lK/ahh ,}݇˗;!xPt||38guO '"C|u{UO|c|#Mn$˂_,.ԓ:h.~(磇l/*Z碬P@7te32clz>ڹ~KQ0JѣXf ,[SJKKUߎ:Į]fc HgR V}k֜2&Zf! |VO S'&Qj^VsMC![|oQ3c;ZWq<$ 2:fr nadf= 8_pFIo }z|fa7# NyΐnTuZ(113n3lŅܨ\C^l0ZMsV{ܶ}OR8}4RjjjFQVVrD"~mٳŨqE$AEEJKKp?<cx衇ېNgbyn̲ś4k̶hZB' sqvɭy[/zwTktIЍNC[9;Wn+ik2K2]ӎ$xCyjG]<JdC(~\j y1?477cժ+++?yE044Zx{hoo'6C0xo#ۧWlMMrnSBpbZ;uj~ Z?_V5/&'IZ$yTaWMc5Z3h#U=Z{Iv3&(. یK:AT'`BXZZ}cnxǑNN㏣_T ǎC*r.],X@6ٛ6m¼yt+S2#fmF=٠dώCf3DξeSٳ›"di<Lj};2g js= 2YhPv )zъfn^F`Z#:jdV>ev,5٣q67ZGtDNLL_*555>,̻:v*іb5KVlw 7I]jU,mޣ4\ IDAT9p2ycIo䖲l4Z ?凹sƽW[Q͎AnRF}kOQ5k'bpy۫Eqsfy"-\d4n嚃ơk$_gͣ3VwhB Ap'PD풕X%Ke;${%N2ljGٜLrd9%q7,%y/y%/Z,˦6j$J"EqA ѨZ랣#誾w$_UUxUUUull,qs&9!.-(p4^ *x0+%v[T-kV*4UzG@5Ht Tn/C3Ǭ0 8էʾ-8" ?paa`mdi\=K+8x` ~o 03 C%c~!.4Q3H:jE XzEk!Q kgTP d m81? .XPkQb!KT z+RwymriQ@4K[Fc`pA(T%3u.p7[o}e_+b#k /+2ۗἈ5C聗܆z`%eX~uf|fyf mnj>AkϧLe$ -..k_~w~ޕN/}q|+_Agg'~?qYK9.h93^liw}k8{<}×( (zWhE7 gjN|/ 043QA?4Sq_Y+*^M]0^_: G|!T twwǘ%n^a*0KӮwAH (h/Fɣ!(F>=m .XYE?91OA u^ChB!Lh ediB4ִk/vh&U1^^I-q S)Cʼ`G4w6˞1ADiWo aqݥH5Sns/a\a4nA+|}H^g4; ?`Y!ǚvoFOo k [n$l]I OVjU02 oߎ9>|zkd&бPNRya^',5wQdZ8:F-HH!s}t 䐫lC#6f~8sSVIJPϣhVΰיp5P=Ǜ~`1 }DPwl޼Y]v7m\\-n>0d./CV%ȮݘUb v*Jk~^FW%@O5z~JtnCUiF|Xy8s.TLq ( p,ϳ\<-5I022o~X~={=H[n5d;ěo7x7tS:UVvy=ڪFxc@Q>(&&&H$|FG9qAl޼'000>q]+0+D\E |rDKaP"鼹Q;rhŬؔ'E*($kpW{ygmyM|l[jFaaeL8`s"*Y@e3^DAvw)H[z] >(0??A455>sw~kq&n*.tD$^iAZ$Wtod `p{[J(/k-GWShBxUY/#2Z*aЇ,c}7ftwf 4 twA4v?Ie˖x=B! Ĩl] sDN7 'L`B-p0浳EZ+L6d:K 9P\҄[DѸ ]CUF55|2Z[[cpT:B>@aWD{,y<(>o0uwO*@hZ \v#/nf\;D4"bȿ}EUΉWZUԯ}Pp]J7'pvz''Y^֢ MTm->3FFW`Rө+z$~Uҧ/P x wSH`.R)^wOz4A~D+[Ѓ6,H`t*C E=k],^aKeW(!x N{@a%.Rws…Y|x ._Ʀ1˗(Jћ0w^|رg /ŗ_ջw`2TMMH튞*8~w;:Ej}AϕqIB{ hAwlbNvXNF@u-DxTk|yA Ng,\2 FJF_]kSk 3 vC <}U O~]]]xp~ ;UI G[/=yLLL>tWۇDwuaqj /++/Ʒ||+ (ᒼ)Ķγ{ݴɚF@%dTDD>:`IubgaÑC Jءu ceVO n+ފF+9(A^"EP/7hɄgyQ__?WSPJ`-?o)|r3|)|{íދZBڶ6 q fYnoX$s-@{\ou qÎYU(ZJZÎG4a~P'&l R1օSj*(vvmc5 a";xh- \= ---OqÃGNyQJ`*.zzz00[?1.PV@Y}7̍V]FE .\)*x׎KUܣGg 9WD`ьXzk6\o SY8ENw9X?^RƯqnH {\hXȼT2g|KxG8za $Ul^{S_y~ ٜD*bu~<ȧ[xg㪑qoJrJ:,eIJkjMƭ*EL"iky|HAQȆ}x8U,GNeY#V!˕y"6 VüyuڹӸBjozH3oyC#W.%`!%cHksX7TL鯼ilEbl1=VTd2ZiݤTI2y y#~]$SUy]Fcc#n EM$^[Iee.IyӇFy$5J ZwI(P1[;SQmH%o"xgͽsFW/uδ40W}]tuuOWpoa7e{ugىl6??~w=$q[@FXW)Ue+͸# QY* 0ɨ];@dA¸vxI։#R/L2G>djԳ#\%ϛ9+dNXDKD#vY1qeőa,>ĺv|3wpqAܻZk_'g5cF~a.\6 %I}Mm-dt:a|gDt>K8 S YÚx~%Kœګ)[Z+0kZ{f bPR}c#n>,/-៿}|(҂T*'z/ }6p y-{{ ؼ{dYƫ?߷^s z{/7ǵ܂vKvwq%Bى{ZSǮM7~#48J}8*V!|n'aO<;|*Huw܁Z[!;-[A/PٟUո YO<:GmJc*VM͜DأY)Gx#=#}!lx鋦g%azd$ry/$n~oWtm,[ܬP9~,cöm|B Øt[W\Pi2~p=~Ӄz GfygG{OFND}c#v@2&\شs'&FGѷys)\vyq#'O"aöm_\CGgG n- F0u"$IºnqEJIdÙ@T[^j@aVim(Ipk0FeDx*Vlai{;}ֿr.n`d3GqNbi-V8/_M{xIMǭh}O?z6l.]z UHgHx;8q!KFQ0v,: R"\8s@1gr=x}}XY^'@>Cu hhjBφ h]>jŋx %kh?!FO.١#Gpw B^я  #Yl޽n &nNޜM蔥WCzSUpQYU"nkẗج6PȞJeKB*4NFZv-?[ T=IL=dmnbj,S\c*Aγp(7GAXT=LN"!ko?u[=ؾvŋHR[@$ -xE.E҆b ˸|ݶww_/-~>U=6`fr@H3gпy3\uUqIwӦ(yhjm-kxˋklw-ҤUT Ϩf,J.WJGy|Đ 6 hs8؜rtB}=*QӨGc17.OOax^y:zCϰݺIUQ$ɑCm[c]CC ϿݍK.@e\< :5-{[IB]c#gf*6w2[ZJ]U]fO?NLOLϗBPW_eν{q!pA,-,FOU٫t D1O@[ߢB1PTuﳹ|$hevayL/ 99]D6Y?EtW%μVsѨv^=RUUH&رw/ԄҿPP7lj‚nc,/;!GG+\\6\6[ٙ9*tm-H"ab5ӷO|7}7/F4>d".f HhQqʖkƦ*Q&:ס@׆EU~P9ǔB&mʞŠ|l+ϪslmNN;W/gѭ5L}9g- $ ;nsгaFf0rd)OszLNbfj p)5^7NġC%~ţbav.'( 096>@cK gg-7oφ 8?W[_q={JUN;{{qYގᄏ.姞T( AQuܼ y '\@Jcd =/^y.Je\>K~ZG;~CmN/Gca9_Zi J$~|gG},kZdʪ16P nill;ЬeWVBPU],ܿwrH$\PP(H$le(xKt뻪<WUp)I {eDeT,V1:r9+rx,)^u?X4ϸb=ki]pR*Y斧?,rS ,k) IDAT̲c4ΧFf]0Ply"RϢw 첔 ;?(7}w[S ?`(yS߭Zu:/z]h9<4޲uٙ87Ax/ֵ2}o*zQ z݊S ¦'R,_Rq?_GoH'ZLRY׉?0jvs˯o˯kl1 HKUWc`ǎx"}QxR[a#U-pfJx>^SiPEt؍)*uHƠH^]UfbXܵ2п=~`1f{}0ğМFU`S !lRStWMV=H.$6SQȅ0۝EEo4K %DPc' , 4U6Z?=iYDi%/؂Y=qR¸-n{r#CFa=A%h $YW *|txm6)4 ň!{n7Mm.UX^Cw{swfz( dM{T f#mq*n k B[ܮh,2ȯ gu+]U+0:5^v{t[!ID'(J2 R3GS\fkحfj6*?q%rM+,qa=moG=#2.LOd-aEo Z)eB\h: PO?61*{hϠ P.&5$VoeT8w]!`8,W_J+_HhR!a Ξo]0r!+$y;gFso2R|?Lz:T(,B+$< \ڊgNaLYdz9|8>ھ!qBZ9)\^_`Ea/sV/+CD[[7bz J/1EJcwdΪSW L9oN֠<;.*KO¸Mgp5AN?f#/f 0Ck%9V\fE*oÕ?א]_헷]z#k_@Kh+۟k,\S!^`yquuR],n(hvUU-xp8cVyS$E1 pO͓"z&sM5A|DDG/XUX cuPF%̦5SYInTfXIzO#rLkhѦ & F vbfj Lja]M:Ɩa&zvz's/0{7lgx?O}Sb@GwϾJ)5Jj^2wc^5_qoGˮwnF+&E:࣒Gq ع& .B^/!mq沙99{bC$9bnP|;^}9n@xQ|۷&./&tVO{b3\/^\sHcrl w ,cvn^R&DFk;F4{9` bۇ/FȄJq_b)`5L͕ (`w g@Jiة&fb.@8|(^?L, eZpHJ \$x[}Jkh@ͥ,-rذu+ꛚ,y%;u MMۼ\ayi Dcgbp.4('n-X6""ʷ"?\_uk<wZQBA 9 /10X!qPʡQneeU12TB94,bNx ֞8]!f9 v?O^EuVWw+Kcnvpei T'& /`ΝKsauסopcヒl*NOcOD3SS8hFMN| l5y:_{/Yt2hC?Z3R!"1'g`篴DS8CԽ#Z/y%0s/=0c1px?9͚YU+ԊBKo߫cTeǎ#w /`rf 4/@p= 2ː$ m]]p 媫Jp T燇ىM87s0}; H[oE2K:"(Bpv #\ 26NR4!Zj7.[^8 : H ߤ7I)֋C+is Fy=R@?Mw9vaA3NeU4Pk~# rct% AA`nĸ\SUUe33hjm5Q]8ikg'>|mygfP\]{O&FGK=qVQZ*Eܟﴲ"Hg{̊ *jA(O|3JvCѨ%5xx+I]3D:MOgWc+C7 _+oOX*aFƦW07[B),CH!Ja|d645aQÁZD(tRL74?7L$fZy8lH Vum+X W?.9?Fi,q eQ҆ Qi* H+)dynmilv:`y~Mr4mn((@C8bNJ$}9~ǎ!,]YA!ȩSHUUgO,Xsٰ!F&qXs>%"rZR !c-:7Vޯ_q-@Ef<>,GgT3Wjv߄y/.իY!~r1o͡>TTxeMZq;LR=A )ÑB l߳nF,OCQt_M;vk=8q Ho+-zp$"/eON0ͼҕW"wiyǝ0%:R_i9U6q'\O &7N yyZ[U)Ulp~j@X٥_Qt6YkA 2#0ؾ۷c`vd2uF2Žök"˺Tu5>ϔ܌w܁|.D2[ͻwH#nT8׼8,7^ytT8U?Bx^vk߸T4^pem?9q"\C3VV o_~i-:x:zCju 6 ^w|Wd-*XX^FŘՇ^ ˎbR M$..;}U_-*\@ 8* kef$0b6jE {,.ʑĢ"+Ϫě'w+h7H4ri=J&$ܳV4,*3:9zᙥSP..Rk7c…#ʁ6emW}̯<9UWz<)䊢U]C܆vރu2q RsmZsi}fʳJf1sEϻ>ik1@Keh߭<ګ ݬ^8 is+ŭ::6= I^ץ]X^QMO(!nW|RVpC7,QZCT]\QLޯ]<4\QًvzQGTgk6XC>?"IJ*qe{JP-y4,Y٨3_8c`[$ʜI@8w%*7T &cL/U Ą5}^(h[0ERޠ3alxM_PZ*ڵ H4E'UvK|_mh]%5/έ,x?Т2G݁l Jl՘CæI0UQrTh]l5++4VGgFp*6XL>ykY^28(WT//*HЂv ,g<9|hwZ{<wa/c4AJJ09V`)QoSw?/t<9& R(#UYґ~[TAz%xV\go{,' +S-v_ $BLN\ƙn1RT0qw5'PfHHϲJ\)6Fr;#*c|@őZAԱxcQL `Ot^{#*YY;[ wa3 V!*’gL&A[c#)i<&fg146|#E*6S^6S sMeh49Ӟ jL5OCE`jw30woDI7J{s<~Vvzy)TVLL mohWr ˗}iN>DCgo;݁oG*Ɇ]$ֵ o;¸E(npUv;h@A8<㣭v߅WZ}81F *@QHUУƪ(ª$WkKgx09G d &|6)l !lFj{]^`w5i vtZf0md==8>:E+[nˬ"?/ҧ˝"uvAe0͗Z5Q@Gk!qڬ"(-u_KRG ou=G8XPq"@tk $<@F!Z˺S#64(MM#]M<<9VT#&i>'{;ΓM_ё}XvCǬ(LTYR,dT[;UT#HEJp`85̙W+a8wW ݹMBL"mޡgCl&ZfWV@$ *Ȳ2uu55CWZ+.k.`ͽ^ɟ'v#sf y]4}Q0e; 2UYeiۧDx}ݨRu/ k5Wwi wblmNuR;x?fry=q\i T98YsE;y0N>/~L%U'GI|y_:.ctGLzjǦ_pcGqWǤrx' RZUF1ȫcPtܓ~"k Uq^{E k<34V ,k망/1QϝV扠^>UX8$j[qP9v *Lc:r,N>:ׯGr҂knu {b-tL#Ь9 > a@0tSYq?SBuqbM&{Uhxa0>c8rHmu)B4ZHI[I/֞-EIPLdƀp?}mhɓ:@x 54`vz3Gφ $ ǎ!ػ"LbK.0&FG( z6l@Wo/&lϟGSk+™3?wr~t@gfy熆0}"$ @1jYL?>t銒=h>nrIxnq>%g"aɣ@9H4̪~?'E$֢BSZYȞȻ ACjs N!p\wR QVa 5{Na{&U!k$|.YB_b!9KHOc`gZ[cp8: [D`$BJ^Õ%lڹ,˶T܎xssؾgZ ccoj®/֗|e0~'QS[> f@ђ[yц w SUҎͫQ(CƤ|Z9ꬦ֎"h:·["nkƳ*|EPPIHwŬOy 5 ( o(i9y-<9Y#'Oa{ww& =Jgg!%AveLs>OC$T !ZܻGz 6z1};i\8{/]Nd1}RUUU?m7mt"- X<y *n73g !¬gğPik_Fg1 f*tH%*7uEW{EuMU%gMiٝ eYꛚp/_hli)Ni,-ܩS󡇐"wd0tzaT FGW_f&'1t~%z}hhjB"57\E,/뼓K󨮩ӚmS.6KD˧ZE =ԯ7 . 9:ytJ a((9qS؈֮.!I:ׯGm}cuu'@"@[w7ꛚJD2Y$/kz\o'XY^.{E"8 IDAT7݄#)@jeҸݦ7S0܃A+ZA_E!_Nav:| xV4kA Ea@6/},+y3Ikr(UpaTUH =s}qfkX>wϛ~\zVFZ#䳏>*t-;wzjy8r$qYHdJ7aUcd2O fs&N{/q)FFȪd\nI?4HqqZ=g->~__C;]G\GhkThgϚ, I @ba;gzx1Y""<鷺* 4rv:}?Ys9A7~Y-p[/f̓v?֟O]~ͽ}sܣL;s};uC857umm11;8RUU\%m hF ܅a9sgY/0Uƈ(<1Qy[qzo ֞En=z0AG5&:s\3Tj\8o^rфK}W!56 }*/2Rphl MMH%146#A+3*Up$JmJhk??JdwQՋp\%>[aZI޸~7JpeE%yZ0bJ'a{uX{1[jý<  x1 IJ`0571)-nE\*SL;%B'\@;TpZ#x{0PDH@‘ʩ̊Hi?H Aڥ(8 fyk~!ʶan=YPU@y^@s*; kL  z h vBOK w` '}<:v+ĵ6a) UxE"&hW($R8.]!'& ŬQw2XyUxO*+DExk)>L ݤ8x;o}{a \`{ v76Z|ᅼVm%P/"P8sQYs`4Qld&zp!Cmab5dkjpv"<2yx(鼆~/v-}Z+#7O,;s3V{lxRܬF >!i#~ʜVEY=hm蔻 /]ɳ' Hj܂wԄdPd_Z?}]}A!0M7cݺX׎[܄݇CW R`8Y{?@w׍RQkOZ-jAbʎZx${O+ms f^} îj>Af)&f⫹LjG̃0I$`"c _ذ.Z'~窹L$0ӃFjN|>ٸLܮdXh,}\- 0ZuBA`W(?^-srl^ΓfS஝Jj c+GȒPJ`V3\Q 5=,rI 7=r–I_N=eqR${z qRa-1QFèڣ._肯*qxͼAzZ|@ѱaxj4$Tr[wAƓ(+q.VBYNkB9=j+DC<3e;;D&SUI$Y"ːe@2!~c=d .Zi[cc v6/reY^l!A$.`rNTp(Jɻ/N3>qqqV; 8UVdOX8ljk"!8KEfF*`)~~c$N܇i\l à^{ .A{~}v~T򬛶_"4mߴ}7 gښ ʄ0u}^%0_~7mMC~7 t@,dgPL#bOwT~k=TOǗk=شi==9x@ASk+B>|m75aUWh!nkYa(N*ЄJctίW:='@N|}2w$ZAsĤaT7Fjbx4Ƶ+Nyn*I`f<k{zSܨJ~sgY./.b̳_DsC1W0]۴zhdrh*Y8B>|.BB/ʘ>,ܹ2tvj c7 oϝBSS/h1k2Irgեͧ=Ξ7K13S1 ywĭiw^VʶAfPmXiu Y8i^1/='>^+CBW4֫6x6s|kz?Mߨ<:4lW/5AB6T`L`6B.BA+DV`0*NBk hnoGs{;0r$zue>zӨI~&ttw&<\6-[Ylm- >~`NBfe~{^|ą vDAm\$G;+RTHT'U((:R.y>*t(a5WōxP4\i$ wGѳ[fs:4:reٳan_y[îJZG{ uh{w7-/~/Q_#|Q"tw0|.|>cCwK8azoU55^`0䧙XYZBLdv"5lZ۸p \p} '@}c#++n߳=6@Y}(z7mBDc|%I UxK3 .UDo/ڇXm#e-g4笋LkaUÇhͪ:qȌʱ| Dҁ@c۷oo믿|[z!=VM#?Bw{Jq ȑRdq)*TUWǷ _iJ!|>B. eKo~W= iWO{ Ξf&'1=1[ﻯ3u ܵ ,c)F-)B( lm./]F56ۼc##ٰشsgfƭ4YqT* ~%k=Uy!3rœ{OgL1xw !\hhjb=Zn<;[?|/!^khn&|{77??@ rC7"at V݄;lpvfLT{_o R\lKKY?-V!!)i^r=KҘOСM3HA";qwCJ$*>f+`av54dEbTPXʕex,͕]Z=#Va9^C+!'8ao|i/yhzqkibP _6j{E{Q+l\ Ьw#ƛoB__q,XbFP 琽_fR3E= ,jCelݘD]?a470ؗpslYF{C<.H7ma~>G<ߏAϜB"ݟ$bC*YϞ:d*Uz8u3n&nWTHRez -VDN g% E9KZ' "g"c ռ%W\2_lJHS-5A#m Ν;od^+򗿊SF4i"ԹQWt~fVzH63qnkh6gkɌ@gg/ E1;tYGP?j09]@ QI,\Mzi[fi UN Ν:E2fVV0:4#1+|f16n\OrA-1( ˞)ɬט0V'J с"צ$\W(@C; 9r-v04ptvԩS:o°uY^%*Z|,Qn=̀0K~܄Du15~+s0Y&8{/Fcn2+ )tox2*(l @֭xǑѿe FOzv֭xnތ1҉ }Nn8aĩ <"a)kiZ>~E:*sGEk5(T4pҫ_̋/bo]-C !pmnٹի5c[ZAm;<9gQUSõ<+ \J/ū0r^E6TF{TaS\bePP޹e4`N<}Y;u3<̟qYc'9OX;TSg`9 ,}ﳅ޲'\ڍg>γ2vyMA=h>yd"3#x5KVgn>{,w2Mݺ'Boj¹;}ޑ )΂+|Ccc12[8?P2qW. q<`$xn-*$GЉhgceuiMS'|ǦWplz[[Z zwp.047/} ;W=ak/fYT՞ &$YZB]/xT$ geR>]nuOZ:UiBo;t65!I 3046|!ø-ꠎUrIZ%ݮJsYµ"%OX()i@@ a4h"8҃@{ٽ:C'._Vf`8.--y1b&yX F8 ^`+{m{p h mϻgPyFyw VUHWƂ*>@(bHhi\_QWUk`z0,d6֦<6=c҂nX{7 Ww]8s/ެ+e5 /ab>;=]q)tL>ؠµDTI? hʧ$̀G^ChTgJf`P (ʪn ,́K0wѕaex?uk;S8 +5)1r."ˡۮ+{/pԽN0W$k/ :=hZ%.?hRjP[+k^hD$'P|oë@ 5" `Hoqd9B"($ 2!^AUF:j;l>nW\30N^%M({+IIzo$6U*RV^)9 LY)D3\z/`(pڰ<@`ӳnn@,b9,-L´wJJ#$CFkm.< f28Ϣ:۸E>.=q:lغ:FNں~`Fs[Ν:6lܶ \t #N }7#UUt2ː =Ny h h%R ^{`3C3/ZE g44Fw@XrFEAK9" =XI}jPBPabC,/<Wk^xY?UuX[y){ =U#7m›Q؈~gА?]YCpat"_ IDAT4<-x=nٌ_=_޾Ѱ`%HοD~**1]sY-Tε_UP&3wQ]G-/7_` ٓwQYI5]Fݻ~iI\CsQ8Dzξ܍Dwߍ#G"Jaܵ}+ QS[^C2PI4^\( ͖>4?/n*TyxTd.[PsizYj=U[[.8g*:8{?eQA;UU@}^:\&"_L`=7l(ز.K$BpURLrs hhhtV<`gCvl΂"缟#QTfj| c|dT[1ɔLNbE4>pnh۷cvz3[+UU]N=qۮK8:wcpPTT{֌[_]PJ">~)-Sf+*0\>}OZ{"xpJߜ]vPA_$# -]yrܴWVyIohkr KY4u@VNkg#0T4j@3OFzNެ6Ϟ)< T@lܵjw{d*D"Q U[Cs3&0 ` 7OmuC ءq[PRt%,Ε\C\@,wSczS/sY3ЉX9](YީJ3L!{_Qr,}&a%/]?G+q۶ܴM%! IQ `C;zpnd '^?SU8  <[ '\PgÆ6{r@3_VsG>裞@\gCCl+Yl*VC,ݴ|. B]ed3mf&'kᮇB6A* TFZc(\*9/ +>^CX<`wBA-ͨT\ CY.@ >gaІc&wmqVO{>YsdYf~7ܲvh0 ^]?jMmw'ڛjDuyU,,e(PdR eMI5O$lA !IrjsyE_@~m+"N6K{|h?œ#cij%#xuu<7ݯpY 94e۸I7a~njoXmj])Tnj% [Uu5bn]C^]U"h=W͸UJ}[݃ XX ޛq]߭n4}% AHJ\$%ҳ)9%;J<;3(K^b/v^f23~OvLdEےG-ѤLIEQ$nם?n}~? M֭[s2=+S!ttd|{ùDcΦn8>+5ʩ2$4(xZ;B*cib O^@PY]v \P _ز{O9 !d%ܓ ҭ:gDa3Щ^bd߼U,M-`_N8bB!CVܵq}*t ǃqC\n^RmCjW \hjl R~knȅ x=> _};-} ?x#کiRU>O}򷰰 7cfjSSS`97o"ff@AmC-4N 94Bq,s^B890T2),FZd"Ck yDT*4"#ˡ`w߲)H-7 ~:Kک%鋣8}qMùpfaZZm4JBr(6î˩0BlVVW6~.^*\pã\SSvKKh 5즰[7mkoFYAQ{Qn4icx 1]wiM.D`(^'b!b(9[vprm#2Vj}ъL)"1S͜'aPH#jPȀ` &Ÿej6Y h P5 Ԛj> =pgkU:R/jh/B|TT0χ {"cLt[OVċFa$z0LXEyy u_ydۑqTW'DARfCH5a_v TT4[:qsu%g}SSS 6l@?/g"ڼ,75AJy3_Ye:3jP$KhaQ"P!" ɪ1̷`DYt;{'gZȻ89مf\f'R!eT=OIQñfBiaíO'TJ.ӗ;(ƍ$1Ya֗PkEcɚ+s~|E~ ;#c9Y0x]%Vu@<ի X/YN622[oׯǵk~Mn,F<}+2]iNWd/a˳1{i P"ǸY'< Mi8LǒLbh.f&>vF Sy**# Щ>v #֤qqZ6@zHRE-9 6n6L:ǟUn]vxw]%V؅W_UH,W0??ظ^obl8 ;~าt?.ܹo#ʕXn"nYcc#ݍ[Y0ѣAmm-n݊OoǏv܉^8Nٳ8<6mڄ 6JIG:2&V; E^ʧ@RkHK 0qE]}@U('+TVr)~C @l:S-F߻1fEvg4Ծs+)Y8{v4{gL zg }} DQ\Ď.(YT*!A<8fnn J= >_A)y;m߁u~4)}gWy3z+PBc.Z :襥%|>ݻ===xqe8v]]]xg0&;Fx122[̙3" Zܭ /g&K ށ%$;{e3!4\Fm<\rN-`LfnA(JT1>(@eTI`i=.tbikv;)110%]by#;T>G)ᡂVV̝6>9ҺEcy0vh=^,jS!MQE]>]'eo9BXށRοHrLhhE֮'N|k~C(/oBK˭ wbnY#h^߬vYڵk?y ވ}ybΝ8{,6o, ;w⮻\|.\@ss3.^6<^|_J^;kHeT+3 i:z</--M"_@gnLNK/ZZ`_Gsfi47gh;KB1 g|SϗFbrr555HRWC",EϜ9A|+_ pUlذK$hrYeK=uJ=H}$B*Z0 jAd0tPI=T٥ujlG 9SeJTVN-+^K9 Ɣ%C&?ዛ> nzrPs5t4BxYyy#jkpK9]XbzzwGDA\:2 -umذ۷oycǎ%ՋP" z1A>Ǒ,;Z+௪pMK?q3b^45L\NXՂDLbWC*wF  #)x+M9f  Ȁ! uǹ@a(TѝBqr—\uŶ(M8ƈqXNv-1śub(rۺgS(/U]~\""LQ8< J)I**Z͕:! (+zqqTHeõ?3Ns'Q\:v 7Bl0|FkͼWr}1_D}C{/E]߱l*+J~uuMWxNenBǵOaU'.n7-'%;͵8j m0(?GZ᢬0SC=SK7,X<,j*yOdD/3<\D83@`7J/:4yt'Q'MBe.6.biY d7))Hys/5Wd3k.=^4Z&kZIsZN$7;Jjw7׊^ʝۄ 1O'Pn/{v0hmɓggNwV~{_G2@RLΆq}rNX[$P(ȒX=bK:*EꙪA C$x!O4o5s$4vb P d7%6Dw0 IDATf32ǰ f={eWFCzu4k R\It2V8X"xAV;xM -~((qA[[7Xv߾'O %<͹^{wW[XO)"qR`(E{S Z19+`L(&V$0FKd +erIpՉQ:-;Gt|tGv8m Hږ;`Y±/<~R'_Hs&Jy)opq^:}`+þjo2&@w{Ž Za5O| <.Ţh_l fo #;G*DGG/FGo}=Y[;7h) B!X<`(MH"D')秎:o.7R̭ Av&^ fbN6;0\jT5969`{퉨w)(ao Sj΁bS_ (o}H aX,khL€\lݺ14j{ؽMLM%5e(C,RD39)E5 KVe3z@8RteGDkWʘ)ٻգ<N_Kva~@C\\5sKq p?Z[E,9RI$ $ ,'kORR(,8Ώm"gC--uYm0 @*8"-߇2J)f⩴/oCM9X!5B@ņ <ʣa :ɩq'4jV[jI.b?. sM1uݶaJ ,[ )cceQ)"Z25%ep:Q߻MKb'fFs[W#$E8M|}5k2[lg1nV5Tk'}Ş="d 0b] J%0,XI  z,8!ͅ,'Ь[wㅀ%2&XAD4,Jk*@A11<"* @*;@I INdݩ%+>;i xf/ վG\r?E.ꎥm%ىkd Rgm/6NMAy*=0W2YEb "80꼸}8NƽkziBthGMBp^^PݷQڵ_BgRg)gB0  TJ=`>_Y G=" GqgB1@m F|B?J"?b @G7٩޵I 35VVEnel-uD(J u}ٌܻ}p$DܸS(Y 0#%IDdRV}(L&H& 8"}z&FŔP0FH%a"C*3~XafCKtm p}j<!@jʏSI!R?u5@h,|yTIcn0f҉+SCc*%"69-,`|$*+p!TT4a͚!Õ+?zGPQ*\]A,.NiJXl/z{?X "FoPW*g7zU$043TV5._ **q`z=LMڵS43:; q]=(Hx\!v`Q$ ` 04)noЃKY8pk7SԲjzk7!S "WB$`YN4:C8sqg. AMp8`pcӡ P3fjLdQ];(Ek޺hy!*f6&mGINA CjyBE"3xmV؍[_ٹeq!X\CC:tu9:'x< z{?8w/bQVVw'AUխ8q⿢X~ͶMN\y?~W~?= ڵ ]Ž~hl\7"*+Ϳ_.:vEIJyLk")pGv p1֖GM2)W[ TG\xa <f*}Di҆0B&G@#2HU`BN\{ysɰpΚ5F4I L`+}cc6VnYS7l1 [~:>547oB[1TUu`ŊDb ~ &'Ocj4:: 44ŦM7С?sX7r|J\C]@0,nנi#^y"alhiXZo-&**tvAGdnY."\N7A(n_^WmzUR\zE*i@TݚW&D-iVţ(GA)_ BH:]3QJGI1#r&Qs@K,heAZQܺfEN`0h2A`z@  !__S7F Zs-AOjpl‰Q %g55+W**PVVڕqD3;m$Khu̜GG]< ykkUR8&&{8{IE*]B_vBH&P[+ܼ##BG}}LcݺRzEOղڕ^ z,#n/,VRh< rDx404^X|s&A`!T"JRǣRTH%@͐bQp+F^sHy2t:tMC}5C*SDE (P*(IQ֒#coa6@4˴C=HBc8Ȫ 'y<:TGh ?=ѿ`mm.e4"vlZ[o7Ԯht<ID"Bt0h!xeeqTWwI}xQȒyj᳣ӣ\"UMۃץٻt%9N Q8%+@O 嬤f}@M'<{D*@%S' EA!YYI3aSv!a8P)ᩋ8uqTx0ˉbC(@r) ?u &wu4lV[t=c z$4dD/̓oK܉{/cmcXՀq{b฀/`z|&'O|laյ.uuQVV J)F@Nn 11wbbPBUUX MM08x7~ _[ӧ;ñc_F}}?jjVcwv!w*jxk9GAfAX7ahs> ܧsqSV=e"E41\~:B}w?djE8R)"IN7s>y*}PΌa'@*soBaO[<#Ja5`@..β,]@ `z<D]Ar 8bo;J$4~RG=to4 |w>oΝ폇]=6BY1q`Y?::vlw΢o?H,/e}z;m{RzMMqx_͛,+b֯Ο ƇԴ_êUV@cxa߾ cρwבt5WT3}44xXXsH0t ʙȂ=qaJNbA-`t36,ڭ`@`- &!UQL H!3}>A1 L'O7; >8PA6 Q Fab)! J9@SGc ̬D&Ipy嵵L O]Dp,54[0Zg뻥fHh2Sw^ıco!UYZ+hL'KK%݆=#}nnތҿ+*X0xҿWgM2;޾ZY*B&JF@{_]ر? X.wsY֬yLfvԝ D0G"t T604w;O5R&nF 0kC8Š5cM}=={DȦ<9@e?~Z+a`#;_IyB1;;ӧ_~2D5gC-CrNρ@@ @(~niB4ioseԺ1]ad:p$';yJl'p.bTI&<I5~HIܻN;6[܋<`$y먩$Ǝ[~Ssk3NP|qɚJx+;sV,)x ˩'_{嚆C,WOuysE ,@Jy(v/IDH90&)iq+<t}D^&Q1Zn#ԏQƉ`PC(0:|0| H@0S`ϱhS3XXX@u2e}䜂Lm Ơڸ'f'e-aZo󋭞Hv55طo/~~_| C ~/^q|%+~c== 5ظS%L{i0"o}2ݛV?uH 3Oli: bޗ١DLO;vYY]?xFB+)qݔ;yTkÐIbfb-~/oa|d<CVR&E08wN p!٬Li ;DU5hB 8G2>B3?5Axa+j;Z`Ҕ""NaI2TUu%2Srel k\:uv7Z ײrI]xXyA @)PhfF1;0nPqqqfpCgJ MFL΂@Q0 Ph^O>B)V9BzB- ui08| 0Йej0Lfo0yBȀ 'TH`OvA`X4 ǘݱ0>w-1A9s❶$2e'uMd/nU$4Z@ȘΓ;6 CYE:V\0 R/YU*8;P bHx "4)n*mp:k ;&6j]OycGgM`6T3x+̎=HJ&0EY3'&HΌaY> .~pXSG$Ч ,k 4ax!Q*"}0=/033 Jy,,,:4Σhprvع_b|b _>'#`G4`9:8O#.FAy㏗@n~9qdODLQ2 /٤EV{/-攪p)\*'&)x  tXHQD޸lcM M~ à;IE߳AV2A&bv 'Nt&̝ـƆ[Z0/0UQaj@g@ , 3{SnN4Z8$ΐv:)YG,<' TUbMMBcxZՉ!C2'|"Z=HHஒ_t~"˶+H93Z|SLݶRTw4/r`ɨեFA40MZ(=_{D|Z0~I_O}HD8H0bA893\K@HLJTɀ @H" 5(! R0@#z0V24 :%&z1Ej B69b=FU #1Nb%כ *},yB_Bop>-hmPc*.‘$DJfq$?YiO',k p=1}fθHqۛm79-"4#iX,a PH?y6L?$a>b0œH$2fgyZO+YFQ+P jOe]UJ<"xs|3L RPJ4>4Is.(Ъt.P5y YY:[kؘʓ^H:)-\ͷ`9e~?q?5.\D_^y.R}7_4 :fj%G_k݇wLmGuG+D!ieX $r")zcbլMK81=z?T5|Z'SIC1J(ΈI+҅7Mh^zKH$aZ:6j6iPGdP̑:0|:(#)),$$ TlB] U4l}Ip%$|Wϧɂڛ QC5]Mcj1QyINq,..^B`Qq Po,N}@  0Cpp̾^#@ӻrQfa(1$Bѫ!  U~ 0dr@Q+S9lVO K[[&eP׬a@"OB@SWJFAR̥ea ZA"~zQBs0@Y~2Z~?4AZ FXXX,Һ@Gv #N.EӽxDUÌCB-Ghu7«ׯ ֭ïگIWR|O୷ÇQUUO}S6}Y o/!l``/2qFإ%9r넼$ IDAT.]}݇/#_h(%4'7i e PSDFA,!i`XF")/OIrEu tj2{V4c'-x)iHrF2[Q)"ZYɢT*98q>]|7uV|3իWq! 㳟,  ʕ+?k+,>\ّ#GpQ8pW^OOАuo`G>Gty;x oߎZi`ÿ(z2rV.|)gx$Xϥ*fa%.+\ԥSx xd$`Akg4d%OAۏoP:t>Jt8+5 / L#lȜ Nc$ (KXPhT*i'0#J2G;9L:YL hCvzMG"ަ3Z ^ 2XXݏнm)lDW^ũSp)b1Ӏƞ={:::i&|_D8p8^z $^{5444Ξ=)Gmm-![oH$;mmmH&x  /8aժUXj000 e#~h#Ǐǖ-[etuu-S=Lj-Zn*߽sz.ϗS `ط*rD"Zb.t3bHu RIwڵ_ K3ȣqF2֓qF3vQ+Yya8+s&FrCyyDxBrv)%1 l$U0>+m| P;*?^~l@7aSRJ:C׾$d @1MJn̿ƞ)@c2Ր`]mnn/".]p8 J)˥~ٳgOZ*tvvضmVZalܸ믿ףP/~v&&&A)ӧqAݻMMMwz֭COO&&&iӦ$1?կI'dhhGߵapp۶m:~hhةPUUe|СCx~z߿Rpź`6tJ$\g-4QhOO@~`0u:f=njAXN+ PDL: tP=O|=Q0>H T? ϔR0{Ȉe[ Eאr.Tnu4C#%%Rj$A[{3o}҅];v oX, ‰ b1fm8S+H/;SdڦW\ZC8팊z;20HI5Tʃ"0S) m @YZ a顱XEZۜ{R HE&]cE``7$4IԼ)sd֢uׯ_x<͈Ƨ_.ue ." ]K @c'a>vR;K>Ү̎qA{֭[qeKзQXv-} L$t"0,{ ᅬ^z >.±1e<+H3sss4}V< (-d*@iu%Bl!|| Vu][f| )zEAX)O3`W9L+b(]Uhki"c`a\2"㧼,08B38MԻ0nob(#TYM$f8fFd,@OtJ(MNeFԉ,0Wf8{?G8#뱓z'%C;k=3%Rb5BuVl޼N8a<[lOSTWWo4gxЀD"zܹ{n9rߏp8-[GAMM mۆ}k p `> 9C $Y/nC]]O|Cl޼7u'|~@ 0?)X8ܒSr: kPUNvb`bS`8;0فQ}q{7@W.e9ERDtZpױ o;vϨVZB$Q CLD=qLaֻH 6E-L[4E4ADD(088"fЌ{'V`^/v@[bQ23f|':?q%󘛛{ɜX,!'JRJǥנ^@cz#GgƎ^K#8u9kk>@ evgQo]h[!CW5~H_ShoU>?ұtPBe'4+(U $Z Xf-*D(gfo.ڵ}'5 P]'4=3kJk WȘ{43$6 ˘H{ ZVZ5wH+:;?WrnVWWg n6iA:OY!)3_ZzjrHF,&P,p/E 'Gr:2C:J''B'0L7skSH&`(UKi(JO(pt"`pK)anEcQLOX Pw~100w/@˽Դ#i˗Njg5kz9u#ƱWE}8s,[B5%̹sUTX9BYS+A?XMA#&| [:ע PPM?^/n\gChC=-?&0#H)%5L·K&brr'9]MOZS#ћ6nBCCrDSQYre9 z2{$4|nVdKe@}(,LL:7~YQ㗬dFF0ęgP!Ox勆54o~aЖ0Psii2AoHUmzšky ^jP^W q XypQ{ll٪H7߈2J N`{jKfqG@@i\&@7Ƿ},œ'gL4i6SИ[ͤ7լE+)Fn4}NqǪobԛBKV,7@2-!pUThA '9." XghAkPejuAQFޖNܛ ^=IEfC̆H} 9/۟$ #? #?Ɓޏ1g2LZZM #qQk {9pD^;ɓG<̗-zmҎ(K,)&faHiG16Jr=G1յCcFh2e2Z46Cn҅Zc ' J0k7 l@n!qtX|mUmC3x/xݓ'.ۃjyNx)at9 U2G'| >=ǖƁؤR)$Az_8hr:sC>*RVa80 KG3iZGoƷ툡!R]@ Qvƶ6T'qjJd嫆vܴDGIaf.uz5Um3볷D_JGAyR<[3%C %@MkE~T6ց0 KQo\&pʪ+LjĖ5zZ̧nF UpJ?BU AYj4$FGcnnxqe,g}< q ذTV՘ZP)$ RI0 e}`Ơπe9tt+qm{2RJ0HMk-h SM`b-zK\%w;,93\s0?SK2`Σſ-Ey0槦ۋGy,,Egw>pO~m]]h>jz;W{g|ڰ>?;;D#_V&Eeeں&|睨Akg'"hlkȕ+Xy3V~ ?KV0 | yR%D38U4Ձi(Ɋ6|r \#`PKz+Fym"sa,Ny(FT8)9 l.TW:]JY,øc}{>6R)$II^hMD)>jg?cxx_{<4aznvlGS=&zlݽx $ lܱPUS@E.- p|BHVJ( 0S˲5\*J SIR))_<|K$C:eGyۡ퓯q)L_ #S)̲: 9z _xp7?c׎xq65EE}=nmow3E[w7b(.9#BNª оr%(8_(`<C2"hhiaYTVW㖭[QaKVDI9I "Y_tV׃hU#Vz&vrR"쵗Y PS C2ҜwBMiBp@תHy-FVR= X T(HUM`2)99YK&]{M*# _^4)Bı" qekJfmWSGe4IV[s,]Ra@ۋ==+=:.~x,quw b$Ư]C[wǚ$iLLQ:&H`r gg17=-v!+z{qQ J)C!T֖fޒ U(i9O.1AC}LgE sY$MNȵ{.(~nd1Z B*}i.g \O:P: tIM5z>97aW۬y^~ QtBLqHD 9 @1X9CyQ<$!&3/F.AN)Z{vj䩭CcL,PT1廦a@q\VWu7@E >DER$HJcIvbN,M8gw̬3g8#N3Gvf؊I<= eK&-ԃ( h QunUݪjTD&w{?}kW??_Wى>tٖDo<himE\Fwo/6lmض o dETQ;;16<'O{駫7nD\OR)EZ=셛 Y4fA!7%f>YA~@` JFū߫=~|wRB$d;(fCH%q@"ߒv&J:Luɵ>m[a -8iU?X ^aE!e3ҨS9ԱmsUv</ḵUJM~Y9JtR|&0>u--P ڊ> "ZBwTP.L sÛ (JP?7;L6khfkT;#>@4EU )6gMɘ_%CtC"&"&]ڧD^K.IQjyLlO1_~.N& s|8s(sӷ"BX[kBvPi| N ez% TiRByQVo '@cj)hMukOq`5~N=F"9~}V)JQ#:&_}Ĭ#°Lg:)O?ܸz_?$;Ŀ7 ĿW /=ӓ ˊb^M$ :[:{7ۢkz0iDasn_9hj5Im$>'ՌZte<vd;0?5E`Xoj)/䱑 ٹihdo9V 0@ {:UBRB^RFZ6T t$ rIRCPƞ=ԚZVh(xkUDMccenT}CېR ~->y WC=0na5?qY+3;;M۶-FVt.[umQ7?B )@>_QX\iSQBdHCDBؒhؑL/iAd|5 Saed^lMԖ$df*'U$T*bdd7~CsO|{~G2"} (hل4YNCQy/h7gQE} L8TʨT* @e(J@R~ڦ_˰j.6|jD3+Tд*(iP6PW\}}kp1$\(hO %~ܬ9گO &vފTxJgߝ>0<:Xއ'N… xױ1;;'OcXӃ=^z cc7my7qMlf[1y[[#: Z5'ـԊy+g"} ~]~;gGGў`~l_ ډ}RJ111O(VhfEom"0G+|,TdҠ3̌׃8ukE @ ^?P^!8J8zު,qvW `\J *0~n=0F,EM%;8"q]`\hj }Om(='-VM`8x6u ^ETݳJnJ[33ujNszwT⊯کD /c]'{½G|-+)!|2a<' R.5@oUIB27>amn@qsw|^hPIrJcт_B`0h3yg,sPt>BA9K㉰ PÞ16]s0K;W7`}o`HE*3v= c靶%A4\`H)E |q꩎ gnEK痶ݦg1tO I)8jFؔ:ʎZ~+k{2/룃a#:­' U$#1t-43ďIjh sNlvXDWWW]լ\8H&tJ΃,XSs7_-=;` i`j(43 00hN*I=B2( ^D8!"Rjś+fB=ƧLQXPTw*ih#%K (]a-x6MEUUSEWXVkzmS;*'Ҍ#uLT:=ʤzQǜ)5_&4Nf/5r"q4 u /BYmԚi4,`̅:^q̌ڴ12wnJwzB kBlG%0@ w^&#! _5kh_,n]TLj٠=#M-&4P2?`xgq'}!P|K$dSDU͈xKmVT>'٢:HPPk@E qaŊ5Xτh~~Y~>%2m dYZpĞaIN+5OY*n JzڷY5S"L YUm5ȬfE4Q)חp0,8/ntasP ?ܶ@X.155MىL&>Ϟ6֥aK/O`QVe[/"A5`2 S0>;RA;]ªUU2{H% 6uӅm6i`*Qp ꩛ @ 3_0 uB1p2aAIJ hEy̟׹g zDyp6¹ ϰOF/݄h?Nha #a9Fx+yCmq ) grzNo?ڐ碽7dSF{SU*FΏ Gsu &09CJϝ6Ł{?>v)w\7?bcz&y-9L(]4&R:{_zXeDp3FKw=UQG>Ό3,AR=2ȃ!l ((D*tu+[1goc``H]yZ`Exs$&mK{</0]AqFZ!=o_$Y~~>DQ37ĹNh^V~'!I:<I9R;ݱc/_5On~$Vmt9_~Ƃ },>t!_غj^{5,_ϝ;?c/ \qI}a| 7'ǛԵ[%oUQa.hPƪ(/P?fF fP:pTCBQ 8@G4ЌP1RWcvo_X~D4s 3 =C-NG<@XuKn3>(fYgJCOsL&JT i-$I EIGN8Dk^g=2)غ.S}g!L&0FVp]A~,qtajmàiR K/~_R_E&G 73}+VdcF) x5M FF0:6n֨5h&WU4P1 +̌Z ,v0l|o1UBaD@۵\W``n| 3#R"090ԯ m'?7T=k}>I}5r;}5 /CktMw2MP @NgAqDR)yX&ĀTMYjb1t^>}6;'w(}L&ٯ͓)T{2<] t<  J `Ps˴|2֮](`OiRWZTc**jRs󘙽rEEEU"E *!?qIx5+A$72F}!@mE.b#D;nqy  ֢qPa3cB(ЌyUP,{H04)оrج~)43b0D- O#K# ^.V5SB%*zlHu]) 8NeYP -+,v>@9AVz6Zݦ~$3uVU+ D&j+ֺO"kV;$/5P{zmX{hpzrپl$4 3hf[-yJtvQ0y_7u6 5{D:2c{{B8~ n ׅLp~E_< םG;M0 "3P%'d000??= N/mPt1fҩp^ÿ^Nlzѽ (Ed??+ESFܩgבּqۖPNTZЍ^CiExL<0ˊ(SvX-ΝCxWB Аf^]Qh!RmFhmIa\ |Iv; a 6xB`Ж.hHm*E \ֺjTP^x=mcg-]ytc0eE ]"3\-x0$ܟ`HT^.}604IZ}adC CJ)T왮L'JNsTJ$!ZG0uv"aϒ3bG,a)݄jNZB7=%QMglHM]xW;p=N&h^1ͮ3BP@ $ x$Ku`UӠdRhf=Z;HuM,X{_uόHZ d !6 - L?GJq_A3b=R`ؙ$f u/04\]`H{l@[r5zHtD)=؇tik}ʲ7zRu{cIa[GJPRH0VUMh}:L?d%f;;H%~+/ W_̎2ct̂%ɑs*jI \(*DPtu`E qQ? ~"ERVsC($aho= i ,,$j IRf`JdZj~w`XV8Q+zC=] >Rx",k"4iF]eALjxfS4ʤVk&0HDPqzʕpE|K_@"$I0c|&oO ܾ};۸{0iM\=mY|e-@  7";U6enrgC2 z E!;Z*nQ{ MoiAokn-ftCBܸ0}J҄tuV% n 蟒CIBW= %jȡS)y+[ 9 kHkʁ?"V5>قhϋ0]d6~GgP؀uع6 _eѽF+q:xf K{W6ju ?pi<>Ҥf B/AV@=SG{X邆r9B`f#IIf {ckF|ѾtQ GoA.R 1~%=ȃ-3f!!.أwV%_Ӓۣ;b$[F#FTE2fJh4/?{tKU-0b)Q)NDJi`'gqt3vy^/׫uSXUF%Ȳ={CPs:CO#EYg(Z|(=q?ƫسno(qcMiW:0EZA3°`8ZQ"zC0.FzO;}kƯR@~LJZ5U4 iYFrAb->ج*F8 JW3 ;RlǴcWw c`hl/ΈPrz8&߇L)#2YT"BcO{U eyhhk wvkpxwo覸sJЖ}МJ{7×_CvN-V0G~2t:[coᮕ[屋شo [ptGTluA $@T de=|CRHfh70y7ߟ,LF";kߝokQEx[UИ,5.;t4&i$"F0|-snC#2E0{%TV%H_5T*[t˝J<`ڢPƨZbQ9sÓ^['NwR1@b>eYg/R&;hfwH}(ػM|=D-0RXdž!GvxS3#v<@;NK/㞾]H! E.žۉ;v,ؠtq<1 IEH۩j*&i-A!j'X! uyߥA`;5] r_@L6 j#> -?=?TEx9f5HI UJra"0d{ܞ^U4uFH_/V# = ÄW=`d <ߨHT=?hJפT3S>>QaR;?t&dϥV@$" iB R)E A)'"1aDhxKU6y*HQҶ=QL0G'<գvʀVd`>HunJHD)LجbeWߓLR~\<{m)N=f[4T7Sqv?eU'M|hiic?<LMMa||Rtuu+m똞 e#rxמٳgo ZE>ׁ9 j"1qkeǽ.ɩs'%Q_1B39L 㝑?j (%oER2ۮ12+s8L΋Ƙ͝(pR#Jw$2Œ)|)%YthL2FH8aDC>Q`/\C4;=/^40)eW6S}%I3 nܸ]4Y}9H%@툣7H&Db `nV\MzY+C b/X/C`@+#V̿ ;3ggTiz c~Wa C/_O8?G+ڞ &UiEq}jсDյ]]͸i&lڴ P.1>>iKE;ӉMF&iN4.&NQ Qa\ՔXFfF HZdӱ)噂 `B dffy{q>a!ZM"6!w ٬Y_/$ 3Ҙ*USU8Ӹ0~~(0$|]7,.TRRv" .āG<~TUJ6`fVP#׉[#WA*E h.Ov%tx "e,I>i^3^S$o_ېj=/t`U1Q<5,{ه%*@zKXDP諾gy/Śp}O:=T2x<](!ےc?/׽l!t}}}mbl5rS9#g% Cx+#ik =Rp9;:נyD ۊ'42`hn pDiμ -f]3Tv/kU@UiN(tWr`V%2cJ6/v0-lB`Cf{mxpAC,rPZJ3Pq3bte}n2RX'ωb/2wZVx>j!k!JourL*|S oj,ݬy{+pW5 e,.5;B /l*#OZnӟ5|'041jr6 tww7 &&& g q7ZRH^sIbWe eLEeMbp :(n-Sh\3GC`04YPk"i ^LTЯ۪M"<ZG'Z` mI$ m}Ĺ4J|&i0|r?O={|Mf{#<> wgՊ~wЖk͘3 mP@enjؤ59!T[v;GnN>cO)}8dj*F{eq|R2 !N5Rʿ @X]ú $ +ä{ߩy|F1\q b5=^hF3mm6u yfURJAZ)0 @<r |\Y>xH03}DN䎁6bP%M(OR`Ǫ=}36?Mfan$r韭cr$y>Q?V: &Ës I9ѪGX[XitZQm~tYRpT]V{ʠ]ӨynQh7I(6g ]+9E40s0?`GvH3(ehI5[jNHћદ|@"lUO⡇>5JE{k{yg\ițy#lJ߰8>($I2A W7N?L }i=y:N7?9;ˣ~sڵS2r~jN]oUw}E>尪uXU1B˾Vrb41xO\ е~%W&q)&l#6ĥ곏D0}|BP(}yK@7ljæS0J^P$I D7aG۲BOY%#NH>r)4?eUjTæXFW&h!8A=[35e_on{w|فic>ۯ᳟& 6[ElI#ݴF;hA?J;TJTc퍓?\RIiKkdw[woZ%L#-KGMS06uaj],%j:SFነnktIF(+a{.BVX$Ÿ_ΣAH:]_(L%L +&+=Ā򍠉Ro/5R\kGtM9eu:%{ ~`/jz1zmR"L= ʧ,82l(s,gy7qŖ2b7 Mp؂-ok>?9qMlfK=fꏨ5~gW:567hzS ׷,WUJ )?nm>kΌP(-G)kx5ܽi-xҍ@s(kg&'wvuau[ xzk[UӪbr3C "Sƴ{&Gjiy48~ߙWc>4;3uu1Tl>~Vdл9m0*Ͳ‚(\W=.Q(p]uD3Ebא$Su"U5 s KO'ݳQڥ20lPg@/s'6UIl0ȷv_}ۆG׶cy{ڄ7MȷeC@710SI )`S 51V`H+*gfP/"rg|X`#ސTf i& $4f|zCMpwΚ1v(Rl3kj&{ͩ闝6Hu|J =RugFM*|P75 *DCi~Hj/,X&L94dQ0AV-H,[4hBC=3'|kfWΜJ<ܱݽV 6fKu4r}u?5X1"+y+:VṔV_t#[Xޞ19MӨy(oT   D8ߟ0aUROERUWPI+*(bbbsDE 2Sed(ueQg΁CF+aę9lJC&zQW%U5v6V4 j~PT*ՊYY,U~PLL3VC`赋|uJ{I$Hޖl>UV$2w.2|$yXe50sBFtl&u$}hu´wt#~!ֆ[@I1~ҙ />xUy-ǚR~,>'wΕ*ÊcQs}䑧ŊklgVVluaSOfZfSq޲4T2I#D|ޮZ.t y!XܥiᤖA"ERg:iXfgf`:hq@,DJ`\ "IG 5 H \h5WnÀ{zBnO=2)NjNYM`TxJ5V[8/SE5Wm i ][(~ eƎ;vY*j1\)YƖ]p%3ܚ06l݊ׯ;NOcyl޹9`5َ~p> Ԍ@hDՆz;zSW$6 @!_\U+9`F{)5Hu%|$hDZٲk>"v݊@ s<= IaXD0>/Pԕ!@1O4(޵~UvuCw1P/y0pi^)X Y@-/|![ )Wik3IDB4~"-n0 rL@kmZlY!Jԕyˍy亲k{˸p~ER>C <J2.\2-- :|2&ưb`wzG4V[?u 7nlo*lڄ,cMs($IBոv"F0~V897.\;Gbʕȶ❣GkoGkGggqkfmC[GZpp)( Жcׇl.8}4M3ϧٚ x*(C]@=ֶ<2>8xIƞԄ$ka !c7 Y% H($#lk?e  H2#e|QOqt_pەm ,boe8YS UCkJGA{zKzcj\3Z0 8l.4 l@ZiJ>5bT%\8.]zX$.jItZ6#9|Szj=MYIK&u3BP vbPH2H'}"ժiWk) R\d*`Gj$ߏ T }k֠T,oc޽ `ݝwS. 'rعo:- <]e8&wuK:kS3uro_/ynj 8VΧBrOB2i 03 _WobeC qY(%TZʠ%ZN3?Cހg''Mh\m, i3 .NO\ 'jE (`>Y<`'8"5~ɄoXipu[잎NHl`X=K%FFзf"WU\5k^S|w{oCbCIA5 shىJ;GjfkU!Pg >00}}k|()V! OUzQX)kSƊv*F*g{8Pj 1@ QMn#F ť6g&'qfrwP$ ( :o 0d QZ,`D40d'A{nk_.Z|g@Sp0dv<%(YpVɂZ&לQ-w$W/vT"8Y颖D=Nfi",Nlz:Z A?~.ĒBJ)-ڊJ^lغg7nĥӧѿvmÎm-8^ַ 2J"֯ǖݻmmupȓOzngʕ͚5l͖w̚U8Q=;i+ sH[Rl+"x0o"l"!1&uದ(z/彽 n@? WbxlUu{); P҂[0Պ[/1p`X+  14J"EksPw!{lؠ!dtrEo;Z\,Mxq|3lٽ{A&n!bibGM]X;#E?:i- DUz>H}>5HD[+*7(SSTRL@ӂM f:s &ݧWXVjBjC۲nGoWZҐ$Ko%,aAA~/);P(ͺ0m"ׂl* 5ߧdT2 ;|`XG**gK]-4i \F 񼕏Ȫ!h?3 4נcAq]^&עuq{Z^ED*j8 >2ؼτ j}Vkߏ'~/} "v|kI\xWΞLfIKpYh@VNAhBy4#NuzDl};{gu:=}99TCeڀ@P` q{a8g\PRBd4ߖ6HAkKmDDsn~W|"0A!j ǨQC» a*,xpdK⽘A0} m/}ǹ @pzyz h(3خ8۟^@= z=kѽ)_ 4x VF[Gǒ:vJ)= )B3]bB̴:DžB?#ՃŊk9x""&U^OTxxIL6%l2M-(UU!o8,@>Zwyx/*U*U؞aMXݎ\ƀ>L:ӮFAoCQk<, <A B`-ve0u_o7te{dn'V=+wp}$82a x+? "5JѢ` 4,6SXG!L8ѲDS+3Hu#nW ]ox~4x lfk΂@bB#<(VX09&9*&jޮ].yoHۭ({\js.822/O!bbI5nGkK*)Ȳ Ph<|ۖ *C'JP!P/'s)'{RfMD> gý<.IW/^z=Ӣ hƆs?vݧV߷_ #4hERuX*H"硪󐤔!'nVu 2Ɖ(nFpİƂ$j-HfGs@4k"hd :v6oތ%&Gӧq}} ΗR }$fEXzol5}}6ZЭ@I߿3]Ɲ8a<>D7N35zWUR[ ' ?=ѿӷ8yZނ|k+Ej]Lq wGđ~겪C $ſ 6&b_kđ'1J=j} cqj GWvNjZDhҧFnu*:쵈AoQb4|d4 #sڳYܿlc##GpPpE YIT#007kpp8) g:LUN|f{?ڧDGQ&|)慡0tk{kI7>&+|F-tG{f8{4b0c Rhy`×k\:~i'c}:ERiD~@0sw>iy'hڮ~xK}pסh|T;}}![#E(MV*%c!ز`P|?VݪݲMmYk{®]4±/ܙwƭ[=ܩS#27>śѶ}7^~UvH#|jؿ􃒊 IDAT׷&;}dN:at((Aö+ZpiP}i'-Sj(pY k'LT:Sgye ymQs\7k,!ĝH#avh U_8~~߾ &~_`8Tb1|wUI HR t6T.SU7 kǾ] =D50 J,В$5mRAKT~ ٰzPud Q0GU+~>ہ9~v={=  gO¦[߯].`E_/YTUNꌂ7 I ۨb]]]́>+:dV:SxsF=}Uo#hYrL\|C$ًHW8BL3VWTxZ@O5i`,U[D@ ~%JuȲf$ xYNu?kI/ٵk?v@^vS{81J((P,Q*cߦ>|S^~6\-Ncۿ[o6EÇ1::!!v)x_ayǝ:[w7l"рh,ddAz;3,;r8L<%^H5|'˖,$aId! D4g|TeUfUVszdD9Nm677R'x˗/6x>#<3ԧ>u]M qe mv 9xѬ,24b؊MXޕFcsy8ljho[6ch!3`Aެ5xKT=oZ4CL !ϣ'O`&H9;DSH7Vb1$ 0C?*U'tљcsYtkFSa ^6\MR/3gxR<3(:HX vy/QSt:x:/v\6z,_|֏͆i~w~ַp=:/T==@0~Jb"0Q^l!p+|-T(:rd!{?rPI&Vb:BE*e$@ST7|J\CzC3˓検`nF ڇ%20X[e0jW~T7e2i(=N@B4PE%IZ(4-M3:LfJ TAE8mqB?:/sJ/Bc*ҩ/2d! /@ʤuu3r<T<aIK#nh+劊~)AS%uGf4r)Q;gdNLFQ:YӺދdJ*ހ*h)܅@ $.O Tt} 0,rMfT`HUȿ/6_hm sLZ@9^|1QZ*eYSx 6>=gN]Pm}eގTЭxwؽC*o9rȪ_[(ٔ$H1zZga~c JϢěXT/FGK_z ޴iV{ի-U_P-عs'V\9R5M*>|M]Z] 5un%R"H'o`0}u|> JcO,pe˄ |;.Q*@P@uJ {N8L\kȶ,@f#ܾTC;5,$f UQ 0,]J `bpP , S>g=hb1k^'1#{[.تZV>~[YTZBF^LCv ~[<͢"~9>k#G>__Y~8|0z{{qibxx< yήk΄~@վQ=¤O+;6g3O 62и$PN8E5^Z 7i%25j)U$BW,^3!>~q hw6`jڴ#ެa+Y*8&$ENQԜGF an\ZsBϞܿO.fφpIxg5{(]TXQjEgfφ ~1SZBVH]["Y_CaMװ&%ฆoG]n֭[dO亃ۿnuؾ}ܝ0 D[kDiF-DªdBAlg0NA6x]D8d*άR[8;;wN$V8)Y؆:vG^9r;R9m[tPԑk" BPYW&Ǧ :o͢At=@IS #hX0̌M`\ $:g9#LWJ, Ҙ};i{qOf2Rh -v:(cYHS2 g(% urS?1?%U<zG&gCr,e:PB4FHIE9#ɑ rwcfM8sX_˗[E@0~,|F } y qyk Ҽ"tƠ[k}t) ,TPZURT=ЩviZ(t. ov (qx$'Q[}5/DUHs| zE^fOE) ۨ۬gX(רwـfabY}[D$Q*HV,+"41i.*p"t,X3QaY+XID'3ΔZ$bX8`dn4 9S!F@F(HkT`Ae(ΥKC !RB E Jj*t9p@v.Y$B +jaF0~ehFCRgԪlw =<5_Ne~ Lƹ08fE295{i ׋r "4‘ Է.R~BŲBs tF8#xc~LM\CϚ|r"dMm >_WO~kޏo:0r+ XLH5 R'|-'WtSsgqg1/Dt=/3lu3*FL?+]IU_ޯFJ/5~YOP.*X[]ֆ,J2$6 Lp}4 @^DZĽRB:G,__܆MK7sxܱsE5sYL4 FS\L-ʭ)*|{¨D )LY)"11s! fT/k.FJ5q'_YV"Y#d,6s^;3S?k=r>!߂=Ñ8v<^~9ӟb?޽Lv4Hq|4-xX|>$8&":p)zgNYTbKJ xzlګ+iiB€4͘T2 Zu.'bsGf]fY]`[*Jh6GJ(h 9&Lߨ!jDWk'N]:g NMPd%Jl1 O/@w-BdS y,'݆,N V΄ 8ZbC V FŽ73w`FSde:0N6r8 {H@xI?ip^ܳy⋭e*Wു*:l?~gVnT ddV܊!3Yg dRmഭ$ #w-B`|aT ~J?ز}N 7܎\/ϒT'ɺz 5&hh 5H&b&JkV# g_TP gQJ(P|hubOF)jDWuA)H1D+_WCi:I20dZS%'KEdN[G -h͞_-`,^-T&ZaPQN'UR>{b DS+R3/,FPC͞"$`z޶'p8Bˏh@[nVn-L!/Ւdi2u>y.3rO$u1 *1=s͙F#;Oa l@zwL$H$d)N9A1)A蔢:hmAue"Ufj |fu;֬^Fw|A-qB̫!9% k 9[s@ A!~J*]aؔqLWO 3z)QT/\.8S^X,݃Ą 5J <ćYB]i華@{c멊 ,^YuVnVx `,;$89Tݢ3BI! rxpF0.eum0R"@r-e(NcrчS`KkӪk#?lFh  a dB9%OԭHsˈfi{A`4Mȗ } 0a3HA#UpUoQ`yG;%T#Zxl:̓pS97Q(=?,@%)I ʔMWgt]w!;3bnσY/4& >~P2=J5Jt=dQWG ,Un'prWDcw{ P34+c|_y-'[HNMp)ʧs^;Wf~YJymSNG{{;nz~vbb N8 @8fE>G66}9;dRC.HoBaP#w (!Y,% U/T;34m%Hc5Q(PW]zW] $@H,~&l8:>\(Ư^+g0{*|O/@4)bİ /qy/tHțѹbOIqoeT F? `(™]&e~`f勯=%Ï̪+Z-p+2_@@^`~(z,7/H)a:t;im{Wꫯƙ3go|_W8aÆ x'N]ۋ͛7N*>,M#١F23Y8y+)3I)ʾ3|>kdu)ʿi?6%l IDAT4)!EH wvNZCo]ƩsjI+ջrBA{}d|'^…+E\ "~(ߴ:zy/SB%,tyKZ;q9?;C`8m3D(4;`A:RD&3鿄+ uS 'ɿ@C~7&fԷyJAUpUW,w"l6+r4רEBJ y < RJq>|F:W^Łp}!JR^xXlFFF0992ḿvqw}XbVXSNԩSR @EEv MӰk.,t2$}sog[oG}7beښmttSSShj햖X ###=lx7;`شiSca T.nxc;e?{0KLd)+(7-z=KaQP ^!;,%Z 8/“fij|:g/a)ait :)5aSBM'<,RlE8Aȣ]`8] 0U4/2Y}Ch`Ez6\Gض{A6G±̝JLax3")s ӄTd2XFE$E0M?&:QEwQ}j\Cgnd2>|O7h-W2Į]cBzacc#˴5ڂ 0::j]Ԅa{prr|>0 +WgZ.L1yEsΤ-[q3rwLN5MS4H yNV.04?bTة 8vXbIŝR_ Z4@p@,m iI̮g ; )lI+ t&"ʭѷ `J*;^u@%6fG p5byXGZ@>V&SzA-+pf ֭[qFGoo/VZW_}z+dX.\@WWcՅ_V0***`nmmC;v sر ?0:::ǦMP__|_Doo/ك 6`Ν裏H4 1P,6"M^w؏[Fv>!,n:Mx'-lkF˭VPBȌW{_b;̇r}Xu̫ψl5 kX)d2љBN5ZGdifF]e5רGH{jv$*a,B3ڬ)1objaLGRϡja(Hb4x2My^%W.CZL\C_b@s*TsB>h)kU&l|#G~ J*f9el4Ę>xXYi,8z ּ)\Z-x23h! yB .n>g]TB805U]jYQm^?Sc]1N%6eOVNR Mm5 3AӲR)W#M' ^~@EU-VH,eIvyD@4ʅ3PD:T"gI"Rra *k094C Iă KKTKg.`kj3 HIel v}yaJgd>g,>&QVEET<C߀i'MT|} U:B"1 bAcaeReE˭8]Ŝ F#V.7XsPP?xCy尵zu]ȧՆN'ڑH1,pHE"ht]ε3+k:-HRV顉jP&ڥV`eC]0@),RTUcrx  WFP{.59#fa!p&SfF20dz60G UG5{CY4鸰}iQi(/`YCcP+ t:5BASxs~2 [?oD o!呬D"eEʺ;x 4oV83A4Dg"xߓRp$RU&8uV㻱tc_NҒ1;)R @Ƙ KW1~y5mB dB22@TI,}/TuF#]ȸz ao܄yҢ14@\kuPEMe脳rTyQNzI{cxt[} ν[nفŖw_!_BhKk;EgT#~ o5RXaC 8Eꬃ6V5VhKS"NwT&NQ,"jZ&_KM1F,B,Q; 0OO => XT7pP AGD)Rڛb38i %&JPQWL2s{P h$|abtڪ-tg hf'0iDUWT]^1^`X8U3cYX86ڋQי}:(F/M>yK;H&+t+ *ȯ3Y6YRr+yڎ} G;ݷE2WXXLmm)}DNI-/ᖥbuzrڢ3N/T_)vGnm&ˢKbpVe-dh`1XU@[$;Ue `f^,+ yZ4b@iV4ҘGʮ#)nq9ʤv4ҿ6R教H$+ӗ[ͮ&38v,v>?[-ϟEݒp6&"+pl(f-yh#B:#[ /JukP0Q/=6Ufߛg\}ٞLY!2[h=~$tݎ$Z4kt1+p.)X`ת0xsy0OVYSv0'-X1~JͿ,l<Mss'U ECE*oVX$~$X $~>gD{濔yRR 3 .Fְ5G 3c$s D`8 Z:9cOA(ގ^ Lv\/ӗuN:Q[[+]x"|Im۶aÆ s_x1P [%B.?R"1kc7:eVqE(z2BW PV:=Y%RB}rz 1ZQNZkĥ{ObRdu{h]~Wh wmxԸת>Qf1زcX$%,_GY\u. b`q"ZB'1Οj] 9{.>%FEC0f'0|/^E+3hqj:G'gkm`@BM6+g`s J]dtzʂ(bݛ;bȧ5(\ƠB EhʾxA%t0ϧ2(ގqX7~r½t \, cxxŽ;TtW^y*~a9s7կ~ {hjj ###`N@͛QWWgmc&[oc5DgXTܝ% CR]T>5jڜgFG sшm[4<@uնV#u)!NoB}f-g4肓YЯSuxLCW*_rʽ!ω) aR3g8|0t yAL#kuװWF͘ R&BI9&:PQPF1).^>^T7;:]lY̨}'YHeg>ϯ͇k`h%VZ٩YU32@)~pO5NA`8w4r\E&ƒl_ }JHPFYL+ E[h'wFB{tCgaV/M#[A"\"YOS8qcccҚZ<ý 8x ;GyL[QJׇ|z O-"xnUTEֹ|{Fy6QWOUtF~sN ciܛED%@inXA99صX8b`q MYj-QxFU1(Z5f4}:C1 aF90#>3{Na}/dRW}af| Lar?K֡m#-rpK` 2[&q'+4j[>Zȼ#(  FN-tj :H~iQQx_^ x ZZZׇ{pwFGGowݻiӦH Pw8|hhhd S4y IDATGM2/tL:VOuޫDq_b.USkۆ@TE{jfqj"$^y$(Dank%@f"Oq| l5 K b< @C'$!'#G6kM9j!S$#Ķ& AZT.9ah'VM@z`76!0􆷸TR%;& F8L% 10!bALTe@ir茚Z[JX,WiXEy fԱ=U{)`{" ;4 ˄n%Ux+uR 20,"BJ İ VӸ^`(.JH1a9fc`89Υp’Pn5-y7YD/2 mkZJdp%zƤބA-S u)6+dT""S7vteC^x@{O,MpGdq2\R __7<(ZqJNU ȕDz 0MuR88(C7_UC-094Wh9 ~wnZˢf,󃇷bL4y{QJs&L:|L=8t9|(cwޤO%S(}2!ٗNq'# `)f2"EMZSS7bÆ 8p:x;D7oƿ뿢K 9}4._[oL\suuu_q%8qwuCkغu+$.^$ 㥗^M7uQřjRX+,1@9BVSYi=儕mlQj۶xt15XZ휏wĀm;HT^gH*ԢpA\_F%]PȄE,Th&aH%0;9-϶U_5ZhI*9>PC?7kP%m/'V(W)CKxƾ1e^]CeC-k194j̥Y4êRK?JQ3SݾwƢK,6tͨi2Otu)at>ypR5 m}svdA-Eutm_G@(kضmqxWk.?ǎ+i;v+|;?kcӦMH&8t8  c͚5'>h>(Lܹw}7DZpPP1WaPCfQq5L\5xi%mM3O[FZ^" 0LْV/HZ\4VmX6R)c g~x3;%{m%PфJGnTI!V0Z7U-eUr K0haBJ TyS6!X[( k`ʉQ+MOJ;oC,N,kցl*~B g:Z3M# 1ʔUNLtĻP= _.m&Y+̲m[RXv6[v-ȶ@,5Mnrϫ:0hxk]n M }zh{n-,z%yn @fY>>lUjsK4qЩ 4> ټjBXնNkq | X};ZdfB", U4/ pF%։#:)}R!e ~(M5I,?I@Z3h<|js3H~eDaxclL -\k yd[$&:'%/10[ ej^Qj*L1^<(%,ЙDgmFvzml"1}&''OQnT=}?!mmKҲ$eE͊e2iBLu1+ՆX|@6O&H` e 5v߳}K 5-4cx w  LT=@=u3SM ҁ xWk'Z;qҹRv_kho]xu݊E>\aYUm+zy!HhzԌCl;-.C'US5yxc7#Y?ƫhqyc^+UXBɌaǎQnf{sb;Bfl"Ve-lxaBwaSΜ}oLd  9[=eidAC׍Pӈ5q)E~1j6*fIKAPt{AP2Ds﷭:X B#xEsMhn^WOM3ޙ)9)ÍX3Ձ5RH< ƕ='qX 8 ttePy=[via`#Wv iL[P0G蒂PmW:cԎ"AvNЙSmweUO'Δ:#oALuGUu=\.gemWd"\>@OgVn3Ο73AĈ)`ft,S+ڒzD)DgռOҩӞT@5zfzCW0qYDH(u 燠dQη/8Oln7 î$!>tߤ񾺏lN1 CɥA9 r޶GSMШ嶣z(;mP4Ut:-DbZЩ btCg1]B *S2Ũ \.'XmC](Nֽ2'ʭfW۷طޯ`zѢ7?$::~RDtoV? @ayY3Y)5#\^V"}]|`I lF ;(k ꫩ ,J(Xh)~Cq 7vi'曬]xfڞsؾΎfh ĄB)PЌ/  @-QA|k ,bذCcxAZeCR 0waǑ5] 0vNd^NXRN TJS= CǞCJ40kZg#HhWtXPBT.YɅH2[[޽R`ݺۅU3?oB?\NODgNf' N\gjm>).5'+y+m(: RW4@j"F6(sRA6)a[Ej=}DgT u!Z([ 7tEgP7H\- US9hN pw¦Nxk}Am5Qh=;D HJhNe ^p(UKYi\? CflֈʆZC9"fE\i!_~I)L?V_(ah 2j-qT'P_j tZQϼ{+$y>nYU-R߻Ev6`aU L`J)8c~Tnቋ|"L :)*S mT$Cܧ`4iqK 6\EtBgHtϜ5f,lBj_g 躱mY v1Z˭ʭH`hXT]1K%zHTIMDlMYDH"Sѓ65LkB @`抵w / V жXDU]ϻ (#VYXCfQMCR<`!0$AՓ&r ԡOCj'/gڴ*#:(B,*lQwlYJ)0jĩPuըnkDB~r'4{̑ m<*8xHAX@,gN~̮1 /nF^`K.-tzZZz)"0G2D\ 0$ bBTA4e.u^|b.7Y2ۜoǏǑ#G0005k஻ruÇ166N|_ۋT*{3~'"R nǭS9^l%M#e2]^Ɵ[VnxGi[dNBp5k%3y m;"e)j)O]i\{ٯ{BlN\zVmډƖ8vl/?gvAL!(y#5 l!u<lX [*v+}r|0m:/`!QCNI4,!N$p (Z4qc2@(*! a$"UvUH,A?~W)Xڼ g $Pyk y[ro:x$;:maLFYZ(R7i0챂W&3Web7L3(py `h+x ߈%u{J}`<9KBoQ>0:T… F<Ǖ+W\?s8voߎ+W[O~o6.5C^l޼uuuVG;w7|Z[(1|[Ռz1l0&錺Bjd XΥ_ͣtQTg)Ų`pyDr\9Өo ٬e1gAL rnj ל.gaڥY~}TE"p(8hAUeC6 9#?W}!;!Dy8 d?2;-(L6/0\ЁdS->JD#ܽ(SP)([nvt/CmeAZ=œ}Oɾвq[( pF"ѫlɸ "7?\Ʌ[xYaCP')!3(>lXQo:[.:wwnigΜÇqa@@x9… }vd2 `ɒ%e E퓟4[كl6Z,x/} j|twy8qB݋_AOO/^|^{-)NNWf 6iF1E2gtڨ鯔V_کiHREIݕ26YhW/YC [>)䊤o487 >R2m\-[= ,B%:0p M iu6hg(Fd G+*u:-oh. há[Z:w<^HzFBmkGJ00|Y9PVKgԢ#+ڐ"Q%އNC&lwKrɲKx$z"cJ% =lbb`N#[H O@ŭsby^x(@0~ӟĉmZtww[g?ĄV|%|72͑600\.>g?CWW6oތzֆwy'>~:6-¦%H tB=(|ƌyݬфEMI=K4&8ӣr.,0lmDeW} 9KC 9~Ǐ*@-*M" Euʇ"h.VXm9Z`ش_j@P]2"΄%8c4n 2s *X=F0t`8A'c ƀT+މk_ЕsAP|nf>YӿP S갟pNzϘE-U{8ƿ{1ݽo;{zo*| ` j`80)D H -tFaj~mğٟ!2HW.SjugQ__+WwDZn:᳉DEkk+`ddZ DrJh!0 = Ѭb|6lq81 :LUe/S7t m0H$] t[!5R䁺  ?HږSS?0BRBa Zv^OW-n^ x}_?l;/^UTNX7-÷iC^A j6P︍8lNAlKkBB'{md@nTڷ3L>qxCGw4-27 fԳ" ۨ_W2Xw>p`rE Y_ !_ e$Fx*>bRιjm6֭[qF !=۷/"veEΞ=W_}պOn6?Mp]waڵGE2,b|m? KҲ\mLaQ+'FNgtΘD$,{r'93Agtn/S{#}]~tV!nA,C ]Y4Pԉ֦N|_4 `(V59pxoRF[rCpy#Guzzd:P^^PՈ)eޕn(4?`A!{'nE(iXaLC:o0L ^J{a09I?[ `/JCQb[hXG? ʔCZ1bȳ7^wϗ}n 'N೟l9Rn$*++>fF,(xghvkt]_EWMR5|{d+laI>(tP:VyHl?kdm<2SzW#u@^]T+EG'(3R}gNg)k5!g{a4ύf,N,aZQkQ@>YThE ݩV _ Rqdp85iF*(!F:P_ٌ?u@) ℛEi`vE{x[`2nÕLpP,DCp7QȾb.;6%?.iƅ_A5KR75Slٜ!h+*0442є[ !03mhh? XnK9~R[Tf6t@_ŹQNQսl˂PNfd$怖jv{AR*.Y0k^hn\;oؽ?g8/X7EaHQS-I#ؼ̫/) LB,J)E@' RJ1lvD\y'f=uL5hiWt),-WT. $1<2kQ1,ƲfDM1\} f[:!E R'Es׍fwW_0p?{otǑ^}YU^pg@. ٲC5{?9BrļČ=l5aAZԖfil \@@BuVUUyN[Y[ ޔ/{0& K\L&y#aeY;T&Iqԝg\ Gԩ.WOhRٳga0ʕ+);IM-43}ؿ?pQ| W+F#Ǽb1:L,Kض=jAKpiHhC1őtN)Ɋ^ך5˔UM(cp &g`T26׫b2|0>{''$scɔ)$BM t(x̛ !] Wms>kK|RA ޓ71P ΡlgA%l"ߩF*$\+$>wcN wO{;V6E1dž$8ݮϥ*JP%>}^|%87?+7lrRCس/kKSĎjEQz@^IiQ VWāSΡ0|!r#{!_ĜLp;ė|]|z42h2zw\xQhd%0I8<:u <q 4q(8 ʲXZnn#:1LgG  9֤h)&'%Q餐1*e1,tb"6RN$7= 2*$( ISHT)UA)s]/57Ո!>|\{>۪QT6|,T%*$(v2׈7Z䊟.agJzwâd2Q^G 1cA6bwϏmHrubxo&N&cjץC7LB{E{ l ܺu?Zz]wwr exC,qw,˄J)KBq/^ý2OWbťڻ,le{:C{<Fw|1xoF~Иg9oٲ6nZj5bqGK|WP^/Xe}͑4vglmƸ&˲RS~&G9y(KߠLYcp=lVJ]&gl9GK%S K,%0AHb+!࿸?&a^j?CuΧ_OuKZ0ef|wyߙΫj*ˢ}%@փ6GPC "mCl!p5j'p=xz>" EDH #n>D4 P庾x]I.Zvs:ʡ ~e;?{/_Vg2¶m`ͭdpС`P_|dcZAe<3l{ҢupCƩV$P ugUǩFN8 ';Ph=q~O14:;A Ae R [~z/B|CN.eC f`e׾Ϋ6g7p:e[-jCWvR-{bDmk?hB6b:}|(@tTp>ٕ߁n խ%R š{[)KbKi'}zI(C+.al+ -^KP1gA2 3H/_>ǎ^hBx9O MSXjU4ŋo߾%mزwe 1Tpuغfxdck-\ᅪ4M`0׵${N37ܑ!Kd:6R~~ J`` f/1řNjKpJ6cS \`RB P5(E>bK$Y%oyVJ\cL#J/!-8zF^z^7 m{!Qzz9$ VKzGceT)$*no,Gjngt)5qRD H ^|/ann=[E_NܦN&N [x7I՗\$肊Uw]}%Fs+ُ_7{駟Bfp8pALWv֞UL_^;z2ߋ$RݔaԨ~~~Z%@ KY҉԰3gb1{'G:d 'z,߳DAV9L1x̛!_hˠu3bC6u%<}lҌޯ:1,[+Inb[ö@83FX[2tn|w띇UV<,>E@ BqӰjbiZWL,5v{UI4ܥ KJUVe`6$wWo5knupLbFdgϞ±ciQaS &ܰv |_[^ËbP } d1Tz7&`IJVئ~oJ!Dc5!k2a#$pT2X}& 3~L)TE2t~ p #zbfJF!Pi&}}7\jgrX&%1ϚqU;jCոE qxNv#u7P;Pb&V/!yNssD "WN}V7سM1Au/IugI.M;7Qa'\;MVXVmf.zk2 r\M[??ȯ/bx$ɥy!F/A4BsMCe?O}A ͒O 50@PվTs1X̄yMx:1&,&m afTWzH⩪RߕF cmĐ?˰ 5vC;19NM UuU6$ Bᕅ~/r:ذa[G/W6+H'7٠vY予`Ō,A!Zzp IFb,7B($~iM9&b_$0[s 5S 4Ba].>CCDRS'REt җheme`!,C3o†t-0(6{=-Nž7Hd6bjbNUz{V:q˼^nKjD|Iާ'l,ӈN yeM s~m!$D}aJ[72*2$Vj{J WHU.dU͙V}iɹ7i ;tbT]ͦBaeD "W1[4c$TsES/\݀Y-4k* U&ә&-UWЗmxS`2C,~R)Em~&'ש¼\en7+??;1Pze1~D?͖! A a?8 9s ֬Wp%T*ł%igWvPwfxfv!YACOA ̻r/# ZmEy6H.2հPw͊ka[n=<"KpLmdAqaBcCs;3둹 UR(ȡ4ԩB hѝagjdFΗM‰5c}b34MVKS}~݈^f;0?1 1n1]>Z+ߵzƣfL DJ<1Ɠ07֭EaE +G `8ylUЩgCQu5E㵫W1H׮>Gann9Ѳ]/o"nw E۶2wCP es /%) aJ>_LP>2˵c#4d*h};c;KAчBbn \x?JYhAN[xnrҭޯ7ρPժb:t!eYzmR#rax8'BH !q+#*쮤Y%Jn!DP~c7l6qk[onnH;ȫVm .#]6㎯7 +W N©SB}enzحG;t댱!bfg_8)6dg d, j!!_84=s)ҧC̗ A IDATS3 /#]eݥT!/'?篁?y?<=.bݵ5FS}.Qz`wܧJ|Dٸpׇٶ$e?w3 ?Pv=T\=Kaa-SWhXN!Mr Db4,,zg[(7JREB$Xʏ~ l_ ֬eYG=$۶ klpa]ސ{:Sk:xCĎxU4*g ]xg/؜@Iܺ5IOJ `%s*y^mD?+ I JVVbVXYsmE&l8eW1()? Qgp|"\8qF|mEK,}b2Ns\y'aZ5jϗq 4sO8``߅htߏxwa<$߿#/޾^h{T 9H6-w6e3))T ۬f we2ڽTdɈ>σjdA O{Xgzbo /FP;gT?+W^g>E,I`_վW4, u\`HT)BDϵ# {jUb1_ۻ =:*m\(U'p`rF%kDgMD~NL/?'CSJhzrEo,+`u./Y։]BQ]BBjO&Mréx1*UIHRƢ  NZ$ŝ],&v]T+?e(ٻ?_zON¹ONª-aR*%dL:F Oc&lwDT'pX% a1As3K'9;PZqd+$S -[5:IvrMOg'2rSbdsd0JF4hEgI /IӬDWoh4h綍vXǸ,H1.D eh\)x?$acn bIJ|Ծ}&a^{jH<*2j{j'$^v3ޮ}{sfZR^x1.:k4IȲ 1x٢ڼ_eJ"ȪRұtHH(B UP#<|<9G,4aҴV|j塶X ŦSNt*yQM-52,>?z Xb#mu"!^\'ʹQMþ牪&`UCZ/\N xY!z(~Ks3wA`[]۵G=2ӧi<;r:XnKZ~dˡ(d ^Y~]\v羟.Hl;}X?mZ/A$>?af=,uga4Zu%*`:c pSQQϵa|(#(3\<u%_A'Jм^Բ^~.0>W,I%/*!³Dū}{KXG5[ ˯;1\5+dݼ.8!m9غf뵯n`\1?sUbzL؈ɪ=z >SCO??bcľuSD3Q* I4N X5>isU{]>f)O>>pÝkÐeSs&hgo'u]>@'Qo7QW߸ V\ .9'QZwݜT t_V-CIc%KѳWmeROWOUrMiRs MigC㶘~JALb$1L?'é5D  3P%}C2nHSP0C1c9w|GCQLĜˏNz}Of)ΡK:ThŞ< r&npѓVAUYE ^Z94aH4u}BRɢRV ϙBe̪𭕫`jz;!ɏ> { 7zTsP7o4E }2lltSgIN<^0~sw''T2eYndKA*Zj[Sf s"~D e\!>o'x Tpo+ C3󧻅 Ve.cޚuФP-5*[WU*va$˧Οl?C_i C01AF9\T9O^7g2,@߻~ڿԃܗھb> 2 W^ 5+!ɳ:˿/~õs[I V0A4zq |s|P{ّM?m{pMeROΡڲ|;a%D "@brz| = f~4k<}}j' ed+Nt%ݩpz]Z-J Q~aR[}g9_s!4'9~I o^s :__bzǠ@@ d T~ 9˨كA! Eo2(L'rΓ8Z޺.T#?B/8iQÑAƽsTҢiJɢeڈn<6v|H9a3I]gM<=CܶkN"B!!)|:Xn(kQ7W@j| z5eT%$ J55]*ѕCXz3lÅ&6%,,5T&VNP~876 ?/í/{vHK0p 4j'xFH4"ǎLƨOS QS -)Joy*t0$8Y|GѪp-[81+W)dE4ǒj~(zD*|ޯ.^w] S6![j&?Pc%قM+ҫ/xI.ebcjz8 qfot K4k mV|?8X\Ki7c0VTU-N7wx6UHs<I))Kw`nzX~kψPY nCbxga/ɍe> 1P^ġª> qN'ʜ+kloFQYo]{qǏM7}Vr-2db%b\A;͛õ^'T-ļq.dϬčX2+ws /4CYiD}֒PI gG!evUE&>9< ɥyxlOk3HR6ȧOQeOԄ;:hii95?P6Cn$x7#d$L'#?~>87[UR@X8?M2£*h* ɤ%X|M,d,n]|cL{* |kKt>]ٳّHxڮ Y&\(jazNqA*1' ]FXi V,F[L(!fEp4E8{7{պ>o!Ų^ [ ;#봹gPV륯ej?#>ڞWU¢%NŒcĹq*9~ ,\wmD "c&d$e!k^ל vpE,Kkxh]b7O#e*6cG U7,}^Sf&̇.ʐrqZmE%(1!VQ\]$-nPwKYY;dX} "[x*r =g':ηwukppL!iM<3"7TYLdJv>&I 'Pȵngʻg$9ehb!'{B!a$eݛE52?.4 I8_:Mp:~n. p,3'Ywpz<Ҵ%Sse1"M\݉h.~iW-<1ܲ_fH3 gJE^qXxq1\5'Mf%/ُœg[?{ KӍigxvUS7e/g0G~+BԺinʆnӱcמw߭D B vz(jyNsaOIk'e/`]ă8⮮ܝO,HU5Qme؟ǀF^x ɟ!&!;|gpzaT*g,U#Ceu4-}o`f*jla׉JQZiј9xU ۉ!NwW C>~G?}'!$ =cǃ{܄)' ,PM|$joZj'eijO,-|Hj`Z2BT&&2Dڈbc'B )_emUs5ЗkRz5+0{Ӛ56o)MT7c)uƟ5jjw}l'eY±c''!$!8@p+_-"gRؽs&)NYE2i:/XݤqHlCHxB]S ?mSٕxcTlq}})T-.z;ǣ΀B~Թl8*LT7|68JENڎ}:F3J O8 8sA[D GMظFظ޼Kn*;=%’'IҞ u7UĈA+ P+2tMUYURU9׎ܦsb^yo B!a +_FkD龨VX}"$fSϗ3ݕi UF[IY줇ҦKdNk\v#[IH! /`*IiPʛK,]i/CmV<0h1JE=.hBB_uP$gzW3;TKdoWd Kxƃ"AS MЧ?GG⩅#_֞u]L&6Φg*as9u3 oW2q0ygnX)j1aNb$9 3VI!$%'P;wƍH2 !j`$]2 NysgyАij] lJ&RUSp KEeR^iR{M%_N`2z\/\JmLTg!x\^GXr)a@gsAYBi/6΂;r9l6c?ֽwqBnf_Taϻ'*4T9=n\0c1g u= 1O=o1;v< "Bj"wRU(S-E٢ZMJ+f#ش* S??Ѵncs^Ckܩz7 T IDAT vU*6Ga[:i)skpЇ}aۻ(ܑR'BC18nc3q t{-<ƠyW i"|<^>yHbvYTyaqz)jUN{mw鞣F>C4c?k=R eO?&_oB kBs5m57;O 1Ԣ?͊5$[IvT N1E~BD\˦+F:<6\z Μ9V]\JTb:d&IlE 0T}c(10< ,[/3Q'6''`Xlp %@λ9ɤ"D+$@ ΃-_I*mIk+2y>d"`0|"53#☸` Fh8GH+Vb*siG9ž,o[֯X{{ Ӑd Y1 *^ W` HYE@KpCpza\_rdͷµsE#4$%x L~PGK(I4ʲV:\L&AC#*TĬυkEu %VʣK[>/4Qz ysysypE^GHLp!A] 9RAjV}:_)!WTLeSe47R7#ë<5#v9|D_IQ]}{0O-xLbV3gScݲVnF-6B=w/©-9x7l.yg+?c˽~LD)lg(F=2a2xPUz:N77K5B"B2 S#]rI7f@ٵ׿-}6Ͱ)mNLJd\W[Ix\Qռ44WԾbVg^?xEc<3x~eYeB@ʮe ܰ6Lb`Yht=k_~wCʚzfHyJ\F1f,L[F1G~ B! ŗsyӔ ; [b9eE u#x/ [ǧ'*{{I7zso:QRB!%߀]"饋.%~dESA2}K_Mˤ2(ɳ5İF<r:yUJ4Ѻ6ß( 7|ȗxf 14\ 珜gqș&Ppp c+KĎ;o=_ybB*ܔ*[) m(vb8&l?~|yA"BU|cǃA /Y1/ QB7_N*af1ρ]lGtF@J fUTIYU1,j~pr2\8z .z" I/!d 0knk]l T7\YHH;GS EUI3d<~Zd m۪&ߤ\ORr %BH \%8G4 =VG>3NK G8lGyf,ьSvEE,)|( ӿ2!grjǹ$>wfsfHﹺʠ0 1iތrw 572m/mx=K1!@@j:-I mVӏQNn zc|!ǯH"H@ BH hW#*T5pN꘨"1/p"پ0i?RX[ht:Iлd gLT=H}.gI &B{~`Q<]]wL,ӟET=1zڴA:&:"&!̀@ WzBA3.li \/Gr ĎyYfKap+&8MX$&\*HvL7&"3Nd i3UXꪍ6*&k;tަf })`S?_xBXC~n|koPSZ, 1uC]]bLs+7ߴ ':D 6~n 7gN'm-JC(rQT/Ӳ+s*_YS('a͊U [4ȴU$e q"fB"jB${ IROfOgKrП-ofZeIj-Y-_-dQL[ڕ ($Nx^~尦c(A"BP-5q\ )rkU"٥̷gM{wIJfSSq-ky:m2B$X2BZ͜sFCLC)W\ҹ^ٓاc|@D!@@B wzO"5/Iݰ.L48 mdߒ[{O۠eVŴaKڥ-Give<`tm4(J~bJs;i Oÿ'!TgA?P ;R{ zS͛w_S=x"sIWQ B!0sRQKTꥋ% XZ$V4E~eY_k" "Үu\F߰%JQYuuypn/I[ ruZ5Ÿ{ !=?w޴ AIq o^޼H~DδE߀EV)׈!$ B "*ljQ*.E`}Q؉J<˳&3zciٌmꥨMbtuu9~!Nηz^SfpuV=_~pU|5!;yx@X{/~7 !*f<Ujs?Bzz&snӦ|f|w= %WstB*ÅiKn@m/jNFhKU$}b*`4/Fu˕"qJX@aKW-X?a x껈A YİO~Ԯ _Oۂ{=_4^N+l;HBH.IM|v! ΍JJ>~{< #Vx#B!_߃~ZO- U}1ds ӫ)Hx}f*ad[ϜJ㙩ԕ9ƒQa4lI#e1JEU=hVhɡGd%?sc lpevM_ބo?[6m#C-Uع4*47ek* Rvtx9=~0wa߾=&BH !$ >> 6lVɃ4C"i["#o°9Mi=#L6")V=cX,ِM*.c6^{gP%w? ?ӡ2d#`:?v m"*Hpcdڵ3j)zFSmCH[u~;FD "4 %/~$\ܮfrf'..TP[ɟwU _ɟ=о07I:.DܥqG@eN bu˃OWa*EϽՋH&Gz/?1zMV 0Knm c(7!"H@ !$,Lr\w3Fv D^˅7RTj؇i#G! .g|6ϯ0Ti/:P7aLN0C/T{;|gJIF$ކKկzcޫ'sgU6$sm:a}}?h H :sonX4}Q/t==yG#P"!!QѼql""|!4f F +왛rrL8=s~t 3VLE9b *TMʬP а*{_Hk^a6ޫ֡-x-շ"&M 9@X(<cPET׶pZ<)&L !g &q(t4QV!&y-QSV@,*D[3`0Jz'0??Y6lcTyHө8G6{-!pBqTfӦ`&I a*x|9Xٱ)G870dg<p$L/ BD"Hiȹd$dO/4Jq>Gx yދY7od}pg:;3C+߅_uRXgBH ,}\̙eM#ݺKUeaeaf*(63 :﫦Xl 1K'26 uciM k1tÖB>e`ײEu3B1߆Q Uu5 tl}X4sǜoO>Qr)2)+@wϜ幮'Yf0(5zk"qITs'Iz?OTI&^OQ̕R eR W+P-E?ˏ}M?Kl6B_k䧹֭688.I Ie!sSJ{+`d]K#_z:vOF#kHϜS$ߵ/~ە99Q2Xw -!I{kW?~%"x%B@ ,<ܷȑ}>7_.I(T,F}oHҧEIVt.TP-=`V'da}zuǹN], IDATȚ]%U>6WI/cbFZG3T;k4Qչ3ܥ.=s}y> 6eTp}U?ҋNYvWWS޽OcUR eR -˦Ł+=of"DBƕ~}zmέ6B{*bNFR1.cPP-^@/DT# x tё P-rml`ϜZo*\+Q 7슦i3[ot` !B!#_H>C- sNLgBIot"d>sͿ?!'!2R! %]LNGaU鵓AsmewƘw|WrT{wS-!C>9~ߐcUJd@  >M(v|Uѱ50Hծ_|D$.(q}ն "YeZdj%E+#wU5iɉԯ5' #dC2`X!7MXD( B'I"6rbA)y;RϦ@Y{Yllpb].FVM0M'`~A ! @ !`{څG4׻M3!g-`0 adBw! {fK5R6i1Azm礟a^brb;.T(޶4م@)k$(uiTS/ωt =LW1H!$MpI஻X71ou U!{[ΘmevU*y2ڡާܠP"hr6GVJBc,ɉnb7 5lqT7LB[&0M߷ܦ+t`d2_)sL+IVW>e` "H )²&@hu}QM/ 7};*%}6C *k UW^'R52x w 1~`rcVT CgwS˹fc{^ud?q޿k KCx)R bVop#lp#ČK#-^ڏQZfC BȔ]z9_%(P]]/WW?D~N((Kt%',F|F=E-Y~(6в>MwTkJE(H|Bbdj.SW]޿k#*R R 0<ЯΝFsT =p1qKԅ$_ƬTK>_%|{k`Yf1Rcҝ;z3M2?x?~#NBH +?-8ztl]z̩5UmE7)ˢrMFTp(KŨyg+ V*$g3NiSra6j0ЯT(&1(|Rq~+kufJT3Q:n ;x Su }'(: "@"oطoe ;v<]kc89bO1 1-K{UшGL25_Yo䳉ϧ; M.b|$ 2?/"{;1AQUr_& L#!scxfJY7?$ev׿$!QoABg'KT2J #|vXP ;BJ 뮝2 1x, td\N=m"9a4pn$s5#G-[ߓBH ?m`]w'"c6>c>@5Gc,5"e\STѸh!chfO~v{:'c( ϽD@+Ͻ+ ^Uc-/1ϧQ 2B"Dk3[RU8d)ڷ~^x& C-* 7jIi TTL6¥l]ƕP lqTܐhTBǕƼ_έq5/nL<3pޥ|l)~Yj.YSF 5_4ƑقytUBDJC K#GhEݿ ;w>㢙EQڌZTTMgNeq+PUmL%~h^Q#lqJ4B!kb6UҦ4vU%%VbJ7D / =X I!$/m` ;!*Q CJ7AZ \碇 U.aD/0Յ_f% kzn!W%L>*5+ih{INņPg$H!$#^xO6l6lr @rREUYD'jT%Dg-R*aSQe?dرr6UNuЦH{%ͮ/*<|E+#a5%\OZ5&=깒xm8AD@ ! @ !{tpӥSLu1'Z79>BUBc1{ ]ym'_*Յ$M5_(( F;Y_Z<$҇!$x_3}M)ŧ?#:91MgB TTۨP/L{69W2b9B@2⮄(F/[z+^$w68gO7e-!Q@ zeY6cn&'z,S-k UrD6t#z\E̒Hۜ劼4lYF&|ܩgЕ2%ƮPYF,#7|z93^vvGeH$Ɍ9~5}!x㍧)CA ! @ !v^9(HE%*,h9޺Zk륰QX1%MtJQ;/c(aYBa9D." / %W]5a<dJLd0I2U8U-qhUqlt8A M7UR%J6ըljJs Z)T:XJbPV*!>ig&C۹%ϔyȲwY4^1 {p3I!$>&G$ >˰}:wAbP\ ˀnL] 7ǰy|g3:*F@aga4=iV嗪纖Pȫ}zCLt$•MI!$aسO1wu0몊3,2;Qb/vȰy\K빅 /j5U%%@d<3UeY@QL,K i6989ϴs$I^Lhz!5:$\ @X @Xx_QQ'z_"/D\lWES¼X* M8MnL?B'>,t(uTR5Wo_!}K?p*6 fSWǓ C޽D W6H!$agϟ‘#೟} ﶈnP,JF<1}r1ɧ]Y3!UD-C2mopg6AuTHݥ:)^L/}h<Fbdk^{2m{8\!s8qAU "@ ,>V M*,+zh*'c0rtfU䥊%eY}rLgREH~>v†%2R[FMPIq˝+}"+Lgu {`Ϟ?T2J \yؽW`N/46 )3c#ܥ>3T'IVm+8ݗ 1)2R'@Y/PUIi(3Zk7Y_k#-J \mQa +Jus}z"%K Ge{ͥ6E=T]'I2R0.W$*.U,+5"CYNONKM5q_kC x~TγHVH!$>ch+XFgZtH'8^9 WxnJu[92J4!4PQ=Rظ JPT3*y[ *μ?bDq{@ Zn ME4$aϬ{\=n({\;U)Q%q6]H]Jz8o]D0Wpܡ*glĐ3N=B$v)#(@xzBH ,}BH \=@pꍪwTpdи+פ~VGmUW=CФ㵓1PYɯ̉F=qA$p76BH FTsWzET  êP*oHxIdW'δU;MU4EFV*kԏ|1<`jql$, (N>o48=HHS@ ҂Q}.4i/Z|LV$%$cpvt#c7Τڕ&I*uY#>N~2\9D|d>}KA yQ(A%ՍݻvU>ŬB[ZKr( Y.( 8."b̴fSԯ4bhz|q}+ E~? {>~z@Q@ ^xO,oYnǬE/x߲>{ILl3aȒe DZtEY0!qeTQOjYJ7o;C Ba`z8M@3hf-;?8@~ZO.҈A"hm-||!}ަ՜1|gQƙNLxpO8o4A! ߓBH 2‹/)0pU|*{0e(> s HQ{0T=SHʲ\T8+d2Hm1!]{2c(pJF e*%񠷡IS~q˿2l"0Q{cF:}Vט+/e1!>ɻYF}!r %9d@XM 6pz`aIR2ol_ә0bwp2(zڿԷ~RN2Ҳ,ĉ["H% ZgBH ,}'O$ZFXbDE !1 MD SVyoaXtDQT Q\c|7•D׭~O !@  <;]! M%М;9iDe]#$7{dyghv˜Gۦ0A}!ػ{dC Mo\ǧ[V) (RmY@?""AbǮ?*Z>$⤭nBZ 2+xř3sf53c%u'sL}y>ф>B`,.g_R< IDAT՝Bl8J0Ud%f7=8 ;voڮWGp !07ފ$ĉ'ĉ#OvŤosgzR\$?|uD> e-}.^}Oun ;/|vL@_{e哸sGuU!޻ vUQ1h=tYKzG. Hd7 YvAпdզ:݅j> u-Y:q; ;yxp2wZGxBkjbpg14 kܶҧ;Apۛf} CF|q#V9H[.7͎\nvoڿ(&7QBh_Z$VHSdg=""쳏AsR(Ǐ=@Z\<gμĈ\Ptf`fM,Ɏ\ۭm\&f|F$teTG=Ǐ}iBƍݎ8}zab"юGn,fa0sG/tf(z!4_Bb#c[~H?gMLȖΤɔv41tf~\/疵Ts^;% ;WG!lvj idea#Fjr-aBͷ"I"NLŦRܯIlr?.-Q!4 f%mvchJ$髎uN~cһ 0g ! !P2 ̙V+>fz/"e!nҥ3j5+tfa 8$4mdGRWVݻ 0BhYEwNNtfb`؎ FDDKJw_Xwu'WGܽGCx@tZ:T*YX#T|B[jWG(Nf݅TZ6qdJQX\<gϾIg͛W: (+aڊaΌΝw[_L4Є<Ce~8{ a- CiAnŴ$!ƫظt6vObiA@}_{^I13нa_?9Nmƥ3cdBejBboĩSsQ$\eYC~b3Zv7az1&7޿:( !p$s''#zZHNMMf)LznOav7-yQ_+wYLV$IBVtf'fڙNUyըׯ¹ҙnm MdhgKNRҹ؎ cJa8paD;N^^_{:SSOm z{4ftQz|>ρAP#+=FP[;7/9PlF>lch`c(pാ徯M-[233ZSSSC&;"b>O=A(B(Bia&ȥѝZ'X:[O&Q<Bk\$I(&N'-Z7kBdYHӌ?3 ! !FTTdJøsPLC^}ߎ'Nf;JT*Y|G(o o }[ {Joh\.Vl•qAŀ@pע޾b+]/xP@ (FZ4bn8sf fsN\>uC0LSVE:Ջv?piɢ@ 8tkQ_:w kjwໂ zah\G>~gB(y 0M&P( !@@@@@@٩P;@LBBBBBBJI!B`B      PJzPBS;%v"B(=@ @ @ @ @ N@ &!!!!!!J@!E0!(%=Pz( !@@@@@@٩P;@LBBBBBBJI!B`B guu!VW<8j<'Of<!8 =[Щpp (@ @ @ @ @ @ B ݷ:NJ~{^ !ob G͛ތK/ !pL_>Tpnu5~׿K .=8؞m?ƫ7^ӻ~9} oF1?Dd`2/OǛߌq⥉"CW@! '$<>p0? |{v6B:8x5"{p?i @GAƕoq}zaj<~_׿""^[~DB`oL_ W.aB8A{KK?9>ַٸe01B ?n0u0\^a&@~Ýዹ1>><~\(8:2 LL(_^vbÄJxIa_/ !gLw7^w?~40!8~ꋫ߇LJn=&΄@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @  ""sIENDB`goxel-0.11.0/screenshots/screenshot-procedural-city.png000066400000000000000000003201351435762723100232540ustar00rootroot00000000000000PNG  IHDRd?gAMA asRGBtEXtSoftwaregnome-screenshot>PLTEumibEk[Uhhrrr999n}kc|ogol_goyf_ʲ{r񛯳o_Xwtqi}uitkêLtژфR~؏}vToZ[fx|IprlLtleHfPK5ltj(Frp̃Gݝt^_Ԇpq`[?{k@a!|Mv1F"c:afgfaDYT;5piKQ{auVggXSC#zddG,/_!?XIG3d#mQwnff̔wag ^3{Vu`POnTc>9(FB. ^$hpI(|uSQ';MMMjj@bY_tc\S.U3dxz#g(¯r{Ȩ41"tnN[2wab6 Z@#,b.utJmpb]xqP7Rd^BnpEh+W;Zǎk~Ff#%%#[7Rcb<[\ӔcUYVą̀ll~Ĝ*O^^_fff댆`z{ϼxww~,,,쓔DEEmmmΏYxv_lO>>|Vo233ʭKY:~LrptЏ3D.zOOycwv==oqOtM5R6/f IDATxk- g@[^7Mp1BjBNi) )7)<\tS s(.3 P v!uyD$&6Nx_mͣ-Xswc$Vx @ @9@ }-v~ ^z?\ br)V)!qf-E?SF7~/=N<c+Ů/{oe~R2D\@c>@7grp?TG ᨃ'ODs}=Jf%~S)C%#z4E+=Q&{ʁ `*p [!@ H@@ @ @  '2 [( Pz5=S3ѿ:k4Niaaiii_u{G@/BY௦[>`_K3,bP>xWp^xC5}68XXp 1nt~b@53D p~Q!2A;0Bh2a ,&G0%]#M>`@)8mYX@_^!@ 0 !,=ac A~8N C_ o& i8nNM}Lv*tAw@&>in> 8WR`vƺ%&!z%΍kZD+1m30 j@>Y'(fjzj7}J6=" -]/LB"<] @oߎ%YEؙ?(t#ػ1?Q 1vߘұ T@݈b 1<l- TU@5oE5P \;TQX(ܐ;[:/]%%*Y&?!nvPh$t`Zxx DYD[ L@q/!% ,p ĪXo f:j?Z@KKZ98,ٍ?@ժ5[nj;/IvdK X@ʴ*j)NeAp[ `*97F<' HgA0NQ=d_]ܮ k $*z\jkok{{;uu<_ qy`02X4POoMӀqoy{{[vr G+u>N x3Q:M?8,( 3B V$eөl6K\fYB ;8{^c vЖ@+@:YR\6yli|ˡm6FO*pY*b{Vx  =w@bHkH bΠ9*$J!fydsCC4٧SRCGsdH*!8L,%SBq %ߔed\m0N W-0;r%6`ko_iޡc_1OhVǘ Y^#'Syu !hX# Q&|zK6~ 6js`+Q޴2h/s}$\\Z[IҼC_Ѡ`y>mFAؘ"MQsp  _`OU]_CF pնםDU)_$%>*Z,ήPv\=BAJ.7:(rt5C=j Z50WcQ9 TP@4cxQ@(VPT y h +\-S]N |$~kˇ߱wsXp@I~t7S韞*P*+|z߿o/"+@#=g>W zM)_yq*PO6 {:& `+*[4Ϳ vtoVb!к |$oUWPK|~6<!@}k~K'ԛ6.{ 0NX[hՍ3χ,{>gϚy}Kڝ, h8)#|{ ϳnl< VI(=& vaW%n07vt@k@2{'4R5@UA+OcytO?: hsB4d 6}qC& Kj_V J(3Zgƒ$[@6JͿX @t:=m---/-cn@ttdAeyxo>`d,`o ;L  hRYel{&V"(R!KCm M'x?P*6B$ X .?ZZ hx ?."l Z;K n"Bm x/G@wƱ5S# A: {(໓Vujx/ؚ|4 O&~ =@CԿ٬s\C@i"Ћh?6I>.}x+CA/PyPP3Qe#U7/p`~okF**`~E6x !xgo8e08= ?b#l PcKS:EVD|x',$q}p' >`[`-$@O7>?-C4,DJ  ?)AJ pgo Ir- WN _:B\NJzq[N9QD?-(2 l|AÊ3@EOu`@f2!`%(wp(p uc{n_fx~~;׶,+m 0$',l Ϣ *tEQ^B3 y(dJ9 !I; ]NF`p7^/?=LǎȪ<9괂xB 9Nlc+7cp*#YZPnc5n&2! Eٰ1q)5(0R8@#@ LxLlWWy a[4@Ee1,ҭy'| )@g]G@'ڀtRq/g"͂I@%H!R\q{Tc nE~uazV+bV+=a0x'eWWVV67}_7rw;@a +-- B O=O@'eU@~z?I$>r||7NqA!ɕ @.Ҩ M$vWǤ'p@ tlx1pkuїLBߩ ۀ7xz|'$(&>b==R= 7E]ZK@<@(N08JD:9BV8 AYW[pLi j6P5M iA'އC0\";sܺU7ĵtSCa`هyw H@9!dUId٣oԷ,$0 كp`)!@ŗ:/9@ z"&:q#~׍ ]7nv8l<04~ʵx^@p`jlde/e?;]8^Q'( :`Q E*^Jl;4#;WW9#!y3@ !|E >Gt=$ug0@\.җy[ P².n LTqbxB⿖@p`x5e | Ƕkhi~%7obQCt0 I^=<;Rȓh h@DX0ʸCppϣۆ$YKeMP=zq#U T@-g`!C d$ |p0HQ~2eeQqF18B!@i'HB)C*2W?V,r_yy E@ ; IDAT.{i}Ŝw"[Grfn OuZ($cp @4z)@dvHB{Yd.rQ 0 PsV>ЗXJY ?.?e(? `y >_,D_ LhsXPC#x"F6v u sˉbC:}1m W/⛀s%xb?'n2^__k#hrbՂ@ec+%wzJ,%L[ 02|x F?>CT5HPD wYϯ GԱlC_gWf`F2Pʰx+T9kMSG\~`p8=]%@2`[rhkh>BL)[hJ\6 nR:"KKPs3!%`KSٖr%]p>]ݻd/^=t|:`T5RKS6 o9Y@BrO~ٟ/>U`p*,@r!y3x8^}I A q:fQUw>tХ*^UWqT4{Zg)r2;5ځ_YU.lU~ Ԃ-+vٌ~/S[8Pۅ r|:; \9GӹtլvOtu 9pmKݞ9k2%czž! ( @o}/ yޫq{-ZpF?V`K ONVz_A$;^O97ͮp1&7BnEWA(QJO%$8T&ee2p{{p׬6y4^Y%= Op1^&w<_&+wKǂ%.2| FJe#W=KְZZop9&@QY= Xe@&2-А ڈޯuu8Pc::oQrCĝq{ʛy@J+PhG)~R%݁հҩ3 %I(?_%w>/mtkO"*`jVPpSJnZ"ݔP,ey.SDH-DBA Z(sΜ3s&5.J>9(x>c,t)kbH_PSyP3P|xtTI Wu@0&3씰'!@Ϛ?Inƞ7姈b; e3# O&*8(Jn .40ȯDt&N'>d2L 6kfS P,AIiQNBP(KL0'~ G `4Pn4 U@?8 @N / %HLW kI8 ;(ffn 3>=u7RQeDŽjUy%I i[Q_`Bf1& 3+>N|aԧC[়/HAm;p)lE Ji eLU\rC>p' V|8']V$Nbu*ҿuɏ̑Հ7D()ڶsRTjךC98mdCyISeZ_z= |/2ފi'])QOPKl$~a vH x: -1JۑZD0 F[+RhtmbyJ]eSX_z,}(XgaFk PphGJ|k?WԤ B ɽ q@+e` PoK` F[L H:"|@e>Su>RSP`4] p1 Qzxu&"s> k | #UP .a:@vxٗA@[vaΓ`'onh#磕Jk$&vG y&zYн`uILr/01`I{ {`G)4p]FehuHl>`uʬ h7D$_=1)-8s0?? O$ڽ -Ca8U55сG/zTK6m=7,%Tg܇'- =kO]%~`S Ł `=TgŐk#v@+7A `37?7LpƦ> xwéA @ӻJ|< NŁR ^ҚۆV yH}@w0+>I| C7*.A'〼8ՀeURsާ`ڀot,r?Wa#D=Cdӭptx#b )6`sw9(p[Q_*`!x) 2w I1Zim00R`@?Ut@kv[cO TceBu\D$@KDW@E 6ɑ`uخu r) ๹9[=M@L<'8@lq? YZA,\0 Pם]mh 3 @ZM잮-p1 !rds^> л2쏺 l _C!@Y@s,H**8\VzOx#?z׭{֛,Ab۝ع`/@oUPl; (XpӁN.`@Fd. >tV.@Kz'3q&Aɩf$9wYVd*E/|@mv 7+0%sm[^,OM\sysieWp;NWvNL{|)&C~G3'.Ss$@P̯\8Cbv7psy}=.T i`Y}Hi$jELb $Ё '{sp; @{&qDPu@Ԁ7m+Jd `R (Sey̸J8>v|I =X@hxEgo  f鲏d&`r>A}m O#@RbQp~8!a=/"G6& ob.Ȼ_ V+w$]=pI)@V3jQ~ 83&f8}; 8yVW@0*Q4h F  @V0.]c*sO(B鯮@o> |G0"|1H,X5@\/5}oZ׃f6`n~p<~K/89x^PZU`); A,->@@2 *e/@VwAl,a.,VRy pv *F\ ,_Epm m`xO :9Oǹs9h8Vp @]G]py@8b ^G^#MJ6@&+A"<MF H+<;r3Hn~GlK0 Ž@`ķ(W K ` &eZymHM@Nxd-; ?J <oƋn~oU>KxA |/|{4S4NCy@ R }8 J8V `ߓ62 q޳g X_^B=WWQ 2P$;6$e"G f1-B|:ę>>d_x浍$ {p!2;LÀKd_L/D94& X !`|iuQ H̠%ڈ( 1C^ [՟jN"1~eRK}}3ϣ؁3t~`APQ9z{F/X ;UWx6W;.ǺqxxOHP8o97i(N.mcβ}3:m fl<0N ! H8 wh3,~#x *D05sD" "| q|-/PK^XzwX:  i |@XKC9`s'z}@_{ t?c$|} /_&)Ӝsrq| {"l`tn5o8娯5 u<8H2Gl!P39pw @L"(IL2DOGE ~8 ^ rp.Cahe6(0Xf^ ?9lD%w\.|CPHwy v>JhN Z;B֘],X/`^ˀ@M=G R ?M0,-AG"Ǔ|q4j E40'1uC/tiǭ q43r,ښy|7` My ׾1phT`[i\U\ѻտdgK +|, 7><(O쁞("2v4"!J$F(? _5K)`uWz[@0C .zN:kcS3HNA~³#=𰛁`6x9L"SɿW2 /1e?_rDrT2/Q?nv9e .}GI[`TI)dm$b 0\#V(48!hV&zS7F KX:V+S:QWR`՘BmN8kmnzz=NHZ)vM=aOIf~dɏL{/x2Q:7(V͓'O6)i*_0Z`!HLm*r=6c`Nnz|ҭ1rWQWn qa+@q6F5O0n  h> X?ܘzzf_>zZRi+H¿^ ԻUXxDpL1 oss)ɓ7{>g`j;P[Pǂqm6T3 pe C@ >_ۋ( {Z@&)𳿲)a$DdY/^  0f ^8tpyFû6nc-Ed"F`NB @$|[AP`7p8RzZ*x/9pc Ե+ )pr_v S+i1Á [[[8v3pkwww@,?CgHQ8Bn #8D?;0-s/4 b;PprZuu HE,=KpaP[dAT)@kNuz*Z2fjze5(v50vQx`(n`())K9_ n>`IÚ:]5x}P Փ@\/>њ*_J_,.) RLS_׍@~@f?یXf@/(&AxM;@0t)Dyٯ?@X[spT`09h56 ,78J-S IDAT)6ZΗ5 cU=nq` N (&,yh[uĦ5|xH/ %cfܑ #3}m)#|7J i)óg>|b8Zs@7~7/0.H]V- 7m^A t_Ȭ)7,6_c>nL z$g|Rh}`nd0 W 10< C<w;9[3 :Tso@(,~!h^0d*[J@Kp ^S-)O)6{djpjo;Z9V&?~>ӧ-:?./Fΐi>_YkuqKKg(nvIkTJWߕ<|7~W jY= u??ۙ}w~߷ <n+k\*divU{9a%R٩V\ߙf[tP(l8?zN @7] w@Z4`}#r~6d\ Yn bJ3_m6h ym[H^ fx5<)d j'Yj6^ D& D,f,bZFPfH &6nMw1sL;Ȗd||yRoݾ_\%?yr4/?im؎@ c_PTp D&-$p*]*qD$) z&Η0T{==@l)!Z l>k(wMi}s#I Rƚ=!`2J7P$xgo~oB UX_.(~DZ ?Q>*"Ap:vc`;—S(1pfy8,70#V#3 KMi "Cu60VZn9  |c¶;?ͦ >/ +.pc Y K  ~̧7<.Ν@C@0E"Rǧ?v>5< hXW@WzBm#8 anedSGpǞۓ>&,2F$ w0@x Xe"}xrM$ %6"Ό8:?!CvxIR^H l(JQp`@ b "'-F|29+0B, 0ұ[@ dSE?55uLDgĻ`H t~CSj' gdss ($Q?z[Ch/r4aWN p^M^G mxZ VxXpa D|~a@I'$P0RkP. <RQ\`iS>0CWEܡ(]]b0c*=pJ>M|` `Zq&1c#B3/0=E%r&)S?I$*$/]WQ k @QxAnD|&@l=w'6 Z^ ŝ?IO@@ iA ZN߬R26d)weKC<;U?D(H\;p+iy %F.\=͛_Eg`T]Eߕv318#(Jqt;8:|ZRpjuK/l I8} yDpуXvp<|X pA=Q(5b`'Or%~lVW*ZnPg> ~6^SG ` _(677mST?c*H`#P~aTyχ9?,d~R C@8Ub :v8;fڄh{4s x.<ھ[ H?7 pK1%n,EQv_@>tbqTY8'*bG@8 D)}(EBrytRn^C3h4'sOQ}gեxKPb `cT.l1yэ ppMcT(n&I~|v(Cƒ#|!h4ދ||O[XN}=QqQ~%8P1@m>~YلakA-6Ȕ&4Бl_֗-< s 8[ʱ`*m^;#0rP 8cTƊ>U?7 {'٠N~sHhyЎiଟ*f&mvT[& :wh*)+#H_.[g20ʰٸѣH0"+PqP`k) Vm L@`μe3o`2r z8@c %:n`MRKM@3ˊ>s?[]ТpȆҌh O<7, DŽaKU}CwP[e8`@0C2@K)Hf_mѕTM$ p9`@`Q\̟3`S…V-@7s՛. /}jLQ),mY \BGopgb"mIR@PL$5$ATtc L K,&e8fȠOӕGe_gZ 0N`[̵Lp=(f`% -A.\̿Od?pInll +Plmm5\_Gi0O0)C/Fo+M!*  l=8`iTo1, nk/@ ٵ{ ba0``eK [p-Vs?<&`(; ruJgf>phޑAx1~ 7@'g%6΄(4aJ|?t]Wjf3kDl7ohX$41@!c #GHC}e@㇇;;;V۵$X?DHjL@Z "H { @6PGhPNb"~2" :+ Z@:Z%m@pٙy`ёT 3s <86wCq`0[;rVXV`_V@N(J. @)ybPŰxI;-dliits˽F(`!U(3I@{@U,i<R~Li\pu8x# 569y[\cLx1g]lMF MmL p|!(.w )sguX8;Is ,*Aw/xT06Tffk@'.B e nKij ( .j] ERUZH&+ |`[8N;h$5CzU@rf0rw )Ue. HR{c*> 1t!ZQUR۾hJ-[e ' @hb\9^ {)(P b.z۟ D `F@\@j"?=&R(ӯO <0;$dssq03 `! 1&'71 F +n8i ]Ͱ7OG_T ^6߯` FLVNOnB 1o`p`)``T>$䖬U\ "gm`9`8AXzK{Ph//ա$` RVXA]``?8 %<6Ib@̯sx 쳿 `F`V0 W[0@0QpT)؀_)m:PAF@ ;++WvZmb0~n|sӆp=>4T᝼jB_E>tS/ٿ  !,+hܜq쓀C⼀GL3իЀ{*( 8B`A@TNQA2 8 m 0p$`TVpK.@M~F FjJ/$?&&)`h'μq.`I 9|݇w;,R[>ۀ*@?2wUO_e *$3 )c/`^P|?.@o9Pwj8**@`uzIP0pS zۀV 7 &d0s8=]лq}knp gPl]\"q>O tH-D‚P{X(| gg 0@vټF7rd1u`N˯|I<_220@o " AoXp+, PnùێCAZ dl+涞i(J,U Eœv H$r rr,uxdMBhDF$[صC Rj-,l+EBTCzIFK]{-KT Qy :+n@G#DY $}-t  rp3@vPށ7As` c@9m!V)?n?^hTRj2`W"&*v /zRю@ `A~TQ\@ZR j4UiiR@ly<5B ly:R5D\"NvU<yI/,xW>Qj! ǯė$T\EYdׄh*3%xƫhWi@ie< vo [x 8u)sT"P/%..?f~ojsH%~%p)(#= Ҁ$zV O@ @+j 9}!@Su(PX@vzzSOc2߉Z` z~=yߡ" @ 3VPp J _4WaVj@@"NJX @:]Y]? 02)0e0c/xJgQ.@/˂ @T8Ȥׇ6I Hw1vmED2]zU]?U-)ڕ׶{Է^W Q.zՁsR ]bȸfz꽨߼<C4"ִdU ,1_-%!2@,`9 _G/ỗh( $`@'L-Rc!xm_ 5/Xg{8^ߞΟLp#pI 3{[@Do>i_;,udc`pp} Z/8&@*Y Q1{[ IDAT`kkkΎ%H "u%@=~&0 hREzj%.)ɱ4!Q.-/&Mjn!w,g`36 ~al8ƓL`@L(nB".N{7 L=}xq]H pHX *dA2!v Rܞ%!'prҷ`UIeC nAh7)ww?FG4kR,]>P\:=?0e Ph9Q@oW_/nC_{SSތ_캟Y3_\%i *zӺg{/5_ 9lO?>T?m+|/"7=zt *vC :V':$p Za}WD^@$Q-Z Nʀ+JhvVU&H-A^Pl@[eiZ`;'e9vH `K%QJeyWRM c[U,\-Ox q1}ƞ.0f`:O ts ڿĕqZm|U z d_(jfcHrlz D2n04DfpAa [)sy[8p?mr w ^ rXtK?$Hb`=g},k{tFOcȪR `t@Ze:sRI Kd g SO(Q K \B*УB(tX+tw:|Gͼˡ5@ ?O"v1n`3&f=6y=xX = NF43qTD% BJ sX D,V/4 łzV"ii`D ɚzK &Elr}|v+oK7^MK\nq! "^`IX N3逌}?^h6] o5N$I?T&u8 LTDժ-V}t iZYB".a=X [ҨNh8yrUϞ>Y ,,/" g=K׌8 : V?$p@PT ;& DOke($d]!+#]$D\3\HN h;Cs^ʻqo%3}~ـ2O⛱ZLO@p5$ S !%E(owe-#SJG9EN5܃Gw r@"@Yf88 @/3p}1@^!L 0JD3br~u= ̻[ucz Qq]|׆A>@'H?EG] :p \pf>McIL$@S. Ph,Հ,.\x=xEJ!@^R3=\;='ĠO(l87٢i.Bwn g psD+c{ gl@߉g|>dP^\ߴ?vX a@b6_` ˯;8d`J Z K`&_Ϲq9%!{1|^'!u1hͯVsՅ d C'M66 X uX_ٞ f%sߡ܃ |\+g$ ``dW4ڲ҇ɦ3o[Y(rS }?Yһ&ݷ(bl4M}@P͑Dp&&"m9}O!A^`}]X7݉#~铰%opTti ʆnu%){NfP Z&̦ݓThŢ͆֔1#5dY[R#A`;Xs0Q@LL@ ppK5h >A؆%1>Q!>@O>) <+0wGd@3-Z"TaʤmӮ6=A8[1bvˤHPYP9ƇZj@} ĂE4@:d1` >6ږ@@6uG&eLz7(_z%Hh F +63;/=Hk-\jceiۿl̐[m P!޾@8(plS,u><{(MEz8Ȋh;f_DηdD`8HjQ0 úCr nOXpa$_-\(h.M6R r"BC Ż貋 wY8P`LtYжd$a$F`s}y$GØZ)}>>眧\XNHP*XlssC#z|Cx@FX sOGǤli&@L NO[@\)At{0 F(qhITJ(dNSpWc㄁RB?MT*KJӷT>CT fOTOĀ?j @K8 =!@:Q`D -'})^;[.3AwzY  n.z;]es^h}c`{:O%I ;0J׍Y@ `dnE06On4 Xd4i0ቁW݃0#"p DG LAF"Dg@ް$@h eew3,\?2Q )a fxe^7|7B(UlON'3LS,n:=O;ߠ6t>[rpb `XK@ c$(yQ@+[ PDQo ڀG{PYV-_H䇇Zkz<xb@Z/R`1&35t z{SS ibĜ  d< Lݩ/hr_*Y;I}MɃ@V;6AaSQ\osoFiNfࣦ@6u@j P)p:u_@XHm`X,\=i p%G ?N\kip_,S~ Ua+`+d"EtiN;0 sR¯?Y x1 K1\x 2J/" C(F]%z-Xz @r͜>@K+@N5 m8*]#TerX'2ͧ/&5n>I8p~h=8 7888 ϟg\Eb^ݻz`p{{ 9Nģ&0 0+P ÊRwUSў.?մxUd=>]x}UDLP)quZO5ؒ &(]=>B}u> `gϞyPN*)#N@( RHG JJ"\M}z^3+=@j(:E8B)|}-Xހ@mr,^ hOeBI|2@VfqPB3Û=pN qPJm%$|R.rm9WZ`HK8u0 P _!SCPDcB[p]$@VJ-, zn~pZ*:3:L&TAd뽚 R]J$Q} 'H  t@H0L`3B|Q[ ]1A"+:{iNO +'[, x;juPs/ƺ]LLpM.|%@+~o<%܏ (>+S p =Y?bپP ڭp)B@ HYbPhO"O H3PM2b`Ҫ6!ƶt;S_S^GCXSPO qD h$_ط:J{ZLRL"Q4 CWRHdO1 UL$`@+hC/`X ֫ ޽( Bc @KC}7@|ykPYzwc|  l|bU8b }B Sco.=1Qmx{I@V_ ,i?\D SlwK1  )@] `_ڡ i@@@o;$CO&6G\2=m`gk6l[|L(0O&  < 9Õ'*P~h)F=:)=F3V hj0t HK7w?hw$5 ę)V(Oe@dz3t 0D 9`7@rFǀ?{ՕqC^T8e0 d'hE$?2MXE!q_/:% v@M|D־pD5Cv--,`5C Z[7?`q=s=ݛL2E}sd@]r)Odlp6 2?4d_;Yk׮e*Z %B`@|G6G`Kw ~ T . =d(%@C.o^P P^_!~_|A}׺3RW~#9I@ Tc l{RwrRH< PxʳJ]2~=ǎݫjJf!w!c]V `'Ά@+VX(<9RQ'!hu7Z 3w+sAj Sx502J BI47CM:MP_,@gct& ]fX/@ΊmM) [Gf͒O? a,&qE`+\C"\P[ mЪ t<Uc@ !Ae 5clæS ~? l2.{T@TmVuw9%Tg֥!0!0DXkŅ6l(`/vQqcg=?Ќ]Fb"@=ٛ;U zx_`ɻ+b ?/@7dWV+(R Iɑ`g> nH$_+(P\}"b!RA6 3u贈X@L@@RM},fB.\~I 0Ic |(q#cr5 @ Fb HP[x\ $Ȓ'uEj(3ΘL ѱ~7H3x&S-]Ga!TQإ~3f4;$s{*U&i-A0T _@0x#`:!0P#PWㅭ)+:[:;@r_WמǀҩZx|[lB'WX/` A@ʚ_Z F]S܇|$sWKx u #Yܓ&0L|Jܦ@ZI7xHĮTPP.n ϿojX$Gt5g`s 3H= 7r#@, ൊSuXv @=nz,p3T@)4GOޮy)pP qh'0X@@'>L(@RwHd IDAT r.SYR *G,@ R"èIWv\as@`^jH};T" `X1Kf# ]?~|O pDe 1rS $0ps ] 4v^fa`F X,cY8@.?m ЦSJ~no>l`Т^>Lw'Ran @ X n[r_~J$@ )9)3Р8 _oг ,IatކحD OH܀j_8L  tʻ@3`=0 x z/)OxRsݗ!6c(Vȥ=?yO^y7Ct%U?@0ؗH]h@t3\6` 57P8cTr.C (QD?`nV%u2e_S` ? .׭(\ܧVp<#@0B|t`z_ @OEV4\֨|T|ԇptD 1]@̏陀D?|-_@N:dtNU>^Q<Т{~lOXb[!|00*p sQQ?I~O0jD/R[e2VM[&Z F= 쩠%V (~+X;JU PsNvJ*/RZP7 (Y^@]8=z`o Pr@$? @Xxn>]y \SP)%$a ~6 pZ p 2_`Q@zGqK@*sf.hF0;|K'TpOPح@VhY'Ő 1_`?  *" O?d @t*z- jO'?xS Q m{dY<JY (qg:k()ShGox ԩ?>g!{`NJ?V w0RvO7zss.81B2ٵ_X`Rp<~+Llnz;EA;p>z|Ft Wx@CPv)v@ g֭OuJ*v_xjsm7 NܷbjJRSx*} )[Fhji H<Pqf;p@X@Ӕ!*W^={I@C<3)+AԡR~O>!4~tU^Ï In `+2GwU0tГ'O=<(&2k oM10(0@3D-&θrĩ)di jmTe  ?.կad?9Tpm@G h?&}ܟ:eE#R*< (!t @ h(p$TAw|,wEyp)Hj `}}'~s ~pC9#2:t]TpHܓL:`V\[ӃfC )yF!(9@fitL@F=07f]:,]b $0?zį~q0!|6~b qt Z$ 1~W TN2LCF&ӕѴ2Q: e`"7AgނgFcW `p*@3P!Q !P PR?U@ @"g+)VHHYOt ^xnS98 djԄtͺ [ ӅBU\o52pj4mv/0;S-g/{y:s;瀋6@nd kj_Pi@)JD\ abc F'@Y h}S .M@8kq/]Z몜yk|j;򷟞^}J d0`۾#PB}$hƿ٨ + (?Oz@R% Yʦ@K4Y2 ijDla0{ c̹`F,>䟭 v*+HXbmp,@ ߵ `2ZP MHhr(rW{+߀rMCW |-mPV^p)/B= J_hIP)sTt}B"=8M߰Y.g`lxhi@n ݬ8,6vTB=1/U*~pf=\(S _5oN<`?<SQY?A@C/~1m 0&CfV<U\ p`tTӄA@iէ3 ,=-EGP4q/UvR09}_XYY< 뿶'LO\ ~د2uO6tfn vc\ ~u` 8EH .D ?9-ooO=pMg_@; Ec|~$s(Aǰs ') rXcmX0wrq{%0 :(S#Ó{?8 MЂ>zm%".yFVr1r=w}jUǶFO,fyZy ϣFгi  UopO(lبVCW 1s{۳%?\sct0`~AŔxp'vF\ qL [8@>=@(c"ko p{Řyzp l-PeA3-6WIvKgdWoHxVpLWxR>vov }T)/Ir퇿6BdG; I] zPx]{w}@T!HwP%FEl ~I 3`aJt}{a_ Jө%h|%(dV`Rs`y|šh ;c'ZCA @JH<ְ4MUjv7c)ZZU7G 3 ] r,_1|ϕ\  `.@89)GJ7Q䳠)X 4`G@ 39n7*+fG$( 7.9 Xp A?$ s>aPCĘ8: `*t! B ^q-`, Ӏ+>6O /:!D?G GI ޏ R4 fbtPL p< CR߂0`ǟ,ܡ* *Co0XXb(CبR A`1Gn@S7Dջ4 '6`@ֺ++Y3#xVTel +D *Qy)YBoqDx A^lvlPmUU|ȊvF<r0XI{ѹ\1Rxr՗Jӿ*{D^W99%@ zl @vJ:2NRn5Ao?8c!i@6aH \bf@e6nnmmӛ P.B1_fG#OT7P[}k:I)P懤bJCSA.@>h/}UKllO€G{߶pرX 1ߐ<wR ObGa5ᘯ_^+.Q@ 7{R}ټxU^\tRt?, aa394}t<>=y);!.ƠK7`pξA٠)?W?^}P aY{y<.X^߇ ئ4{x9mTga B0?=lt50+ 4j.Z(i9j21еhhXGSRȀKM'q`e{cX͛7 ݻ۔{?,\߁vp cD$>Bc~X`7 :ƸfWZ36ꉚ]O;ʦoPьxQ Kz(yֽO=sw cv{v p!TR  =NX`χ\ۡfȮZB wWu`l;0r f540ypnq1 ݃Q L;tP=^I`?XSQA 8YJypmMsT٧)狀9LV@eRiSABbCȓ?_w(P/fj +s%3?˭rX6H=X *Й߬lv(MPݿo7+z=}UR"*i[wMW "L.)v`(rUdY*j[W8Q8ND!Ph `Hn?i_4YÜ Ƕ `w"B~7n#ۻnCy3_/Xl]XK.EhfEgr (53`:}N YlX!3 h*;꿣n1d}@]Uof0 ݘlrU^k(Ӛb3'1T{e+J,JQREl~yA^ԫUn!&Bp( /ޏB'Ug=%b``y :uݧ\)FPdHC܅ ,H3z)pcY F;;N vmiH ._>"y^ug&Oa}:A I@: POԭ JYD+^-K} Y|@a  k!Wq RkkkY'99[^WQ qϾNЕ#CF`#DP@!@D#G>,/N ŀ9_#qB6B9}|_&|}*C2ڵ`n~&A@ Cfr`鍜gg?~86 >Ĵ@@;\ȿpQ`0`^F]@[G Z4WCHl˗!ckx %Tk{H<ښ&M=hSʀUbB xFۄ!i@01=$Qiyr٨@bPs>l]6`[U`Rebj@˝(2ӲT4!ҚMU%D,5RUHC^pY2m>B)C|k=q! >09iL?S*@pF}L,-y #@_:?ūU L; TF+C2ULV-ɬ13]1kMzhK[nߤ݃4!LK@ڑk'5[*1@`Nc#BO ?77w9ML0lW<8(@M d~d3!@be p 3Z_`hjz@Ck: J>, YISXQVם?%nIiBB7{`St&$ê]L i{b  cp-sNNNf]HJ`mu'T/ 6tL?Y^^?0P $ IDAT&VVz!Hez@ Já_esT0z47f ӄpT6ͪfUgETWm$FX_`6ɆCdLYm~0J4~xX+ `=Ǐ/^sܸ#GUo HD\U{¶J"Ns4eۦ.a,|#* $ >Vi !YMeUa DVL 60 a{p0c=>;ub, cDp9({4MPz{sc W/>}/=r(0m)R  n&ePLwsHR_&DJBBX KiN#vU2 ~K\Enve?ykLU0ǟ=uSxF`*fЇϳ{;msh &qϧ">' n[ `=`(@^'@sߑ  iB=l'qE¿ZT"X/bDe@Į%# f^ym+^H6bڞjA2]$e@8.C!U& N4 g9a o#7r "1AB&fUq T y8a%g0_zAv0!i/@X8ܨ\N$jP' U_;#03:!Эꑑx @Tu5Gfx_0T*vd//-" 8EQgBP'vwH^ H pFLH9\,S/L.5 @2-h$*>Sv$p8N[A pi+P _8)07L 49 s_e_~~\9ق20W-n3J0nnA-’ŶR(!8 RK 0- 6| gϤ\ABXcc c~s' >0Wv @tϞŦ!#ŶRB?)DW L |ȤcH"\_ϫ`b0µv7D?38?yE=t^| iN<[6 ܏zH~(ݻF  @4q!;&9 ^!ʗ ?PK<嵞jRR ㄲ jdtz/YƼ$I).s@FƎqa(g>_etȌ[GNl5  (8yQD ߸$7r p50L`L$]^'Uƭg5^7N} 0-qɏ-.7xr d'8"#.90 U AqHIǺHtꀲZɹsԟs0QQ @ 7- /G7P%f2`ݽ]CMDPR~G GP&>.HQ7ūM;(U}- `lllaaxyz0g8|7~[G/q/k[^p?E,)Qe@4_ ((jy]: P MH(PPZT']]x@*k*$aW@N~ `XTOC/ݼyA :F\t ;,7 i4 {n[4NMM/{gu=R7Ub(.\k3%RRDDD X^) &0eZX"1yԕ-.6%&tdc3/d-` y^$U58~vA^90l}>)`lm`|p)Waw{ :蟊 @`_G"0pv qm<p{W pF9€ITxjvA ~

xt֠4]`:}<:mJ?W~c @c&UDDay^>$~4)aQS"fyPҊ:&y `%  A$( _~?y(\4f%,ghz&8@1X,XG=4!!dLagL F?J$Ͼ PQ "q,"$ @Nv+~Oe HB!Pׯ?`A `'M`(PpRЎC .LG=Bz9mi[|p':eшSaLhهA b]B}O%uST-7b5 9L`*eA 0@Pp@?REOwB0%X|gL9DR Rf0Lx@oi?fF̀(dE@L/ ?da_%wlSJEDM+SB @Kk,Zl6 *I&A+ /Y(d#69TKؽ!@0NHg@[T~~:|?4b1 SYNaT'a*x1LSئp[Ipb@d4P\\ XzlBI8y (d.AUU]d?[Y` C`@͛)KXQ[/nا"  8 D;SS)ypx!ԏOXv@|a(.iQ y4$P)l `s{7wN2?A'YF }'~BHV=t&ď{k}⏑W|! Q )xrjTreBB~wrcC#@`گ.uS+S_lc^Q@d\K@@3ޢZ3^:c~RGUUA40?Үc[̊8DmV>Tm?4B~'|#OHY?'DH\! zAOH<)GQٓxXa.3.P_@R@c+J_ k A0  d/,Ė2sjJ At.|$\648pRI>R?0n";Dy?ɟ =љRyW;۷ *8֣h|b'= uۂ2dl oB,W9PaaZЅ[^@L}_"y'?gq\6X^٦m7}"[(c b# @9F pS B:=;++_ VJр8Las?WH|A (@N1`B˴ O%`q.ǃ"@Qh&\"׎DM["{,Ȭ?Fh-CT/|ON:-=R#%wZ)s9@t?> $+wuu1H< T \^$_<)weX`Au;;dA/0`/ğho۳I[SS1|fP޵kW1 RXZ y*[c苢?=N՟f?1z0^P0|< F>Vj`R(yO&4 HѲЬN ˙@sN.^ЯADG{7{::^o͹|W v3篛L#1LAgC@`?q&>:@h @W`^a T.D, $@]CV N U.cX\T@Tgw>};u|0p[Wu -B/LǴ/?@,FnPu5DQݸ=.1p@l |R:t3 XZF8t(gRD[ P :zl?9?By\FHudyNP 03&B~- X7'}I (ic wjTCB8oĸeg87ȡ3A^l*A@OF4@`pppt@ |1` "8?ZLBȯ)9~29>0*{gue|h#ūکZ 5/ 5K$! d%nJy3ıY*KTmHE4jͤYRHQQ!P> M%T@(wι/Ͻϛ_H?c;|s A.f IDAT@V;OvmӀkB  4#\z+АT8(+HEZw 6@4GOVojP$RCD |A_5xxA 9^omGƴD)|ߧ4*/1\Z:pႝ5o ^T ,/}URl~}w.K2NLJdێ͹;5=mُ/0JAP(BW[X1oF SÞ_J<{ zKQ@?1p@9wJ*V<Ex~D<r l@_'m._ds5FeJ8/Ko`C5@4З90W:`0;wszh/Nc!oY4׊0-w'TtgUo  K6>oW]nt)h`@rc~{$2Wv l ]}s{ԔR|tB0;%4F - `r`P>Sϟu߾h|Br@kavcP^u_( G(uZ6.HW0;J\Wݵ`A\$3ARf]V tb(@Ȋ=v}>..~?5W_V`YP$!GPfl5U!{ pNU](@/[eV ׿V`>]F#2DN,3nAǸ@oUle "i*jh Ub%xW $jξA] h*F)/0W>t =;;;f*ɀaZ;x5 xP)OS ja&,5#xD$F(n8~-D `O]=!` #~sL:?0X2akT*1r AH(P Ii9\ `Ɋ\a}. g!'vhj R^rr@TdT!?s2_ & K'#|>z㢐?sDNaF5V9oG7$ cKfQPfBr @UY7v2PW1s 8%o|?9 WrtTqUVe.{P@F b&XĿжq߷`#|>uA+od@4 @UAc3GFF d s0L!6{ mlkVK 2 R\xv2Hʴ) \p@vr̡o./ GT\Q@_D^ZFnD-] @L~֑ďŸ `OO\`@@fȎ#@`P4ʶ⨴t@eA) %~FNUVy() >@O44@t'{2Yb"I2KWF~1ǍwVFj(ooo'=kE b3ٻX[OmF|kC5}yN! :o&^+&@XDhrkEPOKW@9y0n@ 4,~d*ԿEqv⺥sv70% 'e:x47o|Nnˁ(Ӏkm O.xbR @@z PQ6+GيжGo/rMIɗ^/mXpiA0 r\ϊ)0 `@2 aj0MF$9p2 (>d:b'N I(7EOm 9 b}f_Nq0gG>higKK}~ +DnLOGA*j(v Pc0  .@O @,\B劀vM~Sz2YJhXdl@ܒ.c14ﴌ*f8 x499~}=~Eμp S]E@{e7N),/ "Ϡ|!"q {{zzQQ н?3E ?\{>6In OEi Onns vOF B5222 ⧼g PHG@ۀp3 @@(pPP `=z>7֏Hi0V \2%OLb .-@\M-̉tz2=ӀtdU#0;ǐײߥpԩS_h[weXH@ˁ SD#-~Qs[" ೣWXgs(*-]EW"`#\ @`'}x+-) 48@`|C0$F %&b1)r7@k[~p8ІG7ڮ_LTC.ę]q|_ 2a"f<}bRuM,&+юEp0$ln)d1 ˄ح0ӾXf{{kl[ӞyѼssϵo?J#7bOUY`P`fJCP#6oukAb&Ԅ@겏s_7 `6)L@+X[S2O٤o1Sܸ15E@= lw)H{6 J ,?N ÏR =Mx;^ξ84;-['sP'k>mv>( "f| ](|M a>Q{8xl@gp־WPN5 M_BcL߼]٦PD@eT,0ğB5 _L=HN( Q##7VxdREIEV%hD~m@U?jQ(#->AhbOSB):M`Ei?Pǥnxks'@oIR@Mm'Y LTU>{f\PЯm_Mp$?u='I_;d[@{|Rn)br8{'&@j@k.7}8?7DIk!D> Ȗ!B?X[XK95.~JtiB~W +>/}zL YB;| ί}4v.+R\qSg)˯/>8D#|lUG0:;&'ܠp.RY`xJ&GeM h p,@ĺmt/#> cG_Y8XpB-ľ?E( ?B3ܼ#3@]# &k*fܣf(",ۯsdOT~vm@ ? Cq,ɿR8lHXj0x#!Oq"T)i` $uSIZHC*0>hw "^t%G{v hp@BX  #a`@%>`mJjx:GozD~:& 5--5׎jQ> nk1+'!hD032#Z0遃F[-Q_|[(o=ߗ ]Dk A PȒjHH `0sk\ px~Hq,}g`KL͆:-~=/F-B7pH^}gt9l@'\D(~W0,a5p (G8Aڇ @k ǿcѧQ(r$A!Z(4{$h8ݙW !Ȁ_:2^@k/m\@#xvDt=@W@Ļp;4- 3f8oy-J0/ڕ#`ph ?;a#Q@8huwW | s=c.}>1?Ƅ8&8K@ŋ=]o JEadl0pPwoݲ1`Ze1G\ ֠߯L^?//$j$!dt:Ʉ̚)h1h 11*e2쮓 [ʔּFfPhb4Ȣ I#>{;f5ɮd9_!rX%O]?HS)+(bd }Ht݄8XWH E`^B:9γgA xh[|(?Zmqd10?oI kn$-RKI Nz<J qsloA$VK*[P~vGra ]vPjlyv6Օ+E`޻5|]]„[U@~v L-4 hRW)e?gᶶ8l L(k׬Z υԿ p P|? t9^JKK~/ ?ick~D}_r) $%E@0oeWE.Q@e3Ptw9pĢ >9hپgGn`H@ JXe(S Ŵq1rN] Z Bho?)p|pW8] LńۀCO`=C={~R_m zO@b/E||0K HNn{IN\R IDAT)@C::&?t& b"`96 )Yh0t8.sTRs9RWdoÌؘCbY<x(j}8G;}خvϣC> 7uY(-F'S)=8 P]8%PB"E{vDvceR@vxgٱ>rلdbGrm[ঘUd3ȑ#NykZ$ٯ2~xu#o6 nr fB`@6jLʃ (1ƿ_{`۹Jc8UxѤ D)4l EH`@:`,|`Q~!(D6[&`-(#W$j"j"H ়@i8Y^7ƿ?~nlpUUG3!ߣ:+ }[94uRqZ^4?~lr}`\|2B,075 9?=e0b- 3Ž@4 Cn;flSPޟ%WWm^* >?OsE6r^VI?g~b ?>m XR, I&e@-W5*Fr_4~x @=L@x4 =Cmf`M*VU/VL;XWqU@Y!и" z5^53ol|q7?jF 8w_$u};~b<HRE)*~_:1biۑ@91}<0i<nܹssiOac\Ɵ G8 p`Q{ 2Jn2(^s?ӧ~:wlS7ڈohݠ00$m <2} Mumݹ*`GF\0_MFy2s譱y#ÿ$C~\&kMWŀѠ~o ½X PP8lfpk!MCЫ^ tV @'<ӧ/^`p~#1KNJ8)_`_S(R $[=.#T_9GK2 !0#f%bz #)ͣtnܸ ҥg] ߿8~)[!` D|@ ~FhRtR7/!Ȁ9 ] $!@{tE7~^s P : @p9_#)x@{2P)>PEֿ\a|tɣ?\&-Ch@!%x(F`CcH_VC嵲-id1>"Ш: w`t6UnoYb)U#`ʶ(@J*_J@@0 ;U; C'N\Q?c9p\F N4+=@@QTCw󏦅Ajib u W*^ dT ~vy~+P%zYЯ1L*( pJS&w Wv JtVT6?)W#=C Ff=i28̿Is !I@@(1сiF;*@E >/}:@d?*yjp-D?\U }Q0CUM|?ZUE +S\0;%,8}ϯ15t& C3> Sp_ӛ~`' ?4@EAP.~p/V$fbڼ8j.$N<)P&R4ޚ&m.ҩDs$`ERQ%E^E )M)!-4d)lR46U*Xr~ @kz~<ӂ|h9ٲpWk@?6t΀>X[Kva pC8 @a!_=I.?_k.{af(~cEDFGi[ŋb DЃc<1kn`2 J]"@ ()D++uO ܙAWU\HdKm 9 Vc5diPtS{$7X\X?!3i}ƆF^y76|#?"]ŋ\V b@EDʴ_Ƽ !t? ?I$U!N{@( `Eɝ'=/7 }YX[SU_)NXp04 JT~X_Q $=( 8ߡ҂ǂ^ f4obXa ^ p W!Vf ?r]]r4I$xy+v PIMlmďx `^ \D"$O aļXf hAFYhÞ \TTCzW~2ٯ(!7;`,piDdڿΜvM3r){^Axr` Ah:Tlj;M7[00 RsojҽA5KR[۩SIrj)E` + 05=0k >:i! D.cN@\I(𭀑l rUȢ_`FV:t&(hR3s_Vή#3w:\8H lE?\o~p T@ pBW} oހ`%@lLKB !JH H#l O.6\ɀWFบ5eK_zΣS`nr_ <H$!RR y\XXY`?rԪr7^*(mr[@--_A _.@WE3FP!-a%E 4"ZA@Ş*󀴴q9\]- PFՔjA@2KMx@et0nNL+8^y )c >+/Jmp@x}VH'䯖Y.@Ȟ LEve&Qß+>k?Q=}0`i r t<p[ޮNe_*lu؃G3PsvrzA4 Mn5v3ȯNM ¿ʀ c3@sT =OIx6:jy}q;£ͤ}hup*:.L ţ]ۯT=@@Cx.@J(KR( x4!g_&)@PQh Iz @@* F޵؀eU R~=Akm^h 4qE fJZ O8!X> sf-P]oYu J\N&$ ,7|j!cn[wn@Ɵ@x C@+C@`pЖ0( ,W10Џ$)-*0+#SSS3W^?MsP)Ka#KhZ@h 80g>X HTr0T '^8^JRFCe۽a!۹ FdFd#HJbgȰ^,NkHT;muI&t[mEp?`ϯ99I [ד߼I[o>?+ ީh*@u$>@0ɳgO@C! U0])v<0;eYg oCWC F +TPUB(`ԩ)OPQ@K˯(N[6xm_HP JB 7Ҁmڔ J>陁P9P& `!|\'y)s6 C`[|y `:o:/Ϗ Sh0"x]H;pt܂Nʀ,p^)93O{)'`) - lRy*Һű,/gJ-gɪ:$_'Q8GnS*Toi7p>x>=dq8v!rp<=)N6/ ;e~P໻2Hǂ2nhx 0Qs/Q`, @hVaΧ!Ay5SZ1o>(t$TCЋ\OpXaEu+X)hwt`E(nM(G$5W)@@) 0R  H5~ %^(?LJ~u0:[P5te@-oM8@b`,;NQ j?1WxٳX9i2l}1P[xCT!VVF/;w@"Rw4'w,1ljpY2p k#xܩ&XBb&A@~"S >| OЈM e)0YM ,s J$i}M:cyФBCX9a,6J n@EEAcò8hlUU8 AdI6›1nMߦvMCEp2` <~R47-@ 2.Hyg|lf$%lLb@0WZ?V!ڂvaImD)0?h婁VAVP'I)v^BC(ƣGXUPpa`+@l>;<ə<)!/oa&^d.Wg2lxWWX+(Tx`!/,H+,x.1d|]"' dX= o)wǀyÀx?kd  ~<_>6@}#J /\%euP'XЯ3I\`3y\ti8Eʊ\HTdu*3蟨 pˎ=v6MDth>1 ?d=# 4Q `W%K8]" v8 3tPUjJ#^B$J:R 9x7ɤp t}U,B<P뀶_TH Zנ4n%o_.kpRF!Mx\X$> nzi*  ggkW0 G,0J  v .VKI^4c1`ac90>}yyv,_yR0uj.DR[A f75<!vK\T  $J?'݃S` 3a ^C.(0w߾sCoB}HV"3n_\|^ dH:Bl2=nj#kd(S ƣ , / .ZC H@R&p[)0=z IDAT_ 4Z ~n\]@q`Q@k.p qD#Iy /F!r'tO5@ߴǧ PU(@PBsB g$`* =2O@\/m= 3Flj>_f@<u 2.v { XF2a; )vL0 P} ]h~鿝_nlnnrLu~~uR3믯-[N65g}T/r#K2礌:|7 <&(3Ai0 0?L0V&"./wkvr\Q 8*]v51<@;rĿ7xW1*f_4PZS\t~ft?k] tAx KY`ֿ]l[;v4Ÿ\\J<e-h њciJ-1 K`,BTؤ|'G;2*(T+mߐ!]ׅc8V$k_0V>}C~u_)/<__}R>k'ݨx/0:,|Edڕ-+Z;:LϞ=}`J]sۣAξ+ X( #PMRT 0<C䇇az~ c/G"/hd0^X\\ :k! }VV{41p.8_~e?\x?T pgu]h6$=ŸX}:3?זmO= p1( ,(Rl0R"Xh2" =SMM䞩/ 3{p]'mA`R@[(`Y4h&Co@._ODF XgNp{Hᯬm~ldmy:FFFO@#]0˺UJ:&(,>-C0Qn(7?YX@rIAcLLn[t\,I\$LELD-xd!90bl1<O*E!Y] `$V@*@0 FA} |G$*0yIsd󿩅lݸc3'!>>S]=:Jfq!.3> +?|@AK: j} _F؆jN}8eaoI@A hU7R & IuD]l , n?ܟB/_ #6*LI>E)t}R'9^kδ\W uTP{ 09YSBE9TgB@$)ekϰOVPFx @QJYWZ~x<",@+mPk~ /E/@Lɿ3g1:!jAʪ̭R/~0Eyopk`CCv?p!Z MHr#0EնNbO>{eF0e@< ?`8C9?驴#3{Z#z GA1T &e417W qr+>dIŋJL#*5lWy*}ާ"T]y_>0[qbU X4ƺah.ofggkܑA+vy`끝(~(3Ȫ`@/Ea` V>dmR}RD޿џi12UPtld>yvK_ lR|@L`ə< m(Rr^N Fț?HhÆ\LY~( S<3O_M۔vc9vm0P{6э rl`VT@`L>-eq )*7Bt ) "@%0,# ʃ)?>Mpok- #N `Wz?7dp 1mrtZ5,^Y:p/(;L+CQgT _9;.r % K~j@klUĐh9N, qy2L--mH}}UG<)[_X3JSyTsL57 p+jr#Y]rZ4搹Njf QeS&P`\ " ¼s9B|@La .K9-ۣ `mvI><fa81-|[NA7PdkWxAd+b# R}D`҃[{ðmRAXTH|zk`OBr ((wcp=p~nŪvO 0vF}Kzd2VtP'|X_MƘycQ H?^{Bv_ČftOk $#c^p'I@T|M U8A_.@P1[G@O&L,khCPk>1`AbI?ѣGUaD J7DMÆdBJK_ k_-^뮻yO 9#W~<+~B9 `d`x߬c^ @/@]bp8@>yP(‚yc]g? )(' .<+(O+#Bb߾iu\ٓ_[G^-J25oxJw-'MJJUvz@j ,mW@/̀_GkяlR3/G"p06w-Ok+55ZʂM H%. %lP~k+yG<+Elh ~^ yY4FK-m ?`0,] ,S`\+@~u5 @ccԢ 3DGѨ_`οXZZ!Q-@$ 0@o_-b \}Gc@~ < ^ Wzϵ'%rC gAx*k@*5MPs4@^ eQR߯"3(nH6EG7-_պ@(DϓG{my^l\:7v~y}BieeQl;Ouv XЅ506ZS3*2Z~;;p` 1"_mX$kwp`\ `j*Q8OL ƾ2^@X#O.HA'#@o_~# IU}_E?pw N4NI Vkx$.ʥ~R@Ӏ7g g73.\y$3- 6zg]K`2h!qS}<p] j_ DwE{cG1%~g[Ix ?@'-?xۣ$N2*zu7X\7){u+X4F\G~'@'Svt~ ؽxA Ve[0`FLsSB0wky [6wKɧ1D ~Lô?Fx7={Zs irԎ#_DϞ]GhJI]@~b2 -} ٛe3Mצerc}`ah[J4e4B KD$VS|Yŕ-7,aIxT:KE!6G"Ƶ5Eĉ[-0d#a{='ɎCs'ɖp?{ot~Ŋ 3bY>pD:\:`̯R1Dw#J-E8 joYU9\윃V~l:G:P7,[5MxJs Y]U~ S_'C1r%TmzFYQT8C0:־]iدtO`9.(oÀ<)Ic|NуŁs(`(p ?S`D fh"j҉B0fK$sY#7ÇEAdoG4:Ý!ٜ(Rh2&1mF}AۻYI Hܑ` 7lP,l߷Ù 8oj}1N8P&kw%>ƒަI@gW?; D"À _tAxy4 6|8csh|wT~ll蟅#Ԙp / p۝Uk9'_LFуtHX#9@ R~3kB,Xk 7/tTN)!@ ] X4 q_*cS `ƃϷ{z<iYMHpͲBp 9}ʱ0 l jsO }d!Ip#teg?k%OwKSG.@az%%( \Mp@=(y~]梆 \;[Ӳ ?g\!hw: rc bm P,F3q@T &t"dŇ~je%0P%P#/@A-$|@l)}|m [ӿ@3x'lЋE,,~@Rp8 g c}v@7W%UlvWͬJo˿.ܨ>4>E hzC[ W!r Dʟ(D E}@,r X4m(3U,d$@?hJ2bU;CuR ~W ]Xw?c6NLj!zQ֫@,S8 g*4rHDo V878hvf?tp( 7Ww[?Ypwݹ +!YpFGɏW!zKrf/UKJҟ6M-)?e cuj),X |;qP3F֒e < ͉`4૪,鲁M$`mb;(K>x:=F>!ewn9O^id5SvNGepA8;cWɟg1&B@[oluNp񪾙R}*s88^e0vdmLRd }Kʥ@4v`Ci @L":Ck׺G$E J eڷ8D`vw Pu = B@臣_S3?SR lyw3ˁJ,c'dgU4ɀ#vkMy"MI3n EerldZavv## BОZuޑd20bI ;# mmoΡrHt J' `n{wr2}; 8]rX9@ϾճF}S$6;<*?= 3R^._S?<\^A"*A}"re; 9H=Z@v(YGn 0D 4Cj_T]]YZ'BpJ& '^Jf(C!_Ų)z4.[Z<5PԩjZdTud迪Kk>tjھ+'e} ܿ hmo٢j@yi0f2P3VcUبi`EJ__+hRm8#k $?u`_@k_q?n),ޣ5SO睻Y|5 +pm p#.Ǐv3 x$Ņ uic(6 IDAT*TVF \*XT)6'sm _ <m'7 Z.@^br@QxH|a{k/.uzIk 1Ie93^!?Up N]ȺoIS?6$+A,Bknw4dv3u釀o8D# :,%2ld IvDnf*~KX6a%Y as=sw[9ڙqƾPrSE@@ߥOXACf?X |݊-0yA "1X@ Np@:'o^^@@+eR0u~uR`@/WcXqnnbkO_7[f'u2y#DDdrkxnn$'jDکqI_y\P W(u$SWT[yuv.oYeX_/Q,8-@ ?S?ğ:\#DbJAnq1b[2g{x;`Hd0[ɺrT̘ZDp10ri@;ߺ0}6W>}ږJ#>Zٕ'ɚα 蛣.9D\tP k T9>m]9Rtvo/>ި `8`NS=GLv,.D0;+c[P'Џ4b@Z`58J?jP@N;3ip)pIߪi0'Zz{-ȀC$@:P0!|b÷Dp &;sdmo--m/-BB`>-9lU{(| Xx8"_ ck8i&u&jZ]GLQ2 i4`)161{A~]46A t T ?ɷP; +I@>  [ӁòmƟg]]]++kjN\Wrd,0m"   R`? <pYB+Cdu&_9^S3#0r`NNͯgufggG2QBP@$&dWI@֨ _YF!0 J8h4*",>ty4p4DHQ7~? sj€3ud ыA77y7N?@1(#S &Z p2 @3:& P)xb7Q.lԚ0hV91Eǁ݁u~AZT wMa/a'h?,PTK+ d.Zu8hz&+WX#˾#0;pL={xH$L`ʟF54ğ6 cR%U%`C@pIl:tԏk.U `> vema'c@eP^"zb@C/v3fmW7xPVoςF$`scG "4h3'+ 36@@b' ٿYL鬗;r 8;zV0sLB ְ8Yɫ|w od-M+ ,m٬ 晑toZ7 ;/8u U tN3a ~[a@sWB?McohH~, mUJE@b9?Ȉڧȟ0 YNJ/2?x'>p( ؔoUz;# lcazx⼏NUt,[0~kw|PL񞩽 h։@(D%Z3> "] $M@ 7E)  ZzYpO >q,G@c;cc)LJ 8:c ARYl:mtm2  +M5 7I= BZ tht㾯kquC?8PD%@t`xaC'^{/w~0  qہ= ?LϔL];F _#w$P2wci%Ⱦ9 3P4'_ L^Q/#Z[ ܶb9 ?'k\ ,Pt=c]öu\midQP.mqkM?ϝ;X5P@ߴ5P C!k Tp[WPדZ 7nxtB%@7_|ٖ--E8 7; 5C&Nt ;0|?M~_z50 n{\(CsdԀb$ʿd:@N7x30{w@%BolKAoh8֊Q@/hʀr#`TmB˷dP%nG, TȌe ?k$VuoBn2uqu -K/,t47_ ?A_9g\xORNje$С_6Cx P@8`mjb7I [`0X^R?> O +;Ц3ڤH/ ۋ ZQ+ebTUk;+vp]ul.iJD6D*n̦*hmš$]P[C(}qrs99/5ӽԘ?` #歃HIpɲm0:\!u n[mЦCGwuutux!u,Z[ijKw3`&?pPď{@`O%A* uo'?^ Y>96s0}Ƣߏ7%ee7\!,/|@I|>P@@ Ȇ\E>mlF5h;mB>Gה Tm@2/IiC~|'ammTl))~~\0mF4 _3s[jz[ @|x83/( fJKK%3O[.e~e [X@_E `SD5!l;V{OAp3<2+@|#~"lƒ}cvXD@vtCl@^:T?܈08Ze  Nx: +510WȯQbvsHB> Z (0*_WVfܭDB!V 饔/1:3>@77G.ۈdb Gp4]ʑDz T{٧f9YGZ@"; UKٵPi@xA $3.LyzB%xմ~  d/+={Ϟ='];a`ս{ƕ 2Ǐ?#-=7Jl@­~yR`$S89K ;`oLT6d?@szeOxʂ &d м$M|XϖfpNl10>_lsKW ΧR=L/<秣%_gE>G0M\Jl=50_j>8U@shSUG3-".C?Ia =Ǒ]Bl{ t/7쇴CȀu#_*m졕/5~gI_V|:TqoMd8R@жa6oMӞ?C:[=@ y_0F=~n|6 6H! ջJw;N \B&]4 =,?@sjO8X [t GBfBCE3@C㮞2T@oȑN VpEѽDۯ׍4,n8$9KSÆ)4 i@%/*ލ hF eS =ˑ>}}=Lt壵6i@%G̟ QxD.`קc("O2r`dիW@̠OSB68?a UvC7> g7nT] V R/T0.%W!/9 .L@v?m ]<50U~W8 B^: IO'`VmaP shO꯮>j&رVuߩZ t+,tY(+ⱼHo1շDK%]Ak\VU䤲1^E P!yng3fbFZaFE`҅7ovc<+3Btf,,r =M13 Bz9wߛw'9msH#ye"}w='d]@SQg1ۖ 'l|40ؓ=obpvlc `loo,[{ ,vMD?#nG 4bU^ƻ-?yg 77 p8>Wω;}xcR+Pԅ. ~y@#x'r"=x_} п_?{KGH_/m qġA iBQ_I"/t~S-7>- hB[08T~?]20{6TA] Æ }/1%/C?'N t4e݁ L N+x~ 31yݠAQÉpa_\޹s #?`<=}QZCQKFIq|<i_S~ B k:=@لaN>\ϻP(~r:>S N`5HiY&C?+"N34_^_cS>^O~xGP՟ҥ?|B1G4@$ΘS{w"w'~Nnd踿 >k8h$B ^-;7=߅п9; H؊ +J!_i=B]3痑τ} «nԡXRO~_Aw!Aڏs94JҁoO].>mo!q#ׇc T y01u$LP@jX +ʞ$pn} WGqO5N  A+ͪ'=o T*9n"@ٲ|9}aAgD?'7\hVLR(3"|bv : Wԋ@! 0,P ;Hߟƭf!;rXVPA/;x< 2 }~M_*2^f$ /X+{!Ls"(i7 xᡉ &ݻ) iEMp@'`XA@Ǟʴw.YL 8` Om>5@X*ľ73C/PrmQayǶ['qڎS :ܛNI1եi*GnO))?XJOMx9@:(c,UШR@ .> 5n! hŏ,*93q2 3 --YKt !3ES ; x<g[ -8/ `JCABbQĩ,f!$_~pa2hŲerF:^KdHdOGGd-:svo~  {"[L: hS4촦z N&P xB>O臿Ҧf(0feƤiZY_/ !>M>~@_<"P.Q^Hh0c6iO_mFYk!~''ET[@>DyA? e@ q.o7=dwn H3io2'EuD(dKqҝ#8H@_jOaD )j &|(5w@5[^m! :|~ 1b)-Af%Y$x$KKw0 Gĭ# ;+-b8PgˑHGq + jFD b_0)q~`!p+e[`@eD' R~T`}:3"$ٗ}[~LD\,tB};bf8AXY(D#0((U s++h쀭PԷmMRpHF51 rK D$_A5m TV ,Z Uj)? xPPB?a CmY` mC@WRzo$ rK &@A8BlKяݶÎEδDr fkbC';q#0v_d}A_)b?H\Ds p\o~B3#B(@(fag?]AR98Qe8O*.IFTo }xN[̥^~V1=pֺA4Z!MqM|Í b@E?: -@NA&4zdHO\³~9,mq~.hMȚE Є_lpҨP#(lWBW.UUL#TB4EL%Hj1IX4) >{k_;Aklb0`0})Q1QKN%XC@a^Yvźl'<8ـLxj|7 =I,*3" D$ GGGv,f@)ul]1yFɐo6\H*HQ!:ռLմrd` 5 !PY HPxD5*_R)hZKiQIIx,*]ze8`g_"`kPL.@QNV@Ia `Xˌa:\@{hqQCߙ_+i8Z&̧3IdKI$44 \7PD`K8WiuǴ `(`DEɒ{87W:31 NL$q*XF)+&TE-$-@T%U-lа7D" Ӷ4t}Vi6DI`˦xn [@ p@I =w'oLJ'aQ?Or?[;+\3OAeϏۿnyY=#$x례sՂ@)')` w: zi`QֻAbҦ`%7I& 4\t|ǭ!ɁGhW ILZ75 K;H8~,=8fA5Z9רu3HA z`Kpp@sZ$=}v7<0q`5 a*m7Zv;ZPP>ZH+"~p ?PlQLOp7&&`@ R8O@CPRpO7G;Kz=<3@? o=3&MOp.U% :` ̡L@Y4XT+zMuRM6F#?AT 2߾?|W.p4&œ 1Aa)੤!߯vR+% .h"R5\-֋ ~T/^'y䙭7goooo)+j!@*Nmx-0BN, P#TT3G- ,, r$ В9LF:qzc6T8zRW9"!žHH&;'>uyɭ¿J7x  f@Ņ>1!SX @[x<'V~)駟,?)hZKCłLPPA u@ĞP-4Έ4 ; Iͻ#":B~ @ٯyQ>oի`PbP@Tb@o$D~y6?mkG,/DBF] `@~_ŏ_*O/_3.=]؅1gI;+)@E] _|ILIх~>zM`=h(8L|xPQ8 F m pz_*'2rW=#00_b1|1@xÅ!X/WU#&F甇!x< (Ms|FQ9?2M/+=%n?˿8̪>6@F$ Qb]ѯe8k nϕ(N~$Ow0*{FT}(SA@9 pom/u0j4Wtذ 7pτ5trfHgGirpX -@u Z:t+#t1!߯Q@q6+UOMF-dVD r9yлs!} ?cǂ$)M&W!/T@n֬:O?EN|>b_()H U}$\(:mպ@(@IRrx. t0 "@~;~߳ÃL? IG]2j+ Z lJp#H 2HK3FclVȲ8 xeB/)ѦJ5 D@C,H;!m"^i!7#<-`sǽܪ[VfrD=:8d#ԪsN?q5Gc-"ٙ7 Ȱ.V0HOjTdfJ}h9sAԙV>x>gB/b?Eҷ{VVɛ=&^NPKJM.0TVkJ #kqhg~YL`E>z<οӭ@44(N^}/ݷ <D*6!sPD9Z?f) Gp9Y#^ uNYia. `V$ ?i#&P$lno?~ !!"ϊmj`+Z? f3n >LV깃/+Q=[}]b5ž[1p.q{Te9l8VK )Xen%U&{x"7T` aE_| ԅ@c8H㙝6n!+?S_VU}/<h>&K`Dp(S=@]aH@ʡ0mi=\ @lۈx'8)E6)@iCo@_0o+w6pucONH [e97z-.#/Noъi65*cOW T<T' "J fjͿ`t`xeM{-<\ʵ,؛1b}g[|KIm\ `8(mo[l7ŶV:r`iz0u?d`?;d< Z t(h]c ܆5Ȥ_V/ XX0`'cqҊc1!SHԹ_8 7<j~D(`9 ʝ/T\Kofe cF/$IWFK\ p-oJDi[qZQapG_0D(DB@`,1w}#o WDw~{^# *6z-'sy߫"ۿ]+7RW 8M'75h=d<4 9qEq@Zmow| kU^~-QtG0G eG&FN'g\<Ve(\xԷjU=v{8Lc#ԯ@ (NBOR,BMZSn b \0`jꀟczQzTQnδ$`~]f|[+ݮb5Dh 0v0O\GֳQ l c([4FtU IDATVe3 , /w*כ$IR5@SrzJhw6~} jG] uvY( z: $:<:.  |vu"i(- dPXC|1VpbmPֶ*lЌ=1CUèOC)WFJ\d'ȯ'~izUǭV:8ᑠ4vXj4J*.\X> )"u}-Vy Mו}*aǖe 50gIHw yGU|c{rdr~;ǭ P(9AԣDi{V)vgŊ#`t) |A(+l0{FrQ' %* ܸ%;$AQ|*$,~ y<͆_I9tj8v|:~ɼ92a{z c 0fnݵ4M5~zICjdt g(hy $:h9>"ps~\?nX3 eC1I=^߯'&$~6SLKrْZ \7+4^\\NLZOV8^mz 0:T ]l 9IX5w"p=`XWlS@hYeiXeTg8Vt喠$N }Pf8BS]9J|g,} `!@z (*Ւ_;N|bH` d3v^TPOy!0Usm:`cy7W+z\p[t2 CC>Y,1 +g30^8cX3ԿKؒ=@Z0l(9H&~c9#j|:'7]Yxa" m `^d[X@K8?(%q@ Sd32!/:xɯ-Ňz-?)x5@>OhﴞY6*@M49?%R'KU\'ޡCP\ [{ʴk3nEYeYоׂRSgo@&%)UK_̗ "G*SV-o ^_ڑ`#^I@z dF<ؿuA贵H PcYI(VOp$DA'/v FhGRjh`y"!A>6`7+M4(N'z]uVխևa.3Ӷv:s4;? ~@&0Ur€J 4@W15un5@=xzyK;Ia$ȱ 9byK?`.=TS7 c-:,t,8T!g !_SfҺ[8ݏ (P9ȩ,! 9x€M3R$w`Hȑ\uK4H`> 4?"#՗~ŀ6,t;FSP1 NT8}>Hs,lџ$ O. A R J1uftya Ki&_^d`|0|'WEZ 0_ h/(oTȫ{bނɪxܾכ.['!0Fgc4ٺ8(hx.,T} WJSF2,z4c )1† %090EKNBaW O*lH ~b@ʠ5ϏS&ѼijbNF $P@5x`@`b}1y@ϑ 4pF4FسZL0)4t#cu۳jOt.W0[5|/J;V1g h1ĸYQ@Ie,5LEt vN WL?0ʣZ)@uݓ2!kٌcLYBN!s9XD] aWeݏADTs~:zQn]FcXe3GU/( 'n@b(NGUA<1w>U `#8It4w@N8;C)@N2iV,=K /D)_")> {{f> p^,@jc,#@d遥L50a2(?/3 |%oTv (Jnː&i8`З'0 U? dKIFy` ;gp@x<)() $軅UIz ZA@YU@ fbٜA+pw@ǝ,7D/QRy-?UGD&*}@3!{Rcn zulmg`P, _ zb,;bC(<_^ @O%@t9s_"@?zBm=9$MZvC # 4- j@B5@UWA4@c1Upm57@  c{`8_pxsh=, H\)@tq"(̷ /Y\D `j,|oxzzJ 7~4e[ @1kkt H4 ֕'ND@D"Hs"0v.o寊쥉<`f8FVu9 5h+{0,e{\_w(Бi C{n4  p_Q9ЀMV:Wh +U`k&}Կ6*Z|iϼ@Wrw;&?U~AF cA܌ɾr(]^4Ԩf O(ow*o HbhԀ} qruZm4S7` ewq> /f MO !7 6"scP$ 0ߝ ~n@*p5<8 ͩZroxA1J zʹ\)@.Kf."@sQ3@1 }7$|x ʂ|P 4`A A@lX#Rj3pQ zg4dDu 0XI{QRmk)l@23wAgJ }M}*@dn9X>?I9U'T ba u, eF?4K/#pw\tDCUpYoa(h@B@EJHyjb  HN:@!5`' _?@wA-2, W7W 3-`k M ~^o4/Do:ڠȫ`'AXD5sihзj4uhL"m +vO_1X5K D0 ѐgB)`](r26^4w  9 7 _1;wM M_DF Z[LbaH>o]h>}Ԓ#F(&VW.X~@]C ! JF7 TV>b%lÐ-)0 `x~ˀ@pcRϠ G 'T DOKRJ#,E0W02̋83o Z?1@mG''O3K `Ok|}_|+ $Ru }ɧx߼Eg]I8!(+Q# 6S$d!ZNJ΃A2R$ԉ$H,-6;0LИñWՏ.S{<z}?HX?g@zD Ȁw g6`7F߼ j_Tθ8C`3ryvcfhwv(+y1P83a{@_E"` W6С!@ԙGQA d 54l 􀟒T )QF: "}<R\Kza_)GKai!!Kg19Д+1`DAidEbm| YeWՊ. =X G6x.䌠i+3y.[N7h ȅ۲zlʀo RGF=|{U f(: \(I(;!? WFtnK %FV8ˀ(5x$, ? ou@?'DM']DZW+(p"HA Than* : 'RD<>EBQC%ՂA;"&V BYP^Cim)'ksrn7_}"%[{wo1-}HKrZ2O( hƑ ݻC'gnp]|nIe#)&OR?I8&h.pe@%. HmO|,bZz߸ȦRv'Ooj!/V= pt8ʝ^ -8|m 2f`a%3n^ϫ!|?=X Q N`"d5D =̌$kRMBVز|{C_Q)}ǴS̒tm);#l,(hؔdƛݞ](Ps4C`(DWAF(!? 0 +DO444!()@?9gud4HFMڠ79RH$J@̄@@$p+<*f9yWk Nz U.bNzlz^Y'!%P2Q p|u`hArx`H*JŞ.^1`90ޞ{yqTI^34; o;1s ޘJx[P )%8F#4M/77+'qD4 hIe57`Vhl mC7mR iwd>LO9G Z8 D\hEBp.+Π~8$O^8an#G53(0[g@G' ZWa*FIDATh2xM eIR߼39%<'0] @%~YPM @g/o,%1&bX0Gtjȕ8U降R\ J"@~^Uٴle@zs|>ؗ^ !/SC^ck# w9-@FX{+9E`)ǴCҪtVW "C1 YrATJhclD,XR =RaMK(揧/\E KKw|R [ Czjvx2VtPO)H.80Ldx M6To7h 4&ILV 㣼X @tJI>z2 d0 |^ٽ:ygsaiǏײC Oi忔uqj B *`D_Ob `6ht9qͪO=bIT@#/0'one6ㄟ#ɿu~K*ṋ)#?=\k$`.@d#*vAP?~r0p++ǻ߿7O 0E^S $r /Һr ?}KjNE.0n5V[dA@/##h(b*]lnM-?$wDr&?{`6`%K :C:iAݞR>h1 1#d,% Hʀr2Rmzůda0h"Q (Ǖ\;kv>w0QPtqr;l(L֟@(2V9@b0>$)>JO{RN/܈Rryk'z^B/+xS ,9? ףsH z{V/}*@~St)Ư>@\/,0Me?^E^/e%@_KU?" "0~016[}ȗn,sP&[~7N,JƤ$/_Xчp+(0[8"ड़jjÜ;í)@hwm$Ie%  IC1P\h0"RX6`KpL9p@r .3uU{{zzl0]X;)0.$m*B@3A@k#7"u|a* ww= ~nD/ `k2PwJ>;_j mn'sCZ~ǃT( xysb"6Emߨ0V}"!(&ȷF آ\ݚ"@Ǝ &{e~0 PP%Z;KlкN믟>&o96]DkDk0 ~P.Y?; xxSLUM)%w?>k27U0ONֿbڠ?PP P4\"lp^s_C{@8 $7v*TG*D߿ tqj(Kw?ͽ>=!BTWWur3(S>t<'xC2f'OqGP, ^?~0K8@ _n8vl <\ F1p|=?0 ?["D32@lJsc %(9D`6gLXTX,OId[9D&Kcb/ tJqIzUJ#Jnu| o_{j KZ  ?q:?hBL|, np~s5ac0@I\y7..hߴx"gd k3">2gk"ې߭k!_ZƬ]4w1{2lk{(O-?F=,Y3wqB@%Wp\tJWĶk5 0@گ=@e ]zˆ}ARn[o~-0~aȷn! 6^(j x(K0/-?$~g t8X8ScNC7?18nr( lZ\3~KWF'`Oi 'p1\ˁ 5  P2`b:~XBHb{qmB`;~Z*:[~+ח &pxcX>`3F@(ׁ%ñD-%O?yP!fݦ":\:-Xj/ -Nr ʔovZ\X!(,0_/2V~Yh+|Ub)HOl@{֯-!X$_UKJΓSY mo TM1˅APE6?#pӇ'~)d;7"\5~ Yxw3EDR6k`832kc⦑_m|D~BˏEꟃaQ,2?+|U( k:U껬!4T ԭp?OdgS!ocLK8X}ـxQRޗwE8ڝZڠOC͵A| Za"`κ,q( M` c#"Yp`CpcvH0QΟDD^ _)nwXqPw|%)|724='!uO6/ هmEGUQ,>J0Ɛ2n10U1$C, _exnQv[I(/ pRP " 9)6B0QO O^++R$]\_;j*- 6mƭ' ɀ_eKi+[PlQQNk #ϑ40F/(K Bo)p X <D _l%g CUnQqB/)*6S  }*|2BKjK)*~PjR]/R( 0gۢ N<0P{>\?pޣa#гQ@`W@՜WkX 5Q@\ŁC Ҙf*4B.׆(tSWB{>F=&z` rP/s$u{a|`$ s"jܰ Vpn4.QTlp(sk[Эb$f8"ݪK!/s\!J ,;h1@֙Z L+/%X NO (Ė"oWv֖c=v?`` ?tԍ]@ߥ[ (+:pWQ@`_@HWuׂĭk_Y.8|x: Fh`KOt0qUY)s~`5EdIѦ (Kuk kV )> K&L QOԖW]zJ ip@&Z @Uέ jǾX\ 0օ|YmOεF(edH=077vivZɀ]G۩B?O޿IW`C4R*󫠀 P T)`eVMAu}?[/c,=jgIލ? ~=/ #xX%!%^sy,wt`"8x,rQʊ* :GdKlc"paa]_"ǖjA`Yθ'}},=n8TEX FFEWn{`BX;jr–*|sIIP$Jp=~I z?z@cfl@Sְ 竵$d٫X:vl6 ;F?=:!@F .EXI,? oew{l.t L+ iם*`}钿 vs"FX0'l^%Cgrq2M"oc& r7Gs+pW7_daFTt\f >[ <,uT0( hbK|fJt{Gޢ |#BI< ி4&ex)4 `Iуx@ 1t/G؂˝ҺUzTTD䐍Qrj~JP@gqX޶gllN@-yZ*SRue P2`hpeHta- ]C V_e%q#WbFIz<ſk҄ۄVГ.V9\OE`UͧUܔO3s;f TXAvszغ j.دt W(J0- sM?}Ctٳܣ'"\ymYwZO'LnN@Bc}k@@@@7|fIENDB`goxel-0.11.0/snap/000077500000000000000000000000001435762723100136625ustar00rootroot00000000000000goxel-0.11.0/snap/gui/000077500000000000000000000000001435762723100144465ustar00rootroot00000000000000goxel-0.11.0/snap/gui/goxel.desktop000066400000000000000000000003021435762723100171520ustar00rootroot00000000000000[Desktop Entry] Version=1.0 Encoding=UTF-8 Name=Goxel GenericName=Voxel graphics editor Comment=3D Voxel Editor Exec=goxel Icon=${SNAP}/icon.png Type=Application Categories=Graphics;3DGraphics; goxel-0.11.0/snap/gui/io.github.guillaumechereau.Goxel.appdata.xml000066400000000000000000000024511435762723100250700ustar00rootroot00000000000000 io.github.guillaumechereau.Goxel.desktop Goxel GPL-3.0-only CC0-1.0

Open Source 3D voxel editor Guillaume Chereau

Goxel is a 3D program that lets you create voxel volumes, a bit similar to minecraft. The code is Open Source and fully available on Github.

Features:

  • Unlimited scene size: You can create voxel images as big as you want.
  • Layers support: Decompose your image into several layers for easy editing.
  • Many export formats: Goxel can export to obj, pyl, magica voxel, png, qubicle, povray, and more.
https://github.com/guillaumechereau/goxel/raw/b06a56c3c10fa54d5616367195251d84ff95124f/screenshots/screenshot-plane.png https://goxel.xyz/ https://github.com/guillaumechereau/goxel/issues goxel-0.11.0/snap/snapcraft.yaml000066400000000000000000000012231435762723100165250ustar00rootroot00000000000000name: goxel version: git summary: Goxel. Free and Open Source 3D Voxel Editor description: | You can use goxel to create voxel graphics (3D images formed of cubes). It works on Linux, BSD, Windows and macOS. confinement: strict apps: goxel: command: desktop-launch $SNAP/goxel plugs: - x11 - opengl - home parts: goxel: after: [desktop-gtk3] source: . plugin: make build: | make release install: | cp goxel $SNAPCRAFT_PART_INSTALL cp icon.png $SNAPCRAFT_PART_INSTALL build-packages: - scons - pkg-config - libglfw3-dev - libgtk-3-dev - libpng12-dev goxel-0.11.0/src/000077500000000000000000000000001435762723100135105ustar00rootroot00000000000000goxel-0.11.0/src/action.c000066400000000000000000000050051435762723100151310ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" // Global array of actions. static action_t *g_actions = NULL; void action_register(const action_t *action, int idx) { action_t *a; assert(idx > 0 && idx < ACTION_COUNT); if (!g_actions) g_actions = calloc(ACTION_COUNT, sizeof(*g_actions)); a = &g_actions[idx]; *a = *action; a->idx = idx; assert(!a->shortcut[0]); if (a->default_shortcut) { assert(strlen(a->default_shortcut) < sizeof(a->shortcut)); strcpy(a->shortcut, a->default_shortcut); } } action_t *action_get(int idx, bool assert_exists) { action_t *action; assert(g_actions); assert(idx > 0 && idx < ACTION_COUNT); action = &g_actions[idx]; if (!action->idx && assert_exists) { LOG_E("Cannot find action %d", idx); assert(false); } return action; } action_t *action_get_by_name(const char *name) { int i; action_t *action; assert(g_actions); for (i = 0; i < ACTION_COUNT; i++) { action = &g_actions[i]; if (!action->idx) continue; if (strcmp(name, action->id) == 0) return action; } return NULL; } void actions_iter(int (*f)(action_t *action, void *user), void *user) { action_t *action; int i; for (i = 0; i < ACTION_COUNT; i++) { action = &g_actions[i]; if (!action->idx) continue; if (f(action, user)) return; } } int action_exec(const action_t *action) { assert(action); // So that we do not add undo snapshot when an action calls an other one. static int reentry = 0; if (reentry == 0 && (action->flags & ACTION_TOUCH_IMAGE)) { image_history_push(goxel.image); } reentry++; if (action->data) action->cfunc_data(action->data); else action->cfunc(); reentry--; return 0; } goxel-0.11.0/src/action.h000066400000000000000000000055631435762723100151470ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef ACTION_H #define ACTION_H #include #include #include "actions.h" #include "image.h" // #### Action ################# // We support some basic reflexion of functions. We do this by registering the // functions with the ACTION_REGISTER macro. Once a function has been // registered, it is possible to query it (action_get) and call it // (action_exec). // Check the end of image.c to see some examples. The idea is that this will // make it much easier to add meta information to functions, like // documentation, shortcuts. Also in theory this should allow to add a // scripting engine on top of goxel quite easily. // XXX: this is still pretty experimental. This might change in the future. enum { ACTION_TOUCH_IMAGE = 1 << 0, // Push the undo history. ACTION_CAN_EDIT_SHORTCUT = 1 << 2, }; // Represent an action. typedef struct action action_t; struct action { int idx; const char *id; // Globally unique id. const char *help; // Help text. int flags; const char *default_shortcut; char shortcut[8]; // Can be changed at runtime. int icon; // Optional icon id. void *data; // cfunc and csig can be used to directly call any function. union { void (*cfunc)(void); void (*cfunc_data)(void *data); }; }; void action_register(const action_t *action, int idx); action_t *action_get(int idx, bool assert_exists); action_t *action_get_by_name(const char *name); int action_exec(const action_t *action); void actions_iter(int (*f)(action_t *action, void *user), void *user); inline void action_exec2(int id) { action_exec(action_get(id, true)); } // Convenience macro to register an action from anywere in a c file. #define ACTION_REGISTER(id_, ...) \ static const action_t GOX_action_##id_ = {.id = #id_, __VA_ARGS__}; \ static void GOX_register_action_##id_(void) __attribute__((constructor)); \ static void GOX_register_action_##id_(void) { \ action_register(&GOX_action_##id_, ACTION_##id_); \ } #endif // ACTION_H goxel-0.11.0/src/actions.h000066400000000000000000000041431435762723100153230ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2020 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* * This file contains the list of all the actions, in the form of an * enum of values ACTION_. */ #ifndef ACTIONS_H #define ACTIONS_H #define X(name) ACTION_##name enum { ACTION_NULL = 0, X(layer_clear), X(img_new_layer), X(img_del_layer), X(img_move_layer_up), X(img_move_layer_down), X(img_duplicate_layer), X(img_clone_layer), X(img_unclone_layer), X(img_select_parent_layer), X(img_merge_visible_layers), X(img_new_camera), X(img_del_camera), X(img_move_camera_up), X(img_move_camera_down), X(img_image_layer_to_mesh), X(img_new_shape_layer), X(img_new_material), X(img_del_material), X(img_auto_resize), X(cut_as_new_layer), X(reset_selection), X(fill_selection), X(add_selection), X(sub_selection), X(copy), X(past), X(view_left), X(view_right), X(view_top), X(view_default), X(view_front), X(quit), X(undo), X(redo), X(toggle_mode), X(export_render_buf_to_photos), X(open), X(save_as), X(save), X(reset), X(tool_set_brush), X(tool_set_laser), X(tool_set_shape), X(tool_set_pick_color), X(tool_set_extrude), X(tool_set_plane), X(tool_set_selection), X(tool_set_fuzzy_select), X(tool_set_line), X(tool_set_move), X(export_to_photos), ACTION_COUNT }; #undef X #endif // ACTIONS_H goxel-0.11.0/src/assets.c000066400000000000000000000037371435762723100151700ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2016 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" typedef struct { const char *path; int size; const void *data __attribute__((aligned(4))); } asset_t; static asset_t ASSETS[]; // Defined in assets.inl const void *assets_get(const char *url, int *size) { int i; if (str_startswith(url, "asset://")) url += 8; // Skip asset:// for (i = 0; ASSETS[i].path; i++) { if (strcmp(ASSETS[i].path, url) == 0) { if (size) *size = ASSETS[i].size; return ASSETS[i].data; } } return NULL; } int assets_list(const char *url, void *user, int (*f)(int i, const char *path, void *user)) { int i, j = 0; for (i = 0; ASSETS[i].path; i++) { if (str_startswith(ASSETS[i].path, url)) { if (!f || f(j, ASSETS[i].path, user) == 0) j++; } } return j; } static asset_t ASSETS[] = { #include "assets/fonts.inl" #include "assets/icons.inl" #include "assets/images.inl" #include "assets/other.inl" #include "assets/palettes.inl" #include "assets/progs.inl" #include "assets/shaders.inl" #include "assets/sounds.inl" #include "assets/themes.inl" #ifdef ASSETS_EXTRA # include ASSETS_EXTRA // Allow to add custom assets at build time. #endif {}, // NULL asset at the end of the list. }; goxel-0.11.0/src/assets.h000066400000000000000000000022121435762723100151600ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef ASSETS_H #define ASSETS_H // All the assets are saved in binary directly in the code, using // tool/create_assets.py. const void *assets_get(const char *url, int *size); // List all the assets in a given asset dir. // Return the number of assets. // If f returns not 0, the asset is skipped. int assets_list(const char *url, void *user, int (*f)(int i, const char *path, void *user)); #endif // ASSETS_H goxel-0.11.0/src/assets/000077500000000000000000000000001435762723100150125ustar00rootroot00000000000000goxel-0.11.0/src/assets/fonts.inl000066400000000000000000004351531435762723100166620ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* This file is autogenerated by tools/create_assets.py */ {.path = "data/fonts/DejaVuSans-light.ttf", .size = 48104, .data = (const uint8_t[]){ 0,1,0,0,0,19,1,0,0,4,0,48,70,70,84,77,111,57,158,184,0,0,185,60,0,0,0, 28,71,68,69,70,0,151,0,38,0,0,142,160,0,0,0,40,71,80,79,83,145,118,235, 121,0,0,148,108,0,0,36,208,71,83,85,66,151,144,198,116,0,0,142,200,0,0, 5,164,77,65,84,72,166,169,146,240,0,0,185,88,0,0,2,144,79,83,47,50,89, 44,155,253,0,0,1,184,0,0,0,86,99,109,97,112,12,114,85,31,0,0,3,176,0,0, 1,170,99,118,116,32,5,122,29,125,0,0,11,112,0,0,2,2,102,112,103,109,113, 52,118,106,0,0,5,92,0,0,0,171,103,97,115,112,0,7,0,7,0,0,142,148,0,0,0, 12,103,108,121,102,63,60,141,82,0,0,14,72,0,0,66,24,104,101,97,100,17, 72,124,3,0,0,1,60,0,0,0,54,104,104,101,97,14,172,6,91,0,0,1,116,0,0,0, 36,104,109,116,120,246,246,53,200,0,0,2,16,0,0,1,160,108,111,99,97,90, 113,71,168,0,0,13,116,0,0,0,210,109,97,120,112,4,155,2,211,0,0,1,152,0, 0,0,32,110,97,109,101,31,109,77,161,0,0,80,96,0,0,61,8,112,111,115,116, 243,247,1,96,0,0,141,104,0,0,1,41,112,114,101,112,59,7,241,0,0,0,6,8,0, 0,5,104,0,1,0,0,0,2,89,153,91,114,106,154,95,15,60,245,0,31,8,0,0,0,0, 0,213,107,236,158,0,0,0,0,213,107,236,158,255,150,254,29,7,166,6,20,0, 0,0,8,0,2,0,0,0,0,0,0,0,1,0,0,7,109,254,29,0,0,8,0,255,150,255,213,7,166, 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,104,0,1,0,0,0,104,0,77,0,5,0,0,0,0,0, 2,0,16,0,153,0,8,0,0,4,21,1,235,0,0,0,0,0,1,4,14,1,144,0,5,0,0,5,51,5, 153,0,0,1,30,5,51,5,153,0,0,3,215,0,102,2,18,0,0,2,11,6,3,3,8,4,2,2,4, 231,0,110,255,210,0,253,255,10,36,96,41,4,0,32,12,80,102,69,100,0,64,0, 32,37,207,6,20,254,20,1,154,7,109,1,227,96,0,1,255,223,255,0,0,0,0,2,236, 0,68,0,0,0,0,2,170,0,0,2,139,0,0,3,53,1,53,3,174,0,197,6,180,0,158,5,23, 0,170,7,154,0,113,6,61,0,129,2,51,0,197,3,31,0,176,3,31,0,164,4,0,0,61, 6,180,0,217,2,139,0,158,2,227,0,100,2,139,0,219,2,178,0,0,5,23,0,135,5, 23,0,225,5,23,0,150,5,23,0,156,5,23,0,100,5,23,0,158,5,23,0,143,5,23,0, 168,5,23,0,139,5,23,0,129,2,178,0,240,6,180,0,217,6,180,0,217,6,180,0, 217,4,63,0,147,8,0,0,135,5,121,0,16,5,125,0,201,5,150,0,115,6,41,0,201, 5,14,0,201,4,154,0,201,6,51,0,115,6,4,0,201,2,92,0,201,2,92,255,150,5, 63,0,201,4,117,0,201,6,231,0,201,5,252,0,201,6,76,0,115,4,211,0,201,6, 76,0,115,5,143,0,201,5,20,0,135,4,227,255,250,5,219,0,178,5,121,0,16,7, 233,0,68,5,123,0,61,4,227,255,252,5,123,0,92,3,31,0,176,3,31,0,199,6,180, 0,217,4,0,255,236,4,231,0,123,5,20,0,186,4,102,0,113,5,20,0,113,4,236, 0,113,2,209,0,47,5,20,0,113,5,18,0,186,2,57,0,193,2,57,255,219,4,162,0, 186,2,57,0,193,7,203,0,186,5,18,0,186,4,229,0,113,5,20,0,186,5,20,0,113, 3,74,0,186,4,43,0,111,3,35,0,55,5,18,0,174,4,188,0,61,6,139,0,86,4,188, 0,59,4,188,0,61,4,51,0,88,5,23,1,0,5,23,1,0,8,0,1,27,4,0,0,213,4,0,0,195, 6,180,0,217,6,39,0,6,4,4,0,6,6,39,0,6,6,39,0,6,4,4,0,6,6,39,0,6,6,251, 0,112,0,0,0,3,0,0,0,3,0,0,0,28,0,1,0,0,0,0,0,164,0,3,0,1,0,0,0,28,0,4, 0,136,0,0,0,30,0,16,0,3,0,14,0,58,0,91,0,95,0,123,0,125,0,169,0,177,37, 178,37,180,37,182,37,188,37,190,37,192,37,207,255,255,0,0,0,32,0,60,0, 93,0,97,0,125,0,169,0,175,37,178,37,180,37,182,37,188,37,190,37,192,37, 207,255,255,255,227,255,226,255,225,255,224,255,223,255,180,255,175,218, 175,218,174,218,173,218,168,218,167,218,166,218,152,0,1,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,6,0,0,1,0,0,0,0,0, 0,0,1,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,3,4,5,6,7,8,9,10,11, 12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,0,30,31,32,33,34, 35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58, 59,60,61,0,62,63,64,0,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80, 81,82,83,84,85,86,87,88,89,90,91,0,92,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,95,0,0,0,0,0,0,0,93,0,0,0,0,0,0, 0,96,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,94,0,0,0,0,0,0,0,0,0,183,7,6,5,4,3,2,1,0,44,32,16,176,2,37,73,100, 176,64,81,88,32,200,89,33,45,44,176,2,37,73,100,176,64,81,88,32,200,89, 33,45,44,32,16,7,32,176,0,80,176,13,121,32,184,255,255,80,88,4,27,5,89, 176,5,28,176,3,37,8,176,4,37,35,225,32,176,0,80,176,13,121,32,184,255, 255,80,88,4,27,5,89,176,5,28,176,3,37,8,225,45,44,75,80,88,32,176,253, 69,68,89,33,45,44,176,2,37,69,96,68,45,44,75,83,88,176,2,37,176,2,37,69, 68,89,33,33,45,44,69,68,45,44,176,2,37,176,2,37,73,176,5,37,176,5,37,73, 96,176,32,99,104,32,138,16,138,35,58,138,16,101,58,45,0,184,2,128,64,255, 251,254,3,250,20,3,249,37,3,248,50,3,247,150,3,246,14,3,245,254,3,244, 254,3,243,37,3,242,14,3,241,150,3,240,37,3,239,138,65,5,239,254,3,238, 150,3,237,150,3,236,250,3,235,250,3,234,254,3,233,58,3,232,66,3,231,254, 3,230,50,3,229,228,83,5,229,150,3,228,138,65,5,228,83,3,227,226,47,5,227, 250,3,226,47,3,225,254,3,224,254,3,223,50,3,222,20,3,221,150,3,220,254, 3,219,18,3,218,125,3,217,187,3,216,254,3,214,138,65,5,214,125,3,213,212, 71,5,213,125,3,212,71,3,211,210,27,5,211,254,3,210,27,3,209,254,3,208, 254,3,207,254,3,206,254,3,205,150,3,204,203,30,5,204,254,3,203,30,3,202, 50,3,201,254,3,198,133,17,5,198,28,3,197,22,3,196,254,3,195,254,3,194, 254,3,193,254,3,192,254,3,191,254,3,190,254,3,189,254,3,188,254,3,187, 254,3,186,17,3,185,134,37,5,185,254,3,184,183,187,5,184,254,3,183,182, 93,5,183,187,3,183,128,4,182,181,37,5,182,93,64,255,3,182,64,4,181,37, 3,180,254,3,179,150,3,178,254,3,177,254,3,176,254,3,175,254,3,174,100, 3,173,14,3,172,171,37,5,172,100,3,171,170,18,5,171,37,3,170,18,3,169,138, 65,5,169,250,3,168,254,3,167,254,3,166,254,3,165,18,3,164,254,3,163,162, 14,5,163,50,3,162,14,3,161,100,3,160,138,65,5,160,150,3,159,254,3,158, 157,12,5,158,254,3,157,12,3,156,155,25,5,156,100,3,155,154,16,5,155,25, 3,154,16,3,153,10,3,152,254,3,151,150,13,5,151,254,3,150,13,3,149,138, 65,5,149,150,3,148,147,14,5,148,40,3,147,14,3,146,250,3,145,144,187,5, 145,254,3,144,143,93,5,144,187,3,144,128,4,143,142,37,5,143,93,3,143,64, 4,142,37,3,141,254,3,140,139,46,5,140,254,3,139,46,3,138,134,37,5,138, 65,3,137,136,11,5,137,20,3,136,11,3,135,134,37,5,135,100,3,134,133,17, 5,134,37,3,133,17,3,132,254,3,131,130,17,5,131,254,3,130,17,3,129,254, 3,128,254,3,127,254,3,64,255,126,125,125,5,126,254,3,125,125,3,124,100, 3,123,84,21,5,123,37,3,122,254,3,121,254,3,120,14,3,119,12,3,118,10,3, 117,254,3,116,250,3,115,250,3,114,250,3,113,250,3,112,254,3,111,254,3, 110,254,3,108,33,3,107,254,3,106,17,66,5,106,83,3,105,254,3,104,125,3, 103,17,66,5,102,254,3,101,254,3,100,254,3,99,254,3,98,254,3,97,58,3,96, 250,3,94,12,3,93,254,3,91,254,3,90,254,3,89,88,10,5,89,250,3,88,10,3,87, 22,25,5,87,50,3,86,254,3,85,84,21,5,85,66,3,84,21,3,83,1,16,5,83,24,3, 82,20,3,81,74,19,5,81,254,3,80,11,3,79,254,3,78,77,16,5,78,254,3,77,16, 3,76,254,3,75,74,19,5,75,254,3,74,73,16,5,74,19,3,73,29,13,5,73,16,3,72, 13,3,71,254,3,70,150,3,69,150,3,68,254,3,67,2,45,5,67,250,3,66,187,3,65, 75,3,64,254,3,63,254,3,62,61,18,5,62,20,3,61,60,15,5,61,18,3,60,59,13, 5,60,64,255,15,3,59,13,3,58,254,3,57,254,3,56,55,20,5,56,250,3,55,54,16, 5,55,20,3,54,53,11,5,54,16,3,53,11,3,52,30,3,51,13,3,50,49,11,5,50,254, 3,49,11,3,48,47,11,5,48,13,3,47,11,3,46,45,9,5,46,16,3,45,9,3,44,50,3, 43,42,37,5,43,100,3,42,41,18,5,42,37,3,41,18,3,40,39,37,5,40,65,3,39,37, 3,38,37,11,5,38,15,3,37,11,3,36,254,3,35,254,3,34,15,3,33,1,16,5,33,18, 3,32,100,3,31,250,3,30,29,13,5,30,100,3,29,13,3,28,17,66,5,28,254,3,27, 250,3,26,66,3,25,17,66,5,25,254,3,24,100,3,23,22,25,5,23,254,3,22,1,16, 5,22,25,3,21,254,3,20,254,3,19,254,3,18,17,66,5,18,254,3,17,2,45,5,17, 66,3,16,125,3,15,100,3,14,254,3,13,12,22,5,13,254,3,12,1,16,5,12,22,3, 11,254,3,10,16,3,9,254,3,8,2,45,5,8,254,3,7,20,3,6,100,3,4,1,16,5,4,254, 3,64,21,3,2,45,5,3,254,3,2,1,16,5,2,45,3,1,16,3,0,254,3,1,184,1,100,133, 141,1,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,0, 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43, 43,43,43,43,43,43,43,43,43,43,43,43,43,29,1,53,0,184,0,203,0,203,0,193, 0,170,0,156,1,166,0,184,0,102,0,0,0,113,0,203,0,160,2,178,0,133,0,117, 0,184,0,195,1,203,1,137,2,45,0,203,0,166,0,240,0,211,0,170,0,135,0,203, 3,170,4,0,1,74,0,51,0,203,0,0,0,217,5,2,0,244,1,84,0,180,0,156,1,57,1, 20,1,57,7,6,4,0,4,78,4,180,4,82,4,184,4,231,4,205,0,55,4,115,4,205,4,96, 4,115,1,51,3,162,5,86,5,166,5,86,5,57,3,197,2,18,0,201,0,31,0,184,1,223, 0,115,0,186,3,233,3,51,3,188,4,68,4,14,0,223,3,205,3,170,0,229,3,170,4, 4,0,0,0,203,0,143,0,164,0,123,0,184,0,20,1,111,0,127,2,123,2,82,0,143, 0,199,5,205,0,154,0,154,0,111,0,203,0,205,1,158,1,211,0,240,0,186,1,131, 0,213,0,152,3,4,2,72,0,158,1,213,0,193,0,203,0,246,0,131,3,84,2,127,0, 0,3,51,2,102,0,211,0,199,0,164,0,205,0,143,0,154,0,115,4,0,5,213,1,10, 0,254,2,43,0,164,0,180,0,156,0,0,0,98,0,156,0,0,0,29,3,45,5,213,5,213, 5,213,5,240,0,127,0,123,0,84,0,164,6,184,6,20,7,35,1,211,0,184,0,203,0, 166,1,195,1,236,6,147,0,160,0,211,3,92,3,113,3,219,1,133,4,35,4,168,4, 72,0,143,1,57,1,20,1,57,3,96,0,143,5,213,1,154,6,20,7,35,6,102,1,121,4, 96,4,96,4,96,4,123,0,156,0,0,2,119,4,96,1,170,0,233,4,96,7,98,0,123,0, 197,0,127,2,123,0,0,0,180,2,82,5,205,0,102,0,188,0,102,0,119,6,16,0,205, 1,59,1,133,3,137,0,143,0,123,0,0,0,29,0,205,7,74,4,47,0,156,0,156,0,0, 7,125,0,111,0,0,0,111,3,53,0,106,0,111,0,123,0,174,0,178,0,45,3,150,0, 143,2,123,0,246,0,131,3,84,6,55,5,246,0,143,0,156,4,225,2,102,0,143,1, 141,2,246,0,205,3,68,0,41,0,102,4,238,0,115,0,0,20,0,0,150,0,68,5,17,0, 0,0,0,0,44,0,44,0,44,0,44,0,94,0,148,1,0,1,172,2,64,3,116,3,158,3,214, 4,2,4,80,4,122,4,150,4,172,4,192,4,230,5,40,5,96,5,224,6,84,6,178,7,18, 7,126,7,196,8,46,8,152,8,184,8,244,9,22,9,82,9,190,10,126,10,252,11,84, 11,160,11,224,12,16,12,58,12,142,12,188,12,224,13,24,13,172,13,206,14, 76,14,160,14,230,15,38,15,140,16,22,16,146,16,202,17,12,17,124,18,90,18, 172,19,14,19,110,19,158,19,200,19,234,20,0,20,150,20,226,21,46,21,122, 21,228,22,48,22,148,22,208,22,248,23,54,23,174,23,204,24,46,24,106,24, 188,25,12,25,92,25,148,26,68,26,130,26,196,27,86,28,104,29,42,30,16,30, 118,30,228,31,90,31,236,32,18,32,78,32,134,32,148,32,162,32,176,32,190, 32,204,32,218,33,12,0,0,0,2,0,68,0,0,2,100,5,85,0,3,0,7,0,46,177,1,0,47, 60,178,7,4,255,237,50,177,6,5,220,60,178,3,2,255,237,50,0,177,3,0,47,60, 178,5,4,255,237,50,178,7,6,0,252,60,178,1,2,255,237,50,51,17,33,17,37, 33,17,33,68,2,32,254,36,1,152,254,104,5,85,250,171,68,4,205,0,0,0,2,1, 53,0,0,2,0,5,213,0,3,0,9,0,53,64,15,7,0,131,4,129,2,8,7,5,1,3,4,0,0,10, 16,252,75,176,11,84,88,185,0,0,255,192,56,89,60,236,50,57,57,49,0,47,228, 252,204,48,1,182,0,11,32,11,80,11,3,93,37,51,21,35,17,51,17,3,35,3,1,53, 203,203,203,20,162,21,254,254,5,213,253,113,254,155,1,101,0,0,0,0,2,0, 197,3,170,2,233,5,213,0,3,0,7,0,66,64,15,5,1,132,4,0,129,8,4,5,6,0,5,2, 4,8,16,252,75,176,18,84,75,176,19,84,91,88,185,0,2,255,192,56,89,252,220, 236,49,0,16,244,60,236,50,48,1,64,15,48,9,64,9,80,9,96,9,112,9,160,9,191, 9,7,93,1,17,35,17,33,17,35,17,1,111,170,2,36,170,5,213,253,213,2,43,253, 213,2,43,0,0,0,2,0,158,0,0,6,23,5,190,0,3,0,31,0,96,64,49,27,11,0,135, 7,4,29,9,5,25,13,2,135,23,19,15,21,17,31,30,28,27,26,23,22,21,20,19,18, 17,16,14,13,12,9,8,7,6,5,4,3,2,1,0,26,10,24,6,32,16,252,204,23,57,49,0, 47,60,212,60,60,252,60,60,212,60,60,196,50,236,50,50,48,64,17,11,1,11, 2,11,12,11,13,20,4,26,17,26,18,20,31,8,1,93,1,33,3,33,11,1,33,19,51,3, 33,21,33,3,33,21,33,3,35,19,33,3,35,19,33,53,33,19,33,53,33,19,4,23,254, 221,84,1,37,68,104,1,36,105,160,103,1,56,254,161,82,1,62,254,155,104,160, 103,254,219,103,161,104,254,197,1,96,84,254,190,1,105,102,3,133,254,178, 3,135,254,97,1,159,254,97,154,254,178,153,254,98,1,158,254,98,1,158,153, 1,78,154,1,159,0,0,3,0,170,254,211,4,109,6,20,0,33,0,40,0,47,0,189,64, 85,34,2,10,11,10,39,1,38,40,2,11,11,10,29,1,30,28,2,47,41,47,27,2,41,41, 47,66,19,17,16,34,10,27,41,4,23,6,9,42,33,5,2,23,134,22,6,134,5,17,35, 26,138,22,137,16,0,42,138,5,137,2,45,8,22,10,30,7,41,26,18,3,0,9,34,16, 9,3,1,7,38,8,13,5,6,48,16,252,75,176,9,84,88,185,0,5,255,192,56,89,75, 176,12,84,75,176,16,84,91,75,176,15,84,91,88,185,0,5,0,64,56,89,60,236, 244,23,60,252,23,60,244,228,236,49,0,47,228,236,196,212,228,236,50,196, 16,238,16,238,17,18,57,17,57,17,18,23,57,17,18,57,48,75,83,88,7,16,4,237, 7,16,14,237,17,23,57,7,16,14,237,17,23,57,7,16,4,237,89,34,1,35,3,46,1, 39,53,30,1,23,17,46,1,53,52,54,55,53,51,21,30,1,23,21,46,1,39,17,30,1, 21,20,6,7,3,17,14,1,21,20,22,23,17,62,1,53,52,38,2,180,100,1,105,210,106, 102,209,111,221,201,218,204,100,93,174,83,83,175,92,227,214,227,214,100, 116,122,113,225,127,129,123,254,211,1,45,2,45,45,180,64,65,1,1,200,36, 172,150,163,188,14,235,232,4,31,27,175,42,46,4,254,85,35,180,156,169,195, 15,3,0,1,154,13,106,88,86,96,213,254,79,17,110,90,88,104,0,0,0,0,5,0,113, 255,227,7,41,5,240,0,11,0,23,0,35,0,39,0,51,0,137,64,54,36,15,37,38,37, 38,15,39,36,39,66,0,146,12,30,146,46,141,24,146,36,6,146,12,141,38,18, 140,40,36,145,52,39,33,27,37,9,3,13,21,14,9,13,15,33,13,43,14,27,13,15, 49,11,52,16,252,75,176,9,84,75,176,11,84,91,75,176,12,84,91,75,176,20, 84,91,75,176,14,84,91,75,176,13,84,91,88,185,0,49,255,192,56,89,196,236, 244,236,16,238,246,238,17,57,17,18,57,49,0,16,228,50,244,60,228,236,16, 238,246,238,16,238,48,75,83,88,7,16,5,237,7,16,5,237,89,34,1,34,6,21,20, 22,51,50,54,53,52,38,39,50,22,21,20,6,35,34,38,53,52,54,1,34,6,21,20,22, 51,50,54,53,52,38,37,51,1,35,19,50,22,21,20,6,35,34,38,53,52,54,5,209, 87,99,99,87,85,99,99,85,158,186,187,157,160,186,187,252,151,86,99,98,87, 87,99,100,3,49,160,252,90,160,31,158,188,187,159,159,185,186,2,145,148, 132,130,149,149,130,131,149,127,220,187,187,219,219,187,188,219,2,97,149, 130,132,148,148,132,129,150,127,249,243,6,13,219,187,189,218,219,188,186, 220,0,0,0,0,2,0,129,255,227,5,254,5,240,0,9,0,48,1,205,64,150,13,1,14, 12,134,17,18,17,11,134,10,11,18,18,17,9,134,0,9,21,22,21,7,1,6,8,134,22, 22,21,2,1,3,1,134,29,30,29,0,134,9,0,30,30,29,32,31,2,33,30,17,10,19,10, 23,22,21,3,24,20,17,19,10,7,8,2,6,9,17,19,19,10,2,1,2,3,0,17,10,19,10, 23,22,2,24,21,17,19,10,20,17,19,19,10,66,18,11,9,3,6,0,10,30,3,40,21,14, 6,40,39,6,149,24,43,149,39,148,36,145,24,140,14,19,10,46,11,14,9,0,46, 18,21,39,14,30,3,46,18,39,33,14,17,15,19,33,3,18,27,16,49,16,252,236,196, 212,212,236,16,198,238,17,57,17,18,57,57,17,57,57,17,57,17,57,49,0,47, 198,228,246,230,238,16,238,16,198,17,18,57,17,23,57,17,23,57,48,75,83, 88,7,16,5,237,7,5,237,17,23,57,7,16,5,237,17,23,57,7,16,5,237,17,23,57, 7,5,237,17,23,57,7,16,5,237,17,23,57,7,16,8,237,7,16,14,237,17,23,57,7, 16,14,237,17,23,57,7,16,8,237,7,16,8,237,7,16,14,237,17,23,57,89,34,178, 15,50,1,1,93,64,178,7,11,5,34,9,41,28,0,28,1,31,2,23,11,42,0,42,1,38,18, 58,0,52,18,68,11,94,0,89,1,90,10,85,18,90,26,90,31,89,48,103,30,123,0, 155,0,154,1,153,2,151,8,149,11,147,21,149,22,149,34,153,45,31,9,11,9,12, 8,17,12,39,12,40,24,2,27,9,25,11,25,12,25,17,28,20,28,21,22,29,31,50,39, 0,39,1,41,9,35,18,42,19,42,20,40,21,47,50,59,9,52,18,57,19,63,50,74,9, 76,20,75,21,70,25,79,50,86,1,90,9,89,12,85,18,89,19,92,31,95,50,106,12, 105,17,96,50,117,1,121,12,122,17,147,0,147,1,151,2,149,5,156,7,156,8,159, 8,154,9,155,11,154,12,144,50,160,50,176,50,57,93,0,93,1,14,1,21,20,22, 51,50,54,55,9,1,62,1,55,51,6,2,7,1,35,39,14,1,35,34,0,53,52,54,55,46,1, 53,52,54,51,50,22,23,21,46,1,35,34,6,21,20,22,1,242,91,85,212,160,95,166, 73,254,123,1,252,59,66,6,186,12,104,93,1,23,252,143,104,228,131,241,254, 206,134,134,48,50,222,184,83,165,85,87,158,68,105,131,59,3,35,81,161,88, 146,194,63,64,2,143,253,248,89,203,114,132,254,254,126,254,227,147,89, 87,1,19,215,128,225,99,63,125,60,162,197,36,36,182,47,49,111,88,51,103, 0,1,0,197,3,170,1,111,5,213,0,3,0,55,64,10,1,132,0,129,4,0,5,2,4,4,16, 252,75,176,18,84,75,176,19,84,91,88,185,0,2,255,192,56,89,236,49,0,16, 244,236,48,1,64,13,64,5,80,5,96,5,112,5,144,5,160,5,6,93,1,17,35,17,1, 111,170,5,213,253,213,2,43,0,0,0,1,0,176,254,242,2,123,6,18,0,13,0,55, 64,15,6,152,0,151,14,13,7,0,3,18,6,0,19,10,14,16,220,75,176,19,84,88,185, 0,10,255,192,56,89,75,176,15,84,88,185,0,10,0,64,56,89,228,50,236,17,57, 57,49,0,16,252,236,48,1,6,2,21,20,18,23,35,38,2,53,52,18,55,2,123,134, 130,131,133,160,150,149,148,151,6,18,230,254,62,231,231,254,59,229,235, 1,198,224,223,1,196,236,0,1,0,164,254,242,2,111,6,18,0,13,0,31,64,15,7, 152,0,151,14,7,1,0,11,18,4,19,8,0,14,16,220,60,244,236,17,57,57,49,0,16, 252,236,48,19,51,22,18,21,20,2,7,35,54,18,53,52,2,164,160,150,149,149, 150,160,133,131,131,6,18,236,254,60,223,224,254,58,235,229,1,197,231,231, 1,194,0,0,0,1,0,61,2,74,3,195,5,240,0,17,0,78,64,44,16,13,11,0,4,12,9, 7,4,2,4,8,3,153,5,17,12,153,10,1,14,145,18,8,12,10,3,9,6,17,3,1,3,2,0, 20,15,4,11,9,20,13,6,18,16,212,60,228,50,220,60,228,50,23,57,17,18,23, 57,49,0,16,244,212,60,236,50,196,236,50,23,57,18,23,57,48,1,13,1,7,37, 17,35,17,5,39,45,1,55,5,17,51,17,37,3,195,254,153,1,103,58,254,176,114, 254,176,58,1,103,254,153,58,1,80,114,1,80,4,223,194,195,98,203,254,135, 1,121,203,98,195,194,99,203,1,121,254,135,203,0,0,0,1,0,217,0,0,5,219, 5,4,0,11,0,35,64,17,0,9,1,156,7,3,5,2,21,4,0,23,10,6,21,8,12,16,220,252, 60,252,60,236,49,0,47,212,60,252,60,196,48,1,17,33,21,33,17,35,17,33,53, 33,17,3,174,2,45,253,211,168,253,211,2,45,5,4,253,211,170,253,211,2,45, 170,2,45,0,1,0,158,255,18,1,195,0,254,0,5,0,25,64,12,3,158,0,131,6,3,4, 1,25,0,24,6,16,252,236,212,204,49,0,16,252,236,48,55,51,21,3,35,19,240, 211,164,129,82,254,172,254,192,1,64,0,1,0,100,1,223,2,127,2,131,0,3,0, 17,182,0,156,2,4,1,0,4,16,220,204,49,0,16,212,236,48,19,33,21,33,100,2, 27,253,229,2,131,164,0,0,1,0,219,0,0,1,174,0,254,0,3,0,17,183,0,131,2, 1,25,0,24,4,16,252,236,49,0,47,236,48,55,51,21,35,219,211,211,254,254, 0,1,0,0,255,66,2,178,5,213,0,3,0,45,64,20,0,26,1,2,1,2,26,3,0,3,66,2,159, 0,129,4,2,0,1,3,47,196,57,57,49,0,16,244,236,48,75,83,88,7,16,5,237,7, 16,5,237,89,34,1,51,1,35,2,8,170,253,248,170,5,213,249,109,0,0,0,0,2,0, 135,255,227,4,143,5,240,0,11,0,23,0,35,64,19,6,160,18,0,160,12,145,18, 140,24,9,28,15,30,3,28,21,27,24,16,252,236,244,236,49,0,16,228,244,236, 16,238,48,1,34,2,17,16,18,51,50,18,17,16,2,39,50,0,17,16,0,35,34,0,17, 16,0,2,139,156,157,157,156,157,157,157,157,251,1,9,254,247,251,251,254, 247,1,9,5,80,254,205,254,204,254,205,254,205,1,51,1,51,1,52,1,51,160,254, 115,254,134,254,135,254,115,1,141,1,121,1,122,1,141,0,0,1,0,225,0,0,4, 90,5,213,0,10,0,64,64,21,66,3,160,4,2,160,5,129,7,0,160,9,8,31,6,28,3, 0,31,1,11,16,212,75,176,15,84,88,185,0,1,0,64,56,89,236,196,252,236,49, 0,47,236,50,244,236,212,236,48,75,83,88,89,34,1,180,15,3,15,4,2,93,55, 33,17,5,53,37,51,17,33,21,33,254,1,74,254,153,1,101,202,1,74,252,164,170, 4,115,72,184,72,250,213,170,0,0,0,1,0,150,0,0,4,74,5,240,0,28,0,158,64, 39,25,26,27,3,24,28,17,5,4,0,17,5,5,4,66,16,161,17,148,13,160,20,145,4, 0,160,2,0,16,10,2,1,10,28,23,16,3,6,29,16,252,75,176,21,84,75,176,22,84, 91,75,176,20,84,91,88,185,0,3,255,192,56,89,196,212,236,192,192,17,18, 57,49,0,47,236,50,244,236,244,236,48,75,83,88,7,16,5,237,7,5,237,1,176, 28,16,17,23,57,89,34,1,64,50,85,4,86,5,86,7,122,4,122,5,118,27,135,25, 7,4,0,4,25,4,26,4,27,5,28,116,0,118,6,117,26,115,27,116,28,130,0,134,25, 130,26,130,27,130,28,168,0,168,27,17,93,0,93,37,33,21,33,53,54,0,55,62, 1,53,52,38,35,34,6,7,53,62,1,51,50,4,21,20,6,7,6,0,1,137,2,193,252,76, 115,1,141,51,97,77,167,134,95,211,120,122,212,88,232,1,20,69,91,25,254, 244,170,170,170,119,1,145,58,109,151,73,119,150,66,67,204,49,50,232,194, 92,165,112,29,254,235,0,0,0,1,0,156,255,227,4,115,5,240,0,40,0,112,64, 46,0,21,19,10,134,9,31,134,32,19,160,21,13,160,9,147,6,28,160,32,147,35, 145,6,140,21,163,41,22,28,19,0,3,20,25,28,38,32,16,28,3,20,31,9,6,41,16, 252,75,176,22,84,75,176,20,84,91,88,185,0,9,255,192,56,89,196,196,212, 236,244,236,17,23,57,57,49,0,16,236,228,244,228,236,16,230,238,16,238, 16,238,16,238,17,18,57,48,1,64,9,100,30,97,31,97,32,100,33,4,0,93,1,30, 1,21,20,4,33,34,38,39,53,30,1,51,50,54,53,52,38,43,1,53,51,50,54,53,52, 38,35,34,6,7,53,62,1,51,50,4,21,20,6,3,63,145,163,254,208,254,232,94,199, 106,84,200,109,190,199,185,165,174,182,149,158,163,152,83,190,114,115, 201,89,230,1,12,142,3,37,31,196,144,221,242,37,37,195,49,50,150,143,132, 149,166,119,112,115,123,36,38,180,32,32,209,178,124,171,0,0,2,0,100,0, 0,4,164,5,213,0,2,0,13,0,129,64,29,1,13,3,13,0,3,3,13,66,0,3,11,7,160, 5,1,3,129,9,1,12,10,0,28,6,8,4,12,14,16,220,75,176,11,84,75,176,13,84, 91,88,185,0,12,255,192,56,89,212,60,196,236,50,17,57,49,0,47,228,212,60, 236,50,18,57,48,75,83,88,7,16,4,201,7,16,5,201,89,34,1,64,42,11,0,42,0, 72,0,89,0,105,0,119,0,138,0,7,22,1,43,0,38,1,43,3,54,1,78,1,79,12,79,13, 86,1,102,1,117,1,122,3,133,1,13,93,0,93,9,1,33,3,51,17,51,21,35,17,35, 17,33,53,3,6,254,2,1,254,53,254,213,213,201,253,94,5,37,252,227,3,205, 252,51,168,254,160,1,96,195,0,0,0,1,0,158,255,227,4,100,5,213,0,29,0,94, 64,35,4,26,7,17,134,16,29,26,160,7,20,160,16,137,13,2,160,0,129,13,140, 7,164,30,23,28,1,10,3,28,0,10,16,6,30,16,252,1,75,176,22,84,75,176,20, 84,91,88,185,0,16,255,192,56,89,75,176,15,84,88,185,0,16,0,64,56,89,196, 212,236,16,196,238,49,0,16,228,228,244,236,16,230,238,16,254,196,16,238, 17,18,57,48,19,33,21,33,17,62,1,51,50,0,21,20,0,33,34,38,39,53,30,1,51, 50,54,53,52,38,35,34,6,7,221,3,25,253,160,44,88,44,250,1,36,254,212,254, 239,94,195,104,90,192,107,173,202,202,173,81,161,84,5,213,170,254,146, 15,15,254,238,234,241,254,245,32,32,203,49,48,182,156,156,182,36,38,0, 0,0,2,0,143,255,227,4,150,5,240,0,11,0,36,0,88,64,36,19,6,0,13,134,12, 0,160,22,6,160,28,22,165,16,160,12,137,34,145,28,140,37,12,34,9,28,25, 30,19,28,3,33,31,27,37,16,252,236,236,244,236,228,49,0,16,228,244,228, 252,228,16,238,16,238,16,238,17,18,57,48,64,20,203,0,203,1,205,2,205,3, 205,4,203,5,203,6,7,164,30,178,30,2,93,1,93,1,34,6,21,20,22,51,50,54,53, 52,38,1,21,46,1,35,34,2,3,62,1,51,50,0,21,20,0,35,32,0,17,16,0,33,50,22, 2,164,136,159,159,136,136,159,159,1,9,76,155,76,200,211,15,59,178,107, 225,1,5,254,240,226,254,253,254,238,1,80,1,27,76,155,3,59,186,162,161, 187,187,161,162,186,2,121,184,36,38,254,242,254,239,87,93,254,239,235, 230,254,234,1,141,1,121,1,98,1,165,30,0,0,0,0,1,0,168,0,0,4,104,5,213, 0,6,0,99,64,24,5,17,2,3,2,3,17,4,5,4,66,5,160,0,129,3,5,3,1,4,1,0,6,7, 16,252,204,196,17,57,57,49,0,47,244,236,48,75,83,88,7,16,5,237,7,16,5, 237,89,34,1,75,176,22,84,88,189,0,7,0,64,0,1,0,7,0,7,255,192,56,17,55, 56,89,64,18,88,2,1,6,3,26,5,57,5,72,5,103,3,176,0,176,6,7,93,0,93,19,33, 21,1,35,1,33,168,3,192,253,226,211,1,254,253,51,5,213,86,250,129,5,43, 0,0,0,0,3,0,139,255,227,4,139,5,240,0,11,0,35,0,47,0,67,64,37,24,12,0, 160,39,6,160,30,45,160,18,145,30,140,39,163,48,24,12,36,42,28,21,36,28, 15,9,28,21,27,30,3,28,15,33,27,48,16,252,196,236,244,196,236,16,238,16, 238,17,57,57,49,0,16,236,228,244,236,16,238,16,238,57,57,48,1,34,6,21, 20,22,51,50,54,53,52,38,37,46,1,53,52,36,51,50,22,21,20,6,7,30,1,21,20, 4,35,34,36,53,52,54,19,20,22,51,50,54,53,52,38,35,34,6,2,139,144,165,165, 144,144,166,165,254,165,130,145,0,255,222,223,254,145,129,146,163,254, 247,247,247,254,247,164,72,145,131,130,147,147,130,131,145,2,197,154,135, 135,154,155,134,135,154,86,32,178,128,179,208,208,179,128,178,32,34,198, 143,217,232,232,217,143,198,1,97,116,130,130,116,116,130,130,0,0,0,2,0, 129,255,227,4,135,5,240,0,24,0,36,0,88,64,35,7,31,25,1,134,0,25,160,10, 165,4,160,0,137,22,31,160,16,145,22,140,37,7,28,28,33,19,30,0,34,34,28, 13,27,37,16,252,236,228,244,236,236,49,0,16,228,244,236,16,230,254,245, 238,16,238,17,18,57,48,64,22,196,25,194,26,192,27,192,28,192,29,194,30, 196,31,7,170,18,188,18,233,18,3,93,1,93,55,53,30,1,51,50,18,19,14,1,35, 34,0,53,52,0,51,32,0,17,16,0,33,34,38,1,50,54,53,52,38,35,34,6,21,20,22, 225,76,156,75,200,211,15,58,178,108,224,254,251,1,16,226,1,3,1,17,254, 177,254,229,76,156,1,62,136,159,159,136,136,159,159,31,184,36,38,1,13, 1,18,86,92,1,15,235,230,1,22,254,115,254,134,254,159,254,91,30,2,151,186, 162,161,187,187,161,162,186,0,0,2,0,240,0,0,1,195,4,35,0,3,0,7,0,28,64, 14,6,131,4,166,0,131,2,5,1,3,4,0,24,8,16,252,60,236,50,49,0,47,236,244, 236,48,55,51,21,35,17,51,21,35,240,211,211,211,211,254,254,4,35,254,0, 0,0,1,0,217,0,94,5,219,4,166,0,6,0,77,64,42,2,156,3,4,3,1,156,0,1,4,4, 3,1,156,2,1,5,6,5,0,156,6,5,66,5,4,2,1,0,5,3,168,6,167,7,1,2,0,36,4,35, 7,16,252,236,50,57,49,0,16,244,236,23,57,48,75,83,88,7,4,237,7,16,8,237, 7,16,8,237,7,16,4,237,89,34,9,2,21,1,53,1,5,219,251,248,4,8,250,254,5, 2,3,240,254,145,254,147,182,1,209,166,1,209,0,0,2,0,217,1,96,5,219,3,162, 0,3,0,7,0,28,64,13,0,156,2,6,156,4,8,5,1,4,0,35,8,16,252,60,196,50,49, 0,16,212,236,212,236,48,19,33,21,33,21,33,21,33,217,5,2,250,254,5,2,250, 254,3,162,168,240,170,0,0,0,1,0,217,0,94,5,219,4,166,0,6,0,79,64,43,6, 156,0,6,3,4,3,5,156,4,4,3,0,156,1,2,1,6,156,5,6,2,2,1,66,6,5,3,2,0,5,4, 168,1,167,7,6,2,36,4,0,35,7,16,252,60,236,57,49,0,16,244,236,23,57,48, 75,83,88,7,16,8,237,7,16,4,237,7,16,4,237,7,16,8,237,89,34,19,53,1,21, 1,53,1,217,5,2,250,254,4,6,3,240,182,254,47,166,254,47,182,1,109,0,0,0, 2,0,147,0,0,3,176,5,240,0,3,0,36,0,101,64,43,36,30,9,6,4,10,29,19,4,0, 20,134,19,136,16,149,23,145,0,131,2,29,26,13,9,5,4,10,30,1,13,28,26,4, 28,5,1,3,0,38,26,19,37,16,220,75,176,12,84,88,185,0,19,255,192,56,89,196, 252,236,212,236,16,238,17,57,57,17,18,57,17,18,57,49,0,47,238,246,254, 244,238,16,205,17,57,57,23,57,48,1,182,121,9,122,10,122,32,3,93,37,51, 21,35,19,35,53,52,54,63,1,62,1,53,52,38,35,34,6,7,53,62,1,51,50,22,21, 20,6,15,1,14,1,7,14,1,21,1,135,203,203,197,191,56,90,90,57,51,131,108, 79,179,97,94,193,103,184,223,72,90,88,47,39,8,6,6,254,254,1,145,154,101, 130,86,89,53,94,49,89,110,70,67,188,57,56,194,159,76,137,86,86,47,53,25, 21,60,52,0,0,0,2,0,135,254,156,7,113,5,162,0,11,0,76,0,149,64,50,24,12, 3,9,169,25,21,27,3,169,76,15,52,51,15,172,48,169,55,21,172,36,169,55,67, 77,51,52,30,26,0,40,18,6,24,12,40,26,43,30,40,73,18,43,42,40,73,44,61, 77,16,220,236,252,236,16,254,253,254,60,198,16,238,17,18,57,57,49,0,16, 212,196,252,236,16,254,237,212,198,16,197,238,50,16,196,238,17,57,57,48, 0,75,176,9,84,75,176,12,84,91,75,176,16,84,91,75,176,19,84,91,75,176,20, 84,91,88,189,0,77,255,192,0,1,0,77,0,77,0,64,56,17,55,56,89,64,9,15,78, 31,78,47,78,63,78,4,1,93,1,20,22,51,50,54,53,52,38,35,34,6,1,14,1,35,34, 38,53,52,54,51,50,22,23,53,51,17,62,1,53,52,38,39,38,36,35,34,6,7,6,2, 21,20,18,23,22,4,51,50,54,55,23,6,4,35,34,36,39,38,2,53,52,18,55,54,36, 51,50,4,23,30,1,21,16,0,5,2,250,142,124,123,141,144,122,121,143,2,33,60, 155,103,172,215,216,171,103,156,59,143,146,165,63,64,104,254,213,176,123, 226,96,157,177,115,109,105,1,20,157,129,249,104,90,125,254,217,152,185, 254,184,128,128,134,136,126,129,1,82,189,212,1,107,123,75,79,254,194,254, 232,2,25,143,163,164,142,140,165,164,254,72,77,73,249,200,200,250,75,76, 131,253,32,22,223,177,107,188,80,131,139,65,64,102,254,181,193,159,254, 234,106,104,109,87,81,111,97,103,131,125,125,1,73,189,182,1,74,125,127, 135,174,160,98,230,123,254,249,254,208,6,0,0,2,0,16,0,0,5,104,5,213,0, 2,0,10,0,194,64,65,0,17,1,0,4,5,4,2,17,5,5,4,1,17,10,3,10,0,17,2,0,3,3, 10,7,17,5,4,6,17,5,5,4,9,17,3,10,8,17,10,3,10,66,0,3,7,149,1,3,129,9,5, 9,8,7,6,4,3,2,1,0,9,5,10,11,16,212,196,23,57,49,0,47,60,228,212,236,18, 57,48,75,83,88,7,16,5,237,7,5,237,7,16,5,237,7,5,237,7,16,8,237,7,16,5, 237,7,16,5,237,7,16,8,237,89,34,178,32,12,1,1,93,64,66,15,1,15,2,15,7, 15,8,15,0,88,0,118,0,112,0,140,0,9,7,1,8,2,6,3,9,4,22,1,25,2,86,1,88,2, 80,12,103,1,104,2,120,1,118,2,124,3,114,4,119,7,120,8,135,1,136,2,128, 12,152,2,153,3,150,4,23,93,0,93,9,1,33,1,51,1,35,3,33,3,35,2,188,254,238, 2,37,254,123,229,2,57,210,136,253,95,136,213,5,14,253,25,3,174,250,43, 1,127,254,129,0,0,0,3,0,201,0,0,4,236,5,213,0,8,0,17,0,32,0,67,64,35,25, 0,149,10,9,149,18,129,1,149,10,173,31,17,11,8,2,19,25,31,5,0,14,28,22, 5,25,28,46,9,0,28,18,4,33,16,252,236,50,252,236,212,236,17,23,57,57,57, 49,0,47,236,236,244,236,16,238,57,48,178,15,34,1,1,93,1,17,33,50,54,53, 52,38,35,1,17,33,50,54,53,52,38,35,37,33,50,22,21,20,6,7,30,1,21,20,4, 35,33,1,147,1,68,163,157,157,163,254,188,1,43,148,145,145,148,254,11,2, 4,231,250,128,124,149,165,254,240,251,253,232,2,201,253,221,135,139,140, 133,2,102,254,62,111,114,113,112,166,192,177,137,162,20,32,203,152,200, 218,0,1,0,115,255,227,5,39,5,240,0,25,0,54,64,26,13,161,14,174,10,149, 17,1,161,0,174,4,149,23,145,17,140,26,7,25,13,0,48,20,16,26,16,252,236, 50,236,49,0,16,228,244,236,244,236,16,238,246,238,48,180,15,27,31,27,2, 1,93,1,21,46,1,35,32,0,17,16,0,33,50,54,55,21,14,1,35,32,0,17,16,0,33, 50,22,5,39,102,231,130,255,0,254,240,1,16,1,0,130,231,102,106,237,132, 254,173,254,122,1,134,1,83,134,237,5,98,213,95,94,254,199,254,216,254, 217,254,199,94,95,211,72,72,1,159,1,103,1,104,1,159,71,0,0,0,2,0,201,0, 0,5,176,5,213,0,8,0,17,0,46,64,21,0,149,9,129,1,149,16,8,2,16,10,0,5,25, 13,50,0,28,9,4,18,16,252,236,244,236,17,57,57,57,57,49,0,47,236,244,236, 48,178,96,19,1,1,93,1,17,51,32,0,17,16,0,33,37,33,32,0,17,16,0,41,1,1, 147,244,1,53,1,31,254,225,254,203,254,66,1,159,1,178,1,150,254,104,254, 80,254,97,5,47,251,119,1,24,1,46,1,44,1,23,166,254,151,254,128,254,126, 254,150,0,0,0,1,0,201,0,0,4,139,5,213,0,11,0,46,64,21,6,149,4,2,149,0, 129,8,149,4,173,10,5,1,9,7,3,28,0,4,12,16,252,236,50,212,196,196,49,0, 47,236,236,244,236,16,238,48,178,31,13,1,1,93,19,33,21,33,17,33,21,33, 17,33,21,33,201,3,176,253,26,2,199,253,57,2,248,252,62,5,213,170,254,70, 170,253,227,170,0,0,0,1,0,201,0,0,4,35,5,213,0,9,0,41,64,18,6,149,4,2, 149,0,129,4,173,8,5,1,7,3,28,0,4,10,16,252,236,50,212,196,49,0,47,236, 244,236,16,238,48,178,15,11,1,1,93,19,33,21,33,17,33,21,33,17,35,201,3, 90,253,112,2,80,253,176,202,5,213,170,254,72,170,253,55,0,0,1,0,115,255, 227,5,139,5,240,0,29,0,57,64,32,0,5,27,1,149,3,27,149,8,18,161,17,174, 21,149,14,145,8,140,30,2,0,28,17,52,4,51,24,25,11,16,30,16,252,236,252, 228,252,196,49,0,16,228,244,236,244,236,16,254,212,238,17,57,57,48,37, 17,33,53,33,17,6,4,35,32,0,17,16,0,33,50,4,23,21,46,1,35,32,0,17,16,0, 33,50,54,4,195,254,182,2,18,117,254,230,160,254,162,254,117,1,139,1,94, 146,1,7,111,112,252,139,254,238,254,237,1,19,1,18,107,168,213,1,145,166, 253,127,83,85,1,153,1,109,1,110,1,153,72,70,215,95,96,254,206,254,209, 254,210,254,206,37,0,0,0,1,0,201,0,0,5,59,5,213,0,11,0,44,64,20,8,149, 2,173,4,0,129,10,6,7,3,28,5,56,9,1,28,0,4,12,16,252,236,50,252,236,50, 49,0,47,60,228,50,252,236,48,178,80,13,1,1,93,19,51,17,33,17,51,17,35, 17,33,17,35,201,202,2,222,202,202,253,34,202,5,213,253,156,2,100,250,43, 2,199,253,57,0,0,1,0,201,0,0,1,147,5,213,0,3,0,46,183,0,175,2,1,28,0,4, 4,16,252,75,176,16,84,88,185,0,0,0,64,56,89,236,49,0,47,236,48,1,64,13, 48,5,64,5,80,5,96,5,143,5,159,5,6,93,19,51,17,35,201,202,202,5,213,250, 43,0,0,1,255,150,254,102,1,147,5,213,0,11,0,66,64,19,11,2,0,7,149,5,176, 0,129,12,5,8,6,57,1,28,0,4,12,16,252,75,176,16,84,88,185,0,0,0,64,56,89, 236,228,57,57,49,0,16,228,252,236,17,57,57,48,1,64,13,48,13,64,13,80,13, 96,13,143,13,159,13,6,93,19,51,17,16,6,43,1,53,51,50,54,53,201,202,205, 227,77,63,134,110,5,213,250,147,254,242,244,170,150,194,0,0,0,1,0,201, 0,0,5,106,5,213,0,10,0,239,64,40,8,17,5,6,5,7,17,6,6,5,3,17,4,5,4,2,17, 5,5,4,66,8,5,2,3,3,0,175,9,6,5,1,4,6,8,1,28,0,4,11,16,252,236,50,212,196, 17,57,49,0,47,60,236,50,23,57,48,75,83,88,7,16,4,237,7,16,5,237,7,16,5, 237,7,16,4,237,89,34,178,8,3,1,1,93,64,146,20,2,1,4,2,9,8,22,2,40,5,40, 8,55,2,54,5,52,8,71,2,70,5,67,8,85,2,103,2,118,2,119,5,131,2,136,5,143, 8,148,2,155,8,231,2,21,6,3,9,5,9,6,27,3,25,7,5,10,3,10,7,24,3,40,5,43, 6,42,7,54,4,54,5,54,6,53,7,48,12,65,3,64,4,69,5,64,6,64,7,64,12,98,3,96, 4,104,5,103,7,119,5,112,12,139,3,139,5,142,6,143,7,143,12,154,3,157,6, 157,7,182,3,181,7,197,3,197,7,215,3,214,7,232,3,233,4,232,5,234,6,247, 3,248,5,249,6,44,93,113,0,93,113,19,51,17,1,33,9,1,33,1,17,35,201,202, 2,158,1,4,253,27,3,26,254,246,253,51,202,5,213,253,137,2,119,253,72,252, 227,2,207,253,49,0,0,0,0,1,0,201,0,0,4,106,5,213,0,5,0,37,64,12,2,149, 0,129,4,1,28,3,58,0,4,6,16,252,236,236,49,0,47,228,236,48,64,9,48,7,80, 7,128,3,128,4,4,1,93,19,51,17,33,21,33,201,202,2,215,252,95,5,213,250, 213,170,0,1,0,201,0,0,6,31,5,213,0,12,0,191,64,52,3,17,7,8,7,2,17,1,2, 8,8,7,2,17,3,2,9,10,9,1,17,10,10,9,66,10,7,2,3,8,3,0,175,8,11,5,9,8,3, 2,1,5,10,6,28,4,62,10,28,0,4,13,16,252,236,252,236,17,23,57,49,0,47,60, 196,236,50,17,23,57,48,75,83,88,7,16,5,237,7,16,8,237,7,16,8,237,7,16, 5,237,89,34,178,112,14,1,1,93,64,86,3,7,15,8,15,9,2,10,21,2,20,7,19,10, 38,2,38,7,32,7,38,10,32,10,52,7,53,10,105,2,124,2,123,7,121,10,128,2,130, 7,130,10,144,2,22,4,1,11,3,19,1,27,3,35,1,44,3,39,8,40,9,52,1,60,3,86, 8,89,9,101,8,106,9,118,8,121,9,129,1,141,3,149,1,155,3,20,93,0,93,19,33, 9,1,33,17,35,17,1,35,1,17,35,201,1,45,1,125,1,127,1,45,197,254,127,203, 254,127,196,5,213,252,8,3,248,250,43,5,31,252,0,4,0,250,225,0,0,0,1,0, 201,0,0,5,51,5,213,0,9,0,121,64,30,7,17,1,2,1,2,17,6,7,6,66,7,2,3,0,175, 8,5,6,1,7,2,28,4,54,7,28,0,4,10,16,252,236,252,236,17,57,57,49,0,47,60, 236,50,57,57,48,75,83,88,7,16,4,237,7,16,4,237,89,34,178,31,11,1,1,93, 64,48,54,2,56,7,72,2,71,7,105,2,102,7,128,2,7,6,1,9,6,21,1,26,6,70,1,73, 6,87,1,88,6,101,1,105,6,121,6,133,1,138,6,149,1,154,6,159,11,16,93,0,93, 19,33,1,17,51,17,33,1,17,35,201,1,16,2,150,196,254,240,253,106,196,5,213, 251,31,4,225,250,43,4,225,251,31,0,2,0,115,255,227,5,217,5,240,0,11,0, 23,0,35,64,19,6,149,18,0,149,12,145,18,140,24,9,25,15,51,3,25,21,16,24, 16,252,236,252,236,49,0,16,228,244,236,16,238,48,1,34,0,17,16,0,51,50, 0,17,16,0,39,32,0,17,16,0,33,32,0,17,16,0,3,39,220,254,253,1,3,220,220, 1,1,254,255,220,1,58,1,120,254,136,254,198,254,197,254,135,1,121,5,76, 254,184,254,229,254,230,254,184,1,72,1,26,1,27,1,72,164,254,91,254,158, 254,159,254,91,1,164,1,98,1,98,1,165,0,0,0,2,0,201,0,0,4,141,5,213,0,8, 0,19,0,58,64,24,1,149,16,0,149,9,129,18,16,10,8,2,4,0,5,25,13,63,17,0, 28,9,4,20,16,252,236,50,252,236,17,23,57,49,0,47,244,236,212,236,48,64, 11,15,21,31,21,63,21,95,21,175,21,5,1,93,1,17,51,50,54,53,52,38,35,37, 33,50,4,21,20,4,43,1,17,35,1,147,254,141,154,154,141,254,56,1,200,251, 1,1,254,255,251,254,202,5,47,253,207,146,135,134,146,166,227,219,221,226, 253,168,0,2,0,115,254,248,5,217,5,240,0,11,0,29,0,82,64,42,17,16,2,15, 1,12,13,12,14,1,13,13,12,66,15,30,12,6,149,18,0,149,24,145,18,140,13,30, 13,27,15,12,3,9,25,27,51,3,25,21,16,30,16,252,236,252,236,17,57,57,17, 57,49,0,16,196,228,244,236,16,238,57,18,57,48,75,83,88,7,16,5,237,7,16, 5,237,23,57,89,34,1,34,0,17,16,0,51,50,0,17,16,0,19,1,35,39,14,1,35,32, 0,17,16,0,33,32,0,17,16,2,3,39,220,254,253,1,3,220,220,1,1,254,255,63, 1,10,244,221,33,35,16,254,197,254,135,1,121,1,59,1,58,1,120,209,5,76,254, 184,254,229,254,230,254,184,1,72,1,26,1,27,1,72,250,207,254,221,239,2, 2,1,165,1,97,1,98,1,165,254,91,254,158,254,252,254,142,0,0,2,0,201,0,0, 5,84,5,213,0,19,0,28,0,177,64,53,9,8,7,3,10,6,17,3,4,3,5,17,4,4,3,66,6, 4,0,21,3,4,21,149,9,20,149,13,129,11,4,5,6,3,17,9,0,28,22,14,5,10,25,25, 4,17,63,20,10,28,12,4,29,16,252,236,50,252,196,236,17,23,57,17,57,57,57, 49,0,47,60,244,236,212,236,18,57,18,57,18,57,48,75,83,88,7,16,5,237,7, 16,5,237,17,23,57,89,34,178,64,30,1,1,93,64,66,122,19,1,5,0,5,1,5,2,6, 3,7,4,21,0,21,1,20,2,22,3,23,4,37,0,37,1,37,2,38,3,39,6,38,7,38,8,38,9, 32,30,54,1,54,2,70,1,70,2,104,5,117,4,117,5,119,19,136,6,136,7,152,6,152, 7,31,93,0,93,1,30,1,23,19,35,3,46,1,43,1,17,35,17,33,32,22,21,20,6,1,17, 51,50,54,53,52,38,35,3,141,65,123,62,205,217,191,74,139,120,220,202,1, 200,1,0,252,131,253,137,254,146,149,149,146,2,188,22,144,126,254,104,1, 127,150,98,253,137,5,213,214,216,141,186,2,79,253,238,135,131,131,133, 0,0,1,0,135,255,227,4,162,5,240,0,39,0,126,64,60,13,12,2,14,11,2,30,31, 30,8,9,2,7,10,2,31,31,30,66,10,11,30,31,4,21,1,0,21,161,20,148,24,149, 17,4,149,0,148,37,145,17,140,40,30,10,11,31,27,7,0,34,27,25,14,45,7,25, 20,34,40,16,220,196,236,252,236,228,17,18,57,57,57,57,49,0,16,228,244, 228,236,16,238,246,238,16,198,17,23,57,48,75,83,88,7,16,14,237,17,23,57, 7,16,14,237,17,23,57,89,34,178,15,41,1,1,93,182,31,41,47,41,79,41,3,93, 1,21,46,1,35,34,6,21,20,22,31,1,30,1,21,20,4,33,34,38,39,53,30,1,51,50, 54,53,52,38,47,1,46,1,53,52,36,51,50,22,4,72,115,204,95,165,179,119,166, 122,226,215,254,221,254,231,106,239,128,123,236,114,173,188,135,154,123, 226,202,1,23,245,105,218,5,164,197,55,54,128,118,99,101,31,25,43,217,182, 217,224,48,47,208,69,70,136,126,110,124,31,24,45,192,171,198,228,38,0, 0,1,255,250,0,0,4,233,5,213,0,7,0,74,64,14,6,2,149,0,129,4,1,64,3,28,0, 64,5,8,16,212,228,252,228,49,0,47,244,236,50,48,1,75,176,10,84,88,189, 0,8,0,64,0,1,0,8,0,8,255,192,56,17,55,56,89,64,19,0,9,31,0,16,1,16,2,31, 7,16,9,64,9,112,9,159,9,9,93,3,33,21,33,17,35,17,33,6,4,239,253,238,203, 253,238,5,213,170,250,213,5,43,0,0,1,0,178,255,227,5,41,5,213,0,17,0,64, 64,22,8,2,17,11,0,5,149,14,140,9,0,129,18,8,28,10,56,1,28,0,65,18,16,252, 75,176,16,84,88,185,0,0,255,192,56,89,236,252,236,49,0,16,228,50,244,236, 17,57,57,57,57,48,1,182,31,19,143,19,159,19,3,93,19,51,17,20,22,51,50, 54,53,17,51,17,16,0,33,32,0,17,178,203,174,195,194,174,203,254,223,254, 230,254,229,254,223,5,213,252,117,240,211,211,240,3,139,252,92,254,220, 254,214,1,42,1,36,0,0,1,0,16,0,0,5,104,5,213,0,6,0,183,64,39,4,17,5,6, 5,3,17,2,3,6,6,5,3,17,4,3,0,1,0,2,17,1,1,0,66,3,4,1,175,0,6,4,3,2,0,5, 5,1,7,16,212,196,23,57,49,0,47,236,50,57,48,75,83,88,7,16,5,237,7,16,8, 237,7,16,8,237,7,16,5,237,89,34,178,80,8,1,1,93,64,98,0,3,42,3,71,4,71, 5,90,3,125,3,131,3,7,6,0,7,2,8,4,9,6,21,1,20,2,26,4,26,5,42,0,38,1,38, 2,41,4,41,5,37,6,32,8,56,0,51,1,51,2,60,4,60,5,55,6,72,0,69,1,69,2,73, 4,73,5,71,6,89,0,86,6,102,2,105,4,105,5,122,0,118,1,118,2,121,4,121,5, 117,6,128,8,152,0,151,6,41,93,0,93,33,1,51,9,1,51,1,2,74,253,198,211,1, 217,1,218,210,253,199,5,213,251,23,4,233,250,43,0,1,0,68,0,0,7,166,5,213, 0,12,1,123,64,73,5,26,6,5,9,10,9,4,26,10,9,3,26,10,11,10,2,26,1,2,11,11, 10,6,17,7,8,7,5,17,4,5,8,8,7,2,17,3,2,12,0,12,1,17,0,0,12,66,10,5,2,3, 6,3,0,175,11,8,12,11,10,9,8,6,5,4,3,2,1,11,7,0,13,16,212,204,23,57,49, 0,47,60,236,50,50,23,57,48,75,83,88,7,16,5,237,7,16,8,237,7,16,8,237,7, 16,5,237,7,16,8,237,7,16,5,237,7,5,237,7,16,8,237,89,34,178,0,14,1,1,93, 64,242,6,2,6,5,2,10,0,10,0,10,18,10,40,5,36,10,32,10,62,2,62,5,52,10,48, 10,76,2,77,5,66,10,64,10,89,2,106,2,107,5,103,10,96,10,123,2,127,2,124, 5,127,5,128,10,150,2,149,5,29,7,0,9,2,8,3,0,4,6,5,0,5,0,6,1,7,4,8,0,8, 7,9,0,9,4,10,10,12,0,14,26,3,21,4,21,8,25,12,16,14,32,4,33,5,32,6,32,7, 32,8,35,9,36,10,37,11,32,14,32,14,60,2,58,3,53,4,51,5,48,8,54,9,57,11, 63,12,48,14,70,0,70,1,74,2,64,4,69,5,64,5,66,6,66,7,66,8,64,8,64,9,68, 10,77,12,64,14,64,14,88,2,86,8,89,12,80,14,102,2,103,3,97,4,98,5,96,6, 96,7,96,8,100,9,100,10,100,11,119,0,118,1,123,2,120,3,119,4,116,5,121, 6,121,7,119,8,112,8,120,12,127,12,127,14,134,2,135,3,136,4,137,5,133,9, 138,11,143,14,151,4,159,14,175,14,91,93,0,93,19,51,9,1,51,9,1,51,1,35, 9,1,35,68,204,1,58,1,57,227,1,58,1,57,205,254,137,254,254,197,254,194, 254,5,213,251,18,4,238,251,18,4,238,250,43,5,16,250,240,0,0,0,1,0,61,0, 0,5,59,5,213,0,11,0,102,64,6,13,4,6,0,10,12,16,212,196,220,196,196,49, 180,128,0,127,10,2,93,0,64,5,3,0,175,9,6,47,60,236,50,48,75,176,66,80, 88,64,20,7,17,6,6,5,9,17,10,11,10,3,17,4,5,4,1,17,0,11,0,5,7,16,236,7, 16,236,7,16,236,7,16,236,64,20,11,10,3,7,0,8,9,4,7,0,5,9,4,6,1,2,10,3, 6,1,15,15,15,15,89,19,51,9,1,51,9,1,35,9,1,35,1,129,217,1,115,1,117,217, 254,32,2,0,217,254,92,254,89,218,2,21,5,213,253,213,2,43,253,51,252,248, 2,123,253,133,3,29,0,0,1,255,252,0,0,4,231,5,213,0,8,0,148,64,40,3,17, 4,5,4,2,17,1,2,5,5,4,2,17,3,2,8,0,8,1,17,0,0,8,66,2,3,0,175,6,2,7,4,64, 5,28,0,64,7,9,16,212,228,252,228,18,57,49,0,47,236,50,57,48,75,83,88,7, 16,5,237,7,16,8,237,7,16,8,237,7,16,5,237,89,34,178,0,10,1,1,93,64,60, 5,2,20,2,53,2,48,2,48,5,48,8,70,2,64,2,64,5,64,8,81,2,81,5,81,8,101,2, 132,2,147,2,16,22,1,26,3,31,10,38,1,41,3,55,1,56,3,64,10,103,1,104,3,120, 3,112,10,159,10,13,93,0,93,3,51,9,1,51,1,17,35,17,4,217,1,158,1,155,217, 253,240,203,5,213,253,154,2,102,252,242,253,57,2,199,0,0,0,0,1,0,92,0, 0,5,31,5,213,0,9,0,144,64,27,3,17,7,8,7,8,17,2,3,2,66,8,149,0,129,3,149, 5,8,3,0,1,66,4,0,6,10,16,220,75,176,9,84,75,176,10,84,91,88,185,0,6,255, 192,56,89,196,212,228,17,57,57,49,0,47,236,244,236,48,75,83,88,7,16,5, 237,7,16,5,237,89,34,1,64,64,5,2,10,7,24,7,41,2,38,7,56,7,72,2,71,7,72, 8,9,5,3,11,8,0,11,22,3,26,8,16,11,47,11,53,3,57,8,63,11,71,3,74,8,79,11, 85,3,89,8,102,3,105,8,111,11,119,3,120,8,127,11,159,11,22,93,0,93,19,33, 21,1,33,21,33,53,1,33,115,4,149,252,80,3,199,251,61,3,176,252,103,5,213, 154,251,111,170,154,4,145,0,0,0,1,0,176,254,242,2,88,6,20,0,7,0,59,64, 15,4,169,6,178,2,169,0,177,8,5,1,3,67,0,8,16,220,75,176,12,84,88,185,0, 0,0,64,56,89,75,176,18,84,75,176,19,84,91,88,185,0,0,255,192,56,89,252, 204,50,49,0,16,252,236,244,236,48,19,33,21,35,17,51,21,33,176,1,168,240, 240,254,88,6,20,143,249,252,143,0,0,0,1,0,199,254,242,2,111,6,20,0,7,0, 48,64,16,3,169,1,178,5,169,0,177,8,0,67,4,6,2,4,8,16,252,75,176,15,84, 75,176,16,84,91,88,185,0,2,0,64,56,89,60,220,236,49,0,16,252,236,244,236, 48,1,17,33,53,51,17,35,53,2,111,254,88,239,239,6,20,248,222,143,6,4,143, 0,1,0,217,3,168,5,219,5,213,0,6,0,24,64,10,3,4,1,0,129,7,3,1,5,7,16,220, 204,57,49,0,16,244,204,50,57,48,9,1,35,9,1,35,1,3,188,2,31,201,254,72, 254,72,201,2,31,5,213,253,211,1,139,254,117,2,45,0,0,1,255,236,254,29, 4,20,254,172,0,3,0,15,181,0,169,1,0,2,4,16,196,196,49,0,212,236,48,1,21, 33,53,4,20,251,216,254,172,143,143,0,0,0,0,2,0,123,255,227,4,45,4,123, 0,10,0,37,0,188,64,39,25,31,11,23,9,14,0,169,23,6,185,14,17,32,134,31, 186,28,185,35,184,17,140,23,12,0,23,3,24,13,9,8,11,31,3,8,20,69,38,16, 252,236,204,212,236,50,50,17,57,57,49,0,47,196,228,244,252,244,236,16, 198,238,16,238,17,57,17,57,18,57,48,64,110,48,29,48,30,48,31,48,32,48, 33,48,34,63,39,64,29,64,30,64,31,64,32,64,33,64,34,80,29,80,30,80,31,80, 32,80,33,80,34,80,39,112,39,133,29,135,30,135,31,135,32,135,33,133,34, 144,39,160,39,240,39,30,48,30,48,31,48,32,48,33,64,30,64,31,64,32,64,33, 80,30,80,31,80,32,80,33,96,30,96,31,96,32,96,33,112,30,112,31,112,32,112, 33,128,30,128,31,128,32,128,33,24,93,1,93,1,34,6,21,20,22,51,50,54,61, 1,55,17,35,53,14,1,35,34,38,53,52,54,51,33,53,52,38,35,34,6,7,53,62,1, 51,50,22,2,190,223,172,129,111,153,185,184,184,63,188,136,172,203,253, 251,1,2,167,151,96,182,84,101,190,90,243,240,2,51,102,123,98,115,217,180, 41,76,253,129,170,102,97,193,162,189,192,18,127,139,46,46,170,39,39,252, 0,0,2,0,186,255,227,4,164,6,20,0,11,0,28,0,56,64,25,3,185,12,15,9,185, 24,21,140,15,184,27,151,25,0,18,18,71,24,12,6,8,26,70,29,16,252,236,50, 50,244,236,49,0,47,236,228,244,196,236,16,198,238,48,182,96,30,128,30, 160,30,3,1,93,1,52,38,35,34,6,21,20,22,51,50,54,1,62,1,51,50,0,17,16,2, 35,34,38,39,21,35,17,51,3,229,167,146,146,167,167,146,146,167,253,142, 58,177,123,204,0,255,255,204,123,177,58,185,185,2,47,203,231,231,203,203, 231,231,2,82,100,97,254,188,254,248,254,248,254,188,97,100,168,6,20,0, 1,0,113,255,227,3,231,4,123,0,25,0,63,64,27,0,134,1,136,4,14,134,13,136, 10,185,17,4,185,23,184,17,140,26,7,18,13,0,72,20,69,26,16,252,228,50,236, 49,0,16,228,244,236,16,254,244,238,16,245,238,48,64,11,15,27,16,27,128, 27,144,27,160,27,5,1,93,1,21,46,1,35,34,6,21,20,22,51,50,54,55,21,14,1, 35,34,0,17,16,0,33,50,22,3,231,78,157,80,179,198,198,179,80,157,78,77, 165,93,253,254,214,1,45,1,6,85,162,4,53,172,43,43,227,205,205,227,43,43, 170,36,36,1,62,1,14,1,18,1,58,35,0,0,0,2,0,113,255,227,4,90,6,20,0,16, 0,28,0,56,64,25,26,185,0,14,20,185,5,8,140,14,184,1,151,3,23,4,0,8,2,71, 17,18,11,69,29,16,252,236,244,236,50,50,49,0,47,236,228,244,196,236,16, 196,238,48,182,96,30,128,30,160,30,3,1,93,1,17,51,17,35,53,14,1,35,34, 2,17,16,0,51,50,22,1,20,22,51,50,54,53,52,38,35,34,6,3,162,184,184,58, 177,124,203,255,0,255,203,124,177,253,199,167,146,146,168,168,146,146, 167,3,182,2,94,249,236,168,100,97,1,68,1,8,1,8,1,68,97,254,21,203,231, 231,203,203,231,231,0,2,0,113,255,227,4,127,4,123,0,20,0,27,0,112,64,36, 0,21,1,9,134,8,136,5,21,169,1,5,185,12,1,187,24,185,18,184,12,140,28,27, 21,2,8,21,8,0,75,2,18,15,69,28,16,252,236,244,236,196,17,18,57,49,0,16, 228,244,236,228,16,238,16,238,16,244,238,17,18,57,48,64,41,63,29,112,29, 160,29,208,29,240,29,5,63,0,63,1,63,2,63,21,63,27,5,44,7,47,8,47,9,44, 10,111,0,111,1,111,2,111,21,111,27,9,93,113,1,93,1,21,33,30,1,51,50,54, 55,21,14,1,35,32,0,17,16,0,51,50,0,7,46,1,35,34,6,7,4,127,252,178,12,205, 183,106,199,98,99,208,107,254,244,254,199,1,41,252,226,1,7,184,2,165,136, 154,185,14,2,94,90,190,199,52,52,174,42,44,1,56,1,10,1,19,1,67,254,221, 196,151,180,174,158,0,0,1,0,47,0,0,2,248,6,20,0,19,0,89,64,28,5,16,1,12, 8,169,6,1,135,0,151,14,6,188,10,2,19,7,0,7,9,5,8,13,15,11,76,20,16,252, 75,176,10,84,88,185,0,11,0,64,56,89,75,176,14,84,88,185,0,11,255,192,56, 89,60,196,252,60,196,196,18,57,57,49,0,47,228,50,252,236,16,238,50,18, 57,57,48,1,182,64,21,80,21,160,21,3,93,1,21,35,34,6,29,1,33,21,33,17,35, 17,35,53,51,53,52,54,51,2,248,176,99,77,1,47,254,209,185,176,176,174,189, 6,20,153,80,104,99,143,252,47,3,209,143,78,187,171,0,2,0,113,254,86,4, 90,4,123,0,11,0,40,0,74,64,35,25,12,29,9,18,134,19,22,185,15,3,185,38, 35,184,39,188,9,185,15,189,26,29,38,25,0,8,12,71,6,18,18,32,69,41,16,252, 196,236,244,236,50,50,49,0,47,196,228,236,228,244,196,236,16,254,213,238, 17,18,57,57,48,182,96,42,128,42,160,42,3,1,93,1,52,38,35,34,6,21,20,22, 51,50,54,23,16,2,33,34,38,39,53,30,1,51,50,54,61,1,14,1,35,34,2,17,16, 18,51,50,22,23,53,51,3,162,165,149,148,165,165,148,149,165,184,254,254, 250,97,172,81,81,158,82,181,180,57,178,124,206,252,252,206,124,178,57, 184,2,61,200,220,220,200,199,220,220,235,254,226,254,233,29,30,179,44, 42,189,191,91,99,98,1,58,1,3,1,4,1,58,98,99,170,0,0,1,0,186,0,0,4,100, 6,20,0,19,0,52,64,25,3,9,0,3,14,1,6,135,14,17,184,12,151,10,1,2,8,0,78, 13,9,8,11,70,20,16,252,236,50,244,236,49,0,47,60,236,244,196,236,17,18, 23,57,48,178,96,21,1,1,93,1,17,35,17,52,38,35,34,6,21,17,35,17,51,17,62, 1,51,50,22,4,100,184,124,124,149,172,185,185,66,179,117,193,198,2,164, 253,92,2,158,159,158,190,164,253,135,6,20,253,158,101,100,239,0,0,2,0, 193,0,0,1,121,6,20,0,3,0,7,0,43,64,14,6,190,4,177,0,188,2,5,1,8,4,0,70, 8,16,252,60,236,50,49,0,47,228,252,236,48,64,11,16,9,64,9,80,9,96,9,112, 9,5,1,93,19,51,17,35,17,51,21,35,193,184,184,184,184,4,96,251,160,6,20, 233,0,0,2,255,219,254,86,1,121,6,20,0,11,0,15,0,68,64,28,11,2,7,0,14,190, 12,7,135,5,189,0,188,12,177,16,8,16,5,6,79,13,1,8,12,0,70,16,16,252,60, 236,50,228,57,18,57,49,0,16,236,228,244,236,16,238,17,18,57,57,48,64,11, 16,17,64,17,80,17,96,17,112,17,5,1,93,19,51,17,20,6,43,1,53,51,50,54,53, 17,51,21,35,193,184,163,181,70,49,105,76,184,184,4,96,251,140,214,192, 156,97,153,6,40,233,0,0,0,1,0,186,0,0,4,156,6,20,0,10,0,188,64,41,8,17, 5,6,5,7,17,6,6,5,3,17,4,5,4,2,17,5,5,4,66,8,5,2,3,3,188,0,151,9,6,5,1, 4,6,8,1,8,0,70,11,16,252,236,50,212,196,17,57,49,0,47,60,236,228,23,57, 48,75,83,88,7,16,4,237,7,16,5,237,7,16,5,237,7,16,4,237,89,34,178,16,12, 1,1,93,64,95,4,2,10,8,22,2,39,2,41,5,43,8,86,2,102,2,103,8,115,2,119,5, 130,2,137,5,142,8,147,2,150,5,151,8,163,2,18,9,5,9,6,2,11,3,10,7,40,3, 39,4,40,5,43,6,43,7,64,12,104,3,96,12,137,3,133,4,137,5,141,6,143,7,154, 3,151,7,170,3,167,5,182,7,197,7,214,7,247,3,240,3,247,4,240,4,26,93,113, 0,93,19,51,17,1,51,9,1,35,1,17,35,186,185,2,37,235,253,174,2,107,240,253, 199,185,6,20,252,105,1,227,253,244,253,172,2,35,253,221,0,1,0,193,0,0, 1,121,6,20,0,3,0,34,183,0,151,2,1,8,0,70,4,16,252,236,49,0,47,236,48,64, 13,16,5,64,5,80,5,96,5,112,5,240,5,6,1,93,19,51,17,35,193,184,184,6,20, 249,236,0,0,1,0,186,0,0,7,29,4,123,0,34,0,90,64,38,6,18,9,24,15,0,6,29, 7,21,12,135,29,32,3,184,27,188,25,16,7,0,17,15,8,8,6,80,17,8,15,80,28, 24,8,26,70,35,16,252,236,50,252,252,252,236,17,18,57,49,0,47,60,60,228, 244,60,196,236,50,17,18,23,57,48,64,19,48,36,80,36,112,36,144,36,160,36, 160,36,191,36,223,36,255,36,9,1,93,1,62,1,51,50,22,21,17,35,17,52,38,35, 34,6,21,17,35,17,52,38,35,34,6,21,17,35,17,51,21,62,1,51,50,22,4,41,69, 192,130,175,190,185,114,117,143,166,185,114,119,141,166,185,185,63,176, 121,122,171,3,137,124,118,245,226,253,92,2,158,161,156,190,164,253,135, 2,158,162,155,191,163,253,135,4,96,174,103,98,124,0,0,0,0,1,0,186,0,0, 4,100,4,123,0,19,0,54,64,25,3,9,0,3,14,1,6,135,14,17,184,12,188,10,1,2, 8,0,78,13,9,8,11,70,20,16,252,236,50,244,236,49,0,47,60,228,244,196,236, 17,18,23,57,48,180,96,21,207,21,2,1,93,1,17,35,17,52,38,35,34,6,21,17, 35,17,51,21,62,1,51,50,22,4,100,184,124,124,149,172,185,185,66,179,117, 193,198,2,164,253,92,2,158,159,158,190,164,253,135,4,96,174,101,100,239, 0,2,0,113,255,227,4,117,4,123,0,11,0,23,0,74,64,19,6,185,18,0,185,12,184, 18,140,24,9,18,15,81,3,18,21,69,24,16,252,236,244,236,49,0,16,228,244, 236,16,238,48,64,35,63,25,123,0,123,6,127,7,127,8,127,9,127,10,127,11, 123,12,127,13,127,14,127,15,127,16,127,17,123,18,160,25,240,25,17,1,93, 1,34,6,21,20,22,51,50,54,53,52,38,39,50,0,17,16,0,35,34,0,17,16,0,2,115, 148,172,171,149,147,172,172,147,240,1,18,254,238,240,241,254,239,1,17, 3,223,231,201,201,231,232,200,199,233,156,254,200,254,236,254,237,254, 199,1,57,1,19,1,20,1,56,0,0,0,2,0,186,254,86,4,164,4,123,0,16,0,28,0,62, 64,27,26,185,0,14,20,185,5,8,184,14,140,1,189,3,188,29,17,18,11,71,23, 4,0,8,2,70,29,16,252,236,50,50,244,236,49,0,16,228,228,228,244,196,236, 16,196,238,48,64,9,96,30,128,30,160,30,224,30,4,1,93,37,17,35,17,51,21, 62,1,51,50,0,17,16,2,35,34,38,1,52,38,35,34,6,21,20,22,51,50,54,1,115, 185,185,58,177,123,204,0,255,255,204,123,177,2,56,167,146,146,167,167, 146,146,167,168,253,174,6,10,170,100,97,254,188,254,248,254,248,254,188, 97,1,235,203,231,231,203,203,231,231,0,0,0,0,2,0,113,254,86,4,90,4,123, 0,11,0,28,0,62,64,27,3,185,12,15,9,185,24,21,184,15,140,27,189,25,188, 29,24,12,6,8,26,71,0,18,18,69,29,16,252,236,244,236,50,50,49,0,16,228, 228,228,244,196,236,16,198,238,48,64,9,96,30,128,30,160,30,224,30,4,1, 93,1,20,22,51,50,54,53,52,38,35,34,6,1,14,1,35,34,2,17,16,0,51,50,22,23, 53,51,17,35,1,47,167,146,146,168,168,146,146,167,2,115,58,177,124,203, 255,0,255,203,124,177,58,184,184,2,47,203,231,231,203,203,231,231,253, 174,100,97,1,68,1,8,1,8,1,68,97,100,170,249,246,0,0,0,1,0,186,0,0,3,74, 4,123,0,17,0,48,64,20,6,11,7,0,17,11,3,135,14,184,9,188,7,10,6,8,0,8,70, 18,16,252,196,236,50,49,0,47,228,244,236,196,212,204,17,18,57,48,180,80, 19,159,19,2,1,93,1,46,1,35,34,6,21,17,35,17,51,21,62,1,51,50,22,23,3,74, 31,73,44,156,167,185,185,58,186,133,19,46,28,3,180,18,17,203,190,253,178, 4,96,174,102,99,5,5,0,0,0,1,0,111,255,227,3,199,4,123,0,39,0,231,64,60, 13,12,2,14,11,83,31,30,8,9,2,7,10,83,31,31,30,66,10,11,30,31,4,21,0,134, 1,137,4,20,134,21,137,24,185,17,4,185,37,184,17,140,40,30,10,11,31,27, 7,0,82,27,8,14,7,8,20,34,69,40,16,252,196,236,212,236,228,17,18,57,57, 57,57,49,0,16,228,244,236,16,254,245,238,16,245,238,18,23,57,48,75,83, 88,7,16,14,237,17,23,57,7,14,237,17,23,57,89,34,178,0,39,1,1,93,64,109, 28,10,28,11,28,12,46,9,44,10,44,11,44,12,59,9,59,10,59,11,59,12,11,32, 0,32,1,36,2,40,10,40,11,42,19,47,20,47,21,42,22,40,30,40,31,41,32,41,33, 36,39,134,10,134,11,134,12,134,13,18,0,0,0,1,2,2,6,10,6,11,3,12,3,13,3, 14,3,15,3,16,3,25,3,26,3,27,3,28,4,29,9,39,47,41,63,41,95,41,127,41,128, 41,144,41,160,41,240,41,24,93,0,93,113,1,21,46,1,35,34,6,21,20,22,31,1, 30,1,21,20,6,35,34,38,39,53,30,1,51,50,54,53,52,38,47,1,46,1,53,52,54, 51,50,22,3,139,78,168,90,137,137,98,148,63,196,165,247,216,90,195,108, 102,198,97,130,140,101,171,64,171,152,224,206,102,180,4,63,174,40,40,84, 84,64,73,33,14,42,153,137,156,182,35,35,190,53,53,89,81,75,80,37,15,36, 149,130,158,172,30,0,0,0,0,1,0,55,0,0,2,242,5,158,0,19,0,56,64,25,14,5, 8,15,3,169,0,17,1,188,8,135,10,11,8,9,2,4,0,8,16,18,14,70,20,16,252,60, 196,252,60,196,50,57,57,49,0,47,236,244,60,196,236,50,17,57,57,48,178, 175,21,1,1,93,1,17,33,21,33,17,20,22,59,1,21,35,34,38,53,17,35,53,51,17, 1,119,1,123,254,133,75,115,189,189,213,162,135,135,5,158,254,194,143,253, 160,137,78,154,159,210,2,96,143,1,62,0,0,0,0,2,0,174,255,227,4,88,4,123, 0,19,0,20,0,59,64,28,3,9,0,3,14,1,6,135,14,17,140,10,1,188,20,184,12,13, 9,8,20,11,78,2,8,0,70,21,16,252,236,244,57,236,50,49,0,47,228,228,50,244, 196,236,17,18,23,57,48,180,111,21,192,21,2,1,93,19,17,51,17,20,22,51,50, 54,53,17,51,17,35,53,14,1,35,34,38,1,174,184,124,124,149,173,184,184,67, 177,117,193,200,1,207,1,186,2,166,253,97,159,159,190,164,2,123,251,160, 172,102,99,240,3,168,0,0,1,0,61,0,0,4,127,4,96,0,6,0,251,64,39,3,17,4, 5,4,2,17,1,2,5,5,4,2,17,3,2,6,0,6,1,17,0,0,6,66,2,3,0,191,5,6,5,3,2,1, 5,4,0,7,16,212,75,176,10,84,88,185,0,0,0,64,56,89,75,176,20,84,75,176, 21,84,91,88,185,0,0,255,192,56,89,196,23,57,49,0,47,236,50,57,48,75,83, 88,7,16,5,237,7,16,8,237,7,16,8,237,7,16,5,237,89,34,1,64,142,72,2,106, 2,123,2,127,2,134,2,128,2,145,2,164,2,8,6,0,6,1,9,3,9,4,21,0,21,1,26,3, 26,4,38,0,38,1,41,3,41,4,32,8,53,0,53,1,58,3,58,4,48,8,70,0,70,1,73,3, 73,4,70,5,72,6,64,8,86,0,86,1,89,3,89,4,80,8,102,0,102,1,105,3,105,4,103, 5,104,6,96,8,117,0,116,1,123,3,123,4,117,5,122,6,133,0,133,1,137,3,137, 4,137,5,134,6,150,0,150,1,151,2,154,3,152,4,152,5,151,6,168,5,167,6,176, 8,192,8,223,8,255,8,62,93,0,93,19,51,9,1,51,1,35,61,195,1,94,1,94,195, 254,92,250,4,96,252,84,3,172,251,160,0,0,0,1,0,86,0,0,6,53,4,96,0,12,1, 235,64,73,5,85,6,5,9,10,9,4,85,10,9,3,85,10,11,10,2,85,1,2,11,11,10,6, 17,7,8,7,5,17,4,5,8,8,7,2,17,3,2,12,0,12,1,17,0,0,12,66,10,5,2,3,6,3,0, 191,11,8,12,11,10,9,8,6,5,4,3,2,1,11,7,0,13,16,212,75,176,10,84,75,176, 17,84,91,75,176,18,84,91,75,176,19,84,91,75,176,11,84,91,88,185,0,0,0, 64,56,89,1,75,176,12,84,75,176,13,84,91,75,176,16,84,91,88,185,0,0,255, 192,56,89,204,23,57,49,0,47,60,236,50,50,23,57,48,75,83,88,7,16,5,237, 7,16,8,237,7,16,8,237,7,16,5,237,7,16,8,237,7,16,5,237,7,5,237,7,16,8, 237,89,34,1,64,255,5,2,22,2,22,5,34,10,53,10,73,2,73,5,70,10,64,10,91, 2,91,5,85,10,80,10,110,2,110,5,102,10,121,2,127,2,121,5,127,5,135,2,153, 2,152,5,148,10,188,2,188,5,206,2,199,3,207,5,29,5,2,9,3,6,4,11,5,10,8, 11,9,4,11,5,12,21,2,25,3,22,4,26,5,27,8,27,9,20,11,21,12,37,0,37,1,35, 2,39,3,33,4,37,5,34,6,34,7,37,8,39,9,36,10,33,11,35,12,57,3,54,4,54,8, 57,12,48,14,70,2,72,3,70,4,64,4,66,5,64,6,64,7,64,8,68,9,68,10,68,11,64, 14,64,14,86,0,86,1,86,2,80,4,81,5,82,6,82,7,80,8,83,9,84,10,85,11,99,0, 100,1,101,2,106,3,101,4,106,5,106,6,106,7,110,9,97,11,103,12,111,14,117, 0,117,1,121,2,125,3,120,4,125,5,122,6,127,6,122,7,127,7,120,8,121,9,127, 9,123,10,118,11,125,12,135,2,136,5,143,14,151,0,151,1,148,2,147,3,156, 4,155,5,152,6,152,7,153,8,64,47,150,12,159,14,166,0,166,1,164,2,164,3, 171,4,171,5,169,6,169,7,171,8,164,12,175,14,181,2,177,3,189,4,187,5,184, 9,191,14,196,2,195,3,204,4,202,5,121,93,0,93,19,51,27,1,51,27,1,51,1,35, 11,1,35,86,184,230,229,217,230,229,184,254,219,217,241,242,217,4,96,252, 150,3,106,252,150,3,106,251,160,3,150,252,106,0,1,0,59,0,0,4,121,4,96, 0,11,1,67,64,70,5,17,6,7,6,4,17,3,4,7,7,6,4,17,5,4,1,2,1,3,17,2,2,1,11, 17,0,1,0,10,17,9,10,1,1,0,10,17,11,10,7,8,7,9,17,8,8,7,66,10,7,4,1,4,8, 0,191,5,2,10,7,4,1,4,8,0,2,8,6,12,16,212,75,176,10,84,75,176,15,84,91, 75,176,16,84,91,75,176,17,84,91,88,185,0,6,0,64,56,89,75,176,20,84,88, 185,0,6,255,192,56,89,196,212,196,17,23,57,49,0,47,60,236,50,23,57,48, 75,83,88,7,16,5,237,7,16,8,237,7,16,8,237,7,16,5,237,7,16,5,237,7,16,8, 237,7,16,8,237,7,16,5,237,89,34,1,64,152,10,4,4,10,26,4,21,10,38,10,61, 4,49,10,85,4,87,7,88,10,102,10,118,1,122,4,118,7,116,10,141,4,130,10,153, 4,159,4,151,7,146,10,144,10,166,1,169,4,175,4,165,7,163,10,160,10,28,10, 3,4,5,5,9,10,11,26,3,21,5,21,9,26,11,41,3,38,5,37,9,42,11,32,13,58,1,57, 3,55,5,52,7,54,9,57,11,48,13,73,3,70,5,69,9,74,11,64,13,89,0,86,1,89,2, 89,3,87,5,86,6,89,7,86,8,86,9,89,11,80,13,111,13,120,1,127,13,155,1,148, 7,171,1,164,7,176,13,207,13,223,13,255,13,47,93,0,93,9,2,35,9,1,35,9,1, 51,9,1,4,100,254,107,1,170,217,254,186,254,186,217,1,179,254,114,217,1, 41,1,41,4,96,253,223,253,193,1,184,254,72,2,74,2,22,254,113,1,143,0,0, 1,0,61,254,86,4,127,4,96,0,15,1,139,64,67,7,8,2,9,17,0,15,10,17,11,10, 0,0,15,14,17,15,0,15,13,17,12,13,0,0,15,13,17,14,13,10,11,10,12,17,11, 11,10,66,13,11,9,16,0,11,5,135,3,189,14,11,188,16,14,13,12,10,9,6,3,0, 8,15,4,15,11,16,16,212,75,176,10,84,75,176,8,84,91,88,185,0,11,0,64,56, 89,75,176,20,84,88,185,0,11,255,192,56,89,196,196,17,23,57,49,0,16,228, 50,244,236,17,57,17,57,18,57,48,75,83,88,7,16,5,237,7,16,8,237,7,16,8, 237,7,16,5,237,7,16,8,237,7,5,237,23,50,89,34,1,64,240,6,0,5,8,6,9,3,13, 22,10,23,13,16,13,35,13,53,13,73,10,79,10,78,13,90,9,90,10,106,10,135, 13,128,13,147,13,18,10,0,10,9,6,11,5,12,11,14,11,15,23,1,21,2,16,4,16, 5,23,10,20,11,20,12,26,14,26,15,39,0,36,1,36,2,32,4,32,5,41,8,40,9,37, 10,36,11,36,12,39,13,42,14,42,15,32,17,55,0,53,1,53,2,48,4,48,5,56,10, 54,11,54,12,56,13,57,14,57,15,48,17,65,0,64,1,64,2,64,3,64,4,64,5,64,6, 64,7,64,8,66,9,69,10,71,13,73,14,73,15,64,17,84,0,81,1,81,2,85,3,80,4, 80,5,86,6,85,7,86,8,87,9,87,10,85,11,85,12,89,14,89,15,80,17,102,1,102, 2,104,10,105,14,105,15,96,17,123,8,120,14,120,15,137,0,138,9,133,11,133, 12,137,13,137,14,137,15,153,9,149,11,149,12,154,14,154,15,164,11,164,12, 171,14,171,15,176,17,207,17,223,17,255,17,101,93,0,93,5,14,1,43,1,53,51, 50,54,63,1,1,51,9,1,51,2,147,78,148,124,147,108,76,84,51,33,254,59,195, 1,94,1,94,195,104,200,122,154,72,134,84,4,78,252,148,3,108,0,0,0,0,1,0, 88,0,0,3,219,4,96,0,9,0,157,64,26,8,17,2,3,2,3,17,7,8,7,66,8,169,0,188, 3,169,5,8,3,1,0,4,1,6,10,16,220,75,176,11,84,75,176,12,84,91,88,185,0, 6,255,192,56,89,75,176,19,84,88,185,0,6,0,64,56,89,196,50,196,17,57,57, 49,0,47,236,244,236,48,75,83,88,7,16,5,237,7,16,5,237,89,34,1,64,66,5, 2,22,2,38,2,71,2,73,7,5,11,8,15,11,24,3,27,8,43,8,32,11,54,3,57,8,48,11, 64,1,64,2,69,3,64,4,64,5,67,8,87,3,89,8,95,11,96,1,96,2,102,3,96,4,96, 5,98,8,127,11,128,11,175,11,27,93,0,93,19,33,21,1,33,21,33,53,1,33,113, 3,106,253,76,2,180,252,125,2,180,253,101,4,96,168,252,219,147,168,3,37, 0,0,1,1,0,254,178,4,23,6,20,0,36,0,119,64,52,25,15,21,11,6,37,9,26,16, 21,29,11,5,32,33,3,0,11,169,9,0,169,1,192,9,21,169,19,177,37,12,9,10,5, 36,22,25,0,29,10,5,19,2,20,0,32,25,67,10,15,5,37,16,212,75,176,12,84,88, 185,0,5,0,64,56,89,60,196,252,60,196,50,57,57,17,18,57,17,18,57,57,17, 18,57,57,49,0,16,252,236,196,244,236,16,238,18,23,57,18,57,17,57,57,17, 18,57,17,18,57,57,48,1,178,0,38,1,93,5,21,35,34,38,61,1,52,38,43,1,53, 51,50,54,61,1,52,54,59,1,21,35,34,6,29,1,20,6,7,30,1,29,1,20,22,51,4,23, 62,249,169,108,142,61,61,143,107,169,249,62,68,141,86,91,110,111,90,86, 141,190,144,148,221,239,151,116,143,115,149,240,221,147,143,88,141,248, 157,142,25,27,142,156,248,141,88,0,0,1,1,0,254,178,4,23,6,20,0,36,0,135, 64,54,31,37,27,22,12,15,8,27,11,21,25,15,4,5,32,3,0,25,169,27,0,169,35, 192,27,15,169,17,177,37,28,25,26,21,15,1,4,0,8,26,21,35,18,4,0,26,31,21, 67,16,0,11,4,37,16,212,75,176,10,84,88,185,0,4,255,192,56,89,75,176,14, 84,88,185,0,4,0,64,56,89,60,196,50,252,60,196,17,18,57,57,17,18,57,17, 18,57,57,17,18,57,57,49,0,16,252,236,196,244,236,16,238,18,23,57,17,18, 57,57,17,57,17,57,57,17,18,57,48,1,178,0,38,1,93,5,51,50,54,61,1,52,54, 55,46,1,61,1,52,38,43,1,53,51,50,22,29,1,20,22,59,1,21,35,34,6,29,1,20, 6,43,1,1,0,70,140,85,90,111,111,90,85,140,70,63,249,167,108,142,62,62, 142,108,167,249,63,190,86,143,248,156,142,27,25,142,157,248,142,87,143, 147,221,240,149,115,143,116,151,239,221,148,0,0,3,1,27,0,0,6,229,5,205, 0,23,0,47,0,73,0,67,64,38,61,203,62,58,204,65,202,36,49,203,48,52,204, 71,202,24,201,0,200,36,201,12,55,97,68,61,48,94,42,9,6,68,94,30,9,6,18, 74,16,220,204,252,236,16,254,237,50,16,238,49,0,47,238,246,254,253,238, 214,238,16,253,238,214,238,48,1,50,4,23,22,18,21,20,2,7,6,4,35,34,36,39, 38,2,53,52,18,55,54,36,23,34,6,7,14,1,21,20,22,23,30,1,51,50,54,55,62, 1,53,52,38,39,46,1,23,21,46,1,35,34,6,21,20,22,51,50,54,55,21,14,1,35, 34,38,53,52,54,51,50,22,4,0,152,1,7,109,109,108,108,109,109,254,249,152, 152,254,249,109,109,108,108,109,109,1,7,152,131,226,94,94,96,96,94,94, 226,131,132,227,94,93,93,94,92,94,227,167,66,130,66,149,167,171,155,64, 122,66,67,137,70,216,251,251,216,73,136,5,205,110,109,109,254,250,154, 152,254,251,109,109,110,110,109,109,1,5,152,154,1,6,109,109,110,103,94, 94,94,229,130,129,227,94,94,95,95,94,93,226,131,133,227,93,94,94,245,129, 33,32,175,157,159,174,31,34,127,29,28,244,208,209,242,28,0,0,0,0,1,0,213, 5,98,3,43,5,246,0,3,0,47,183,2,239,0,238,4,1,0,4,16,212,204,49,0,16,252, 236,48,0,75,176,9,84,75,176,14,84,91,88,189,0,4,255,192,0,1,0,4,0,4,0, 64,56,17,55,56,89,19,33,21,33,213,2,86,253,170,5,246,148,0,0,0,0,2,0,195, 3,117,3,61,5,240,0,11,0,26,0,32,64,17,6,195,21,196,0,195,12,145,27,9,90, 18,91,3,90,24,27,16,220,236,252,236,49,0,16,244,236,252,236,48,1,34,6, 21,20,22,51,50,54,53,52,38,39,50,22,23,30,1,21,20,6,35,34,38,53,52,54, 2,0,80,110,110,80,80,110,111,79,64,118,43,46,46,185,134,135,180,184,5, 111,111,80,79,109,109,79,79,112,129,49,46,45,114,66,132,183,180,135,134, 186,0,0,0,0,2,0,217,0,0,5,219,5,4,0,11,0,15,0,46,64,24,5,208,7,3,156,0, 208,9,1,12,156,14,13,2,21,4,0,23,12,8,21,10,6,16,16,212,60,236,50,252, 60,236,50,49,0,47,236,212,60,236,252,60,236,48,1,17,33,21,33,17,35,17, 33,53,33,17,1,33,21,33,3,174,2,45,253,211,168,253,211,2,45,253,211,5,2, 250,254,5,4,254,125,170,254,125,1,131,170,1,131,251,166,170,0,0,0,1,0, 6,255,4,6,33,5,36,0,2,0,0,23,9,1,6,3,13,3,14,252,6,32,249,224,0,0,1,0, 6,0,22,3,254,4,18,0,2,0,0,55,9,1,6,1,252,1,252,22,3,252,252,4,0,0,1,0, 6,255,4,6,33,5,36,0,2,0,0,23,17,1,6,6,27,252,6,32,252,240,0,0,0,0,1,0, 6,255,4,6,33,5,36,0,2,0,0,19,33,1,6,6,27,252,242,5,36,249,224,0,0,0,1, 0,6,0,22,3,254,4,18,0,2,0,0,19,33,1,6,3,248,254,4,4,18,252,4,0,0,0,1,0, 6,255,4,6,33,5,36,0,2,0,0,19,1,17,6,6,27,2,20,3,16,249,224,0,0,0,1,0,112, 255,4,6,139,5,32,0,23,0,19,64,7,6,18,24,25,12,0,24,16,220,212,204,49,0, 16,212,196,48,19,52,55,54,55,54,51,50,23,22,23,22,21,20,7,6,7,6,35,34, 39,38,39,38,112,105,104,182,181,210,209,181,182,104,105,105,104,182,181, 209,210,181,182,104,105,2,18,209,182,181,105,105,105,105,181,182,209,209, 182,181,105,105,105,105,181,182,0,0,0,0,26,1,62,0,1,0,0,0,0,0,0,0,152, 1,50,0,1,0,0,0,0,0,1,0,11,1,227,0,1,0,0,0,0,0,2,0,4,1,249,0,1,0,0,0,0, 0,3,0,11,2,22,0,1,0,0,0,0,0,4,0,11,2,58,0,1,0,0,0,0,0,5,0,12,2,96,0,1, 0,0,0,0,0,6,0,10,2,131,0,1,0,0,0,0,0,8,0,17,2,178,0,1,0,0,0,0,0,11,0,29, 3,0,0,1,0,0,0,0,0,13,18,157,40,90,0,1,0,0,0,0,0,14,0,52,59,98,0,1,0,0, 0,0,0,16,0,11,59,175,0,1,0,0,0,0,0,17,0,4,59,197,0,3,0,1,4,9,0,0,1,48, 0,0,0,3,0,1,4,9,0,1,0,22,1,203,0,3,0,1,4,9,0,2,0,8,1,239,0,3,0,1,4,9,0, 3,0,22,1,254,0,3,0,1,4,9,0,4,0,22,2,34,0,3,0,1,4,9,0,5,0,24,2,70,0,3,0, 1,4,9,0,6,0,20,2,109,0,3,0,1,4,9,0,8,0,34,2,142,0,3,0,1,4,9,0,11,0,58, 2,196,0,3,0,1,4,9,0,13,37,58,3,30,0,3,0,1,4,9,0,14,0,104,58,248,0,3,0, 1,4,9,0,16,0,22,59,151,0,3,0,1,4,9,0,17,0,8,59,187,0,67,0,111,0,112,0, 121,0,114,0,105,0,103,0,104,0,116,0,32,0,40,0,99,0,41,0,32,0,50,0,48,0, 48,0,51,0,32,0,98,0,121,0,32,0,66,0,105,0,116,0,115,0,116,0,114,0,101, 0,97,0,109,0,44,0,32,0,73,0,110,0,99,0,46,0,32,0,65,0,108,0,108,0,32,0, 82,0,105,0,103,0,104,0,116,0,115,0,32,0,82,0,101,0,115,0,101,0,114,0,118, 0,101,0,100,0,46,0,10,0,67,0,111,0,112,0,121,0,114,0,105,0,103,0,104,0, 116,0,32,0,40,0,99,0,41,0,32,0,50,0,48,0,48,0,54,0,32,0,98,0,121,0,32, 0,84,0,97,0,118,0,109,0,106,0,111,0,110,0,103,0,32,0,66,0,97,0,104,0,46, 0,32,0,65,0,108,0,108,0,32,0,82,0,105,0,103,0,104,0,116,0,115,0,32,0,82, 0,101,0,115,0,101,0,114,0,118,0,101,0,100,0,46,0,10,0,68,0,101,0,106,0, 97,0,86,0,117,0,32,0,99,0,104,0,97,0,110,0,103,0,101,0,115,0,32,0,97,0, 114,0,101,0,32,0,105,0,110,0,32,0,112,0,117,0,98,0,108,0,105,0,99,0,32, 0,100,0,111,0,109,0,97,0,105,0,110,0,10,0,0,67,111,112,121,114,105,103, 104,116,32,40,99,41,32,50,48,48,51,32,98,121,32,66,105,116,115,116,114, 101,97,109,44,32,73,110,99,46,32,65,108,108,32,82,105,103,104,116,115, 32,82,101,115,101,114,118,101,100,46,10,67,111,112,121,114,105,103,104, 116,32,40,99,41,32,50,48,48,54,32,98,121,32,84,97,118,109,106,111,110, 103,32,66,97,104,46,32,65,108,108,32,82,105,103,104,116,115,32,82,101, 115,101,114,118,101,100,46,10,68,101,106,97,86,117,32,99,104,97,110,103, 101,115,32,97,114,101,32,105,110,32,112,117,98,108,105,99,32,100,111,109, 97,105,110,10,0,0,68,0,101,0,106,0,97,0,86,0,117,0,32,0,83,0,97,0,110, 0,115,0,0,68,101,106,97,86,117,32,83,97,110,115,0,0,66,0,111,0,111,0,107, 0,0,66,111,111,107,0,0,68,0,101,0,106,0,97,0,86,0,117,0,32,0,83,0,97,0, 110,0,115,0,0,68,101,106,97,86,117,32,83,97,110,115,0,0,68,0,101,0,106, 0,97,0,86,0,117,0,32,0,83,0,97,0,110,0,115,0,0,68,101,106,97,86,117,32, 83,97,110,115,0,0,86,0,101,0,114,0,115,0,105,0,111,0,110,0,32,0,50,0,46, 0,51,0,53,0,0,86,101,114,115,105,111,110,32,50,46,51,53,0,0,68,0,101,0, 106,0,97,0,86,0,117,0,83,0,97,0,110,0,115,0,0,68,101,106,97,86,117,83, 97,110,115,0,0,68,0,101,0,106,0,97,0,86,0,117,0,32,0,102,0,111,0,110,0, 116,0,115,0,32,0,116,0,101,0,97,0,109,0,0,68,101,106,97,86,117,32,102, 111,110,116,115,32,116,101,97,109,0,0,104,0,116,0,116,0,112,0,58,0,47, 0,47,0,100,0,101,0,106,0,97,0,118,0,117,0,46,0,115,0,111,0,117,0,114,0, 99,0,101,0,102,0,111,0,114,0,103,0,101,0,46,0,110,0,101,0,116,0,0,104, 116,116,112,58,47,47,100,101,106,97,118,117,46,115,111,117,114,99,101, 102,111,114,103,101,46,110,101,116,0,0,70,0,111,0,110,0,116,0,115,0,32, 0,97,0,114,0,101,0,32,0,40,0,99,0,41,0,32,0,66,0,105,0,116,0,115,0,116, 0,114,0,101,0,97,0,109,0,32,0,40,0,115,0,101,0,101,0,32,0,98,0,101,0,108, 0,111,0,119,0,41,0,46,0,32,0,68,0,101,0,106,0,97,0,86,0,117,0,32,0,99, 0,104,0,97,0,110,0,103,0,101,0,115,0,32,0,97,0,114,0,101,0,32,0,105,0, 110,0,32,0,112,0,117,0,98,0,108,0,105,0,99,0,32,0,100,0,111,0,109,0,97, 0,105,0,110,0,46,0,32,0,71,0,108,0,121,0,112,0,104,0,115,0,32,0,105,0, 109,0,112,0,111,0,114,0,116,0,101,0,100,0,32,0,102,0,114,0,111,0,109,0, 32,0,65,0,114,0,101,0,118,0,32,0,102,0,111,0,110,0,116,0,115,0,32,0,97, 0,114,0,101,0,32,0,40,0,99,0,41,0,32,0,84,0,97,0,118,0,109,0,106,0,117, 0,110,0,103,0,32,0,66,0,97,0,104,0,32,0,40,0,115,0,101,0,101,0,32,0,98, 0,101,0,108,0,111,0,119,0,41,0,10,0,10,0,66,0,105,0,116,0,115,0,116,0, 114,0,101,0,97,0,109,0,32,0,86,0,101,0,114,0,97,0,32,0,70,0,111,0,110, 0,116,0,115,0,32,0,67,0,111,0,112,0,121,0,114,0,105,0,103,0,104,0,116, 0,10,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45, 0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45, 0,45,0,45,0,45,0,10,0,10,0,67,0,111,0,112,0,121,0,114,0,105,0,103,0,104, 0,116,0,32,0,40,0,99,0,41,0,32,0,50,0,48,0,48,0,51,0,32,0,98,0,121,0,32, 0,66,0,105,0,116,0,115,0,116,0,114,0,101,0,97,0,109,0,44,0,32,0,73,0,110, 0,99,0,46,0,32,0,65,0,108,0,108,0,32,0,82,0,105,0,103,0,104,0,116,0,115, 0,32,0,82,0,101,0,115,0,101,0,114,0,118,0,101,0,100,0,46,0,32,0,66,0,105, 0,116,0,115,0,116,0,114,0,101,0,97,0,109,0,32,0,86,0,101,0,114,0,97,0, 32,0,105,0,115,0,10,0,97,0,32,0,116,0,114,0,97,0,100,0,101,0,109,0,97, 0,114,0,107,0,32,0,111,0,102,0,32,0,66,0,105,0,116,0,115,0,116,0,114,0, 101,0,97,0,109,0,44,0,32,0,73,0,110,0,99,0,46,0,10,0,10,0,80,0,101,0,114, 0,109,0,105,0,115,0,115,0,105,0,111,0,110,0,32,0,105,0,115,0,32,0,104, 0,101,0,114,0,101,0,98,0,121,0,32,0,103,0,114,0,97,0,110,0,116,0,101,0, 100,0,44,0,32,0,102,0,114,0,101,0,101,0,32,0,111,0,102,0,32,0,99,0,104, 0,97,0,114,0,103,0,101,0,44,0,32,0,116,0,111,0,32,0,97,0,110,0,121,0,32, 0,112,0,101,0,114,0,115,0,111,0,110,0,32,0,111,0,98,0,116,0,97,0,105,0, 110,0,105,0,110,0,103,0,32,0,97,0,32,0,99,0,111,0,112,0,121,0,10,0,111, 0,102,0,32,0,116,0,104,0,101,0,32,0,102,0,111,0,110,0,116,0,115,0,32,0, 97,0,99,0,99,0,111,0,109,0,112,0,97,0,110,0,121,0,105,0,110,0,103,0,32, 0,116,0,104,0,105,0,115,0,32,0,108,0,105,0,99,0,101,0,110,0,115,0,101, 0,32,0,40,0,34,0,70,0,111,0,110,0,116,0,115,0,34,0,41,0,32,0,97,0,110, 0,100,0,32,0,97,0,115,0,115,0,111,0,99,0,105,0,97,0,116,0,101,0,100,0, 10,0,100,0,111,0,99,0,117,0,109,0,101,0,110,0,116,0,97,0,116,0,105,0,111, 0,110,0,32,0,102,0,105,0,108,0,101,0,115,0,32,0,40,0,116,0,104,0,101,0, 32,0,34,0,70,0,111,0,110,0,116,0,32,0,83,0,111,0,102,0,116,0,119,0,97, 0,114,0,101,0,34,0,41,0,44,0,32,0,116,0,111,0,32,0,114,0,101,0,112,0,114, 0,111,0,100,0,117,0,99,0,101,0,32,0,97,0,110,0,100,0,32,0,100,0,105,0, 115,0,116,0,114,0,105,0,98,0,117,0,116,0,101,0,32,0,116,0,104,0,101,0, 10,0,70,0,111,0,110,0,116,0,32,0,83,0,111,0,102,0,116,0,119,0,97,0,114, 0,101,0,44,0,32,0,105,0,110,0,99,0,108,0,117,0,100,0,105,0,110,0,103,0, 32,0,119,0,105,0,116,0,104,0,111,0,117,0,116,0,32,0,108,0,105,0,109,0, 105,0,116,0,97,0,116,0,105,0,111,0,110,0,32,0,116,0,104,0,101,0,32,0,114, 0,105,0,103,0,104,0,116,0,115,0,32,0,116,0,111,0,32,0,117,0,115,0,101, 0,44,0,32,0,99,0,111,0,112,0,121,0,44,0,32,0,109,0,101,0,114,0,103,0,101, 0,44,0,10,0,112,0,117,0,98,0,108,0,105,0,115,0,104,0,44,0,32,0,100,0,105, 0,115,0,116,0,114,0,105,0,98,0,117,0,116,0,101,0,44,0,32,0,97,0,110,0, 100,0,47,0,111,0,114,0,32,0,115,0,101,0,108,0,108,0,32,0,99,0,111,0,112, 0,105,0,101,0,115,0,32,0,111,0,102,0,32,0,116,0,104,0,101,0,32,0,70,0, 111,0,110,0,116,0,32,0,83,0,111,0,102,0,116,0,119,0,97,0,114,0,101,0,44, 0,32,0,97,0,110,0,100,0,32,0,116,0,111,0,32,0,112,0,101,0,114,0,109,0, 105,0,116,0,10,0,112,0,101,0,114,0,115,0,111,0,110,0,115,0,32,0,116,0, 111,0,32,0,119,0,104,0,111,0,109,0,32,0,116,0,104,0,101,0,32,0,70,0,111, 0,110,0,116,0,32,0,83,0,111,0,102,0,116,0,119,0,97,0,114,0,101,0,32,0, 105,0,115,0,32,0,102,0,117,0,114,0,110,0,105,0,115,0,104,0,101,0,100,0, 32,0,116,0,111,0,32,0,100,0,111,0,32,0,115,0,111,0,44,0,32,0,115,0,117, 0,98,0,106,0,101,0,99,0,116,0,32,0,116,0,111,0,32,0,116,0,104,0,101,0, 10,0,102,0,111,0,108,0,108,0,111,0,119,0,105,0,110,0,103,0,32,0,99,0,111, 0,110,0,100,0,105,0,116,0,105,0,111,0,110,0,115,0,58,0,10,0,10,0,84,0, 104,0,101,0,32,0,97,0,98,0,111,0,118,0,101,0,32,0,99,0,111,0,112,0,121, 0,114,0,105,0,103,0,104,0,116,0,32,0,97,0,110,0,100,0,32,0,116,0,114,0, 97,0,100,0,101,0,109,0,97,0,114,0,107,0,32,0,110,0,111,0,116,0,105,0,99, 0,101,0,115,0,32,0,97,0,110,0,100,0,32,0,116,0,104,0,105,0,115,0,32,0, 112,0,101,0,114,0,109,0,105,0,115,0,115,0,105,0,111,0,110,0,32,0,110,0, 111,0,116,0,105,0,99,0,101,0,32,0,115,0,104,0,97,0,108,0,108,0,10,0,98, 0,101,0,32,0,105,0,110,0,99,0,108,0,117,0,100,0,101,0,100,0,32,0,105,0, 110,0,32,0,97,0,108,0,108,0,32,0,99,0,111,0,112,0,105,0,101,0,115,0,32, 0,111,0,102,0,32,0,111,0,110,0,101,0,32,0,111,0,114,0,32,0,109,0,111,0, 114,0,101,0,32,0,111,0,102,0,32,0,116,0,104,0,101,0,32,0,70,0,111,0,110, 0,116,0,32,0,83,0,111,0,102,0,116,0,119,0,97,0,114,0,101,0,32,0,116,0, 121,0,112,0,101,0,102,0,97,0,99,0,101,0,115,0,46,0,10,0,10,0,84,0,104, 0,101,0,32,0,70,0,111,0,110,0,116,0,32,0,83,0,111,0,102,0,116,0,119,0, 97,0,114,0,101,0,32,0,109,0,97,0,121,0,32,0,98,0,101,0,32,0,109,0,111, 0,100,0,105,0,102,0,105,0,101,0,100,0,44,0,32,0,97,0,108,0,116,0,101,0, 114,0,101,0,100,0,44,0,32,0,111,0,114,0,32,0,97,0,100,0,100,0,101,0,100, 0,32,0,116,0,111,0,44,0,32,0,97,0,110,0,100,0,32,0,105,0,110,0,32,0,112, 0,97,0,114,0,116,0,105,0,99,0,117,0,108,0,97,0,114,0,10,0,116,0,104,0, 101,0,32,0,100,0,101,0,115,0,105,0,103,0,110,0,115,0,32,0,111,0,102,0, 32,0,103,0,108,0,121,0,112,0,104,0,115,0,32,0,111,0,114,0,32,0,99,0,104, 0,97,0,114,0,97,0,99,0,116,0,101,0,114,0,115,0,32,0,105,0,110,0,32,0,116, 0,104,0,101,0,32,0,70,0,111,0,110,0,116,0,115,0,32,0,109,0,97,0,121,0, 32,0,98,0,101,0,32,0,109,0,111,0,100,0,105,0,102,0,105,0,101,0,100,0,32, 0,97,0,110,0,100,0,10,0,97,0,100,0,100,0,105,0,116,0,105,0,111,0,110,0, 97,0,108,0,32,0,103,0,108,0,121,0,112,0,104,0,115,0,32,0,111,0,114,0,32, 0,99,0,104,0,97,0,114,0,97,0,99,0,116,0,101,0,114,0,115,0,32,0,109,0,97, 0,121,0,32,0,98,0,101,0,32,0,97,0,100,0,100,0,101,0,100,0,32,0,116,0,111, 0,32,0,116,0,104,0,101,0,32,0,70,0,111,0,110,0,116,0,115,0,44,0,32,0,111, 0,110,0,108,0,121,0,32,0,105,0,102,0,32,0,116,0,104,0,101,0,32,0,102,0, 111,0,110,0,116,0,115,0,10,0,97,0,114,0,101,0,32,0,114,0,101,0,110,0,97, 0,109,0,101,0,100,0,32,0,116,0,111,0,32,0,110,0,97,0,109,0,101,0,115,0, 32,0,110,0,111,0,116,0,32,0,99,0,111,0,110,0,116,0,97,0,105,0,110,0,105, 0,110,0,103,0,32,0,101,0,105,0,116,0,104,0,101,0,114,0,32,0,116,0,104, 0,101,0,32,0,119,0,111,0,114,0,100,0,115,0,32,0,34,0,66,0,105,0,116,0, 115,0,116,0,114,0,101,0,97,0,109,0,34,0,32,0,111,0,114,0,32,0,116,0,104, 0,101,0,32,0,119,0,111,0,114,0,100,0,10,0,34,0,86,0,101,0,114,0,97,0,34, 0,46,0,10,0,10,0,84,0,104,0,105,0,115,0,32,0,76,0,105,0,99,0,101,0,110, 0,115,0,101,0,32,0,98,0,101,0,99,0,111,0,109,0,101,0,115,0,32,0,110,0, 117,0,108,0,108,0,32,0,97,0,110,0,100,0,32,0,118,0,111,0,105,0,100,0,32, 0,116,0,111,0,32,0,116,0,104,0,101,0,32,0,101,0,120,0,116,0,101,0,110, 0,116,0,32,0,97,0,112,0,112,0,108,0,105,0,99,0,97,0,98,0,108,0,101,0,32, 0,116,0,111,0,32,0,70,0,111,0,110,0,116,0,115,0,32,0,111,0,114,0,32,0, 70,0,111,0,110,0,116,0,10,0,83,0,111,0,102,0,116,0,119,0,97,0,114,0,101, 0,32,0,116,0,104,0,97,0,116,0,32,0,104,0,97,0,115,0,32,0,98,0,101,0,101, 0,110,0,32,0,109,0,111,0,100,0,105,0,102,0,105,0,101,0,100,0,32,0,97,0, 110,0,100,0,32,0,105,0,115,0,32,0,100,0,105,0,115,0,116,0,114,0,105,0, 98,0,117,0,116,0,101,0,100,0,32,0,117,0,110,0,100,0,101,0,114,0,32,0,116, 0,104,0,101,0,32,0,34,0,66,0,105,0,116,0,115,0,116,0,114,0,101,0,97,0, 109,0,10,0,86,0,101,0,114,0,97,0,34,0,32,0,110,0,97,0,109,0,101,0,115, 0,46,0,10,0,10,0,84,0,104,0,101,0,32,0,70,0,111,0,110,0,116,0,32,0,83, 0,111,0,102,0,116,0,119,0,97,0,114,0,101,0,32,0,109,0,97,0,121,0,32,0, 98,0,101,0,32,0,115,0,111,0,108,0,100,0,32,0,97,0,115,0,32,0,112,0,97, 0,114,0,116,0,32,0,111,0,102,0,32,0,97,0,32,0,108,0,97,0,114,0,103,0,101, 0,114,0,32,0,115,0,111,0,102,0,116,0,119,0,97,0,114,0,101,0,32,0,112,0, 97,0,99,0,107,0,97,0,103,0,101,0,32,0,98,0,117,0,116,0,32,0,110,0,111, 0,10,0,99,0,111,0,112,0,121,0,32,0,111,0,102,0,32,0,111,0,110,0,101,0, 32,0,111,0,114,0,32,0,109,0,111,0,114,0,101,0,32,0,111,0,102,0,32,0,116, 0,104,0,101,0,32,0,70,0,111,0,110,0,116,0,32,0,83,0,111,0,102,0,116,0, 119,0,97,0,114,0,101,0,32,0,116,0,121,0,112,0,101,0,102,0,97,0,99,0,101, 0,115,0,32,0,109,0,97,0,121,0,32,0,98,0,101,0,32,0,115,0,111,0,108,0,100, 0,32,0,98,0,121,0,32,0,105,0,116,0,115,0,101,0,108,0,102,0,46,0,10,0,10, 0,84,0,72,0,69,0,32,0,70,0,79,0,78,0,84,0,32,0,83,0,79,0,70,0,84,0,87, 0,65,0,82,0,69,0,32,0,73,0,83,0,32,0,80,0,82,0,79,0,86,0,73,0,68,0,69, 0,68,0,32,0,34,0,65,0,83,0,32,0,73,0,83,0,34,0,44,0,32,0,87,0,73,0,84, 0,72,0,79,0,85,0,84,0,32,0,87,0,65,0,82,0,82,0,65,0,78,0,84,0,89,0,32, 0,79,0,70,0,32,0,65,0,78,0,89,0,32,0,75,0,73,0,78,0,68,0,44,0,32,0,69, 0,88,0,80,0,82,0,69,0,83,0,83,0,10,0,79,0,82,0,32,0,73,0,77,0,80,0,76, 0,73,0,69,0,68,0,44,0,32,0,73,0,78,0,67,0,76,0,85,0,68,0,73,0,78,0,71, 0,32,0,66,0,85,0,84,0,32,0,78,0,79,0,84,0,32,0,76,0,73,0,77,0,73,0,84, 0,69,0,68,0,32,0,84,0,79,0,32,0,65,0,78,0,89,0,32,0,87,0,65,0,82,0,82, 0,65,0,78,0,84,0,73,0,69,0,83,0,32,0,79,0,70,0,32,0,77,0,69,0,82,0,67, 0,72,0,65,0,78,0,84,0,65,0,66,0,73,0,76,0,73,0,84,0,89,0,44,0,10,0,70, 0,73,0,84,0,78,0,69,0,83,0,83,0,32,0,70,0,79,0,82,0,32,0,65,0,32,0,80, 0,65,0,82,0,84,0,73,0,67,0,85,0,76,0,65,0,82,0,32,0,80,0,85,0,82,0,80, 0,79,0,83,0,69,0,32,0,65,0,78,0,68,0,32,0,78,0,79,0,78,0,73,0,78,0,70, 0,82,0,73,0,78,0,71,0,69,0,77,0,69,0,78,0,84,0,32,0,79,0,70,0,32,0,67, 0,79,0,80,0,89,0,82,0,73,0,71,0,72,0,84,0,44,0,32,0,80,0,65,0,84,0,69, 0,78,0,84,0,44,0,10,0,84,0,82,0,65,0,68,0,69,0,77,0,65,0,82,0,75,0,44, 0,32,0,79,0,82,0,32,0,79,0,84,0,72,0,69,0,82,0,32,0,82,0,73,0,71,0,72, 0,84,0,46,0,32,0,73,0,78,0,32,0,78,0,79,0,32,0,69,0,86,0,69,0,78,0,84, 0,32,0,83,0,72,0,65,0,76,0,76,0,32,0,66,0,73,0,84,0,83,0,84,0,82,0,69, 0,65,0,77,0,32,0,79,0,82,0,32,0,84,0,72,0,69,0,32,0,71,0,78,0,79,0,77, 0,69,0,10,0,70,0,79,0,85,0,78,0,68,0,65,0,84,0,73,0,79,0,78,0,32,0,66, 0,69,0,32,0,76,0,73,0,65,0,66,0,76,0,69,0,32,0,70,0,79,0,82,0,32,0,65, 0,78,0,89,0,32,0,67,0,76,0,65,0,73,0,77,0,44,0,32,0,68,0,65,0,77,0,65, 0,71,0,69,0,83,0,32,0,79,0,82,0,32,0,79,0,84,0,72,0,69,0,82,0,32,0,76, 0,73,0,65,0,66,0,73,0,76,0,73,0,84,0,89,0,44,0,32,0,73,0,78,0,67,0,76, 0,85,0,68,0,73,0,78,0,71,0,10,0,65,0,78,0,89,0,32,0,71,0,69,0,78,0,69, 0,82,0,65,0,76,0,44,0,32,0,83,0,80,0,69,0,67,0,73,0,65,0,76,0,44,0,32, 0,73,0,78,0,68,0,73,0,82,0,69,0,67,0,84,0,44,0,32,0,73,0,78,0,67,0,73, 0,68,0,69,0,78,0,84,0,65,0,76,0,44,0,32,0,79,0,82,0,32,0,67,0,79,0,78, 0,83,0,69,0,81,0,85,0,69,0,78,0,84,0,73,0,65,0,76,0,32,0,68,0,65,0,77, 0,65,0,71,0,69,0,83,0,44,0,10,0,87,0,72,0,69,0,84,0,72,0,69,0,82,0,32, 0,73,0,78,0,32,0,65,0,78,0,32,0,65,0,67,0,84,0,73,0,79,0,78,0,32,0,79, 0,70,0,32,0,67,0,79,0,78,0,84,0,82,0,65,0,67,0,84,0,44,0,32,0,84,0,79, 0,82,0,84,0,32,0,79,0,82,0,32,0,79,0,84,0,72,0,69,0,82,0,87,0,73,0,83, 0,69,0,44,0,32,0,65,0,82,0,73,0,83,0,73,0,78,0,71,0,32,0,70,0,82,0,79, 0,77,0,44,0,32,0,79,0,85,0,84,0,32,0,79,0,70,0,10,0,84,0,72,0,69,0,32, 0,85,0,83,0,69,0,32,0,79,0,82,0,32,0,73,0,78,0,65,0,66,0,73,0,76,0,73, 0,84,0,89,0,32,0,84,0,79,0,32,0,85,0,83,0,69,0,32,0,84,0,72,0,69,0,32, 0,70,0,79,0,78,0,84,0,32,0,83,0,79,0,70,0,84,0,87,0,65,0,82,0,69,0,32, 0,79,0,82,0,32,0,70,0,82,0,79,0,77,0,32,0,79,0,84,0,72,0,69,0,82,0,32, 0,68,0,69,0,65,0,76,0,73,0,78,0,71,0,83,0,32,0,73,0,78,0,32,0,84,0,72, 0,69,0,10,0,70,0,79,0,78,0,84,0,32,0,83,0,79,0,70,0,84,0,87,0,65,0,82, 0,69,0,46,0,10,0,10,0,69,0,120,0,99,0,101,0,112,0,116,0,32,0,97,0,115, 0,32,0,99,0,111,0,110,0,116,0,97,0,105,0,110,0,101,0,100,0,32,0,105,0, 110,0,32,0,116,0,104,0,105,0,115,0,32,0,110,0,111,0,116,0,105,0,99,0,101, 0,44,0,32,0,116,0,104,0,101,0,32,0,110,0,97,0,109,0,101,0,115,0,32,0,111, 0,102,0,32,0,71,0,110,0,111,0,109,0,101,0,44,0,32,0,116,0,104,0,101,0, 32,0,71,0,110,0,111,0,109,0,101,0,10,0,70,0,111,0,117,0,110,0,100,0,97, 0,116,0,105,0,111,0,110,0,44,0,32,0,97,0,110,0,100,0,32,0,66,0,105,0,116, 0,115,0,116,0,114,0,101,0,97,0,109,0,32,0,73,0,110,0,99,0,46,0,44,0,32, 0,115,0,104,0,97,0,108,0,108,0,32,0,110,0,111,0,116,0,32,0,98,0,101,0, 32,0,117,0,115,0,101,0,100,0,32,0,105,0,110,0,32,0,97,0,100,0,118,0,101, 0,114,0,116,0,105,0,115,0,105,0,110,0,103,0,32,0,111,0,114,0,10,0,111, 0,116,0,104,0,101,0,114,0,119,0,105,0,115,0,101,0,32,0,116,0,111,0,32, 0,112,0,114,0,111,0,109,0,111,0,116,0,101,0,32,0,116,0,104,0,101,0,32, 0,115,0,97,0,108,0,101,0,44,0,32,0,117,0,115,0,101,0,32,0,111,0,114,0, 32,0,111,0,116,0,104,0,101,0,114,0,32,0,100,0,101,0,97,0,108,0,105,0,110, 0,103,0,115,0,32,0,105,0,110,0,32,0,116,0,104,0,105,0,115,0,32,0,70,0, 111,0,110,0,116,0,32,0,83,0,111,0,102,0,116,0,119,0,97,0,114,0,101,0,10, 0,119,0,105,0,116,0,104,0,111,0,117,0,116,0,32,0,112,0,114,0,105,0,111, 0,114,0,32,0,119,0,114,0,105,0,116,0,116,0,101,0,110,0,32,0,97,0,117,0, 116,0,104,0,111,0,114,0,105,0,122,0,97,0,116,0,105,0,111,0,110,0,32,0, 102,0,114,0,111,0,109,0,32,0,116,0,104,0,101,0,32,0,71,0,110,0,111,0,109, 0,101,0,32,0,70,0,111,0,117,0,110,0,100,0,97,0,116,0,105,0,111,0,110,0, 32,0,111,0,114,0,32,0,66,0,105,0,116,0,115,0,116,0,114,0,101,0,97,0,109, 0,10,0,73,0,110,0,99,0,46,0,44,0,32,0,114,0,101,0,115,0,112,0,101,0,99, 0,116,0,105,0,118,0,101,0,108,0,121,0,46,0,32,0,70,0,111,0,114,0,32,0, 102,0,117,0,114,0,116,0,104,0,101,0,114,0,32,0,105,0,110,0,102,0,111,0, 114,0,109,0,97,0,116,0,105,0,111,0,110,0,44,0,32,0,99,0,111,0,110,0,116, 0,97,0,99,0,116,0,58,0,32,0,102,0,111,0,110,0,116,0,115,0,32,0,97,0,116, 0,32,0,103,0,110,0,111,0,109,0,101,0,32,0,100,0,111,0,116,0,10,0,111,0, 114,0,103,0,46,0,32,0,10,0,10,0,65,0,114,0,101,0,118,0,32,0,70,0,111,0, 110,0,116,0,115,0,32,0,67,0,111,0,112,0,121,0,114,0,105,0,103,0,104,0, 116,0,10,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0, 45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0,45,0, 45,0,45,0,45,0,45,0,10,0,10,0,67,0,111,0,112,0,121,0,114,0,105,0,103,0, 104,0,116,0,32,0,40,0,99,0,41,0,32,0,50,0,48,0,48,0,54,0,32,0,98,0,121, 0,32,0,84,0,97,0,118,0,109,0,106,0,111,0,110,0,103,0,32,0,66,0,97,0,104, 0,46,0,32,0,65,0,108,0,108,0,32,0,82,0,105,0,103,0,104,0,116,0,115,0,32, 0,82,0,101,0,115,0,101,0,114,0,118,0,101,0,100,0,46,0,10,0,10,0,80,0,101, 0,114,0,109,0,105,0,115,0,115,0,105,0,111,0,110,0,32,0,105,0,115,0,32, 0,104,0,101,0,114,0,101,0,98,0,121,0,32,0,103,0,114,0,97,0,110,0,116,0, 101,0,100,0,44,0,32,0,102,0,114,0,101,0,101,0,32,0,111,0,102,0,32,0,99, 0,104,0,97,0,114,0,103,0,101,0,44,0,32,0,116,0,111,0,32,0,97,0,110,0,121, 0,32,0,112,0,101,0,114,0,115,0,111,0,110,0,32,0,111,0,98,0,116,0,97,0, 105,0,110,0,105,0,110,0,103,0,10,0,97,0,32,0,99,0,111,0,112,0,121,0,32, 0,111,0,102,0,32,0,116,0,104,0,101,0,32,0,102,0,111,0,110,0,116,0,115, 0,32,0,97,0,99,0,99,0,111,0,109,0,112,0,97,0,110,0,121,0,105,0,110,0,103, 0,32,0,116,0,104,0,105,0,115,0,32,0,108,0,105,0,99,0,101,0,110,0,115,0, 101,0,32,0,40,0,34,0,70,0,111,0,110,0,116,0,115,0,34,0,41,0,32,0,97,0, 110,0,100,0,10,0,97,0,115,0,115,0,111,0,99,0,105,0,97,0,116,0,101,0,100, 0,32,0,100,0,111,0,99,0,117,0,109,0,101,0,110,0,116,0,97,0,116,0,105,0, 111,0,110,0,32,0,102,0,105,0,108,0,101,0,115,0,32,0,40,0,116,0,104,0,101, 0,32,0,34,0,70,0,111,0,110,0,116,0,32,0,83,0,111,0,102,0,116,0,119,0,97, 0,114,0,101,0,34,0,41,0,44,0,32,0,116,0,111,0,32,0,114,0,101,0,112,0,114, 0,111,0,100,0,117,0,99,0,101,0,10,0,97,0,110,0,100,0,32,0,100,0,105,0, 115,0,116,0,114,0,105,0,98,0,117,0,116,0,101,0,32,0,116,0,104,0,101,0, 32,0,109,0,111,0,100,0,105,0,102,0,105,0,99,0,97,0,116,0,105,0,111,0,110, 0,115,0,32,0,116,0,111,0,32,0,116,0,104,0,101,0,32,0,66,0,105,0,116,0, 115,0,116,0,114,0,101,0,97,0,109,0,32,0,86,0,101,0,114,0,97,0,32,0,70, 0,111,0,110,0,116,0,32,0,83,0,111,0,102,0,116,0,119,0,97,0,114,0,101,0, 44,0,10,0,105,0,110,0,99,0,108,0,117,0,100,0,105,0,110,0,103,0,32,0,119, 0,105,0,116,0,104,0,111,0,117,0,116,0,32,0,108,0,105,0,109,0,105,0,116, 0,97,0,116,0,105,0,111,0,110,0,32,0,116,0,104,0,101,0,32,0,114,0,105,0, 103,0,104,0,116,0,115,0,32,0,116,0,111,0,32,0,117,0,115,0,101,0,44,0,32, 0,99,0,111,0,112,0,121,0,44,0,32,0,109,0,101,0,114,0,103,0,101,0,44,0, 32,0,112,0,117,0,98,0,108,0,105,0,115,0,104,0,44,0,10,0,100,0,105,0,115, 0,116,0,114,0,105,0,98,0,117,0,116,0,101,0,44,0,32,0,97,0,110,0,100,0, 47,0,111,0,114,0,32,0,115,0,101,0,108,0,108,0,32,0,99,0,111,0,112,0,105, 0,101,0,115,0,32,0,111,0,102,0,32,0,116,0,104,0,101,0,32,0,70,0,111,0, 110,0,116,0,32,0,83,0,111,0,102,0,116,0,119,0,97,0,114,0,101,0,44,0,32, 0,97,0,110,0,100,0,32,0,116,0,111,0,32,0,112,0,101,0,114,0,109,0,105,0, 116,0,10,0,112,0,101,0,114,0,115,0,111,0,110,0,115,0,32,0,116,0,111,0, 32,0,119,0,104,0,111,0,109,0,32,0,116,0,104,0,101,0,32,0,70,0,111,0,110, 0,116,0,32,0,83,0,111,0,102,0,116,0,119,0,97,0,114,0,101,0,32,0,105,0, 115,0,32,0,102,0,117,0,114,0,110,0,105,0,115,0,104,0,101,0,100,0,32,0, 116,0,111,0,32,0,100,0,111,0,32,0,115,0,111,0,44,0,32,0,115,0,117,0,98, 0,106,0,101,0,99,0,116,0,32,0,116,0,111,0,10,0,116,0,104,0,101,0,32,0, 102,0,111,0,108,0,108,0,111,0,119,0,105,0,110,0,103,0,32,0,99,0,111,0, 110,0,100,0,105,0,116,0,105,0,111,0,110,0,115,0,58,0,10,0,10,0,84,0,104, 0,101,0,32,0,97,0,98,0,111,0,118,0,101,0,32,0,99,0,111,0,112,0,121,0,114, 0,105,0,103,0,104,0,116,0,32,0,97,0,110,0,100,0,32,0,116,0,114,0,97,0, 100,0,101,0,109,0,97,0,114,0,107,0,32,0,110,0,111,0,116,0,105,0,99,0,101, 0,115,0,32,0,97,0,110,0,100,0,32,0,116,0,104,0,105,0,115,0,32,0,112,0, 101,0,114,0,109,0,105,0,115,0,115,0,105,0,111,0,110,0,32,0,110,0,111,0, 116,0,105,0,99,0,101,0,10,0,115,0,104,0,97,0,108,0,108,0,32,0,98,0,101, 0,32,0,105,0,110,0,99,0,108,0,117,0,100,0,101,0,100,0,32,0,105,0,110,0, 32,0,97,0,108,0,108,0,32,0,99,0,111,0,112,0,105,0,101,0,115,0,32,0,111, 0,102,0,32,0,111,0,110,0,101,0,32,0,111,0,114,0,32,0,109,0,111,0,114,0, 101,0,32,0,111,0,102,0,32,0,116,0,104,0,101,0,32,0,70,0,111,0,110,0,116, 0,32,0,83,0,111,0,102,0,116,0,119,0,97,0,114,0,101,0,10,0,116,0,121,0, 112,0,101,0,102,0,97,0,99,0,101,0,115,0,46,0,10,0,10,0,84,0,104,0,101, 0,32,0,70,0,111,0,110,0,116,0,32,0,83,0,111,0,102,0,116,0,119,0,97,0,114, 0,101,0,32,0,109,0,97,0,121,0,32,0,98,0,101,0,32,0,109,0,111,0,100,0,105, 0,102,0,105,0,101,0,100,0,44,0,32,0,97,0,108,0,116,0,101,0,114,0,101,0, 100,0,44,0,32,0,111,0,114,0,32,0,97,0,100,0,100,0,101,0,100,0,32,0,116, 0,111,0,44,0,32,0,97,0,110,0,100,0,32,0,105,0,110,0,10,0,112,0,97,0,114, 0,116,0,105,0,99,0,117,0,108,0,97,0,114,0,32,0,116,0,104,0,101,0,32,0, 100,0,101,0,115,0,105,0,103,0,110,0,115,0,32,0,111,0,102,0,32,0,103,0, 108,0,121,0,112,0,104,0,115,0,32,0,111,0,114,0,32,0,99,0,104,0,97,0,114, 0,97,0,99,0,116,0,101,0,114,0,115,0,32,0,105,0,110,0,32,0,116,0,104,0, 101,0,32,0,70,0,111,0,110,0,116,0,115,0,32,0,109,0,97,0,121,0,32,0,98, 0,101,0,10,0,109,0,111,0,100,0,105,0,102,0,105,0,101,0,100,0,32,0,97,0, 110,0,100,0,32,0,97,0,100,0,100,0,105,0,116,0,105,0,111,0,110,0,97,0,108, 0,32,0,103,0,108,0,121,0,112,0,104,0,115,0,32,0,111,0,114,0,32,0,99,0, 104,0,97,0,114,0,97,0,99,0,116,0,101,0,114,0,115,0,32,0,109,0,97,0,121, 0,32,0,98,0,101,0,32,0,97,0,100,0,100,0,101,0,100,0,32,0,116,0,111,0,32, 0,116,0,104,0,101,0,10,0,70,0,111,0,110,0,116,0,115,0,44,0,32,0,111,0, 110,0,108,0,121,0,32,0,105,0,102,0,32,0,116,0,104,0,101,0,32,0,102,0,111, 0,110,0,116,0,115,0,32,0,97,0,114,0,101,0,32,0,114,0,101,0,110,0,97,0, 109,0,101,0,100,0,32,0,116,0,111,0,32,0,110,0,97,0,109,0,101,0,115,0,32, 0,110,0,111,0,116,0,32,0,99,0,111,0,110,0,116,0,97,0,105,0,110,0,105,0, 110,0,103,0,32,0,101,0,105,0,116,0,104,0,101,0,114,0,10,0,116,0,104,0, 101,0,32,0,119,0,111,0,114,0,100,0,115,0,32,0,34,0,84,0,97,0,118,0,109, 0,106,0,111,0,110,0,103,0,32,0,66,0,97,0,104,0,34,0,32,0,111,0,114,0,32, 0,116,0,104,0,101,0,32,0,119,0,111,0,114,0,100,0,32,0,34,0,65,0,114,0, 101,0,118,0,34,0,46,0,10,0,10,0,84,0,104,0,105,0,115,0,32,0,76,0,105,0, 99,0,101,0,110,0,115,0,101,0,32,0,98,0,101,0,99,0,111,0,109,0,101,0,115, 0,32,0,110,0,117,0,108,0,108,0,32,0,97,0,110,0,100,0,32,0,118,0,111,0, 105,0,100,0,32,0,116,0,111,0,32,0,116,0,104,0,101,0,32,0,101,0,120,0,116, 0,101,0,110,0,116,0,32,0,97,0,112,0,112,0,108,0,105,0,99,0,97,0,98,0,108, 0,101,0,32,0,116,0,111,0,32,0,70,0,111,0,110,0,116,0,115,0,10,0,111,0, 114,0,32,0,70,0,111,0,110,0,116,0,32,0,83,0,111,0,102,0,116,0,119,0,97, 0,114,0,101,0,32,0,116,0,104,0,97,0,116,0,32,0,104,0,97,0,115,0,32,0,98, 0,101,0,101,0,110,0,32,0,109,0,111,0,100,0,105,0,102,0,105,0,101,0,100, 0,32,0,97,0,110,0,100,0,32,0,105,0,115,0,32,0,100,0,105,0,115,0,116,0, 114,0,105,0,98,0,117,0,116,0,101,0,100,0,32,0,117,0,110,0,100,0,101,0, 114,0,32,0,116,0,104,0,101,0,32,0,10,0,34,0,84,0,97,0,118,0,109,0,106, 0,111,0,110,0,103,0,32,0,66,0,97,0,104,0,32,0,65,0,114,0,101,0,118,0,34, 0,32,0,110,0,97,0,109,0,101,0,115,0,46,0,10,0,10,0,84,0,104,0,101,0,32, 0,70,0,111,0,110,0,116,0,32,0,83,0,111,0,102,0,116,0,119,0,97,0,114,0, 101,0,32,0,109,0,97,0,121,0,32,0,98,0,101,0,32,0,115,0,111,0,108,0,100, 0,32,0,97,0,115,0,32,0,112,0,97,0,114,0,116,0,32,0,111,0,102,0,32,0,97, 0,32,0,108,0,97,0,114,0,103,0,101,0,114,0,32,0,115,0,111,0,102,0,116,0, 119,0,97,0,114,0,101,0,32,0,112,0,97,0,99,0,107,0,97,0,103,0,101,0,32, 0,98,0,117,0,116,0,10,0,110,0,111,0,32,0,99,0,111,0,112,0,121,0,32,0,111, 0,102,0,32,0,111,0,110,0,101,0,32,0,111,0,114,0,32,0,109,0,111,0,114,0, 101,0,32,0,111,0,102,0,32,0,116,0,104,0,101,0,32,0,70,0,111,0,110,0,116, 0,32,0,83,0,111,0,102,0,116,0,119,0,97,0,114,0,101,0,32,0,116,0,121,0, 112,0,101,0,102,0,97,0,99,0,101,0,115,0,32,0,109,0,97,0,121,0,32,0,98, 0,101,0,32,0,115,0,111,0,108,0,100,0,32,0,98,0,121,0,10,0,105,0,116,0, 115,0,101,0,108,0,102,0,46,0,10,0,10,0,84,0,72,0,69,0,32,0,70,0,79,0,78, 0,84,0,32,0,83,0,79,0,70,0,84,0,87,0,65,0,82,0,69,0,32,0,73,0,83,0,32, 0,80,0,82,0,79,0,86,0,73,0,68,0,69,0,68,0,32,0,34,0,65,0,83,0,32,0,73, 0,83,0,34,0,44,0,32,0,87,0,73,0,84,0,72,0,79,0,85,0,84,0,32,0,87,0,65, 0,82,0,82,0,65,0,78,0,84,0,89,0,32,0,79,0,70,0,32,0,65,0,78,0,89,0,32, 0,75,0,73,0,78,0,68,0,44,0,10,0,69,0,88,0,80,0,82,0,69,0,83,0,83,0,32, 0,79,0,82,0,32,0,73,0,77,0,80,0,76,0,73,0,69,0,68,0,44,0,32,0,73,0,78, 0,67,0,76,0,85,0,68,0,73,0,78,0,71,0,32,0,66,0,85,0,84,0,32,0,78,0,79, 0,84,0,32,0,76,0,73,0,77,0,73,0,84,0,69,0,68,0,32,0,84,0,79,0,32,0,65, 0,78,0,89,0,32,0,87,0,65,0,82,0,82,0,65,0,78,0,84,0,73,0,69,0,83,0,32, 0,79,0,70,0,10,0,77,0,69,0,82,0,67,0,72,0,65,0,78,0,84,0,65,0,66,0,73, 0,76,0,73,0,84,0,89,0,44,0,32,0,70,0,73,0,84,0,78,0,69,0,83,0,83,0,32, 0,70,0,79,0,82,0,32,0,65,0,32,0,80,0,65,0,82,0,84,0,73,0,67,0,85,0,76, 0,65,0,82,0,32,0,80,0,85,0,82,0,80,0,79,0,83,0,69,0,32,0,65,0,78,0,68, 0,32,0,78,0,79,0,78,0,73,0,78,0,70,0,82,0,73,0,78,0,71,0,69,0,77,0,69, 0,78,0,84,0,10,0,79,0,70,0,32,0,67,0,79,0,80,0,89,0,82,0,73,0,71,0,72, 0,84,0,44,0,32,0,80,0,65,0,84,0,69,0,78,0,84,0,44,0,32,0,84,0,82,0,65, 0,68,0,69,0,77,0,65,0,82,0,75,0,44,0,32,0,79,0,82,0,32,0,79,0,84,0,72, 0,69,0,82,0,32,0,82,0,73,0,71,0,72,0,84,0,46,0,32,0,73,0,78,0,32,0,78, 0,79,0,32,0,69,0,86,0,69,0,78,0,84,0,32,0,83,0,72,0,65,0,76,0,76,0,10, 0,84,0,65,0,86,0,77,0,74,0,79,0,78,0,71,0,32,0,66,0,65,0,72,0,32,0,66, 0,69,0,32,0,76,0,73,0,65,0,66,0,76,0,69,0,32,0,70,0,79,0,82,0,32,0,65, 0,78,0,89,0,32,0,67,0,76,0,65,0,73,0,77,0,44,0,32,0,68,0,65,0,77,0,65, 0,71,0,69,0,83,0,32,0,79,0,82,0,32,0,79,0,84,0,72,0,69,0,82,0,32,0,76, 0,73,0,65,0,66,0,73,0,76,0,73,0,84,0,89,0,44,0,10,0,73,0,78,0,67,0,76, 0,85,0,68,0,73,0,78,0,71,0,32,0,65,0,78,0,89,0,32,0,71,0,69,0,78,0,69, 0,82,0,65,0,76,0,44,0,32,0,83,0,80,0,69,0,67,0,73,0,65,0,76,0,44,0,32, 0,73,0,78,0,68,0,73,0,82,0,69,0,67,0,84,0,44,0,32,0,73,0,78,0,67,0,73, 0,68,0,69,0,78,0,84,0,65,0,76,0,44,0,32,0,79,0,82,0,32,0,67,0,79,0,78, 0,83,0,69,0,81,0,85,0,69,0,78,0,84,0,73,0,65,0,76,0,10,0,68,0,65,0,77, 0,65,0,71,0,69,0,83,0,44,0,32,0,87,0,72,0,69,0,84,0,72,0,69,0,82,0,32, 0,73,0,78,0,32,0,65,0,78,0,32,0,65,0,67,0,84,0,73,0,79,0,78,0,32,0,79, 0,70,0,32,0,67,0,79,0,78,0,84,0,82,0,65,0,67,0,84,0,44,0,32,0,84,0,79, 0,82,0,84,0,32,0,79,0,82,0,32,0,79,0,84,0,72,0,69,0,82,0,87,0,73,0,83, 0,69,0,44,0,32,0,65,0,82,0,73,0,83,0,73,0,78,0,71,0,10,0,70,0,82,0,79, 0,77,0,44,0,32,0,79,0,85,0,84,0,32,0,79,0,70,0,32,0,84,0,72,0,69,0,32, 0,85,0,83,0,69,0,32,0,79,0,82,0,32,0,73,0,78,0,65,0,66,0,73,0,76,0,73, 0,84,0,89,0,32,0,84,0,79,0,32,0,85,0,83,0,69,0,32,0,84,0,72,0,69,0,32, 0,70,0,79,0,78,0,84,0,32,0,83,0,79,0,70,0,84,0,87,0,65,0,82,0,69,0,32, 0,79,0,82,0,32,0,70,0,82,0,79,0,77,0,10,0,79,0,84,0,72,0,69,0,82,0,32, 0,68,0,69,0,65,0,76,0,73,0,78,0,71,0,83,0,32,0,73,0,78,0,32,0,84,0,72, 0,69,0,32,0,70,0,79,0,78,0,84,0,32,0,83,0,79,0,70,0,84,0,87,0,65,0,82, 0,69,0,46,0,10,0,10,0,69,0,120,0,99,0,101,0,112,0,116,0,32,0,97,0,115, 0,32,0,99,0,111,0,110,0,116,0,97,0,105,0,110,0,101,0,100,0,32,0,105,0, 110,0,32,0,116,0,104,0,105,0,115,0,32,0,110,0,111,0,116,0,105,0,99,0,101, 0,44,0,32,0,116,0,104,0,101,0,32,0,110,0,97,0,109,0,101,0,32,0,111,0,102, 0,32,0,84,0,97,0,118,0,109,0,106,0,111,0,110,0,103,0,32,0,66,0,97,0,104, 0,32,0,115,0,104,0,97,0,108,0,108,0,32,0,110,0,111,0,116,0,10,0,98,0,101, 0,32,0,117,0,115,0,101,0,100,0,32,0,105,0,110,0,32,0,97,0,100,0,118,0, 101,0,114,0,116,0,105,0,115,0,105,0,110,0,103,0,32,0,111,0,114,0,32,0, 111,0,116,0,104,0,101,0,114,0,119,0,105,0,115,0,101,0,32,0,116,0,111,0, 32,0,112,0,114,0,111,0,109,0,111,0,116,0,101,0,32,0,116,0,104,0,101,0, 32,0,115,0,97,0,108,0,101,0,44,0,32,0,117,0,115,0,101,0,32,0,111,0,114, 0,32,0,111,0,116,0,104,0,101,0,114,0,10,0,100,0,101,0,97,0,108,0,105,0, 110,0,103,0,115,0,32,0,105,0,110,0,32,0,116,0,104,0,105,0,115,0,32,0,70, 0,111,0,110,0,116,0,32,0,83,0,111,0,102,0,116,0,119,0,97,0,114,0,101,0, 32,0,119,0,105,0,116,0,104,0,111,0,117,0,116,0,32,0,112,0,114,0,105,0, 111,0,114,0,32,0,119,0,114,0,105,0,116,0,116,0,101,0,110,0,32,0,97,0,117, 0,116,0,104,0,111,0,114,0,105,0,122,0,97,0,116,0,105,0,111,0,110,0,10, 0,102,0,114,0,111,0,109,0,32,0,84,0,97,0,118,0,109,0,106,0,111,0,110,0, 103,0,32,0,66,0,97,0,104,0,46,0,32,0,70,0,111,0,114,0,32,0,102,0,117,0, 114,0,116,0,104,0,101,0,114,0,32,0,105,0,110,0,102,0,111,0,114,0,109,0, 97,0,116,0,105,0,111,0,110,0,44,0,32,0,99,0,111,0,110,0,116,0,97,0,99, 0,116,0,58,0,32,0,116,0,97,0,118,0,109,0,106,0,111,0,110,0,103,0,32,0, 64,0,32,0,102,0,114,0,101,0,101,0,10,0,46,0,32,0,102,0,114,0,46,0,0,70, 111,110,116,115,32,97,114,101,32,40,99,41,32,66,105,116,115,116,114,101, 97,109,32,40,115,101,101,32,98,101,108,111,119,41,46,32,68,101,106,97, 86,117,32,99,104,97,110,103,101,115,32,97,114,101,32,105,110,32,112,117, 98,108,105,99,32,100,111,109,97,105,110,46,32,71,108,121,112,104,115,32, 105,109,112,111,114,116,101,100,32,102,114,111,109,32,65,114,101,118,32, 102,111,110,116,115,32,97,114,101,32,40,99,41,32,84,97,118,109,106,117, 110,103,32,66,97,104,32,40,115,101,101,32,98,101,108,111,119,41,10,10, 66,105,116,115,116,114,101,97,109,32,86,101,114,97,32,70,111,110,116,115, 32,67,111,112,121,114,105,103,104,116,10,45,45,45,45,45,45,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,10,10,67,111, 112,121,114,105,103,104,116,32,40,99,41,32,50,48,48,51,32,98,121,32,66, 105,116,115,116,114,101,97,109,44,32,73,110,99,46,32,65,108,108,32,82, 105,103,104,116,115,32,82,101,115,101,114,118,101,100,46,32,66,105,116, 115,116,114,101,97,109,32,86,101,114,97,32,105,115,10,97,32,116,114,97, 100,101,109,97,114,107,32,111,102,32,66,105,116,115,116,114,101,97,109, 44,32,73,110,99,46,10,10,80,101,114,109,105,115,115,105,111,110,32,105, 115,32,104,101,114,101,98,121,32,103,114,97,110,116,101,100,44,32,102, 114,101,101,32,111,102,32,99,104,97,114,103,101,44,32,116,111,32,97,110, 121,32,112,101,114,115,111,110,32,111,98,116,97,105,110,105,110,103,32, 97,32,99,111,112,121,10,111,102,32,116,104,101,32,102,111,110,116,115, 32,97,99,99,111,109,112,97,110,121,105,110,103,32,116,104,105,115,32,108, 105,99,101,110,115,101,32,40,34,70,111,110,116,115,34,41,32,97,110,100, 32,97,115,115,111,99,105,97,116,101,100,10,100,111,99,117,109,101,110, 116,97,116,105,111,110,32,102,105,108,101,115,32,40,116,104,101,32,34, 70,111,110,116,32,83,111,102,116,119,97,114,101,34,41,44,32,116,111,32, 114,101,112,114,111,100,117,99,101,32,97,110,100,32,100,105,115,116,114, 105,98,117,116,101,32,116,104,101,10,70,111,110,116,32,83,111,102,116, 119,97,114,101,44,32,105,110,99,108,117,100,105,110,103,32,119,105,116, 104,111,117,116,32,108,105,109,105,116,97,116,105,111,110,32,116,104,101, 32,114,105,103,104,116,115,32,116,111,32,117,115,101,44,32,99,111,112, 121,44,32,109,101,114,103,101,44,10,112,117,98,108,105,115,104,44,32,100, 105,115,116,114,105,98,117,116,101,44,32,97,110,100,47,111,114,32,115, 101,108,108,32,99,111,112,105,101,115,32,111,102,32,116,104,101,32,70, 111,110,116,32,83,111,102,116,119,97,114,101,44,32,97,110,100,32,116,111, 32,112,101,114,109,105,116,10,112,101,114,115,111,110,115,32,116,111,32, 119,104,111,109,32,116,104,101,32,70,111,110,116,32,83,111,102,116,119, 97,114,101,32,105,115,32,102,117,114,110,105,115,104,101,100,32,116,111, 32,100,111,32,115,111,44,32,115,117,98,106,101,99,116,32,116,111,32,116, 104,101,10,102,111,108,108,111,119,105,110,103,32,99,111,110,100,105,116, 105,111,110,115,58,10,10,84,104,101,32,97,98,111,118,101,32,99,111,112, 121,114,105,103,104,116,32,97,110,100,32,116,114,97,100,101,109,97,114, 107,32,110,111,116,105,99,101,115,32,97,110,100,32,116,104,105,115,32, 112,101,114,109,105,115,115,105,111,110,32,110,111,116,105,99,101,32,115, 104,97,108,108,10,98,101,32,105,110,99,108,117,100,101,100,32,105,110, 32,97,108,108,32,99,111,112,105,101,115,32,111,102,32,111,110,101,32,111, 114,32,109,111,114,101,32,111,102,32,116,104,101,32,70,111,110,116,32, 83,111,102,116,119,97,114,101,32,116,121,112,101,102,97,99,101,115,46, 10,10,84,104,101,32,70,111,110,116,32,83,111,102,116,119,97,114,101,32, 109,97,121,32,98,101,32,109,111,100,105,102,105,101,100,44,32,97,108,116, 101,114,101,100,44,32,111,114,32,97,100,100,101,100,32,116,111,44,32,97, 110,100,32,105,110,32,112,97,114,116,105,99,117,108,97,114,10,116,104, 101,32,100,101,115,105,103,110,115,32,111,102,32,103,108,121,112,104,115, 32,111,114,32,99,104,97,114,97,99,116,101,114,115,32,105,110,32,116,104, 101,32,70,111,110,116,115,32,109,97,121,32,98,101,32,109,111,100,105,102, 105,101,100,32,97,110,100,10,97,100,100,105,116,105,111,110,97,108,32, 103,108,121,112,104,115,32,111,114,32,99,104,97,114,97,99,116,101,114, 115,32,109,97,121,32,98,101,32,97,100,100,101,100,32,116,111,32,116,104, 101,32,70,111,110,116,115,44,32,111,110,108,121,32,105,102,32,116,104, 101,32,102,111,110,116,115,10,97,114,101,32,114,101,110,97,109,101,100, 32,116,111,32,110,97,109,101,115,32,110,111,116,32,99,111,110,116,97,105, 110,105,110,103,32,101,105,116,104,101,114,32,116,104,101,32,119,111,114, 100,115,32,34,66,105,116,115,116,114,101,97,109,34,32,111,114,32,116,104, 101,32,119,111,114,100,10,34,86,101,114,97,34,46,10,10,84,104,105,115, 32,76,105,99,101,110,115,101,32,98,101,99,111,109,101,115,32,110,117,108, 108,32,97,110,100,32,118,111,105,100,32,116,111,32,116,104,101,32,101, 120,116,101,110,116,32,97,112,112,108,105,99,97,98,108,101,32,116,111, 32,70,111,110,116,115,32,111,114,32,70,111,110,116,10,83,111,102,116,119, 97,114,101,32,116,104,97,116,32,104,97,115,32,98,101,101,110,32,109,111, 100,105,102,105,101,100,32,97,110,100,32,105,115,32,100,105,115,116,114, 105,98,117,116,101,100,32,117,110,100,101,114,32,116,104,101,32,34,66, 105,116,115,116,114,101,97,109,10,86,101,114,97,34,32,110,97,109,101,115, 46,10,10,84,104,101,32,70,111,110,116,32,83,111,102,116,119,97,114,101, 32,109,97,121,32,98,101,32,115,111,108,100,32,97,115,32,112,97,114,116, 32,111,102,32,97,32,108,97,114,103,101,114,32,115,111,102,116,119,97,114, 101,32,112,97,99,107,97,103,101,32,98,117,116,32,110,111,10,99,111,112, 121,32,111,102,32,111,110,101,32,111,114,32,109,111,114,101,32,111,102, 32,116,104,101,32,70,111,110,116,32,83,111,102,116,119,97,114,101,32,116, 121,112,101,102,97,99,101,115,32,109,97,121,32,98,101,32,115,111,108,100, 32,98,121,32,105,116,115,101,108,102,46,10,10,84,72,69,32,70,79,78,84, 32,83,79,70,84,87,65,82,69,32,73,83,32,80,82,79,86,73,68,69,68,32,34,65, 83,32,73,83,34,44,32,87,73,84,72,79,85,84,32,87,65,82,82,65,78,84,89,32, 79,70,32,65,78,89,32,75,73,78,68,44,32,69,88,80,82,69,83,83,10,79,82,32, 73,77,80,76,73,69,68,44,32,73,78,67,76,85,68,73,78,71,32,66,85,84,32,78, 79,84,32,76,73,77,73,84,69,68,32,84,79,32,65,78,89,32,87,65,82,82,65,78, 84,73,69,83,32,79,70,32,77,69,82,67,72,65,78,84,65,66,73,76,73,84,89,44, 10,70,73,84,78,69,83,83,32,70,79,82,32,65,32,80,65,82,84,73,67,85,76,65, 82,32,80,85,82,80,79,83,69,32,65,78,68,32,78,79,78,73,78,70,82,73,78,71, 69,77,69,78,84,32,79,70,32,67,79,80,89,82,73,71,72,84,44,32,80,65,84,69, 78,84,44,10,84,82,65,68,69,77,65,82,75,44,32,79,82,32,79,84,72,69,82,32, 82,73,71,72,84,46,32,73,78,32,78,79,32,69,86,69,78,84,32,83,72,65,76,76, 32,66,73,84,83,84,82,69,65,77,32,79,82,32,84,72,69,32,71,78,79,77,69,10, 70,79,85,78,68,65,84,73,79,78,32,66,69,32,76,73,65,66,76,69,32,70,79,82, 32,65,78,89,32,67,76,65,73,77,44,32,68,65,77,65,71,69,83,32,79,82,32,79, 84,72,69,82,32,76,73,65,66,73,76,73,84,89,44,32,73,78,67,76,85,68,73,78, 71,10,65,78,89,32,71,69,78,69,82,65,76,44,32,83,80,69,67,73,65,76,44,32, 73,78,68,73,82,69,67,84,44,32,73,78,67,73,68,69,78,84,65,76,44,32,79,82, 32,67,79,78,83,69,81,85,69,78,84,73,65,76,32,68,65,77,65,71,69,83,44,10, 87,72,69,84,72,69,82,32,73,78,32,65,78,32,65,67,84,73,79,78,32,79,70,32, 67,79,78,84,82,65,67,84,44,32,84,79,82,84,32,79,82,32,79,84,72,69,82,87, 73,83,69,44,32,65,82,73,83,73,78,71,32,70,82,79,77,44,32,79,85,84,32,79, 70,10,84,72,69,32,85,83,69,32,79,82,32,73,78,65,66,73,76,73,84,89,32,84, 79,32,85,83,69,32,84,72,69,32,70,79,78,84,32,83,79,70,84,87,65,82,69,32, 79,82,32,70,82,79,77,32,79,84,72,69,82,32,68,69,65,76,73,78,71,83,32,73, 78,32,84,72,69,10,70,79,78,84,32,83,79,70,84,87,65,82,69,46,10,10,69,120, 99,101,112,116,32,97,115,32,99,111,110,116,97,105,110,101,100,32,105,110, 32,116,104,105,115,32,110,111,116,105,99,101,44,32,116,104,101,32,110, 97,109,101,115,32,111,102,32,71,110,111,109,101,44,32,116,104,101,32,71, 110,111,109,101,10,70,111,117,110,100,97,116,105,111,110,44,32,97,110, 100,32,66,105,116,115,116,114,101,97,109,32,73,110,99,46,44,32,115,104, 97,108,108,32,110,111,116,32,98,101,32,117,115,101,100,32,105,110,32,97, 100,118,101,114,116,105,115,105,110,103,32,111,114,10,111,116,104,101, 114,119,105,115,101,32,116,111,32,112,114,111,109,111,116,101,32,116,104, 101,32,115,97,108,101,44,32,117,115,101,32,111,114,32,111,116,104,101, 114,32,100,101,97,108,105,110,103,115,32,105,110,32,116,104,105,115,32, 70,111,110,116,32,83,111,102,116,119,97,114,101,10,119,105,116,104,111, 117,116,32,112,114,105,111,114,32,119,114,105,116,116,101,110,32,97,117, 116,104,111,114,105,122,97,116,105,111,110,32,102,114,111,109,32,116,104, 101,32,71,110,111,109,101,32,70,111,117,110,100,97,116,105,111,110,32, 111,114,32,66,105,116,115,116,114,101,97,109,10,73,110,99,46,44,32,114, 101,115,112,101,99,116,105,118,101,108,121,46,32,70,111,114,32,102,117, 114,116,104,101,114,32,105,110,102,111,114,109,97,116,105,111,110,44,32, 99,111,110,116,97,99,116,58,32,102,111,110,116,115,32,97,116,32,103,110, 111,109,101,32,100,111,116,10,111,114,103,46,32,10,10,65,114,101,118,32, 70,111,110,116,115,32,67,111,112,121,114,105,103,104,116,10,45,45,45,45, 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45, 45,45,10,10,67,111,112,121,114,105,103,104,116,32,40,99,41,32,50,48,48, 54,32,98,121,32,84,97,118,109,106,111,110,103,32,66,97,104,46,32,65,108, 108,32,82,105,103,104,116,115,32,82,101,115,101,114,118,101,100,46,10, 10,80,101,114,109,105,115,115,105,111,110,32,105,115,32,104,101,114,101, 98,121,32,103,114,97,110,116,101,100,44,32,102,114,101,101,32,111,102, 32,99,104,97,114,103,101,44,32,116,111,32,97,110,121,32,112,101,114,115, 111,110,32,111,98,116,97,105,110,105,110,103,10,97,32,99,111,112,121,32, 111,102,32,116,104,101,32,102,111,110,116,115,32,97,99,99,111,109,112, 97,110,121,105,110,103,32,116,104,105,115,32,108,105,99,101,110,115,101, 32,40,34,70,111,110,116,115,34,41,32,97,110,100,10,97,115,115,111,99,105, 97,116,101,100,32,100,111,99,117,109,101,110,116,97,116,105,111,110,32, 102,105,108,101,115,32,40,116,104,101,32,34,70,111,110,116,32,83,111,102, 116,119,97,114,101,34,41,44,32,116,111,32,114,101,112,114,111,100,117, 99,101,10,97,110,100,32,100,105,115,116,114,105,98,117,116,101,32,116, 104,101,32,109,111,100,105,102,105,99,97,116,105,111,110,115,32,116,111, 32,116,104,101,32,66,105,116,115,116,114,101,97,109,32,86,101,114,97,32, 70,111,110,116,32,83,111,102,116,119,97,114,101,44,10,105,110,99,108,117, 100,105,110,103,32,119,105,116,104,111,117,116,32,108,105,109,105,116, 97,116,105,111,110,32,116,104,101,32,114,105,103,104,116,115,32,116,111, 32,117,115,101,44,32,99,111,112,121,44,32,109,101,114,103,101,44,32,112, 117,98,108,105,115,104,44,10,100,105,115,116,114,105,98,117,116,101,44, 32,97,110,100,47,111,114,32,115,101,108,108,32,99,111,112,105,101,115, 32,111,102,32,116,104,101,32,70,111,110,116,32,83,111,102,116,119,97,114, 101,44,32,97,110,100,32,116,111,32,112,101,114,109,105,116,10,112,101, 114,115,111,110,115,32,116,111,32,119,104,111,109,32,116,104,101,32,70, 111,110,116,32,83,111,102,116,119,97,114,101,32,105,115,32,102,117,114, 110,105,115,104,101,100,32,116,111,32,100,111,32,115,111,44,32,115,117, 98,106,101,99,116,32,116,111,10,116,104,101,32,102,111,108,108,111,119, 105,110,103,32,99,111,110,100,105,116,105,111,110,115,58,10,10,84,104, 101,32,97,98,111,118,101,32,99,111,112,121,114,105,103,104,116,32,97,110, 100,32,116,114,97,100,101,109,97,114,107,32,110,111,116,105,99,101,115, 32,97,110,100,32,116,104,105,115,32,112,101,114,109,105,115,115,105,111, 110,32,110,111,116,105,99,101,10,115,104,97,108,108,32,98,101,32,105,110, 99,108,117,100,101,100,32,105,110,32,97,108,108,32,99,111,112,105,101, 115,32,111,102,32,111,110,101,32,111,114,32,109,111,114,101,32,111,102, 32,116,104,101,32,70,111,110,116,32,83,111,102,116,119,97,114,101,10,116, 121,112,101,102,97,99,101,115,46,10,10,84,104,101,32,70,111,110,116,32, 83,111,102,116,119,97,114,101,32,109,97,121,32,98,101,32,109,111,100,105, 102,105,101,100,44,32,97,108,116,101,114,101,100,44,32,111,114,32,97,100, 100,101,100,32,116,111,44,32,97,110,100,32,105,110,10,112,97,114,116,105, 99,117,108,97,114,32,116,104,101,32,100,101,115,105,103,110,115,32,111, 102,32,103,108,121,112,104,115,32,111,114,32,99,104,97,114,97,99,116,101, 114,115,32,105,110,32,116,104,101,32,70,111,110,116,115,32,109,97,121, 32,98,101,10,109,111,100,105,102,105,101,100,32,97,110,100,32,97,100,100, 105,116,105,111,110,97,108,32,103,108,121,112,104,115,32,111,114,32,99, 104,97,114,97,99,116,101,114,115,32,109,97,121,32,98,101,32,97,100,100, 101,100,32,116,111,32,116,104,101,10,70,111,110,116,115,44,32,111,110, 108,121,32,105,102,32,116,104,101,32,102,111,110,116,115,32,97,114,101, 32,114,101,110,97,109,101,100,32,116,111,32,110,97,109,101,115,32,110, 111,116,32,99,111,110,116,97,105,110,105,110,103,32,101,105,116,104,101, 114,10,116,104,101,32,119,111,114,100,115,32,34,84,97,118,109,106,111, 110,103,32,66,97,104,34,32,111,114,32,116,104,101,32,119,111,114,100,32, 34,65,114,101,118,34,46,10,10,84,104,105,115,32,76,105,99,101,110,115, 101,32,98,101,99,111,109,101,115,32,110,117,108,108,32,97,110,100,32,118, 111,105,100,32,116,111,32,116,104,101,32,101,120,116,101,110,116,32,97, 112,112,108,105,99,97,98,108,101,32,116,111,32,70,111,110,116,115,10,111, 114,32,70,111,110,116,32,83,111,102,116,119,97,114,101,32,116,104,97,116, 32,104,97,115,32,98,101,101,110,32,109,111,100,105,102,105,101,100,32, 97,110,100,32,105,115,32,100,105,115,116,114,105,98,117,116,101,100,32, 117,110,100,101,114,32,116,104,101,32,10,34,84,97,118,109,106,111,110, 103,32,66,97,104,32,65,114,101,118,34,32,110,97,109,101,115,46,10,10,84, 104,101,32,70,111,110,116,32,83,111,102,116,119,97,114,101,32,109,97,121, 32,98,101,32,115,111,108,100,32,97,115,32,112,97,114,116,32,111,102,32, 97,32,108,97,114,103,101,114,32,115,111,102,116,119,97,114,101,32,112, 97,99,107,97,103,101,32,98,117,116,10,110,111,32,99,111,112,121,32,111, 102,32,111,110,101,32,111,114,32,109,111,114,101,32,111,102,32,116,104, 101,32,70,111,110,116,32,83,111,102,116,119,97,114,101,32,116,121,112, 101,102,97,99,101,115,32,109,97,121,32,98,101,32,115,111,108,100,32,98, 121,10,105,116,115,101,108,102,46,10,10,84,72,69,32,70,79,78,84,32,83, 79,70,84,87,65,82,69,32,73,83,32,80,82,79,86,73,68,69,68,32,34,65,83,32, 73,83,34,44,32,87,73,84,72,79,85,84,32,87,65,82,82,65,78,84,89,32,79,70, 32,65,78,89,32,75,73,78,68,44,10,69,88,80,82,69,83,83,32,79,82,32,73,77, 80,76,73,69,68,44,32,73,78,67,76,85,68,73,78,71,32,66,85,84,32,78,79,84, 32,76,73,77,73,84,69,68,32,84,79,32,65,78,89,32,87,65,82,82,65,78,84,73, 69,83,32,79,70,10,77,69,82,67,72,65,78,84,65,66,73,76,73,84,89,44,32,70, 73,84,78,69,83,83,32,70,79,82,32,65,32,80,65,82,84,73,67,85,76,65,82,32, 80,85,82,80,79,83,69,32,65,78,68,32,78,79,78,73,78,70,82,73,78,71,69,77, 69,78,84,10,79,70,32,67,79,80,89,82,73,71,72,84,44,32,80,65,84,69,78,84, 44,32,84,82,65,68,69,77,65,82,75,44,32,79,82,32,79,84,72,69,82,32,82,73, 71,72,84,46,32,73,78,32,78,79,32,69,86,69,78,84,32,83,72,65,76,76,10,84, 65,86,77,74,79,78,71,32,66,65,72,32,66,69,32,76,73,65,66,76,69,32,70,79, 82,32,65,78,89,32,67,76,65,73,77,44,32,68,65,77,65,71,69,83,32,79,82,32, 79,84,72,69,82,32,76,73,65,66,73,76,73,84,89,44,10,73,78,67,76,85,68,73, 78,71,32,65,78,89,32,71,69,78,69,82,65,76,44,32,83,80,69,67,73,65,76,44, 32,73,78,68,73,82,69,67,84,44,32,73,78,67,73,68,69,78,84,65,76,44,32,79, 82,32,67,79,78,83,69,81,85,69,78,84,73,65,76,10,68,65,77,65,71,69,83,44, 32,87,72,69,84,72,69,82,32,73,78,32,65,78,32,65,67,84,73,79,78,32,79,70, 32,67,79,78,84,82,65,67,84,44,32,84,79,82,84,32,79,82,32,79,84,72,69,82, 87,73,83,69,44,32,65,82,73,83,73,78,71,10,70,82,79,77,44,32,79,85,84,32, 79,70,32,84,72,69,32,85,83,69,32,79,82,32,73,78,65,66,73,76,73,84,89,32, 84,79,32,85,83,69,32,84,72,69,32,70,79,78,84,32,83,79,70,84,87,65,82,69, 32,79,82,32,70,82,79,77,10,79,84,72,69,82,32,68,69,65,76,73,78,71,83,32, 73,78,32,84,72,69,32,70,79,78,84,32,83,79,70,84,87,65,82,69,46,10,10,69, 120,99,101,112,116,32,97,115,32,99,111,110,116,97,105,110,101,100,32,105, 110,32,116,104,105,115,32,110,111,116,105,99,101,44,32,116,104,101,32, 110,97,109,101,32,111,102,32,84,97,118,109,106,111,110,103,32,66,97,104, 32,115,104,97,108,108,32,110,111,116,10,98,101,32,117,115,101,100,32,105, 110,32,97,100,118,101,114,116,105,115,105,110,103,32,111,114,32,111,116, 104,101,114,119,105,115,101,32,116,111,32,112,114,111,109,111,116,101, 32,116,104,101,32,115,97,108,101,44,32,117,115,101,32,111,114,32,111,116, 104,101,114,10,100,101,97,108,105,110,103,115,32,105,110,32,116,104,105, 115,32,70,111,110,116,32,83,111,102,116,119,97,114,101,32,119,105,116, 104,111,117,116,32,112,114,105,111,114,32,119,114,105,116,116,101,110, 32,97,117,116,104,111,114,105,122,97,116,105,111,110,10,102,114,111,109, 32,84,97,118,109,106,111,110,103,32,66,97,104,46,32,70,111,114,32,102, 117,114,116,104,101,114,32,105,110,102,111,114,109,97,116,105,111,110, 44,32,99,111,110,116,97,99,116,58,32,116,97,118,109,106,111,110,103,32, 64,32,102,114,101,101,10,46,32,102,114,46,0,0,104,0,116,0,116,0,112,0, 58,0,47,0,47,0,100,0,101,0,106,0,97,0,118,0,117,0,46,0,115,0,111,0,117, 0,114,0,99,0,101,0,102,0,111,0,114,0,103,0,101,0,46,0,110,0,101,0,116, 0,47,0,119,0,105,0,107,0,105,0,47,0,105,0,110,0,100,0,101,0,120,0,46,0, 112,0,104,0,112,0,47,0,76,0,105,0,99,0,101,0,110,0,115,0,101,0,0,104,116, 116,112,58,47,47,100,101,106,97,118,117,46,115,111,117,114,99,101,102, 111,114,103,101,46,110,101,116,47,119,105,107,105,47,105,110,100,101,120, 46,112,104,112,47,76,105,99,101,110,115,101,0,0,68,0,101,0,106,0,97,0, 86,0,117,0,32,0,83,0,97,0,110,0,115,0,0,68,101,106,97,86,117,32,83,97, 110,115,0,0,66,0,111,0,111,0,107,0,0,66,111,111,107,0,0,2,0,0,0,0,0,0, 255,126,0,90,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,104,0,0,0,1,0,2, 0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0,12,0,13,0,14,0,15,0,16,0,17,0, 18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,0,29,0,31,0,32,0, 33,0,34,0,35,0,36,0,37,0,38,0,39,0,40,0,41,0,42,0,43,0,44,0,45,0,46,0, 47,0,48,0,49,0,50,0,51,0,52,0,53,0,54,0,55,0,56,0,57,0,58,0,59,0,60,0, 61,0,62,0,64,0,65,0,66,0,68,0,69,0,70,0,71,0,72,0,73,0,74,0,75,0,76,0, 77,0,78,0,79,0,80,0,81,0,82,0,83,0,84,0,85,0,86,0,87,0,88,0,89,0,90,0, 91,0,92,0,93,0,94,0,96,0,139,0,218,0,131,0,147,1,2,1,3,1,4,1,5,1,6,1,7, 1,8,7,116,114,105,97,103,117,112,7,117,110,105,50,53,66,52,7,117,110,105, 50,53,66,54,7,116,114,105,97,103,100,110,7,117,110,105,50,53,66,69,7,117, 110,105,50,53,67,48,6,72,49,56,53,51,51,0,0,0,0,0,0,2,0,8,0,2,255,255, 0,3,0,1,0,0,0,14,0,0,0,24,0,32,0,0,0,2,0,1,0,3,0,103,0,1,0,4,0,0,0,2,0, 0,0,1,0,0,0,1,0,0,0,1,0,0,0,10,1,194,1,248,0,20,68,70,76,84,0,122,97,114, 97,98,0,134,97,114,109,110,0,164,98,114,97,105,0,176,99,97,110,115,0,188, 99,104,101,114,0,200,99,121,114,108,0,212,103,101,111,114,0,236,103,114, 101,107,0,248,104,97,110,105,1,4,104,101,98,114,1,16,107,97,110,97,1,28, 108,97,111,32,1,40,108,97,116,110,1,52,109,97,116,104,1,112,110,107,111, 32,1,124,111,103,97,109,1,136,114,117,110,114,1,148,116,102,110,103,1, 160,116,104,97,105,1,172,0,4,0,0,0,0,0,0,0,1,0,1,0,22,0,3,75,85,82,32, 0,22,83,78,68,32,0,22,85,82,68,32,0,22,0,0,255,255,0,1,0,2,0,4,0,0,0,0, 255,255,0,1,0,1,0,4,0,0,0,0,255,255,0,1,0,1,0,4,0,0,0,0,255,255,0,1,0, 1,0,4,0,0,0,0,255,255,0,1,0,1,0,16,0,2,77,75,68,32,0,16,83,82,66,32,0, 16,0,0,255,255,0,1,0,3,0,4,0,0,0,0,255,255,0,1,0,1,0,4,0,0,0,0,255,255, 0,1,0,3,0,4,0,0,0,0,255,255,0,1,0,1,0,4,0,0,0,0,255,255,0,1,0,2,0,4,0, 0,0,0,255,255,0,1,0,1,0,4,0,0,0,0,255,255,0,1,0,1,0,52,0,8,73,83,77,32, 0,52,75,83,77,32,0,52,76,83,77,32,0,52,77,79,76,32,0,52,78,83,77,32,0, 52,82,79,77,32,0,52,83,75,83,32,0,52,83,83,77,32,0,52,0,0,255,255,0,1, 0,3,0,4,0,0,0,0,255,255,0,1,0,1,0,4,0,0,0,0,0,0,0,1,0,2,0,4,0,0,0,0,255, 255,0,1,0,1,0,4,0,0,0,0,255,255,0,1,0,1,0,4,0,0,0,0,255,255,0,1,0,1,0, 4,0,0,0,0,255,255,0,1,0,1,0,4,32,82,81,68,0,26,99,99,109,112,0,32,99,99, 109,112,0,38,99,99,109,112,0,46,0,0,0,1,0,0,0,0,0,1,0,3,0,0,0,2,0,1,0, 3,0,0,0,2,0,2,0,3,0,4,0,10,0,18,0,26,0,34,0,6,0,9,0,1,0,50,0,6,0,1,0,1, 0,110,0,6,0,0,0,1,0,154,0,6,0,0,0,10,1,60,1,126,1,192,2,2,2,68,2,134,2, 186,2,238,3,34,3,86,0,2,0,16,0,20,0,20,0,20,0,2,0,0,0,28,0,1,0,0,0,1,0, 0,0,1,0,0,0,3,0,8,0,20,0,30,0,1,0,1,0,1,0,1,0,1,0,0,0,1,0,1,0,1,0,0,0, 0,0,0,0,1,0,1,0,1,0,0,0,2,0,18,0,22,0,30,0,30,0,3,0,0,0,38,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,4,0,0,0,1,0,1,0,2,0,0,0,2,0,22,0, 30,0,30,0,30,0,5,0,0,0,82,0,126,0,0,0,0,0,1,0,2,0,73,0,74,0,2,0,8,0,35, 0,60,0,3,0,66,0,66,0,3,0,68,0,68,0,3,0,70,0,70,0,3,0,72,0,72,0,3,0,73, 0,74,0,1,0,75,0,76,0,3,0,84,0,84,0,3,0,3,0,8,0,18,0,30,0,0,0,1,0,1,0,2, 0,0,0,0,0,1,0,2,0,4,0,2,0,0,0,0,0,1,0,3,0,4,0,4,0,2,0,0,0,3,0,8,0,18,0, 30,0,1,0,3,0,1,0,0,0,0,0,2,0,4,0,3,0,1,0,0,0,0,0,3,0,4,0,4,0,3,0,1,0,0, 0,0,0,2,0,18,0,22,0,30,0,30,0,3,0,0,0,38,0,52,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,1,0,4,0,0,0,1,0,1,0,1,0,0,0,1,0,4,0,0,0,1,0,1,0,1,0, 0,0,2,0,18,0,22,0,30,0,30,0,3,0,0,0,38,0,52,0,1,0,0,0,1,0,0,0,1,0,0,0, 1,0,0,0,1,0,0,0,1,0,4,0,0,0,1,0,1,0,1,0,0,0,1,0,4,0,0,0,1,0,1,0,1,0,0, 0,2,0,18,0,22,0,30,0,30,0,3,0,0,0,38,0,52,0,1,0,0,0,1,0,0,0,1,0,0,0,1, 0,0,0,1,0,0,0,1,0,4,0,0,0,1,0,1,0,1,0,0,0,1,0,4,0,0,0,1,0,1,0,1,0,0,0, 2,0,18,0,22,0,30,0,30,0,3,0,0,0,38,0,52,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0, 0,0,1,0,0,0,1,0,4,0,0,0,1,0,1,0,1,0,0,0,1,0,4,0,0,0,1,0,1,0,1,0,0,0,2, 0,18,0,22,0,30,0,30,0,3,0,0,0,38,0,52,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,4,0,0,0,1,0,1,0,1,0,0,0,1,0,4,0,0,0,1,0,1,0,1,0,0,0,2,0, 18,0,22,0,22,0,30,0,3,0,0,0,38,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1, 0,0,0,1,0,4,0,1,0,2,0,1,0,0,0,0,0,2,0,18,0,22,0,22,0,30,0,3,0,0,0,38,0, 0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,4,0,1,0,2,0,1,0,0,0,0, 0,2,0,18,0,22,0,22,0,30,0,3,0,0,0,38,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0, 0,0,1,0,0,0,1,0,4,0,1,0,2,0,1,0,0,0,0,0,2,0,18,0,22,0,22,0,30,0,3,0,0, 0,38,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,4,0,1,0,2,0,1,0, 0,0,0,0,2,0,18,0,22,0,22,0,30,0,3,0,0,0,38,0,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,1,0,4,0,1,0,2,0,1,0,0,0,0,0,1,0,0,0,10,1,194,1,222,0, 20,68,70,76,84,0,122,97,114,97,98,0,134,97,114,109,110,0,164,98,114,97, 105,0,176,99,97,110,115,0,188,99,104,101,114,0,200,99,121,114,108,0,212, 103,101,111,114,0,236,103,114,101,107,0,248,104,97,110,105,1,4,104,101, 98,114,1,16,107,97,110,97,1,28,108,97,111,32,1,40,108,97,116,110,1,52, 109,97,116,104,1,112,110,107,111,32,1,124,111,103,97,109,1,136,114,117, 110,114,1,148,116,102,110,103,1,160,116,104,97,105,1,172,0,4,0,0,0,0,255, 255,0,1,0,0,0,22,0,3,75,85,82,32,0,22,83,78,68,32,0,22,85,82,68,32,0,22, 0,0,255,255,0,1,0,0,0,4,0,0,0,0,255,255,0,1,0,0,0,4,0,0,0,0,255,255,0, 1,0,0,0,4,0,0,0,0,255,255,0,1,0,0,0,4,0,0,0,0,255,255,0,1,0,0,0,16,0,2, 77,75,68,32,0,16,83,82,66,32,0,16,0,0,255,255,0,1,0,0,0,4,0,0,0,0,255, 255,0,1,0,0,0,4,0,0,0,0,255,255,0,1,0,0,0,4,0,0,0,0,255,255,0,1,0,0,0, 4,0,0,0,0,255,255,0,1,0,0,0,4,0,0,0,0,255,255,0,1,0,0,0,4,0,0,0,0,255, 255,0,1,0,0,0,52,0,8,73,83,77,32,0,52,75,83,77,32,0,52,76,83,77,32,0,52, 77,79,76,32,0,52,78,83,77,32,0,52,82,79,77,32,0,52,83,75,83,32,0,52,83, 83,77,32,0,52,0,0,255,255,0,1,0,1,0,4,0,0,0,0,255,255,0,1,0,0,0,4,0,0, 0,0,255,255,0,1,0,0,0,4,0,0,0,0,255,255,0,1,0,0,0,4,0,0,0,0,255,255,0, 1,0,0,0,4,0,0,0,0,255,255,0,1,0,0,0,4,0,0,0,0,255,255,0,1,0,0,0,2,107, 101,114,110,0,14,107,101,114,110,0,20,0,0,0,1,0,1,0,0,0,2,0,0,0,1,0,2, 0,6,0,14,0,2,0,0,0,1,0,16,0,2,0,0,0,1,34,172,0,2,34,100,0,4,0,0,33,48, 33,202,0,53,0,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,255,211,255,183,0,0,0,0,0,0,0,75,0,114,0,57,0,75,0,0,255,68,0,0,255, 136,255,173,255,154,255,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,38, 0,0,0,0,0,0,0,0,255,201,0,0,0,0,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 38,0,0,255,211,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,75,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,255,211,255,220,255,220,0,57,0,0,255,220,0,0,0,0,255,220,0,0,255,220, 255,220,0,0,255,97,0,0,255,125,255,144,0,0,255,97,0,0,0,0,255,220,255, 220,255,220,255,183,0,0,0,0,0,0,0,0,255,220,0,0,0,0,255,220,0,0,255,136, 255,173,0,0,255,117,255,183,0,0,0,0,255,220,0,0,255,220,0,0,255,220,0, 0,0,57,0,0,255,220,255,220,255,220,255,220,255,220,255,220,255,220,255, 220,0,0,0,0,255,220,255,220,255,97,0,0,0,0,255,144,255,173,255,97,255, 117,255,220,255,220,255,97,0,0,255,97,255,117,255,173,255,144,254,248, 255,3,0,47,0,0,0,0,0,0,0,0,0,0,0,0,255,220,0,0,0,0,255,220,0,0,255,220, 0,0,255,220,0,0,0,0,255,193,255,183,0,0,255,144,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,193,255,220, 0,0,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,0,0,0,0,0,0,0,0,0, 0,255,220,255,220,0,0,0,0,255,220,0,0,0,0,0,0,255,183,0,0,255,144,0,0, 255,220,0,0,0,0,0,0,0,0,0,0,0,0,255,183,255,144,255,144,255,173,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,255,220,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220, 0,0,0,0,0,0,0,0,0,0,255,220,0,0,0,0,0,0,0,0,0,38,0,0,0,0,0,0,0,0,0,0,255, 220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,0,0,0,0,255,144, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,255,220,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,144,0, 0,0,0,0,0,0,0,0,0,255,144,0,0,0,0,0,0,255,211,255,201,255,68,0,0,0,0,254, 183,255,97,255,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,255,220,0,0, 0,0,0,0,0,0,0,0,0,0,255,68,0,0,0,0,255,144,0,0,0,0,255,107,0,0,0,0,255, 183,255,107,0,0,0,0,255,144,0,0,0,0,0,0,255,68,0,0,0,0,0,0,0,0,255,68, 255,144,0,0,255,183,255,144,255,68,255,68,0,0,0,0,0,0,0,0,0,0,0,0,255, 144,0,0,0,0,255,107,255,183,0,0,255,220,255,220,255,144,0,0,0,0,0,0,255, 68,0,0,255,183,255,220,255,183,0,0,255,68,0,0,0,0,255,211,0,0,254,136, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,183,0,0,0, 0,0,0,0,0,255,154,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,255,220,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,211,255,211,255,201,0, 0,0,0,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,183,255,193,255,183,0,0,255,183,0,0, 0,0,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,255,220,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,183,255,193,255,144,0,0,255,41,0,0,0,0, 255,220,0,0,255,144,0,0,0,0,0,0,0,0,255,144,0,0,0,0,255,97,255,201,0,0, 255,183,0,0,255,183,0,0,255,220,0,0,0,0,255,154,0,0,0,0,0,0,0,0,0,0,255, 154,0,0,0,0,0,0,255,154,0,0,0,0,0,0,255,107,255,125,0,0,0,0,255,144,255, 220,255,154,0,0,255,154,255,154,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,255,193,255,193,0,0,0,0,255,220,0,0,0,0,0,47,0,0,0,0,0,0,0,0,0, 0,0,0,255,183,0,0,0,0,254,230,255,154,255,31,255,68,0,0,254,240,0,0,0, 0,0,0,0,0,255,220,0,0,0,0,0,0,0,0,0,0,255,220,0,0,0,0,0,0,255,220,0,0, 0,0,0,0,255,68,0,0,0,0,0,0,0,0,0,0,255,220,0,0,255,220,255,220,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,97,253,230,0,0,0,0,0,57,255, 173,255,220,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220, 0,0,255,125,255,144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,211,255,220,255,68,0,0,255, 211,254,193,0,0,255,125,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,255,211,0,0,255,164,0,0,0,0,255,183,0,0,0,0,255,211,0,0,255, 220,255,183,255,220,255,220,0,0,255,220,0,0,0,0,0,0,0,0,255,220,0,0,0, 0,0,0,255,164,255,183,0,0,255,183,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,38,0,38,254,183,0,0,0,57,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,211, 255,220,255,125,0,0,255,173,255,183,255,193,255,173,0,0,255,154,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,255,107,0,0,255,144,255,173,0,0,255,125,0,0,255, 211,0,0,0,0,255,164,0,0,0,0,0,0,0,0,0,0,255,164,0,0,0,0,0,0,255,164,0, 0,0,0,0,0,255,144,255,144,255,220,0,0,255,154,255,211,255,164,0,0,255, 164,255,164,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,107,255, 125,255,220,0,0,0,0,0,0,0,0,0,38,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,68,255,13, 255,31,255,97,0,0,255,136,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,0,0,0,0, 0,0,0,0,0,0,0,0,254,173,254,164,0,0,254,164,0,0,0,0,255,193,0,0,0,0,254, 164,254,211,254,173,0,0,254,201,0,0,254,173,0,0,254,193,255,68,255,144, 0,0,255,136,255,17,254,224,0,0,254,244,254,231,0,0,0,0,254,164,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,211,254,248,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,255,136,254,248,255,89,255,125,0,0,0,0,0,0,0,0, 0,0,0,0,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,97,0,0,0,0,255, 97,0,0,0,0,255,211,0,0,0,0,255,97,0,0,0,0,0,0,255,117,0,0,0,0,0,0,255, 201,255,78,255,144,0,0,0,0,255,97,255,97,0,0,255,97,255,117,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,230,0,0,255,173,255,21, 255,136,255,144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,255,125,0,0,0,0,255,136,0,0,0,0,255,211,0,0,0,0,255,136,255, 164,0,0,0,0,255,183,0,0,0,0,0,0,255,220,255,144,255,220,0,0,0,0,255,125, 255,136,0,0,255,136,255,183,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,255,220,0,0,254,248,0,0,255,154,0,0,0,0,0,0,0,0,255,107,0,0,0,0,0, 0,0,0,255,125,0,0,0,0,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, 164,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,144,0, 0,0,0,255,107,0,0,255,164,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,255,97,255,173,255,211,0,0,255,13,254,97,254,240,255,97, 0,0,255,144,0,0,0,0,0,0,0,0,255,144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,254,230,0,0,0,0,254,240,0,0,0,0,255,183,0,0,0,0,254,240,0,0,0,0,0,0, 255,21,0,0,0,0,0,0,0,0,255,31,255,107,0,0,255,144,254,230,254,240,0,0, 254,240,255,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,144,255, 220,254,248,0,0,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,255,220,255,220,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,144,255,107,255,183, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,0,0,0,0,255,220, 0,0,255,220,255,183,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65,0,0,255,21,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220, 0,0,0,0,255,183,0,0,0,0,0,0,0,0,0,0,255,183,0,0,0,0,0,0,255,193,0,0,0, 0,0,0,255,183,0,0,0,0,0,0,0,0,255,220,255,183,0,0,255,183,255,193,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,255,107,255,144,255,164,0,0,0,38,255,220,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,193,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,255,107,255,183,255,125,0,0,255,125,255,68,255,220,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,211,255,220, 255,211,0,0,255,220,0,0,0,0,255,220,255,211,255,220,0,0,0,0,0,0,0,0,0, 0,255,201,0,0,255,183,0,0,0,0,0,0,0,0,255,211,0,0,255,211,0,0,0,0,0,0, 255,211,0,0,0,0,0,0,0,72,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,86,254,201,0,0,255,201, 255,97,255,144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,255,220,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,254,240,0,0,0,0,255,68,255, 144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,255,220,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,0,0,255, 193,0,0,0,0,0,0,0,0,0,0,255,193,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,255,193,0,0,255,193,0,0,0,0,0,0,255,220,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,254,220,255,107,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,255, 220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,254,211,0,0,0,0,0,0,0,0,0,0,255,220,255,220,255,220,0, 0,255,220,255,220,0,0,0,0,0,0,255,144,0,0,255,144,255,220,0,0,255,107, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,255, 220,0,0,255,220,0,0,0,0,0,151,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, 183,255,183,255,220,255,220,0,0,0,0,255,220,255,220,0,0,0,0,255,68,0,0, 255,78,255,144,255,144,255,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,255,220,255,220,0,0,255,220,0,0,0,0,0,0,255,220,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,255,211,255,220,255,220,0,57,0,0,255,220,0,0,0,0,255,220,0,0, 255,220,255,220,0,0,255,97,0,0,255,125,255,144,0,0,255,97,0,0,0,0,255, 220,255,220,255,220,255,183,0,0,0,0,0,0,0,0,255,220,0,0,0,0,255,220,0, 0,255,136,255,173,0,0,255,117,255,183,0,0,0,0,255,220,0,0,255,220,0,0, 255,220,0,0,0,57,0,0,255,220,255,220,0,0,255,220,255,220,0,0,255,220,255, 220,0,0,0,0,255,220,255,220,255,97,0,0,0,0,255,144,255,173,255,97,255, 117,0,0,0,0,0,0,255,220,0,0,0,0,0,0,0,0,254,248,255,3,0,47,0,0,255,211, 255,220,255,220,0,57,0,0,255,220,0,0,0,0,255,220,0,0,255,220,255,220,0, 0,255,97,0,0,255,125,255,144,0,0,255,97,0,0,0,0,255,220,255,220,255,220, 255,183,0,0,0,0,0,0,0,0,255,220,0,0,0,0,255,220,0,0,255,136,255,173,0, 0,255,117,255,183,0,0,0,0,255,220,0,0,255,220,0,0,255,220,0,0,0,57,0,0, 255,220,255,220,0,0,255,220,255,220,0,0,255,220,255,220,0,0,0,0,255,220, 255,220,255,97,0,0,0,0,255,144,255,173,255,97,255,117,0,0,0,0,0,0,255, 220,0,0,0,0,0,0,255,144,254,248,255,3,0,47,0,0,255,211,255,220,255,220, 0,57,0,0,255,220,0,0,0,0,255,220,0,0,255,220,255,220,0,0,255,97,0,0,255, 125,255,144,0,0,255,97,0,0,0,0,255,220,255,220,255,220,255,183,0,0,0,0, 0,0,0,0,255,220,0,0,0,0,255,220,0,0,255,136,255,173,0,0,255,117,255,183, 0,0,0,0,255,220,0,0,255,220,0,0,255,220,0,0,0,57,0,0,255,220,255,220,0, 0,255,220,255,220,0,0,255,220,255,220,0,0,0,0,255,220,255,220,255,97,0, 0,0,0,255,144,255,173,255,97,255,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,144, 254,248,255,3,0,47,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,173,255,164,255,144, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,255,220,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,38,0,0,0,0,0,0,255,107,255, 183,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,255,220,0,0,255,68,0,0,0,38,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,144, 255,144,255,173,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,164,255,144,255,183,0, 0,255,211,255,220,255,220,0,57,0,0,255,220,0,0,0,0,255,220,0,0,255,220, 255,220,0,0,255,97,0,0,255,125,255,144,0,0,255,97,0,0,0,0,255,220,255, 220,255,220,255,183,0,0,0,0,0,0,0,0,255,220,0,0,0,0,255,220,0,0,255,136, 255,173,0,0,255,117,255,183,0,0,0,0,0,0,0,0,255,220,0,0,255,220,0,0,0, 57,0,0,0,0,255,220,0,0,255,220,255,220,255,220,255,220,0,0,0,0,0,0,255, 220,255,220,255,97,0,0,0,0,255,144,255,173,255,97,255,117,0,0,0,0,0,0, 255,220,0,0,0,0,0,0,255,144,254,248,255,2,0,47,0,0,255,211,255,220,255, 220,0,57,0,0,255,220,0,0,0,0,255,220,0,0,255,220,255,220,0,0,255,97,0, 0,255,125,255,144,0,0,255,97,0,0,0,0,255,220,255,220,255,220,255,183,0, 0,0,0,0,0,0,0,255,220,0,0,0,0,255,220,0,0,255,136,255,173,0,0,0,0,255, 183,0,0,0,0,0,0,0,0,255,220,0,0,255,220,0,0,0,57,0,0,0,0,255,220,0,0,255, 220,255,220,255,220,255,220,0,0,0,0,0,0,255,220,0,0,255,97,0,0,0,0,255, 144,255,173,255,97,0,0,0,0,0,0,0,0,255,220,0,0,0,0,0,0,255,144,254,248, 255,2,0,47,0,0,0,0,0,0,0,0,255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,255,220,0,0,0,0,255,144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,220,255,220,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,211,255, 201,255,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,63,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,125,255,68, 255,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,255,211,255,220,255,211,0,0,255,220,0,0,0,0,255,220,255,211, 255,220,0,0,0,0,0,0,0,0,0,0,255,201,0,0,255,183,0,0,0,0,0,0,0,0,255,211, 0,0,255,211,0,0,0,0,0,0,255,211,0,0,0,0,0,0,255,220,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,86,254,201,0,0,255,68,255,13,255,31,255,97,0,0,255,136,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,255,220,0,0,0,0,0,0,0,0,0,0,0,0,254,173,254,164,0,0, 254,164,0,0,0,0,255,193,0,0,0,0,254,164,254,211,254,173,0,0,254,201,0, 0,254,173,0,0,254,193,255,68,255,144,0,0,255,136,254,173,254,164,0,0,254, 164,254,201,0,0,0,0,254,164,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, 211,254,248,0,0,0,0,0,0,0,0,255,211,255,183,0,0,0,0,0,0,0,75,0,114,0,57, 0,75,0,0,255,68,0,0,255,136,255,173,255,154,255,13,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,38,0,0,0,0,0,0,0,0,255,201,0,0,0,0,255,220,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,38,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,75, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,248,255,193,255,183,255,193,255, 193,255,183,255,193,255,183,255,183,0,0,0,0,0,0,0,0,0,0,255,136,0,0,255, 220,0,0,0,0,0,0,0,0,255,183,0,0,0,0,0,0,255,144,255,107,255,144,0,0,0, 0,0,0,255,183,255,183,0,0,255,183,0,0,0,0,254,125,255,183,0,0,0,0,255, 183,255,107,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,183,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,38,255,183,255,144,255,183,255,183,255,183,0, 47,255,144,255,144,0,0,254,230,0,0,254,136,255,3,255,183,254,136,0,0,0, 0,0,0,0,0,0,0,255,220,0,0,0,0,0,0,255,183,255,183,255,183,0,0,0,0,0,0, 255,21,255,60,0,0,255,144,0,0,0,0,0,38,255,144,0,0,0,0,255,183,255,183, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,183,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 0,16,0,74,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,2,0,3,0,4,0,5,0,0,0,6,0,7,0,8,0,0,0,9,0,10,0,11,0,0, 0,0,0,12,0,13,0,14,0,15,0,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,25,0,0,0,0,0,0,0,0,0,26,0,0,0,0,0,27, 0,28,0,0,0,0,0,29,0,0,0,0,0,0,0,30,0,31,0,32,0,33,0,1,0,16,0,74,0,1,0, 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0, 0,4,0,5,0,6,0,7,0,0,0,8,0,9,0,8,0,0,0,10,0,8,0,8,0,0,0,0,0,11,0,8,0,12, 0,8,0,13,0,14,0,15,0,16,0,17,0,18,0,19,0,20,0,0,0,0,0,0,0,0,0,21,0,0,0, 22,0,23,0,24,0,25,0,26,0,26,0,27,0,0,0,0,0,28,0,26,0,29,0,30,0,0,0,23, 0,31,0,32,0,33,0,34,0,35,0,36,0,37,0,38,0,2,0,10,0,16,0,16,0,0,0,35,0, 38,0,1,0,40,0,42,0,5,0,44,0,46,0,8,0,49,0,60,0,11,0,69,0,70,0,23,0,75, 0,75,0,25,0,78,0,79,0,26,0,82,0,82,0,28,0,86,0,89,0,29,0,2,0,52,0,4,0, 0,0,36,0,44,0,5,0,2,0,0,0,0,0,0,255,216,0,0,255,177,0,0,255,163,0,0,255, 156,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,204,61,162, 207,0,0,0,0,209,125,253,244,0,0,0,0,209,125,253,244,0,1,0,0,0,10,0,224, 0,232,0,80,0,60,12,0,7,221,0,0,0,0,2,130,0,0,4,96,0,0,5,213,0,0,0,0,0, 0,4,96,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,96,0,0,0,0,0,0,1,104,0,0,4,96,0,0, 0,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,14,0,0,2,118,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,90,0,0,1,14,0,0,0,90,0,0,0,90,0,0,1,14,0,0,0,0,0,0,0,0, 0,0,1,14,0,0,0,90,0,0,0,90,0,0,1,14,0,0,0,90,0,0,0,90,0,0,0,90,0,0,1,114, 0,0,0,90,0,0,0,90,0,0,2,56,0,0,251,143,0,0,0,60,0,0,0,0,0,0,0,0,0,40,1, 142,1,158,0,6,0,3,0,28,0,32,0,36,0,40,0,44,0,48,0,52,0,56,0,60,0,36,0, 0,0,68,0,0,0,100,0,0,0,132,0,0,0,164,0,0,0,216,0,0,1,12,0,0,1,34,0,0,1, 56,0,0,0,0,0,0,0,3,0,0,0,0,0,40,9,117,0,0,0,0,0,40,0,40,9,141,0,1,0,0, 0,40,0,0,9,150,0,0,0,0,0,0,0,3,0,0,0,0,0,40,9,117,0,0,0,0,0,40,0,40,9, 141,0,1,0,0,0,40,0,0,9,150,0,0,0,0,0,0,0,3,0,0,0,0,0,40,9,117,0,0,0,0, 0,40,0,40,9,141,0,1,0,0,0,40,0,0,9,113,0,0,0,0,0,0,0,3,0,0,0,0,0,40,9, 102,0,0,0,0,0,40,0,40,9,126,0,1,0,0,0,40,0,0,9,113,0,0,0,0,0,0,0,5,0,0, 0,0,0,40,9,114,0,0,0,0,0,40,0,40,9,152,0,1,0,0,0,40,0,40,9,138,0,0,0,0, 0,40,0,40,9,152,0,1,0,0,0,40,0,0,9,131,0,0,0,0,0,0,0,5,0,0,0,0,0,40,9, 114,0,0,0,0,0,40,0,40,9,152,0,1,0,0,0,40,0,40,9,138,0,0,0,0,0,40,0,40, 9,152,0,1,0,0,0,40,0,0,9,131,0,0,0,0,0,0,0,2,0,31,0,0,0,40,5,2,0,0,0,31, 0,40,0,0,5,2,0,1,0,0,0,0,0,2,0,64,0,0,0,40,4,40,0,0,0,64,0,40,0,0,4,40, 0,1,0,0,0,0,0,2,0,94,0,0,0,40,2,86,0,0,0,94,0,40,0,0,2,86,0,1,0,1,0,6, 0,11,0,12,0,61,0,62,0,91,0,92,0,1,0,3,0,31,0,64,0,94, } }, goxel-0.11.0/src/assets/icons.inl000066400000000000000000005326061435762723100166450ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* This file is autogenerated by tools/create_assets.py */ {.path = "data/icons/icon128.png", .size = 10628, .data = (const uint8_t[]){ 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,128,0,0,0,128,8,6, 0,0,0,195,62,97,203,0,0,41,75,73,68,65,84,120,156,237,125,121,148,100, 87,121,223,239,222,251,182,90,186,122,157,93,163,209,46,144,4,8,132,192, 6,155,193,145,100,203,38,44,33,30,111,96,67,192,1,12,18,139,188,0,78,114, 20,229,47,231,159,156,99,147,19,231,36,113,156,248,196,118,44,97,98,48, 16,97,73,54,2,44,27,193,32,130,228,145,4,154,209,236,211,107,237,85,111, 185,203,151,63,238,123,85,213,93,213,221,213,51,93,51,35,92,191,57,221, 53,93,245,222,125,239,213,253,221,239,126,219,253,46,48,198,24,99,140, 49,198,24,99,140,49,198,24,99,140,49,198,24,99,140,49,198,24,99,140,49, 198,24,99,140,49,198,24,99,252,112,130,93,234,27,184,52,32,246,250,247, 252,231,3,30,57,59,117,181,252,236,19,95,248,100,227,82,223,209,165,194, 75,142,0,135,238,127,208,91,94,226,123,194,165,19,139,127,255,208,175, 135,91,61,255,224,123,254,48,16,65,225,167,29,191,240,175,0,92,165,226, 246,183,101,220,250,108,18,86,30,13,230,171,167,31,127,252,1,53,130,219, 190,108,241,18,34,0,177,159,248,240,151,174,204,23,138,247,112,225,190, 93,198,237,167,226,168,241,103,50,170,124,253,27,127,248,190,101,128,209, 38,13,176,131,31,252,211,3,158,155,255,56,119,115,191,34,132,59,157,182, 11,163,165,84,73,116,76,198,141,135,147,118,243,115,172,89,123,234,31, 139,84,120,73,16,224,71,62,241,96,174,132,233,159,241,131,137,79,114,199, 127,13,231,66,128,8,90,197,109,41,219,79,171,176,246,185,56,108,255,229, 114,253,185,163,71,30,122,32,89,123,254,221,119,255,174,31,239,223,243, 83,110,190,240,175,133,19,188,134,49,46,6,93,135,140,38,173,146,170,146, 173,39,101,248,143,67,42,92,222,4,32,98,119,220,243,229,235,131,98,233, 19,142,155,255,69,46,220,201,65,135,25,45,181,150,225,233,36,106,62,162, 162,250,131,181,114,229,201,195,15,125,176,14,0,111,252,229,255,185,63, 40,78,124,212,13,10,239,229,194,157,29,238,145,187,82,65,203,248,97,56, 252,115,113,84,125,234,137,255,254,171,63,116,82,225,178,37,192,193,15, 63,88,204,231,103,223,233,56,133,223,20,110,112,19,227,156,111,118,14, 145,129,150,113,93,37,205,111,197,97,245,33,29,183,202,126,113,199,125, 92,120,183,115,62,120,212,111,4,225,120,112,130,9,98,224,85,41,219,79, 170,176,254,89,85,47,63,150,252,224,31,78,253,176,72,133,203,142,0,247, 223,79,252,155,149,199,110,225,129,255,91,174,151,127,7,23,110,97,171, 109,24,149,160,182,240,188,12,155,203,106,106,215,13,57,55,152,0,64,48, 70,3,180,153,170,0,48,198,224,248,69,120,65,9,76,56,233,187,4,173,164, 212,50,58,166,162,198,95,201,184,249,57,102,150,191,243,240,103,126,185, 1,96,243,70,47,83,92,86,4,120,203,167,190,56,45,216,206,95,18,126,240, 113,6,118,45,1,108,152,14,235,130,32,163,38,26,75,71,209,88,62,14,48,160, 56,125,5,220,220,36,188,252,20,28,47,15,34,2,105,9,34,51,176,5,46,92,184, 185,18,92,175,0,176,193,95,79,170,43,212,100,220,252,182,78,90,159,141, 91,229,71,212,145,167,79,190,20,165,194,101,65,128,131,247,255,141,83, 10,157,215,58,185,201,79,9,47,248,41,206,157,0,32,144,49,48,90,129,140, 2,109,66,4,34,141,168,177,140,86,249,36,226,118,25,50,108,128,9,7,133, 169,189,16,110,0,225,6,112,188,60,28,191,8,199,13,64,68,48,42,177,82,1, 4,48,6,199,205,193,203,77,130,59,222,144,119,78,208,90,73,157,132,199, 85,220,252,74,88,61,247,231,141,230,217,239,60,249,199,31,123,201,72,133, 75,78,128,187,126,253,43,59,11,249,217,247,9,183,240,97,238,120,87,48, 214,63,236,136,12,72,43,24,163,64,166,127,228,106,21,33,172,205,35,172, 47,64,37,109,24,21,67,70,77,112,225,32,159,18,128,59,62,132,227,129,11, 55,37,68,30,194,245,1,34,24,45,45,65,252,2,24,219,84,213,24,0,130,140, 91,20,214,231,107,73,171,246,109,25,55,62,75,73,245,17,113,166,118,217, 75,133,75,70,128,219,62,240,109,119,239,180,250,113,39,87,248,180,227, 6,111,98,92,108,62,236,200,206,227,38,19,225,100,32,163,6,194,218,60,146, 168,14,163,98,104,149,172,33,192,190,148,0,94,135,0,92,184,96,220,1,119, 60,56,110,128,92,105,23,188,92,9,42,137,160,100,4,50,195,247,25,165,247, 32,163,122,74,78,130,73,165,130,140,27,95,145,97,227,207,37,146,203,86, 42,92,10,2,176,183,252,246,19,123,5,247,63,236,250,133,247,11,225,238, 90,111,174,221,8,70,37,104,215,206,33,106,44,65,203,16,70,43,24,157,64, 43,9,163,34,200,168,1,46,220,141,9,32,92,112,238,32,40,237,68,80,152,5, 23,14,192,0,45,99,168,36,132,209,201,134,83,143,209,18,73,187,10,37,195, 129,202,101,166,43,168,184,117,217,74,133,139,74,128,131,239,249,195,32, 55,119,245,93,185,137,153,79,57,94,254,117,140,113,103,243,179,250,161, 101,132,184,85,70,216,88,128,150,49,72,203,62,2,36,41,1,10,41,1,132,227, 129,175,34,128,11,46,156,14,1,188,156,117,49,48,198,193,133,3,198,5,140, 86,80,73,27,90,197,32,163,123,238,128,160,146,16,73,187,10,163,229,16, 119,220,47,21,168,81,63,124,57,120,27,207,171,3,182,14,98,63,113,239,255, 185,38,31,236,248,168,227,231,126,153,49,62,77,70,3,156,97,192,148,191, 126,43,70,67,70,13,36,97,13,70,37,67,153,116,93,176,193,127,50,172,154, 247,137,12,180,74,0,198,192,185,3,47,87,2,200,64,201,8,42,9,161,85,12, 25,214,33,163,198,186,150,196,160,107,115,225,186,60,231,94,239,4,197, 235,220,96,242,221,109,49,255,111,0,252,199,45,60,192,72,48,114,2,220, 245,238,63,42,120,187,190,250,86,238,237,253,164,112,131,87,48,198,5,25, 3,109,98,48,38,237,104,19,206,166,202,151,150,17,146,118,5,42,105,247, 136,229,243,17,96,108,184,51,83,229,208,104,9,198,69,199,146,104,87,207, 89,130,156,39,72,43,150,132,213,201,118,245,140,123,222,141,108,35,70, 71,128,251,239,231,119,151,95,255,50,145,47,253,134,227,230,126,150,11, 119,98,237,33,157,209,166,37,56,119,58,162,119,213,49,198,64,70,117,59, 234,135,18,183,91,5,91,215,222,239,222,131,134,54,218,190,202,200,154, 145,174,15,163,18,104,149,164,211,195,102,210,136,172,194,218,88,130,138, 219,218,168,120,105,219,30,225,2,48,18,2,220,125,239,151,75,172,229,255, 188,59,81,188,143,11,255,134,77,221,184,217,104,51,202,142,54,225,128, 49,1,173,146,158,81,191,70,220,14,236,179,158,55,201,164,132,161,1,159, 159,159,234,99,9,27,195,168,4,4,2,99,28,194,241,145,198,14,64,70,15,156, 22,200,104,68,141,37,68,205,101,128,8,100,180,34,69,203,231,117,19,219, 140,109,37,192,161,67,15,138,218,158,201,91,157,160,240,73,199,203,191, 133,9,39,191,165,6,136,64,90,65,170,24,90,198,169,118,191,245,81,175,84, 132,234,210,243,136,195,50,226,184,130,201,29,55,32,63,177,107,221,227, 135,214,67,58,83,15,129,140,134,209,49,136,52,236,28,239,128,113,23,140, 217,14,207,148,70,149,132,104,87,78,35,9,107,96,156,131,11,23,0,69,100, 226,234,150,31,108,4,216,86,2,180,14,236,190,171,56,49,243,251,32,28,32, 50,91,30,102,4,130,138,91,72,218,101,144,49,16,110,48,228,153,246,82,68, 132,176,181,128,149,179,255,15,237,218,25,128,8,43,103,191,139,122,229, 40,38,102,174,198,244,206,155,80,156,218,159,118,66,255,249,195,220,95, 47,9,0,2,145,245,86,202,184,5,192,128,49,39,53,59,93,196,205,21,52,150, 142,65,171,200,90,30,224,217,125,134,6,166,54,228,195,141,20,219,74,0, 238,122,7,28,47,127,37,231,14,211,90,194,168,24,70,15,51,63,90,187,62, 106,45,67,134,53,16,25,8,55,183,165,107,107,29,163,186,244,28,42,11,207, 64,198,77,219,81,12,176,38,91,11,213,197,35,104,84,94,68,97,242,10,204, 236,186,5,165,185,107,225,5,147,0,219,130,37,66,4,251,207,62,82,246,154, 145,193,40,9,163,91,72,194,42,252,194,108,106,82,186,48,70,194,222,140, 253,33,163,91,224,73,115,75,15,56,34,108,43,1,140,150,21,149,68,154,51, 198,193,88,106,119,147,181,209,141,26,236,44,33,131,36,172,34,170,47,64, 203,8,96,28,124,75,238,1,66,212,94,193,242,217,195,104,86,78,193,232,245, 53,116,163,18,52,42,199,209,170,159,70,238,236,78,76,239,186,25,211,187, 111,65,126,114,247,112,87,34,51,216,244,36,116,222,231,194,133,95,152, 69,48,177,3,140,9,20,166,247,35,110,45,163,93,95,128,140,26,150,68,164, 234,90,55,219,91,120,200,145,97,91,9,192,192,107,0,41,34,114,141,150,48, 177,6,99,12,92,120,16,194,181,145,184,158,192,142,146,33,194,234,25,68, 173,50,64,100,231,209,204,28,220,212,198,103,48,164,81,91,254,1,86,206, 126,7,113,88,29,218,46,39,163,17,54,23,16,181,151,81,94,120,26,97,114, 7,230,246,188,6,185,194,78,112,190,190,117,214,105,127,213,189,117,255, 47,220,0,65,113,22,110,80,234,60,135,227,229,224,120,251,145,43,237,134, 140,26,104,215,231,161,86,98,153,43,92,227,195,138,132,75,234,30,222,86, 2,40,35,235,62,81,2,206,82,249,109,160,165,132,140,27,0,1,220,241,225, 248,86,47,12,107,231,208,44,159,132,78,66,48,33,236,188,188,5,199,78,18, 215,177,120,242,9,84,22,142,88,167,208,121,128,136,144,196,53,172,44,63, 141,102,120,6,133,194,62,76,205,220,136,98,233,10,56,78,14,125,186,1,89, 81,223,251,119,246,151,227,23,224,231,103,224,120,65,255,121,200,36,195, 12,188,252,20,138,51,7,94,165,146,246,159,204,221,115,219,131,166,213, 120,88,29,251,254,37,115,15,111,175,14,160,101,19,160,24,224,232,204,121, 12,176,249,123,9,146,168,14,17,249,8,138,115,136,219,21,168,184,5,0,96, 232,79,214,161,117,6,6,145,70,179,118,26,203,103,15,163,81,62,190,137, 149,48,204,220,110,143,209,42,66,189,118,20,205,198,73,4,185,57,76,78, 95,143,210,228,53,240,252,238,104,166,1,35,159,49,6,39,152,176,97,228, 62,229,114,192,213,24,135,235,23,2,215,207,31,244,114,147,111,212,133, 246,139,201,228,204,151,238,184,233,179,159,121,236,247,127,246,216,16, 55,188,173,216,94,2,80,208,34,80,180,250,107,183,68,96,140,35,40,206,34, 63,181,15,94,80,66,126,106,15,218,213,115,104,44,191,136,184,85,70,214, 229,150,47,26,164,21,200,104,251,229,167,74,154,146,109,84,22,159,65,101, 233,89,104,21,97,107,210,115,48,25,24,99,171,188,144,198,72,180,91,243, 8,219,11,88,89,250,30,74,147,87,99,106,230,6,4,185,29,0,233,85,151,100, 140,195,241,11,112,253,2,24,219,106,198,25,131,112,60,71,56,222,245,196, 240,17,217,174,61,1,224,165,77,0,133,102,232,81,169,181,246,125,238,120, 200,149,118,33,40,206,129,59,118,148,56,94,30,165,157,215,160,48,125,5, 162,198,34,154,229,83,136,91,101,40,25,66,69,77,48,225,164,230,147,15, 46,28,196,113,21,43,243,223,69,216,60,183,105,114,200,133,131,64,4,36, 113,13,203,139,223,69,181,252,60,10,19,251,144,115,231,32,88,0,33,60,48, 238,192,205,21,32,134,136,98,111,112,21,168,168,137,168,177,148,132,181, 249,242,54,62,192,208,216,86,2,56,113,49,34,162,150,29,241,44,19,119,240, 11,51,235,36,91,48,8,215,71,97,102,63,114,165,93,136,90,101,212,22,190, 143,106,107,5,170,93,181,83,4,99,104,55,207,161,81,61,6,173,99,48,206, 193,184,176,46,227,97,120,176,217,44,176,70,2,116,145,201,35,64,169,16, 181,202,11,88,40,255,45,92,228,177,255,198,159,70,126,114,31,68,154,57, 68,100,0,99,82,98,14,71,78,34,131,164,93,69,18,214,160,101,20,73,165,94, 250,4,72,242,47,38,142,185,165,1,0,140,9,120,249,194,208,115,35,119,60, 228,39,119,35,40,206,97,114,215,13,168,205,127,31,181,133,231,177,116, 250,73,180,26,103,97,211,182,56,24,227,29,18,24,153,88,247,113,102,199, 15,45,24,134,245,81,117,73,0,0,174,91,196,220,174,87,35,63,185,183,211, 249,246,89,57,32,56,24,89,199,208,186,230,98,10,99,20,226,214,10,100,212, 76,205,66,106,130,228,37,113,12,109,43,1,166,138,129,148,134,106,92,184, 112,253,60,132,151,219,114,138,21,23,78,74,132,89,20,231,174,132,155,47, 98,225,248,19,104,86,78,216,184,60,96,71,45,152,13,196,104,157,254,141, 142,174,64,105,71,12,51,47,51,182,89,48,136,0,112,228,114,115,152,221, 251,79,144,47,238,238,11,88,245,52,6,198,4,24,56,200,80,39,107,169,23, 74,70,136,155,203,54,137,36,131,81,245,132,162,75,226,24,218,230,96,208, 77,200,79,78,145,95,40,193,104,182,133,120,249,106,216,68,140,16,174,63, 129,189,55,222,137,185,253,175,69,229,220,51,88,56,254,4,234,203,47,64, 201,182,245,200,105,13,163,21,176,202,69,155,106,235,198,128,57,14,140, 86,224,140,175,31,59,218,196,11,200,152,131,210,196,1,204,204,222,2,207, 43,109,122,124,214,48,227,204,18,161,51,61,24,200,184,129,168,177,12,173, 226,180,109,75,62,67,84,86,101,92,18,199,208,54,19,224,8,220,252,79,82, 97,178,104,109,236,80,34,137,229,192,68,206,129,176,203,189,160,146,176, 67,30,198,56,252,194,12,118,93,251,227,152,185,226,86,212,22,158,195,194, 139,79,160,186,248,44,140,76,58,231,165,162,52,253,194,83,9,0,130,142, 67,123,125,215,102,4,101,254,248,46,50,23,109,63,28,17,96,106,250,229, 152,154,186,30,194,25,54,46,177,166,117,198,65,12,72,218,21,132,141,197, 53,102,171,37,166,81,201,10,150,112,254,73,6,23,128,109,37,192,77,56,164, 142,170,90,53,106,3,142,203,225,231,125,248,57,23,113,36,33,35,9,179,1, 17,200,232,52,227,38,193,160,201,156,49,6,47,40,97,199,149,183,99,122, 207,205,168,47,29,197,252,209,175,97,233,228,97,36,237,149,1,54,122,154, 86,174,100,22,130,5,215,26,34,35,130,16,89,195,3,98,1,12,65,48,131,217, 217,87,162,80,216,187,190,200,31,2,198,40,196,141,101,68,173,21,24,21, 119,238,147,49,150,121,18,64,164,23,142,28,130,194,3,231,125,153,243,198, 182,18,224,129,7,24,189,235,63,44,84,136,0,37,1,173,0,46,56,252,156,37, 66,18,41,36,145,76,3,68,25,172,147,72,37,225,154,188,187,117,192,24,28, 175,128,153,125,175,192,228,206,27,176,247,134,59,177,112,244,235,88,60, 241,77,132,141,69,144,206,72,198,178,24,161,13,207,42,59,45,144,81,224, 90,217,28,65,215,235,83,214,24,227,152,152,56,128,157,187,95,135,32,55, 99,163,125,74,118,215,15,108,1,90,198,136,154,139,72,194,122,119,13,66, 39,72,197,83,63,48,131,49,242,28,30,120,224,252,230,203,11,196,118,39, 132,16,12,171,100,218,51,145,37,129,214,128,16,28,94,224,193,15,28,196, 41,17,180,146,157,60,187,173,229,247,1,214,132,12,48,181,251,101,40,237, 188,14,87,190,226,173,88,56,246,4,206,126,255,175,209,92,57,62,48,109, 139,200,128,148,180,68,208,150,8,220,241,160,101,4,193,2,56,78,14,211, 179,55,99,110,231,173,118,101,144,189,10,56,119,58,233,232,235,5,181,214, 66,197,45,132,141,69,168,164,5,210,218,198,64,50,18,81,234,33,229,12,48, 100,140,150,243,91,124,248,109,195,182,103,4,105,50,43,68,100,88,239,100, 155,17,65,1,194,225,240,124,15,142,231,160,89,73,191,148,11,112,236,112, 97,19,55,243,165,157,152,220,117,35,174,184,233,167,48,255,194,215,113, 250,217,175,160,177,116,20,134,250,93,236,25,17,200,24,168,176,137,164, 94,70,97,122,63,118,239,127,3,38,103,111,132,88,107,182,50,155,240,193, 133,0,25,3,173,165,245,84,14,202,254,33,130,12,107,136,154,75,54,99,217, 104,24,147,45,106,209,105,115,188,199,98,49,146,136,22,207,251,11,184, 64,108,59,1,200,168,10,145,49,128,24,104,255,101,68,0,8,92,120,8,138,179, 80,73,104,87,244,100,26,253,80,96,16,174,7,199,203,119,76,77,46,28,20, 103,174,196,181,175,253,5,236,125,217,29,88,60,246,247,56,243,252,35,168, 45,60,7,165,162,65,55,11,16,161,80,220,135,43,175,123,11,38,166,14,128, 109,152,189,198,192,184,128,195,5,72,24,24,35,97,84,119,157,33,25,141, 184,85,70,220,42,67,235,164,147,25,68,70,217,103,35,3,128,217,80,9,113, 128,52,26,213,83,113,101,254,123,151,44,61,108,219,9,192,24,175,49,34, 181,89,219,70,83,39,254,239,184,1,92,47,7,37,67,200,120,115,34,48,198, 225,120,121,235,140,25,96,150,49,46,144,47,237,198,129,87,189,13,123,174, 127,19,150,79,125,7,167,159,123,4,149,179,79,67,38,93,79,181,112,3,236, 185,238,205,184,230,214,159,67,144,159,29,210,196,203,174,193,33,184,15, 46,92,144,214,144,113,19,97,125,1,73,88,181,235,25,73,119,8,208,93,223, 104,44,89,137,129,140,68,125,249,40,150,207,124,167,29,86,87,42,67,95, 120,155,49,2,9,144,212,9,148,0,216,216,110,202,156,119,70,67,25,109,147, 65,157,0,142,151,131,74,162,148,8,107,147,58,109,88,213,241,242,155,120, 23,51,77,219,154,144,123,111,188,3,59,174,122,29,42,103,159,193,153,231, 31,197,202,233,167,192,184,192,213,183,30,194,190,151,221,217,153,239, 207,7,140,113,104,74,16,53,22,17,183,43,61,163,94,119,196,190,73,23,174, 216,152,56,96,84,132,234,210,179,168,173,252,0,42,9,27,0,234,231,125,3, 23,136,237,151,0,90,55,137,40,222,244,184,142,253,109,59,171,75,4,14,238, 248,200,121,1,148,140,161,226,22,116,106,59,103,4,217,220,187,184,38,30, 201,24,188,96,18,187,174,126,3,102,175,184,21,75,199,191,5,37,219,216, 119,227,155,193,184,59,116,218,218,32,216,145,191,136,36,170,119,20,61, 179,70,244,119,214,23,48,6,37,67,148,23,159,65,171,118,10,96,0,145,169, 233,92,216,23,64,187,88,24,129,4,208,45,16,54,175,222,197,88,111,255,247, 156,111,160,77,4,195,56,184,227,34,40,206,194,232,24,54,66,119,254,246, 184,189,38,32,163,38,100,104,87,100,181,43,167,81,152,222,13,215,47,194, 104,3,173,135,211,240,129,52,153,36,172,89,207,158,140,210,142,86,105, 106,184,238,172,102,238,18,64,65,38,13,84,22,159,65,216,94,182,49,13,198, 1,208,202,68,165,16,93,170,12,209,109,39,64,168,26,161,43,195,182,205, 140,217,12,235,207,185,105,185,23,24,198,225,229,2,20,74,62,148,52,136, 219,18,74,110,94,47,160,191,61,141,86,249,52,170,243,207,33,110,149,225, 229,38,17,54,171,208,74,33,40,78,35,40,206,192,15,114,80,74,165,138,221, 250,237,147,49,86,217,107,151,237,26,1,163,108,209,137,108,212,155,140, 0,86,73,212,42,70,216,90,68,101,233,8,100,210,180,138,102,103,10,164,165, 211,215,250,18,167,183,244,56,219,134,109,39,192,11,71,190,16,77,237,184, 162,181,115,223,109,152,154,185,1,206,186,21,94,108,64,103,211,245,52, 100,32,99,137,176,237,195,245,4,10,147,2,90,105,68,109,9,149,12,71,4,163, 19,52,87,78,160,185,114,2,42,105,195,70,22,1,48,192,24,141,184,221,128, 86,10,94,110,2,65,97,18,204,43,66,201,4,90,174,173,36,194,160,117,130, 184,185,2,25,213,83,191,64,215,204,51,70,117,235,24,164,98,95,201,8,173, 218,41,155,196,162,99,27,202,238,16,159,192,24,205,227,241,199,135,240, 128,141,6,219,78,0,167,122,52,174,243,176,222,110,157,69,97,98,31,118, 236,121,205,64,34,176,206,175,225,64,6,72,34,64,114,192,117,5,10,37,1, 173,53,226,182,132,140,215,39,130,78,218,104,172,28,71,88,95,237,135,183, 238,223,238,13,24,99,144,196,109,104,109,224,5,5,248,249,34,60,63,128, 76,18,40,25,131,12,65,201,208,70,242,146,112,205,60,111,59,187,179,74, 57,29,249,74,134,104,53,78,163,213,58,3,238,121,128,98,171,188,157,100, 12,105,169,231,113,9,19,67,183,157,0,106,42,150,12,168,25,163,208,168, 157,64,171,113,6,133,137,125,216,185,247,118,76,206,92,159,38,91,158,63, 200,0,73,12,72,105,137,144,159,16,48,121,141,168,173,32,147,213,21,68, 100,84,71,179,124,18,73,187,182,122,36,19,144,185,98,1,172,38,34,25,200, 36,130,49,6,174,159,131,23,4,112,125,15,141,149,121,132,245,165,206,106, 160,76,217,51,186,59,218,123,127,100,210,66,163,118,2,81,180,4,112,6,39, 200,3,140,217,8,166,74,108,13,130,184,173,129,75,231,5,4,70,64,128,35, 128,190,153,168,163,211,116,137,112,22,197,210,126,236,216,115,27,38,103, 174,131,227,12,206,158,29,12,90,155,155,97,137,144,88,34,56,25,17,140, 139,184,45,145,68,9,162,230,10,218,213,115,214,21,75,182,114,71,150,177, 211,159,112,218,191,102,144,200,64,37,118,228,115,71,32,14,107,118,205, 1,217,32,83,54,250,59,18,64,73,91,157,68,75,200,184,142,122,237,69,36, 73,45,93,2,47,108,18,11,227,128,227,66,248,57,56,90,67,184,1,180,150,215, 236,250,209,187,118,46,252,221,35,75,184,4,146,96,251,23,135,62,244,144, 161,67,247,85,108,208,163,87,196,74,212,171,199,208,172,159,74,137,240, 26,228,243,123,6,102,4,111,5,68,128,76,108,240,201,113,57,114,5,15,97, 125,5,237,218,252,224,101,220,233,87,220,141,0,178,85,47,171,193,64,68, 208,82,217,196,147,85,157,175,59,249,8,90,203,116,209,104,140,40,172,160, 81,127,17,74,181,0,222,237,120,171,248,241,110,18,170,112,32,252,192,129, 49,191,173,181,250,167,251,223,248,142,63,97,82,127,225,228,129,224,36, 30,122,232,162,233,4,163,88,29,76,0,95,55,191,173,151,8,249,226,30,204, 206,189,2,197,210,149,16,194,223,176,197,53,2,160,243,126,71,155,78,137, 160,37,33,137,218,221,185,118,189,49,149,233,0,61,141,174,166,68,247,51, 74,215,0,2,221,148,175,142,143,63,93,2,167,101,132,176,189,136,70,253, 4,140,73,210,188,197,180,211,179,209,159,18,160,251,202,192,28,39,224, 174,255,58,242,131,215,24,165,62,116,213,162,252,28,222,248,115,15,230, 43,244,236,145,35,15,141,60,71,96,36,203,195,141,81,101,34,162,65,21,191, 186,199,72,52,235,39,209,110,158,67,161,184,23,51,115,175,64,177,180,127, 99,34,12,129,161,242,50,41,101,206,170,187,219,96,58,90,147,112,178,202, 199,111,84,170,236,157,65,179,121,10,4,221,237,252,108,244,247,118,58, 95,243,119,150,64,203,93,135,59,254,203,56,231,159,2,240,158,100,34,254, 191,87,237,252,197,255,21,150,151,191,189,240,189,71,70,230,40,26,81,129, 8,42,19,72,179,33,218,55,70,162,81,63,129,86,243,236,186,68,32,100,189, 58,160,147,214,121,187,247,227,62,244,37,129,176,30,133,112,13,49,24,235, 164,116,33,235,124,210,48,100,59,95,203,16,245,234,49,180,163,121,59,223, 195,73,59,52,27,241,60,213,3,120,247,186,189,18,0,233,223,60,91,75,233, 112,0,251,184,235,189,95,120,185,119,58,65,254,107,133,93,239,250,163, 200,180,190,118,246,177,191,40,175,247,72,231,139,145,16,128,17,175,49, 194,166,1,161,94,172,37,194,236,142,87,162,56,177,31,195,84,143,27,10, 61,95,155,49,105,92,191,15,221,73,96,149,97,176,42,219,215,164,122,128, 129,74,90,88,153,255,46,154,181,83,16,65,14,194,11,108,166,15,145,213, 82,179,78,238,116,126,47,9,50,18,218,41,66,244,102,41,1,96,140,51,225, 122,51,194,113,223,161,117,112,23,87,249,195,215,222,241,238,63,142,20, 125,249,204,227,215,157,5,182,39,129,100,36,4,208,70,215,29,64,98,179, 128,208,0,116,136,208,58,135,98,241,10,204,236,184,5,19,165,3,27,159,180, 137,20,232,133,76,154,40,47,62,131,122,253,24,230,204,107,80,154,185,182, 155,239,183,90,40,116,222,232,204,251,100,58,100,72,162,42,22,207,124, 43,245,233,179,206,212,192,28,23,194,113,1,198,187,239,101,101,104,214, 74,0,88,73,33,92,111,195,76,99,225,184,5,225,184,111,50,174,255,35,92, 38,31,185,246,39,143,63,168,162,159,255,220,9,54,255,3,60,254,248,5,173, 41,28,9,1,136,88,147,64,49,3,250,234,2,13,11,163,19,212,107,199,208,108, 158,198,196,196,126,236,220,247,122,148,166,175,30,74,71,88,103,85,33, 162,246,18,150,206,29,70,187,113,22,142,42,226,220,201,175,163,86,121, 1,179,187,95,137,201,153,235,224,13,44,17,203,86,45,252,32,210,8,91,11, 88,60,157,166,160,145,45,21,195,122,200,98,140,6,23,188,19,174,182,149, 78,83,165,180,87,2,112,97,71,254,230,133,208,1,0,92,56,30,23,206,43,141, 235,223,44,188,220,175,94,35,115,127,169,15,238,250,19,55,87,127,234,133, 135,31,222,52,0,55,8,35,33,128,163,162,22,67,126,203,219,185,12,130,209, 9,106,213,163,104,54,78,99,98,234,42,236,220,243,90,76,76,93,221,191,36, 107,93,51,193,142,216,70,245,56,150,231,159,66,18,86,59,126,0,50,10,237, 230,57,68,39,86,80,89,121,14,179,187,95,133,169,217,27,225,231,38,87,53, 70,166,171,249,55,170,39,177,120,230,155,72,194,74,167,253,65,186,174, 37,130,74,139,95,185,96,174,159,78,29,214,107,201,185,0,119,189,45,175, 155,0,0,46,132,224,66,92,37,92,239,30,237,250,239,72,154,252,16,128,111, 110,185,33,140,136,0,10,104,11,67,237,45,175,151,220,0,90,199,168,174, 60,143,70,237,4,74,83,215,88,34,76,94,185,169,142,96,116,130,242,210,51, 168,44,62,147,198,1,82,172,114,42,105,75,132,23,87,80,89,250,7,204,238, 190,21,211,59,94,142,32,55,221,89,172,106,180,68,117,249,57,44,157,61, 12,213,41,238,65,221,182,86,185,21,123,29,74,4,100,169,96,194,233,116, 186,173,37,52,252,82,178,129,96,140,105,25,7,82,54,6,164,59,13,135,145, 16,64,184,78,4,96,36,166,139,86,17,42,203,71,80,175,30,235,39,66,71,10, 216,47,85,38,77,44,157,253,22,106,229,163,157,202,33,246,16,182,70,205, 179,32,210,104,183,22,16,29,127,12,229,165,167,49,183,251,213,152,217, 117,11,84,210,194,210,252,119,80,158,255,94,186,42,25,232,94,5,232,116, 58,235,102,57,116,124,9,221,198,211,26,196,2,78,16,64,184,190,141,27,200, 120,232,125,12,86,221,171,49,80,113,27,38,142,202,76,135,231,157,82,54, 18,2,240,10,197,180,219,140,180,12,106,31,17,246,190,22,19,147,7,32,184, 0,64,8,219,139,88,56,245,119,104,55,206,193,86,242,234,98,176,43,184,39, 70,71,6,97,107,17,103,142,63,134,149,197,239,1,154,80,89,248,7,24,147, 244,54,210,125,221,40,149,108,173,175,129,144,38,160,36,96,66,192,9,242, 54,7,66,90,55,242,48,68,32,99,160,162,150,77,87,39,51,31,215,245,121,167, 19,140,132,0,73,78,72,239,34,165,57,101,68,104,84,143,97,114,230,122,236, 216,253,106,212,202,47,224,236,241,175,34,142,42,235,22,154,232,179,247, 7,128,200,32,108,47,65,133,205,62,18,217,3,210,166,214,54,196,6,188,219, 235,102,76,77,69,82,10,134,49,112,46,224,248,57,144,241,210,226,147,235, 19,129,140,134,138,218,118,193,139,125,227,212,210,14,92,94,83,192,11, 19,243,234,38,186,186,58,138,182,215,131,82,17,86,22,159,70,117,229,7, 136,235,75,72,226,33,7,197,154,80,192,32,78,88,187,190,239,93,172,213, 1,108,191,175,207,170,190,105,193,54,158,134,144,53,56,231,16,94,0,238, 250,118,229,179,234,205,71,96,214,235,24,182,64,90,117,207,37,58,134,175, 157,191,41,120,62,187,35,108,142,135,30,50,128,186,36,153,174,90,69,208, 27,84,10,91,141,213,162,191,191,251,123,2,13,189,50,127,237,232,164,110, 91,157,243,214,113,51,175,189,98,183,13,130,209,26,42,73,96,180,1,119, 125,184,185,162,117,46,113,110,23,204,246,118,62,0,178,218,233,5,85,21, 25,13,1,178,128,208,200,43,121,172,115,233,97,176,105,10,248,42,95,96, 247,133,86,189,147,22,122,168,217,69,168,125,229,108,51,87,111,79,123, 195,76,61,70,67,203,4,58,93,185,196,133,11,21,173,238,124,123,15,20,26, 50,39,55,121,144,13,49,186,98,209,82,149,201,35,98,91,73,182,31,37,122, 107,251,108,234,54,92,253,249,122,217,70,140,11,48,97,160,195,6,72,73, 232,36,130,91,40,217,106,40,3,157,59,172,27,133,28,230,150,141,129,54, 9,116,18,13,94,55,105,168,174,181,186,160,132,146,145,17,128,56,171,128, 96,46,56,224,191,221,72,243,20,248,102,37,234,87,7,3,250,62,206,138,89, 102,133,172,8,128,78,66,24,25,67,121,77,184,197,73,184,185,34,216,154, 5,82,155,147,111,192,45,235,193,102,34,145,89,49,136,46,168,180,204,200, 8,192,225,84,25,227,10,96,67,22,243,185,136,72,221,176,204,113,186,225, 90,96,112,110,72,22,10,238,61,55,219,75,48,37,83,167,202,8,217,12,40,221, 174,65,182,235,112,242,19,240,75,179,150,8,142,215,177,0,182,138,245,86, 77,19,153,115,66,213,46,200,220,30,149,14,0,67,73,29,12,146,103,201,16, 23,19,91,224,27,227,28,76,184,96,142,155,222,231,0,7,81,143,182,207,210, 61,13,58,177,125,116,59,159,58,145,66,157,86,48,81,136,235,43,8,203,243, 144,173,90,186,58,104,171,4,160,193,4,32,130,73,226,19,231,14,31,62,111, 19,16,24,165,14,192,68,3,196,98,128,21,89,58,74,58,21,60,46,9,214,77,13, 178,191,211,194,83,131,79,77,3,62,92,88,50,24,3,234,36,149,246,36,139, 24,3,34,13,206,29,56,185,162,45,68,145,234,2,113,179,10,25,181,144,159, 221,219,41,149,55,220,109,15,32,0,17,180,140,73,37,225,49,0,23,244,133, 142,78,7,208,104,17,81,15,59,179,248,55,3,96,214,85,172,46,6,250,242,1, 123,192,185,0,88,186,112,35,251,242,83,157,129,64,96,198,128,24,7,99,189, 157,110,58,175,92,184,105,231,187,169,164,200,242,1,237,181,116,28,130, 187,254,192,221,81,6,33,11,65,247,188,1,109,119,42,81,134,204,5,23,150, 28,25,1,20,147,109,23,166,175,240,145,253,242,173,187,246,210,18,161,95, 29,235,141,231,48,38,192,4,3,25,187,139,152,33,9,70,0,165,254,254,44,233, 195,46,7,51,233,254,6,30,156,92,177,103,154,232,205,7,180,121,0,224,28, 164,37,180,81,233,214,117,27,19,129,76,79,165,177,180,243,201,46,97,107, 27,163,47,120,61,209,232,148,64,25,71,0,91,55,32,148,17,129,177,110,194, 197,104,176,150,96,61,222,187,206,205,172,125,163,231,131,76,127,97,12, 157,104,83,71,228,119,55,177,20,158,15,39,40,130,139,180,136,101,39,31, 48,235,124,150,18,171,91,13,189,75,4,145,110,101,215,175,131,116,36,64, 111,231,219,15,106,144,241,194,5,124,49,0,70,72,0,198,85,76,180,121,64, 136,113,14,14,1,67,221,88,249,200,144,185,116,7,213,20,232,249,189,202, 147,151,21,117,2,3,245,116,62,210,180,112,210,26,194,203,193,9,242,224, 220,89,147,12,218,211,249,200,140,128,126,87,48,105,5,157,46,145,95,75, 4,210,26,48,166,83,109,164,123,154,89,242,201,92,176,183,117,100,4,136, 106,251,165,87,84,155,7,132,8,0,103,224,204,206,189,198,104,24,186,176, 178,49,131,47,178,17,216,6,127,245,188,73,182,173,76,98,25,163,225,4,133, 116,219,59,214,147,245,219,223,249,221,76,228,117,172,128,94,34,48,209, 153,26,72,171,158,157,201,122,14,55,250,108,46,89,190,224,144,251,200, 8,112,21,160,86,104,139,97,202,204,65,67,34,77,185,182,185,248,163,193, 144,230,88,70,68,66,58,250,87,39,134,114,215,179,59,135,49,214,137,24, 102,201,158,189,82,36,171,14,178,169,73,108,119,20,73,37,2,135,138,219, 125,46,96,0,32,67,47,190,240,194,11,23,188,110,96,100,6,250,227,143,63, 160,115,14,43,243,77,191,231,254,14,182,187,140,216,228,74,171,32,109, 163,55,185,119,30,222,244,88,214,77,31,203,150,150,17,217,50,176,153,114, 150,230,9,50,198,32,188,156,45,143,43,220,190,206,135,49,91,116,4,89,137, 48,104,51,12,34,67,100,212,49,108,195,232,24,229,206,161,116,251,129,137, 114,203,248,56,94,142,80,143,212,150,165,58,99,28,66,112,16,79,181,237, 11,85,20,211,90,190,221,117,6,67,128,186,29,143,14,9,250,37,147,237,100, 109,171,137,121,129,85,16,211,98,214,157,117,5,27,77,1,3,47,77,3,171,172, 146,161,4,134,142,15,221,208,6,24,233,214,177,62,67,101,118,198,167,157, 37,143,157,170,196,56,89,142,208,78,182,190,236,205,110,208,232,194,100, 94,182,173,18,129,0,187,248,34,53,171,76,111,58,207,128,240,46,122,7,112, 127,231,83,182,86,109,192,25,171,136,32,92,187,255,97,28,90,49,190,94, 205,226,245,110,123,221,170,227,166,69,74,157,217,66,83,235,98,164,4,32, 134,10,136,76,222,19,226,134,157,121,236,153,244,112,124,57,194,153,90, 140,68,165,165,213,48,172,128,103,169,183,142,117,221,173,67,138,20,198, 211,154,188,58,237,112,214,239,3,32,16,6,150,171,232,93,89,76,166,191, 227,215,196,17,58,68,48,6,140,115,56,126,14,194,245,161,162,86,103,123, 250,161,97,250,253,36,68,6,42,108,85,34,93,223,150,173,103,71,235,164, 39,83,37,64,1,246,123,42,5,14,110,217,87,192,237,7,74,216,51,233,195,217, 92,65,24,0,214,49,151,120,170,125,111,120,116,182,185,196,170,22,122,255, 55,136,10,221,224,15,173,154,2,58,135,172,73,53,235,49,243,214,222,0,17, 152,16,240,138,83,224,206,214,10,82,173,45,162,73,100,19,65,85,18,45,178, 152,87,135,106,100,19,140,86,2,24,170,17,145,4,208,89,205,193,25,195,92, 209,197,84,222,193,98,61,193,177,149,8,181,200,116,165,242,176,96,214, 116,36,198,237,124,187,86,92,166,243,125,166,164,173,62,183,243,107,80, 195,29,141,31,105,217,249,94,75,96,173,254,144,37,124,244,181,182,54,238, 159,102,5,171,72,90,242,186,30,184,216,88,193,165,30,43,40,235,252,180, 248,245,233,202,244,246,148,151,31,45,1,56,53,64,131,203,160,59,156,97, 239,148,143,217,162,139,51,149,24,39,170,9,90,177,217,146,90,107,125,58, 54,60,203,58,158,57,221,9,247,90,77,122,144,206,193,54,252,115,117,191, 165,157,208,231,80,92,235,81,236,118,248,170,9,166,87,66,165,196,50,105, 33,137,205,136,144,217,254,107,58,31,68,230,24,14,31,222,150,109,230,70, 74,128,36,74,154,84,48,27,134,43,125,135,227,192,140,135,29,5,129,83,53, 137,51,117,133,72,14,175,228,101,58,68,135,8,60,245,221,115,62,32,138, 214,115,194,26,172,55,14,187,9,161,67,88,14,235,52,98,189,136,107,42,147, 12,65,132,76,225,237,116,190,189,31,3,162,109,49,1,129,17,19,192,112,17, 18,134,168,25,8,32,239,113,220,48,231,99,247,132,139,19,149,4,11,77,5, 169,135,156,43,211,87,75,132,141,156,45,182,19,24,227,27,73,222,158,25, 61,51,249,250,193,25,224,34,129,84,26,224,133,30,47,242,22,245,154,53, 68,16,174,7,38,28,80,154,45,220,219,249,246,112,138,53,153,19,91,187,200, 250,24,41,1,32,27,109,210,165,234,102,135,117,194,44,12,152,12,56,110, 222,29,96,111,91,227,120,37,193,74,91,67,15,169,32,116,7,247,32,145,221, 189,22,31,176,65,196,122,140,232,213,194,173,32,32,8,6,204,20,4,156,132, 16,70,45,36,74,35,70,1,112,115,0,68,87,39,96,171,26,218,216,189,221,75, 4,199,5,99,162,179,248,99,205,113,13,34,117,110,253,134,182,134,145,90, 1,123,38,38,170,141,70,253,223,181,154,205,175,43,53,252,254,174,130,1, 115,5,129,87,237,13,112,203,110,31,83,57,177,45,169,165,140,1,83,121,23, 215,236,40,96,38,239,64,240,213,33,160,85,61,182,38,24,148,117,157,195, 25,118,21,57,102,114,2,156,115,120,14,199,132,163,48,131,38,114,170,14, 166,162,129,230,233,208,65,46,34,24,153,64,134,13,91,76,187,15,166,44, 24,182,173,186,248,54,250,88,215,191,198,251,63,250,209,157,185,220,204, 47,229,39,138,31,244,130,224,122,193,87,167,204,26,189,177,77,31,41,194, 185,186,196,201,154,68,43,214,27,78,126,12,64,84,91,134,12,91,176,37,91, 109,57,23,102,52,166,3,96,46,32,228,115,57,184,65,128,182,18,88,12,9,141, 4,32,38,58,165,93,58,225,92,48,196,245,21,232,36,178,129,31,104,236,202, 19,138,142,29,205,141,90,21,82,74,240,212,63,193,24,135,34,190,178,172, 253,175,147,91,188,141,123,254,21,156,11,150,229,245,119,246,56,26,2,58, 137,16,55,43,125,82,67,203,232,171,48,213,183,46,29,57,178,45,187,140, 93,140,100,61,250,131,223,251,189,133,217,128,126,119,121,105,225,237, 205,106,229,247,226,56,90,160,45,196,125,3,135,225,234,185,0,63,122,245, 36,174,219,153,71,224,110,237,182,5,103,216,93,114,177,183,148,142,122, 6,8,198,48,157,23,184,113,71,128,235,119,4,40,5,2,253,110,9,234,252,243, 5,176,111,66,96,210,231,224,220,254,48,198,210,206,231,118,103,50,198, 150,29,166,63,61,221,54,239,138,195,230,219,85,216,250,79,90,38,243,100, 247,144,219,210,61,147,233,247,2,146,209,49,41,245,55,75,71,110,222,150, 165,247,192,197,145,0,171,112,232,208,253,222,236,85,201,235,115,133,137, 143,231,114,249,159,116,93,175,184,153,4,0,172,55,207,115,93,24,48,84, 219,18,71,151,67,204,215,227,62,69,113,173,4,112,96,176,167,200,49,237, 51,91,195,79,38,240,131,28,130,32,7,199,117,225,56,46,132,35,160,33,80, 14,9,231,154,26,109,133,78,34,72,84,91,134,75,9,246,22,128,188,200,138, 68,216,159,90,165,12,173,117,166,83,44,104,152,223,146,245,234,159,30, 62,124,88,2,192,77,55,29,242,106,51,241,171,93,55,255,47,193,248,219,24, 99,115,27,21,206,234,133,108,55,58,69,173,1,128,140,145,58,73,254,171, 142,227,223,174,28,59,188,181,40,235,6,184,232,4,200,240,174,119,221,91, 154,218,55,243,51,185,98,225,99,158,231,221,198,57,223,48,83,50,35,64, 39,183,206,16,22,155,9,142,46,133,88,105,201,142,162,216,75,0,143,27,92, 81,114,48,233,1,90,43,40,37,161,164,68,16,4,240,115,57,56,142,7,199,113, 32,28,7,66,8,8,33,144,24,134,197,150,193,124,83,163,157,104,176,246,10, 246,230,20,2,145,229,255,101,142,25,66,181,188,146,122,246,216,25,192, 252,150,99,228,131,143,15,40,217,114,224,224,193,32,9,131,219,29,225,127, 72,120,193,221,220,113,103,54,83,106,146,102,21,42,182,190,30,50,70,154, 36,254,31,17,169,79,55,158,251,214,202,150,191,236,13,112,201,8,144,93, 255,125,31,249,205,61,249,82,254,221,190,159,251,128,31,4,87,243,53,250, 65,231,64,198,224,122,94,159,235,55,209,6,103,171,49,142,45,135,168,69, 10,160,116,212,234,16,87,78,10,20,93,171,99,40,213,75,128,28,252,92,14, 174,227,66,184,14,132,232,18,128,167,63,145,2,22,234,49,116,125,17,30, 201,52,99,169,235,72,48,70,163,90,94,129,214,234,20,136,62,190,119,110, 250,243,15,109,82,224,113,207,109,183,229,25,155,123,131,112,253,15,113, 63,184,75,8,183,52,136,8,68,132,164,81,78,179,128,140,210,50,250,211,72, 201,251,154,223,63,188,237,91,203,92,106,2,0,0,14,29,58,36,38,246,92,249, 242,66,97,226,215,114,133,252,207,185,174,63,183,182,163,215,35,64,134, 80,26,156,40,135,56,89,142,144,212,150,113,69,94,34,239,0,90,41,232,85, 4,72,16,4,121,75,0,215,133,112,28,56,194,1,119,4,4,183,157,47,132,0,231, 2,74,73,44,158,59,11,41,147,110,76,0,214,177,163,181,66,101,101,233,152, 214,250,227,123,103,167,190,188,89,231,247,98,199,77,7,139,110,224,191, 89,4,185,15,10,63,120,51,231,78,177,151,8,100,140,85,62,101,172,117,18, 255,111,30,153,95,95,124,241,155,23,156,255,55,8,151,5,1,50,220,125,239, 189,254,149,110,240,99,185,124,233,99,65,62,127,135,235,184,249,236,179, 205,8,0,88,157,169,25,43,44,47,156,131,14,155,48,70,247,16,192,238,51, 160,148,68,144,203,195,15,130,85,4,16,78,218,249,41,9,56,23,144,50,193, 210,252,57,168,108,255,128,30,47,98,28,71,47,84,87,150,239,253,198,99, 63,250,87,231,91,178,109,250,182,59,39,125,198,239,116,188,252,135,28, 207,127,3,119,156,60,192,96,180,66,84,91,210,42,106,127,158,116,116,239, 202,243,79,157,61,159,246,135,193,101,69,128,12,239,121,207,199,166,252, 185,220,219,139,133,210,61,126,46,119,171,16,194,25,134,0,128,21,159,11, 231,206,162,89,175,15,32,128,132,148,18,185,92,30,65,46,83,2,187,58,0, 23,14,4,231,125,4,208,58,75,102,177,18,32,73,226,103,91,141,198,135,31, 251,210,231,191,134,11,92,152,1,0,165,155,126,100,166,80,152,190,219,245, 252,15,113,47,184,157,180,242,218,229,249,191,212,81,114,79,249,133,39, 71,186,149,196,101,73,128,20,236,189,191,118,223,21,249,201,226,123,243, 249,194,251,124,63,56,224,7,193,166,74,244,42,2,104,13,173,187,4,144,113, 108,218,237,214,55,92,215,59,49,49,57,245,211,65,46,55,231,186,30,132, 35,32,210,125,1,173,248,183,36,72,162,8,203,139,11,233,174,161,0,17,81, 28,69,79,55,155,141,123,254,250,75,159,255,6,182,201,31,159,61,239,238, 91,127,108,206,9,74,111,3,115,110,151,43,243,255,126,225,251,79,190,184, 141,237,15,190,232,168,47,112,161,56,116,232,144,200,239,61,240,138,82, 97,226,158,201,169,153,127,230,249,222,204,198,211,64,70,128,90,74,0,251, 147,36,177,110,53,155,95,108,55,43,247,9,165,206,230,103,246,188,161,48, 81,188,183,80,40,222,233,7,65,81,56,253,4,136,195,16,43,75,139,89,110, 62,197,97,248,221,90,163,254,107,95,253,242,23,158,196,246,118,126,47, 216,109,183,221,230,100,166,228,168,113,217,19,32,195,161,67,159,200,237, 184,182,116,176,88,156,248,68,144,203,189,201,117,221,129,85,72,7,17,32, 73,98,217,106,54,255,172,86,95,249,228,19,143,62,218,153,79,239,190,251, 238,82,97,118,207,221,249,98,241,158,32,95,120,189,231,251,94,166,0,114, 193,17,181,219,40,47,47,193,24,67,113,24,62,217,168,86,62,252,215,95,249, 226,83,24,93,231,95,116,188,100,8,144,225,253,159,248,196,76,49,63,243, 207,243,133,226,71,252,156,127,139,16,206,170,116,159,181,4,72,146,56, 110,55,155,127,80,15,235,247,63,254,197,47,14,50,163,216,91,127,225,23, 118,230,11,147,135,138,197,210,7,115,185,252,203,29,215,19,66,112,180, 91,45,172,44,45,82,20,182,255,182,81,169,220,243,55,127,245,165,239,225, 135,168,243,129,151,32,1,44,136,253,234,61,191,113,85,113,102,246,125, 133,98,241,189,158,231,237,227,220,58,114,123,9,144,36,113,171,89,111, 124,38,44,199,191,243,232,163,15,109,226,61,187,159,191,243,151,78,94, 85,152,156,248,23,197,226,196,175,4,185,252,254,86,179,65,243,167,79,127, 173,218,44,127,248,107,95,254,242,179,23,227,201,46,54,94,162,4,176,56, 120,255,253,206,77,77,243,234,194,100,225,222,92,190,240,54,215,245,38, 1,96,225,220,89,84,203,43,181,70,163,246,59,225,242,252,103,30,121,100, 248,122,251,7,15,30,116,246,93,127,243,45,197,82,233,67,82,202,185,83, 199,94,252,244,163,95,250,220,15,70,247,20,151,22,47,105,2,100,248,192, 7,238,207,187,51,184,179,80,156,248,88,16,228,222,184,56,127,166,177,112, 250,204,191,13,171,11,255,237,225,243,44,162,124,239,189,247,250,101,192, 255,227,207,124,230,146,109,235,122,49,240,67,65,128,12,31,184,239,190, 185,137,137,29,239,108,52,106,149,195,143,151,255,226,240,225,255,114, 81,52,233,49,46,47,172,159,222,51,198,24,99,140,49,198,24,99,140,49,198, 24,99,140,49,198,24,99,140,49,198,24,99,140,49,198,24,99,140,49,198,24, 99,140,49,198,24,255,56,240,255,1,180,29,225,136,38,255,92,154,0,0,0,0, 73,69,78,68,174,66,96,130, } }, {.path = "data/icons/icon16.png", .size = 686, .data = (const uint8_t[]){ 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,16,0,0,0,16,8,6,0, 0,0,31,243,255,97,0,0,2,117,73,68,65,84,120,156,173,146,187,107,83,97, 24,198,159,239,124,231,154,211,156,164,49,41,218,14,109,189,118,20,65, 116,116,233,32,21,21,74,6,113,112,83,68,68,112,80,113,9,245,127,112,113, 237,36,186,40,29,138,139,84,116,81,90,132,82,74,165,109,154,166,77,47, 49,57,151,228,92,114,190,115,206,231,212,218,216,130,131,62,211,203,11, 207,239,125,30,120,129,127,20,57,188,226,164,248,116,214,216,85,91,29, 195,140,51,177,28,144,139,250,183,221,137,137,137,228,175,128,59,165,178, 234,8,254,85,30,179,135,158,93,179,8,48,160,232,57,69,210,50,83,29,183, 241,14,205,198,194,212,171,235,222,145,128,27,165,197,33,1,236,137,64, 197,91,161,111,101,27,213,239,80,123,242,40,12,95,66,204,2,238,153,155, 63,3,215,156,92,95,219,120,190,60,253,168,179,231,19,247,73,36,186,205, 227,248,94,219,174,9,174,85,69,109,229,35,68,69,131,144,82,160,235,253, 132,74,74,65,213,123,71,207,141,24,47,151,167,177,186,231,19,246,134,158, 108,31,51,10,131,66,58,63,140,132,51,36,81,8,215,222,68,179,190,128,132, 51,200,90,22,156,243,147,126,199,30,60,88,97,63,1,168,104,9,162,146,40, 122,78,24,62,63,142,254,211,87,176,189,242,25,249,193,11,80,83,121,152, 181,69,236,86,191,6,129,189,101,29,4,236,39,248,49,63,105,174,45,189,79, 60,183,6,73,237,129,102,20,160,165,79,64,20,83,112,173,26,182,43,95,96, 153,75,26,147,195,241,145,155,15,206,162,88,164,93,9,92,183,110,251,126, 131,217,246,170,152,105,158,65,74,237,195,86,229,19,90,237,50,66,207,134, 227,172,66,78,103,83,84,82,158,37,49,27,59,101,27,197,21,96,89,252,29, 133,59,4,156,197,81,160,53,235,243,168,119,2,120,173,117,48,222,70,232, 218,96,158,13,73,55,32,136,18,101,126,43,205,19,39,236,170,144,75,235, 109,77,86,2,74,69,16,66,192,147,24,128,0,65,148,64,40,5,161,18,98,214, 65,20,250,136,2,111,71,112,90,86,87,133,203,67,186,227,49,212,55,172,176, 175,230,48,196,157,0,146,68,65,8,64,121,12,65,145,3,206,33,69,126,155, 50,207,174,150,227,186,223,5,80,125,179,38,167,142,221,79,229,229,199, 253,25,101,180,178,195,244,152,170,190,146,86,100,151,74,155,77,203,125, 97,50,105,32,138,217,88,28,134,175,49,55,203,14,189,50,0,60,44,149,140, 156,145,191,214,110,187,197,106,165,252,182,55,219,59,212,106,89,115,204, 106,124,120,3,224,248,22,114,219,116,215,196,204,76,244,167,247,160,200, 221,82,41,197,57,39,156,115,114,212,161,255,166,95,198,13,47,109,193,128, 95,158,0,0,0,0,73,69,78,68,174,66,96,130, } }, {.path = "data/icons/icon24.png", .size = 1156, .data = (const uint8_t[]){ 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,24,0,0,0,24,8,6,0, 0,0,224,119,61,248,0,0,4,75,73,68,65,84,120,156,229,148,91,136,85,85,24, 199,255,107,173,125,246,62,251,92,183,141,51,227,56,86,106,99,163,86,134, 18,20,100,8,133,72,6,5,129,212,147,224,67,18,148,208,91,69,15,167,121, 42,232,33,144,222,130,40,232,169,99,47,221,156,64,2,195,16,82,81,52,50, 115,46,122,230,118,206,156,251,62,251,178,246,222,235,210,195,96,56,205, 56,22,61,69,255,183,197,226,251,126,124,127,254,223,7,252,215,69,214,250, 44,149,74,244,172,123,192,105,250,102,239,194,208,215,242,153,238,222, 205,134,246,20,191,116,105,246,244,233,49,241,175,0,135,222,60,95,76,76, 246,146,6,142,200,36,188,194,221,234,84,202,46,30,38,132,48,195,204,124, 79,173,194,151,92,185,23,199,199,158,112,255,17,224,208,161,47,152,218, 185,125,55,49,237,183,136,214,7,69,28,218,110,125,2,220,107,170,66,255, 3,52,227,12,193,48,109,45,69,220,229,94,243,156,224,189,19,66,69,227,167, 142,63,63,3,64,255,181,31,93,214,252,253,201,98,60,58,242,134,4,78,104, 153,188,40,146,208,230,126,3,220,171,35,14,219,84,201,24,41,43,135,148, 149,39,74,196,142,18,209,126,173,213,71,137,215,126,103,223,190,18,91, 109,2,227,246,135,12,253,39,9,99,99,90,198,217,94,123,6,132,80,196,81, 15,141,249,139,232,53,167,224,251,243,160,118,26,197,190,17,72,17,65,43, 9,102,152,41,102,102,7,201,195,123,139,56,141,230,154,0,77,145,48,106, 209,84,198,129,86,2,157,234,111,88,184,241,35,186,139,191,67,75,129,110, 227,26,42,83,39,81,236,142,192,41,140,194,46,108,0,33,4,134,85,56,16,123, 245,103,1,124,190,38,160,176,110,56,160,166,45,180,146,96,169,52,88,42, 13,5,1,201,67,184,141,9,200,36,2,163,6,114,249,77,200,228,6,64,8,67,28, 118,16,116,230,152,20,60,184,171,69,52,149,243,40,51,34,80,153,79,8,135, 149,235,195,125,59,15,98,120,116,63,26,149,11,168,77,159,193,166,251,247, 195,25,216,14,173,36,252,246,60,220,250,4,188,214,205,200,15,171,141,187, 2,230,110,142,251,233,204,70,94,112,182,130,80,6,51,157,71,42,109,67,9, 129,245,247,238,6,99,38,178,133,141,160,148,193,119,23,225,214,39,208, 170,94,70,123,241,215,88,137,48,194,82,42,245,29,1,245,27,103,2,101,218, 129,157,25,128,115,207,14,172,235,219,14,51,157,7,161,26,65,123,14,49, 119,33,98,14,195,140,16,116,230,208,170,93,70,207,171,192,200,23,10,204, 28,252,224,193,23,94,255,140,104,125,242,218,87,235,171,192,152,90,1,136, 100,134,27,74,122,129,95,67,24,212,209,105,93,69,255,208,99,40,56,91,17, 120,85,84,103,126,66,36,58,232,219,176,11,181,153,179,112,187,83,48,236, 28,152,149,54,152,97,62,165,181,126,92,43,121,113,219,193,217,35,215,191, 195,213,21,0,0,49,0,15,0,180,86,8,252,26,42,147,227,176,172,34,220,133, 235,8,188,26,100,45,65,183,125,29,126,163,2,173,36,8,33,96,169,52,168, 97,66,203,196,140,67,127,179,226,254,159,251,181,108,209,226,94,43,33, 32,238,237,11,174,181,68,232,47,34,137,61,16,74,65,25,131,84,17,64,41, 98,191,139,168,215,130,146,75,103,73,41,5,25,135,45,161,100,115,85,192, 68,190,42,24,99,29,74,25,40,53,64,200,242,75,66,64,64,152,1,202,82,32, 132,130,153,54,64,8,100,204,161,146,8,42,230,144,9,95,224,237,78,111,85, 0,202,101,245,232,112,182,61,236,88,48,13,3,148,153,32,148,1,132,44,5, 132,210,91,99,65,43,9,195,206,194,176,50,0,52,148,76,32,162,0,50,137,42, 181,81,135,175,154,34,0,122,184,104,77,15,57,52,106,120,137,53,221,138, 208,10,1,161,53,40,51,96,232,4,148,44,89,97,81,5,173,148,84,44,171,84, 18,167,160,20,4,247,32,184,63,137,242,55,242,78,0,8,229,127,74,169,29, 246,103,232,107,142,109,239,168,135,154,77,47,122,176,179,6,250,45,27, 52,107,163,229,113,152,202,224,158,215,253,184,33,114,191,40,173,142,40, 145,236,73,184,63,171,132,58,181,220,214,85,164,181,38,111,191,251,225, 22,106,147,87,44,43,125,216,143,146,161,217,233,73,63,230,254,185,190, 254,129,135,162,40,202,181,235,245,227,11,157,197,247,126,30,31,239,109, 121,250,229,1,37,228,115,73,16,84,230,207,127,251,3,0,181,38,224,150,142, 30,61,154,26,220,182,107,143,82,226,213,133,217,202,149,166,219,252,100, 104,96,227,35,81,20,143,120,11,149,114,185,92,246,214,170,255,219,58,118, 236,152,85,42,149,86,216,249,255,208,31,211,152,67,184,18,172,9,128,0, 0,0,0,73,69,78,68,174,66,96,130, } }, {.path = "data/icons/icon256.png", .size = 25043, .data = (const uint8_t[]){ 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,1,0,0,0,1,0,8,6,0,0, 0,92,114,168,102,0,0,97,154,73,68,65,84,120,156,237,189,121,148,100,87, 125,38,248,221,251,246,88,115,173,77,251,142,4,2,172,2,44,104,176,12,216, 141,198,216,6,108,87,131,7,27,153,197,178,1,111,221,182,199,237,110,247, 225,104,206,216,211,103,122,254,24,79,219,61,99,187,123,122,102,142,105, 47,50,227,165,141,141,187,237,134,2,140,133,160,88,36,144,16,42,169,170, 84,91,110,145,177,199,219,238,50,127,220,247,94,188,136,140,200,140,200, 140,200,204,168,122,159,142,42,35,99,121,239,190,151,241,251,238,111,255, 1,25,50,100,200,144,33,67,134,12,25,50,100,200,144,33,67,134,12,25,50, 100,200,144,33,67,134,12,25,50,100,200,144,33,67,134,12,25,50,100,200, 144,33,67,134,12,25,50,100,200,144,33,67,134,12,25,50,100,200,144,33,67, 134,12,25,50,100,200,144,33,67,134,12,25,50,100,200,144,33,67,134,12,25, 50,100,200,144,33,67,134,12,25,50,100,200,144,33,67,134,12,25,50,100,200, 144,33,67,134,12,25,50,100,200,144,33,67,134,12,25,50,100,200,144,33,67, 134,12,25,198,5,1,64,15,122,17,25,14,30,228,160,23,144,97,127,113,231, 195,63,107,45,46,220,245,22,74,232,107,130,70,229,191,181,42,23,158,122, 238,11,255,87,11,128,60,232,181,101,216,127,100,4,112,29,225,193,83,255, 199,13,102,49,255,51,166,83,254,32,161,250,34,243,219,21,191,83,253,98, 216,217,252,4,243,54,62,93,106,127,249,242,233,211,167,217,65,175,51,195, 254,33,35,128,125,192,169,83,127,172,93,45,248,247,128,185,204,117,228, 185,51,191,251,83,225,126,158,255,228,163,191,99,228,2,231,77,166,157, 255,53,221,206,191,81,211,77,67,253,233,37,4,103,8,253,182,31,186,141, 231,67,183,246,215,65,187,246,231,153,86,112,253,32,35,128,41,227,141, 239,255,15,203,185,252,145,247,233,86,225,195,60,244,136,215,174,124,42, 116,235,127,194,54,215,206,60,249,169,199,154,152,178,144,189,233,189, 191,115,156,218,133,159,50,157,210,163,186,233,28,39,84,27,248,62,41,5, 120,232,139,208,107,84,130,78,253,139,65,167,254,9,230,213,63,93,106,127, 62,211,10,174,97,100,4,48,37,156,124,244,119,140,18,242,175,55,115,71, 127,197,202,149,222,170,233,150,37,1,240,208,147,204,111,85,253,78,237, 73,175,181,249,71,110,103,245,211,119,106,79,93,122,252,241,199,249,164, 207,159,11,140,55,25,86,233,95,26,78,225,77,221,93,127,39,100,90,193,245, 132,140,0,38,15,242,134,15,252,251,227,197,252,13,143,234,185,194,79,26, 102,254,56,161,122,239,125,150,18,66,48,48,191,229,251,157,218,243,129, 219,248,207,161,95,249,211,160,94,253,230,153,191,124,172,179,215,5,188, 246,145,223,58,150,211,231,127,122,167,93,127,39,244,104,5,94,253,139, 65,43,211,10,174,53,100,4,48,65,60,252,240,111,90,254,45,71,223,106,231, 151,126,197,176,75,175,215,12,107,199,93,87,10,14,22,122,34,116,235,107, 190,91,253,44,115,27,127,194,91,141,211,255,240,167,173,13,224,49,49,206, 249,79,158,124,212,176,239,59,249,157,102,110,254,215,76,167,248,22,77, 179,12,144,73,252,137,51,173,224,90,69,70,0,19,129,36,111,250,208,227, 183,230,242,133,143,26,86,233,125,186,149,95,30,123,215,149,18,156,7,8, 253,102,39,236,52,190,17,184,213,79,116,106,27,127,85,115,95,122,254,236, 167,254,173,191,211,199,95,125,234,215,151,139,133,19,31,180,114,11,31, 49,172,220,141,91,180,142,9,33,211,10,174,45,100,4,176,71,188,242,199, 254,77,254,72,254,214,183,155,197,165,95,210,173,194,3,154,110,106,123, 187,173,82,105,5,129,203,2,183,126,217,111,87,255,54,232,212,31,111,53, 94,122,242,233,79,254,235,26,250,118,91,181,235,191,242,59,13,103,249, 87,77,167,244,86,93,183,172,201,236,250,59,175,51,214,10,120,232,62,15, 232,127,205,130,250,159,139,234,230,83,95,248,139,95,201,180,130,25,65, 70,0,187,197,199,62,70,31,58,127,235,221,214,220,209,159,55,157,185,247, 232,166,51,71,200,238,108,237,97,144,82,64,48,95,134,94,179,225,119,106, 95,14,59,213,199,125,215,253,47,206,90,229,226,233,211,143,177,87,159, 250,245,229,98,238,196,7,173,194,194,71,116,51,119,35,213,166,179,235, 15,7,129,102,216,48,236,34,0,41,66,183,85,9,220,205,47,122,237,205,79, 4,157,218,167,205,203,235,151,79,159,126,44,211,10,14,49,50,2,216,5,94, 247,222,223,44,149,231,239,248,33,195,41,254,162,110,229,239,213,52,99, 143,187,254,78,80,187,45,243,219,65,224,53,94,12,90,27,127,229,182,214, 255,161,184,120,251,251,204,92,233,31,19,170,91,83,60,249,64,16,170,193, 176,139,48,172,2,18,115,39,113,110,182,253,192,109,60,31,180,171,127,237, 117,54,50,173,224,16,35,35,128,49,112,234,212,41,109,181,248,253,175,180, 75,71,127,217,114,230,126,64,51,236,2,33,251,155,82,47,120,128,230,250, 57,209,88,123,62,40,44,221,102,21,22,110,34,84,183,32,5,131,224,1,164, 24,203,111,184,43,104,186,5,211,153,131,102,90,24,246,21,82,190,2,47,210, 10,170,95,12,221,230,159,135,157,218,223,209,139,151,47,102,90,193,225, 65,70,0,35,226,193,15,254,222,66,41,119,252,189,134,93,252,25,221,202, 223,69,53,131,236,235,237,35,0,243,59,104,87,206,163,177,254,34,252,78, 21,133,197,91,96,229,230,97,56,101,88,185,57,104,134,29,155,13,16,130, 3,114,178,27,46,33,20,186,149,135,225,148,64,169,62,218,135,34,173,32, 244,219,65,232,53,95,244,219,245,79,249,110,245,207,130,160,246,213,39, 63,254,243,83,79,132,202,176,61,50,2,216,1,39,79,62,106,44,188,254,237, 175,179,114,75,191,172,25,214,219,168,110,216,251,45,248,16,2,94,187,130, 118,229,2,188,86,5,126,167,10,30,184,40,44,221,2,221,202,67,211,45,104, 134,3,195,204,195,112,138,208,140,28,0,9,206,2,72,30,66,202,189,107,5, 84,51,96,58,101,232,102,14,187,117,50,70,90,129,12,189,86,53,116,107,95, 242,221,250,39,88,187,254,183,153,86,112,112,200,8,96,27,60,244,145,191, 60,150,115,156,247,91,249,133,15,235,102,254,70,66,53,34,37,135,228,108, 42,59,108,63,8,1,88,232,195,173,95,133,91,191,138,192,107,130,135,30,152, 223,6,15,93,20,150,110,133,110,230,64,53,3,132,234,208,52,19,212,136,200, 192,202,67,51,28,16,66,33,120,0,193,2,181,230,113,55,92,66,160,27,57,152, 185,50,168,102,76,230,194,50,173,224,208,32,35,128,1,184,243,225,223,180, 238,188,239,222,55,154,246,220,191,208,157,226,27,117,205,52,251,119,61, 41,56,132,96,144,156,79,100,135,77,131,16,64,74,137,192,109,192,173,95, 129,223,222,4,11,92,8,30,66,240,112,40,1,80,170,129,80,29,68,211,161,233, 38,52,221,134,102,58,208,13,7,132,106,16,60,4,103,126,164,21,236,44,99, 132,234,48,237,34,116,187,128,105,249,58,122,181,130,250,151,124,183,150, 105,5,251,136,140,0,122,32,201,63,254,240,31,222,168,229,142,126,196,206, 47,190,95,183,114,71,119,74,232,145,82,40,50,224,12,82,236,61,157,159, 16,64,176,16,94,123,3,110,99,29,161,223,128,96,1,36,87,132,211,75,0,183, 65,55,157,173,4,64,181,228,127,170,25,145,137,96,67,51,108,80,170,67,8, 6,30,250,145,211,112,208,154,9,52,35,114,244,25,251,20,96,216,162,21,84, 63,213,94,127,225,207,54,154,231,191,122,246,83,255,54,211,10,166,132, 140,0,34,60,244,200,167,109,103,129,255,119,102,174,244,203,134,85,122, 141,166,27,227,165,209,74,9,17,19,129,28,223,60,136,119,125,22,180,225, 53,55,16,180,55,17,134,46,164,80,196,178,149,0,188,72,3,216,134,0,8,237, 18,1,213,65,117,51,33,3,66,117,64,237,190,224,204,135,16,12,144,18,132, 80,21,222,179,139,216,109,13,193,94,33,120,8,183,177,38,59,245,149,106, 224,214,190,20,184,213,79,248,94,253,111,231,27,122,166,21,76,24,25,1, 224,99,244,173,31,122,217,157,206,194,205,63,99,228,74,239,213,13,103, 129,208,189,169,187,105,141,96,20,243,128,16,2,33,24,130,78,13,126,171, 130,208,107,130,71,187,179,148,124,34,4,64,8,85,255,107,26,40,85,90,1, 53,108,80,77,87,105,200,204,135,20,2,186,153,131,102,152,56,168,175,6, 103,1,130,78,13,60,244,0,41,162,188,130,78,16,120,141,23,67,183,241,169, 208,173,255,89,205,91,201,180,130,9,225,186,38,128,135,62,242,199,5,199, 156,127,135,153,47,255,146,97,151,238,215,244,201,38,244,72,41,18,193, 29,164,106,171,93,31,224,204,67,208,174,194,239,84,193,66,23,146,179,196, 180,152,56,1,80,10,66,162,223,35,95,1,213,45,232,166,3,167,116,4,144,0, 11,58,202,68,216,141,211,112,247,55,11,44,104,35,112,235,16,124,235,38, 223,245,21,52,171,129,215,204,180,130,9,225,186,36,128,83,167,78,105,181, 227,239,187,215,202,47,254,162,105,149,126,88,51,237,226,84,19,122,6,152, 7,74,248,5,66,175,141,160,83,85,187,62,243,83,130,63,1,2,136,133,61,33, 131,136,4,34,2,64,252,28,213,96,88,121,20,22,111,129,110,216,0,0,206,3, 48,223,5,11,189,137,133,18,135,222,30,193,17,184,117,48,191,189,243,121, 146,108,195,76,43,152,4,174,59,2,120,232,145,255,56,103,207,31,123,143, 93,60,242,243,186,85,184,91,211,116,186,159,183,65,105,5,12,44,232,32, 112,235,8,58,117,176,176,19,217,250,98,68,2,104,69,4,112,91,20,5,208,35, 2,232,117,0,246,104,1,253,187,63,161,64,66,8,20,154,97,35,55,119,2,84, 51,34,199,161,1,66,104,92,174,12,22,184,137,153,48,73,25,227,161,143,192, 141,84,254,93,220,203,68,43,232,52,191,20,248,153,86,48,46,174,27,2,56, 117,234,143,181,250,141,165,147,150,61,247,63,24,118,241,97,205,176,242, 251,157,198,75,8,129,148,18,60,244,224,214,87,224,119,170,202,195,47,69, 36,232,162,247,241,126,19,64,249,120,226,248,35,132,130,106,122,68,8,58, 0,9,30,6,8,3,23,60,116,19,167,225,110,33,165,0,243,219,8,221,134,58,214, 94,144,105,5,187,198,117,65,0,111,124,255,31,47,151,151,142,188,207,112, 230,63,170,155,246,173,42,141,119,63,65,84,120,143,115,176,64,125,233, 253,246,38,56,243,182,10,253,33,33,128,238,210,9,40,209,64,117,165,25, 196,14,75,22,120,81,110,194,176,80,226,112,8,193,16,38,42,255,100,101, 51,211,10,198,195,53,77,0,39,31,253,29,99,142,44,252,35,171,120,228,151, 237,194,226,91,117,211,217,167,90,249,46,146,93,159,249,8,189,38,152,223, 78,236,248,184,120,71,9,125,74,245,223,129,0,66,175,5,30,186,40,46,223, 190,149,0,52,173,107,247,143,65,0,186,233,192,41,31,223,54,225,135,80, 26,69,16,12,16,170,37,215,165,156,134,222,72,217,145,60,244,148,151,159, 237,216,227,100,111,200,180,130,145,112,173,18,0,121,195,7,254,253,241, 124,254,248,163,86,110,238,81,221,116,142,81,205,36,84,51,34,1,217,15, 213,191,111,215,143,210,120,99,39,215,161,35,0,43,143,92,233,216,72,121, 254,132,16,117,62,221,128,166,233,0,136,34,181,192,77,50,22,251,157,121, 177,202,31,184,245,137,36,76,141,131,68,43,240,155,85,191,85,253,12,235, 172,252,252,147,127,250,216,165,125,93,196,33,197,136,37,93,179,131,135, 30,249,152,77,245,123,223,98,149,151,126,197,180,139,175,215,116,219,0, 33,234,75,192,124,16,78,147,12,185,189,198,251,135,161,107,235,7,8,189, 38,66,191,21,133,182,70,221,116,246,135,151,119,123,22,41,37,36,15,33, 56,3,167,52,113,26,154,185,18,12,187,160,156,134,190,155,84,37,10,30,42, 71,95,208,153,184,202,63,10,162,40,7,161,84,95,224,129,119,50,112,109, 115,223,23,113,72,113,13,17,128,234,203,103,23,138,63,103,88,165,247,234, 166,179,76,6,148,172,42,47,188,74,48,161,61,68,48,9,161,75,239,250,157, 104,215,119,71,15,161,169,89,29,35,32,126,19,233,251,57,248,144,3,127, 155,8,199,168,246,101,92,112,8,22,128,106,26,168,102,194,48,115,48,76, 7,156,5,240,218,85,248,237,10,120,224,30,140,240,71,100,28,6,29,4,157, 26,154,149,11,205,202,229,175,185,251,190,144,67,138,107,130,0,84,95,190, 63,121,187,89,92,30,189,47,159,84,93,118,4,231,202,182,213,140,72,85,222, 157,100,236,125,215,159,0,14,208,160,83,26,150,0,231,12,132,104,137,159, 0,82,64,183,242,160,154,14,22,120,187,114,26,238,22,132,208,200,225,216, 64,224,214,148,121,18,186,53,29,205,61,183,94,191,86,48,219,4,240,177, 143,209,239,185,244,178,123,104,190,252,243,102,110,238,221,187,235,203, 215,221,197,98,39,215,120,126,130,104,215,23,28,60,232,168,146,221,96, 140,93,127,234,32,35,241,2,165,19,74,130,148,18,82,50,176,128,169,157, 215,109,66,66,130,106,22,76,71,117,46,226,204,139,50,13,247,22,74,220, 14,132,16,240,208,131,223,174,34,240,234,42,187,18,18,82,202,58,47,220, 48,101,15,228,236,96,102,9,224,117,239,253,205,82,185,114,199,15,153,11, 197,95,210,204,252,189,154,110,236,57,161,71,10,1,46,34,63,65,148,51,191, 157,159,128,128,64,77,251,241,17,250,45,132,94,11,130,135,216,183,93,191, 71,163,223,122,237,227,221,141,201,171,15,82,240,164,208,136,128,36,142, 73,205,112,160,233,118,82,158,28,231,66,76,2,177,38,22,120,77,85,87,225, 183,146,34,167,168,248,105,237,194,233,243,89,56,48,194,204,17,192,169, 83,127,172,173,22,221,169,246,229,147,82,64,50,1,73,88,159,195,176,43, 36,42,30,206,193,3,55,181,235,143,161,218,238,41,28,73,14,172,82,111,60, 68,68,40,5,68,228,56,36,0,64,40,168,166,129,16,29,186,153,135,52,28,213, 176,132,249,16,187,168,164,140,17,255,77,252,246,38,252,86,69,101,23,18, 128,16,165,221,72,33,32,137,220,0,78,31,22,245,236,192,49,83,4,240,224, 7,127,111,161,154,119,126,188,96,30,253,25,195,206,223,49,237,190,124, 202,219,29,251,9,52,80,93,143,122,225,17,101,235,251,77,149,148,195,195, 169,119,7,234,93,152,234,251,55,212,150,222,231,92,135,97,80,33,205,248, 190,200,200,60,16,144,50,132,96,82,213,34,16,77,101,28,82,3,212,54,35, 19,97,252,86,102,177,202,239,54,214,16,116,170,224,177,214,145,50,9,165, 16,66,114,182,14,32,35,128,8,51,65,0,39,79,62,106,20,95,243,150,215,217, 249,165,95,54,172,194,219,116,195,182,177,175,105,188,82,117,221,13,57, 4,60,85,183,239,183,85,229,222,20,28,90,219,5,3,4,15,208,168,158,67,171, 122,30,174,87,193,220,145,123,144,43,157,0,53,183,255,83,238,228,9,80, 90,212,164,137,67,98,216,149,72,41,33,69,8,200,0,60,68,146,175,16,247, 44,32,134,13,206,3,8,22,70,247,120,240,113,8,33,144,144,8,220,58,58,245, 171,8,189,38,164,16,74,67,234,35,66,33,184,16,158,187,49,225,139,156,105, 28,122,2,120,232,35,255,241,152,169,45,189,223,116,202,31,214,205,124, 52,252,98,223,51,121,147,50,217,208,111,171,62,157,123,80,85,7,29,123, 103,72,248,110,21,213,213,111,160,85,125,9,130,5,104,86,95,68,167,189, 130,92,225,40,202,75,119,161,48,127,11,76,187,180,203,117,76,158,80,165, 16,221,123,36,147,127,122,223,35,37,32,57,132,20,234,229,160,211,237,100, 100,216,208,205,156,234,116,204,131,173,173,204,34,149,223,107,174,193, 173,175,128,5,110,87,229,143,94,87,63,147,5,49,98,217,107,19,191,208,25, 198,161,37,128,83,167,78,105,155,71,222,247,38,59,87,252,87,154,153,127, 163,54,160,47,223,126,64,197,245,85,246,93,220,168,35,238,177,183,95,16, 156,161,185,121,14,181,245,103,17,120,141,30,213,88,240,0,237,198,101, 184,237,85,88,107,207,160,180,116,7,74,139,119,193,206,45,2,195,214,120, 160,22,66,63,9,116,127,79,178,33,153,122,142,120,13,16,106,64,55,29,104, 166,3,77,55,163,208,173,50,185,88,232,162,93,189,4,175,185,14,193,195, 164,212,121,216,245,9,30,250,34,108,213,167,116,97,51,137,67,75,0,23,235, 247,149,151,238,88,124,44,63,127,195,119,1,0,15,188,129,41,166,83,3,1, 32,37,66,191,173,74,118,131,142,242,102,71,94,230,253,146,161,208,111, 162,186,242,13,52,107,23,162,8,3,34,153,217,218,164,212,235,84,224,95, 170,162,182,254,28,10,115,183,96,238,200,203,144,47,157,128,78,157,3,17, 122,41,5,36,100,143,204,203,212,191,67,85,31,41,33,37,135,16,2,82,186, 8,189,38,8,85,5,75,134,85,128,166,91,240,218,21,52,215,206,194,239,212, 148,151,191,39,140,169,12,158,248,255,248,145,148,220,11,89,216,152,248, 133,206,48,14,45,1,180,13,91,46,19,170,171,178,84,101,23,114,22,168,162, 147,41,79,192,33,164,219,154,42,244,26,170,112,69,42,167,213,126,105,33, 82,114,180,235,151,80,89,121,10,126,103,115,107,132,97,216,58,164,84,164, 177,246,77,52,171,47,32,87,186,1,243,71,238,67,113,225,86,24,86,49,125, 0,76,157,21,182,37,235,46,49,200,244,115,61,175,201,148,86,16,213,18,180, 171,48,156,50,120,232,38,181,21,42,178,208,61,50,73,253,219,189,79,18, 82,202,182,77,115,153,6,144,194,161,37,128,133,215,60,232,146,144,54,88, 208,1,165,1,72,84,240,98,216,5,21,95,14,61,229,45,158,164,19,142,0,144, 2,65,167,169,218,115,249,109,8,25,123,147,35,27,121,202,206,126,2,32,12, 59,216,92,125,6,141,141,111,131,49,111,215,39,229,204,71,115,243,28,218, 245,75,176,243,75,152,91,126,25,202,203,247,192,206,47,164,188,227,68, 149,252,106,147,55,105,198,74,253,149,91,216,160,247,170,165,0,64,96,230, 230,224,148,142,130,16,10,187,176,4,183,185,6,175,185,14,22,180,123,53, 179,1,89,207,34,244,107,85,247,74,150,5,152,194,161,37,128,245,103,62, 35,114,55,63,84,53,236,34,132,12,33,121,144,36,147,40,7,145,3,205,176, 85,34,73,232,67,236,177,83,141,26,194,225,193,111,111,118,203,85,165,84, 241,127,162,18,126,166,189,247,75,41,224,182,86,80,185,242,53,116,90,43, 35,145,219,40,107,18,130,193,109,173,194,107,111,160,178,242,20,202,139, 119,98,254,232,203,145,47,157,0,213,237,189,47,124,8,122,156,128,91,94, 220,241,211,61,143,169,110,193,46,44,195,202,47,168,40,1,33,208,13,7,118, 97,9,225,66,11,126,171,2,183,181,30,69,1,226,60,159,238,221,145,82,66, 66,54,66,215,28,191,245,208,53,140,67,75,0,203,107,159,17,242,134,215, 55,16,139,158,148,16,146,43,34,8,93,85,142,170,233,202,60,112,76,8,198, 122,218,91,143,12,229,229,131,215,174,193,111,173,35,244,219,145,186,157, 218,245,251,49,1,63,68,127,205,1,103,62,234,27,207,97,115,245,27,96,126, 75,217,206,19,134,148,2,129,87,199,198,229,175,160,182,254,44,10,115,183, 96,225,216,253,40,46,220,6,96,105,226,231,75,206,59,194,181,244,155,1, 202,2,80,143,117,51,15,187,184,12,195,46,37,229,199,0,34,205,197,128,149, 155,135,105,151,224,148,143,35,112,107,240,90,27,8,221,58,4,83,62,19,41, 37,4,11,192,153,95,155,231,65,80,153,228,197,205,56,14,45,1,156,62,125, 154,191,253,59,127,125,93,70,13,52,19,72,9,33,5,36,11,35,237,149,118,67, 70,86,78,165,243,134,158,234,177,183,3,17,16,2,176,160,13,183,177,22,181, 231,138,119,253,84,12,121,106,91,127,124,124,9,191,83,193,198,149,175, 160,89,127,9,114,64,71,220,9,157,41,5,229,65,175,109,60,135,102,245,28, 156,226,49,156,184,251,45,88,186,241,36,76,179,52,161,126,9,114,12,243, 108,176,107,144,16,10,195,42,192,42,44,66,55,243,170,94,97,8,226,198,166, 186,153,83,90,129,167,204,184,160,189,9,191,83,69,232,183,192,189,214, 218,217,179,238,254,54,35,56,228,56,180,4,0,64,178,208,109,152,40,11,64, 75,125,35,83,78,29,33,32,68,16,205,203,107,117,67,70,134,3,0,42,189,148, 7,91,137,64,141,223,65,167,185,1,183,190,10,22,180,32,5,79,154,99,72,236, 143,151,95,8,134,70,229,44,54,174,124,13,129,91,131,220,175,4,181,212, 197,9,30,162,211,184,140,149,75,159,71,203,187,132,82,249,118,148,231, 239,132,237,44,129,210,189,206,2,148,3,31,247,254,57,122,255,54,113,186, 0,161,26,12,187,8,203,81,83,143,71,37,37,66,136,26,126,82,48,97,230,230, 192,75,71,225,181,55,209,169,93,1,168,166,189,250,225,91,231,191,246,169, 211,27,91,78,124,157,226,48,19,0,194,118,181,138,242,81,1,160,251,215, 39,0,137,194,96,201,142,33,226,68,18,95,17,129,166,67,55,115,48,172,34, 116,189,16,13,199,140,66,136,4,96,126,11,157,234,101,120,237,13,112,22, 0,82,78,174,26,110,212,107,243,27,88,125,233,9,212,43,207,67,176,0,251, 251,125,28,112,161,148,192,247,170,88,247,190,130,106,229,91,200,23,111, 192,252,194,61,200,23,110,128,182,75,63,193,200,33,91,217,251,128,234, 6,76,187,4,195,46,129,234,198,136,245,140,253,32,106,26,146,93,130,110, 21,224,148,142,162,228,53,223,19,180,107,247,188,233,253,255,207,39,188, 206,250,95,137,179,223,62,119,230,204,239,134,187,56,248,53,131,67,77, 0,86,97,97,3,82,114,16,162,67,118,131,59,233,118,24,50,242,98,171,84,115, 161,84,127,166,136,192,111,85,160,155,57,152,185,57,232,166,13,22,116, 208,174,94,65,187,122,17,161,223,138,14,221,91,250,59,138,198,191,151, 92,4,21,222,187,136,213,11,255,128,86,237,226,33,42,27,142,33,193,88,7, 245,234,243,104,54,206,195,113,142,160,60,127,23,74,229,91,97,152,165, 209,251,37,200,65,247,105,120,18,144,250,53,158,73,88,142,84,254,201,124, 61,9,161,208,13,7,186,97,231,173,220,252,27,109,191,253,96,206,93,250, 168,87,56,254,55,111,184,231,228,39,24,185,114,230,201,143,63,118,93,246, 9,60,212,4,32,132,108,73,17,25,146,209,206,47,147,95,160,84,69,12,248, 171,73,1,33,56,164,240,16,250,45,120,173,13,152,185,57,72,206,208,220, 120,17,129,219,0,33,136,108,253,174,253,73,100,234,128,164,47,30,69,210, 191,236,14,44,236,160,186,254,77,212,214,158,133,223,169,238,111,1,209, 88,80,235,18,60,68,187,117,25,157,246,85,84,214,159,66,121,238,14,148, 231,239,132,101,47,140,40,156,3,174,79,198,245,1,91,205,50,221,204,193, 112,138,42,211,114,42,181,30,177,211,112,78,55,237,226,157,118,97,249, 142,192,111,254,104,216,89,126,242,77,143,252,251,63,106,53,175,126,250, 78,237,169,75,143,63,254,248,117,227,39,56,212,4,208,217,188,220,176,10, 115,46,128,92,178,219,247,96,208,110,148,14,253,168,127,140,92,41,106, 121,77,65,117,3,205,202,121,248,205,202,150,126,244,83,243,247,73,137, 78,123,21,27,87,190,130,78,243,242,4,119,253,73,174,118,208,177,212,29, 145,82,192,247,54,177,182,82,69,181,242,12,242,165,155,48,55,127,15,242, 133,227,208,180,193,211,131,149,54,54,194,117,202,120,135,182,161,71,89, 126,187,237,202,52,14,8,213,160,91,121,162,153,185,5,43,55,255,176,237, 47,191,217,42,44,63,191,30,222,253,123,15,125,236,35,255,238,244,99,111, 190,46,122,6,28,106,2,160,58,237,0,36,216,246,77,61,154,65,47,116,195, 134,93,58,2,167,116,20,186,225,0,132,192,180,75,200,207,223,8,183,190, 170,242,200,91,235,170,156,119,44,140,190,115,11,30,160,86,249,54,54,87, 158,66,24,52,199,60,207,62,33,26,15,54,24,105,90,148,8,195,54,106,149, 111,161,89,123,17,78,254,24,230,230,239,70,177,116,51,116,163,176,179, 224,14,72,242,33,84,131,102,58,208,205,124,111,136,111,159,64,8,137,71, 167,91,154,233,188,162,93,187,252,93,87,158,89,255,63,247,117,17,7,136, 67,77,0,246,242,77,45,10,244,181,111,138,213,255,109,26,97,18,13,86,174, 4,167,116,20,134,83,86,95,172,232,203,73,116,19,150,62,15,195,46,33,55, 119,2,94,115,29,237,218,101,120,173,13,21,6,236,65,175,23,59,201,197,39, 20,132,26,32,148,128,96,88,122,176,170,222,171,92,253,42,154,181,243,123, 159,126,115,160,216,170,27,113,30,160,213,120,9,237,230,101,88,246,60, 202,243,119,162,60,119,7,44,123,30,132,168,153,1,74,211,233,13,241,165, 65,168,30,77,35,118,182,13,241,77,21,209,223,142,51,31,126,187,138,198, 218,217,181,103,30,127,34,51,1,14,3,106,23,174,186,198,173,102,67,151, 5,245,196,208,210,89,162,218,115,17,2,170,155,176,114,243,42,118,108,56, 67,90,122,17,80,77,135,153,43,67,183,243,176,75,71,225,183,43,232,212, 175,194,111,109,128,135,105,34,80,133,41,220,15,84,91,113,170,69,57,6, 34,234,191,31,213,177,71,189,248,227,22,228,173,218,121,108,92,253,10, 124,183,54,108,209,7,130,221,239,175,131,13,36,41,57,60,119,3,190,87,193, 230,198,55,81,44,221,140,185,249,187,97,219,75,189,62,142,244,45,32,4, 154,102,69,173,193,204,125,154,211,48,0,68,125,161,88,208,65,208,169,35, 112,171,16,44,92,5,50,31,192,161,0,217,124,46,148,183,220,28,229,110,15, 248,234,166,53,1,66,96,152,5,88,249,133,110,198,216,8,182,36,165,58,76, 167,8,195,202,193,46,46,35,104,87,209,105,172,68,45,165,92,136,104,144, 39,11,218,16,92,181,8,227,134,5,61,244,213,64,14,45,30,201,165,131,16, 10,198,60,212,42,223,66,99,243,5,213,240,162,191,82,37,94,250,33,233,218, 51,30,250,219,145,167,94,145,18,97,208,196,230,198,55,81,175,158,133,109, 45,194,144,14,242,197,19,208,141,92,247,141,132,64,215,237,168,83,176, 1,85,249,39,39,146,93,57,22,34,162,102,126,11,65,167,174,6,159,114,198, 66,175,185,178,191,11,57,88,28,106,2,192,203,95,238,82,205,104,108,221, 123,250,126,211,116,152,86,65,133,251,134,238,250,219,163,155,73,230,192, 42,44,34,112,107,112,235,171,104,109,190,4,214,90,71,232,181,146,247,201, 184,121,5,33,106,74,14,81,237,196,125,175,134,90,229,57,248,94,5,113,145, 13,81,225,134,212,207,120,253,147,38,128,221,31,47,158,26,52,58,182,119, 151,114,238,163,190,121,22,237,149,115,176,172,121,148,151,239,193,220, 242,189,176,156,57,24,70,14,90,52,210,60,94,182,170,188,22,128,136,91, 136,77,81,99,138,136,87,181,11,111,34,244,234,137,105,39,4,231,58,213, 87,167,119,242,195,135,67,77,0,55,149,192,59,29,191,6,91,70,127,184,173, 81,0,205,176,97,56,37,24,86,113,228,93,127,59,196,115,242,52,195,130,149, 155,135,51,119,28,157,205,75,168,175,62,135,118,237,114,164,21,132,64, 98,2,40,147,160,213,184,136,70,245,28,4,247,35,193,143,132,138,80,16,26, 11,63,77,72,65,141,253,74,125,217,71,238,12,52,5,144,109,234,30,134,98, 231,152,137,16,12,157,230,85,176,208,133,83,56,138,252,220,141,208,13, 123,160,195,145,16,10,104,20,36,233,27,184,77,33,209,110,17,11,63,11,16, 184,117,85,56,148,42,179,22,156,121,33,243,174,171,150,97,135,154,0,214, 62,243,219,194,126,245,191,168,13,250,178,17,74,161,27,57,24,118,105,215, 187,254,118,136,39,230,58,186,34,130,194,226,45,104,215,46,161,177,122, 22,157,250,149,104,16,102,136,192,111,160,89,59,7,175,83,137,63,24,249, 35,4,192,145,210,2,186,164,160,6,86,112,213,226,42,190,178,84,221,250, 232,139,156,232,37,239,2,195,73,64,10,14,72,32,95,190,1,55,220,249,189, 40,47,223,13,205,112,118,54,125,98,141,74,210,110,83,209,73,152,7,145, 189,207,3,15,190,91,3,247,59,189,225,88,2,72,201,59,1,119,107,123,63,217, 236,224,80,19,192,233,211,167,249,247,127,231,255,212,203,200,132,128, 82,3,186,153,131,110,229,161,105,198,158,119,253,237,160,114,203,77,104, 133,69,152,78,25,133,133,91,224,214,87,208,220,56,135,205,171,79,163,186, 254,77,132,126,111,120,79,166,213,255,56,83,145,144,40,143,161,59,72,68, 132,65,234,125,81,66,99,100,90,116,15,118,120,28,136,131,49,152,4,40,213, 176,112,244,229,56,126,251,155,145,47,159,136,84,254,49,254,78,49,17,96, 2,230,1,33,128,20,170,187,147,91,7,11,221,158,60,47,117,25,18,82,240,54, 149,206,117,213,49,232,80,19,0,0,41,37,111,75,193,37,209,40,137,189,199, 186,149,31,170,74,78,13,132,128,234,6,44,125,14,134,93,132,51,119,28,206, 220,81,24,118,30,149,43,95,71,167,121,181,27,38,76,90,96,39,191,37,154, 1,8,133,36,68,77,170,137,166,213,168,215,186,231,233,54,180,234,53,15, 134,7,212,208,125,223,214,135,163,92,220,88,239,222,138,94,18,208,168, 137,185,229,59,81,158,187,27,166,51,183,231,16,223,174,205,3,2,117,191, 57,67,232,53,213,128,82,22,36,43,238,190,141,64,74,128,179,160,42,234, 87,218,123,90,236,140,225,176,19,0,188,214,198,134,153,95,224,132,80,93, 51,44,21,55,158,242,174,191,61,212,142,77,169,134,252,220,77,184,233,229, 75,88,186,233,181,168,94,125,26,27,151,191,138,118,253,162,106,38,210, 15,213,144,34,81,103,69,52,238,187,39,195,145,116,191,215,105,66,72,29, 4,50,157,99,191,39,237,160,123,92,74,181,9,152,80,138,4,12,163,128,249, 242,61,40,148,110,153,124,74,239,56,230,65,98,239,251,202,222,119,27,209, 172,198,173,239,81,253,10,4,0,84,91,218,210,117,213,49,232,208,19,128, 97,21,125,205,112,164,233,148,64,53,115,106,35,189,71,131,4,103,1,88,160, 230,1,168,146,213,2,116,243,54,228,230,142,99,241,198,7,80,91,125,22,235, 151,190,140,214,230,57,176,112,187,118,94,234,203,43,165,250,2,202,158, 77,52,149,206,188,165,113,158,4,132,170,106,148,156,67,18,10,162,109,67, 134,100,200,227,9,131,128,192,182,151,177,48,127,31,156,252,81,104,154, 57,61,146,222,201,60,136,147,123,66,23,126,167,134,208,107,69,206,62,25, 173,52,66,215,1,3,41,37,56,115,87,47,133,237,89,206,216,26,27,135,158, 0,230,111,124,197,13,249,185,121,221,180,76,4,190,0,11,2,8,190,183,246, 95,187,129,20,2,44,84,51,239,251,251,11,16,170,65,55,243,200,47,56,112, 74,71,48,127,226,126,212,215,158,195,198,197,51,104,84,206,170,249,116, 163,172,87,70,166,3,84,92,189,91,152,20,127,60,142,153,43,123,64,240,168, 41,10,36,84,231,178,173,195,48,246,3,148,232,40,228,111,198,220,252,61, 176,236,185,110,136,111,31,208,111,30,0,170,97,12,243,218,8,58,85,176, 160,131,116,70,34,146,71,4,132,72,149,71,66,34,167,165,16,43,56,243,187, 215,77,18,16,48,3,4,192,66,63,36,84,147,150,163,17,203,209,16,6,58,124, 151,33,244,67,8,62,124,98,204,36,33,120,168,218,130,239,208,173,71,69, 14,28,228,202,39,96,231,151,48,127,236,229,104,108,188,128,141,139,95, 70,125,253,57,53,165,118,71,143,118,202,246,143,4,61,17,250,152,0,162, 93,44,94,15,145,18,160,2,68,170,54,105,216,195,152,243,113,161,107,14, 230,74,119,161,56,119,7,12,35,119,112,51,11,137,170,255,23,60,26,7,222, 222,84,26,88,108,122,197,111,139,25,53,50,183,226,219,36,174,211,177,97, 135,158,0,220,218,74,53,95,58,42,58,212,164,134,9,24,38,129,97,26,189, 68,32,38,52,165,167,15,82,74,213,125,56,106,63,61,42,84,129,137,5,71,63, 2,43,55,143,242,145,187,209,218,60,143,141,139,95,65,117,245,155,240,59, 149,110,132,96,28,2,75,136,32,50,13,4,135,140,213,93,41,64,165,80,249, 9,84,135,208,84,142,2,25,161,219,111,220,248,116,60,16,88,230,28,22,230, 239,67,174,112,34,170,226,59,56,243,140,16,2,206,66,4,110,45,73,231,150, 113,217,113,58,35,57,118,183,68,209,150,184,242,91,10,198,153,215,186, 238,166,6,29,122,2,48,243,11,27,18,224,156,65,23,28,8,3,32,38,2,211,138, 137,128,35,244,67,112,62,185,121,243,66,48,240,192,5,103,123,24,247,29, 213,38,216,121,21,66,44,46,221,129,35,213,7,81,185,252,53,84,46,127,21, 237,205,139,169,200,193,46,32,165,242,3,72,9,42,53,229,201,150,18,132, 10,80,169,131,104,2,36,234,118,180,173,144,143,57,239,128,16,13,121,231, 24,230,231,95,14,43,183,160,156,178,7,149,148,64,8,136,84,29,157,131,78, 21,129,171,230,56,72,136,20,89,34,49,165,226,240,159,76,61,142,76,0,70, 12,235,186,202,2,4,102,128,0,116,195,104,73,165,235,71,161,26,64,112,32, 136,136,192,52,9,12,83,7,11,52,120,30,71,232,133,16,124,231,134,160,67, 33,37,56,243,163,193,159,19,210,6,147,238,181,42,132,88,88,184,21,203, 55,191,22,149,75,95,195,250,133,39,209,174,93,76,194,83,187,93,179,20, 28,18,18,68,106,80,141,83,37,136,224,32,154,0,52,29,68,106,234,255,1,67, 51,199,129,166,217,152,159,187,7,229,242,157,81,98,207,1,58,101,163,196, 137,48,232,192,111,87,193,252,22,132,8,147,48,225,150,188,1,169,34,46, 36,14,171,198,105,200,32,16,34,236,248,237,198,230,1,93,201,129,225,208, 19,64,123,237,92,195,112,230,92,72,153,75,194,54,18,144,12,240,251,52, 130,130,169,131,57,26,124,151,35,240,67,8,54,30,17,72,193,193,66,55,233, 19,56,121,144,168,248,168,4,195,202,35,63,127,19,150,111,121,45,54,47, 63,141,181,243,79,168,200,65,224,238,254,240,209,72,45,9,9,42,37,32,169, 42,203,21,92,21,44,105,26,164,166,131,38,68,48,158,240,154,102,25,75,75, 175,70,105,238,118,213,95,1,50,153,213,183,223,173,205,226,116,234,208, 111,41,225,143,156,125,82,8,72,17,133,245,100,111,67,242,184,12,35,109, 251,199,79,72,33,58,38,213,171,251,122,17,135,0,135,158,0,52,187,208,34, 132,250,3,243,205,36,32,98,34,240,187,68,144,47,233,176,152,6,223,21,8, 189,16,156,133,59,16,129,4,103,97,20,222,219,159,40,144,42,62,42,64,95, 188,29,185,242,9,44,221,124,18,181,171,223,196,234,185,47,160,190,254, 124,84,124,52,100,205,59,185,14,98,34,144,82,57,8,165,6,33,4,136,208,64, 132,0,52,77,85,47,106,218,240,1,162,233,211,17,138,92,238,24,150,151,31, 128,83,60,14,77,51,19,39,163,70,53,80,221,232,18,193,30,7,180,140,2,66, 8,4,103,8,220,6,2,183,26,249,104,162,156,128,232,167,132,76,145,184,250, 246,36,26,127,76,2,169,190,114,146,5,117,207,175,183,166,186,240,67,136, 67,79,0,78,233,104,135,128,12,200,172,73,65,249,195,224,187,145,70,96, 0,134,69,144,47,106,224,142,6,223,53,16,120,33,56,99,91,118,42,41,69,202, 209,183,255,105,183,132,82,232,102,14,249,249,27,225,20,151,177,112,227, 171,209,172,156,195,218,249,39,80,185,248,21,4,157,234,30,214,165,90,167, 75,41,65,41,141,28,94,50,202,97,224,160,66,149,51,67,10,72,198,148,169, 208,151,103,65,169,129,114,249,14,44,46,189,10,150,51,175,162,12,253,215, 64,168,74,151,214,12,8,161,136,96,42,142,217,84,243,14,85,191,95,83,221, 158,209,85,249,21,241,41,18,234,189,111,82,145,86,154,5,16,53,128,87,67, 103,106,65,7,215,85,18,16,48,3,4,208,185,250,130,171,221,252,242,38,48, 218,220,123,193,35,141,32,4,116,3,48,45,32,95,210,96,229,52,4,46,135,239, 133,224,161,34,2,21,222,115,247,230,136,155,16,8,161,208,173,2,236,194, 50,202,71,238,196,242,173,175,67,125,229,91,88,57,251,89,172,93,120,18, 94,115,109,15,106,182,76,198,116,73,66,65,36,5,149,18,92,10,144,120,206, 162,223,81,45,184,53,3,36,138,32,232,122,30,139,139,175,192,220,194,203, 162,46,189,59,152,12,145,175,131,106,186,170,117,96,97,84,245,56,153,73, 74,113,84,198,239,84,17,122,81,102,95,42,195,50,238,66,148,196,253,123, 188,127,93,213,95,170,228,95,36,58,165,114,166,110,208,101,235,186,27, 27,118,232,9,96,253,234,185,48,127,227,189,157,62,195,109,71,8,14,4,28, 96,41,34,112,138,26,44,71,131,215,225,232,52,91,96,126,231,144,180,234, 34,208,116,85,224,20,199,209,29,221,130,157,155,199,252,137,151,227,134, 181,239,197,202,11,159,199,234,139,127,143,78,237,50,68,255,164,224,145, 17,9,138,80,201,50,202,97,40,192,3,31,161,215,6,213,13,104,154,9,106,152, 200,21,79,224,200,177,215,162,80,190,25,154,110,143,153,87,16,245,228, 55,117,53,179,97,175,126,130,164,121,71,7,126,123,19,97,208,142,170,13, 101,106,183,23,177,45,31,153,0,232,49,1,72,154,4,82,38,129,50,7,4,24,115, 215,206,126,234,169,235,42,9,8,152,1,2,184,233,198,151,187,212,48,27,187, 181,43,19,34,8,0,221,84,126,2,221,84,53,255,144,64,24,196,217,125,7,147, 255,17,151,29,171,233,55,36,245,60,1,137,67,136,183,148,81,62,118,15,110, 120,217,247,96,245,133,191,199,202,11,159,67,179,114,30,91,70,134,143, 1,41,37,192,213,238,44,88,8,17,6,144,156,3,186,68,105,254,46,28,187,241, 31,193,41,28,5,213,245,116,242,236,248,215,71,181,1,126,130,209,215,77, 8,129,16,28,161,215,64,208,174,169,232,76,148,239,16,39,72,37,194,15,209, 173,17,72,251,0,8,65,156,88,153,132,0,82,255,171,17,227,218,26,112,58, 35,128,67,135,82,137,243,192,173,201,220,252,158,34,205,66,0,129,167,136, 64,141,26,32,48,157,34,116,203,1,11,60,176,160,51,249,113,227,59,128,106, 58,116,211,1,213,204,225,111,74,135,16,173,34,138,75,183,227,248,61,111, 193,250,185,127,192,202,11,159,71,99,227,133,193,197,71,163,34,18,22,17, 6,48,236,18,142,222,248,122,28,185,233,65,152,78,121,162,141,58,99,63, 1,213,12,200,17,253,4,221,228,158,216,222,247,123,67,124,41,181,191,75, 4,125,213,130,177,159,47,189,251,247,77,123,246,221,77,222,216,120,110, 5,251,145,86,122,200,112,232,9,96,237,51,143,139,165,183,190,167,54,169, 105,185,66,0,60,228,96,129,27,13,21,53,97,218,5,232,102,154,8,252,233, 18,65,212,99,64,53,50,25,85,200,162,70,166,78,9,186,149,71,97,254,38,28, 187,243,33,172,191,116,6,171,47,124,22,181,213,111,129,133,187,11,33,18, 66,225,20,142,224,134,59,190,7,11,199,239,135,110,228,166,86,116,69,8, 1,217,226,39,232,11,215,70,229,209,42,185,167,166,38,253,114,150,114,246, 245,239,254,41,251,95,240,174,118,160,14,214,45,169,216,50,240,85,162, 211,92,193,213,23,63,199,155,235,103,175,171,94,128,49,14,61,1,156,62, 253,24,127,207,219,127,114,99,210,77,35,165,20,106,156,56,15,65,53,29, 154,110,193,180,115,48,76,27,44,244,192,252,14,216,20,136,32,105,57,166, 91,187,78,200,161,84,3,181,11,208,205,28,114,229,227,56,122,219,131,168, 92,254,58,86,94,248,28,170,87,191,129,192,111,142,236,129,39,84,195,220, 145,123,113,219,253,167,80,152,191,37,234,210,187,31,89,125,253,126,130, 48,170,109,80,187,123,24,116,224,119,170,96,94,43,25,249,158,118,246,245, 254,236,18,128,136,8,1,73,121,101,228,248,4,208,175,246,183,106,151,176, 126,229,203,112,91,171,62,151,226,186,156,26,126,232,9,0,128,148,34,108, 74,33,6,166,2,236,6,106,119,139,190,28,82,128,179,0,130,179,136,8,76,24, 86,174,71,35,96,161,55,145,248,54,213,148,163,143,110,25,128,177,187,227, 18,74,161,91,57,228,205,27,97,151,142,96,249,230,147,168,174,60,139,149, 23,62,135,202,165,175,170,137,195,61,68,208,123,251,116,51,135,227,119, 191,25,183,222,255,78,216,197,163,209,96,142,253,71,236,39,208,140,104, 215,111,85,148,240,251,237,62,245,94,14,208,2,82,118,191,224,137,19,80, 33,46,156,74,229,3,16,149,230,93,223,60,139,205,149,167,192,152,7,41,120, 135,112,118,221,37,1,1,179,65,0,104,55,214,54,236,226,17,142,41,174,183, 75,4,97,66,4,186,229,168,161,162,161,15,230,119,192,67,47,242,31,140,41, 176,209,200,234,225,170,245,118,188,182,243,185,226,209,90,90,249,56,172, 252,34,22,78,220,143,198,218,243,88,121,241,243,216,184,120,6,110,123, 93,217,62,41,216,133,101,220,246,202,31,194,241,187,190,91,77,225,61,208, 62,11,36,73,238,97,126,27,126,171,2,22,118,250,118,250,148,208,67,244, 16,67,226,249,151,2,144,188,75,122,81,157,64,226,4,0,192,152,143,234,250, 51,168,175,127,171,27,1,146,178,13,199,172,29,192,133,31,56,102,130,0, 76,43,87,157,168,155,158,144,110,255,189,62,168,198,16,97,52,3,32,34,2, 211,129,110,88,41,34,240,163,47,207,8,194,73,53,232,198,94,84,254,97,159, 217,122,238,110,21,226,50,172,220,28,202,199,94,134,27,42,223,131,149, 115,95,192,198,133,39,209,105,92,133,148,2,165,35,119,227,142,7,126,20, 139,55,188,114,75,244,97,223,17,85,69,114,22,32,232,212,224,181,43,41, 79,255,78,206,190,116,139,48,101,255,75,33,226,244,30,32,110,193,22,69, 4,88,216,66,101,229,41,52,107,23,148,150,16,167,150,11,81,101,181,230, 117,151,4,4,204,8,1,24,70,190,41,177,135,152,215,46,32,165,132,228,33, 132,96,160,44,77,4,54,120,232,35,12,58,224,129,7,33,135,87,32,42,149,63, 63,48,123,110,239,216,190,11,144,170,66,92,128,233,148,80,92,190,3,39, 238,250,110,172,158,251,7,120,205,53,220,246,192,41,20,23,111,69,84,6, 55,133,181,141,8,66,64,36,1,99,46,252,118,21,161,215,84,14,216,129,118, 126,63,17,244,61,22,2,66,136,36,52,170,254,34,20,42,3,48,30,211,246,53, 116,218,43,209,169,227,251,39,1,200,106,145,148,219,215,93,30,48,102,132, 0,154,149,243,117,35,95,118,33,225,236,123,213,169,148,81,200,170,75,4, 154,97,65,51,44,112,203,71,152,152,6,41,34,136,166,223,104,230,65,85,203, 197,69,239,4,84,51,97,231,45,69,92,129,139,78,237,10,116,77,135,101,233, 32,186,3,22,134,224,225,254,134,63,213,218,40,32,5,194,160,173,132,223, 111,69,93,121,120,95,156,127,128,173,159,60,238,85,255,165,228,221,10, 78,18,219,254,2,157,230,26,42,43,95,71,224,86,17,119,104,142,33,165,132, 16,98,253,234,188,203,112,117,127,111,193,97,192,76,16,128,70,116,23,64, 40,227,140,174,61,34,30,208,49,170,167,28,64,47,17,80,77,17,129,174,136, 64,132,1,194,160,3,22,120,128,20,208,76,53,243,238,192,106,228,83,32,132, 128,249,109,212,86,190,133,250,234,243,144,130,161,93,91,129,20,12,185, 210,34,236,226,34,12,51,15,22,176,200,180,217,143,98,30,53,23,129,197, 149,124,97,39,170,89,80,187,56,132,216,222,217,23,87,253,165,237,126,17, 153,0,82,229,120,16,80,72,112,180,234,151,177,185,250,13,176,176,51,212, 212,33,82,174,225,153,103,14,67,74,232,190,99,38,8,32,183,120,83,3,68, 219,67,157,236,4,33,227,18,88,14,74,3,80,195,132,166,155,176,13,19,36, 175,122,244,177,16,123,235,73,48,1,196,95,118,191,189,137,218,202,115, 232,212,175,34,244,91,208,12,27,130,5,240,58,13,112,198,224,119,218,112, 138,101,88,249,57,24,102,1,140,177,168,239,226,104,62,142,49,87,213,173, 228,243,26,8,58,181,164,219,82,119,215,231,189,130,142,193,206,190,180, 6,16,199,255,227,161,173,0,129,148,28,205,234,57,212,54,158,131,224,193, 224,210,103,2,128,11,41,33,87,113,157,181,2,139,49,19,4,80,91,253,150, 191,120,211,3,45,56,147,58,34,233,9,14,237,14,82,85,190,249,28,156,6,208, 12,3,133,178,5,203,166,96,33,84,79,130,164,2,113,127,137,128,68,185,243, 110,125,5,141,245,23,187,163,207,165,140,76,18,18,53,57,245,19,167,103, 224,186,176,114,37,88,249,34,140,66,30,44,100,8,3,63,41,184,153,192,162, 144,56,251,220,58,2,183,14,193,130,68,240,147,93,61,49,1,134,216,250,253, 130,47,121,215,249,23,141,91,19,34,64,125,227,121,52,107,231,161,166,56, 247,10,127,79,0,86,10,206,121,112,93,38,1,1,51,66,0,155,149,179,65,233, 200,93,29,71,46,2,100,82,233,169,147,82,207,37,164,96,96,1,135,219,210, 32,97,246,84,32,38,68,16,238,15,17,16,66,33,120,128,246,230,69,180,170, 23,17,184,13,213,227,32,169,140,235,91,125,20,254,244,93,9,198,66,132, 190,7,43,87,128,225,228,97,20,10,96,33,71,232,123,145,70,179,187,77,146, 68,158,120,30,184,8,92,213,166,59,137,162,36,101,188,91,51,249,134,57, 251,18,45,65,164,9,64,21,29,177,176,131,218,250,179,232,180,86,226,147, 35,153,179,210,187,170,232,250,37,163,218,245,215,10,44,198,76,16,192, 37,231,105,23,103,89,253,136,247,26,44,28,121,5,44,187,140,189,8,48,73, 254,153,32,164,132,224,162,219,147,192,4,76,83,17,129,29,117,41,242,61, 150,148,34,79,3,132,80,240,160,141,230,230,75,112,235,43,8,131,206,224, 182,102,3,108,97,41,5,56,15,225,123,45,48,22,194,240,125,88,78,30,134, 237,192,40,22,16,198,68,192,198,171,234,35,68,13,241,96,126,71,205,228, 11,58,41,33,223,238,255,237,156,125,34,17,122,41,4,132,84,115,22,189,78, 5,181,245,103,225,71,206,62,229,235,73,47,166,255,1,129,148,162,195,130, 246,117,215,10,44,198,76,16,192,124,181,202,154,226,124,35,8,170,168,172, 63,133,165,163,175,198,252,210,125,187,39,130,169,48,0,162,47,237,214, 46,69,189,26,129,142,192,99,96,33,155,88,207,193,216,222,15,220,26,218, 155,23,225,181,42,96,161,191,53,196,215,167,129,144,212,191,233,218,120, 193,67,4,126,27,156,133,48,2,95,165,72,91,14,140,98,81,153,6,190,63,66, 225,20,73,85,242,181,16,184,117,240,208,131,74,226,73,237,248,177,9,16, 11,184,232,243,1,136,180,127,32,245,122,188,235,71,59,191,215,89,71,117, 253,25,4,110,61,42,255,31,241,239,43,165,107,66,175,141,246,230,107,15, 51,65,0,207,172,173,137,123,74,75,85,97,115,116,90,43,184,216,254,175, 216,88,253,218,222,137,96,154,232,239,82,20,19,65,49,210,8,60,3,190,203, 192,194,112,79,68,16,219,251,126,171,130,118,237,138,178,173,121,128,174, 186,47,163,127,227,114,170,97,157,129,251,215,175,124,28,129,215,1,103, 33,194,32,136,136,192,134,97,26,96,140,33,244,124,229,71,232,39,130,104, 190,33,231,161,42,227,117,27,81,211,149,72,240,209,215,190,43,109,215, 39,233,188,50,165,13,240,94,103,95,226,245,103,16,44,68,167,179,138,118, 235,34,160,83,24,185,98,82,96,52,240,194,122,6,175,10,72,33,234,176,141, 235,106,32,104,26,51,65,0,56,125,154,211,31,122,85,82,172,33,229,94,137, 128,168,148,220,125,10,125,247,19,129,97,2,78,129,194,114,76,165,17,68, 68,32,198,36,2,66,41,36,11,208,105,174,193,109,172,69,177,244,225,209, 44,2,178,115,137,239,128,198,139,66,112,132,190,11,206,89,68,4,14,12,211, 132,81,210,193,66,91,17,65,224,67,8,158,104,35,60,140,102,242,249,205, 110,217,111,210,183,47,157,197,215,39,232,219,58,251,162,159,92,121,252, 57,11,208,110,93,70,167,179,2,9,1,77,55,0,195,84,199,228,138,28,4,15,83, 154,79,58,254,31,145,9,231,53,230,177,195,17,97,58,0,204,6,1,168,13,172, 1,33,36,40,77,254,138,131,136,96,225,200,253,48,205,2,14,157,70,128,136, 8,60,69,4,73,151,162,136,8,2,79,13,58,97,1,139,234,13,134,131,68,201,44, 60,112,225,54,86,35,149,223,29,160,242,247,253,140,115,226,147,9,196,227, 64,245,18,84,45,212,24,88,96,193,176,109,24,166,14,163,148,7,15,109,120, 174,15,22,184,42,159,191,83,75,141,229,138,62,143,62,129,23,3,126,38,38, 64,218,201,215,235,237,23,34,4,99,30,218,141,151,224,122,21,168,108,63, 26,217,253,4,132,18,64,55,160,153,182,26,194,202,2,8,22,38,247,71,10,174, 230,61,72,1,64,86,231,200,130,91,31,243,110,92,43,152,21,2,0,115,155,27, 154,229,112,50,96,205,105,34,216,92,255,38,150,142,125,7,230,23,239,129, 177,13,17,76,35,255,125,36,47,191,140,154,147,248,189,237,202,236,124, 164,17,196,166,65,60,241,104,200,186,67,183,9,183,185,166,98,233,81,136, 111,219,147,2,189,49,128,30,207,248,118,247,98,144,195,144,35,12,61,112, 206,193,2,19,134,101,194,180,117,216,196,64,195,109,192,107,111,70,132, 36,227,15,244,105,0,3,76,0,193,149,51,47,118,238,13,176,249,133,224,106, 212,119,208,66,179,121,1,65,160,196,54,174,238,36,148,0,160,9,65,130,18, 232,154,1,105,90,144,17,17,240,208,87,93,162,163,14,198,156,135,43,23, 46,156,190,46,147,128,128,25,34,0,98,152,53,144,237,147,53,164,228,104, 53,46,162,211,186,138,141,149,175,238,64,4,211,208,16,70,12,243,69,133, 205,61,68,160,3,134,5,56,57,2,203,54,16,248,58,252,14,67,24,132,201,48, 84,18,165,207,250,110,29,94,115,29,161,215,28,179,161,105,191,23,160,247, 30,116,157,130,59,223,27,130,168,79,95,24,68,142,56,11,154,14,132,94,51, 154,109,144,18,126,164,67,125,91,85,255,94,7,31,223,34,248,137,179,79, 48,4,94,29,205,230,121,48,214,6,72,44,236,93,161,87,189,255,122,31,19, 66,85,15,5,195,132,102,57,16,97,0,230,181,193,252,14,36,65,5,215,105,18, 16,48,67,4,96,24,118,93,165,133,237,12,33,216,24,68,112,240,16,66,77,58, 98,12,8,35,34,176,157,136,8,188,104,244,89,160,114,246,253,78,21,126,43, 106,140,57,86,56,81,14,215,18,70,186,37,195,223,36,165,140,18,135,84,135, 159,45,68,152,244,232,19,91,132,191,199,203,159,18,246,56,189,87,36,49, 254,16,158,187,129,86,243,37,112,17,116,211,185,135,9,127,60,123,49,121, 30,145,121,16,165,113,91,57,24,204,7,15,252,239,63,254,154,239,185,34, 2,255,47,86,159,162,23,129,235,75,27,152,25,2,240,188,122,211,214,77,23, 128,61,234,103,182,35,130,3,29,105,53,4,49,17,164,91,154,91,57,2,221,208, 209,216,100,232,180,55,225,181,43,224,225,78,42,255,112,196,153,128,67, 94,77,253,232,247,158,15,253,37,65,34,204,201,19,233,221,63,14,237,165, 29,129,253,49,125,150,8,124,58,193,135,243,0,157,214,10,218,237,203,144, 146,111,217,245,211,2,159,60,135,126,34,64,151,32,64,64,117,10,77,215, 161,91,185,251,56,11,254,13,15,252,159,58,241,90,255,207,16,60,244,199, 185,246,229,103,207,158,61,187,135,70,139,179,131,153,33,0,26,6,29,41, 229,174,26,248,15,34,130,82,233,182,232,213,3,210,8,182,233,111,36,165, 114,20,178,80,69,12,108,91,66,112,23,126,148,62,59,154,169,209,191,11, 3,73,244,99,26,32,234,36,91,252,32,253,36,0,177,85,245,239,9,1,242,30, 66,96,204,67,187,117,25,110,103,85,213,249,239,74,248,35,151,231,0,50, 32,4,208,173,156,161,27,246,189,130,135,247,240,32,255,99,158,93,248,235, 163,229,219,255,16,161,124,114,245,169,255,218,158,206,13,59,28,152,25, 2,128,89,110,16,66,92,200,110,119,151,113,145,38,2,39,119,4,115,139,247, 162,92,190,3,186,145,155,200,18,187,109,195,38,67,42,49,17,8,14,132,126, 8,201,135,105,167,178,231,199,54,71,28,176,182,29,214,58,70,210,84,50, 158,43,57,87,87,240,211,142,192,222,212,223,174,183,95,8,166,10,122,34, 123,159,5,46,90,205,11,240,124,149,168,151,246,244,119,51,253,98,129,142, 178,254,210,166,192,64,225,143,134,131,162,143,12,52,13,154,166,83,106, 216,55,73,158,251,73,45,244,127,152,135,254,233,27,94,243,182,143,75,194, 78,95,249,210,223,109,142,114,135,103,13,51,67,0,212,247,61,228,156,137, 176,177,16,12,237,214,21,116,218,171,168,21,158,195,226,210,253,40,150, 110,129,166,143,108,93,76,6,35,114,133,202,139,217,253,119,111,75,52,176, 103,254,192,152,7,75,127,54,249,167,123,38,153,38,163,196,246,143,119, 255,110,78,127,156,229,135,200,233,23,103,244,117,61,253,77,52,26,23,16, 134,141,222,93,190,223,211,191,197,241,135,193,194,158,242,5,32,33,8,108, 121,142,18,2,104,22,209,12,115,81,136,220,15,241,192,127,155,8,131,39, 111,120,195,15,254,129,240,197,223,92,61,115,242,18,240,216,53,227,52, 156,25,2,104,214,55,253,82,169,216,154,92,167,122,21,53,104,55,47,193, 109,175,34,151,63,134,133,165,87,28,12,17,76,24,131,169,34,118,2,198,18, 219,31,1,24,196,4,227,177,67,98,227,39,103,236,238,246,177,19,16,114,64, 36,32,86,249,163,193,33,190,91,69,171,121,1,140,119,70,246,244,15,22,254, 216,167,177,85,248,187,239,29,242,28,165,160,148,66,83,51,209,222,44,5, 127,3,247,189,111,221,252,166,111,254,9,9,190,239,19,75,108,245,236,153, 51,103,14,126,166,220,30,49,51,4,32,143,30,113,41,213,166,146,178,41,68, 136,86,243,34,58,237,149,253,39,130,61,89,12,219,104,5,195,94,26,245,92, 187,88,83,215,182,71,111,236,191,47,12,136,196,33,216,91,210,203,185,15, 183,179,134,86,243,37,8,17,238,202,211,223,107,2,96,7,225,239,62,223,35, 252,41,159,2,213,141,184,165,155,165,155,246,171,116,59,255,10,30,186, 31,216,8,10,127,113,226,13,199,255,136,138,141,175,93,122,226,137,153, 205,36,156,25,2,200,179,151,184,144,247,182,38,105,99,247,227,64,137,96, 106,232,38,1,145,216,110,78,48,182,254,191,253,107,241,78,31,153,2,113, 222,191,76,147,193,160,48,160,16,224,220,71,167,189,130,118,231,50,36, 248,22,123,127,91,103,95,66,10,24,34,252,233,223,177,141,240,247,30,131, 26,6,40,237,138,8,161,26,116,75,211,52,195,188,77,183,114,63,167,155,249, 119,115,191,240,223,110,120,195,209,143,91,126,251,239,95,60,243,183,13, 108,203,202,135,15,51,67,0,103,93,151,223,99,250,27,210,206,237,214,7, 56,50,118,77,4,82,238,206,71,57,61,78,235,61,7,72,242,223,40,97,189,29, 65,122,31,36,161,62,116,119,254,30,45,32,149,10,156,142,0,112,230,170, 26,126,119,13,212,208,161,105,142,186,151,130,119,75,152,198,12,243,13, 38,3,140,36,252,132,82,53,41,121,72,221,4,161,20,26,181,8,213,205,99,194, 118,126,84,15,252,183,243,160,240,196,205,111,252,225,223,135,219,250, 187,151,206,252,205,204,116,24,154,25,2,192,233,211,130,188,235,85,213, 253,60,229,181,165,17,196,187,51,118,144,247,254,23,119,216,245,211,175, 247,169,253,137,189,159,56,255,186,218,64,108,2,132,65,11,155,43,95,71, 171,254,18,168,97,129,104,221,209,97,32,166,34,9,174,136,162,235,116,28, 164,5,96,7,225,79,155,1,125,175,111,17,126,115,164,112,41,33,4,154,110, 18,77,51,202,194,114,222,198,45,255,187,184,157,251,198,45,223,245,35, 127,196,155,141,63,191,84,242,207,227,244,225,78,44,154,29,2,0,4,64,155, 187,77,128,217,211,137,83,68,144,47,156,192,226,242,171,144,47,222,8,109, 187,161,158,227,98,162,90,64,255,61,82,191,115,22,128,139,0,216,241,84, 164,247,17,233,125,174,255,61,241,57,18,181,62,93,246,155,210,2,100,202, 31,0,41,224,185,155,216,184,250,85,184,173,213,36,202,161,66,169,12,2, 106,120,42,213,12,64,87,105,199,224,28,66,8,196,3,62,135,10,127,252,56, 122,126,44,225,55,76,140,157,36,70,212,220,70,234,104,142,102,217,175, 229,97,238,213,220,202,125,232,150,192,253,11,188,225,29,127,96,172,249, 207,158,61,251,169,67,153,88,52,75,4,0,230,181,214,117,219,230,4,218,36, 131,1,35,67,136,16,205,198,5,116,218,87,145,47,222,136,133,197,87,76,158, 8,38,13,169,254,241,189,42,54,215,159,70,171,115,17,139,236,149,40,45, 220,1,195,74,253,249,35,7,218,32,144,45,15,6,127,172,27,239,143,78,156, 10,5,246,146,129,64,167,185,130,141,149,175,192,239,108,14,206,106,20, 2,2,12,84,74,16,77,7,213,116,165,25,196,166,65,212,255,111,220,48,95,143, 179,47,45,252,154,74,17,222,155,125,169,202,173,169,229,24,186,97,189, 140,179,220,221,60,240,254,123,102,186,255,229,230,227,239,250,184,91, 217,124,114,253,153,211,135,106,252,192,76,17,0,136,108,73,85,15,112,32, 4,16,131,243,0,141,218,139,104,55,47,245,16,129,82,27,247,176,149,15,250, 232,158,20,30,181,43,183,155,87,177,185,242,20,60,183,2,65,24,86,175,60, 137,70,253,60,230,151,95,134,226,220,109,48,237,242,128,207,110,87,48, 220,239,67,136,206,22,77,229,217,170,254,119,181,0,33,24,154,181,115,216, 88,253,58,152,223,236,61,234,0,225,83,59,127,212,152,84,211,65,52,13,84, 215,213,177,121,138,8,162,101,245,8,255,118,97,190,20,65,80,77,7,213,141, 61,10,127,47,8,165,208,77,155,106,134,121,163,176,114,239,103,129,255, 14,170,91,159,179,231,223,249,7,97,219,251,244,202,215,62,181,129,67,224, 48,156,41,2,48,204,66,133,168,9,65,198,65,175,5,216,74,4,139,203,175,196, 188,121,47,116,125,98,237,139,119,135,232,107,197,69,136,122,245,44,106, 27,207,130,5,109,196,130,32,5,135,219,94,131,239,85,81,171,60,135,185, 165,123,49,183,116,23,76,123,174,247,56,100,224,195,1,32,145,204,167,226, 252,241,66,146,200,0,192,121,136,218,198,179,168,174,127,83,13,92,237, 95,112,218,167,208,119,194,152,8,164,20,74,27,136,39,11,39,68,208,109, 186,218,99,18,68,143,135,10,191,30,9,255,148,188,176,132,80,104,134,73, 168,110,44,74,203,126,39,11,253,239,53,28,247,171,55,189,241,135,254,83, 200,189,191,90,249,135,252,37,224,241,125,158,202,210,197,76,17,0,247, 220,38,181,76,31,99,20,4,237,7,186,68,112,25,213,205,103,177,124,252,36, 74,229,219,212,60,192,113,177,87,95,64,36,75,140,117,176,185,250,52,26, 181,115,81,139,176,1,111,149,28,158,91,193,234,229,39,80,175,62,143,249, 229,251,80,94,184,11,166,61,143,225,141,180,183,59,183,232,170,243,169, 144,32,164,4,11,58,168,172,126,29,245,205,231,183,148,48,171,0,197,96, 173,98,203,26,162,110,63,82,74,80,169,41,243,192,212,33,165,169,158,143, 91,138,37,31,217,38,198,31,239,252,251,0,66,8,136,110,192,212,244,188, 48,237,55,106,86,254,117,70,224,125,248,230,239,234,124,66,116,222,254, 137,163,114,229,185,131,72,44,154,45,2,8,218,29,93,150,6,127,155,15,1, 56,247,81,171,60,135,102,253,60,138,229,219,176,124,252,129,221,19,193, 216,232,38,252,250,94,21,27,43,95,133,219,186,154,244,235,219,78,215,148, 82,192,235,84,176,122,241,11,168,110,60,139,249,165,151,97,126,249,62, 88,206,66,143,86,76,82,255,14,58,127,236,0,236,70,1,212,121,3,191,129, 181,203,95,66,187,113,49,26,161,182,245,211,201,177,71,61,159,84,173,202, 8,36,136,212,148,48,27,150,50,57,162,172,194,184,183,224,150,208,95,111, 130,207,254,34,38,30,77,55,117,211,190,95,183,114,247,113,171,243,19,155, 97,254,215,128,51,31,223,239,229,204,20,1,16,115,161,78,8,57,244,89,87, 156,249,168,85,190,133,102,253,28,138,229,219,112,228,196,107,81,42,223, 170,60,218,163,96,151,90,128,148,2,173,230,101,108,172,124,5,129,91,235, 214,15,164,5,110,27,59,87,74,1,223,173,98,237,242,147,168,109,62,143,249, 165,123,49,191,244,50,216,249,229,29,61,227,82,202,174,192,37,6,128,128, 215,94,195,218,229,39,209,105,173,98,80,203,50,217,163,254,239,128,62, 111,36,81,39,142,186,9,73,16,170,52,2,77,55,33,117,51,149,94,172,70,186, 199,222,127,205,48,135,198,248,247,19,68,211,160,83,71,3,33,55,241,208, 93,60,136,53,204,22,1,104,129,39,133,213,217,75,69,224,126,34,38,130,86, 227,2,202,243,119,97,249,248,3,40,20,111,26,157,8,210,144,219,239,226, 66,48,212,55,191,141,205,181,167,17,6,195,106,166,82,71,216,230,246,73, 41,224,123,85,172,93,126,2,213,141,103,49,183,116,15,22,143,222,15,39, 127,4,132,104,219,108,202,170,26,82,2,16,66,160,85,191,136,181,203,79, 34,240,106,221,115,15,186,8,41,1,74,83,10,64,95,126,65,122,189,67,21,16, 153,56,4,17,17,1,213,12,64,51,64,99,141,64,202,200,127,112,8,122,65,16, 229,55,225,60,4,243,90,97,224,54,206,31,196,50,102,138,0,90,43,151,253, 185,91,238,104,29,50,23,192,142,96,161,139,202,218,83,168,87,207,162,60, 127,231,104,68,48,134,22,192,66,55,178,175,191,29,117,228,25,134,193,14, 182,45,167,73,204,109,137,192,175,99,253,202,151,81,223,252,54,230,150, 238,197,194,145,251,145,43,28,1,73,133,62,227,214,228,234,127,64,10,134, 122,229,219,216,88,57,51,132,140,182,212,39,110,187,190,94,178,31,226, 43,72,158,147,170,182,128,73,21,215,143,236,124,98,88,208,116,67,85,29, 178,184,21,251,1,57,225,19,225,15,192,61,23,220,247,90,34,240,174,28,196, 82,102,138,0,196,194,156,11,109,58,5,65,251,1,22,118,198,39,130,29,224, 123,85,172,95,253,50,218,141,75,209,184,173,97,80,205,52,72,207,238,186, 3,195,164,132,42,240,27,88,187,242,37,212,42,223,66,121,225,110,44,29, 123,53,242,197,227,93,34,136,118,96,206,61,108,174,62,133,202,234,211, 16,188,47,247,101,224,238,31,157,42,246,212,79,204,27,175,124,18,130,135, 32,82,64,51,44,80,211,130,6,64,112,14,30,6,169,217,132,251,72,4,177,240, 179,0,220,119,99,95,69,149,80,99,109,255,22,209,197,76,17,64,81,155,103, 16,242,80,37,82,236,6,147,32,2,21,223,191,140,245,43,95,130,219,169,108, 181,175,187,239,76,126,68,229,0,125,216,73,29,232,69,24,180,176,177,242, 53,52,170,103,81,94,188,7,139,199,94,133,66,233,70,144,232,181,181,75, 95,84,154,72,79,243,146,109,36,127,91,244,239,246,59,199,37,201,128,199, 82,40,34,96,190,7,170,233,208,52,13,212,206,65,10,171,219,37,56,158,93, 48,77,12,16,126,64,2,130,173,118,216,250,129,108,108,51,69,0,103,221,167, 248,221,198,125,27,186,157,27,152,52,50,107,216,145,8,122,204,128,238, 151,83,217,251,207,99,253,234,25,176,176,5,108,103,95,79,3,68,70,68,240, 85,212,54,159,195,220,194,157,40,206,221,142,171,231,62,131,250,230,183, 183,78,10,74,214,182,205,2,147,220,254,45,190,190,81,23,133,237,9,66,77, 68,230,34,128,224,81,151,96,213,19,16,154,161,230,4,240,48,80,131,85,166, 65,4,132,0,82,130,135,1,120,224,37,221,157,164,148,224,92,188,84,15,195, 206,228,79,186,51,102,138,0,240,221,223,45,200,215,55,235,7,189,140,73, 99,43,17,156,68,161,116,83,79,41,106,12,206,60,108,172,126,29,213,245, 103,212,60,128,161,216,90,15,176,43,202,220,246,67,50,90,251,211,168,172, 62,13,175,81,193,40,157,138,123,185,32,177,1,118,179,58,108,77,30,26,166, 26,116,29,127,138,8,4,4,231,32,26,133,166,25,208,77,27,154,97,130,179, 0,34,12,163,177,232,19,42,232,35,4,82,74,136,48,218,249,211,4,41,37,8, 228,121,60,243,204,129,52,23,57,4,238,208,49,240,216,99,66,211,181,250, 65,20,4,237,7,98,34,56,251,204,31,227,194,217,191,66,43,142,155,71,8,188, 26,174,94,252,60,54,215,158,30,154,220,211,131,45,183,105,39,207,226,246, 175,109,247,170,24,180,115,14,243,245,109,119,244,36,157,183,119,77,3, 207,62,196,103,56,170,234,32,165,128,96,12,44,240,162,97,170,18,186,97, 195,116,10,48,236,220,238,10,131,182,44,69,9,63,15,253,173,194,15,64,72, 193,120,24,92,192,1,121,36,103,75,3,0,16,186,237,10,53,28,78,14,184,30, 96,154,96,97,27,235,87,207,160,86,121,14,243,75,247,224,200,177,87,163, 213,88,193,149,11,159,70,187,121,181,119,103,26,242,181,25,252,244,168, 78,191,93,37,33,12,62,235,182,95,235,116,88,114,180,115,146,109,126,27, 250,78,130,109,77,70,41,37,36,83,249,2,202,52,208,160,25,22,52,221,132, 224,202,52,16,124,220,33,174,138,196,164,148,224,129,15,30,184,170,185, 99,63,184,240,65,228,249,49,14,60,81,204,28,1,8,193,26,145,158,121,205, 18,128,130,68,24,52,177,118,229,12,170,27,207,34,108,183,208,105,175,98, 76,137,239,69,74,8,198,159,13,184,61,100,82,241,183,245,149,161,191,15, 92,115,111,132,98,248,42,199,89,63,25,141,96,164,76,26,147,18,202,160, 69,33,68,170,27,16,156,69,145,131,81,66,136,145,240,11,9,30,122,224,129, 55,88,248,1,8,41,154,60,240,175,142,113,49,19,197,204,17,128,233,20,55, 160,230,250,30,138,130,160,233,67,34,12,218,8,195,189,53,68,78,180,243, 65,110,242,157,48,146,240,96,7,95,228,246,196,181,107,167,238,8,245,3, 81,246,255,232,199,140,10,140,152,16,32,140,64,139,210,134,169,166,119, 67,136,60,72,101,62,246,157,147,68,126,134,208,223,86,248,213,169,248, 38,215,205,202,208,55,76,25,51,71,0,96,94,11,134,29,96,214,178,129,14, 28,99,164,220,238,234,240,67,76,128,29,223,187,115,37,224,128,204,160, 225,199,222,66,112,35,238,254,131,16,85,54,178,192,79,146,138,122,67,136, 1,56,11,82,33,68,117,46,41,56,120,224,169,9,78,219,153,13,82,2,156,175, 80,63,60,176,220,150,153,35,128,160,213,110,217,118,233,80,118,87,57,124, 24,213,175,52,36,187,110,220,115,13,116,58,14,125,119,239,239,50,234,244, 211,191,174,45,152,108,186,208,168,24,28,66,116,162,200,65,168,136,32, 234,79,192,131,72,237,223,193,89,45,33,33,56,63,191,254,12,188,125,186, 140,45,152,173,40,0,0,228,203,13,204,64,65,208,190,98,170,254,227,17,50, 110,128,145,52,128,97,30,2,41,56,66,183,165,226,227,209,110,58,80,9,24, 38,245,59,177,1,217,131,22,208,7,41,4,56,11,193,124,95,69,14,8,129,110, 218,48,172,28,64,200,200,194,31,29,75,18,41,46,0,167,179,126,0,35,131, 74,31,66,122,179,82,16,116,152,64,8,221,185,236,126,220,99,70,63,7,59, 0,251,177,245,61,148,82,112,65,193,220,58,68,232,67,179,28,232,118,30, 154,97,131,234,145,212,167,163,19,187,88,252,52,146,198,164,20,144,76, 64,114,174,76,3,93,7,4,7,15,70,31,220,42,165,96,140,251,231,113,96,69, 9,51,168,1,116,106,23,93,193,249,204,214,3,28,28,246,193,7,48,14,7,72, 68,85,123,70,210,196,83,10,14,230,181,17,52,171,8,218,53,48,223,141,18, 114,70,147,143,225,254,205,233,109,20,82,74,8,30,34,244,35,155,127,140, 228,33,41,132,11,78,46,76,109,113,35,96,230,52,128,32,164,62,40,153,249, 122,128,125,135,68,74,99,218,205,54,186,195,225,101,127,24,80,166,100, 125,192,206,175,105,81,118,94,212,198,43,53,249,39,38,2,17,6,208,44,27, 186,149,135,102,218,221,190,125,3,215,178,77,26,240,148,71,193,75,0,136, 26,149,142,247,65,217,160,156,175,76,99,77,163,98,230,8,160,112,215,124, 136,14,174,233,145,205,123,195,160,100,156,72,200,162,58,121,244,215,195, 15,43,184,153,210,206,73,52,61,42,33,238,77,4,234,159,249,39,5,3,115,219, 224,129,7,205,84,166,129,110,57,125,13,60,211,102,194,193,152,132,4,4, 34,110,136,50,6,132,96,27,156,120,213,41,45,107,36,204,156,9,112,225,27, 223,224,210,247,215,247,50,45,247,250,68,188,211,170,112,22,209,245,129, 105,174,227,235,8,4,61,195,64,82,231,26,244,94,162,233,160,84,83,143,83, 163,202,182,140,0,75,21,65,73,22,34,236,52,224,215,215,225,213,55,16,186, 45,213,247,96,224,119,128,108,249,117,63,10,199,146,185,136,163,127,0, 224,252,10,53,130,3,213,102,103,78,3,192,237,183,11,201,104,235,90,168, 6,220,119,164,181,100,66,85,103,28,178,247,226,55,9,12,110,63,214,115, 110,146,8,126,119,106,86,215,133,24,199,208,183,252,93,83,3,69,84,98,141, 15,230,54,161,219,5,24,249,18,116,43,15,106,24,170,83,81,247,100,189,143, 167,254,93,145,42,222,47,70,191,145,202,119,192,46,92,61,115,187,15,156, 153,226,218,182,199,204,105,0,120,252,113,174,155,118,133,16,21,143,189, 190,137,96,12,201,149,24,176,227,19,16,162,98,218,106,20,215,104,95,135, 129,22,67,122,32,72,255,251,99,173,35,34,156,100,247,71,223,8,239,190, 191,101,122,180,120,119,182,128,0,15,60,248,141,13,184,149,43,240,170, 171,8,219,13,136,208,239,219,129,119,153,5,184,75,196,237,208,198,120, 191,16,144,231,15,178,37,56,48,139,26,0,0,230,119,170,154,110,9,66,53, 170,152,95,142,253,7,184,110,208,179,49,111,85,143,227,7,132,18,80,66, 83,66,55,2,122,14,55,164,252,40,210,52,20,55,168,248,190,36,232,41,76, 84,19,126,182,10,63,250,132,63,221,189,71,51,149,47,128,121,109,176,192, 133,110,231,96,228,74,208,237,28,168,110,69,125,255,246,97,247,143,175, 65,136,209,239,27,0,193,57,19,190,119,126,58,139,26,29,51,73,0,156,133, 13,169,226,45,20,64,100,75,106,232,153,78,155,97,48,118,144,7,66,41,40, 33,145,89,47,123,179,243,210,241,248,116,102,78,63,105,200,238,177,98, 130,38,241,176,16,2,16,217,117,218,13,18,154,244,36,161,184,205,120,87, 248,137,106,226,97,217,74,163,49,212,238,203,125,15,60,240,161,91,14,140, 92,17,186,157,143,134,124,78,191,102,76,70,237,208,198,248,0,88,208,105, 133,237,246,75,211,91,213,104,152,73,2,208,173,194,58,81,5,65,61,235,143, 19,93,174,79,34,216,233,90,199,72,11,70,52,40,147,244,170,225,221,215, 119,62,62,161,26,8,213,34,97,78,125,180,167,37,65,218,129,136,40,155,120, 7,225,119,242,208,140,104,135,39,52,50,35,116,80,221,236,22,224,212,60, 104,86,11,70,174,8,51,63,7,205,156,254,164,166,145,123,11,70,189,1,100, 24,54,52,240,245,169,47,108,7,204,36,1,72,230,183,164,116,2,0,3,39,110, 40,34,136,70,84,77,170,171,203,53,131,113,84,98,146,210,8,98,65,28,244, 190,148,16,131,168,24,63,165,93,149,63,58,45,145,128,220,146,139,16,11, 252,0,225,23,41,225,167,20,134,157,87,35,196,41,77,69,11,104,18,62,36, 154,14,106,24,144,92,64,176,16,126,109,3,82,8,232,118,14,100,64,119,165, 73,65,74,49,154,6,32,69,210,118,76,114,182,230,117,218,181,169,45,106, 68,204,158,19,16,64,216,110,180,228,150,150,179,253,80,33,38,229,40,156, 201,203,156,56,246,226,48,37,84,83,101,177,250,128,60,130,88,65,32,80, 225,197,254,225,205,169,170,188,248,191,238,103,251,38,10,197,26,135,136, 194,106,82,128,80,10,195,41,244,9,127,164,1,164,66,135,177,41,72,13,3, 186,157,131,102,57,42,169,200,109,119,59,0,79,24,36,214,98,118,200,1,144, 137,240,171,217,5,66,178,203,71,115,236,192,19,218,102,82,3,48,11,165, 6,161,163,22,4,117,191,28,93,211,224,58,5,73,139,222,110,200,128,68,118, 61,212,142,45,226,65,32,50,202,236,141,18,116,6,238,252,82,121,255,8,162, 15,171,159,106,247,20,41,225,239,14,24,133,20,32,154,1,221,201,131,106, 70,116,110,181,235,119,163,6,36,33,129,222,199,0,49,52,101,26,64,66,176, 0,132,51,149,132,164,13,206,129,216,45,118,114,0,74,41,32,34,225,143,158, 0,24,63,127,246,236,217,3,233,3,152,198,76,18,64,96,132,158,46,225,247, 25,148,59,128,224,186,138,24,140,125,121,3,238,35,25,246,154,138,26,40, 7,155,18,86,170,235,201,244,157,158,207,71,41,200,177,252,247,216,201, 201,56,49,245,191,76,107,0,82,130,232,134,218,249,163,16,229,182,194,159, 206,36,4,186,36,144,10,47,170,2,158,0,224,161,10,75,106,198,4,136,64,38, 154,202,192,87,251,133,31,128,20,156,11,193,207,161,155,16,113,96,152, 73,221,184,115,181,234,10,22,236,170,32,136,68,9,41,138,12,174,135,28, 130,52,19,144,30,231,253,72,216,142,23,0,53,166,91,211,183,190,177,159, 60,210,230,135,202,28,138,8,128,119,53,51,217,21,38,106,24,48,156,98,164, 85,208,68,229,239,218,254,195,132,191,47,244,71,232,214,181,73,9,193,66, 240,192,133,96,254,216,41,188,61,135,66,172,1,12,120,109,128,240,3,128, 16,50,144,66,190,184,235,147,78,16,51,169,1,20,10,166,79,40,109,141,165, 0,244,161,27,58,148,0,174,109,211,96,72,126,206,246,24,231,190,166,238, 93,162,250,71,150,190,236,110,253,201,106,186,222,253,136,0,68,87,248, 165,4,52,211,86,241,124,170,167,236,253,33,2,191,69,248,123,47,98,219, 29,62,34,2,16,6,74,35,211,96,156,176,97,124,46,193,209,127,131,135,9,127, 244,254,22,194,224,192,250,0,166,49,147,26,64,120,244,206,128,16,218,158, 132,200,170,44,53,83,125,1,174,217,172,194,81,194,120,219,96,216,71,98, 213,58,245,111,250,121,37,143,177,240,71,255,203,180,176,139,148,6,160, 34,12,186,101,43,111,255,184,194,63,164,74,144,208,17,146,129,162,146, 94,30,122,42,163,112,204,152,126,127,111,192,109,133,31,128,144,162,198, 37,54,70,63,201,244,48,147,4,112,193,186,202,89,224,87,38,101,199,19,18, 207,108,55,163,97,28,215,34,17,144,209,167,226,142,123,249,61,29,71,123, 12,132,110,41,112,164,246,171,221,95,36,158,115,201,121,98,63,199,205, 64,8,213,82,106,255,136,194,63,236,50,122,28,159,59,95,71,76,4,60,244, 70,12,237,245,134,154,165,224,16,193,118,36,34,1,193,175,18,170,213,70, 93,214,52,49,147,38,0,170,85,33,97,77,188,41,8,137,98,201,132,82,245,135, 60,200,9,178,105,36,58,252,120,107,145,67,127,35,3,31,14,198,208,237,191, 247,216,41,14,72,226,253,105,193,232,11,243,201,148,9,0,64,213,252,199, 217,125,125,225,189,174,192,71,181,4,35,8,63,162,142,81,100,55,123,156, 148,144,156,129,11,14,66,181,36,2,49,232,94,164,175,65,10,174,118,254, 109,194,141,82,153,29,151,54,203,252,80,180,181,155,73,13,0,143,63,206, 117,221,172,140,148,121,181,35,36,250,143,163,204,2,3,154,222,95,101,118, 109,130,108,249,101,116,21,96,107,170,240,32,47,227,214,68,31,164,202, 103,141,92,9,154,229,116,179,251,40,1,104,55,209,39,173,13,140,44,252, 73,62,242,8,38,192,48,196,68,16,168,52,99,41,24,210,68,170,114,0,162,8, 198,8,194,175,14,41,1,136,243,56,115,102,187,81,206,251,134,217,212,0, 0,240,32,168,105,166,35,8,180,169,145,24,33,20,154,78,33,5,133,136,108, 213,217,192,128,252,250,189,30,114,152,172,245,228,243,247,58,251,18,181, 63,237,245,79,253,15,33,160,217,121,213,224,35,206,7,0,182,170,250,41, 7,95,247,241,246,194,47,165,28,205,254,31,9,18,82,48,240,32,210,8,244, 174,179,48,30,47,54,138,240,3,128,228,130,113,30,158,195,161,80,45,103, 152,0,88,232,213,12,89,74,10,130,246,130,157,130,9,132,106,208,40,133, 16,93,167,213,108,64,246,61,158,148,111,99,107,88,173,71,240,83,137,62, 241,235,178,231,185,174,3,144,68,37,221,68,139,178,186,19,199,160,236, 19,126,18,201,242,14,194,159,62,215,160,254,2,123,66,154,8,168,154,24, 196,66,149,219,63,234,119,66,114,159,114,121,97,130,139,218,19,102,150, 0,52,51,183,65,64,182,20,4,77,15,81,67,11,66,33,36,239,126,73,103,1,81, 74,94,143,44,12,148,139,221,8,203,86,223,68,28,21,80,242,222,245,254,39, 225,63,17,57,0,1,37,240,209,168,108,162,25,160,154,169,62,45,56,164,84, 247,152,36,225,189,81,133,63,10,68,238,69,253,223,22,50,234,255,47,192, 252,206,88,81,3,193,121,51,12,216,129,246,1,76,99,118,9,0,164,37,164,100, 116,72,65,208,212,64,8,40,209,33,137,166,236,62,201,147,47,220,97,192, 176,149,36,59,233,128,172,190,225,24,150,220,211,119,78,153,222,253,129, 184,184,7,113,9,112,252,79,42,197,183,55,115,32,58,6,103,106,227,214,116, 80,195,66,44,104,59,146,109,191,240,199,254,134,137,107,0,105,40,115,71, 69,49,70,255,148,148,124,147,26,226,192,70,129,245,99,102,9,32,207,27, 13,205,204,187,1,144,31,163,19,211,16,140,175,30,39,17,3,169,65,10,118, 120,34,6,3,64,40,77,133,0,135,68,3,70,63,218,214,71,137,192,119,15,47, 83,100,144,168,228,233,210,223,248,205,164,247,88,82,114,85,232,13,169, 178,12,13,43,210,26,212,244,222,45,131,57,183,8,127,247,124,100,80,22, 224,4,33,227,28,128,81,255,238,74,251,185,172,215,120,125,106,139,26,19, 51,75,0,247,221,60,215,42,46,20,253,138,175,225,98,213,71,219,231,7,34, 126,138,8,12,16,42,148,163,112,220,214,208,211,6,161,145,167,158,164,165, 44,10,147,245,221,177,93,90,0,50,37,249,178,135,5,186,172,32,35,199,92, 127,139,112,146,214,74,146,40,66,156,92,163,188,238,68,211,85,151,31,77, 153,11,130,179,238,60,190,129,194,31,71,0,232,52,229,95,173,83,142,254, 247,86,69,73,225,197,181,213,167,14,205,104,187,153,37,128,188,229,184, 142,161,249,119,150,114,56,94,182,112,97,211,195,229,170,15,143,29,140, 131,142,16,10,77,163,144,68,131,16,108,58,142,194,49,25,142,80,45,9,101, 13,53,83,34,103,219,150,207,142,118,134,228,24,177,248,39,63,228,214,93, 58,249,117,228,179,164,136,64,211,162,142,194,58,136,198,33,88,208,45, 241,29,64,4,32,100,104,236,126,34,32,0,184,220,177,12,184,231,106,132, 144,144,252,2,34,29,231,48,96,54,243,0,0,92,93,189,224,178,48,168,19,2, 20,109,29,247,29,207,227,53,183,150,112,195,156,5,67,59,184,76,190,216, 59,76,181,131,76,45,142,203,118,71,251,243,110,55,214,139,108,243,155, 250,53,22,110,185,69,240,123,4,114,235,73,135,30,118,224,10,5,135,96,33, 164,84,163,184,116,43,7,221,202,129,234,38,64,186,61,7,19,63,3,34,237, 108,167,67,239,1,227,150,151,75,41,24,23,236,5,28,34,91,113,102,53,128, 64,136,16,232,246,4,160,132,96,49,111,160,236,232,88,111,6,56,183,225, 162,210,102,16,163,252,129,38,25,33,139,64,162,70,36,50,29,214,218,7,16, 144,168,97,71,223,160,138,36,47,127,24,98,65,29,156,83,159,62,206,150, 79,198,62,128,126,51,32,37,140,137,205,159,220,134,94,31,192,224,147,108, 77,40,82,149,119,12,148,106,106,126,160,97,38,3,57,5,11,85,178,78,218, 4,152,34,182,43,3,30,4,17,50,151,132,252,226,20,151,52,54,102,150,0,150, 238,186,203,213,169,214,232,239,40,171,83,130,227,101,11,11,121,3,87,235, 62,206,87,60,52,60,118,48,142,250,168,226,144,16,10,41,196,244,35,6,177, 218,219,35,120,177,204,245,135,196,134,61,238,170,208,35,33,181,195,167, 101,91,14,122,62,253,153,45,231,222,249,124,93,2,139,162,3,144,32,84,139, 134,137,90,96,126,7,220,119,85,133,95,92,9,56,45,45,76,98,104,25,240,32, 8,30,34,116,27,13,63,244,86,167,179,160,221,97,102,77,128,206,51,207,8, 223,31,62,86,201,210,41,110,93,116,240,186,91,75,184,251,104,30,57,83, 59,184,18,31,66,64,52,13,154,102,164,134,99,76,24,148,70,243,246,70,56, 246,8,111,73,183,229,222,238,67,93,167,91,58,4,40,183,74,253,64,65,233, 173,73,32,125,191,15,140,90,166,95,143,203,137,185,74,40,50,243,101,152, 165,197,110,71,224,169,134,0,49,176,12,120,16,4,103,96,94,7,130,133,235, 130,146,161,223,217,131,192,204,18,192,218,218,154,8,57,107,236,68,193, 57,83,195,61,71,114,120,221,173,37,220,178,104,195,210,7,93,242,62,169, 231,81,213,161,166,235,19,37,2,21,230,219,233,120,187,187,198,116,26,239, 176,195,246,132,252,122,72,99,66,216,177,62,33,50,13,132,128,166,27,176, 74,75,48,114,197,109,125,27,123,199,214,50,224,65,16,156,129,249,29,229, 24,134,184,50,31,228,154,83,92,212,216,152,89,2,56,125,250,52,183,44,103, 164,25,129,132,0,101,71,199,253,39,10,56,121,75,9,199,202,22,116,186,255, 250,64,44,26,241,164,28,109,2,189,233,226,246,219,59,158,121,207,178,48, 100,103,79,59,250,6,254,45,134,169,2,114,80,70,65,234,215,29,211,22,183, 190,34,99,31,1,7,64,32,2,79,101,234,241,201,59,221,71,233,56,29,11,127, 18,178,20,242,165,75,151,158,8,38,190,152,61,96,102,125,0,0,36,243,189, 134,200,231,133,54,34,145,81,74,176,92,48,48,231,232,88,139,28,133,213, 14,131,192,148,195,197,125,136,125,142,132,82,104,169,210,227,113,67,135, 132,234,80,61,56,211,33,183,190,159,61,143,71,185,202,17,66,115,232,170, 235,73,124,127,92,223,198,48,203,98,152,218,190,211,178,122,220,24,18, 136,210,136,101,24,64,50,6,162,235,208,116,107,107,199,226,221,34,85,6, 60,8,61,194,15,64,10,33,36,151,231,112,136,66,128,192,108,19,0,90,157, 86,181,56,191,48,118,65,144,161,17,220,48,103,97,49,111,224,74,228,40, 236,108,19,42,159,6,210,129,135,173,197,70,59,44,36,29,227,30,145,52,210, 115,249,118,8,238,141,134,120,199,23,178,111,13,93,6,218,222,249,7,36, 109,188,182,197,54,175,111,243,82,250,236,82,138,201,18,1,1,176,77,4,160, 95,248,163,53,132,68,30,142,62,128,105,204,52,1,20,10,197,141,72,223,219, 213,117,216,6,197,109,75,14,142,20,77,188,180,233,225,114,35,132,23,238, 31,11,244,70,31,211,197,70,195,137,32,61,82,123,172,24,116,116,142,238, 191,59,97,180,119,73,57,130,165,221,191,206,97,235,30,145,11,70,90,217, 128,115,76,146,8,148,207,97,235,57,6,9,63,0,72,46,218,16,236,242,174,78, 54,69,204,52,1,64,162,37,199,201,197,28,0,2,160,96,105,184,123,217,198, 209,162,142,151,170,33,86,91,12,33,223,31,34,216,146,130,64,8,40,209,32, 73,100,26,164,70,78,117,51,219,182,113,202,13,61,209,78,239,31,125,39, 238,125,231,104,107,233,167,137,196,12,66,207,63,35,174,101,167,147,109, 239,243,216,51,17,200,40,7,160,239,36,195,132,63,58,103,141,75,172,141, 126,146,253,193,76,19,64,165,90,105,56,249,130,11,32,183,215,99,17,2,204, 217,26,138,71,53,28,47,50,92,168,133,168,116,56,248,222,43,141,118,196, 160,60,164,110,177,145,132,36,81,221,188,166,71,19,115,182,95,211,176, 87,7,58,211,119,43,107,233,186,130,1,194,61,20,61,47,14,207,1,136,117, 149,169,103,242,237,146,8,250,135,129,108,39,252,138,144,196,154,20,188, 54,161,165,79,12,51,77,0,182,105,181,40,33,19,41,172,136,246,85,104,20, 88,46,232,152,115,52,172,182,24,94,170,133,104,120,28,227,240,0,1,25,100, 1,111,139,65,36,0,68,17,3,93,139,122,239,239,22,187,32,177,81,204,115, 196,249,2,219,156,101,64,212,160,63,61,40,173,91,236,120,202,158,178,230, 193,139,236,206,42,26,13,227,17,65,92,172,212,21,244,109,133,31,241,61, 18,87,142,216,65,123,226,141,44,247,136,153,38,128,82,174,208,1,129,63, 104,190,252,94,97,104,4,55,150,13,44,229,117,92,169,135,184,88,15,209, 9,196,110,68,105,100,12,35,129,254,247,140,119,196,20,118,115,139,70,200, 211,31,122,190,161,171,149,160,82,66,112,15,130,216,160,241,184,177,221, 32,173,214,116,19,5,119,229,209,77,19,1,213,13,80,99,200,120,241,216,4, 144,114,71,225,87,239,23,144,66,30,138,81,96,253,152,217,60,0,0,88,221, 168,186,97,24,78,53,177,194,214,9,110,91,52,113,242,70,7,183,46,152,176, 244,233,6,12,167,144,70,3,72,108,173,140,27,43,223,127,248,155,7,39,254, 12,80,9,82,9,67,58,5,22,29,130,57,226,194,8,154,144,190,27,117,5,74,127, 96,80,164,98,84,199,228,222,42,49,213,32,79,31,204,109,131,251,238,86, 135,30,68,210,168,100,148,142,64,82,8,46,184,120,1,135,96,20,88,63,102, 154,0,54,27,87,67,193,69,103,218,231,33,0,10,38,197,61,203,22,30,184,193, 193,137,146,14,99,202,137,68,147,36,1,57,233,3,2,72,132,113,148,40,64, 10,58,5,150,115,26,74,54,133,165,1,101,131,161,76,58,48,194,38,68,224, 66,240,97,233,181,59,145,87,234,201,9,197,115,135,18,129,84,19,133,70, 109,7,38,165,12,136,174,93,152,200,162,38,140,153,54,1,202,55,222,232, 74,130,138,224,28,154,62,253,75,161,4,152,119,52,148,44,27,27,29,142,243, 213,80,37,18,77,201,46,24,197,36,24,245,72,116,160,142,61,224,185,17,223, 214,61,116,28,5,232,15,245,109,121,0,131,18,28,201,105,200,27,0,11,185, 234,161,64,0,157,0,54,24,124,217,134,27,134,8,133,3,98,216,170,182,97, 172,160,229,116,72,57,38,2,193,66,80,195,132,20,2,204,107,67,240,209,58, 123,75,193,91,194,63,28,163,192,250,49,211,4,112,95,169,228,95,218,172, 254,22,243,253,66,190,80,124,208,114,28,139,142,58,253,166,31,42,165,110, 164,183,106,148,224,104,65,199,188,163,97,181,25,57,10,125,62,149,68,162, 241,72,96,192,2,36,144,55,117,28,41,89,8,52,19,245,128,128,203,157,142, 57,206,25,71,187,104,75,3,142,228,40,114,70,188,76,130,184,211,111,60, 193,55,71,0,7,33,124,201,209,14,2,48,205,1,49,172,161,14,208,161,171,156, 82,215,102,41,5,120,224,39,100,48,198,7,55,169,33,214,167,178,168,61,98, 166,9,224,177,199,30,19,0,254,230,61,239,249,224,87,221,229,242,63,41, 20,203,63,157,43,22,239,49,77,75,219,143,102,28,166,70,112,211,156,129, 165,188,134,75,117,134,203,245,16,110,56,93,71,225,184,40,218,20,71,115, 58,242,142,9,203,182,225,9,130,245,142,64,195,151,96,177,32,110,139,29, 94,223,169,217,7,148,240,31,203,107,112,244,222,148,97,210,67,0,106,26, 16,77,17,129,199,35,34,208,157,168,37,216,144,175,107,223,18,167,95,4, 52,70,218,168,148,144,146,175,18,146,175,79,113,81,187,198,76,251,0,34, 200,63,252,195,255,176,122,211,66,241,183,87,47,94,124,215,198,202,202, 255,86,175,213,174,134,97,40,199,217,146,247,66,23,142,65,113,231,162, 137,7,110,116,112,243,188,1,243,0,59,18,197,32,68,98,206,209,113,67,217, 132,101,196,194,5,20,45,13,183,47,90,184,115,201,194,66,78,235,27,171, 50,180,60,103,240,13,218,182,6,64,61,239,24,4,39,138,20,121,67,13,251, 80,227,217,169,10,224,37,130,79,19,45,32,30,8,170,81,130,130,1,44,155, 33,202,178,5,120,141,14,243,93,63,177,185,119,50,75,166,9,33,70,38,153, 168,107,208,161,25,5,214,143,131,255,166,78,24,15,63,252,176,53,127,243, 237,175,45,21,203,63,87,40,149,223,230,228,242,37,109,132,228,14,41,68, 212,217,119,111,16,18,168,251,2,231,107,33,214,154,1,216,158,51,10,213, 174,232,183,235,8,218,245,168,4,85,116,133,47,106,75,21,119,167,145,66, 130,64,96,193,161,56,154,163,32,16,224,156,195,52,76,88,142,13,77,211, 65,53,10,74,53,72,16,212,3,96,181,197,208,244,37,36,104,52,146,171,59, 155,175,103,78,95,162,182,171,231,1,32,104,215,192,188,78,178,142,36,81, 73,10,56,58,112,162,64,96,210,120,173,50,49,105,58,157,54,58,173,86,34, 248,189,4,128,164,141,57,33,4,82,202,115,13,63,120,108,221,51,108,195, 202,189,95,179,156,7,52,211,54,84,234,116,239,218,32,37,120,224,237,57, 18,48,28,18,97,187,137,208,107,141,246,110,206,192,58,173,95,175,156,253, 202,191,194,20,92,177,123,197,76,155,0,131,240,169,79,125,202,7,240,249, 135,223,251,222,167,150,59,75,111,43,149,74,63,151,47,149,95,103,89,182, 185,107,255,192,24,160,4,88,204,27,88,44,58,88,107,250,120,97,195,197, 230,168,173,201,70,194,246,199,209,40,176,156,51,176,156,167,32,82,32, 169,132,237,205,55,142,222,75,176,148,215,48,239,24,216,244,4,86,90,12, 237,190,90,136,97,59,68,92,133,152,238,252,147,70,209,36,56,154,39,176, 52,164,180,4,146,132,237,187,26,64,191,240,119,39,0,197,194,207,88,248, 11,79,159,88,254,36,30,127,92,44,220,255,208,39,237,48,248,39,186,29,190, 79,51,237,251,52,195,50,38,86,225,55,2,212,53,143,51,8,132,121,156,177, 231,112,8,133,31,184,6,53,128,62,144,247,188,231,3,199,115,75,243,239, 45,148,75,31,202,21,74,119,154,166,73,7,249,7,38,165,1,0,0,165,20,134, 169,38,220,120,76,224,114,213,199,185,138,139,166,191,187,214,100,74,3, 104,68,26,64,170,29,118,159,6,160,19,137,99,5,13,139,142,6,72,14,46,4, 4,231,224,156,193,52,45,88,118,172,1,104,160,84,105,1,84,163,160,68,205, 13,8,5,176,209,230,88,105,113,120,76,66,198,133,71,3,52,0,53,65,89,194, 111,85,193,125,55,89,15,145,2,5,19,56,94,32,48,72,186,84,88,166,60,154, 4,173,70,29,158,235,14,20,254,248,60,177,240,127,241,232,210,39,241,248, 227,105,169,163,199,190,227,205,55,233,86,238,221,212,180,63,160,155,249, 59,53,211,212,8,213,34,71,157,55,53,51,64,10,142,160,85,3,15,119,78,64, 21,97,24,114,191,243,251,126,147,255,74,107,229,107,135,210,9,120,173, 19,0,0,224,212,169,83,154,89,88,184,39,55,55,255,211,133,82,233,159,228, 114,249,35,186,97,244,92,251,180,8,0,80,223,251,182,207,241,210,166,135, 151,170,30,58,193,120,245,75,163,16,128,65,37,110,40,234,152,119,162,254, 131,34,38,0,6,206,57,12,211,132,109,59,9,1,104,148,130,36,68,160,236,112, 26,169,255,30,3,214,218,28,171,45,134,128,67,141,250,238,33,0,154,140, 80,247,155,213,148,192,73,204,89,192,177,60,129,158,18,254,30,45,33,34, 223,102,189,6,223,243,134,9,191,148,130,127,51,96,236,151,190,116,108, 249,111,251,132,63,133,83,218,137,251,55,238,36,185,220,143,234,118,225, 61,186,229,220,73,52,170,137,112,90,61,55,8,36,15,225,183,170,59,70,1, 4,11,25,247,59,31,215,66,255,87,214,206,125,227,80,245,1,76,227,186,32, 128,24,15,63,252,176,181,120,203,29,175,207,23,74,191,80,42,207,189,213, 113,114,5,170,197,83,94,101,148,132,178,119,244,19,64,12,41,129,154,27, 226,92,197,195,149,186,143,96,196,25,6,219,17,128,148,2,182,14,220,84, 50,80,180,8,32,5,4,31,68,0,86,68,0,90,66,0,84,211,84,27,243,132,0,40,104, 220,107,128,16,116,66,224,106,51,196,122,155,35,16,105,187,92,141,240, 150,92,40,13,32,240,64,34,225,63,158,39,208,250,133,63,190,248,148,230, 85,175,110,34,12,130,33,194,47,190,17,250,254,71,159,252,194,103,63,143, 145,84,231,135,244,99,223,97,220,101,56,185,15,16,205,60,69,8,185,137, 26,6,221,107,183,165,173,32,16,161,15,191,85,221,190,25,8,11,57,243,59, 159,148,220,251,153,234,11,223,60,84,93,128,251,113,93,17,64,140,119,188, 227,145,185,210,241,210,15,148,202,243,31,41,148,74,39,45,203,54,64,200, 212,9,32,6,23,18,27,237,16,47,172,119,176,222,10,119,172,56,220,142,0, 242,6,112,211,156,129,130,65,146,174,66,131,8,192,178,108,152,150,61,148, 0,98,51,32,214,2,8,37,160,132,66,130,160,25,8,92,110,48,84,58,28,76,196, 38,128,186,95,126,179,10,48,31,75,14,193,145,28,1,69,175,218,223,219,22, 188,251,117,171,109,86,16,134,97,215,7,0,236,82,248,83,56,121,210,88,246, 74,247,233,134,246,8,181,237,119,235,150,115,92,211,205,190,169,168,123, 3,15,60,4,237,90,111,203,245,20,98,225,231,94,248,11,245,151,158,58,55, 177,19,79,9,215,37,1,68,32,239,122,239,135,110,152,159,47,255,68,97,110, 238,253,185,124,225,86,141,210,129,254,129,177,15,76,41,12,195,216,177, 64,41,228,18,87,235,62,94,172,184,168,117,194,161,25,133,131,8,128,72, 137,130,69,113,203,156,14,91,39,137,9,211,67,0,60,69,0,246,238,8,32,182, 247,133,4,106,158,34,130,170,43,32,64,84,171,235,86,21,139,6,83,194,79, 122,85,254,88,248,123,68,159,168,181,214,54,43,96,140,165,157,126,82,10, 241,68,192,197,47,126,233,179,127,247,4,246,226,52,187,239,62,115,65,20, 30,176,236,194,251,53,39,255,3,186,229,28,163,154,49,17,34,96,94,27,65, 167,49,208,199,48,107,194,15,92,223,4,0,0,120,232,161,135,244,155,94,118, 255,203,109,39,255,225,124,190,240,195,78,62,183,164,235,198,158,142,57, 42,1,196,240,66,129,139,85,15,231,55,93,180,6,100,20,246,19,0,129,196, 188,173,225,166,57,29,22,5,68,212,12,115,60,2,80,14,192,225,4,16,155,3, 221,176,32,33,20,92,2,149,14,199,229,38,67,163,237,163,204,107,88,48,153, 42,128,238,17,126,32,157,146,147,38,0,33,4,106,149,13,112,206,19,225,23, 66,252,189,207,253,143,156,249,236,103,191,129,73,121,204,111,185,197, 62,226,220,240,29,90,206,249,176,110,231,190,79,51,115,11,84,211,247,68, 4,97,167,137,208,109,109,89,162,228,76,50,223,253,59,230,250,143,206,138, 240,3,25,1,36,56,117,234,148,99,22,151,222,148,43,149,126,190,88,42,189, 217,206,229,28,186,99,183,221,193,24,151,0,0,245,117,106,121,12,231,55, 61,92,172,122,240,194,174,138,153,38,0,34,57,150,242,58,110,42,233,208, 105,228,188,220,66,0,170,201,232,100,8,160,155,164,147,16,1,37,96,130, 160,218,234,32,168,175,131,135,65,210,23,32,25,0,26,23,9,165,24,32,82, 243,33,56,71,181,178,1,33,56,166,38,252,41,28,63,126,50,23,204,155,15, 26,118,225,67,186,157,123,88,183,236,121,74,117,140,77,4,82,34,232,52, 192,188,118,239,211,156,75,230,119,254,94,132,222,71,170,47,62,253,244, 4,151,62,117,100,4,208,135,119,190,243,199,23,157,35,165,119,205,149,231, 126,58,87,40,189,202,182,109,125,92,179,96,55,4,16,67,72,160,214,9,241, 226,134,139,171,13,31,33,151,9,1,240,78,29,199,10,26,78,148,116,104,144, 93,193,79,19,64,20,1,80,4,192,163,48,32,135,101,59,48,45,11,154,30,11, 127,42,2,176,11,2,160,148,194,115,93,84,214,86,17,134,97,36,240,189,9, 63,253,213,189,36,98,1,198,88,172,1,112,72,249,25,143,251,255,116,90,194, 159,198,209,87,190,50,207,121,254,205,186,85,248,73,195,206,61,164,89, 78,57,73,38,26,1,82,10,21,2,12,188,238,115,189,194,63,245,107,152,52,50, 2,24,12,250,142,71,30,185,185,148,155,251,137,114,121,238,39,114,249,194, 205,134,105,146,81,5,122,47,4,16,131,9,137,245,102,128,23,43,42,145,40, 104,55,112,68,239,224,104,65,83,142,182,180,224,79,130,0,82,145,128,36, 93,119,16,1,80,146,16,131,215,233,96,99,125,21,156,177,148,250,31,41,254, 3,182,255,132,0,194,16,155,27,235,92,48,254,201,144,123,191,240,228,231, 62,183,175,42,243,252,237,39,203,134,109,61,164,57,133,159,214,237,220, 67,186,105,231,200,8,149,135,146,243,40,4,168,194,140,82,112,201,188,217, 21,126,32,35,128,109,241,208,67,15,233,71,111,187,251,59,138,165,185,143, 20,74,165,119,56,185,252,188,62,66,217,49,33,4,134,57,153,209,84,1,151, 88,169,251,104,55,106,48,195,6,16,117,11,222,137,0,226,36,32,193,213,99, 219,118,96,154,38,232,164,8,128,80,184,157,54,42,235,107,224,156,109,17, 254,216,250,79,202,116,83,4,224,185,46,175,86,54,62,25,134,238,190,11, 127,26,165,251,30,92,176,53,235,109,154,101,127,200,176,115,15,106,134, 157,35,218,176,145,226,4,130,5,8,90,85,8,206,148,240,251,238,211,240,131, 15,85,206,125,237,203,152,65,225,7,50,2,24,9,223,255,232,163,185,146,48, 222,82,44,149,126,54,95,44,190,201,118,114,206,118,105,197,147,36,0,64, 57,156,235,213,77,84,55,55,32,248,246,4,16,207,22,232,102,1,42,109,192, 182,29,152,150,169,38,18,69,17,128,241,8,128,70,14,193,46,1,116,218,45, 108,110,172,131,115,158,152,0,105,225,79,238,71,215,1,128,48,240,195,122, 173,250,159,59,237,250,47,29,164,240,167,64,138,47,123,237,66,206,176, 127,128,90,249,71,117,219,249,14,221,180,237,173,173,192,8,120,232,33, 104,213,32,88,32,153,239,126,131,251,238,71,107,231,158,30,63,92,121,136, 144,17,192,24,248,254,31,125,116,105,174,104,157,42,150,75,31,206,23,74, 247,89,182,61,176,236,248,80,18,128,19,105,0,154,14,45,42,6,234,18,128, 6,26,135,253,232,214,16,96,76,0,148,166,114,247,41,69,187,217,76,156,121, 61,26,192,214,59,2,66,128,192,247,195,102,163,246,251,245,102,237,95,158, 249,220,231,14,91,131,12,178,244,178,147,199,168,145,255,1,221,206,125, 64,183,115,15,104,134,101,164,137,128,249,46,130,230,166,12,189,246,53, 33,252,192,181,81,14,188,111,248,203,63,248,221,141,59,142,47,252,206, 198,213,11,63,180,190,122,245,127,169,215,170,151,194,32,144,99,143,197, 218,21,182,59,199,246,231,151,178,219,194,122,0,93,13,255,224,142,173, 0,182,120,249,162,164,158,110,233,111,28,231,247,61,47,172,215,106,191, 191,86,105,255,234,33,20,126,0,144,27,223,58,115,117,237,233,207,254,158, 87,221,252,17,175,190,249,207,253,102,237,235,204,119,195,56,233,71,114, 134,208,119,159,231,158,251,51,215,130,240,3,153,6,176,107,156,124,244, 81,227,174,16,15,228,139,165,159,45,148,202,223,159,203,23,202,113,217, 241,52,52,128,90,181,130,218,102,101,136,6,160,202,128,7,105,0,140,49, 184,157,214,166,166,25,245,98,185,124,179,109,59,154,154,78,76,147,130, 160,216,251,63,40,18,144,182,255,187,26,128,122,190,217,168,161,86,221, 140,38,228,200,100,173,253,8,124,215,171,85,107,31,175,212,214,255,229, 55,190,248,197,67,155,23,223,7,58,119,239,235,111,178,76,235,221,186,157, 255,128,145,43,220,17,180,26,23,253,234,202,207,87,206,126,245,147,56, 132,13,62,119,131,140,0,246,136,31,252,193,31,44,22,150,111,248,222,98, 121,254,231,242,197,194,131,182,147,179,52,77,83,81,128,9,149,31,239,150, 0,120,24,162,221,110,157,111,214,170,191,70,168,252,106,161,180,240,99, 249,66,241,199,114,249,194,141,166,101,17,77,211,18,83,32,14,237,165,139, 130,210,4,64,251,157,129,132,160,81,175,162,81,171,70,17,128,158,21,67, 125,181,36,60,207,115,27,213,205,223,246,234,149,255,249,137,39,158,216, 156,200,13,217,95,104,139,247,191,225,78,187,176,248,78,30,122,79,173, 124,249,191,254,23,28,178,1,159,123,65,70,0,147,1,249,129,247,124,240, 72,121,174,240,238,98,177,248,225,66,169,116,87,190,80,212,70,105,68,50, 10,198,35,0,101,243,179,48,148,237,86,243,133,122,173,250,207,190,252, 247,159,253,43,0,252,228,201,147,70,126,110,249,213,78,177,248,83,133, 66,241,157,185,124,126,81,55,77,104,41,45,32,237,8,220,142,0,64,128,70, 173,138,102,189,222,211,26,60,174,249,145,82,194,117,93,183,89,175,254, 86,115,221,255,245,51,103,254,246,80,182,196,26,3,20,152,78,215,246,131, 68,70,0,19,196,169,83,167,52,174,231,238,42,45,44,62,186,176,180,252,158, 66,169,120,76,215,141,145,243,7,134,97,92,2,96,97,40,91,141,198,211,181, 122,237,231,190,252,249,207,124,30,125,59,214,131,15,62,232,20,151,142, 189,201,206,229,62,154,47,148,222,226,228,114,5,221,48,182,68,2,182,115, 0,2,202,49,217,108,108,205,139,151,82,194,235,180,219,245,90,245,183,91, 149,224,55,174,1,225,191,102,145,17,192,20,240,240,195,15,91,203,55,223, 253,218,226,220,220,207,21,75,229,135,157,124,174,184,23,109,96,28,2,8, 3,95,54,27,141,47,52,107,213,95,252,226,231,63,243,36,182,217,177,30,122, 232,161,57,107,238,200,247,229,243,185,143,22,138,229,147,118,206,177, 52,77,223,66,0,52,21,2,76,8,64,74,212,54,55,209,106,246,14,187,146,82, 194,115,59,245,122,117,243,95,175,180,106,191,253,220,23,190,48,213,193, 45,25,246,134,140,0,166,136,135,223,251,222,210,241,249,163,111,47,150, 202,63,83,40,149,95,99,217,187,107,75,54,26,1,8,4,65,192,155,245,218,103, 154,245,202,63,125,98,244,212,90,242,166,183,189,237,88,169,56,255,238, 124,161,244,147,249,66,241,30,203,182,53,45,170,20,28,104,255,83,2,41, 37,106,149,10,218,173,174,124,75,41,225,118,218,245,70,181,250,235,126, 115,243,183,158,120,226,137,67,217,8,51,67,23,25,1,76,31,228,61,31,248, 192,241,82,121,249,189,249,98,233,67,249,226,240,182,100,195,176,35,1, 8,129,32,240,89,163,86,251,171,122,109,125,119,217,117,31,251,24,125,235, 147,95,191,179,80,42,254,68,161,84,254,177,92,33,127,163,105,217,164,219, 49,168,55,26,32,132,68,181,178,129,78,187,21,173,81,162,211,110,213,234, 181,218,111,132,153,240,207,12,50,2,216,39,156,58,117,74,211,202,203,47, 43,149,202,31,41,205,205,253,72,46,95,88,214,117,125,36,255,192,78,4,224, 185,110,216,108,84,255,211,102,117,227,95,125,249,115,159,219,83,7,154, 147,39,79,26,203,55,223,241,234,124,161,240,83,197,98,249,157,78,33,191, 104,24,102,138,4,20,1,112,33,80,221,216,128,219,105,67,74,137,118,171, 181,218,168,215,62,22,54,55,255,223,76,248,103,7,25,1,236,51,30,122,228, 17,251,70,171,252,143,74,115,115,63,91,42,151,223,234,228,114,133,157, 252,3,131,8,32,206,251,119,93,215,173,215,170,255,177,185,86,251,31,191, 248,197,255,54,177,24,251,131,167,78,57,75,212,124,83,46,87,248,104,177, 84,122,75,46,95,40,232,186,222,37,0,46,176,185,177,6,183,211,70,187,213, 90,173,215,106,191,234,86,215,126,255,204,153,51,135,110,2,110,134,225, 200,8,224,128,240,142,71,30,153,155,203,47,253,192,220,124,249,103,243, 165,210,171,45,203,54,134,249,7,18,2,168,84,146,180,91,193,57,60,183,211, 170,214,54,255,93,181,211,252,141,51,127,59,29,79,251,67,239,120,199,220, 98,126,254,251,156,66,225,163,133,82,233,164,227,228,44,93,215,193,56, 71,101,117,5,149,141,181,213,70,189,250,171,110,181,146,9,255,12,34,35, 128,131,5,249,241,71,31,189,201,202,207,191,175,84,156,123,127,174,84, 184,213,52,182,250,7,250,9,64,112,1,183,211,170,215,170,213,223,184,220, 168,252,187,103,78,159,30,109,74,197,30,214,249,182,119,189,235,88,177, 176,248,238,66,169,248,193,98,169,124,47,213,52,237,210,133,115,231,175, 94,185,244,207,253,90,229,255,203,132,127,54,145,17,192,33,128,106,75, 246,192,203,139,165,252,135,243,197,210,143,228,243,249,69,221,232,182, 37,75,19,0,231,12,237,86,107,181,86,217,120,172,85,89,249,191,247,211, 222,254,216,199,62,70,191,242,204,51,183,47,28,185,225,17,39,151,127,235, 234,197,139,255,250,79,185,219,223,179,63,195,12,33,35,128,67,132,83,167, 78,57,206,226,137,239,46,148,203,63,91,42,205,125,183,157,115,28,77,211, 18,2,216,92,95,71,171,89,191,180,89,221,248,87,245,43,151,62,126,80,187, 238,163,143,62,106,116,104,113,222,175,188,84,121,60,19,254,153,70,70, 0,135,16,239,252,241,31,95,156,43,45,191,171,60,55,255,211,249,82,233, 85,150,101,235,181,205,13,92,190,112,254,92,101,125,253,159,178,118,245, 147,167,79,159,30,109,56,125,134,12,219,32,35,128,195,11,250,238,71,126, 234,230,185,133,133,15,204,47,47,63,210,106,52,106,231,159,127,246,159, 253,37,21,159,201,84,238,12,147,66,70,0,135,28,143,62,250,168,97,205,31, 121,69,199,245,248,127,248,223,255,215,167,113,141,21,163,100,200,144, 33,67,134,12,25,50,100,200,144,33,67,134,12,25,50,100,200,144,33,67,134, 12,25,50,100,200,144,33,67,134,12,25,50,100,200,144,33,67,134,12,25,50, 100,200,144,33,67,134,12,25,50,100,200,144,33,67,134,12,25,50,100,200, 144,33,67,134,12,25,50,100,200,144,33,67,134,12,25,50,100,200,144,33,67, 134,12,25,50,100,200,144,33,67,134,12,25,50,100,200,144,33,67,134,12,25, 50,100,200,144,33,67,134,12,25,50,100,200,144,33,67,134,12,25,50,100,200, 144,33,67,134,12,25,50,100,200,144,33,67,134,12,25,50,28,118,252,255,59, 169,108,135,95,233,25,250,0,0,0,0,73,69,78,68,174,66,96,130, } }, {.path = "data/icons/icon32.png", .size = 1712, .data = (const uint8_t[]){ 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,32,0,0,0,32,8,6,0, 0,0,115,122,122,244,0,0,6,119,73,68,65,84,120,156,237,150,77,108,92,87, 21,199,255,247,227,189,55,243,198,95,99,59,113,106,39,33,184,8,33,153, 66,213,162,8,218,162,84,98,7,173,88,160,68,130,118,81,64,138,100,81,171, 236,80,96,225,5,18,98,129,132,186,64,136,170,66,40,72,72,212,18,84,34, 45,10,82,155,66,18,146,84,148,66,235,182,137,227,16,55,51,246,120,198, 158,143,55,239,205,188,143,251,113,88,140,211,166,182,19,39,82,11,155, 158,229,213,189,239,252,206,255,127,207,185,15,248,56,254,207,193,110, 119,227,161,217,83,178,152,234,65,231,74,179,53,55,119,196,28,154,61,37, 221,86,231,179,204,216,164,92,77,254,243,246,220,145,236,35,3,120,244, 216,185,49,46,156,163,128,120,212,90,117,58,141,27,39,184,229,15,48,41, 166,137,200,128,232,101,175,48,52,199,180,189,240,252,79,15,54,0,70,31, 10,192,225,217,121,215,74,254,48,35,126,204,90,243,32,145,113,84,18,82, 176,122,49,114,253,98,46,215,55,226,112,233,194,201,245,67,56,185,136, 172,121,67,165,225,31,195,86,249,197,213,213,108,241,118,84,185,9,0,177, 71,126,112,102,159,231,23,159,228,50,247,109,198,249,40,89,131,180,211, 64,187,182,136,110,176,2,127,112,28,254,224,93,232,27,61,0,199,235,131, 209,41,84,18,34,233,52,140,85,233,50,89,245,178,234,182,159,121,233,153, 35,231,1,220,84,17,185,93,213,153,249,215,87,193,250,143,25,107,239,39, 157,9,192,66,37,33,178,110,11,214,164,80,89,4,149,69,0,8,140,113,48,46, 32,164,135,56,171,130,140,22,96,216,175,178,238,19,113,183,222,2,112,254, 86,10,240,205,11,70,176,79,8,199,249,57,231,252,32,89,45,226,96,5,209, 250,85,168,36,132,49,25,130,250,21,172,46,157,65,233,210,139,168,44,157, 70,220,169,129,200,128,172,129,213,25,140,234,246,52,52,26,156,139,228, 208,236,41,113,43,128,45,10,192,116,140,37,151,147,53,224,156,67,37,109, 24,149,130,120,132,122,229,117,172,151,254,9,149,134,176,164,80,43,93, 128,150,41,134,247,220,131,254,129,79,2,100,145,235,27,133,112,124,228, 251,119,195,106,245,184,234,54,47,3,248,245,109,3,144,211,23,123,210,143, 29,175,0,46,29,248,67,227,104,175,45,162,244,206,159,209,88,126,3,42,110, 195,26,13,65,61,91,181,234,162,213,188,4,149,134,216,181,235,126,56,94, 63,64,4,107,20,84,210,222,155,68,173,137,59,82,32,151,219,171,10,131,185, 4,32,104,149,193,40,192,31,156,192,228,125,223,196,200,196,189,88,190, 248,18,214,175,189,6,21,71,96,66,130,49,129,225,145,41,12,15,79,129,115, 15,0,193,154,12,221,96,5,105,167,105,173,49,149,59,2,200,15,165,169,181, 126,196,133,128,144,12,138,37,96,92,64,186,62,118,31,248,18,198,38,31, 68,80,189,132,210,59,39,209,94,91,192,158,241,7,48,54,241,69,112,46,97, 141,65,214,109,33,172,47,33,9,215,144,198,13,221,13,43,181,59,2,48,165, 72,233,162,105,123,254,8,64,0,99,2,210,43,64,8,14,206,37,140,181,24,217, 119,31,10,197,253,104,148,255,141,145,137,207,65,72,15,100,45,116,214, 69,212,44,33,14,42,104,55,174,162,81,155,79,116,18,212,111,5,176,165,11, 150,94,249,141,190,248,230,241,224,221,203,39,16,181,203,32,50,0,17,184, 240,32,115,62,188,124,14,58,139,208,174,45,194,168,20,89,28,130,172,129, 209,9,58,205,50,226,246,42,90,245,5,4,173,5,16,183,144,125,67,19,119,61, 114,212,191,25,192,118,131,136,221,243,216,15,127,193,184,152,150,142, 143,129,193,73,12,143,78,161,127,232,0,28,175,0,128,16,172,46,160,181, 122,9,89,210,198,240,248,20,114,3,99,80,73,136,230,202,91,168,149,46,32, 10,175,1,156,131,75,135,184,116,27,194,117,94,33,107,143,199,134,157,190, 246,194,47,91,184,97,48,109,81,0,0,17,81,3,232,221,240,198,250,60,150, 174,252,9,165,165,191,32,10,203,189,126,183,6,157,112,25,171,165,179,168, 46,191,138,180,91,71,22,7,168,149,95,69,187,121,5,220,117,33,115,62,100, 206,103,50,231,143,112,225,126,131,75,247,119,190,35,230,38,191,246,157, 169,27,147,109,157,3,61,89,62,224,155,86,93,172,175,190,142,160,113,25, 197,145,207,32,11,91,168,150,207,67,165,17,214,42,175,161,211,89,6,105, 141,160,190,240,222,23,152,144,144,185,2,24,23,32,163,1,75,5,157,101,7, 145,169,161,29,1,192,120,131,64,134,129,125,96,138,169,44,66,173,242,15, 164,65,29,70,39,0,99,0,8,89,26,64,117,67,16,44,76,150,130,187,30,132,151, 239,149,2,6,46,93,168,110,2,147,197,1,50,93,221,17,128,24,11,4,227,134, 8,98,219,119,132,8,0,129,11,1,46,29,48,206,1,214,75,148,69,45,36,173,222, 35,40,93,191,167,0,89,88,173,64,198,172,165,113,220,216,17,64,112,22,48, 198,21,99,112,1,192,146,221,72,122,3,3,0,6,6,198,4,152,116,192,165,124, 175,90,233,230,1,107,97,84,12,128,192,184,128,81,25,172,74,86,28,191,217, 217,17,96,188,223,11,83,139,44,136,109,129,24,7,3,109,92,62,139,247,21, 97,61,11,216,117,81,8,100,53,156,124,63,132,227,129,54,246,89,163,64,58, 133,201,98,88,171,223,45,157,249,107,186,35,192,189,227,3,145,149,44,169, 134,10,75,141,20,97,106,65,140,3,220,128,140,233,201,205,197,251,118,16, 245,214,173,5,227,27,182,8,209,123,51,24,239,193,171,140,84,26,47,98,147, 167,219,119,1,233,192,97,206,181,253,195,185,177,81,95,242,114,144,161, 220,82,232,40,2,147,28,92,74,112,206,224,138,13,21,0,128,44,124,73,32, 155,145,134,175,192,152,107,210,164,231,189,53,80,73,164,172,206,174,110, 206,181,221,28,128,163,130,106,150,168,239,106,165,127,229,9,170,223,61, 236,226,11,251,124,76,142,230,225,73,14,193,57,246,12,56,248,244,88,30, 119,143,122,232,119,57,134,243,12,19,3,146,138,34,57,231,216,228,40,105, 253,7,34,211,38,163,161,147,14,172,81,243,164,213,155,91,138,221,14,224, 122,204,60,253,180,151,107,37,15,73,215,249,190,20,206,87,164,231,230, 27,29,133,229,114,25,20,174,89,33,184,26,26,30,245,32,93,212,171,21,202, 226,232,111,141,160,254,189,179,39,79,190,189,235,208,225,66,30,252,97, 46,216,180,78,227,221,105,171,241,212,218,91,167,207,109,182,224,182,254, 138,159,154,157,29,202,123,131,95,207,229,243,51,156,177,207,175,174,44, 179,181,234,202,11,4,246,92,177,56,242,184,155,243,190,188,94,171,253, 61,237,116,158,124,254,247,191,93,184,241,236,167,14,62,54,208,113,130, 161,202,217,19,165,205,201,111,27,224,250,222,31,253,248,103,123,153,231, 62,209,172,175,239,169,85,150,126,50,119,252,248,242,183,166,167,139,125, 222,192,67,205,168,62,63,247,236,179,91,60,254,208,227,240,225,231,196, 204,204,140,247,145,39,250,56,254,87,241,95,105,140,140,8,113,124,24,60, 0,0,0,0,73,69,78,68,174,66,96,130, } }, {.path = "data/icons/icon48.png", .size = 3004, .data = (const uint8_t[]){ 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,48,0,0,0,48,8,6,0, 0,0,87,2,249,135,0,0,11,131,73,68,65,84,120,156,237,153,123,108,100,215, 93,199,63,231,156,123,239,220,25,207,172,237,125,122,55,235,58,97,243, 88,218,180,75,66,11,229,209,164,136,134,63,40,45,136,200,149,136,68,2, 68,9,16,37,72,64,17,132,86,50,81,255,160,21,8,9,36,10,138,84,129,80,20, 164,24,21,136,82,66,5,37,164,74,66,186,209,86,129,77,54,9,251,142,119, 253,24,219,243,158,185,207,115,126,252,113,199,222,93,225,245,62,1,33, 237,79,178,228,153,251,187,191,243,253,158,223,243,156,129,27,114,67,110, 200,255,107,81,215,106,224,190,223,252,230,72,48,200,130,111,252,217,167, 91,160,100,237,251,79,61,250,220,168,248,225,167,148,228,75,25,249,155, 47,127,245,115,189,107,93,107,35,185,106,2,211,211,207,153,232,182,189, 7,140,10,126,75,96,210,101,209,223,165,121,255,5,157,185,147,78,236,126, 237,135,191,171,180,249,41,196,197,206,102,7,197,229,179,158,85,223,26, 89,30,156,153,157,253,156,253,63,37,48,61,243,214,214,52,139,31,84,158, 249,53,133,190,25,165,148,136,88,155,39,115,189,250,177,67,193,200,216, 1,227,151,247,173,219,87,10,227,135,89,16,214,142,139,184,23,109,156,252, 173,228,241,155,207,255,193,143,118,255,87,9,220,59,243,146,55,206,248, 199,61,63,124,18,212,143,139,115,37,113,57,34,130,205,19,122,171,167,233, 46,159,160,50,190,135,114,109,23,94,80,70,105,131,87,26,193,11,42,40,165, 65,68,156,179,45,155,199,7,163,246,194,108,52,104,124,107,103,195,204, 93,173,87,46,155,192,79,126,254,59,19,229,45,181,71,180,9,126,69,105,181, 103,237,85,113,150,116,208,162,187,122,138,168,83,39,139,218,84,198,111, 34,28,217,134,95,174,81,222,178,155,176,186,21,155,167,184,60,69,196,225, 108,74,58,104,147,37,253,76,92,126,194,218,244,69,155,70,95,175,184,210, 161,23,158,254,236,224,74,8,120,151,82,152,158,121,46,136,146,15,124,210, 243,253,39,69,248,17,16,31,244,16,124,78,58,104,19,247,86,176,89,4,8,32, 231,118,69,214,254,87,120,126,25,252,144,52,234,144,244,155,216,44,65, 41,229,43,227,223,161,181,119,59,194,131,173,246,210,227,192,95,95,55, 2,63,253,133,151,39,211,188,242,132,231,251,191,168,180,222,46,46,39,207, 44,74,233,2,124,212,193,102,49,226,134,222,23,71,60,88,197,11,171,4,149, 113,64,129,26,122,74,28,0,206,102,5,49,165,16,41,222,73,163,150,26,116, 150,70,179,164,123,197,57,121,81,2,51,51,51,250,176,217,254,27,160,158, 192,57,179,6,192,102,49,73,127,21,113,22,109,252,66,89,65,158,69,52,22, 15,211,88,124,139,230,202,17,198,118,125,47,219,111,186,155,176,182,227, 2,187,226,44,206,166,100,233,0,151,167,24,63,36,238,55,176,121,154,98, 221,234,149,18,216,140,177,250,217,153,127,255,99,65,61,225,242,4,148, 38,139,59,244,155,115,136,8,65,121,12,47,40,35,226,232,183,231,152,63, 250,47,244,91,115,228,73,132,9,203,24,191,132,95,170,177,243,214,31,98, 226,150,79,80,173,77,226,249,101,162,78,157,168,91,199,102,49,126,169, 74,80,30,69,108,78,50,104,166,206,229,95,177,186,244,23,255,244,135,247, 156,66,157,235,41,155,201,102,33,36,2,13,196,33,206,18,84,170,120,165, 50,121,58,32,233,55,201,147,30,226,114,58,205,227,172,204,127,151,168, 187,88,132,137,90,219,23,133,181,9,221,246,41,178,211,49,97,184,141,177, 241,219,240,168,160,181,71,80,219,129,241,194,98,167,188,128,242,150,93, 129,88,251,100,50,104,222,245,195,15,127,237,129,215,224,178,74,236,230, 73,172,212,170,231,151,165,60,58,161,188,32,4,20,149,45,19,196,189,21, 26,103,14,51,127,252,37,218,171,255,137,184,188,168,48,206,22,180,47,180, 129,184,156,104,176,68,18,53,168,149,39,217,177,231,99,24,19,32,226,10, 210,34,136,179,36,81,211,139,123,43,129,235,182,243,203,1,127,73,2,181, 109,19,145,23,84,196,229,162,156,43,114,64,105,67,105,100,43,219,167,190, 159,112,203,14,234,167,254,141,165,147,175,145,116,26,184,60,67,16,148, 241,206,229,199,48,74,61,175,204,248,248,135,24,27,187,109,253,153,82, 6,133,198,102,49,131,206,34,89,220,197,185,116,121,146,201,244,245,235, 65,64,235,106,87,123,37,231,7,104,107,51,242,36,37,77,34,108,26,33,226, 24,25,219,203,205,7,238,103,98,223,61,212,79,190,206,194,209,127,165,83, 63,74,30,247,17,103,17,169,130,179,132,225,54,118,237,254,56,149,202,196, 240,123,183,190,70,158,70,12,90,243,36,131,38,74,41,156,203,23,103,103, 127,238,178,155,218,166,4,68,92,91,44,185,21,237,41,93,194,248,160,210, 184,40,163,67,16,74,105,70,198,246,114,219,15,254,60,83,31,249,12,75,199, 95,101,238,157,111,210,89,62,134,75,98,42,225,110,38,167,238,35,172,108, 95,179,137,179,69,200,37,131,38,131,246,2,89,212,193,230,9,34,86,162,110, 125,225,114,193,95,146,0,46,233,162,202,41,16,138,3,103,65,107,15,29,214, 112,46,195,102,9,90,123,152,160,140,82,154,176,186,147,169,3,63,195,238, 219,127,140,250,169,239,208,111,206,49,245,145,207,226,151,106,235,38, 149,210,104,227,145,246,155,244,155,103,200,147,30,121,210,39,137,219, 52,235,111,187,126,235,204,226,117,35,208,91,61,213,45,141,237,73,202, 213,29,40,101,64,129,20,221,7,173,61,252,106,25,191,20,144,167,57,54,95, 243,186,194,120,33,97,101,59,90,121,136,205,208,90,1,26,231,44,206,229, 196,221,21,6,173,5,178,184,75,158,244,232,119,230,105,44,30,38,73,219, 169,35,95,190,110,4,222,125,247,235,253,176,58,26,111,221,241,65,118,76, 220,77,80,26,95,127,38,34,20,81,20,16,148,125,196,229,100,73,70,50,232, 210,169,31,163,223,58,139,241,2,210,184,135,50,1,97,101,12,227,121,244, 87,230,73,250,13,178,164,75,22,119,232,181,231,232,180,79,224,116,142, 54,94,70,238,82,138,204,191,230,62,64,174,210,40,73,90,131,165,179,7,105, 174,188,195,216,214,219,25,29,187,131,176,188,173,152,44,41,170,166,205, 21,74,251,120,190,208,106,207,147,197,157,225,28,52,236,147,226,176,121, 134,136,35,79,122,216,52,34,141,218,116,26,199,233,245,230,16,13,126,165, 134,175,198,70,148,226,43,251,238,123,232,175,172,111,94,56,245,177,201, 57,158,122,202,109,2,113,115,2,129,54,17,162,122,40,33,77,58,212,23,14, 209,92,125,143,209,177,91,217,186,253,67,84,170,19,235,186,34,224,172, 224,108,62,252,44,56,151,179,214,212,138,126,224,112,121,70,150,116,105, 173,188,67,111,112,22,140,70,27,131,214,30,202,24,163,141,255,3,218,15, 238,242,225,177,59,190,187,244,55,217,167,127,105,118,124,209,123,239, 208,161,167,179,141,48,234,205,8,40,157,165,32,231,29,5,133,44,237,178, 82,127,147,147,199,254,158,249,185,111,51,232,47,13,155,209,57,45,103, 51,58,205,99,44,188,255,109,26,245,195,100,105,15,40,154,85,154,180,169, 159,125,131,118,227,40,74,107,76,169,140,23,148,209,158,143,246,2,76,80, 66,27,207,215,198,251,160,246,75,95,12,130,145,127,232,238,241,254,228, 246,159,120,104,255,21,123,32,79,170,153,246,179,246,127,31,152,10,34, 245,133,55,104,53,222,99,219,206,59,217,190,235,46,252,160,70,150,245, 89,94,60,68,99,249,45,148,82,44,206,189,74,183,115,138,29,55,125,148,32, 24,101,225,244,43,116,154,199,214,199,14,5,69,227,27,130,95,235,202,0, 74,41,173,148,153,20,229,30,201,144,131,192,187,87,68,224,8,71,236,157, 220,218,186,184,134,144,38,109,22,230,94,163,177,252,54,91,70,191,135, 213,247,223,164,221,56,138,56,139,242,124,68,28,209,96,153,179,167,94, 66,156,99,208,153,47,42,153,58,23,90,5,90,80,218,67,105,13,82,132,154, 56,139,203,51,242,184,159,74,156,158,217,8,193,166,33,196,236,172,5,105, 110,170,51,36,146,196,45,234,243,7,233,117,230,134,243,144,172,3,43,52, 28,54,27,192,112,246,113,89,138,203,207,133,181,26,22,30,113,14,17,133, 246,74,160,52,121,220,199,89,219,85,202,109,216,224,54,39,0,32,250,138, 103,116,89,131,100,188,245,106,5,172,239,188,246,124,92,158,16,183,150, 136,91,203,216,44,89,167,177,102,65,196,13,7,68,135,194,173,230,46,219, 16,199,37,143,148,74,169,134,82,90,0,117,254,12,115,57,162,148,30,38,167, 191,78,68,27,191,56,116,10,184,60,195,166,49,105,183,152,131,116,16,94, 72,216,218,53,111,45,37,237,94,103,163,53,46,237,1,84,19,180,85,74,163, 181,25,46,112,153,39,191,225,217,64,105,83,16,49,62,202,24,4,65,68,240, 202,85,188,112,4,237,121,56,107,177,105,180,126,240,135,162,36,15,47,3, 222,95,250,143,177,120,163,37,46,233,1,99,104,129,88,80,30,40,180,241, 214,141,95,218,35,231,17,85,195,146,35,130,216,28,191,82,43,60,163,205, 240,177,42,118,59,79,193,102,40,101,138,169,215,230,56,103,143,195,236, 134,19,234,37,61,240,225,61,213,206,45,219,194,52,244,207,169,42,165,49, 94,128,49,254,5,46,191,0,186,82,23,250,73,0,87,156,238,196,89,148,241, 48,65,136,246,75,231,8,174,235,10,46,79,138,74,36,206,138,184,19,23,195, 119,73,15,236,170,233,222,84,169,146,76,38,182,118,98,37,166,222,203,201, 135,27,175,180,65,235,162,195,138,179,69,242,42,133,214,6,167,245,16,148, 172,255,21,122,110,120,43,81,216,208,158,143,241,75,195,91,10,119,110, 68,113,14,156,195,101,105,100,211,232,253,171,38,224,105,211,83,138,120, 188,226,243,125,123,61,150,187,41,39,27,9,141,129,197,21,136,81,107,185, 33,130,54,6,119,129,87,214,234,168,156,23,114,114,222,217,25,148,214,184, 60,197,69,57,218,15,208,158,143,56,71,158,197,228,201,160,147,217,100, 233,170,9,164,137,180,180,201,143,160,252,9,163,149,183,179,230,51,22, 106,22,187,57,167,91,41,157,196,22,101,95,21,68,24,130,47,121,154,32,48, 216,243,128,138,56,60,45,140,149,132,44,27,144,138,231,68,124,0,141,128, 136,197,38,81,209,35,178,20,155,12,16,113,43,126,164,27,23,195,119,201, 28,248,163,167,62,191,218,29,196,15,167,113,252,148,181,246,148,136,136, 111,20,147,99,62,31,221,91,97,255,174,10,35,129,185,224,157,145,64,51, 181,53,100,255,206,50,83,227,37,42,190,6,4,95,193,238,170,97,91,213,103, 139,103,179,49,233,62,43,54,251,162,184,252,109,183,126,59,86,220,29,229, 201,0,113,206,137,147,55,170,44,110,88,66,207,109,205,101,200,244,244, 180,217,251,225,187,239,44,153,224,113,109,244,253,90,155,113,165,20,158, 31,208,75,45,39,86,34,206,172,246,145,206,18,19,165,20,101,19,70,70,170, 84,170,53,156,41,177,60,176,164,173,58,33,9,241,32,74,187,157,246,95,250, 46,249,194,203,47,127,178,241,129,79,28,153,82,138,7,148,241,30,84,218, 236,83,10,147,116,155,46,139,122,47,102,121,254,88,243,200,171,23,205, 129,43,190,202,123,104,102,38,220,166,203,247,250,158,249,117,227,5,247, 134,165,82,168,180,198,137,208,232,198,172,204,159,38,143,250,68,209,192, 86,171,53,70,106,53,83,10,203,40,165,168,47,206,147,37,105,146,164,241, 211,237,133,206,204,43,175,124,227,188,49,101,70,223,116,207,225,125,30, 230,65,101,244,3,105,191,125,52,143,122,143,213,15,191,114,209,10,116, 85,4,214,228,87,127,231,247,199,203,21,125,127,181,50,242,184,231,123, 119,42,165,77,150,101,156,57,125,146,94,167,211,237,247,123,127,90,173, 142,68,213,218,232,67,229,74,245,102,165,149,94,94,92,136,226,100,240, 213,94,26,125,233,159,103,103,219,27,26,158,158,54,123,22,178,125,42,141, 7,103,15,254,227,134,3,220,117,33,0,128,136,250,237,223,251,242,148,25, 169,60,28,120,254,47,88,231,110,58,115,250,100,171,211,108,125,73,39,157, 63,7,210,242,232,142,253,149,209,177,95,214,198,124,166,190,52,255,108, 218,92,254,242,243,207,63,127,205,63,108,172,201,53,255,70,6,48,51,51, 227,37,97,237,0,194,35,245,249,197,215,187,75,167,159,157,157,157,77,215, 158,79,79,207,4,181,61,131,91,210,213,133,51,207,60,243,76,255,122,172, 249,63,34,143,62,250,168,63,51,51,115,25,243,213,13,185,33,55,228,134, 12,229,191,0,28,195,92,201,114,89,143,242,0,0,0,0,73,69,78,68,174,66,96, 130, } }, {.path = "data/icons/icon64.png", .size = 4397, .data = (const uint8_t[]){ 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,64,0,0,0,64,8,6,0, 0,0,170,105,113,222,0,0,16,244,73,68,65,84,120,156,237,155,107,140,156, 87,121,199,127,231,156,247,50,179,51,187,222,139,189,107,39,113,66,10, 9,73,192,113,131,40,132,168,109,26,165,208,40,4,104,63,36,173,132,74,27, 84,12,162,16,26,160,42,208,22,203,226,99,219,15,85,81,171,182,162,21,52, 109,74,162,74,33,180,8,84,154,96,66,128,212,184,105,67,227,224,96,39,94, 95,246,50,187,59,59,183,119,222,219,185,244,195,59,187,59,123,113,118, 215,177,65,170,252,151,102,61,59,123,222,51,231,249,159,231,121,206,115, 57,134,203,184,140,203,184,140,203,184,140,159,22,196,255,211,5,56,113, 251,199,191,58,22,136,70,252,239,127,246,190,104,163,191,255,242,7,255, 229,117,206,15,126,221,154,244,88,55,107,60,253,204,23,206,206,193,33, 123,105,214,115,126,92,116,2,238,57,248,248,0,233,174,119,73,229,125,204, 90,189,160,211,248,159,117,218,122,242,155,59,159,157,225,208,33,123,235, 131,143,148,135,242,210,187,101,80,254,180,16,106,159,115,54,117,38,63, 166,243,228,43,58,139,190,74,158,255,232,240,23,239,79,46,246,186,206, 135,139,71,192,193,131,242,238,248,142,215,43,191,242,73,37,189,123,133, 84,131,0,206,154,212,154,252,71,38,143,31,139,59,115,135,253,176,114,175, 148,193,123,133,148,67,253,143,59,103,45,48,235,5,149,111,163,228,35,180, 90,79,127,117,228,169,57,14,93,90,173,184,40,4,220,117,240,251,67,161, 9,238,19,66,124,2,33,175,23,66,200,85,3,156,35,238,204,217,198,212,177, 168,50,178,183,18,86,70,164,144,2,103,29,224,0,80,126,137,160,60,140,242, 3,156,53,177,53,230,88,158,199,143,107,147,63,30,157,235,254,232,240,23, 239,184,36,90,241,170,8,184,247,222,71,148,190,233,245,251,133,23,252, 129,82,254,61,192,128,179,6,107,52,206,26,0,172,213,196,205,105,218,243, 47,147,69,117,42,163,123,9,43,163,248,165,29,40,63,4,10,225,253,176,138, 144,106,213,252,206,89,235,140,158,141,59,243,79,197,141,217,71,209,233, 83,79,92,117,252,162,106,197,5,19,112,239,193,255,29,213,82,190,207,243, 252,7,132,144,175,65,136,149,185,156,195,90,67,158,180,136,22,207,146, 116,230,200,227,54,58,237,80,25,221,75,80,222,129,23,84,80,97,153,82,101, 140,242,142,221,88,163,49,121,138,179,122,101,154,222,28,121,210,193,216, 60,182,58,123,193,234,236,43,121,154,61,78,30,93,20,95,177,109,2,110,63, 248,164,55,152,120,183,122,225,224,167,189,160,114,167,84,42,92,59,198, 57,75,158,180,137,155,51,36,157,121,76,30,147,39,29,242,180,67,117,244, 106,130,242,80,65,64,80,34,172,140,49,176,99,15,66,74,64,224,172,70,231, 9,58,141,72,163,58,38,79,89,50,147,98,110,103,157,213,179,38,235,126,171, 221,156,251,236,247,31,250,192,137,87,67,128,220,124,200,10,238,254,228, 147,187,135,242,129,79,123,65,245,203,66,136,187,173,78,194,98,215,204, 242,34,173,78,73,218,53,210,206,60,214,228,188,50,199,2,129,0,28,206,90, 156,53,8,161,240,252,50,86,103,224,220,42,197,2,16,66,72,156,219,147,198, 173,119,153,110,227,138,237,137,187,30,222,86,6,29,56,240,3,127,106,84, 223,33,149,247,25,169,252,219,132,16,62,128,115,14,103,114,172,209,8,1, 214,100,100,113,171,39,56,208,183,120,107,50,162,230,89,84,88,194,11,43, 43,188,136,229,31,20,115,90,172,201,49,58,197,57,11,8,132,144,56,28,56, 71,22,55,137,155,211,232,60,73,116,158,53,126,34,4,212,38,196,205,165, 96,248,11,206,217,171,172,89,217,237,222,146,209,89,161,174,66,8,132,92, 59,165,35,141,23,153,59,119,132,246,194,41,90,141,151,24,28,187,150,177, 43,246,179,99,231,117,108,168,33,206,81,56,211,28,147,39,24,157,2,32,165, 71,103,225,52,214,100,8,161,34,67,183,125,65,82,247,97,75,4,232,220,72, 229,217,138,195,246,54,85,224,28,88,147,18,183,107,100,157,58,8,65,80, 222,65,255,1,232,172,166,181,240,99,230,206,254,128,52,170,227,156,197, 232,132,214,194,9,186,237,115,44,204,92,201,158,215,221,206,68,120,27, 126,48,180,172,238,110,13,193,32,8,202,67,132,3,35,132,213,49,146,246, 28,221,214,108,58,228,57,1,61,27,186,148,4,120,158,233,88,103,82,103,114, 116,222,197,25,141,23,84,232,44,76,18,183,107,40,47,64,249,229,85,207, 100,105,139,185,51,207,176,112,238,127,208,121,188,110,78,107,114,162, 230,89,166,78,61,73,87,215,24,26,126,45,195,35,215,81,42,237,44,52,192, 21,49,130,84,62,97,101,12,63,168,20,36,43,159,160,52,72,101,228,170,107, 172,209,95,120,231,239,127,235,225,180,89,251,242,55,255,230,190,230,37, 35,32,115,182,27,66,140,16,8,161,8,42,67,148,6,199,41,13,238,162,83,63, 77,220,156,38,79,58,100,56,84,48,64,28,213,88,152,121,150,110,107,26,107, 243,13,102,92,218,184,98,183,211,100,145,185,153,163,44,46,188,64,117, 112,47,213,202,94,208,22,229,149,240,130,1,164,242,215,61,175,188,48,148, 42,248,37,171,211,55,100,90,31,1,158,189,100,4,132,9,177,240,137,164,23, 82,170,238,196,47,85,17,66,226,5,101,194,129,97,242,93,175,165,85,59,65, 99,250,5,102,79,125,151,86,227,165,158,3,115,56,163,161,247,126,35,172, 4,141,14,157,71,52,234,199,105,206,29,103,231,232,126,70,38,222,80,56, 64,103,139,249,92,255,113,104,72,187,13,210,246,124,154,101,209,5,251, 130,45,17,96,171,3,217,64,117,56,246,130,10,66,172,142,214,16,2,191,84, 101,244,170,125,148,135,119,227,13,84,177,39,53,173,249,19,232,180,131, 206,51,232,121,240,66,181,237,186,231,251,17,4,67,140,141,221,204,224, 224,213,203,145,161,16,10,129,42,158,181,22,163,83,226,206,28,58,237,96, 156,110,153,52,237,92,82,2,170,163,123,109,121,160,170,61,223,67,231,57, 121,150,247,226,248,2,214,228,232,172,139,148,62,19,215,222,198,216,149, 251,105,204,30,103,250,196,147,204,159,254,47,178,184,89,104,2,14,98,81, 156,239,225,0,66,169,101,199,39,132,164,82,185,130,177,157,63,75,169,52, 194,70,167,131,16,18,109,18,162,198,20,58,237,20,228,25,179,40,130,185, 238,37,37,192,171,183,51,19,14,182,132,84,40,79,225,5,62,58,203,201,211, 140,60,141,49,121,178,106,103,189,160,194,206,189,111,98,100,247,77,180, 230,79,48,125,226,219,212,94,250,46,73,103,14,171,115,116,18,97,77,142, 23,14,96,181,70,10,143,145,157,111,96,215,248,45,40,21,98,77,142,181,102, 149,202,227,28,89,210,38,110,77,147,199,109,156,51,8,233,97,173,89,232, 100,92,112,72,188,37,2,94,195,107,244,164,77,154,206,129,49,128,45,136, 176,22,116,150,20,59,177,129,137,123,97,133,241,107,223,198,248,181,111, 163,53,119,130,179,199,190,193,204,201,167,72,162,121,156,206,209,46,130, 220,48,49,241,86,70,39,222,136,148,133,179,147,202,195,89,131,49,57,206, 104,172,53,164,81,157,164,93,67,103,113,47,46,112,8,103,73,162,133,218, 177,155,208,235,191,125,107,216,98,46,224,196,111,253,101,252,87,126,80, 254,96,255,167,58,235,98,116,142,0,140,78,209,121,178,156,5,42,47,192, 11,6,86,101,120,214,106,162,197,51,76,189,248,36,51,39,14,227,151,6,185, 254,214,247,51,60,113,3,107,51,232,37,24,157,210,89,56,77,210,174,97,242, 20,163,211,66,227,176,180,234,39,89,156,125,225,115,231,142,126,237,179, 23,38,254,22,53,0,132,115,174,189,184,193,231,56,107,112,128,244,66,66, 47,196,154,12,4,72,25,174,115,112,82,250,12,142,253,12,215,189,101,47, 163,123,246,33,176,140,238,190,1,164,71,81,15,89,13,163,83,186,205,25, 146,206,28,58,143,177,121,134,206,99,242,180,69,99,225,69,58,205,211,78, 235,100,250,2,228,94,89,211,86,7,214,107,207,47,196,209,236,26,47,222, 23,195,91,131,181,6,21,148,168,142,140,82,170,150,80,106,253,244,206,106, 58,245,211,68,139,231,200,146,136,168,49,141,51,41,158,239,35,213,138, 182,232,172,75,183,49,69,22,213,49,89,130,201,18,116,22,17,119,106,212, 206,254,39,173,250,73,156,53,26,228,236,133,137,94,96,139,26,0,167,142, 63,94,47,85,198,236,216,196,27,229,206,221,183,80,42,143,173,203,212,0, 156,113,228,153,68,121,138,82,213,195,104,77,158,106,140,54,88,157,209, 89,152,164,83,159,44,178,61,4,70,231,36,81,139,192,66,56,48,136,231,7, 68,205,57,226,86,13,157,70,69,106,156,119,123,194,207,210,108,156,68,187, 20,229,135,88,157,167,206,102,11,63,17,2,156,211,141,52,89,52,211,103, 158,150,245,185,231,25,27,223,199,240,232,13,40,89,94,93,11,89,74,139, 13,88,43,145,42,160,84,241,73,163,54,245,218,105,226,206,252,178,186,247, 211,103,173,38,79,19,148,23,144,117,27,43,246,158,21,181,132,168,117,150, 118,251,20,214,25,252,82,5,33,37,214,152,32,192,253,198,213,191,112,95, 59,168,180,158,63,241,245,175,167,151,140,0,139,107,74,92,14,206,79,147, 69,166,206,60,197,252,236,115,12,143,94,207,200,232,141,4,225,112,31,17, 69,2,131,235,17,97,4,58,203,208,105,196,170,227,66,136,34,131,4,150,126, 218,158,41,57,155,99,117,74,158,182,105,55,94,166,211,57,131,19,14,233, 121,8,233,33,164,194,243,195,64,72,249,65,224,61,168,29,223,184,254,174, 247,63,228,197,237,103,142,29,126,116,203,129,209,150,9,16,86,180,129, 12,24,40,100,116,100,105,131,218,244,17,26,245,227,12,143,190,158,145, 209,27,41,149,199,54,124,222,185,181,191,23,130,46,17,209,63,208,25,141, 53,57,121,26,177,56,119,140,40,158,66,120,10,33,36,66,74,132,84,189,151, 68,72,37,148,23,236,145,202,251,109,231,236,175,154,160,244,157,235,239, 254,157,127,64,70,79,188,248,175,15,47,176,73,166,184,101,2,192,116,192, 223,64,197,28,89,218,164,54,125,132,102,253,69,70,118,222,196,174,43,222, 188,226,35,122,202,208,143,60,143,168,215,126,136,108,4,140,243,22,134, 119,221,136,23,12,20,74,227,44,214,234,34,155,156,58,66,171,126,18,21, 150,81,65,25,169,60,150,179,95,33,145,82,33,253,160,247,57,8,161,134,149, 84,247,56,165,238,116,38,124,246,250,123,14,252,147,235,38,143,253,248, 137,47,157,123,213,4,24,169,187,10,183,62,175,237,35,34,77,27,204,78,125, 143,70,253,56,99,19,251,25,27,191,153,176,52,130,16,130,34,185,117,164, 241,2,181,169,103,232,52,79,227,133,3,156,123,249,9,154,141,147,236,186, 242,205,140,236,186,17,169,2,146,238,60,51,167,159,166,221,56,85,156,58, 66,44,171,144,244,252,34,132,70,32,148,183,161,35,22,82,149,133,84,183, 97,213,207,153,64,79,0,7,57,143,38,108,153,128,48,243,186,214,35,218,44, 114,114,206,145,196,11,76,77,126,139,133,218,115,236,28,223,207,216,196, 62,156,51,116,154,147,204,156,126,154,164,51,87,228,251,2,172,211,116, 90,103,72,146,121,234,243,207,51,56,116,13,211,47,31,38,106,79,245,132, 94,170,27,46,127,1,56,144,65,136,23,148,10,83,210,43,101,248,254,117,152, 52,246,178,180,187,120,62,225,183,69,64,199,243,210,1,199,150,157,139, 115,150,164,59,207,185,201,39,89,168,61,71,224,85,153,61,243,12,121,218, 234,27,213,87,51,180,5,17,237,197,83,164,221,185,222,154,93,95,233,64, 176,214,150,172,181,8,33,81,65,169,136,67,116,94,4,102,206,161,147,46, 38,75,114,172,125,249,149,214,185,229,64,104,156,44,19,208,218,124,228, 106,56,103,137,187,115,44,212,158,199,232,87,206,89,4,162,200,253,97,89, 254,194,33,154,21,249,151,95,189,130,138,115,197,223,17,40,191,132,244, 3,116,210,197,230,41,56,23,73,199,121,237,31,182,65,64,254,82,164,29,92, 80,217,105,35,8,65,175,23,176,6,189,186,1,128,80,30,86,103,164,205,57, 178,246,34,54,207,150,158,94,109,22,244,136,176,133,57,20,65,22,128,107, 184,92,215,94,105,29,91,38,224,232,61,123,140,68,52,206,151,180,108,31, 133,19,147,202,95,110,138,0,43,206,78,121,133,195,147,10,103,52,105,115, 158,238,252,57,210,86,189,143,136,245,112,125,105,180,179,182,230,186, 11,175,184,105,91,151,230,208,33,139,16,117,33,100,81,161,217,192,251, 110,21,75,30,73,32,16,82,34,61,191,39,172,196,137,37,79,95,4,59,75,42, 46,148,87,132,191,121,74,218,46,242,131,117,193,5,224,76,225,12,157,53, 232,44,57,59,233,117,54,184,159,176,130,109,196,1,224,156,173,3,61,225, 21,75,134,186,174,204,181,249,76,197,63,125,206,77,72,137,84,62,82,103, 189,20,218,97,141,197,233,28,233,7,248,229,42,210,11,122,90,163,138,158, 65,22,23,68,41,111,57,157,118,214,20,14,49,207,176,70,191,204,209,163, 175,88,43,216,22,1,32,234,206,97,133,40,52,167,104,132,168,229,102,232, 230,68,172,221,177,243,104,145,16,189,174,147,70,250,33,202,15,16,202, 47,2,158,37,115,17,61,135,169,51,132,209,203,26,99,117,134,205,51,156, 53,214,25,119,114,131,47,93,133,109,17,16,120,98,209,10,103,221,170,246, 71,177,123,74,202,94,12,111,122,53,253,77,112,62,19,114,44,119,134,156, 49,120,165,10,210,15,138,19,2,7,189,83,98,117,51,186,32,2,64,167,221,94, 21,217,101,194,153,201,205,150,177,45,2,110,189,166,218,140,172,151,79, 214,83,175,25,107,236,242,121,85,168,177,148,30,78,168,149,56,255,60,68, 20,126,100,173,251,89,58,214,108,175,81,90,148,194,151,252,141,244,66, 16,244,108,127,101,124,63,150,212,191,247,91,27,105,166,54,147,105,91, 4,84,66,218,163,165,48,155,24,42,149,207,54,18,38,23,18,186,249,106,33, 133,16,32,20,74,44,105,196,234,158,64,145,208,40,16,75,166,233,250,94, 128,93,223,3,88,26,39,165,135,28,24,92,55,231,242,8,107,193,22,199,168, 73,227,197,184,217,154,223,76,166,237,249,0,27,180,29,164,37,95,242,218, 93,3,236,30,10,153,172,39,156,107,230,164,122,205,130,132,232,217,172, 197,218,34,158,47,252,5,96,244,242,152,222,155,66,0,103,113,206,244,197, 2,174,55,102,101,156,16,18,4,232,164,219,59,61,130,229,120,98,169,129, 162,179,24,157,37,51,202,15,55,141,91,182,69,128,17,166,43,240,227,165, 37,87,67,197,13,227,101,118,87,61,78,45,230,212,58,26,109,215,18,33,81, 74,98,213,210,153,110,214,204,186,62,160,89,89,92,143,144,165,113,203, 167,70,225,35,76,86,132,191,210,243,145,126,128,51,26,157,118,49,121,138, 117,238,204,220,49,177,105,185,124,91,4,104,221,89,204,51,245,61,63,16, 227,82,202,50,128,20,48,92,86,236,11,21,11,93,205,169,197,156,122,55,199, 244,151,244,97,149,211,19,194,49,84,242,16,190,92,95,207,238,237,252,128, 47,24,10,32,137,219,100,22,50,39,45,120,2,129,232,39,169,159,136,60,238, 244,110,148,0,216,151,224,59,155,150,203,183,21,214,253,249,161,67,141, 102,171,246,225,164,27,125,36,203,178,255,118,118,37,5,83,18,198,171,30, 183,92,81,98,223,158,10,195,101,111,141,163,239,69,120,2,38,170,62,215, 238,44,115,195,120,153,171,134,3,74,222,74,127,16,231,24,12,4,87,14,41, 42,129,79,217,147,12,203,164,89,209,237,63,181,121,254,143,206,154,250, 134,1,144,53,216,60,233,189,183,93,12,63,220,138,76,23,26,206,137,15,255, 225,231,174,174,150,203,239,247,124,239,126,129,184,74,244,157,75,158, 231,145,57,201,100,61,102,114,33,33,202,12,58,137,208,173,121,118,15,56, 134,188,162,97,58,56,180,131,48,44,147,9,143,90,23,230,187,6,17,205,51, 30,100,40,44,113,183,75,20,181,23,5,242,160,111,211,191,61,153,142,139, 160,172,222,102,156,251,144,16,234,29,82,201,29,43,12,56,210,118,29,157, 197,169,53,250,243,54,179,135,22,142,127,119,211,166,233,171,186,38,119, 251,193,131,222,126,171,246,7,126,248,81,223,15,223,163,148,28,94,34,64, 121,30,206,65,59,213,188,52,31,51,53,183,200,176,89,100,135,103,72,211, 4,103,45,213,161,29,148,74,101,130,48,68,121,62,81,102,105,204,77,21,103, 186,115,68,81,103,62,106,183,254,104,113,108,248,239,143,61,250,232,114, 2,48,113,243,219,43,94,117,224,118,207,15,62,36,149,127,135,144,178,234, 172,37,105,206,101,38,75,254,58,143,186,127,188,248,210,209,45,37,110, 23,229,162,228,131,15,62,88,54,149,145,59,75,97,249,247,60,223,251,249, 32,8,67,229,173,184,23,235,28,11,245,6,139,181,41,242,44,37,77,18,140, 49,102,199,142,97,21,150,203,4,65,136,31,4,56,231,168,77,79,145,231,57, 206,152,90,28,119,63,85,59,125,242,161,163,71,143,110,116,201,128,209, 183,220,53,52,224,7,119,42,175,244,33,224,173,73,115,238,225,196,228,159, 105,254,240,59,27,52,113,54,198,69,189,43,252,187,159,250,212,88,24,12, 222,87,174,84,63,28,150,74,55,138,190,94,122,187,213,100,230,220,89,178, 44,37,238,70,39,211,36,253,252,142,145,209,95,172,84,171,111,47,149,202, 85,63,8,176,214,50,63,59,67,150,165,211,105,146,124,178,93,59,247,200, 225,195,135,55,117,100,215,236,127,207,176,174,184,91,92,30,61,55,117, 228,63,182,213,39,184,232,151,165,15,30,60,40,235,218,187,182,58,56,248, 129,48,8,126,83,42,181,71,8,33,122,4,184,184,219,125,62,106,55,31,248, 218,190,27,15,191,251,217,51,149,234,238,129,187,42,149,234,71,74,229, 242,173,206,185,160,54,51,117,38,233,68,31,111,214,206,62,182,21,225,95, 45,46,217,125,253,3,7,14,248,131,87,94,247,166,114,57,248,152,239,135, 239,236,180,91,131,83,103,38,143,68,157,246,71,31,123,248,75,71,232,11, 229,238,191,255,163,187,188,225,202,189,82,202,95,171,205,156,253,11,47, 139,255,237,209,71,31,93,27,48,92,18,92,242,255,176,240,137,79,252,73, 197,27,145,239,200,243,244,87,206,158,60,241,249,71,30,250,187,231,217, 48,142,117,226,189,15,60,48,248,186,209,209,206,161,75,124,67,252,167, 130,3,7,14,172,189,233,116,25,151,113,25,151,113,25,151,113,25,63,93,252, 31,113,255,168,42,55,107,155,132,0,0,0,0,73,69,78,68,174,66,96,130, } }, goxel-0.11.0/src/assets/images.inl000066400000000000000000004662711435762723100170030ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* This file is autogenerated by tools/create_assets.py */ {.path = "data/images/icons.png", .size = 41358, .data = (const uint8_t[]){ 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,2,0,0,0,2,0,8,6,0,0, 0,244,120,212,250,0,0,161,85,73,68,65,84,120,156,236,221,119,96,20,101, 250,192,241,239,236,110,54,201,166,66,232,29,149,142,210,196,6,136,32, 22,236,221,211,67,61,123,239,245,231,89,176,158,229,236,245,244,236,32, 103,111,32,136,138,162,168,244,142,32,189,6,2,164,39,187,217,50,243,254, 254,152,221,100,19,82,118,147,109,9,207,231,110,77,50,59,229,125,147,144, 231,153,183,13,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16, 66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132, 16,66,8,33,132,16,66,8,33,68,75,119,164,255,37,132,8,193,112,224,34,32, 39,222,5,17,66,136,70,179,90,255,150,156,154,86,158,226,72,119,90,173, 214,191,197,187,56,98,255,164,197,187,0,97,56,198,158,156,50,181,103,223, 65,190,141,171,151,218,45,22,235,251,238,10,231,189,64,65,188,11,38,106, 117,24,48,38,156,3,58,116,232,208,217,48,12,223,238,221,187,243,194,188, 214,71,192,230,48,143,105,172,19,129,219,99,116,173,80,61,3,204,136,119, 33,68,104,108,182,228,219,210,179,178,30,125,242,157,105,169,22,205,194, 93,151,157,226,44,45,206,127,206,231,241,220,23,239,178,133,32,7,104,11, 172,241,127,221,31,72,5,242,128,237,128,13,24,228,127,111,61,80,12,180, 2,14,240,111,91,2,24,64,55,255,121,202,35,120,174,205,64,126,132,234,25, 47,150,148,20,46,172,168,96,10,160,71,251,98,205,37,1,56,198,158,156,50, 245,234,255,123,193,214,163,239,80,163,176,176,64,155,62,229,21,99,249, 188,239,203,188,110,215,201,192,194,120,23,80,84,51,58,51,51,243,251,203, 46,187,44,201,102,179,133,116,64,89,89,25,27,55,110,228,192,3,15,36,45, 45,45,228,11,205,156,57,147,229,203,151,63,4,76,108,92,81,195,246,83,86, 86,246,232,193,67,134,26,160,0,243,191,37,101,21,154,2,50,210,82,64,5, 222,129,191,54,239,214,64,209,187,71,59,3,64,41,165,41,96,215,158,82,13, 160,125,155,12,101,110,55,247,95,191,117,143,6,112,64,215,54,129,77,0, 236,222,107,238,223,38,39,163,114,179,82,138,117,171,150,107,229,165,197, 179,9,51,217,106,33,52,224,239,254,207,39,83,245,109,79,84,90,82,106,218, 115,29,59,119,187,234,201,55,191,72,45,243,37,1,144,158,164,115,239,53, 231,56,183,111,94,63,201,91,225,188,22,51,168,37,162,214,192,6,96,29,102, 130,15,176,18,24,0,60,13,220,133,25,136,119,251,223,59,5,152,6,156,11, 124,236,223,150,142,25,244,95,6,174,7,22,68,240,92,69,192,129,52,227,155, 194,172,116,206,27,114,8,111,109,222,198,150,205,219,56,29,243,251,29, 53,161,253,117,142,175,106,193,223,227,51,176,165,100,112,252,132,59,173, 93,250,12,111,53,237,189,71,127,242,121,220,39,0,191,199,187,160,17,54, 0,184,4,56,6,232,238,223,182,5,248,9,120,15,248,51,62,197,106,208,200, 172,172,172,153,31,127,252,113,210,232,209,163,67,58,32,55,55,151,233, 211,167,115,231,157,119,210,185,115,231,144,47,180,100,201,18,22,46,140, 125,238,55,240,144,67,140,25,223,127,175,123,116,229,53,148,210,12,5,175, 253,239,183,36,101,40,237,170,243,143,242,26,10,20,10,135,205,106,187, 228,190,41,86,5,188,249,240,223,124,165,21,62,67,41,48,148,226,189,207, 230,38,41,96,194,153,71,152,251,43,67,203,72,177,89,175,127,248,99,171, 82,240,204,255,157,227,43,172,240,250,247,135,79,167,206,79,82,74,113, 250,73,195,125,230,54,131,214,169,118,203,101,103,157,104,93,177,176,165, 253,234,135,196,2,188,105,185,246,129,203,40,41,196,152,252,146,6,124, 16,239,66,213,35,217,158,234,248,104,192,160,195,142,123,224,217,119,82, 183,23,121,216,148,87,2,64,151,28,7,207,189,243,181,227,177,187,175,185, 104,217,252,95,187,123,42,202,207,4,92,241,45,110,173,186,1,217,152,93, 177,131,129,165,113,44,75,109,54,0,109,104,198,9,64,171,86,60,240,206, 179,164,23,151,48,224,242,219,153,179,125,23,47,229,237,225,95,68,41,185, 77,244,4,96,159,224,239,246,234,154,219,171,107,30,175,78,247,1,71,169, 227,47,153,152,50,243,221,137,211,125,94,247,96,96,83,188,11,28,1,201, 192,19,14,135,227,178,179,206,58,203,62,108,216,48,107,74,74,138,86,84, 84,164,109,220,184,177,245,162,69,139,6,45,91,182,236,58,93,215,223,4, 238,1,60,113,46,111,176,145,89,89,89,63,126,252,241,199,246,112,131,255, 137,39,158,24,118,240,255,238,187,239,26,91,206,38,82,120,116,229,45,118, 121,221,186,82,24,10,202,221,62,139,2,246,148,121,43,12,165,208,13,165, 181,77,183,3,88,81,80,90,225,51,114,75,220,30,221,48,247,47,174,240,89, 12,20,155,11,93,94,221,48,52,93,65,247,236,20,80,88,1,10,43,188,198,198, 124,151,79,87,10,93,87,90,65,185,215,106,0,127,237,113,250,116,195,208, 12,3,250,180,5,133,185,255,126,198,12,254,119,63,119,153,229,226,91,48, 94,126,48,222,229,105,72,182,61,53,237,251,177,39,159,59,240,186,59,31, 73,249,115,71,41,187,139,221,149,111,110,207,119,226,242,232,220,255,239, 255,166,190,245,226,163,199,76,255,236,131,185,30,87,249,88,18,175,57, 59,31,120,35,232,115,128,243,168,106,182,7,40,4,14,245,127,190,222,255, 241,135,160,109,129,196,230,41,224,29,204,59,248,128,166,158,107,81,184, 21,74,36,41,54,198,157,60,150,142,57,173,59,208,174,93,22,51,38,255,213, 225,133,183,184,251,221,143,57,121,231,110,94,109,215,134,158,201,73,116, 213,44,116,54,12,218,107,22,210,183,231,114,179,207,199,204,198,94,51, 145,19,128,122,131,191,215,171,107,110,159,161,181,63,96,168,26,52,238, 146,212,229,179,38,125,237,117,59,7,19,131,126,147,40,74,6,62,63,226,136, 35,198,60,241,196,19,118,171,213,74,126,126,62,123,247,238,181,90,173, 86,58,118,236,200,209,71,31,77,183,110,221,146,230,204,153,115,203,222, 189,123,15,3,198,146,0,73,192,144,33,67,46,222,176,97,195,219,143,62,250, 168,53,61,61,157,69,139,26,254,183,88,92,92,204,234,213,171,233,215,175, 31,187,118,237,98,215,174,93,13,30,179,107,215,46,74,75,75,217,188,121, 115,4,74,221,72,230,93,188,22,8,254,186,97,104,10,179,25,63,16,252,13, 255,123,254,221,81,10,2,193,95,55,148,102,160,252,219,204,224,111,24,193, 251,251,223,243,7,127,67,41,140,202,115,152,193,63,176,45,241,91,189,35, 206,12,254,183,61,97,6,255,247,159,199,120,237,225,183,49,187,0,18,81, 167,228,212,140,95,38,92,123,87,183,83,207,191,52,105,241,166,34,74,92, 222,125,118,202,47,117,179,112,67,33,255,184,241,190,228,110,61,122,245, 127,227,153,7,22,187,93,229,163,128,173,177,47,114,157,182,1,87,215,216, 86,179,37,210,199,190,129,184,176,150,109,91,217,183,110,145,60,87,179, 211,190,3,255,186,233,114,90,219,146,59,96,79,233,14,154,149,91,175,252, 51,243,164,177,28,185,98,13,71,182,203,65,107,147,3,57,217,144,211,26, 62,248,20,247,29,143,144,220,148,107,38,106,2,16,82,240,247,120,13,220, 94,159,214,115,216,201,218,166,101,179,123,20,237,218,120,141,97,120,95, 137,119,225,155,224,201,35,142,56,98,204,235,175,191,158,92,90,90,170, 2,193,127,239,222,189,20,20,20,144,159,159,31,120,105,237,218,181,163, 162,162,226,168,178,178,178,127,17,255,65,105,35,55,110,220,248,223,137, 19,39,90,7,14,28,136,199,211,112,62,82,82,82,194,186,117,235,232,213,171, 23,169,169,169,33,29,3,176,96,193,2,86,175,94,205,144,33,67,154,90,230, 38,49,252,77,243,129,0,174,148,217,39,31,8,254,149,219,42,247,175,10,254, 186,82,129,100,161,90,240,15,140,15,32,112,110,189,230,185,20,129,224, 239,243,159,107,63,11,255,26,240,138,229,182,39,46,179,92,126,183,25,252, 159,188,245,29,224,74,18,179,223,124,64,106,90,198,207,119,62,250,82,171, 163,70,159,96,221,178,183,156,156,76,59,57,153,118,0,138,202,204,68,32, 59,61,169,242,128,221,197,21,156,124,214,133,182,118,157,186,116,121,252, 206,43,150,184,202,75,143,37,113,154,218,173,64,166,255,243,18,154,126, 179,117,61,230,63,145,87,155,120,158,222,192,135,254,207,47,4,214,54,241, 124,241,48,248,168,67,233,222,166,181,134,205,222,1,128,100,71,47,64,163, 207,129,171,180,190,189,146,176,90,179,177,218,115,176,37,181,198,227, 218,194,206,221,59,156,192,158,166,92,52,17,19,128,81,246,228,212,169, 87,221,253,108,72,193,223,227,209,53,143,79,209,251,216,203,29,11,254, 247,192,131,24,222,215,105,158,173,0,3,28,14,199,165,79,60,241,132,189, 129,224,79,65,65,1,5,5,5,56,28,14,202,202,202,174,2,254,11,172,142,83, 185,3,205,254,97,247,249,159,121,230,153,205,162,207,191,166,220,61,37, 150,215,254,247,91,82,160,217,95,41,88,241,215,14,155,2,140,47,231,165, 4,238,214,51,146,173,182,192,96,191,247,62,155,155,20,104,246,87,10,214, 109,216,105,83,10,166,77,95,152,172,48,3,126,43,71,146,117,79,126,153, 166,148,226,211,169,243,147,2,205,254,74,193,214,45,187,172,10,48,140, 229,24,128,97,24,218,134,116,187,86,80,88,222,92,6,242,54,149,6,188,106, 185,237,137,107,106,4,255,43,72,204,224,127,152,213,102,255,249,208,17, 99,83,75,75,203,249,110,234,231,213,222,236,63,120,56,173,51,90,1,96,247, 22,242,231,210,5,149,239,249,135,196,91,14,29,49,182,245,31,63,205,248, 195,231,117,143,6,230,199,170,224,245,56,24,115,228,61,192,16,154,150, 152,140,3,158,247,127,190,22,179,105,191,177,28,192,176,160,207,155,147, 148,14,109,184,33,61,131,27,239,185,158,182,86,91,54,22,75,213,77,125, 178,227,32,146,146,187,96,177,166,84,59,200,85,178,148,188,61,120,104, 98,55,81,162,37,0,254,59,255,231,195,8,254,6,110,159,79,75,105,213,67, 75,206,106,159,234,220,187,229,84,224,203,120,87,164,17,46,57,235,172, 179,170,53,251,215,21,252,3,159,119,239,222,157,221,187,119,219,128,139, 129,255,139,67,153,247,147,62,255,234,20,160,252,119,223,129,59,255,202, 59,119,2,93,1,134,166,148,181,106,127,32,16,252,13,165,180,192,16,255, 64,240,87,65,231,6,243,156,129,115,41,170,159,223,8,116,57,196,162,178, 137,161,185,5,127,0,183,238,243,188,248,235,204,175,248,117,230,87,53, 223,27,121,253,63,159,25,209,127,228,105,0,44,157,247,43,175,60,118,251, 111,192,156,186,206,21,197,114,198,67,111,204,145,252,129,248,243,49,112, 4,141,191,115,223,13,60,25,244,121,115,144,222,177,61,183,100,164,241, 143,27,46,165,211,249,167,145,106,179,66,82,114,199,125,118,172,25,252, 13,195,133,97,56,217,181,27,31,77,172,111,34,37,0,97,53,251,7,7,127,183, 199,208,246,108,89,78,69,209,46,13,115,254,104,115,112,10,240,31,255,231, 55,1,99,134,13,27,102,13,53,248,123,189,94,188,94,175,134,217,39,58,54, 14,229,223,47,131,63,64,199,54,25,234,170,243,143,242,6,15,248,11,220, 249,159,119,234,97,21,129,110,129,78,25,201,201,75,215,108,183,40,20,19, 206,60,194,27,60,224,47,112,231,63,110,220,80,79,160,123,224,128,156,212, 164,63,215,229,86,142,246,15,30,240,23,184,243,63,244,168,1,190,64,183, 65,255,246,105,182,57,147,211,44,59,227,252,253,136,178,230,24,252,1,150, 249,95,181,153,8,140,168,177,237,7,98,55,149,181,177,54,99,14,212,11,124, 222,24,173,128,111,252,31,107,110,59,2,179,143,63,92,185,152,3,162,155, 133,142,109,184,178,117,107,30,188,251,122,218,157,52,150,36,171,45,141, 36,123,59,108,246,246,88,237,109,27,60,222,231,217,11,64,81,137,57,3,185, 41,101,73,148,4,160,17,205,254,85,193,127,239,182,149,172,158,246,180, 211,240,185,79,163,249,172,9,240,58,208,201,255,249,255,128,114,135,195, 161,133,26,252,1,246,238,221,27,56,87,183,24,151,125,191,13,254,80,117, 215,94,109,192,31,84,27,212,167,27,170,234,14,189,198,120,1,195,255,94, 224,28,134,127,192,159,242,223,214,171,160,115,5,15,248,51,130,142,55, 175,27,159,250,199,80,115,13,254,45,85,17,240,73,19,142,183,97,222,237, 247,174,229,189,64,171,192,120,204,193,127,225,136,244,216,132,168,42, 42,103,249,192,126,36,157,50,206,154,148,150,61,2,171,173,85,195,7,5,81, 122,25,0,135,244,35,101,253,86,78,43,42,98,159,38,166,80,89,26,123,96, 4,141,178,39,167,78,191,234,238,103,109,61,251,31,218,168,224,255,231, 55,79,6,130,255,172,120,87,166,145,108,64,86,126,126,190,45,212,224,15, 4,6,206,233,196,182,53,248,176,204,204,204,89,159,126,250,105,200,193, 127,215,174,93,204,152,49,131,241,227,199,55,251,224,15,248,131,244,190, 3,254,12,85,21,252,13,85,181,184,143,25,208,171,143,246,15,52,251,7,130, 191,174,155,221,2,85,131,0,141,106,3,254,2,205,254,129,224,175,171,234, 93,7,45,80,115,11,254,195,169,90,181,46,154,6,249,175,21,15,25,152,125, 247,227,252,159,135,235,5,255,177,117,9,30,23,16,142,131,49,231,254,23, 248,63,79,104,46,23,243,86,252,197,7,147,191,212,203,93,165,43,80,42,188, 124,39,57,173,15,54,123,59,30,189,139,54,237,91,243,34,208,174,177,101, 137,119,11,192,254,28,252,111,198,188,243,175,252,25,172,95,191,158,54, 109,218,132,20,252,237,118,187,242,120,60,21,152,9,192,182,24,150,251, 164,113,227,198,37,21,23,23,51,117,234,212,144,14,88,185,114,37,0,139, 23,47,102,241,226,197,33,95,40,112,92,34,114,216,172,182,182,233,246,202, 64,159,145,108,181,41,101,165,83,70,114,114,224,14,62,43,213,106,13,4, 232,140,20,155,181,123,118,74,229,104,255,86,142,36,43,152,205,254,202, 127,142,214,14,155,21,204,160,222,58,213,110,233,211,214,140,116,186,161, 180,13,233,118,77,1,253,219,167,217,2,9,68,251,12,123,75,29,0,216,220, 130,255,193,214,36,251,108,221,235,121,138,186,155,253,35,229,76,171,205, 126,151,238,243,28,14,172,136,242,181,106,58,16,248,222,255,121,99,6,1, 94,239,127,5,4,254,121,180,212,223,227,58,237,218,205,61,79,189,202,241, 163,134,23,30,220,83,155,135,35,251,72,180,144,239,199,45,56,50,135,163, 212,111,252,231,201,162,46,19,110,226,163,237,59,27,183,18,104,60,19,128, 253,57,248,3,124,6,92,128,153,4,88,193,188,227,29,58,116,104,184,193,31, 224,199,88,22,60,212,229,125,3,148,106,89,247,169,235,182,238,213,46,185, 111,138,21,255,207,77,81,181,180,239,210,53,219,43,255,21,43,96,195,214, 61,22,128,235,31,254,184,114,145,31,5,236,201,47,211,20,240,231,186,220, 164,224,165,131,183,108,223,107,1,184,247,233,207,81,96,85,6,154,2,10, 11,205,102,191,245,27,118,90,130,91,22,114,119,22,180,180,63,158,205,45, 248,119,77,77,203,248,105,240,240,17,169,127,252,28,155,199,49,28,54,114, 108,234,178,133,191,255,236,44,43,25,76,108,147,255,68,181,1,56,46,232, 243,230,192,183,109,7,103,92,118,27,115,102,124,184,183,163,86,188,0,71, 230,97,160,133,246,207,89,211,108,164,101,29,201,224,129,115,44,231,159, 94,58,116,242,231,92,183,107,119,248,211,41,227,213,5,176,191,7,255,128, 60,155,205,230,179,88,204,31,195,242,229,203,217,190,125,123,184,193,95, 7,222,143,121,201,19,68,105,105,41,52,161,9,172,49,20,160,27,40,159,129, 242,25,74,233,186,82,102,95,190,194,103,40,229,211,149,242,234,74,249, 116,3,148,166,80,154,210,13,133,110,190,239,239,34,80,254,117,3,12,124, 134,81,249,177,114,198,128,82,24,149,11,6,169,160,237,85,175,224,117,6, 90,136,230,22,252,51,147,83,211,127,186,247,169,55,179,135,142,56,174, 225,189,35,100,232,136,227,184,231,137,255,100,39,167,166,253,74,245,193, 116,209,182,2,243,121,0,173,137,125,235,67,125,74,49,7,81,254,224,255, 188,185,216,152,187,139,103,223,249,136,114,175,103,23,94,79,195,11,161, 213,148,148,210,141,187,175,35,179,125,27,254,73,213,146,241,33,139,71, 11,128,4,127,211,40,187,221,62,253,210,75,47,77,214,117,157,119,222,121, 7,93,215,249,227,143,63,232,210,165,75,101,2,208,64,240,7,115,105,206, 53,53,79,190,63,216,186,117,43,171,87,175,134,24,255,30,31,208,53,199, 120,225,190,115,221,78,175,87,153,43,246,193,228,47,231,219,149,130,243, 79,27,238,9,12,216,179,219,172,150,127,62,245,185,29,224,241,59,207,242, 150,184,125,134,161,204,233,128,95,78,93,152,164,128,147,79,28,234,11, 12,248,203,72,182,107,143,61,255,165,13,13,30,184,245,12,125,119,185,91, 41,255,35,135,190,251,97,137,85,41,24,59,118,176,110,248,7,0,182,77,183, 107,183,205,253,143,181,36,55,150,181,39,13,232,64,228,239,180,154,91, 240,183,219,83,211,191,187,232,186,187,186,13,63,106,180,245,155,79,63, 108,248,136,8,58,108,196,49,150,75,111,188,175,243,219,47,61,250,189,199, 85,62,18,168,136,193,101,117,26,55,74,63,218,178,169,106,1,248,30,115, 176,98,179,176,107,47,191,236,204,195,13,164,89,147,178,26,220,95,215, 203,241,186,119,224,243,228,161,251,10,217,149,167,120,250,53,242,139, 75,200,179,219,73,13,113,61,181,74,177,78,0,36,248,155,2,193,63,237,144, 67,14,33,45,45,141,204,204,76,94,120,225,133,202,21,242,148,82,248,124, 85,131,67,234,8,254,63,1,255,140,117,225,19,193,182,109,219,248,234,171, 175,232,211,167,15,75,150,44,137,109,8,4,156,94,175,42,116,233,190,192, 128,63,151,71,183,25,40,246,148,123,245,192,104,255,28,135,255,22,93,131, 18,183,207,216,94,236,214,3,3,254,138,43,124,202,0,54,23,186,245,192,104, 255,110,217,88,253,131,0,181,221,229,110,181,38,207,169,7,6,252,237,46, 245,88,20,176,60,183,84,233,10,101,40,197,128,14,25,241,104,193,155,208, 182,109,219,137,123,246,236,57,3,152,23,161,115,54,183,224,175,217,83, 211,167,140,59,245,252,193,39,159,123,105,210,246,124,103,204,11,176,109, 175,147,19,206,186,200,182,51,119,235,192,233,159,189,255,169,199,85,126, 26,209,255,94,117,194,156,178,12,240,34,230,244,187,68,208,131,170,39, 4,54,117,129,162,88,107,219,177,45,25,22,171,3,139,165,225,53,140,42,74, 151,225,243,238,97,203,14,120,250,117,246,252,177,136,237,121,123,184, 209,229,226,183,198,92,60,150,127,64,36,248,155,246,9,254,14,135,131,99, 143,61,150,7,30,120,0,171,213,138,215,235,173,22,252,109,54,91,109,205, 254,175,1,103,3,251,46,44,222,194,21,23,23,243,229,151,95,114,218,105, 167,145,149,213,112,214,28,113,42,180,181,253,3,77,244,129,39,250,53,180, 182,191,30,60,107,192,32,104,180,191,170,92,124,40,240,181,30,52,51,32, 198,124,135,30,122,104,135,142,29,59,126,10,28,30,129,243,53,183,224,79, 82,114,234,75,3,135,28,126,226,213,119,76,76,89,186,185,8,183,55,246,197, 244,248,12,150,108,42,228,178,155,238,77,30,52,252,232,49,73,41,142,55, 26,62,170,201,218,1,119,251,95,49,237,118,107,169,146,147,56,165,109,27, 146,108,73,109,170,109,55,140,10,116,111,81,181,109,202,240,226,243,230, 243,241,55,56,79,185,132,95,166,124,193,177,155,183,50,180,177,193,31, 98,215,2,32,193,223,84,107,240,79,75,75,35,45,45,141,241,227,199,147,153, 153,201,29,119,220,129,174,87,221,232,251,124,62,13,243,129,63,127,97, 14,248,123,159,253,180,217,191,184,184,152,85,171,86,113,254,249,231,211, 189,123,119,54,109,218,20,243,50,40,204,102,255,134,214,246,247,25,170, 114,68,143,129,106,112,109,255,224,21,255,170,174,225,223,223,223,236, 95,25,252,117,35,94,235,0,232,7,30,120,32,103,158,121,102,151,7,31,124, 240,211,157,59,119,158,7,252,209,200,115,53,187,224,111,179,37,223,217, 177,91,207,127,220,255,204,91,142,213,219,75,41,117,249,104,87,149,131, 142,192,12,142,13,169,185,8,80,163,142,45,171,240,177,106,91,41,255,124, 242,117,199,173,151,158,114,193,182,141,127,173,245,121,60,79,133,112, 142,198,114,82,245,32,158,216,55,123,212,45,48,54,1,154,184,48,78,140, 157,219,167,111,207,171,218,230,108,66,179,36,227,113,109,194,231,45,64, 247,22,96,24,78,64,35,53,99,144,249,96,32,192,231,221,141,97,24,60,255, 38,121,185,187,56,142,8,60,4,46,22,9,128,4,127,83,189,193,63,240,249,25, 103,156,65,90,90,26,215,94,123,109,181,36,0,179,239,245,9,224,139,248, 20,63,254,182,109,219,198,170,85,171,232,223,191,63,221,187,135,61,222, 37,98,118,231,151,90,38,127,57,223,30,104,246,175,107,109,255,52,187,213, 178,183,160,76,3,248,114,234,194,164,64,179,127,93,107,251,175,113,36, 105,133,254,181,253,191,251,97,137,53,208,236,175,12,165,229,237,216,107, 1,133,49,95,217,148,50,163,99,97,134,93,43,46,46,175,171,152,209,226,107, 213,170,21,227,198,141,163,115,231,206,93,174,184,226,138,143,27,153,4, 52,187,224,143,213,122,65,122,118,246,196,39,223,248,220,177,37,223,93, 237,145,190,135,12,31,201,149,119,62,30,152,35,223,160,67,134,143,172, 92,237,166,41,199,238,45,113,179,57,217,202,227,175,125,226,184,238,220, 99,30,44,41,220,179,77,215,245,41,97,212,42,28,107,169,122,20,111,34,73, 212,177,9,245,57,247,184,227,198,77,201,76,247,88,52,109,19,203,87,172, 35,191,16,246,22,192,206,60,92,121,249,184,254,118,154,106,221,251,128, 165,40,229,35,57,245,64,188,238,93,124,243,61,222,226,50,222,35,66,79, 128,141,118,2,32,193,223,20,82,240,15,124,236,209,163,7,54,155,205,173, 235,186,141,170,231,189,219,128,151,216,79,19,128,109,219,182,241,229, 151,95,210,191,127,127,178,179,179,227,93,28,243,142,191,129,181,253,131, 111,208,21,52,188,182,127,160,207,64,171,26,225,175,42,87,252,83,85,221, 9,4,22,25,82,160,98,62,135,90,47,43,43,35,63,63,159,126,253,250,241,223, 255,254,183,49,73,64,243,11,254,112,84,114,114,234,127,159,124,123,154, 163,204,151,196,214,61,85,55,154,69,229,30,114,50,114,24,54,238,188,122, 14,175,78,1,69,165,102,2,209,148,99,1,182,238,113,146,150,156,201,147, 111,79,115,220,244,183,209,111,233,206,178,45,192,239,33,159,176,249,235, 10,220,231,255,252,81,18,127,106,228,185,199,31,127,220,148,127,252,227, 31,214,95,127,153,193,115,239,244,39,47,47,95,237,204,203,251,210,229, 100,170,179,130,93,64,241,103,223,242,204,149,23,208,255,250,127,172,204, 80,202,192,231,205,227,153,255,176,107,215,110,158,137,84,65,162,153,0, 72,240,55,133,21,252,151,46,93,202,153,103,158,89,238,118,187,79,3,218, 2,147,136,255,130,77,113,21,8,254,167,157,118,26,219,182,197,255,223,118, 219,214,25,198,249,167,13,247,4,15,248,171,109,109,255,54,233,73,214,191, 214,231,90,52,205,28,237,31,60,224,175,182,181,253,123,182,78,177,110, 220,152,103,209,52,115,180,191,127,192,159,57,37,208,127,231,127,192,208, 190,122,96,60,193,224,142,233,214,249,31,165,169,24,63,253,196,103,177, 88,200,205,205,69,215,245,202,36,224,202,43,175,252,56,55,55,247,188,137, 223,173,223,224,243,120,14,5,122,105,154,106,13,160,148,86,96,81,214,181, 22,95,197,162,137,103,13,218,67,243,11,254,245,50,12,240,234,225,23,221, 240,31,210,148,99,107,138,242,204,208,68,125,236,110,14,112,149,255,243, 215,72,236,4,224,220,227,143,63,126,202,101,151,93,106,245,122,189,12, 59,244,104,254,92,189,213,88,185,250,207,139,129,201,193,59,110,207,229, 200,55,62,224,182,47,191,227,206,55,159,254,179,253,230,109,24,197,101, 124,9,148,69,170,48,209,10,44,18,252,77,141,10,254,229,229,229,193,245, 246,0,47,251,63,191,38,62,213,136,159,224,224,223,189,123,247,132,72,0, 2,119,243,13,174,237,175,155,99,0,2,43,253,133,186,182,191,50,183,105, 129,209,254,149,75,13,7,95,195,191,127,28,134,1,232,86,171,217,40,149, 151,151,7,64,191,126,253,120,243,205,55,187,92,123,195,141,95,47,255,254, 139,153,253,143,62,41,95,179,104,86,148,57,200,88,211,104,99,40,223,129, 36,37,141,25,126,234,133,3,23,247,62,100,188,118,89,179,11,254,191,187, 221,174,43,238,190,244,228,55,95,251,116,118,90,183,182,14,182,238,49, 187,193,91,103,216,247,121,164,111,67,234,123,28,112,168,199,22,150,155, 173,192,221,218,58,72,183,121,185,238,178,147,157,62,183,235,10,162,119, 247,159,168,143,221,77,212,177,9,53,157,123,226,137,39,76,185,252,242, 203,172,230,64,111,47,31,126,248,161,49,123,246,236,125,130,191,159,218, 177,155,103,118,236,230,155,51,175,224,83,11,116,216,158,203,195,145,44, 80,52,18,0,9,254,166,72,4,127,48,155,252,247,235,102,255,64,240,79,36, 193,193,187,174,181,253,13,127,179,189,70,245,224,223,208,218,254,26,65, 15,27,10,12,248,35,48,155,192,159,44,248,175,27,7,149,11,87,65,245,36, 224,181,151,95,106,115,195,45,183,159,110,75,73,153,221,231,240,177,69, 160,153,59,42,101,88,44,154,119,195,162,57,227,218,156,116,97,191,33,67, 142,98,201,7,47,52,167,224,111,210,245,41,101,197,69,93,238,190,234,172, 7,95,120,255,219,180,10,143,94,57,14,32,132,71,250,6,11,247,113,192,117, 30,219,38,51,153,30,57,41,220,122,233,41,206,210,162,130,135,162,216,255, 15,230,179,231,223,8,250,60,81,36,234,216,132,96,231,158,120,226,137,83, 174,188,242,114,171,255,73,174,124,240,193,100,99,214,172,159,234,10,254, 193,214,110,219,193,80,204,231,64,236,109,96,223,176,68,58,1,144,224,111, 138,84,240,79,56,14,135,163,221,238,221,187,89,181,106,85,200,199,4,130, 68,112,224,104,72,110,110,46,95,124,241,5,103,156,113,6,221,186,197,250, 97,135,13,179,219,172,150,28,135,57,6,192,103,40,45,205,110,181,40,204, 102,127,229,15,254,14,187,205,108,1,0,50,146,237,90,183,108,172,186,127, 12,192,26,71,146,166,148,217,236,31,72,32,178,29,73,26,74,129,166,209, 54,221,174,13,232,144,97,49,12,115,180,127,97,134,93,3,197,160,142,233, 149,251,119,200,76,170,28,123,16,67,149,45,0,1,193,73,192,203,207,63,147, 118,227,173,119,140,177,88,109,75,122,13,59,218,236,40,215,52,125,199, 95,203,251,87,116,233,209,51,249,192,1,180,91,62,159,161,43,23,252,184, 160,57,5,127,63,159,207,253,244,206,173,155,186,63,114,251,229,151,62, 248,252,187,14,151,167,218,64,221,80,31,233,59,145,198,63,14,184,242,216, 244,20,27,3,186,102,240,232,29,87,58,183,111,222,48,197,231,139,234,12, 0,48,155,214,175,142,242,53,90,162,115,199,143,63,113,202,85,87,93,233, 15,254,62,222,127,127,146,49,107,214,172,80,130,127,128,143,170,86,142, 136,137,100,2,32,193,223,212,98,131,127,128,97,24,213,86,40,108,72,96, 54,67,56,199,0,156,122,234,169,9,25,252,55,111,207,55,87,248,11,106,130, 15,140,246,255,107,125,174,5,170,182,111,207,45,176,0,60,246,252,151,182, 192,54,5,20,22,150,107,40,216,184,49,175,106,127,165,216,149,87,168,1, 60,245,210,55,214,192,51,20,20,80,226,31,237,191,101,243,110,45,248,252, 123,118,23,198,122,16,160,175,182,68,46,56,9,120,241,217,167,83,111,190, 253,174,97,142,172,236,191,58,245,58,196,89,176,125,99,15,111,187,142, 29,236,157,123,226,221,252,23,105,121,219,215,13,189,234,222,63,143,187, 242,158,182,143,159,126,112,94,140,203,223,100,94,183,235,198,149,75,230, 117,248,207,191,31,60,249,202,219,30,74,201,47,139,200,128,236,176,216, 109,22,134,244,108,197,219,47,62,86,177,108,193,175,179,188,21,206,171, 26,62,170,201,18,245,177,187,137,58,54,1,224,220,147,78,26,63,229,234, 171,175,174,12,254,239,189,247,190,241,227,143,63,134,19,252,163,38,82, 9,192,81,246,228,148,233,87,255,223,243,182,30,125,135,134,29,252,247, 108,89,206,234,105,79,59,13,159,251,20,224,231,8,149,41,30,90,124,240, 119,58,157,187,59,116,232,192,224,193,131,67,62,102,197,10,115,217,240, 131,15,14,239,73,157,137,252,52,192,192,250,252,230,23,213,31,253,187, 207,72,44,5,62,85,125,142,191,225,63,64,55,2,231,9,172,247,111,126,229, 241,25,213,206,161,27,230,123,30,221,168,118,158,68,104,1,8,200,203,203, 35,57,57,153,126,253,250,209,187,87,47,171,199,229,204,42,43,216,221,77, 207,206,201,182,231,180,67,203,221,138,163,96,207,182,142,131,14,95,162, 105,42,85,195,114,4,52,254,89,230,113,164,60,174,178,11,127,248,230,227, 159,59,117,237,113,232,57,19,174,76,90,18,227,2,116,109,227,224,203,41, 239,250,166,127,246,254,42,143,171,252,92,98,211,146,114,48,16,168,106, 34,173,184,151,168,99,19,206,61,249,228,147,166,92,115,205,53,149,205, 254,239,190,251,158,241,195,15,63,36,68,240,135,8,37,0,142,180,204,87, 222,127,100,88,106,235,214,83,217,228,209,125,219,244,193,134,4,255,150, 23,252,19,81,141,181,18,98,162,91,231,214,198,3,183,157,233,45,247,248, 84,160,207,127,234,244,69,73,74,193,137,199,15,245,154,219,12,45,45,201, 170,253,251,229,111,146,12,224,250,171,199,251,74,220,134,82,186,194,64, 105,179,127,94,110,85,40,142,28,117,136,30,24,56,152,110,183,106,239,188, 253,157,77,41,56,111,194,56,189,196,173,171,64,159,255,178,185,171,44, 10,232,123,104,63,21,88,133,48,51,197,198,174,185,255,177,148,133,255, 12,145,166,168,181,5,0,204,46,30,135,195,193,186,117,235,84,190,215,234, 62,248,192,1,109,189,73,73,142,228,180,12,60,133,123,73,46,47,217,211, 250,160,1,107,209,180,36,133,150,100,213,84,127,154,103,2,0,224,241,184, 202,78,252,224,213,167,22,117,239,217,171,39,85,211,117,99,98,254,156, 159,140,119,94,122,116,135,199,85,126,28,177,121,14,64,77,151,18,185,165, 128,67,89,0,169,62,153,192,108,96,35,16,227,73,49,117,58,247,228,147,79, 158,114,221,117,215,86,6,255,119,222,121,199,248,254,251,239,19,38,248, 67,100,18,128,193,93,219,39,245,57,48,107,155,69,211,13,90,235,171,236, 29,212,80,227,55,223,165,94,175,55,165,193,102,127,127,240,63,141,230, 29,252,143,76,74,74,154,113,217,101,151,57,14,62,248,224,6,131,255,162, 69,139,56,251,236,179,203,157,78,103,115,79,122,226,106,243,230,205,204, 155,55,175,28,248,54,150,215,53,148,210,202,61,62,181,187,204,91,185,182, 127,153,91,87,6,144,91,234,49,252,3,254,84,251,244,36,139,129,191,9,223, 109,168,157,197,110,195,63,224,79,149,84,248,44,10,216,86,88,81,57,213, 175,83,86,50,84,238,175,171,109,69,21,202,63,224,79,21,85,248,80,74,177, 213,220,134,161,160,115,166,221,18,135,113,128,190,186,90,0,218,181,107, 135,197,98,225,181,255,190,167,31,50,254,111,86,75,170,35,37,217,150,132, 199,89,142,213,227,46,73,235,212,125,27,40,43,96,213,148,178,98,177,228, 196,182,232,17,87,226,118,149,141,125,252,238,171,150,12,30,62,34,102, 117,89,252,219,247,44,91,240,123,161,219,85,62,138,216,46,128,179,25,248, 228,200,177,167,28,53,118,252,25,35,52,139,181,73,217,183,179,172,116, 61,128,35,61,227,172,166,22,108,246,119,95,103,252,58,243,139,159,73,140, 231,19,156,123,234,169,167,76,185,254,250,235,42,131,255,219,111,191,109, 204,156,153,88,193,31,34,144,0,164,164,166,223,125,211,132,67,146,52,182, 84,110,235,172,45,182,156,144,148,107,255,218,117,147,94,234,109,165,90, 120,159,63,41,41,41,55,30,127,252,241,18,252,99,104,235,214,173,124,248, 225,135,101,30,143,231,52,96,126,76,47,174,194,91,219,31,5,74,87,33,172, 237,175,42,215,246,15,30,237,111,78,3,84,254,199,16,7,158,63,96,104,42, 62,195,231,244,218,90,0,236,118,59,57,57,57,204,155,63,95,149,38,183,242, 29,216,245,160,20,108,73,224,243,98,243,122,92,59,183,111,44,41,217,147, 155,218,169,215,192,170,21,116,226,84,129,8,219,230,42,47,29,51,127,206, 172,72,61,24,169,65,243,231,204,114,233,62,207,24,98,63,223,189,8,248, 243,248,211,206,235,60,232,200,49,29,10,74,221,238,134,14,104,64,96,80, 80,70,83,78,210,58,35,57,217,106,181,238,250,117,102,66,76,150,58,247, 212,83,79,157,114,227,141,215,87,6,255,183,222,122,203,248,238,187,153, 9,23,252,161,233,9,64,155,100,171,239,244,195,187,239,222,231,150,32,203, 178,75,59,37,227,5,235,228,221,183,234,30,79,74,139,13,254,0,154,166,29, 209,183,111,223,144,154,253,207,57,231,156,114,167,211,217,220,91,60,226, 170,168,168,136,95,126,249,37,16,252,127,138,245,245,21,213,131,127,93, 107,251,27,152,1,221,92,55,160,198,188,254,186,214,246,247,103,0,129,59, 127,93,129,79,249,167,12,6,18,15,127,146,17,184,110,140,213,218,5,208, 169,83,39,60,30,15,111,79,254,88,239,118,198,181,41,190,180,116,84,121, 25,101,91,215,187,150,127,247,177,158,109,113,119,88,183,126,125,187,35, 39,220,90,118,192,144,17,133,74,211,116,13,149,72,83,201,154,98,133,238, 243,140,38,66,203,179,54,224,11,221,231,153,134,185,254,125,220,20,148, 186,221,171,182,149,38,196,186,251,3,186,86,14,76,140,183,115,79,59,237, 212,41,55,221,116,99,101,240,127,243,205,255,26,51,102,124,151,144,193, 31,154,152,0,216,108,246,107,175,248,219,96,139,141,221,181,142,68,110, 101,205,211,78,200,154,100,253,160,236,50,163,165,6,127,32,197,227,241, 116,233,213,171,87,181,128,47,125,254,209,81,84,84,196,146,37,75,60,186, 174,199,37,248,3,184,42,60,76,157,190,40,41,208,236,95,215,218,254,233, 41,54,173,184,176,92,83,192,236,159,151,91,3,205,254,117,173,237,159,155, 98,213,74,75,204,117,76,150,205,93,101,9,52,251,43,160,36,175,64,51,23, 8,90,107,13,60,93,208,149,98,195,85,230,210,44,246,180,108,195,19,179, 103,2,236,51,8,48,51,51,147,140,140,12,190,158,58,77,105,189,135,219,108, 221,15,162,100,235,6,182,205,254,186,34,181,124,119,210,131,55,93,150, 210,167,79,31,109,205,154,53,220,112,235,237,7,251,188,222,226,222,135, 141,206,215,149,241,103,172,10,29,3,161,175,228,211,52,203,98,116,29,17, 158,115,79,63,253,180,41,55,223,124,83,101,240,127,227,141,55,141,233, 211,103,36,108,240,135,166,37,0,54,205,98,189,249,228,67,177,215,183,83, 47,199,74,173,71,202,74,203,242,130,222,180,192,224,15,48,168,77,155,54, 174,172,172,172,36,25,240,23,93,91,183,110,101,217,178,101,78,93,215,111, 36,78,193,31,168,28,245,223,208,218,254,193,183,231,129,125,234,91,219, 191,106,38,65,224,189,170,21,6,43,223,11,90,48,40,62,235,0,85,111,1,176, 88,44,116,236,216,145,162,162,34,62,251,249,15,173,253,165,255,100,203, 15,159,97,172,158,235,253,199,249,103,37,31,113,248,225,154,97,24,148, 148,148,152,235,4,60,247,76,202,245,183,220,118,164,207,227,41,60,120, 236,169,141,125,138,160,16,137,228,220,51,206,56,125,202,205,55,223,108, 245,249,124,120,189,62,94,127,253,13,227,219,111,167,39,116,240,135,166, 37,0,103,142,59,170,91,74,235,164,218,239,254,131,141,204,254,69,155,181, 204,163,90,96,240,7,56,162,119,239,222,182,186,238,252,165,207,63,50,182, 110,221,202,164,73,147,202,189,94,239,169,196,51,248,3,41,41,118,78,60, 126,168,55,104,192,95,173,107,251,119,204,176,91,55,109,202,179,40,5,71, 142,58,68,15,30,240,87,115,109,127,67,41,186,100,37,91,114,183,239,177, 42,165,232,123,104,63,21,60,224,47,112,231,159,211,239,64,35,240,24,226, 110,217,169,172,254,42,149,34,79,121,81,12,171,95,173,5,32,39,39,7,187, 221,206,135,159,124,234,46,77,202,72,54,222,121,156,51,71,28,106,140,191, 228,145,164,148,148,20,242,243,243,201,203,203,195,48,12,218,183,111,31, 72,2,210,174,189,254,198,49,159,61,121,107,79,18,103,212,118,164,13,2, 78,172,227,189,112,31,7,60,3,185,243,79,84,231,158,121,230,25,83,110,185, 229,22,127,240,247,242,218,107,175,27,223,126,251,109,194,7,127,104,66, 2,144,236,72,191,247,226,83,58,165,18,52,248,175,54,6,26,69,197,165,129, 59,255,150,22,4,143,73,78,78,126,252,140,51,206,112,4,247,253,91,173,86, 254,250,235,47,150,45,91,198,67,15,61,36,193,191,137,2,193,223,227,241, 196,61,248,67,208,146,191,13,173,237,95,109,127,127,95,127,29,107,251, 155,207,2,80,213,230,247,87,27,240,167,130,199,0,168,202,235,198,115,12, 128,205,102,163,93,187,118,228,230,230,178,112,209,178,237,167,13,29,212, 229,244,147,199,39,183,106,213,202,82,90,90,202,218,181,107,241,120,170, 186,197,243,242,242,176,90,173,244,239,223,159,215,94,121,169,205,21,87, 92,241,241,174,93,187,206,3,98,54,128,46,134,146,173,54,251,131,131,134, 143,72,29,54,242,184,125,222,12,229,113,192,139,231,124,207,210,133,191, 185,116,175,39,238,191,243,162,86,231,158,121,230,153,83,110,187,237,214, 202,224,255,234,171,175,25,211,166,77,107,22,193,31,26,159,0,12,238,208, 218,222,187,79,171,237,117,174,237,234,214,147,249,101,93,166,241,230, 103,235,60,27,119,236,90,99,248,220,215,211,178,30,81,57,34,57,57,121, 218,67,15,61,228,24,58,116,40,155,54,109,226,203,47,191,116,46,95,190, 220,183,125,251,118,71,122,122,250,86,165,212,60,167,211,249,34,48,55, 222,133,109,174,182,110,221,202,228,201,147,157,137,18,252,3,116,101,78, 245,171,127,109,255,170,69,126,234,90,219,95,15,60,216,199,31,236,149, 63,3,8,14,254,102,176,39,48,11,64,51,12,115,97,33,255,179,0,98,254,56, 224,224,22,0,195,48,104,215,174,29,247,222,113,243,129,129,129,128,91, 182,108,161,164,164,246,241,97,185,185,230,44,173,254,253,251,243,223, 255,254,183,219,149,87,94,249,233,206,157,59,207,161,229,37,1,243,117, 159,103,248,234,229,11,127,58,229,188,75,90,31,117,204,9,214,220,2,23, 30,159,153,22,42,106,127,28,176,221,102,161,83,235,84,22,252,241,139,49, 233,213,127,21,233,94,207,177,36,206,130,59,162,202,185,103,159,125,214, 148,219,111,191,205,234,243,249,240,249,188,188,242,202,171,198,212,169, 83,155,77,240,135,70,38,0,41,169,105,119,95,255,247,65,201,150,90,238, 254,119,187,90,241,205,124,60,239,124,182,202,112,121,181,31,116,143,235, 49,90,102,0,60,238,140,51,206,112,28,113,196,17,172,94,189,154,219,110, 187,173,220,229,114,221,135,153,228,44,47,42,42,138,199,226,28,45,138, 127,170,95,133,219,237,62,133,4,10,254,10,69,90,146,85,107,159,158,100, 209,253,163,253,211,83,108,26,202,108,246,55,239,236,21,233,246,36,45, 112,71,159,110,183,106,157,178,146,43,159,226,151,155,98,213,148,130,174, 89,201,150,192,66,64,25,201,85,207,14,200,76,177,153,243,252,253,163,253, 93,41,54,20,208,45,59,181,242,137,131,153,41,86,45,246,13,0,85,45,0,62, 159,143,141,27,55,114,192,1,7,208,161,67,7,118,237,218,69,126,126,62,70, 93,207,170,245,171,145,4,116,185,226,138,43,62,221,185,115,231,121,64, 75,27,19,176,202,85,94,58,248,201,123,111,248,121,194,181,119,117,63,245, 252,203,236,75,55,21,81,226,170,190,36,118,126,169,217,74,146,158,98,99, 200,1,173,152,246,217,135,222,55,254,125,255,14,119,133,115,52,176,53, 14,229,22,245,59,251,236,179,207,158,114,231,157,183,87,222,249,191,244, 210,203,250,55,223,124,243,119,224,163,120,23,46,28,141,73,0,218,88,240, 157,62,170,87,126,229,221,191,66,99,213,222,78,234,253,105,187,92,179, 230,174,244,26,62,253,101,195,240,61,79,132,159,92,148,104,214,175,95, 207,228,201,147,153,52,105,82,185,203,229,218,111,154,249,215,172,89,195, 151,95,126,25,242,254,187,118,153,75,213,109,216,176,33,228,99,188,94, 47,95,127,253,181,167,162,162,226,68,204,85,190,18,198,150,181,171,181, 187,46,57,51,41,104,154,63,69,133,230,179,0,230,127,146,166,5,6,4,42,208, 242,118,21,106,10,197,83,11,222,178,42,168,76,8,74,253,107,251,47,251, 34,205,90,57,160,79,65,193,30,115,109,255,188,5,111,153,207,8,240,95,196, 89,90,174,1,172,249,198,17,184,166,166,20,20,110,249,43,22,85,14,86,173, 5,192,237,118,179,110,221,58,192,76,8,66,21,72,2,250,245,235,23,72,2,62, 110,161,73,64,174,219,85,118,216,7,175,61,249,253,142,45,27,6,94,119,215, 163,41,127,238,40,173,124,138,96,64,78,70,50,7,119,203,228,191,207,63, 226,158,241,197,164,191,60,21,206,177,36,214,19,247,132,223,160,65,135, 188,122,207,61,119,85,142,246,127,225,133,23,245,175,191,110,126,193,31, 26,145,0,216,108,182,107,47,62,103,136,37,85,219,173,57,245,116,126,89, 159,163,191,62,101,169,123,199,238,220,109,94,183,235,113,96,10,85,11, 60,180,100,95,44,90,180,40,101,209,162,69,0,95,210,50,91,57,106,243,238, 242,229,203,83,150,47,95,30,242,1,14,135,163,45,128,211,233,220,19,230, 181,62,39,214,139,252,52,236,73,103,105,177,111,213,130,234,79,110,181, 218,211,90,1,236,92,95,94,88,219,65,37,59,106,63,89,93,223,144,210,240, 214,51,123,38,172,189,155,102,159,117,0,194,9,252,193,130,147,128,135, 31,126,184,203,3,15,60,208,82,147,128,34,143,171,124,196,172,111,63,249, 40,111,199,214,227,31,120,246,29,71,90,138,141,77,121,102,18,216,37,199, 193,1,109,147,121,228,142,203,157,203,230,207,249,197,83,81,126,22,224, 138,111,145,69,93,148,50,127,231,189,94,47,207,61,247,66,179,13,254,16, 126,2,96,195,146,116,243,192,3,51,236,175,252,128,123,210,151,75,148,215, 176,252,224,115,183,216,102,254,250,44,99,255,28,153,187,25,184,39,156, 3,156,78,103,116,74,18,31,51,252,175,106,244,216,205,195,143,55,159,199, 227,169,108,234,15,188,116,93,175,243,235,192,231,117,237,147,150,150, 70,113,113,49,135,30,122,104,151,185,115,231,126,190,103,207,158,81,192, 250,120,87,52,194,60,30,151,243,172,149,75,230,62,115,243,197,227,175, 122,242,205,47,210,82,186,152,235,215,164,39,233,220,242,143,83,203,119, 108,222,48,201,235,118,94,71,51,123,68,242,254,102,249,242,229,151,95, 121,229,213,111,41,165,88,181,106,213,117,192,103,241,46,83,99,133,59, 128,232,84,224,107,91,82,74,190,161,124,207,27,62,223,235,180,240,102, 126,33,68,53,54,160,53,144,132,249,0,28,91,208,171,161,175,67,217,199, 10,188,13,180,216,140,202,102,75,190,45,61,43,235,209,39,223,153,150,106, 209,44,220,117,217,201,206,210,194,130,231,124,62,207,125,241,46,91,8, 6,189,249,229,239,183,105,233,237,134,39,206,74,128,25,153,170,108,247, 130,43,207,56,234,89,246,207,155,178,152,73,197,76,2,34,245,24,97,33,132, 216,239,88,173,214,191,37,59,210,203,147,29,233,229,86,171,245,111,241, 46,143,16,66,8,33,98,231,72,255,75,8,33,132,16,66,8,33,132,16,66,8,33, 132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66, 8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16, 66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132, 16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33, 132,16,66,132,69,139,119,1,132,104,161,14,7,142,137,209,181,62,2,54,199, 232,90,34,124,54,160,61,208,25,104,7,100,249,183,165,99,254,13,46,5,116, 160,24,216,13,228,2,187,0,111,60,10,219,128,95,129,145,53,182,149,99,214, 37,88,59,32,175,142,115,60,14,252,179,198,182,199,128,123,235,216,191, 61,230,247,37,88,25,144,86,99,219,28,96,84,29,231,16,181,176,197,187,0, 66,180,64,199,56,146,83,103,142,27,122,108,146,213,98,137,234,133,150, 172,91,206,230,221,155,83,129,137,81,189,144,8,71,111,96,108,122,106,250, 72,13,109,152,199,231,233,156,225,200,240,117,105,219,69,117,204,238,144, 148,145,154,110,181,88,109,86,135,221,97,81,10,92,21,78,229,51,188,222, 18,103,169,202,43,220,237,221,81,176,93,43,113,150,216,172,150,164,92, 48,150,184,60,174,57,192,79,192,170,56,215,11,246,13,254,137,36,145,203, 150,144,36,1,16,34,178,70,57,146,29,51,239,58,255,246,164,131,123,14,136, 234,133,54,108,221,206,134,77,59,104,102,55,255,86,160,27,208,5,200,6, 44,152,119,190,185,152,21,241,196,171,96,77,212,37,197,158,114,117,146, 53,105,66,90,114,90,214,216,33,199,56,250,116,233,157,220,46,187,29,153, 142,76,44,22,179,177,85,41,0,85,219,71,187,249,190,2,192,235,243,81,88, 90,212,123,103,126,94,239,13,185,235,207,252,109,245,111,206,210,138,210, 82,67,25,255,243,248,60,175,1,155,226,80,199,96,13,181,30,239,14,97,159, 96,255,100,223,86,129,250,212,108,113,80,97,28,27,9,118,224,17,224,34, 255,181,63,0,30,160,153,253,254,74,23,128,16,145,51,202,145,236,248,49, 86,193,127,249,202,181,44,223,177,136,229,185,139,30,34,177,91,0,114,44, 22,203,57,153,169,153,23,120,117,239,193,89,105,89,122,219,204,182,154, 195,238,176,161,161,185,42,92,190,189,101,123,141,194,178,66,155,205,98, 91,95,225,169,248,196,237,115,79,1,182,199,187,224,33,104,149,150,146, 246,140,213,106,61,243,204,163,78,119,140,28,112,148,61,43,61,11,148,50, 35,146,255,99,32,176,215,147,0,248,223,87,251,124,84,128,97,24,236,46, 216,203,252,213,11,188,51,151,125,87,174,43,125,70,133,183,226,38,96,79, 236,170,106,22,201,255,49,209,98,71,172,203,245,4,112,119,141,109,79,2, 247,196,232,250,17,145,104,63,68,33,154,171,152,7,127,32,209,19,128,110, 233,41,233,247,91,44,150,51,135,247,58,52,101,240,1,67,210,186,181,237, 138,213,98,51,3,91,141,151,110,232,236,200,207,101,229,150,149,21,11,54, 44,40,247,233,222,95,203,92,101,247,3,43,227,93,145,58,244,75,75,73,251, 254,172,17,167,183,57,229,240,241,201,22,171,109,159,192,31,169,4,160, 234,124,80,238,114,241,237,188,153,222,89,43,102,230,187,117,247,73,192, 146,152,212,214,95,68,255,71,13,96,229,234,37,115,99,120,237,125,12,236, 55,228,8,255,167,177,78,0,114,129,142,53,182,237,170,101,91,66,147,46, 0,33,154,46,46,193,63,129,89,83,237,169,119,218,147,236,183,159,52,252, 164,236,35,250,28,110,75,178,38,249,3,61,181,6,127,51,224,105,116,106, 221,153,142,173,58,165,140,57,120,108,202,138,45,203,79,159,177,100,198, 209,110,111,197,100,167,219,121,55,224,138,119,197,130,100,101,164,102, 76,255,191,191,221,213,169,119,151,131,52,136,93,27,180,35,53,133,179, 71,159,154,116,96,135,158,29,222,252,225,141,169,110,95,197,16,246,29, 36,39,162,171,182,31,119,172,187,33,154,44,150,9,64,36,70,69,203,104,103, 145,104,36,248,87,215,38,61,53,253,179,126,93,251,13,254,219,209,231,103, 58,146,29,65,65,190,238,224,111,212,120,223,162,89,56,164,251,32,173,111, 167,126,173,191,95,54,243,138,37,155,22,31,91,238,46,63,21,216,24,239, 10,250,157,60,102,208,209,109,250,116,237,165,5,238,208,99,73,67,99,80, 159,129,140,221,53,182,205,244,165,223,158,3,188,26,163,75,95,29,163,235, 132,43,214,229,250,128,125,187,0,236,152,45,0,59,99,92,150,70,139,85,2, 112,140,195,102,155,118,197,128,1,14,91,35,71,69,151,109,217,194,27,5, 5,50,218,89,36,18,9,254,213,117,73,79,73,255,241,212,195,78,233,57,250, 224,209,73,213,131,124,232,193,63,248,101,179,218,56,113,200,248,212,238, 109,123,244,251,106,193,23,115,202,42,202,198,3,203,226,93,81,160,109, 255,30,253,83,226,89,0,13,232,215,163,175,253,251,229,51,219,251,12,95, 172,46,251,70,172,46,20,166,88,151,235,1,255,199,139,48,7,178,90,129,182, 192,44,96,44,205,36,9,136,69,2,48,42,45,41,105,234,199,227,199,59,70,119, 238,220,168,19,44,93,182,140,37,110,119,132,139,37,68,147,72,240,175,174, 77,122,74,250,143,127,27,253,183,3,15,237,53,204,26,137,224,31,124,124, 159,78,125,181,243,143,186,160,227,255,126,255,112,122,121,69,249,104, 96,93,188,43,236,241,197,127,192,183,203,229,140,119,17,246,87,30,204, 1,127,129,65,127,109,129,31,129,131,105,70,73,64,116,39,41,155,193,127, 250,199,227,199,167,53,41,248,47,75,132,132,95,136,74,18,252,171,179,166, 167,166,127,118,234,225,167,244,140,70,240,15,124,222,53,167,27,167,31, 122,86,135,212,228,180,105,64,70,188,43,189,51,127,103,92,251,124,43,220, 110,86,110,92,19,207,34,136,42,123,128,99,129,21,64,95,204,36,32,225,7, 4,70,51,1,144,224,47,90,162,195,29,201,169,63,222,243,183,59,36,248,251, 165,218,83,239,236,215,181,223,144,72,53,251,215,117,188,161,20,7,118, 56,72,27,126,192,240,174,169,246,212,87,226,93,111,67,25,40,77,161,148, 17,243,107,23,151,150,177,108,213,58,92,210,50,154,72,154,93,18,16,173, 46,0,9,254,162,165,26,127,72,247,161,73,165,197,58,115,151,173,136,234, 133,118,238,136,245,20,239,70,233,110,79,178,223,126,254,209,231,101,68, 59,248,43,204,207,143,234,51,50,229,207,29,43,79,118,121,92,71,2,127,196, 181,246,10,179,108,134,129,69,211,208,180,232,206,66,43,119,185,216,177, 51,143,93,123,242,209,245,216,39,30,192,199,254,143,231,197,227,226,245, 72,148,114,5,146,128,102,209,29,16,141,4,224,112,135,205,54,227,211,147, 78,114,140,234,212,169,81,39,144,224,47,18,153,37,202,203,251,54,39,233, 41,233,247,157,116,232,248,236,180,228,180,152,4,127,115,134,128,149,113, 3,79,108,253,245,226,47,159,118,86,148,37,196,242,175,74,41,60,186,94, 57,131,193,98,209,176,104,77,255,61,81,64,69,133,155,194,226,18,242,11, 139,41,45,45,199,103,232,241,156,112,118,110,220,174,92,191,68,42,87,179, 73,2,162,145,0,140,255,95,255,254,142,35,214,174,197,187,182,113,205,151, 75,182,110,141,112,145,132,16,81,144,99,181,90,207,60,178,239,145,182, 88,5,255,192,251,61,218,246,36,221,158,214,215,89,81,54,24,88,26,231,239, 67,37,165,20,30,159,23,195,48,48,12,5,154,194,170,89,64,3,77,211,208,176, 80,149,63,106,254,85,254,116,12,195,252,232,241,250,240,120,188,184,221, 30,156,21,46,74,203,156,120,125,62,12,195,64,215,13,84,243,155,106,190, 191,106,22,73,64,84,186,0,172,81,110,6,19,66,196,159,197,98,57,103,216, 65,195,82,108,86,91,76,131,127,224,53,164,199,176,86,191,172,254,233,114, 151,215,117,99,28,170,223,224,31,57,133,66,247,233,120,12,47,186,97,96, 232,134,249,209,31,204,13,163,142,175,131,246,51,140,184,52,243,139,200, 72,248,36,64,218,50,133,16,141,146,153,154,121,193,144,3,134,164,197,35, 248,43,165,56,176,125,47,139,102,209,78,139,247,247,65,136,122,36,244, 192,192,230,182,20,240,8,246,93,125,41,216,12,18,99,145,16,136,237,243, 224,3,18,169,254,151,1,231,196,248,154,239,0,159,196,248,154,251,43,171, 87,247,30,220,173,109,215,184,4,127,165,20,14,187,131,100,91,138,195,233, 118,118,5,182,197,251,27,34,68,29,18,182,37,160,89,37,0,67,134,14,30,55, 100,232,144,113,181,189,183,102,245,26,126,255,237,143,84,18,35,0,30,147, 154,154,58,237,188,191,157,227,176,90,99,243,45,78,176,250,223,146,149, 156,252,220,115,19,38,96,183,219,163,126,177,111,231,205,99,197,146,37, 172,80,42,23,73,0,98,165,91,86,90,150,94,215,131,125,162,29,252,3,175, 118,153,237,45,133,229,5,125,145,4,32,86,10,227,93,128,58,36,106,185,2, 18,50,9,136,70,116,234,22,133,115,2,112,196,145,135,115,221,13,215,236, 179,125,243,230,45,124,242,145,151,223,127,139,239,140,32,191,81,169,169, 169,83,95,122,245,121,199,225,71,28,22,147,11,38,88,253,175,207,78,78, 126,110,241,11,47,208,41,35,3,99,99,148,150,110,183,90,73,58,254,120,114, 23,45,226,181,73,147,56,165,119,47,86,252,181,182,57,60,62,182,165,232, 214,38,179,141,37,158,193,95,41,104,149,150,147,70,20,255,230,136,125, 180,142,119,1,234,144,168,229,10,150,112,73,64,164,19,128,81,54,155,109, 66,132,207,9,192,207,154,198,89,71,143,216,103,251,230,205,91,216,188, 105,115,52,46,217,24,163,82,83,83,167,191,244,234,243,105,193,193,255, 243,207,191,100,221,95,235,104,219,182,77,163,79,60,98,228,8,250,244,237, 189,207,246,4,171,255,245,89,118,251,203,139,159,127,158,78,41,41,184, 158,120,2,124,81,88,163,220,106,37,245,150,91,216,185,116,41,23,222,113, 7,87,142,29,77,110,110,220,91,211,246,55,25,105,246,52,107,60,131,191, 82,10,187,205,110,183,88,44,153,50,88,78,52,19,9,149,4,68,50,1,24,149, 154,154,58,253,184,227,143,77,98,115,100,91,227,126,214,52,198,191,244, 12,135,28,114,112,181,237,9,22,252,106,13,254,31,188,63,153,103,255,253, 60,157,58,117,162,103,207,30,97,159,116,235,214,173,228,238,216,201,161, 195,15,221,231,189,4,171,255,245,89,118,251,203,75,94,120,129,78,169,169, 184,158,121,38,170,193,127,55,112,193,173,183,114,229,216,209,116,238, 210,89,18,128,216,51,31,129,27,199,224,111,40,133,134,166,209,204,186, 50,197,126,47,97,146,128,72,253,195,169,12,126,139,22,46,38,146,9,64,32, 248,215,108,78,79,176,224,87,107,240,255,112,210,20,94,122,254,21,134, 15,63,148,180,52,7,227,142,59,54,172,147,110,218,180,153,165,75,150,241, 202,235,47,114,200,160,132,78,126,226,26,252,69,92,148,87,120,42,244,120, 6,127,165,20,110,111,133,215,48,140,226,120,127,51,132,8,83,66,36,1,145, 152,6,88,107,240,139,132,230,28,252,167,124,248,63,94,120,238,101,94,122, 245,121,6,15,25,20,246,73,55,109,218,204,255,62,252,152,103,158,127,42, 209,235,47,193,127,255,180,99,79,233,30,35,158,193,95,41,69,145,179,168, 12,144,177,31,177,115,128,255,149,104,18,181,92,245,137,251,20,193,166, 38,0,18,252,235,8,254,207,63,243,18,47,190,242,220,62,229,15,133,4,255, 26,36,248,39,162,77,69,101,69,54,221,208,227,22,252,149,82,236,45,221, 237,3,18,255,137,73,45,199,6,255,43,209,36,106,185,26,18,215,36,160,41, 93,0,117,6,255,25,69,69,216,90,55,110,80,166,207,48,248,89,211,56,249, 149,231,24,126,88,245,126,239,4,11,126,181,15,248,251,244,11,158,250,215, 51,140,24,121,20,171,86,174,98,213,202,85,44,89,188,148,189,123,247,50, 251,231,95,26,60,169,215,235,99,254,252,5,60,255,226,51,137,94,127,9,254, 251,55,143,213,98,93,159,91,144,59,188,99,171,206,113,9,254,21,94,23,101, 158,50,157,230,249,135,95,136,128,184,117,7,52,54,1,168,51,248,159,113, 230,105,124,228,246,240,81,19,10,117,214,189,183,55,203,1,127,0,105,233, 233,244,31,208,143,194,194,66,126,252,225,167,202,237,3,15,30,72,235,16, 147,162,139,46,249,59,67,135,13,169,182,45,193,234,127,125,118,114,242, 203,139,95,120,129,174,131,7,227,249,230,27,236,39,157,20,149,11,89,7, 12,32,207,229,170,28,237,47,193,63,113,84,120,42,62,89,177,101,229,33, 29,178,59,37,199,58,248,43,165,216,178,119,179,210,20,223,19,207,71,227, 8,17,25,113,73,2,26,147,0,28,145,154,154,58,227,149,215,95,116,212,188, 67,5,232,212,185,19,183,222,126,83,211,75,22,36,148,224,23,195,105,64, 245,214,255,132,19,143,227,132,19,143,139,232,5,19,172,254,87,36,105,218, 203,19,14,59,140,213,155,55,179,122,243,102,115,107,148,158,255,224,92, 176,128,231,223,125,135,171,142,29,67,167,206,117,63,93,114,127,157,6, 102,196,225,89,244,1,110,159,123,202,130,245,11,238,30,51,112,108,178, 69,179,196,52,248,43,165,88,181,99,121,129,203,235,250,111,220,190,1,66, 68,86,204,147,128,198,36,0,39,222,120,243,245,142,172,172,44,214,254,181, 46,226,5,170,77,110,110,110,253,239,239,200,101,246,79,179,43,48,151,194, 141,182,253,189,254,195,158,26,208,159,78,169,201,148,45,94,24,131,203, 193,213,199,29,75,199,142,29,234,124,63,119,71,46,159,175,92,21,171,250, 39,140,188,210,92,214,228,173,40,7,166,199,169,8,219,125,186,247,215,21, 91,150,159,126,72,247,65,90,44,131,127,94,113,30,5,206,130,93,192,175, 113,170,187,16,209,16,211,36,160,81,93,0,137,244,60,244,157,59,119,50, 233,253,15,43,182,109,219,113,50,48,55,22,215,220,207,235,159,215,181, 107,151,125,198,39,68,211,218,189,123,235,124,111,231,206,157,188,48,125, 102,197,98,183,39,102,63,255,68,176,187,116,23,63,173,157,81,238,51,124, 167,1,243,226,85,142,50,87,217,125,223,45,153,49,170,111,231,126,57,54, 75,237,79,5,140,116,240,87,10,126,95,255,115,97,133,199,121,15,210,252, 47,90,158,152,37,1,137,19,201,26,97,231,206,157,124,240,238,228,138,109, 219,182,159,140,249,77,218,175,72,253,119,242,252,180,239,42,22,187,221, 251,85,253,119,151,238,98,214,218,111,3,193,63,222,245,94,229,246,186, 39,127,191,116,166,43,86,193,255,207,220,21,190,66,87,209,2,96,106,156, 235,190,63,122,210,255,74,52,137,90,174,198,138,201,236,128,102,155,0, 72,240,147,250,75,240,79,140,122,151,187,203,239,89,178,105,241,166,213, 219,87,171,104,7,255,61,165,121,204,223,244,91,94,133,199,121,73,188,235, 189,159,186,199,255,74,52,137,90,174,166,136,122,18,208,44,19,0,9,126, 82,127,9,254,9,85,111,87,185,187,252,212,47,231,127,158,187,101,207,230, 168,5,255,98,103,17,51,86,126,147,239,242,184,206,5,118,197,187,210,66, 196,64,84,147,128,102,151,0,72,240,147,250,75,240,79,200,122,111,44,119, 151,159,244,191,223,63,204,93,187,115,173,138,248,157,127,73,30,95,47, 249,52,223,85,225,188,8,72,136,199,94,10,17,35,53,147,128,21,152,9,240, 14,224,9,160,209,207,92,111,86,9,128,4,63,169,255,254,27,252,167,59,19, 56,248,7,44,47,175,40,63,230,139,5,159,175,159,189,234,167,10,159,238, 139,88,159,255,180,21,95,236,40,243,148,158,170,163,199,107,198,67,77, 37,69,101,197,158,120,23,162,194,87,225,53,12,163,40,222,229,16,81,183, 7,24,231,255,152,3,180,7,58,1,119,3,15,55,246,164,205,38,1,144,224,39, 245,223,95,131,255,79,235,166,187,124,134,247,84,154,71,189,215,185,220, 229,195,22,110,152,255,241,127,103,189,81,176,49,111,125,163,131,127,94, 113,30,95,46,254,168,112,222,166,223,103,185,60,174,67,73,172,59,255,25, 191,255,57,183,124,227,206,77,113,43,64,145,171,144,245,187,215,148,24, 24,95,199,240,178,79,248,95,137,38,81,203,21,73,187,129,218,22,254,104, 244,120,152,102,241,24,77,9,126,82,255,253,55,248,207,168,240,234,222, 83,104,94,245,46,117,122,156,151,56,61,206,35,191,94,244,213,211,233,201, 105,125,135,244,24,214,234,192,246,189,44,14,187,163,50,248,215,22,248, 43,188,46,182,236,221,172,86,237,88,94,80,224,44,216,229,159,234,151,136, 163,253,115,75,157,165,231,63,250,225,19,159,76,24,119,97,171,145,253, 143,138,233,205,212,166,252,245,106,254,230,223,138,42,124,174,127,16, 219,165,144,239,246,127,76,180,1,119,137,90,174,72,211,67,220,22,146,70, 37,0,187,118,238,98,201,226,165,141,189,102,88,116,93,103,210,7,147,43, 182,109,219,62,30,248,57,38,23,109,128,212,63,182,245,127,254,199,89,21, 139,221,158,132,169,255,142,252,237,204,91,23,221,155,81,93,247,177,96, 253,92,143,87,79,156,122,55,194,31,78,119,217,72,167,187,108,240,47,171, 127,186,252,151,53,63,159,158,98,79,73,109,151,209,222,210,58,173,117, 154,221,150,146,172,80,120,188,110,111,145,179,168,108,111,233,110,95, 153,167,76,215,20,223,251,87,248,251,149,196,158,231,255,83,73,121,201, 81,31,204,156,252,238,180,185,223,246,61,241,208,19,178,135,247,58,84, 179,90,162,115,95,165,27,58,27,247,172,99,249,246,197,133,165,21,37,155, 221,62,247,37,152,253,193,113,51,176,223,144,35,226,121,253,253,208,7, 84,37,59,193,219,26,165,49,235,183,14,2,46,104,236,5,27,105,42,48,39,198, 215,172,139,212,127,255,174,127,15,224,154,24,93,235,11,226,184,200,79, 148,116,197,28,200,212,29,72,7,172,64,41,230,128,166,53,52,223,7,251,140, 202,72,205,184,195,48,140,209,61,59,246,52,6,31,48,40,187,107,219,110, 90,251,172,246,36,89,109,232,134,129,161,27,230,71,195,64,215,253,31,107, 251,218,191,159,199,235,97,119,73,30,121,197,187,212,198,221,235,139,119, 22,231,90,44,22,237,247,10,79,197,191,49,91,132,226,145,28,5,174,25,157, 181,191,27,47,81,203,21,105,118,204,62,255,139,252,95,127,0,60,0,52,106, 60,74,75,255,102,9,33,68,44,165,3,199,56,146,29,227,109,86,219,81,30,175, 231,128,76,71,166,47,59,61,91,181,74,107,101,111,149,222,202,97,183,37, 91,173,154,21,171,197,138,161,20,94,159,23,143,215,131,199,231,214,243, 203,10,93,197,206,34,119,137,179,88,43,119,151,37,217,44,73,155,116,165, 207,115,123,43,166,97,182,4,21,199,183,122,181,38,29,229,152,245,14,214, 14,200,171,227,28,143,3,255,172,177,237,49,224,222,58,246,111,143,217, 255,29,172,12,72,171,101,95,137,105,97,104,22,99,0,132,16,162,153,40,3, 166,58,221,206,192,184,5,91,69,113,69,207,221,197,187,59,99,206,223,238, 108,179,216,50,172,86,107,134,213,98,77,7,208,13,189,92,215,245,82,159, 225,43,193,92,238,117,39,102,139,200,70,15,30,111,60,42,81,143,57,192, 200,120,23,162,14,137,210,74,40,132,16,66,8,33,132,16,66,8,33,132,16,66, 8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16, 66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132, 16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33, 132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66, 136,168,211,66,221,81,41,21,205,114,68,156,166,133,92,181,144,72,253,165, 254,205,137,212,95,234,31,73,82,255,150,89,127,75,148,203,33,132,16,66, 136,4,36,9,128,16,66,8,177,31,146,4,64,8,33,132,136,191,246,192,3,192, 10,96,15,80,10,124,11,92,11,216,162,113,65,25,3,16,34,169,191,212,191, 57,145,250,75,253,35,73,234,31,245,250,159,6,124,8,164,213,241,254,34, 224,31,192,202,80,78,38,99,0,132,16,66,136,196,119,62,240,57,117,7,127, 128,97,192,79,64,207,72,94,88,18,0,17,79,19,129,39,226,93,136,56,154,200, 254,93,127,177,255,152,8,168,16,95,251,211,191,137,14,192,171,128,181, 198,118,195,255,10,214,6,248,138,250,19,133,176,72,2,32,226,101,34,240, 32,112,55,240,100,124,139,18,23,19,169,170,255,254,244,7,79,236,127,38, 98,254,174,135,106,127,250,55,113,31,208,58,232,235,114,224,18,32,25,104, 11,60,95,99,255,131,49,91,12,34,34,158,99,0,106,158,48,162,157,54,205, 176,15,40,162,18,188,254,19,217,247,15,194,253,192,163,145,186,64,130, 215,255,30,224,95,53,182,61,132,249,125,137,136,4,175,127,212,73,253,99, 94,255,88,127,131,234,173,96,51,249,249,107,192,86,160,75,208,182,9,192, 228,26,251,61,15,220,28,244,245,217,152,93,6,117,159,56,196,250,71,101, 100,161,16,245,152,200,190,193,191,24,248,33,246,69,137,155,239,128,59, 169,158,249,63,8,164,96,38,7,66,136,150,111,32,213,131,255,78,204,129, 128,53,221,225,255,120,28,48,21,248,50,82,5,144,4,64,196,210,68,106,15, 254,39,2,115,99,94,154,248,89,2,140,195,76,122,130,147,128,187,253,31, 37,9,72,124,137,214,36,16,217,91,94,17,11,131,107,124,253,51,181,255,94, 249,128,91,162,81,0,25,3,32,98,101,34,18,252,131,5,146,128,130,26,219, 247,167,254,79,33,246,103,3,107,124,29,210,20,191,72,146,4,64,196,194, 68,36,248,215,166,165,36,1,118,204,129,73,31,2,107,128,50,26,30,233,93, 83,67,251,151,249,207,253,33,112,158,255,154,34,113,104,49,126,181,4,3, 106,124,189,42,214,5,144,65,128,33,146,65,64,141,174,255,68,226,16,252, 19,168,254,161,24,10,124,79,245,238,0,48,103,71,52,170,59,32,134,245,63, 27,120,10,56,32,204,83,214,44,96,184,223,224,13,152,227,40,190,168,245, 228,209,175,127,162,253,65,168,86,225,102,246,251,31,113,205,164,254,155, 129,238,65,95,31,132,249,123,221,100,161,214,95,18,128,16,201,63,128,70, 213,127,34,113,186,243,79,144,250,135,35,162,73,64,12,234,111,197,44,219, 237,141,60,101,83,19,128,128,167,49,191,63,213,230,76,55,195,159,127,68, 197,177,254,209,254,70,133,84,177,102,240,243,79,7,74,168,170,143,19,200, 96,223,185,255,141,34,179,0,68,188,77,68,154,253,195,177,24,115,148,111, 205,36,32,81,7,6,214,21,252,221,192,38,204,249,204,225,88,212,192,251, 233,152,171,160,213,108,250,191,19,51,232,220,189,207,17,66,36,174,129, 84,79,102,254,36,66,193,63,28,146,0,136,104,152,136,4,255,198,104,46,73, 192,217,236,27,252,215,99,254,204,191,196,188,155,9,215,161,33,236,227, 0,206,196,92,51,225,192,160,237,119,1,127,16,193,233,81,66,68,89,205,1, 128,49,239,255,7,233,2,8,153,52,1,134,92,255,137,36,64,240,111,230,63, 255,38,119,7,68,177,254,118,96,53,213,251,252,103,2,231,96,62,189,44,22, 50,129,207,48,7,80,6,172,199,28,84,229,129,102,255,243,111,50,233,2,136, 251,207,191,47,48,146,186,7,218,159,7,28,27,244,245,103,152,255,142,106, 42,0,102,96,14,130,13,153,140,1,136,255,47,64,92,197,169,254,19,73,128, 224,15,45,226,231,63,20,115,157,128,86,53,182,135,148,4,68,177,254,231, 3,255,11,122,107,61,102,89,99,21,252,3,50,49,91,76,130,91,2,206,3,62,129, 22,241,243,111,18,73,0,226,250,243,239,137,217,164,159,18,161,203,127, 135,249,55,52,100,242,52,64,17,107,19,73,144,224,223,66,4,186,3,10,107, 108,143,247,20,193,211,107,124,253,32,177,15,254,96,14,160,154,88,99,91, 205,178,9,17,15,221,137,92,240,7,232,19,193,115,85,19,201,22,128,253,125, 45,232,253,185,254,19,9,239,97,31,145,84,107,69,99,88,255,120,221,26,214, 219,18,16,197,250,255,5,244,246,127,94,1,228,80,127,159,127,83,191,63, 245,85,36,13,200,199,124,112,74,160,108,125,65,166,1,38,104,11,128,162, 225,152,211,208,62,205,161,5,192,130,249,172,143,99,235,120,223,74,245, 85,0,117,96,105,29,251,186,128,71,168,189,123,160,78,241,232,2,216,159, 3,32,236,191,245,159,72,252,130,63,236,191,9,0,212,147,4,68,177,254,165, 152,35,242,33,40,224,214,119,104,19,47,221,80,69,214,2,189,252,159,151, 97,78,165,146,4,32,241,18,128,114,204,22,154,43,128,191,213,177,207,167, 192,43,192,215,248,127,142,181,104,14,9,64,67,142,6,102,7,125,253,7,112, 84,36,47,32,211,0,69,172,184,226,93,128,253,88,188,191,247,137,176,34, 91,112,25,98,62,141,74,132,164,28,56,25,51,232,253,140,153,36,92,80,99, 159,79,253,219,124,192,73,192,183,212,157,4,52,119,113,95,2,56,64,198, 0,136,166,106,244,106,117,162,73,38,98,78,135,139,181,220,160,207,187, 97,78,205,139,151,52,160,107,208,215,59,227,85,16,81,39,131,170,224,15, 102,115,247,37,152,1,63,224,99,170,130,63,192,28,204,233,158,137,214,202, 18,41,113,95,2,56,32,146,9,64,83,215,114,110,238,107,65,135,91,254,166, 190,18,73,93,73,64,9,112,36,45,251,251,16,205,186,29,202,190,131,0,33, 126,193,31,96,97,208,231,41,152,127,168,235,19,205,159,239,89,84,245,255, 3,44,8,169,6,145,17,235,127,239,137,254,239,160,46,22,224,58,170,183,54, 123,49,187,1,38,99,38,2,127,167,42,248,131,217,71,126,25,137,93,175,166, 72,152,4,32,228,111,176,76,3,108,94,201,104,156,234,95,219,8,245,18,224, 4,100,26,96,184,134,97,174,5,208,170,198,246,137,132,16,252,163,88,255, 243,128,143,130,222,218,8,12,193,252,57,199,82,22,230,195,148,122,6,109, 59,23,255,157,101,11,248,249,55,73,2,142,1,248,31,112,17,213,3,125,32, 41,168,185,109,50,230,239,89,109,66,170,88,130,255,252,247,0,109,130,190, 238,8,236,138,228,5,100,26,160,136,135,218,90,2,50,49,23,178,56,34,246, 197,105,182,154,20,252,163,236,75,170,63,176,228,0,204,69,76,50,99,88, 134,44,255,53,131,131,255,58,224,171,24,150,65,132,231,111,192,20,170, 183,4,248,216,247,206,255,61,234,14,254,45,65,7,170,7,255,124,34,28,252, 195,33,9,128,136,180,218,146,128,44,204,36,224,240,216,23,167,217,73,228, 224,15,230,74,123,119,214,216,54,14,115,221,130,9,152,253,242,209,146, 134,121,23,185,132,234,83,172,20,112,7,102,211,178,72,92,231,96,38,1,73, 181,188,103,5,222,7,46,140,105,137,98,47,97,6,0,130,204,2,16,209,241,164, 255,99,112,119,64,22,230,138,86,39,0,243,98,94,162,230,33,209,131,127, 192,23,152,79,225,11,78,4,14,4,62,192,76,16,54,211,240,226,64,53,215,254, 95,88,235,94,85,50,128,30,236,251,48,32,48,127,223,190,110,224,120,145, 56,234,106,79,111,94,253,44,141,147,16,207,0,8,144,4,64,68,139,36,1,225, 105,46,193,63,224,30,204,63,216,119,213,216,110,167,106,161,160,112,12, 107,196,49,10,120,10,248,103,35,142,21,177,23,60,213,175,166,192,236,0, 48,7,5,182,84,161,12,0,76,194,28,235,224,169,229,189,52,194,127,210,102, 157,164,11,64,68,83,93,221,1,223,33,221,1,193,154,91,240,7,115,122,215, 221,152,179,0,214,199,225,250,235,252,215,190,135,248,204,255,87,9,246, 74,116,53,167,250,129,121,3,26,124,19,170,3,255,240,239,219,82,213,76, 0,106,118,1,164,0,107,128,29,236,155,72,95,130,185,188,250,155,145,42, 140,204,2,8,145,140,2,110,82,253,107,155,29,80,76,20,91,2,18,172,254,245, 137,74,240,143,113,253,147,128,51,48,87,122,27,6,116,161,106,181,192,186, 212,44,96,67,223,224,50,96,27,176,8,115,176,223,87,212,211,231,47,43,1, 38,212,44,128,218,238,252,3,125,254,118,204,126,127,111,141,247,222,163, 246,150,128,230,60,11,64,195,156,214,155,21,180,173,45,176,55,232,235, 12,204,224,159,1,44,199,28,60,237,2,14,193,156,73,149,10,76,199,92,44, 169,238,11,201,211,0,19,242,23,32,102,18,176,254,49,77,2,18,176,254,181, 137,218,157,127,51,169,127,212,72,2,144,48,9,128,194,124,168,213,143,65, 219,106,78,245,251,152,125,215,2,56,22,243,223,70,205,138,52,231,4,160, 27,176,37,232,235,157,64,167,90,246,187,0,248,208,255,249,91,192,45,152, 107,92,244,197,28,91,51,28,115,25,238,58,201,52,64,145,104,164,59,160, 186,230,216,236,47,68,184,52,204,1,154,99,253,95,215,54,213,239,60,170, 207,14,24,137,57,221,180,165,45,4,20,234,0,192,41,192,127,253,159,95,142, 249,32,160,190,152,201,212,165,52,16,252,195,33,9,128,136,165,250,146, 128,195,98,95,156,184,145,224,223,252,197,123,229,191,230,178,18,32,152, 203,69,127,131,217,18,80,215,84,191,115,48,239,122,199,96,54,113,55,212, 133,148,136,44,212,31,83,71,213,248,122,121,61,251,222,136,57,221,21,204, 213,84,1,158,199,92,255,34,98,36,1,16,177,246,36,251,6,185,44,170,238, 16,246,7,227,217,55,248,63,132,4,127,209,114,57,48,19,253,250,230,249, 159,131,217,85,208,28,131,255,185,64,129,255,85,219,66,70,26,112,90,141, 109,223,215,115,190,10,224,209,26,95,63,222,148,2,214,38,158,99,0,162, 42,65,251,128,98,166,25,212,63,120,76,192,68,34,28,252,154,65,253,39,82, 245,24,229,137,236,127,245,143,42,169,127,194,140,1,136,180,68,29,3,176, 29,232,236,255,220,13,28,67,245,229,207,47,1,222,13,250,218,9,228,96,6, 246,218,100,99,46,174,21,188,218,229,71,212,253,40,229,106,228,113,192, 34,209,61,137,57,162,21,246,207,59,223,137,65,159,239,143,245,23,162,37, 9,158,155,159,140,217,111,255,32,240,43,102,211,255,191,106,236,255,62, 117,7,127,13,120,27,51,248,43,204,71,35,159,12,156,143,249,56,229,215, 35,85,104,105,1,8,145,212,95,234,223,156,72,253,165,254,145,20,70,253, 139,137,222,115,33,138,49,239,140,27,20,135,250,143,195,28,187,16,202, 77,117,33,208,7,243,161,64,181,185,19,115,129,43,48,155,253,31,194,76, 36,14,195,76,26,70,96,182,14,212,73,102,1,8,33,132,136,181,31,162,120, 238,250,250,204,227,237,7,224,182,16,246,115,99,62,234,184,174,224,223, 138,170,190,255,217,192,3,152,43,2,158,143,57,190,32,5,120,182,73,37,13, 34,9,128,16,66,136,72,249,63,204,39,220,69,90,129,255,220,137,236,37,204, 129,126,187,235,120,127,47,112,42,230,20,199,186,148,98,174,139,178,10, 115,61,0,221,191,125,51,230,90,9,187,129,95,154,94,84,147,116,1,132,72, 234,47,245,111,78,164,254,82,255,72,10,179,254,157,49,239,82,79,164,233, 221,1,37,152,253,233,255,71,24,75,78,199,185,254,173,48,87,198,60,209, 255,121,33,102,11,193,36,204,85,253,162,174,57,172,4,24,85,242,7,64,234, 31,73,82,127,169,127,115,34,245,151,250,135,66,186,0,132,16,66,8,33,132, 16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33, 132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66, 8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16, 66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132, 16,66,180,24,90,168,59,42,165,162,89,142,136,211,180,144,171,22,18,169, 191,212,191,57,145,250,75,253,35,73,234,223,50,235,111,137,114,57,132, 16,66,8,145,128,108,241,46,128,16,66,52,83,135,1,143,3,195,129,204,40, 93,227,80,96,81,148,206,45,98,195,138,249,187,50,6,24,6,244,5,58,2,233, 254,247,203,128,92,224,47,96,33,240,19,48,31,48,162,93,48,233,2,8,145, 212,95,234,223,156,72,253,163,94,255,35,129,95,136,254,77,84,163,18,0, 249,249,39,68,253,187,2,215,3,19,128,206,97,30,187,29,152,4,188,226,255, 60,44,210,5,16,93,29,48,179,180,126,241,46,136,16,251,129,30,192,28,160, 20,120,1,243,142,42,222,158,64,90,80,69,237,218,0,175,3,235,129,187,9, 63,248,3,116,1,238,1,54,0,175,2,57,17,43,93,16,105,1,8,81,80,253,59,0, 179,48,131,255,46,96,44,176,58,162,23,139,128,4,201,128,227,70,234,223, 98,234,223,13,51,217,62,32,104,219,199,192,223,1,95,93,7,197,160,254,101, 64,154,255,243,221,192,236,136,94,176,202,61,192,198,112,15,106,65,63, 255,70,137,99,253,47,4,94,2,90,71,180,0,144,143,217,154,240,81,40,59,135, 90,127,73,0,66,20,84,255,159,128,99,130,222,218,129,217,183,179,46,162, 23,108,34,249,3,32,245,143,164,56,213,191,182,224,31,80,111,18,16,131, 250,7,111,152,5,28,27,209,11,54,81,20,235,31,238,47,66,160,32,49,61,46, 14,191,255,73,192,203,192,85,17,189,240,190,94,3,110,162,158,228,23,18, 47,1,200,2,70,0,35,129,161,64,123,204,38,141,64,179,70,190,255,149,135, 217,223,245,155,255,85,220,216,11,70,241,23,160,23,230,31,165,224,102, 157,134,146,128,182,152,73,195,145,192,0,204,63,104,57,64,6,224,161,170, 254,187,168,94,255,146,198,150,183,133,4,128,70,147,250,55,251,250,215, 23,252,3,234,76,2,36,1,144,4,32,146,26,248,253,119,0,159,0,39,69,244,162, 117,155,10,156,7,184,234,218,33,17,18,128,20,224,28,204,140,104,4,225, 143,55,48,48,251,253,254,3,124,6,184,195,57,56,202,191,0,225,36,1,207, 1,55,18,126,191,165,14,252,138,89,255,47,72,172,250,39,60,169,127,179, 175,255,245,152,119,84,13,249,16,184,24,243,223,75,37,73,0,36,1,136,164, 122,126,255,147,128,47,137,93,240,15,152,6,156,65,19,91,192,162,145,0, 100,0,255,135,25,248,35,53,112,97,47,102,32,124,2,179,239,173,65,49,248, 5,8,53,9,104,13,252,0,12,105,194,229,247,96,14,42,121,18,40,15,229,128, 22,16,0,154,68,234,223,34,234,127,47,240,88,8,251,189,8,220,28,188,33, 65,18,128,49,152,55,65,7,17,217,1,215,10,115,112,216,231,192,247,181,237, 32,9,64,204,126,255,255,67,244,155,253,235,242,42,102,162,188,143,72,215, 31,165,84,40,175,83,149,82,91,84,244,228,42,165,46,86,74,105,13,149,37, 210,234,184,78,47,165,212,246,26,101,220,169,148,234,87,99,191,108,165, 212,252,8,212,127,71,130,213,63,97,95,82,255,102,89,255,30,74,169,177, 53,182,221,171,26,86,18,135,250,7,251,177,150,247,239,87,74,25,33,148, 189,169,30,173,229,218,209,172,127,184,226,114,92,20,235,31,252,186,176, 17,229,139,180,243,84,19,126,254,145,106,1,104,131,217,20,119,92,200,87, 110,154,239,129,11,48,251,205,107,21,195,12,48,150,45,1,1,211,49,251,62, 11,235,218,161,133,220,1,54,154,212,191,217,213,191,7,230,191,163,14,192, 233,192,204,160,247,26,106,9,248,21,56,58,120,67,156,91,0,14,6,150,18, 155,105,214,10,56,10,152,27,188,81,90,0,162,254,243,207,1,214,96,198,190, 120,202,199,92,88,104,111,240,198,88,174,3,48,8,115,213,162,80,130,191, 7,115,26,195,133,152,133,78,247,191,250,250,183,125,236,223,167,33,199, 249,175,121,72,35,202,27,105,201,236,251,75,218,25,243,143,89,175,160, 109,5,192,56,204,38,163,75,128,62,52,190,254,227,49,235,63,160,41,5,23, 34,65,244,192,252,247,210,3,115,236,208,87,192,241,65,239,63,14,252,179, 142,99,55,3,23,69,175,104,141,50,134,234,127,91,75,49,147,245,72,189,130, 7,7,107,152,127,15,68,108,61,70,211,130,191,86,227,213,88,57,192,131,77, 56,62,52,181,53,51,40,165,78,80,74,149,133,216,84,241,169,82,234,128,58, 206,19,252,58,80,41,245,121,136,231,44,85,74,29,215,148,38,144,38,214, 127,140,82,170,176,158,242,109,87,102,55,65,56,205,160,225,212,191,196, 95,134,150,210,4,28,177,151,212,191,217,212,191,155,82,106,131,218,87, 133,82,234,148,26,251,222,81,99,159,45,170,142,191,41,49,168,127,176,154, 93,0,143,212,120,255,168,8,127,207,6,215,56,255,51,49,172,127,184,226, 114,92,20,235,143,82,170,139,82,202,221,136,178,213,86,191,198,214,51, 88,133,82,170,179,106,196,207,191,41,45,0,71,98,142,206,79,107,96,63,29, 184,3,115,48,76,40,11,90,108,0,206,2,238,162,225,181,144,211,49,7,194, 28,30,194,121,35,109,20,102,83,124,118,61,251,212,214,18,208,144,112,234, 159,129,121,183,116,104,24,231,143,21,123,130,158,43,145,88,73,140,85, 237,226,165,190,169,126,201,192,167,192,41,65,219,254,13,220,233,255,124, 43,230,157,118,216,139,228,8,209,68,55,144,88,127,147,146,169,99,48,96, 67,26,155,0,12,192,156,139,216,80,240,7,115,41,196,103,26,113,141,167, 49,103,19,52,36,29,115,74,68,255,70,92,163,177,122,97,78,205,75,14,97, 223,198,36,1,16,122,253,51,128,111,49,187,20,18,69,22,230,202,104,15,68, 224,92,119,1,191,3,173,34,112,174,68,98,5,222,197,28,59,179,63,46,41,219, 3,243,119,164,190,121,254,201,152,243,171,131,187,3,254,141,249,7,120, 52,18,252,69,236,89,48,199,95,37,154,139,105,196,205,68,99,18,0,7,230, 157,127,40,75,29,126,198,190,193,63,5,115,202,206,60,204,41,125,101,152, 3,88,110,98,223,128,250,20,230,28,203,134,228,248,175,149,26,194,190,77, 149,129,153,112,132,51,197,177,174,36,32,19,115,176,211,111,212,158,85, 134,90,255,182,152,245,15,37,33,137,182,44,96,6,112,4,240,16,77,75,2,238, 194,156,250,56,12,115,224,103,75,73,2,2,193,127,2,230,130,30,147,217,191, 146,128,110,192,143,152,73,64,67,82,128,175,169,222,18,240,10,102,223, 191,16,177,118,56,230,58,253,77,165,106,188,154,170,51,230,223,201,232, 8,234,95,120,33,196,126,9,183,218,183,127,174,139,82,106,89,61,199,44, 245,239,19,124,204,65,42,244,254,150,103,195,237,3,105,68,253,95,14,177, 44,62,101,78,91,12,86,219,152,128,108,165,212,2,255,251,75,154,88,255, 39,99,80,255,134,94,223,213,82,174,251,194,56,62,240,186,175,150,243,124, 23,234,241,113,172,127,67,47,171,82,234,131,90,234,246,145,82,202,22,169, 235,36,112,253,123,40,165,54,213,82,255,134,184,148,82,199,38,80,253,131, 201,24,128,186,197,229,184,40,214,63,148,105,169,241,114,143,10,179,254, 225,182,0,140,193,188,83,13,197,23,84,111,162,75,193,188,115,174,111,228, 254,32,204,174,133,224,59,217,245,152,253,220,161,184,153,26,211,129,34, 108,20,112,109,136,251,254,136,217,76,185,35,104,91,109,45,1,69,152,179, 26,22,2,131,49,235,159,18,244,126,56,245,191,29,115,74,80,60,221,203,190, 211,19,31,33,188,150,128,187,252,199,4,43,38,22,163,93,163,43,248,206, 191,166,253,161,37,32,156,59,255,154,118,3,155,34,90,26,33,194,151,136, 227,173,2,194,110,1,8,55,1,120,42,140,99,106,6,173,171,9,109,218,222,32, 246,93,89,41,212,0,104,193,236,59,143,6,13,243,41,79,161,214,127,18,230, 58,0,99,8,47,9,24,4,92,83,227,92,161,214,223,138,249,51,138,167,69,152, 117,169,153,4,60,68,104,1,252,110,204,102,255,96,197,192,137,212,152,235, 220,204,212,23,252,3,90,114,18,16,202,218,254,117,145,1,127,34,81,244, 142,119,1,234,17,246,56,176,112,18,128,19,8,47,251,89,84,227,235,11,195, 56,182,230,190,11,195,56,246,48,170,15,26,138,148,241,152,193,57,84,203, 252,31,3,73,64,240,220,221,134,146,128,154,131,76,194,169,255,8,255,245, 226,169,174,36,96,34,245,39,1,119,99,46,247,28,172,165,4,255,247,217,55, 248,111,102,223,190,236,243,128,247,104,89,179,3,36,248,139,150,162,99, 132,206,19,169,117,0,130,133,93,182,112,18,128,186,22,226,168,75,110,141, 175,195,25,165,63,176,198,215,59,106,221,171,110,225,150,53,20,161,140, 200,15,182,37,232,243,117,212,190,88,208,47,64,191,160,109,69,152,139, 5,213,92,239,63,17,234,31,174,112,147,128,150,28,252,223,101,223,164,118, 43,230,234,113,181,141,102,191,144,150,51,59,64,130,191,104,73,210,227, 93,128,122,100,132,123,64,44,150,170,108,140,154,243,223,19,161,156,225, 142,44,169,89,135,218,238,232,58,96,142,110,15,110,9,40,198,124,202,83, 176,112,51,196,68,248,126,65,232,73,64,75,15,254,53,239,252,183,98,62, 30,122,35,117,7,185,150,208,29,32,193,191,229,169,121,231,218,208,43,94, 199,137,16,132,19,40,66,121,42,87,176,78,53,190,254,51,140,99,107,238, 27,110,211,198,163,97,238,31,138,112,235,95,179,204,117,213,191,174,238, 128,96,53,191,151,13,169,217,135,30,79,139,48,187,79,138,107,108,159,136, 153,4,60,72,237,193,255,4,90,118,240,223,84,99,219,24,204,69,160,130,53, 231,36,64,130,191,104,137,66,122,26,109,156,148,134,123,64,56,9,192,119, 192,130,48,246,175,57,94,96,114,24,199,214,220,119,120,24,199,206,163, 142,71,100,54,81,52,235,223,208,98,65,71,132,113,221,133,152,101,77,36, 243,48,155,187,107,107,9,152,88,99,91,224,206,127,94,212,75,21,61,225, 4,255,224,247,90,74,18,32,193,191,229,170,57,127,189,161,87,188,142,139, 150,157,49,184,70,99,133,93,182,112,155,138,67,89,158,54,224,244,26,95, 255,135,170,129,113,245,89,10,188,209,192,185,234,98,80,181,84,104,52, 68,179,254,245,37,1,71,134,120,77,131,208,167,105,198,90,93,221,1,193, 90,114,179,255,22,234,14,254,1,219,104,254,73,128,4,127,209,146,253,21, 239,2,212,99,77,184,7,132,155,0,252,140,57,21,46,20,103,0,7,6,125,237, 198,92,205,171,190,32,184,212,191,79,240,19,241,122,17,122,2,240,60,230, 163,65,163,229,103,162,91,255,186,146,128,123,129,37,33,92,243,21,18,251, 206,185,190,36,160,37,4,127,128,119,216,55,248,111,196,92,159,34,148,121, 236,219,128,177,212,62,38,224,237,38,151,46,186,36,248,139,150,174,230, 236,182,68,18,118,217,26,51,88,236,255,8,45,11,178,179,239,156,252,237, 152,75,41,222,132,249,135,62,176,20,240,31,192,141,254,247,130,71,188, 107,152,107,127,39,133,112,189,53,192,125,33,236,215,84,145,174,127,17, 213,251,110,234,123,148,112,125,73,192,74,204,68,33,209,213,150,4,180, 148,224,15,230,66,78,190,160,175,183,96,254,236,182,134,113,142,64,87, 65,112,75,128,142,185,108,116,162,146,224,47,246,7,179,226,93,128,122, 68,175,108,170,250,82,147,3,148,82,123,67,92,158,240,78,213,184,229,46, 241,47,109,24,138,189,74,169,126,42,54,75,97,70,163,254,189,148,185,76, 112,176,218,150,13,110,173,148,90,92,203,53,246,168,26,203,46,71,185,254, 145,120,13,83,74,21,40,165,138,148,82,71,68,250,252,113,174,255,121,74, 41,175,82,106,179,82,170,103,19,234,209,85,41,181,94,153,203,74,79,72, 224,250,215,245,72,223,80,212,249,72,223,4,255,249,7,147,165,128,235,22, 151,227,162,88,127,139,82,106,107,35,202,85,87,253,26,91,207,154,182,40, 179,108,97,213,191,177,211,197,86,97,54,103,215,156,175,94,155,39,48,251, 206,195,161,97,78,13,11,101,228,125,25,112,18,176,58,204,107,52,69,164, 235,31,234,138,129,181,181,4,148,3,103,211,252,238,158,2,179,3,154,251, 104,255,218,124,12,156,143,185,116,116,83,150,175,13,140,9,56,15,115,101, 201,68,36,119,254,98,127,98,16,222,128,246,88,153,68,232,227,211,42,53, 101,190,248,92,204,231,214,55,20,4,45,152,211,210,190,0,14,10,225,188, 129,71,237,62,17,66,249,202,128,51,129,249,33,156,55,210,34,93,255,64, 18,16,60,146,179,161,36,32,48,93,238,151,112,10,158,64,230,145,216,99, 22,154,226,115,204,0,222,84,219,252,231,74,68,18,252,197,254,232,21,170, 143,83,139,55,55,240,106,99,14,108,234,130,49,51,49,31,62,19,202,93,206, 25,152,115,225,63,198,92,234,182,47,230,170,74,233,152,171,225,77,192, 124,246,247,42,66,27,244,183,209,127,237,31,194,45,116,4,69,162,254,217, 152,75,12,95,130,249,139,213,174,198,113,245,37,1,163,49,31,37,44,68,172, 237,239,193,191,117,208,235,140,248,22,69,196,216,118,224,173,120,23,34, 200,27,132,191,90,44,16,198,202,73,13,244,43,228,0,83,48,7,119,197,194, 76,204,229,82,243,235,218,65,211,34,187,40,84,2,212,127,7,230,31,205,117, 161,236,28,227,250,39,28,169,127,212,235,191,137,198,61,213,111,51,230, 239,241,230,38,21,168,1,113,254,249,63,66,245,1,201,35,128,223,35,88,156, 193,84,239,6,124,22,243,73,160,149,162,88,255,112,255,33,4,10,18,211,227, 98,240,243,111,141,57,240,188,109,68,47,20,190,124,204,135,0,85,139,133, 161,214,63,82,75,198,230,99,62,128,231,52,194,27,237,28,174,92,204,59, 229,19,169,39,248,199,65,44,234,95,219,179,3,132,136,151,30,141,56,38, 240,252,131,205,17,45,137,16,177,87,128,57,115,45,222,174,161,9,177,48, 210,107,198,127,3,12,192,92,138,119,79,4,207,187,27,120,24,243,81,140, 239,19,155,21,159,26,35,90,245,15,168,237,217,1,66,52,7,45,161,217,95, 136,96,31,1,175,197,241,250,47,1,159,54,229,4,209,120,104,76,25,112,63, 208,21,179,153,126,54,230,28,230,112,233,152,11,239,92,224,63,215,131, 132,54,234,62,222,34,85,127,195,127,236,237,52,60,48,80,136,68,38,193, 95,180,84,55,98,14,240,142,181,169,192,109,77,61,73,52,151,22,117,99,246, 139,79,1,50,49,7,203,141,0,134,97,222,201,182,193,236,59,7,179,9,99,15, 144,135,57,61,236,55,204,62,179,146,40,150,47,218,66,173,191,13,51,177, 217,141,249,7,114,53,102,221,127,161,170,21,225,91,204,69,30,2,15,24,10, 36,1,33,143,9,16,34,78,36,248,139,150,76,199,28,212,253,49,230,212,240, 88,248,6,115,154,177,175,161,29,27,18,171,181,197,75,128,25,254,215,254, 168,169,245,95,131,185,50,220,44,204,224,15,85,99,2,198,18,219,53,16,132, 8,149,4,127,177,63,112,97,78,71,127,1,184,46,202,215,122,9,243,206,191, 201,193,31,154,199,195,69,132,105,45,230,31,211,159,168,74,2,58,96,38, 5,146,4,136,68,179,63,7,255,154,127,156,31,33,178,131,150,179,107,124, 237,141,224,185,69,227,248,128,235,49,187,109,95,38,242,179,3,118,251, 207,223,164,62,255,154,34,53,13,48,225,180,224,105,96,189,49,147,128,78, 65,219,126,198,252,99,91,169,5,215,63,36,82,255,168,215,191,190,111,72, 220,131,127,156,127,254,167,2,95,71,180,0,245,59,15,115,13,149,74,50,13, 48,174,63,255,214,192,67,192,149,64,114,19,47,93,1,188,137,57,6,174,190, 39,169,86,19,106,253,37,1,8,81,130,213,191,23,85,45,1,181,45,35,220,210, 235,223,32,169,191,212,63,146,194,172,191,6,76,195,92,234,58,218,102,97, 174,63,82,109,25,88,249,249,39,68,253,59,97,222,181,95,132,57,40,60,28, 91,129,15,48,87,248,203,13,247,194,146,0,36,198,47,64,52,245,194,92,1, 106,2,181,172,2,181,31,212,191,94,82,127,169,127,36,53,162,254,41,152, 179,129,46,165,106,240,110,36,237,194,156,18,253,16,224,172,249,102,2, 212,63,174,18,172,254,22,224,80,204,174,218,97,152,11,247,116,198,92,9, 22,204,153,99,219,49,187,121,23,98,38,117,139,104,196,218,254,1,146,0, 36,214,47,64,204,73,253,165,254,145,36,245,151,250,55,39,82,255,216,174, 4,40,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16, 66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132, 16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33, 132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66, 8,33,132,16,66,8,33,132,16,66,196,157,22,234,142,74,169,104,150,35,226, 52,45,228,170,133,68,234,47,245,111,78,164,254,82,255,72,146,250,183,204, 250,91,162,92,14,33,132,16,66,36,160,88,39,0,223,1,170,129,215,247,49, 46,147,16,66,8,177,223,137,101,23,64,43,160,32,196,125,219,0,249,77,185, 152,52,1,73,253,35,73,234,47,245,111,78,164,254,82,255,80,196,178,5,160, 119,24,251,246,138,90,41,68,162,56,25,216,225,127,157,28,231,178,8,33, 196,126,39,150,9,64,56,65,93,18,128,150,173,3,48,9,232,228,127,125,8,116, 142,107,137,132,16,98,63,19,203,4,224,160,48,246,109,169,9,192,17,192, 191,128,159,128,237,128,19,40,3,54,250,183,61,232,223,167,165,123,9,200, 14,250,58,19,120,46,62,69,17,66,136,253,83,162,38,0,225,236,155,232,52, 224,60,224,79,224,15,224,30,224,24,204,59,222,84,32,13,232,233,223,54, 209,191,207,34,224,92,194,24,163,209,140,156,12,156,83,203,246,115,105, 25,93,1,3,154,233,185,133,16,251,153,72,36,0,199,96,246,227,254,15,24, 203,190,65,43,19,248,39,112,106,24,231,60,5,184,31,200,170,177,93,3,198, 0,83,128,109,254,207,19,89,23,224,71,224,35,160,95,24,199,13,5,62,6,190, 5,58,70,161,92,241,226,192,188,251,175,203,171,64,122,140,202,18,13,19, 129,101,192,132,40,156,251,92,96,41,240,68,20,206,45,132,16,117,83,74, 213,246,178,43,165,214,168,234,214,42,165,238,86,74,181,85,74,157,164, 148,218,161,26,111,183,82,234,108,165,84,182,82,234,42,165,212,138,26, 239,175,87,74,37,215,86,182,24,213,191,190,215,161,74,169,61,77,168,123, 240,247,96,112,184,215,79,128,250,215,246,122,186,70,221,188,254,87,176, 167,35,113,173,56,212,127,98,80,29,124,74,169,9,17,250,158,161,148,58, 183,198,247,233,137,4,172,127,66,189,164,254,82,127,169,127,195,154,58, 13,240,118,224,223,117,28,226,5,146,66,46,73,253,234,59,215,93,192,211, 53,55,198,121,26,200,80,204,62,253,204,8,93,190,0,56,22,243,14,48,36,9, 56,13,230,96,204,174,141,224,159,227,211,152,191,131,119,4,109,243,1,135, 1,75,154,114,177,24,215,127,32,102,121,109,65,219,124,152,45,1,31,53,241, 210,231,99,14,152,172,121,238,33,192,202,186,14,74,192,159,127,76,73,253, 165,254,145,212,82,235,223,148,4,160,29,176,150,125,155,233,99,173,20, 232,3,236,12,222,24,199,95,128,118,192,66,160,107,68,11,0,155,48,255,232, 23,135,178,115,130,253,3,176,0,115,128,35,131,182,109,197,236,211,54,48, 3,89,207,160,247,22,248,247,213,27,123,193,56,212,255,28,204,174,169,224, 64,173,3,255,192,12,224,141,113,46,230,12,137,154,231,188,4,152,92,223, 129,9,246,243,143,57,169,191,212,63,146,90,106,253,155,50,6,224,49,226, 31,252,1,50,128,71,226,93,136,32,207,18,249,224,15,102,128,124,57,10,231, 141,133,235,168,30,252,1,110,192,156,1,225,4,174,175,241,222,112,224,154, 24,148,43,146,62,5,46,192,188,59,15,176,2,239,210,184,49,1,141,14,254, 66,8,17,138,198,182,0,12,193,188,75,179,70,186,64,141,100,96,78,159,91, 16,216,16,227,12,176,61,112,52,112,20,112,51,209,27,189,175,48,187,23, 150,54,180,99,2,101,192,29,128,213,84,159,246,247,9,230,204,8,106,108, 11,158,29,80,2,244,199,28,96,26,182,56,214,63,18,45,1,77,14,254,9,244, 243,143,11,169,191,212,63,146,90,106,253,27,219,2,240,60,137,19,252,193, 172,199,11,196,126,218,220,33,152,163,245,183,249,63,222,18,229,50,104, 192,189,81,60,127,52,212,156,243,95,2,220,90,203,126,55,2,69,65,95,55, 215,181,1,154,218,18,32,119,254,66,136,152,104,76,2,112,34,230,221,110, 99,237,193,156,226,55,20,115,202,87,186,255,243,251,253,239,53,214,145, 254,178,197,130,5,120,24,179,175,255,92,34,55,216,49,20,167,209,124,166, 202,141,103,223,57,255,247,82,251,93,253,46,204,223,129,96,231,18,222, 244,209,68,209,216,36,64,130,191,16,34,102,26,211,5,112,56,48,27,72,110, 196,245,62,3,46,195,188,11,172,77,38,240,54,112,118,35,206,237,1,70,3, 115,33,170,77,64,73,192,123,152,127,224,227,229,12,224,171,250,118,72, 128,38,48,7,225,15,238,171,111,176,96,89,56,23,79,128,250,67,120,221,1, 17,13,254,9,82,255,184,145,250,75,253,35,169,165,214,191,49,45,0,243,48, 3,237,182,48,143,251,12,179,223,183,174,224,143,255,189,115,253,251,134, 99,59,65,193,63,202,158,37,190,193,31,204,4,100,54,230,162,48,253,227, 92,150,186,60,68,245,224,239,3,174,166,254,145,253,134,127,31,111,208, 182,110,192,3,17,47,93,108,132,218,18,32,119,254,66,136,152,107,202,52, 192,182,84,173,254,215,144,61,152,203,251,214,23,252,131,101,2,235,253, 215,104,200,79,192,223,128,221,193,27,163,148,1,158,70,3,119,222,113,160, 48,131,196,237,4,125,15,226,156,1,215,53,231,255,174,16,143,127,154,38, 174,13,144,96,119,0,245,181,4,184,137,66,240,79,176,250,199,156,212,95, 234,31,73,45,181,254,77,93,8,200,138,57,29,240,174,6,206,245,0,225,79, 213,187,31,179,159,189,206,34,97,46,66,116,47,213,239,176,128,168,252, 2,88,128,229,36,238,122,236,91,48,251,220,87,67,92,255,1,68,162,25,191, 49,221,7,213,36,224,31,128,218,146,0,3,243,247,56,120,64,109,68,238,252, 19,176,254,49,37,245,151,250,71,82,75,173,127,83,159,5,160,99,62,220,166, 161,169,90,223,52,226,220,13,29,179,19,51,241,216,39,248,71,201,137,36, 110,240,7,232,14,124,71,104,173,38,209,84,223,156,255,80,181,148,181,1, 130,213,214,29,96,33,10,193,95,8,33,66,17,169,167,1,230,52,240,254,250, 70,156,179,161,99,26,186,102,164,157,18,227,235,53,70,87,224,245,56,94, 191,3,251,182,244,124,66,227,18,192,233,152,65,51,216,227,152,79,81,108, 174,2,73,64,109,173,24,6,18,252,133,16,49,20,169,4,160,161,246,145,198, 92,167,161,54,140,88,183,201,140,140,241,245,26,235,76,96,88,156,174,29, 234,156,255,80,181,148,181,1,130,213,247,123,221,18,31,255,44,132,72,80, 145,74,0,10,26,120,255,192,70,156,243,160,38,94,51,210,154,203,157,167, 6,252,61,14,215,13,103,206,127,168,90,210,218,0,80,53,218,191,182,69,180, 44,52,126,217,96,33,132,8,91,83,19,0,43,230,84,180,134,130,99,99,254,96, 55,116,76,71,224,41,170,15,170,138,166,180,24,93,39,18,142,141,241,245, 28,192,43,53,182,45,32,50,221,17,175,2,127,212,216,246,50,205,103,49,164, 128,218,166,250,25,84,239,14,104,202,179,3,132,16,34,44,77,73,0,218,2, 51,129,187,105,184,233,242,6,194,123,112,80,22,102,243,111,125,52,224, 78,127,25,218,133,113,238,198,218,221,240,46,9,35,26,15,35,170,79,99,230, 252,135,170,37,172,13,80,215,60,255,139,49,167,176,70,234,1,66,66,8,17, 178,198,38,0,135,99,206,243,14,101,13,0,48,147,133,183,67,188,158,5,120, 7,104,19,226,185,199,248,203,114,68,136,251,55,214,150,40,159,63,146,82, 98,120,173,131,49,31,128,20,236,57,194,152,179,31,130,21,152,207,122,8, 118,43,230,67,169,18,93,67,139,252,68,250,41,130,66,8,17,146,198,36,0, 129,165,128,195,189,203,60,11,243,143,93,125,45,1,89,254,125,206,12,243, 220,93,252,101,138,102,18,240,93,20,207,29,105,77,233,119,15,135,5,248, 15,213,23,252,217,74,253,235,55,52,214,131,192,166,160,175,109,254,107, 39,210,67,169,106,10,117,133,63,73,2,132,16,49,215,152,4,32,155,198,61, 7,0,204,192,190,30,179,249,118,40,144,65,213,195,128,30,240,191,23,110, 240,15,176,3,173,26,121,108,40,62,35,246,51,15,26,107,97,140,174,19,137, 57,255,161,106,110,107,3,132,187,188,175,36,1,66,136,152,106,236,74,128, 63,99,174,189,159,72,126,199,156,170,167,32,106,43,65,253,15,56,63,162, 39,142,142,243,53,77,251,56,146,39,172,101,37,172,14,152,171,14,102,7, 109,251,4,243,121,15,209,244,9,213,103,27,148,96,62,15,161,90,171,71,156, 87,2,107,202,218,254,225,60,64,168,78,178,18,154,212,63,146,164,254,45, 179,254,141,77,0,6,99,222,101,38,74,243,171,129,217,252,191,32,176,33, 74,191,0,61,129,165,152,243,209,19,213,106,224,16,77,211,34,186,66,98, 45,255,0,66,10,196,81,16,82,226,17,199,63,0,145,120,176,79,147,147,0,249, 3,40,245,143,36,169,127,203,172,127,99,7,1,46,197,28,212,151,40,222,38, 40,248,71,209,38,234,94,201,45,17,248,48,155,201,163,189,60,114,52,230, 252,135,42,145,215,6,136,212,83,253,164,59,64,8,17,117,77,121,24,80,59, 224,47,170,223,137,197,67,41,208,7,243,217,0,149,162,156,1,158,135,57, 83,193,17,209,139,52,141,194,12,254,175,65,84,235,223,228,7,245,68,64, 131,15,28,138,195,29,64,52,30,233,219,232,150,0,185,3,146,250,71,146,212, 191,101,214,191,41,235,0,236,6,30,173,231,125,111,61,239,133,171,190,115, 61,66,141,224,31,3,31,3,163,136,221,96,187,134,20,2,103,227,15,254,81, 22,205,57,255,161,74,180,181,1,6,178,111,240,247,97,174,200,216,148,181, 253,63,197,188,227,175,217,18,240,142,255,154,66,8,209,104,77,93,9,240, 69,204,86,128,96,235,48,159,16,216,25,56,25,200,109,194,249,243,48,3,91, 59,204,63,248,43,107,188,191,193,95,134,120,88,140,249,140,250,243,129, 105,64,69,28,202,176,21,120,18,115,217,228,47,98,112,189,88,204,249,15, 85,34,173,13,176,18,184,47,232,235,192,93,250,71,17,56,247,71,236,219, 29,240,40,251,254,91,16,66,136,176,52,165,11,32,96,52,240,62,230,114,173, 111,0,63,81,125,186,92,38,230,170,126,119,17,250,224,185,18,204,101,126, 95,196,108,226,15,46,239,49,192,85,192,209,152,119,71,63,213,118,130,56, 52,1,165,99,222,25,119,33,250,203,212,22,0,219,128,181,117,237,16,133, 250,55,216,236,30,7,117,118,71,104,154,22,209,22,137,16,155,0,239,6,30, 35,58,79,245,11,116,7,60,138,217,10,83,47,105,2,149,250,71,146,212,191, 101,214,63,18,9,64,168,38,17,250,67,106,166,0,23,54,229,98,242,11,16,241, 250,95,143,185,6,127,115,112,131,166,105,53,159,77,208,36,97,252,252,7, 0,171,34,121,237,198,156,91,126,255,165,254,145,36,245,111,153,245,143, 212,211,0,67,177,62,74,251,138,216,184,55,222,5,8,67,60,203,26,173,224, 31,237,115,11,33,246,51,137,154,0,172,139,90,41,68,99,53,167,20,184,57, 149,85,8,33,226,34,150,9,64,56,65,93,18,128,196,115,13,77,27,208,25,43, 185,36,238,242,192,66,8,145,48,98,57,6,160,21,230,224,181,80,180,1,242, 155,114,49,233,3,146,250,71,146,212,95,234,223,156,72,253,165,254,161, 136,101,11,64,33,48,51,132,253,190,167,137,193,95,8,33,132,16,245,139, 101,11,64,76,73,6,40,245,143,36,169,191,212,191,57,145,250,75,253,67,17, 203,22,0,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33, 132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66, 8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16, 66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132, 16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,34,178,180,120,23,32,68, 105,192,177,64,47,64,1,235,129,31,0,103,140,203,113,140,255,149,200,126, 246,191,132,16,66,136,58,217,226,93,128,6,88,236,54,203,157,118,155,245, 190,139,206,59,65,59,106,248,192,20,139,197,198,23,95,79,119,125,243,227, 98,20,234,17,143,143,167,49,147,130,88,56,38,187,251,208,51,114,122,141, 40,10,231,160,97,206,89,21,195,172,171,82,194,57,166,200,110,175,72,105, 101,15,235,152,153,203,221,217,191,173,245,130,36,0,45,89,123,224,116, 155,205,246,15,93,215,15,82,74,117,3,42,226,93,40,33,68,53,191,2,169,192, 73,192,238,70,158,163,29,240,45,224,2,70,69,168,92,213,36,114,2,96,113, 36,107,159,92,116,222,201,39,61,247,210,27,41,158,162,205,148,110,91,128, 82,58,125,112,164,159,121,80,38,15,127,94,246,192,182,2,227,8,167,91,157, 77,140,146,128,156,94,35,138,122,12,26,51,58,59,43,45,164,253,139,138, 203,25,183,103,222,236,163,147,24,157,154,28,218,53,92,110,200,207,178, 207,182,119,234,50,218,145,213,33,164,99,156,197,187,128,237,179,253,9, 128,104,89,122,0,103,89,44,182,9,96,244,203,200,204,242,102,231,228,100, 228,229,238,44,173,112,149,31,7,124,19,231,242,9,33,170,75,6,134,1,63, 98,182,94,23,0,199,56,146,173,231,218,108,150,17,110,143,222,205,171,171, 84,0,155,85,115,37,39,89,182,120,189,198,111,21,94,227,83,224,39,32,199, 127,236,64,96,65,180,10,153,176,9,128,221,198,29,23,156,125,226,73,47, 188,252,70,202,234,143,46,161,100,91,245,239,65,151,214,22,94,185,52,51, 237,186,183,75,142,223,178,87,191,195,109,182,4,196,68,118,86,26,221,187, 182,11,113,239,221,176,7,82,147,161,77,86,104,71,236,45,54,63,58,178,58, 208,166,219,33,161,29,179,21,96,123,136,101,18,205,192,1,22,139,229,116, 139,197,114,105,155,54,109,122,245,31,56,80,219,184,121,107,114,70,86, 22,154,166,165,0,120,189,222,244,188,29,21,19,116,93,151,4,32,241,92,129, 249,199,123,103,20,206,253,27,48,39,10,231,141,180,116,224,63,192,242, 40,157,255,201,40,157,55,20,191,250,63,214,117,103,126,10,85,1,124,174, 35,197,150,214,179,75,78,202,5,227,135,165,31,210,175,187,165,83,251,28, 236,73,86,12,3,74,75,75,50,182,229,238,25,184,124,205,230,254,159,127, 191,242,194,173,121,197,206,10,175,42,7,14,0,86,250,207,213,216,114,212, 43,81,19,0,135,205,106,187,255,249,23,94,77,249,235,243,107,246,9,254, 1,73,86,120,224,172,180,180,203,223,40,125,0,212,43,196,126,76,128,16, 145,52,192,98,177,92,128,166,93,172,105,90,235,171,175,185,38,249,146, 139,47,182,29,58,108,24,154,166,241,217,151,95,241,236,11,47,82,94,94, 14,64,86,118,43,109,231,246,109,39,97,254,59,246,197,181,228,77,211,17, 24,14,244,4,44,64,46,102,55,86,94,28,203,212,20,183,36,37,37,61,55,120, 240,96,142,58,234,200,136,158,120,238,220,121,204,155,55,239,33,18,63, 1,72,79,79,79,223,92,86,86,150,115,243,205,55,93,24,233,147,191,240,194, 139,16,223,4,96,100,3,239,239,6,78,180,104,218,170,172,204,180,110,31, 61,123,185,181,95,191,190,184,75,242,112,22,239,194,85,184,134,98,183, 19,175,187,2,133,149,246,169,41,156,52,178,151,229,172,241,35,51,254,90, 191,41,227,150,167,167,235,5,69,37,69,74,113,34,245,119,33,52,84,142,122, 37,98,2,112,56,112,201,249,103,140,209,148,187,144,162,141,191,212,187, 115,215,28,43,7,117,176,232,171,182,235,99,129,169,49,41,161,16,145,97, 5,142,180,88,108,231,128,58,223,98,177,164,103,181,110,149,156,221,58, 39,41,45,61,131,213,107,215,83,82,90,134,197,98,1,224,156,51,207,224,152, 81,35,121,248,241,39,152,253,235,175,36,217,237,216,237,118,195,93,81, 113,52,48,43,174,53,105,156,65,41,142,148,167,250,244,238,115,204,49,99, 142,214,219,180,201,73,170,168,112,107,171,86,253,89,49,125,250,12,171, 134,182,176,194,85,113,19,176,36,222,5,13,195,77,14,135,227,185,195,14, 59,140,195,15,63,140,187,239,190,43,162,39,127,242,201,167,152,55,111, 94,68,207,25,5,105,233,233,233,155,14,59,236,176,156,89,179,102,241,224, 131,15,68,252,2,254,4,32,161,101,166,217,159,62,105,204,80,251,51,247, 93,110,245,150,238,160,104,227,47,120,92,165,120,189,30,188,94,47,94,175, 7,159,199,19,244,245,106,116,93,167,117,251,190,124,254,194,101,214,127, 191,253,125,202,15,191,175,122,194,229,225,162,104,149,49,209,18,128,99, 178,210,146,167,189,240,232,141,142,99,142,57,166,206,59,255,154,250,117, 178,57,86,109,215,251,32,9,128,72,124,41,192,56,171,213,122,129,130,83, 71,28,117,20,167,159,121,86,250,207,191,252,170,109,221,94,189,11,39,191, 160,128,219,239,190,135,227,199,29,203,63,239,190,139,236,236,108,218, 180,105,195,139,207,254,155,153,63,252,200,35,255,250,23,217,173,115,210, 247,230,237,186,64,215,245,68,74,0,58,0,163,129,78,84,191,163,175,108, 14,79,74,74,186,97,212,209,35,254,125,239,125,247,36,167,165,167,81,144, 95,128,215,227,197,150,100,227,164,83,78,76,251,191,123,239,98,198,183, 51,70,252,235,241,167,231,232,186,126,159,215,235,125,46,46,53,9,207,245, 105,105,105,47,76,158,60,137,63,254,248,35,222,101,137,23,71,122,122,250, 230,161,67,135,182,153,60,121,18,29,59,118,138,119,121,226,101,64,231, 78,157,78,127,238,193,171,83,43,118,45,193,85,146,135,225,107,120,124, 150,50,116,242,183,46,165,112,215,58,110,190,232,248,148,213,155,139,207, 94,191,121,251,227,192,234,104,20,50,145,18,128,193,41,73,218,180,69,63, 127,236,200,105,157,77,233,142,37,20,108,170,255,238,63,64,211,80,52,159, 41,141,205,221,32,224,196,24,95,115,54,48,55,198,215,140,164,12,96,188, 213,106,189,216,80,106,108,106,106,170,119,200,176,67,51,38,127,240,190, 214,189,91,55,0,110,186,225,122,222,120,235,109,222,122,247,61,116,93, 175,118,240,204,31,126,100,209,226,37,220,247,127,119,51,246,152,99,200, 219,189,155,220,220,29,232,30,119,249,238,157,185,86,77,179,230,199,161, 78,181,25,150,154,154,242,98,86,86,214,176,147,78,25,111,244,236,217,211, 110,177,104,108,216,176,209,243,237,212,233,150,226,226,226,249,46,87, 197,173,86,171,117,232,77,183,220,240,204,185,231,157,101,255,115,213, 26,118,239,222,183,133,179,85,118,54,227,78,24,167,13,26,50,216,113,197, 101,87,61,82,92,84,66,34,39,1,169,109,15,250,151,197,149,119,207,228,73, 239,115,244,209,163,248,227,143,63,88,186,118,23,239,78,93,214,228,115, 15,238,213,158,193,125,66,27,12,28,103,142,172,54,157,119,15,234,127,80, 218,71,31,77,33,57,217,14,16,145,239,1,192,63,78,25,20,145,243,68,88,22, 80,92,203,246,195,219,100,37,219,255,251,222,255,40,41,220,131,174,251, 208,117,3,195,208,49,252,159,235,134,15,195,167,99,24,58,186,110,190,2, 159,27,122,49,233,43,190,198,145,228,78,2,142,160,246,4,32,196,97,229, 117,75,164,4,0,128,141,75,167,147,187,227,11,148,238,9,249,152,63,119, 248,92,68,41,67,18,251,72,177,89,45,143,156,126,220,225,73,227,70,15,7, 20,74,249,39,96,40,5,24,160,240,111,83,230,212,12,255,231,230,255,21,40, 21,244,190,185,61,176,143,121,42,163,114,187,199,227,225,177,87,190,114, 150,56,61,39,211,188,166,55,182,6,78,177,217,108,23,234,186,62,58,57,213, 225,105,157,147,147,145,213,58,71,75,74,74,74,45,117,186,184,229,142,187, 120,228,193,251,25,56,96,0,73,73,73,92,127,205,213,28,119,236,177,60,240, 240,195,172,94,243,87,181,147,237,220,185,147,9,23,95,98,180,203,201,113, 174,88,177,92,211,224,39,93,215,63,1,62,87,202,87,22,151,26,6,177,217, 108,119,180,109,215,246,225,127,61,245,104,234,193,135,12,164,48,191,144, 178,50,179,88,135,31,113,120,234,245,55,93,203,138,229,43,71,221,115,231, 63,127,29,123,236,24,235,25,103,157,102,255,253,247,185,120,220,181,255, 59,47,44,42,226,247,57,127,48,252,176,67,121,229,181,151,210,46,153,112, 217,35,94,175,247,39,96,105,236,106,21,178,235,131,131,127,192,250,157, 78,212,146,189,77,58,113,126,126,33,110,143,222,28,18,0,71,122,122,250, 150,67,6,244,78,251,232,127,147,43,131,63,192,140,38,126,15,0,214,254, 181,49,209,18,128,85,192,0,224,19,224,100,160,230,237,253,198,95,23,254, 245,204,175,11,255,218,231,192,208,85,14,105,219,84,199,14,119,251,63, 174,105,236,21,18,41,1,88,90,225,85,39,159,118,221,127,190,125,242,130, 244,212,193,221,67,43,218,246,2,131,245,121,134,5,115,234,132,136,190, 121,62,221,24,251,253,156,37,211,239,191,227,178,244,94,189,251,225,222, 243,39,202,240,161,148,66,41,195,31,224,141,26,159,43,80,6,202,240,7,119, 255,71,21,244,17,204,253,204,207,205,143,246,172,206,28,125,196,193,142, 19,46,122,116,90,137,211,115,42,137,221,215,221,22,24,111,181,217,46,115, 164,166,30,113,246,57,231,168,51,206,60,51,197,225,72,227,137,127,63,147, 178,119,111,245,63,132,27,55,109,226,226,203,175,228,146,139,38,112,205, 149,87,144,108,183,211,187,215,65,124,240,246,91,188,241,246,59,188,252, 202,171,20,236,221,227,43,46,44,112,122,61,30,11,154,54,125,231,182,173, 31,0,223,1,161,103,200,81,102,179,217,238,24,50,108,200,195,47,191,250, 92,234,174,157,121,252,244,195,108,124,53,154,59,109,182,36,14,234,117, 32,95,77,253,44,213,106,181,240,199,111,243,234,12,254,1,186,174,179,104, 225,18,142,30,51,138,75,47,191,36,245,221,183,223,123,209,229,170,56,58, 154,117,105,132,235,211,210,210,94,174,25,252,1,218,181,207,97,224,33, 189,155,116,242,213,171,214,55,233,248,24,113,164,167,167,111,25,58,116, 104,155,154,193,31,104,242,247,0,204,4,32,193,156,12,204,3,142,3,94,3, 174,176,90,173,231,89,45,188,163,5,181,70,171,160,255,18,180,209,103,40, 187,97,40,107,136,215,10,4,122,82,237,124,228,242,240,55,204,69,241,254, 207,127,242,235,27,91,137,68,74,0,0,80,22,187,229,238,255,149,241,228, 223,210,105,40,9,240,248,20,15,125,86,86,142,82,19,145,25,0,177,52,167, 164,172,98,252,168,211,110,152,254,203,87,47,165,247,236,152,69,233,134, 239,80,186,15,165,116,51,168,87,126,52,80,134,94,245,177,198,54,35,248, 189,64,130,16,180,13,160,243,224,11,153,57,233,1,199,241,19,30,254,38, 1,147,128,158,22,139,229,12,139,197,114,169,97,24,189,50,179,91,25,173, 114,114,28,19,31,124,144,139,46,188,0,77,51,255,22,28,62,124,56,79,62, 243,12,83,191,157,94,237,96,93,215,121,251,221,247,248,121,246,47,60,116, 255,125,248,124,94,166,78,155,166,127,56,105,178,123,221,186,117,78,80, 159,26,134,49,25,248,29,48,98,95,189,6,13,107,215,190,221,67,47,191,250, 92,234,95,171,215,146,155,91,251,172,55,159,207,203,154,213,107,40,46, 42,194,98,177,86,206,100,8,112,185,42,48,19,36,69,155,54,109,73,77,53, 215,192,242,122,61,108,218,176,145,83,78,61,201,242,223,55,222,30,142, 185,56,74,99,23,86,137,52,51,248,79,158,180,79,240,223,143,84,5,255,143, 254,183,79,240,111,138,254,93,51,57,247,200,174,0,184,114,235,186,9,142, 155,45,192,105,152,173,146,151,3,37,157,58,180,189,250,219,15,30,115,84, 108,154,94,217,164,111,54,251,251,252,205,250,230,75,215,117,172,22,133, 205,162,42,223,171,236,2,208,125,181,126,174,235,58,125,199,92,195,165, 119,189,118,234,218,45,123,174,49,12,206,198,28,79,244,54,77,248,123,152, 72,9,192,168,236,236,236,169,159,125,241,105,242,159,171,87,113,207,237, 183,243,248,185,169,117,38,1,219,11,12,30,250,172,172,124,123,129,49,221, 237,227,249,216,22,85,0,115,74,157,238,241,71,159,126,227,244,95,190,120, 49,189,231,129,199,83,178,238,59,80,122,195,71,134,65,41,131,221,139,39, 211,113,200,5,204,252,224,126,199,241,23,61,146,8,73,192,0,44,150,11,44, 22,203,121,157,59,118,234,154,150,158,174,85,120,125,129,57,250,0,60,243, 252,11,204,250,249,103,30,126,224,126,186,117,237,74,102,102,6,143,61, 52,145,241,39,28,207,195,143,253,139,60,127,191,183,82,10,103,121,25,115, 102,255,92,49,244,243,79,149,130,189,134,174,127,4,124,69,226,79,245,34, 53,53,229,197,127,61,249,168,99,231,206,188,58,131,127,176,157,59,119, 237,179,205,233,114,177,102,245,154,202,174,164,61,123,246,210,191,95, 95,82,82,83,253,199,228,113,212,136,35,233,121,64,15,207,218,191,214,141, 198,108,118,141,183,171,146,146,146,94,30,57,114,4,75,150,44,97,201,146, 234,19,21,230,206,157,7,217,125,27,60,73,247,54,201,116,207,49,187,114, 183,228,187,217,178,215,29,149,194,70,75,70,70,198,22,195,48,218,140,24, 113,20,175,191,254,122,163,207,115,116,159,204,202,207,127,249,171,4,128, 115,142,236,202,201,39,140,165,162,162,130,175,190,254,6,187,221,142,199, 147,48,13,95,0,243,129,139,128,143,53,184,249,221,231,238,212,90,105,121, 148,167,217,107,4,117,13,93,183,160,235,22,255,231,90,229,123,225,40,220, 186,132,103,254,239,239,142,51,174,123,225,121,195,80,201,192,30,160,73, 211,76,44,77,57,56,130,70,101,101,101,77,95,186,108,73,218,176,161,195, 200,200,72,227,255,238,191,143,127,126,90,193,210,45,213,167,55,175,223, 165,115,221,59,37,197,151,253,167,164,108,203,94,253,33,167,71,157,79, 98,222,25,237,15,204,36,224,204,155,202,54,238,40,34,227,160,227,65,11, 181,85,43,116,74,233,236,94,60,137,142,217,26,223,125,112,159,35,211,145, 244,13,48,54,226,23,10,205,89,201,201,201,139,31,122,232,161,123,22,45, 92,216,107,243,230,77,41,243,231,205,77,190,232,162,9,149,193,63,96,201, 210,101,156,63,225,34,62,254,244,179,202,224,54,242,168,163,152,244,238, 219,180,206,206,98,235,198,245,229,171,150,44,170,216,178,126,221,170, 130,189,123,30,212,117,253,96,67,215,187,1,119,210,12,130,63,208,33,51, 43,115,216,192,67,6,176,126,93,245,166,106,151,171,130,109,219,182,179, 109,219,54,92,174,250,87,42,206,223,187,23,165,20,173,90,183,162,117,235, 86,40,165,216,179,183,106,92,163,203,233,196,110,79,162,115,231,14,41, 64,215,104,84,164,17,134,12,30,60,152,190,125,251,82,84,84,196,207,243, 255,226,131,233,203,249,118,193,54,190,93,176,13,103,218,1,116,238,61, 164,193,147,116,207,73,230,240,3,82,56,252,128,148,202,68,160,57,41,45, 45,109,115,233,165,255,192,233,116,82,84,84,196,243,147,102,87,126,15, 190,93,176,141,225,39,93,26,210,121,142,238,155,197,224,46,230,199,128, 44,71,18,115,230,204,97,225,194,133,156,112,252,113,148,151,187,176,219, 19,238,123,244,153,197,98,121,227,156,211,142,245,13,234,211,81,115,237, 109,74,159,127,253,118,173,251,131,214,89,169,156,123,226,161,54,204,49, 7,215,3,77,26,0,156,8,45,0,199,100,101,101,77,91,190,98,153,163,85,171, 86,108,221,177,137,33,67,135,160,20,220,245,207,123,185,123,226,195,60, 121,65,85,119,192,79,171,61,172,218,174,127,6,220,72,156,154,253,139,138, 203,9,181,21,210,220,215,92,222,119,111,109,99,69,107,225,114,3,41,230, 242,190,230,10,127,13,51,151,2,142,139,57,165,78,247,248,209,103,222,60, 125,246,231,207,167,247,60,232,68,138,215,126,27,133,150,0,157,188,69, 31,208,113,232,4,190,123,255,62,199,9,23,63,250,77,137,211,27,143,150, 128,239,61,94,175,90,187,97,163,181,85,171,86,88,44,22,50,50,50,120,248, 129,251,57,241,184,227,120,232,177,199,217,149,87,181,126,141,211,233, 226,177,39,159,226,187,239,127,224,196,227,198,49,109,218,180,138,207, 62,253,68,171,168,168,88,235,243,249,222,6,62,49,12,99,71,140,235,16,41, 163,79,62,245,100,163,48,191,16,159,183,42,81,111,232,142,190,46,26,254, 177,160,181,48,183,107,26,137,51,219,39,111,236,216,49,149,243,252,255, 243,249,98,126,89,83,76,191,1,7,85,237,161,20,238,77,155,1,72,238,209, 221,95,252,150,231,225,135,31,170,252,252,171,117,111,50,234,220,234,147, 132,12,167,11,247,250,245,36,31,116,16,22,71,253,191,3,117,89,185,114, 37,163,71,143,102,214,172,89,100,102,166,55,169,188,17,150,228,72,177, 158,243,208,237,23,219,157,59,151,214,253,11,28,1,74,25,108,89,54,157, 107,254,126,138,245,179,239,22,122,220,94,213,228,155,132,120,39,0,251, 4,127,229,31,33,110,24,6,142,84,7,202,98,175,184,107,74,153,122,234,130, 244,84,128,79,231,185,203,129,55,136,83,240,79,78,159,93,97,105,179,104, 118,73,136,251,91,218,64,121,78,110,97,129,149,217,225,92,167,116,190, 171,176,124,250,134,217,176,33,228,99,118,187,84,188,30,10,99,38,1,103, 221,50,125,246,231,207,165,247,232,53,158,146,181,83,81,17,110,152,49, 147,128,247,232,56,244,34,102,188,255,79,199,137,23,63,22,143,36,160,212, 98,177,204,255,245,151,95,70,157,123,161,57,120,239,31,23,77,192,98,177, 112,212,145,71,240,249,71,83,120,246,133,23,249,236,203,175,240,122,189, 148,22,23,81,152,191,183,116,197,162,5,246,247,223,254,239,124,159,207, 55,9,248,146,196,233,199,110,138,46,61,123,244,176,7,70,251,7,4,223,209, 107,64,65,65,33,123,246,230,211,181,107,151,90,79,210,166,77,91,246,236, 217,75,65,65,33,0,22,139,133,54,109,219,84,190,159,234,72,197,235,245, 178,99,199,78,23,205,97,189,107,165,112,111,222,66,197,130,249,164,219, 204,156,165,120,193,60,82,134,31,190,79,34,176,37,223,93,235,231,45,129, 225,116,225,90,178,8,207,218,181,116,238,220,129,29,139,22,96,239,221, 135,212,33,67,247,73,4,126,89,19,184,59,170,253,46,233,160,94,7,177,102, 205,26,142,63,254,120,126,252,241,71,38,76,152,192,164,73,147,162,92,131, 134,89,173,76,56,227,132,163,29,29,90,217,41,218,187,39,234,215,43,217, 179,137,206,70,5,103,143,59,216,242,241,119,203,47,243,25,60,214,148,243, 197,51,1,24,149,149,149,53,117,217,242,165,213,130,191,207,231,101,193, 188,133,20,22,22,241,208,131,143,150,185,221,238,227,128,148,187,167,148, 77,3,168,240,170,83,48,71,95,198,133,163,221,159,41,173,123,218,71,167, 102,134,246,173,115,149,248,72,47,119,205,78,205,98,116,106,102,195,251, 155,199,192,174,79,245,217,172,214,71,135,246,200,33,40,7,44,132,151,100, 52,82,157,235,0,148,58,221,147,142,62,235,214,203,102,127,246,172,189, 103,239,147,40,94,51,213,156,9,16,65,74,233,236,90,248,30,29,15,189,152, 25,239,221,235,56,241,146,199,99,158,4,232,62,223,123,69,5,5,131,179,91, 231,100,188,240,242,43,252,250,219,111,60,116,255,253,116,235,218,133, 194,162,34,218,183,109,67,121,113,97,201,134,117,235,146,45,22,203,239, 186,174,191,11,124,225,243,249,74,99,85,198,24,177,105,160,213,117,103, 91,223,29,125,176,212,212,20,250,247,235,91,217,236,223,166,109,27,82, 83,170,30,132,217,177,99,7,118,231,229,177,105,211,102,59,9,62,21,212, 155,151,135,115,246,108,82,53,197,136,193,125,232,220,213,156,190,183, 43,119,15,139,22,205,223,39,17,216,178,183,249,245,251,135,162,252,183, 57,184,215,252,69,175,222,61,56,248,244,113,164,164,38,227,118,123,88, 181,122,3,127,253,111,10,246,62,213,19,129,64,191,127,93,222,126,247,13, 46,191,244,234,202,150,128,239,191,255,158,15,62,248,96,130,166,105,113, 205,2,50,29,41,23,95,126,225,137,14,119,254,186,152,93,51,111,253,60,78, 58,246,240,228,175,102,45,63,199,231,110,158,9,192,168,172,172,172,233, 203,150,47,77,107,221,186,117,101,240,247,184,221,204,155,187,128,226, 226,98,245,200,195,143,23,57,157,206,99,240,63,72,162,194,171,2,139,106, 71,235,193,18,33,75,205,180,145,211,37,180,39,245,230,111,175,128,114, 72,205,132,182,33,46,138,21,200,35,211,128,54,245,237,24,31,245,174,3, 176,97,203,14,78,184,240,110,190,251,240,73,122,244,57,5,79,241,54,148, 210,171,166,3,26,230,90,1,193,211,255,246,153,50,24,52,13,80,81,227,24, 255,126,238,162,237,28,112,224,24,166,191,125,151,99,252,101,79,197,58, 9,248,170,172,164,248,21,101,24,104,22,11,115,231,206,99,204,184,113,70, 187,214,173,93,243,231,207,67,211,180,233,186,174,191,15,204,212,117,189, 229,253,117,175,178,109,227,230,77,238,35,70,28,94,237,118,174,161,59, 250,218,164,164,166,214,218,66,144,148,100,167,231,129,7,240,246,27,111, 43,155,213,58,215,139,55,161,159,15,224,217,186,149,46,153,105,28,49,114, 40,86,107,213,16,171,142,157,218,113,114,167,182,228,110,207,99,241,130, 121,117,182,8,180,20,229,203,86,112,230,153,199,147,145,157,78,219,238, 109,233,55,122,0,201,105,201,245,62,213,166,62,173,90,183,226,173,119, 254,195,229,151,94,205,154,53,107,56,238,184,227,152,53,107,214,59,74, 41,175,166,105,31,69,180,240,161,179,185,125,234,240,254,253,250,224,222, 52,35,228,131,214,239,40,227,143,63,243,43,255,238,25,134,193,208,3,211, 233,214,54,180,25,20,133,59,215,112,240,9,39,163,43,91,63,240,217,105, 194,148,224,88,36,0,135,3,199,4,125,157,146,149,149,117,87,205,102,127, 151,171,130,121,115,231,179,103,207,110,245,239,39,159,219,227,116,58, 143,162,122,251,119,220,3,191,0,26,92,7,160,47,163,6,119,229,164,9,255, 199,99,119,93,76,106,106,138,127,13,0,85,185,8,80,240,162,64,170,242,235, 170,247,205,124,162,106,223,202,69,131,2,119,147,10,64,71,173,253,30,20, 156,114,76,127,199,199,223,45,155,225,211,25,69,108,90,135,246,90,44,150, 85,91,55,109,24,228,44,43,175,208,117,159,11,248,100,163,97,252,15,243, 73,109,145,29,0,145,184,126,253,246,155,233,218,245,55,94,75,82,82,18, 94,175,57,247,191,161,59,122,155,45,137,97,195,135,178,100,241,82,60,238, 186,243,35,171,213,202,176,67,135,176,113,253,6,222,126,235,61,151,219, 237,190,53,186,213,137,12,155,205,74,121,65,25,246,84,59,201,105,201,149, 131,67,53,52,58,119,233,64,167,206,237,217,177,125,23,139,230,207,165, 120,193,60,28,163,143,33,169,125,251,56,151,58,242,12,143,78,121,97,57, 163,46,26,205,184,19,199,49,103,78,211,186,172,91,181,110,197,127,223, 126,189,50,9,56,254,248,227,109,63,254,248,227,36,165,20,113,74,2,14,61, 124,232,0,95,178,114,82,17,198,194,117,191,172,216,203,59,51,54,7,63,209, 113,100,197,152,14,35,186,181,109,27,210,241,62,143,11,79,249,30,14,233, 219,195,51,127,249,250,33,52,225,111,94,180,19,128,99,178,179,179,167, 189,242,234,203,142,224,209,155,35,70,28,69,90,122,90,101,240,119,150, 59,153,55,111,62,219,182,110,211,95,121,233,245,29,78,167,115,4,205,161, 175,111,255,85,239,58,0,131,219,26,188,118,219,112,102,254,246,125,85, 80,15,94,1,48,176,96,144,63,184,7,182,85,6,123,101,4,37,11,144,218,174, 63,101,21,138,143,166,254,230,245,120,245,207,48,231,224,214,38,102,99, 32,124,62,223,253,165,197,197,71,27,134,241,9,176,40,86,215,77,48,219, 138,139,75,150,172,88,190,242,200,131,122,29,196,234,63,171,22,227,172, 235,142,30,160,87,159,131,176,89,109,140,28,121,20,43,87,174,98,119,94, 45,75,1,183,202,102,224,193,7,179,103,207,110,174,189,250,198,114,93,215, 31,32,49,87,1,172,149,82,10,183,211,141,199,229,33,217,145,140,221,97, 175,74,4,52,141,46,93,59,210,169,115,123,230,206,89,204,206,173,91,91, 100,2,0,224,243,250,72,73,79,105,82,240,31,58,172,106,54,69,235,156,214, 149,45,1,43,87,174,228,216,99,143,141,103,18,208,253,144,190,61,44,186, 167,81,61,123,63,0,19,253,159,79,4,70,132,115,176,171,100,55,7,118,203, 177,204,95,190,190,59,9,154,0,140,202,206,206,158,186,116,217,18,71,155, 54,109,112,186,170,198,236,25,134,206,182,29,155,81,74,81,90,90,202,130, 185,11,88,191,97,163,239,237,183,222,221,224,116,58,71,81,213,10,46,18, 87,189,235,0,12,233,149,195,224,3,91,53,121,33,32,179,201,63,159,182,67, 46,224,250,9,199,37,29,127,209,35,167,37,192,58,0,0,61,12,195,56,4,56, 36,206,229,8,246,14,49,158,35,239,114,185,110,184,231,142,123,231,124, 57,245,243,212,226,226,98,114,119,228,214,187,127,231,46,157,233,216,177, 35,115,126,153,67,102,86,38,253,250,245,99,192,128,254,228,231,231,227, 241,120,176,217,146,104,221,58,27,171,213,198,180,111,167,171,39,31,123, 202,101,24,234,159,62,159,239,133,24,85,41,162,148,82,84,148,87,224,118, 186,171,181,8,232,62,29,87,137,11,171,53,242,211,102,19,217,138,213,77, 127,176,99,235,156,214,53,199,4,216,102,205,154,21,171,36,224,87,170,30, 193,235,75,74,73,69,121,93,81,190,228,190,220,206,98,82,211,90,217,128, 201,64,160,206,115,128,176,86,164,138,86,2,80,57,175,191,117,235,214,108, 222,182,161,170,159,56,72,81,81,49,11,231,47,100,249,178,21,158,143,254, 247,201,90,167,211,57,26,40,136,82,153,68,228,5,214,1,152,62,251,139,23, 210,123,30,116,60,37,235,166,19,233,101,25,42,215,1,24,242,119,190,251, 224,62,199,9,23,61,18,175,41,128,193,206,27,56,112,224,232,243,254,246, 183,202,13,31,127,242,41,121,121,213,187,168,207,59,247,92,218,183,111, 7,192,150,45,91,249,250,155,111,246,61,81,4,246,113,150,149,82,94,86,230, 32,246,139,228,44,222,187,55,255,193,235,175,185,241,161,87,94,127,41, 53,43,43,139,117,235,214,85,155,22,8,102,95,254,65,189,15,164,99,199,142, 204,159,55,31,143,199,195,222,61,123,249,117,207,175,100,102,101,144,157, 221,138,164,164,36,114,119,236,228,245,87,255,83,254,195,247,179,172,104, 252,225,118,123,110,161,5,116,255,5,183,8,216,146,109,120,43,26,126,50, 156,168,91,205,49,1,99,199,142,141,101,18,16,160,57,146,109,22,85,115, 169,223,152,80,216,44,202,74,19,167,197,70,35,1,168,117,106,95,109,230, 205,157,199,188,185,11,220,211,167,205,88,224,116,58,79,64,150,243,109, 142,246,183,117,0,42,237,45,44,226,200,35,143,98,220,216,49,0,156,126, 218,233,92,126,205,181,213,86,43,43,46,43,227,217,127,63,141,221,110,71, 41,69,86,171,86,252,48,171,250,99,43,34,177,79,94,238,14,202,107,76,199, 139,21,159,207,247,244,178,165,203,213,25,167,158,253,240,19,79,61,150, 58,246,216,49,20,20,20,80,86,90,142,166,105,164,165,59,200,201,105,77, 238,142,157,252,58,123,14,94,111,245,254,210,146,226,82,74,138,205,102, 212,31,190,255,145,31,190,159,245,57,230,10,103,245,45,110,17,60,182,104, 6,16,153,71,206,69,153,82,74,130,127,132,212,54,38,96,197,138,21,147,168, 186,35,142,134,224,59,236,235,82,146,172,207,106,22,107,204,87,39,178, 88,147,176,88,156,62,204,245,112,254,219,232,243,68,174,72,64,24,193,31, 204,254,161,79,62,250,52,185,172,172,236,88,36,248,55,103,129,117,0,202, 54,229,22,145,217,107,60,90,148,86,4,204,91,244,30,29,179,96,198,251,255, 140,247,138,128,40,165,120,224,161,135,217,184,201,92,167,252,144,131, 7,114,255,255,221,83,109,159,229,43,86,242,200,191,158,0,204,190,223,135, 31,124,128,3,15,56,32,42,251,196,147,207,231,251,247,174,157,187,70,94, 117,249,53,171,222,122,243,109,10,242,11,240,122,60,184,221,21,236,216, 182,131,89,63,252,204,138,229,43,247,9,254,117,216,72,253,193,255,152, 14,29,59,252,60,246,216,99,158,232,222,163,251,19,192,153,17,169,68,19, 181,118,175,34,185,112,17,154,82,104,134,30,218,75,41,146,11,23,145,181, 225,63,181,190,90,187,87,197,187,90,97,203,218,240,31,128,202,58,182,96, 219,215,111,217,225,181,216,99,191,48,81,106,70,27,54,111,47,244,18,206, 66,49,181,136,100,2,80,235,188,254,16,37,212,2,207,162,94,131,48,159,78, 85,243,53,194,191,14,128,103,83,110,17,153,189,79,138,90,18,176,107,161, 63,9,120,239,222,184,39,1,229,78,39,183,220,113,87,229,163,111,79,59,229, 100,206,57,243,140,106,251,124,61,117,26,159,126,241,37,0,105,14,7,207, 61,253,36,233,233,233,81,217,39,206,22,123,60,222,79,123,246,236,137,205, 102,99,195,134,141,108,220,176,137,157,59,119,85,206,16,8,209,8,106,255, 29,187,27,120,176,83,231,78,51,142,30,61,50,101,196,200,163,232,213,235, 192,136,87,162,177,90,121,254,36,179,116,9,238,138,10,192,139,134,175, 193,23,24,180,113,45,165,79,225,123,251,188,58,231,190,77,43,207,159,241, 174,86,216,50,55,188,1,128,199,237,242,215,49,58,10,11,10,185,226,178, 107,88,191,110,61,125,251,246,229,251,239,191,247,1,19,162,118,193,125, 109,93,188,98,157,178,166,180,138,225,37,77,105,173,58,177,106,221,86, 43,77,76,0,34,213,5,80,235,188,126,209,34,201,58,0,53,108,217,186,149, 123,31,152,200,243,255,126,10,139,197,194,255,221,117,39,27,55,111,102, 241,146,165,149,251,252,235,169,167,57,160,71,15,134,14,25,76,247,110, 221,120,252,225,137,220,114,199,93,24,134,17,145,125,18,81,122,122,58, 233,233,161,45,101,85,92,82,130,203,233,162,79,159,94,216,237,246,113, 192,184,186,246,205,200,204,224,160,131,14,34,45,45,212,101,178,98,167, 75,206,78,86,239,216,200,236,223,247,210,247,192,222,116,104,223,26,173, 158,110,90,13,72,79,181,209,177,245,190,235,138,236,44,168,32,138,241, 51,170,6,246,216,200,143,191,26,116,235,210,145,179,162,112,254,194,130, 66,46,191,244,106,214,173,93,71,223,190,125,249,233,167,159,124,29,58, 116,152,16,227,153,0,171,86,175,219,98,41,43,175,192,154,146,141,94,222, 164,101,249,67,150,214,170,19,101,46,157,188,221,249,94,154,56,91,46,18, 9,64,88,205,254,1,5,249,5,216,108,251,215,8,216,22,66,214,1,240,43,47, 43,101,207,46,243,9,120,159,126,242,49,24,62,250,244,238,3,64,215,78,29, 249,110,122,245,71,255,94,126,197,21,92,113,249,229,149,95,103,167,167, 241,215,218,181,17,217,103,125,89,226,45,50,152,145,153,142,69,179,84, 123,54,66,109,58,180,111,79,118,118,22,46,167,139,54,109,219,160,89,234, 255,187,144,157,157,29,114,98,17,107,217,233,123,57,243,200,105,108,221, 221,137,69,27,74,88,179,33,179,206,68,64,161,168,168,240,144,154,112,207, 183,105,186,35,251,46,98,112,207,85,44,221,52,160,218,246,131,251,53,252, 128,164,154,134,14,27,194,123,147,222,174,252,186,32,191,128,203,47,189, 154,245,235,214,51,112,224,64,126,252,241,71,95,187,118,237,98,29,252, 1,188,41,118,219,119,191,205,91,120,230,49,67,187,107,158,24,37,0,109, 186,13,98,206,220,37,134,69,83,159,208,196,17,215,77,77,0,26,21,252,75, 74,74,88,188,104,49,11,22,44,242,164,167,167,255,84,115,45,241,68,231, 42,241,153,43,252,133,184,175,249,49,244,185,141,46,255,170,152,229,245, 239,86,77,56,251,70,192,126,191,14,0,176,250,224,1,253,71,143,59,254,248, 106,27,243,118,87,117,93,95,113,249,190,79,66,11,126,127,212,168,17,140, 26,181,239,244,223,198,236,227,118,149,243,199,31,115,87,239,179,99,156, 109,223,177,131,197,139,234,159,250,53,116,216,16,58,117,234,72,102,86, 6,7,30,212,112,147,126,126,126,62,69,133,69,17,42,97,228,105,64,247,118, 185,116,107,151,91,107,34,0,176,43,175,128,53,27,214,97,161,132,67,250, 197,237,65,94,81,149,154,92,193,145,125,23,81,81,188,139,145,35,71,54, 122,45,128,224,223,159,4,10,254,0,20,151,185,39,191,248,214,151,199,31, 63,246,217,116,75,222,42,116,61,186,67,217,108,246,84,218,245,24,202,228, 167,159,42,175,240,210,228,101,144,155,146,0,52,170,207,191,180,180,148, 249,115,231,179,124,217,10,207,180,111,166,47,42,43,43,59,163,9,101,136, 185,236,210,1,21,93,115,7,204,166,254,233,206,213,20,218,188,133,11,203, 108,179,9,227,153,111,123,186,22,23,22,20,122,194,90,219,127,99,193,230, 10,10,214,55,188,99,100,236,239,235,0,228,1,108,218,186,141,229,43,226, 59,80,235,144,131,43,239,178,18,122,153,220,134,116,232,208,129,204,204, 76,86,175,174,59,143,177,104,86,14,59,124,56,75,151,44,35,63,63,54,119, 92,141,85,123,34,96,62,238,214,66,49,195,15,92,66,183,118,185,9,243,120, 195,104,89,63,245,86,126,252,246,19,236,25,29,194,62,54,248,17,219,181, 245,249,199,51,248,251,125,189,228,207,45,197,203,151,45,77,239,221,109, 0,222,109,11,162,122,177,46,3,142,101,217,242,165,108,219,85,88,130,185, 38,65,147,52,54,1,104,84,159,127,121,185,147,249,115,23,176,122,205,90, 239,199,31,125,182,186,188,188,252,120,98,123,215,214,100,237,172,253, 83,122,164,30,62,58,35,61,35,164,253,75,203,74,41,45,41,155,109,239,212, 113,116,167,142,157,67,58,38,119,231,14,182,171,229,179,43,58,120,71,219, 147,147,66,58,198,227,246,82,2,179,99,152,0,192,254,189,14,128,136,130, 165,75,150,113,199,109,119,7,47,147,90,147,109,196,200,163,174,127,238, 133,127,167,44,94,220,244,69,101,98,161,102,34,0,236,23,129,63,160,224, 175,239,152,251,116,255,202,175,93,238,20,54,236,234,202,129,29,182,145, 154,92,247,159,255,163,31,174,90,18,166,102,159,255,15,63,252,64,135,14, 29,254,17,231,224,15,224,43,119,121,110,186,238,190,87,222,251,229,203, 87,211,147,210,183,224,46,9,227,238,48,12,25,109,123,146,221,169,63,215, 60,252,175,50,175,143,59,137,192,31,218,198,36,0,131,83,83,83,103,44,91, 190,212,209,170,117,232,119,254,174,10,23,243,230,206,103,211,166,205, 190,201,31,124,248,87,121,121,249,40,160,121,181,253,251,101,164,103,208, 177,83,136,217,108,46,148,150,148,209,169,99,103,134,13,29,22,218,49,139, 1,150,99,79,78,34,35,35,180,190,206,210,88,119,2,84,217,111,215,1,16,81, 19,188,76,234,62,126,155,243,251,212,235,174,190,241,219,254,3,251,167, 110,222,92,87,111,80,226,9,36,2,251,187,212,228,10,6,118,15,239,233,121, 151,253,227,170,224,102,127,110,187,237,54,38,79,158,60,57,74,69,12,215, 175,235,182,236,41,126,243,173,73,169,87,92,54,193,234,253,235,91,116, 61,178,99,114,236,169,89,28,120,216,57,188,241,206,135,250,182,221,229, 249,186,249,111,164,201,26,213,2,160,148,82,219,182,109,165,204,85,28, 82,240,119,187,221,204,251,99,1,219,183,109,211,223,122,243,173,205,229, 101,206,163,129,196,27,181,36,26,43,176,14,192,244,217,159,63,151,222, 163,215,120,74,214,78,69,69,161,37,32,111,209,123,116,28,122,17,51,222, 255,167,227,196,139,31,147,36,32,193,117,232,208,158,65,131,234,95,45, 185,67,135,176,215,193,255,121,225,194,69,99,22,46,92,20,152,255,255,69, 99,202,38,154,143,160,102,127,210,210,82,73,156,216,79,59,224,71,183,71, 239,252,207,23,190,116,15,25,216,195,58,120,232,88,10,214,206,68,215,35, 115,127,155,148,146,193,65,71,254,157,185,191,253,204,127,191,90,233,213, 13,213,29,243,111,222,177,192,190,15,210,8,67,99,214,1,88,90,81,81,113, 226,113,199,157,80,54,247,143,134,7,92,123,60,30,230,253,49,159,61,187, 247,24,175,188,244,250,174,178,50,231,40,160,176,17,215,21,137,205,159, 4,220,90,182,63,173,3,32,234,86,84,84,140,213,106,163,91,247,110,245,190, 172,86,27,69,69,197,225,158,126,30,112,143,255,213,44,86,1,20,141,55,112, 224,64,102,207,158,77,70,70,122,181,149,54,227,172,29,240,35,48,16,88, 233,211,141,243,207,184,238,69,231,202,229,75,105,213,235,56,108,41,153, 77,190,64,114,122,14,125,70,93,194,242,101,139,185,237,217,153,78,221, 80,231,1,43,253,215,252,209,95,134,70,107,236,24,128,57,21,174,138,241, 55,92,119,243,244,151,95,125,33,253,240,35,14,171,117,39,159,215,199,252, 185,243,217,187,119,143,250,247,83,207,230,57,157,206,195,168,127,133, 47,209,188,205,41,117,186,199,143,57,247,246,233,63,125,242,76,250,254, 178,14,64,192,191,159,156,24,214,254,119,220,29,222,254,205,73,171,214, 173,208,245,208,91,128,82,83,83,105,213,186,21,108,216,20,197,82,69,95, 153,75,55,231,239,71,232,92,132,54,4,40,225,68,226,123,224,42,202,101, 228,200,145,84,84,84,240,213,215,223,144,150,150,138,199,83,247,227,163, 99,172,45,102,51,252,64,96,13,112,28,176,203,89,225,59,227,228,43,159, 253,236,181,135,46,78,27,63,254,68,75,209,150,121,148,239,94,91,239,137, 234,210,170,203,193,116,236,55,150,111,166,78,51,30,122,125,150,211,227, 83,103,3,51,129,185,152,193,255,96,96,54,230,13,208,206,198,92,163,41, 179,0,234,77,2,116,93,103,254,252,133,20,21,150,168,39,254,245,239,124, 151,211,53,2,194,25,59,47,154,169,57,37,101,21,167,142,57,231,182,169, 207,62,112,101,90,75,94,7,64,212,110,198,140,153,36,167,216,195,62,110, 215,174,157,204,152,49,51,10,37,138,141,205,174,174,88,210,206,140,220, 24,216,100,216,92,222,133,208,134,14,39,142,77,217,231,178,41,2,223,131, 226,41,147,152,58,245,107,0,254,239,149,159,121,236,218,163,155,126,210, 200,153,133,255,206,159,234,77,241,223,187,220,190,195,174,155,248,254, 143,103,253,182,162,213,253,119,92,153,218,166,245,1,20,109,93,136,179, 40,180,240,151,214,170,11,109,15,26,65,133,207,198,63,31,127,181,226,251, 185,27,118,123,124,234,120,224,47,255,46,123,48,23,202,10,180,62,204,196, 76,6,194,214,212,117,0,106,77,2,12,221,96,193,252,133,20,23,23,242,200, 195,143,21,187,156,174,81,64,243,78,237,69,56,126,46,41,119,143,187,226, 238,151,207,136,241,117,227,58,163,164,37,223,209,135,225,139,31,102,254, 152,242,195,204,31,155,116,142,72,21,38,86,198,28,218,29,183,231,216,136, 159,183,181,255,220,205,197,173,23,30,65,97,201,160,136,156,107,39,240, 252,135,115,1,232,219,61,246,203,237,54,96,160,255,99,109,253,240,107, 156,21,190,222,159,205,92,50,241,139,31,174,191,254,158,171,79,179,159, 121,234,241,214,78,61,147,112,21,109,35,59,167,12,216,92,237,128,86,57, 29,232,216,127,44,142,236,206,148,56,125,252,239,155,153,190,151,39,255, 236,49,116,253,85,183,143,135,216,119,192,252,110,255,181,243,130,202, 18,182,72,172,4,88,45,9,56,236,240,225,44,90,184,152,162,194,34,38,62, 240,104,177,211,233,28,137,217,68,34,246,47,115,253,47,177,127,89,198, 126,216,39,223,187,91,14,189,187,229,196,187,24,113,119,209,73,141,186, 17,109,206,234,26,132,87,238,114,251,238,4,94,123,252,181,47,111,127,244, 213,47,39,28,62,184,183,118,252,81,253,29,91,118,149,239,51,56,106,235, 30,23,95,253,252,151,49,107,222,87,229,11,151,111,84,22,77,251,176,194, 107,252,11,216,218,136,107,135,44,82,207,2,168,76,2,254,253,236,147,233, 30,183,135,135,30,124,180,204,89,238,60,22,104,126,143,179,18,34,68,237, 219,182,227,144,56,255,205,107,223,182,29,27,214,36,220,34,128,66,8,216, 232,114,235,215,3,183,254,50,127,245,216,223,23,174,62,202,145,146,52, 22,8,254,7,251,231,207,243,55,204,153,246,235,95,63,25,6,191,3,63,130, 138,201,51,163,35,149,0,128,153,4,156,122,231,109,247,76,3,148,203,229, 58,14,88,20,193,243,11,145,80,182,109,219,206,239,191,134,181,88,99,84, 108,88,179,154,109,219,154,244,76,16,209,8,115,231,206,227,133,23,94,140, 249,53,19,77,172,191,7,205,148,7,152,225,51,152,81,226,244,62,80,227,189, 143,75,93,190,143,227,81,168,72,38,0,0,63,187,92,174,35,49,135,105,173, 136,240,185,133,72,36,95,108,223,190,61,101,251,246,132,10,188,205,174, 239,188,25,155,51,123,246,236,39,103,207,142,75,2,216,184,69,245,163,227, 201,135,30,122,56,222,101,136,135,68,249,25,52,169,28,145,78,0,0,150,71, 225,156,9,165,180,172,52,228,249,12,165,254,167,180,229,238,220,225,95, 225,175,97,185,59,205,135,6,120,220,222,144,87,248,243,184,99,210,98,36, 170,236,151,125,221,162,210,15,68,104,53,182,102,238,158,120,23,32,78, 70,197,187,0,126,77,42,71,52,18,128,22,109,233,146,37,217,152,115,47,67, 86,225,118,85,164,36,167,134,117,76,222,142,130,10,79,129,30,214,49,155, 246,174,207,14,103,127,33,132,16,251,175,253,229,121,20,145,114,140,255, 149,200,126,246,191,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16, 66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132, 16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33, 132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66, 8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16,66,8,33,132,16, 66,8,17,81,135,250,95,66,8,33,132,216,79,116,112,164,90,10,29,169,150, 66,160,67,188,11,19,65,7,0,223,3,170,198,43,216,196,38,190,15,80,86,203, 62,191,70,160,252,66,136,253,132,37,222,5,16,251,37,75,122,186,245,211, 107,46,234,228,184,250,162,142,105,25,105,214,175,1,107,188,11,21,1,71, 3,243,128,113,113,186,254,200,56,93,87,8,209,12,105,241,46,64,11,118,24, 48,166,158,247,45,128,17,194,121,66,217,239,35,96,115,104,197,138,191, 148,20,203,195,253,123,57,110,157,62,121,64,58,10,78,185,228,207,242,85, 107,202,159,117,86,24,15,196,187,108,77,112,6,230,207,193,14,124,11,92, 0,148,196,240,250,129,86,2,249,55,45,132,8,137,252,177,136,142,209,153, 105,73,223,255,253,196,131,147,108,214,125,191,197,62,221,96,203,206,18, 122,118,206,194,162,213,253,35,8,101,191,217,11,215,177,124,99,201,67, 152,205,198,205,193,232,172,76,235,183,191,125,57,200,209,190,109,18,74, 41,118,239,245,48,242,140,21,206,162,18,253,52,224,199,120,23,176,145, 58,2,243,49,131,255,245,128,47,198,215,151,4,64,8,17,22,91,188,11,208, 2,141,204,74,75,154,249,206,131,167,38,141,24,212,101,159,55,221,30,157, 153,243,54,113,247,37,71,146,154,92,247,183,63,148,253,54,253,181,152, 181,127,150,178,60,98,69,143,186,182,142,84,203,231,111,62,221,171,50, 248,43,165,104,219,218,198,127,159,62,208,113,241,45,235,63,113,186,140, 254,192,174,120,23,180,17,118,2,131,129,252,192,6,165,84,79,160,103,52, 47,170,105,218,172,104,158,95,8,209,114,73,2,16,89,35,51,82,109,179,30, 191,97,76,82,167,182,233,108,202,45,170,246,166,199,107,48,103,233,118, 142,26,212,153,93,249,101,117,158,36,148,253,220,5,235,89,188,112,110, 36,203,222,104,169,118,235,5,88,213,81,46,151,177,10,88,231,127,109,163, 250,224,53,75,70,186,245,139,203,206,111,159,62,230,168,172,202,224,143, 255,227,136,225,233,92,118,94,219,180,247,62,219,251,105,105,153,126,52, 213,187,61,52,160,43,208,11,232,149,154,108,25,160,43,237,119,143,71,159, 18,171,58,134,40,166,193,95,8,33,154,34,86,9,128,29,24,130,217,47,62,4, 104,111,181,90,219,91,44,150,182,74,41,167,97,24,46,195,48,246,0,235,129, 21,254,215,60,98,223,140,218,20,35,179,210,146,126,124,252,134,49,73,195, 250,238,59,168,61,56,168,167,216,235,30,239,22,202,126,75,150,46,97,251, 134,85,180,201,136,88,217,155,70,83,71,30,58,40,235,134,238,157,83,220, 171,215,149,123,54,109,117,218,74,74,245,164,244,116,91,174,205,198,250, 114,167,190,220,231,35,251,192,238,169,131,238,185,177,139,189,102,240, 15,188,238,186,174,189,253,215,5,37,131,255,92,231,126,75,41,35,223,145, 98,29,168,12,213,219,233,86,93,210,29,22,79,215,78,73,158,131,122,216, 109,187,118,123,211,151,253,233,6,72,180,4,0,136,91,240,151,166,127,33, 68,88,162,153,0,164,0,227,129,11,44,22,203,105,134,97,36,3,100,103,103, 235,29,59,118,212,178,178,50,45,14,71,26,62,159,15,183,219,141,211,89, 174,54,110,220,116,108,121,121,185,21,192,106,181,22,235,186,254,53,240, 57,240,13,160,71,177,172,77,53,50,43,45,233,199,119,30,60,213,94,95,179, 255,133,39,246,15,169,217,191,190,253,54,253,181,152,237,27,86,69,172, 224,145,224,114,27,127,118,237,152,236,124,229,95,189,29,74,169,100,165, 20,229,78,31,27,54,187,186,109,216,236,234,182,97,139,107,204,182,237, 110,207,29,215,117,74,182,90,168,37,248,27,160,20,86,11,188,245,116,247, 180,103,223,204,187,160,107,71,187,189,71,151,36,173,71,151,36,186,119, 78,194,145,162,37,41,165,210,148,82,220,241,120,158,115,238,18,87,98,125, 19,252,228,206,95,8,209,92,68,35,1,200,0,110,176,90,173,119,233,186,158, 157,157,157,173,143,28,57,194,218,187,119,111,186,117,235,202,159,127, 174,182,206,155,191,144,213,107,214,82,86,90,138,166,65,90,122,6,7,28, 112,128,54,97,194,223,173,125,250,244,97,231,206,93,172,92,185,34,235, 183,223,126,191,176,164,164,228,34,171,213,186,69,215,245,167,129,119, 0,103,20,202,220,20,33,5,255,113,135,245,8,41,248,215,183,223,166,191, 22,243,199,31,191,71,172,224,17,180,110,245,250,114,111,240,221,188,35, 197,194,192,62,14,6,244,78,69,41,165,161,84,178,66,161,235,138,229,171, 203,88,183,209,197,158,124,47,10,69,187,214,54,14,232,158,204,192,222, 41,180,111,99,227,201,123,58,37,7,159,171,102,75,193,218,141,21,94,96, 109,156,234,250,29,112,124,45,219,181,64,240,31,62,124,248,37,11,23,46, 188,56,248,77,165,212,177,213,118,214,180,106,131,29,15,61,244,208,247, 23,44,88,240,94,224,107,155,205,54,77,215,245,148,224,125,114,114,114, 86,238,221,187,247,230,38,215,64,8,33,136,108,2,96,5,110,180,90,173,15, 26,134,145,61,108,216,80,117,220,113,227,232,223,127,128,213,98,177,240, 203,47,191,48,241,161,199,232,126,80,63,134,140,62,131,11,111,58,148,156, 182,237,176,89,52,138,10,246,176,102,217,124,230,255,50,147,143,63,249, 148,191,157,127,30,23,95,124,49,19,38,76,176,174,92,185,146,105,211,190, 237,186,124,249,242,151,173,86,235,131,186,174,223,136,57,221,42,17,236, 151,125,254,181,88,183,121,171,43,169,174,128,141,82,236,218,227,225,197, 183,119,242,237,143,197,244,237,219,141,161,131,122,146,211,202,142,211, 89,196,156,69,91,121,237,131,124,246,22,120,56,101,92,22,215,77,104,77, 155,214,214,58,207,181,45,215,151,132,57,206,32,30,70,213,182,49,22,119, 254,249,249,249,3,163,121,126,33,196,254,37,82,253,134,125,173,86,235, 187,186,174,31,62,108,216,48,117,214,89,103,105,7,28,208,19,187,61,137, 54,109,218,240,226,75,175,178,120,217,42,46,190,253,73,122,246,25,136, 205,162,97,179,106,216,44,22,172,86,173,218,215,27,215,174,224,233,251, 111,98,96,191,62,92,114,201,69,84,84,184,1,216,184,113,3,147,38,125,104, 172,94,189,218,162,105,218,12,165,212,53,192,150,8,149,191,49,2,125,254, 246,88,247,249,239,45,53,63,182,201,128,233,203,21,51,87,169,120,79,3, 180,216,108,90,197,230,249,71,36,57,82,44,213,2,182,50,20,47,189,147,203, 235,31,236,230,206,91,142,225,239,231,31,70,251,54,14,20,85,1,221,240, 229,227,115,173,98,211,150,82,254,59,105,59,31,124,186,147,107,254,222, 154,43,255,214,10,168,30,252,157,46,131,33,167,108,246,250,116,149,66, 104,235,40,68,90,5,144,140,217,197,229,134,152,141,246,255,209,127,173, 154,45,9,129,89,0,50,13,80,8,17,150,72,252,177,152,96,177,88,222,74,75, 75,179,93,122,233,63,44,71,30,121,36,41,41,41,28,112,64,79,58,119,238, 204,141,55,221,202,159,27,115,185,244,238,23,72,77,115,96,179,88,204,96, 111,213,176,6,62,183,84,255,218,91,225,228,209,59,175,228,192,238,157, 120,224,129,251,216,188,121,51,123,247,230,163,148,193,207,63,207,102, 210,164,201,186,219,237,46,213,117,253,76,224,231,8,212,33,92,49,109,246, 255,102,166,217,236,95,51,1,200,114,192,135,115,21,75,183,170,71,128,184, 46,162,147,149,105,221,250,205,123,7,119,29,208,219,81,25,176,43,42,124, 220,120,223,38,74,92,41,124,248,246,69,180,201,201,54,239,232,217,183, 121,95,119,175,67,175,216,142,194,96,235,118,23,151,221,242,39,29,218, 88,120,242,158,118,36,219,169,220,239,207,117,110,38,220,186,115,107,73, 185,209,61,78,85,245,0,73,152,3,91,189,177,234,243,151,4,64,8,17,105,77, 89,10,88,195,12,58,239,15,24,208,63,233,233,167,159,182,140,24,49,130, 131,14,58,136,81,163,70,210,181,107,87,62,252,112,10,191,205,95,194,133, 183,63,135,213,158,130,110,168,170,151,174,208,13,195,255,177,250,203, 158,226,224,254,127,191,201,220,5,139,152,57,243,123,134,13,27,198,176, 97,195,200,204,204,98,204,152,49,252,235,95,255,178,118,237,218,53,83, 211,180,31,128,107,34,243,173,8,217,97,153,105,73,179,222,157,120,90,157, 193,255,135,5,155,57,46,132,224,223,208,126,245,245,249,251,12,248,51, 87,209,38,29,136,207,157,112,53,86,139,182,118,195,102,23,74,25,230,203, 48,184,225,159,155,200,204,206,225,219,207,174,162,77,155,108,80,230,146, 245,129,192,143,81,213,74,128,165,21,134,50,80,186,162,83,251,36,190,122, 123,0,88,172,220,245,68,30,202,168,74,24,54,109,247,96,177,106,241,234, 255,135,170,127,51,129,239,185,12,248,19,66,52,75,77,25,3,240,10,112,237, 152,49,199,112,249,229,151,209,186,117,107,14,62,248,96,210,210,210,0, 112,58,157,60,252,232,227,92,112,215,43,88,147,82,240,25,10,52,208,80, 84,46,106,87,243,107,255,231,26,144,148,226,224,238,71,95,230,190,27,39, 112,250,233,167,209,166,77,14,57,57,71,176,113,227,70,52,77,227,193,7, 239,183,188,254,250,127,212,188,121,243,95,3,50,129,167,154,80,151,112, 156,116,218,16,107,82,235,146,89,172,153,179,239,155,59,10,12,82,128,205, 11,234,31,172,23,202,126,139,215,23,215,186,221,103,192,186,221,138,195, 15,208,216,89,84,219,115,98,98,175,220,101,44,91,191,201,57,86,169,108, 13,165,120,241,237,157,20,151,39,241,209,228,191,99,75,74,174,188,243, 15,60,182,70,213,248,31,202,94,149,60,40,157,36,187,226,149,71,123,114, 198,21,127,241,223,143,138,184,252,188,76,148,82,108,222,238,85,46,151, 190,44,142,85,173,153,0,8,33,68,179,212,216,22,128,135,128,107,207,56, 227,116,174,186,234,42,186,117,235,206,97,135,29,86,25,252,1,62,255,252, 115,58,31,116,8,29,122,244,195,87,227,174,223,103,40,118,109,223,194,180, 255,189,201,212,255,189,201,206,237,91,252,119,255,213,91,4,122,246,30, 64,239,1,131,248,226,139,47,1,208,52,141,3,15,60,144,195,14,27,78,118, 118,43,110,190,249,38,109,244,232,209,0,79,0,87,55,237,91,17,58,91,28, 31,161,228,211,205,224,127,80,59,141,122,134,22,196,154,197,48,104,189, 105,155,219,163,252,3,254,94,255,32,143,41,239,76,48,131,191,129,191,9, 31,148,50,48,130,155,255,141,64,55,128,7,195,48,91,14,12,93,97,24,6,246, 36,120,253,241,238,188,49,165,136,61,5,94,80,6,219,114,189,30,195,32,135, 248,61,200,202,130,153,163,198,52,243,82,74,29,91,179,249,191,6,13,105, 254,23,66,132,161,49,127,68,175,1,30,24,59,118,44,231,159,127,62,189,122, 245,98,224,192,1,88,44,213,79,245,197,87,211,232,53,252,132,125,154,247, 117,67,49,243,147,183,248,97,210,19,28,63,252,64,166,77,126,137,137,215, 159,195,215,83,222,172,124,223,23,148,44,28,125,220,233,76,155,54,189, 218,185,179,179,179,57,226,136,35,200,202,202,230,202,43,175,96,248,240, 225,104,154,246,26,112,110,163,191,19,205,128,79,135,85,185,102,240,79, 74,156,231,56,182,203,72,183,206,30,208,59,245,220,187,174,235,148,28, 184,251,191,245,134,35,105,219,182,141,255,110,223,48,163,165,50,252,45, 0,6,24,85,235,1,24,74,161,251,74,81,186,81,149,4,24,10,195,208,233,212, 206,194,57,39,103,243,198,148,18,148,82,220,112,113,102,114,223,131,146, 206,203,72,215,126,5,218,197,183,234,66,8,209,124,133,27,70,134,104,154, 246,210,208,161,67,212,229,151,95,70,175,94,189,56,224,128,218,187,64, 151,47,95,78,167,94,67,240,213,232,227,207,203,221,66,241,150,37,204,156, 62,141,131,15,62,24,128,194,189,121,76,251,223,27,236,220,190,165,170, 181,192,255,234,63,248,112,150,46,219,183,197,55,57,217,206,97,135,13, 167,67,135,246,220,120,227,13,90,159,62,125,176,88,44,239,98,46,23,219, 226,248,12,51,248,247,235,148,80,193,127,116,106,170,229,207,115,78,105, 115,216,180,15,250,167,117,106,151,132,174,43,166,126,95,196,63,254,62, 194,220,67,25,230,157,191,161,80,128,161,12,204,113,0,70,101,223,62,134, 129,225,221,139,161,20,134,210,49,12,29,165,235,149,201,192,133,103,100, 241,237,207,229,24,134,162,125,142,133,41,207,181,117,252,253,212,180, 67,147,237,218,95,192,113,113,172,191,16,66,52,91,225,132,146,100,155, 205,246,97,86,86,150,229,218,107,175,213,122,247,174,59,248,235,186,78, 113,81,1,169,25,173,247,105,218,95,254,199,15,76,184,224,60,22,47,94,204, 17,71,28,65,113,177,217,207,93,184,55,143,121,63,207,48,247,13,74,0,178, 114,218,82,144,191,23,93,223,119,33,64,171,213,202,224,193,131,233,216, 177,3,55,221,116,131,230,112,56,82,108,54,219,167,152,211,180,90,140,64, 159,127,191,78,9,211,236,175,165,166,90,238,200,204,176,78,123,231,217, 94,57,79,222,219,221,158,100,53,239,232,151,253,89,70,159,222,93,105,223, 62,211,63,112,15,243,142,31,115,208,31,4,146,129,170,217,0,134,238,68, 119,239,1,67,71,233,10,229,79,2,12,195,64,55,12,186,117,176,144,149,97, 97,213,58,15,74,41,44,154,226,198,139,210,237,175,78,204,206,206,74,215, 190,76,73,225,49,204,117,40,132,16,66,132,40,156,4,224,159,186,174,247, 189,254,250,107,45,7,28,112,192,255,183,119,231,209,85,86,231,30,199,127, 239,57,25,72,64,102,100,16,208,200,160,160,40,112,175,82,17,45,82,209, 58,128,128,67,21,212,186,168,88,236,213,219,82,197,97,181,85,244,182,10, 214,161,93,162,86,111,173,179,208,216,82,22,21,238,189,90,177,72,47,214, 161,122,69,25,194,144,4,3,52,33,132,33,36,103,124,247,222,247,143,115, 78,72,72,0,195,144,115,130,223,207,90,103,193,57,121,207,122,247,27,22, 235,217,195,179,159,173,126,253,250,237,247,66,207,243,228,201,83,220, 52,12,230,190,117,178,86,154,49,99,134,198,142,29,43,107,27,230,81,89, 121,245,114,5,156,124,227,228,155,3,231,90,5,2,1,13,29,58,84,5,5,5,186, 245,214,91,3,198,152,51,36,221,219,140,231,202,104,25,184,230,223,237, 184,118,89,239,13,234,159,55,235,127,23,158,209,118,204,185,29,26,20,235, 217,80,26,209,200,111,244,79,100,248,167,182,251,73,245,234,2,36,102,4, 100,19,127,151,181,138,71,54,38,3,126,242,101,156,156,53,178,198,36,255, 116,58,181,95,142,138,203,226,13,238,53,226,140,108,45,250,77,231,252, 193,39,103,255,176,109,190,183,66,137,35,121,143,182,100,26,99,203,242, 60,239,157,125,171,7,238,35,45,237,2,208,122,53,167,3,16,117,206,169,182, 182,86,67,134,28,184,32,89,32,16,80,135,78,157,85,179,107,123,195,117, 125,235,116,234,89,99,228,130,185,117,35,255,148,142,93,187,107,216,185, 99,27,229,11,84,85,86,168,115,151,174,10,6,247,31,253,130,193,160,134, 15,31,174,142,29,59,212,125,212,140,231,202,88,25,184,230,63,60,63,47, 176,110,218,228,238,103,47,121,245,180,182,221,187,101,55,170,212,87,81, 25,87,239,222,93,148,88,252,79,198,164,186,109,124,54,217,25,72,38,2,202, 201,196,171,100,162,91,19,211,253,201,28,128,212,232,223,154,68,39,192, 88,163,110,157,3,170,172,50,13,139,12,57,167,78,237,61,61,255,139,246, 109,167,92,150,59,60,47,215,91,45,233,64,137,114,0,128,164,230,108,3,156, 237,121,222,57,79,62,249,212,165,99,198,124,203,27,53,234,220,3,94,124, 198,153,103,106,203,186,79,213,110,196,197,201,212,100,43,207,11,168,67, 183,222,26,53,238,38,253,237,207,47,169,122,71,133,36,169,99,151,238,26, 123,213,52,117,58,190,183,140,117,242,228,234,242,153,87,254,227,125,13, 29,54,236,160,141,11,133,66,154,59,247,41,19,12,6,55,250,190,255,80,51, 158,171,217,170,195,78,101,85,77,159,77,84,177,59,49,8,179,238,192,131, 177,175,114,221,234,173,78,131,123,121,218,125,128,211,15,14,114,155,163, 195,37,19,248,164,6,193,56,21,240,3,94,150,172,219,155,228,87,191,240, 79,253,195,127,172,9,43,86,251,185,172,73,108,255,179,214,200,58,43,107, 18,51,3,137,92,0,43,103,77,98,183,64,189,251,237,219,241,96,232,11,0,205, 211,156,14,128,113,206,77,241,60,239,163,27,110,184,241,228,5,11,254,24, 28,54,108,232,126,47,158,56,254,82,61,243,202,34,157,50,226,226,134,53, 0,36,141,184,244,70,13,30,113,161,214,126,244,142,60,73,67,71,93,164,238, 61,251,38,131,191,148,216,55,22,144,39,233,239,75,223,212,245,87,143,59, 96,195,226,241,184,166,77,187,197,149,151,151,59,231,220,181,146,194,205, 120,174,140,53,184,151,167,172,3,204,101,196,141,180,45,81,21,176,165, 230,7,62,9,133,237,192,255,156,87,190,224,221,247,119,13,123,241,137,254, 109,187,119,205,106,16,144,187,119,205,82,249,182,234,186,228,63,165,166, 253,149,234,16,216,68,192,54,17,197,246,124,34,99,34,137,209,191,51,178, 214,37,131,125,114,244,159,234,4,248,70,21,85,190,6,247,207,109,20,252, 171,118,25,221,49,167,166,118,93,169,89,21,142,186,9,146,254,217,66,191, 11,0,104,213,154,91,8,104,183,239,251,23,213,212,212,188,59,126,252,21, 125,10,11,127,31,60,231,156,111,52,121,225,149,87,94,169,255,248,197,28, 85,148,174,81,247,147,6,53,26,217,183,239,218,75,35,47,251,110,162,4,112, 48,177,246,159,42,2,148,234,44,148,20,125,166,146,162,207,53,113,226,243, 251,109,144,115,78,183,223,254,239,250,203,95,222,145,18,91,20,63,109, 230,51,53,91,251,60,79,125,186,52,29,153,3,94,34,103,225,132,206,7,142, 201,95,229,186,202,157,251,255,126,26,43,1,86,238,169,49,231,175,221,24, 190,227,188,73,95,204,122,230,161,130,182,23,140,60,174,46,40,159,220, 55,87,111,190,186,94,206,13,223,27,168,229,246,102,252,59,201,198,171, 21,175,253,76,214,15,37,58,7,214,212,155,250,119,117,185,0,206,79,118, 6,156,213,186,18,95,223,157,144,223,32,248,127,240,89,76,51,31,169,9,69, 125,247,235,72,68,247,169,101,142,140,78,203,94,251,131,212,0,144,168, 1,0,160,153,14,101,228,88,106,140,57,55,26,141,110,156,52,233,74,187,112, 225,194,38,47,106,211,166,141,238,251,233,189,250,235,203,15,40,30,13, 201,57,53,89,19,160,254,158,255,250,185,2,161,218,90,253,238,151,119,107, 214,253,63,83,94,94,94,147,247,240,125,95,51,102,252,88,133,133,111,72, 137,196,191,253,247,20,142,33,245,119,5,4,211,147,27,224,194,97,251,104, 245,30,115,217,205,51,139,171,238,157,253,101,44,30,79,76,227,159,126, 74,174,86,174,92,175,178,178,45,117,193,58,145,253,239,228,108,76,126, 120,189,162,123,62,150,241,67,201,132,191,212,222,255,196,90,191,51,70, 198,216,6,73,129,155,182,248,170,222,99,53,232,228,196,9,129,198,88,205, 125,173,54,118,251,207,107,118,237,174,113,19,34,17,253,68,45,19,252,1, 224,152,113,168,225,99,171,239,251,163,124,223,255,96,234,212,155,117, 199,29,119,42,26,141,54,186,104,242,228,235,116,254,200,179,244,223,207, 222,173,120,52,148,40,248,98,92,163,196,192,186,247,201,159,133,106,106, 245,220,207,111,211,121,231,142,208,119,190,115,77,147,13,216,185,115, 167,38,77,186,202,190,252,242,43,146,244,160,164,57,135,248,44,173,74, 134,237,10,88,22,142,216,193,127,92,188,235,195,113,83,215,215,110,173, 136,201,147,211,37,163,219,233,201,103,150,200,15,125,46,19,45,149,31, 45,85,188,246,11,69,171,151,43,30,46,145,179,241,196,186,191,169,159,240, 183,247,253,222,78,64,98,185,96,254,226,144,46,62,47,87,146,85,249,118, 95,55,204,220,29,154,255,102,244,227,104,204,157,34,233,237,116,255,18, 0,160,53,58,156,241,99,165,49,230,124,73,115,94,120,225,69,55,122,244, 5,102,249,242,198,197,241,127,245,248,47,117,214,224,2,45,152,51,85,21, 165,107,18,157,0,235,154,60,4,200,88,167,146,162,149,122,98,230,53,58, 125,96,95,61,250,200,236,38,111,188,108,217,50,141,30,61,198,172,88,177, 194,151,116,189,164,251,15,227,57,90,141,12,220,21,32,73,219,106,66,230, 155,107,214,133,223,120,236,185,138,168,115,78,183,94,223,89,175,188,177, 85,155,54,109,150,137,108,148,31,217,40,19,45,175,183,174,159,42,249,107, 235,173,247,167,246,253,239,45,4,228,156,211,150,242,184,22,45,141,232, 123,87,181,145,115,78,79,191,30,138,22,149,152,194,61,33,119,158,164,109, 233,126,120,0,104,173,14,231,48,32,73,242,37,221,35,233,221,245,235,55, 60,123,197,21,19,78,188,252,242,203,220,253,247,223,231,165,234,4,100, 103,103,107,238,147,79,104,222,188,249,154,245,224,29,234,218,119,144, 10,254,101,172,250,158,50,92,29,58,119,147,51,1,85,239,217,174,178,162, 79,180,238,195,183,244,207,146,85,122,224,254,159,53,57,242,47,47,47,215, 172,89,15,168,176,240,13,5,131,193,18,107,237,20,73,31,30,230,51,180,10, 245,43,1,86,31,96,87,64,154,216,64,32,176,227,196,19,114,114,156,115,234, 218,57,168,233,147,59,235,166,31,173,210,162,23,135,40,59,59,149,249,159, 40,241,235,234,37,248,89,151,218,235,191,119,219,159,53,126,226,56,225, 168,213,157,143,84,107,218,213,121,234,212,222,147,115,78,189,187,7,114, 20,80,149,76,218,14,227,73,203,177,187,251,59,14,184,30,142,3,6,208,44, 135,219,1,72,249,31,107,237,169,146,102,44,89,242,95,63,93,188,120,73, 222,133,23,94,168,233,211,111,241,70,143,30,45,207,243,116,221,117,215, 106,194,132,43,180,96,193,159,180,112,209,18,253,97,193,175,181,107,103, 149,36,169,83,167,46,26,58,108,152,166,77,185,66,19,39,190,208,104,205, 191,168,168,72,115,231,62,173,194,194,66,107,18,37,1,31,50,198,60,44,169, 241,186,195,49,168,254,233,127,25,48,237,223,164,182,249,222,153,5,125, 178,189,84,150,254,205,215,118,212,202,162,136,190,127,215,90,61,253,80, 63,229,100,43,89,216,103,239,94,127,99,173,100,108,114,237,223,202,90, 63,49,250,79,6,255,123,30,221,163,62,61,130,154,50,46,183,46,241,175,111, 207,128,215,54,207,59,115,87,156,141,127,0,112,56,142,84,7,64,146,34,146, 30,182,214,62,47,105,250,210,165,75,255,237,237,183,223,62,190,91,183, 110,230,146,75,190,29,188,232,162,139,52,98,196,217,154,50,101,178,166, 76,153,44,73,117,149,0,247,61,72,40,22,139,105,213,170,85,122,235,173, 183,181,120,241,18,243,197,23,95,4,3,129,64,216,90,251,91,73,79,72,42, 57,130,237,206,104,7,91,243,55,25,18,7,125,227,6,158,212,59,103,111,226, 159,156,230,220,221,77,247,204,217,166,9,83,87,235,55,179,11,212,235,248, 172,189,75,0,38,149,253,239,39,63,243,19,89,255,206,106,115,185,175,59, 231,84,171,111,207,160,102,221,150,47,105,239,222,255,62,61,60,249,190, 6,166,251,121,1,160,181,59,146,29,128,148,109,146,30,52,198,204,150,52, 161,178,178,114,210,107,175,189,126,233,203,47,191,114,156,36,117,233, 210,197,12,25,114,122,160,71,143,30,94,251,246,237,149,151,151,39,107, 173,170,171,171,181,99,199,14,21,21,173,51,197,197,27,3,190,111,60,207, 243,108,32,160,247,37,45,176,214,190,36,105,199,81,104,111,198,58,216, 154,255,198,109,210,123,69,174,86,210,146,22,111,92,67,129,80,196,245, 56,241,132,172,6,197,121,218,228,72,143,255,164,155,158,47,220,165,177, 215,173,209,53,151,119,210,245,19,59,169,79,207,96,114,7,128,95,87,238, 215,25,171,210,45,113,205,95,28,210,162,165,81,77,187,58,79,83,198,229, 170,126,240,119,206,169,79,79,79,145,168,235,169,68,254,74,186,150,1,50, 205,180,116,55,0,64,235,115,52,58,0,41,49,73,133,146,10,141,49,89,146, 70,74,26,94,85,85,53,100,249,242,191,13,9,4,2,221,173,181,29,173,181,237, 60,207,139,4,2,94,141,228,237,242,125,191,72,210,74,73,159,57,231,222, 53,70,219,143,98,27,15,73,38,84,2,44,219,33,205,255,208,214,196,124,141, 87,250,243,32,122,183,203,15,196,243,114,189,236,125,43,245,73,78,83,175, 110,175,241,223,202,215,115,243,118,235,202,239,23,171,195,113,65,13,238, 159,163,206,29,3,146,179,170,220,97,180,102,99,92,123,106,173,46,30,149, 171,133,79,117,168,91,243,223,183,240,79,155,28,41,63,215,139,87,135,220, 9,146,202,210,240,172,153,84,7,160,68,210,15,36,205,85,34,7,96,106,139, 54,10,64,171,118,52,59,0,245,249,146,222,75,190,100,140,105,112,186,159, 115,137,67,130,208,208,254,42,1,150,237,144,230,125,96,67,113,163,241, 146,222,109,241,134,53,54,160,111,207,172,248,254,202,244,202,89,117,233, 232,233,158,233,29,116,215,45,237,181,102,67,76,27,191,140,107,251,78, 35,231,60,157,90,144,173,27,39,180,209,41,5,65,121,218,247,187,141,223, 247,234,225,197,171,139,221,0,165,167,3,144,41,74,60,207,219,38,105,102, 242,253,109,146,94,76,95,115,0,180,54,45,213,1,56,166,164,179,18,96,113, 101,98,228,159,65,193,95,146,6,244,47,200,205,174,31,176,67,97,163,146, 178,152,74,55,199,181,105,75,220,109,46,247,99,63,152,114,92,110,247,46, 1,13,234,151,165,83,147,69,125,26,84,11,116,78,21,219,141,158,153,31,142, 246,234,230,229,244,237,25,240,250,244,240,212,167,167,167,54,57,170,187, 182,95,111,47,123,109,177,6,74,90,154,238,7,79,147,18,207,243,82,121,48, 23,72,250,166,164,151,210,216,30,0,173,16,29,128,86,164,184,82,122,246, 175,117,211,254,153,18,252,149,155,27,24,188,181,34,158,127,215,236,138, 232,250,146,88,236,203,45,241,172,61,33,155,221,46,47,176,53,43,203,219, 16,10,155,149,190,175,142,171,55,196,174,154,247,120,215,118,129,64,19, 163,123,57,25,223,233,71,15,239,169,93,87,108,222,112,158,170,218,228, 120,167,59,167,129,145,168,235,221,54,207,139,245,58,222,139,21,244,246, 178,182,85,185,118,185,185,58,173,137,218,83,95,7,245,131,191,36,149,38, 95,0,208,44,116,0,90,137,178,29,210,239,63,180,181,153,22,252,37,201,57, 239,253,207,86,71,189,191,127,26,94,37,105,125,242,85,182,187,198,214, 79,112,8,148,110,246,7,252,234,165,234,179,102,220,212,46,167,169,169, 253,39,95,13,197,54,109,182,255,23,55,250,158,36,91,227,215,125,221,171, 174,117,125,170,75,220,128,181,37,26,144,155,171,211,156,211,138,22,126, 204,148,180,214,1,104,233,251,2,56,118,209,1,104,5,202,118,72,243,63,176, 225,152,209,56,101,88,240,151,164,88,204,204,147,52,239,32,151,217,154, 144,155,248,250,159,67,107,207,30,146,221,121,228,176,236,6,193,255,131, 149,113,205,95,18,173,13,71,220,85,106,156,221,239,36,125,153,124,189, 243,53,29,249,3,192,17,69,7,32,195,21,87,74,133,31,217,80,204,232,114, 101,96,240,111,166,202,112,196,77,154,57,103,247,146,63,61,213,41,191, 107,39,79,114,78,219,119,26,221,57,167,38,20,142,184,171,37,149,167,187, 145,205,225,121,222,215,53,15,1,64,43,151,57,21,229,209,72,113,165,244, 219,101,54,18,137,31,19,193,63,101,89,44,238,61,246,195,135,170,107,108, 242,60,136,31,207,169,169,141,25,239,49,73,239,28,244,219,0,128,35,130, 25,128,67,240,121,153,209,235,43,34,77,254,108,119,56,177,68,220,33,239, 192,75,181,7,187,46,238,75,243,223,183,177,112,92,223,150,180,236,208, 91,155,121,34,49,59,171,184,204,141,153,251,122,232,44,57,231,109,216, 100,86,71,34,122,32,221,237,106,166,125,11,56,236,251,15,121,184,63,223, 44,41,255,16,218,5,0,95,9,9,69,205,119,146,164,233,45,116,175,5,74,127, 145,159,163,165,71,94,174,183,70,146,194,81,55,72,173,103,234,127,185, 164,81,77,124,126,164,59,0,53,146,218,238,243,217,63,36,253,235,193,26, 8,0,95,5,29,0,164,83,42,152,125,156,214,86,100,166,142,106,252,255,115, 183,40,127,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,215,201,255,3,249,81,189,66, 57,102,195,118,0,0,0,0,73,69,78,68,174,66,96,130, } }, goxel-0.11.0/src/assets/other.inl000066400000000000000000000036161435762723100166450ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* This file is autogenerated by tools/create_assets.py */ {.path = "data/other/povray_template.pov", .size = 748, .data = "// Generated from goxel {{version}}\n" "// https://github.com/guillaumechereau/goxel\n" "\n" "{{#camera}}\n" "camera {\n" " perspective\n" " right x*{{width}}/{{height}}\n" " direction <0, 0, -1>\n" " angle {{angle}}\n" " transform {\n" " matrix {{modelview}}\n" " inverse\n" " }\n" "}\n" "{{/camera}}\n" "\n" "#declare Voxel = box {<-0.5, -0.5, -0.5>, <0.5, 0.5, 0.5>}\n" "#macro Vox(Pos, Color)\n" " object {\n" " Voxel\n" " translate Pos\n" " translate <0.5, 0.5, 0.5>\n" " texture { pigment {color rgb Color / 255} }\n" " }\n" "#end\n" "\n" "{{#light}}\n" "global_settings { ambient_light rgb<1, 1, 1> * {{ambient}} }\n" "light_source {\n" " <0, 0, 1024> color rgb <2, 2, 2>\n" " parallel\n" " point_at {{point_at}}\n" "}\n" "{{/light}}\n" "\n" "union {\n" "{{#voxels}}\n" " Vox({{pos}}, {{color}})\n" "{{/voxels}}\n" "}\n" "" }, goxel-0.11.0/src/assets/palettes.inl000066400000000000000000002622661435762723100173550ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* This file is autogenerated by tools/create_assets.py */ {.path = "data/palettes/Blues.gpl", .size = 5204, .data = "GIMP Palette\n" "Name: Blues\n" "#\n" "# For them rainy days ... by Daniel Egnor\n" "#\n" " 0 0 0 #000000\n" "128 128 128 #808080\n" "255 255 255 #FFFFFF\n" " 0 0 4 #000004\n" " 0 0 12 #00000C\n" " 0 0 16 #000010\n" " 0 0 24 #000018\n" " 0 0 32 #000020\n" " 0 0 36 #000024\n" " 0 0 44 #00002C\n" " 0 0 48 #000030\n" " 0 0 56 #000038\n" " 0 0 64 #000040\n" " 0 0 68 #000044\n" " 0 0 76 #00004C\n" " 0 0 80 #000050\n" " 0 0 88 #000058\n" " 0 0 96 #000060\n" " 0 0 100 #000064\n" " 0 0 108 #00006C\n" " 0 0 116 #000074\n" " 0 0 120 #000078\n" " 0 0 128 #000080\n" " 0 0 132 #000084\n" " 0 0 140 #00008C\n" " 0 0 148 #000094\n" " 0 0 152 #000098\n" " 0 0 160 #0000A0\n" " 0 0 164 #0000A4\n" " 0 0 172 #0000AC\n" " 0 0 180 #0000B4\n" " 0 0 184 #0000B8\n" " 0 0 192 #0000C0\n" " 0 0 200 #0000C8\n" " 0 4 200 #0004C8\n" " 0 12 200 #000CC8\n" " 0 16 204 #0010CC\n" " 0 24 204 #0018CC\n" " 0 28 208 #001CD0\n" " 0 36 208 #0024D0\n" " 0 40 208 #0028D0\n" " 0 48 212 #0030D4\n" " 0 56 212 #0038D4\n" " 0 60 216 #003CD8\n" " 0 68 216 #0044D8\n" " 0 72 216 #0048D8\n" " 0 80 220 #0050DC\n" " 0 84 220 #0054DC\n" " 0 92 224 #005CE0\n" " 0 100 224 #0064E0\n" " 0 104 224 #0068E0\n" " 0 112 228 #0070E4\n" " 0 116 228 #0074E4\n" " 0 124 232 #007CE8\n" " 0 128 232 #0080E8\n" " 0 136 232 #0088E8\n" " 0 140 236 #008CEC\n" " 0 148 236 #0094EC\n" " 0 156 240 #009CF0\n" " 0 160 240 #00A0F0\n" " 0 168 240 #00A8F0\n" " 0 172 244 #00ACF4\n" " 0 180 244 #00B4F4\n" " 0 184 248 #00B8F8\n" " 0 192 248 #00C0F8\n" " 0 200 252 #00C8FC\n" " 4 200 252 #04C8FC\n" " 12 200 252 #0CC8FC\n" " 20 204 252 #14CCFC\n" " 28 204 252 #1CCCFC\n" " 36 208 252 #24D0FC\n" " 44 208 252 #2CD0FC\n" " 52 208 252 #34D0FC\n" " 60 212 252 #3CD4FC\n" " 68 212 252 #44D4FC\n" " 76 216 252 #4CD8FC\n" " 84 216 252 #54D8FC\n" " 92 216 252 #5CD8FC\n" "100 220 252 #64DCFC\n" "108 220 252 #6CDCFC\n" "116 224 252 #74E0FC\n" "124 224 252 #7CE0FC\n" "132 224 252 #84E0FC\n" "140 228 252 #8CE4FC\n" "148 228 252 #94E4FC\n" "156 232 252 #9CE8FC\n" "164 232 252 #A4E8FC\n" "172 232 252 #ACE8FC\n" "180 236 252 #B4ECFC\n" "188 236 252 #BCECFC\n" "196 240 252 #C4F0FC\n" "204 240 252 #CCF0FC\n" "212 240 252 #D4F0FC\n" "220 244 252 #DCF4FC\n" "228 244 252 #E4F4FC\n" "236 248 252 #ECF8FC\n" "244 248 252 #F4F8FC\n" "252 252 252 #FCFCFC\n" "248 252 252 #F8FCFC\n" "244 252 252 #F4FCFC\n" "240 252 252 #F0FCFC\n" "232 252 252 #E8FCFC\n" "228 252 252 #E4FCFC\n" "224 252 252 #E0FCFC\n" "216 252 252 #D8FCFC\n" "212 252 252 #D4FCFC\n" "208 252 252 #D0FCFC\n" "200 252 252 #C8FCFC\n" "196 252 252 #C4FCFC\n" "192 252 252 #C0FCFC\n" "184 252 252 #B8FCFC\n" "180 252 252 #B4FCFC\n" "176 252 252 #B0FCFC\n" "168 252 252 #A8FCFC\n" "164 252 252 #A4FCFC\n" "160 252 252 #A0FCFC\n" "156 252 252 #9CFCFC\n" "148 252 252 #94FCFC\n" "144 252 252 #90FCFC\n" "140 252 252 #8CFCFC\n" "132 252 252 #84FCFC\n" "128 252 252 #80FCFC\n" "124 252 252 #7CFCFC\n" "116 252 252 #74FCFC\n" "112 252 252 #70FCFC\n" "108 252 252 #6CFCFC\n" "100 252 252 #64FCFC\n" " 96 252 252 #60FCFC\n" " 92 252 252 #5CFCFC\n" " 84 252 252 #54FCFC\n" " 80 252 252 #50FCFC\n" " 76 252 252 #4CFCFC\n" " 72 252 252 #48FCFC\n" " 64 252 252 #40FCFC\n" " 60 252 252 #3CFCFC\n" " 56 252 252 #38FCFC\n" " 48 252 252 #30FCFC\n" " 44 252 252 #2CFCFC\n" " 40 252 252 #28FCFC\n" " 32 252 252 #20FCFC\n" " 28 252 252 #1CFCFC\n" " 24 252 252 #18FCFC\n" " 16 252 252 #10FCFC\n" " 12 252 252 #0CFCFC\n" " 8 252 252 #08FCFC\n" " 0 252 252 #00FCFC\n" " 0 248 252 #00F8FC\n" " 0 244 252 #00F4FC\n" " 0 240 252 #00F0FC\n" " 0 232 252 #00E8FC\n" " 0 228 252 #00E4FC\n" " 0 224 252 #00E0FC\n" " 0 216 252 #00D8FC\n" " 0 212 252 #00D4FC\n" " 0 208 252 #00D0FC\n" " 0 200 252 #00C8FC\n" " 0 196 252 #00C4FC\n" " 0 192 252 #00C0FC\n" " 0 184 252 #00B8FC\n" " 0 180 252 #00B4FC\n" " 0 176 252 #00B0FC\n" " 0 168 252 #00A8FC\n" " 0 164 252 #00A4FC\n" " 0 160 252 #00A0FC\n" " 0 156 252 #009CFC\n" " 0 148 252 #0094FC\n" " 0 144 252 #0090FC\n" " 0 140 252 #008CFC\n" " 0 132 252 #0084FC\n" " 0 128 252 #0080FC\n" " 0 124 252 #007CFC\n" " 0 116 252 #0074FC\n" " 0 112 252 #0070FC\n" " 0 108 252 #006CFC\n" " 0 100 252 #0064FC\n" " 0 96 252 #0060FC\n" " 0 92 252 #005CFC\n" " 0 84 252 #0054FC\n" " 0 80 252 #0050FC\n" " 0 76 252 #004CFC\n" " 0 72 252 #0048FC\n" " 0 64 252 #0040FC\n" " 0 60 252 #003CFC\n" " 0 56 252 #0038FC\n" " 0 48 252 #0030FC\n" " 0 44 252 #002CFC\n" " 0 40 252 #0028FC\n" " 0 32 252 #0020FC\n" " 0 28 252 #001CFC\n" " 0 24 252 #0018FC\n" " 0 16 252 #0010FC\n" " 0 12 252 #000CFC\n" " 0 8 252 #0008FC\n" " 0 0 252 #0000FC\n" " 0 0 248 #0000F8\n" " 0 0 244 #0000F4\n" " 0 0 240 #0000F0\n" " 0 0 236 #0000EC\n" " 0 0 232 #0000E8\n" " 0 0 228 #0000E4\n" " 0 0 224 #0000E0\n" " 0 0 220 #0000DC\n" " 0 0 216 #0000D8\n" " 0 0 212 #0000D4\n" " 0 0 208 #0000D0\n" " 0 0 204 #0000CC\n" " 0 0 200 #0000C8\n" " 0 0 196 #0000C4\n" " 0 0 192 #0000C0\n" " 0 0 188 #0000BC\n" " 0 0 184 #0000B8\n" " 0 0 180 #0000B4\n" " 0 0 176 #0000B0\n" " 0 0 172 #0000AC\n" " 0 0 168 #0000A8\n" " 0 0 164 #0000A4\n" " 0 0 160 #0000A0\n" " 0 0 156 #00009C\n" " 0 0 152 #000098\n" " 0 0 148 #000094\n" " 0 0 144 #000090\n" " 0 0 140 #00008C\n" " 0 0 136 #000088\n" " 0 0 132 #000084\n" " 0 0 128 #000080\n" " 0 0 124 #00007C\n" " 0 0 120 #000078\n" " 0 0 116 #000074\n" " 0 0 112 #000070\n" " 0 0 108 #00006C\n" " 0 0 104 #000068\n" " 0 0 100 #000064\n" " 0 0 96 #000060\n" " 0 0 92 #00005C\n" " 0 0 88 #000058\n" " 0 0 84 #000054\n" " 0 0 80 #000050\n" " 0 0 76 #00004C\n" " 0 0 72 #000048\n" " 0 0 68 #000044\n" " 0 0 64 #000040\n" " 0 0 60 #00003C\n" " 0 0 56 #000038\n" " 0 0 52 #000034\n" " 0 0 48 #000030\n" " 0 0 44 #00002C\n" " 0 0 40 #000028\n" " 0 0 36 #000024\n" " 0 0 32 #000020\n" " 0 0 28 #00001C\n" " 0 0 24 #000018\n" " 0 0 20 #000014\n" " 0 0 16 #000010\n" " 0 0 12 #00000C\n" " 0 0 8 #000008\n" " 0 0 0 #000000\n" "" }, {.path = "data/palettes/Caramel.gpl", .size = 3112, .data = "GIMP Palette\n" "Name: Caramel\n" "#\n" " 48 48 48 grey19\n" "164 136 192\n" "172 140 192\n" "180 144 192\n" "188 148 192\n" "196 152 192\n" "204 152 192\n" "212 156 192\n" "220 160 192\n" "228 164 192\n" "236 168 192\n" "228 160 188\n" "216 148 184\n" "204 136 180\n" "192 124 176\n" "180 112 168\n" "168 104 164\n" "156 92 160\n" "144 80 156\n" "132 68 152\n" "120 56 144\n" "140 84 140\n" "160 116 132\n" "180 144 128\n" "200 176 120\n" "224 208 112\n" "212 200 120\n" "196 188 132\n" "184 176 144\n" "168 168 156\n" "156 156 164\n" "140 144 176\n" "128 136 188\n" "112 124 200\n" " 96 112 212\n" "108 112 192\n" "124 116 172\n" "136 116 148\n" "152 120 128\n" "168 120 108\n" "180 124 84\n" "196 124 64\n" "212 128 40\n" "212 128 44\n" "212 132 48\n" "212 136 52\n" "212 140 56\n" "216 144 60\n" "216 148 64\n" "216 148 68\n" "216 152 72\n" "220 156 76\n" "220 160 80\n" "220 164 84\n" "220 168 88\n" "224 168 92\n" "224 172 96\n" "224 176 100\n" "224 180 104\n" "228 184 108\n" "228 188 112\n" "228 188 116\n" "228 192 120\n" "232 196 124\n" "232 200 128\n" "232 204 132\n" "232 208 136\n" "236 212 140\n" "232 208 140\n" "224 204 140\n" "216 196 140\n" "208 192 136\n" "200 188 136\n" "192 180 136\n" "188 176 132\n" "180 172 132\n" "172 164 132\n" "164 160 128\n" "156 156 128\n" "148 148 128\n" "144 144 124\n" "136 136 124\n" "128 132 124\n" "120 128 120\n" "112 120 120\n" "104 116 120\n" "100 112 116\n" " 92 104 116\n" " 84 100 116\n" " 76 96 112\n" " 68 88 112\n" " 60 84 112\n" " 52 76 108\n" " 56 80 108\n" " 60 88 108\n" " 64 96 108\n" " 72 100 108\n" " 76 108 108\n" " 80 116 108\n" " 88 120 108\n" " 92 128 108\n" " 96 136 108\n" "104 144 104\n" "108 148 104\n" "112 156 104\n" "116 164 104\n" "124 168 104\n" "128 176 104\n" "132 184 104\n" "140 188 104\n" "144 196 104\n" "148 204 104\n" "156 212 100\n" "156 208 100\n" "156 204 100\n" "156 200 96\n" "156 196 96\n" "156 192 92\n" "156 188 92\n" "156 184 88\n" "156 180 88\n" "156 176 84\n" "156 172 84\n" "156 168 80\n" "156 164 80\n" "156 160 76\n" "156 156 76\n" "156 152 72\n" "156 148 72\n" "156 144 68\n" "156 140 68\n" "156 136 64\n" "156 132 64\n" "156 124 60\n" "160 124 72\n" "164 128 84\n" "168 132 96\n" "176 136 112\n" "180 136 124\n" "184 140 136\n" "188 144 148\n" "196 148 164\n" "196 148 164\n" "196 148 160\n" "196 144 156\n" "196 144 152\n" "192 140 148\n" "192 140 144\n" "192 140 140\n" "192 136 136\n" "192 136 132\n" "188 132 128\n" "188 132 124\n" "188 132 120\n" "188 128 116\n" "184 128 112\n" "184 124 108\n" "184 124 104\n" "184 124 104\n" "184 120 100\n" "180 120 96\n" "180 116 92\n" "180 116 88\n" "180 116 84\n" "176 112 80\n" "176 112 76\n" "176 108 72\n" "176 108 68\n" "176 108 64\n" "172 104 60\n" "172 104 56\n" "172 100 52\n" "172 100 48\n" "168 96 44\n" "160 96 44\n" "152 96 48\n" "140 100 52\n" "132 100 56\n" "120 100 60\n" "112 104 60\n" "100 104 64\n" " 92 104 68\n" " 80 108 72\n" " 72 108 76\n" " 60 108 80\n" " 52 112 80\n" " 40 112 84\n" " 32 112 88\n" " 20 116 92\n" " 12 116 96\n" " 0 120 100\n" " 0 120 100\n" " 0 116 100\n" " 0 112 104\n" " 0 112 104\n" " 0 108 104\n" " 0 104 108\n" " 0 104 108\n" " 0 100 112\n" " 0 96 112\n" " 0 96 112\n" " 0 92 116\n" " 4 88 116\n" " 4 84 120\n" " 4 84 120\n" " 4 80 120\n" " 4 76 124\n" " 4 76 124\n" " 4 72 128\n" " 4 68 128\n" " 4 68 128\n" " 4 64 132\n" " 4 60 132\n" " 8 56 136\n" " 28 60 136\n" " 48 68 140\n" " 72 76 144\n" " 92 80 148\n" "116 88 152\n" "136 96 156\n" "160 100 160\n" "180 108 164\n" "204 116 168\n" "204 116 168\n" "204 120 168\n" "200 124 168\n" "200 128 168\n" "200 128 168\n" "196 132 168\n" "196 136 168\n" "192 140 168\n" "192 140 168\n" "192 144 168\n" "188 148 168\n" "188 152 168\n" "184 156 168\n" "184 156 168\n" "184 160 168\n" "180 164 168\n" "180 168 168\n" "180 168 168\n" "176 172 168\n" "176 176 168\n" "172 180 168\n" "172 184 168\n" "172 184 168\n" "168 188 168\n" "168 192 168\n" "164 196 168\n" "164 196 168\n" "164 200 168\n" "160 204 168\n" "160 208 168\n" "156 212 164\n" "148 212 168\n" "136 216 176\n" "" }, {.path = "data/palettes/db16.gpl", .size = 382, .data = "GIMP Palette\n" "Name: DB16\n" "Columns: 8\n" "#\n" " 20 12 28 Dark1\n" " 68 36 52 Dark2\n" " 48 52 109 Dark3\n" " 78 74 78 Dark4\n" "133 76 48 Dark5\n" " 52 101 36 Dark6\n" "208 70 72 Dark7\n" "117 113 97 Dark8\n" " 89 125 206 Light1\n" "210 125 44 Light2\n" "133 149 161 Light3\n" "109 170 44 Light4\n" "210 170 153 Light5\n" "109 194 202 Light6\n" "218 212 94 Light7\n" "222 238 214 Light8\n" "" }, {.path = "data/palettes/db32.gpl", .size = 659, .data = "GIMP Palette\n" "Name: DB32\n" "Columns: 8\n" "#\n" "0 0 0 Black\n" "34 32 52 Valhalla\n" "69 40 60 Loulou\n" "102 57 49 Oiled cedar\n" "143 86 59 Rope\n" "223 113 38 Tahiti gold\n" "217 160 102 Twine\n" "238 195 154 Pancho\n" "251 242 54 Golden fizz\n" "153 229 80 Atlantis\n" "106 190 48 Christi\n" "55 148 110 Elf green\n" "75 105 47 Dell\n" "82 75 36 Verdigris\n" "50 60 57 Opal\n" "63 63 116 Deep koamaru\n" "48 96 130 Venice blue\n" "91 110 225 Royal blue\n" "99 155 255 Cornflower\n" "95 205 228 Viking\n" "203 219 252 Light steel blue\n" "255 255 255 White\n" "155 173 183 Heather\n" "132 126 135 Topaz\n" "105 106 106 Dim gray\n" "89 86 82 Smokey ash\n" "118 66 138 Clairvoyant\n" "172 50 50 Brown\n" "217 87 99 Mandy\n" "215 123 186 Plum\n" "143 151 74 Rain forest\n" "138 111 48 Stinger\n" "" }, {.path = "data/palettes/echo-palette.gpl", .size = 681, .data = "GIMP Palette\n" "Name: Echo Icon Theme Palette\n" "Columns: 3\n" "#\n" " 25 174 255 Blue1 \n" " 0 132 200 Blue2\n" " 0 92 148 Blue3\n" "255 65 65 Red1\n" "220 0 0 Red2\n" "181 0 0 Red3\n" "255 255 62 Orange1\n" "255 153 0 Orange2\n" "255 102 0 Orange3\n" "255 192 34 Brown1\n" "184 129 0 Brown2\n" "128 77 0 Brown3\n" "204 255 66 Green1\n" "154 222 0 Green2\n" " 0 145 0 Green3\n" "241 202 255 Purple1\n" "215 108 255 Purple2\n" "186 0 255 Purple3\n" "189 205 212 Metalic1\n" "158 171 176 Metalic2\n" " 54 78 89 Metalic3\n" " 14 35 46 Metalic4\n" "255 255 255 Grey1\n" "204 204 204 Grey2\n" "153 153 153 Grey3\n" "102 102 102 Grey4\n" " 45 45 45 Grey5\n" "" }, {.path = "data/palettes/Gold.gpl", .size = 2079, .data = "GIMP Palette\n" "Name: Gold\n" "#\n" " 0 0 0 #000000\n" "128 128 128 #808080\n" "255 255 255 #FFFFFF\n" "252 252 128 #FCFC80\n" "252 248 124 #FCF87C\n" "252 244 120 #FCF478\n" "248 244 120 #F8F478\n" "248 240 116 #F8F074\n" "248 240 112 #F8F070\n" "248 236 112 #F8EC70\n" "244 236 108 #F4EC6C\n" "244 232 108 #F4E86C\n" "244 232 104 #F4E868\n" "244 228 104 #F4E468\n" "240 228 100 #F0E464\n" "240 224 96 #F0E060\n" "240 220 92 #F0DC5C\n" "236 220 92 #ECDC5C\n" "236 216 88 #ECD858\n" "236 216 84 #ECD854\n" "236 212 84 #ECD454\n" "236 212 80 #ECD450\n" "232 208 80 #E8D050\n" "232 208 76 #E8D04C\n" "232 204 76 #E8CC4C\n" "232 204 72 #E8CC48\n" "228 200 68 #E4C844\n" "228 196 64 #E4C440\n" "224 192 60 #E0C03C\n" "224 192 56 #E0C038\n" "224 188 56 #E0BC38\n" "224 188 52 #E0BC34\n" "220 184 52 #DCB834\n" "220 184 48 #DCB830\n" "220 180 48 #DCB430\n" "220 180 44 #DCB42C\n" "220 176 40 #DCB028\n" "216 176 40 #D8B028\n" "216 172 36 #D8AC24\n" "216 168 32 #D8A820\n" "212 168 28 #D4A81C\n" "212 164 28 #D4A41C\n" "212 164 24 #D4A418\n" "212 160 24 #D4A018\n" "208 160 20 #D0A014\n" "208 156 20 #D09C14\n" "208 156 16 #D09C10\n" "208 152 12 #D0980C\n" "204 152 12 #CC980C\n" "204 148 8 #CC9408\n" "204 144 4 #CC9004\n" "200 140 0 #C88C00\n" "196 136 0 #C48800\n" "192 132 0 #C08400\n" "188 128 0 #BC8000\n" "184 124 0 #B87C00\n" "180 120 0 #B47800\n" "176 116 0 #B07400\n" "172 112 0 #AC7000\n" "168 108 0 #A86C00\n" "164 104 0 #A46800\n" "160 100 0 #A06400\n" "156 96 0 #9C6000\n" "152 92 0 #985C00\n" "148 88 0 #945800\n" "144 84 0 #905400\n" "140 80 0 #8C5000\n" "136 76 0 #884C00\n" "132 72 0 #844800\n" "128 68 0 #804400\n" "124 64 0 #7C4000\n" "120 60 0 #783C00\n" "116 56 0 #743800\n" "112 52 0 #703400\n" "108 48 0 #6C3000\n" "104 44 0 #682C00\n" "100 40 0 #642800\n" " 96 36 0 #602400\n" " 92 32 0 #5C2000\n" " 88 28 0 #581C00\n" " 84 24 0 #541800\n" " 80 20 0 #501400\n" " 76 16 0 #4C1000\n" " 72 12 0 #480C00\n" " 68 8 0 #440800\n" " 64 4 0 #400400\n" " 60 0 0 #3C0000\n" " 56 0 0 #380000\n" " 52 0 0 #340000\n" " 48 0 0 #300000\n" " 44 0 0 #2C0000\n" " 40 0 0 #280000\n" " 36 0 0 #240000\n" " 32 0 0 #200000\n" " 28 0 0 #1C0000\n" " 24 0 0 #180000\n" " 20 0 0 #140000\n" " 16 0 0 #100000\n" " 12 0 0 #0C0000\n" " 8 0 0 #080000\n" " 4 0 0 #040000\n" " 0 0 0 #000000\n" "" }, {.path = "data/palettes/Gray.gpl", .size = 6585, .data = "GIMP Palette\n" "Name: Gray\n" "Columns: 3\n" "# \n" " 0 0 0 00 hex (0)\n" " 1 1 1 01 hex (1)\n" " 2 2 2 02 hex (2)\n" " 3 3 3 03 hex (3)\n" " 4 4 4 04 hex (4)\n" " 5 5 5 05 hex (5)\n" " 6 6 6 06 hex (6)\n" " 7 7 7 07 hex (7)\n" " 8 8 8 08 hex (8)\n" " 9 9 9 09 hex (9)\n" " 10 10 10 0A hex (10)\n" " 11 11 11 0B hex (11)\n" " 12 12 12 0C hex (12)\n" " 13 13 13 0D hex (13)\n" " 14 14 14 0E hex (14)\n" " 15 15 15 0F hex (15)\n" " 16 16 16 10 hex (16)\n" " 17 17 17 11 hex (17)\n" " 18 18 18 12 hex (18)\n" " 19 19 19 13 hex (19)\n" " 20 20 20 14 hex (20)\n" " 21 21 21 15 hex (21)\n" " 22 22 22 16 hex (22)\n" " 23 23 23 17 hex (23)\n" " 24 24 24 18 hex (24)\n" " 25 25 25 19 hex (25)\n" " 26 26 26 1A hex (26)\n" " 27 27 27 1B hex (27)\n" " 28 28 28 1C hex (28)\n" " 29 29 29 1D hex (29)\n" " 30 30 30 1E hex (30)\n" " 31 31 31 1F hex (31)\n" " 32 32 32 20 hex (32)\n" " 33 33 33 21 hex (33)\n" " 34 34 34 22 hex (34)\n" " 35 35 35 23 hex (35)\n" " 36 36 36 24 hex (36)\n" " 37 37 37 25 hex (37)\n" " 38 38 38 26 hex (38)\n" " 39 39 39 27 hex (39)\n" " 40 40 40 28 hex (40)\n" " 41 41 41 29 hex (41)\n" " 42 42 42 2A hex (42)\n" " 43 43 43 2B hex (43)\n" " 44 44 44 2C hex (44)\n" " 45 45 45 2D hex (45)\n" " 46 46 46 2E hex (46)\n" " 47 47 47 2F hex (47)\n" " 48 48 48 30 hex (48)\n" " 49 49 49 31 hex (49)\n" " 50 50 50 32 hex (50)\n" " 51 51 51 33 hex (51)\n" " 52 52 52 34 hex (52)\n" " 53 53 53 35 hex (53)\n" " 54 54 54 36 hex (54)\n" " 55 55 55 37 hex (55)\n" " 56 56 56 38 hex (56)\n" " 57 57 57 39 hex (57)\n" " 58 58 58 3A hex (58)\n" " 59 59 59 3B hex (59)\n" " 60 60 60 3C hex (60)\n" " 61 61 61 3D hex (61)\n" " 62 62 62 3E hex (62)\n" " 63 63 63 3F hex (63)\n" " 64 64 64 40 hex (64)\n" " 65 65 65 41 hex (65)\n" " 66 66 66 42 hex (66)\n" " 67 67 67 43 hex (67)\n" " 68 68 68 44 hex (68)\n" " 69 69 69 45 hex (69)\n" " 70 70 70 46 hex (70)\n" " 71 71 71 47 hex (71)\n" " 72 72 72 48 hex (72)\n" " 73 73 73 49 hex (73)\n" " 74 74 74 4A hex (74)\n" " 75 75 75 4B hex (75)\n" " 76 76 76 4C hex (76)\n" " 77 77 77 4D hex (77)\n" " 78 78 78 4E hex (78)\n" " 79 79 79 4F hex (79)\n" " 80 80 80 50 hex (80)\n" " 81 81 81 51 hex (81)\n" " 82 82 82 52 hex (82)\n" " 83 83 83 53 hex (83)\n" " 84 84 84 54 hex (84)\n" " 85 85 85 55 hex (85)\n" " 86 86 86 56 hex (86)\n" " 87 87 87 57 hex (87)\n" " 88 88 88 58 hex (88)\n" " 89 89 89 59 hex (89)\n" " 90 90 90 5A hex (90)\n" " 91 91 91 5B hex (91)\n" " 92 92 92 5C hex (92)\n" " 93 93 93 5D hex (93)\n" " 94 94 94 5E hex (94)\n" " 95 95 95 5F hex (95)\n" " 96 96 96 60 hex (96)\n" " 97 97 97 61 hex (97)\n" " 98 98 98 62 hex (98)\n" " 99 99 99 63 hex (99)\n" "100 100 100 64 hex (100)\n" "101 101 101 65 hex (101)\n" "102 102 102 66 hex (102)\n" "103 103 103 67 hex (103)\n" "104 104 104 68 hex (104)\n" "105 105 105 69 hex (105)\n" "106 106 106 6A hex (106)\n" "107 107 107 6B hex (107)\n" "108 108 108 6C hex (108)\n" "109 109 109 6D hex (109)\n" "110 110 110 6E hex (110)\n" "111 111 111 6F hex (111)\n" "112 112 112 70 hex (112)\n" "113 113 113 71 hex (113)\n" "114 114 114 72 hex (114)\n" "115 115 115 73 hex (115)\n" "116 116 116 74 hex (116)\n" "117 117 117 75 hex (117)\n" "118 118 118 76 hex (118)\n" "119 119 119 77 hex (119)\n" "120 120 120 78 hex (120)\n" "121 121 121 79 hex (121)\n" "122 122 122 7A hex (122)\n" "123 123 123 7B hex (123)\n" "124 124 124 7C hex (124)\n" "125 125 125 7D hex (125)\n" "126 126 126 7E hex (126)\n" "127 127 127 7F hex (127)\n" "128 128 128 80 hex (128)\n" "129 129 129 81 hex (129)\n" "130 130 130 82 hex (130)\n" "131 131 131 83 hex (131)\n" "132 132 132 84 hex (132)\n" "133 133 133 85 hex (133)\n" "134 134 134 86 hex (134)\n" "135 135 135 87 hex (135)\n" "136 136 136 88 hex (136)\n" "137 137 137 89 hex (137)\n" "138 138 138 8A hex (138)\n" "139 139 139 8B hex (139)\n" "140 140 140 8C hex (140)\n" "141 141 141 8D hex (141)\n" "142 142 142 8E hex (142)\n" "143 143 143 8F hex (143)\n" "144 144 144 90 hex (144)\n" "145 145 145 91 hex (145)\n" "146 146 146 92 hex (146)\n" "147 147 147 93 hex (147)\n" "148 148 148 94 hex (148)\n" "149 149 149 95 hex (149)\n" "150 150 150 96 hex (150)\n" "151 151 151 97 hex (151)\n" "152 152 152 98 hex (152)\n" "153 153 153 99 hex (153)\n" "154 154 154 9A hex (154)\n" "155 155 155 9B hex (155)\n" "156 156 156 9C hex (156)\n" "157 157 157 9D hex (157)\n" "158 158 158 9E hex (158)\n" "159 159 159 9F hex (159)\n" "160 160 160 A0 hex (160)\n" "161 161 161 A1 hex (161)\n" "162 162 162 A2 hex (162)\n" "163 163 163 A3 hex (163)\n" "164 164 164 A4 hex (164)\n" "165 165 165 A5 hex (165)\n" "166 166 166 A6 hex (166)\n" "167 167 167 A7 hex (167)\n" "168 168 168 A8 hex (168)\n" "169 169 169 A9 hex (169)\n" "170 170 170 AA hex (170)\n" "171 171 171 AB hex (171)\n" "172 172 172 AC hex (172)\n" "173 173 173 AD hex (173)\n" "174 174 174 AE hex (174)\n" "175 175 175 AF hex (175)\n" "176 176 176 B0 hex (176)\n" "177 177 177 B1 hex (177)\n" "178 178 178 B2 hex (178)\n" "179 179 179 B3 hex (179)\n" "180 180 180 B4 hex (180)\n" "181 181 181 B5 hex (181)\n" "182 182 182 B6 hex (182)\n" "183 183 183 B7 hex (183)\n" "184 184 184 B8 hex (184)\n" "185 185 185 B9 hex (185)\n" "186 186 186 BA hex (186)\n" "187 187 187 BB hex (187)\n" "188 188 188 BC hex (188)\n" "189 189 189 BD hex (189)\n" "190 190 190 BE hex (190)\n" "191 191 191 BF hex (191)\n" "192 192 192 C0 hex (192)\n" "193 193 193 C1 hex (193)\n" "194 194 194 C2 hex (194)\n" "195 195 195 C3 hex (195)\n" "196 196 196 C4 hex (196)\n" "197 197 197 C5 hex (197)\n" "198 198 198 C6 hex (198)\n" "199 199 199 C7 hex (199)\n" "200 200 200 C8 hex (200)\n" "201 201 201 C9 hex (201)\n" "202 202 202 CA hex (202)\n" "203 203 203 CB hex (203)\n" "204 204 204 CC hex (204)\n" "205 205 205 CD hex (205)\n" "206 206 206 CE hex (206)\n" "207 207 207 CF hex (207)\n" "208 208 208 D0 hex (208)\n" "209 209 209 D1 hex (209)\n" "210 210 210 D2 hex (210)\n" "211 211 211 D3 hex (211)\n" "212 212 212 D4 hex (212)\n" "213 213 213 D5 hex (213)\n" "214 214 214 D6 hex (214)\n" "215 215 215 D7 hex (215)\n" "216 216 216 D8 hex (216)\n" "217 217 217 D9 hex (217)\n" "218 218 218 DA hex (218)\n" "219 219 219 DB hex (219)\n" "220 220 220 DC hex (220)\n" "221 221 221 DD hex (221)\n" "222 222 222 DE hex (222)\n" "223 223 223 DF hex (223)\n" "224 224 224 E0 hex (224)\n" "225 225 225 E1 hex (225)\n" "226 226 226 E2 hex (226)\n" "227 227 227 E3 hex (227)\n" "228 228 228 E4 hex (228)\n" "229 229 229 E5 hex (229)\n" "230 230 230 E6 hex (230)\n" "231 231 231 E7 hex (231)\n" "232 232 232 E8 hex (232)\n" "233 233 233 E9 hex (233)\n" "234 234 234 EA hex (234)\n" "235 235 235 EB hex (235)\n" "236 236 236 EC hex (236)\n" "237 237 237 ED hex (237)\n" "238 238 238 EE hex (238)\n" "239 239 239 EF hex (239)\n" "240 240 240 F0 hex (240)\n" "241 241 241 F1 hex (241)\n" "242 242 242 F2 hex (242)\n" "243 243 243 F3 hex (243)\n" "244 244 244 F4 hex (244)\n" "245 245 245 F5 hex (245)\n" "246 246 246 F6 hex (246)\n" "247 247 247 F7 hex (247)\n" "248 248 248 F8 hex (248)\n" "249 249 249 F9 hex (249)\n" "250 250 250 FA hex (250)\n" "251 251 251 FB hex (251)\n" "252 252 252 FC hex (252)\n" "253 253 253 FD hex (253)\n" "254 254 254 FE hex (254)\n" "255 255 255 FF hex (255)\n" "" }, {.path = "data/palettes/Grays.gpl", .size = 587, .data = "GIMP Palette\n" "Name: Grays\n" "#\n" "0 0 0 gray0\n" "7 7 7 gray3\n" "15 15 15 gray6\n" "23 23 23 gray9\n" "31 31 31 gray12\n" "39 39 39 gray15\n" "47 47 47 gray18\n" "55 55 55 gray21\n" "63 63 63 gray25\n" "71 71 71 gray28\n" "79 79 79 gray31\n" "87 87 87 gray34\n" "95 95 95 gray37\n" "103 103 103 gray40\n" "111 111 111 gray43\n" "119 119 119 gray46\n" "127 127 127 gray50\n" "135 135 135 gray53\n" "143 143 143 gray56\n" "151 151 151 gray59\n" "159 159 159 gray62\n" "167 167 167 gray65\n" "175 175 175 gray68\n" "183 183 183 gray71\n" "191 191 191 gray75\n" "199 199 199 gray78\n" "207 207 207 gray81\n" "215 215 215 gray84\n" "223 223 223 gray87\n" "231 231 231 gray90\n" "239 239 239 gray93\n" "247 247 247 gray96\n" "" }, {.path = "data/palettes/Greens.gpl", .size = 5161, .data = "GIMP Palette\n" "Name: Greens\n" "#\n" " 0 0 0 #000000\n" "128 128 128 #808080\n" "255 255 255 #FFFFFF\n" " 0 4 0 #000400\n" " 0 12 0 #000C00\n" " 0 16 0 #001000\n" " 0 24 0 #001800\n" " 0 32 0 #002000\n" " 0 36 0 #002400\n" " 0 44 0 #002C00\n" " 0 48 0 #003000\n" " 0 56 0 #003800\n" " 0 64 0 #004000\n" " 0 68 0 #004400\n" " 0 76 0 #004C00\n" " 0 80 0 #005000\n" " 0 88 0 #005800\n" " 0 96 0 #006000\n" " 0 100 0 #006400\n" " 0 108 0 #006C00\n" " 0 116 0 #007400\n" " 0 120 0 #007800\n" " 0 128 0 #008000\n" " 0 132 0 #008400\n" " 0 140 0 #008C00\n" " 0 148 0 #009400\n" " 0 152 0 #009800\n" " 0 160 0 #00A000\n" " 0 164 0 #00A400\n" " 0 172 0 #00AC00\n" " 0 180 0 #00B400\n" " 0 184 0 #00B800\n" " 0 192 0 #00C000\n" " 0 200 0 #00C800\n" " 4 200 0 #04C800\n" " 12 200 0 #0CC800\n" " 16 204 0 #10CC00\n" " 24 204 0 #18CC00\n" " 28 208 0 #1CD000\n" " 36 208 0 #24D000\n" " 40 208 0 #28D000\n" " 48 212 0 #30D400\n" " 56 212 0 #38D400\n" " 60 216 0 #3CD800\n" " 68 216 0 #44D800\n" " 72 216 0 #48D800\n" " 80 220 0 #50DC00\n" " 84 220 0 #54DC00\n" " 92 224 0 #5CE000\n" "100 224 0 #64E000\n" "104 224 0 #68E000\n" "112 228 0 #70E400\n" "116 228 0 #74E400\n" "124 232 0 #7CE800\n" "128 232 0 #80E800\n" "136 232 0 #88E800\n" "140 236 0 #8CEC00\n" "148 236 0 #94EC00\n" "156 240 0 #9CF000\n" "160 240 0 #A0F000\n" "168 240 0 #A8F000\n" "172 244 0 #ACF400\n" "180 244 0 #B4F400\n" "184 248 0 #B8F800\n" "192 248 0 #C0F800\n" "200 252 0 #C8FC00\n" "200 252 4 #C8FC04\n" "200 252 12 #C8FC0C\n" "204 252 20 #CCFC14\n" "204 252 28 #CCFC1C\n" "208 252 36 #D0FC24\n" "208 252 44 #D0FC2C\n" "208 252 52 #D0FC34\n" "212 252 60 #D4FC3C\n" "212 252 68 #D4FC44\n" "216 252 76 #D8FC4C\n" "216 252 84 #D8FC54\n" "216 252 92 #D8FC5C\n" "220 252 100 #DCFC64\n" "220 252 108 #DCFC6C\n" "224 252 116 #E0FC74\n" "224 252 124 #E0FC7C\n" "224 252 132 #E0FC84\n" "228 252 140 #E4FC8C\n" "228 252 148 #E4FC94\n" "232 252 156 #E8FC9C\n" "232 252 164 #E8FCA4\n" "232 252 172 #E8FCAC\n" "236 252 180 #ECFCB4\n" "236 252 188 #ECFCBC\n" "240 252 196 #F0FCC4\n" "240 252 204 #F0FCCC\n" "240 252 212 #F0FCD4\n" "244 252 220 #F4FCDC\n" "244 252 228 #F4FCE4\n" "248 252 236 #F8FCEC\n" "248 252 244 #F8FCF4\n" "252 252 252 #FCFCFC\n" "252 252 248 #FCFCF8\n" "252 252 244 #FCFCF4\n" "252 252 240 #FCFCF0\n" "252 252 232 #FCFCE8\n" "252 252 228 #FCFCE4\n" "252 252 224 #FCFCE0\n" "252 252 216 #FCFCD8\n" "252 252 212 #FCFCD4\n" "252 252 208 #FCFCD0\n" "252 252 200 #FCFCC8\n" "252 252 196 #FCFCC4\n" "252 252 192 #FCFCC0\n" "252 252 184 #FCFCB8\n" "252 252 180 #FCFCB4\n" "252 252 176 #FCFCB0\n" "252 252 168 #FCFCA8\n" "252 252 164 #FCFCA4\n" "252 252 160 #FCFCA0\n" "252 252 156 #FCFC9C\n" "252 252 148 #FCFC94\n" "252 252 144 #FCFC90\n" "252 252 140 #FCFC8C\n" "252 252 132 #FCFC84\n" "252 252 128 #FCFC80\n" "252 252 124 #FCFC7C\n" "252 252 116 #FCFC74\n" "252 252 112 #FCFC70\n" "252 252 108 #FCFC6C\n" "252 252 100 #FCFC64\n" "252 252 96 #FCFC60\n" "252 252 92 #FCFC5C\n" "252 252 84 #FCFC54\n" "252 252 80 #FCFC50\n" "252 252 76 #FCFC4C\n" "252 252 72 #FCFC48\n" "252 252 64 #FCFC40\n" "252 252 60 #FCFC3C\n" "252 252 56 #FCFC38\n" "252 252 48 #FCFC30\n" "252 252 44 #FCFC2C\n" "252 252 40 #FCFC28\n" "252 252 32 #FCFC20\n" "252 252 28 #FCFC1C\n" "252 252 24 #FCFC18\n" "252 252 16 #FCFC10\n" "252 252 12 #FCFC0C\n" "252 252 8 #FCFC08\n" "252 252 0 #FCFC00\n" "248 252 0 #F8FC00\n" "244 252 0 #F4FC00\n" "240 252 0 #F0FC00\n" "232 252 0 #E8FC00\n" "228 252 0 #E4FC00\n" "224 252 0 #E0FC00\n" "216 252 0 #D8FC00\n" "212 252 0 #D4FC00\n" "208 252 0 #D0FC00\n" "200 252 0 #C8FC00\n" "196 252 0 #C4FC00\n" "192 252 0 #C0FC00\n" "184 252 0 #B8FC00\n" "180 252 0 #B4FC00\n" "176 252 0 #B0FC00\n" "168 252 0 #A8FC00\n" "164 252 0 #A4FC00\n" "160 252 0 #A0FC00\n" "156 252 0 #9CFC00\n" "148 252 0 #94FC00\n" "144 252 0 #90FC00\n" "140 252 0 #8CFC00\n" "132 252 0 #84FC00\n" "128 252 0 #80FC00\n" "124 252 0 #7CFC00\n" "116 252 0 #74FC00\n" "112 252 0 #70FC00\n" "108 252 0 #6CFC00\n" "100 252 0 #64FC00\n" " 96 252 0 #60FC00\n" " 92 252 0 #5CFC00\n" " 84 252 0 #54FC00\n" " 80 252 0 #50FC00\n" " 76 252 0 #4CFC00\n" " 72 252 0 #48FC00\n" " 64 252 0 #40FC00\n" " 60 252 0 #3CFC00\n" " 56 252 0 #38FC00\n" " 48 252 0 #30FC00\n" " 44 252 0 #2CFC00\n" " 40 252 0 #28FC00\n" " 32 252 0 #20FC00\n" " 28 252 0 #1CFC00\n" " 24 252 0 #18FC00\n" " 16 252 0 #10FC00\n" " 12 252 0 #0CFC00\n" " 8 252 0 #08FC00\n" " 0 252 0 #00FC00\n" " 0 248 0 #00F800\n" " 0 244 0 #00F400\n" " 0 240 0 #00F000\n" " 0 236 0 #00EC00\n" " 0 232 0 #00E800\n" " 0 228 0 #00E400\n" " 0 224 0 #00E000\n" " 0 220 0 #00DC00\n" " 0 216 0 #00D800\n" " 0 212 0 #00D400\n" " 0 208 0 #00D000\n" " 0 204 0 #00CC00\n" " 0 200 0 #00C800\n" " 0 196 0 #00C400\n" " 0 192 0 #00C000\n" " 0 188 0 #00BC00\n" " 0 184 0 #00B800\n" " 0 180 0 #00B400\n" " 0 176 0 #00B000\n" " 0 172 0 #00AC00\n" " 0 168 0 #00A800\n" " 0 164 0 #00A400\n" " 0 160 0 #00A000\n" " 0 156 0 #009C00\n" " 0 152 0 #009800\n" " 0 148 0 #009400\n" " 0 144 0 #009000\n" " 0 140 0 #008C00\n" " 0 136 0 #008800\n" " 0 132 0 #008400\n" " 0 128 0 #008000\n" " 0 124 0 #007C00\n" " 0 120 0 #007800\n" " 0 116 0 #007400\n" " 0 112 0 #007000\n" " 0 108 0 #006C00\n" " 0 104 0 #006800\n" " 0 100 0 #006400\n" " 0 96 0 #006000\n" " 0 92 0 #005C00\n" " 0 88 0 #005800\n" " 0 84 0 #005400\n" " 0 80 0 #005000\n" " 0 76 0 #004C00\n" " 0 72 0 #004800\n" " 0 68 0 #004400\n" " 0 64 0 #004000\n" " 0 60 0 #003C00\n" " 0 56 0 #003800\n" " 0 52 0 #003400\n" " 0 48 0 #003000\n" " 0 44 0 #002C00\n" " 0 40 0 #002800\n" " 0 36 0 #002400\n" " 0 32 0 #002000\n" " 0 28 0 #001C00\n" " 0 24 0 #001800\n" " 0 20 0 #001400\n" " 0 16 0 #001000\n" " 0 12 0 #000C00\n" " 0 8 0 #000800\n" " 0 0 0 #000000\n" "" }, {.path = "data/palettes/Hilite.gpl", .size = 3441, .data = "GIMP Palette\n" "Name: Hilite\n" "#\n" " 0 0 0 #000000\n" "128 128 128 #808080\n" "255 255 255 #FFFFFF\n" "164 144 180 #A490B4\n" "160 144 180 #A090B4\n" "160 144 176 #A090B0\n" "160 140 172 #A08CAC\n" "160 140 168 #A08CA8\n" "160 140 164 #A08CA4\n" "160 136 164 #A088A4\n" "156 136 160 #9C88A0\n" "156 136 156 #9C889C\n" "156 132 152 #9C8498\n" "156 132 148 #9C8494\n" "156 132 144 #9C8490\n" "152 128 144 #988090\n" "152 128 140 #98808C\n" "152 128 136 #988088\n" "152 128 132 #988084\n" "152 124 132 #987C84\n" "152 124 128 #987C80\n" "152 124 124 #987C7C\n" "148 124 124 #947C7C\n" "148 124 120 #947C78\n" "148 120 120 #947878\n" "148 120 116 #947874\n" "148 120 112 #947870\n" "148 116 108 #94746C\n" "144 116 108 #90746C\n" "144 116 104 #907468\n" "144 116 100 #907464\n" "144 112 100 #907064\n" "144 112 96 #907060\n" "144 112 92 #90705C\n" "144 112 88 #907058\n" "140 108 88 #8C6C58\n" "140 108 84 #8C6C54\n" "140 108 80 #8C6C50\n" "140 104 76 #8C684C\n" "140 104 72 #8C6848\n" "136 104 68 #886844\n" "136 100 68 #886444\n" "136 100 64 #886440\n" "136 100 60 #88643C\n" "136 96 56 #886038\n" "136 96 52 #886034\n" "132 96 48 #846030\n" "132 92 44 #845C2C\n" "132 92 40 #845C28\n" "132 92 36 #845C24\n" "132 88 36 #845824\n" "132 88 32 #845820\n" "128 88 32 #805820\n" "128 88 28 #80581C\n" "128 88 24 #805818\n" "128 84 24 #805418\n" "128 84 20 #805414\n" "128 84 16 #805410\n" "124 80 12 #7C500C\n" "124 84 16 #7C5410\n" "128 84 16 #805410\n" "128 88 20 #805814\n" "128 92 24 #805C18\n" "132 92 24 #845C18\n" "132 92 28 #845C1C\n" "132 96 28 #84601C\n" "136 96 32 #886020\n" "136 100 32 #886420\n" "136 104 36 #886824\n" "140 104 36 #8C6824\n" "140 108 40 #8C6C28\n" "144 108 44 #906C2C\n" "144 112 44 #90702C\n" "144 112 48 #907030\n" "144 116 48 #907430\n" "148 116 52 #947434\n" "148 120 52 #947834\n" "148 120 56 #947838\n" "152 120 56 #987838\n" "152 124 56 #987C38\n" "152 124 60 #987C3C\n" "152 128 60 #98803C\n" "156 128 64 #9C8040\n" "156 132 64 #9C8440\n" "156 132 68 #9C8444\n" "160 136 68 #A08844\n" "160 136 72 #A08848\n" "160 140 76 #A08C4C\n" "164 140 76 #A48C4C\n" "164 144 76 #A4904C\n" "164 144 80 #A49050\n" "164 148 80 #A49450\n" "168 148 84 #A89454\n" "168 152 88 #A89858\n" "172 152 88 #AC9858\n" "172 156 92 #AC9C5C\n" "172 160 96 #ACA060\n" "176 160 96 #B0A060\n" "176 164 100 #B0A464\n" "180 164 100 #B4A464\n" "180 168 104 #B4A868\n" "180 172 108 #B4AC6C\n" "184 172 108 #B8AC6C\n" "184 176 112 #B8B070\n" "188 176 116 #BCB074\n" "188 180 116 #BCB474\n" "188 180 120 #BCB478\n" "188 184 120 #BCB878\n" "192 184 120 #C0B878\n" "192 188 124 #C0BC7C\n" "196 192 128 #C4C080\n" "196 192 132 #C4C084\n" "196 196 132 #C4C484\n" "200 196 136 #C8C488\n" "200 200 136 #C8C888\n" "200 200 140 #C8C88C\n" "200 204 140 #C8CC8C\n" "204 204 144 #CCCC90\n" "204 208 144 #CCD090\n" "208 208 148 #D0D094\n" "208 212 148 #D0D494\n" "208 212 152 #D0D498\n" "208 216 152 #D0D898\n" "212 216 156 #D4D89C\n" "212 220 156 #D4DC9C\n" "212 220 160 #D4DCA0\n" "216 220 160 #D8DCA0\n" "216 224 164 #D8E0A4\n" "216 228 164 #D8E4A4\n" "220 228 168 #DCE4A8\n" "220 232 168 #DCE8A8\n" "220 232 172 #DCE8AC\n" "224 232 172 #E0E8AC\n" "224 236 176 #E0ECB0\n" "224 240 180 #E0F0B4\n" "228 240 180 #E4F0B4\n" "228 244 184 #E4F4B8\n" "232 248 188 #E8F8BC\n" "228 244 188 #E4F4BC\n" "224 244 188 #E0F4BC\n" "224 240 188 #E0F0BC\n" "220 240 188 #DCF0BC\n" "220 236 188 #DCECBC\n" "216 236 188 #D8ECBC\n" "216 232 188 #D8E8BC\n" "212 232 188 #D4E8BC\n" "212 232 184 #D4E8B8\n" "212 228 184 #D4E4B8\n" "208 228 184 #D0E4B8\n" "204 224 184 #CCE0B8\n" "204 220 184 #CCDCB8\n" "200 220 184 #C8DCB8\n" "196 216 184 #C4D8B8\n" "192 212 184 #C0D4B8\n" "192 212 180 #C0D4B4\n" "188 212 180 #BCD4B4\n" "188 208 180 #BCD0B4\n" "184 208 180 #B8D0B4\n" "184 204 180 #B8CCB4\n" "180 204 180 #B4CCB4\n" "180 200 180 #B4C8B4\n" "176 200 180 #B0C8B4\n" "176 196 180 #B0C4B4\n" "172 196 180 #ACC4B4\n" "172 192 180 #ACC0B4\n" "168 192 176 #A8C0B0\n" "168 188 176 #A8BCB0\n" "164 188 176 #A4BCB0\n" "160 184 176 #A0B8B0\n" "156 180 176 #9CB4B0\n" "" }, {.path = "data/palettes/inkscape.gpl", .size = 9231, .data = "GIMP Palette\n" "Name: Inkscape default\n" "Columns: 3\n" "# generated by PaletteGen.py\n" " 0 0 0 Black\n" " 26 26 26 90% Gray\n" " 51 51 51 80% Gray\n" " 77 77 77 70% Gray\n" "102 102 102 60% Gray\n" "128 128 128 50% Gray\n" "153 153 153 40% Gray\n" "179 179 179 30% Gray\n" "204 204 204 20% Gray\n" "230 230 230 10% Gray\n" "236 236 236 7.5% Gray\n" "242 242 242 5% Gray\n" "249 249 249 2.5% Gray\n" "255 255 255 White\n" "128 0 0 Maroon (#800000)\n" "255 0 0 Red (#FF0000)\n" "128 128 0 Olive (#808000)\n" "255 255 0 Yellow (#FFFF00)\n" " 0 128 0 Green (#008000)\n" " 0 255 0 Lime (#00FF00)\n" " 0 128 128 Teal (#008080)\n" " 0 255 255 Aqua (#00FFFF)\n" " 0 0 128 Navy (#000080)\n" " 0 0 255 Blue (#0000FF)\n" "128 0 128 Purple (#800080)\n" "255 0 255 Fuchsia (#FF00FF)\n" " 43 0 0 #2B0000\n" " 85 0 0 #550000\n" "128 0 0 #800000\n" "170 0 0 #AA0000\n" "212 0 0 #D40000\n" "255 0 0 #FF0000\n" "255 42 42 #FF2A2A\n" "255 85 85 #FF5555\n" "255 128 128 #FF8080\n" "255 170 170 #FFAAAA\n" "255 213 213 #FFD5D5\n" " 40 11 11 #280B0B\n" " 80 22 22 #501616\n" "120 33 33 #782121\n" "160 44 44 #A02C2C\n" "200 55 55 #C83737\n" "211 95 95 #D35F5F\n" "222 135 135 #DE8787\n" "233 175 175 #E9AFAF\n" "244 215 215 #F4D7D7\n" " 36 28 28 #241C1C\n" " 72 55 55 #483737\n" "108 83 83 #6C5353\n" "145 111 111 #916F6F\n" "172 147 147 #AC9393\n" "200 183 183 #C8B7B7\n" "227 219 219 #E3DBDB\n" " 43 17 0 #2B1100\n" " 85 34 0 #552200\n" "128 51 0 #803300\n" "170 68 0 #AA4400\n" "212 85 0 #D45500\n" "255 102 0 #FF6600\n" "255 127 42 #FF7F2A\n" "255 153 85 #FF9955\n" "255 179 128 #FFB380\n" "255 204 170 #FFCCAA\n" "255 230 213 #FFE6D5\n" " 40 23 11 #28170B\n" " 80 45 22 #502D16\n" "120 68 33 #784421\n" "160 90 44 #A05A2C\n" "200 113 55 #C87137\n" "211 141 95 #D38D5F\n" "222 170 135 #DEAA87\n" "233 198 175 #E9C6AF\n" "244 227 215 #F4E3D7\n" " 36 31 28 #241F1C\n" " 72 62 55 #483E37\n" "108 93 83 #6C5D53\n" "145 124 111 #917C6F\n" "172 157 147 #AC9D93\n" "200 190 183 #C8BEB7\n" "227 222 219 #E3DEDB\n" " 43 34 0 #2B2200\n" " 85 68 0 #554400\n" "128 102 0 #806600\n" "170 136 0 #AA8800\n" "212 170 0 #D4AA00\n" "255 204 0 #FFCC00\n" "255 212 42 #FFD42A\n" "255 221 85 #FFDD55\n" "255 230 128 #FFE680\n" "255 238 170 #FFEEAA\n" "255 246 213 #FFF6D5\n" " 40 34 11 #28220B\n" " 80 68 22 #504416\n" "120 103 33 #786721\n" "160 137 44 #A0892C\n" "200 171 55 #C8AB37\n" "211 188 95 #D3BC5F\n" "222 205 135 #DECD87\n" "233 221 175 #E9DDAF\n" "244 238 215 #F4EED7\n" " 36 34 28 #24221C\n" " 72 69 55 #484537\n" "108 103 83 #6C6753\n" "145 138 111 #918A6F\n" "172 167 147 #ACA793\n" "200 196 183 #C8C4B7\n" "227 226 219 #E3E2DB\n" " 34 43 0 #222B00\n" " 68 85 0 #445500\n" "102 128 0 #668000\n" "136 170 0 #88AA00\n" "170 212 0 #AAD400\n" "204 255 0 #CCFF00\n" "212 255 42 #D4FF2A\n" "221 255 85 #DDFF55\n" "229 255 128 #E5FF80\n" "238 255 170 #EEFFAA\n" "246 255 213 #F6FFD5\n" " 34 40 11 #22280B\n" " 68 80 22 #445016\n" "103 120 33 #677821\n" "137 160 44 #89A02C\n" "171 200 55 #ABC837\n" "188 211 95 #BCD35F\n" "205 222 135 #CDDE87\n" "221 233 175 #DDE9AF\n" "238 244 215 #EEF4D7\n" " 34 36 28 #22241C\n" " 69 72 55 #454837\n" "103 108 83 #676C53\n" "138 145 111 #8A916F\n" "167 172 147 #A7AC93\n" "196 200 183 #C4C8B7\n" "226 227 219 #E2E3DB\n" " 17 43 0 #112B00\n" " 34 85 0 #225500\n" " 51 128 0 #338000\n" " 68 170 0 #44AA00\n" " 85 212 0 #55D400\n" "102 255 0 #66FF00\n" "127 255 42 #7FFF2A\n" "153 255 85 #99FF55\n" "179 255 128 #B3FF80\n" "204 255 170 #CCFFAA\n" "229 255 213 #E5FFD5\n" " 23 40 11 #17280B\n" " 45 80 22 #2D5016\n" " 68 120 33 #447821\n" " 90 160 44 #5AA02C\n" "113 200 55 #71C837\n" "141 211 95 #8DD35F\n" "170 222 135 #AADE87\n" "198 233 175 #C6E9AF\n" "227 244 215 #E3F4D7\n" " 31 36 28 #1F241C\n" " 62 72 55 #3E4837\n" " 93 108 83 #5D6C53\n" "124 145 111 #7C916F\n" "157 172 147 #9DAC93\n" "190 200 183 #BEC8B7\n" "222 227 219 #DEE3DB\n" " 0 43 0 #002B00\n" " 0 85 0 #005500\n" " 0 128 0 #008000\n" " 0 170 0 #00AA00\n" " 0 212 0 #00D400\n" " 0 255 0 #00FF00\n" " 42 255 42 #2AFF2A\n" " 85 255 85 #55FF55\n" "128 255 128 #80FF80\n" "170 255 170 #AAFFAA\n" "213 255 213 #D5FFD5\n" " 11 40 11 #0B280B\n" " 22 80 22 #165016\n" " 33 120 33 #217821\n" " 44 160 44 #2CA02C\n" " 55 200 55 #37C837\n" " 95 211 95 #5FD35F\n" "135 222 135 #87DE87\n" "175 233 175 #AFE9AF\n" "215 244 215 #D7F4D7\n" " 28 36 28 #1C241C\n" " 55 72 55 #374837\n" " 83 108 83 #536C53\n" "111 145 111 #6F916F\n" "147 172 147 #93AC93\n" "183 200 183 #B7C8B7\n" "219 227 219 #DBE3DB\n" " 0 43 17 #002B11\n" " 0 85 34 #005522\n" " 0 128 51 #008033\n" " 0 170 68 #00AA44\n" " 0 212 85 #00D455\n" " 0 255 102 #00FF66\n" " 42 255 128 #2AFF80\n" " 85 255 153 #55FF99\n" "128 255 179 #80FFB3\n" "170 255 204 #AAFFCC\n" "213 255 230 #D5FFE6\n" " 11 40 23 #0B2817\n" " 22 80 45 #16502D\n" " 33 120 68 #217844\n" " 44 160 90 #2CA05A\n" " 55 200 113 #37C871\n" " 95 211 141 #5FD38D\n" "135 222 170 #87DEAA\n" "175 233 198 #AFE9C6\n" "215 244 227 #D7F4E3\n" " 28 36 31 #1C241F\n" " 55 72 62 #37483E\n" " 83 108 93 #536C5D\n" "111 145 124 #6F917C\n" "147 172 157 #93AC9D\n" "183 200 190 #B7C8BE\n" "219 227 222 #DBE3DE\n" " 0 43 34 #002B22\n" " 0 85 68 #005544\n" " 0 128 102 #008066\n" " 0 170 136 #00AA88\n" " 0 212 170 #00D4AA\n" " 0 255 204 #00FFCC\n" " 42 255 213 #2AFFD5\n" " 85 255 221 #55FFDD\n" "128 255 230 #80FFE6\n" "170 255 238 #AAFFEE\n" "213 255 246 #D5FFF6\n" " 11 40 34 #0B2822\n" " 22 80 68 #165044\n" " 33 120 103 #217867\n" " 44 160 137 #2CA089\n" " 55 200 171 #37C8AB\n" " 95 211 188 #5FD3BC\n" "135 222 205 #87DECD\n" "175 233 221 #AFE9DD\n" "215 244 238 #D7F4EE\n" " 28 36 34 #1C2422\n" " 55 72 69 #374845\n" " 83 108 103 #536C67\n" "111 145 138 #6F918A\n" "147 172 167 #93ACA7\n" "183 200 196 #B7C8C4\n" "219 227 226 #DBE3E2\n" " 0 34 43 #00222B\n" " 0 68 85 #004455\n" " 0 102 128 #006680\n" " 0 136 170 #0088AA\n" " 0 170 212 #00AAD4\n" " 0 204 255 #00CCFF\n" " 42 212 255 #2AD4FF\n" " 85 221 255 #55DDFF\n" "128 229 255 #80E5FF\n" "170 238 255 #AAEEFF\n" "213 246 255 #D5F6FF\n" " 11 34 40 #0B2228\n" " 22 68 80 #164450\n" " 33 103 120 #216778\n" " 44 137 160 #2C89A0\n" " 55 171 200 #37ABC8\n" " 95 188 211 #5FBCD3\n" "135 205 222 #87CDDE\n" "175 221 233 #AFDDE9\n" "215 238 244 #D7EEF4\n" " 28 34 36 #1C2224\n" " 55 69 72 #374548\n" " 83 103 108 #53676C\n" "111 138 145 #6F8A91\n" "147 167 172 #93A7AC\n" "183 196 200 #B7C4C8\n" "219 226 227 #DBE2E3\n" " 0 17 43 #00112B\n" " 0 34 85 #002255\n" " 0 51 128 #003380\n" " 0 68 170 #0044AA\n" " 0 85 212 #0055D4\n" " 0 102 255 #0066FF\n" " 42 127 255 #2A7FFF\n" " 85 153 255 #5599FF\n" "128 179 255 #80B3FF\n" "170 204 255 #AACCFF\n" "213 229 255 #D5E5FF\n" " 11 23 40 #0B1728\n" " 22 45 80 #162D50\n" " 33 68 120 #214478\n" " 44 90 160 #2C5AA0\n" " 55 113 200 #3771C8\n" " 95 141 211 #5F8DD3\n" "135 170 222 #87AADE\n" "175 198 233 #AFC6E9\n" "215 227 244 #D7E3F4\n" " 28 31 36 #1C1F24\n" " 55 62 72 #373E48\n" " 83 93 108 #535D6C\n" "111 124 145 #6F7C91\n" "147 157 172 #939DAC\n" "183 190 200 #B7BEC8\n" "219 222 227 #DBDEE3\n" " 0 0 43 #00002B\n" " 0 0 85 #000055\n" " 0 0 128 #000080\n" " 0 0 170 #0000AA\n" " 0 0 212 #0000D4\n" " 0 0 255 #0000FF\n" " 42 42 255 #2A2AFF\n" " 85 85 255 #5555FF\n" "128 128 255 #8080FF\n" "170 170 255 #AAAAFF\n" "213 213 255 #D5D5FF\n" " 11 11 40 #0B0B28\n" " 22 22 80 #161650\n" " 33 33 120 #212178\n" " 44 44 160 #2C2CA0\n" " 55 55 200 #3737C8\n" " 95 95 211 #5F5FD3\n" "135 135 222 #8787DE\n" "175 175 233 #AFAFE9\n" "215 215 244 #D7D7F4\n" " 28 28 36 #1C1C24\n" " 55 55 72 #373748\n" " 83 83 108 #53536C\n" "111 111 145 #6F6F91\n" "147 147 172 #9393AC\n" "183 183 200 #B7B7C8\n" "219 219 227 #DBDBE3\n" " 17 0 43 #11002B\n" " 34 0 85 #220055\n" " 51 0 128 #330080\n" " 68 0 170 #4400AA\n" " 85 0 212 #5500D4\n" "102 0 255 #6600FF\n" "127 42 255 #7F2AFF\n" "153 85 255 #9955FF\n" "179 128 255 #B380FF\n" "204 170 255 #CCAAFF\n" "229 213 255 #E5D5FF\n" " 23 11 40 #170B28\n" " 45 22 80 #2D1650\n" " 68 33 120 #442178\n" " 90 44 160 #5A2CA0\n" "113 55 200 #7137C8\n" "141 95 211 #8D5FD3\n" "170 135 222 #AA87DE\n" "198 175 233 #C6AFE9\n" "227 215 244 #E3D7F4\n" " 31 28 36 #1F1C24\n" " 62 55 72 #3E3748\n" " 93 83 108 #5D536C\n" "124 111 145 #7C6F91\n" "157 147 172 #9D93AC\n" "190 183 200 #BEB7C8\n" "222 219 227 #DEDBE3\n" " 34 0 43 #22002B\n" " 68 0 85 #440055\n" "102 0 128 #660080\n" "136 0 170 #8800AA\n" "170 0 212 #AA00D4\n" "204 0 255 #CC00FF\n" "212 42 255 #D42AFF\n" "221 85 255 #DD55FF\n" "229 128 255 #E580FF\n" "238 170 255 #EEAAFF\n" "246 213 255 #F6D5FF\n" " 34 11 40 #220B28\n" " 68 22 80 #441650\n" "103 33 120 #672178\n" "137 44 160 #892CA0\n" "171 55 200 #AB37C8\n" "188 95 211 #BC5FD3\n" "205 135 222 #CD87DE\n" "221 175 233 #DDAFE9\n" "238 215 244 #EED7F4\n" " 34 28 36 #221C24\n" " 69 55 72 #453748\n" "103 83 108 #67536C\n" "138 111 145 #8A6F91\n" "167 147 172 #A793AC\n" "196 183 200 #C4B7C8\n" "226 219 227 #E2DBE3\n" " 43 0 34 #2B0022\n" " 85 0 68 #550044\n" "128 0 102 #800066\n" "170 0 136 #AA0088\n" "212 0 170 #D400AA\n" "255 0 204 #FF00CC\n" "255 42 212 #FF2AD4\n" "255 85 221 #FF55DD\n" "255 128 229 #FF80E5\n" "255 170 238 #FFAAEE\n" "255 213 246 #FFD5F6\n" " 40 11 34 #280B22\n" " 80 22 68 #501644\n" "120 33 103 #782167\n" "160 44 137 #A02C89\n" "200 55 171 #C837AB\n" "211 95 188 #D35FBC\n" "222 135 205 #DE87CD\n" "233 175 221 #E9AFDD\n" "244 215 238 #F4D7EE\n" " 36 28 34 #241C22\n" " 72 55 69 #483745\n" "108 83 103 #6C5367\n" "145 111 138 #916F8A\n" "172 147 167 #AC93A7\n" "200 183 196 #C8B7C4\n" "227 219 226 #E3DBE2\n" " 43 0 17 #2B0011\n" " 85 0 34 #550022\n" "128 0 51 #800033\n" "170 0 68 #AA0044\n" "212 0 85 #D40055\n" "255 0 102 #FF0066\n" "255 42 127 #FF2A7F\n" "255 85 153 #FF5599\n" "255 128 178 #FF80B2\n" "255 170 204 #FFAACC\n" "255 213 229 #FFD5E5\n" " 40 11 23 #280B17\n" " 80 22 45 #50162D\n" "120 33 68 #782144\n" "160 44 90 #A02C5A\n" "200 55 113 #C83771\n" "211 95 141 #D35F8D\n" "222 135 170 #DE87AA\n" "233 175 198 #E9AFC6\n" "244 215 227 #F4D7E3\n" " 36 28 31 #241C1F\n" " 72 55 62 #48373E\n" "108 83 93 #6C535D\n" "145 111 124 #916F7C\n" "172 147 157 #AC939D\n" "200 183 190 #C8B7BE\n" "227 219 222 #E3DBDE\n" "" }, {.path = "data/palettes/Khaki.gpl", .size = 3160, .data = "GIMP Palette\n" "Name: Khaki\n" "#\n" " 0 0 0 #000000\n" "128 128 128 #808080\n" "255 255 255 #FFFFFF\n" "144 132 108 #90846C\n" "144 132 112 #908470\n" "144 132 116 #908474\n" "144 136 116 #908874\n" "144 136 120 #908878\n" "144 140 120 #908C78\n" "144 140 124 #908C7C\n" "144 140 128 #908C80\n" "144 144 128 #909080\n" "144 144 132 #909084\n" "144 144 136 #909088\n" "144 148 136 #909488\n" "144 148 140 #90948C\n" "144 152 140 #90988C\n" "144 152 144 #909890\n" "144 152 148 #909894\n" "144 156 148 #909C94\n" "144 156 152 #909C98\n" "144 160 152 #90A098\n" "144 160 156 #90A09C\n" "144 160 160 #90A0A0\n" "144 164 160 #90A4A0\n" "144 164 164 #90A4A4\n" "144 164 168 #90A4A8\n" "144 168 168 #90A8A8\n" "144 168 172 #90A8AC\n" "144 172 172 #90ACAC\n" "144 172 176 #90ACB0\n" "144 172 180 #90ACB4\n" "144 176 180 #90B0B4\n" "144 176 184 #90B0B8\n" "144 180 184 #90B4B8\n" "144 180 188 #90B4BC\n" "144 180 192 #90B4C0\n" "144 184 192 #90B8C0\n" "144 184 196 #90B8C4\n" "148 188 192 #94BCC0\n" "152 188 192 #98BCC0\n" "152 188 188 #98BCBC\n" "156 188 188 #9CBCBC\n" "160 188 184 #A0BCB8\n" "164 188 184 #A4BCB8\n" "164 188 180 #A4BCB4\n" "164 192 180 #A4C0B4\n" "168 192 180 #A8C0B4\n" "172 192 176 #ACC0B0\n" "176 192 176 #B0C0B0\n" "176 192 172 #B0C0AC\n" "180 192 172 #B4C0AC\n" "180 192 168 #B4C0A8\n" "184 192 168 #B8C0A8\n" "184 196 168 #B8C4A8\n" "188 196 164 #BCC4A4\n" "192 196 164 #C0C4A4\n" "192 196 160 #C0C4A0\n" "196 196 160 #C4C4A0\n" "200 196 156 #C8C49C\n" "200 200 156 #C8C89C\n" "204 200 156 #CCC89C\n" "204 200 152 #CCC898\n" "208 200 152 #D0C898\n" "208 200 148 #D0C894\n" "212 200 148 #D4C894\n" "216 200 148 #D8C894\n" "216 200 144 #D8C890\n" "220 200 144 #DCC890\n" "220 204 144 #DCCC90\n" "220 204 140 #DCCC8C\n" "224 204 140 #E0CC8C\n" "228 204 136 #E4CC88\n" "232 204 136 #E8CC88\n" "232 204 132 #E8CC84\n" "236 204 132 #ECCC84\n" "232 200 128 #E8C880\n" "228 200 128 #E4C880\n" "228 196 128 #E4C480\n" "228 196 124 #E4C47C\n" "224 196 124 #E0C47C\n" "220 192 124 #DCC07C\n" "220 192 120 #DCC078\n" "216 192 120 #D8C078\n" "216 188 120 #D8BC78\n" "212 188 120 #D4BC78\n" "212 188 116 #D4BC74\n" "208 188 116 #D0BC74\n" "208 184 116 #D0B874\n" "204 184 116 #CCB874\n" "204 184 112 #CCB870\n" "204 180 112 #CCB470\n" "200 180 112 #C8B470\n" "196 180 108 #C4B46C\n" "196 176 108 #C4B06C\n" "192 176 108 #C0B06C\n" "188 172 104 #BCAC68\n" "184 172 104 #B8AC68\n" "184 168 104 #B8A868\n" "180 168 100 #B4A864\n" "176 168 100 #B0A864\n" "176 164 100 #B0A464\n" "176 164 96 #B0A460\n" "172 164 96 #ACA460\n" "172 160 96 #ACA060\n" "168 160 96 #A8A060\n" "168 160 92 #A8A05C\n" "164 160 92 #A4A05C\n" "164 156 92 #A49C5C\n" "160 156 92 #A09C5C\n" "160 156 88 #A09C58\n" "156 152 88 #9C9858\n" "152 152 88 #989858\n" "152 152 84 #989854\n" "152 148 84 #989454\n" "148 148 84 #949454\n" "144 144 80 #909050\n" "140 144 80 #8C9050\n" "140 140 80 #8C8C50\n" "140 140 76 #8C8C4C\n" "136 140 76 #888C4C\n" "132 136 76 #84884C\n" "132 136 72 #848848\n" "128 136 72 #808848\n" "128 132 72 #808448\n" "124 132 72 #7C8448\n" "124 132 68 #7C8444\n" "120 132 68 #788444\n" "120 128 68 #788044\n" "116 128 68 #748044\n" "116 128 64 #748040\n" "116 124 64 #747C40\n" "112 124 64 #707C40\n" "108 124 60 #6C7C3C\n" "108 120 60 #6C783C\n" "104 120 60 #68783C\n" "100 116 56 #647438\n" " 96 116 56 #607438\n" " 96 112 56 #607038\n" " 92 112 52 #5C7034\n" " 88 112 52 #587034\n" " 88 108 52 #586C34\n" " 88 108 48 #586C30\n" " 84 108 48 #546C30\n" " 84 104 48 #546830\n" " 80 104 48 #506830\n" " 80 104 44 #50682C\n" " 76 104 44 #4C682C\n" " 76 100 44 #4C642C\n" " 72 100 44 #48642C\n" " 72 100 40 #486428\n" " 68 96 40 #446028\n" " 64 96 40 #406028\n" " 64 96 36 #406024\n" " 64 92 36 #405C24\n" " 60 92 36 #3C5C24\n" "" }, {.path = "data/palettes/MagicaVoxel.gpl", .size = 5154, .data = "GIMP Palette\n" "Name: MagicaVoxel\n" "#\n" "255 255 255 #FFFFFF\n" "255 255 204 #FFFFCC\n" "255 255 153 #FFFF99\n" "255 255 102 #FFFF66\n" "255 255 51 #FFFF33\n" "255 255 0 #FFFF00\n" "255 204 255 #FFCCFF\n" "255 204 204 #FFCCCC\n" "255 204 153 #FFCC99\n" "255 204 102 #FFCC66\n" "255 204 51 #FFCC33\n" "255 204 0 #FFCC00\n" "255 153 255 #FF99FF\n" "255 153 204 #FF99CC\n" "255 153 153 #FF9999\n" "255 153 102 #FF9966\n" "255 153 51 #FF9933\n" "255 153 0 #FF9900\n" "255 102 255 #FF66FF\n" "255 102 204 #FF66CC\n" "255 102 153 #FF6699\n" "255 102 102 #FF6666\n" "255 102 51 #FF6633\n" "255 102 0 #FF6600\n" "255 51 255 #FF33FF\n" "255 51 204 #FF33CC\n" "255 51 153 #FF3399\n" "255 51 102 #FF3366\n" "255 51 51 #FF3333\n" "255 51 0 #FF3300\n" "255 0 255 #FF00FF\n" "255 0 204 #FF00CC\n" "255 0 153 #FF0099\n" "255 0 102 #FF0066\n" "255 0 51 #FF0033\n" "255 0 0 #FF0000\n" "204 255 255 #CCFFFF\n" "204 255 204 #CCFFCC\n" "204 255 153 #CCFF99\n" "204 255 102 #CCFF66\n" "204 255 51 #CCFF33\n" "204 255 0 #CCFF00\n" "204 204 255 #CCCCFF\n" "204 204 204 #CCCCCC\n" "204 204 153 #CCCC99\n" "204 204 102 #CCCC66\n" "204 204 51 #CCCC33\n" "204 204 0 #CCCC00\n" "204 153 255 #CC99FF\n" "204 153 204 #CC99CC\n" "204 153 153 #CC9999\n" "204 153 102 #CC9966\n" "204 153 51 #CC9933\n" "204 153 0 #CC9900\n" "204 102 255 #CC66FF\n" "204 102 204 #CC66CC\n" "204 102 153 #CC6699\n" "204 102 102 #CC6666\n" "204 102 51 #CC6633\n" "204 102 0 #CC6600\n" "204 51 255 #CC33FF\n" "204 51 204 #CC33CC\n" "204 51 153 #CC3399\n" "204 51 102 #CC3366\n" "204 51 51 #CC3333\n" "204 51 0 #CC3300\n" "204 0 255 #CC00FF\n" "204 0 204 #CC00CC\n" "204 0 153 #CC0099\n" "204 0 102 #CC0066\n" "204 0 51 #CC0033\n" "204 0 0 #CC0000\n" "153 255 255 #99FFFF\n" "153 255 204 #99FFCC\n" "153 255 153 #99FF99\n" "153 255 102 #99FF66\n" "153 255 51 #99FF33\n" "153 255 0 #99FF00\n" "153 204 255 #99CCFF\n" "153 204 204 #99CCCC\n" "153 204 153 #99CC99\n" "153 204 102 #99CC66\n" "153 204 51 #99CC33\n" "153 204 0 #99CC00\n" "153 153 255 #9999FF\n" "153 153 204 #9999CC\n" "153 153 153 #999999\n" "153 153 102 #999966\n" "153 153 51 #999933\n" "153 153 0 #999900\n" "153 102 255 #9966FF\n" "153 102 204 #9966CC\n" "153 102 153 #996699\n" "153 102 102 #996666\n" "153 102 51 #996633\n" "153 102 0 #996600\n" "153 51 255 #9933FF\n" "153 51 204 #9933CC\n" "153 51 153 #993399\n" "153 51 102 #993366\n" "153 51 51 #993333\n" "153 51 0 #993300\n" "153 0 255 #9900FF\n" "153 0 204 #9900CC\n" "153 0 153 #990099\n" "153 0 102 #990066\n" "153 0 51 #990033\n" "153 0 0 #990000\n" "102 255 255 #66FFFF\n" "102 255 204 #66FFCC\n" "102 255 153 #66FF99\n" "102 255 102 #66FF66\n" "102 255 51 #66FF33\n" "102 255 0 #66FF00\n" "102 204 255 #66CCFF\n" "102 204 204 #66CCCC\n" "102 204 153 #66CC99\n" "102 204 102 #66CC66\n" "102 204 51 #66CC33\n" "102 204 0 #66CC00\n" "102 153 255 #6699FF\n" "102 153 204 #6699CC\n" "102 153 153 #669999\n" "102 153 102 #669966\n" "102 153 51 #669933\n" "102 153 0 #669900\n" "102 102 255 #6666FF\n" "102 102 204 #6666CC\n" "102 102 153 #666699\n" "102 102 102 #666666\n" "102 102 51 #666633\n" "102 102 0 #666600\n" "102 51 255 #6633FF\n" "102 51 204 #6633CC\n" "102 51 153 #663399\n" "102 51 102 #663366\n" "102 51 51 #663333\n" "102 51 0 #663300\n" "102 0 255 #6600FF\n" "102 0 204 #6600CC\n" "102 0 153 #660099\n" "102 0 102 #660066\n" "102 0 51 #660033\n" "102 0 0 #660000\n" "51 255 255 #33FFFF\n" "51 255 204 #33FFCC\n" "51 255 153 #33FF99\n" "51 255 102 #33FF66\n" "51 255 51 #33FF33\n" "51 255 0 #33FF00\n" "51 204 255 #33CCFF\n" "51 204 204 #33CCCC\n" "51 204 153 #33CC99\n" "51 204 102 #33CC66\n" "51 204 51 #33CC33\n" "51 204 0 #33CC00\n" "51 153 255 #3399FF\n" "51 153 204 #3399CC\n" "51 153 153 #339999\n" "51 153 102 #339966\n" "51 153 51 #339933\n" "51 153 0 #339900\n" "51 102 255 #3366FF\n" "51 102 204 #3366CC\n" "51 102 153 #336699\n" "51 102 102 #336666\n" "51 102 51 #336633\n" "51 102 0 #336600\n" "51 51 255 #3333FF\n" "51 51 204 #3333CC\n" "51 51 153 #333399\n" "51 51 102 #333366\n" "51 51 51 #333333\n" "51 51 0 #333300\n" "51 0 255 #3300FF\n" "51 0 204 #3300CC\n" "51 0 153 #330099\n" "51 0 102 #330066\n" "51 0 51 #330033\n" "51 0 0 #330000\n" "0 255 255 #00FFFF\n" "0 255 204 #00FFCC\n" "0 255 153 #00FF99\n" "0 255 102 #00FF66\n" "0 255 51 #00FF33\n" "0 255 0 #00FF00\n" "0 204 255 #00CCFF\n" "0 204 204 #00CCCC\n" "0 204 153 #00CC99\n" "0 204 102 #00CC66\n" "0 204 51 #00CC33\n" "0 204 0 #00CC00\n" "0 153 255 #0099FF\n" "0 153 204 #0099CC\n" "0 153 153 #009999\n" "0 153 102 #009966\n" "0 153 51 #009933\n" "0 153 0 #009900\n" "0 102 255 #0066FF\n" "0 102 204 #0066CC\n" "0 102 153 #006699\n" "0 102 102 #006666\n" "0 102 51 #006633\n" "0 102 0 #006600\n" "0 51 255 #0033FF\n" "0 51 204 #0033CC\n" "0 51 153 #003399\n" "0 51 102 #003366\n" "0 51 51 #003333\n" "0 51 0 #003300\n" "0 0 255 #0000FF\n" "0 0 204 #0000CC\n" "0 0 153 #000099\n" "0 0 102 #000066\n" "0 0 51 #000033\n" "238 0 0 #EE0000\n" "221 0 0 #DD0000\n" "187 0 0 #BB0000\n" "170 0 0 #AA0000\n" "136 0 0 #880000\n" "119 0 0 #770000\n" "85 0 0 #550000\n" "68 0 0 #440000\n" "34 0 0 #220000\n" "17 0 0 #110000\n" "0 238 0 #00EE00\n" "0 221 0 #00DD00\n" "0 187 0 #00BB00\n" "0 170 0 #00AA00\n" "0 136 0 #008800\n" "0 119 0 #007700\n" "0 85 0 #005500\n" "0 68 0 #004400\n" "0 34 0 #002200\n" "0 17 0 #001100\n" "0 0 238 #0000EE\n" "0 0 221 #0000DD\n" "0 0 187 #0000BB\n" "0 0 170 #0000AA\n" "0 0 136 #000088\n" "0 0 119 #000077\n" "0 0 85 #000055\n" "0 0 68 #000044\n" "0 0 34 #000022\n" "0 0 17 #000011\n" "238 238 238 #EEEEEE\n" "221 221 221 #DDDDDD\n" "187 187 187 #BBBBBB\n" "170 170 170 #AAAAAA\n" "136 136 136 #888888\n" "119 119 119 #777777\n" "85 85 85 #555555\n" "68 68 68 #444444\n" "34 34 34 #222222\n" "17 17 17 #111111\n" "0 0 0 #000000\n" "" }, {.path = "data/palettes/Pastels.gpl", .size = 435, .data = "GIMP Palette\n" "Name: Pastels\n" "# Pastels -- GIMP Palette file\n" "226 145 145 Untitled\n" "153 221 146 Untitled\n" "147 216 185 Untitled\n" "148 196 211 Untitled\n" "148 154 206 Untitled\n" "179 148 204 Untitled\n" "204 150 177 Untitled\n" "204 164 153 Untitled\n" "223 229 146 Untitled\n" "255 165 96 Untitled\n" "107 255 99 Untitled\n" "101 255 204 Untitled\n" "101 196 255 Untitled\n" "101 107 255 Untitled\n" "173 101 255 Untitled\n" "255 101 244 Untitled\n" "255 101 132 Untitled\n" "255 101 101 Untitled\n" "" }, {.path = "data/palettes/Plasma.gpl", .size = 3111, .data = "GIMP Palette\n" "Name: Plasma\n" "#\n" "240 240 0\n" "240 224 0\n" "240 208 0\n" "240 192 0\n" "240 176 0\n" "240 160 0\n" "240 144 0\n" "240 128 0\n" "240 112 0\n" "240 96 0\n" "240 80 0\n" "240 64 0\n" "240 48 0\n" "240 32 0\n" "240 16 0\n" "240 0 0\n" "224 224 16\n" "224 212 16\n" "224 200 16\n" "224 184 16\n" "224 172 12\n" "224 156 12\n" "224 144 12\n" "224 128 12\n" "224 116 8\n" "224 100 8\n" "224 88 8\n" "224 72 8\n" "224 60 4\n" "224 44 4\n" "224 32 4\n" "224 16 0\n" "208 208 32\n" "208 200 32\n" "208 188 28\n" "208 176 28\n" "208 164 24\n" "208 152 24\n" "208 140 20\n" "208 128 20\n" "208 116 16\n" "208 104 16\n" "208 92 12\n" "208 80 12\n" "208 68 8\n" "208 56 8\n" "208 44 4\n" "208 32 0\n" "192 192 48\n" "192 184 48\n" "192 176 44\n" "192 164 40\n" "192 156 36\n" "192 144 32\n" "192 136 32\n" "192 128 28\n" "192 116 24\n" "192 108 20\n" "192 96 16\n" "192 88 16\n" "192 80 12\n" "192 68 8\n" "192 60 4\n" "192 48 0\n" "176 176 64\n" "176 172 60\n" "176 164 56\n" "176 156 52\n" "176 148 48\n" "176 140 44\n" "176 132 40\n" "176 124 36\n" "176 120 32\n" "176 112 28\n" "176 104 24\n" "176 96 20\n" "176 88 16\n" "176 80 12\n" "176 72 8\n" "176 64 0\n" "160 160 80\n" "160 156 76\n" "160 152 72\n" "160 144 64\n" "160 140 60\n" "160 136 56\n" "160 128 48\n" "160 124 44\n" "160 120 40\n" "160 112 32\n" "160 108 28\n" "160 104 24\n" "160 96 16\n" "160 92 12\n" "160 88 8\n" "160 80 0\n" "144 144 96\n" "144 144 92\n" "144 140 84\n" "144 136 80\n" "144 132 72\n" "144 128 64\n" "144 128 60\n" "144 124 52\n" "144 120 48\n" "144 116 40\n" "144 112 32\n" "144 112 28\n" "144 108 20\n" "144 104 16\n" "144 100 8\n" "144 96 0\n" "128 128 112\n" "128 128 108\n" "128 128 100\n" "128 128 92\n" "128 124 84\n" "128 124 76\n" "128 124 68\n" "128 124 60\n" "128 120 56\n" "128 120 48\n" "128 120 40\n" "128 120 32\n" "128 116 24\n" "128 116 16\n" "128 116 8\n" "128 112 0\n" "112 112 128\n" "112 112 120\n" "112 112 112 grey44\n" "112 112 104\n" "112 116 96\n" "112 116 88\n" "112 116 80\n" "112 116 72\n" "112 120 60\n" "112 120 52\n" "112 120 44\n" "112 120 36\n" "112 124 28\n" "112 124 20\n" "112 124 12\n" "112 128 0\n" " 96 96 144\n" " 96 96 136\n" " 96 100 128\n" " 96 104 116\n" " 96 108 108\n" " 96 112 96\n" " 96 112 88\n" " 96 116 80\n" " 96 120 68\n" " 96 124 60\n" " 96 128 48\n" " 96 128 40\n" " 96 132 32\n" " 96 136 20\n" " 96 140 12\n" " 96 144 0\n" " 80 80 160\n" " 80 84 152\n" " 80 88 140\n" " 80 96 128\n" " 80 100 120\n" " 80 104 108\n" " 80 112 96\n" " 80 116 88\n" " 80 120 76\n" " 80 128 64\n" " 80 132 56\n" " 80 136 44\n" " 80 144 32\n" " 80 148 24\n" " 80 152 12\n" " 80 160 0\n" " 64 64 176\n" " 64 68 168\n" " 64 76 156\n" " 64 84 144\n" " 64 92 132\n" " 64 100 120\n" " 64 108 108\n" " 64 116 96\n" " 64 120 84\n" " 64 128 72\n" " 64 136 60\n" " 64 144 48\n" " 64 152 36\n" " 64 160 24\n" " 64 168 12\n" " 64 176 0\n" " 48 48 192\n" " 48 56 180\n" " 48 64 168\n" " 48 76 156\n" " 48 84 144\n" " 48 96 128\n" " 48 104 116\n" " 48 112 104\n" " 48 124 92\n" " 48 132 80\n" " 48 144 64\n" " 48 152 52\n" " 48 160 40\n" " 48 172 28\n" " 48 180 16\n" " 48 192 0\n" " 32 32 208\n" " 32 40 196\n" " 32 52 184\n" " 32 64 168\n" " 32 76 156\n" " 32 88 140\n" " 32 100 128\n" " 32 112 112\n" " 32 124 100\n" " 32 136 84\n" " 32 148 72\n" " 32 160 56\n" " 32 172 44\n" " 32 184 28\n" " 32 196 16\n" " 32 208 0\n" " 16 16 224\n" " 16 28 212\n" " 16 40 196\n" " 16 56 180\n" " 16 68 168\n" " 16 84 152\n" " 16 96 136\n" " 16 112 120\n" " 16 124 108\n" " 16 140 92\n" " 16 152 76\n" " 16 168 60\n" " 16 180 48\n" " 16 196 32\n" " 16 208 16\n" " 16 224 0\n" " 0 0 240\n" " 0 16 224\n" " 0 32 208\n" " 0 48 192\n" " 0 64 176\n" " 0 80 160\n" " 0 96 144\n" " 0 112 128\n" " 0 128 112\n" " 0 144 96\n" " 0 160 80\n" " 0 176 64\n" " 0 192 48\n" " 0 208 32\n" " 0 224 16\n" " 0 240 0\n" "" }, {.path = "data/palettes/Reds.gpl", .size = 3579, .data = "GIMP Palette\n" "Name: Reds\n" "#\n" " 0 0 0 #000000\n" "128 128 128 #808080\n" "255 255 255 #FFFFFF\n" " 76 0 0 #4C0000\n" " 72 0 0 #480000\n" " 68 0 0 #440000\n" " 64 0 0 #400000\n" " 60 0 0 #3C0000\n" " 56 0 0 #380000\n" " 52 0 0 #340000\n" " 48 0 0 #300000\n" " 44 0 0 #2C0000\n" " 40 0 0 #280000\n" " 36 0 0 #240000\n" " 32 0 0 #200000\n" " 28 0 0 #1C0000\n" " 24 0 0 #180000\n" " 20 0 0 #140000\n" " 16 0 0 #100000\n" " 12 0 0 #0C0000\n" " 8 0 0 #080000\n" " 4 0 0 #040000\n" " 0 0 0 #000000\n" " 4 0 0 #040000\n" " 4 4 4 #040404\n" " 8 4 4 #080404\n" " 12 8 8 #0C0808\n" " 16 8 8 #100808\n" " 16 12 12 #100C0C\n" " 20 12 12 #140C0C\n" " 24 16 16 #181010\n" " 28 16 16 #1C1010\n" " 28 20 20 #1C1414\n" " 32 20 20 #201414\n" " 36 24 24 #241818\n" " 40 24 24 #281818\n" " 40 28 28 #281C1C\n" " 44 28 28 #2C1C1C\n" " 48 32 32 #302020\n" " 52 32 32 #342020\n" " 52 36 36 #342424\n" " 56 36 36 #382424\n" " 60 40 40 #3C2828\n" " 64 40 40 #402828\n" " 64 44 44 #402C2C\n" " 68 44 44 #442C2C\n" " 72 48 48 #483030\n" " 76 48 48 #4C3030\n" " 76 52 52 #4C3434\n" " 80 52 52 #503434\n" " 84 56 56 #543838\n" " 88 56 56 #583838\n" " 88 60 60 #583C3C\n" " 92 60 60 #5C3C3C\n" " 92 64 64 #5C4040\n" " 96 64 64 #604040\n" "100 64 64 #644040\n" "100 68 68 #644444\n" "104 68 68 #684444\n" "104 72 72 #684848\n" "108 72 72 #6C4848\n" "112 72 72 #704848\n" "112 76 76 #704C4C\n" "116 76 76 #744C4C\n" "116 80 80 #745050\n" "120 80 80 #785050\n" "124 84 84 #7C5454\n" "128 84 84 #805454\n" "128 88 88 #805858\n" "132 88 88 #845858\n" "252 252 252 #FCFCFC\n" "252 248 248 #FCF8F8\n" "252 244 244 #FCF4F4\n" "252 240 240 #FCF0F0\n" "252 236 236 #FCECEC\n" "252 232 232 #FCE8E8\n" "252 228 228 #FCE4E4\n" "252 224 224 #FCE0E0\n" "252 220 220 #FCDCDC\n" "252 216 216 #FCD8D8\n" "252 212 212 #FCD4D4\n" "252 208 208 #FCD0D0\n" "252 204 204 #FCCCCC\n" "252 200 200 #FCC8C8\n" "252 196 196 #FCC4C4\n" "252 192 192 #FCC0C0\n" "252 188 188 #FCBCBC\n" "252 184 184 #FCB8B8\n" "252 180 180 #FCB4B4\n" "252 176 176 #FCB0B0\n" "252 172 172 #FCACAC\n" "252 168 168 #FCA8A8\n" "252 164 164 #FCA4A4\n" "252 160 160 #FCA0A0\n" "252 156 156 #FC9C9C\n" "252 152 152 #FC9898\n" "252 148 148 #FC9494\n" "252 144 144 #FC9090\n" "252 140 140 #FC8C8C\n" "252 136 136 #FC8888\n" "252 132 132 #FC8484\n" "252 128 128 #FC8080\n" "252 124 124 #FC7C7C\n" "252 120 120 #FC7878\n" "252 116 116 #FC7474\n" "252 112 112 #FC7070\n" "252 108 108 #FC6C6C\n" "252 104 104 #FC6868\n" "252 100 100 #FC6464\n" "252 96 96 #FC6060\n" "252 92 92 #FC5C5C\n" "252 88 88 #FC5858\n" "252 84 84 #FC5454\n" "252 80 80 #FC5050\n" "252 76 76 #FC4C4C\n" "252 72 72 #FC4848\n" "252 68 68 #FC4444\n" "252 64 64 #FC4040\n" "252 60 60 #FC3C3C\n" "252 56 56 #FC3838\n" "252 52 52 #FC3434\n" "252 48 48 #FC3030\n" "252 44 44 #FC2C2C\n" "252 40 40 #FC2828\n" "252 36 36 #FC2424\n" "252 32 32 #FC2020\n" "252 28 28 #FC1C1C\n" "252 24 24 #FC1818\n" "252 20 20 #FC1414\n" "252 16 16 #FC1010\n" "252 12 12 #FC0C0C\n" "252 8 8 #FC0808\n" "252 4 4 #FC0404\n" "252 0 0 #FC0000\n" "248 0 0 #F80000\n" "244 0 0 #F40000\n" "240 0 0 #F00000\n" "236 0 0 #EC0000\n" "232 0 0 #E80000\n" "228 0 0 #E40000\n" "224 0 0 #E00000\n" "220 0 0 #DC0000\n" "216 0 0 #D80000\n" "212 0 0 #D40000\n" "208 0 0 #D00000\n" "204 0 0 #CC0000\n" "200 0 0 #C80000\n" "196 0 0 #C40000\n" "192 0 0 #C00000\n" "188 0 0 #BC0000\n" "184 0 0 #B80000\n" "180 0 0 #B40000\n" "176 0 0 #B00000\n" "172 0 0 #AC0000\n" "168 0 0 #A80000\n" "164 0 0 #A40000\n" "160 0 0 #A00000\n" "156 0 0 #9C0000\n" "152 0 0 #980000\n" "148 0 0 #940000\n" "144 0 0 #900000\n" "140 0 0 #8C0000\n" "136 0 0 #880000\n" "132 0 0 #840000\n" "128 0 0 #800000\n" "124 0 0 #7C0000\n" "120 0 0 #780000\n" "116 0 0 #740000\n" "112 0 0 #700000\n" "108 0 0 #6C0000\n" "104 0 0 #680000\n" "100 0 0 #640000\n" " 96 0 0 #600000\n" " 92 0 0 #5C0000\n" " 88 0 0 #580000\n" " 84 0 0 #540000\n" " 80 0 0 #500000\n" "" }, {.path = "data/palettes/Royal.gpl", .size = 4480, .data = "GIMP Palette\n" "Name: Royal\n" "#\n" " 0 0 0 #000000\n" "128 128 128 #808080\n" "255 255 255 #FFFFFF\n" " 60 0 80 #3C0050\n" " 60 0 84 #3C0054\n" " 64 0 84 #400054\n" " 64 0 88 #400058\n" " 68 0 88 #440058\n" " 68 0 92 #44005C\n" " 72 0 96 #480060\n" " 72 0 100 #480064\n" " 76 0 100 #4C0064\n" " 76 0 104 #4C0068\n" " 80 0 104 #500068\n" " 80 0 108 #50006C\n" " 84 0 112 #540070\n" " 84 0 116 #540074\n" " 88 0 116 #580074\n" " 88 0 120 #580078\n" " 92 0 120 #5C0078\n" " 92 0 124 #5C007C\n" " 96 0 128 #600080\n" " 96 0 132 #600084\n" "100 0 132 #640084\n" "100 0 136 #640088\n" "104 0 136 #680088\n" "104 0 140 #68008C\n" "108 0 144 #6C0090\n" "108 0 148 #6C0094\n" "112 0 148 #700094\n" "112 0 152 #700098\n" "116 0 152 #740098\n" "116 0 156 #74009C\n" "120 0 160 #7800A0\n" "124 4 160 #7C04A0\n" "124 8 164 #7C08A4\n" "128 12 164 #800CA4\n" "128 16 164 #8010A4\n" "132 20 168 #8414A8\n" "132 24 168 #8418A8\n" "136 28 168 #881CA8\n" "136 32 172 #8820AC\n" "140 36 172 #8C24AC\n" "140 40 172 #8C28AC\n" "144 44 176 #902CB0\n" "144 48 176 #9030B0\n" "148 52 180 #9434B4\n" "148 56 180 #9438B4\n" "152 60 180 #983CB4\n" "152 64 184 #9840B8\n" "156 68 184 #9C44B8\n" "156 72 184 #9C48B8\n" "160 76 188 #A04CBC\n" "160 80 188 #A050BC\n" "164 84 188 #A454BC\n" "164 88 192 #A458C0\n" "168 92 192 #A85CC0\n" "168 96 192 #A860C0\n" "172 100 196 #AC64C4\n" "172 104 196 #AC68C4\n" "176 108 200 #B06CC8\n" "176 112 200 #B070C8\n" "180 116 200 #B474C8\n" "180 120 204 #B478CC\n" "184 124 204 #B87CCC\n" "188 128 204 #BC80CC\n" "188 132 208 #BC84D0\n" "192 136 208 #C088D0\n" "192 140 208 #C08CD0\n" "196 144 212 #C490D4\n" "196 148 212 #C494D4\n" "200 152 216 #C898D8\n" "200 156 216 #C89CD8\n" "204 160 216 #CCA0D8\n" "204 164 220 #CCA4DC\n" "208 168 220 #D0A8DC\n" "208 172 220 #D0ACDC\n" "212 176 224 #D4B0E0\n" "212 180 224 #D4B4E0\n" "216 184 224 #D8B8E0\n" "216 188 228 #D8BCE4\n" "220 192 228 #DCC0E4\n" "220 196 228 #DCC4E4\n" "224 200 232 #E0C8E8\n" "224 204 232 #E0CCE8\n" "228 208 236 #E4D0EC\n" "228 212 236 #E4D4EC\n" "232 216 236 #E8D8EC\n" "232 220 240 #E8DCF0\n" "236 224 240 #ECE0F0\n" "236 228 240 #ECE4F0\n" "240 232 244 #F0E8F4\n" "240 236 244 #F0ECF4\n" "244 240 244 #F4F0F4\n" "244 244 248 #F4F4F8\n" "248 248 248 #F8F8F8\n" "252 252 252 #FCFCFC\n" "252 252 248 #FCFCF8\n" "252 252 244 #FCFCF4\n" "252 252 240 #FCFCF0\n" "252 252 236 #FCFCEC\n" "252 252 232 #FCFCE8\n" "252 252 228 #FCFCE4\n" "252 252 224 #FCFCE0\n" "252 252 220 #FCFCDC\n" "252 252 216 #FCFCD8\n" "252 252 212 #FCFCD4\n" "252 252 208 #FCFCD0\n" "252 252 204 #FCFCCC\n" "252 252 200 #FCFCC8\n" "252 252 196 #FCFCC4\n" "252 252 192 #FCFCC0\n" "252 252 188 #FCFCBC\n" "252 252 184 #FCFCB8\n" "252 252 180 #FCFCB4\n" "252 252 176 #FCFCB0\n" "252 252 172 #FCFCAC\n" "252 252 168 #FCFCA8\n" "252 252 164 #FCFCA4\n" "252 252 160 #FCFCA0\n" "252 252 156 #FCFC9C\n" "252 252 152 #FCFC98\n" "252 252 148 #FCFC94\n" "252 252 144 #FCFC90\n" "252 252 140 #FCFC8C\n" "252 252 136 #FCFC88\n" "252 252 132 #FCFC84\n" "252 252 128 #FCFC80\n" "252 252 124 #FCFC7C\n" "252 252 120 #FCFC78\n" "252 252 116 #FCFC74\n" "252 252 112 #FCFC70\n" "252 252 108 #FCFC6C\n" "252 252 104 #FCFC68\n" "252 252 100 #FCFC64\n" "252 252 96 #FCFC60\n" "252 252 92 #FCFC5C\n" "252 252 88 #FCFC58\n" "252 252 84 #FCFC54\n" "252 252 80 #FCFC50\n" "252 252 76 #FCFC4C\n" "252 252 72 #FCFC48\n" "252 252 68 #FCFC44\n" "252 252 64 #FCFC40\n" "252 252 60 #FCFC3C\n" "252 252 56 #FCFC38\n" "252 252 52 #FCFC34\n" "252 252 48 #FCFC30\n" "252 252 44 #FCFC2C\n" "252 252 40 #FCFC28\n" "252 252 36 #FCFC24\n" "252 252 32 #FCFC20\n" "252 252 28 #FCFC1C\n" "252 252 24 #FCFC18\n" "252 252 20 #FCFC14\n" "252 252 16 #FCFC10\n" "252 252 12 #FCFC0C\n" "252 252 8 #FCFC08\n" "252 252 4 #FCFC04\n" "252 252 0 #FCFC00\n" "252 248 0 #FCF800\n" "248 244 0 #F8F400\n" "244 240 0 #F4F000\n" "240 236 4 #F0EC04\n" "240 232 4 #F0E804\n" "236 228 4 #ECE404\n" "232 224 8 #E8E008\n" "228 220 8 #E4DC08\n" "228 216 8 #E4D808\n" "224 212 12 #E0D40C\n" "220 208 12 #DCD00C\n" "216 204 12 #D8CC0C\n" "212 200 16 #D4C810\n" "212 196 16 #D4C410\n" "208 192 16 #D0C010\n" "204 188 20 #CCBC14\n" "200 184 20 #C8B814\n" "200 180 20 #C8B414\n" "196 176 24 #C4B018\n" "192 172 24 #C0AC18\n" "188 168 24 #BCA818\n" "184 164 28 #B8A41C\n" "184 160 28 #B8A01C\n" "180 156 28 #B49C1C\n" "176 152 32 #B09820\n" "172 148 32 #AC9420\n" "172 144 32 #AC9020\n" "168 140 36 #A88C24\n" "164 136 36 #A48824\n" "160 132 36 #A08424\n" "160 128 36 #A08024\n" "156 124 40 #9C7C28\n" "152 120 40 #987828\n" "148 116 40 #947428\n" "144 112 44 #90702C\n" "144 108 44 #906C2C\n" "140 104 44 #8C682C\n" "136 100 48 #886430\n" "132 96 48 #846030\n" "132 92 48 #845C30\n" "128 88 52 #805834\n" "124 84 52 #7C5434\n" "120 80 52 #785034\n" "116 76 56 #744C38\n" "116 72 56 #744838\n" "112 68 56 #704438\n" "108 64 60 #6C403C\n" "104 60 60 #683C3C\n" "104 56 60 #68383C\n" "100 52 64 #643440\n" " 96 48 64 #603040\n" " 92 44 64 #5C2C40\n" " 88 40 68 #582844\n" " 88 36 68 #582444\n" " 84 32 68 #542044\n" " 80 28 72 #501C48\n" " 76 24 72 #4C1848\n" " 76 20 72 #4C1448\n" " 72 16 76 #48104C\n" " 68 12 76 #440C4C\n" " 64 8 76 #40084C\n" " 60 0 80 #3C0050\n" "" }, {.path = "data/palettes/Tango-Palette.gpl", .size = 709, .data = "GIMP Palette\n" "Name: Tango icons\n" "Columns: 3\n" "#\n" "252 233 79 Butter 1\n" "237 212 0 Butter 2\n" "196 160 0 Butter 3\n" "138 226 52 Chameleon 1\n" "115 210 22 Chameleon 2\n" " 78 154 6 Chameleon 3\n" "252 175 62 Orange 1\n" "245 121 0 Orange 2\n" "206 92 0 Orange 3\n" "114 159 207 Sky Blue 1\n" " 52 101 164 Sky Blue 2\n" " 32 74 135 Sky Blue 3\n" "173 127 168 Plum 1\n" "117 80 123 Plum 2\n" " 92 53 102 Plum 3\n" "233 185 110 Chocolate 1\n" "193 125 17 Chocolate 2\n" "143 89 2 Chocolate 3\n" "239 41 41 Scarlet Red 1\n" "204 0 0 Scarlet Red 2\n" "164 0 0 Scarlet Red 3\n" "255 255 255 Snowy White\n" "238 238 236 Aluminium 1\n" "211 215 207 Aluminium 2\n" "186 189 182 Aluminium 3\n" "136 138 133 Aluminium 4\n" " 85 87 83 Aluminium 5\n" " 46 52 54 Aluminium 6\n" " 0 0 0 Jet Black\n" "" }, {.path = "data/palettes/Ubuntu.gpl", .size = 1104, .data = "GIMP Palette\n" "Name: Ubuntu\n" "Columns: 0\n" "#\n" "238 199 62 Orange Hilight\n" "240 165 19 Orange\n" "251 139 0 Orange Base\n" "244 72 0 Orange Shadow\n" "255 255 153 Accent Yellow Highlight\n" "255 255 0 Yellow\n" "253 202 1 Accent Yellow Base\n" "152 102 1 Accent Yellow Shadow\n" "244 72 0 Accent Orange\n" "253 51 1 Accent Red\n" "212 0 0 Accent Red Base\n" "152 1 1 Accent Deep Red\n" "253 217 155 Human Highlight\n" "217 187 122 Human\n" "129 102 71 Human Base\n" " 86 82 72 Environmental Shadow\n" "170 204 238 Environmental Blue Highlight\n" "102 153 204 Environmental Blue Medium\n" " 51 102 153 Environmental Blue Base\n" " 0 51 102 Environmental Blue Shadow\n" "179 222 253 Accent Blue Shadow\n" " 1 151 253 Accent Blue\n" " 1 105 201 Accent Blue Base\n" " 1 51 151 Accent Blue Shadow\n" "204 255 153 Accent Green Highlight\n" "152 252 102 Accent Green\n" " 51 153 0 Accent Green Base\n" " 1 90 1 Accent Green Shadow\n" " 0 43 61 Ubuntu Toner\n" "255 155 255 Accent Magenta Highlight\n" "255 0 255 Accent Magenta\n" "102 0 204 Accent Dark Violet\n" "238 238 238 Grey 1\n" "204 204 207 Grey 2\n" "170 170 170 Grey 3\n" "136 136 136 Grey 4\n" "102 102 102 Grey 5\n" " 51 51 51 Grey 6\n" " 0 0 0 Black\n" "" }, {.path = "data/palettes/webhex.gpl", .size = 4133, .data = "GIMP Palette\n" "Name: WebHex\n" "#\n" "255 255 255 FFFFFF\n" "255 255 204 FFFFCC\n" "255 255 153 FFFF99\n" "255 255 102 FFFF66\n" "255 255 51 FFFF33\n" "255 255 0 FFFF00\n" "255 204 255 FFCCFF\n" "255 204 204 FFCCCC\n" "255 204 153 FFCC99\n" "255 204 102 FFCC66\n" "255 204 51 FFCC33\n" "255 204 0 FFCC00\n" "255 153 255 FF99FF\n" "255 153 204 FF99CC\n" "255 153 153 FF9999\n" "255 153 102 FF9966\n" "255 153 51 FF9933\n" "255 153 0 FF9900\n" "255 102 255 FF66FF\n" "255 102 204 FF66CC\n" "255 102 153 FF6699\n" "255 102 102 FF6666\n" "255 102 51 FF6633\n" "255 102 0 FF6600\n" "255 51 255 FF33FF\n" "255 51 204 FF33CC\n" "255 51 153 FF3399\n" "255 51 102 FF3366\n" "255 51 51 FF3333\n" "255 51 0 FF3300\n" "255 0 255 FF00FF\n" "255 0 204 FF00CC\n" "255 0 153 FF0099\n" "255 0 102 FF0066\n" "255 0 51 FF0033\n" "255 0 0 FF0000\n" "204 255 255 CCFFFF\n" "204 255 204 CCFFCC\n" "204 255 153 CCFF99\n" "204 255 102 CCFF66\n" "204 255 51 CCFF33\n" "204 255 0 CCFF00\n" "204 204 255 CCCCFF\n" "204 204 204 CCCCCC\n" "204 204 153 CCCC99\n" "204 204 102 CCCC66\n" "204 204 51 CCCC33\n" "204 204 0 CCCC00\n" "204 153 255 CC99FF\n" "204 153 204 CC99CC\n" "204 153 153 CC9999\n" "204 153 102 CC9966\n" "204 153 51 CC9933\n" "204 153 0 CC9900\n" "204 102 255 CC66FF\n" "204 102 204 CC66CC\n" "204 102 153 CC6699\n" "204 102 102 CC6666\n" "204 102 51 CC6633\n" "204 102 0 CC6600\n" "204 51 255 CC33FF\n" "204 51 204 CC33CC\n" "204 51 153 CC3399\n" "204 51 102 CC3366\n" "204 51 51 CC3333\n" "204 51 0 CC3300\n" "204 0 255 CC00FF\n" "204 0 204 CC00CC\n" "204 0 153 CC0099\n" "204 0 102 CC0066\n" "204 0 51 CC0033\n" "204 0 0 CC0000\n" "153 255 255 99FFFF\n" "153 255 204 99FFCC\n" "153 255 153 99FF99\n" "153 255 102 99FF66\n" "153 255 51 99FF33\n" "153 255 0 99FF00\n" "153 204 255 99CCFF\n" "153 204 204 99CCCC\n" "153 204 153 99CC99\n" "153 204 102 99CC66\n" "153 204 51 99CC33\n" "153 204 0 99CC00\n" "153 153 255 9999FF\n" "153 153 204 9999CC\n" "153 153 153 999999\n" "153 153 102 999966\n" "153 153 51 999933\n" "153 153 0 999900\n" "153 102 255 9966FF\n" "153 102 204 9966CC\n" "153 102 153 996699\n" "153 102 102 996666\n" "153 102 51 996633\n" "153 102 0 996600\n" "153 51 255 9933FF\n" "153 51 204 9933CC\n" "153 51 153 993399\n" "153 51 102 993366\n" "153 51 51 993333\n" "153 51 0 993300\n" "153 0 255 9900FF\n" "153 0 204 9900CC\n" "153 0 153 990099\n" "153 0 102 990066\n" "153 0 51 990033\n" "153 0 0 990000\n" "102 255 255 66FFFF\n" "102 255 204 66FFCC\n" "102 255 153 66FF99\n" "102 255 102 66FF66\n" "102 255 51 66FF33\n" "102 255 0 66FF00\n" "102 204 255 66CCFF\n" "102 204 204 66CCCC\n" "102 204 153 66CC99\n" "102 204 102 66CC66\n" "102 204 51 66CC33\n" "102 204 0 66CC00\n" "102 153 255 6699FF\n" "102 153 204 6699CC\n" "102 153 153 669999\n" "102 153 102 669966\n" "102 153 51 669933\n" "102 153 0 669900\n" "102 102 255 6666FF\n" "102 102 204 6666CC\n" "102 102 153 666699\n" "102 102 102 666666\n" "102 102 51 666633\n" "102 102 0 666600\n" "102 51 255 6633FF\n" "102 51 204 6633CC\n" "102 51 153 663399\n" "102 51 102 663366\n" "102 51 51 663333\n" "102 51 0 663300\n" "102 0 255 6600FF\n" "102 0 204 6600CC\n" "102 0 153 660099\n" "102 0 102 660066\n" "102 0 51 660033\n" "102 0 0 660000\n" " 51 255 255 33FFFF\n" " 51 255 204 33FFCC\n" " 51 255 153 33FF99\n" " 51 255 102 33FF66\n" " 51 255 51 33FF33\n" " 51 255 0 33FF00\n" " 51 204 255 33CCFF\n" " 51 204 204 33CCCC\n" " 51 204 153 33CC99\n" " 51 204 102 33CC66\n" " 51 204 51 33CC33\n" " 51 204 0 33CC00\n" " 51 153 255 3399FF\n" " 51 153 204 3399CC\n" " 51 153 153 339999\n" " 51 153 102 339966\n" " 51 153 51 339933\n" " 51 153 0 339900\n" " 51 102 255 3366FF\n" " 51 102 204 3366CC\n" " 51 102 153 336699\n" " 51 102 102 336666\n" " 51 102 51 336633\n" " 51 102 0 336600\n" " 51 51 255 3333FF\n" " 51 51 204 3333CC\n" " 51 51 153 333399\n" " 51 51 102 333366\n" " 51 51 51 333333\n" " 51 51 0 333300\n" " 51 0 255 3300FF\n" " 51 0 204 3300CC\n" " 51 0 153 330099\n" " 51 0 102 330066\n" " 51 0 51 330033\n" " 51 0 0 330000\n" " 0 255 255 00FFFF\n" " 0 255 204 00FFCC\n" " 0 255 153 00FF99\n" " 0 255 102 00FF66\n" " 0 255 51 00FF33\n" " 0 255 0 00FF00\n" " 0 204 255 00CCFF\n" " 0 204 204 00CCCC\n" " 0 204 153 00CC99\n" " 0 204 102 00CC66\n" " 0 204 51 00CC33\n" " 0 204 0 00CC00\n" " 0 153 255 0099FF\n" " 0 153 204 0099CC\n" " 0 153 153 009999\n" " 0 153 102 009966\n" " 0 153 51 009933\n" " 0 153 0 009900\n" " 0 102 255 0066FF\n" " 0 102 204 0066CC\n" " 0 102 153 006699\n" " 0 102 102 006666\n" " 0 102 51 006633\n" " 0 102 0 006600\n" " 0 51 255 0033FF\n" " 0 51 204 0033CC\n" " 0 51 153 003399\n" " 0 51 102 003366\n" " 0 51 51 003333\n" " 0 51 0 003300\n" " 0 0 255 0000FF\n" " 0 0 204 0000CC\n" " 0 0 153 000099\n" " 0 0 102 000066\n" " 0 0 51 000033\n" " 0 0 0 000000\n" "" }, goxel-0.11.0/src/assets/progs.inl000066400000000000000000000251001435762723100166460ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* This file is autogenerated by tools/create_assets.py */ {.path = "data/progs/cherry.goxcf", .size = 469, .data = "shape main {\n" " [seed 7]\n" " tree(0, 40, 10)[s 10 light -0.9]\n" "}\n" "\n" "shape tree($n, $e, $f)\n" "rule {\n" " cylinder[]\n" " if ($n < $e) {\n" " tree($n + 1)[rz 0+-10 z 0.5 s 0.95 z 0.5 rx 4]\n" " }\n" " if (($n >= $e) || ($n > $f && 0+-1 > 0.5)) {\n" " flower[]\n" " }\n" "}\n" "rule 0.1 {\n" " tree[rz 180]\n" "}\n" "rule 0.08 {\n" " tree[]\n" " tree($n + 1)[rz 0+-180 rx -45]\n" "}\n" "\n" "shape flower {\n" " [light 0.5 sat 0.7 sn 1 s 6 z -0.5 x -1 hue -10]\n" " sphere[x 0+-0.5 0+-0.5 light 0+-0.2]\n" "}" }, {.path = "data/progs/city.goxcf", .size = 1199, .data = "shape main {\n" " [seed 4]\n" " city[]\n" "}\n" "\n" "shape ground {\n" " [s 128 128 1\n" " light -0.6 sat 0.2 hue 50]\n" " cube[]\n" " loop 16 [] {\n" " cube[x 0+-0.4 0+-0.4 \n" " s 0.2+-0.1 0.2+-0.1 3+-1\n" " light -0.3+-0.2]\n" " }\n" "}\n" "\n" "shape city {\n" " ground[]\n" " loop 128 [wait 1] {\n" " building[x 0+-58 0+-58 s 2+-0.5\n" " sat 0.2+-0.1 hue 0+-180]\n" " }\n" "}\n" "\n" "shape building\n" "// Tall building\n" "rule 1 {\n" " [s 3]\n" " $n = int(10+-5)\n" " loop $n [z 1 wait 1] {\n" " $s = 2+-0.2\n" " floor[s $s $s 1 z 0.5]\n" " }\n" " [z $n - 0.5]\n" " loop 1+-2 [] {\n" " antenna[]\n" " }\n" "}\n" "// Low building\n" "rule 1 {\n" " [s 8+-4 8+-4 4+-2 z 0.5]\n" " cube[light -0.3]\n" " windows(8)[]\n" " loop 2+-1 [] {antenna[]}\n" "}\n" "// Tree\n" "rule 10 {\n" " [z 0.5 sn 1 z 0.5]\n" " [sat 1 0.5 light 1 0.2 hue 1 20]\n" " cube[z 0.5 sz 5]\n" " loop 2 [] {\n" " sphere[z 4 s 4+-1\n" " x 0+-0.1 0+-0.1\n" " hue 100+-40]\n" " }\n" "}\n" "\n" "shape windows($n) {\n" " loop $n [rz 90] {\n" " cube[x 0.5 0+-0.4 sn s 1/3 x -0.5\n" " light 1 1 light 0+-0.2]\n" " }\n" "}\n" "\n" "shape floor {\n" " cube[light -0.5+-0.1]\n" " windows(8)[]\n" "}\n" "\n" "shape antenna {\n" " [z 0.5 x 0+-0.4 0+-0.4\n" " sn 1 sz 2+-1 z 0.5\n" " light -0.5]\n" " cube[]\n" "}" }, {.path = "data/progs/intro.goxcf", .size = 2552, .data = "// The 'main' shape is always the entry point of the program.\n" "shape main {\n" " // Initial random seed of 2.\n" " // Remove this line to use different seed each time.\n" " [seed 2]\n" " // Improves marching cube rendering.\n" " [antialiased 1]\n" "\n" " // Render a single white voxel.\n" " cube []\n" "\n" " // Put an other cube next to it.\n" " // 'x' applies a translation of 1 along x.\n" " // Those transformation are only applied\n" " // to this cube.\n" " cube [x 1]\n" "\n" " // Now render a bigger grey sphere.\n" " // light -0.5 move the light value to half\n" " // the current value of 1 and the target\n" " sphere [s 10 x 1 light -0.5]\n" "\n" " // We can also render cylinders:\n" " cylinder [s 10 x -1 light -0.9]\n" "\n" " // This time we use a user defined shape.\n" " // And we increase the saturation to give it a color.\n" " my_shape [z 20 light -0.5 sat 0.5]\n" "}\n" "\n" "// A user defined shape\n" "shape my_shape {\n" " // s 8 8 1 scales with different values\n" " // for each axis.\n" " // rx A applies a rotation along z of\n" " // 45 deg.\n" "\n" " // Note that the color is red, because we set the\n" " // Saturation when we called my_shape.\n" " cube [s 8 8 1 z 1 rz 45]\n" "\n" " // Loop 16 time, each time increasing the x\n" " // translation and the hue.\n" " loop 16 [x 2 hue 10] {\n" " cube []\n" " }\n" " // The loop transformations only affect\n" " // the loop block, after it we return to\n" " // the previous context.\n" " sphere [s 6 z 1]\n" "\n" " // Let's try a recursive shape:\n" " tree [x -10 s 4]\n" "\n" " // And an other one with a bit or randomness:\n" " tree2 [x 10 s 4 rz 180 hue 180]\n" "\n" " // A shape with several rules:\n" " my_other_shape [y 10 rz 90 hue -60 s 3]\n" "}\n" "\n" "// Tree render a cylinder and then call itself.\n" "// Since we scale down the shape at each iteration\n" "// at some point it becomes too small, and is\n" "// then automatically stopped.\n" "shape tree {\n" " cylinder []\n" " tree [z 1 s 0.99 ry -6]\n" "}\n" "\n" "shape tree2 {\n" " cylinder []\n" " // 'A +- B' means that we use a random value in the range\n" " // A - B, A + B. this make the second spiral a bit\n" " // messy.\n" " tree2 [z 1 s 0.99 ry -6+-6]\n" "}\n" "\n" "// Here 'my_other_shape' defines several rules. The rule\n" "// used is picked randomly using the weight.\n" "shape my_other_shape\n" "\n" "// Most of the time, just keep growing in z.\n" "rule 15 {\n" " cube []\n" " my_other_shape [z 1]\n" "}\n" "\n" "// Sometime split into two\n" "rule 1 {\n" " my_other_shape [rx 45 s 0.9]\n" " my_other_shape [rx -45 s 0.9]\n" "}\n" "\n" "// Some other times render a shpere and stop\n" "rule 0.5 {\n" " // 'hue 1 70' means that we immediately set the hue\n" " // to 70 (yellow).\n" " sphere [s 3 hue 1 70]\n" "}\n" "" }, {.path = "data/progs/planet.goxcf", .size = 523, .data = "// Simple planet\n" "shape main {\n" " [s 50]\n" " sphere [sat 0.5 light -0.75 hue 200]\n" " loop 3 [] {\n" " continent[rz 0+-180 ry 0+-180\n" " hue 1 40+-10 sat 1 0.5\n" " light -0.5+-0.1]\n" " }\n" " loop 16 [wait 1] {\n" " cloud [rz 0+-180 ry 0+-180\n" " hue 200 light -0.1 sat 0.5]\n" " }\n" "}\n" "\n" "shape continent {\n" " loop 30 [rz 10 rx 0+-80 wait 1] {\n" " sphere[x 0.3 s 0.4+-0.05]\n" " }\n" "}\n" "\n" "shape cloud {\n" " loop 5 [rz 2 rx 0+-180 wait 1] {\n" " sphere[x 0.5 s 0.04 +- 0.01]\n" " }\n" "}\n" "" }, {.path = "data/progs/test.goxcf", .size = 323, .data = "// Simple Test\n" "\n" "shape branch\n" "rule {\n" " cylinder [sz 0.7]\n" " branch [rz 0 z 0.25 s 0.9 rx 30 z 0.25\n" " light -0.1 hue 10 sat 0.1]\n" "}\n" "rule 0.2 {\n" "branch [rz 180]\n" "}\n" "rule 0.2 {\n" " branch [rz 90]\n" "}\n" "rule 0.1 {\n" " branch [rx -90 s 0.8 z 1]\n" " branch []\n" "}\n" "\n" "shape main {\n" " [light 1 antialiased 1]\n" " branch [s 32]\n" "}\n" "" }, {.path = "data/progs/test2.goxcf", .size = 419, .data = "shape main {\n" " [antialiased 1]\n" " [light 0.5 sat 0.5 s 100]\n" " loop 5 [s -0.95 light 0.1 sat 0.01 hue 5] {\n" " sphere [light -0.6 hue 30]\n" " }\n" " loop 30 [wait 1] {\n" " sphere [sub rz 0+-180 ry 0+-180\n" " z 0.5 s 0.3]\n" " }\n" " loop 2 [rz 90] {\n" " loop 120 [ry 10 wait 1] {\n" " sphere [hue 30+-30 light -0.5+-0.4\n" " z 0.5 s 0.05+-0.01 z 4+-0.5]\n" " }\n" " }\n" "}\n" "" }, {.path = "data/progs/test3.goxcf", .size = 302, .data = "shape main {\n" " [antialiased 1]\n" " loop 8 [rz 45] {\n" " test [s 20 x 2]\n" " }\n" "}\n" "\n" "shape test {\n" " [sat 0.4 light -0.2 hue 240]\n" " sphere[]\n" " cube [z 0.5 sub]\n" " tige (15) [s 0.5 light -0.5]\n" "}\n" "\n" "shape tige ($n) {\n" " cylinder[]\n" " if $n {\n" " tige($n - 1)[z 0.5 ry $n z 0.5 sat -0.1]\n" " }\n" "}\n" "" }, {.path = "data/progs/tree-big.goxcf", .size = 541, .data = "\n" "shape leaf {\n" " cube[]\n" " leaf[x 0.5 s 0.9 0.9 0.8 ry 25 x 0.4]\n" "}\n" "\n" "shape top {\n" " loop 8 [rz 360 / 8] {\n" " [life 8 sy 2 z 0+-5]\n" " leaf[s 5 light -0.4 sat 0.5 hue 60+-20 ry -45]\n" " }\n" "}\n" "\n" "shape part($n) {\n" " loop $i = $n [z 1 rz 30+-10 rx 0+-10 wait 1] {\n" " cylinder[s 4 x 0.1 light 0+-0.1]\n" " if ($i == int($n - 2)) {\n" " top[]\n" " }\n" " }\n" "}\n" "\n" "shape main {\n" " [antialiased 1 hue 40 light -0.5 sat 0.5]\n" " $n = 40+-10\n" " loop 3 [rz 120+-45] {\n" " [y 0.5]\n" " part($n)[light -0.3+-0.05]\n" " }\n" "}\n" "" }, {.path = "data/progs/tree-small.goxcf", .size = 372, .data = "shape branch2 {\n" " cube[]\n" " branch2 [z 0.5 s 0.8 rx 20+-4 z 0.5]\n" "}\n" "\n" "shape branch {\n" " [rx 90]\n" " branch2[s 2]\n" "}\n" "\n" "shape tree($s) {\n" " loop $s [z 1] {\n" " cube[s 1 light -0.8+-0.1 sat 0.5]\n" " }\n" " [z $s]\n" " [sat 1 light -0.5 hue 50+-30]\n" " loop 6 [rz 360 / 6 rz 0+-10] {\n" " branch[light 0+-0.3]\n" " }\n" "}\n" "\n" "shape main {\n" " [antialiased 0]\n" " tree(8+-2)[]\n" "}\n" "" }, goxel-0.11.0/src/assets/shaders.inl000066400000000000000000000440551435762723100171570ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* This file is autogenerated by tools/create_assets.py */ {.path = "data/shaders/background.glsl", .size = 570, .data = "varying lowp vec4 v_color;\n" "\n" "#ifdef VERTEX_SHADER\n" "\n" "/************************************************************************/\n" "attribute highp vec3 a_pos;\n" "attribute lowp vec4 a_color;\n" "\n" "void main()\n" "{\n" " gl_Position = vec4(a_pos, 1.0);\n" " v_color = a_color;\n" "}\n" "/************************************************************************/\n" "\n" "#endif\n" "\n" "#ifdef FRAGMENT_SHADER\n" "\n" "/************************************************************************/\n" "void main()\n" "{\n" " gl_FragColor = v_color;\n" "}\n" "/************************************************************************/\n" "\n" "#endif\n" "" }, {.path = "data/shaders/mesh.glsl", .size = 8877, .data = "/* Goxel 3D voxels editor\n" " *\n" " * copyright (c) 2015 Guillaume Chereau \n" " *\n" " * Goxel is free software: you can redistribute it and/or modify it under the\n" " * terms of the GNU General Public License as published by the Free Software\n" " * Foundation, either version 3 of the License, or (at your option) any later\n" " * version.\n" "\n" " * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY\n" " * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n" " * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n" " * details.\n" "\n" " * You should have received a copy of the GNU General Public License along with\n" " * goxel. If not, see .\n" " */\n" "\n" "// Some of the algos come from glTF Sampler, under Apache Licence V2.\n" "\n" "uniform highp mat4 u_model;\n" "uniform highp mat4 u_view;\n" "uniform highp mat4 u_proj;\n" "uniform lowp float u_pos_scale;\n" "uniform highp vec3 u_camera;\n" "uniform highp float u_z_ofs; // Used for line rendering.\n" "\n" "// Light parameters\n" "uniform lowp vec3 u_l_dir;\n" "uniform lowp float u_l_int;\n" "uniform lowp float u_l_amb; // Ambient light coef.\n" "\n" "// Material parameters\n" "uniform lowp float u_m_metallic;\n" "uniform lowp float u_m_roughness;\n" "uniform lowp float u_m_smoothness;\n" "uniform lowp vec4 u_m_base_color;\n" "uniform lowp vec3 u_m_emissive_factor;\n" "\n" "uniform mediump sampler2D u_normal_sampler;\n" "uniform lowp float u_normal_scale;\n" "\n" "#ifdef HAS_OCCLUSION_MAP\n" "uniform mediump sampler2D u_occlusion_tex;\n" "uniform mediump float u_occlusion_strength;\n" "#endif\n" "\n" "#ifdef SHADOW\n" "uniform highp mat4 u_shadow_mvp;\n" "uniform mediump sampler2D u_shadow_tex;\n" "uniform mediump float u_shadow_strength;\n" "varying mediump vec4 v_shadow_coord;\n" "#endif\n" "\n" "\n" "varying highp vec3 v_Position;\n" "varying lowp vec4 v_color;\n" "varying mediump vec2 v_occlusion_uv;\n" "varying mediump vec2 v_UVCoord1;\n" "varying mediump vec3 v_gradient;\n" "\n" "#ifdef HAS_TANGENTS\n" "varying mediump mat3 v_TBN;\n" "#else\n" "varying mediump vec3 v_Normal;\n" "#endif\n" "\n" "\n" "const mediump float M_PI = 3.141592653589793;\n" "\n" "/*\n" " * Function: F_Schlick.\n" " * Compute Fresnel (specular).\n" " *\n" " * Optimized variant (presented by Epic at SIGGRAPH '13)\n" " * https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n" " */\n" "mediump vec3 F_Schlick(mediump vec3 f0, mediump float LdotH)\n" "{\n" " mediump float fresnel = exp2((-5.55473 * LdotH - 6.98316) * LdotH);\n" " return (1.0 - f0) * fresnel + f0;\n" "}\n" "\n" "/*\n" " * Function: V_SmithGGXCorrelatedFast\n" " * Compute Geometic occlusion.\n" " *\n" " * Fast approximation from\n" " * https://google.github.io/filament/Filament.html#materialsystem/standardmodel\n" " */\n" "mediump float V_GGX(mediump float NdotL, mediump float NdotV,\n" " mediump float alpha)\n" "{\n" " mediump float a = alpha;\n" " mediump float GGXV = NdotL * (NdotV * (1.0 - a) + a);\n" " mediump float GGXL = NdotV * (NdotL * (1.0 - a) + a);\n" " return 0.5 / (GGXV + GGXL);\n" "}\n" "\n" "/*\n" " * Function: D_GGX\n" " * Microfacet distribution\n" " */\n" "mediump float D_GGX(mediump float NdotH, mediump float alpha)\n" "{\n" " mediump float a2 = alpha * alpha;\n" " mediump float f = (NdotH * a2 - NdotH) * NdotH + 1.0;\n" " return a2 / (M_PI * f * f);\n" "}\n" "\n" "mediump vec3 compute_light(mediump vec3 L,\n" " mediump float light_intensity,\n" " mediump float light_ambient,\n" " mediump vec3 base_color,\n" " mediump float metallic,\n" " mediump float roughness,\n" " mediump vec3 N, mediump vec3 V)\n" "{\n" " mediump vec3 H = normalize(L + V);\n" "\n" " mediump float NdotL = clamp(dot(N, L), 0.0, 1.0);\n" " mediump float NdotV = clamp(dot(N, V), 0.0, 1.0);\n" " mediump float NdotH = clamp(dot(N, H), 0.0, 1.0);\n" " mediump float LdotH = clamp(dot(L, H), 0.0, 1.0);\n" " mediump float VdotH = clamp(dot(V, H), 0.0, 1.0);\n" "\n" " mediump float a_roughness = roughness * roughness;\n" " // Schlick GGX model, as used by glTF2.\n" " mediump vec3 f0 = vec3(0.04);\n" " mediump vec3 diffuse_color = base_color * (vec3(1.0) - f0) * (1.0 - metallic);\n" " mediump vec3 specular_color = mix(f0, base_color, metallic);\n" " mediump vec3 F = F_Schlick(specular_color, LdotH);\n" " mediump float Vis = V_GGX(NdotL, NdotV, a_roughness);\n" " mediump float D = D_GGX(NdotH, a_roughness);\n" " // Calculation of analytical lighting contribution\n" " mediump vec3 diffuseContrib = (1.0 - F) * (diffuse_color / M_PI);\n" " mediump vec3 specContrib = F * (Vis * D);\n" " mediump vec3 shade = NdotL * (diffuseContrib + specContrib);\n" " shade = max(shade, vec3(0.0));\n" " return light_intensity * shade + light_ambient * base_color;\n" "}\n" "\n" "mediump vec3 getNormal()\n" "{\n" " mediump vec3 ret;\n" "#ifdef HAS_TANGENTS\n" " mediump mat3 tbn = v_TBN;\n" " mediump vec3 n = texture2D(u_normal_sampler, v_UVCoord1).rgb;\n" " n = tbn * ((2.0 * n - 1.0) * vec3(u_normal_scale, u_normal_scale, 1.0));\n" " ret = normalize(n);\n" "#else\n" " ret = normalize(v_Normal);\n" "#endif\n" "\n" "#ifdef SMOOTHNESS\n" " ret = normalize(mix(ret, normalize(v_gradient), u_m_smoothness));\n" "#endif\n" " return ret;\n" "}\n" "\n" "\n" "#ifdef VERTEX_SHADER\n" "\n" "/************************************************************************/\n" "attribute highp vec3 a_pos;\n" "attribute mediump vec3 a_normal;\n" "attribute mediump vec3 a_tangent;\n" "attribute mediump vec3 a_gradient;\n" "attribute lowp vec4 a_color;\n" "attribute mediump vec2 a_occlusion_uv;\n" "attribute mediump vec2 a_bump_uv; // bump tex base coordinates [0,255]\n" "attribute mediump vec2 a_uv; // uv coordinates [0,1]\n" "\n" "// Must match the value in goxel.h\n" "#define VOXEL_TEXTURE_SIZE 8.0\n" "\n" "void main()\n" "{\n" " vec4 pos = u_model * vec4(a_pos * u_pos_scale, 1.0);\n" " v_Position = vec3(pos.xyz) / pos.w;\n" "\n" " v_color = a_color.rgba * a_color.rgba; // srgb to linear (fast).\n" " v_occlusion_uv = (a_occlusion_uv + 0.5) / (16.0 * VOXEL_TEXTURE_SIZE);\n" " gl_Position = u_proj * u_view * vec4(v_Position, 1.0);\n" " gl_Position.z += u_z_ofs;\n" "\n" "#ifdef SHADOW\n" " v_shadow_coord = u_shadow_mvp * vec4(v_Position, 1.0);\n" "#endif\n" "\n" "#ifdef HAS_TANGENTS\n" " mediump vec4 tangent = vec4(normalize(a_tangent), 1.0);\n" " mediump vec3 normalW = normalize(a_normal);\n" " mediump vec3 tangentW = normalize(vec3(u_model * vec4(tangent.xyz, 0.0)));\n" " mediump vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n" " v_TBN = mat3(tangentW, bitangentW, normalW);\n" "#else\n" " v_Normal = normalize(a_normal);\n" "#endif\n" "\n" " v_gradient = a_gradient;\n" " v_UVCoord1 = (a_bump_uv + 0.5 + a_uv * 15.0) / 256.0;\n" "\n" "#ifdef VERTEX_LIGHTNING\n" " mediump vec3 N = getNormal();\n" " v_color.rgb = compute_light(normalize(u_l_dir), u_l_int, u_l_amb,\n" " (v_color * u_m_base_color).rgb,\n" " u_m_metallic, u_m_roughness, N,\n" " normalize(u_camera - v_Position));\n" "#endif\n" "}\n" "\n" "#endif\n" "\n" "#ifdef FRAGMENT_SHADER\n" "\n" "#ifdef GL_ES\n" "precision mediump float;\n" "#endif\n" "\n" "\n" "/************************************************************************/\n" "vec3 toneMap(vec3 color)\n" "{\n" " // color *= u_exposure;\n" " return sqrt(color); // Gamma correction.\n" "}\n" "\n" "void main()\n" "{\n" "\n" "#ifdef ONLY_EDGES\n" " mediump vec3 n = 2.0 * texture2D(u_normal_sampler, v_UVCoord1).rgb - 1.0;\n" " if (n.z > 0.75)\n" " discard;\n" "#endif\n" "\n" " float metallic = u_m_metallic;\n" " float roughness = u_m_roughness;\n" " vec4 base_color = u_m_base_color * v_color;\n" "\n" "#ifdef MATERIAL_UNLIT\n" " gl_FragColor = vec4(sqrt(base_color.rgb), base_color.a);\n" " return;\n" "#endif\n" "\n" " vec3 N = getNormal();\n" " vec3 V = normalize(u_camera - v_Position);\n" " vec3 L = normalize(u_l_dir);\n" "\n" "#ifndef VERTEX_LIGHTNING\n" " vec3 color = compute_light(L, u_l_int, u_l_amb, base_color.rgb,\n" " metallic, roughness,\n" " N, V);\n" "#else\n" " vec3 color = v_color.rgb;\n" "#endif\n" "\n" " // Shadow map.\n" "#ifdef SHADOW\n" " float NdotL = clamp(dot(N, L), 0.0, 1.0);\n" " lowp vec2 PS[4]; // Poisson offsets used for the shadow map.\n" " float visibility = 1.0;\n" " mediump vec4 shadow_coord = v_shadow_coord / v_shadow_coord.w;\n" " lowp float bias = 0.005 * tan(acos(clamp(NdotL, 0.0, 1.0)));\n" " bias = clamp(bias, 0.0015, 0.015);\n" " shadow_coord.z -= bias;\n" " PS[0] = vec2(-0.94201624, -0.39906216) / 1024.0;\n" " PS[1] = vec2(+0.94558609, -0.76890725) / 1024.0;\n" " PS[2] = vec2(-0.09418410, -0.92938870) / 1024.0;\n" " PS[3] = vec2(+0.34495938, +0.29387760) / 1024.0;\n" " for (int i = 0; i < 4; i++)\n" " if (texture2D(u_shadow_tex, v_shadow_coord.xy +\n" " PS[i]).z < shadow_coord.z) visibility -= 0.2;\n" " if (NdotL <= 0.0) visibility = 0.5;\n" " float shade = mix(1.0, visibility, u_shadow_strength);\n" " color *= shade;\n" "#endif // SHADOW\n" "\n" "#ifdef HAS_OCCLUSION_MAP\n" " lowp float ao;\n" " ao = texture2D(u_occlusion_tex, v_occlusion_uv).r;\n" " color = mix(color, color * ao, u_occlusion_strength);\n" "#endif\n" "\n" " color += u_m_emissive_factor;\n" "\n" " gl_FragColor = vec4(toneMap(color), 1.0);\n" "}\n" "\n" "#endif\n" "" }, {.path = "data/shaders/model3d.glsl", .size = 2766, .data = "#if defined(GL_ES) && defined(FRAGMENT_SHADER)\n" "#extension GL_OES_standard_derivatives : enable\n" "#endif\n" "\n" "uniform highp mat4 u_model;\n" "uniform highp mat4 u_view;\n" "uniform highp mat4 u_proj;\n" "uniform highp mat4 u_clip;\n" "uniform lowp vec4 u_color;\n" "uniform mediump vec2 u_uv_scale;\n" "uniform lowp float u_grid_alpha;\n" "uniform mediump vec3 u_l_dir;\n" "uniform mediump float u_l_diff;\n" "uniform mediump float u_l_emit;\n" "\n" "uniform mediump sampler2D u_tex;\n" "uniform mediump float u_strip;\n" "uniform mediump float u_time;\n" "\n" "varying mediump vec3 v_normal;\n" "varying highp vec3 v_pos;\n" "varying lowp vec4 v_color;\n" "varying mediump vec2 v_uv;\n" "varying mediump vec4 v_clip_pos;\n" "\n" "#ifdef VERTEX_SHADER\n" "\n" "/************************************************************************/\n" "attribute highp vec3 a_pos;\n" "attribute lowp vec4 a_color;\n" "attribute mediump vec3 a_normal;\n" "attribute mediump vec2 a_uv;\n" "\n" "void main()\n" "{\n" " lowp vec4 col = u_color * a_color;\n" " highp vec3 pos = (u_view * u_model * vec4(a_pos, 1.0)).xyz;\n" " if (u_clip[3][3] > 0.0)\n" " v_clip_pos = u_clip * u_model * vec4(a_pos, 1.0);\n" " gl_Position = u_proj * vec4(pos, 1.0);\n" " mediump float diff = max(0.0, dot(u_l_dir, a_normal));\n" " col.rgb *= (u_l_emit + u_l_diff * diff);\n" " v_color = col;\n" " v_uv = a_uv * u_uv_scale;\n" " v_pos = (u_model * vec4(a_pos, 1.0)).xyz;\n" " v_normal = a_normal;\n" "}\n" "/************************************************************************/\n" "\n" "#endif\n" "\n" "#ifdef FRAGMENT_SHADER\n" "\n" "/************************************************************************/\n" "void main()\n" "{\n" " gl_FragColor = v_color * texture2D(u_tex, v_uv);\n" " if (u_strip > 0.0) {\n" " mediump float p = gl_FragCoord.x + gl_FragCoord.y + u_time * 4.0;\n" " if (mod(p, 8.0) < 4.0) gl_FragColor.rgb *= 0.5;\n" " }\n" " if (u_clip[3][3] > 0.0) {\n" " if ( v_clip_pos[0] < -v_clip_pos[3] ||\n" " v_clip_pos[1] < -v_clip_pos[3] ||\n" " v_clip_pos[2] < -v_clip_pos[3] ||\n" " v_clip_pos[0] > +v_clip_pos[3] ||\n" " v_clip_pos[1] > +v_clip_pos[3] ||\n" " v_clip_pos[2] > +v_clip_pos[3]) discard;\n" " }\n" "\n" " // Grid effect.\n" "#if !defined(GL_ES) || defined(GL_OES_standard_derivatives)\n" " if (u_grid_alpha > 0.0) {\n" " mediump vec2 c;\n" " if (abs((u_model * vec4(v_normal, 0.0)).x) > 0.5) c = v_pos.yz;\n" " if (abs((u_model * vec4(v_normal, 0.0)).y) > 0.5) c = v_pos.zx;\n" " if (abs((u_model * vec4(v_normal, 0.0)).z) > 0.5) c = v_pos.xy;\n" " mediump vec2 grid = abs(fract(c - 0.5) - 0.5) / fwidth(c);\n" " mediump float line = min(grid.x, grid.y);\n" " gl_FragColor.rgb *= mix(1.0 - u_grid_alpha, 1.0, min(line, 1.0));\n" " }\n" "#endif\n" "\n" "}\n" "/************************************************************************/\n" "\n" "#endif\n" "" }, {.path = "data/shaders/pos_data.glsl", .size = 790, .data = "varying lowp vec2 v_pos_data;\n" "uniform highp mat4 u_model;\n" "uniform highp mat4 u_view;\n" "uniform highp mat4 u_proj;\n" "uniform lowp vec2 u_block_id;\n" "\n" "#ifdef VERTEX_SHADER\n" "\n" "/************************************************************************/\n" "attribute highp vec3 a_pos;\n" "attribute lowp vec2 a_pos_data;\n" "\n" "void main()\n" "{\n" " highp vec3 pos = a_pos;\n" " gl_Position = u_proj * u_view * u_model * vec4(pos, 1.0);\n" " v_pos_data = a_pos_data;\n" "}\n" "/************************************************************************/\n" "\n" "#endif\n" "\n" "#ifdef FRAGMENT_SHADER\n" "\n" "/************************************************************************/\n" "void main()\n" "{\n" " gl_FragColor.rg = u_block_id;\n" " gl_FragColor.ba = v_pos_data;\n" "}\n" "/************************************************************************/\n" "\n" "#endif\n" "" }, {.path = "data/shaders/shadow_map.glsl", .size = 639, .data = "#ifdef VERTEX_SHADER\n" "\n" "/************************************************************************/\n" "attribute highp vec3 a_pos;\n" "uniform highp mat4 u_model;\n" "uniform highp mat4 u_view;\n" "uniform highp mat4 u_proj;\n" "uniform mediump float u_pos_scale;\n" "void main()\n" "{\n" " gl_Position = u_proj * u_view * u_model * vec4(a_pos * u_pos_scale, 1.0);\n" "}\n" "\n" "/************************************************************************/\n" "\n" "#endif\n" "\n" "#ifdef FRAGMENT_SHADER\n" "\n" "/************************************************************************/\n" "void main() {}\n" "/************************************************************************/\n" "\n" "#endif\n" "" }, goxel-0.11.0/src/assets/sounds.inl000066400000000000000000000254021435762723100170340ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* This file is autogenerated by tools/create_assets.py */ {.path = "data/sounds/build.wav", .size = 2662, .data = (const uint8_t[]){ 82,73,70,70,94,10,0,0,87,65,86,69,102,109,116,32,16,0,0,0,1,0,1,0,68,172, 0,0,136,88,1,0,2,0,16,0,100,97,116,97,58,10,0,0,1,0,11,0,28,0,42,0,49, 0,51,0,54,0,58,0,59,0,0,0,149,255,77,255,60,255,73,255,88,255,94,255,93, 255,89,255,87,255,87,255,88,255,90,255,92,255,94,255,96,255,98,255,101, 255,104,255,107,255,110,255,113,255,116,255,119,255,123,255,126,255,129, 255,133,255,136,255,205,255,46,1,141,2,20,3,245,2,162,2,97,2,65,2,52,2, 42,2,202,1,3,0,68,254,146,253,175,253,13,254,84,254,115,254,123,254,127, 254,135,254,148,254,163,254,178,254,191,254,203,254,215,254,226,254,237, 254,248,254,2,255,13,255,22,255,32,255,41,255,49,255,58,255,66,255,73, 255,81,255,88,255,95,255,102,255,108,255,130,255,59,1,124,4,109,6,167, 6,5,6,84,5,227,4,170,4,135,4,98,4,55,4,159,3,113,0,239,252,102,251,132, 251,55,252,204,252,21,253,46,253,59,253,79,253,107,253,139,253,169,253, 197,253,223,253,247,253,14,254,36,254,58,254,78,254,98,254,117,254,134, 254,152,254,168,254,184,254,199,254,213,254,227,254,240,254,252,254,8, 255,20,255,31,255,41,255,51,255,60,255,70,255,78,255,86,255,94,255,251, 255,75,4,20,9,12,11,172,10,119,9,112,8,213,7,129,7,64,7,249,6,169,6,86, 6,6,6,87,5,219,0,30,251,83,248,77,248,102,249,102,250,242,250,42,251,74, 251,111,251,162,251,217,251,16,252,66,252,112,252,156,252,197,252,236, 252,18,253,54,253,89,253,121,253,153,253,182,253,211,253,238,253,7,254, 32,254,55,254,77,254,98,254,118,254,137,254,156,254,173,254,189,254,205, 254,220,254,234,254,248,254,5,255,17,255,29,255,40,255,51,255,61,255,70, 255,79,255,88,255,96,255,104,255,112,255,123,255,16,2,179,9,97,15,188, 16,116,15,161,13,75,12,138,11,20,11,170,10,52,10,180,9,53,9,188,8,76,8, 227,7,128,7,33,7,185,4,111,252,106,245,33,243,9,244,200,245,21,247,192, 247,16,248,79,248,156,248,247,248,86,249,175,249,2,250,79,250,151,250, 220,250,29,251,92,251,152,251,208,251,6,252,57,252,105,252,151,252,195, 252,237,252,20,253,58,253,94,253,128,253,160,253,190,253,219,253,247,253, 17,254,42,254,66,254,89,254,110,254,130,254,149,254,168,254,185,254,202, 254,217,254,232,254,247,254,4,255,17,255,29,255,40,255,51,255,62,255,72, 255,81,255,90,255,98,255,106,255,114,255,121,255,128,255,135,255,141,255, 147,255,152,255,158,255,163,255,167,255,172,255,176,255,180,255,184,255, 188,255,130,0,173,8,79,19,79,24,245,23,104,21,254,18,115,17,142,16,231, 15,61,15,130,14,193,13,6,13,87,12,181,11,28,11,139,10,1,10,125,9,249,8, 131,8,19,8,169,7,68,7,228,6,48,4,148,248,47,238,153,234,214,235,127,238, 154,240,200,241,105,242,230,242,114,243,16,244,179,244,79,245,224,245, 102,246,228,246,91,247,205,247,58,248,160,248,2,249,95,249,182,249,10, 250,88,250,163,250,234,250,46,251,110,251,170,251,228,251,26,252,78,252, 127,252,174,252,218,252,3,253,43,253,81,253,116,253,150,253,182,253,213, 253,242,253,13,254,39,254,64,254,87,254,109,254,130,254,150,254,169,254, 187,254,204,254,220,254,235,254,249,254,7,255,20,255,32,255,44,255,55, 255,66,255,76,255,85,255,94,255,102,255,111,255,118,255,125,255,132,255, 139,255,145,255,151,255,156,255,161,255,166,255,171,255,176,255,180,255, 184,255,188,255,191,255,195,255,198,255,201,255,204,255,207,255,209,255, 212,255,214,255,216,255,218,255,220,255,222,255,224,255,226,255,227,255, 229,255,230,255,232,255,233,255,234,255,235,255,237,255,238,255,239,255, 240,255,240,255,241,255,242,255,243,255,244,255,244,255,245,255,246,255, 246,255,247,255,247,255,248,255,248,255,249,255,249,255,249,255,250,255, 250,255,250,255,251,255,251,255,251,255,252,255,252,255,252,255,252,255, 253,255,253,255,253,255,253,255,30,0,57,8,131,25,98,36,14,38,192,34,178, 30,198,27,9,26,225,24,212,23,178,22,130,21,86,20,58,19,50,18,59,17,82, 16,117,15,163,14,221,13,32,13,110,12,197,11,37,11,141,10,254,9,118,9,245, 8,123,8,8,8,155,7,51,7,209,6,116,6,28,6,201,5,122,5,48,5,233,4,166,4,103, 4,43,4,242,3,188,3,137,3,89,3,43,3,0,3,215,2,52,1,93,242,130,224,108,216, 28,217,88,221,92,225,249,227,130,229,160,230,188,231,239,232,45,234,98, 235,130,236,143,237,139,238,120,239,90,240,48,241,251,241,187,242,113, 243,29,244,192,244,90,245,236,245,118,246,249,246,116,247,233,247,88,248, 193,248,37,249,131,249,220,249,48,250,128,250,203,250,19,251,87,251,151, 251,211,251,13,252,67,252,118,252,167,252,213,252,0,253,42,253,81,253, 118,253,153,253,186,253,217,253,247,253,19,254,45,254,70,254,94,254,117, 254,138,254,158,254,177,254,195,254,212,254,228,254,244,254,2,255,16,255, 29,255,41,255,53,255,64,255,74,255,84,255,93,255,102,255,110,255,118,255, 126,255,133,255,139,255,146,255,152,255,157,255,163,255,168,255,173,255, 177,255,181,255,185,255,168,255,173,255,178,255,182,255,186,255,190,255, 194,255,197,255,201,255,204,255,207,255,210,255,212,255,215,255,217,255, 219,255,222,255,223,255,225,255,227,255,229,255,230,255,232,255,233,255, 235,255,236,255,237,255,238,255,239,255,240,255,241,255,242,255,243,255, 243,255,244,255,245,255,246,255,246,255,247,255,247,255,248,255,248,255, 249,255,249,255,250,255,250,255,250,255,251,255,251,255,251,255,252,255, 252,255,252,255,252,255,253,255,253,255,253,255,253,255,253,255,254,255, 254,255,254,255,254,255,254,255,254,255,254,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, } }, {.path = "data/sounds/click.wav", .size = 524, .data = (const uint8_t[]){ 82,73,70,70,4,2,0,0,87,65,86,69,102,109,116,32,16,0,0,0,1,0,2,0,68,172, 0,0,16,177,2,0,4,0,16,0,100,97,116,97,224,1,0,0,168,201,64,55,0,163,250, 85,78,141,216,83,156,149,46,39,1,200,226,224,202,28,39,168,12,104,166, 154,176,124,102,188,87,79,102,242,254,0,181,21,14,210,232,23,106,225,187, 247,223,17,183,187,202,66,73,143,175,95,200,156,154,78,240,214,86,25,177, 26,114,242,42,78,193,240,64,82,43,2,194,28,15,21,224,212,239,29,236,170, 37,17,161,175,69,240,202,217,203,206,83,14,92,201,29,43,22,239,212,31, 52,43,176,247,251,83,40,207,122,75,233,187,179,20,242,192,117,217,194, 218,60,198,213,252,102,222,163,12,117,10,89,2,58,52,164,241,12,74,53,235, 166,66,40,243,72,31,19,5,178,234,162,19,157,189,39,21,22,178,66,12,158, 204,254,0,145,247,169,249,111,18,123,249,63,11,36,2,172,236,142,17,55, 206,195,30,253,192,47,33,126,199,40,23,114,213,124,2,93,224,187,234,16, 235,52,223,195,246,47,234,56,253,5,8,152,250,239,41,58,241,209,59,4,235, 132,49,195,240,140,16,157,251,170,234,51,254,155,211,238,246,174,216,96, 238,120,247,48,239,82,30,229,251,67,55,135,8,247,51,210,9,119,22,26,2, 175,238,201,246,41,207,146,233,212,198,42,221,49,218,244,214,155,253,57, 223,129,28,54,246,207,36,24,15,219,18,147,26,119,246,215,16,204,227,190, 248,245,228,18,227,243,246,40,218,0,11,141,222,83,19,234,236,184,12,159, 254,98,253,120,13,40,242,30,20,239,245,69,12,128,7,111,246,51,25,223,223, 58,28,185,215,36,11,222,224,217,238,121,242,61,219,240,0,224,222,194,6, 64,247,172,5,79,21,118,254,21,38,89,241,117,31,129,228,129,9,156,225,237, 243,225,237,46,233,254,1,100,235,89,13,172,246,236,6,153,5,217,245,68, 19,88,233,95,26,150,234,52,23,37,247,89,11,129,4,196,252,45,8,90,241,182, 0,162,238,105,245,193,245,46,237,218,1,217,235,119,12,44,242,29,16,25, 254,12,11,201,9,234,1,214,12,122,250,28,4,158,248,175,246,153,252,65,240, 18,2,243,245,254,3, } }, goxel-0.11.0/src/assets/themes.inl000066400000000000000000000033641435762723100170110ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* This file is autogenerated by tools/create_assets.py */ {.path = "data/themes/dark.ini", .size = 260, .data = "[theme]\n" "name=dark\n" "\n" "[base]\n" "background=#2D2D2DFF\n" "outline=#FF\n" "inner=#595959FF\n" "inner_selected=#0F87FAFF\n" "text=#CCCCCCFF\n" "text_selected=#FFFFFFFF\n" "\n" "[widget]\n" "\n" "[tab]\n" "background=#FF\n" "inner=#444444FF\n" "\n" "[menu]\n" "inner=#353535FF\n" "\n" "[titlebar]\n" "text=#E7E7E7FF\n" "background=#4FA9FFFF\n" "" }, {.path = "data/themes/original.ini", .size = 253, .data = "[theme]\n" "name=original\n" "\n" "[base]\n" "background=#607272FF\n" "outline=#4D4D4DFF\n" "inner=#A1A1A1FF\n" "inner_selected=#6666CCFF\n" "text=#111111FF\n" "text_selected=#111111FF\n" "\n" "[widget]\n" "\n" "[tab]\n" "background=#304242FF\n" "inner=#607272FF\n" "inner_selected=#455656FF\n" "\n" "[menu]\n" "inner=#5A6E6EFF\n" "" }, goxel-0.11.0/src/block_def.h000066400000000000000000000071501435762723100155740ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* * Here is the convention I used for the cube vertices, edges and faces: * * v4 +----------e4---------+ v5 * /. /| * / . / | * e7 . e5 | +-----------+ * / . / | / /| * / . / | / f1 / | | |f4| * | e8 | | | | | * | . | | | f3 | + * | . | | | | / * | v0 . . . .e0 . . . | . . + v1 | |/ * e11 . | / +-----------+ * | . e10 / ^ * | e3 | e1 f0 * | . | / * |. |/ * v3 +---------e2----------+ v2 * */ #include "utils/vec.h" // face index -> [vertex0, vertex1, vertex2, vertex3] static const int FACES_VERTICES[6][4] = { {0, 1, 2, 3}, {5, 4, 7, 6}, {0, 4, 5, 1}, {2, 6, 7, 3}, {1, 5, 6, 2}, {0, 3, 7, 4} }; static const int FACES_OPPOSITES[6] = { 1, 0, 3, 2, 5, 4 }; // face index + edge -> neighbor face index. static const int FACES_NEIGHBORS[6][4] = { {4, 3, 5, 2}, {5, 3, 4, 2}, {1, 4, 0, 5}, {1, 5, 0, 4}, {1, 3, 0, 2}, {3, 1, 2, 0}, }; // vertex index -> vertex position static const int VERTICES_POSITIONS[8][3] = { {0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}, {0, 1, 0}, {1, 1, 0}, {1, 1, 1}, {0, 1, 1} }; static const int VERTICE_UV[4][2] = { {0, 0}, {1, 0}, {1, 1}, {0, 1}, }; static const int FACES_NORMALS[6][3] = { { 0, -1, 0}, { 0, +1, 0}, { 0, 0, -1}, { 0, 0, +1}, { 1, 0, 0}, {-1, 0, 0}, }; static const int FACES_TANGENTS[6][3] = { {+1, 0, 0}, {-1, 0, 0}, { 0, +1, 0}, { 0, +1, 0}, { 0, +1, 0}, { 0, 0, +1}, }; // Matrices of transformation: unity plane => cube face plane. static const float FACES_MATS[6][4][4] = { {{ 1, 0, 0, 0}, { 0, 0, 1, 0}, { 0, -1, 0, 0}, { 0, -1, 0, 1}}, {{-1, 0, 0, 0}, { 0, 0, 1, 0}, { 0, 1, 0, 0}, { 0, 1, 0, 1}}, {{ 0, 1, 0, 0}, { 1, 0, 0, 0}, { 0, 0, -1, 0}, { 0, 0, -1, 1}}, {{ 0, 1, 0, 0}, {-1, 0, 0, 0}, { 0, 0, 1, 0}, { 0, 0, 1, 1}}, {{ 0, 1, 0, 0}, { 0, 0, 1, 0}, { 1, 0, 0, 0}, { 1, 0, 0, 1}}, {{ 0, 0, 1, 0}, { 0, 1, 0, 0}, {-1, 0, 0, 0}, {-1, 0, 0, 1}}, }; static const int EDGES_VERTICES[12][2] = { {0, 1}, {1, 2}, {2, 3}, {3, 0}, {4, 5}, {5, 6}, {6, 7}, {7, 4}, {0, 4}, {1, 5}, {2, 6}, {3, 7}, }; goxel-0.11.0/src/box_edit.c000066400000000000000000000125321435762723100154540ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" typedef struct data { int snap; int mode; // 0: move, 1: resize. float box[4][4]; float start_box[4][4]; float transf[4][4]; int snap_face; struct { gesture3d_t hover; gesture3d_t drag; } gestures; int state; // 0: init, 1: snaped, 2: first change, 3: following changes. } data_t; static data_t g_data = {}; // Get the face index from the normal. static int get_face(const float n[3]) { int f; const int *n2; for (f = 0; f < 6; f++) { n2 = FACES_NORMALS[f]; if (vec3_dot(n, VEC(n2[0], n2[1], n2[2])) > 0.5) return f; } return -1; } static void get_transf(const float src[4][4], const float dst[4][4], float out[4][4]) { mat4_invert(src, out); mat4_mul(dst, out, out); } static int on_hover(gesture3d_t *gest, void *user) { data_t *data = (void*)user; cursor_t *curs = gest->cursor; float face_plane[4][4]; goxel_set_help_text("Drag to move face"); if (curs->snaped != data->snap) { data->state = 0; return GESTURE_FAILED; } data->state = 1; // Snaped. data->snap_face = get_face(curs->normal); curs->snap_offset = 0; curs->snap_mask &= ~SNAP_ROUNDED; // Render a white box on the side. // XXX: replace that with something better like an arrow. mat4_mul(data->box, FACES_MATS[data->snap_face], face_plane); mat4_itranslate(face_plane, 0, 0, 0.001); render_img(&goxel.rend, NULL, face_plane, EFFECT_NO_SHADING); return 0; } static int on_drag(gesture3d_t *gest, void *user) { data_t *data = (void*)user; cursor_t *curs = gest->cursor; float face_plane[4][4], v[3], pos[3], n[3], d[3], ofs[3], box[4][4]; goxel_set_help_text("Drag to move face"); if (gest->state == GESTURE_BEGIN) { if (curs->snaped != data->snap) { data->state = 0; return GESTURE_FAILED; } mat4_copy(data->box, data->start_box); data->state = 2; data->snap_face = get_face(curs->normal); mat4_mul(data->box, FACES_MATS[data->snap_face], face_plane); vec3_normalize(face_plane[0], v); plane_from_vectors(goxel.tool_plane, curs->pos, curs->normal, v); curs->snap_offset = 0; curs->snap_mask &= ~SNAP_ROUNDED; return 0; } data->state = 3; curs->snap_offset = 0; curs->snap_mask &= ~SNAP_ROUNDED; mat4_mul(data->start_box, FACES_MATS[data->snap_face], face_plane); vec3_normalize(face_plane[2], n); vec3_sub(curs->pos, goxel.tool_plane[3], v); vec3_project(v, n, v); vec3_add(goxel.tool_plane[3], v, pos); pos[0] = round(pos[0]); pos[1] = round(pos[1]); pos[2] = round(pos[2]); if (data->mode == 1) { // Resize box_move_face(data->start_box, data->snap_face, pos, box); if (box_get_volume(box) == 0) return 0; get_transf(data->box, box, data->transf); } else { // Move vec3_add(data->box[3], face_plane[2], d); vec3_sub(pos, d, ofs); vec3_project(ofs, n, ofs); mat4_set_identity(data->transf); mat4_itranslate(data->transf, ofs[0], ofs[1], ofs[2]); } if (gest->state == GESTURE_END) { mat4_copy(plane_null, goxel.tool_plane); data->state = 0; } return 0; } int box_edit(int snap, int mode, float transf[4][4], bool *first) { cursor_t *curs = &goxel.cursor; float box[4][4] = {}; int ret; if (snap == SNAP_LAYER_OUT) { curs->snap_mask = SNAP_LAYER_OUT; mesh_get_box(goxel.image->active_layer->mesh, true, box); // Fix problem with shape layer box. if (goxel.image->active_layer->shape) mat4_copy(goxel.image->active_layer->mat, box); } if (snap == SNAP_SELECTION_OUT) { curs->snap_mask |= SNAP_SELECTION_OUT; mat4_copy(goxel.selection, box); } if (box_is_null(box)) return 0; if (!g_data.gestures.drag.type) { g_data.gestures.hover = (gesture3d_t) { .type = GESTURE_HOVER, .callback = on_hover, }; g_data.gestures.drag = (gesture3d_t) { .type = GESTURE_DRAG, .callback = on_drag, }; } g_data.snap = snap; g_data.mode = mode; mat4_copy(box, g_data.box); mat4_set_identity(g_data.transf); gesture3d(&g_data.gestures.hover, curs, &g_data); gesture3d(&g_data.gestures.drag, curs, &g_data); ret = g_data.state; render_box(&goxel.rend, box, NULL, EFFECT_STRIP | EFFECT_WIREFRAME); if (transf) mat4_copy(g_data.transf, transf); if (first) *first = g_data.state == 2; if (g_data.state == 2) g_data.state = 3; return ret; } goxel-0.11.0/src/camera.c000066400000000000000000000123731435762723100151120ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2016 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "xxhash.h" camera_t *camera_new(const char *name) { camera_t *cam = calloc(1, sizeof(*cam)); if (name) strncpy(cam->name, name, sizeof(cam->name) - 1); mat4_set_identity(cam->mat); cam->dist = 128; cam->aspect = 1; mat4_itranslate(cam->mat, 0, 0, cam->dist); camera_turntable(cam, M_PI / 4, M_PI / 4); return cam; } void camera_delete(camera_t *cam) { free(cam); } camera_t *camera_copy(const camera_t *other) { camera_t *cam = malloc(sizeof(*cam)); *cam = *other; cam->next = cam->prev = NULL; return cam; } void camera_set(camera_t *cam, const camera_t *other) { cam->ortho = other->ortho; cam->dist = other->dist; mat4_copy(other->mat, cam->mat); } static void compute_clip(const float view_mat[4][4], float *near_, float *far_) { int bpos[3]; float p[3]; float n = FLT_MAX, f = 256; int i; const int margin = 8 * BLOCK_SIZE; float vertices[8][3]; const mesh_t *mesh = goxel_get_layers_mesh(goxel.image); mesh_iterator_t iter; if (!box_is_null(goxel.image->box)) { box_get_vertices(goxel.image->box, vertices); for (i = 0; i < 8; i++) { mat4_mul_vec3(view_mat, vertices[i], p); if (p[2] < 0) { n = min(n, -p[2] - margin); f = max(f, -p[2] + margin); } } } iter = mesh_get_iterator(mesh, MESH_ITER_BLOCKS); while (mesh_iter(&iter, bpos)) { vec3_set(p, bpos[0], bpos[1], bpos[2]); mat4_mul_vec3(view_mat, p, p); if (p[2] < 0) { n = min(n, -p[2] - margin); f = max(f, -p[2] + margin); } } if (n >= f) n = 1; n = max(n, 1); *near_ = n; *far_ = f; } void camera_update(camera_t *camera) { float size; float clip_near, clip_far; camera->fovy = 20.; mat4_invert(camera->mat, camera->view_mat); compute_clip(camera->view_mat, &clip_near, &clip_far); if (camera->ortho) { size = camera->dist; mat4_ortho(camera->proj_mat, -size, +size, -size / camera->aspect, +size / camera->aspect, clip_near, clip_far); } else { mat4_perspective(camera->proj_mat, camera->fovy, camera->aspect, clip_near, clip_far); } } // Get the raytracing ray of the camera at a given screen position. void camera_get_ray(const camera_t *camera, const float win[2], const float viewport[4], float o[3], float d[3]) { float o1[3], o2[3], p[3]; vec3_set(p, win[0], win[1], 0); unproject(p, camera->view_mat, camera->proj_mat, viewport, o1); vec3_set(p, win[0], win[1], 1); unproject(p, camera->view_mat, camera->proj_mat, viewport, o2); vec3_copy(o1, o); vec3_sub(o2, o1, d); vec3_normalize(d, d); } // Adjust the camera settings so that the rotation works for a given // position. void camera_set_target(camera_t *cam, const float pos[3]) { float world_to_mat[4][4], p[3]; mat4_invert(cam->mat, world_to_mat); mat4_mul_vec3(world_to_mat, pos, p); cam->dist = -p[2]; } /* * Function: camera_fit_box * Move a camera so that a given box is entirely visible. */ void camera_fit_box(camera_t *cam, const float box[4][4]) { float size[3], dist; if (box_is_null(box)) { cam->dist = 128; cam->aspect = 1; return; } box_get_size(box, size); // XXX: not the proper way to compute the distance. dist = max3(size[0], size[1], size[2]) * 8; mat4_mul_vec3(box, VEC(0, 0, 0), cam->mat[3]); mat4_itranslate(cam->mat, 0, 0, dist); cam->dist = dist; } /* * Function: camera_get_key * Return a value that is guarantied to change when the camera change. */ uint32_t camera_get_key(const camera_t *cam) { uint32_t key = 0; key = XXH32(&cam->name, sizeof(cam->name), key); key = XXH32(&cam->ortho, sizeof(cam->ortho), key); key = XXH32(&cam->dist, sizeof(cam->dist), key); key = XXH32(&cam->mat, sizeof(cam->mat), key); return key; } void camera_turntable(camera_t *camera, float rz, float rx) { float center[3], mat[4][4] = MAT4_IDENTITY; mat4_mul_vec3(camera->mat, VEC(0, 0, -camera->dist), center); mat4_itranslate(mat, center[0], center[1], center[2]); mat4_irotate(mat, rz, 0, 0, 1); mat4_itranslate(mat, -center[0], -center[1], -center[2]); mat4_imul(mat, camera->mat); mat4_copy(mat, camera->mat); mat4_itranslate(camera->mat, 0, 0, -camera->dist); mat4_irotate(camera->mat, rx, 1, 0, 0); mat4_itranslate(camera->mat, 0, 0, camera->dist); } goxel-0.11.0/src/camera.h000066400000000000000000000066441435762723100151230ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* * Section: Camera * Camera manipulation functions. */ #ifndef CAMERA_H #define CAMERA_H #include #include /* Type: camera_t * Camera structure. * * Attributes: * next, prev - Used for linked list of cameras in an image. * name - Name to show in the GUI. * ortho - Set to true for orthographic projection. * dist - Distance used to compute the position. * mat - Position of the camera (the camera points toward -z). * fovy - Field of view in y direction. * aspect - Aspect ratio. * view_mat - Modelview transformation matrix (auto computed). * proj_mat - Projection matrix (auto computed). */ typedef struct camera camera_t; struct camera { camera_t *next, *prev; // List of camera in an image. char name[128]; // 127 chars max. bool ortho; // Set to true for orthographic projection. float dist; // Rotation distance. float fovy; float aspect; float mat[4][4]; // Auto computed from other values: float view_mat[4][4]; // Model to view transformation. float proj_mat[4][4]; // Proj transform from camera coordinates. }; /* * Function: camera_new * Create a new camera. * * Parameters: * name - The name of the camera. * * Return: * A newly instanciated camera. */ camera_t *camera_new(const char *name); /* * Function: camera_delete * Delete a camera */ void camera_delete(camera_t *camera); camera_t *camera_copy(const camera_t *other); /* * Function: camera_set * Set a camera position from an other camera. */ void camera_set(camera_t *camera, const camera_t *other); /* * Function: camera_update * Update camera matrices. */ void camera_update(camera_t *camera); /* * Function: camera_set_target * Adjust the camera settings so that the rotation works for a given * position. */ void camera_set_target(camera_t *camera, const float pos[3]); /* * Function: camera_get_ray * Get the raytracing ray of the camera at a given screen position. * * Parameters: * win - Pixel position in screen coordinates. * view - Viewport rect: [min_x, min_y, max_x, max_y]. * o - Output ray origin. * d - Output ray direction. */ void camera_get_ray(const camera_t *camera, const float win[2], const float viewport[4], float o[3], float d[3]); /* * Function: camera_fit_box * Move a camera so that a given box is entirely visible. */ void camera_fit_box(camera_t *camera, const float box[4][4]); /* * Function: camera_get_key * Return a value that is guarantied to change when the camera change. */ uint32_t camera_get_key(const camera_t *camera); void camera_turntable(camera_t *camera, float rz, float rx); #endif // CAMERA_H goxel-0.11.0/src/config.h000066400000000000000000000025441435762723100151330ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* * This file gets included before any compiled file. So we can use it * to set configuration macros that affect external libraries. */ #ifdef __cplusplus extern "C" { #endif #ifndef _GNU_SOURCE # define _GNU_SOURCE #endif #pragma GCC diagnostic ignored "-Wpragmas" // Define the LOG macros, so that they get available in the utils files. #include "log.h" // Disable yocto with older version of gcc, since it doesn't compile then. #ifndef YOCTO # if !defined(__clang__) && __GNUC__ < 6 # define YOCTO 0 # endif #endif // Disable OpenGL deprecation warnings on Mac. #define GL_SILENCE_DEPRECATION 1 #ifdef __cplusplus } #endif goxel-0.11.0/src/dialogs_osx.m000066400000000000000000000016401435762723100162020ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ // XXX: if noc_file_dialog didn't use obj c on ios, I could directly include // this file in system.c #define NOC_FILE_DIALOG_OSX #define NOC_FILE_DIALOG_IMPLEMENTATION #include "noc_file_dialog.h" goxel-0.11.0/src/file_format.c000066400000000000000000000045101435762723100161430ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2020 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "file_format.h" #include "utlist.h" #include #include #include // The global hash table of file formats. file_format_t *file_formats = NULL; static bool endswith(const char *str, const char *end) { const char *start; if (strlen(str) < strlen(end)) return false; start = str + strlen(str) - strlen(end); return strcmp(start, end) == 0; } void file_format_register(file_format_t *format) { DL_APPEND(file_formats, format); } const file_format_t *file_format_for_path(const char *path, const char *name, const char *mode) { const file_format_t *f; bool need_read = strchr(mode, 'r'); bool need_write = strchr(mode, 'w'); const char *ext; assert(mode); assert(path || name); DL_FOREACH(file_formats, f) { if (need_read && !f->import_func) continue; if (need_write && !f->export_func) continue; if (name && strcasecmp(f->name, name) != 0) continue; if (path) { ext = f->ext + strlen(f->ext) + 2; // Pick the string after '*'. if (!endswith(path, ext)) continue; } return f; } return NULL; } void file_format_iter(const char *mode, void *user, void (*fun)(void *user, const file_format_t *f)) { assert(mode); assert(fun); const file_format_t *f; bool need_read = strchr(mode, 'r'); bool need_write = strchr(mode, 'w'); DL_FOREACH(file_formats, f) { if (need_read && !f->import_func) continue; if (need_write && !f->export_func) continue; fun(user, f); } } goxel-0.11.0/src/file_format.h000066400000000000000000000034541435762723100161560ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2020 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef FILE_FORMAT_H #define FILE_FORMAT_H #include "image.h" typedef struct file_format file_format_t; struct file_format { file_format_t *next, *prev; // For the global list of formats. const char *name; const char *ext; void (*export_gui)(void); int (*export_func)(const image_t *img, const char *path); int (*import_func)(image_t *img, const char *path); }; void file_format_register(file_format_t *format); const file_format_t *file_format_for_path(const char *path, const char *name, const char *mode); void file_format_iter(const char *mode, void *user, void (*f)(void *user, const file_format_t *f)); // The global list of registered file formats. extern file_format_t *file_formats; #define FILE_FORMAT_REGISTER(id_, ...) \ static file_format_t GOX_format_##id_ = {__VA_ARGS__}; \ __attribute__((constructor)) \ static void GOX_register_format_##id_(void) { \ file_format_register(&GOX_format_##id_); \ } #endif // FILE_FORMAT_H goxel-0.11.0/src/formats/000077500000000000000000000000001435762723100151635ustar00rootroot00000000000000goxel-0.11.0/src/formats/gltf.c000066400000000000000000000411461435762723100162710ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "file_format.h" #include "utils/json.h" #include "utils/vec.h" #define CGLTF_IMPLEMENTATION #define CGLTF_WRITE_IMPLEMENTATION #include "../ext_src/cgltf/cgltf_write.h" typedef struct { cgltf_data *data; palette_t palette; cgltf_material *default_mat; } gltf_t; typedef struct { float pos[3]; float normal[3]; // XXX: for vertex color we are wasting space here. union { uint8_t color[4]; float texcoord[2]; }; } gltf_vertex_t; typedef struct { bool vertex_color; } export_options_t; static export_options_t g_export_options = {}; // Return the next power of 2 larger or equal to x. static int next_pow2(int x) { x--; x |= x >> 1; x |= x >> 2; x |= x >> 4; x |= x >> 8; x |= x >> 16; x++; return x; } static size_t base64_encode(const uint8_t *data, size_t len, char *buf) { const char table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'}; const int mod_table[] = {0, 2, 1}; uint32_t a, b, c, triple; int i, j; size_t out_len = 4 * ((len + 2) / 3); if (!buf) return out_len; for (i = 0, j = 0; i < len;) { a = i < len ? data[i++] : 0; b = i < len ? data[i++] : 0; c = i < len ? data[i++] : 0; triple = (a << 0x10) + (b << 0x08) + c; buf[j++] = table[(triple >> 3 * 6) & 0x3F]; buf[j++] = table[(triple >> 2 * 6) & 0x3F]; buf[j++] = table[(triple >> 1 * 6) & 0x3F]; buf[j++] = table[(triple >> 0 * 6) & 0x3F]; } for (i = 0; i < mod_table[len % 3]; i++) buf[out_len - 1 - i] = '='; return out_len; } static char *data_new(const void *data, uint32_t len, const char *mime) { char *string; if (!mime) mime = "application/octet-stream"; string = calloc(strlen("data:") + strlen(mime) + strlen(";base64,") + base64_encode(data, len, NULL) + 1, 1); sprintf(string, "data:%s;base64,", mime); base64_encode(data, len, string + strlen(string)); return string; } #define DL_SIZE(head) ({ \ int size = 0; \ typeof(*(head)) *tmp; \ DL_COUNT(head, tmp, size); \ size; \ }) #define ALLOC(array, size) ({ array = calloc(size, sizeof(*(array))); }) static void gltf_init(gltf_t *g, const export_options_t *options, const image_t *img) { const layer_t *layer; mesh_iterator_t iter; int bpos[3], nb_blocks = 0; g->data = calloc(1, sizeof(*g->data)); g->data->memory.free = &cgltf_default_free; g->data->asset.version = strdup("2.0"); g->data->asset.generator = strdup("goxel"); // Count the total number of blocks. DL_FOREACH(img->layers, layer) { iter = mesh_get_iterator(layer->mesh, MESH_ITER_BLOCKS | MESH_ITER_INCLUDES_NEIGHBORS); while (mesh_iter(&iter, bpos)) { nb_blocks++; } } // Initialize all the gltf base object arrays. ALLOC(g->data->materials, DL_SIZE(img->materials) + 1); ALLOC(g->data->scenes, 1); ALLOC(g->data->nodes, 1 + nb_blocks + DL_SIZE(img->layers)); ALLOC(g->data->meshes, nb_blocks); ALLOC(g->data->accessors, nb_blocks * 4); ALLOC(g->data->buffers, nb_blocks * 2 + 1); ALLOC(g->data->buffer_views, nb_blocks * 2 + 1); ALLOC(g->data->images, 1); ALLOC(g->data->textures, 1); } #define add_item(data, list) ({ &data->list[data->list##_count++]; }) // Create a buffer view and attribute. static void make_attribute(gltf_t *g, cgltf_buffer_view *buffer_view, cgltf_primitive *primitive, const char *name, cgltf_component_type component_type, cgltf_type type, bool normalized, int count, int ofs, const float v_min[3], const float v_max[3]) { cgltf_accessor *accessor; cgltf_attribute *attribute; accessor = add_item(g->data, accessors); accessor->buffer_view = buffer_view; accessor->component_type = component_type; accessor->offset = ofs; accessor->type = type; accessor->count = count; accessor->normalized = normalized; if (v_min) { vec3_copy(v_min, accessor->min); accessor->has_min = true; } if (v_max) { vec3_copy(v_max, accessor->max); accessor->has_max = true; } attribute = add_item(primitive, attributes); attribute->data = accessor; attribute->name = strdup(name); cgltf_parse_attribute_type(name, &attribute->type, &attribute->index); } static void make_quad_indices(gltf_t *g, cgltf_primitive *primitive, int nb, int size) { cgltf_buffer *buffer; cgltf_buffer_view *buffer_view; cgltf_accessor *accessor; uint16_t *data; int i; data = calloc(nb * 6, sizeof(*data)); for (i = 0; i < nb * 6; i++) data[i] = (i / 6) * 4 + ((int[]){0, 1, 2, 2, 3, 0})[i % 6]; buffer = add_item(g->data, buffers); buffer->size = nb * 6 * sizeof(*data); buffer->uri = data_new(data, nb * 6 * sizeof(*data), NULL); free(data); buffer_view = add_item(g->data, buffer_views); buffer_view->buffer = buffer; buffer_view->size = nb * 6 * sizeof(*data); buffer_view->type = cgltf_buffer_view_type_indices; accessor = add_item(g->data, accessors); accessor->buffer_view = buffer_view; accessor->component_type = cgltf_component_type_r_16u; accessor->count = nb * 6; accessor->type = cgltf_type_scalar; primitive->indices = accessor; } static void fill_buffer(const gltf_t *g, gltf_vertex_t *bverts, const voxel_vertex_t *verts, int nb, int subdivide, bool vertex_color) { int i, c, s = 0; float uv[2]; // The palette texture size. if (!vertex_color) s = max(next_pow2(ceil(log2(g->palette.size))), 16); for (i = 0; i < nb; i++) { bverts[i].pos[0] = (float)verts[i].pos[0] / subdivide; bverts[i].pos[1] = (float)verts[i].pos[1] / subdivide; bverts[i].pos[2] = (float)verts[i].pos[2] / subdivide; bverts[i].normal[0] = verts[i].normal[0]; bverts[i].normal[1] = verts[i].normal[1]; bverts[i].normal[2] = verts[i].normal[2]; vec3_normalize(bverts[i].normal, bverts[i].normal); if (vertex_color) { bverts[i].color[0] = verts[i].color[0]; bverts[i].color[1] = verts[i].color[1]; bverts[i].color[2] = verts[i].color[2]; bverts[i].color[3] = verts[i].color[3]; } else { c = palette_search(&g->palette, verts[i].color, true); assert(c != -1); uv[0] = (c % s + 0.5) / s; uv[1] = (c / s + 0.5) / s; bverts[i].texcoord[0] = uv[0]; bverts[i].texcoord[1] = uv[1]; } } } static void get_pos_min_max(gltf_vertex_t *bverts, int nb, float pos_min[3], float pos_max[3]) { int i; pos_min[0] = +FLT_MAX; pos_min[1] = +FLT_MAX; pos_min[2] = +FLT_MAX; pos_max[0] = -FLT_MAX; pos_max[1] = -FLT_MAX; pos_max[2] = -FLT_MAX; for (i = 0; i < nb; i++) { pos_min[0] = min(bverts[i].pos[0], pos_min[0]); pos_min[1] = min(bverts[i].pos[1], pos_min[1]); pos_min[2] = min(bverts[i].pos[2], pos_min[2]); pos_max[0] = max(bverts[i].pos[0], pos_max[0]); pos_max[1] = max(bverts[i].pos[1], pos_max[1]); pos_max[2] = max(bverts[i].pos[2], pos_max[2]); } } static int get_material_idx(const image_t *img, const material_t *mat) { int i; const material_t *m; for (i = 0, m = img->materials; m; m = m->next, i++) { if (m == mat) return i; } return 0; } static cgltf_material *save_material( gltf_t *g, const material_t *mat, const export_options_t *options) { cgltf_material *material; cgltf_pbr_metallic_roughness *pbr; material = add_item(g->data, materials); material->alpha_cutoff = 0.5; material->has_pbr_metallic_roughness = true; pbr = &material->pbr_metallic_roughness; material->name = strdup(mat->name); vec3_copy(mat->emission, material->emissive_factor); vec4_copy(mat->base_color, pbr->base_color_factor); pbr->metallic_factor = mat->metallic; pbr->roughness_factor = mat->roughness; if (!options->vertex_color) { pbr->base_color_texture.texture = &g->data->textures[0]; pbr->base_color_texture.scale = 1; } return material; } static cgltf_material *get_default_mat( gltf_t *g, const export_options_t *options) { material_t mat; if (!g->default_mat) { mat = (material_t) { .base_color = {1, 1, 1, 1}, .metallic = 1, .roughness = 1, }; g->default_mat = save_material(g, &mat, options); } return g->default_mat; } static void save_layer(gltf_t *g, cgltf_node *root_node, const image_t *img, const layer_t *layer, const export_options_t *options) { cgltf_mesh *gmesh; cgltf_primitive *primitive; cgltf_buffer *buffer; cgltf_node *node, *layer_node; cgltf_buffer_view *buffer_view; mesh_iterator_t iter; int nb_elems, bpos[3], size = 0, subdivide; voxel_vertex_t *verts; const int N = BLOCK_SIZE; gltf_vertex_t *gverts; int buf_size, start_nodes_count, i; float pos_min[3], pos_max[3]; mesh_t *mesh = layer->mesh; start_nodes_count = g->data->nodes_count; verts = calloc(N * N * N * 6 * 4, sizeof(*verts)); gverts = calloc(N * N * N * 6 * 4, sizeof(*gverts)); iter = mesh_get_iterator(mesh, MESH_ITER_BLOCKS | MESH_ITER_INCLUDES_NEIGHBORS); while (mesh_iter(&iter, bpos)) { nb_elems = mesh_generate_vertices(mesh, bpos, goxel.rend.settings.effects, verts, &size, &subdivide); if (!nb_elems) continue; fill_buffer(g, gverts, verts, nb_elems * size, subdivide, options->vertex_color); get_pos_min_max(gverts, nb_elems * size, pos_min, pos_max); buf_size = nb_elems * size * sizeof(*gverts); buffer = add_item(g->data, buffers); buffer->size = buf_size; buffer->uri = data_new(gverts, buf_size, NULL); gmesh = add_item(g->data, meshes); ALLOC(gmesh->primitives, 1); primitive = add_item(gmesh, primitives); primitive->type = cgltf_primitive_type_triangles; ALLOC(primitive->attributes, 3); if (layer->material) { primitive->material = g->data->materials + get_material_idx(img, layer->material); } else { primitive->material = get_default_mat(g, options); } if (size == 4) make_quad_indices(g, primitive, nb_elems, size); buffer_view = add_item(g->data, buffer_views); buffer_view->buffer = buffer; buffer_view->size = buf_size; buffer_view->stride = sizeof(gltf_vertex_t); buffer_view->type = cgltf_buffer_view_type_vertices; make_attribute(g, buffer_view, primitive, "POSITION", cgltf_component_type_r_32f, cgltf_type_vec3, false, nb_elems * size, offsetof(gltf_vertex_t, pos), pos_min, pos_max); make_attribute(g, buffer_view, primitive, "NORMAL", cgltf_component_type_r_32f, cgltf_type_vec3, false, nb_elems * size, offsetof(gltf_vertex_t, normal), NULL, NULL); if (options->vertex_color) { make_attribute(g, buffer_view, primitive, "COLOR_0", cgltf_component_type_r_8u, cgltf_type_vec4, true, nb_elems * size, offsetof(gltf_vertex_t, color), NULL, NULL); } else { make_attribute(g, buffer_view, primitive, "TEXCOORD_0", cgltf_component_type_r_32f, cgltf_type_vec2, false, nb_elems * size, offsetof(gltf_vertex_t, texcoord), NULL, NULL); } node = add_item(g->data, nodes); vec3_set(node->translation, bpos[0], bpos[1], bpos[2]); node->has_translation = true; node->mesh = gmesh; } free(verts); free(gverts); // Add all the new created nodes into a single layer node. layer_node = add_item(g->data, nodes); ALLOC(layer_node->children, g->data->nodes_count - start_nodes_count); for (i = start_nodes_count; i < g->data->nodes_count - 1; i++) { *add_item(layer_node, children) = &g->data->nodes[i]; } *add_item(root_node, children) = layer_node; } static void create_palette_texture(gltf_t *g, const image_t *img) { // Create the global palette with all the colors. layer_t *layer; mesh_iterator_t iter; int i, s, pos[3], size; uint8_t c[4]; uint8_t (*data)[3]; uint8_t *png; cgltf_buffer *buffer; cgltf_buffer_view *buffer_view; cgltf_image *image; cgltf_texture *texture; DL_FOREACH(img->layers, layer) { iter = mesh_get_iterator(layer->mesh, 0); while (mesh_iter(&iter, pos)) { mesh_get_at(layer->mesh, &iter, pos, c); palette_insert(&g->palette, c, NULL); } } s = max(next_pow2(ceil(sqrt(g->palette.size))), 16); data = calloc(s * s, sizeof(*data)); for (i = 0; i < g->palette.size; i++) memcpy(data[i], g->palette.entries[i].color, 3); png = img_write_to_mem((void*)data, s, s, 3, &size); free(data); buffer = add_item(g->data, buffers); buffer->size = size; buffer->uri = data_new(png, size, NULL); buffer_view = add_item(g->data, buffer_views); buffer_view->buffer = buffer; buffer_view->size = size; image = add_item(g->data, images); image->mime_type = strdup("image/png"); image->buffer_view = buffer_view; texture = add_item(g->data, textures); texture->image = image; free(png); } static void gltf_export(const image_t *img, const char *path, const export_options_t *options) { gltf_t g = {}; const layer_t *layer; cgltf_scene *scene; cgltf_node *root_node; material_t *mat; gltf_init(&g, options, img); if (!options->vertex_color) create_palette_texture(&g, img); DL_FOREACH(img->materials, mat) { save_material(&g, mat, options); } root_node = add_item(g.data, nodes); mat4_set((void*)root_node->matrix, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1); root_node->has_matrix = true; scene = add_item(g.data, scenes); ALLOC(scene->nodes, 1); *add_item(scene, nodes) = root_node; ALLOC(root_node->children, DL_SIZE(img->layers)); DL_FOREACH(img->layers, layer) { save_layer(&g, root_node, img, layer, options); } cgltf_write_file(NULL, path, g.data); cgltf_free(g.data); free(g.palette.entries); } static int export_as_gltf(const image_t *img, const char *path) { gltf_export(img, path, &g_export_options); return 0; } static void export_gui(void) { gui_checkbox("Vertex color", &g_export_options.vertex_color, "Save colors as a vertex attribute"); } FILE_FORMAT_REGISTER(gltf, .name = "gltf", .ext = "glTF2\0*.gltf\0", .export_gui = export_gui, .export_func = export_as_gltf, ) goxel-0.11.0/src/formats/gox.c000066400000000000000000000612451435762723100161340ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "file_format.h" #include #define VERSION 2 // Current version of the file format. /* * File format, version 2: * * This is inspired by the png format, where the file consists of a list of * chunks with different types. * * 4 bytes magic string : "GOX " * 4 bytes version : 2 * List of chunks: * 4 bytes: type * 4 bytes: data length * n bytes: data * 4 bytes: CRC * * The layer can end with a DICT: * for each entry: * 4 byte : key size (0 = end of dict) * n bytes: key * 4 bytes: value size * n bytes: value * * chunks types: * * IMG : a dict of info: * - box: the image gox. * * PREV: a png image for preview. * * BL16: a 16^3 block saved as a 64x64 png image. * * LAYR: a layer: * 4 bytes: number of blocks. * for each block: * 4 bytes: block index * 4 bytes: x * 4 bytes: y * 4 bytes: z * 4 bytes: 0 * [DICT] * * CAMR: a camera: * [DICT] containing the following entries: * name: string * dist: float * rot: quaternion * ofs: offset * ortho: bool * * LIGH: the light: * [DICT] containing the following entries: * pitch: radian * yaw: radian * intensity: float */ // We create a hash table of all the blocks, so that blocks with the same // ids get written only once. typedef struct { UT_hash_handle hh; void *v; uint64_t uid; int index; } block_hash_t; #define CHUNK_BUFF_SIZE (1 << 20) // 1 MiB max buffer size! // XXX: should be something in goxel.h static const shape_t *SHAPES[] = { &shape_sphere, &shape_cube, &shape_cylinder, }; typedef struct { char type[4]; int length; uint32_t crc; char *buffer; // Used when writing. int pos; } chunk_t; // Conveniance macro to call snprintf without gcc warning us about // possible truncations. #define copy_string(dst, src) ({ \ int r = snprintf(dst, sizeof(dst), "%s", src); \ if (r >= sizeof(dst)) LOG_W("String truncated"); \ }) static void write_int32(FILE *out, int32_t v) { fwrite((char*)&v, 4, 1, out); } static int32_t read_int32(FILE *in) { int32_t v; if (fread(&v, 4, 1, in) != 1) { // XXX: use a better error mechanism! LOG_E("Error reading file"); } return v; } static bool chunk_read_start(chunk_t *c, FILE *in) { size_t r; memset(c, 0, sizeof(*c)); r = fread(c->type, 4, 1, in); if (r == 0) return false; // eof. if (r != 1) LOG_E("Error reading file"); c->length = read_int32(in); return true; } static void chunk_read(chunk_t *c, FILE *in, char *buff, int size, int line) { if (size == 0) return; c->pos += size; assert(c->pos <= c->length); if (buff) { // XXX: use a better error mechanism! if (fread(buff, size, 1, in) != 1) { LOG_E("Error reading file (line %d)", line); } } else { fseek(in, size, SEEK_CUR); } } static int32_t chunk_read_int32(chunk_t *c, FILE *in, int line) { int32_t v; chunk_read(c, in, (char*)&v, 4, line); return v; } static void chunk_read_finish(chunk_t *c, FILE *in) { assert(c->pos == c->length); read_int32(in); // TODO: check crc. } static bool chunk_read_dict_value(chunk_t *c, FILE *in, char *key, char *value, int *value_size, int line) { int size; assert(c->pos <= c->length); if (c->pos == c->length) return 0; size = chunk_read_int32(c, in, line); if (size == 0) return false; assert(size < 256); chunk_read(c, in, key, size, line); key[size] = '\0'; size = chunk_read_int32(c, in, line); chunk_read(c, in, value, size, line); value[size] = '\0'; *value_size = size; return true; } static void chunk_write_start(chunk_t *c, FILE *out, const char *type) { memset(c, 0, sizeof(*c)); assert(strlen(type) == 4); memcpy(c->type, type, 4); c->buffer = calloc(1, CHUNK_BUFF_SIZE); } static void chunk_write(chunk_t *c, FILE *out, const char *data, int size) { if (size == 0) return; assert(c->length + size < CHUNK_BUFF_SIZE); memcpy(c->buffer + c->length, data, size); c->length += size; } static void chunk_write_int32(chunk_t *c, FILE *out, int32_t v) { chunk_write(c, out, (char*)&v, 4); } static void chunk_write_dict_value(chunk_t *c, FILE *out, const char *name, const void *data, int size) { chunk_write_int32(c, out, (int)strlen(name)); chunk_write(c, out, name, (int)strlen(name)); chunk_write_int32(c, out, size); chunk_write(c, out, data, size); } static void chunk_write_finish(chunk_t *c, FILE *out) { fwrite(c->type, 4, 1, out); write_int32(out, c->length); fwrite(c->buffer, c->length, 1, out); write_int32(out, 0); // CRC XXX: todo. free(c->buffer); c->buffer = NULL; } static void chunk_write_all(FILE *out, const char *type, const char *data, int size) { fwrite(type, 4, 1, out); write_int32(out, size); fwrite(data, size, 1, out); write_int32(out, 0); // CRC XXX: todo. } static int get_material_idx(const image_t *img, const material_t *mat) { int i; const material_t *m; for (i = 0, m = img->materials; m; m = m->next, i++) { if (m == mat) return i; } return 0; } static const material_t *get_material(const image_t *img, int idx) { int i; const material_t *m; for (i = 0, m = img->materials; m; m = m->next, i++) { if (i == idx) return m; } return NULL; } void save_to_file(const image_t *img, const char *path) { // XXX: remove all empty blocks before saving. LOG_I("Save to %s", path); block_hash_t *blocks_table = NULL, *data, *data_tmp; layer_t *layer; chunk_t c; int nb_blocks, index, size, bpos[3], material_idx; uint64_t uid; FILE *out; uint8_t *png, *preview; camera_t *camera; material_t *material; mesh_iterator_t iter; img = img ?: goxel.image; out = fopen(path, "wb"); if (!out) { LOG_E("Cannot save to %s: %s", path, strerror(errno)); return; } fwrite("GOX ", 4, 1, out); write_int32(out, VERSION); // Write image info. chunk_write_start(&c, out, "IMG "); if (!box_is_null(img->box)) chunk_write_dict_value(&c, out, "box", &img->box, sizeof(img->box)); chunk_write_finish(&c, out); preview = calloc(128 * 128, 4); goxel_render_to_buf(preview, 128, 128, 4); png = img_write_to_mem(preview, 128, 128, 4, &size); chunk_write_all(out, "PREV", (char*)png, size); free(preview); free(png); // Add all the blocks data into the hash table. index = 0; DL_FOREACH(img->layers, layer) { iter = mesh_get_iterator(layer->mesh, MESH_ITER_BLOCKS); while (mesh_iter(&iter, bpos)) { mesh_get_block_data(layer->mesh, &iter, bpos, &uid); HASH_FIND(hh, blocks_table, &uid, sizeof(uid), data); if (data) continue; data = calloc(1, sizeof(*data)); data->v = mesh_get_block_data(layer->mesh, &iter, bpos, NULL); assert(data->v); data->uid = uid; data->index = index++; HASH_ADD(hh, blocks_table, uid, sizeof(data->uid), data); } } // Write all the blocks chunks. HASH_ITER(hh, blocks_table, data, data_tmp) { png = img_write_to_mem((uint8_t*)data->v, 64, 64, 4, &size); chunk_write_all(out, "BL16", (char*)png, size); free(png); } // Write all the materials. DL_FOREACH(img->materials, material) { chunk_write_start(&c, out, "MATE"); chunk_write_dict_value(&c, out, "name", material->name, strlen(material->name)); chunk_write_dict_value(&c, out, "color", &material->base_color, sizeof(material->base_color)); chunk_write_dict_value(&c, out, "metallic", &material->metallic, sizeof(material->metallic)); chunk_write_dict_value(&c, out, "roughness", &material->roughness, sizeof(material->roughness)); chunk_write_dict_value(&c, out, "emission", &material->emission, sizeof(material->emission)); chunk_write_finish(&c, out); } // Write all the layers. DL_FOREACH(img->layers, layer) { chunk_write_start(&c, out, "LAYR"); nb_blocks = 0; if (!layer->base_id && !layer->shape) { iter = mesh_get_iterator(layer->mesh, MESH_ITER_BLOCKS); while (mesh_iter(&iter, bpos)) { nb_blocks++; } } chunk_write_int32(&c, out, nb_blocks); if (!layer->base_id && !layer->shape) { iter = mesh_get_iterator(layer->mesh, MESH_ITER_BLOCKS); while (mesh_iter(&iter, bpos)) { mesh_get_block_data(layer->mesh, &iter, bpos, &uid); HASH_FIND(hh, blocks_table, &uid, sizeof(uid), data); assert(data); chunk_write_int32(&c, out, data->index); chunk_write_int32(&c, out, bpos[0]); chunk_write_int32(&c, out, bpos[1]); chunk_write_int32(&c, out, bpos[2]); chunk_write_int32(&c, out, 0); } } chunk_write_dict_value(&c, out, "name", layer->name, strlen(layer->name)); chunk_write_dict_value(&c, out, "mat", &layer->mat, sizeof(layer->mat)); chunk_write_dict_value(&c, out, "id", &layer->id, sizeof(layer->id)); chunk_write_dict_value(&c, out, "base_id", &layer->base_id, sizeof(layer->base_id)); material_idx = get_material_idx(img, layer->material); chunk_write_dict_value(&c, out, "material", &material_idx, sizeof(material_idx)); if (layer->image) { chunk_write_dict_value(&c, out, "img-path", layer->image->path, strlen(layer->image->path)); } if (!box_is_null(layer->box)) chunk_write_dict_value(&c, out, "box", &layer->box, sizeof(layer->box)); if (layer->shape) { chunk_write_dict_value(&c, out, "shape", layer->shape->id, strlen(layer->shape->id)); chunk_write_dict_value(&c, out, "color", layer->color, sizeof(layer->color)); } chunk_write_dict_value(&c, out, "visible", &layer->visible, sizeof(layer->visible)); chunk_write_finish(&c, out); } // Write all the cameras. DL_FOREACH(img->cameras, camera) { chunk_write_start(&c, out, "CAMR"); chunk_write_dict_value(&c, out, "name", camera->name, strlen(camera->name)); chunk_write_dict_value(&c, out, "dist", &camera->dist, sizeof(camera->dist)); // chunk_write_dict_value(&c, out, "rot", &camera->rot, // sizeof(camera->rot)); // chunk_write_dict_value(&c, out, "ofs", &camera->ofs, // sizeof(camera->ofs)); chunk_write_dict_value(&c, out, "ortho", &camera->ortho, sizeof(camera->ortho)); chunk_write_dict_value(&c, out, "mat", &camera->mat, sizeof(camera->mat)); if (camera == img->active_camera) chunk_write_dict_value(&c, out, "active", NULL, 0); chunk_write_finish(&c, out); } // Write the light settings. chunk_write_start(&c, out, "LIGH"); chunk_write_dict_value(&c, out, "pitch", &goxel.rend.light.pitch, sizeof(goxel.rend.light.pitch)); chunk_write_dict_value(&c, out, "yaw", &goxel.rend.light.yaw, sizeof(goxel.rend.light.yaw)); chunk_write_dict_value(&c, out, "intensity", &goxel.rend.light.intensity, sizeof(goxel.rend.light.intensity)); chunk_write_dict_value(&c, out, "fixed", &goxel.rend.light.fixed, sizeof(goxel.rend.light.fixed)); chunk_write_dict_value(&c, out, "ambient", &goxel.rend.settings.ambient, sizeof(goxel.rend.settings.ambient)); chunk_write_dict_value(&c, out, "shadow", &goxel.rend.settings.shadow, sizeof(goxel.rend.settings.shadow)); chunk_write_finish(&c, out); HASH_ITER(hh, blocks_table, data, data_tmp) { HASH_DEL(blocks_table, data); free(data); } fclose(out); } // Iter info of a gox file, without actually reading it. // For the moment only returns the image preview if available. int gox_iter_infos(const char *path, int (*callback)(const char *attr, int size, void *value, void *user), void *user) { FILE *in; chunk_t c; uint8_t *png; char magic[4]; in = fopen(path, "rb"); if (fread(magic, 4, 1, in) != 1) goto error; if (strncmp(magic, "GOX ", 4) != 0) goto error; read_int32(in); while (chunk_read_start(&c, in)) { if (strncmp(c.type, "BL16", 4) == 0) break; if (strncmp(c.type, "LAYR", 4) == 0) break; if (strncmp(c.type, "PREV", 4) == 0) { png = calloc(1, c.length); chunk_read(&c, in, (char*)png, c.length, __LINE__); callback(c.type, c.length, png, user); free(png); } else { // Ignore other blocks. chunk_read(&c, in, NULL, c.length, __LINE__); } chunk_read_finish(&c, in); } fclose(in); return 0; error: fclose(in); LOG_W("Cannot get gox file info"); return -1; } static block_hash_t *hash_find_at(block_hash_t *hash, int index) { int i; for (i = 0; i < index; i++) { hash = hash->hh.next; } return hash; } // Ugly macro that check dict key/value and copy them if needed. #define DICT_CPY(key, dst) ({ \ bool r = false; \ if (strcmp(key, dict_key) == 0) { \ if (dict_value_size != sizeof(dst)) { \ LOG_E("Dict value %s size doesn't match!", key); \ } else { \ memcpy(&(dst), dict_value, dict_value_size); \ r = true; \ } \ } \ r; }) int load_from_file(const char *path, bool replace) { layer_t *layer, *layer_tmp; block_hash_t *blocks_table = NULL, *data, *data_tmp; FILE *in; char magic[4] = {}; uint8_t *voxel_data; int nb_blocks; int w, h, bpp; uint8_t *png; chunk_t c; int i, index, version, x, y, z, material_idx; int dict_value_size; char dict_key[256]; char dict_value[256]; uint64_t uid = 1; int aabb[2][3]; camera_t *camera, *camera_tmp; material_t *mat, *mat_tmp; in = fopen(path, "rb"); if (!in) return -1; if (fread(magic, 4, 1, in) != 1) goto error; if (strncmp(magic, "GOX ", 4) != 0) goto error; version = read_int32(in); if (version > VERSION) { LOG_W("Cannot open gox file version %d", version); goto error; } // Remove all layers, materials and camera. // XXX: should have a way to create a totally empty image instead. if (replace) { DL_FOREACH_SAFE(goxel.image->layers, layer, layer_tmp) { mesh_delete(layer->mesh); free(layer); } DL_FOREACH_SAFE(goxel.image->materials, mat, mat_tmp) { material_delete(mat); } DL_FOREACH_SAFE(goxel.image->cameras, camera, camera_tmp) { camera_delete(camera); } goxel.image->layers = NULL; goxel.image->materials = NULL; goxel.image->active_material = NULL; goxel.image->cameras = NULL; goxel.image->active_camera = NULL; memset(&goxel.image->box, 0, sizeof(goxel.image->box)); } while (chunk_read_start(&c, in)) { if (strncmp(c.type, "BL16", 4) == 0) { png = calloc(1, c.length); chunk_read(&c, in, (char*)png, c.length, __LINE__); bpp = 4; voxel_data = img_read_from_mem((void*)png, c.length, &w, &h, &bpp); assert(w == 64 && h == 64 && bpp == 4); data = calloc(1, sizeof(*data)); data->v = calloc(1, 64 * 64 * 4); memcpy(data->v, voxel_data, 64 * 64 * 4); data->uid = ++uid; HASH_ADD(hh, blocks_table, uid, sizeof(data->uid), data); free(voxel_data); free(png); } else if (strncmp(c.type, "LAYR", 4) == 0) { layer = image_add_layer(goxel.image, NULL); nb_blocks = chunk_read_int32(&c, in, __LINE__); assert(nb_blocks >= 0); for (i = 0; i < nb_blocks; i++) { index = chunk_read_int32(&c, in, __LINE__); assert(index >= 0); x = chunk_read_int32(&c, in, __LINE__); y = chunk_read_int32(&c, in, __LINE__); z = chunk_read_int32(&c, in, __LINE__); if (version == 1) { // Previous version blocks pos. x -= 8; y -= 8; z -= 8; } chunk_read_int32(&c, in, __LINE__); data = hash_find_at(blocks_table, index); assert(data); mesh_blit(layer->mesh, data->v, x, y, z, 16, 16, 16, NULL); } while ((chunk_read_dict_value(&c, in, dict_key, dict_value, &dict_value_size, __LINE__))) { if (strcmp(dict_key, "name") == 0) sprintf(layer->name, "%s", dict_value); DICT_CPY("mat", layer->mat); if (strcmp(dict_key, "img-path") == 0) { layer->image = texture_new_image(dict_value, TF_NEAREST); } typeof(layer->id) id; if (DICT_CPY("id", id)) { if (id) layer->id = id; } DICT_CPY("base_id", layer->base_id); DICT_CPY("box", layer->box); if (strcmp(dict_key, "shape") == 0) { for (i = 0; i < ARRAY_SIZE(SHAPES); i++) { if (strcmp(SHAPES[i]->id, dict_value) == 0) { layer->shape = SHAPES[i]; break; } } } DICT_CPY("color", layer->color); DICT_CPY("visible", layer->visible); if (DICT_CPY("material", material_idx)) layer->material = get_material(goxel.image, material_idx); } } else if (strncmp(c.type, "CAMR", 4) == 0) { camera = camera_new("unnamed"); DL_APPEND(goxel.image->cameras, camera); while ((chunk_read_dict_value(&c, in, dict_key, dict_value, &dict_value_size, __LINE__))) { if (strcmp(dict_key, "name") == 0) { copy_string(camera->name, dict_value); } DICT_CPY("dist", camera->dist); DICT_CPY("ortho", camera->ortho); DICT_CPY("mat", camera->mat); if (strcmp(dict_key, "active") == 0) goxel.image->active_camera = camera; } } else if (strncmp(c.type, "MATE", 4) == 0) { mat = image_add_material(goxel.image, NULL); while ((chunk_read_dict_value(&c, in, dict_key, dict_value, &dict_value_size, __LINE__))) { if (strcmp(dict_key, "name") == 0) copy_string(mat->name, dict_value); DICT_CPY("color", mat->base_color); DICT_CPY("metallic", mat->metallic); DICT_CPY("roughness", mat->roughness); DICT_CPY("emission", mat->emission); } } else if (strncmp(c.type, "IMG ", 4) == 0) { while ((chunk_read_dict_value(&c, in, dict_key, dict_value, &dict_value_size, __LINE__))) { DICT_CPY("box", goxel.image->box); } } else if (strncmp(c.type, "LIGH", 4) == 0) { while ((chunk_read_dict_value(&c, in, dict_key, dict_value, &dict_value_size, __LINE__))) { DICT_CPY("pitch", goxel.rend.light.pitch); DICT_CPY("yaw", goxel.rend.light.yaw); DICT_CPY("intensity", goxel.rend.light.intensity); DICT_CPY("fixed", goxel.rend.light.fixed); DICT_CPY("ambient", goxel.rend.settings.ambient); DICT_CPY("shadow", goxel.rend.settings.shadow); } } else { // Ignore other blocks. chunk_read(&c, in, NULL, c.length, __LINE__); } chunk_read_finish(&c, in); } // Free the block hash table. We do not delete the block data because // they have been used by the meshes. HASH_ITER(hh, blocks_table, data, data_tmp) { HASH_DEL(blocks_table, data); free(data->v); free(data); } goxel.image->path = strdup(path); goxel.image->saved_key = image_get_key(goxel.image); fclose(in); // Add a default camera if there is none. if (!goxel.image->cameras) { image_add_camera(goxel.image, NULL); camera_fit_box(goxel.image->active_camera, goxel.image->box); } // Set default image box if we didn't have one. if (box_is_null(goxel.image->box)) { mesh_get_bbox(goxel_get_layers_mesh(goxel.image), aabb, true); if (aabb[0][0] > aabb[1][0]) { aabb[0][0] = -16; aabb[0][1] = -16; aabb[0][2] = 0; aabb[1][0] = 16; aabb[1][1] = 16; aabb[1][2] = 32; } bbox_from_aabb(goxel.image->box, aabb); } // Update plane, snap mask not to confuse people. plane_from_vectors(goxel.plane, goxel.image->box[3], VEC(1, 0, 0), VEC(0, 1, 0)); return 0; error: fclose(in); return -1; } static void a_open(void) { const char *path; path = noc_file_dialog_open(NOC_FILE_DIALOG_OPEN, "gox\0*.gox\0", NULL, NULL); if (!path) return; image_delete(goxel.image); goxel.image = image_new(); load_from_file(path, true); } ACTION_REGISTER(open, .help = "Open an image", .cfunc = a_open, .default_shortcut = "Ctrl O", ) static void a_save_as(void) { const char *path; path = sys_get_save_path("gox\0*.gox\0", "untitled.gox"); if (!path) return; if (path != goxel.image->path) { free(goxel.image->path); goxel.image->path = strdup(path); } save_to_file(goxel.image, goxel.image->path); goxel.image->saved_key = image_get_key(goxel.image); sys_on_saved(path); } ACTION_REGISTER(save_as, .help = "Save the image as", .cfunc = a_save_as, ) static void a_save(void) { const char *path = goxel.image->path; if (!path) path = sys_get_save_path("gox\0*.gox\0", "untitled.gox"); if (!path) return; if (path != goxel.image->path) { free(goxel.image->path); goxel.image->path = strdup(path); } save_to_file(goxel.image, goxel.image->path); goxel.image->saved_key = image_get_key(goxel.image); sys_on_saved(path); } ACTION_REGISTER(save, .help = "Save the image", .cfunc = a_save, .default_shortcut = "Ctrl S" ) static void a_reset(void) { goxel_reset(); } ACTION_REGISTER(reset, .help = "New", .cfunc = a_reset, .default_shortcut = "Ctrl N" ) static int gox_import(image_t *image, const char *path) { return load_from_file(path, false); } FILE_FORMAT_REGISTER(gox, .name = "gox", .ext = "gox\0*.gox\0", .import_func = gox_import, ) goxel-0.11.0/src/formats/png.c000066400000000000000000000046161435762723100161220ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "file_format.h" // XXX: this function has to be rewritten. static int png_export(const image_t *img, const char *path, int w, int h) { uint8_t *buf; int bpp = img->export_transparent_background ? 4 : 3; if (!path) return -1; LOG_I("Exporting to file %s", path); buf = calloc(w * h, bpp); goxel_render_to_buf(buf, w, h, bpp); img_write(buf, w, h, bpp, path); free(buf); return 0; } static void export_gui(void) { int maxsize, i; GL(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize)); maxsize /= 2; // Because png export already double it. goxel.show_export_viewport = true; gui_group_begin(NULL); gui_checkbox("Custom size", &goxel.image->export_custom_size, NULL); if (!goxel.image->export_custom_size) { goxel.image->export_width = goxel.gui.viewport[2]; goxel.image->export_height = goxel.gui.viewport[3]; } gui_enabled_begin(goxel.image->export_custom_size); i = goxel.image->export_width; if (gui_input_int("w", &i, 1, maxsize)) goxel.image->export_width = clamp(i, 1, maxsize); i = goxel.image->export_height; if (gui_input_int("h", &i, 1, maxsize)) goxel.image->export_height = clamp(i, 1, maxsize); gui_enabled_end(); gui_group_end(); gui_checkbox("Transparent background", &goxel.image->export_transparent_background, NULL); } static int export_as_png(const image_t *img, const char *path) { png_export(img, path, img->export_width, img->export_height); return 0; } FILE_FORMAT_REGISTER(png, .name = "png", .ext = "png\0*.png\0", .export_gui = export_gui, .export_func = export_as_png, ) goxel-0.11.0/src/formats/png_slices.c000066400000000000000000000037431435762723100174640ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "file_format.h" static int export_as_png_slices(const image_t *image, const char *path) { float box[4][4]; const mesh_t *mesh; int x, y, z, w, h, d, pos[3], start_pos[3]; uint8_t c[4]; uint8_t *img; mesh_iterator_t iter = {0}; mesh = goxel_get_layers_mesh(image); mat4_copy(image->box, box); if (box_is_null(box)) mesh_get_box(mesh, true, box); w = box[0][0] * 2; h = box[1][1] * 2; d = box[2][2] * 2; start_pos[0] = box[3][0] - box[0][0]; start_pos[1] = box[3][1] - box[1][1]; start_pos[2] = box[3][2] - box[2][2]; img = calloc(w * h * d, 4); for (z = 0; z < d; z++) for (y = 0; y < h; y++) for (x = 0; x < w; x++) { pos[0] = x + start_pos[0]; pos[1] = y + start_pos[1]; pos[2] = z + start_pos[2]; mesh_get_at(mesh, &iter, pos, c); img[(y * w * d + z * w + x) * 4 + 0] = c[0]; img[(y * w * d + z * w + x) * 4 + 1] = c[1]; img[(y * w * d + z * w + x) * 4 + 2] = c[2]; img[(y * w * d + z * w + x) * 4 + 3] = c[3]; } img_write(img, w * d, h, 4, path); free(img); return 0; } FILE_FORMAT_REGISTER(png_slices, .name = "png slices", .ext = "png\0*.png\0", .export_func = export_as_png_slices, ) goxel-0.11.0/src/formats/povray.c000066400000000000000000000067401435762723100166560ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2016 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ // Povray export support. #include "goxel.h" #include "file_format.h" #include "utils/mustache.h" static int export_as_pov(const image_t *image, const char *path) { FILE *file; layer_t *layer; int size, p[3], w, h; char *buf; const char *template; uint8_t v[4]; float modelview[4][4], light_dir[3]; mustache_t *m, *m_cam, *m_light, *m_voxels, *m_voxel; camera_t camera = *image->active_camera; mesh_iterator_t iter; w = image->export_width; h = image->export_height; template = assets_get("asset://data/other/povray_template.pov", NULL); assert(template); camera.aspect = (float)w / h; camera_update(&camera); mat4_copy(camera.view_mat, modelview); // cam_to_view = mat4_inverted(camera.view_mat); // cam_look_at = mat4_mul_vec(cam_to_view, vec4(0, 0, -1, 1)).xyz; render_get_light_dir(&goxel.rend, light_dir); m = mustache_root(); mustache_add_str(m, "version", GOXEL_VERSION_STR); m_cam = mustache_add_dict(m, "camera"); mustache_add_str(m_cam, "width", "%d", w); mustache_add_str(m_cam, "height", "%d", h); mustache_add_str(m_cam, "angle", "%.1f", camera.fovy * camera.aspect); mustache_add_str(m_cam, "modelview", "<%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f>", modelview[0][0], modelview[0][1], modelview[0][2], modelview[1][0], modelview[1][1], modelview[1][2], modelview[2][0], modelview[2][1], modelview[2][2], modelview[3][0], modelview[3][1], modelview[3][2]); m_light = mustache_add_dict(m, "light"); mustache_add_str(m_light, "ambient", "%.2f", goxel.rend.settings.ambient); mustache_add_str(m_light, "point_at", "<%.1f, %.1f, %.1f + 1024>", -light_dir[0], -light_dir[1], -light_dir[2]); m_voxels = mustache_add_list(m, "voxels"); DL_FOREACH(image->layers, layer) { iter = mesh_get_iterator(layer->mesh, MESH_ITER_VOXELS); while (mesh_iter(&iter, p)) { mesh_get_at(layer->mesh, &iter, p, v); if (v[3] < 127) continue; m_voxel = mustache_add_dict(m_voxels, NULL); mustache_add_str(m_voxel, "pos", "<%d, %d, %d>", p[0], p[1], p[2]); mustache_add_str(m_voxel, "color", "<%d, %d, %d>", v[0], v[1], v[2]); } } size = mustache_render(m, template, NULL); buf = calloc(size + 1, 1); mustache_render(m, template, buf); mustache_free(m); file = fopen(path, "wb"); fwrite(buf, 1, size, file); fclose(file); free(buf); return 0; } FILE_FORMAT_REGISTER(povray, .name = "povray", .ext = "povray\0*.povray\0", .export_func = export_as_pov, ) goxel-0.11.0/src/formats/qubicle.c000066400000000000000000000143031435762723100167540ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2016 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "file_format.h" // Load qubicle files. #define READ(type, file) \ ({ type v; size_t r = fread(&v, sizeof(v), 1, file); (void)r; v;}) #define WRITE(type, v, file) \ ({ type v_ = v; fwrite(&v_, sizeof(v_), 1, file);}) static void apply_orientation(int orientation, int pos[3]) { if (orientation == 1) {// Right SWAP(pos[1], pos[2]); } else { // Left SWAP(pos[1], pos[2]); pos[1] = -pos[1]; } } static int qubicle_import(image_t *image, const char *path) { FILE *file; int version, color_format, orientation, compression, vmask, mat_count; int i, j, r, index, len, w, h, d, pos[3], vpos[3], x, y, z, bbox[2][3]; union { uint8_t v[4]; uint32_t uint32; struct { uint8_t r, g, b, a; }; } v; const uint32_t CODEFLAG = 2; const uint32_t NEXTSLICEFLAG = 6; layer_t *layer; mesh_iterator_t iter = {0}; file = fopen(path, "rb"); version = READ(uint32_t, file); (void)version; color_format = READ(uint32_t, file); (void)color_format; orientation = READ(uint32_t, file); compression = READ(uint32_t, file); vmask = READ(uint32_t, file); (void)vmask; mat_count = READ(uint32_t, file); for (i = 0; i < mat_count; i++) { layer = image_add_layer(goxel.image, NULL); iter = mesh_get_accessor(layer->mesh); memset(layer->name, 0, sizeof(layer->name)); len = READ(uint8_t, file); r = (int)fread(layer->name, len, 1, file); (void)r; w = READ(uint32_t, file); h = READ(uint32_t, file); d = READ(uint32_t, file); pos[0] = READ(int32_t, file); pos[1] = READ(int32_t, file); pos[2] = READ(int32_t, file); // Set the layer bounding box. vec3_set(bbox[0], pos[0], pos[1], pos[2]); vec3_set(bbox[1], pos[0] + w, pos[1] + h, pos[2] + d); apply_orientation(orientation, bbox[0]); apply_orientation(orientation, bbox[1]); if (bbox[1][1] < bbox[0][1]) { SWAP(bbox[1][1], bbox[0][1]); bbox[0][1] += 1; bbox[1][1] += 1; } bbox_from_aabb(layer->box, bbox); if (compression == 0) { for (index = 0; index < w * h * d; index++) { v.uint32 = READ(uint32_t, file); if (!v.a) continue; v.a = v.a ? 255 : 0; vpos[0] = pos[0] + index % w; vpos[1] = pos[1] + (index % (w * h)) / w; vpos[2] = pos[2] + index / (w * h); apply_orientation(orientation, vpos); mesh_set_at(layer->mesh, &iter, vpos, v.v); } } else { for (z = 0; z < d; z++) { index = 0; while (true) { v.uint32 = READ(uint32_t, file); if (v.uint32 == NEXTSLICEFLAG) { break; // Next z. } len = 1; if (v.uint32 == CODEFLAG) { len = READ(uint32_t, file); v.uint32 = READ(uint32_t, file); v.a = v.a ? 255 : 0; } for (j = 0; j < len; j++) { x = index % w; y = index / w; v.a = v.a ? 255 : 0; vpos[0] = pos[0] + x; vpos[1] = pos[1] + y; vpos[2] = pos[2] + z; apply_orientation(orientation, vpos); mesh_set_at(layer->mesh, &iter, vpos, v.v); index++; } } } } } return 0; } static int qubicle_export(const image_t *img, const char *path) { FILE *file; int i, count, x, y, z, pos[3], bbox[2][3]; uint8_t v[4]; layer_t *layer; mesh_iterator_t iter; mesh_t *mesh; count = 0; DL_COUNT(img->layers, layer, count); file = fopen(path, "wb"); WRITE(uint32_t, 257, file); // version WRITE(uint32_t, 0, file); // color format RGBA WRITE(uint32_t, 1, file); // orientation right handed WRITE(uint32_t, 0, file); // no compression WRITE(uint32_t, 0, file); // vmask WRITE(uint32_t, count, file); i = 0; DL_FOREACH(img->layers, layer) { mesh = layer->mesh; if (!box_is_null(layer->box)) bbox_to_aabb(layer->box, bbox); else if (!mesh_get_bbox(mesh, bbox, true)) continue; WRITE(uint8_t, strlen(layer->name), file); fwrite(layer->name, strlen(layer->name), 1, file); WRITE(uint32_t, bbox[1][0] - bbox[0][0], file); WRITE(uint32_t, bbox[1][2] - bbox[0][2], file); WRITE(uint32_t, bbox[1][1] - bbox[0][1], file); WRITE(int32_t, bbox[0][0], file); WRITE(int32_t, bbox[0][2], file); WRITE(int32_t, bbox[0][1], file); iter = mesh_get_accessor(mesh); for (y = bbox[0][1]; y < bbox[1][1]; y++) for (z = bbox[0][2]; z < bbox[1][2]; z++) for (x = bbox[0][0]; x < bbox[1][0]; x++) { pos[0] = x; pos[1] = y; pos[2] = z; mesh_get_at(mesh, &iter, pos, v); fwrite(v, 4, 1, file); } i++; } fclose(file); return 0; } FILE_FORMAT_REGISTER(qubicle, .name = "qubicle", .ext = "qubicle\0*.qb\0", .import_func = qubicle_import, .export_func = qubicle_export, ) goxel-0.11.0/src/formats/txt.c000066400000000000000000000053671435762723100161610ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "file_format.h" #include static int import_as_txt(image_t *image, const char *path) { FILE *file; char line[2048]; layer_t *layer; mesh_iterator_t iter = {0}; int pos[3]; unsigned int c[4]; char *token; LOG_I("Reading text file. One line per voxel. Format should be: X Y Z RRGGBB"); file = fopen(path, "r"); //Checks if file is empty if (file == NULL) { LOG_E("Can not open file for reading: %s", path); return 1; } layer = image->active_layer; while (fgets(line, 2048, file)) { token = strtok(line, " "); // get first token (X) if (strcmp(token, "#") == 0) continue; pos[0] = atoi(token); token = strtok(NULL, " "); // get second token (Y) pos[1] = atoi(token); token = strtok(NULL, " "); // get third token (Z) pos[2] = atoi(token); token = strtok(NULL, " "); // get forth token (RRGGBB) sscanf(token, "%02x%02x%02x", &c[0], &c[1], &c[2]); mesh_set_at(layer->mesh, &iter, pos, (uint8_t[]){c[0], c[1], c[2], 255}); } fclose(file); return 0; } static int export_as_txt(const image_t *image, const char *path) { FILE *out; const mesh_t *mesh = goxel_get_layers_mesh(image); int p[3]; uint8_t v[4]; mesh_iterator_t iter; out = fopen(path, "w"); if (!out) { LOG_E("Cannot save to %s: %s", path, strerror(errno)); return -1; } fprintf(out, "# Goxel " GOXEL_VERSION_STR "\n"); fprintf(out, "# One line per voxel\n"); fprintf(out, "# X Y Z RRGGBB\n"); iter = mesh_get_iterator(mesh, MESH_ITER_VOXELS); while (mesh_iter(&iter, p)) { mesh_get_at(mesh, &iter, p, v); if (v[3] < 127) continue; fprintf(out, "%d %d %d %02x%02x%02x\n", p[0], p[1], p[2], v[0], v[1], v[2]); } fclose(out); return 0; } FILE_FORMAT_REGISTER(txt, .name = "text", .ext = "text\0*.txt\0", .import_func = import_as_txt, .export_func = export_as_txt, ) goxel-0.11.0/src/formats/vox.c000066400000000000000000000465121435762723100161530ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2016 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ // Magica voxel vox format support. #include "goxel.h" #include "file_format.h" #include static const uint32_t VOX_DEFAULT_PALETTE[256]; static inline void hexcolor(uint32_t v, uint8_t out[4]) { out[0] = (v >> 24) & 0xff; out[1] = (v >> 16) & 0xff; out[2] = (v >> 8) & 0xff; out[3] = (v >> 0) & 0xff; } #define READ(type, file) \ ({ type v; size_t r = fread(&v, sizeof(v), 1, file); (void)r; v;}) #define WRITE(type, v, file) \ ({ type v_ = v; fwrite(&v_, sizeof(v_), 1, file);}) #define FILE_ERROR(msg) do { LOG_E("%s", msg); goto error; } while (0); // Import the old magica voxel file format: // // d, h, w, , static int vox_import_old(const char *path) { FILE *file; int w, h, d, i; uint8_t *voxels; uint8_t (*palette)[4]; uint8_t (*cube)[4]; file = fopen(path, "rb"); d = READ(uint32_t, file); h = READ(uint32_t, file); w = READ(uint32_t, file); voxels = calloc(w * h * d, 1); palette = calloc(256, sizeof(*palette)); cube = calloc(w * h * d, sizeof(*cube)); for (i = 0; i < w * h * d; i++) { voxels[i] = READ(uint8_t, file); } for (i = 0; i < 256; i++) { palette[i][0] = READ(uint8_t, file); palette[i][1] = READ(uint8_t, file); palette[i][2] = READ(uint8_t, file); palette[i][3] = 255; } memset(palette[255], 0, 4); for (i = 0; i < w * h * d; i++) { if (voxels[i] == 255) continue; memcpy(cube[i], palette[voxels[i]], 4); } mesh_blit(goxel.image->active_layer->mesh, (uint8_t*)cube, -w / 2, -h / 2, -d / 2, w, h, d, NULL); free(palette); free(voxels); free(cube); fclose(file); return 0; } typedef struct node node_t; struct node { node_t *children; node_t *next, *prev; char id[4]; node_t *parent; // Logical parent. int node_id; int nb_children; int *children_ids; union { struct { int w, h, d; } size; struct { uint8_t (*values)[4]; } rgba; struct { int nb; uint8_t *values; } xyzi; struct { int id; int child_id; int nb_frames; int tr[3]; bool has_rot; int rot[3][3]; bool has_trans; int trans[3]; } ntrn; struct { int id; int nb_models; int model_id; } nshp; }; }; static int read_string(FILE *file, char **out) { int size, r; size = READ(int32_t, file); *out = calloc(size + 1, 1); r = fread(*out, 1, size, file); if (r != size) { return -1; } return size; } static void read_dict(FILE *file, void *user, void (*callback)(void *user, const char *key, int size, const char *value)) { int nb, i, size; char *key, *value; nb = READ(int32_t, file); for (i = 0; i < nb; i++) { read_string(file, &key); size = read_string(file, &value); if (callback) callback(user, key, size, value); free(key); free(value); } } static void on_trn_dict(void *user, const char *key, int size, const char *value) { node_t *node = user; int v, x, y, z; if (strcmp(key, "_r") == 0) { node->ntrn.has_rot = true; v = atoi(value); x = (v >> 0) & 3; y = (v >> 2) & 3; z = 3 - x - y; node->ntrn.rot[x][0] = ((v >> 4) & 1) ? -1 : +1; node->ntrn.rot[y][1] = ((v >> 5) & 1) ? -1 : +1; node->ntrn.rot[z][2] = ((v >> 6) & 1) ? -1 : +1; } if (strcmp(key, "_t") == 0) { node->ntrn.has_trans = true; sscanf(value, "%d %d %d", &x, &y, &z); node->ntrn.trans[0] = x; node->ntrn.trans[1] = y; node->ntrn.trans[2] = z; } } static bool node_is(const node_t *node, const char *id) { return strncmp(node->id, id, 4) == 0; } static void free_node(node_t *node) { node_t *child, *tmp; if (node_is(node, "RGBA")) free(node->rgba.values); if (node_is(node, "XYZI")) free(node->xyzi.values); DL_FOREACH_SAFE(node->children, child, tmp) { DL_DELETE(node->children, child); free_node(child); } free(node->children_ids); free(node); } static node_t *read_node(FILE *file) { int i, r, size, children_size; node_t *node, *child, *child2; long fpos; node = calloc(1, sizeof(*node)); node->node_id = -1; r = fread(node->id, 1, 4, file); if (r != 4) goto error; size = READ(uint32_t, file); children_size = READ(uint32_t, file); fpos = ftell(file); if (strncmp(node->id, "MAIN", 4) == 0) { // Nothing to do. } else if (strncmp(node->id, "SIZE", 4) == 0) { node->size.w = READ(uint32_t, file); node->size.h = READ(uint32_t, file); node->size.d = READ(uint32_t, file); } else if (strncmp(node->id, "RGBA", 4) == 0) { node->rgba.values = malloc(4 * 256); for (i = 1; i < 256; i++) { node->rgba.values[i][0] = READ(uint8_t, file); node->rgba.values[i][1] = READ(uint8_t, file); node->rgba.values[i][2] = READ(uint8_t, file); node->rgba.values[i][3] = READ(uint8_t, file); } // Skip the last value! for (i = 0; i < 4; i++) READ(uint8_t, file); } else if (strncmp(node->id, "XYZI", 4) == 0) { node->xyzi.nb = READ(uint32_t, file); node->xyzi.values = calloc(node->xyzi.nb, 4); for (i = 0; i < node->xyzi.nb; i++) { node->xyzi.values[i * 4 + 0] = READ(uint8_t, file); node->xyzi.values[i * 4 + 1] = READ(uint8_t, file); node->xyzi.values[i * 4 + 2] = READ(uint8_t, file); node->xyzi.values[i * 4 + 3] = READ(uint8_t, file); } } else if (strncmp(node->id, "nTRN", 4) == 0) { node->node_id = READ(int32_t, file); read_dict(file, NULL, NULL); node->nb_children = 1; node->children_ids = calloc(1, sizeof(int)); *node->children_ids = READ(int32_t, file); READ(int32_t, file); READ(int32_t, file); node->ntrn.nb_frames = READ(int32_t, file); for (i = 0; i < node->ntrn.nb_frames; i++) { read_dict(file, node, on_trn_dict); } } else if (strncmp(node->id, "nSHP", 4) == 0) { node->node_id = READ(int32_t, file); read_dict(file, NULL, NULL); node->nshp.nb_models = READ(int32_t, file); for (i = 0; i < node->nshp.nb_models; i++) { node->nshp.model_id = READ(int32_t, file); read_dict(file, NULL, NULL); } } else if (strncmp(node->id, "nGRP", 4) == 0) { node->node_id = READ(int32_t, file); read_dict(file, NULL, NULL); node->nb_children = READ(int32_t, file); node->children_ids = calloc(node->nb_children, sizeof(int)); for (i = 0; i < node->nb_children; i++) { node->children_ids[i] = READ(int32_t, file); } } if (ftell(file) < fpos + size) { fseek(file, fpos + size, SEEK_SET); } while (ftell(file) < fpos + size + children_size) { child = read_node(file); if (!child) continue; DL_APPEND(node->children, child); } // Set the parents. DL_FOREACH(node->children, child) { for (i = 0; i < child->nb_children; i++) { DL_FOREACH(node->children, child2) { if (child2->node_id == child->children_ids[i]) { child2->parent = child; } } } } return node; error: free_node(node); return NULL; } static const node_t *tree_find_shape(const node_t *tree, int model_id) { const node_t *child, *ret; DL_FOREACH(tree->children, child) { if (node_is(child, "nSHP") && child->nshp.model_id == model_id) return child; ret = tree_find_shape(child, model_id); if (ret) return ret; } return NULL; } static void node_apply_mat(const node_t *node, float mat[4][4]) { float rot[4][4] = MAT4_IDENTITY; int i, j; if (node->parent) { node_apply_mat(node->parent, mat); } if (node_is(node, "nTRN") && node->ntrn.has_trans) { mat4_itranslate(mat, node->ntrn.trans[0], node->ntrn.trans[1], node->ntrn.trans[2]); } if (node_is(node, "nTRN") && node->ntrn.has_rot) { for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) { rot[i][j] = node->ntrn.rot[i][j]; } mat4_imul(mat, rot); } } static int import_layer(image_t *image, const node_t *size, const node_t *xyzi, const node_t *rgba, const node_t *tree, int model_id) { int i, x, y, z, c, pos[3]; layer_t *layer; uint8_t color[4]; mesh_iterator_t iter = {0}; const node_t *shape; float mat[4][4] = MAT4_IDENTITY; // Use the current layer for first shape, then create new layers. if (size == tree->children) layer = image->active_layer; else layer = image_add_layer(image, NULL); for (i = 0; i < xyzi->xyzi.nb; i++) { x = xyzi->xyzi.values[i * 4 + 0]; y = xyzi->xyzi.values[i * 4 + 1]; z = xyzi->xyzi.values[i * 4 + 2]; c = xyzi->xyzi.values[i * 4 + 3]; pos[0] = x - size->size.w / 2; pos[1] = y - size->size.h / 2; pos[2] = z - size->size.d / 2; if (!c) continue; // Not sure what c == 0 means. if (rgba) memcpy(color, rgba->rgba.values[c], 4); else hexcolor(VOX_DEFAULT_PALETTE[c], color); mesh_set_at(layer->mesh, &iter, pos, color); } // Apply the transformation. // XXX: would be better to properly support layer transformations! shape = tree_find_shape(tree, model_id); if (shape) { node_apply_mat(shape, mat); mesh_move(layer->mesh, mat); } return 0; } static int vox_import(image_t *image, const char *path) { FILE *file; char magic[4]; int r, i, version; node_t *tree, *size_n, *xyzi_n, *rgba_n; path = path ?: noc_file_dialog_open(NOC_FILE_DIALOG_OPEN, "vox\0*.vox\0", NULL, NULL); if (!path) return -1; file = fopen(path, "rb"); r = fread(magic, 1, 4, file); if (r != 4) FILE_ERROR("Cannot read file"); if (strncmp(magic, "VOX ", 4) != 0) { LOG_D("Old style magica voxel file"); fclose(file); return vox_import_old(path); } if (strncmp(magic, "VOX ", 4) != 0) FILE_ERROR("Wrong magic string"); version = READ(uint32_t, file); if (version != 150) LOG_W("Magica voxel file version %d!", version); tree = read_node(file); if (!tree) goto error; // Get the palette. DL_FOREACH(tree->children, rgba_n) { if (strncmp(rgba_n->id, "RGBA", 4) == 0) break; } // Create one layer for each ('size', 'xyzi') chunks in the main chunk. i = 0; DL_FOREACH(tree->children, size_n) { if (strncmp(size_n->id, "SIZE", 4) != 0) continue; xyzi_n = size_n->next; if (strncmp(xyzi_n->id, "XYZI", 4) != 0) continue; import_layer(image, size_n, xyzi_n, rgba_n, tree, i); i++; } free_node(tree); return 0; error: return -1; } static int get_color_index(uint8_t v[4], uint8_t (*palette)[4], bool exact) { const uint8_t *c; int i, dist, best = -1, best_dist = 1024; for (i = 1; i < 255; i++) { c = palette[i]; dist = abs((int)c[0] - (int)v[0]) + abs((int)c[1] - (int)v[1]) + abs((int)c[2] - (int)v[2]); if (dist == 0) return i; if (exact) continue; if (dist < best_dist) { best_dist = dist; best = i; } } return best; } static int voxel_cmp(const void *a_, const void *b_) { const uint8_t *a = a_; const uint8_t *b = b_; if (a[2] != b[2]) return cmp(a[2], b[2]); if (a[1] != b[1]) return cmp(a[1], b[1]); if (a[0] != b[0]) return cmp(a[0], b[0]); return 0; } static int vox_export(const image_t *image, const char *path) { FILE *file; int children_size, nb_vox = 0, i, pos[3]; int xmin = INT_MAX, ymin = INT_MAX, zmin = INT_MAX; int xmax = INT_MIN, ymax = INT_MIN, zmax = INT_MIN; uint8_t (*palette)[4]; bool use_default_palette = true; uint8_t *voxels; uint8_t v[4]; mesh_iterator_t iter; const mesh_t *mesh; mesh = goxel_get_layers_mesh(image); palette = calloc(256, sizeof(*palette)); for (i = 0; i < 256; i++) hexcolor(VOX_DEFAULT_PALETTE[i], palette[i]); // Iter all the voxels to get the count and the size. iter = mesh_get_iterator(mesh, MESH_ITER_VOXELS); while (mesh_iter(&iter, pos)) { mesh_get_at(mesh, &iter, pos, v); if (v[3] < 127) continue; v[3] = 255; use_default_palette = use_default_palette && get_color_index(v, palette, true) != -1; nb_vox++; xmin = min(xmin, pos[0]); ymin = min(ymin, pos[1]); zmin = min(zmin, pos[2]); xmax = max(xmax, pos[0] + 1); ymax = max(ymax, pos[1] + 1); zmax = max(zmax, pos[2] + 1); } if (!use_default_palette) quantization_gen_palette(mesh, 255, (void*)(palette + 1)); children_size = 12 + 4 * 3 + // SIZE chunk 12 + 4 + 4 * nb_vox + // XYZI chunk (use_default_palette ? 0 : (12 + 4 * 256)); // RGBA chunk. file = fopen(path, "wb"); fprintf(file, "VOX "); WRITE(uint32_t, 150, file); // Version fprintf(file, "MAIN"); WRITE(uint32_t, 0, file); // Main chunck size. WRITE(uint32_t, children_size, file); fprintf(file, "SIZE"); WRITE(uint32_t, 4 * 3, file); WRITE(uint32_t, 0, file); WRITE(uint32_t, xmax - xmin, file); WRITE(uint32_t, ymax - ymin, file); WRITE(uint32_t, zmax - zmin, file); fprintf(file, "XYZI"); WRITE(uint32_t, 4 * nb_vox + 4, file); WRITE(uint32_t, 0, file); WRITE(uint32_t, nb_vox, file); voxels = calloc(nb_vox, 4); i = 0; iter = mesh_get_iterator(mesh, MESH_ITER_VOXELS); while (mesh_iter(&iter, pos)) { mesh_get_at(mesh, &iter, pos, v); if (v[3] < 127) continue; pos[0] -= xmin; pos[1] -= ymin; pos[2] -= zmin; assert(pos[0] >= 0 && pos[0] < 255); assert(pos[1] >= 0 && pos[1] < 255); assert(pos[2] >= 0 && pos[2] < 255); voxels[i * 4 + 0] = pos[0]; voxels[i * 4 + 1] = pos[1]; voxels[i * 4 + 2] = pos[2]; voxels[i * 4 + 3] = get_color_index(v, palette, false); i++; } qsort(voxels, nb_vox, 4, voxel_cmp); for (i = 0; i < nb_vox; i++) fwrite(voxels + i * 4, 4, 1, file); free(voxels); if (!use_default_palette) { fprintf(file, "RGBA"); WRITE(uint32_t, 4 * 256, file); WRITE(uint32_t, 0, file); for (i = 1; i < 256; i++) { WRITE(uint8_t, palette[i][0], file); WRITE(uint8_t, palette[i][1], file); WRITE(uint8_t, palette[i][2], file); WRITE(uint8_t, palette[i][3], file); } WRITE(uint32_t, 0, file); } fclose(file); free(palette); return 0; } FILE_FORMAT_REGISTER(vox, .name = "Magica Voxel", .ext = "vox\0*.vox\0", .import_func = vox_import, .export_func = vox_export, ) static const uint32_t VOX_DEFAULT_PALETTE[256] = { 0x00000000, 0xffffffff, 0xffffccff, 0xffff99ff, 0xffff66ff, 0xffff33ff, 0xffff00ff, 0xffccffff, 0xffccccff, 0xffcc99ff, 0xffcc66ff, 0xffcc33ff, 0xffcc00ff, 0xff99ffff, 0xff99ccff, 0xff9999ff, 0xff9966ff, 0xff9933ff, 0xff9900ff, 0xff66ffff, 0xff66ccff, 0xff6699ff, 0xff6666ff, 0xff6633ff, 0xff6600ff, 0xff33ffff, 0xff33ccff, 0xff3399ff, 0xff3366ff, 0xff3333ff, 0xff3300ff, 0xff00ffff, 0xff00ccff, 0xff0099ff, 0xff0066ff, 0xff0033ff, 0xff0000ff, 0xccffffff, 0xccffccff, 0xccff99ff, 0xccff66ff, 0xccff33ff, 0xccff00ff, 0xccccffff, 0xccccccff, 0xcccc99ff, 0xcccc66ff, 0xcccc33ff, 0xcccc00ff, 0xcc99ffff, 0xcc99ccff, 0xcc9999ff, 0xcc9966ff, 0xcc9933ff, 0xcc9900ff, 0xcc66ffff, 0xcc66ccff, 0xcc6699ff, 0xcc6666ff, 0xcc6633ff, 0xcc6600ff, 0xcc33ffff, 0xcc33ccff, 0xcc3399ff, 0xcc3366ff, 0xcc3333ff, 0xcc3300ff, 0xcc00ffff, 0xcc00ccff, 0xcc0099ff, 0xcc0066ff, 0xcc0033ff, 0xcc0000ff, 0x99ffffff, 0x99ffccff, 0x99ff99ff, 0x99ff66ff, 0x99ff33ff, 0x99ff00ff, 0x99ccffff, 0x99ccccff, 0x99cc99ff, 0x99cc66ff, 0x99cc33ff, 0x99cc00ff, 0x9999ffff, 0x9999ccff, 0x999999ff, 0x999966ff, 0x999933ff, 0x999900ff, 0x9966ffff, 0x9966ccff, 0x996699ff, 0x996666ff, 0x996633ff, 0x996600ff, 0x9933ffff, 0x9933ccff, 0x993399ff, 0x993366ff, 0x993333ff, 0x993300ff, 0x9900ffff, 0x9900ccff, 0x990099ff, 0x990066ff, 0x990033ff, 0x990000ff, 0x66ffffff, 0x66ffccff, 0x66ff99ff, 0x66ff66ff, 0x66ff33ff, 0x66ff00ff, 0x66ccffff, 0x66ccccff, 0x66cc99ff, 0x66cc66ff, 0x66cc33ff, 0x66cc00ff, 0x6699ffff, 0x6699ccff, 0x669999ff, 0x669966ff, 0x669933ff, 0x669900ff, 0x6666ffff, 0x6666ccff, 0x666699ff, 0x666666ff, 0x666633ff, 0x666600ff, 0x6633ffff, 0x6633ccff, 0x663399ff, 0x663366ff, 0x663333ff, 0x663300ff, 0x6600ffff, 0x6600ccff, 0x660099ff, 0x660066ff, 0x660033ff, 0x660000ff, 0x33ffffff, 0x33ffccff, 0x33ff99ff, 0x33ff66ff, 0x33ff33ff, 0x33ff00ff, 0x33ccffff, 0x33ccccff, 0x33cc99ff, 0x33cc66ff, 0x33cc33ff, 0x33cc00ff, 0x3399ffff, 0x3399ccff, 0x339999ff, 0x339966ff, 0x339933ff, 0x339900ff, 0x3366ffff, 0x3366ccff, 0x336699ff, 0x336666ff, 0x336633ff, 0x336600ff, 0x3333ffff, 0x3333ccff, 0x333399ff, 0x333366ff, 0x333333ff, 0x333300ff, 0x3300ffff, 0x3300ccff, 0x330099ff, 0x330066ff, 0x330033ff, 0x330000ff, 0x00ffffff, 0x00ffccff, 0x00ff99ff, 0x00ff66ff, 0x00ff33ff, 0x00ff00ff, 0x00ccffff, 0x00ccccff, 0x00cc99ff, 0x00cc66ff, 0x00cc33ff, 0x00cc00ff, 0x0099ffff, 0x0099ccff, 0x009999ff, 0x009966ff, 0x009933ff, 0x009900ff, 0x0066ffff, 0x0066ccff, 0x006699ff, 0x006666ff, 0x006633ff, 0x006600ff, 0x0033ffff, 0x0033ccff, 0x003399ff, 0x003366ff, 0x003333ff, 0x003300ff, 0x0000ffff, 0x0000ccff, 0x000099ff, 0x000066ff, 0x000033ff, 0xee0000ff, 0xdd0000ff, 0xbb0000ff, 0xaa0000ff, 0x880000ff, 0x770000ff, 0x550000ff, 0x440000ff, 0x220000ff, 0x110000ff, 0x00ee00ff, 0x00dd00ff, 0x00bb00ff, 0x00aa00ff, 0x008800ff, 0x007700ff, 0x005500ff, 0x004400ff, 0x002200ff, 0x001100ff, 0x0000eeff, 0x0000ddff, 0x0000bbff, 0x0000aaff, 0x000088ff, 0x000077ff, 0x000055ff, 0x000044ff, 0x000022ff, 0x000011ff, 0xeeeeeeff, 0xddddddff, 0xbbbbbbff, 0xaaaaaaff, 0x888888ff, 0x777777ff, 0x555555ff, 0x444444ff, 0x222222ff, 0x111111ff, }; goxel-0.11.0/src/formats/voxlap.c000066400000000000000000000403211435762723100166400ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2016 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* * Support for KVX format, used by the Build engine (Shadow Warrior/Blood) * and KV6 format, used by Voxlap, Evaldraw. * From the great Ken Silvemans. */ #include "goxel.h" #include "file_format.h" /* * Structure that represents a single voxel and visible faces. * Used as an intermediate structure for export. */ typedef struct { int pos[3]; int color; int vis; } voxel_t; /* * Structure that represents a single slab, for export. */ typedef struct { int pos[3]; // Starting top position. uint8_t len; // Number of voxels in the slab. uint8_t vis; // Visible faces. uint8_t colors[256]; // Colors from top to bottom. } slab_t; #define READ(type, file) \ ({ type v; size_t r = fread(&v, sizeof(v), 1, file); (void)r; v;}) #define WRITE(type, v, file) \ ({ type v_ = v; fwrite(&v_, sizeof(v_), 1, file);}) #define raise(msg) do { \ LOG_E(msg); \ ret = -1; \ goto end; \ } while (0) static inline int AT(int x, int y, int z, int w, int h, int d) { y = h - y - 1; z = d - z - 1; return x + y * w + z * w * h; } static void swap_color(uint32_t v, uint8_t ret[4]) { uint8_t o[4]; memcpy(o, &v, 4); ret[0] = o[2]; ret[1] = o[1]; ret[2] = o[0]; ret[3] = o[3]; } static int kv6_import(image_t *image, const char *path) { FILE *file; char magic[4]; int i, r, ret = 0, w, h, d, blklen, x, y, z = 0, nb, p = 0; uint32_t *xoffsets = NULL; uint16_t *xyoffsets = NULL; uint8_t (*cube)[4] = NULL; uint8_t color[4] = {0}; (void)r; struct { uint32_t color; uint8_t zpos; uint8_t visface; } *blocks = NULL; file = fopen(path, "rb"); r = fread(magic, 1, 4, file); if (strncmp(magic, "Kvxl ", 4) != 0) raise("Invalid magic"); w = READ(uint32_t, file); h = READ(uint32_t, file); d = READ(uint32_t, file); cube = calloc(w * h * d, sizeof(*cube)); READ(float, file); READ(float, file); READ(float, file); blklen = READ(uint32_t, file); blocks = calloc(blklen, sizeof(*blocks)); for (i = 0; i < blklen; i++) { blocks[i].color = READ(uint32_t, file); blocks[i].zpos = READ(uint16_t, file); blocks[i].visface = READ(uint8_t, file); READ(uint8_t, file); // lighting } xoffsets = calloc(w, sizeof(*xoffsets)); xyoffsets = calloc(w * h, sizeof(*xyoffsets)); for (i = 0; i < w; i++) xoffsets[i] = READ(uint32_t, file); for (i = 0; i < w * h; i++) xyoffsets[i] = READ(uint16_t, file); for (x = 0; x < w; x++) for (y = 0; y < h; y++) { nb = xyoffsets[x * h + y]; for (i = 0; i < nb; i++, p++) { z = blocks[p].zpos; swap_color(blocks[p].color, cube[AT(x, y, z, w, h, d)]); } } // Fill p = 0; for (x = 0; x < w; x++) for (y = 0; y < h; y++) { nb = xyoffsets[x * h + y]; for (i = 0; i < nb; i++, p++) { if (blocks[p].visface & 0x10) { z = blocks[p].zpos; swap_color(blocks[p].color, color); color[3] = 255; } if (blocks[p].visface & 0x20) { for (; z < blocks[p].zpos; z++) if (cube[AT(x, y, z, w, h, d)][3] == 0) memcpy(cube[AT(x, y, z, w, h, d)], color, 4); } } } mesh_blit(image->active_layer->mesh, (const uint8_t*)cube, -w / 2, -h / 2, -d / 2, w, h, d, NULL); end: free(cube); free(blocks); free(xoffsets); free(xyoffsets); fclose(file); return ret; } static int kvx_import(image_t *image, const char *path) { FILE *file; int i, r, ret = 0, nb, size, lastz = 0, len, visface; int w, h, d, px, py, pz, x, y, z; int offsetsize, voxdatasize; int aabb[2][3]; uint8_t color = 0; uint8_t (*palette)[4] = NULL; uint32_t *xoffsets = NULL; uint16_t *xyoffsets = NULL; uint8_t (*cube)[4] = NULL; long datpos; (void)r; path = path ?: noc_file_dialog_open(NOC_FILE_DIALOG_OPEN, "kvx\0*.kvx\0", NULL, NULL); if (!path) return -1; file = fopen(path, "rb"); size = READ(uint32_t, file); w = READ(uint32_t, file); h = READ(uint32_t, file); d = READ(uint32_t, file); cube = calloc(w * h * d, sizeof(*cube)); px = READ(uint32_t, file) / 256; py = READ(uint32_t, file) / 256; pz = READ(uint32_t, file) / 256; xoffsets = calloc(w + 1, sizeof(*xoffsets)); xyoffsets = calloc(w * (h + 1), sizeof(*xyoffsets)); for (i = 0; i < w + 1; i++) xoffsets[i] = READ(uint32_t, file); for (i = 0; i < w * (h + 1); i++) xyoffsets[i] = READ(uint16_t, file); // Make sure the final x offset points pass the end the voxel data. // Just a warning for the moment. offsetsize = (w + 1) * 4 + w * (h + 1) * 2; voxdatasize = size - 24 - offsetsize; if (xoffsets[w] != offsetsize + voxdatasize) LOG_W("Invalide kvx file"); datpos = ftell(file); // Read the palette at the end of the file first. fseek(file, -256 * 3, SEEK_END); palette = calloc(256, sizeof(*palette)); for (i = 0; i < 256; i++) { palette[i][0] = clamp(round(READ(uint8_t, file) * 255 / 63.f), 0, 255); palette[i][1] = clamp(round(READ(uint8_t, file) * 255 / 63.f), 0, 255); palette[i][2] = clamp(round(READ(uint8_t, file) * 255 / 63.f), 0, 255); palette[i][3] = 255; } fseek(file, datpos, SEEK_SET); for (x = 0; x < w; x++) for (y = 0; y < h; y++) { if (xyoffsets[x * (h + 1) + y + 1] < xyoffsets[x * (h + 1) + y]) raise("Invalid format"); nb = xyoffsets[x * (h + 1) + y + 1] - xyoffsets[x * (h + 1) + y]; while (nb > 0) { z = READ(uint8_t, file); len = READ(uint8_t, file); visface = READ(uint8_t, file); assert(z + len - 1 < d); for (i = 0; i < len; i++) { color = READ(uint8_t, file); memcpy(cube[AT(x, y, z + i, w, h, d)], palette[color], 4); } nb -= len + 3; /* KVX format only saves the visible voxels. Since we have the * face information, we can fill the gaps ourself between * top visible and bottom visible voxels. * Note: this should be an option. */ if (visface & 0x10) lastz = z + len; if (visface & 0x20) { for (i = lastz; i < z; i++) { if (cube[AT(x, y, i, w, h, d)][3] == 0) { memcpy(cube[AT(x, y, i, w, h, d)], palette[color], 4); } } } } } vec3_set(aabb[0], -px, -py, pz - d); vec3_set(aabb[1], w - px, h - py, pz); bbox_from_aabb(image->box, aabb); bbox_from_aabb(image->active_layer->box, aabb); mesh_blit(image->active_layer->mesh, (uint8_t*)cube, -px, -py, pz - d, w, h, d, NULL); end: free(palette); free(cube); free(xoffsets); free(xyoffsets); fclose(file); return ret; } static int get_color_index(uint8_t v[4], uint8_t (*palette)[4], bool exact) { const uint8_t *c; int i, dist, best = -1, best_dist = 1024; for (i = 1; i < 255; i++) { c = palette[i]; dist = abs((int)c[0] - (int)v[0]) + abs((int)c[1] - (int)v[1]) + abs((int)c[2] - (int)v[2]); if (dist == 0) return i; if (exact) continue; if (dist < best_dist) { best_dist = dist; best = i; } } return best; } // Sort the voxels as they appear in the slabs. static int voxel_cmp(const void *a_, const void *b_) { const voxel_t *a = (void*)a_; const voxel_t *b = (void*)b_; return cmp(a->pos[0], b->pos[0]) ?: cmp(a->pos[1], b->pos[1]) ?: cmp(a->pos[2], b->pos[2]); } /* * Attempt to add a voxel into a slab, return true for success. */ static bool slab_append(slab_t *slab, voxel_t *vox) { if (slab->vis & 32) return false; // Slab already finished. if (slab->len == 255) return false; // No more space. if (slab->len == 0) { memcpy(slab->pos, vox->pos, sizeof(slab->pos)); slab->vis = vox->vis; } if ( vox->pos[0] != slab->pos[0] || vox->pos[1] != slab->pos[1] || vox->pos[2] != slab->pos[2] + slab->len) return false; // All the vertical faces should have the same visibility. if ((vox->vis & 15) != (slab->vis & 15)) return false; slab->vis |= (vox->vis & 32); // Add bottom face if needed. slab->colors[slab->len++] = vox->color; return true; } static int kvx_export(const image_t *image, const char *path) { FILE *file; uint8_t (*palette)[4]; mesh_iterator_t iter; mesh_accessor_t acc; uint8_t v[4]; float box[4][4]; int pos[3], size[3], orig[3], x, y, i; UT_array *slabs; UT_array *voxels; slab_t *slab; voxel_t voxel, *vox; uint32_t ofs; uint32_t *xoffsets; uint32_t *xyoffsets; bool use_current_palette = false; float pivot[3]; const mesh_t *mesh = goxel_get_layers_mesh(image); UT_icd voxel_icd = {sizeof(voxel_t), NULL, NULL, NULL}; UT_icd slab_icd = {sizeof(slab_t), NULL, NULL, NULL}; mat4_copy(image->box, box); if (box_is_null(box)) mesh_get_box(mesh, true, box); size[0] = box[0][0] * 2; size[1] = box[1][1] * 2; size[2] = box[2][2] * 2; orig[0] = box[3][0] - box[0][0]; orig[1] = box[3][1] - box[1][1]; orig[2] = box[3][2] - box[2][2]; file = fopen(path, "wb"); // If the current palette is enough to export the model, use it, else // create a palette. if (goxel.palette->size == 256) { use_current_palette = true; iter = mesh_get_iterator(mesh, MESH_ITER_VOXELS); while (mesh_iter(&iter, pos)) { mesh_get_at(mesh, &iter, pos, v); if (v[3] < 127) continue; if (palette_search(goxel.palette, v, true) < 0) { use_current_palette = false; break; } } } palette = calloc(256, sizeof(*palette)); if (use_current_palette) { LOG_I("Using the current palette"); for (i = 0; i < 256; i++) { memcpy(palette[i], goxel.palette->entries[i].color, 4); } } else { quantization_gen_palette(mesh, 256, (void*)(palette)); } // Iter the voxels and only keep the visible ones, plus the visible // faces mask. Put them all into an array. utarray_new(voxels, &voxel_icd); iter = mesh_get_iterator(mesh, MESH_ITER_VOXELS | MESH_ITER_SKIP_EMPTY); acc = mesh_get_accessor(mesh); while (mesh_iter(&iter, voxel.pos)) { mesh_get_at(mesh, &iter, voxel.pos, v); if (v[3] < 127) continue; // XXX: we should be able to use box iterator instead of this, // but for some reason it doesn't work! if (!bbox_contains_vec(box, (float[]){voxel.pos[0], voxel.pos[1], voxel.pos[2]})) continue; // Compute visible face mask. voxel.vis = 0; #define vis_test(x, y, z) \ (mesh_get_alpha_at(mesh, &acc, (int[]){voxel.pos[0] + (x), \ voxel.pos[1] + (y), \ voxel.pos[2] + (z)}) < 127) if (vis_test(-1, 0, 0)) voxel.vis |= 1; if (vis_test(+1, 0, 0)) voxel.vis |= 2; if (vis_test( 0, +1, 0)) voxel.vis |= 4; if (vis_test( 0, -1, 0)) voxel.vis |= 8; if (vis_test( 0, 0, +1)) voxel.vis |= 16; if (vis_test( 0, 0, -1)) voxel.vis |= 32; #undef vis_test if (!voxel.vis) continue; // No visible faces. voxel.color = get_color_index(v, palette, false); voxel.pos[0] -= orig[0]; voxel.pos[1] -= orig[1]; voxel.pos[2] -= orig[2]; voxel.pos[1] = size[1] - voxel.pos[1] - 1; voxel.pos[2] = size[2] - voxel.pos[2] - 1; assert(voxel.pos[0] >= 0 && voxel.pos[0] < size[0]); assert(voxel.pos[1] >= 0 && voxel.pos[1] < size[1]); assert(voxel.pos[2] >= 0 && voxel.pos[2] < size[2]); utarray_push_back(voxels, &voxel); } // Sort the voxels by xy columns in order they will be in the slabs. utarray_sort(voxels, voxel_cmp); // Iter the voxels and generates the slabs array. utarray_new(slabs, &slab_icd); utarray_extend_back(slabs); // Add an initial slab. for (vox = (void*)utarray_front(voxels); vox; vox = (void*)utarray_next(voxels, vox)) { slab = (void*)utarray_back(slabs); if (slab_append(slab, vox)) continue; // Finished a slab, create a new one. utarray_extend_back(slabs); // Add a new slab. slab = (void*)utarray_back(slabs); slab_append(slab, vox); // Always works. } // Compute xoffsets and xyoffsetx. // Can we do it in a simpler way? xoffsets = calloc(size[0] + 1, sizeof(*xoffsets)); xyoffsets = calloc(size[0] * (size[1] + 1), sizeof(*xyoffsets)); ofs = (size[0] + 1) * 4 + size[0] * (size[1] + 1) * 2; xoffsets[0] = ofs; ofs = (size[0] + 1) * 4 + size[0] * (size[1] + 1) * 2; slab = (void*)utarray_front(slabs); for (x = 0; x < size[0]; x++) { while (slab && slab->pos[0] <= x) { ofs += 3 + slab->len; slab = (void*)utarray_next(slabs, slab); } xoffsets[x + 1] = ofs; } ofs = (size[0] + 1) * 4 + size[0] * (size[1] + 1) * 2; slab = (void*)utarray_front(slabs); for (x = 0; x < size[0]; x++) { xyoffsets[x * (size[1] + 1)] = 0; for (y = 0; y < size[1]; y++) { while (slab && slab->pos[0] <= x && slab->pos[1] <= y) { ofs += 3 + slab->len; slab = (void*)utarray_next(slabs, slab); } xyoffsets[x * (size[1] + 1) + y + 1] = ofs - xoffsets[x]; } } // Now we have all the data ready to be saved. // The byte size is the last x offset plus the header size (24). WRITE(uint32_t, xoffsets[size[0]] + 24, file); WRITE(uint32_t, size[0], file); WRITE(uint32_t, size[1], file); WRITE(uint32_t, size[2], file); pivot[0] = -orig[0] + (size[0] % 2) / 2.; pivot[1] = -orig[1] + (size[1] % 2) / 2.; pivot[2] = size[2] - orig[2]; WRITE(int32_t, (int)(pivot[0] * 256), file); WRITE(int32_t, (int)(pivot[1] * 256), file); WRITE(int32_t, (int)(pivot[2] * 256), file); for (i = 0; i < size[0] + 1; i++) WRITE(uint32_t, xoffsets[i], file); for (i = 0; i < size[0] * (size[1] + 1); i++) WRITE(uint16_t, xyoffsets[i], file); for (slab = (void*)utarray_front(slabs); slab; slab = (void*)utarray_next(slabs, slab)) { assert(slab->pos[2] >= 0); assert(slab->pos[2] <= 255); assert(slab->pos[2] + slab->len - 1 < size[2]); WRITE(uint8_t, slab->pos[2], file); WRITE(uint8_t, slab->len, file); WRITE(uint8_t, slab->vis, file); fwrite(slab->colors, 1, slab->len, file); } for (i = 0; i < 256; i++) { WRITE(uint8_t, palette[i][0] / 4, file); WRITE(uint8_t, palette[i][1] / 4, file); WRITE(uint8_t, palette[i][2] / 4, file); } utarray_free(slabs); utarray_free(voxels); free(xoffsets); free(xyoffsets); free(palette); fclose(file); return 0; } FILE_FORMAT_REGISTER(kv6, .name = "kv6", .ext = "slab\0*.kv6\0", .import_func = kv6_import, ) FILE_FORMAT_REGISTER(kvx, .name = "kvx", .ext = "slab\0*.kvx\0", .import_func = kvx_import, .export_func = kvx_export, ) goxel-0.11.0/src/formats/vxl.c000066400000000000000000000216371435762723100161510ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2016 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ // Support for Ace of Spades map files (vxl) #include "goxel.h" #include "file_format.h" #define READ(type, file) \ ({ type v; size_t r = fread(&v, sizeof(v), 1, file); (void)r; v;}) #define raise(msg) do { \ LOG_E(msg); \ ret = -1; \ goto end; \ } while (0) static inline int AT(int x, int y, int z, int d) { x = 511 - x; z = d - 1 - z; return x + y * 512 + z * 512 * 512; } static void swap_color(uint32_t v, uint8_t ret[4]) { uint8_t o[4]; memcpy(o, &v, 4); ret[0] = o[2]; ret[1] = o[1]; ret[2] = o[0]; ret[3] = o[3]; } /* * Get the max height of a vlx file. */ static int vxl_get_d(const uint8_t *data, int size) { int w = 512, h = 512, d = 64, x, y; const uint8_t *v; int number_4byte_chunks; int top_color_start; int top_color_end; int len_bottom; v = data; for (y = 0; y < h; y++) for (x = 0; x < w; x++) { while (true) { number_4byte_chunks = v[0]; top_color_start = v[1]; top_color_end = v[2]; d = max(d, top_color_end + 1); len_bottom = top_color_end - top_color_start + 1; if (number_4byte_chunks == 0) { v += 4 * (len_bottom + 1); break; } v += v[0] * 4; } } return d; } static int vxl_import(image_t *image, const char *path) { // The algo is based on // https://silverspaceship.com/aosmap/aos_file_format.html // From Sean Barrett (the same person that wrote the code used in // ext_src/stb!). int ret = 0, size; int w = 512, h = 512, d = 64, x, y, z; uint8_t (*cube)[4] = NULL; uint8_t *data, *v; uint32_t *color; int i; int number_4byte_chunks; int top_color_start; int top_color_end; int bottom_color_start; int bottom_color_end; // exclusive int len_top; int len_bottom; if (!path) return -1; data = (void*)read_file(path, &size); d = vxl_get_d(data, size); cube = calloc(w * h * d, sizeof(*cube)); v = data; for (y = 0; y < h; y++) for (x = 0; x < w; x++) { for (z = 0; z < d; z++) cube[AT(x, y, z, d)][3] = 255; z = 0; while (true) { number_4byte_chunks = v[0]; top_color_start = v[1]; top_color_end = v[2]; for (i = z; i < top_color_start; i++) cube[AT(x, y, i, d)][3] = 0; color = (uint32_t*)(v + 4); for (z = top_color_start; z <= top_color_end; z++) { CHECK(z >= 0 && z < d); swap_color(*color++, cube[AT(x, y, z, d)]); } len_bottom = top_color_end - top_color_start + 1; // check for end of data marker if (number_4byte_chunks == 0) { // infer ACTUAL number of 4-byte chunks from the length of the // color data v += 4 * (len_bottom + 1); break; } // infer the number of bottom colors in next span from chunk length len_top = (number_4byte_chunks-1) - len_bottom; // now skip the v pointer past the data to the beginning of the // next span v += v[0] * 4; bottom_color_end = v[3]; // aka air start bottom_color_start = bottom_color_end - len_top; for(z = bottom_color_start; z < bottom_color_end; z++) swap_color(*color++, cube[AT(x, y, z, d)]); } } mesh_blit(image->active_layer->mesh, (uint8_t*)cube, -w / 2, -h / 2, -d / 2, w, h, d, NULL); if (box_is_null(image->box)) { bbox_from_extents(image->box, vec3_zero, w / 2, h / 2, d / 2); } free(cube); free(data); return ret; } static int is_surface(int x, int y, int z, uint8_t map[512][512][64]) { if (map[x][y][z]==0) return 0; if (x == 0 || x == 511) return 1; if (y == 0 || y == 511) return 1; if (z == 0 || z == 63) return 1; if (x > 0 && map[x-1][y][z]==0) return 1; if (x+1 < 512 && map[x+1][y][z]==0) return 1; if (y > 0 && map[x][y-1][z]==0) return 1; if (y+1 < 512 && map[x][y+1][z]==0) return 1; if (z > 0 && map[x][y][z-1]==0) return 1; if (z+1 < 64 && map[x][y][z+1]==0) return 1; return 0; } static void write_color(FILE *f, uint32_t color) { uint8_t c[4]; memcpy(c, &color, 4); fputc(c[2], f); fputc(c[1], f); fputc(c[0], f); fputc(c[3], f); } #define MAP_Z 64 void write_map(const char *filename, uint8_t map[512][512][64], uint32_t color[512][512][64]) { int i,j,k; FILE *f = fopen(filename, "wb"); for (j = 0; j < 512; ++j) { for (i=0; i < 512; ++i) { k = 0; while (k < MAP_Z) { int z; int air_start; int top_colors_start; int top_colors_end; // exclusive int bottom_colors_start; int bottom_colors_end; // exclusive int top_colors_len; int bottom_colors_len; int colors; // find the air region air_start = k; while (k < MAP_Z && !map[i][j][k]) ++k; // find the top region top_colors_start = k; while (k < MAP_Z && is_surface(i,j,k,map)) ++k; top_colors_end = k; // now skip past the solid voxels while (k < MAP_Z && map[i][j][k] && !is_surface(i,j,k,map)) ++k; // at the end of the solid voxels, we have colored voxels. // in the "normal" case they're bottom colors; but it's // possible to have air-color-solid-color-solid-color-air, // which we encode as air-color-solid-0, 0-color-solid-air // so figure out if we have any bottom colors at this point bottom_colors_start = k; z = k; while (z < MAP_Z && is_surface(i,j,z,map)) ++z; if (z == MAP_Z || 0) ; // in this case, the bottom colors of this span are // empty, because we'l emit as top colors else { // otherwise, these are real bottom colors so we can write // them while (is_surface(i,j,k,map)) ++k; } bottom_colors_end = k; // now we're ready to write a span top_colors_len = top_colors_end - top_colors_start; bottom_colors_len = bottom_colors_end - bottom_colors_start; colors = top_colors_len + bottom_colors_len; if (k == MAP_Z) fputc(0,f); // last span else fputc(colors+1, f); fputc(top_colors_start, f); fputc(top_colors_end-1, f); fputc(air_start, f); for (z=0; z < top_colors_len; ++z) write_color(f, color[i][j][top_colors_start + z]); for (z=0; z < bottom_colors_len; ++z) write_color(f, color[i][j][bottom_colors_start + z]); } } } fclose(f); } static int export_as_vxl(const image_t *image, const char *path) { uint8_t (*map)[512][512][64]; uint32_t (*color)[512][512][64]; const mesh_t *mesh = goxel_get_layers_mesh(image); mesh_iterator_t iter = {0}; uint8_t c[4]; int x, y, z, pos[3]; assert(path); map = calloc(1, sizeof(*map)); color = calloc(1, sizeof(*color)); for (z = 0; z < 64; z++) for (y = 0; y < 512; y++) for (x = 0; x < 512; x++) { pos[0] = 256 - x; pos[1] = y - 256; pos[2] = 31 - z; mesh_get_at(mesh, &iter, pos, c); if (c[3] <= 127) continue; (*map)[x][y][z] = 1; memcpy(&((*color)[x][y][z]), c, 4); } write_map(path, *map, *color); free(map); free(color); return 0; } FILE_FORMAT_REGISTER(vxl, .name = "vxl", .ext = "vxl\0*.vxl\0", .import_func = vxl_import, .export_func = export_as_vxl, ) goxel-0.11.0/src/formats/wavefront.c000066400000000000000000000173071435762723100173520ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "file_format.h" typedef struct { union { struct { float v[3]; uint8_t c[3]; }; float vn[3]; struct { int vs[4]; int vns[4]; }; }; } line_t; static UT_icd line_icd = {sizeof(line_t), NULL, NULL, NULL}; static int lines_find(UT_array *lines, const line_t *line, int search_nb) { int i, len; line_t *l; len = utarray_len(lines); for (i = len - 1; (i >= 0) && (i > len - 1 - search_nb); i--) { l = (line_t*)utarray_eltptr(lines, i); if (memcmp(l, line, sizeof(*line)) == 0) return i + 1; } return 0; } /* * Function: lines_add * Add a line entry into a list and return its index. * * Parameters: * lines - The list. * line - The new line we want to add. * search_nb - How far into the list we search for a similar line. If * a similar line is found we just return its index insead * of adding a new one. */ static int lines_add(UT_array *lines, const line_t *line, int search_nb) { int idx; idx = lines_find(lines, line, search_nb); if (idx) return idx; utarray_push_back(lines, line); return utarray_len(lines); } static int export(const mesh_t *mesh, const char *path, bool ply) { // XXX: Merge faces that can be merged into bigger ones. // Allow to chose between quads or triangles. // Also export mlt file for the colors. voxel_vertex_t* verts; float v[3]; uint8_t c[3]; int nb_elems, i, j, bpos[3]; float mat[4][4]; FILE *out; const int N = BLOCK_SIZE; int size = 0, subdivide; UT_array *lines_f, *lines_v, *lines_vn; line_t line, face, *line_ptr = NULL; mesh_iterator_t iter; utarray_new(lines_f, &line_icd); utarray_new(lines_v, &line_icd); utarray_new(lines_vn, &line_icd); verts = calloc(N * N * N * 6 * 4, sizeof(*verts)); face = (line_t){}; iter = mesh_get_iterator(mesh, MESH_ITER_BLOCKS | MESH_ITER_INCLUDES_NEIGHBORS); while (mesh_iter(&iter, bpos)) { mat4_set_identity(mat); mat4_itranslate(mat, bpos[0], bpos[1], bpos[2]); nb_elems = mesh_generate_vertices(mesh, bpos, goxel.rend.settings.effects, verts, &size, &subdivide); for (i = 0; i < nb_elems; i++) { // Put the vertices. for (j = 0; j < size; j++) { v[0] = verts[i * size + j].pos[0] / (float)subdivide; v[1] = verts[i * size + j].pos[1] / (float)subdivide; v[2] = verts[i * size + j].pos[2] / (float)subdivide; mat4_mul_vec3(mat, v, v); memcpy(c, verts[i * size + j].color, 3); line = (line_t){ .v = {v[0], v[1], v[2]}, .c = {c[0], c[1], c[2]}}; // XXX: not sure about the search nb value to use here. face.vs[j] = lines_add(lines_v, &line, 1024); } // Put the normals for (j = 0; j < size; j++) { v[0] = verts[i * size + j].normal[0]; v[1] = verts[i * size + j].normal[1]; v[2] = verts[i * size + j].normal[2]; line = (line_t){.vn = {v[0], v[1], v[2]}}; face.vns[j] = lines_add(lines_vn, &line, 512); } lines_add(lines_f, &face, 0); } } out = fopen(path, "w"); if (ply) { fprintf(out, "ply\n"); fprintf(out, "format ascii 1.0\n"); fprintf(out, "comment Generated from Goxel " GOXEL_VERSION_STR "\n"); fprintf(out, "element vertex %d\n", utarray_len(lines_v)); fprintf(out, "property float x\n"); fprintf(out, "property float y\n"); fprintf(out, "property float z\n"); fprintf(out, "property float red\n"); fprintf(out, "property float green\n"); fprintf(out, "property float blue\n"); fprintf(out, "element face %d\n", utarray_len(lines_f)); fprintf(out, "property list uchar int vertex_indices\n"); fprintf(out, "end_header\n"); while( (line_ptr = (line_t*)utarray_next(lines_v, line_ptr))) { fprintf(out, "%g %g %g %f %f %f\n", line_ptr->v[0], line_ptr->v[1], line_ptr->v[2], line_ptr->c[0] / 255., line_ptr->c[1] / 255., line_ptr->c[2] / 255.); } while( (line_ptr = (line_t*)utarray_next(lines_f, line_ptr))) { if (size == 4) { fprintf(out, "4 %d %d %d %d\n", line_ptr->vs[0] - 1, line_ptr->vs[1] - 1, line_ptr->vs[2] - 1, line_ptr->vs[3] - 1); } else { fprintf(out, "3 %d %d %d\n", line_ptr->vs[0] - 1, line_ptr->vs[1] - 1, line_ptr->vs[2] - 1); } } } else { fprintf(out, "# Goxel " GOXEL_VERSION_STR "\n"); while( (line_ptr = (line_t*)utarray_next(lines_v, line_ptr))) { fprintf(out, "v %g %g %g %f %f %f\n", line_ptr->v[0], line_ptr->v[1], line_ptr->v[2], line_ptr->c[0] / 255., line_ptr->c[1] / 255., line_ptr->c[2] / 255.); } while( (line_ptr = (line_t*)utarray_next(lines_vn, line_ptr))) { fprintf(out, "vn %g %g %g\n", line_ptr->vn[0], line_ptr->vn[1], line_ptr->vn[2]); } while( (line_ptr = (line_t*)utarray_next(lines_f, line_ptr))) { if (size == 4) { fprintf(out, "f %d//%d %d//%d %d//%d %d//%d\n", line_ptr->vs[0], line_ptr->vns[0], line_ptr->vs[1], line_ptr->vns[1], line_ptr->vs[2], line_ptr->vns[2], line_ptr->vs[3], line_ptr->vns[3]); } else { fprintf(out, "f %d//%d %d//%d %d//%d\n", line_ptr->vs[0], line_ptr->vns[0], line_ptr->vs[1], line_ptr->vns[1], line_ptr->vs[2], line_ptr->vns[2]); } } } fclose(out); utarray_free(lines_f); utarray_free(lines_v); utarray_free(lines_vn); free(verts); return 0; } static int wavefront_export(const image_t *image, const char *path) { const mesh_t *mesh = goxel_get_layers_mesh(image); return export(mesh, path, false); } int ply_export(const image_t *image, const char *path) { const mesh_t *mesh = goxel_get_layers_mesh(image); return export(mesh, path, true); } FILE_FORMAT_REGISTER(obj, .name = "obj", .ext = "obj\0*.obj\0", .export_func = wavefront_export, ) FILE_FORMAT_REGISTER(ply, .name = "ply", .ext = "ply\0*.ply\0", .export_func = ply_export, ) goxel-0.11.0/src/gesture.c000066400000000000000000000166211435762723100153400ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" // Still experimental gestures manager. // XXX: this value should be set depending on the screen resolution. static float g_start_dist = 8; static bool test_button(const inputs_t *inputs, const touch_t *touch, int mask) { if (mask & GESTURE_SHIFT && !inputs->keys[KEY_LEFT_SHIFT]) return false; if (mask & GESTURE_CTRL && !inputs->keys[KEY_CONTROL]) return false; if ((mask & GESTURE_LMB) && !touch->down[0]) return false; if ((mask & GESTURE_MMB) && !touch->down[1]) return false; if ((mask & GESTURE_RMB) && !touch->down[2]) return false; return true; } static bool rect_contains(const float rect[4], const float pos[2]) { return pos[0] >= rect[0] && pos[0] < rect[0] + rect[2] && pos[1] >= rect[1] && pos[1] < rect[1] + rect[3]; } static float get_angle(const float a0[2], const float a1[2], const float b0[2], const float b1[2]) { float u[2], v[2], dot, det; vec2_sub(a1, a0, u); vec2_normalize(u, u); vec2_sub(b1, b0, v); vec2_normalize(v, v); dot = vec2_dot(u, v); det = vec2_cross(u, v); return atan2(det, dot); } static int update(gesture_t *gest, const inputs_t *inputs, int mask) { const touch_t *ts = inputs->touches; int nb_ts = 0; int i, j; for (i = 0; i < ARRAY_SIZE(inputs->touches); i++) { for (j = 0; j < ARRAY_SIZE(inputs->touches[i].down); j++) { if (ts[i].down[j]) { nb_ts++; break; } } } if (gest->type == GESTURE_DRAG) { switch (gest->state) { case GESTURE_POSSIBLE: if (nb_ts == 1 && test_button(inputs, &ts[0], gest->button)) { vec2_copy(ts[0].pos, gest->start_pos[0]); vec2_copy(gest->start_pos[0], gest->pos); vec2_copy(gest->start_pos[0], gest->last_pos); if (!rect_contains(gest->viewport, gest->pos)) { gest->state = GESTURE_FAILED; break; } gest->state = (mask & (GESTURE_CLICK | GESTURE_PINCH)) ? GESTURE_RECOGNISED : GESTURE_BEGIN; } break; case GESTURE_RECOGNISED: if (vec2_dist(gest->start_pos[0], ts[0].pos) >= g_start_dist) gest->state = GESTURE_BEGIN; if (nb_ts == 0) { gest->state = (!(mask & GESTURE_CLICK)) ? GESTURE_BEGIN : GESTURE_FAILED; } if (nb_ts > 1) gest->state = GESTURE_FAILED; break; case GESTURE_BEGIN: case GESTURE_UPDATE: vec2_copy(ts[0].pos, gest->pos); gest->state = GESTURE_UPDATE; if (!test_button(inputs, &ts[0], gest->button)) gest->state = GESTURE_END; break; } } if (gest->type == GESTURE_CLICK) { vec2_copy(ts[0].pos, gest->pos); switch (gest->state) { case GESTURE_POSSIBLE: if (test_button(inputs, &ts[0], gest->button)) { vec2_copy(ts[0].pos, gest->start_pos[0]); gest->state = GESTURE_RECOGNISED; } break; case GESTURE_RECOGNISED: if (!test_button(inputs, &ts[0], gest->button)) gest->state = GESTURE_TRIGGERED; break; } } if (gest->type == GESTURE_PINCH) { switch (gest->state) { case GESTURE_POSSIBLE: if (ts[0].down[0] && ts[1].down[0]) { gest->state = GESTURE_BEGIN; vec2_copy(ts[0].pos, gest->start_pos[0]); vec2_copy(ts[1].pos, gest->start_pos[1]); gest->pinch = 1; gest->rotation = 0; vec2_mix(ts[0].pos, ts[1].pos, 0.5, gest->pos); } break; case GESTURE_BEGIN: case GESTURE_UPDATE: gest->state = GESTURE_UPDATE; gest->pinch = vec2_dist(ts[0].pos, ts[1].pos) / vec2_dist(gest->start_pos[0], gest->start_pos[1]); gest->rotation = get_angle(gest->start_pos[0], gest->start_pos[1], ts[0].pos, ts[1].pos); vec2_mix(ts[0].pos, ts[1].pos, 0.5, gest->pos); if (!ts[0].down[0] || !ts[1].down[0]) gest->state = GESTURE_END; break; } } if (gest->type == GESTURE_HOVER) { switch (gest->state) { case GESTURE_POSSIBLE: if (DEFINED(GOXEL_MOBILE)) break; //Workaround. if (nb_ts == 0) { vec2_copy(ts[0].pos, gest->pos); if (rect_contains(gest->viewport, gest->pos)) { gest->state = GESTURE_BEGIN; } } break; case GESTURE_BEGIN: case GESTURE_UPDATE: vec2_copy(ts[0].pos, gest->pos); gest->state = rect_contains(gest->viewport, gest->pos) ? GESTURE_UPDATE : GESTURE_END; break; } } return 0; } int gesture_update(int nb, gesture_t *gestures[], const inputs_t *inputs, const float viewport[4], void *user) { int i, j, mask = 0; bool allup = true; // Set if all the mouse buttons are up. gesture_t *gest, *triggered = NULL; for (i = 0; allup && i < ARRAY_SIZE(inputs->touches); i++) { for (j = 0; allup && j < ARRAY_SIZE(inputs->touches[i].down); j++) { if (inputs->touches[i].down[j]) { allup = false; break; } } } for (i = 0; i < nb; i++) { gest = gestures[i]; if (gest->state == GESTURE_POSSIBLE) mask |= gest->type; } for (i = 0; i < nb; i++) { gest = gestures[i]; vec4_copy(viewport, gest->viewport); if ((gest->state == GESTURE_FAILED) && allup) { gest->state = GESTURE_POSSIBLE; } if (gest->state == GESTURE_END || gest->state == GESTURE_TRIGGERED) gest->state = GESTURE_POSSIBLE; update(gest, inputs, mask); if ( gest->state == GESTURE_BEGIN || gest->state == GESTURE_UPDATE || gest->state == GESTURE_END || gest->state == GESTURE_TRIGGERED) { gest->callback(gest, user); vec2_copy(gest->pos, gest->last_pos); triggered = gest; break; } } // If one gesture started, fail all the other gestures. if (triggered && triggered->state == GESTURE_BEGIN) { for (i = 0; i < nb; i++) { gest = gestures[i]; if (gest != triggered) gest->state = GESTURE_FAILED; } } return triggered ? 1 : 0; } goxel-0.11.0/src/gesture.h000066400000000000000000000062641435762723100153470ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* * Section: Mouse gestures * Detect 2d mouse or touch gestures. * * The way it works is that we have to create one instance of * per gesture we can recognise, and then use the * function to update their states and call the callback * functions of active gestures. */ /* XXX: This part of the code is not very clear */ #include "inputs.h" /* * Enum: GESTURE_TYPES * Define the different types of recognised gestures. * * GESTURE_DRAG - Click and drag the mouse. * GESTURE_CLICK - Single click. * GESTURE_PINCH - Two fingers pinch. * GESTURE_HOVER - Move the mouse without clicking. */ enum { GESTURE_DRAG = 1 << 0, GESTURE_CLICK = 1 << 1, GESTURE_PINCH = 1 << 2, GESTURE_HOVER = 1 << 3, }; /* * Enum: GESTURE_STATES * Define the states a gesture can be in. * * GESTURE_POSSIBLE - The gesture is not recognised yet (default state). * GESTURE_RECOGNISED - The gesture has been recognised. * GESTURE_BEGIN - The gesture has begun. * GESTURE_UPDATE - The gesture is in progress. * GESTURE_END - The testure has ended. * GESTURE_TRIGGERED - For click gestures: the gesture has occured. * GESTURE_FAILED - The gesture has failed. */ enum { GESTURE_POSSIBLE = 0, GESTURE_RECOGNISED, GESTURE_BEGIN, GESTURE_UPDATE, GESTURE_END, GESTURE_TRIGGERED, GESTURE_FAILED, }; enum { GESTURE_LMB = 1 << 0, GESTURE_MMB = 1 << 1, GESTURE_RMB = 1 << 2, GESTURE_SHIFT = 1 << 3, GESTURE_CTRL = 1 << 4, }; /* * Type: gesture_t * Structure used to handle a given gesture. */ typedef struct gesture gesture_t; struct gesture { int type; int button; int state; float viewport[4]; float pos[2]; float start_pos[2][2]; float last_pos[2]; float pinch; float rotation; int (*callback)(const gesture_t *gest, void *user); }; /* * Function: gesture_update * Update the state of a list of gestures, and call the gestures * callbacks as needed. * * Parameters: * nb - Number of gestures. * gestures - A pointer to an array of instances. * inputs - The inputs structure. * viewport - Current viewport rect. * user - User data pointer, passed to the callbacks. */ int gesture_update(int nb, gesture_t *gestures[], const inputs_t *inputs, const float viewport[4], void *user); goxel-0.11.0/src/gesture3d.c000066400000000000000000000062001435762723100155570ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" int gesture3d(gesture3d_t *gest, cursor_t *curs, void *user) { bool pressed = curs->flags & CURSOR_PRESSED; int r, ret = 0; const int btns_mask = CURSOR_CTRL; gest->cursor = curs; if (gest->state == GESTURE_FAILED && !pressed) gest->state = GESTURE_POSSIBLE; if (gest->type == GESTURE_DRAG) { switch (gest->state) { case GESTURE_POSSIBLE: if ((gest->buttons & btns_mask) != (curs->flags & btns_mask)) break; if (curs->snaped && pressed) gest->state = GESTURE_BEGIN; break; case GESTURE_BEGIN: case GESTURE_UPDATE: gest->state = GESTURE_UPDATE; if (!pressed) gest->state = GESTURE_END; break; } } if (gest->type == GESTURE_CLICK) { switch (gest->state) { case GESTURE_POSSIBLE: if (curs->snaped && !pressed) gest->state = GESTURE_RECOGNISED; break; case GESTURE_RECOGNISED: if ((gest->buttons & btns_mask) != (curs->flags & btns_mask)) break; if (curs->snaped && pressed) gest->state = GESTURE_TRIGGERED; break; } } if (!DEFINED(GOXEL_MOBILE) && gest->type == GESTURE_HOVER) { switch (gest->state) { case GESTURE_POSSIBLE: if ((gest->buttons & btns_mask) != (curs->flags & btns_mask)) break; if (curs->snaped && !pressed && !(curs->flags & CURSOR_OUT)) gest->state = GESTURE_BEGIN; break; case GESTURE_BEGIN: case GESTURE_UPDATE: gest->state = GESTURE_UPDATE; if ((gest->buttons & btns_mask) != (curs->flags & btns_mask)) gest->state = GESTURE_END; if (pressed) gest->state = GESTURE_END; if (curs->flags & CURSOR_OUT) gest->state = GESTURE_END; break; } } if ( gest->state == GESTURE_BEGIN || gest->state == GESTURE_UPDATE || gest->state == GESTURE_END || gest->state == GESTURE_TRIGGERED) { r = gest->callback(gest, user); if (r == GESTURE_FAILED) { gest->state = GESTURE_FAILED; ret = 0; } else { ret = gest->state; } } if (gest->state == GESTURE_END || gest->state == GESTURE_TRIGGERED) gest->state = GESTURE_POSSIBLE; return ret; } goxel-0.11.0/src/gesture3d.h000066400000000000000000000031571435762723100155740ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef GESTURE3D_H #define GESTURE3D_H typedef struct gesture3d gesture3d_t; // Represent a 3d cursor. // The program keeps track of two cursors, that are then used by the tools. enum { // The state flags of the cursor. CURSOR_PRESSED = 1 << 0, CURSOR_SHIFT = 1 << 1, CURSOR_CTRL = 1 << 2, CURSOR_OUT = 1 << 3, // Outside of sensing area. }; typedef struct cursor { float pos[3]; float normal[3]; int snap_mask; int snaped; int flags; // Union of CURSOR_* values. float snap_offset; // XXX: fix this. } cursor_t; // #### 3d gestures struct gesture3d { int type; int state; int buttons; // CURSOR_SHIFT | CURSOR_CTRL cursor_t *cursor; int (*callback)(gesture3d_t *gest, void *user); }; int gesture3d(gesture3d_t *gest, cursor_t *curs, void *user); #endif // GESTURE3D_H goxel-0.11.0/src/glew-mx.h000066400000000000000000000024671435762723100152520ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* This file is only here to be included by cycles ! */ #define GL_GLEXT_PROTOTYPES #ifdef WIN32 # include # include "GL/glew.h" #endif #ifdef __APPLE__ # include "TargetConditionals.h" # if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR # define GLES2 1 # include # include # else # include # endif #else # ifdef GLES2 # include # include # else # include # endif #endif #ifndef GLEW_VERSION_1_5 # define GLEW_VERSION_1_5 0 #endif goxel-0.11.0/src/goxel.c000066400000000000000000001251031435762723100147740ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015-2022 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "xxhash.h" #include "file_format.h" #include "shader_cache.h" #include // The global goxel instance. goxel_t goxel = {}; texture_t *texture_new_image(const char *path, int flags) { char *data; uint8_t *img; bool need_to_free = false; int size; int w, h, bpp = 0; texture_t *tex; if (str_startswith(path, "asset://")) { data = (char*)assets_get(path, &size); } else { data = read_file(path, &size); need_to_free = true; } img = img_read_from_mem(data, size, &w, &h, &bpp); tex = texture_new_from_buf(img, w, h, bpp, flags); tex->path = strdup(path); free(img); if (need_to_free) free(data); return tex; } static void unpack_pos_data(uint32_t v, int pos[3], int *face, int *cube_id) { assert(BLOCK_SIZE == 16); int x, y, z, f, i; x = v >> 28; y = (v >> 24) & 0x0f; z = (v >> 20) & 0x0f; f = (v >> 16) & 0x0f; i = v & 0xffff; assert(f < 6); pos[0] = x; pos[1] = y; pos[2] = z; *face = f; *cube_id = i; } // Conveniance function to add a char in the inputs. void inputs_insert_char(inputs_t *inputs, uint32_t c) { int i; if (c > 0 && c < 0x10000) { for (i = 0; i < ARRAY_SIZE(inputs->chars); i++) { if (!inputs->chars[i]) { inputs->chars[i] = c; break; } } } } static camera_t *get_camera(void) { if (!goxel.image->cameras) image_add_camera(goxel.image, NULL); if (goxel.image->active_camera) return goxel.image->active_camera; return goxel.image->cameras; } // XXX: lot of cleanup to do here. static bool goxel_unproject_on_plane( const float viewport[4], const float pos[2], const float plane[4][4], float out[3], float normal[3]) { // If the angle between the screen and the plane is close to 90 deg, // the projection fails. This prevents projecting too far away. const float min_angle_cos = 0.1; // XXX: pos should already be in windows coordinates. float wpos[3] = {pos[0], pos[1], 0}; float opos[3], onorm[3]; camera_t *cam = get_camera(); camera_get_ray(cam, wpos, viewport, opos, onorm); if (fabs(vec3_dot(onorm, plane[2])) <= min_angle_cos) return false; if (!plane_line_intersection(plane, opos, onorm, out)) return false; mat4_mul_vec3(plane, out, out); vec3_copy(plane[2], normal); return true; } static bool goxel_unproject_on_box( const float viewport[4], const float pos[2], const float box[4][4], bool inside, float out[3], float normal[3], int *face) { int f; float wpos[3] = {pos[0], pos[1], 0}; float opos[3], onorm[3]; float plane[4][4]; camera_t *cam = get_camera(); if (box_is_null(box)) return false; camera_get_ray(cam, wpos, viewport, opos, onorm); for (f = 0; f < 6; f++) { mat4_copy(box, plane); mat4_imul(plane, FACES_MATS[f]); if (!inside && vec3_dot(plane[2], onorm) >= 0) continue; if (inside && vec3_dot(plane[2], onorm) <= 0) continue; if (!plane_line_intersection(plane, opos, onorm, out)) continue; if (!(out[0] >= -1 && out[0] < 1 && out[1] >= -1 && out[1] < 1)) continue; if (face) *face = f; mat4_mul_vec3(plane, out, out); vec3_normalize(plane[2], normal); if (inside) vec3_imul(normal, -1); return true; } return false; } static bool goxel_unproject_on_mesh( const float view[4], const float pos[2], const mesh_t *mesh, float out[3], float normal[3]) { int view_size[2] = {view[2], view[3]}; // XXX: No need to render the fbo if it is not dirty. if (goxel.pick_fbo && (goxel.pick_fbo->w != view_size[0] || goxel.pick_fbo->h != view_size[1])) { texture_delete(goxel.pick_fbo); goxel.pick_fbo = NULL; } if (!goxel.pick_fbo) { goxel.pick_fbo = texture_new_buffer( view_size[0], view_size[1], TF_DEPTH); } renderer_t rend = {.settings = goxel.rend.settings}; mat4_copy(goxel.rend.view_mat, rend.view_mat); mat4_copy(goxel.rend.proj_mat, rend.proj_mat); uint32_t pixel; int voxel_pos[3]; int face, block_id, block_pos[3]; int x, y; float rect[4] = {0, 0, view_size[0], view_size[1]}; uint8_t clear_color[4] = {0, 0, 0, 0}; rend.settings.shadow = 0; rend.fbo = goxel.pick_fbo->framebuffer; rend.scale = 1; render_mesh(&rend, mesh, NULL, EFFECT_RENDER_POS); render_submit(&rend, rect, clear_color); x = round(pos[0] - view[0]); y = round(pos[1] - view[1]); GL(glViewport(0, 0, goxel.pick_fbo->w, goxel.pick_fbo->h)); if (x < 0 || x >= view_size[0] || y < 0 || y >= view_size[1]) return false; GL(glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel)); unpack_pos_data(pixel, voxel_pos, &face, &block_id); if (!block_id) return false; render_get_block_pos(&rend, mesh, block_id, block_pos); out[0] = block_pos[0] + voxel_pos[0] + 0.5; out[1] = block_pos[1] + voxel_pos[1] + 0.5; out[2] = block_pos[2] + voxel_pos[2] + 0.5; normal[0] = FACES_NORMALS[face][0]; normal[1] = FACES_NORMALS[face][1]; normal[2] = FACES_NORMALS[face][2]; vec3_iaddk(out, normal, 0.5); return true; } int goxel_unproject(const float viewport[4], const float pos[2], int snap_mask, float offset, float out[3], float normal[3]) { int i, ret = 0; bool r = false; float dist, best = INFINITY; float v[3], p[3] = {}, n[3] = {}, box[4][4]; camera_t *cam = get_camera(); // If tool_plane is set, we specifically use it. if (!plane_is_null(goxel.tool_plane)) { r = goxel_unproject_on_plane(viewport, pos, goxel.tool_plane, out, normal); ret = r ? SNAP_PLANE : 0; goto end; } for (i = 0; i < 7; i++) { if (!(snap_mask & (1 << i))) continue; if ((1 << i) == SNAP_MESH) { r = goxel_unproject_on_mesh(viewport, pos, goxel_get_layers_mesh(goxel.image), p, n); } if ((1 << i) == SNAP_PLANE) r = goxel_unproject_on_plane(viewport, pos, goxel.plane, p, n); if ((1 << i) == SNAP_SELECTION_IN) r = goxel_unproject_on_box(viewport, pos, goxel.selection, true, p, n, NULL); if ((1 << i) == SNAP_SELECTION_OUT) r = goxel_unproject_on_box(viewport, pos, goxel.selection, false, p, n, NULL); if ((1 << i) == SNAP_LAYER_OUT) { mesh_get_box(goxel.image->active_layer->mesh, true, box); r = goxel_unproject_on_box(viewport, pos, box, false, p, n, NULL); } if ((1 << i) == SNAP_IMAGE_BOX) r = goxel_unproject_on_box(viewport, pos, goxel.image->box, true, p, n, NULL); if ((1 << i) == SNAP_IMAGE_BOX) r = goxel_unproject_on_box(viewport, pos, goxel.image->box, true, p, n, NULL); if ((1 << i) == SNAP_CAMERA) { camera_get_ray(cam, pos, viewport, p, n); r = true; } if (!r) continue; mat4_mul_vec3(cam->view_mat, p, v); dist = -v[2]; if (dist < 0 || dist > best) continue; vec3_copy(p, out); vec3_copy(n, normal); ret = 1 << i; best = dist; } end: if (ret && offset) vec3_iaddk(out, normal, offset); if (ret && (snap_mask & SNAP_ROUNDED)) { out[0] = round(out[0] - 0.5) + 0.5; out[1] = round(out[1] - 0.5) + 0.5; out[2] = round(out[2] - 0.5) + 0.5; } return ret; } static int on_drag(const gesture_t *gest, void *user); static int on_pan(const gesture_t *gest, void *user); static int on_zoom(const gesture_t *gest, void *user); static int on_rotate(const gesture_t *gest, void *user); static int on_hover(const gesture_t *gest, void *user); static void goxel_init_sound() { #ifdef SOUND sound_init(); sound_register("build", assets_get("asset://data/sounds/build.wav", NULL)); sound_register("click", assets_get("asset://data/sounds/click.wav", NULL)); #endif } void goxel_add_gesture(int type, int button, int (*fn)(const gesture_t *gest, void *user)) { goxel.gestures[goxel.gestures_count] = calloc(1, sizeof(gesture_t)); *goxel.gestures[goxel.gestures_count] = (gesture_t) { .type = type, .button = button, .callback = fn, }; goxel.gestures_count++; } KEEPALIVE void goxel_init(void) { shapes_init(); goxel_init_sound(); // Load and set default palette. palette_load_all(&goxel.palettes); DL_FOREACH(goxel.palettes, goxel.palette) { if (strcmp(goxel.palette->name, "DB32") == 0) break; } goxel.palette = goxel.palette ?: goxel.palettes; goxel_add_gesture(GESTURE_DRAG, GESTURE_LMB, on_drag); goxel_add_gesture(GESTURE_DRAG, GESTURE_RMB, on_pan); goxel_add_gesture(GESTURE_DRAG, GESTURE_MMB | GESTURE_SHIFT, on_pan); goxel_add_gesture(GESTURE_DRAG, GESTURE_MMB | GESTURE_CTRL, on_zoom); goxel_add_gesture(GESTURE_DRAG, GESTURE_MMB, on_rotate); goxel_add_gesture(GESTURE_HOVER, 0, on_hover); goxel_reset(); } void goxel_reset(void) { image_delete(goxel.image); goxel.image = image_new(); settings_load(); // Put plane horizontal at the origin. plane_from_vectors(goxel.plane, VEC(0, 0, 0), VEC(1, 0, 0), VEC(0, 1, 0)); vec4_set(goxel.back_color, 70, 70, 70, 255); vec4_set(goxel.grid_color, 255, 255, 255, 127); vec4_set(goxel.image_box_color, 204, 204, 255, 255); action_exec2(ACTION_tool_set_brush); goxel.tool_radius = 0.5; goxel.painter = (painter_t) { .shape = &shape_cube, .mode = MODE_OVER, .smoothness = 0, .color = {255, 255, 255, 255}, }; // Set symmetry origin to the center of the image. mat4_mul_vec3(goxel.image->box, VEC(0, 0, 0), goxel.painter.symmetry_origin); goxel.rend.light = (typeof(goxel.rend.light)) { .pitch = 20 * DD2R, .yaw = 120 * DD2R, .intensity = 2.0, }; goxel.rend.settings = (render_settings_t) { .occlusion_strength = 0.4, .ambient = 0.3, .shadow = 0.3, }; if (DEFINED(NO_SHADOW)) goxel.rend.settings.shadow = 0; goxel.snap_mask = SNAP_MESH | SNAP_IMAGE_BOX; goxel.pathtracer = (pathtracer_t) { .num_samples = 512, .world = { .type = PT_WORLD_UNIFORM, .energy = 1, .color = {127, 127, 127, 255} }, .floor = { .color = {157, 172, 157, 255}, .size = {64, 64}, }, }; #ifdef AFTER_RESET_FUNC AFTER_RESET_FUNC(); #endif } void goxel_release(void) { pathtracer_stop(&goxel.pathtracer); gui_release(); } /* * Function: goxel_create_graphics * Called after the graphics context has been created. */ void goxel_create_graphics(void) { render_init(); goxel.graphics_initialized = true; } /* * Function: goxel_release_graphics * Called before the graphics context gets destroyed. */ void goxel_release_graphics(void) { render_deinit(); model3d_release_graphics(); gui_release_graphics(); shaders_release_all(); texture_delete(goxel.pick_fbo); goxel.pick_fbo = NULL; goxel.graphics_initialized = false; } static void update_window_title(void) { char buf[1024]; sprintf(buf, "Goxel %s%s %s", GOXEL_VERSION_STR, DEBUG ? " (debug)" : "", goxel.image->path ?: ""); sys_set_window_title(buf); } KEEPALIVE int goxel_iter(inputs_t *inputs) { double time = sys_get_time(); uint64_t mesh_key; float pitch; camera_t *camera = get_camera(); if (!goxel.graphics_initialized) goxel_create_graphics(); goxel.delta_time = time - goxel.frame_time; goxel.fps = mix(goxel.fps, 1.0 / goxel.delta_time, 0.1); goxel.frame_time = time; goxel_set_help_text(NULL); goxel_set_hint_text(NULL); goxel.screen_size[0] = inputs->window_size[0]; goxel.screen_size[1] = inputs->window_size[1]; goxel.screen_scale = inputs->scale; goxel.rend.fbo = inputs->framebuffer; goxel.rend.scale = inputs->scale; camera_update(camera); mat4_copy(camera->view_mat, goxel.rend.view_mat); mat4_copy(camera->proj_mat, goxel.rend.proj_mat); gui_iter(inputs); if (DEFINED(SOUND) && time - goxel.last_click_time > 0.1) { mesh_key = mesh_get_key(goxel_get_render_mesh(goxel.image)); if (goxel.last_mesh_key != mesh_key) { if (goxel.last_mesh_key) { pitch = goxel.painter.mode == MODE_OVER ? 1.0 : goxel.painter.mode == MODE_SUB ? 0.8 : 1.2; sound_play("build", 0.2, pitch); goxel.last_click_time = time; } goxel.last_mesh_key = mesh_key; } } sound_iter(); update_window_title(); goxel.frame_count++; if (goxel.request_test_graphic_release) { goxel_release_graphics(); goxel_create_graphics(); goxel.request_test_graphic_release = false; } return goxel.quit ? 1 : 0; } static void set_cursor_hint(cursor_t *curs) { const char *snap_str = NULL; if (!curs->snaped) { goxel_set_hint_text(NULL); return; } if (curs->snaped == SNAP_MESH) snap_str = "mesh"; if (curs->snaped == SNAP_PLANE) snap_str = "plane"; if (curs->snaped == SNAP_IMAGE_BOX) snap_str = "bounding box"; if ( curs->snaped == SNAP_SELECTION_IN || curs->snaped == SNAP_SELECTION_OUT) snap_str = "selection"; goxel_set_hint_text("[%.0f %.0f %.0f] (%s)", curs->pos[0] - 0.5, curs->pos[1] - 0.5, curs->pos[2] - 0.5, snap_str); } static int on_drag(const gesture_t *gest, void *user) { cursor_t *c = &goxel.cursor; if (gest->state == GESTURE_BEGIN) c->flags |= CURSOR_PRESSED; if (gest->state == GESTURE_END) c->flags &= ~CURSOR_PRESSED; c->snaped = goxel_unproject( gest->viewport, gest->pos, c->snap_mask, c->snap_offset, c->pos, c->normal); // Set some default values. The tools can override them. // XXX: would be better to reset the cursor when we change tool! c->snap_mask = goxel.snap_mask; set_flag(&c->snap_mask, SNAP_ROUNDED, goxel.painter.smoothness == 0); c->snap_offset = 0; return 0; } // XXX: can we merge this with unproject? static bool unproject_delta(const float win[3], const float model[4][4], const float proj[4][4], const float viewport[4], float out[3]) { float inv[4][4], norm_pos[4]; mat4_mul(proj, model, inv); if (!mat4_invert(inv, inv)) { vec3_copy(vec3_zero, out); return false; } vec4_set(norm_pos, win[0] / viewport[2], win[1] / viewport[3], 0, 0); mat4_mul_vec4(inv, norm_pos, norm_pos); vec3_copy(norm_pos, out); return true; } static int on_pan(const gesture_t *gest, void *user) { camera_t *camera = get_camera(); if (gest->state == GESTURE_BEGIN) { mat4_copy(camera->mat, goxel.move_origin.camera_mat); vec2_copy(gest->pos, goxel.move_origin.pos); } float wpos[3] = {gest->pos[0], gest->pos[1], 0}; float worigin_pos[3], wdelta[3], odelta[3]; vec3_set(worigin_pos, goxel.move_origin.pos[0], goxel.move_origin.pos[1], 0); vec3_sub(wpos, worigin_pos, wdelta); unproject_delta(wdelta, mat4_identity, camera->proj_mat, gest->viewport, odelta); vec3_imul(odelta, 2); // XXX: why do I need that? if (!camera->ortho) vec3_imul(odelta, camera->dist); mat4_translate(goxel.move_origin.camera_mat, -odelta[0], -odelta[1], 0, camera->mat); return 0; } static int on_rotate(const gesture_t *gest, void *user) { float x1, y1, x2, y2, x_rot, z_rot; camera_t *camera = get_camera(); if (gest->state == GESTURE_BEGIN) { mat4_copy(camera->mat, goxel.move_origin.camera_mat); vec2_copy(gest->pos, goxel.move_origin.pos); } x1 = goxel.move_origin.pos[0] / gest->viewport[2]; y1 = goxel.move_origin.pos[1] / gest->viewport[3]; x2 = gest->pos[0] / gest->viewport[2]; y2 = gest->pos[1] / gest->viewport[3]; z_rot = (x1 - x2) * 2 * M_PI; x_rot = (y2 - y1) * 2 * M_PI; mat4_copy(goxel.move_origin.camera_mat, camera->mat); camera_turntable(camera, z_rot, x_rot); return 0; } static int on_zoom(const gesture_t *gest, void *user) { float p[3], n[3]; double zoom; camera_t *camera = get_camera(); zoom = (gest->pos[1] - gest->last_pos[1]) / 10.0; mat4_itranslate(camera->mat, 0, 0, -camera->dist * (1 - pow(1.1, -zoom))); camera->dist *= pow(1.1, -zoom); // Auto adjust the camera rotation position. if (goxel_unproject_on_mesh(gest->viewport, gest->pos, goxel_get_layers_mesh(goxel.image), p, n)) { camera_set_target(camera, p); } return 0; } static int on_hover(const gesture_t *gest, void *user) { cursor_t *c = &goxel.cursor; c->snaped = goxel_unproject(gest->viewport, gest->pos, c->snap_mask, c->snap_offset, c->pos, c->normal); set_cursor_hint(c); c->flags &= ~CURSOR_PRESSED; // Set some default values. The tools can override them. // XXX: would be better to reset the cursor when we change tool! c->snap_mask = goxel.snap_mask; set_flag(&c->snap_mask, SNAP_ROUNDED, goxel.painter.smoothness == 0); c->snap_offset = 0; set_flag(&c->flags, CURSOR_OUT, gest->state == GESTURE_END); return 0; } // XXX: Cleanup this. void goxel_mouse_in_view(const float viewport[4], const inputs_t *inputs, bool capture_keys) { float p[3], n[3]; camera_t *camera = get_camera(); painter_t painter = goxel.painter; gesture_update(goxel.gestures_count, goxel.gestures, inputs, viewport, NULL); set_flag(&goxel.cursor.flags, CURSOR_SHIFT, inputs->keys[KEY_LEFT_SHIFT]); set_flag(&goxel.cursor.flags, CURSOR_CTRL, inputs->keys[KEY_CONTROL]); // Need to set the cursor snap mask to default because the tool might // change it. goxel.cursor.snap_mask = goxel.snap_mask; painter.box = !box_is_null(goxel.image->active_layer->box) ? &goxel.image->active_layer->box : !box_is_null(goxel.image->box) ? &goxel.image->box : NULL; // Only paint mode support alpha. if (painter.mode != MODE_PAINT) painter.color[3] = 255; // Swap OVER/SUB modes. if (inputs->keys[' ']) { if (goxel.painter.mode == MODE_SUB) painter.mode = MODE_OVER; if (goxel.painter.mode == MODE_OVER) painter.mode = MODE_SUB; } // Only apply smoothness for paint mode, that is we don't support // semi 'transparent' voxels anymore. if (painter.mode != MODE_PAINT) painter.smoothness = 0; if (!goxel.no_edit) { tool_iter(goxel.tool, &painter, viewport); } if (inputs->mouse_wheel) { mat4_itranslate(camera->mat, 0, 0, -camera->dist * (1 - pow(1.1, -inputs->mouse_wheel))); camera->dist *= pow(1.1, -inputs->mouse_wheel); // Auto adjust the camera rotation position. if (goxel_unproject_on_mesh(viewport, inputs->touches[0].pos, goxel_get_layers_mesh(goxel.image), p, n)) { camera_set_target(camera, p); } return; } // handle keyboard rotations if (!capture_keys) return; if (inputs->keys[KEY_LEFT]) { camera_turntable(camera, +0.05, 0); } if (inputs->keys[KEY_RIGHT]) { camera_turntable(camera, -0.05, 0); } if (inputs->keys[KEY_UP]) { camera_turntable(camera, 0, +0.05); } if (inputs->keys[KEY_DOWN]) { camera_turntable(camera, 0, -0.05); } // C: recenter the view: // XXX: this should be an action! if (inputs->keys['C']) { if (goxel_unproject_on_mesh(viewport, inputs->touches[0].pos, goxel_get_layers_mesh(goxel.image), p, n)) { camera_set_target(camera, p); } } } KEEPALIVE void goxel_render(void) { uint8_t color[4]; theme_get_color(THEME_GROUP_BASE, THEME_COLOR_BACKGROUND, false, color); GL(glViewport(0, 0, goxel.screen_size[0] * goxel.screen_scale, goxel.screen_size[1] * goxel.screen_scale)); GL(glBindFramebuffer(GL_FRAMEBUFFER, goxel.rend.fbo)); GL(glClearColor(color[0] / 255., color[1] / 255., color[2] / 255., 1)); GL(glStencilMask(0xFF)); GL(glDisable(GL_SCISSOR_TEST)); GL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)); gui_render(); } static void render_export_viewport(const float viewport[4]) { // Render the export viewport. int w = goxel.image->export_width; int h = goxel.image->export_height; float aspect = (float)w/h; float plane[4][4]; camera_t *camera = get_camera(); mat4_set_identity(plane); mat4_iscale(plane, viewport[2], viewport[3], 1); mat4_itranslate(plane, 0.5, 0.5, 0); if (aspect < camera->aspect) { mat4_iscale(plane, aspect / camera->aspect, 1, 1); } else { mat4_iscale(plane, 1, camera->aspect / aspect, 1); } render_rect(&goxel.rend, plane, EFFECT_STRIP); } static void render_pathtrace_view(const float viewport[4]) { pathtracer_t *pt = &goxel.pathtracer; float a, mat[4][4]; // Recreate the buffer if needed. if ( !pt->buf || pt->w != goxel.image->export_width || pt->h != goxel.image->export_height) { free(pt->buf); pt->w = goxel.image->export_width; pt->h = goxel.image->export_height; pt->buf = calloc(pt->w * pt->h, 4); texture_delete(pt->texture); pt->texture = texture_new_surface(pt->w, pt->h, 0); } pathtracer_iter(pt, viewport); // Render the buffer. mat4_set_identity(mat); a = 1.0 * pt->w / pt->h / viewport[2] * viewport[3]; mat4_iscale(mat, viewport[2], viewport[3], 1); mat4_itranslate(mat, 0.5, 0.5, 0); mat4_iscale(mat, min(a, 1.f), min(1.f / a, 1.f), 1); texture_set_data(pt->texture, pt->buf, pt->w, pt->h, 4); render_img(&goxel.rend, pt->texture, mat, EFFECT_NO_SHADING | EFFECT_PROJ_SCREEN | EFFECT_ANTIALIASING); render_submit(&goxel.rend, viewport, goxel.back_color); } static void render_axis_arrows(const float viewport[4]) { float rot[4][4], a[3], b[3], l[3]; const float AXIS[][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; uint8_t color[4]; int i; const float size = 40; mat4_copy(get_camera()->mat, rot); vec3_set(rot[3], 0, 0, 0); mat4_invert(rot, rot); vec3_set(a, 50, 50, 0); // Origin pos (viewport coordinates) for (i = 0; i < 3; i++) { vec4_set(color, AXIS[i][0] * 255, AXIS[i][1] * 255, AXIS[i][2] * 255, 255); vec3_mul(AXIS[i], size, b); mat4_mul_vec3(rot, b, b); vec3_add(a, b, b); render_line(&goxel.rend, a, b, color, EFFECT_PROJ_SCREEN); vec3_mul(AXIS[i], size * 0.4, l); mat4_mul_vec3(rot, l, l); vec3_add(b, l, l); // X letter if (i == 0) { float t1[3], t2[3]; vec3_set(t1, l[0] - 3, l[1] + 7, l[2]); vec3_set(t2, l[0] + 3, l[1] - 7, l[2]); render_line(&goxel.rend, t1, t2, color, EFFECT_PROJ_SCREEN); vec3_set(t1, l[0] + 3, l[1] + 7, l[2]); vec3_set(t2, l[0] - 3, l[1] - 7, l[2]); render_line(&goxel.rend, t1, t2, color, EFFECT_PROJ_SCREEN); } // Y letter if (i == 1) { float t1[3], t2[3]; vec3_set(t1, l[0] - 3, l[1] + 7, l[2]); vec3_set(t2, l[0], l[1], l[2]); render_line(&goxel.rend, t1, t2, color, EFFECT_PROJ_SCREEN); vec3_set(t1, l[0] + 3, l[1] + 7, l[2]); vec3_set(t2, l[0], l[1], l[2]); render_line(&goxel.rend, t1, t2, color, EFFECT_PROJ_SCREEN); vec3_set(t1, l[0], l[1] - 7, l[2]); vec3_set(t2, l[0], l[1], l[2]); render_line(&goxel.rend, t1, t2, color, EFFECT_PROJ_SCREEN); } // Z letter if (i == 2) { float t1[3], t2[3]; vec3_set(t1, l[0] - 3, l[1] + 7, l[2]); vec3_set(t2, l[0] + 3, l[1] + 7, l[2]); render_line(&goxel.rend, t1, t2, color, EFFECT_PROJ_SCREEN); vec3_set(t1, l[0] + 3, l[1] + 7, l[2]); vec3_set(t2, l[0] - 3, l[1] - 7, l[2]); render_line(&goxel.rend, t1, t2, color, EFFECT_PROJ_SCREEN); vec3_set(t1, l[0] - 3, l[1] - 7, l[2]); vec3_set(t2, l[0] + 3, l[1] - 7, l[2]); render_line(&goxel.rend, t1, t2, color, EFFECT_PROJ_SCREEN); } } } static bool is_box_face_visible(const float box[4][4], int f) { float mat[4][4], n[4]; camera_t *cam = get_camera(); mat4_mul(box, FACES_MATS[f], mat); mat4_mul_vec4(cam->view_mat, mat[2], n); return (n[2] < 0); } static void render_symmetry_axis( const float box[4][4], int sym, const float sym_o[3]) { int i, f; float plane[4][4], vertices[8][3], triangles[2][3][3], seg[2][3], n[3]; uint8_t color[4]; box_get_vertices(box, vertices); for (i = 0; i < 3; i++) { if (!(sym & (1 << i))) continue; memset(n, 0, sizeof(n)); n[i] = 1; plane_from_normal(plane, sym_o, n); memset(color, 0, sizeof(color)); color[i] = 255; color[3] = 255; for (f = 0; f < 6; f++) { if (!is_box_face_visible(box, f)) continue; vec3_copy(vertices[FACES_VERTICES[f][0]], triangles[0][0]); vec3_copy(vertices[FACES_VERTICES[f][1]], triangles[0][1]); vec3_copy(vertices[FACES_VERTICES[f][2]], triangles[0][2]); vec3_copy(vertices[FACES_VERTICES[f][2]], triangles[1][0]); vec3_copy(vertices[FACES_VERTICES[f][3]], triangles[1][1]); vec3_copy(vertices[FACES_VERTICES[f][0]], triangles[1][2]); if (plane_triangle_intersection(plane, triangles[0], seg)) render_line(&goxel.rend, seg[0], seg[1], color, 0); if (plane_triangle_intersection(plane, triangles[1], seg)) render_line(&goxel.rend, seg[0], seg[1], color, 0); } } } void goxel_render_view(const float viewport[4], bool render_mode) { const layer_t *layer; renderer_t *rend = &goxel.rend; const uint8_t layer_box_color[4] = {128, 128, 255, 255}; int effects = 0; camera_t *camera = get_camera(); if (render_mode) { render_pathtrace_view(viewport); return; } camera->aspect = viewport[2] / viewport[3]; camera_update(camera); mat4_copy(camera->view_mat, goxel.rend.view_mat); mat4_copy(camera->proj_mat, goxel.rend.proj_mat); effects |= goxel.view_effects; for (layer = goxel_get_render_layers(true); layer; layer = layer->next) { if (layer->visible && layer->mesh) render_mesh(rend, layer->mesh, layer->material, effects); } if (!box_is_null(goxel.image->active_layer->box)) render_box(rend, goxel.image->active_layer->box, layer_box_color, EFFECT_WIREFRAME); // Render all the image layers. DL_FOREACH(goxel.image->layers, layer) { if (layer->visible && layer->image) render_img(rend, layer->image, layer->mat, EFFECT_NO_SHADING); } render_box(rend, goxel.selection, NULL, EFFECT_STRIP | EFFECT_WIREFRAME); if (goxel.tool->flags & TOOL_SHOW_MASK) render_mesh(rend, goxel.mask, NULL, EFFECT_GRID_ONLY); // Debug: show the current layer mesh blocks. if ((0)) { mesh_iterator_t iter; mesh_t *mesh = goxel.image->active_layer->mesh; iter = mesh_get_iterator(mesh, MESH_ITER_BLOCKS); int p[3], aabb[2][3]; float box[4][4]; while (mesh_iter(&iter, p)) { mesh_get_block_aabb(p, aabb); bbox_from_aabb(box, aabb); render_box(rend, box, NULL, EFFECT_WIREFRAME); } } // XXX: make a toggle for debug informations. if ((0)) { float b[4][4]; uint8_t c[4]; vec4_set(c, 0, 255, 0, 80); mesh_get_box(goxel_get_layers_mesh(goxel.image), true, b); render_box(rend, b, c, EFFECT_WIREFRAME); vec4_set(c, 0, 255, 255, 80); mesh_get_box(goxel_get_layers_mesh(goxel.image), false, b); render_box(rend, b, c, EFFECT_WIREFRAME); } if (goxel.snap_mask & SNAP_PLANE) render_grid(rend, goxel.plane, goxel.grid_color, goxel.image->box); if (!box_is_null(goxel.image->box) && !goxel.hide_box) { render_box(rend, goxel.image->box, goxel.image_box_color, EFFECT_SEE_BACK | EFFECT_GRID); render_symmetry_axis(goxel.image->box, goxel.painter.symmetry, goxel.painter.symmetry_origin); } if (goxel.show_export_viewport) render_export_viewport(viewport); render_axis_arrows(viewport); render_submit(&goxel.rend, viewport, goxel.back_color); } void image_update(image_t *img); const mesh_t *goxel_get_layers_mesh(const image_t *img) { uint32_t key = 0, k; layer_t *layer; image_update((image_t*)img); DL_FOREACH(img->layers, layer) { if (!layer->visible) continue; if (!layer->mesh) continue; k = layer_get_key(layer); key = XXH32(&k, sizeof(k), key); } if (key != goxel.layers_mesh_hash) { goxel.layers_mesh_hash = key; if (!goxel.layers_mesh_) goxel.layers_mesh_ = mesh_new(); mesh_clear(goxel.layers_mesh_); DL_FOREACH(img->layers, layer) { if (!layer->visible) continue; mesh_merge(goxel.layers_mesh_, layer->mesh, MODE_OVER, NULL); } } return goxel.layers_mesh_; } const mesh_t *goxel_get_render_mesh(const image_t *img) { uint32_t key, k; const mesh_t *mesh; layer_t *layer; if (!goxel.tool_mesh) return goxel_get_layers_mesh(img); key = mesh_get_key(goxel_get_layers_mesh(img)); k = mesh_get_key(goxel.tool_mesh); key = XXH32(&k, sizeof(k), key); if (key != goxel.render_mesh_hash) { image_update(goxel.image); goxel.render_mesh_hash = key; if (!goxel.render_mesh_) goxel.render_mesh_ = mesh_new(); mesh_clear(goxel.render_mesh_); DL_FOREACH(goxel.image->layers, layer) { if (!layer->visible) continue; mesh = layer->mesh; if (mesh == goxel.image->active_layer->mesh) mesh = goxel.tool_mesh; mesh_merge(goxel.render_mesh_, mesh, MODE_OVER, NULL); } } return goxel.render_mesh_; } const layer_t *goxel_get_render_layers(bool with_tool_preview) { uint32_t hash, k; layer_t *l, *layer, *tmp; hash = image_get_key(goxel.image); if (with_tool_preview && goxel.tool_mesh) { k = mesh_get_key(goxel.tool_mesh); hash = XXH32(&k, sizeof(k), hash); } if (hash != goxel.render_layers_hash) { goxel.render_layers_hash = hash; image_update(goxel.image); DL_FOREACH_SAFE(goxel.render_layers, layer, tmp) { DL_DELETE(goxel.render_layers, layer); layer_delete(layer); } DL_FOREACH(goxel.image->layers, l) { if (!l->visible) continue; if (!l->mesh) continue; layer = layer_copy(l); if ( with_tool_preview && goxel.tool_mesh && l->mesh == goxel.image->active_layer->mesh) { mesh_set(layer->mesh, goxel.tool_mesh); } if ( goxel.render_layers && goxel.render_layers->prev->material == layer->material) { mesh_merge(goxel.render_layers->prev->mesh, layer->mesh, MODE_OVER, NULL); layer_delete(layer); } else { DL_APPEND(goxel.render_layers, layer); } } } return goxel.render_layers; } // Render the view into an RGB[A] buffer. void goxel_render_to_buf(uint8_t *buf, int w, int h, int bpp) { camera_t *camera = get_camera(); const mesh_t *mesh; texture_t *fbo; renderer_t rend = goxel.rend; float rect[4] = {0, 0, w * 2, h * 2}; uint8_t *tmp_buf; camera->aspect = (float)w / h; camera_update(camera); mesh = goxel_get_layers_mesh(goxel.image); fbo = texture_new_buffer(w * 2, h * 2, TF_DEPTH); mat4_copy(camera->view_mat, rend.view_mat); mat4_copy(camera->proj_mat, rend.proj_mat); rend.fbo = fbo->framebuffer; rend.scale = 1.0; // XXX: use goxel_get_render_layers! render_mesh(&rend, mesh, NULL, 0); render_submit(&rend, rect, (bpp == 3) ? goxel.back_color : NULL); tmp_buf = calloc(w * h * 4, bpp); texture_get_data(fbo, w * 2, h * 2, bpp, tmp_buf); img_downsample(tmp_buf, w * 2, h * 2, bpp, buf); free(tmp_buf); texture_delete(fbo); } // XXX: we could merge all the set_xxx_text function into a single one. void goxel_set_help_text(const char *msg, ...) { va_list args; free(goxel.help_text); goxel.help_text = NULL; if (!msg) return; va_start(args, msg); vasprintf(&goxel.help_text, msg, args); va_end(args); } void goxel_set_hint_text(const char *msg, ...) { va_list args; free(goxel.hint_text); goxel.hint_text = NULL; if (!msg) return; va_start(args, msg); vasprintf(&goxel.hint_text, msg, args); va_end(args); } void goxel_import_image_plane(const char *path) { layer_t *layer; texture_t *tex; tex = texture_new_image(path, TF_NEAREST); if (!tex) return; image_history_push(goxel.image); layer = image_add_layer(goxel.image, NULL); sprintf(layer->name, "img"); layer->image = tex; mat4_iscale(layer->mat, layer->image->w, layer->image->h, 1); } void goxel_on_low_memory(void) { render_on_low_memory(&goxel.rend); } int goxel_import_file(const char *path, const char *format) { const file_format_t *f; int err; if (str_endswith(path, ".gox")) { return load_from_file(path, false); } f = file_format_for_path(path, format, "r"); if (!f) return -1; if (!path) { path = noc_file_dialog_open(NOC_FILE_DIALOG_OPEN, f->ext, NULL, NULL); if (!path) return -1; } err = f->import_func(goxel.image, path); if (err) return err; return 0; } int goxel_export_to_file(const char *path, const char *format) { const file_format_t *f; char name[128]; int err; f = file_format_for_path(path, format, "w"); if (!f) return -1; if (!path) { snprintf(name, sizeof(name), "Untitled%s", f->ext + strlen(f->ext) + 2); path = sys_get_save_path(f->ext, name); if (!path) return -1; } err = f->export_func(goxel.image, path); if (err) return err; sys_on_saved(path); return 0; } static void a_cut_as_new_layer(void) { layer_t *new_layer; painter_t painter; image_t *img = goxel.image; layer_t *layer = img->active_layer; const float (*box)[4][4] = &goxel.selection; new_layer = image_duplicate_layer(img, layer); // Use the mask in priority. if (!mesh_is_empty(goxel.mask)) { mesh_merge(new_layer->mesh, goxel.mask, MODE_INTERSECT, NULL); mesh_merge(layer->mesh, goxel.mask , MODE_SUB, NULL); return; } painter = (painter_t) { .shape = &shape_cube, .mode = MODE_INTERSECT, .color = {255, 255, 255, 255}, }; mesh_op(new_layer->mesh, &painter, *box); painter.mode = MODE_SUB; mesh_op(layer->mesh, &painter, *box); } ACTION_REGISTER(cut_as_new_layer, .help = "Cut into a new layer", .cfunc = a_cut_as_new_layer, .flags = ACTION_TOUCH_IMAGE, ) static void a_reset_selection(void) { if (!mesh_is_empty(goxel.mask)) { mesh_delete(goxel.mask); goxel.mask = NULL; return; } mat4_copy(mat4_zero, goxel.selection); } ACTION_REGISTER(reset_selection, .help = "Reset the selection", .cfunc = a_reset_selection, ) static void a_fill_selection(void) { layer_t *layer = goxel.image->active_layer; if (!mesh_is_empty(goxel.mask)) { mesh_merge(layer->mesh, goxel.mask, MODE_OVER, goxel.painter.color); return; } if (box_is_null(goxel.selection)) return; mesh_op(layer->mesh, &goxel.painter, goxel.selection); } ACTION_REGISTER(fill_selection, .help = "Fill the selection with the current paint settings", .cfunc = a_fill_selection, .flags = ACTION_TOUCH_IMAGE, ) static void a_add_selection(void) { mesh_t *tmp; painter_t painter; if (box_is_null(goxel.selection)) return; painter = (painter_t) { .shape = &shape_cube, .mode = MODE_INTERSECT_FILL, .color = {255, 255, 255, 255}, }; tmp = mesh_copy(goxel.image->active_layer->mesh); mesh_op(tmp, &painter, goxel.selection); if (goxel.mask == NULL) goxel.mask = mesh_new(); mesh_merge(goxel.mask, tmp, MODE_OVER, painter.color); mesh_delete(tmp); } ACTION_REGISTER(add_selection, .help = "Add the selection to the current mask", .cfunc = a_add_selection, ) static void a_sub_selection(void) { painter_t painter; if (goxel.mask == NULL || box_is_null(goxel.selection)) return; painter = (painter_t) { .shape = &shape_cube, .mode = MODE_SUB, .color = {255, 255, 255, 255}, }; mesh_op(goxel.mask, &painter, goxel.selection); } ACTION_REGISTER(sub_selection, .help = "Subtract the selection from the current mask", .cfunc = a_sub_selection, ) static void copy_action(void) { painter_t painter; mesh_delete(goxel.clipboard.mesh); mat4_copy(goxel.selection, goxel.clipboard.box); goxel.clipboard.mesh = mesh_copy(goxel.image->active_layer->mesh); if (!box_is_null(goxel.selection)) { painter = (painter_t) { .shape = &shape_cube, .mode = MODE_INTERSECT, .color = {255, 255, 255, 255}, }; mesh_op(goxel.clipboard.mesh, &painter, goxel.selection); } } static void past_action(void) { mesh_t *mesh = goxel.image->active_layer->mesh; mesh_t *tmp; float p1[3], p2[3], mat[4][4]; mat4_set_identity(mat); if (!goxel.clipboard.mesh) return; tmp = mesh_copy(goxel.clipboard.mesh); if ( !box_is_null(goxel.selection) && !box_is_null(goxel.clipboard.box)) { vec3_copy(goxel.selection[3], p1); vec3_copy(goxel.clipboard.box[3], p2); mat4_itranslate(mat, +p1[0], +p1[1], +p1[2]); mat4_itranslate(mat, -p2[0], -p2[1], -p2[2]); mesh_move(tmp, mat); } mesh_merge(mesh, tmp, MODE_OVER, NULL); mesh_delete(tmp); } ACTION_REGISTER(copy, .help = "Copy", .cfunc = copy_action, .default_shortcut = "Ctrl C", .flags = 0, ) ACTION_REGISTER(past, .help = "Past", .cfunc = past_action, .default_shortcut = "Ctrl V", .flags = ACTION_TOUCH_IMAGE, ) #define HS2 (M_SQRT2 / 2.0) static void a_view_default(void) { camera_t *camera = get_camera(); mat4_set_identity(camera->mat); camera->dist = 128; camera->aspect = 1; mat4_itranslate(camera->mat, 0, 0, camera->dist); camera_turntable(camera, M_PI / 4, M_PI / 4); camera_fit_box(camera, goxel.image->box); } static void a_view_set(void *data) { float rz = ((float*)data)[0] / 180 * M_PI; float rx = ((float*)data)[1] / 180 * M_PI; camera_t *camera = get_camera(); mat4_set_identity(camera->mat); mat4_itranslate(camera->mat, 0, 0, camera->dist); camera_turntable(camera, rz, rx); } ACTION_REGISTER(view_left, .help = "Set camera view to left", .flags = ACTION_CAN_EDIT_SHORTCUT, .cfunc_data = a_view_set, .data = (float[]){90, 90}, .default_shortcut = "Ctrl 3", ) ACTION_REGISTER(view_right, .help = "Set camera view to right", .flags = ACTION_CAN_EDIT_SHORTCUT, .cfunc_data = a_view_set, .data = (float[]){-90, 90}, .default_shortcut = "3", ) ACTION_REGISTER(view_top, .help = "Set camera view to top", .flags = ACTION_CAN_EDIT_SHORTCUT, .cfunc_data = a_view_set, .data = (float[]){0, 0}, .default_shortcut = "7", ) ACTION_REGISTER(view_default, .help = "Set camera view to default", .flags = ACTION_CAN_EDIT_SHORTCUT, .cfunc = a_view_default, .default_shortcut = "5", ) ACTION_REGISTER(view_front, .help = "Set camera view to front", .flags = ACTION_CAN_EDIT_SHORTCUT, .cfunc_data = a_view_set, .data = (float[]){0, 90}, .default_shortcut = "1", ) static void quit(void) { gui_query_quit(); } ACTION_REGISTER(quit, .help = "Quit the application", .flags = ACTION_CAN_EDIT_SHORTCUT, .cfunc = quit, .default_shortcut = "Ctrl Q", ) static void undo(void) { image_undo(goxel.image); } static void redo(void) { image_redo(goxel.image); } ACTION_REGISTER(undo, .help = "Undo", .flags = ACTION_CAN_EDIT_SHORTCUT, .cfunc = undo, .default_shortcut = "Ctrl Z", .icon = ICON_ARROW_BACK, ) ACTION_REGISTER(redo, .help = "Redo", .flags = ACTION_CAN_EDIT_SHORTCUT, .cfunc = redo, .default_shortcut = "Ctrl Y", .icon = ICON_ARROW_FORWARD, ) static void toggle_mode(void) { int mode = goxel.painter.mode; switch (mode) { case MODE_OVER: mode = MODE_SUB; break; case MODE_SUB: mode = MODE_PAINT; break; case MODE_PAINT: mode = MODE_OVER; break; } goxel.painter.mode = mode; } ACTION_REGISTER(toggle_mode, .help = "Toggle the tool mode (add, sub, paint)", .flags = ACTION_CAN_EDIT_SHORTCUT, .cfunc = toggle_mode, ) goxel-0.11.0/src/goxel.h000066400000000000000000000402411435762723100150000ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015-2022 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ // File: goxel.h #ifndef GOXEL_H #define GOXEL_H #ifndef _GNU_SOURCE # define _GNU_SOURCE #endif #ifndef NOMINMAX # define NOMINMAX #endif #include "action.h" #include "assets.h" #include "block_def.h" #include "camera.h" #include "gesture.h" #include "gesture3d.h" #include "gui.h" #include "image.h" #include "inputs.h" #include "layer.h" #include "log.h" #include "material.h" #include "mesh.h" #include "mesh_utils.h" #include "model3d.h" #include "noc_file_dialog.h" #include "palette.h" #include "pathtracer.h" #include "render.h" #include "shape.h" #include "system.h" #include "theme.h" #include "tools.h" #include "utarray.h" #include "uthash.h" #include "utlist.h" #include "utils/box.h" #include "utils/cache.h" #include "utils/gl.h" #include "utils/img.h" #include "utils/plane.h" #include "utils/sound.h" #include "utils/texture.h" #include "utils/vec.h" #include #include #include #include #include #include #define GOXEL_VERSION_STR "0.11.0" #ifndef GOXEL_DEFAULT_THEME # define GOXEL_DEFAULT_THEME "original" #endif // #### Set the DEBUG macro #### #ifndef DEBUG # if !defined(NDEBUG) # define DEBUG 1 # else # define DEBUG 0 # endif #endif #if !DEBUG && !defined(NDEBUG) # define NDEBUG #endif #include // ############################# // #### DEFINED macro ########## // DEFINE(NAME) returns 1 if NAME is defined to 1, 0 otherwise. #define DEFINED(macro) DEFINED_(macro) #define macrotest_1 , #define DEFINED_(value) DEFINED__(macrotest_##value) #define DEFINED__(comma) DEFINED___(comma 1, 0) #define DEFINED___(_, v, ...) v // ############################# // CHECK is similar to an assert, but the condition is tested even in release // mode. #if DEBUG #define CHECK(c) assert(c) #else #define CHECK(c) do { \ if (!(c)) { \ LOG_E("Error %s %s %d", __func__, __FILE__, __LINE__); \ exit(-1); \ } \ } while (0) #endif // I redefine asprintf so that if the function fails, we just crash the // application. I don't see how we can recover from an asprintf fails // anyway. #define asprintf(...) CHECK(asprintf(__VA_ARGS__) != -1) #define vasprintf(...) CHECK(vasprintf(__VA_ARGS__) != -1) // ############################# #ifdef __EMSCRIPTEN__ # include # define KEEPALIVE EMSCRIPTEN_KEEPALIVE #else # define KEEPALIVE #endif // ####### Section: Utils ################################################ // Some useful inline functions / macros /* * Macro: ARRAY_SIZE * Return the number of elements in an array */ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) /* * Macro: SWAP * Swap two variables */ #define SWAP(x0, x) do {typeof(x0) tmp = x0; x0 = x; x = tmp;} while (0) /* * Macro: USER_PASS * Used to pass values to callback 'void *user' arguments. * * For a function with the following declaration: f(void *user), we can pass * several arguments packed in an array like that: * * int x, y; * f(USER_PASS(&x, &y)); */ #define USER_PASS(...) ((const void*[]){__VA_ARGS__}) /* * Macro: USER_GET * Used to unpack values passed to a callback with USER_PASS: * * void f(void *user) * { * char *arg1 = USER_GET(user, 0); * int arg2 = *((int*)USER_GET(user, 1)); * } */ #define USER_GET(var, n) (((void**)var)[n]) /* Define: DR2D * Convertion ratio from radian to degree. */ #define DR2D (180 / M_PI) /* Define: DR2D * Convertion ratio from degree to radian. */ #define DD2R (M_PI / 180) /* Define: KB * 1024 */ #define KB 1024 /* Define: MB * 1024^2 */ #define MB (1024 * KB) /* Define: GB * 1024^3 */ #define GB (1024 * MB) /* * Macro: min * Safe min function. */ #define min(a, b) ({ \ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ _a < _b ? _a : _b; \ }) /* * Macro: max * Safe max function. */ #define max(a, b) ({ \ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ _a > _b ? _a : _b; \ }) /* * Macro: max3 * Safe max function, return the max of three values. */ #define max3(x, y, z) (max((x), max((y), (z)))) /* * Macro: min3 * Safe max function, return the max of three values. */ #define min3(x, y, z) (min((x), min((y), (z)))) /* * Macro: clamp * Clamp a value. */ #define clamp(x, a, b) (min(max(x, a), b)) /* * Macro: cmp * Compare two values. * * Return: * +1 if a > b, -1 if a < b, 0 if a == b. */ #define cmp(a, b) ({ \ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ (_a > _b) ? +1 : (_a < _b) ? -1 : 0; \ }) /* Function: smoothstep * Perform Hermite interpolation between two values. * * This is similar to the smoothstep function in OpenGL shader language. * * Parameters: * edge0 - Lower edge of the Hermite function. * edge1 - Upper edge of the Hermite function. * x - Source value for interpolation. */ static inline float smoothstep(float edge0, float edge1, float x) { x = clamp((x - edge0) / (edge1 - edge0), 0.0f, 1.0f); return x * x * (3.0f - 2.0f * x); } /* * Function: mix * Linear blend of x and y. * * Similar to GLES mix function. */ static inline float mix(float x, float y, float t) { return (1.0 - t) * x + t * y; } /* Function: set_flag * Set some int bits to 0 or 1. * * Parameters: * x - The int value to change. * flag - Bitmask of the bits we want to set. * v - Value to set. */ static inline void set_flag(int *x, int flag, bool v) { v ? (*x |= flag) : (*x &= ~flag); } /* * Extra texture creation function from a path, that can also be an asset. */ texture_t *texture_new_image(const char *path, int flags); /* * Function: read_file * Read a file from disk. * * Return: * A newly allocated buffer containing the file data. */ char *read_file(const char *path, int *size); /* * Function: unix_to_dtf * Get gregorian date from unix time. * * Parameters: * t - Unix time. * iy - Output year. * im - Output month (1 - 12). * id - Output day (1 - 31). * h - Output hour. * m - Output minute. * s - Output seconds. */ int unix_to_dtf(double t, int *iy, int *im, int *id, int *h, int *m, int *s); /* * Function: utf_16_to_8 * Convert a string encoded in utf_16 to utf_8. * * Parameters: * in16 - Input string in utf 16 encoding. * out8 - Output buffer that receive the utf8 string. * size8 - Size of the output buffer. */ int utf_16_to_8(const wchar_t *in16, char *out8, size_t size8); /* * Function: str_endswith * Return whether a string ends with an other one. */ bool str_endswith(const char *str, const char *end); /* * Function: str_startswith * Return whether a string starts with an other one. */ bool str_startswith(const char *s1, const char *s2); /* * Function: unproject * Convert from screen coordinate to world coordinates. * * Similar to gluUnproject. * * Parameters: * win - Windows coordinates to be mapped. * model - Modelview matrix. * proj - Projection matrix. * viewport - Viewport rect (x, y, w, h). * out - Output of the computed object coordinates. */ void unproject(const float win[3], const float model[4][4], const float proj[4][4], const float viewport[4], float out[3]); // #### Dialogs ################ enum { DIALOG_FLAG_SAVE = 1 << 0, DIALOG_FLAG_OPEN = 1 << 1, DIALOG_FLAG_DIR = 1 << 2, }; // All the icons positions inside icon.png (as Y*8 + X + 1). enum { ICON_NULL = 0, ICON_TOOL_BRUSH = 1, ICON_TOOL_PICK = 2, ICON_TOOL_SHAPE = 3, ICON_TOOL_PLANE = 4, ICON_TOOL_LASER = 5, ICON_TOOL_MOVE = 6, ICON_TOOL_EXTRUDE = 7, ICON_TOOL_FUZZY_SELECT = 8, ICON_MODE_ADD = 9, ICON_MODE_SUB = 10, ICON_MODE_PAINT = 11, ICON_SHAPE_CUBE = 12, ICON_SHAPE_SPHERE = 13, ICON_SHAPE_CYLINDER = 14, ICON_TOOL_RECT_SELECTION = 15, ICON_TOOL_LINE = 16, ICON_ADD = 17, ICON_REMOVE = 18, ICON_ARROW_BACK = 19, ICON_ARROW_FORWARD = 20, ICON_LINK = 21, ICON_MENU = 22, ICON_DELETE = 23, ICON_TOOL_PROCEDURAL = 24, ICON_VISIBILITY = 25, ICON_VISIBILITY_OFF = 26, ICON_ARROW_DOWNWARD = 27, ICON_ARROW_UPWARD = 28, ICON_EDIT = 29, ICON_COPY = 30, ICON_GALLERY = 31, ICON_INFO = 32, ICON_SETTINGS = 33, ICON_CLOUD = 34, ICON_SHAPE = 35, ICON_CLOSE = 36, ICON_TOOLS = 41, ICON_PALETTE = 42, ICON_LAYERS = 43, ICON_RENDER = 44, ICON_CAMERA = 45, ICON_IMAGE = 46, ICON_EXPORT = 47, ICON_DEBUG = 48, ICON_VIEW = 49, ICON_MATERIAL = 50, ICON_LIGHT = 51, ICON_TOOL_SELECTION = 52, }; /* * Some icons have their color blended depending on the style. We define * them with a range in the icons atlas: */ #define ICON_COLORIZABLE_START 17 #define ICON_COLORIZABLE_END 41 // #### Block ################## // The block size can only be 16. #define BLOCK_SIZE 16 #define VOXEL_TEXTURE_SIZE 8 // Generate an optimal palette whith a fixed number of colors from a mesh. void quantization_gen_palette(const mesh_t *mesh, int nb, uint8_t (*palette)[4]); // #### Goxel : core object #### // Flags to set where the mouse snap. In order of priority. enum { SNAP_IMAGE_BOX = 1 << 0, SNAP_SELECTION_IN = 1 << 1, SNAP_SELECTION_OUT = 1 << 2, SNAP_MESH = 1 << 3, SNAP_PLANE = 1 << 4, SNAP_CAMERA = 1 << 5, // Used for laser tool. SNAP_LAYER_OUT = 1 << 6, // Snap the layer box. SNAP_ROUNDED = 1 << 8, // Round the result. }; typedef struct goxel { int screen_size[2]; float screen_scale; image_t *image; // Flag so that we reinit OpenGL after the context has been killed. bool graphics_initialized; // We can't reset the graphics in the middle of the gui, so use this. // for testing. bool request_test_graphic_release; // Tools can set this mesh and it will replace the current layer mesh // during render. mesh_t *tool_mesh; mesh_t *layers_mesh_; uint32_t layers_mesh_hash; mesh_t *render_mesh_; // All the layers + tool mesh. uint32_t render_mesh_hash; layer_t *render_layers; uint32_t render_layers_hash; struct { mesh_t *mesh; float box[4][4]; } clipboard; int snap_mask; // Global snap mask (can edit in the GUI). float snap_offset; // Only for brush tool, remove that? float plane[4][4]; // The snapping plane. bool show_export_viewport; uint8_t back_color[4]; uint8_t grid_color[4]; uint8_t image_box_color[4]; bool hide_box; texture_t *pick_fbo; painter_t painter; renderer_t rend; cursor_t cursor; tool_t *tool; float tool_radius; bool no_edit; // Disable editing. // Some state for the tool iter functions. float tool_plane[4][4]; int tool_drag_mode; // 0: move, 1: resize. float selection[4][4]; // The selection box. mesh_t *mask; // Global selection mask mesh. int mask_mode; struct { float rotation[4]; float pos[2]; float camera_ofs[3]; float camera_mat[4][4]; } move_origin; palette_t *palettes; // The list of all the palettes palette_t *palette; // The current color palette char *help_text; // Seen in the bottom of the screen. char *hint_text; // Seen in the bottom of the screen. double delta_time; // Elapsed time since last frame (sec) int frame_count; // Global frames counter. double frame_time; // Clock time at beginning of the frame (sec) double fps; // Average fps. bool quit; // Set to true to quit the application. int view_effects; // EFFECT_WIREFRAME | EFFECT_GRID | EFFECT_EDGES // All the gestures we listen to. Up to 16. gesture_t *gestures[16]; int gestures_count; pathtracer_t pathtracer; // Used to check if the active mesh changed to play tick sound. uint64_t last_mesh_key; double last_click_time; // Some stats for the UI. struct { void (*current_panel)(void); float panel_width; float viewport[4]; } gui; } goxel_t; // the global goxel instance. extern goxel_t goxel; // XXX: add some doc. void goxel_init(void); void goxel_release(void); void goxel_reset(void); int goxel_iter(inputs_t *inputs); void goxel_render(void); /* * Function: goxel_create_graphics * Called after the graphics context has been created. */ void goxel_create_graphics(void); /* * Function: goxel_release_graphics * Called before the graphics context gets destroyed. */ void goxel_release_graphics(void); /* * Function: goxel_on_low_memory * Attempt to release cached memory */ void goxel_on_low_memory(void); int goxel_unproject(const float viewport[4], const float pos[2], int snap_mask, float offset, float out[3], float normal[3]); void goxel_render_view(const float viewport[4], bool render_mode); void goxel_render_export_view(const float viewport[4]); // Called by the gui when the mouse hover a 3D view. // XXX: change the name since we also call it when the mouse get out of // the view. void goxel_mouse_in_view(const float viewport[4], const inputs_t *inputs, bool capture_keys); const mesh_t *goxel_get_layers_mesh(const image_t *img); const mesh_t *goxel_get_render_mesh(const image_t *img); /* * Function: goxel_get_render_layers * Compute merged current image layer list * * This returns a simplified list of layers from the current image where * we merged as many layers as possible into a single one. * * It also can replace the current layer mesh with the tool preview. * * This is the function that should be used the get the actual list of layers * to be rendered. */ const layer_t *goxel_get_render_layers(bool with_tool_preview); void goxel_set_help_text(const char *msg, ...); void goxel_set_hint_text(const char *msg, ...); void goxel_import_image_plane(const char *path); int goxel_import_file(const char *path, const char *format); int goxel_export_to_file(const char *path, const char *format); // Render the view into an RGB[A] buffer. void goxel_render_to_buf(uint8_t *buf, int w, int h, int bpp); void save_to_file(const image_t *img, const char *path); int load_from_file(const char *path, bool replace); // Iter info of a gox file, without actually reading it. // For the moment only returns the image preview if available. int gox_iter_infos(const char *path, int (*callback)(const char *attr, int size, void *value, void *user), void *user); // Section: box_edit /* * Function: gox_edit * Render a box that can be edited with the mouse. * * This is used for the move and selection tools. * Still a bit experimental. In theory we should be able to edit any box, * but because of the snap mechanism, we can only edit the layer or selection * for the moment. * * Parameters: * snap - SNAP_LAYER_OUT for layer edit, SNAP_SELECTION_OUT for selection * edit. * mode - 0: move, 1: resize. * transf - Receive the output transformation. * first - Set to true if the edit is the first one. */ int box_edit(int snap, int mode, float transf[4][4], bool *first); void settings_load(void); void settings_save(void); // Section: tests /* Function: tests_run * Run all the unit tests */ void tests_run(void); #endif // GOXEL_H goxel-0.11.0/src/gui.cpp000066400000000000000000001506641435762723100150140ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef GUI_HAS_MENU # define GUI_HAS_MENU 1 #endif #ifndef GUI_HAS_SCROLLBARS # define GUI_HAS_SCROLLBARS 1 #endif extern "C" { #include "goxel.h" void gui_app(void); void gui_render_panel(void); void gui_menu(void); } #ifndef typeof # define typeof __typeof__ #endif #define IM_VEC4_CLASS_EXTRA \ ImVec4(const uint8_t f[4]) { \ x = f[0] / 255.; \ y = f[1] / 255.; \ z = f[2] / 255.; \ w = f[3] / 255.; } \ // Prevent warnings with gcc. #ifndef __clang__ #pragma GCC diagnostic push #if __GNUC__ >= 8 #pragma GCC diagnostic ignored "-Wclass-memaccess" #endif #endif #define IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DISABLE_OBSOLETE_FUNCTIONS #include "../ext_src/imgui/imgui.h" #include "../ext_src/imgui/imgui_internal.h" #ifndef __clang__ #pragma GCC diagnostic pop #endif static ImVec4 imvec4(const uint8_t v[4]) { return ImVec4(v[0] / 255., v[1] / 255., v[2] / 255., v[3] / 255.); } static inline ImVec4 color_lighten(ImVec4 c, float k) { c.x *= k; c.y *= k; c.z *= k; return c; } namespace ImGui { void GoxBox2(ImVec2 pos, ImVec2 size, ImVec4 color, bool fill, float thickness = 1, int rounding_corners_flags = ~0) { ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; ImGuiWindow* window = GetCurrentWindow(); float r = style.FrameRounding; size.x = size.x ?: ImGui::GetContentRegionAvail().x; if (fill) { window->DrawList->AddRectFilled( pos, pos + size, ImGui::ColorConvertFloat4ToU32(color), r, rounding_corners_flags); } else { window->DrawList->AddRect( pos, pos + size, ImGui::ColorConvertFloat4ToU32(color), r, rounding_corners_flags, thickness); } } void GoxBox(ImVec2 pos, ImVec2 size, bool selected, int rounding_corners_flags = ~0) { ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; ImVec4 color = style.Colors[selected ? ImGuiCol_ButtonActive : ImGuiCol_Button]; return GoxBox2(pos, size, color, true, 1, rounding_corners_flags); } bool GoxInputFloat(const char *label, float *v, float step, float minv, float maxv, const char *format) { const theme_t *theme = theme_get(); bool ret = false; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImVec2 button_sz = ImVec2( max(g.FontSize * 2.0f, theme->sizes.item_height), g.FontSize + style.FramePadding.y * 2.0f); int button_flags = ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups; float speed = step / 20; uint8_t color[4]; char buf[128]; bool input_active; ImVec4 text_color; ImGui::PushID(label); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 1)); // XXX: commented out for the moment so that diabled input work. // theme_get_color(THEME_GROUP_WIDGET, THEME_COLOR_TEXT, 0, color); // ImGui::PushStyleColor(ImGuiCol_Text, imvec4(color)); theme_get_color(THEME_GROUP_WIDGET, THEME_COLOR_INNER, 0, color); ImGui::PushStyleColor(ImGuiCol_Button, imvec4(color)); ImGui::PushStyleColor(ImGuiCol_FrameBg, imvec4(color)); ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, color_lighten(imvec4(color), 1.2)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, color_lighten(imvec4(color), 1.2)); ImGui::SetWindowFontScale(0.75); if (ImGui::ButtonEx("◀", button_sz, button_flags)) { (*v) -= step; ret = true; } ImGui::SetWindowFontScale(1); ImGui::SameLine(); ImGui::PushItemWidth( ImGui::GetContentRegionAvail().x - button_sz.x - style.ItemSpacing.x); input_active = ImGui::TempInputTextIsActive(ImGui::GetID("")); text_color = ImGui::GetStyleColorVec4(ImGuiCol_Text); if (!input_active) text_color = ImVec4(0, 0, 0, 0); ImGui::PushStyleColor(ImGuiCol_Text, text_color); ret |= ImGui::DragFloat("", v, speed, minv, maxv, format, 1.0); ImGui::PopStyleColor(); if (!input_active) { snprintf(buf, sizeof(buf), "%s:", label); ImGui::RenderTextClipped(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), buf, NULL, NULL, ImVec2(0, 0.5)); snprintf(buf, sizeof(buf), format, *v); ImGui::RenderTextClipped(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), buf, NULL, NULL, ImVec2(1, 0.5)); } ImGui::PopItemWidth(); ImGui::SameLine(); ImGui::SetWindowFontScale(0.75); if (ImGui::ButtonEx("▶", button_sz, button_flags)) { (*v) += step; ret = true; } ImGui::SetWindowFontScale(1); ImGui::PopStyleColor(4); ImGui::PopStyleVar(); ImGui::PopID(); if (ret) *v = clamp(*v, minv, maxv); return ret; } }; static texture_t *g_tex_icons = NULL; static const char *VSHADER = " \n" "attribute vec3 a_pos; \n" "attribute vec2 a_tex_pos; \n" "attribute vec4 a_color; \n" " \n" "uniform mat4 u_proj_mat; \n" " \n" "varying vec2 v_tex_pos; \n" "varying vec4 v_color; \n" " \n" "void main() \n" "{ \n" " gl_Position = u_proj_mat * vec4(a_pos, 1.0); \n" " v_tex_pos = a_tex_pos; \n" " v_color = a_color; \n" "} \n" ; static const char *FSHADER = " \n" "#ifdef GL_ES \n" "precision mediump float; \n" "#endif \n" " \n" "uniform sampler2D u_tex; \n" " \n" "varying vec2 v_tex_pos; \n" "varying vec4 v_color; \n" " \n" "void main() \n" "{ \n" " gl_FragColor = v_color * texture2D(u_tex, v_tex_pos); \n" "} \n" ; typedef struct { float rect[4]; void *user; void (*render)(void *user, const float viewport[4]); } view_t; enum { A_POS_LOC = 0, A_TEX_POS_LOC, A_COLOR_LOC, }; static const char *ATTR_NAMES[] = { [A_POS_LOC] = "a_pos", [A_TEX_POS_LOC] = "a_tex_pos", [A_COLOR_LOC] = "a_color", NULL }; typedef typeof(((inputs_t*)0)->safe_margins) margins_t; typedef struct gui_t { gl_shader_t *shader; GLuint array_buffer; GLuint index_buffer; const inputs_t *inputs; view_t view; struct { gesture_t drag; gesture_t hover; } gestures; bool capture_mouse; // Mouse is captured by a window. int group; margins_t margins; bool is_scrolling; struct { const char *title; int (*func)(void *data); void (*on_closed)(int); int flags; void *data; // Automatically released when popup close. bool opened; } popup[8]; // Stack of modal popups int popup_count; } gui_t; static gui_t *gui = NULL; static void on_click(void) { if (DEFINED(GUI_SOUND)) sound_play("click", 1.0, 1.0); } static bool isCharPressed(int c) { // TODO: remove this function if possible. ImGuiContext& g = *GImGui; if (g.IO.InputQueueCharacters.Size == 0) return false; return g.IO.InputQueueCharacters[0] == c; } #define COLOR(g, c, s) ({ \ uint8_t c_[4]; \ theme_get_color(THEME_GROUP_##g, THEME_COLOR_##c, (s), c_); \ ImVec4 ret_ = c_; ret_; }) /* * Return the color that should be used to draw an icon depending on the * style and the icon. Some icons shouldn't have their color change with * the style and some other do. */ static uint32_t get_icon_color(int icon, bool selected) { return (icon >= ICON_COLORIZABLE_START && icon < ICON_COLORIZABLE_END) ? ImGui::GetColorU32(COLOR(WIDGET, TEXT, selected)) : 0xFFFFFFFF; } static void render_prepare_context(void) { #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT)) // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled GL(glEnable(GL_BLEND)); GL(glBlendEquation(GL_FUNC_ADD)); GL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); GL(glDisable(GL_CULL_FACE)); GL(glDisable(GL_DEPTH_TEST)); GL(glEnable(GL_SCISSOR_TEST)); GL(glActiveTexture(GL_TEXTURE0)); // Setup orthographic projection matrix const float width = ImGui::GetIO().DisplaySize.x; const float height = ImGui::GetIO().DisplaySize.y; const float ortho_projection[4][4] = { { 2.0f/width, 0.0f, 0.0f, 0.0f }, { 0.0f, 2.0f/-height, 0.0f, 0.0f }, { 0.0f, 0.0f, -1.0f, 0.0f }, { -1.0f, 1.0f, 0.0f, 1.0f }, }; GL(glUseProgram(gui->shader->prog)); gl_update_uniform(gui->shader, "u_tex", 0); gl_update_uniform(gui->shader, "u_proj_mat", ortho_projection); GL(glBindBuffer(GL_ARRAY_BUFFER, gui->array_buffer)); GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gui->index_buffer)); // This could probably be done only at init time. GL(glEnableVertexAttribArray(A_POS_LOC)); GL(glEnableVertexAttribArray(A_TEX_POS_LOC)); GL(glEnableVertexAttribArray(A_COLOR_LOC)); GL(glVertexAttribPointer(A_POS_LOC, 2, GL_FLOAT, false, sizeof(ImDrawVert), (void*)OFFSETOF(ImDrawVert, pos))); GL(glVertexAttribPointer(A_TEX_POS_LOC, 2, GL_FLOAT, false, sizeof(ImDrawVert), (void*)OFFSETOF(ImDrawVert, uv))); GL(glVertexAttribPointer(A_COLOR_LOC, 4, GL_UNSIGNED_BYTE, true, sizeof(ImDrawVert), (void*)OFFSETOF(ImDrawVert, col))); #undef OFFSETOF } static void ImImpl_RenderDrawLists(ImDrawData* draw_data) { const float height = ImGui::GetIO().DisplaySize.y; const float scale = ImGui::GetIO().DisplayFramebufferScale.y; render_prepare_context(); for (int n = 0; n < draw_data->CmdListsCount; n++) { const ImDrawList* cmd_list = draw_data->CmdLists[n]; const ImDrawIdx* idx_buffer_offset = 0; if (cmd_list->VtxBuffer.size()) GL(glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.size() * sizeof(ImDrawVert), (GLvoid*)&cmd_list->VtxBuffer.front(), GL_DYNAMIC_DRAW)); if (cmd_list->IdxBuffer.size()) GL(glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx), (GLvoid*)&cmd_list->IdxBuffer.front(), GL_DYNAMIC_DRAW)); for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++) { if (pcmd->UserCallback) { pcmd->UserCallback(cmd_list, pcmd); render_prepare_context(); // Restore context. } else { GL(glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId)); GL(glScissor((int)pcmd->ClipRect.x * scale, (int)(height - pcmd->ClipRect.w) * scale, (int)(pcmd->ClipRect.z - pcmd->ClipRect.x) * scale, (int)(pcmd->ClipRect.w - pcmd->ClipRect.y) * scale)); GL(glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, GL_UNSIGNED_SHORT, idx_buffer_offset)); } idx_buffer_offset += pcmd->ElemCount; } } GL(glDisable(GL_SCISSOR_TEST)); } static void load_fonts_texture() { ImGuiIO& io = ImGui::GetIO(); float scale = goxel.screen_scale; unsigned char* pixels; int width, height; const void *data; int data_size; ImFontConfig conf; const ImWchar ranges[] = { 0x0020, 0x00FF, // Basic Latin + Latin Supplement 0x25A0, 0x25FF, // Geometric shapes 0 }; conf.FontDataOwnedByAtlas = false; data = assets_get("asset://data/fonts/DejaVuSans-light.ttf", &data_size); assert(data); io.Fonts->AddFontFromMemoryTTF((void*)data, data_size, 14 * scale, &conf, ranges); io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); GLuint tex_id; GL(glGenTextures(1, &tex_id)); GL(glActiveTexture(GL_TEXTURE0)); GL(glBindTexture(GL_TEXTURE_2D, tex_id)); GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); GL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels)); io.Fonts->TexID = (void *)(intptr_t)tex_id; } static void init_ImGui(void) { ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); io.DeltaTime = 1.0f/60.0f; io.IniFilename = NULL; io.KeyMap[ImGuiKey_Tab] = KEY_TAB; io.KeyMap[ImGuiKey_LeftArrow] = KEY_LEFT; io.KeyMap[ImGuiKey_RightArrow] = KEY_RIGHT; io.KeyMap[ImGuiKey_UpArrow] = KEY_UP; io.KeyMap[ImGuiKey_DownArrow] = KEY_DOWN; io.KeyMap[ImGuiKey_PageUp] = KEY_PAGE_UP; io.KeyMap[ImGuiKey_PageDown] = KEY_PAGE_DOWN; io.KeyMap[ImGuiKey_Home] = KEY_HOME; io.KeyMap[ImGuiKey_End] = KEY_END; io.KeyMap[ImGuiKey_Delete] = KEY_DELETE; io.KeyMap[ImGuiKey_Backspace] = KEY_BACKSPACE; io.KeyMap[ImGuiKey_Enter] = KEY_ENTER; io.KeyMap[ImGuiKey_Escape] = KEY_ESCAPE; io.KeyMap[ImGuiKey_Space] = ' '; io.KeyMap[ImGuiKey_A] = 'A'; io.KeyMap[ImGuiKey_C] = 'C'; io.KeyMap[ImGuiKey_V] = 'V'; io.KeyMap[ImGuiKey_X] = 'X'; io.KeyMap[ImGuiKey_Y] = 'Y'; io.KeyMap[ImGuiKey_Z] = 'Z'; if (DEFINED(__linux__)) { io.SetClipboardTextFn = sys_set_clipboard_text; io.GetClipboardTextFn = sys_get_clipboard_text; } } static bool color_edit(const char *name, uint8_t color[4], const uint8_t backup_color[4]) { bool ret = false; ImVec4 col = color; ImVec4 backup_col; if (backup_color) backup_col = backup_color; ImGui::Text("Pick Color"); ImGui::Separator(); ret |= ImGui::ColorPicker4("##picker", (float*)&col, ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_NoAlpha); gui_same_line(); ImGui::BeginGroup(); ImGui::Text("Current"); ImGui::ColorButton("##current", col, ImGuiColorEditFlags_NoPicker, ImVec2(60, 40)); if (backup_color) { ImGui::Text("Previous"); if (ImGui::ColorButton("##previous", backup_col, ImGuiColorEditFlags_NoPicker, ImVec2(60, 40))) { col = backup_col; ret = true; } } ImGui::EndGroup(); if (ret) { color[0] = col.x * 255; color[1] = col.y * 255; color[2] = col.z * 255; color[3] = col.w * 255; } return ret; } static int on_gesture(const gesture_t *gest, void *user) { gui_t *gui = (gui_t*)user; ImGuiIO& io = ImGui::GetIO(); if (DEFINED(GOXEL_MOBILE) && gest->type == GESTURE_HOVER) return 0; io.MousePos = ImVec2(gest->pos[0], gest->pos[1]); io.MouseDown[0] = (gest->type == GESTURE_DRAG) && (gest->state != GESTURE_END); if (gest->state == GESTURE_END || gest->type == GESTURE_HOVER) { gui->capture_mouse = false; } if (gest->state == GESTURE_END && gest->type != GESTURE_HOVER) { gui_iter(NULL); io.MousePos = ImVec2(-1, -1); } return 0; } static void gui_init(void) { if (!gui) { gui = (gui_t*)calloc(1, sizeof(*gui)); init_ImGui(); gui->gestures.drag.type = GESTURE_DRAG; gui->gestures.drag.button = GESTURE_LMB; gui->gestures.drag.callback = on_gesture; gui->gestures.hover.type = GESTURE_HOVER; gui->gestures.hover.callback = on_gesture; goxel.gui.panel_width = GUI_PANEL_WIDTH_NORMAL; } if (!gui->shader) { gui->shader = gl_shader_create(VSHADER, FSHADER, NULL, ATTR_NAMES); GL(glGenBuffers(1, &gui->array_buffer)); GL(glGenBuffers(1, &gui->index_buffer)); } if (!g_tex_icons) { g_tex_icons = texture_new_image("asset://data/images/icons.png", 0); GL(glBindTexture(GL_TEXTURE_2D, g_tex_icons->tex)); } ImGuiIO& io = ImGui::GetIO(); if (!io.Fonts->TexID) load_fonts_texture(); } void gui_release(void) { if (gui) ImGui::DestroyContext(); } void gui_release_graphics(void) { ImGuiIO& io = ImGui::GetIO(); gl_shader_delete(gui->shader); gui->shader = NULL; GL(glDeleteBuffers(1, &gui->array_buffer)); GL(glDeleteBuffers(1, &gui->index_buffer)); texture_delete(g_tex_icons); g_tex_icons = NULL; GL(glDeleteTextures(1, (GLuint*)&io.Fonts->TexID)); io.Fonts->TexID = 0; io.Fonts->Clear(); } static int alert_popup(void *data) { if (data) gui_text((const char *)data); return gui_button("OK", 0, 0); } static int check_action_shortcut(action_t *action, void *user) { ImGuiIO& io = ImGui::GetIO(); const char *s = action->shortcut; bool check_key = true; bool check_char = true; if (!*s) return 0; if (io.KeyCtrl) { if (!str_startswith(s, "Ctrl")) return 0; s += strlen("Ctrl "); check_char = false; } else { if (str_startswith(s, "Ctrl")) return 0; } if (io.KeyShift) { check_key = false; } if ( (check_char && isCharPressed(s[0])) || (check_key && ImGui::IsKeyPressed(s[0], false))) { action_exec(action); return 1; } return 0; } static void render_menu(void) { ImGui::PushStyleColor(ImGuiCol_PopupBg, COLOR(MENU, INNER, 0)); ImGui::PushStyleColor(ImGuiCol_Text, COLOR(MENU, TEXT, 0)); if (!ImGui::BeginMenuBar()) return; gui_menu(); ImGui::EndMenuBar(); ImGui::PopStyleColor(2); } static void render_popups(int index) { int r; typeof(gui->popup[0]) *popup; ImGuiIO& io = ImGui::GetIO(); popup = &gui->popup[index]; if (!popup->title) return; if (!popup->opened) { ImGui::OpenPopup(popup->title); popup->opened = true; } int flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove; if (popup->flags & GUI_POPUP_FULL) { ImGui::SetNextWindowSize(ImVec2(io.DisplaySize.x - 40, io.DisplaySize.y - 40), (popup->flags & GUI_POPUP_RESIZE) ? ImGuiCond_Once : 0); } if (popup->flags & GUI_POPUP_RESIZE) { flags &= ~(ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize); } ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10)); if (ImGui::BeginPopupModal(popup->title, NULL, flags)) { typeof(popup->func) func = popup->func; if ((r = func(popup->data))) { ImGui::CloseCurrentPopup(); gui->popup_count--; popup->title = NULL; popup->func = NULL; free(popup->data); popup->data = NULL; if (popup->on_closed) popup->on_closed(r); popup->on_closed = NULL; popup->opened = false; } render_popups(index + 1); ImGui::EndPopup(); } ImGui::PopStyleVar(); } void gui_iter(const inputs_t *inputs) { gui_init(); unsigned int i; ImGuiIO& io = ImGui::GetIO(); ImGuiStyle& style = ImGui::GetStyle(); const theme_t *theme = theme_get(); gesture_t *gestures[] = {&gui->gestures.drag, &gui->gestures.hover}; float display_rect[4] = { 0.f, 0.f, (float)goxel.screen_size[0], (float)goxel.screen_size[1]}; float font_size = ImGui::GetFontSize(); io.DisplaySize = ImVec2((float)goxel.screen_size[0], (float)goxel.screen_size[1]); io.DisplayFramebufferScale = ImVec2(goxel.screen_scale, goxel.screen_scale); io.DeltaTime = goxel.delta_time; gui->inputs = inputs; if (inputs) { io.DisplayFramebufferScale = ImVec2(inputs->scale, inputs->scale); io.FontGlobalScale = 1 / inputs->scale; gui->margins = inputs->safe_margins; gesture_update(2, gestures, inputs, display_rect, gui); io.MouseWheel = inputs->mouse_wheel; for (i = 0; i < ARRAY_SIZE(inputs->keys); i++) io.KeysDown[i] = inputs->keys[i]; io.KeyShift = inputs->keys[KEY_LEFT_SHIFT] || inputs->keys[KEY_RIGHT_SHIFT]; io.KeyCtrl = inputs->keys[KEY_CONTROL]; for (i = 0; i < ARRAY_SIZE(inputs->chars); i++) { if (!inputs->chars[i]) break; io.AddInputCharacter(inputs->chars[i]); } memset((void*)inputs->chars, 0, sizeof(inputs->chars)); } // Setup theme. style.FramePadding = ImVec2(theme->sizes.item_padding_h, (theme->sizes.item_height - font_size) / 2); style.FrameRounding = theme->sizes.item_rounding; style.ItemSpacing = ImVec2(theme->sizes.item_spacing_h, theme->sizes.item_spacing_v); style.ItemInnerSpacing = ImVec2(theme->sizes.item_inner_spacing_h, 0); style.ScrollbarSize = theme->sizes.item_height; style.GrabMinSize = theme->sizes.item_height; style.WindowBorderSize = 0; style.ChildBorderSize = 0; style.WindowRounding = 0; style.WindowPadding = ImVec2(4, 4); style.Colors[ImGuiCol_WindowBg] = COLOR(BASE, BACKGROUND, 0); style.Colors[ImGuiCol_PopupBg] = ImVec4(0.38, 0.38, 0.38, 1.0); style.Colors[ImGuiCol_Header] = style.Colors[ImGuiCol_WindowBg]; style.Colors[ImGuiCol_Text] = COLOR(BASE, TEXT, 0); style.Colors[ImGuiCol_Button] = COLOR(BASE, INNER, 0); style.Colors[ImGuiCol_FrameBg] = COLOR(BASE, INNER, 0); style.Colors[ImGuiCol_PopupBg] = COLOR(BASE, BACKGROUND, 0); style.Colors[ImGuiCol_ButtonActive] = COLOR(BASE, INNER, 1); style.Colors[ImGuiCol_ButtonHovered] = color_lighten(COLOR(BASE, INNER, 0), 1.2); style.Colors[ImGuiCol_CheckMark] = COLOR(WIDGET, INNER, 1); style.Colors[ImGuiCol_MenuBarBg] = COLOR(MENU, BACKGROUND, 0); style.Colors[ImGuiCol_Border] = COLOR(BASE, OUTLINE, 0); ImGui::NewFrame(); // Create the root fullscreen window. ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoBringToFrontOnFocus | (GUI_HAS_MENU ? ImGuiWindowFlags_MenuBar : 0); ImGui::SetNextWindowSize(ImVec2( io.DisplaySize.x - (gui->margins.left + gui->margins.right), io.DisplaySize.y - gui->margins.top)); ImGui::SetNextWindowPos(ImVec2(gui->margins.left, gui->margins.top)); ImGui::Begin("Goxel", NULL, window_flags); render_popups(0); goxel.no_edit = gui->popup_count; if (gui->popup_count) gui->capture_mouse = true; if (GUI_HAS_MENU) render_menu(); gui_app(); ImGui::End(); // Handle the shortcuts. XXX: this should be done with actions. if (ImGui::IsKeyPressed(KEY_DELETE, false)) action_exec2(ACTION_layer_clear); if (!io.WantCaptureKeyboard) { float last_tool_radius = goxel.tool_radius; if (isCharPressed('[')) goxel.tool_radius -= 0.5; if (isCharPressed(']')) goxel.tool_radius += 0.5; if (goxel.tool_radius != last_tool_radius) { goxel.tool_radius = clamp(goxel.tool_radius, 0.5, 64); } actions_iter(check_action_shortcut, NULL); } ImGui::EndFrame(); sys_show_keyboard(io.WantTextInput); } void gui_render(void) { gui_init(); ImGui::Render(); ImImpl_RenderDrawLists(ImGui::GetDrawData()); } extern "C" { using namespace ImGui; static void reset_context_callback(const ImDrawList* parent_list, const ImDrawCmd* cmd) { // Do nothing. } void gui_group_begin(const char *label) { ImDrawList* draw_list = ImGui::GetWindowDrawList(); if (label) ImGui::Text("%s", label); ImGui::PushID(label ? label : "group"); gui->group++; draw_list->ChannelsSplit(2); draw_list->ChannelsSetCurrent(1); ImGui::BeginGroup(); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(1, 1)); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0); } void gui_group_end(void) { gui->group--; ImGui::PopID(); ImGui::PopStyleVar(2); ImGui::Dummy(ImVec2(0, 0)); ImGui::EndGroup(); ImDrawList* draw_list = ImGui::GetWindowDrawList(); draw_list->ChannelsSetCurrent(0); ImVec2 pos = ImGui::GetItemRectMin(); ImVec2 size = ImGui::GetItemRectMax() - pos; GoxBox2(pos, size, COLOR(WIDGET, OUTLINE, 0), true); draw_list->ChannelsMerge(); draw_list->AddCallback(reset_context_callback, NULL); GoxBox2(pos, size, COLOR(WIDGET, OUTLINE, 0), false); } void gui_div_begin(void) { ImGui::BeginGroup(); } void gui_div_end(void) { ImGui::EndGroup(); } void gui_child_begin(const char *id, float w, float h) { ImGui::BeginChild(id, ImVec2(w, h), false, ImGuiWindowFlags_NoScrollWithMouse); } void gui_child_end(void) { ImGui::EndChild(); } bool gui_input_int(const char *label, int *v, int minv, int maxv) { float minvf = minv; float maxvf = maxv; bool ret; float vf = *v; if (minv == 0 && maxv == 0) { minvf = -FLT_MAX; maxvf = +FLT_MAX; } ret = gui_input_float(label, &vf, 1, minvf, maxvf, "%.0f"); if (ret) *v = vf; return ret; } bool gui_input_float(const char *label, float *v, float step, float minv, float maxv, const char *format) { bool self_group = false, ret; if (minv == 0.f && maxv == 0.f) { minv = -FLT_MAX; maxv = +FLT_MAX; } if (gui->group == 0) { gui_group_begin(NULL); self_group = true; } if (step == 0.f) step = 0.1f; if (!format) format = "%.1f"; ret = ImGui::GoxInputFloat(label, v, step, minv, maxv, format); if (ret) on_click(); if (self_group) gui_group_end(); return ret; } bool gui_bbox(float box[4][4]) { int x, y, z, w, h, d; bool ret = false; float p[3]; w = box[0][0] * 2; h = box[1][1] * 2; d = box[2][2] * 2; x = round(box[3][0] - box[0][0]); y = round(box[3][1] - box[1][1]); z = round(box[3][2] - box[2][2]); gui_group_begin("Origin"); ret |= gui_input_int("x", &x, 0, 0); ret |= gui_input_int("y", &y, 0, 0); ret |= gui_input_int("z", &z, 0, 0); gui_group_end(); gui_group_begin("Size"); ret |= gui_input_int("w", &w, 1, 2048); ret |= gui_input_int("h", &h, 1, 2048); ret |= gui_input_int("d", &d, 1, 2048); gui_group_end(); if (ret) { vec3_set(p, x + w / 2., y + h / 2., z + d / 2.); bbox_from_extents(box, p, w / 2., h / 2., d / 2.); } return ret; } bool gui_angle(const char *id, float *v, int vmin, int vmax) { int a; bool ret; a = round(*v * DR2D); ret = gui_input_int(id, &a, vmin, vmax); if (ret) { if (vmin == 0 && vmax == 360) { while (a < 0) a += 360; a %= 360; } a = clamp(a, vmin, vmax); *v = (float)(a * DD2R); } return ret; } bool gui_action_button(int id, const char *label, float size) { bool ret; const action_t *action; action = action_get(id, true); assert(action); PushID(action->id); ret = gui_button(label, size, action->icon); if (IsItemHovered()) goxel_set_help_text(action_get(id, true)->help); if (ret) { action_exec(action_get(id, true)); } PopID(); return ret; } static bool _selectable(const char *label, bool *v, const char *tooltip, float w, int icon, int group) { const theme_t *theme = theme_get(); ImGuiWindow* window = GetCurrentWindow(); ImVec2 size; ImVec2 center; bool ret = false; bool default_v = false; ImVec2 uv0, uv1; // The position in the icon texture. uint8_t color[4]; v = v ? v : &default_v; size = (icon != -1) ? ImVec2(theme->sizes.icons_height, theme->sizes.icons_height) : ImVec2(w, theme->sizes.item_height); if (!tooltip) { tooltip = label; while (*tooltip == '#') tooltip++; } ImGui::PushID(label); theme_get_color(group, THEME_COLOR_INNER, *v, color); if (!*v && group == THEME_GROUP_TAB) color[3] = 0; PushStyleColor(ImGuiCol_Button, color); theme_get_color(group, THEME_COLOR_INNER, *v, color); PushStyleColor(ImGuiCol_ButtonHovered, color_lighten(color, 1.2)); theme_get_color(group, THEME_COLOR_TEXT, *v, color); PushStyleColor(ImGuiCol_Text, color); if (icon != -1) { ret = ImGui::Button("", size); if (icon) { center = (ImGui::GetItemRectMin() + ImGui::GetItemRectMax()) / 2; center.y += 0.5; uv0 = ImVec2(((icon - 1) % 8) / 8.0, ((icon - 1) / 8) / 8.0); uv1 = uv0 + ImVec2(1. / 8, 1. / 8); window->DrawList->AddImage((void*)(intptr_t)g_tex_icons->tex, center - ImVec2(16, 16), center + ImVec2(16, 16), uv0, uv1, get_icon_color(icon, *v)); } } else { ret = ImGui::Button(label, size); } ImGui::PopStyleColor(3); if (ret) *v = !*v; if (ImGui::IsItemHovered()) { gui_tooltip(tooltip); goxel_set_help_text(tooltip); } ImGui::PopID(); if (ret) on_click(); return ret; } bool gui_selectable(const char *name, bool *v, const char *tooltip, float w) { return _selectable(name, v, tooltip, w, -1, THEME_GROUP_WIDGET); } bool gui_selectable_toggle(const char *name, int *v, int set_v, const char *tooltip, float w) { bool b = *v == set_v; if (gui_selectable(name, &b, tooltip, w)) { if (b) *v = set_v; return true; } return false; } bool gui_selectable_icon(const char *name, bool *v, int icon) { return _selectable(name, v, NULL, 0, icon, THEME_GROUP_WIDGET); } float gui_get_avail_width(void) { return ImGui::GetContentRegionAvail().x; } void gui_text(const char *label, ...) { va_list args; va_start(args, label); TextV(label, args); va_end(args); } void gui_text_wrapped(const char *label, ...) { va_list args; ImGui::PushTextWrapPos(0); va_start(args, label); TextV(label, args); va_end(args); ImGui::PopTextWrapPos(); } void gui_same_line(void) { SameLine(); } void gui_spacing(int w) { ImGui::Dummy(ImVec2(w, 0)); ImGui::SameLine(); } bool gui_color(const char *label, uint8_t color[4]) { static uint8_t backup_color[4]; ImVec2 size; const theme_t *theme = theme_get(); size.x = size.y = theme->sizes.icons_height; ImGui::PushID(label); if (ImGui::ColorButton(label, color, 0, size)) memcpy(backup_color, color, 4); if (ImGui::BeginPopupContextItem("color context menu", 0)) { color_edit("##edit", color, backup_color); if (ImGui::Button("Close")) ImGui::CloseCurrentPopup(); ImGui::EndPopup(); } if (label && label[0] != '#') { gui_same_line(); ImGui::Text("%s", label); } ImGui::PopID(); return false; } bool gui_color_small(const char *label, uint8_t color[4]) { uint8_t orig[4]; memcpy(orig, color, 4); ImVec4 c = color; ImGui::PushID(label); ImGui::ColorButton(label, c); if (ImGui::BeginPopupContextItem("color context menu", 0)) { color_edit("##edit", color, NULL); if (ImGui::Button("Close")) { ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } gui_same_line(); ImGui::Text("%s", label); ImGui::PopID(); return memcmp(color, orig, 4) != 0; } bool gui_color_small_f3(const char *label, float color[3]) { uint8_t c[4] = {(uint8_t)(color[0] * 255), (uint8_t)(color[1] * 255), (uint8_t)(color[2] * 255), 255}; bool ret = gui_color_small(label, c); color[0] = c[0] / 255.; color[1] = c[1] / 255.; color[2] = c[2] / 255.; return ret; } bool gui_checkbox(const char *label, bool *v, const char *hint) { bool ret; const theme_t *theme = theme_get(); ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; // Checkbox inside a group box have a plain background. if (gui->group) { GoxBox2(ImGui::GetCursorScreenPos(), ImVec2(0, theme->sizes.item_height), COLOR(WIDGET, INNER, 0), true, 0); ImGui::PushStyleColor(ImGuiCol_FrameBg, color_lighten(style.Colors[ImGuiCol_FrameBg], 1.2)); } ret = Checkbox(label, v); if (gui->group) ImGui::PopStyleColor(); if (hint && ImGui::IsItemHovered()) gui_tooltip(hint); if (ret) on_click(); return ret; } bool gui_checkbox_flag(const char *label, int *v, int flag, const char *hint) { bool ret, b; b = (*v) & flag; ret = gui_checkbox(label, &b, hint); if (ret) { if (b) *v |= flag; else *v &= ~flag; } return ret; } bool gui_button(const char *label, float size, int icon) { bool ret; ImDrawList* draw_list = ImGui::GetWindowDrawList(); ImVec2 uv0, uv1; ImVec2 button_size; const theme_t *theme = theme_get(); ImVec2 center; int w, isize; button_size = ImVec2(size * GetContentRegionAvail().x, theme->sizes.item_height); if (size == -1) button_size.x = GetContentRegionAvail().x; if (size == 0 && (label == NULL || label[0] == '#')) { button_size.x = theme->sizes.icons_height; button_size.y = theme->sizes.icons_height; } if (size == 0 && label && label[0] != '#') { w = CalcTextSize(label, NULL, true).x + theme->sizes.item_padding_h * 2; if (w < theme->sizes.item_height) button_size.x = theme->sizes.item_height; } isize = (label && label[0] != '#' && label) ? 12 : 16; label = label ?: ""; ret = Button(label, button_size); if (icon) { center = GetItemRectMin() + ImVec2(GetItemRectSize().y / 2, GetItemRectSize().y / 2); uv0 = ImVec2(((icon - 1) % 8) / 8.0, ((icon - 1) / 8) / 8.0); uv1 = ImVec2(uv0.x + 1. / 8, uv0.y + 1. / 8); draw_list->AddImage((void*)(intptr_t)g_tex_icons->tex, center - ImVec2(isize, isize), center + ImVec2(isize, isize), uv0, uv1, get_icon_color(icon, 0)); } if (ret) on_click(); return ret; } bool gui_button_right(const char *label, int icon) { const theme_t *theme = theme_get(); float text_size = ImGui::CalcTextSize(label).x; float w = text_size + 2 * theme->sizes.item_padding_h; w = max(w, theme->sizes.item_height); w += theme->sizes.item_padding_h; gui_same_line(); ImGui::Dummy(ImVec2(ImGui::GetContentRegionAvail().x - w, 0)); gui_same_line(); return gui_button(label, 0, icon); } bool gui_input_text(const char *label, char *txt, int size) { return InputText(label, txt, size); } bool gui_input_text_multiline(const char *label, char *buf, int size, float width, float height) { // We set the frame color to a semi transparent value, because otherwise // we cannot render the error highlight. // XXX: fix that. bool ret; ImGuiStyle& style = ImGui::GetStyle(); ImVec4 col = style.Colors[ImGuiCol_FrameBg]; style.Colors[ImGuiCol_FrameBg].w = 0.5; ret = InputTextMultiline(label, buf, size, ImVec2(width, height)); style.Colors[ImGuiCol_FrameBg] = col; return ret; } bool gui_combo(const char *label, int *v, const char **names, int nb) { const theme_t *theme = theme_get(); bool ret; float font_size = ImGui::GetFontSize(); ImGui::PushItemWidth(-1); PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, (theme->sizes.item_height - font_size) / 2)); ImGui::PushStyleColor(ImGuiCol_PopupBg, COLOR(WIDGET, INNER, 0)); ret = Combo(label, v, names, nb); PopStyleVar(); PopStyleColor(); ImGui::PopItemWidth(); return ret; } bool gui_combo_begin(const char *label, const char *preview) { bool ret; const theme_t *theme = theme_get(); float font_size = ImGui::GetFontSize(); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, (theme->sizes.item_height - font_size) / 2)); ImGui::PushStyleColor(ImGuiCol_PopupBg, COLOR(WIDGET, INNER, 0)); ImGui::PushItemWidth(-1); ret = ImGui::BeginCombo(label, preview); if (!ret) { ImGui::PopItemWidth(); ImGui::PopStyleColor(); ImGui::PopStyleVar(); } return ret; } void gui_combo_end(void) { ImGui::EndCombo(); ImGui::PopItemWidth(); ImGui::PopStyleColor(); ImGui::PopStyleVar(); } bool gui_combo_item(const char *label, bool is_selected) { bool ret; ret = ImGui::Selectable(label, is_selected); if (is_selected) ImGui::SetItemDefaultFocus(); return ret; } void gui_input_text_multiline_highlight(int line) { float h = ImGui::CalcTextSize("").y; ImVec2 rmin = ImGui::GetItemRectMin(); ImVec2 rmax = ImGui::GetItemRectMax(); rmin.y = rmin.y + line * h + 2; rmax.y = rmin.y + h; ImDrawList* draw_list = ImGui::GetWindowDrawList(); draw_list->AddRectFilled(rmin, rmax, 0xff0000ff); } void gui_enabled_begin(bool enabled) { ImGuiStyle& style = ImGui::GetStyle(); ImVec4 color = style.Colors[ImGuiCol_Text]; if (!enabled) color.w /= 2; ImGui::PushStyleColor(ImGuiCol_Text, color); } void gui_enabled_end(void) { ImGui::PopStyleColor(); } bool gui_quat(const char *label, float q[4]) { // Hack to prevent weird behavior when we change the euler angles. // We keep track of the last used euler angles value and reuse them if // the quaternion is the same. static struct { float quat[4]; float eul[3]; } last = {}; float eul[3]; bool ret = false; if (memcmp(q, &last.quat, sizeof(last.quat)) == 0) vec3_copy(last.eul, eul); else quat_to_eul(q, EULER_ORDER_DEFAULT, eul); gui_group_begin(label); if (gui_angle("x", &eul[0], -180, +180)) ret = true; if (gui_angle("y", &eul[1], -180, +180)) ret = true; if (gui_angle("z", &eul[2], -180, +180)) ret = true; gui_group_end(); if (ret) { eul_to_quat(eul, EULER_ORDER_DEFAULT, q); quat_copy(q, last.quat); vec3_copy(eul, last.eul); } return ret; } void gui_open_popup(const char *title, int flags, void *data, int (*func)(void *data)) { typeof(gui->popup[0]) *popup; popup = &gui->popup[gui->popup_count++]; popup->title = title; popup->func = func; popup->flags = flags; assert(!popup->data); popup->data = data; } void gui_on_popup_closed(void (*func)(int)) { gui->popup[gui->popup_count - 1].on_closed = func; } void gui_popup_body_begin(void) { ImGui::BeginChild("body", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); } void gui_popup_body_end(void) { ImGui::EndChild(); } void gui_alert(const char *title, const char *msg) { gui_open_popup(title, 0, msg ? strdup(msg) : NULL, alert_popup); } bool gui_collapsing_header(const char *label, bool default_opened) { if (default_opened) ImGui::SetNextItemOpen(true, ImGuiCond_Once); return ImGui::CollapsingHeader(label); } void gui_columns(int count) { ImGui::Columns(count); } void gui_next_column(void) { ImGui::NextColumn(); } void gui_separator(void) { ImGui::Separator(); } void gui_push_id(const char *id) { ImGui::PushID(id); } void gui_pop_id(void) { ImGui::PopID(); } void gui_floating_icon(int icon) { ImDrawList* draw_list = ImGui::GetWindowDrawList(); ImVec2 uv0, uv1, pos; uv0 = ImVec2(((icon - 1) % 8) / 8.0, ((icon - 1) / 8) / 8.0); uv1 = ImVec2(uv0.x + 1. / 8, uv0.y + 1. / 8); pos = GetItemRectMin(); draw_list->AddImage((void*)(intptr_t)g_tex_icons->tex, pos, pos + ImVec2(32, 32), uv0, uv1, get_icon_color(icon, 0)); } void gui_bottom_text(const char *txt) { ImDrawList* draw_list = ImGui::GetWindowDrawList(); ImVec2 pos, size, text_size; float wrap; pos = GetItemRectMin(); size = GetItemRectSize(); wrap = size.x - 8; text_size = CalcTextSize(txt, NULL, false, wrap); draw_list->AddText(ImGui::GetFont(), ImGui::GetFontSize(), ImVec2(pos.x + 4, pos.y + size.y - text_size.y - 4), ImGui::GetColorU32(COLOR(WIDGET, TEXT, false)), txt, NULL, wrap); } void gui_request_panel_width(float width) { goxel.gui.panel_width = width; } bool gui_layer_item(int i, int icon, bool *visible, bool *edit, char *name, int len) { const theme_t *theme = theme_get(); bool ret = false; bool edit_ = *edit; static char *edit_name = NULL; static bool start_edit; float font_size = ImGui::GetFontSize(); ImVec2 center; ImVec2 uv0, uv1; ImDrawList* draw_list = ImGui::GetWindowDrawList(); ImGui::PushID(i); ImGui::PushStyleColor(ImGuiCol_Button, COLOR(WIDGET, INNER, *edit)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, color_lighten(COLOR(WIDGET, INNER, *edit), 1.2)); if (visible) { if (gui_selectable_icon("##visible", &edit_, *visible ? ICON_VISIBILITY : ICON_VISIBILITY_OFF)) { *visible = !*visible; ret = true; } gui_same_line(); } if (edit_name != name) { ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0.5)); if (icon != -1) { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(theme->sizes.icons_height / 1.5, 0)); } if (ImGui::Button(name, ImVec2(-1, theme->sizes.icons_height))) { *edit = true; ret = true; } if (icon != -1) ImGui::PopStyleVar(); if (icon > 0) { center = ImGui::GetItemRectMin() + ImVec2(theme->sizes.icons_height / 2 / 1.5, theme->sizes.icons_height / 2); uv0 = ImVec2(((icon - 1) % 8) / 8.0, ((icon - 1) / 8) / 8.0); uv1 = ImVec2(uv0.x + 1. / 8, uv0.y + 1. / 8); draw_list->AddImage( (void*)(intptr_t)g_tex_icons->tex, center - ImVec2(12, 12), center + ImVec2(12, 12), uv0, uv1, get_icon_color(icon, 0)); } ImGui::PopStyleVar(); if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) { edit_name = name; start_edit = true; } } else { if (start_edit) ImGui::SetKeyboardFocusHere(); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(theme->sizes.item_padding_h, (theme->sizes.icons_height - font_size) / 2)); ImGui::InputText("##name_edit", name, len, ImGuiInputTextFlags_AutoSelectAll); if (!start_edit && !ImGui::IsItemActive()) edit_name = NULL; start_edit = false; ImGui::PopStyleVar(); } ImGui::PopStyleColor(2); ImGui::PopID(); return ret; } bool gui_is_key_down(int key) { return ImGui::IsKeyDown(key); } bool gui_palette_entry(const uint8_t color[4], uint8_t target[4]) { bool ret; ImDrawList* draw_list = ImGui::GetWindowDrawList(); const theme_t *theme = theme_get(); ImGui::PushStyleColor(ImGuiCol_Button, color); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, color); ret = ImGui::Button("", ImVec2(theme->sizes.item_height, theme->sizes.item_height)); if (memcmp(color, target, 4) == 0) { draw_list->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), 0xFFFFFFFF, 0, 0, 1); } ImGui::PopStyleColor(2); if (ret) { on_click(); memcpy(target, color, 4); } return ret; } bool gui_menu_begin(const char *label) { bool ret = ImGui::BeginMenu(label); if (ret) gui->capture_mouse = true; return ret; } void gui_menu_end(void) { return ImGui::EndMenu(); } bool gui_menu_item(int action, const char *label, bool enabled) { const action_t *a = NULL; if (action) { a = action_get(action, true); assert(a); } if (ImGui::MenuItem(label, a ? a->shortcut : NULL, false, enabled)) { if (a) action_exec(a); return true; } return false; } void gui_scrollable_begin(int width) { ImGuiWindowFlags flags = 0; if (!GUI_HAS_SCROLLBARS) { if (gui->is_scrolling && !ImGui::IsAnyMouseDown()) gui->is_scrolling = false; flags |= ImGuiWindowFlags_NoScrollbar; if (gui->is_scrolling) flags |= ImGuiWindowFlags_NoInputs; } ImGui::BeginChild("#scroll", ImVec2(width, 0), true, flags); ImGui::BeginGroup(); } void gui_scrollable_end(void) { // XXX: make this attribute of the item instead, so that we can use // several scrollable widgets. static float scroll_y = 0; static float x, y; static float last_y; static float speed = 0; static int state; // 0: possible, 1: scrolling, 2: cancel. ImGui::EndGroup(); if (!GUI_HAS_SCROLLBARS) { if (ImGui::IsItemClicked()) { state = 0; speed = 0; y = ImGui::GetMousePos().y; x = ImGui::GetMousePos().x; last_y = y; scroll_y = ImGui::GetScrollY(); } if (ImGui::IsItemHovered()) { if (state == 0 && fabs(x - ImGui::GetMousePos().x) > 8) state = 2; if (state == 0 && fabs(y - ImGui::GetMousePos().y) > 8) { state = 1; gui->is_scrolling = true; } if (state == 1) { speed = mix(speed, last_y - ImGui::GetMousePos().y, 0.5); last_y = ImGui::GetMousePos().y; ImGui::ClearActiveID(); ImGui::SetScrollY(scroll_y + y - ImGui::GetMousePos().y); } } else if (speed) { ImGui::SetScrollY(ImGui::GetScrollY() + speed); speed *= 0.95; if (fabs(speed) < 1) speed = 0; } } ImGui::EndChild(); } void gui_tooltip(const char *str) { if (gui->is_scrolling) return; ImGui::SetTooltip("%s", str); } #if !DEFINED(GOXEL_MOBILE) bool gui_need_full_version(void) { return true; } #endif void gui_choice_begin(const char *label, int *value, bool small) { ImGuiStorage* storage = ImGui::GetStateStorage(); gui_group_begin(NULL); storage->SetVoidPtr(ImGui::GetID("choices#value"), value); storage->SetBool(ImGui::GetID("choices#small"), small); } bool gui_choice(const char *label, int idx, int icon) { ImGuiStorage* storage = ImGui::GetStateStorage(); int *value; bool selected, small; small = storage->GetBool(ImGui::GetID("choices#small")); value = (int*)storage->GetVoidPtr(ImGui::GetID("choices#value")); assert(value); if (storage->GetBool(ImGui::GetID("choices#change"))) { storage->SetBool(ImGui::GetID("choices#change"), false); *value = idx; } selected = (*value == idx); if (!small) { if (gui_selectable_icon(label, &selected, icon) && selected) { *value = idx; return true; } gui_same_line(); } else { if (!selected) return false; selected = false; if (gui_selectable_icon(label, &selected, icon)) { storage->SetBool(ImGui::GetID("choices#change"), true); } } return false; } void gui_choice_end(void) { gui_group_end(); } static void gui_canvas_(const ImDrawList* parent_list, const ImDrawCmd* cmd) { float scale = ImGui::GetIO().DisplayFramebufferScale.y; view_t *view = (view_t*)cmd->UserCallbackData; const float width = ImGui::GetIO().DisplaySize.x; const float height = ImGui::GetIO().DisplaySize.y; view->render(view->user, view->rect); GL(glViewport(0, 0, width * scale, height * scale)); } void gui_canvas(float w, float h, inputs_t *inputs, bool *has_mouse, bool *has_keyboard, void *user, void (*render)(void *user, const float viewport[4])) { int i; ImDrawList* draw_list = ImGui::GetWindowDrawList(); ImVec2 canvas_pos = ImGui::GetCursorScreenPos(); ImVec2 canvas_size = ImGui::GetContentRegionAvail(); ImGuiIO& io = ImGui::GetIO(); bool hovered; if (h < 0) canvas_size.y += h; vec4_set(gui->view.rect, canvas_pos.x, goxel.screen_size[1] - (canvas_pos.y + canvas_size.y), canvas_size.x, canvas_size.y); gui->view.user = user; gui->view.render = render; draw_list->AddCallback(gui_canvas_, &gui->view); ImGui::InvisibleButton("canvas", canvas_size); hovered = ImGui::IsItemHovered(); if ( gui->inputs && (hovered || !gui->inputs->mouse_wheel) && !gui->capture_mouse) { *has_mouse = true; *inputs = *gui->inputs; for (i = 0; i < (int)ARRAY_SIZE(inputs->touches); i++) { inputs->touches[i].pos[1] = io.DisplaySize.y - inputs->touches[i].pos[1]; } } else { *has_mouse = false; memset(inputs, 0, sizeof(*inputs)); } *has_keyboard = !io.WantCaptureKeyboard; } bool gui_tab(const char *label, int icon, bool *v) { return _selectable(label, v, NULL, 0, icon, THEME_GROUP_TAB); } bool gui_panel_header(const char *label) { const theme_t *theme = theme_get(); bool ret; float label_w = ImGui::CalcTextSize(label).x; float w = ImGui::GetContentRegionAvail().x - theme->sizes.item_height; gui_push_id("panel_header"); ImGui::Dummy(ImVec2((w - label_w) / 2, 0)); gui_same_line(); ImGui::AlignTextToFramePadding(); gui_text(label); ret = gui_button_right("", ICON_CLOSE); ImGui::Separator(); gui_pop_id(); return ret; } } goxel-0.11.0/src/gui.h000066400000000000000000000121721435762723100144500ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* * Section: Gui * * XXX: add doc and cleanup this. */ #ifndef GUI_H #define GUI_H #include "inputs.h" #ifndef GUI_PANEL_WIDTH_NORMAL # define GUI_PANEL_WIDTH_NORMAL 190 #endif #ifndef GUI_PANEL_WIDTH_LARGE # define GUI_PANEL_WIDTH_LARGE 400 #endif void gui_release(void); void gui_release_graphics(void); void gui_iter(const inputs_t *inputs); void gui_render(void); void gui_request_panel_width(float width); bool gui_panel_header(const char *label); void gui_canvas(float w, float h, inputs_t *inputs, bool *has_mouse, bool *has_keyboard, void *user, void (*render)(void *user, const float viewport[4])); // Gui widgets: bool gui_collapsing_header(const char *label, bool default_opened); void gui_text(const char *label, ...); void gui_text_wrapped(const char *label, ...); bool gui_button(const char *label, float w, int icon); bool gui_button_right(const char *label, int icon); void gui_group_begin(const char *label); void gui_group_end(void); void gui_div_begin(void); void gui_div_end(void); void gui_child_begin(const char *id, float w, float h); void gui_child_end(void); bool gui_tab(const char *label, int icon, bool *v); bool gui_checkbox(const char *label, bool *v, const char *hint); bool gui_checkbox_flag(const char *label, int *v, int flag, const char *hint); bool gui_input_int(const char *label, int *v, int minv, int maxv); bool gui_input_float(const char *label, float *v, float step, float minv, float maxv, const char *format); bool gui_angle(const char *id, float *v, int vmin, int vmax); bool gui_bbox(float box[4][4]); bool gui_quat(const char *label, float q[4]); bool gui_action_button(int id, const char *label, float size); bool gui_selectable(const char *name, bool *v, const char *tooltip, float w); bool gui_selectable_toggle(const char *name, int *v, int set_v, const char *tooltip, float w); bool gui_selectable_icon(const char *name, bool *v, int icon); bool gui_color(const char *label, uint8_t color[4]); bool gui_color_small(const char *label, uint8_t color[4]); bool gui_color_small_f3(const char *label, float color[3]); bool gui_input_text(const char *label, char *buf, int size); bool gui_input_text_multiline(const char *label, char *buf, int size, float width, float height); void gui_input_text_multiline_highlight(int line); bool gui_combo(const char *label, int *v, const char **names, int nb); bool gui_combo_begin(const char *label, const char *preview); bool gui_combo_item(const char *label, bool selected); void gui_combo_end(void); float gui_get_avail_width(void); void gui_same_line(void); void gui_enabled_begin(bool enabled); void gui_enabled_end(void); void gui_spacing(int w); // Add an icon in top left corner of last item. void gui_floating_icon(int icon); // Add a text at the bottom of last item. void gui_bottom_text(const char *txt); void gui_alert(const char *title, const char *msg); void gui_columns(int count); void gui_next_column(void); void gui_separator(void); void gui_push_id(const char *id); void gui_pop_id(void); bool gui_layer_item(int i, int icon, bool *visible, bool *edit, char *name, int len); bool gui_is_key_down(int key); bool gui_palette_entry(const uint8_t color[4], uint8_t target[4]); bool gui_need_full_version(void); void gui_query_quit(void); enum { GUI_POPUP_FULL = 1 << 0, GUI_POPUP_RESIZE = 1 << 1, }; /* * Function: gui_open_popup * Open a modal popup. * * Parameters: * title - The title of the popup. * flags - Union of values. * data - Data passed to the popup. It will be automatically released * by the gui. * func - The popup function, that render the popup gui. Should return * a non zero value to close the popup. */ void gui_open_popup(const char *title, int flags, void *data, int (*func)(void *data)); void gui_on_popup_closed(void (*func)(int v)); void gui_popup_body_begin(void); void gui_popup_body_end(void); bool gui_menu_begin(const char *label); void gui_menu_end(void); bool gui_menu_item(int action, const char *label, bool enabled); void gui_scrollable_begin(int width); void gui_scrollable_end(void); void gui_tooltip(const char *str); void gui_choice_begin(const char *label, int *value, bool small); bool gui_choice(const char *label, int idx, int icon); void gui_choice_end(void); #endif // GUI_H goxel-0.11.0/src/gui/000077500000000000000000000000001435762723100142745ustar00rootroot00000000000000goxel-0.11.0/src/gui/about.c000066400000000000000000000037611435762723100155610ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019-2022 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" int gui_about_popup(void *data) { gui_text("Goxel " GOXEL_VERSION_STR); gui_text("Copyright © 2015-2022 Guillaume Chereau"); gui_text(""); gui_text("All right reserved"); if (!DEFINED(GOXEL_MOBILE)) gui_text("GPL 3 License"); gui_text("http://guillaumechereau.github.io/goxel"); if (gui_collapsing_header("Credits", true)) { gui_text("Code:"); gui_text("● Guillaume Chereau "); gui_text("● Dustin Willis Webber "); gui_text("● Pablo Hugo Reda "); gui_text("● Othelarian (https://github.com/othelarian)"); gui_text("Libraries:"); gui_text("● dear imgui (https://github.com/ocornut/imgui)"); gui_text("● stb (https://github.com/nothings/stb)"); gui_text("● yocto-gl (https://github.com/xelatihy/yocto-gl)"); gui_text("● uthash (https://troydhanson.github.io/uthash/)"); gui_text("● inih (https://github.com/benhoyt/inih)"); gui_text("Design:"); gui_text("● Guillaume Chereau "); gui_text("● Michal (https://github.com/YarlBoro)"); } return gui_button("OK", 0, 0); } goxel-0.11.0/src/gui/app.c000066400000000000000000000112261435762723100152220ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #ifndef GUI_HAS_ROTATION_BAR # define GUI_HAS_ROTATION_BAR 0 #endif #ifndef GUI_HAS_HELP # define GUI_HAS_HELP 1 #endif #ifndef YOCTO # define YOCTO 1 #endif void gui_tools_panel(void); void gui_top_bar(void); void gui_palette_panel(void); void gui_layers_panel(void); void gui_view_panel(void); void gui_material_panel(void); void gui_light_panel(void); void gui_cameras_panel(void); void gui_image_panel(void); void gui_render_panel(void); void gui_debug_panel(void); void gui_export_panel(void); bool gui_rotation_bar(void); static const struct { const char *name; int icon; void (*fn)(void); } PANELS[] = { {NULL}, {"Tools", ICON_TOOLS, gui_tools_panel}, {"Palette", ICON_PALETTE, gui_palette_panel}, {"Layers", ICON_LAYERS, gui_layers_panel}, {"View", ICON_VIEW, gui_view_panel}, {"Material", ICON_MATERIAL, gui_material_panel}, {"Light", ICON_LIGHT, gui_light_panel}, {"Cameras", ICON_CAMERA, gui_cameras_panel}, {"Image", ICON_IMAGE, gui_image_panel}, #if YOCTO {"Render", ICON_RENDER, gui_render_panel}, #endif {"Export", ICON_EXPORT, gui_export_panel}, #if DEBUG {"Debug", ICON_DEBUG, gui_debug_panel}, #endif }; static void on_click(void) { if (DEFINED(GUI_SOUND)) sound_play("click", 1.0, 1.0); } static void render_left_panel(void) { int i, current_i = 0; const theme_t *theme = theme_get(); float left_pane_width; bool selected; static int panel_adjust_w; // Adjust size for scrollbar. left_pane_width = (goxel.gui.current_panel ? goxel.gui.panel_width : 0) + panel_adjust_w + theme->sizes.icons_height + 4; gui_scrollable_begin(left_pane_width); goxel.gui.panel_width = GUI_PANEL_WIDTH_NORMAL; // Small hack to adjust the size if the scrolling bar is visible. panel_adjust_w = left_pane_width - gui_get_avail_width(); gui_div_begin(); for (i = 1; i < (int)ARRAY_SIZE(PANELS); i++) { selected = (goxel.gui.current_panel == PANELS[i].fn); if (selected) current_i = i; if (gui_tab(PANELS[i].name, PANELS[i].icon, &selected)) { on_click(); goxel.gui.current_panel = selected ? PANELS[i].fn : NULL; current_i = goxel.gui.current_panel ? i : 0; } } gui_div_end(); goxel.show_export_viewport = false; if (goxel.gui.current_panel) { gui_same_line(); gui_div_begin(); gui_push_id("panel"); gui_push_id(PANELS[current_i].name); if (gui_panel_header(PANELS[current_i].name)) goxel.gui.current_panel = NULL; else goxel.gui.current_panel(); gui_pop_id(); gui_pop_id(); gui_div_end(); } gui_scrollable_end(); } static void render_view(void *user, const float viewport[4]) { bool render_mode; assert(sizeof(goxel.gui.viewport[0]) == sizeof(viewport[0])); memcpy(goxel.gui.viewport, viewport, sizeof(goxel.gui.viewport)); render_mode = goxel.gui.current_panel == gui_render_panel && goxel.pathtracer.status; goxel_render_view(viewport, render_mode); } void gui_app(void) { const theme_t *theme = theme_get(); inputs_t inputs; bool has_mouse, has_keyboard; gui_top_bar(); render_left_panel(); gui_same_line(); gui_child_begin("3d view", GUI_HAS_ROTATION_BAR ? -theme->sizes.item_height : 0, 0); gui_canvas(0, GUI_HAS_HELP ? -20 : 0, &inputs, &has_mouse, &has_keyboard, NULL, render_view); // Call mouse_in_view with inputs in the view referential. if (has_mouse) goxel_mouse_in_view(goxel.gui.viewport, &inputs, has_keyboard); if (GUI_HAS_HELP) { gui_text("%s", goxel.hint_text ?: ""); gui_same_line(); gui_spacing(180); gui_text("%s", goxel.help_text ?: ""); } gui_child_end(); if (GUI_HAS_ROTATION_BAR) { gui_same_line(); gui_rotation_bar(); } } goxel-0.11.0/src/gui/cameras_panel.c000066400000000000000000000057361435762723100172450ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" void gui_cameras_panel(void) { camera_t *cam; int i = 0; bool current; float rot[3][3], e1[3], e2[3], eul[3], pitch, yaw, v; gui_group_begin(NULL); DL_FOREACH(goxel.image->cameras, cam) { current = goxel.image->active_camera == cam; if (gui_layer_item(i, -1, NULL, ¤t, cam->name, sizeof(cam->name))) { goxel.image->active_camera = cam; } i++; } gui_group_end(); gui_action_button(ACTION_img_new_camera, NULL, 0); gui_same_line(); gui_action_button(ACTION_img_del_camera, NULL, 0); gui_same_line(); gui_action_button(ACTION_img_move_camera_up, NULL, 0); gui_same_line(); gui_action_button(ACTION_img_move_camera_down, NULL, 0); if (!goxel.image->cameras) image_add_camera(goxel.image, NULL); cam = goxel.image->active_camera; gui_input_float("dist", &cam->dist, 10.0, 0, 0, NULL); /* gui_group_begin("Offset"); gui_input_float("x", &cam->ofs[0], 1.0, 0, 0, NULL); gui_input_float("y", &cam->ofs[1], 1.0, 0, 0, NULL); gui_input_float("z", &cam->ofs[2], 1.0, 0, 0, NULL); gui_group_end(); gui_quat("Rotation", cam->rot); */ gui_checkbox("Ortho", &cam->ortho, NULL); gui_group_begin("Set"); gui_action_button(ACTION_view_left, "left", 0.5); gui_same_line(); gui_action_button(ACTION_view_right, "right", 1.0); gui_action_button(ACTION_view_front, "front", 0.5); gui_same_line(); gui_action_button(ACTION_view_top, "top", 1.0); gui_action_button(ACTION_view_default, "default", 1.0); gui_group_end(); // Allow to edit euler angles (Should this be a generic widget?) gui_group_begin(NULL); mat4_to_mat3(cam->mat, rot); mat3_to_eul2(rot, EULER_ORDER_XYZ, e1, e2); if (fabs(e1[1]) < fabs(e2[1])) vec3_copy(e1, eul); else vec3_copy(e2, eul); pitch = round(eul[0] * DR2D); if (pitch < 0) pitch += 360; v = pitch; if (gui_input_float("Pitch", &v, 1, -90, 90, "%.0f")) { v = (v - pitch) * DD2R; camera_turntable(cam, 0, v); } yaw = round(eul[2] * DR2D); v = yaw; if (gui_input_float("Yaw", &v, 1, -180, 180, "%.0f")) { v = (v - yaw) * DD2R; camera_turntable(cam, v, 0); } gui_group_end(); } goxel-0.11.0/src/gui/debug_panel.c000066400000000000000000000027211435762723100167070ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" void gui_debug_panel(void) { mesh_global_stats_t stats; gui_text("FPS: %d", (int)round(goxel.fps)); mesh_get_global_stats(&stats); gui_text("Nb meshes: %d", stats.nb_meshes); gui_text("Nb blocks: %d", stats.nb_blocks); gui_text("Mem: %dM", (int)(stats.mem / (1 << 20))); if (!DEFINED(GLES2)) { gui_checkbox_flag("Show wireframe", &goxel.view_effects, EFFECT_WIREFRAME, NULL); } if (gui_button("Clear undo history", -1, 0)) { image_history_resize(goxel.image, 0); } if (gui_button("On low memory", -1, 0)) { goxel_on_low_memory(); } if (gui_button("Test release", -1, 0)) { goxel.request_test_graphic_release = true; } } goxel-0.11.0/src/gui/export_panel.c000066400000000000000000000043301435762723100171400ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "file_format.h" #ifndef GUI_CUSTOM_EXPORT_PANEL #if 0 Keep this here as a reference until I fix file format names and order. {"glTF (.gltf)", "export_as_gltf"}, {"Wavefront (.obj)", "export_as_obj"}, {"Stanford (.pny)", "export_as_ply"}, {"Png", "export_as_png"}, {"Magica voxel (.vox)", "export_as_vox"}, {"Qubicle (.qb)", "export_as_qubicle"}, {"Slab (.kvx)", "export_as_kvx"}, {"Spades (.vxl)", "export_as_vxl"}, {"Png slices (.png)", "export_as_png_slices"}, {"Plain text (.txt)", "export_as_txt"}, #endif static const file_format_t *g_current = NULL; static const char *make_label(const file_format_t *f, char *buf, int len) { const char *ext = f->ext + strlen(f->ext) + 2; snprintf(buf, len, "%s (%s)", f->name, ext); return buf; } static void on_format(void *user, const file_format_t *f) { char label[128]; make_label(f, label, sizeof(label)); if (gui_combo_item(label, f == g_current)) { g_current = f; } } void gui_export_panel(void) { char label[128]; gui_text("Export as"); if (!g_current) g_current = file_formats; // First one. make_label(g_current, label, sizeof(label)); if (gui_combo_begin("Export as", label)) { file_format_iter("w", NULL, on_format); gui_combo_end(); } if (g_current->export_gui) g_current->export_gui(); if (gui_button("Export", 1, 0)) goxel_export_to_file(NULL, g_current->name); } #endif // GUI_CUSTOM_EXPORT_PANEL goxel-0.11.0/src/gui/image_panel.c000066400000000000000000000016531435762723100167060ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" void gui_image_panel(void) { image_t *image = goxel.image; float (*box)[4][4] = &image->box; gui_bbox(*box); gui_action_button(ACTION_img_auto_resize, "Auto resize", 0); } goxel-0.11.0/src/gui/layers_panel.c000066400000000000000000000106121435762723100171160ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #define DL_FOREACH_REVERSE(head, el) \ for (el = (head) ? (head)->prev : NULL; el; \ el = (el == (head)) ? NULL : el->prev) static void toggle_layer_only_visible(layer_t *layer) { layer_t *other; bool others_all_invisible = true; DL_FOREACH(goxel.image->layers, other) { if (other == layer) continue; if (other->visible) { others_all_invisible = false; break; } } DL_FOREACH(goxel.image->layers, other) other->visible = others_all_invisible; layer->visible = true; } void gui_layers_panel(void) { layer_t *layer; material_t *material; int i = 0, icon, bbox[2][3]; bool current, visible, bounded; gui_group_begin(NULL); DL_FOREACH_REVERSE(goxel.image->layers, layer) { current = goxel.image->active_layer == layer; visible = layer->visible; icon = layer->base_id ? ICON_LINK : layer->shape ? ICON_SHAPE : -1; gui_layer_item(i, icon, &visible, ¤t, layer->name, sizeof(layer->name)); if (current && goxel.image->active_layer != layer) { goxel.image->active_layer = layer; } if (visible != layer->visible) { layer->visible = visible; if (gui_is_key_down(KEY_LEFT_SHIFT)) toggle_layer_only_visible(layer); } i++; } gui_group_end(); gui_action_button(ACTION_img_new_layer, NULL, 0); gui_same_line(); gui_action_button(ACTION_img_del_layer, NULL, 0); gui_same_line(); gui_action_button(ACTION_img_move_layer_up, NULL, 0); gui_same_line(); gui_action_button(ACTION_img_move_layer_down, NULL, 0); gui_group_begin(NULL); gui_action_button(ACTION_img_duplicate_layer, "Duplicate", 1); gui_action_button(ACTION_img_clone_layer, "Clone", 1); gui_action_button(ACTION_img_merge_visible_layers, "Merge visible", 1); layer = goxel.image->active_layer; bounded = !box_is_null(layer->box); if (bounded && gui_button("Crop to box", 1, 0)) { mesh_crop(layer->mesh, layer->box); } if (!box_is_null(goxel.image->box) && gui_button("Crop to image", 1, 0)) { mesh_crop(layer->mesh, goxel.image->box); } if (layer->shape) gui_action_button(ACTION_img_unclone_layer, "To mesh", 1); if (gui_action_button(ACTION_img_new_shape_layer, "New Shape Layer", 1)) { action_exec2(ACTION_tool_set_move); } gui_group_end(); if (layer->base_id) { gui_group_begin(NULL); gui_action_button(ACTION_img_unclone_layer, "Unclone", 1); gui_action_button(ACTION_img_select_parent_layer, "Select parent", 1); gui_group_end(); } if (layer->image) { gui_action_button(ACTION_img_image_layer_to_mesh, "To Mesh", 1); } if (!layer->shape && gui_checkbox("Bounded", &bounded, NULL)) { if (bounded) { mesh_get_bbox(layer->mesh, bbox, true); if (bbox[0][0] > bbox[1][0]) memset(bbox, 0, sizeof(bbox)); bbox_from_aabb(layer->box, bbox); } else { mat4_copy(mat4_zero, layer->box); } } if (bounded) gui_bbox(layer->box); if (layer->shape) { tool_gui_drag_mode(&goxel.tool_drag_mode); tool_gui_shape(&layer->shape); gui_color("##color", layer->color); } gui_text("Material"); if (gui_combo_begin("##material", layer->material ? layer->material->name : NULL)) { DL_FOREACH(goxel.image->materials, material) { if (gui_combo_item(material->name, material == layer->material)) layer->material = material; } gui_combo_end(); } } goxel-0.11.0/src/gui/light_panel.c000066400000000000000000000027331435762723100167330ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" void gui_light_panel(void) { float v; gui_group_begin(NULL); gui_angle("Pitch", &goxel.rend.light.pitch, -90, +90); gui_angle("Yaw", &goxel.rend.light.yaw, 0, 360); gui_input_float("Intensity", &goxel.rend.light.intensity, 0.1, 0, 10, NULL); gui_group_end(); gui_checkbox("Fixed", &goxel.rend.light.fixed, NULL); if (!DEFINED(GOXEL_NO_SHADOW)) { v = goxel.rend.settings.shadow; if (gui_input_float("Shadow", &v, 0.1, 0, 0, NULL)) { goxel.rend.settings.shadow = clamp(v, 0, 1); } } v = goxel.rend.settings.ambient; if (gui_input_float("Ambient", &v, 0.1, 0, 1, NULL)) { v = clamp(v, 0, 1); goxel.rend.settings.ambient = v; } } goxel-0.11.0/src/gui/material_panel.c000066400000000000000000000047451435762723100174270ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" void gui_material_panel(void) { material_t *mat = NULL; int i = 0; bool is_current; float base_color_e, emission_e, emission; gui_group_begin(NULL); DL_FOREACH(goxel.image->materials, mat) { is_current = goxel.image->active_material == mat; if (gui_layer_item(i, -1, NULL, &is_current, mat->name, sizeof(mat->name))) { if (is_current) { goxel.image->active_material = mat; } else { goxel.image->active_material = NULL; } } i++; } gui_group_end(); gui_action_button(ACTION_img_new_material, NULL, 0); gui_same_line(); gui_action_button(ACTION_img_del_material, NULL, 0); mat = goxel.image->active_material; if (!mat) return; gui_group_begin(NULL); gui_input_float("Metallic", &mat->metallic, 0.1, 0, 1, NULL); gui_input_float("Roughness", &mat->roughness, 0.1, 0, 1, NULL); gui_group_end(); // Internally the material has an emission color independant of the // base color, but for the moment the gui only allow to set a factor from // the base color to keep is simple. base_color_e = max3(mat->base_color[0], mat->base_color[1], mat->base_color[2]); emission_e = max3(mat->emission[0], mat->emission[1], mat->emission[2]); emission = base_color_e ? emission_e / base_color_e : 0; if (gui_color_small_f3("Color", mat->base_color)) { vec3_mul(mat->base_color, emission, mat->emission); } if (gui_input_float("Emission", &emission, 0.1, 0, 10, NULL)) { vec3_mul(mat->base_color, emission, mat->emission); } gui_input_float("Opacity", &mat->base_color[3], 0.1, 0, 1, NULL); } goxel-0.11.0/src/gui/menu.c000066400000000000000000000062111435762723100154040ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "file_format.h" int gui_settings_popup(void *data); int gui_about_popup(void *data); static void import_image_plane(void) { const char *path; path = noc_file_dialog_open(NOC_FILE_DIALOG_OPEN, "png\0*.png\0jpg\0*.jpg;*.jpeg\0", NULL, NULL); if (!path) return; goxel_import_image_plane(path); } static void import_menu_callback(void *user, const file_format_t *f) { if (gui_menu_item(0, f->name, true)) goxel_import_file(NULL, f->name); } static void export_menu_callback(void *user, const file_format_t *f) { if (gui_menu_item(0, f->name, true)) goxel_export_to_file(NULL, f->name); } void gui_menu(void) { if (gui_menu_begin("File")) { gui_menu_item(ACTION_reset, "New", true); gui_menu_item(ACTION_save, "Save", image_get_key(goxel.image) != goxel.image->saved_key); gui_menu_item(ACTION_save_as, "Save as", true); gui_menu_item(ACTION_open, "Open", true); if (gui_menu_begin("Import...")) { if (gui_menu_item(0, "image plane", true)) import_image_plane(); file_format_iter("r", NULL, import_menu_callback); gui_menu_end(); } if (gui_menu_begin("Export As..")) { file_format_iter("w", NULL, export_menu_callback); gui_menu_end(); } gui_menu_item(ACTION_quit, "Quit", true); gui_menu_end(); } if (gui_menu_begin("Edit")) { gui_menu_item(ACTION_layer_clear, "Clear", true); gui_menu_item(ACTION_undo, "Undo", true); gui_menu_item(ACTION_redo, "Redo", true); gui_menu_item(ACTION_copy, "Copy", true); gui_menu_item(ACTION_past, "Paste", true); if (gui_menu_item(0, "Settings", true)) gui_open_popup("Settings", GUI_POPUP_FULL | GUI_POPUP_RESIZE, NULL, gui_settings_popup); gui_menu_end(); } if (gui_menu_begin("View")) { gui_menu_item(ACTION_view_left, "Left", true); gui_menu_item(ACTION_view_right, "Right", true); gui_menu_item(ACTION_view_front, "Front", true); gui_menu_item(ACTION_view_top, "Top", true); gui_menu_item(ACTION_view_default, "Default", true); gui_menu_end(); } if (gui_menu_begin("Help")) { if (gui_menu_item(0, "About", true)) gui_open_popup("About", 0, NULL, gui_about_popup); gui_menu_end(); } } goxel-0.11.0/src/gui/palette_panel.c000066400000000000000000000032301435762723100172530ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #ifndef GUI_PALETTE_COLUMNS_NB # define GUI_PALETTE_COLUMNS_NB 8 #endif void gui_palette_panel(void) { palette_t *p; int i, current, nb = 0, nb_col = GUI_PALETTE_COLUMNS_NB; const char **names; char id[128]; DL_COUNT(goxel.palettes, p, nb); names = (const char**)calloc(nb, sizeof(*names)); i = 0; DL_FOREACH(goxel.palettes, p) { if (p == goxel.palette) current = i; names[i++] = p->name; } if (gui_combo("##palettes", ¤t, names, nb)) { goxel.palette = goxel.palettes; for (i = 0; i < current; i++) goxel.palette = goxel.palette->next; } free(names); p = goxel.palette; for (i = 0; i < p->size; i++) { snprintf(id, sizeof(id), "%d", i); gui_push_id(id); gui_palette_entry(p->entries[i].color, goxel.painter.color); if ((i + 1) % nb_col && i != p->size - 1) gui_same_line(); gui_pop_id(); } } goxel-0.11.0/src/gui/quit.c000066400000000000000000000023321435762723100154220ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2021 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" static int gui_quit_popup(void *data) { gui_text("Quit without saving your changes?"); if (gui_button("Quit", 0, 0)) { goxel.quit = true; return 1; } gui_same_line(); if (gui_button("Cancel", 0, 0)) return 2; return 0; } void gui_query_quit(void) { if (image_get_key(goxel.image) == goxel.image->saved_key) { goxel.quit = true; return; } gui_open_popup("Unsaved changes", GUI_POPUP_RESIZE, NULL, gui_quit_popup); } goxel-0.11.0/src/gui/render_panel.c000066400000000000000000000120671435762723100171040ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" void gui_render_panel(void) { int i; int maxsize; pathtracer_t *pt = &goxel.pathtracer; material_t *material; goxel.no_edit |= pt->status; GL(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize)); maxsize /= 2; // Because png export already double it. goxel.show_export_viewport = true; gui_group_begin(NULL); gui_checkbox("Custom size", &goxel.image->export_custom_size, NULL); if (!goxel.image->export_custom_size) { goxel.image->export_width = goxel.gui.viewport[2]; goxel.image->export_height = goxel.gui.viewport[3]; } gui_enabled_begin(goxel.image->export_custom_size); i = goxel.image->export_width; if (gui_input_int("w", &i, 1, maxsize)) goxel.image->export_width = clamp(i, 1, maxsize); i = goxel.image->export_height; if (gui_input_int("h", &i, 1, maxsize)) goxel.image->export_height = clamp(i, 1, maxsize); gui_enabled_end(); gui_group_end(); gui_input_int("Samples", &pt->num_samples, 1, 10000); if (pt->status == PT_STOPPED && gui_button("Start", 1, 0)) pt->status = PT_RUNNING; if (pt->status == PT_RUNNING && gui_button("Stop", 1, 0)) { pathtracer_stop(pt); pt->status = PT_STOPPED; } if (pt->status == PT_FINISHED && gui_button("Restart", 1, 0)) { pt->status = PT_RUNNING; pt->progress = 0; pt->force_restart = true; } if (pt->status) { gui_text("%d/100", (int)(pt->progress * 100)); } if ( pt->status == PT_FINISHED && gui_button("Save to album", -1, 0) && gui_need_full_version()) { action_exec2(ACTION_export_render_buf_to_photos); } if (gui_collapsing_header("World", false)) { gui_push_id("world"); gui_group_begin(NULL); gui_selectable_toggle("None", &pt->world.type, PT_WORLD_NONE, NULL, -1); gui_selectable_toggle("Uniform", &pt->world.type, PT_WORLD_UNIFORM, NULL, -1); gui_selectable_toggle("Sky", &pt->world.type, PT_WORLD_SKY, NULL, -1); gui_group_end(); if (pt->world.type) { gui_input_float("Energy", &pt->world.energy, 0.1, 0, 10, "%.1f"); gui_color_small("Color", pt->world.color); } gui_pop_id(); } if (gui_collapsing_header("Floor", false)) { gui_push_id("floor"); gui_group_begin(NULL); gui_selectable_toggle("None", &pt->floor.type, PT_FLOOR_NONE, NULL, -1); gui_selectable_toggle("Plane", &pt->floor.type, PT_FLOOR_PLANE, NULL, -1); gui_group_end(); if (pt->floor.type == PT_FLOOR_PLANE) { gui_group_begin("size"); gui_input_int("x", &pt->floor.size[0], 1, 2048); gui_input_int("y", &pt->floor.size[1], 1, 2048); gui_group_end(); gui_color_small("Color", pt->floor.color); gui_text("Material"); if (gui_combo_begin("##material", pt->floor.material ? pt->floor.material->name : NULL)) { DL_FOREACH(goxel.image->materials, material) { if (gui_combo_item(material->name, material == pt->floor.material)) { pt->floor.material = material; } } gui_combo_end(); } } gui_pop_id(); } if (gui_collapsing_header("Light", false)) { gui_group_begin("Light"); gui_angle("Pitch", &goxel.rend.light.pitch, -90, +90); gui_angle("Yaw", &goxel.rend.light.yaw, 0, 360); gui_checkbox("Fixed", &goxel.rend.light.fixed, NULL); gui_input_float("Intensity", &goxel.rend.light.intensity, 0.1, 0, 10, NULL); gui_group_end(); } } static void on_saved_to_photo(int ret) { gui_alert("Export", "Export Complete"); } static void export_render_buf_to_photos(void) { int w = goxel.pathtracer.w; int h = goxel.pathtracer.h; int bpp = 4; int size; uint8_t *img; img = img_write_to_mem(goxel.pathtracer.buf, w, h, bpp, &size); sys_save_to_photos(img, size, on_saved_to_photo); free(img); } ACTION_REGISTER(export_render_buf_to_photos, .cfunc = export_render_buf_to_photos, ) goxel-0.11.0/src/gui/settings.c000066400000000000000000000107041435762723100163020ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include #include "utils/ini.h" static int shortcut_callback(action_t *action, void *user) { if (!(action->flags & ACTION_CAN_EDIT_SHORTCUT)) return 0; gui_push_id(action->id); gui_text("%s: %s", action->id, action->help); gui_next_column(); // XXX: need to check if the inputs are valid! gui_input_text("", action->shortcut, sizeof(action->shortcut)); gui_next_column(); gui_pop_id(); return 0; } int gui_settings_popup(void *data) { const char **names; theme_t *theme; int i, nb, current; theme_t *themes = theme_get_list(); gui_popup_body_begin(); DL_COUNT(themes, theme, nb); names = (const char**)calloc(nb, sizeof(*names)); i = 0; DL_FOREACH(themes, theme) { if (strcmp(theme->name, theme_get()->name) == 0) current = i; names[i++] = theme->name; } gui_text("theme"); if (gui_combo("##themes", ¤t, names, nb)) { theme_set(names[current]); } free(names); // For the moment I disable the theme editor! #if 0 int group; uint8_t *color; theme = theme_get(); gui_group_begin("Sizes"); #define X(a) gui_input_int(#a, &theme->sizes.a, 0, 1000); THEME_SIZES(X) #undef X gui_group_end(); for (group = 0; group < THEME_GROUP_COUNT; group++) { if (gui_collapsing_header(THEME_GROUP_INFOS[group].name)) { for (i = 0; i < THEME_COLOR_COUNT; i++) { if (!THEME_GROUP_INFOS[group].colors[i]) continue; color = theme->groups[group].colors[i]; gui_color(THEME_COLOR_INFOS[i].name, color); } } } if (gui_button("Revert", 0, 0)) theme_revert_default(); gui_same_line(); if (gui_button("Save", 0, 0)) theme_save(); #endif if (gui_collapsing_header("Paths", false)) { gui_text("Palettes: %s/palettes", sys_get_user_dir()); gui_text("Progs: %s/progs", sys_get_user_dir()); } if (gui_collapsing_header("Shortcuts", false)) { gui_columns(2); gui_separator(); actions_iter(shortcut_callback, NULL); gui_separator(); gui_columns(1); } gui_popup_body_end(); if (gui_button("Save", 0, 0)) settings_save(); gui_same_line(); return gui_button("OK", 0, 0); } static int settings_ini_handler(void *user, const char *section, const char *name, const char *value, int lineno) { action_t *a; if (strcmp(section, "ui") == 0) { if (strcmp(name, "theme") == 0) { theme_set(value); } } if (strcmp(section, "shortcuts") == 0) { if ((a = action_get_by_name(name))) { strncpy(a->shortcut, value, sizeof(a->shortcut) - 1); } else { LOG_W("Cannot set shortcut for unknown action '%s'", name); } } return 0; } void settings_load(void) { char path[1024]; snprintf(path, sizeof(path), "%s/settings.ini", sys_get_user_dir()); ini_parse(path, settings_ini_handler, NULL); } static int shortcut_save_callback(action_t *a, void *user) { FILE *file = user; if (strcmp(a->shortcut, a->default_shortcut ?: "") != 0) fprintf(file, "%s=%s\n", a->id, a->shortcut); return 0; } void settings_save(void) { char path[1024]; FILE *file; snprintf(path, sizeof(path), "%s/settings.ini", sys_get_user_dir()); sys_make_dir(path); file = fopen(path, "w"); if (!file) { LOG_E("Cannot save settings to %s: %s", path, strerror(errno)); return; } fprintf(file, "[ui]\n"); fprintf(file, "theme=%s\n", theme_get()->name); fprintf(file, "[shortcuts]\n"); actions_iter(shortcut_save_callback, file); fclose(file); } goxel-0.11.0/src/gui/tools_panel.c000066400000000000000000000052151435762723100167620ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #ifndef GUI_TOOLS_COLUMNS_NB # define GUI_TOOLS_COLUMNS_NB 4 #endif // XXX: better replace this by something more automatic. static void auto_grid(int nb, int i, int col) { if ((i + 1) % col != 0) gui_same_line(); } void gui_tools_panel(void) { // XXX: cleanup this. const struct { int tool; int action; int icon; } values[] = { {TOOL_BRUSH, ACTION_tool_set_brush, ICON_TOOL_BRUSH}, {TOOL_SHAPE, ACTION_tool_set_shape, ICON_TOOL_SHAPE}, {TOOL_LASER, ACTION_tool_set_laser, ICON_TOOL_LASER}, {TOOL_SET_PLANE, ACTION_tool_set_plane, ICON_TOOL_PLANE}, {TOOL_MOVE, ACTION_tool_set_move, ICON_TOOL_MOVE}, {TOOL_PICK_COLOR, ACTION_tool_set_pick_color, ICON_TOOL_PICK}, {TOOL_SELECTION, ACTION_tool_set_selection, ICON_TOOL_SELECTION}, {TOOL_FUZZY_SELECT, ACTION_tool_set_fuzzy_select, ICON_TOOL_FUZZY_SELECT}, {TOOL_EXTRUDE, ACTION_tool_set_extrude, ICON_TOOL_EXTRUDE}, {TOOL_LINE, ACTION_tool_set_line, ICON_TOOL_LINE}, }; const int nb = ARRAY_SIZE(values); int i; bool v; char label[64]; const action_t *action = NULL; const tool_t *tool; gui_group_begin(NULL); for (i = 0; i < nb; i++) { tool = tool_get(values[i].tool); v = goxel.tool->id == values[i].tool; sprintf(label, "%s", tool->name); action = action_get(values[i].action, true); assert(action); if (*action->shortcut) sprintf(label, "%s (%s)", tool->name, action->shortcut); if (gui_selectable_icon(label, &v, values[i].icon)) { action_exec(action); } auto_grid(nb, i, GUI_TOOLS_COLUMNS_NB); } gui_group_end(); if (gui_collapsing_header(goxel.tool->name, true)) tool_gui(goxel.tool); } goxel-0.11.0/src/gui/topbar.c000066400000000000000000000026051435762723100157320ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #ifndef GUI_CUSTOM_TOPBAR static int gui_mode_select(void) { gui_choice_begin("Mode", &goxel.painter.mode, false); gui_choice("Add", MODE_OVER, ICON_MODE_ADD); gui_choice("Sub", MODE_SUB, ICON_MODE_SUB); gui_choice("Paint", MODE_PAINT, ICON_MODE_PAINT); gui_choice_end(); return 0; } void gui_top_bar(void) { gui_action_button(ACTION_undo, NULL, 0); gui_same_line(); gui_action_button(ACTION_redo, NULL, 0); gui_same_line(); gui_action_button(ACTION_layer_clear, NULL, 0); gui_same_line(); gui_mode_select(); gui_same_line(); gui_color("##color", goxel.painter.color); } #endif // GUI_CUSTOM_TOPBAR goxel-0.11.0/src/gui/view_panel.c000066400000000000000000000046461435762723100166030ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" void gui_view_panel(void) { // XXX: I don't like to use this array. const struct { uint8_t *color; const char *label; } COLORS[] = { {goxel.back_color, "Back color"}, {goxel.grid_color, "Grid color"}, {goxel.image_box_color, "Box color"}, }; int i; for (i = 0; i < (int)ARRAY_SIZE(COLORS); i++) { gui_color_small(COLORS[i].label, COLORS[i].color); } gui_checkbox("Hide box", &goxel.hide_box, NULL); gui_text("Effects"); if (gui_input_float("occlusion", &goxel.rend.settings.occlusion_strength, 0.1, 0, 1, NULL)) { goxel.rend.settings.occlusion_strength = clamp(goxel.rend.settings.occlusion_strength, 0, 1); } if (gui_input_float("Smoothness", &goxel.rend.settings.smoothness, 0.1, 0, 1, NULL)) { goxel.rend.settings.smoothness = clamp(goxel.rend.settings.smoothness, 0, 1); } gui_checkbox_flag("Grid", &goxel.view_effects, EFFECT_GRID, NULL); gui_checkbox_flag("Edges", &goxel.view_effects, EFFECT_EDGES, NULL); gui_checkbox_flag("Unlit", &goxel.rend.settings.effects, EFFECT_UNLIT, NULL); gui_checkbox_flag("Borders", &goxel.rend.settings.effects, EFFECT_BORDERS, NULL); gui_checkbox_flag("See back", &goxel.rend.settings.effects, EFFECT_SEE_BACK, NULL); gui_checkbox_flag("Marching Cubes", &goxel.rend.settings.effects, EFFECT_MARCHING_CUBES, NULL); if (goxel.rend.settings.effects & EFFECT_MARCHING_CUBES) { gui_checkbox_flag("Smooth Colors", &goxel.rend.settings.effects, EFFECT_MC_SMOOTH, NULL); } } goxel-0.11.0/src/image.c000066400000000000000000000606121435762723100147430ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "xxhash.h" /* History the images undo history is stored in a linked list. Every time we call image_history_push, we add the current image snapshot in the list. For example, if we did three operations, A, B, C, and now the image is in the D state, the history list looks like this: img->history img | | v v +--------+ +--------+ +--------+ +--------+ | | | | | | | | | A |------>| B |------>| C |----->| D | | | | | | | | | +--------+ +--------+ +--------+ +--------+ After an undo, we get: img->history img | | v v +--------+ +--------+ +--------+ +--------+ | | | | | | | | | A |------>| B |------>| C |---->| D | | | | | | | | | +--------+ +--------+ +--------+ +--------+ */ static bool material_name_exists(void *user, const char *name) { const image_t *img = user; const material_t *m; DL_FOREACH(img->materials, m) { if (strcasecmp(m->name, name) == 0) return true; } return false; } static bool layer_name_exists(void *user, const char *name) { const image_t *img = user; const layer_t *layer; DL_FOREACH(img->layers, layer) { if (strcasecmp(layer->name, name) == 0) return true; } return false; } static bool camera_name_exists(void *user, const char *name) { const image_t *img = user; const camera_t *cam; DL_FOREACH(img->cameras, cam) { if (strcasecmp(cam->name, name) == 0) return true; } return false; } static void make_uniq_name( char *buf, int size, const char *base, void *user, bool (*name_exists)(void *user, const char *name)) { int i = 1, n, len; const char *ext; // If base if of the form 'abc.' then we turn it into 'abc' len = strlen(base); ext = strrchr(base, '.'); if (ext) { if (sscanf(ext, ".%d%*c", &n) == 1) { len -= strlen(ext); i = n; } } for (;; i++) { snprintf(buf, size, "%.*s.%d", len, base, i); if (!name_exists(user, buf)) break; } } static layer_t *img_get_layer(const image_t *img, int id) { layer_t *layer; if (id == 0) return NULL; DL_FOREACH(img->layers, layer) if (layer->id == id) return layer; assert(false); return NULL; } static int img_get_new_id(const image_t *img) { int id; layer_t *layer; for (id = 1;; id++) { DL_FOREACH(img->layers, layer) if (layer->id == id) break; if (layer == NULL) break; } return id; } static layer_t *layer_clone(layer_t *other) { int len; layer_t *layer; assert(other); layer = calloc(1, sizeof(*layer)); len = sizeof(layer->name) - 1 - strlen(" clone"); snprintf(layer->name, sizeof(layer->name), "%.*s clone", len, other->name); layer->visible = other->visible; layer->material = other->material; layer->mesh = mesh_copy(other->mesh); mat4_set_identity(layer->mat); layer->base_id = other->id; layer->base_mesh_key = mesh_get_key(other->mesh); return layer; } // Make sure the layer mesh is up to date. void image_update(image_t *img) { painter_t painter = {}; uint32_t key; layer_t *layer, *base; DL_FOREACH(img->layers, layer) { base = img_get_layer(img, layer->base_id); if (base && layer->base_mesh_key != mesh_get_key(base->mesh)) { mesh_set(layer->mesh, base->mesh); mesh_move(layer->mesh, layer->mat); layer->base_mesh_key = mesh_get_key(base->mesh); } if (layer->shape) { key = XXH32(layer->mat, sizeof(layer->mat), 0); key = XXH32(layer->shape, sizeof(layer->shape), key); key = XXH32(layer->color, sizeof(layer->color), key); if (key != layer->shape_key) { painter.mode = MODE_OVER; painter.shape = layer->shape; painter.box = &goxel.image->box; vec4_copy(layer->color, painter.color); mesh_clear(layer->mesh); mesh_op(layer->mesh, &painter, layer->mat); layer->shape_key = key; } } } } image_t *image_new(void) { layer_t *layer; image_t *img = calloc(1, sizeof(*img)); const int aabb[2][3] = {{-16, -16, 0}, {16, 16, 32}}; bbox_from_aabb(img->box, aabb); img->export_width = 1024; img->export_height = 1024; image_add_material(img, NULL); image_add_camera(img, NULL); layer = image_add_layer(img, NULL); layer->visible = true; layer->id = img_get_new_id(img); layer->material = img->active_material; DL_APPEND(img->layers, layer); DL_APPEND2(img->history, img, history_prev, history_next); img->active_layer = layer; // Prevent saving an empty image. img->saved_key = image_get_key(img); return img; } /* * Generate a copy of the image that can be put into the history. */ static image_t *image_snap(image_t *other) { image_t *img; layer_t *layer, *other_layer; camera_t *camera, *other_camera; material_t *material, *other_material; img = calloc(1, sizeof(*img)); *img = *other; img->layers = NULL; img->active_layer = NULL; DL_FOREACH(other->layers, other_layer) { layer = layer_copy(other_layer); DL_APPEND(img->layers, layer); if (other_layer == other->active_layer) img->active_layer = layer; } assert(img->active_layer); img->cameras = NULL; img->active_camera = NULL; DL_FOREACH(other->cameras, other_camera) { camera = camera_copy(other_camera); DL_APPEND(img->cameras, camera); if (other_camera == other->active_camera) img->active_camera = camera; } img->materials = NULL; img->active_material = NULL; DL_FOREACH(other->materials, other_material) { material = material_copy(other_material); DL_APPEND(img->materials, material); if (other_material == other->active_material) img->active_material = material; DL_FOREACH(img->layers, layer) { if (layer->material == other_material) layer->material = material; } } img->history = img->history_next = img->history_prev = NULL; return img; } void image_delete(image_t *img) { image_t *hist, *snap, *snap_tmp; camera_t *cam; layer_t *layer; material_t *mat; if (!img) return; while ((layer = img->layers)) { DL_DELETE(img->layers, layer); layer_delete(layer); } while ((cam = img->cameras)) { DL_DELETE(img->cameras, cam); camera_delete(cam); } while ((mat = img->materials)) { DL_DELETE(img->materials, mat); material_delete(mat); } // Path is shared between images and snaps! // XXX: find a better way. if (img->history) { free(img->path); img->path = NULL; } hist = img->history; DL_FOREACH_SAFE2(hist, snap, snap_tmp, history_next) { if (snap == img) continue; DL_DELETE2(hist, snap, history_prev, history_next); image_delete(snap); } free(img); } layer_t *image_add_layer(image_t *img, layer_t *layer) { assert(img); if (!layer) { layer = layer_new(NULL); make_uniq_name(layer->name, sizeof(layer->name), "Layer", img, layer_name_exists); } layer->visible = true; layer->id = img_get_new_id(img); layer->material = img->active_material; DL_APPEND(img->layers, layer); img->active_layer = layer; return layer; } layer_t *image_add_shape_layer(image_t *img) { layer_t *layer; assert(img); layer = layer_new("shape"); layer->visible = true; layer->shape = &shape_sphere; vec4_copy(goxel.painter.color, layer->color); // If the selection is on use it, otherwise center it in the image. if (!box_is_null(goxel.selection)) { mat4_copy(goxel.selection, layer->mat); } else { vec3_copy(img->box[3], layer->mat[3]); mat4_iscale(layer->mat, 4, 4, 4); } layer->id = img_get_new_id(img); DL_APPEND(img->layers, layer); img->active_layer = layer; return layer; } void image_delete_layer(image_t *img, layer_t *layer) { layer_t *other; assert(img); assert(layer); DL_DELETE(img->layers, layer); if (layer == img->active_layer) img->active_layer = NULL; // Unclone all layers cloned from this one. DL_FOREACH(goxel.image->layers, other) { if (other->base_id == layer->id) { other->base_id = 0; } } layer_delete(layer); if (img->layers == NULL) { layer = layer_new("unnamed"); layer->visible = true; layer->id = img_get_new_id(img); DL_APPEND(img->layers, layer); } if (!img->active_layer) img->active_layer = img->layers->prev; } static void image_move_layer(image_t *img, layer_t *layer, int d) { layer_t *other = NULL; assert(img); assert(layer); assert(d == -1 || d == +1); if (d == -1) { other = layer->next; SWAP(other, layer); } else if (layer != img->layers) { other = layer->prev; } if (!other || !layer) return; DL_DELETE(img->layers, layer); DL_PREPEND_ELEM(img->layers, other, layer); } layer_t *image_duplicate_layer(image_t *img, layer_t *other) { layer_t *layer; assert(img); assert(other); layer = layer_copy(other); make_uniq_name(layer->name, sizeof(layer->name), other->name, img, layer_name_exists); layer->visible = true; layer->id = img_get_new_id(img); DL_APPEND(img->layers, layer); img->active_layer = layer; return layer; } layer_t *image_clone_layer(image_t *img, layer_t *other) { layer_t *layer; img = img ?: goxel.image; other = other ?: img->active_layer; assert(img && other); layer = layer_clone(other); layer->visible = true; layer->id = img_get_new_id(img); DL_APPEND(img->layers, layer); img->active_layer = layer; return layer; } void image_unclone_layer(image_t *img, layer_t *layer) { assert(img); assert(layer); layer->base_id = 0; layer->shape = NULL; } void image_merge_visible_layers(image_t *img) { layer_t *layer, *other, *last = NULL; assert(img); DL_FOREACH(img->layers, layer) { if (!layer->visible) continue; image_unclone_layer(img, layer); if (last) { // Unclone all layers cloned from this one. DL_FOREACH(goxel.image->layers, other) { if (other->base_id == last->id) { other->base_id = 0; } } SWAP(layer->mesh, last->mesh); mesh_merge(layer->mesh, last->mesh, MODE_OVER, NULL); DL_DELETE(img->layers, last); layer_delete(last); } last = layer; } if (last) img->active_layer = last; } camera_t *image_add_camera(image_t *img, camera_t *cam) { assert(img); if (!cam) { cam = camera_new(NULL); make_uniq_name(cam->name, sizeof(cam->name), "Camera", img, camera_name_exists); } DL_APPEND(img->cameras, cam); img->active_camera = cam; return cam; } void image_delete_camera(image_t *img, camera_t *cam) { img = img ?: goxel.image; cam = cam ?: img->active_camera; if (!cam) return; DL_DELETE(img->cameras, cam); if (cam == img->active_camera) img->active_camera = img->cameras; camera_delete(cam); } static void image_move_camera(image_t *img, camera_t *cam, int d) { // XXX: make a generic algo to move objects in a list. assert(d == -1 || d == +1); camera_t *other = NULL; img = img ?: goxel.image; cam = cam ?: img->active_camera; if (!cam) return; if (d == -1) { other = cam->next; SWAP(other, cam); } else if (cam != img->cameras) { other = cam->prev; } if (!other || !cam) return; DL_DELETE(img->cameras, cam); DL_PREPEND_ELEM(img->cameras, other, cam); } material_t *image_add_material(image_t *img, material_t *mat) { img = img ?: goxel.image; if (!mat) { mat = material_new(NULL); make_uniq_name(mat->name, sizeof(mat->name), "Material", img, material_name_exists); } assert(!mat->prev); DL_APPEND(img->materials, mat); img->active_material = mat; return mat; } void image_delete_material(image_t *img, material_t *mat) { layer_t *layer; img = img ?: goxel.image; mat = mat ?: img->active_material; if (!mat) return; DL_DELETE(img->materials, mat); if (mat == img->active_material) img->active_material = NULL; material_delete(mat); DL_FOREACH(img->layers, layer) if (layer->material == mat) layer->material = NULL; } static void a_image_auto_resize(void) { float box[4][4] = {}, layer_box[4][4]; layer_t *layer; image_t *img = goxel.image; DL_FOREACH(img->layers, layer) { layer_get_bounding_box(layer, layer_box); box_union(box, layer_box, box); } mat4_copy(box, img->box); } void image_set(image_t *img, image_t *other) { layer_t *layer, *tmp, *other_layer; DL_FOREACH_SAFE(img->layers, layer, tmp) { DL_DELETE(img->layers, layer); layer_delete(layer); } DL_FOREACH(other->layers, other_layer) { layer = layer_copy(other_layer); DL_APPEND(img->layers, layer); if (other_layer == other->active_layer) img->active_layer = layer; } } #if 0 // For debugging purpose. static void debug_print_history(image_t *img) { int i = 0; image_t *hist; DL_FOREACH2(img->history, hist, history_next) { printf("%d%s ", i++, hist == img ? "*" : " "); } printf("\n"); } #else static void debug_print_history(image_t *img) {} #endif void image_history_push(image_t *img) { image_t *snap = image_snap(img); image_t *hist; // Discard previous undo. while ((hist = img->history_next)) { DL_DELETE2(img->history, hist, history_prev, history_next); assert(hist != img->history_next); image_delete(hist); } DL_DELETE2(img->history, img, history_prev, history_next); DL_APPEND2(img->history, snap, history_prev, history_next); DL_APPEND2(img->history, img, history_prev, history_next); debug_print_history(img); } void image_history_resize(image_t *img, int size) { int i, nb = 0; image_t *hist; layer_t *layer, *layer_tmp; // First cound the size of the history to compute how many we are going // to remove. for (hist = img->history; hist != img; hist = hist->history_next) nb++; nb = max(0, nb - size); for (i = 0; i < nb; i++) { hist = img->history; // XXX: do that in a function! DL_FOREACH_SAFE(hist->layers, layer, layer_tmp) { assert(layer); DL_DELETE(hist->layers, layer); layer_delete(layer); } DL_DELETE2(img->history, hist, history_prev, history_next); free(hist); } } // XXX: not clear what this is doing. We should try to remove it. // It swap the content of two images without touching their pointer or // history. static void swap(image_t *a, image_t *b) { SWAP(*a, *b); SWAP(a->history, b->history); SWAP(a->history_next, b->history_next); SWAP(a->history_prev, b->history_prev); } void image_undo(image_t *img) { image_t *prev = img->history_prev; if (img->history == img) { LOG_D("No more undo"); return; } DL_DELETE2(img->history, img, history_prev, history_next); DL_PREPEND_ELEM2(img->history, prev, img, history_prev, history_next); swap(img, prev); // Don't move the camera for an undo. if (img->active_camera && prev->active_camera && strcmp(img->active_camera->name, prev->active_camera->name) == 0) { camera_set(img->active_camera, prev->active_camera); } debug_print_history(img); } void image_redo(image_t *img) { image_t *next = img->history_next; if (!next) { LOG_D("No more redo"); return; } DL_DELETE2(img->history, next, history_prev, history_next); DL_PREPEND_ELEM2(img->history, img, next, history_prev, history_next); swap(img, next); debug_print_history(img); } static void image_clear_layer(void) { painter_t painter; layer_t *layer = goxel.image->active_layer; if (box_is_null(goxel.selection) && mesh_is_empty(goxel.mask)) { mesh_clear(layer->mesh); return; } // Use the mask in priority if it exists. if (!mesh_is_empty(goxel.mask)) { mesh_merge(layer->mesh, goxel.mask, MODE_SUB, NULL); return; } painter = (painter_t) { .shape = &shape_cube, .mode = MODE_SUB, .color = {255, 255, 255, 255}, }; mesh_op(layer->mesh, &painter, goxel.selection); } bool image_layer_can_edit(const image_t *img, const layer_t *layer) { return !layer->base_id && !layer->image && !layer->shape; } /* * Function: image_get_key * Return a value that is garantied to change when the image change. */ uint32_t image_get_key(const image_t *img) { uint32_t key = 0, k; layer_t *layer; camera_t *camera; material_t *material; DL_FOREACH(img->layers, layer) { k = layer_get_key(layer); key = XXH32(&k, sizeof(k), key); } DL_FOREACH(img->cameras, camera) { k = camera_get_key(camera); key = XXH32(&k, sizeof(k), key); } DL_FOREACH(img->materials, material) { k = material_get_hash(material); key = XXH32(&k, sizeof(k), key); } return key; } /* * Turn an image layer into a mesh of 1 voxel depth. */ static void image_image_layer_to_mesh(image_t *img, layer_t *layer) { uint8_t *data; int x, y, w, h, bpp = 0, pos[3]; uint8_t c[4]; float p[3]; assert(img); assert(layer); mesh_accessor_t acc; image_history_push(img); data = img_read(layer->image->path, &w, &h, &bpp); acc = mesh_get_accessor(layer->mesh); for (y = 0; y < h; y++) for (x = 0; x < w; x++) { vec3_set(p, (x / (float)w) - 0.5, - ((y + 1) / (float)h) + 0.5, 0); mat4_mul_vec3(layer->mat, p, p); pos[0] = round(p[0]); pos[1] = round(p[1]); pos[2] = round(p[2]); memset(c, 0, 4); c[3] = 255; memcpy(c, data + (y * w + x) * bpp, bpp); mesh_set_at(layer->mesh, &acc, pos, c); } texture_delete(layer->image); layer->image = NULL; free(data); } ACTION_REGISTER(layer_clear, .help = "Clear the current layer", .cfunc = image_clear_layer, .icon = ICON_DELETE, .flags = ACTION_TOUCH_IMAGE, .default_shortcut = "Delete", ) static void a_image_add_layer(void) { image_add_layer(goxel.image, NULL); } ACTION_REGISTER(img_new_layer, .help = "Add a new layer to the image", .cfunc = a_image_add_layer, .flags = ACTION_TOUCH_IMAGE, .icon = ICON_ADD, ) static void a_image_delete_layer(void) { image_delete_layer(goxel.image, goxel.image->active_layer); } ACTION_REGISTER(img_del_layer, .help = "Delete the active layer", .cfunc = a_image_delete_layer, .flags = ACTION_TOUCH_IMAGE, .icon = ICON_REMOVE, ) static void a_image_move_layer_up(void) { image_move_layer(goxel.image, goxel.image->active_layer, -1); } static void a_image_move_layer_down(void) { image_move_layer(goxel.image, goxel.image->active_layer, +1); } ACTION_REGISTER(img_move_layer_up, .help = "Move the active layer up", .cfunc = a_image_move_layer_up, .flags = ACTION_TOUCH_IMAGE, .icon = ICON_ARROW_UPWARD, ) ACTION_REGISTER(img_move_layer_down, .help = "Move the active layer down", .cfunc = a_image_move_layer_down, .flags = ACTION_TOUCH_IMAGE, .icon = ICON_ARROW_DOWNWARD, ) static void a_image_duplicate_layer(void) { image_duplicate_layer(goxel.image, goxel.image->active_layer); } ACTION_REGISTER(img_duplicate_layer, .help = "Duplicate the active layer", .cfunc = a_image_duplicate_layer, .flags = ACTION_TOUCH_IMAGE, ) static void a_image_clone_layer(void) { image_clone_layer(goxel.image, goxel.image->active_layer); } ACTION_REGISTER(img_clone_layer, .help = "Clone the active layer", .cfunc = a_image_clone_layer, .flags = ACTION_TOUCH_IMAGE, ) static void a_image_unclone_layer(void) { image_unclone_layer(goxel.image, goxel.image->active_layer); } ACTION_REGISTER(img_unclone_layer, .help = "Unclone the active layer", .cfunc = a_image_unclone_layer, .flags = ACTION_TOUCH_IMAGE, ) static void a_img_select_parent_layer(void) { image_t *image = goxel.image; image->active_layer = img_get_layer(image, image->active_layer->base_id); } ACTION_REGISTER(img_select_parent_layer, .help = "Select the parent of a layer", .cfunc = a_img_select_parent_layer, .flags = ACTION_TOUCH_IMAGE, ) static void a_img_merge_visible_layers(void) { image_merge_visible_layers(goxel.image); } ACTION_REGISTER(img_merge_visible_layers, .help = "Merge all the visible layers", .cfunc = a_img_merge_visible_layers, .flags = ACTION_TOUCH_IMAGE, ) static void a_img_new_camera(void) { image_add_camera(goxel.image, NULL); } ACTION_REGISTER(img_new_camera, .help = "Add a new camera to the image", .cfunc = a_img_new_camera, .flags = ACTION_TOUCH_IMAGE, .icon = ICON_ADD, ) static void a_img_del_camera(void) { image_delete_camera(goxel.image, goxel.image->active_camera); } ACTION_REGISTER(img_del_camera, .help = "Delete the active camera", .cfunc = a_img_del_camera, .flags = ACTION_TOUCH_IMAGE, .icon = ICON_REMOVE, ) static void a_img_move_camera_up(void) { image_move_camera(goxel.image, goxel.image->active_camera, +1); } static void a_img_move_camera_down(void) { image_move_camera(goxel.image, goxel.image->active_camera, -1); } ACTION_REGISTER(img_move_camera_up, .help = "Move the active camera up", .cfunc = a_img_move_camera_up, .flags = ACTION_TOUCH_IMAGE, .icon = ICON_ARROW_UPWARD, ) ACTION_REGISTER(img_move_camera_down, .help = "Move the active camera down", .cfunc = a_img_move_camera_down, .flags = ACTION_TOUCH_IMAGE, .icon = ICON_ARROW_DOWNWARD, ) static void a_img_image_layer_to_mesh(void) { image_image_layer_to_mesh(goxel.image, goxel.image->active_layer); } ACTION_REGISTER(img_image_layer_to_mesh, .help = "Turn an image layer into a mesh", .cfunc = a_img_image_layer_to_mesh, .flags = ACTION_TOUCH_IMAGE, ) static void a_img_new_shape_layer(void) { image_add_shape_layer(goxel.image); } ACTION_REGISTER(img_new_shape_layer, .help = "Add a new shape layer to the image", .cfunc = a_img_new_shape_layer, .flags = ACTION_TOUCH_IMAGE, ) static void a_img_new_material(void) { image_add_material(goxel.image, NULL); } ACTION_REGISTER(img_new_material, .help = "Add a new material to the image", .cfunc = a_img_new_material, .flags = ACTION_TOUCH_IMAGE, .icon = ICON_ADD, ) static void a_img_del_material(void) { image_delete_material(goxel.image, goxel.image->active_material); } ACTION_REGISTER(img_del_material, .help = "Delete a material", .cfunc = a_img_del_material, .flags = ACTION_TOUCH_IMAGE, .icon = ICON_REMOVE, ) ACTION_REGISTER(img_auto_resize, .help = "Auto resize the image to fit the layers", .cfunc = a_image_auto_resize, .flags = ACTION_TOUCH_IMAGE, ) goxel-0.11.0/src/image.h000066400000000000000000000045721435762723100147530ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef IMAGE_H #define IMAGE_H #include "camera.h" #include "layer.h" #include "material.h" #include #include typedef struct history history_t; typedef struct image image_t; struct image { layer_t *layers; layer_t *active_layer; camera_t *cameras; camera_t *active_camera; material_t *materials; material_t *active_material; float box[4][4]; // For saving. // XXX: I think those should be persistend data of export code instead. char *path; bool export_custom_size; int export_width; int export_height; bool export_transparent_background; uint32_t saved_key; // image_get_key() value of saved file. image_t *history; image_t *history_next, *history_prev; }; image_t *image_new(void); void image_delete(image_t *img); layer_t *image_add_layer(image_t *img, layer_t *layer); void image_delete_layer(image_t *img, layer_t *layer); layer_t *image_duplicate_layer(image_t *img, layer_t *layer); void image_merge_visible_layers(image_t *img); void image_history_push(image_t *img); void image_undo(image_t *img); void image_redo(image_t *img); void image_history_resize(image_t *img, int size); bool image_layer_can_edit(const image_t *img, const layer_t *layer); material_t *image_add_material(image_t *img, material_t *mat); void image_delete_material(image_t *img, material_t *mat); camera_t *image_add_camera(image_t *img, camera_t *cam); void image_delete_camera(image_t *img, camera_t *cam); /* * Function: image_get_key * Return a value that is guarantied to change when the image change. */ uint32_t image_get_key(const image_t *img); #endif // IMAGE_H goxel-0.11.0/src/imgui.cpp000066400000000000000000000024321435762723100153270ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* * Just include the imgui cpp files, so that we don't have to handle them * in the Scons file. */ // Prevent warnings with gcc. #ifndef __clang__ #pragma GCC diagnostic push #if __GNUC__ >= 8 #pragma GCC diagnostic ignored "-Wclass-memaccess" #pragma GCC diagnostic ignored "-Wstringop-truncation" #endif #endif #define IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DISABLE_OBSOLETE_FUNCTIONS #include "../ext_src/imgui/imgui.cpp" #include "../ext_src/imgui/imgui_draw.cpp" #include "../ext_src/imgui/imgui_widgets.cpp" #ifdef __clang__ #pragma GCC diagnostic pop #endif goxel-0.11.0/src/inputs.h000066400000000000000000000040301435762723100152000ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef INPUTS_H #define INPUTS_H #include #include // Key id, same as GLFW for convenience. enum { KEY_ESCAPE = 256, KEY_ENTER = 257, KEY_TAB = 258, KEY_BACKSPACE = 259, KEY_DELETE = 261, KEY_RIGHT = 262, KEY_LEFT = 263, KEY_DOWN = 264, KEY_UP = 265, KEY_PAGE_UP = 266, KEY_PAGE_DOWN = 267, KEY_HOME = 268, KEY_END = 269, KEY_LEFT_SHIFT = 340, KEY_RIGHT_SHIFT = 344, KEY_CONTROL = 341, }; // A finger touch or mouse click state. // `down` represent each button in the mouse. For touch events only the // first element is set. typedef struct { float pos[2]; bool down[3]; } touch_t; typedef struct inputs { int window_size[2]; float scale; bool keys[512]; // Table of all the pressed keys. uint32_t chars[16]; touch_t touches[4]; float mouse_wheel; int framebuffer; // Screen framebuffer // Screen safe margins, used for iOS only. struct { int top; int bottom; int left; int right; } safe_margins; } inputs_t; // Conveniance function to add a char in the inputs. void inputs_insert_char(inputs_t *inputs, uint32_t c); #endif // INPUTS_H goxel-0.11.0/src/layer.c000066400000000000000000000053501435762723100147730ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "xxhash.h" layer_t *layer_new(const char *name) { layer_t *layer; layer = calloc(1, sizeof(*layer)); if (name) strncpy(layer->name, name, sizeof(layer->name) - 1); layer->mesh = mesh_new(); mat4_set_identity(layer->mat); return layer; } void layer_delete(layer_t *layer) { mesh_delete(layer->mesh); texture_delete(layer->image); free(layer); } uint32_t layer_get_key(const layer_t *layer) { uint32_t key; key = mesh_get_key(layer->mesh); key = XXH32(&layer->visible, sizeof(layer->visible), key); key = XXH32(&layer->name, sizeof(layer->name), key); key = XXH32(&layer->box, sizeof(layer->box), key); key = XXH32(&layer->mat, sizeof(layer->mat), key); key = XXH32(&layer->shape, sizeof(layer->shape), key); key = XXH32(&layer->color, sizeof(layer->color), key); key = XXH32(&layer->material, sizeof(layer->material), key); return key; } layer_t *layer_copy(layer_t *other) { layer_t *layer; layer = calloc(1, sizeof(*layer)); memcpy(layer->name, other->name, sizeof(layer->name)); layer->visible = other->visible; layer->mesh = mesh_copy(other->mesh); layer->image = texture_copy(other->image); layer->material = other->material; mat4_copy(other->box, layer->box); mat4_copy(other->mat, layer->mat); layer->id = other->id; layer->base_id = other->base_id; layer->base_mesh_key = other->base_mesh_key; layer->shape = other->shape; layer->shape_key = other->shape_key; memcpy(layer->color, other->color, sizeof(layer->color)); return layer; } /* * Function: layer_get_bounding_box * Return the layer box if set, otherwise the bounding box of the layer * mesh. */ void layer_get_bounding_box(const layer_t *layer, float box[4][4]) { int aabb[2][3]; if (!box_is_null(layer->box)) { mat4_copy(layer->box, box); return; } mesh_get_bbox(layer->mesh, aabb, true); if (aabb[0][0] > aabb[1][0]) memset(aabb, 0, sizeof(aabb)); bbox_from_aabb(box, aabb); } goxel-0.11.0/src/layer.h000066400000000000000000000034101435762723100147730ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef LAYER_H #define LAYER_H #include "material.h" #include "mesh.h" #include "shape.h" #include "utils/texture.h" typedef struct layer layer_t; struct layer { layer_t *next, *prev; mesh_t *mesh; const material_t *material; int id; // Uniq id in the image (for clones). bool visible; char name[256]; // 256 chars max. float box[4][4]; // Bounding box. float mat[4][4]; // For 2d image layers. texture_t *image; // For clone layers: int base_id; uint64_t base_mesh_key; // For shape layers. const shape_t *shape; uint32_t shape_key; uint8_t color[4]; }; layer_t *layer_new(const char *name); void layer_delete(layer_t *layer); uint32_t layer_get_key(const layer_t *layer); layer_t *layer_copy(layer_t *other); /* * Function: layer_get_bounding_box * Return the layer box if set, otherwise the bounding box of the layer * mesh. */ void layer_get_bounding_box(const layer_t *layer, float box[4][4]); #endif // LAYER_H goxel-0.11.0/src/log.h000066400000000000000000000033541435762723100144470ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef LOG_H #define LOG_H // #### Logging macros ######### enum { GOX_LOG_VERBOSE = 2, GOX_LOG_DEBUG = 3, GOX_LOG_INFO = 4, GOX_LOG_WARN = 5, GOX_LOG_ERROR = 6, }; #ifndef DEBUG # if !defined(NDEBUG) # define DEBUG 1 # else # define DEBUG 0 # endif #endif #ifndef LOG_LEVEL # if DEBUG # define LOG_LEVEL GOX_LOG_DEBUG # else # define LOG_LEVEL GOX_LOG_INFO # endif #endif #define LOG(level, msg, ...) do { \ if (level >= LOG_LEVEL) \ dolog(level, msg, __func__, __FILE__, __LINE__, ##__VA_ARGS__); \ } while(0) #define LOG_V(msg, ...) LOG(GOX_LOG_VERBOSE, msg, ##__VA_ARGS__) #define LOG_D(msg, ...) LOG(GOX_LOG_DEBUG, msg, ##__VA_ARGS__) #define LOG_I(msg, ...) LOG(GOX_LOG_INFO, msg, ##__VA_ARGS__) #define LOG_W(msg, ...) LOG(GOX_LOG_WARN, msg, ##__VA_ARGS__) #define LOG_E(msg, ...) LOG(GOX_LOG_ERROR, msg, ##__VA_ARGS__) void dolog(int level, const char *msg, const char *func, const char *file, int line, ...); #endif // LOG_H goxel-0.11.0/src/main.c000066400000000000000000000203571435762723100146070ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015-2022 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include #ifdef GLES2 # define GLFW_INCLUDE_ES2 #endif #include static inputs_t *g_inputs = NULL; static GLFWwindow *g_window = NULL; static float g_scale = 1; static void on_glfw_error(int code, const char *msg) { fprintf(stderr, "glfw error %d (%s)\n", code, msg); assert(false); } void on_scroll(GLFWwindow *win, double x, double y) { g_inputs->mouse_wheel = y; } void on_char(GLFWwindow *win, unsigned int c) { inputs_insert_char(g_inputs, c); } void on_drop(GLFWwindow* win, int count, const char** paths) { int i; for (i = 0; i < count; i++) goxel_import_file(paths[i], NULL); } void on_close(GLFWwindow *win) { glfwSetWindowShouldClose(win, GLFW_FALSE); gui_query_quit(); } typedef struct { char *input; char *export; float scale; } args_t; #define OPT_HELP 1 #define OPT_VERSION 2 typedef struct { const char *name; int val; int has_arg; const char *arg_name; const char *help; } gox_option_t; static const gox_option_t OPTIONS[] = { {"export", 'e', required_argument, "FILENAME", .help="Export the image to a file"}, {"scale", 's', required_argument, "FLOAT", .help="Set UI scale"}, {"help", OPT_HELP, .help="Give this help list"}, {"version", OPT_VERSION, .help="Print program version"}, {} }; static void print_help(void) { const gox_option_t *opt; char buf[128]; printf("Usage: goxel [OPTION...] [INPUT]\n"); printf("A 3D voxels editor\n"); printf("\n"); for (opt = OPTIONS; opt->name; opt++) { if (opt->val >= 'a') printf(" -%c, ", opt->val); else printf(" "); if (opt->has_arg) snprintf(buf, sizeof(buf), "--%s=%s", opt->name, opt->arg_name); else snprintf(buf, sizeof(buf), "--%s", opt->name); printf("%-23s %s\n", buf, opt->help); } printf("\n"); printf("Report bugs to .\n"); } static void parse_options(int argc, char **argv, args_t *args) { int i, c, option_index; const gox_option_t *opt; struct option long_options[ARRAY_SIZE(OPTIONS)] = {}; for (i = 0; i < ARRAY_SIZE(OPTIONS); i++) { opt = &OPTIONS[i]; long_options[i] = (struct option) { opt->name, opt->has_arg, NULL, opt->val, }; } while (true) { c = getopt_long(argc, argv, "e:s:", long_options, &option_index); if (c == -1) break; switch (c) { case 'e': args->export = optarg; break; case 's': args->scale = atof(optarg); break; case OPT_HELP: print_help(); exit(0); case OPT_VERSION: printf("Goxel " GOXEL_VERSION_STR "\n"); exit(0); case '?': exit(-1); } } if (optind < argc) { args->input = argv[optind]; } } static void loop_function(void) { int fb_size[2], win_size[2]; int i; double xpos, ypos; float scale; if ( !glfwGetWindowAttrib(g_window, GLFW_VISIBLE) || glfwGetWindowAttrib(g_window, GLFW_ICONIFIED)) { glfwWaitEvents(); goto end; } // The input struct gets all the values in framebuffer coordinates, // On retina display, this might not be the same as the window // size. glfwGetWindowSize(g_window, &win_size[0], &win_size[1]); glfwGetFramebufferSize(g_window, &fb_size[0], &fb_size[1]); scale = g_scale * (float)fb_size[0] / win_size[0]; g_inputs->window_size[0] = win_size[0]; g_inputs->window_size[1] = win_size[1]; g_inputs->scale = scale; GL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); for (i = GLFW_KEY_SPACE; i <= GLFW_KEY_LAST; i++) { g_inputs->keys[i] = glfwGetKey(g_window, i) == GLFW_PRESS; } glfwGetCursorPos(g_window, &xpos, &ypos); vec2_set(g_inputs->touches[0].pos, xpos, ypos); g_inputs->touches[0].down[0] = glfwGetMouseButton(g_window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS; g_inputs->touches[0].down[1] = glfwGetMouseButton(g_window, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS; g_inputs->touches[0].down[2] = glfwGetMouseButton(g_window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS; goxel_iter(g_inputs); goxel_render(); memset(g_inputs, 0, sizeof(*g_inputs)); glfwSwapBuffers(g_window); end: glfwPollEvents(); } #ifndef __EMSCRIPTEN__ static void start_main_loop(void (*func)(void)) { while (!glfwWindowShouldClose(g_window)) { func(); if (goxel.quit) break; } glfwTerminate(); } #else static void start_main_loop(void (*func)(void)) { emscripten_set_main_loop(func, 0, 1); } #endif #if GLFW_VERSION_MAJOR >= 3 && GLFW_VERSION_MINOR >= 2 static void load_icon(GLFWimage *image, const char *path) { uint8_t *img; int w, h, bpp = 0, size; const void *data; data = assets_get(path, &size); assert(data); img = img_read_from_mem(data, size, &w, &h, &bpp); assert(img); assert(bpp == 4); image->width = w; image->height = h; image->pixels = img; } static void set_window_icon(GLFWwindow *window) { GLFWimage icons[7]; int i; load_icon(&icons[0], "asset://data/icons/icon16.png"); load_icon(&icons[1], "asset://data/icons/icon24.png"); load_icon(&icons[2], "asset://data/icons/icon32.png"); load_icon(&icons[3], "asset://data/icons/icon48.png"); load_icon(&icons[4], "asset://data/icons/icon64.png"); load_icon(&icons[5], "asset://data/icons/icon128.png"); load_icon(&icons[6], "asset://data/icons/icon256.png"); glfwSetWindowIcon(window, 7, icons); for (i = 0; i < 7; i++) free(icons[i].pixels); } #else static void set_window_icon(GLFWwindow *window) {} #endif static void set_window_title(void *user, const char *title) { glfwSetWindowTitle(g_window, title); } int main(int argc, char **argv) { args_t args = {.scale = 1}; GLFWwindow *window; GLFWmonitor *monitor; const GLFWvidmode *mode; int width = 640, height = 480, ret = 0; inputs_t inputs = {}; g_inputs = &inputs; // Setup sys callbacks. sys_callbacks.set_window_title = set_window_title; parse_options(argc, argv, &args); g_scale = args.scale; glfwSetErrorCallback(on_glfw_error); glfwInit(); glfwWindowHint(GLFW_SAMPLES, 4); monitor = glfwGetPrimaryMonitor(); mode = glfwGetVideoMode(monitor); if (mode) { width = mode->width ?: 640; height = mode->height ?: 480; } window = glfwCreateWindow(width, height, "Goxel", NULL, NULL); assert(window); g_window = window; glfwMakeContextCurrent(window); if (!DEFINED(EMSCRIPTEN)) glfwSetScrollCallback(window, on_scroll); glfwSetDropCallback(window, on_drop); glfwSetCharCallback(window, on_char); glfwSetWindowCloseCallback(window, on_close); glfwSetInputMode(window, GLFW_STICKY_MOUSE_BUTTONS, false); set_window_icon(window); #ifdef WIN32 glewInit(); #endif goxel_init(); // Run the unit tests in debug. if (DEBUG) { tests_run(); goxel_reset(); } if (args.input) goxel_import_file(args.input, NULL); if (args.export) { if (!args.input) { LOG_E("trying to export an empty image"); ret = -1; } else { ret = goxel_export_to_file(args.export, NULL); } goto end; } start_main_loop(loop_function); end: glfwTerminate(); goxel_release(); return ret; } goxel-0.11.0/src/marchingcube.c000066400000000000000000000727421435762723100163170ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include // Number of sub position per voxel in the marching // cube rendering. #define MC_VOXEL_SUB_POS 8 // XXX: try to make it higher (up to 16!) static const int N = BLOCK_SIZE; // Marching cube data. static const int MC_EDGE_TABLE[256]; static const int8_t MC_TRI_TABLE[256][16]; // Represent a marching cube triangle vertex, by two vertex index and a factor // between them. If mu = 0, the vertex is at v0, if mu = 1, the vertex is // at v1, otherwise the vertex is somewhere in between. typedef struct { int edge; int v0, v1; float mu; float pos[3]; // Interpolated position. uint8_t color[4]; // Computed color. } mc_vert_t; static int mc_compute(const int neighboors[8], mc_vert_t (*out)[3]) { int edges, i, nb_tri; float f0, f1; int cube_index = 0; mc_vert_t verts[12]; for (i = 0; i < 8; i++) if (neighboors[i] >= 127) cube_index |= 1 << i; edges = MC_EDGE_TABLE[cube_index]; if (!edges) return 0; for (i = 0; i < 12; i++) { if (!(edges & (1 << i))) continue; verts[i].edge = i; verts[i].v0 = EDGES_VERTICES[i][0]; verts[i].v1 = EDGES_VERTICES[i][1]; f0 = neighboors[verts[i].v0] / 255.; f1 = neighboors[verts[i].v1] / 255.; verts[i].mu = (f0 - 0.5) / (float)(f0 - f1); } nb_tri = 0; for (i = 0; MC_TRI_TABLE[cube_index][i] != -1; i += 3) { out[nb_tri][0] = verts[MC_TRI_TABLE[cube_index][i + 0]]; out[nb_tri][1] = verts[MC_TRI_TABLE[cube_index][i + 1]]; out[nb_tri][2] = verts[MC_TRI_TABLE[cube_index][i + 2]]; nb_tri++; } assert(nb_tri <= 5); return nb_tri; } static void mc_interp_pos(const mc_vert_t *vert, float out[3], bool rounded) { int i; const int *p0 = VERTICES_POSITIONS[vert->v0]; const int *p1 = VERTICES_POSITIONS[vert->v1]; const float mu = vert->mu; for (i = 0; i < 3; i++) { out[i] = (p0[i] * (1 - mu) + p1[i] * mu); if (rounded) out[i] = round(out[i] * MC_VOXEL_SUB_POS / 4) * 4; else out[i] = out[i] * MC_VOXEL_SUB_POS; } } static void compute_triangle_normal(const mc_vert_t t[3], float out[3]) { int i; float u[3] = {t[1].pos[0] - t[0].pos[0], t[1].pos[1] - t[0].pos[1], t[1].pos[2] - t[0].pos[2]}; float v[3] = {t[2].pos[0] - t[0].pos[0], t[2].pos[1] - t[0].pos[1], t[2].pos[2] - t[0].pos[2]}; float n[3] = {u[1] * v[2] - u[2] * v[1], u[2] * v[0] - u[0] * v[2], u[0] * v[1] - u[1] * v[0]}; for (i = 0; i < 3; i++) out[i] = n[i]; vec3_normalize(out, out); } static void mix_pos(const float a[3], const float b[3], float out[3]) { int i; for (i = 0; i < 3; i++) out[i] = (a[i] + b[i]) / 2; } static bool color_eq(const uint8_t a[4], const uint8_t b[4]) { return memcmp(a, b, 3) == 0; } static bool poly_attach_triangle(int nb, mc_vert_t *poly, const mc_vert_t tri[3]) { int i, j, k; float n1[3], n2[3]; // Can always attach to an empty poly. if (nb == 0) { memcpy(poly, tri, 3 * sizeof(mc_vert_t)); return true; } compute_triangle_normal(poly, n1); compute_triangle_normal(tri, n2); if (fabs(vec3_dot(n1, n2) - 1.0) > 0.01) return false; for (i = 0; i < nb; i++) for (j = 0; j < 3; j++) { if (poly[i].edge == tri[(j + 2) % 3].edge && poly[(i + 1) % nb].edge == tri[(j + 1) % 3].edge) goto ok; } return false; ok: // Shift poly to make space for new vertex and add new point. for (k = nb; k > i + 1; k--) poly[k] = poly[k - 1]; poly[i + 1] = tri[j]; return true; } // Try to extract as many triangles as possible as a single polygon. static int get_poly(int nb, const mc_vert_t (*tri)[3], mc_vert_t *out, int *size) { int i; *size = 0; for (i = 0; i < nb; i++) { if (!poly_attach_triangle(*size, out, tri[i])) break; if (*size == 0) *size = 2; assert(*size < 6 * 6); (*size)++; } return i; } // Shift poly points in place so that the n-th point become the first one. static void poly_shift(int nb, mc_vert_t *poly, int n) { mc_vert_t tmp; int i; for (i = 0; i < n; i++) { tmp = poly[0]; memmove(poly, poly + 1, (nb - 1) * sizeof(*poly)); poly[nb - 1] = tmp; } } static int split_poly(int nb, mc_vert_t *poly, mc_vert_t (*out)[3], const float center[3]) { int i, j; float c[3] = {0, 0, 0}; mc_vert_t p1, p2; if (nb < 3) return 0; if (center == NULL) { center = c; for (i = 0; i < nb; i++) { for (j = 0; j < 3; j++) { c[j] += poly[i].pos[j]; } } for (i = 0; i < 3; i++) c[i] /= nb; } // First pass, try to remove all the plain color triangles. for (i = 0; i < nb; i++) { if ( color_eq(poly[i].color, poly[(i + 1) % nb].color) && color_eq(poly[i].color, poly[(i + nb - 1) % nb].color)) { poly_shift(nb, poly, i); out[0][0] = poly[0]; out[0][1] = poly[1]; out[0][2] = poly[nb - 1]; return 1 + split_poly(nb - 1, poly + 1, out + 1, center); } } // Second pass, try to remove all two adjacent colors into a quad. for (i = 0; nb < 6 && i < nb; i++) { if (color_eq(poly[i].color, poly[(i + 1) % nb].color)) { poly_shift(nb, poly, i); p1 = poly[0]; mix_pos(poly[0].pos, poly[nb - 1].pos, p1.pos); p2 = poly[0]; mix_pos(poly[1].pos, poly[2].pos, p2.pos); out[0][0] = poly[0]; out[0][1] = poly[1]; out[0][2] = p2; out[1][0] = poly[0]; out[1][1] = p2; out[1][2] = p1; poly[0] = p1; memcpy(poly[0].color, poly[nb - 1].color, 4); poly[1] = p2; memcpy(poly[1].color, poly[2].color, 4); return 2 + split_poly(nb, poly, out + 2, center); } } for (i = 0; i < nb; i++) { out[i * 2 + 0][0] = poly[i]; out[i * 2 + 0][1] = poly[i]; out[i * 2 + 0][2] = poly[i]; mix_pos(poly[i].pos, poly[(i + 1) % nb].pos, out[i * 2 + 0][1].pos); memcpy(out[i * 2 + 0][2].pos, center, sizeof(c)); out[i * 2 + 1][0] = poly[i]; out[i * 2 + 1][1] = poly[i]; out[i * 2 + 1][2] = poly[i]; memcpy(out[i * 2 + 1][1].pos, center, sizeof(c)); mix_pos(poly[i].pos, poly[(i + nb - 1) % nb].pos, out[i * 2 + 1][2].pos); } return nb * 2; } static int split_triangles(int nb, const mc_vert_t (*tri)[3], mc_vert_t (*out)[3]) { mc_vert_t poly[6 * 6]; mc_vert_t new_tri[30][3]; int i = 0, ret = 0, poly_size; while (i < nb) { i += get_poly(nb - i, tri + i, poly, &poly_size); ret += split_poly(poly_size, poly, new_tri + ret, NULL); } memcpy(out, new_tri, ret * sizeof(*out)); return ret; } int mesh_generate_vertices_mc(const mesh_t *mesh, const int block_pos[3], int effects, voxel_vertex_t *out, int *size, int *subdivide) { int i, vi, x, y, z, v, vx, vy, vz, nb_tri, nb_tri_tot = 0; uint8_t tmp[4]; uint8_t *data; int densities[8]; int p[3], s[3]; int rect[2][3] = {{INT_MAX, INT_MAX, INT_MAX}, {INT_MIN, INT_MIN, INT_MIN}}; mc_vert_t tri[30][3]; float n[3]; const bool flat = !(effects & EFFECT_MC_SMOOTH); *size = 3; // Triangles. *subdivide = MC_VOXEL_SUB_POS; // To speed things up we first get the voxel cube around the block. data = malloc((N + 2) * (N + 2) * (N + 2) * 4); p[0] = block_pos[0] - 1; p[1] = block_pos[1] - 1; p[2] = block_pos[2] - 1; s[0] = N + 2; s[1] = N + 2; s[2] = N + 2; mesh_read(mesh, p, s, data); #define get_at(d, x, y, z, out) do { \ memcpy(out, &data[( \ (x + 1) + \ (y + 1) * (N + 2) + \ (z + 1) * (N + 2) * (N + 2)) * 4], 4); \ } while (0) // Get the smallest rect we need to consider. // XXX: can we measure how much we gain with that? for (z = -1; z < N + 1; z++) for (y = -1; y < N + 1; y++) for (x = -1; x < N + 1; x++) { get_at(data, x, y, z, tmp); if (tmp[3]) { rect[0][0] = min(rect[0][0], x - 2); rect[0][1] = min(rect[0][1], y - 2); rect[0][2] = min(rect[0][2], z - 2); rect[1][0] = max(rect[1][0], x + 2); rect[1][1] = max(rect[1][1], y + 2); rect[1][2] = max(rect[1][2], z + 2); } } rect[0][0] = max(rect[0][0], 0); rect[0][1] = max(rect[0][1], 0); rect[0][2] = max(rect[0][2], 0); rect[1][0] = min(rect[1][0], N); rect[1][1] = min(rect[1][1], N); rect[1][2] = min(rect[1][2], N); // Add up the contribution of each voxel to the vertices values. for (z = rect[0][2]; z < rect[1][2]; z++) for (y = rect[0][1]; y < rect[1][1]; y++) for (x = rect[0][0]; x < rect[1][0]; x++) { memset(densities, 0, sizeof(densities)); for (v = 0; v < 8; v++) { vx = x + VERTICES_POSITIONS[v][0]; vy = y + VERTICES_POSITIONS[v][1]; vz = z + VERTICES_POSITIONS[v][2]; get_at(data, vx, vy, vz, tmp); densities[v] = tmp[3]; } nb_tri = mc_compute(densities, tri); for (i = 0; i < nb_tri; i++) { for (v = 0; v < 3; v++) { mc_interp_pos(&tri[i][v], tri[i][v].pos, flat); uint8_t c1[4], c2[4]; get_at(data, x + VERTICES_POSITIONS[tri[i][v].v0][0], y + VERTICES_POSITIONS[tri[i][v].v0][1], z + VERTICES_POSITIONS[tri[i][v].v0][2], c1); get_at(data, x + VERTICES_POSITIONS[tri[i][v].v1][0], y + VERTICES_POSITIONS[tri[i][v].v1][1], z + VERTICES_POSITIONS[tri[i][v].v1][2], c2); memcpy(tri[i][v].color, c1[3] > c2[3] ? c1 : c2, 4); } } if (flat) nb_tri = split_triangles(nb_tri, tri, tri); for (i = 0; i < nb_tri; i++) { compute_triangle_normal(tri[i], n); for (v = 0; v < 3; v++) { vi = nb_tri_tot * 3 + v; memcpy(out[vi].color, tri[i][v].color, sizeof(out[vi].color)); out[vi].color[3] = 255; out[vi].pos[0] = tri[i][v].pos[0] + x * MC_VOXEL_SUB_POS + MC_VOXEL_SUB_POS / 2 + 0.5; out[vi].pos[1] = tri[i][v].pos[1] + y * MC_VOXEL_SUB_POS + MC_VOXEL_SUB_POS / 2 + 0.5; out[vi].pos[2] = tri[i][v].pos[2] + z * MC_VOXEL_SUB_POS + MC_VOXEL_SUB_POS / 2 + 0.5; out[vi].normal[0] = n[0] * 64; out[vi].normal[1] = n[1] * 64; out[vi].normal[2] = n[2] * 64; // XXX: this shouldn't matter. memset(out[vi].occlusion_uv, 0, sizeof(out[vi].occlusion_uv)); memset(out[vi].bump_uv, 0, sizeof(out[vi].bump_uv)); memset(out[vi].gradient, 0, sizeof(out[vi].gradient)); } nb_tri_tot++; } } free(data); return nb_tri_tot; } // Static data for marching cube algo. static const int MC_EDGE_TABLE[256] = { 0x0 , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00, 0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90, 0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c, 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30, 0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac, 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0, 0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c, 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60, 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc, 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0, 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c, 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950, 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc , 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0, 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, 0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0, 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650, 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, 0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0, 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, 0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460, 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0, 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230, 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190, 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0 }; static const int8_t MC_TRI_TABLE[256][16] = { {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1}, {3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1}, {3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1}, {3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1}, {9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1}, {9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1}, {2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1}, {8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1}, {9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1}, {4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1}, {3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1}, {1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1}, {4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1}, {4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1}, {5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1}, {2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1}, {9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1}, {0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1}, {2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1}, {10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1}, {4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1}, {5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1}, {5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1}, {9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1}, {0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1}, {1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1}, {10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1}, {8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1}, {2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1}, {7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1}, {2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1}, {11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1}, {5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1}, {11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1}, {11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1}, {1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1}, {9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1}, {5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1}, {2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1}, {5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1}, {6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1}, {3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1}, {6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1}, {5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1}, {1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1}, {10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1}, {6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1}, {8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1}, {7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1}, {3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1}, {5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1}, {0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1}, {9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1}, {8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1}, {5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1}, {0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1}, {6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1}, {10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1}, {10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1}, {8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1}, {1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1}, {0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1}, {10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1}, {3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1}, {6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1}, {9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1}, {8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1}, {3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1}, {6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1}, {0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1}, {10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1}, {10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1}, {2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1}, {7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1}, {7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1}, {2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1}, {1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1}, {11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1}, {8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1}, {0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1}, {7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1}, {10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1}, {2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1}, {6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1}, {7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1}, {2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1}, {1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1}, {10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1}, {10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1}, {0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1}, {7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1}, {6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1}, {8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1}, {9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1}, {6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1}, {4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1}, {10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1}, {8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1}, {0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1}, {1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1}, {8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1}, {10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1}, {4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1}, {10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1}, {5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1}, {11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1}, {9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1}, {6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1}, {7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1}, {3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1}, {7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1}, {9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1}, {3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1}, {6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1}, {9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1}, {1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1}, {4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1}, {7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1}, {6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1}, {3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1}, {0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1}, {6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1}, {0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1}, {11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1}, {6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1}, {5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1}, {9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1}, {1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1}, {1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1}, {10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1}, {0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1}, {5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1}, {10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1}, {11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1}, {9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1}, {7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1}, {2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1}, {8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1}, {9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1}, {9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1}, {1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1}, {9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1}, {9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1}, {5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1}, {0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1}, {10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1}, {2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1}, {0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1}, {0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1}, {9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1}, {5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1}, {3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1}, {5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1}, {8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1}, {0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1}, {9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1}, {0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1}, {1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1}, {3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1}, {4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1}, {9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1}, {11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1}, {11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1}, {2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1}, {9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1}, {3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1}, {1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1}, {4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1}, {4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1}, {0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1}, {3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1}, {3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1}, {0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1}, {9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1}, {1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1} }; goxel-0.11.0/src/material.c000066400000000000000000000027171435762723100154610ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "material.h" #include "xxhash.h" #include #include material_t *material_new(const char *name) { material_t *m = calloc(1, sizeof(*m)); *m = MATERIAL_DEFAULT; if (name) snprintf(m->name, sizeof(m->name), "%s", name); return m; } void material_delete(material_t *m) { free(m); } material_t *material_copy(const material_t *other) { material_t *m = malloc(sizeof(*m)); *m = *other; m->next = m->prev = NULL; return m; } uint32_t material_get_hash(const material_t *m) { uint32_t ret = 0; ret = XXH32(&m->metallic, sizeof(m->metallic), ret); ret = XXH32(&m->roughness, sizeof(m->roughness), ret); ret = XXH32(&m->base_color, sizeof(m->base_color), ret); return ret; } goxel-0.11.0/src/material.h000066400000000000000000000025451435762723100154650ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef MATERIAL_H #define MATERIAL_H #include typedef struct material material_t; struct material { char name[128]; // 127 chars max. float metallic; float roughness; float base_color[4]; float emission[3]; material_t *next, *prev; // List of materials in an image. }; #define MATERIAL_DEFAULT (material_t){ \ .name = {}, \ .metallic = 0.2, \ .roughness = 0.5, \ .base_color = {1, 1, 1, 1}} material_t *material_new(const char *name); void material_delete(material_t *m); material_t *material_copy(const material_t *mat); uint32_t material_get_hash(const material_t *m); #endif // MATERIAL_H goxel-0.11.0/src/mesh.c000066400000000000000000000560151435762723100146170ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "mesh.h" #include "uthash.h" #include #include #include #define min(a, b) ({ \ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ _a < _b ? _a : _b; \ }) #define max(a, b) ({ \ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ _a > _b ? _a : _b; \ }) // Flags for the iterator/accessor status. enum { MESH_ITER_FINISHED = 1 << 9, MESH_ITER_BOX = 1 << 10, MESH_ITER_MESH2 = 1 << 11, }; typedef struct block_data block_data_t; struct block_data { int ref; uint64_t id; uint8_t voxels[BLOCK_SIZE * BLOCK_SIZE * BLOCK_SIZE][4]; // RGBA voxels. }; struct block { UT_hash_handle hh; // The hash table of pos -> blocks in a mesh. block_data_t *data; int pos[3]; uint64_t id; }; struct mesh { block_t *blocks; int *ref; // Used to implement copy on write of the blocks. uint64_t key; // Two meshes with the same key have the same value. }; static uint64_t g_uid = 2; // Global id counter. static mesh_global_stats_t g_global_stats = {}; #define N BLOCK_SIZE #define vec3_copy(a, b) do {b[0] = a[0]; b[1] = a[1]; b[2] = a[2];} while (0) #define vec3_equal(a, b) (b[0] == a[0] && b[1] == a[1] && b[2] == a[2]) #define BLOCK_ITER(x, y, z) \ for (z = 0; z < N; z++) \ for (y = 0; y < N; y++) \ for (x = 0; x < N; x++) #define DATA_AT(d, x, y, z) (d->voxels[x + y * N + z * N * N]) #define BLOCK_AT(c, x, y, z) (DATA_AT(c->data, x, y, z)) static void mat4_mul_vec4(float mat[4][4], const float v[4], float out[4]) { float ret[4] = {0}; int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { ret[i] += mat[j][i] * v[j]; } } memcpy(out, ret, sizeof(ret)); } static void box_get_bbox(float box[4][4], int bbox[2][3]) { const float vertices[8][4] = { {-1, -1, +1, 1}, {+1, -1, +1, 1}, {+1, +1, +1, 1}, {-1, +1, +1, 1}, {-1, -1, -1, 1}, {+1, -1, -1, 1}, {+1, +1, -1, 1}, {-1, +1, -1, 1}}; int i; int ret[2][3] = {{INT_MAX, INT_MAX, INT_MAX}, {INT_MIN, INT_MIN, INT_MIN}}; float p[4]; for (i = 0; i < 8; i++) { mat4_mul_vec4(box, vertices[i], p); ret[0][0] = min(ret[0][0], (int)floor(p[0])); ret[0][1] = min(ret[0][1], (int)floor(p[1])); ret[0][2] = min(ret[0][2], (int)floor(p[2])); ret[1][0] = max(ret[1][0], (int)ceil(p[0])); ret[1][1] = max(ret[1][1], (int)ceil(p[1])); ret[1][2] = max(ret[1][2], (int)ceil(p[2])); } memcpy(bbox, ret, sizeof(ret)); } static void bbox_intersection(int a[2][3], int b[2][3], int out[2][3]) { int i; for (i = 0; i < 3; i++) { out[0][i] = max(a[0][i], b[0][i]); out[1][i] = min(a[1][i], b[1][i]); } } static block_data_t *get_empty_data(void) { static block_data_t *data = NULL; if (!data) { data = calloc(1, sizeof(*data)); data->ref = 1; data->id = 0; } return data; } static bool block_is_empty(const block_t *block, bool fast) { int x, y, z; if (!block) return true; if (block->data->id == 0) return true; if (fast) return false; BLOCK_ITER(x, y, z) { if (BLOCK_AT(block, x, y, z)[3]) return false; } return true; } static block_t *block_new(const int pos[3]) { block_t *block = calloc(1, sizeof(*block)); memcpy(block->pos, pos, sizeof(block->pos)); block->data = get_empty_data(); block->data->ref++; block->id = g_uid++; return block; } static void block_delete(block_t *block) { block->data->ref--; if (block->data->ref == 0) { free(block->data); g_global_stats.nb_blocks--; g_global_stats.mem -= sizeof(*block->data); } free(block); } static block_t *block_copy(const block_t *other) { block_t *block = malloc(sizeof(*block)); *block = *other; memset(&block->hh, 0, sizeof(block->hh)); block->data->ref++; block->id = g_uid++; return block; } static void block_set_data(block_t *block, block_data_t *data) { block->data->ref--; if (block->data->ref == 0) { free(block->data); g_global_stats.nb_blocks--; g_global_stats.mem -= sizeof(*block->data); } block->data = data; data->ref++; } // Copy the data if there are any other blocks having reference to it. static void block_prepare_write(block_t *block) { if (block->data->ref == 1) { block->data->id = ++g_uid; return; } block->data->ref--; block_data_t *data; data = calloc(1, sizeof(*block->data)); memcpy(data->voxels, block->data->voxels, N * N * N * 4); data->ref = 1; block->data = data; block->data->id = ++g_uid; g_global_stats.nb_blocks++; g_global_stats.mem += sizeof(*block->data); } static void block_get_at(const block_t *block, const int pos[3], uint8_t out[4]) { int x, y, z; if (!block) { memset(out, 0, 4); return; } x = pos[0] - block->pos[0]; y = pos[1] - block->pos[1]; z = pos[2] - block->pos[2]; assert(x >= 0 && x < N); assert(y >= 0 && y < N); assert(z >= 0 && z < N); memcpy(out, BLOCK_AT(block, x, y, z), 4); } /* * Function: mesh_get_bbox * * Get the bounding box of a mesh. * * Inputs: * mesh - The mesh * exact - If true, compute the exact bounding box. If false, returns * an approximation that might be slightly bigger than the * actual box, but faster to compute. * * Outputs: * bbox - The bounding box as the bottom left and top right corner of * the mesh. If the mesh is empty, this will contain all zero. * * Returns: * true if the mesh is not empty. */ bool mesh_get_bbox(const mesh_t *mesh, int bbox[2][3], bool exact) { block_t *block; int ret[2][3] = {{INT_MAX, INT_MAX, INT_MAX}, {INT_MIN, INT_MIN, INT_MIN}}; int pos[3]; mesh_iterator_t iter; bool empty = false; if (!exact) { for (block = mesh->blocks; block; block = block->hh.next) { if (block_is_empty(block, true)) continue; ret[0][0] = min(ret[0][0], block->pos[0]); ret[0][1] = min(ret[0][1], block->pos[1]); ret[0][2] = min(ret[0][2], block->pos[2]); ret[1][0] = max(ret[1][0], block->pos[0] + N); ret[1][1] = max(ret[1][1], block->pos[1] + N); ret[1][2] = max(ret[1][2], block->pos[1] + N); } } else { iter = mesh_get_iterator(mesh, MESH_ITER_SKIP_EMPTY); while (mesh_iter(&iter, pos)) { if (!mesh_get_alpha_at(mesh, &iter, pos)) continue; ret[0][0] = min(ret[0][0], pos[0]); ret[0][1] = min(ret[0][1], pos[1]); ret[0][2] = min(ret[0][2], pos[2]); ret[1][0] = max(ret[1][0], pos[0] + 1); ret[1][1] = max(ret[1][1], pos[1] + 1); ret[1][2] = max(ret[1][2], pos[2] + 1); } } empty = ret[0][0] >= ret[1][0]; if (empty) memset(ret, 0, sizeof(ret)); memcpy(bbox, ret, sizeof(ret)); return !empty; } static void mesh_prepare_write(mesh_t *mesh) { block_t *blocks, *block, *new_block; assert(*mesh->ref > 0); mesh->key = g_uid++; if (*mesh->ref == 1) return; (*mesh->ref)--; mesh->ref = calloc(1, sizeof(*mesh->ref)); *mesh->ref = 1; blocks = mesh->blocks; mesh->blocks = NULL; for (block = blocks; block; block = block->hh.next) { block->id = g_uid++; // Invalidate all accessors. new_block = block_copy(block); HASH_ADD(hh, mesh->blocks, pos, sizeof(new_block->pos), new_block); } g_global_stats.nb_meshes++; } static block_t *mesh_add_block(mesh_t *mesh, const int pos[3]); static void mesh_add_neighbors_blocks(mesh_t *mesh) { const int POS[6][3] = { {0, 0, -1}, {0, 0, +1}, {0, -1, 0}, {0, +1, 0}, {-1, 0, 0}, {+1, 0, 0}, }; int i, p[3] = {}; uint64_t key = mesh->key; block_t *block, *tmp, *other; mesh_prepare_write(mesh); HASH_ITER(hh, mesh->blocks, block, tmp) { if (block_is_empty(block, true)) continue; for (i = 0; i < 6; i++) { p[0] = block->pos[0] + POS[i][0] * N; p[1] = block->pos[1] + POS[i][1] * N; p[2] = block->pos[2] + POS[i][2] * N; HASH_FIND(hh, mesh->blocks, p, 3 * sizeof(int), other); if (!other) mesh_add_block(mesh, p); } } // Adding empty blocks shouldn't change the key of the mesh. mesh->key = key; } void mesh_remove_empty_blocks(mesh_t *mesh, bool fast) { block_t *block, *tmp; uint64_t key = mesh->key; mesh_prepare_write(mesh); HASH_ITER(hh, mesh->blocks, block, tmp) { if (block_is_empty(block, false)) { HASH_DEL(mesh->blocks, block); assert(mesh->blocks != block); block_delete(block); } } // Empty blocks shouldn't change the key of the mesh. mesh->key = key; } bool mesh_is_empty(const mesh_t *mesh) { return mesh == NULL || mesh->blocks == NULL; } mesh_t *mesh_new(void) { mesh_t *mesh; mesh = calloc(1, sizeof(*mesh)); mesh->ref = calloc(1, sizeof(*mesh->ref)); mesh->key = 1; // Empty mesh key. *mesh->ref = 1; g_global_stats.nb_meshes++; return mesh; } mesh_iterator_t mesh_get_iterator(const mesh_t *mesh, int flags) { return (mesh_iterator_t){ .mesh = mesh, .flags = flags, }; } mesh_iterator_t mesh_get_union_iterator( const mesh_t *m1, const mesh_t *m2, int flags) { return (mesh_iterator_t){ .mesh = m1, .mesh2 = m2, .flags = flags, }; } mesh_iterator_t mesh_get_box_iterator(const mesh_t *mesh, const float box[4][4], int flags) { int mesh_bbox[2][3]; mesh_iterator_t iter = { .mesh = mesh, .flags = MESH_ITER_BOX | MESH_ITER_VOXELS | flags, }; memcpy(iter.box, box, sizeof(iter.box)); box_get_bbox(iter.box, iter.bbox); if (flags & MESH_ITER_SKIP_EMPTY) { mesh_get_bbox(mesh, mesh_bbox, false); bbox_intersection(mesh_bbox, iter.bbox, iter.bbox); } return iter; } mesh_accessor_t mesh_get_accessor(const mesh_t *mesh) { return (mesh_accessor_t){0}; } void mesh_clear(mesh_t *mesh) { assert(mesh); block_t *block, *tmp; mesh_prepare_write(mesh); HASH_ITER(hh, mesh->blocks, block, tmp) { HASH_DEL(mesh->blocks, block); assert(mesh->blocks != block); block_delete(block); } mesh->key = 1; // Empty mesh key. mesh->blocks = NULL; } void mesh_delete(mesh_t *mesh) { block_t *block, *tmp; if (!mesh) return; (*mesh->ref)--; if (*mesh->ref == 0) { HASH_ITER(hh, mesh->blocks, block, tmp) { HASH_DEL(mesh->blocks, block); assert(mesh->blocks != block); block_delete(block); } free(mesh->ref); g_global_stats.nb_meshes--; } free(mesh); } mesh_t *mesh_copy(const mesh_t *other) { mesh_t *mesh = calloc(1, sizeof(*mesh)); mesh->blocks = other->blocks; mesh->ref = other->ref; mesh->key = other->key; (*mesh->ref)++; return mesh; } void mesh_set(mesh_t *mesh, const mesh_t *other) { block_t *block, *tmp; assert(mesh && other); if (mesh->blocks == other->blocks) return; // Already the same. (*mesh->ref)--; if (*mesh->ref == 0) { HASH_ITER(hh, mesh->blocks, block, tmp) { HASH_DEL(mesh->blocks, block); assert(mesh->blocks != block); block_delete(block); } free(mesh->ref); g_global_stats.nb_meshes--; } mesh->blocks = other->blocks; mesh->ref = other->ref; mesh->key = other->key; (*mesh->ref)++; } static uint64_t get_block_id(const block_t *block) { return block ? block->id : 1; } static block_t *mesh_get_block_at(const mesh_t *mesh, const int pos[3], mesh_accessor_t *it) { block_t *block; int p[3] = {}; p[0] = pos[0] & ~(int)(N - 1); p[1] = pos[1] & ~(int)(N - 1); p[2] = pos[2] & ~(int)(N - 1); if (!it) { HASH_FIND(hh, mesh->blocks, p, sizeof(p), block); return block; } if ( it->block_id && it->block_id == get_block_id(it->block) && vec3_equal(it->block_pos, p)) { return it->block; } HASH_FIND(hh, mesh->blocks, p, sizeof(p), block); it->block = block; it->block_id = get_block_id(block); vec3_copy(p, it->block_pos); return block; } static block_t *mesh_add_block(mesh_t *mesh, const int pos[3]) { block_t *block; assert(pos[0] % BLOCK_SIZE == 0); assert(pos[1] % BLOCK_SIZE == 0); assert(pos[2] % BLOCK_SIZE == 0); assert(!mesh_get_block_at(mesh, pos, NULL)); mesh_prepare_write(mesh); block = block_new(pos); HASH_ADD(hh, mesh->blocks, pos, sizeof(block->pos), block); return block; } void mesh_get_at(const mesh_t *mesh, mesh_iterator_t *it, const int pos[3], uint8_t out[4]) { block_t *block; int p[3]; if (it && it->block_id && it->block_id == get_block_id(it->block)) { p[0] = pos[0] - it->block_pos[0]; p[1] = pos[1] - it->block_pos[1]; p[2] = pos[2] - it->block_pos[2]; if ( p[0] >= 0 && p[0] < N && p[1] >= 0 && p[1] < N && p[2] >= 0 && p[2] < N) { if (!it->block) memset(out, 0, 4); else memcpy(out, BLOCK_AT(it->block, p[0], p[1], p[2]), 4); return; } } block = mesh_get_block_at(mesh, pos, it); return block_get_at(block, pos, out); } void mesh_set_at(mesh_t *mesh, mesh_iterator_t *iter, const int pos[3], const uint8_t v[4]) { int p[3] = {pos[0] & ~(int)(N - 1), pos[1] & ~(int)(N - 1), pos[2] & ~(int)(N - 1)}; mesh_prepare_write(mesh); block_t *block = mesh_get_block_at(mesh, p, iter); if (!block) { block = mesh_add_block(mesh, p); if (iter) { iter->block = block; iter->block_id = get_block_id(block); vec3_copy(p, iter->block_pos); } } block_prepare_write(block); p[0] = pos[0] - block->pos[0]; p[1] = pos[1] - block->pos[1]; p[2] = pos[2] - block->pos[2]; assert(p[0] >= 0 && p[0] < N); assert(p[1] >= 0 && p[1] < N); assert(p[2] >= 0 && p[2] < N); memcpy(BLOCK_AT(block, p[0], p[1], p[2]), v, 4); } void mesh_clear_block(mesh_t *mesh, mesh_iterator_t *it, const int pos[3]) { block_t *block; mesh_prepare_write(mesh); block = mesh_get_block_at(mesh, pos, it); if (!block) return; HASH_DEL(mesh->blocks, block); assert(mesh->blocks != block); block_delete(block); if (it) it->block = NULL; } static bool mesh_iter_next_block_box(mesh_iterator_t *it) { int i; const mesh_t *mesh = it->mesh; if (!it->block_id) { it->block_pos[0] = it->bbox[0][0] & ~(int)(N - 1); it->block_pos[1] = it->bbox[0][1] & ~(int)(N - 1); it->block_pos[2] = it->bbox[0][2] & ~(int)(N - 1); goto end; } for (i = 0; i < 3; i++) { it->block_pos[i] += N; if (it->block_pos[i] <= it->bbox[1][i]) break; it->block_pos[i] = it->bbox[0][i] & ~(int)(N - 1); } if (i == 3) return false; end: HASH_FIND(hh, mesh->blocks, it->block_pos, 3 * sizeof(int), it->block); it->block_id = get_block_id(it->block); vec3_copy(it->block_pos, it->pos); return true; } static bool mesh_iter_next_block_union(mesh_iterator_t *it) { it->block = it->block ? it->block->hh.next : it->mesh->blocks; if (!it->block && !(it->flags & MESH_ITER_MESH2)) { it->block = it->mesh2->blocks; it->flags |= MESH_ITER_MESH2; } if (!it->block) return false; it->block_id = it->block->id; vec3_copy(it->block->pos, it->block_pos); vec3_copy(it->block->pos, it->pos); // Discard blocks that we already did from the first mesh. if (it->flags & MESH_ITER_MESH2) { if (mesh_get_block_at(it->mesh, it->block_pos, NULL)) return mesh_iter_next_block_union(it); } return true; } static bool mesh_iter_next_block(mesh_iterator_t *it) { if (it->block_id && it->block_id != get_block_id(it->block)) { it->block = mesh_get_block_at( (it->flags & MESH_ITER_MESH2) ? it->mesh2 : it->mesh, it->block_pos, it); } if (it->flags & MESH_ITER_BOX) return mesh_iter_next_block_box(it); if (it->mesh2) return mesh_iter_next_block_union(it); it->block = it->block ? it->block->hh.next : it->mesh->blocks; if (!it->block) return false; it->block_id = it->block->id; vec3_copy(it->block->pos, it->block_pos); vec3_copy(it->block->pos, it->pos); return true; } int mesh_iter(mesh_iterator_t *it, int pos[3]) { int i; if (!it->block_id) { // First call. // XXX: this is not good: mesh_iter shouldn't make change to the // mesh. if (it->flags & MESH_ITER_INCLUDES_NEIGHBORS) mesh_add_neighbors_blocks((mesh_t*)it->mesh); if (!mesh_iter_next_block(it)) return 0; goto end; } if (it->flags & MESH_ITER_BLOCKS) goto next_block; for (i = 0; i < 3; i++) { if (++it->pos[i] < it->block_pos[i] + N) break; it->pos[i] = it->block_pos[i]; } if (i < 3) goto end; next_block: if (!mesh_iter_next_block(it)) { // XXX: this is not good: mesh_iter shouldn't make changes to the // mesh. if (it->flags & MESH_ITER_INCLUDES_NEIGHBORS) mesh_remove_empty_blocks((mesh_t*)it->mesh, true); return 0; } end: if (pos) vec3_copy(it->pos, pos); return 1; } uint64_t mesh_get_key(const mesh_t *mesh) { return mesh ? mesh->key : 0; } void *mesh_get_block_data(const mesh_t *mesh, mesh_accessor_t *iter, const int bpos[3], uint64_t *id) { block_t *block = NULL; if ( iter && iter->block_id && iter->block_id == get_block_id(iter->block) && memcmp(&iter->pos, bpos, sizeof(iter->pos)) == 0) { block = iter->block; } else { HASH_FIND(hh, mesh->blocks, bpos, sizeof(iter->pos), block); } if (id) *id = block ? block->data->id : 0; return block ? block->data->voxels : NULL; } uint8_t mesh_get_alpha_at(const mesh_t *mesh, mesh_iterator_t *iter, const int pos[3]) { uint8_t v[4]; mesh_get_at(mesh, iter, pos, v); return v[3]; } void mesh_copy_block(const mesh_t *src, const int src_pos[3], mesh_t *dst, const int dst_pos[3]) { block_t *b1, *b2; mesh_prepare_write(dst); b1 = mesh_get_block_at(src, src_pos, NULL); b2 = mesh_get_block_at(dst, dst_pos, NULL); if (!b2) b2 = mesh_add_block(dst, dst_pos); block_set_data(b2, b1->data); } void mesh_read(const mesh_t *mesh, const int pos[3], const int size[3], uint8_t *data) { // For the moment we only support the case where we get the rectangle // of a block plus a one voxel border around it! assert(pos[0] - (pos[0] & ~(int)(N - 1)) == N - 1); assert(pos[1] - (pos[1] & ~(int)(N - 1)) == N - 1); assert(pos[2] - (pos[2] & ~(int)(N - 1)) == N - 1); assert(size[0] == N + 2); assert(size[1] == N + 2); assert(size[2] == N + 2); block_t *block; int block_pos[3] = {pos[0] + 1, pos[1] + 1, pos[2] + 1}; int i, z, y, x, dx, dy, dz, p[3]; uint8_t v[4]; mesh_accessor_t accessor; memset(data, 0, size[0] * size[1] * size[2] * 4); block = mesh_get_block_at(mesh, block_pos, NULL); if (!block) goto rest; for (z = 0; z < N; z++) for (y = 0; y < N; y++) for (x = 0; x < N; x++) { dx = x + 1; dy = y + 1; dz = z + 1; memcpy(&data[(dz * size[1] * size[0] + dy * size[0] + dx) * 4], &block->data->voxels[z * N * N + y * N + x], 4); } rest: // Fill the rest. // In order to optimize access, we iter in such a way to avoid changing // the current block: start with the planes, then the edges, and finally // the 8 corners. accessor = mesh_get_accessor(mesh); const int ranges[26][3][2] = { // 6 planes. {{0, 1}, {1, N + 1}, {1, N + 1}}, {{N + 1, N + 2}, {1, N + 1}, {1, N + 1}}, {{1, N + 1}, {0, 1}, {1, N + 1}}, {{1, N + 1}, {N + 1, N + 2}, {1, N + 1}}, {{1, N + 1}, {1, N + 1}, {0, 1}}, {{1, N + 1}, {1, N + 1}, {N + 1, N + 2}}, // 4 edges moving along X. {{1, N + 1}, {0, 1}, {0, 1}}, {{1, N + 1}, {N + 1, N + 2}, {0, 1}}, {{1, N + 1}, {0, 1}, {N + 1, N + 2}}, {{1, N + 1}, {N + 1, N + 2}, {N + 1, N + 2}}, // 4 edges moving along Y. {{0, 1}, {1, N + 1}, {0, 1}}, {{N + 1, N + 2}, {1, N + 1}, {0, 1}}, {{0, 1}, {1, N + 1}, {1, N + 2}}, {{N + 1, N + 2}, {1, N + 1}, {1, N + 2}}, // 4 edges moving along Z. {{0, 1}, {0, 1}, {1, N + 1}}, {{N + 1, N + 2}, {0, 1}, {1, N + 1}}, {{0, 1}, {N + 1, N + 2}, {1, N + 1}}, {{N + 1, N + 2}, {N + 1, N + 2}, {1, N + 1}}, // 8 Corners. {{0, 1 }, {0, 1 }, {0, 1 }}, {{N + 1, N + 2}, {0, 1 }, {0, 1 }}, {{0, 1 }, {N + 1, N + 2}, {0, 1 }}, {{N + 1, N + 2}, {N + 1, N + 2}, {0, 1 }}, {{0, 1 }, {0, 1 }, {N + 1, N + 2}}, {{N + 1, N + 2}, {0, 1 }, {N + 1, N + 2}}, {{0, 1 }, {N + 1, N + 2}, {N + 1, N + 2}}, {{N + 1, N + 2}, {N + 1, N + 2}, {N + 1, N + 2}}, }; for (i = 0; i < 26; i++) for (z = ranges[i][2][0]; z < ranges[i][2][1]; z++) for (y = ranges[i][1][0]; y < ranges[i][1][1]; y++) for (x = ranges[i][0][0]; x < ranges[i][0][1]; x++) { p[0] = pos[0] + x; p[1] = pos[1] + y; p[2] = pos[2] + z; mesh_get_at(mesh, &accessor, p, v); memcpy(&data[(z * size[1] * size[0] + y * size[0] + x) * 4], v, 4); } } void mesh_get_global_stats(mesh_global_stats_t *stats) { *stats = g_global_stats; } goxel-0.11.0/src/mesh.h000066400000000000000000000147051435762723100146240ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef MESH_H #define MESH_H #include #include #define BLOCK_SIZE 16 /* Type: mesh_t * Opaque type that represents a mesh. */ typedef struct mesh mesh_t; typedef struct block block_t; /* Enum: MESH_ITER * Some flags that can be used to modify the behavior of the iteration * function. * * MESH_ITER_VOXELS - Iter on the voxels (default if zero). * MESH_ITER_BLOCKS - Iter on the blocks: the iterator return successive * blocks positions. * MESH_ITER_INCLUDES_NEIGHBORS - Also yield one position for each * neighbor of the voxels. * MESH_ITER_SKIP_EMPTY - Don't yield empty voxels/blocks. */ enum { MESH_ITER_VOXELS = 1 << 0, MESH_ITER_BLOCKS = 1 << 1, MESH_ITER_INCLUDES_NEIGHBORS = 1 << 2, MESH_ITER_SKIP_EMPTY = 1 << 3, }; /* Type mesh_iterator_t * Fast iterator of all the mesh voxels. * * This struct can be used when we want to make a lot of successive accesses * to the same mesh. * * It's also the struct used as an iterator into the mesh voxels. * * You don't need to care about the attributes, just create them with * , , or * . */ typedef struct { const mesh_t *mesh; const mesh_t *mesh2; // Current cached block and its position. // the block can be NULL if there is no block at this position. block_t *block; int block_pos[3]; uint64_t block_id; int pos[3]; float box[4][4]; int bbox[2][3]; int flags; } mesh_iterator_t; typedef mesh_iterator_t mesh_accessor_t; /* * Function: mesh_new * Create a new mesh. */ mesh_t *mesh_new(void); /* * Function: mesh_delete * Delete a mesh. */ void mesh_delete(mesh_t *mesh); /* Function: mesh_clear * * Clear all the voxels from a mesh. */ void mesh_clear(mesh_t *mesh); /* * Function: mesh_get_block_aabb * Compute the AABB box of a given block of the mesh. */ static inline void mesh_get_block_aabb(const int pos[3], int aabb[2][3]) { aabb[0][0] = pos[0]; aabb[0][1] = pos[1]; aabb[0][2] = pos[2]; aabb[1][0] = pos[0] + BLOCK_SIZE; aabb[1][1] = pos[1] + BLOCK_SIZE; aabb[1][2] = pos[2] + BLOCK_SIZE; } mesh_t *mesh_copy(const mesh_t *mesh); void mesh_set(mesh_t *mesh, const mesh_t *other); mesh_accessor_t mesh_get_accessor(const mesh_t *mesh); void mesh_get_at(const mesh_t *mesh, mesh_iterator_t *it, const int pos[3], uint8_t out[4]); uint8_t mesh_get_alpha_at(const mesh_t *mesh, mesh_iterator_t *it, const int pos[3]); /* * Function: mesh_set_at * * Set a single voxel value in a mesh. * * Inputs: * mesh - The mesh. * it - Optional mesh iterator. Successive access to the same mesh * using the iterator are optimized. * pos - Position of the voxel. * v - Value to set. */ void mesh_set_at(mesh_t *mesh, mesh_iterator_t *it, const int pos[3], const uint8_t v[4]); // XXX: we should remove this one I guess. void mesh_remove_empty_blocks(mesh_t *mesh, bool fast); /* * Function: mesh_clear_block * Set to zero all the voxels in a given block. */ void mesh_clear_block(mesh_t *mesh, mesh_iterator_t *it, const int pos[3]); /* * Function: mesh_is_empty * * Test whether a mesh has no voxel. * * Returns: * true if the mesh is empty, false otherwise. */ bool mesh_is_empty(const mesh_t *mesh); /* * Function: mesh_get_bbox * * Get the bounding box of a mesh. * * Inputs: * mesh - The mesh * exact - If true, compute the exact bounding box. If false, returns * an approximation that might be slightly bigger than the * actual box, but faster to compute. * * Outputs: * bbox - The bounding box as the bottom left and top right corner of * the mesh. If the mesh is empty, this will contain all zero. * * Returns: * true if the mesh is not empty. */ bool mesh_get_bbox(const mesh_t *mesh, int bbox[2][3], bool exact); /* * Function: mesh_get_iterator * Return an iterator that yield all the voxels of the mesh. * * Parameters: * mesh - The mesh we want to iterate. * flags - Any of the enum. */ mesh_iterator_t mesh_get_iterator(const mesh_t *mesh, int flags); // Return an iterator that follow a given box shape. mesh_iterator_t mesh_get_box_iterator(const mesh_t *mesh, const float box[4][4], int flags); mesh_iterator_t mesh_get_union_iterator( const mesh_t *m1, const mesh_t *m2, int flags); int mesh_iter(mesh_iterator_t *it, int pos[3]); /* * Function: mesh_get_key * * Return a value that is guarantied to be different for different meshes. * * This key can be used for quickly testing if two meshes are the same. * * Note that two meshes with the same key are guarantied to have the same * content, but two meshes with different key could still have the same * content: this is not an actual hash! * * Inputs: * mesh - The mesh. * * Return: * The key, if the mesh input is NULL, returns zero. * */ uint64_t mesh_get_key(const mesh_t *mesh); void *mesh_get_block_data(const mesh_t *mesh, mesh_accessor_t *accessor, const int bpos[3], uint64_t *id); // Maybe replace this with a generic mesh_copy_part function? void mesh_copy_block(const mesh_t *src, const int src_pos[3], mesh_t *dst, const int dst_pos[3]); void mesh_read(const mesh_t *mesh, const int pos[3], const int size[3], uint8_t *data); typedef struct { int nb_meshes; int nb_blocks; uint64_t mem; } mesh_global_stats_t; void mesh_get_global_stats(mesh_global_stats_t *stats); #endif // MESH_H goxel-0.11.0/src/mesh_to_vertices.c000066400000000000000000000236711435762723100172270ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" static const int N = BLOCK_SIZE; // Implemented in marchingcube.c int mesh_generate_vertices_mc(const mesh_t *mesh, const int block_pos[3], int effects, voxel_vertex_t *out, int *size, int *pos_scale); static bool block_is_face_visible(uint32_t neighboors_mask, int f) { #define M(x, y, z) (1 << ((x + 1) + (y + 1) * 3 + (z + 1) * 9)) static const uint32_t MASKS[6] = { M(0, -1, 0), M(0, +1, 0), M(0, 0, -1), M(0, 0, +1), M(+1, 0, 0), M(-1, 0, 0), }; #undef M return !(MASKS[f] & neighboors_mask); } static void block_get_normal(int f, int8_t normal[3], int8_t tangent[3]) { normal[0] = FACES_NORMALS[f][0]; normal[1] = FACES_NORMALS[f][1]; normal[2] = FACES_NORMALS[f][2]; tangent[0] = FACES_TANGENTS[f][0]; tangent[1] = FACES_TANGENTS[f][1]; tangent[2] = FACES_TANGENTS[f][2]; } static void block_get_gradient(uint32_t neighboors_mask, const uint8_t neighboors[27], int f, int8_t gradient[3]) { int x, y, z, i = 0; int sx = 0, sy = 0, sz = 0; int smax; for (z = -1; z <= +1; z++) for (y = -1; y <= +1; y++) for (x = -1; x <= +1; x++) { if (neighboors_mask & (1 << i)) { sx -= neighboors[i] * x; sy -= neighboors[i] * y; sz -= neighboors[i] * z; } i++; } if (sx == 0 && sy == 0 && sz == 0) { gradient[0] = FACES_NORMALS[f][0]; gradient[1] = FACES_NORMALS[f][1]; gradient[2] = FACES_NORMALS[f][2]; return; } smax = max(abs(sx), max(abs(sy), abs(sz))); gradient[0] = sx * 127 / smax; gradient[1] = sy * 127 / smax; gradient[2] = sz * 127 / smax; } static bool block_get_edge_border(uint32_t neighboors_mask, int f, int e) { #define M(x, y, z) (1 << ((x + 1) + (y + 1) * 3 + (z + 1) * 9)) static const uint32_t MASKS[6][4] = { /* F0 */ {M( 0, -1, -1), M(+1, -1, 0), M( 0, -1, +1), M(-1, -1, 0)}, /* F1 */ {M( 0, +1, -1), M(-1, +1, 0), M( 0, +1, +1), M(+1, +1, 0)}, /* F2 */ {M(-1, 0, -1), M( 0, 1, -1), M( 1, 0, -1), M( 0, -1, -1)}, /* F3 */ {M( 1, 0, 1), M( 0, 1, 1), M(-1, 0, 1), M( 0, -1, 1)}, /* F4 */ {M( 1, 0, -1), M( 1, 1, 0), M( 1, 0, 1), M( 1, -1, 0)}, /* F5 */ {M(-1, -1, 0), M(-1, 0, 1), M(-1, 1, 0), M(-1, 0, -1)}, }; #undef M return neighboors_mask & MASKS[f][e]; } static bool block_get_vertice_border(uint32_t neighboors_mask, int f, int i) { #define M(x, y, z) (1 << ((x + 1) + (y + 1) * 3 + (z + 1) * 9)) static const uint32_t MASKS[6][4] = { { // F0 M(-1, -1, 0) | M( 0, -1, -1) | M(-1, -1, -1), M( 0, -1, -1) | M( 1, -1, 0) | M( 1, -1, -1), M( 1, -1, 0) | M( 0, -1, 1) | M( 1, -1, 1), M( 0, -1, 1) | M(-1, -1, 0) | M(-1, -1, 1), }, { //F1 M( 1, 1, 0) | M( 0, 1, -1) | M( 1, 1, -1), M( 0, 1, -1) | M(-1, 1, 0) | M(-1, 1, -1), M(-1, 1, 0) | M( 0, 1, 1) | M(-1, 1, 1), M( 0, 1, 1) | M( 1, 1, 0) | M( 1, 1, 1), }, { // F2 M( 0, -1, -1) | M(-1, 0, -1) | M(-1, -1, -1), M(-1, 0, -1) | M( 0, 1, -1) | M(-1, 1, -1), M( 0, 1, -1) | M( 1, 0, -1) | M( 1, 1, -1), M( 1, 0, -1) | M( 0, -1, -1) | M( 1, -1, -1), }, { // F3 M( 0, -1, 1) | M( 1, 0, 1) | M( 1, -1, 1), M( 1, 0, 1) | M( 0, 1, 1) | M( 1, 1, 1), M( 0, 1, 1) | M(-1, 0, 1) | M(-1, 1, 1), M(-1, 0, 1) | M( 0, -1, 1) | M(-1, -1, 1), }, { // F4 M( 1, -1, 0) | M( 1, 0, -1) | M( 1, -1, -1), M( 1, 0, -1) | M( 1, 1, 0) | M( 1, 1, -1), M( 1, 1, 0) | M( 1, 0, 1) | M( 1, 1, 1), M( 1, 0, 1) | M( 1, -1, 0) | M( 1, -1, 1), }, { // F5 M(-1, 0, -1) | M(-1, -1, 0) | M(-1, -1, -1), M(-1, -1, 0) | M(-1, 0, 1) | M(-1, -1, 1), M(-1, 0, 1) | M(-1, 1, 0) | M(-1, 1, 1), M(-1, 1, 0) | M(-1, 0, -1) | M(-1, 1, -1), }, }; #undef M return neighboors_mask & MASKS[f][i]; } static uint8_t block_get_shadow_mask(uint32_t neighboors_mask, int f) { int i; uint8_t ret = 0; for (i = 0; i < 4; i++) { ret |= block_get_vertice_border(neighboors_mask, f, i) ? (1 << i) : 0; ret |= block_get_edge_border(neighboors_mask, f, i) ? (0x10 << i) : 0; } return ret; } static uint8_t block_get_border_mask(uint32_t neighboors_mask, int f) { #define M(x, y, z) (1 << ((x + 1) + (y + 1) * 3 + (z + 1) * 9)) int e; uint8_t ret = 0; const int *n, *t; for (e = 0; e < 4; e++) { n = FACES_NORMALS[f]; t = FACES_NORMALS[FACES_NEIGHBORS[f][e]]; if (neighboors_mask & M(n[0] + t[0], n[1] + t[1], n[2] + t[2])) { ret |= 2 << (2 * e); } else if (!(neighboors_mask & M(t[0], t[1], t[2]))) { ret |= 1 << (2 * e); } } return ret; #undef M } #define data_get_at(d, x, y, z, out) do { \ memcpy(out, &data[( \ ((x) + 1) + \ ((y) + 1) * (N + 2) + \ ((z) + 1) * (N + 2) * (N + 2)) * 4], 4); \ } while (0) static uint32_t get_neighboors(const uint8_t *data, const int pos[3], uint8_t neighboors[27]) { int xx, yy, zz, i = 0; uint8_t v[4]; uint32_t ret = 0; for (zz = -1; zz <= 1; zz++) for (yy = -1; yy <= 1; yy++) for (xx = -1; xx <= 1; xx++) { data_get_at(data, pos[0] + xx, pos[1] + yy, pos[2] + zz, v); neighboors[i] = v[3]; if (neighboors[i] >= 127) ret |= 1 << i; i++; } return ret; } /* Packing of block id, pos, and face: * * x : 4 bits * y : 4 bits * z : 4 bits * pad : 1 bit * face: 3 bits * ------------- * tot : 16 bits */ static uint16_t get_pos_data(uint16_t x, uint16_t y, uint16_t z, uint16_t f) { assert(BLOCK_SIZE == 16); return (x << 12) | (y << 8) | (z << 4) | (f << 0); } int mesh_generate_vertices(const mesh_t *mesh, const int block_pos[3], int effects, voxel_vertex_t *out, int *size, int *subdivide) { int x, y, z, f; int i, nb = 0; uint32_t neighboors_mask; uint8_t shadow_mask, borders_mask; const int ts = VOXEL_TEXTURE_SIZE; uint8_t *data, neighboors[27], v[4]; int8_t normal[3], tangent[3], gradient[3]; int pos[3]; const int *vpos; if (effects & EFFECT_MARCHING_CUBES) return mesh_generate_vertices_mc(mesh, block_pos, effects, out, size, subdivide); *size = 4; // Quad. *subdivide = 1; // Unit is one voxel. // To speed things up we first get the voxel cube around the block. // XXX: can we do this while still using mesh iterators somehow? #define IVEC(...) ((int[]){__VA_ARGS__}) data = malloc((N + 2) * (N + 2) * (N + 2) * 4); mesh_read(mesh, IVEC(block_pos[0] - 1, block_pos[1] - 1, block_pos[2] - 1), IVEC(N + 2, N + 2, N + 2), data); for (z = 0; z < N; z++) for (y = 0; y < N; y++) for (x = 0; x < N; x++) { pos[0] = x; pos[1] = y; pos[2] = z; data_get_at(data, x, y, z, v); if (v[3] < 127) continue; // Non visible neighboors_mask = get_neighboors(data, pos, neighboors); for (f = 0; f < 6; f++) { if (!block_is_face_visible(neighboors_mask, f)) continue; block_get_normal(f, normal, tangent); block_get_gradient(neighboors_mask, neighboors, f, gradient); shadow_mask = block_get_shadow_mask(neighboors_mask, f); borders_mask = block_get_border_mask(neighboors_mask, f); for (i = 0; i < 4; i++) { vpos = VERTICES_POSITIONS[FACES_VERTICES[f][i]]; out[nb * 4 + i].pos[0] = x + vpos[0]; out[nb * 4 + i].pos[1] = y + vpos[1]; out[nb * 4 + i].pos[2] = z + vpos[2]; memcpy(out[nb * 4 + i].normal, normal, sizeof(normal)); memcpy(out[nb * 4 + i].tangent, tangent, sizeof(tangent)); memcpy(out[nb * 4 + i].gradient, gradient, sizeof(gradient)); memcpy(out[nb * 4 + i].color, v, sizeof(v)); out[nb * 4 + i].color[3] = out[nb * 4 + i].color[3] ? 255 : 0; out[nb * 4 + i].occlusion_uv[0] = shadow_mask % 16 * ts + VERTICE_UV[i][0] * (ts - 1); out[nb * 4 + i].occlusion_uv[1] = shadow_mask / 16 * ts + VERTICE_UV[i][1] * (ts - 1); out[nb * 4 + i].uv[0] = VERTICE_UV[i][0] * 255; out[nb * 4 + i].uv[1] = VERTICE_UV[i][1] * 255; // For testing: // This put a border bump on all the edges of the voxel. out[nb * 4 + i].bump_uv[0] = (borders_mask % 16) * 16; out[nb * 4 + i].bump_uv[1] = (borders_mask / 16) * 16; out[nb * 4 + i].pos_data = get_pos_data(x, y, z, f); } nb++; } } free(data); return nb; } goxel-0.11.0/src/mesh_utils.c000066400000000000000000000374311435762723100160400ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "xxhash.h" #include #define N BLOCK_SIZE // Used for the cache. static int mesh_del(void *data_) { mesh_t *mesh = data_; mesh_delete(mesh); return 0; } int mesh_select(const mesh_t *mesh, const int start_pos[3], int (*cond)(void *user, const mesh_t *mesh, const int base_pos[3], const int new_pos[3], mesh_accessor_t *mesh_accessor), void *user, mesh_t *selection) { int i, a; int pos[3], p[3]; bool keep = true; mesh_iterator_t iter; mesh_accessor_t mesh_accessor, selection_accessor; mesh_clear(selection); mesh_accessor = mesh_get_accessor(mesh); selection_accessor = mesh_get_accessor(selection); if (!mesh_get_alpha_at(mesh, &mesh_accessor, start_pos)) return 0; mesh_set_at(selection, &selection_accessor, start_pos, (uint8_t[]){255, 255, 255, 255}); // XXX: Very inefficient algorithm! // Iter and test all the neighbors of the selection until there is // no more possible changes. while (keep) { keep = false; iter = mesh_get_iterator(selection, MESH_ITER_VOXELS); while (mesh_iter(&iter, pos)) { // Shouldn't be needed if the iter function did filter the voxels. if (!mesh_get_alpha_at(selection, &selection_accessor, pos)) continue; for (i = 0; i < 6; i++) { p[0] = pos[0] + FACES_NORMALS[i][0]; p[1] = pos[1] + FACES_NORMALS[i][1]; p[2] = pos[2] + FACES_NORMALS[i][2]; if (mesh_get_alpha_at(selection, &selection_accessor, p)) continue; // Already done. if (!mesh_get_alpha_at(mesh, &mesh_accessor, p)) continue; // No voxel here. a = cond(user, mesh, pos, p, &mesh_accessor); if (a) { mesh_set_at(selection, &selection_accessor, p, (uint8_t[]){255, 255, 255, a}); keep = true; } } } } return 0; } // XXX: need to redo this function from scratch. Even the API is a bit // stupid. void mesh_extrude(mesh_t *mesh, const float plane[4][4], const float box[4][4]) { float proj[4][4]; float n[3], pos[3], p[3]; mesh_iterator_t iter; int vpos[3]; uint8_t value[4]; vec3_normalize(plane[2], n); vec3_copy(plane[3], pos); // Generate the projection into the plane. // XXX: *very* ugly code, fix this! mat4_set_identity(proj); if (fabs(plane[2][0]) > 0.1) { proj[0][0] = 0; proj[3][0] = pos[0]; } if (fabs(plane[2][1]) > 0.1) { proj[1][1] = 0; proj[3][1] = pos[1]; } if (fabs(plane[2][2]) > 0.1) { proj[2][2] = 0; proj[3][2] = pos[2]; } // XXX: use an accessor to speed up access. iter = mesh_get_box_iterator(mesh, box, 0); while (mesh_iter(&iter, vpos)) { vec3_set(p, vpos[0], vpos[1], vpos[2]); if (!bbox_contains_vec(box, p)) { memset(value, 0, 4); } else { mat4_mul_vec3(proj, p, p); int pi[3] = {floor(p[0]), floor(p[1]), floor(p[2])}; mesh_get_at(mesh, NULL, pi, value); } mesh_set_at(mesh, NULL, vpos, value); } } static void mesh_fill( mesh_t *mesh, const float box[4][4], void (*get_color)(const int pos[3], uint8_t out[4], void *user_data), void *user_data) { int pos[3]; uint8_t color[4]; mesh_iterator_t iter; mesh_accessor_t accessor; mesh_clear(mesh); accessor = mesh_get_accessor(mesh); iter = mesh_get_box_iterator(mesh, box, 0); while (mesh_iter(&iter, pos)) { get_color(pos, color, user_data); mesh_set_at(mesh, &accessor, pos, color); } } static void mesh_move_get_color(const int pos[3], uint8_t c[4], void *user) { float p[3] = {pos[0], pos[1], pos[2]}; mesh_t *mesh = USER_GET(user, 0); float (*mat)[4][4] = USER_GET(user, 1); mat4_mul_vec3(*mat, p, p); int pi[3] = {round(p[0]), round(p[1]), round(p[2])}; mesh_get_at(mesh, NULL, pi, c); } void mesh_move(mesh_t *mesh, const float mat[4][4]) { float box[4][4]; mesh_t *src_mesh = mesh_copy(mesh); float imat[4][4]; mat4_invert(mat, imat); mesh_get_box(mesh, true, box); if (box_is_null(box)) return; mat4_mul(mat, box, box); mesh_fill(mesh, box, mesh_move_get_color, USER_PASS(src_mesh, &imat)); mesh_delete(src_mesh); mesh_remove_empty_blocks(mesh, false); } void mesh_blit(mesh_t *mesh, const uint8_t *data, int x, int y, int z, int w, int h, int d, mesh_iterator_t *iter) { mesh_iterator_t default_iter = {0}; int pos[3]; if (!iter) iter = &default_iter; for (pos[2] = z; pos[2] < z + d; pos[2]++) for (pos[1] = y; pos[1] < y + h; pos[1]++) for (pos[0] = x; pos[0] < x + w; pos[0]++) { mesh_set_at(mesh, iter, pos, data); data += 4; } mesh_remove_empty_blocks(mesh, false); } void mesh_shift_alpha(mesh_t *mesh, int v) { mesh_iterator_t iter; int pos[3]; uint8_t value[4]; iter = mesh_get_iterator(mesh, MESH_ITER_VOXELS); while (mesh_iter(&iter, pos)) { mesh_get_at(mesh, &iter, pos, value); value[3] = clamp(value[3] + v, 0, 255); mesh_set_at(mesh, NULL, pos, value); } } // Multiply two colors together. static void color_mul(const uint8_t a[4], const uint8_t b[4], uint8_t out[4]) { out[0] = (int)a[0] * b[0] / 255; out[1] = (int)a[1] * b[1] / 255; out[2] = (int)a[2] * b[2] / 255; out[3] = (int)a[3] * b[3] / 255; } // XXX: cleanup this: in fact we might not need that many modes! static void combine(const uint8_t a[4], const uint8_t b[4], int mode, uint8_t out[4]) { int i, aa = a[3], ba = b[3]; uint8_t ret[4]; memcpy(ret, a, 4); if (mode == MODE_PAINT) { ret[0] = mix(a[0], b[0], ba / 255.); ret[1] = mix(a[1], b[1], ba / 255.); ret[2] = mix(a[2], b[2], ba / 255.); } else if (mode == MODE_OVER) { if (255 * ba + aa * (255 - ba)) { for (i = 0; i < 3; i++) { ret[i] = (255 * b[i] * ba + a[i] * aa * (255 - ba)) / (255 * ba + aa * (255 - ba)); } } ret[3] = ba + aa * (255 - ba) / 255; } else if (mode == MODE_SUB) { ret[3] = max(0, aa - ba); } else if (mode == MODE_MAX) { ret[0] = b[0]; ret[1] = b[1]; ret[2] = b[2]; ret[3] = max(a[3], b[3]); } else if (mode == MODE_SUB_CLAMP) { ret[0] = a[0]; ret[1] = a[1]; ret[2] = a[2]; ret[3] = min(aa, 255 - ba); } else if (mode == MODE_MULT_ALPHA) { ret[0] = ret[0] * ba / 255; ret[1] = ret[1] * ba / 255; ret[2] = ret[2] * ba / 255; ret[3] = ret[3] * ba / 255; } else if (mode == MODE_INTERSECT) { ret[3] = min(aa, ba); } else if (mode == MODE_INTERSECT_FILL) { ret[3] = min(aa, ba); if (ret[3]) { ret[0] = b[0]; ret[1] = b[1]; ret[2] = b[2]; } } else { assert(false); } memcpy(out, ret, 4); } void mesh_op(mesh_t *mesh, const painter_t *painter, const float box[4][4]) { int i, vp[3]; uint8_t value[4], new_value[4], c[4]; mesh_iterator_t iter; mesh_accessor_t accessor; float size[3], p[3]; float mat[4][4]; float (*shape_func)(const float[3], const float[3], float smoothness); float k, v; int mode = painter->mode; bool use_box, skip_src_empty, skip_dst_empty; painter_t painter2; float box2[4][4]; int aabb[2][3]; mesh_t *cached; static cache_t *cache = NULL; const float *sym_o = painter->symmetry_origin; // Check if the operation has been cached. if (!cache) cache = cache_create(32); struct { uint64_t id; float box[4][4]; painter_t painter; } key; memset(&key, 0, sizeof(key)); key.id = mesh_get_key(mesh); mat4_copy(box, key.box); key.painter = *painter; cached = cache_get(cache, &key, sizeof(key)); if (cached) { mesh_set(mesh, cached); return; } if (painter->symmetry) { painter2 = *painter; for (i = 0; i < 3; i++) { if (!(painter->symmetry & (1 << i))) continue; painter2.symmetry &= ~(1 << i); mat4_set_identity(box2); mat4_itranslate(box2, +sym_o[0], +sym_o[1], +sym_o[2]); if (i == 0) mat4_iscale(box2, -1, 1, 1); if (i == 1) mat4_iscale(box2, 1, -1, 1); if (i == 2) mat4_iscale(box2, 1, 1, -1); mat4_itranslate(box2, -sym_o[0], -sym_o[1], -sym_o[2]); mat4_imul(box2, box); mesh_op(mesh, &painter2, box2); } } shape_func = painter->shape->func; box_get_size(box, size); mat4_copy(box, mat); mat4_iscale(mat, 1 / size[0], 1 / size[1], 1 / size[2]); mat4_invert(mat, mat); use_box = painter->box && !box_is_null(*painter->box); skip_src_empty = mode == MODE_SUB || mode == MODE_SUB_CLAMP || mode == MODE_MULT_ALPHA; skip_dst_empty = mode == MODE_SUB || mode == MODE_SUB_CLAMP || mode == MODE_MULT_ALPHA || mode == MODE_INTERSECT || mode == MODE_INTERSECT_FILL; // for intersection start by deleting all the blocks that are not in // the box. if (mode == MODE_INTERSECT || mode == MODE_INTERSECT_FILL) { iter = mesh_get_iterator(mesh, MESH_ITER_BLOCKS); while (mesh_iter(&iter, vp)) { mesh_get_block_aabb(vp, aabb); if (box_intersect_aabb(box, aabb)) continue; mesh_clear_block(mesh, &iter, vp); } } iter = mesh_get_box_iterator(mesh, box, skip_dst_empty ? MESH_ITER_SKIP_EMPTY : 0); // XXX: for the moment we cannot use the same accessor for both // setting and getting! Need to fix that!! accessor = mesh_get_accessor(mesh); while (mesh_iter(&iter, vp)) { vec3_set(p, vp[0] + 0.5, vp[1] + 0.5, vp[2] + 0.5); if (use_box && !bbox_contains_vec(*painter->box, p)) continue; mat4_mul_vec3(mat, p, p); k = shape_func(p, size, painter->smoothness); if (painter->smoothness) { v = clamp(k / painter->smoothness, -1.0f, 1.0f) / 2.0f + 0.5f; } else { v = (k >= 0.f) ? 1.f : 0.f; } if (!v && skip_src_empty) continue; memcpy(c, painter->color, 4); c[3] *= v; if (!c[3] && skip_src_empty) continue; mesh_get_at(mesh, &accessor, vp, value); if (!value[3] && skip_dst_empty) continue; combine(value, c, mode, new_value); if (!vec4_equal(value, new_value)) mesh_set_at(mesh, &accessor, vp, new_value); } cache_add(cache, &key, sizeof(key), mesh_copy(mesh), 1, mesh_del); } // XXX: remove this function! void mesh_get_box(const mesh_t *mesh, bool exact, float box[4][4]) { int bbox[2][3]; mesh_get_bbox(mesh, bbox, exact); bbox_from_aabb(box, bbox); } static void block_merge(mesh_t *mesh, const mesh_t *other, const int pos[3], int mode, const uint8_t color[4]) { int p[3]; int x, y, z; uint64_t id1, id2; mesh_t *block; uint8_t v1[4], v2[4]; static cache_t *cache = NULL; mesh_accessor_t a1, a2, a3; mesh_get_block_data(mesh, NULL, pos, &id1); mesh_get_block_data(other, NULL, pos, &id2); // XXX: cleanup this code! if ( (mode == MODE_OVER || mode == MODE_MAX || mode == MODE_SUB || mode == MODE_SUB_CLAMP) && id2 == 0) { return; } if ((mode == MODE_OVER || mode == MODE_MAX) && id1 == 0 && !color) { mesh_copy_block(other, pos, mesh, pos); return; } if ((mode == MODE_MULT_ALPHA) && id1 == 0) return; if ((mode == MODE_MULT_ALPHA) && id2 == 0) { // XXX: could just delete the block. } // Check if the merge op has been cached. if (!cache) cache = cache_create(512); struct { uint64_t id1; uint64_t id2; int mode; uint8_t color[4]; } key = { id1, id2, mode }; if (color) memcpy(key.color, color, 4); _Static_assert(sizeof(key) == 24, ""); block = cache_get(cache, &key, sizeof(key)); if (block) goto end; block = mesh_new(); a1 = mesh_get_accessor(mesh); a2 = mesh_get_accessor(other); a3 = mesh_get_accessor(block); for (z = 0; z < N; z++) for (y = 0; y < N; y++) for (x = 0; x < N; x++) { p[0] = pos[0] + x; p[1] = pos[1] + y; p[2] = pos[2] + z; mesh_get_at(mesh, &a1, p, v1); mesh_get_at(other, &a2, p, v2); if (color) color_mul(v2, color, v2); combine(v1, v2, mode, v1); mesh_set_at(block, &a3, (int[]){x, y, z}, v1); } cache_add(cache, &key, sizeof(key), block, 1, mesh_del); end: mesh_copy_block(block, (int[]){0, 0, 0}, mesh, pos); return; } void mesh_merge(mesh_t *mesh, const mesh_t *other, int mode, const uint8_t color[4]) { mesh_t *cached; assert(mesh && other); static cache_t *cache = NULL; mesh_iterator_t iter; int bpos[3]; uint64_t id1, id2; // Simple case for replace. if (mode == MODE_REPLACE) { mesh_set(mesh, other); return; } // Check if the merge op has been cached. if (!cache) cache = cache_create(512); id1 = mesh_get_key(mesh); id2 = mesh_get_key(other); struct { uint64_t id1; uint64_t id2; int mode; uint8_t color[4]; } key = { id1, id2, mode }; if (color) memcpy(key.color, color, 4); _Static_assert(sizeof(key) == 24, ""); cached = cache_get(cache, &key, sizeof(key)); if (cached) { mesh_set(mesh, cached); return; } iter = mesh_get_union_iterator(mesh, other, MESH_ITER_BLOCKS); while (mesh_iter(&iter, bpos)) { block_merge(mesh, other, bpos, mode, color); } cache_add(cache, &key, sizeof(key), mesh_copy(mesh), 1, mesh_del); } void mesh_crop(mesh_t *mesh, const float box[4][4]) { painter_t painter = { .mode = MODE_INTERSECT, .color = {255, 255, 255, 255}, .shape = &shape_cube, }; mesh_op(mesh, &painter, box); } /* Function: mesh_crc32 * Compute the crc32 of the mesh data as an array of xyz rgba values. * * This is only used in the tests, to make sure that we can still open * old file formats. */ uint32_t mesh_crc32(const mesh_t *mesh) { mesh_iterator_t iter; int pos[3]; uint8_t v[4]; uint32_t ret = 0; iter = mesh_get_iterator(mesh, MESH_ITER_VOXELS); while (mesh_iter(&iter, pos)) { mesh_get_at(mesh, &iter, pos, v); if (!v[3]) continue; ret = XXH32(pos, sizeof(pos), ret); ret = XXH32(v, sizeof(v), ret); } return ret; } goxel-0.11.0/src/mesh_utils.h000066400000000000000000000151641435762723100160440ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* ######## Section: Mesh util ############################################ * Some extra mesh functions, not part of the core mesh code. */ #ifndef MESH_UTILS_H #define MESH_UTILS_H #include "shape.h" /* * Enum: MODE * Define how layers/brush are merged. Each mode defines how to apply a * source voxel into a destination voxel. * * MODE_OVER - New values replace old one. * MODE_SUB - Substract source alpha from destination * MODE_SUB_CLAMP - Set alpha to the minimum between the destination value * and one minus the source value. * MODE_PAINT - Set the color of the destination using the source. * MODE_MAX - Set alpha to the max of the source and destination. * MODE_INTERSECT - Set alpha to the min of the source and destination. * MODE_INTERSECT_FILL - Like intersect but use the color of the source. * MODE_MULT_ALPHA - Multiply the source and dest using source alpha. */ enum { MODE_NULL, MODE_OVER, MODE_SUB, MODE_SUB_CLAMP, MODE_PAINT, MODE_MAX, MODE_INTERSECT, MODE_INTERSECT_FILL, MODE_MULT_ALPHA, MODE_REPLACE, }; // Structure used for the OpenGL array data of blocks. // XXX: we can probably make it smaller. typedef struct voxel_vertex { uint8_t pos[3] __attribute__((aligned(4))); int8_t normal[3] __attribute__((aligned(4))); int8_t tangent[3] __attribute__((aligned(4))); int8_t gradient[3] __attribute__((aligned(4))); uint8_t color[4] __attribute__((aligned(4))); uint16_t pos_data __attribute__((aligned(4))); uint8_t uv[2] __attribute__((aligned(4))); uint8_t occlusion_uv[2] __attribute__((aligned(4))); uint8_t bump_uv[2] __attribute__((aligned(4))); } voxel_vertex_t; // Type: painter_t // The painting context, including the tool, brush, mode, radius, // color, etc... // // Attributes: // mode - Define how colors are applied. One of the enum value. typedef struct painter { int mode; const shape_t *shape; uint8_t color[4]; float smoothness; int symmetry; // bitfield X Y Z float symmetry_origin[3]; float (*box)[4][4]; // Clipping box (can be null) } painter_t; /* Function: mesh_get_box * Compute the bounding box of a mesh. */ // XXX: remove this function! void mesh_get_box(const mesh_t *mesh, bool exact, float box[4][4]); /* Function: mesh_op * Apply a paint operation to a mesh. * This function render geometrical 3d shapes into a mesh. * The shape, mode and color are defined in the painter argument. * * Parameters: * mesh - The mesh we paint into. * painter - Defines the paint operation to apply. * box - Defines the position and size of the shape as the * transformation matrix from the zero centered unit box. * * See Also: * */ void mesh_op(mesh_t *mesh, const painter_t *painter, const float box[4][4]); // XXX: to cleanup. void mesh_extrude(mesh_t *mesh, const float plane[4][4], const float box[4][4]); /* Function: mesh_blit * * Blit voxel data into a mesh. * This is the fastest way to quickly put data into a mesh. * * Parameters: * mesh - The mesh we blit into. * data - Pointer to voxel data (RGBA values, in xyz order). * x - X pos. * y - Y pos. * z - Z pos. * w - Width of the data. * h - Height of the data. * d - Depth of the data. * iter - Optional iterator for optimized access. */ void mesh_blit(mesh_t *mesh, const uint8_t *data, int x, int y, int z, int w, int h, int d, mesh_iterator_t *iter); void mesh_move(mesh_t *mesh, const float mat[4][4]); void mesh_shift_alpha(mesh_t *mesh, int v); // Compute the selection mask for a given condition. int mesh_select(const mesh_t *mesh, const int start_pos[3], int (*cond)(void *user, const mesh_t *mesh, const int base_pos[3], const int new_pos[3], mesh_accessor_t *mesh_accessor), void *user, mesh_t *selection); /* * Function: mesh_merge * Merge a mesh into an other using a given blending function. * * Parameters: * mesh - The destination mesh we merge into. * other - The source mesh we merge. Unchanged by this function. * mode - The blending function used. One of the enum values. * color - A color to apply to the source mesh before merging. Can be * set to NULL. */ void mesh_merge(mesh_t *mesh, const mesh_t *other, int mode, const uint8_t color[4]); /* * Function: mesh_generate_vertices * Generate a vertice array for rendering a mesh block. * * Parameters: * mesh - Input mesh. * block_pos - Position of the mesh block to render. * effects - Effect flags. * out - Output array. * size - Output the size of a single face. * 4 for quads and 3 for triangles. Normal mesh uses quad * but marching cube effect return triangle arrays. * subdivide - Ouput the number of subdivisions used for a voxel. Normal * render uses 1 unit per voxel, but marching cube rendering * can use more. */ int mesh_generate_vertices(const mesh_t *mesh, const int block_pos[3], int effects, voxel_vertex_t *out, int *size, int *subdivide); // XXX: use int[2][3] for the box? void mesh_crop(mesh_t *mesh, const float box[4][4]); /* Function: mesh_crc32 * Compute the crc32 of the mesh data as an array of xyz rgba values. * * This is only used in the tests, to make sure that we can still open * old file formats. */ uint32_t mesh_crc32(const mesh_t *mesh); #endif // MESH_UTILS_H goxel-0.11.0/src/model3d.c000066400000000000000000000277351435762723100152210ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" enum { A_POS_LOC = 0, A_COLOR_LOC = 1, A_NORMAL_LOC = 2, A_UV_LOC = 3, }; static const char *ATTR_NAMES[] = { [A_POS_LOC] = "a_pos", [A_COLOR_LOC] = "a_color", [A_NORMAL_LOC] = "a_normal", [A_UV_LOC] = "a_uv", NULL }; static gl_shader_t *g_shader = NULL; static texture_t *g_white_tex = NULL; static texture_t *create_white_tex(void) { texture_t *tex; uint8_t *buffer; const int s = 16; tex = texture_new_surface(s, s, TF_RGB); buffer = malloc(s * s * 3); memset(buffer, 255, s * s * 3); glBindTexture(GL_TEXTURE_2D, tex->tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, s, s, 0, GL_RGB, GL_UNSIGNED_BYTE, buffer); free(buffer); return tex; } static void model3d_init(void) { const char *shader; if (!g_shader) { shader = assets_get("asset://data/shaders/model3d.glsl", NULL); g_shader = gl_shader_create(shader, shader, NULL, ATTR_NAMES); GL(glUseProgram(g_shader->prog)); gl_update_uniform(g_shader, "u_tex", 0); g_white_tex = create_white_tex(); } } void model3d_release_graphics(void) { gl_shader_delete(g_shader); g_shader = NULL; texture_delete(g_white_tex); g_white_tex = NULL; } void model3d_delete(model3d_t *model) { GL(glDeleteBuffers(1, &model->vertex_buffer)); free(model->vertices); free(model); } model3d_t *model3d_cube(void) { int f, i, v; model3d_t *model = calloc(1, sizeof(*model)); model->solid = true; model->cull = true; const int *p; model->nb_vertices = 6 * 6; model->vertices = calloc(model->nb_vertices, sizeof(*model->vertices)); for (f = 0; f < 6; f++) { for (i = 0; i < 6; i++) { v = (int[]){0, 1, 2, 2, 3, 0}[i]; p = VERTICES_POSITIONS[FACES_VERTICES[f][v]]; vec3_set(model->vertices[f * 6 + i].pos, (p[0] - 0.5) * 2, (p[1] - 0.5) * 2, (p[2] - 0.5) * 2); vec3_set(model->vertices[f * 6 + i].normal, FACES_NORMALS[f][0], FACES_NORMALS[f][1], FACES_NORMALS[f][2]); vec4_set(model->vertices[f * 6 + i].color, 255, 255, 255, 255); } } model->dirty = true; return model; } model3d_t *model3d_wire_cube(void) { int f, i, v; const int *p; model3d_t *model = calloc(1, sizeof(*model)); model->nb_vertices = 6 * 8; model->vertices = calloc(model->nb_vertices, sizeof(*model->vertices)); for (f = 0; f < 6; f++) { for (i = 0; i < 8; i++) { v = (int[]){0, 1, 1, 2, 2, 3, 3, 0}[i]; p = VERTICES_POSITIONS[FACES_VERTICES[f][v]]; vec3_set(model->vertices[f * 8 + i].pos, (p[0] - 0.5) * 2, (p[1] - 0.5) * 2, (p[2] - 0.5) * 2); vec4_set(model->vertices[f * 8 + i].color, 255, 255, 255, 255); vec2_set(model->vertices[f * 8 + i].uv, 0.5, 0.5); } } model->cull = true; model->dirty = true; return model; } model3d_t *model3d_sphere(int slices, int stacks) { int slice, stack, ind, i; float z0, z1, r0, r1, a0, a1; model3d_t *model = calloc(1, sizeof(*model)); model_vertex_t *v; model->nb_vertices = slices * stacks * 6; model->vertices = calloc(model->nb_vertices, sizeof(*model->vertices)); v = model->vertices;; for (stack = 0; stack < stacks; stack++) { z0 = -1 + stack * 2.0f / stacks; z1 = -1 + (stack + 1) * 2.0f / stacks; r0 = sqrt(1 - z0 * z0); r1 = sqrt(1 - z1 * z1); for (slice = 0; slice < slices; slice++) { a0 = slice * M_PI * 2 / slices; a1 = (slice + 1) * M_PI * 2 / slices; ind = (stack * slices + slice) * 6; vec3_set(v[ind + 0].pos, r0 * cos(a0), r0 * sin(a0), z0); vec3_set(v[ind + 1].pos, r0 * cos(a1), r0 * sin(a1), z0); vec3_set(v[ind + 2].pos, r1 * cos(a0), r1 * sin(a0), z1); vec3_set(v[ind + 3].pos, r1 * cos(a1), r1 * sin(a1), z1); vec3_set(v[ind + 4].pos, r1 * cos(a0), r1 * sin(a0), z1); vec3_set(v[ind + 5].pos, r0 * cos(a1), r0 * sin(a1), z0); for (i = 0; i < 6; i++) vec3_copy(v[ind + i].pos, v[ind + i].normal); } } model->cull = true; model->dirty = true; return model; } model3d_t *model3d_grid(int nx, int ny) { model3d_t *model = calloc(1, sizeof(*model)); model_vertex_t *v; int i; float x, y; bool side; const uint8_t c[4] = {255, 255, 255, 160}; const uint8_t cb[4] = {255, 255, 255, 255}; model->nb_vertices = (nx + ny + 2) * 2; model->vertices = calloc(model->nb_vertices, sizeof(*model->vertices)); v = model->vertices; for (i = 0; i < nx + 1; i++) { side = i == 0 || i == nx; x = (float)i / nx - 0.5; vec3_set(v[i * 2 + 0].pos, x, -0.5, 0); vec3_set(v[i * 2 + 1].pos, x, +0.5, 0); vec4_copy(side ? cb : c, v[i * 2 + 0].color); vec4_copy(side ? cb : c, v[i * 2 + 1].color); } v = model->vertices + 2 * nx + 2; for (i = 0; i < ny + 1; i++) { side = i == 0 || i == ny; y = (float)i / ny - 0.5; vec3_set(v[i * 2 + 0].pos, -0.5, y, 0); vec3_set(v[i * 2 + 1].pos, +0.5, y, 0); vec4_copy(side ? cb : c, v[i * 2 + 0].color); vec4_copy(side ? cb : c, v[i * 2 + 1].color); } model->dirty = true; return model; } model3d_t *model3d_line(void) { model3d_t *model = calloc(1, sizeof(*model)); model->nb_vertices = 2; model->vertices = calloc(model->nb_vertices, sizeof(*model->vertices)); vec3_set(model->vertices[0].pos, -0.5, 0, 0); vec3_set(model->vertices[1].pos, +0.5, 0, 0); vec4_set(model->vertices[0].color, 255, 255, 255, 255); vec4_set(model->vertices[1].color, 255, 255, 255, 255); model->dirty = true; return model; } model3d_t *model3d_rect(void) { int i, v; model3d_t *model = calloc(1, sizeof(*model)); model->nb_vertices = 6; model->vertices = calloc(model->nb_vertices, sizeof(*model->vertices)); const float POS_UV[4][2][2] = { {{-0.5, -0.5}, {0, 1}}, {{+0.5, -0.5}, {1, 1}}, {{+0.5, +0.5}, {1, 0}}, {{-0.5, +0.5}, {0, 0}}, }; for (i = 0; i < 6; i++) { v = (int[]){0, 1, 2, 2, 3, 0}[i]; vec2_copy(POS_UV[v][0], model->vertices[i].pos); vec2_copy(POS_UV[v][1], model->vertices[i].uv); vec4_set(model->vertices[i].color, 255, 255, 255, 255); vec3_set(model->vertices[i].normal, 0, 0, 1); } model->solid = true; model->dirty = true; return model; } model3d_t *model3d_wire_rect(void) { int i, v; model3d_t *model = calloc(1, sizeof(*model)); model->nb_vertices = 8; model->vertices = calloc(model->nb_vertices, sizeof(*model->vertices)); const float POS_UV[4][2][2] = { {{-0.5, -0.5}, {0, 1}}, {{+0.5, -0.5}, {1, 1}}, {{+0.5, +0.5}, {1, 0}}, {{-0.5, +0.5}, {0, 0}}, }; for (i = 0; i < 8; i++) { v = ((i + 1) / 2) % 4; vec2_copy(POS_UV[v][0], model->vertices[i].pos); vec2_copy(POS_UV[v][1], model->vertices[i].uv); vec4_set(model->vertices[i].color, 255, 255, 255, 255); } model->dirty = true; return model; } static void copy_color(const uint8_t in[4], uint8_t out[4]) { if (in == NULL) { out[0] = 255; out[1] = 255; out[2] = 255; out[3] = 255; } else { memcpy(out, in, 4); } } void model3d_render(model3d_t *model3d, const float model[4][4], const float view[4][4], const float proj[4][4], const uint8_t color[4], const texture_t *tex, const float light[3], const float clip_box[4][4], int effects) { uint8_t c[4]; float cf[4]; float light_dir[3]; float clip[4][4] = {}; float grid_alpha; model3d_init(); copy_color(color, c); GL(glUseProgram(g_shader->prog)); gl_update_uniform(g_shader, "u_model", model); gl_update_uniform(g_shader, "u_view", view); gl_update_uniform(g_shader, "u_proj", proj); GL(glEnableVertexAttribArray(A_POS_LOC)); GL(glEnable(GL_BLEND)); GL(glEnable(GL_DEPTH_TEST)); GL(glDepthFunc(GL_LEQUAL)); GL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); GL(glCullFace(GL_BACK)); model3d->cull ? GL(glEnable(GL_CULL_FACE)) : GL(glDisable(GL_CULL_FACE)); GL(glCullFace(effects & EFFECT_SEE_BACK ? GL_FRONT : GL_BACK)); vec4_set(cf, c[0] / 255.0, c[1] / 255.0, c[2] / 255.0, c[3] / 255.0); gl_update_uniform(g_shader, "u_color", cf); gl_update_uniform(g_shader, "u_strip", effects & EFFECT_STRIP ? 1.0 : 0.0); gl_update_uniform(g_shader, "u_time", 0.0); // No moving strip effects. tex = tex ?: g_white_tex; GL(glActiveTexture(GL_TEXTURE0)); GL(glBindTexture(GL_TEXTURE_2D, tex->tex)); gl_update_uniform(g_shader, "u_uv_scale", VEC((float)tex->w / tex->tex_w, (float)tex->h / tex->tex_h)); if (model3d->dirty) { if (!model3d->vertex_buffer) GL(glGenBuffers(1, &model3d->vertex_buffer)); GL(glBindBuffer(GL_ARRAY_BUFFER, model3d->vertex_buffer)); GL(glBufferData(GL_ARRAY_BUFFER, model3d->nb_vertices * sizeof(*model3d->vertices), model3d->vertices, GL_STATIC_DRAW)); model3d->dirty = false; } GL(glBindBuffer(GL_ARRAY_BUFFER, model3d->vertex_buffer)); GL(glEnableVertexAttribArray(A_POS_LOC)); GL(glVertexAttribPointer(A_POS_LOC, 3, GL_FLOAT, false, sizeof(*model3d->vertices), (void*)offsetof(model_vertex_t, pos))); GL(glEnableVertexAttribArray(A_COLOR_LOC)); GL(glVertexAttribPointer(A_COLOR_LOC, 4, GL_UNSIGNED_BYTE, true, sizeof(*model3d->vertices), (void*)offsetof(model_vertex_t, color))); GL(glEnableVertexAttribArray(A_UV_LOC)); GL(glVertexAttribPointer(A_UV_LOC, 2, GL_FLOAT, false, sizeof(*model3d->vertices), (void*)offsetof(model_vertex_t, uv))); GL(glEnableVertexAttribArray(A_NORMAL_LOC)); GL(glVertexAttribPointer(A_NORMAL_LOC, 3, GL_FLOAT, false, sizeof(*model3d->vertices), (void*)offsetof(model_vertex_t, normal))); gl_update_uniform(g_shader, "u_l_emit", 1.0); gl_update_uniform(g_shader, "u_l_diff", 0.0); if (clip_box && !box_is_null(clip_box)) mat4_invert(clip_box, clip); gl_update_uniform(g_shader, "u_clip", clip); grid_alpha = (effects & EFFECT_GRID) ? 0.05 : 0.0; gl_update_uniform(g_shader, "u_grid_alpha", grid_alpha); if (model3d->solid) { if (light && (!(effects & EFFECT_NO_SHADING))) { vec3_copy(light, light_dir); if (effects & EFFECT_SEE_BACK) vec3_imul(light_dir, -1); gl_update_uniform(g_shader, "u_l_dir", light_dir); gl_update_uniform(g_shader, "u_l_emit", 0.2); gl_update_uniform(g_shader, "u_l_diff", 0.8); } GL(glDrawArrays(GL_TRIANGLES, 0, model3d->nb_vertices)); } else { GL(glDrawArrays(GL_LINES, 0, model3d->nb_vertices)); } GL(glDisableVertexAttribArray(A_POS_LOC)); GL(glDisableVertexAttribArray(A_COLOR_LOC)); GL(glCullFace(GL_BACK)); } goxel-0.11.0/src/model3d.h000066400000000000000000000057601435762723100152200ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* * Section: Model3d * * Functions to render 3d vertex models, like cube, plane, etc. */ #ifndef MODEL3D_H #define MODEL3D_H #include "utils/texture.h" /* * Type: model_vertex_t * Container for a single vertex shader data. */ typedef struct { float pos[3] __attribute__((aligned(4))); float normal[3] __attribute__((aligned(4))); uint8_t color[4] __attribute__((aligned(4))); float uv[2] __attribute__((aligned(4))); } model_vertex_t; /* * Type: model3d_t * Define a 3d model. */ typedef struct { int nb_vertices; model_vertex_t *vertices; bool solid; bool cull; // Rendering buffers. // XXX: move this into the renderer, like for block_t uint32_t vertex_buffer; int nb_lines; bool dirty; } model3d_t; void model3d_release_graphics(void); /* * Function: model3d_delete * Delete a 3d model */ void model3d_delete(model3d_t *model); /* * Function: model3d_cube * Create a 3d cube from (0, 0, 0) to (1, 1, 1) */ model3d_t *model3d_cube(void); /* * Function: model3d_wire_cube * Create a 3d wire cube from (0, 0, 0) to (1, 1, 1) */ model3d_t *model3d_wire_cube(void); /* * Function: model3d_sphere * Create a sphere of radius 1, centered at (0, 0). */ model3d_t *model3d_sphere(int slices, int stacks); /* * Function: model3d_grid * Create a grid plane. */ model3d_t *model3d_grid(int nx, int ny); /* * Function: model3d_line * Create a line from (-0.5, 0, 0) to (+0.5, 0, 0). */ model3d_t *model3d_line(void); /* * Function: model3d_line * Create a 2d rect on xy plane, of size 1x1 centered on the origin. */ model3d_t *model3d_rect(void); /* * Function: model3d_line * Create a 2d rect on xy plane, of size 1x1 centered on the origin. */ model3d_t *model3d_wire_rect(void); /* * Function: model3d_render * Render a 3d model using OpenGL calls. */ void model3d_render(model3d_t *model3d, const float model[4][4], const float view[4][4], const float proj[4][4], const uint8_t color[4], const texture_t *tex, const float light[3], const float clip_box[4][4], int effects); #endif // MODEL3D_H goxel-0.11.0/src/palette.c000066400000000000000000000133501435762723100153140ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" /* * Function: palette_search * Search a given color in a palette * * Parameters: * palette - A palette. * col - The color we are looking for. * exact - If set to true, return -1 if no color is found, else * return the closest color. * * Return: * The index of the color in the palette. */ int palette_search(const palette_t *palette, const uint8_t col[4], bool exact) { int i; assert(exact); // For the moment. for (i = 0; i < palette->size; i++) { if (memcmp(col, palette->entries[i].color, 4) == 0) return i; } return -1; } void palette_insert(palette_t *p, const uint8_t col[4], const char *name) { palette_entry_t *e; if (palette_search(p, col, true) != -1) return; if (p->allocated <= p->size) { p->allocated += 64; p->entries = realloc(p->entries, p->allocated * sizeof(*p->entries)); } e = &p->entries[p->size]; memset(e, 0, sizeof(*e)); memcpy(e->color, col, 4); if (name) snprintf(e->name, sizeof(e->name), "%s", name); p->size++; } // Parse a gimp palette. // XXX: we don't check for buffer overflow! static int parse_gpl(const char *data, char *name, int *columns, palette_entry_t *entries) { const char *start, *end; int linen, r, g, b, nb = 0; char entry_name[128]; for (linen = 1, start = data; *start; start = end + 1, linen++) { end = strchr(start, '\n'); if (!end) end = start + strlen(start); if (name && sscanf(start, "Name: %[^\n]", name) == 1) { name = NULL; continue; } if (columns && sscanf(start, "Columns: %d", columns) == 1) { columns = NULL; continue; } if (sscanf(start, "%d %d %d %[^\n]", &r, &g, &b, entry_name) >= 3) { if (entries) { strcpy(entries[nb].name, entry_name); entries[nb].color[0] = r; entries[nb].color[1] = g; entries[nb].color[2] = b; entries[nb].color[3] = 255; } nb++; } if (!*end) break; } return nb; } /* * Function: parse_dat * Parse a Build engine (duke2d, blood...) palette */ static int parse_dat(const uint8_t *data, int len, palette_entry_t *entries) { int i; if (len < 768) return -1; for (i = 0; i < 256; i++) { entries[i].color[0] = data[i * 3 + 0] * 4; entries[i].color[1] = data[i * 3 + 1] * 4; entries[i].color[2] = data[i * 3 + 2] * 4; entries[i].color[3] = 255; } return 256; } /* * Function: parse_png * Parse a png image into a palette. */ static int parse_png(const void *data, int len, palette_t *palette) { int i, w, h, bpp = 3; uint8_t *img, color[4]; img = img_read_from_mem((void*)data, len, &w, &h, &bpp); if (!img) return -1; for (i = 0; i < w * h; i++) { memcpy(color, (uint8_t[]){0, 0, 0, 255}, 4); memcpy(color, img + i * bpp, bpp); palette_insert(palette, color, NULL); } free(img); return palette->size; } static int on_palette(int i, const char *path, void *user) { palette_t **list = user; const char *data; palette_t *pal; pal = calloc(1, sizeof(*pal)); data = assets_get(path, NULL); pal->size = parse_gpl(data, pal->name, &pal->columns, NULL); pal->entries = calloc(pal->size, sizeof(*pal->entries)); parse_gpl(data, NULL, NULL, pal->entries); DL_APPEND(*list, pal); return 0; } static int on_palette2(const char *dir, const char *name, void *user) { palette_t **list = user; char *data, *path; int size, err = 0; palette_t *pal; if ( !str_endswith(name, ".gpl") && !str_endswith(name, ".dat") && !str_endswith(name, ".png")) return 0; asprintf(&path, "%s/%s", dir, name); pal = calloc(1, sizeof(*pal)); data = read_file(path, &size); if (str_endswith(name, ".gpl")) { pal->size = parse_gpl(data, pal->name, &pal->columns, NULL); pal->entries = calloc(pal->size, sizeof(*pal->entries)); err = parse_gpl(data, NULL, NULL, pal->entries); } else if (str_endswith(name, ".dat")) { snprintf(pal->name, sizeof(pal->name), "%s", name); pal->size = 256; pal->entries = calloc(pal->size, sizeof(*pal->entries)); err = parse_dat((void*)data, size, pal->entries); } else if (str_endswith(name, ".png")) { snprintf(pal->name, sizeof(pal->name), "%s", name); err = parse_png(data, size, pal); } if (err < 0) { LOG_E("Cannot parse palette %s", path); free(pal); goto end; } DL_APPEND(*list, pal); end: free(path); free(data); return 0; } void palette_load_all(palette_t **list) { char *dir; assets_list("data/palettes/", list, on_palette); if (sys_get_user_dir()) { asprintf(&dir, "%s/palettes", sys_get_user_dir()); sys_list_dir(dir, on_palette2, list); free(dir); } } goxel-0.11.0/src/palette.h000066400000000000000000000033141435762723100153200ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ // XXX: probably need to redo the code here. #include #include typedef struct { uint8_t color[4]; char name[32]; } palette_entry_t; typedef struct palette palette_t; struct palette { palette_t *next, *prev; // For the global list of palettes. char name[128]; int columns; int size; int allocated; palette_entry_t *entries; }; // Load all the available palettes into a list. void palette_load_all(palette_t **list); /* * Function: palette_search * Search a given color in a palette * * Parameters: * palette - A palette. * col - The color we are looking for. * exact - If set to true, return -1 if no color is found, else * return the closest color. * * Return: * The index of the color in the palette. */ int palette_search(const palette_t *palette, const uint8_t col[4], bool exact); void palette_insert(palette_t *p, const uint8_t col[4], const char *name); goxel-0.11.0/src/pathtracer.cpp000066400000000000000000000523221435762723100163550ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef YOCTO # define YOCTO 1 #endif #if YOCTO #ifndef __clang__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #define YOCTO_EMBREE 0 #define STB_IMAGE_STATIC #include "../ext_src/yocto/yocto_bvh.h" #include "../ext_src/yocto/yocto_scene.h" #include "../ext_src/yocto/yocto_trace.h" #ifndef __clang__ #pragma GCC diagnostic pop #endif #include #include #include #include #include extern "C" { #include "goxel.h" } #include "xxhash.h" using namespace yocto; using namespace std; typedef yocto::image image4f; enum { CHANGE_MESH = 1 << 0, CHANGE_WORLD = 1 << 1, CHANGE_LIGHT = 1 << 2, CHANGE_CAMERA = 1 << 3, CHANGE_FORCE = 1 << 4, CHANGE_FLOOR = 1 << 5, CHANGE_OPTIONS = 1 << 6, CHANGE_MATERIAL = 1 << 7, }; struct pathtracer_internal { // Different hash keys to quickly check for state changes. uint64_t mesh_key; uint64_t camera_key; uint64_t world_key; uint64_t light_key; uint64_t floor_key; uint64_t options_key; yocto_scene scene; bvh_scene bvh; image4f image; image4f display; trace_state state; trace_lights lights; trace_params trace_prms; bvh_params bvh_prms; tonemap_params tonemap_prms; atomic trace_sample; vector> trace_futures; deque trace_queue; std::mutex trace_queuem; atomic trace_stop; float exposure; }; template inline bool try_pop(std::deque &queue, std::mutex &mut, T& value) { lock_guard lock(mut); if (queue.empty()) return false; value = queue.front(); queue.pop_front(); return true; } /* * Get a item from a list by name or create a new one if it doesn't exists */ template static T* getdefault(vector &list, const string &uri, bool *created=nullptr) { if (created) *created = false; for (T &value : list) { if (value.uri == uri) return &value; } if (created) *created = true; list.push_back(T{}); list.back().uri = uri; return &list.back(); } /* * Return the index of an item in a list. */ template static int getindex(const vector &list, const T* elem) { return elem - &list.front(); } static int get_material_id(pathtracer_t *pt, const material_t *mat, int *changed) { char name[128]; pathtracer_internal_t *p = pt->p; yocto_material *m; bool created; const material_t default_mat = MATERIAL_DEFAULT; if (!mat) mat = &default_mat; snprintf(name, sizeof(name), "", material_get_hash(mat)); m = getdefault(p->scene.materials, name, &created); if (created) { *changed |= CHANGE_MATERIAL; m->metallic = mat->metallic; m->diffuse = {mat->base_color[0], mat->base_color[1], mat->base_color[2]}; m->opacity = mat->base_color[3]; m->specular = {0.04, 0.04, 0.04}; m->roughness = mat->roughness; m->emission = {mat->emission[0], mat->emission[1], mat->emission[2]}; } return getindex(p->scene.materials, m); } static yocto_shape create_shape_for_block( const mesh_t *mesh, const int block_pos[3]) { voxel_vertex_t* vertices; int i, nb, size, subdivide; yocto_shape shape = {}; vertices = (voxel_vertex_t*)calloc( BLOCK_SIZE * BLOCK_SIZE * BLOCK_SIZE * 6 * 4, sizeof(*vertices)); nb = mesh_generate_vertices(mesh, block_pos, goxel.rend.settings.effects, vertices, &size, &subdivide); if (!nb) goto end; // Set vertices data. shape.positions.resize(nb * size); shape.colors.resize(nb * size); shape.normals.resize(nb * size); for (i = 0; i < nb * size; i++) { shape.positions[i] = {vertices[i].pos[0] / (float)subdivide, vertices[i].pos[1] / (float)subdivide, vertices[i].pos[2] / (float)subdivide}; shape.colors[i] = {vertices[i].color[0] / 255.f, vertices[i].color[1] / 255.f, vertices[i].color[2] / 255.f, 1.0f}; shape.normals[i] = {vertices[i].normal[0] / 128.f, vertices[i].normal[1] / 128.f, vertices[i].normal[2] / 128.f}; } // Set primitives (quads or triangles) data. if (size == 4) { shape.quads.resize(nb); for (i = 0; i < nb; i++) shape.quads[i] = {i * 4 + 0, i * 4 + 1, i * 4 + 2, i * 4 + 3}; } else { shape.triangles.resize(nb); for (i = 0; i < nb; i++) shape.triangles[i] = {i * 3 + 0, i * 3 + 1, i * 3 + 2}; } end: free(vertices); return shape; } // Stop the asynchronous renderer. void stop_render(vector>& futures, deque& queue, std::mutex& queuem, atomic* cancel) { if (cancel) *cancel = true; for (auto& f : futures) f.get(); futures.clear(); { std::lock_guard guard{queuem}; queue.clear(); } } static int sync_mesh(pathtracer_t *pt, int w, int h, bool force) { uint32_t key = 0, k; mesh_iterator_t iter; const mesh_t *mesh; int block_pos[3], i, changed = 0; yocto_shape shape; yocto_instance instance; pathtracer_internal_t *p = pt->p; const layer_t *layers, *layer; layers = goxel_get_render_layers(false); DL_FOREACH(layers, layer) { if (!layer->visible || !layer->mesh) continue; k = mesh_get_key(layer->mesh); key = XXH32(&k, sizeof(k), key); i = get_material_id(pt, layer->material, &changed); key = XXH32(&i, sizeof(i), key); } key = XXH32(goxel.back_color, sizeof(goxel.back_color), key); key = XXH32(&w, sizeof(w), key); key = XXH32(&h, sizeof(h), key); key = XXH32(&goxel.rend.settings.effects, sizeof(goxel.rend.settings.effects), key); key = XXH32(&pt->floor.type, sizeof(pt->floor.type), key); key = XXH32(&force, sizeof(force), key); if (!force && key == p->mesh_key) return changed; p->mesh_key = key; stop_render(p->trace_futures, p->trace_queue, p->trace_queuem, &p->trace_stop); p->scene = {}; p->lights = {}; changed |= CHANGE_MESH; DL_FOREACH(layers, layer) { if (!layer->visible || !layer->mesh) continue; mesh = layer->mesh; iter = mesh_get_iterator(mesh, MESH_ITER_BLOCKS | MESH_ITER_INCLUDES_NEIGHBORS); while (mesh_iter(&iter, block_pos)) { shape = create_shape_for_block(mesh, block_pos); // shape.material = get_material_id(pt, layer->material, &changed); if (shape.positions.empty()) continue; p->scene.shapes.push_back(shape); instance.material = get_material_id(pt, layer->material, &changed); instance.uri = shape.uri; instance.shape = p->scene.shapes.size() - 1; instance.frame = translation_frame(vec3f( block_pos[0], block_pos[1], block_pos[2])); p->scene.instances.push_back(instance); } } return changed; } static int sync_floor(pathtracer_t *pt, bool force) { pathtracer_internal_t *p = pt->p; uint64_t key = 0; yocto_shape *shape; yocto_instance *instance; int i; vec4f color; float pos[3] = {0, 0, 0}; int changed = 0; key = XXH32(&pt->floor, sizeof(pt->floor), key); if (!force && key == p->floor_key) return 0; changed |= CHANGE_FLOOR; p->floor_key = key; stop_render(p->trace_futures, p->trace_queue, p->trace_queuem, &p->trace_stop); if (pt->floor.type == PT_FLOOR_NONE) return changed; color[0] = pt->floor.color[0] / 255.f; color[1] = pt->floor.color[1] / 255.f; color[2] = pt->floor.color[2] / 255.f; color[3] = 1.0; if (!box_is_null(goxel.image->box)) { pos[0] = goxel.image->box[3][0]; pos[1] = goxel.image->box[3][1]; pos[2] = goxel.image->box[3][2] - goxel.image->box[2][2]; } shape = getdefault(p->scene.shapes, ""); shape->positions = {}; shape->colors = {}; shape->normals = {}; shape->quads = {}; for (i = 0; i < 4; i++) { shape->positions.push_back({i % 2 - 0.5f, i / 2 - 0.5f, 0.f}); shape->normals.push_back({0, 0, 1}); shape->colors.push_back(color); } shape->quads.push_back({0, 1, 3, 2}); // shape->material = get_material_id(pt, pt->floor.material, &changed); instance = getdefault(p->scene.instances, ""); instance->material = get_material_id(pt, pt->floor.material, &changed); instance->shape = getindex(p->scene.shapes, shape); instance->frame = translation_frame({pos[0], pos[1], pos[2]}) * scaling_frame( vec3f(pt->floor.size[0], pt->floor.size[1], 1.f)); return changed; } static int sync_camera(pathtracer_t *pt, int w, int h, const float viewport[4], const camera_t *camera, bool force) { pathtracer_internal_t *p = pt->p; yocto_camera *cam; uint64_t key; float m[4][4], aspect, viewport_aspect, fovy; add_cameras(p->scene); cam = &p->scene.cameras[0]; key = XXH32(camera->view_mat, sizeof(camera->view_mat), 0); key = XXH32(camera->proj_mat, sizeof(camera->proj_mat), key); key = XXH32(&w, sizeof(w), key); key = XXH32(&h, sizeof(h), key); if (!force && key == p->camera_key) return 0; p->camera_key = key; stop_render(p->trace_futures, p->trace_queue, p->trace_queuem, &p->trace_stop); mat4_copy(camera->mat, m); cam->frame = frame3f(mat4f({m[0][0], m[0][1], m[0][2], m[0][3]}, {m[1][0], m[1][1], m[1][2], m[1][3]}, {m[2][0], m[2][1], m[2][2], m[2][3]}, {m[3][0], m[3][1], m[3][2], m[3][3]})); aspect = (float)w / h; viewport_aspect = viewport[2] / viewport[3]; fovy = camera->fovy / 180 * M_PI; if (viewport_aspect < aspect) { fovy *= viewport_aspect / aspect; } set_yperspective(*cam, fovy, aspect, camera->dist); return CHANGE_CAMERA; } static int sync_world(pathtracer_t *pt, bool force) { uint64_t key = 0; pathtracer_internal_t *p = pt->p; yocto_texture *texture; yocto_environment *environment; float turbidity = 3; bool has_sun = false; vec4f color; key = XXH32(&pt->world.type, sizeof(pt->world.type), key); key = XXH32(&pt->world.energy, sizeof(pt->world.energy), key); key = XXH32(&pt->world.color, sizeof(pt->world.color), key); if (!force && key == p->world_key) return 0; p->world_key = key; stop_render(p->trace_futures, p->trace_queue, p->trace_queuem, &p->trace_stop); texture = getdefault(p->scene.textures, ""); texture->uri = "textures/uniform.hdr"; color[0] = pt->world.color[0] / 255.f; color[1] = pt->world.color[1] / 255.f; color[2] = pt->world.color[2] / 255.f; color[3] = 1.0; switch (pt->world.type) { case PT_WORLD_NONE: return true; case PT_WORLD_SKY: texture->hdr = make_sunsky({512, 256}, pif / 4, turbidity, has_sun, 1.0f, 0, {color.x, color.y, color.z}); break; case PT_WORLD_UNIFORM: texture->hdr = {{64, 64}, color}; break; } environment = getdefault(p->scene.environments, ""); environment->emission = vec3f{1, 1, 1} * pt->world.energy; environment->emission_tex = getindex(p->scene.textures, texture); environment->frame = rotation_frame(vec3f{1.f, 0.f, 0.f}, pif / 2); return CHANGE_WORLD; } static int sync_light(pathtracer_t *pt, bool force) { uint64_t key = 0; pathtracer_internal_t *p = pt->p; yocto_shape *shape; yocto_instance *instance; yocto_material *material; // Large enough to be considered at infinity, but not enough to produce // rendering effects. const float d = 10000; float ke; float light_dir[3]; render_get_light_dir(&goxel.rend, light_dir); key = XXH32(&pt->world, sizeof(pt->world), key); key = XXH32(&goxel.rend.light.intensity, sizeof(goxel.rend.light.intensity), key); key = XXH32(light_dir, sizeof(light_dir), key); if (!force && key == p->light_key) return 0; p->light_key = key; stop_render(p->trace_futures, p->trace_queue, p->trace_queuem, &p->trace_stop); ke = goxel.rend.light.intensity; material = getdefault(p->scene.materials, ""); material->emission = {ke * d * d, ke * d * d, ke * d * d}; shape = getdefault(p->scene.shapes, ""); shape->positions = {}; shape->triangles = {}; shape->positions.push_back({0, 0, 0}); shape->positions.push_back({1, 0, 0}); shape->positions.push_back({1, 1, 0}); shape->triangles.push_back({0, 1, 2}); instance = getdefault(p->scene.instances, ""); instance->material = getindex(p->scene.materials, material); instance->shape = getindex(p->scene.shapes, shape); instance->frame = translation_frame( {light_dir[0] * d, light_dir[1] * d, light_dir[2] * d}); return CHANGE_LIGHT; } static int sync_options(pathtracer_t *pt, bool force) { uint64_t key = 0; pathtracer_internal_t *p = pt->p; key = XXH32(&pt->num_samples, sizeof(pt->num_samples), key); if (!force && key == p->options_key) return 0; p->options_key = key; stop_render(p->trace_futures, p->trace_queue, p->trace_queuem, &p->trace_stop); p->trace_prms.samples = pt->num_samples; p->trace_prms.resolution = max(pt->w, pt->h); return CHANGE_OPTIONS; } static void start_render( image4f& image, trace_state& state, const yocto_scene& scene, const bvh_scene& bvh, const trace_lights& lights, vector>& futures, atomic& current_sample, deque& queue, mutex& queuem, const trace_params& trace_prms, atomic* cancel) { auto& camera = scene.cameras.at(trace_prms.camera); auto image_size = camera_resolution(camera, trace_prms.resolution); state = make_trace_state(image_size, trace_prms.seed); auto regions = make_regions(image.size(), trace_prms.region, true); if (cancel) *cancel = false; futures.clear(); futures.emplace_back(async([trace_prms, regions, ¤t_sample, &image, &scene, &lights, &bvh, &state, &queue, &queuem, cancel]() { for (auto sample = 0; sample < trace_prms.samples; sample += trace_prms.batch) { if (cancel && *cancel) return; current_sample = sample; auto num_samples = min(trace_prms.batch, trace_prms.samples - current_sample); auto futures = vector>{}; int nthreads = std::thread::hardware_concurrency(); std::atomic next_idx(0); for (int thread_id = 0; thread_id < nthreads; thread_id++) { futures.emplace_back(async(std::launch::async, [num_samples, &trace_prms, &image, &scene, &lights, &bvh, &state, &queue, &queuem, &next_idx, cancel, ®ions]() { while (true) { if (cancel && *cancel) break; auto idx = next_idx.fetch_add(1); if (idx >= regions.size()) break; auto region = regions[idx]; trace_region(image, state, scene, bvh, lights, region, num_samples, trace_prms); { std::lock_guard guard{queuem}; queue.push_back(region); } } })); } } current_sample = trace_prms.samples; })); } static int sync(pathtracer_t *pt, int w, int h, const float viewport[4], bool force) { pathtracer_internal_t *p = pt->p; int changes = 0; if (force) changes |= CHANGE_FORCE; changes |= sync_mesh(pt, w, h, changes); changes |= sync_floor(pt, changes); changes |= sync_world(pt, changes); changes |= sync_light(pt, changes); changes |= sync_camera(pt, w, h, viewport, goxel.image->active_camera, changes); changes |= sync_options(pt, changes); if (changes) { add_materials(p->scene); update_transforms(p->scene); } // Update BVH if needed. if (changes & (CHANGE_MESH | CHANGE_LIGHT | CHANGE_FLOOR)) { p->bvh = make_bvh(p->scene, p->bvh_prms); } if (changes & (CHANGE_LIGHT | CHANGE_MATERIAL)) { p->lights = make_trace_lights(p->scene); } if (changes) { if (p->lights.instances.empty() && p->lights.environments.empty()) { p->trace_prms.sampler = trace_params::sampler_type::eyelight; } p->trace_prms.resolution = max(w, h); p->image = image4f({w, h}); p->display = image4f({w, h}); stop_render(p->trace_futures, p->trace_queue, p->trace_queuem, &p->trace_stop); p->state = make_trace_state({w, h}); p->trace_sample = 0; p->trace_stop = false; start_render(p->image, p->state, p->scene, p->bvh, p->lights, p->trace_futures, p->trace_sample, p->trace_queue, p->trace_queuem, p->trace_prms, &p->trace_stop); } return changes; } static void make_preview(pathtracer_t *pt) { int i, j, pi, pj; pathtracer_internal_t *p = pt->p; trace_params preview_prms = p->trace_prms; int preview_ratio = 8; image4f preview; vec4b v; preview_prms.resolution /= preview_ratio; preview_prms.samples = 1; preview = trace_image(p->scene, p->bvh, p->lights, preview_prms); preview = tonemap(preview, p->tonemap_prms); for (i = 0; i < pt->h; i++) { for (j = 0; j < pt->w; j++) { pi = clamp(i / preview_ratio, 0, preview.size().y - 1); pj = clamp(j / preview_ratio, 0, preview.size().x - 1); v = float_to_byte(preview[{pj, pi}]); memcpy(&pt->buf[(i * pt->w + j) * 4], &v, 4); } } } /* * Function: pathtracer_iter * Iter the rendering process of the current mesh. * * Parameters: * pt - A pathtracer instance. * viewport - The full view viewport. */ void pathtracer_iter(pathtracer_t *pt, const float viewport[4]) { pathtracer_internal_t *p; int changes, i, j, size = 0; image_region region = image_region{}; vec4b v; if (!pt->p) pt->p = new pathtracer_internal_t(); p = pt->p; p->trace_prms.resolution = max(pt->w, pt->h); changes = sync(pt, pt->w, pt->h, viewport, pt->force_restart); pt->force_restart = false; assert(p->display.size()[0] == pt->w); assert(p->display.size()[1] == pt->h); if (changes) pt->status = PT_RUNNING; if (changes & CHANGE_CAMERA) { make_preview(pt); pt->progress = 0; return; } while (try_pop(p->trace_queue, p->trace_queuem, region)) { tonemap(p->display, p->image, region, p->tonemap_prms); for (i = region.min[1]; i < region.max[1]; i++) for (j = region.min[0]; j < region.max[0]; j++) { v = float_to_byte(p->display[{j, i}]); memcpy(&pt->buf[(i * pt->w + j) * 4], &v, 4); } size += region.size().x * region.size().y; if (size >= p->image.size().x * p->image.size().y) break; } pt->progress = (float)p->trace_sample / p->trace_prms.samples; if (pt->status != PT_FINISHED && p->trace_sample == p->trace_prms.samples) { pt->status = PT_FINISHED; } } /* * Stop the pathtracer thread if it is running. */ void pathtracer_stop(pathtracer_t *pt) { pathtracer_internal_t *p = pt->p; if (!p) return; stop_render(p->trace_futures, p->trace_queue, p->trace_queuem, &p->trace_stop); delete p; pt->p = nullptr; } #else // Dummy implementation. extern "C" { #include "goxel.h" } void pathtracer_iter(pathtracer_t *pt, const float viewport[4]) {} void pathtracer_stop(pathtracer_t *pt) {} #endif // YOCTO goxel-0.11.0/src/pathtracer.h000066400000000000000000000035151435762723100160220ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "utils/texture.h" enum { PT_WORLD_NONE = 0, PT_WORLD_UNIFORM, PT_WORLD_SKY, }; enum { PT_FLOOR_NONE = 0, PT_FLOOR_PLANE, }; enum { PT_STOPPED = 0, PT_RUNNING, PT_FINISHED, }; typedef struct pathtracer_internal pathtracer_internal_t; // Hold info about the cycles rendering task. typedef struct { int status; uint8_t *buf; // RGBA buffer. int w, h; // Size of the buffer. float progress; bool force_restart; texture_t *texture; pathtracer_internal_t *p; int num_samples; struct { int type; float energy; uint8_t color[4]; } world; struct { int type; uint8_t color[4]; int size[2]; material_t *material; } floor; } pathtracer_t; /* * Function: pathtracer_iter * Iter the rendering process of the current mesh. * * Parameters: * pt - A pathtracer instance. * viewport - The full view viewport. */ void pathtracer_iter(pathtracer_t *pt, const float viewport[4]); /* * Stop the pathtracer thread if it is running. */ void pathtracer_stop(pathtracer_t *pt); goxel-0.11.0/src/quantization.c000066400000000000000000000120001435762723100163730ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2016 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" typedef struct { uint8_t c[4]; uint32_t n; } value_t; static UT_icd value_icd = {sizeof(value_t), NULL, NULL, NULL}; typedef struct { UT_array *values; } bucket_t; static void bucket_add(bucket_t *b, const uint8_t c[4], int n, bool check) { assert(b->values); int size = utarray_len(b->values); value_t v, *values = (value_t*)utarray_front(b->values); int i; assert(n); if (check) { for (i = 0; i < size; i++) { if (memcmp(values[i].c, c, 4) == 0) { values[i].n += n; return; } } } memcpy(v.c, c, 4); v.n = n; utarray_push_back(b->values, &v); } static int g_k; // Used in the sorting algo. // qsort_r is not portable! static int value_cmp(const void *a_, const void *b_) { int k = g_k; const value_t *a = a_; const value_t *b = b_; return cmp(a->c[k], b->c[k]); } // Split a bucket into two new buckets. static void bucket_split(const bucket_t *bucket, bucket_t *a, bucket_t *b) { int size = utarray_len(bucket->values); value_t *values = (value_t*)utarray_front(bucket->values); int i, j, k, nb = 0; uint8_t min_c[4] = {255, 255, 255, 255}; uint8_t max_c[4] = {0, 0, 0, 0}; // Find the channel with the max range for (i = 0; i < size; i++) { nb += values[i].n; for (k = 0; k < 4; k++) { min_c[k] = min(min_c[k], values[i].c[k]); max_c[k] = max(max_c[k], values[i].c[k]); } } k = 0; for (i = 0; i < 4; i++) if (max_c[i] - min_c[i] > max_c[k] - min_c[k]) k = i; // Sort the values by color. g_k = k; qsort(values, size, sizeof(*values), value_cmp); // Now take the bottom half into the first buket, and the top half into // the second one. utarray_new(a->values, &value_icd); utarray_new(b->values, &value_icd); for (i = 0, j = 0; i < size; i++) { if (j < nb / 2) bucket_add(a, values[i].c, min(values[i].n, nb / 2 - j), false); j += values[i].n; if (j > nb / 2) bucket_add(b, values[i].c, min(values[i].n, j - nb / 2), false); } } static void bucket_average_color(const bucket_t *b, uint8_t out[4]) { int size = utarray_len(b->values); value_t *values = (value_t*)utarray_front(b->values); int s[4] = {}, n = 0, i, k; if (size == 0) { memset(out, 0, 4); return; } for (i = 0; i < size; i++) { assert(values[i].n); n += values[i].n; for (k = 0; k < 4; k++) s[k] += values[i].n * values[i].c[k]; } out[0] = s[0] / n; out[1] = s[1] / n; out[2] = s[2] / n; out[3] = s[3] / n; } static int bucket_cmp(const void *a_, const void *b_) { const bucket_t *a = (void*)a_; const bucket_t *b = (void*)b_; int na = a->values ? utarray_len(a->values) : -1; int nb = b->values ? utarray_len(b->values) : -1; return cmp(nb, na); } // Generate an optimal palette whith a fixed number of colors from a mesh. // This is based on https://en.wikipedia.org/wiki/Median_cut. void quantization_gen_palette(const mesh_t *mesh, int nb, uint8_t (*palette)[4]) { uint8_t v[4]; int i, pos[3]; bucket_t *buckets, b; mesh_iterator_t iter; buckets = calloc(nb, sizeof(*buckets)); // Fill the initial bucket. utarray_new(buckets[0].values, &value_icd); iter = mesh_get_iterator(mesh, MESH_ITER_VOXELS); while (mesh_iter(&iter, pos)) { mesh_get_at(mesh, &iter, pos, v); if (v[3] < 127) continue; v[3] = 255; bucket_add(&buckets[0], v, 1, true); } // Split until we get nb buckets. I do it a bit stupidly, by sorting // the buckets at every iterations! I should use a stack! while (!buckets[nb - 1].values) { assert(!buckets[nb - 1].values); b = buckets[0]; memset(&buckets[0], 0, sizeof(buckets[0])); bucket_split(&b, &buckets[0], &buckets[nb - 1]); utarray_free(b.values); qsort(buckets, nb, sizeof(*buckets), bucket_cmp); } // Fill the palette colors and cleanup. for (i = 0; i < nb; i++) { assert(buckets[i].values); bucket_average_color(&buckets[i], palette[i]); utarray_free(buckets[i].values); } free(buckets); } goxel-0.11.0/src/render.c000066400000000000000000001101261435762723100151340ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "shader_cache.h" #ifndef RENDER_CACHE_SIZE # define RENDER_CACHE_SIZE (1 * GB) #endif /* * The rendering is delayed from the time we call the different render * functions. This allows to call `render_xxx` anywhere in the code, without * having to worry about the current OpenGL state. * * Since generating the blocks vertex buffers is slow, we buffer them in a hash * table. We can evict blocks from the buffer when we need to save space or * if we know that the block won't be used anymore. */ // TODO: we need to get ride of unused blocks in the buffer, that hav not been // rendered for too long. First we might need to keep track of how much video // memory is used, so we get an idea of how much we need that. enum { ITEM_MESH = 1, ITEM_MODEL3D, ITEM_GRID, }; typedef struct { uint64_t ids[27]; int effects; } block_item_key_t; struct render_item_t { render_item_t *next, *prev; // The rendering queue. int type; block_item_key_t key; union { mesh_t *mesh; float mat[4][4]; }; material_t material; uint8_t color[4]; float clip_box[4][4]; bool proj_screen; // Render with a 2d proj. model3d_t *model3d; texture_t *tex; int effects; GLuint vertex_buffer; int size; // 4 (quads) or 3 (triangles). int nb_elements; // Number of quads or triangle. int subdivide; // Unit per voxel (usually 1). }; // The buffered item hash table. For the moment it is only used of the blocks. // static render_item_t *g_items = NULL; // The cache of the g_items. static cache_t *g_items_cache; static const int BATCH_QUAD_COUNT = 1 << 14; static model3d_t *g_cube_model; static model3d_t *g_line_model; static model3d_t *g_wire_cube_model; static model3d_t *g_sphere_model; static model3d_t *g_grid_model; static model3d_t *g_rect_model; static model3d_t *g_wire_rect_model; static GLuint g_index_buffer; static GLuint g_background_array_buffer; static GLuint g_occlusion_tex; static GLuint g_bump_tex; static GLuint g_shadow_map_fbo; static texture_t *g_shadow_map; // XXX: the fbo should be part of the tex. #define OFFSET(n) offsetof(voxel_vertex_t, n) enum { A_POS_LOC = 0, A_NORMAL_LOC, A_TANGENT_LOC, A_GRADIENT_LOC, A_COLOR_LOC, A_POS_DATA_LOC, A_UV_LOC, A_BUMP_UV_LOC, A_OCCLUSION_UV_LOC, }; // The list of all the attributes used by the shaders. static const struct { int size; int type; int norm; int offset; } ATTRIBUTES[] = { [A_POS_LOC] = {3, GL_UNSIGNED_BYTE, false, OFFSET(pos)}, [A_NORMAL_LOC] = { 3, GL_BYTE, false, OFFSET(normal)}, [A_TANGENT_LOC] = {3, GL_BYTE, false, OFFSET(tangent)}, [A_GRADIENT_LOC] = {3, GL_BYTE, false, OFFSET(gradient)}, [A_COLOR_LOC] = {4, GL_UNSIGNED_BYTE, true, OFFSET(color)}, [A_POS_DATA_LOC] = {2, GL_UNSIGNED_BYTE, true, OFFSET(pos_data)}, [A_UV_LOC] = {2, GL_UNSIGNED_BYTE, true, OFFSET(uv)}, [A_BUMP_UV_LOC] = {2, GL_UNSIGNED_BYTE, false, OFFSET(bump_uv)}, [A_OCCLUSION_UV_LOC] = {2, GL_UNSIGNED_BYTE, false, OFFSET(occlusion_uv)}, }; static const char *ATTR_NAMES[] = { [A_POS_LOC] = "a_pos", [A_NORMAL_LOC] = "a_normal", [A_TANGENT_LOC] = "a_tangent", [A_GRADIENT_LOC] = "a_gradient", [A_COLOR_LOC] = "a_color", [A_POS_DATA_LOC] = "a_pos_data", [A_UV_LOC] = "a_uv", [A_BUMP_UV_LOC] = "a_bump_uv", [A_OCCLUSION_UV_LOC] = "a_occlusion_uv", NULL, }; /* * Create a texture atlas of the 256 possible border textures for a voxel * face. Each pixel correspond to the minimum distance to a border or an * edge. * * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |15 | * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ * |16 |.. | | | | | | | | | | | | | | | * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ * | | | | | | | | | | | | | | | | | * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ * | | | | | | | | | | | | | | | | | * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ * | | | | | | | | | | | | | | | | | * * The index into the atlas is the bit mask of the touching side for * the 4 corners and the 4 edges => 8bit => 256 blocks. * */ static void copy_color(const uint8_t in[4], uint8_t out[4]) { if (in == NULL) { out[0] = 255; out[1] = 255; out[2] = 255; out[3] = 255; } else { memcpy(out, in, 4); } } static float get_border_dist(float x, float y, int mask) { const float corners[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; const float normals[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}}; float ret = 1; int i; float u[2]; float p[2] = {x, y}; for (i = 0; i < 4; i++) { if (mask & (1 << i)) // Corners. ret = min(ret, vec2_dist(p, corners[i])); if (mask & (0x10 << i)) { // Edges. vec2_sub(p, corners[i], u); ret = min(ret, vec2_dot(normals[i], u)); } } return ret; } static void init_occlusion_texture(void) { const int s = VOXEL_TEXTURE_SIZE; // the individual tile size. uint8_t data[256 * s * s]; int mask, x, y, ax, ay; for (mask = 0; mask < 256; mask++) { for (y = 0; y < s; y++) for (x = 0; x < s; x++) { ay = mask / 16 * s + y; ax = mask % 16 * s + x; data[ay * s * 16 + ax] = 255 * sqrt(get_border_dist( (float)x / s + 0.5 / s, (float)y / s + 0.5 / s, mask)); } } GL(glGenTextures(1, &g_occlusion_tex)); GL(glActiveTexture(GL_TEXTURE0)); GL(glBindTexture(GL_TEXTURE_2D, g_occlusion_tex)); GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); GL(glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, s * 16, s * 16, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data)); } static void set_bump_block(uint8_t (*data)[3], int bx, int by, uint8_t mask) { float v[3]; int y, x, k; for (y = 0; y < 16; y++) for (x = 0; x < 16; x++) { vec3_set(v, 0, 0, 1); if ((mask & 1) && x == 15) vec2_add(v, VEC( 1, 0), v); if ((mask & 2) && x == 15) vec2_add(v, VEC(-1, 0), v); if ((mask & 4) && y == 15) vec2_add(v, VEC( 0, 1), v); if ((mask & 8) && y == 15) vec2_add(v, VEC( 0, -1), v); if ((mask & 16) && x == 0) vec2_add(v, VEC(-1, 0), v); if ((mask & 32) && x == 0) vec2_add(v, VEC( 1, 0), v); if ((mask & 64) && y == 0) vec2_add(v, VEC( 0, -1), v); if ((mask & 128) && y == 0) vec2_add(v, VEC( 0, +1), v); vec3_normalize(v, v); for (k = 0; k < 3; k++) { data[(by * 16 + y) * 256 + bx * 16 + x][k] = mix(0, 255, (v[k] / 2 + 0.5)); } } } /* * The bump texture is an atlas of 256 16x16 rects for each combination * of edge neighboor: * * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |15 | * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ * |16 |.. | | | | | | | | | | | | | | | * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ * | | | | | | | | | | | | | | | | | * * * If we index the edges of a face like that: * * y * ^ * | * +-----------+ * | 1 | * | | * |2 0| * | | * | 3 | * +-----------+---> x * * The index in the atlas is the 8 bit concatenation of the mask for each edge: * [e0, e1, e2, e3] * * With each edge mask a 2 bits value: * 0 -> z = 0 * 1 -> z = +1 * 2 -> z = -1 * */ static void init_bump_texture(void) { uint8_t (*data)[3]; int i; data = calloc(1, 256 * 256 * 3); for (i = 0; i < 256; i++) { set_bump_block(data, i % 16, i / 16, i); } GL(glGenTextures(1, &g_bump_tex)); GL(glActiveTexture(GL_TEXTURE0)); GL(glBindTexture(GL_TEXTURE_2D, g_bump_tex)); GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); GL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, data)); free(data); } static void shader_init(gl_shader_t *shader) { GL(glUseProgram(shader->prog)); gl_update_uniform(shader, "u_normal_sampler", 0); gl_update_uniform(shader, "u_occlusion_tex", 1); gl_update_uniform(shader, "u_shadow_tex", 2); } void render_init() { // 6 vertices (2 triangles) per face. uint16_t *index_array = NULL; int i; LOG_D("render init"); GL(glGenBuffers(1, &g_index_buffer)); GL(glGenBuffers(1, &g_background_array_buffer)); // Index buffer start with the quads, followed by the lines. index_array = calloc(BATCH_QUAD_COUNT * (6 + 8), sizeof(*index_array)); for (i = 0; i < BATCH_QUAD_COUNT * 6; i++) { index_array[i] = (i / 6) * 4 + ((int[]){0, 1, 2, 2, 3, 0})[i % 6]; } for (i = 0; i < BATCH_QUAD_COUNT * 8; i++) { index_array[BATCH_QUAD_COUNT * 6 + i] = (i / 8) * 4 + ((int[]){0, 1, 1, 2, 2, 3, 3, 0})[i % 8]; } GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_index_buffer)); GL(glBufferData(GL_ELEMENT_ARRAY_BUFFER, BATCH_QUAD_COUNT * (6 + 8) * 2, index_array, GL_STATIC_DRAW)); #ifndef GLES2 GL(glEnable(GL_LINE_SMOOTH)); #endif free(index_array); init_occlusion_texture(); init_bump_texture(); // XXX: pick the proper memory size according to what is available. g_items_cache = cache_create(RENDER_CACHE_SIZE); g_cube_model = model3d_cube(); g_line_model = model3d_line(); g_wire_cube_model = model3d_wire_cube(); g_sphere_model = model3d_sphere(16, 16); g_grid_model = model3d_grid(8, 8); g_rect_model = model3d_rect(); g_wire_rect_model = model3d_wire_rect(); } void render_deinit(void) { cache_delete(g_items_cache); GL(glDeleteBuffers(1, &g_index_buffer)); g_index_buffer = 0; model3d_delete(g_cube_model); model3d_delete(g_line_model); model3d_delete(g_wire_cube_model); model3d_delete(g_sphere_model); model3d_delete(g_grid_model); model3d_delete(g_rect_model); model3d_delete(g_wire_rect_model); } // A global buffer large enough to contain all the vertices for any block. static voxel_vertex_t* g_vertices_buffer = NULL; // Used for the cache. static int item_delete(void *item_) { render_item_t *item = item_; GL(glDeleteBuffers(1, &item->vertex_buffer)); free(item); return 0; } static render_item_t *get_item_for_block( const mesh_t *mesh, mesh_iterator_t *iter, const int block_pos[3], int effects, float smoothness) { render_item_t *item; const int effects_mask = EFFECT_MARCHING_CUBES | EFFECT_MC_SMOOTH; uint64_t block_data_id; int p[3], i, x, y, z; block_item_key_t key = {}; memset(&key, 0, sizeof(key)); // Just to be sure! key.effects = effects & effects_mask; // The hash key take into consideration all the blocks adjacent to // the current block! for (i = 0, z = -1; z <= 1; z++) for (y = -1; y <= 1; y++) for (x = -1; x <= 1; x++, i++) { p[0] = block_pos[0] + x * BLOCK_SIZE; p[1] = block_pos[1] + y * BLOCK_SIZE; p[2] = block_pos[2] + z * BLOCK_SIZE; mesh_get_block_data(mesh, NULL, p, &block_data_id); key.ids[i] = block_data_id; } item = cache_get(g_items_cache, &key, sizeof(key)); if (item) return item; item = calloc(1, sizeof(*item)); item->key = key; GL(glGenBuffers(1, &item->vertex_buffer)); GL(glBindBuffer(GL_ARRAY_BUFFER, item->vertex_buffer)); if (!g_vertices_buffer) g_vertices_buffer = calloc( BLOCK_SIZE * BLOCK_SIZE * BLOCK_SIZE * 6 * 4, sizeof(*g_vertices_buffer)); item->nb_elements = mesh_generate_vertices( mesh, block_pos, effects, g_vertices_buffer, &item->size, &item->subdivide); if (item->nb_elements > BATCH_QUAD_COUNT) { LOG_W("Too many quads!"); item->nb_elements = BATCH_QUAD_COUNT; } if (item->nb_elements != 0) { GL(glBufferData(GL_ARRAY_BUFFER, item->nb_elements * item->size * sizeof(*g_vertices_buffer), g_vertices_buffer, GL_STATIC_DRAW)); } cache_add(g_items_cache, &key, sizeof(key), item, item->nb_elements * item->size * sizeof(*g_vertices_buffer), item_delete); return item; } static void render_block_(renderer_t *rend, mesh_t *mesh, mesh_iterator_t *iter, const int block_pos[3], int block_id, const material_t *material, int effects, gl_shader_t *shader, const float model[4][4]) { render_item_t *item; float block_model[4][4]; int attr; float block_id_f[2]; item = get_item_for_block(mesh, iter, block_pos, effects, rend->settings.smoothness); if (item->nb_elements == 0) return; GL(glBindBuffer(GL_ARRAY_BUFFER, item->vertex_buffer)); if (gl_has_uniform(shader, "u_block_id")) { block_id_f[1] = ((block_id >> 8) & 0xff) / 255.0; block_id_f[0] = ((block_id >> 0) & 0xff) / 255.0; gl_update_uniform(shader, "u_block_id", block_id_f); } gl_update_uniform(shader, "u_pos_scale", 1.f / item->subdivide); for (attr = 0; attr < ARRAY_SIZE(ATTRIBUTES); attr++) { GL(glVertexAttribPointer(attr, ATTRIBUTES[attr].size, ATTRIBUTES[attr].type, ATTRIBUTES[attr].norm, sizeof(voxel_vertex_t), (void*)(intptr_t)ATTRIBUTES[attr].offset)); } mat4_copy(model, block_model); mat4_itranslate(block_model, block_pos[0], block_pos[1], block_pos[2]); gl_update_uniform(shader, "u_model", block_model); if (item->size == 4) { if (!(effects & (EFFECT_GRID | EFFECT_EDGES))) { GL(glDrawElements(GL_TRIANGLES, item->nb_elements * 6, GL_UNSIGNED_SHORT, 0)); } else { gl_update_uniform(shader, "u_l_amb", 0.0); gl_update_uniform(shader, "u_z_ofs", -0.001); GL(glDrawElements(GL_LINES, item->nb_elements * 8, GL_UNSIGNED_SHORT, (void*)(uintptr_t)(BATCH_QUAD_COUNT * 6 * 2))); gl_update_uniform(shader, "u_l_amb", rend->settings.ambient); gl_update_uniform(shader, "u_z_ofs", 0.0); } } else { GL(glDrawArrays(GL_TRIANGLES, 0, item->nb_elements * item->size)); } #ifndef GLES2 if (effects & EFFECT_WIREFRAME) { gl_update_uniform(shader, "u_l_amb", 0.0); GL(glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)); if (item->size == 4) GL(glDrawElements(GL_TRIANGLES, item->nb_elements * 6, GL_UNSIGNED_SHORT, 0)); else GL(glDrawArrays(GL_TRIANGLES, 0, item->nb_elements * item->size)); GL(glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)); gl_update_uniform(shader, "u_l_amb", rend->settings.ambient); } #endif } static void get_light_dir(const renderer_t *rend, float out[3]) { float light_dir[4]; float m[4][4]; mat4_set_identity(m); mat4_irotate(m, rend->light.yaw, 0, 0, 1); mat4_irotate(m, rend->light.pitch, 1, 0, 0); mat4_mul_vec4(m, VEC(0, 0, 1, 0), light_dir); if (rend->light.fixed) { mat4_invert(rend->view_mat, m); mat4_irotate(m, -M_PI / 4, 1, 0, 0); mat4_irotate(m, -M_PI / 4, 0, 0, 1); mat4_mul_vec4(m, light_dir, light_dir); } vec3_copy(light_dir, out); } void render_get_light_dir(const renderer_t *rend, float out[3]) { get_light_dir(rend, out); } // Compute the minimum projection box to use for the shadow map. static void compute_shadow_map_box( const renderer_t *rend, float rect[6]) { const float POS[8][3] = { {0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}, {0, 1, 0}, {1, 1, 0}, {1, 1, 1}, {0, 1, 1}, }; const int N = BLOCK_SIZE; render_item_t *item; float p[3]; int i, bpos[3]; mesh_iterator_t iter; float view_mat[4][4], light_dir[3]; get_light_dir(rend, light_dir); mat4_lookat(view_mat, light_dir, VEC(0, 0, 0), VEC(0, 1, 0)); rect[0] = +FLT_MAX; rect[1] = -FLT_MAX; rect[2] = +FLT_MAX; rect[3] = -FLT_MAX; rect[4] = +FLT_MAX; rect[5] = -FLT_MAX; DL_FOREACH(rend->items, item) { if (item->type != ITEM_MESH) continue; iter = mesh_get_iterator(item->mesh, MESH_ITER_BLOCKS); while (mesh_iter(&iter, bpos)) { for (i = 0; i < 8; i++) { vec3_set(p, bpos[0], bpos[1], bpos[2]); vec3_addk(p, POS[i], N, p); mat4_mul_vec3(view_mat, p, p); rect[0] = min(rect[0], p[0]); rect[1] = max(rect[1], p[0]); rect[2] = min(rect[2], p[1]); rect[3] = max(rect[3], p[1]); rect[4] = min(rect[4], -p[2]); rect[5] = max(rect[5], -p[2]); } } } } static void render_mesh_(renderer_t *rend, mesh_t *mesh, const material_t *material, int effects, const float shadow_mvp[4][4]) { gl_shader_t *shader; float model[4][4], camera[4][4]; int attr, block_pos[3], block_id; float light_dir[3], alpha; bool shadow = false; mesh_iterator_t iter; mat4_set_identity(model); get_light_dir(rend, light_dir); if (effects & EFFECT_MARCHING_CUBES) effects &= ~EFFECT_BORDERS; if (effects & EFFECT_RENDER_POS) shader = shader_get("pos_data", NULL, ATTR_NAMES, shader_init); else if (effects & EFFECT_SHADOW_MAP) shader = shader_get("shadow_map", NULL, ATTR_NAMES, shader_init); else { shadow = rend->settings.shadow; shader_define_t defines[] = { {"SHADOW", shadow}, {"MATERIAL_UNLIT", (rend->settings.effects & EFFECT_UNLIT) || (effects & EFFECT_EDGES)}, {"HAS_TANGENTS", effects & EFFECT_BORDERS}, {"ONLY_EDGES", effects & EFFECT_EDGES}, {"HAS_OCCLUSION_MAP", rend->settings.occlusion_strength > 0}, {"VERTEX_LIGHTNING", !(effects & (EFFECT_BORDERS | EFFECT_UNLIT))}, {"SMOOTHNESS", rend->settings.smoothness > 0}, {} }; shader = shader_get("mesh", defines, ATTR_NAMES, shader_init); } GL(glEnable(GL_DEPTH_TEST)); GL(glDepthFunc(GL_LEQUAL)); GL(glEnable(GL_CULL_FACE)); GL(glCullFace(GL_BACK)); GL(glActiveTexture(GL_TEXTURE0)); GL(glBindTexture(GL_TEXTURE_2D, g_bump_tex)); GL(glActiveTexture(GL_TEXTURE1)); GL(glBindTexture(GL_TEXTURE_2D, g_occlusion_tex)); GL(glDisable(GL_BLEND)); if (effects & EFFECT_SEE_BACK) { GL(glCullFace(GL_FRONT)); vec3_imul(light_dir, -0.5); } alpha = material->base_color[3]; if (effects & EFFECT_SEMI_TRANSPARENT) alpha *= 0.75; if (alpha < 1) { GL(glEnable(GL_BLEND)); GL(glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR)); GL(glBlendColor(alpha, alpha, alpha, alpha)); } GL(glUseProgram(shader->prog)); if (shadow) { assert(shadow_mvp); GL(glActiveTexture(GL_TEXTURE2)); GL(glBindTexture(GL_TEXTURE_2D, g_shadow_map->tex)); gl_update_uniform(shader, "u_shadow_mvp", shadow_mvp); gl_update_uniform(shader, "u_shadow_tex", 2); gl_update_uniform(shader, "u_shadow_strength", rend->settings.shadow); } gl_update_uniform(shader, "u_proj", rend->proj_mat); gl_update_uniform(shader, "u_view", rend->view_mat); gl_update_uniform(shader, "u_normal_sampler", 0); gl_update_uniform(shader, "u_occlusion_tex", 1); gl_update_uniform(shader, "u_normal_scale", effects & EFFECT_BORDERS ? 0.5 : 0.0); gl_update_uniform(shader, "u_l_dir", light_dir); gl_update_uniform(shader, "u_l_int", rend->light.intensity); gl_update_uniform(shader, "u_l_amb", rend->settings.ambient); gl_update_uniform(shader, "u_m_metallic", material->metallic); gl_update_uniform(shader, "u_m_roughness", material->roughness); gl_update_uniform(shader, "u_m_base_color", material->base_color); gl_update_uniform(shader, "u_m_emissive_factor", material->emission); gl_update_uniform(shader, "u_m_smoothness", rend->settings.smoothness); gl_update_uniform(shader, "u_occlusion_strength", rend->settings.occlusion_strength); mat4_invert(rend->view_mat, camera); gl_update_uniform(shader, "u_camera", camera[3]); for (attr = 0; attr < ARRAY_SIZE(ATTRIBUTES); attr++) GL(glEnableVertexAttribArray(attr)); GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_index_buffer)); block_id = 1; iter = mesh_get_iterator(mesh, MESH_ITER_BLOCKS | MESH_ITER_INCLUDES_NEIGHBORS); while (mesh_iter(&iter, block_pos)) { render_block_(rend, mesh, &iter, block_pos, block_id++, material, effects, shader, model); } for (attr = 0; attr < ARRAY_SIZE(ATTRIBUTES); attr++) GL(glDisableVertexAttribArray(attr)); if (effects & EFFECT_SEE_BACK) { effects &= ~EFFECT_SEE_BACK; effects |= EFFECT_SEMI_TRANSPARENT; render_mesh_(rend, mesh, material, effects, shadow_mvp); } GL(glDisable(GL_BLEND)); } // XXX: this is quite ugly. We could maybe use a callback of some sort // in the renderer instead. void render_get_block_pos(renderer_t *rend, const mesh_t *mesh, int id, int pos[3]) { // Basically we simulate the algo of render_mesh_ but without rendering // anything. int block_id, block_pos[3]; mesh_iterator_t iter; block_id = 1; iter = mesh_get_iterator(mesh, MESH_ITER_BLOCKS | MESH_ITER_INCLUDES_NEIGHBORS); while (mesh_iter(&iter, block_pos)) { if (block_id == id) { memcpy(pos, block_pos, sizeof(block_pos)); return; } block_id++; } } void render_mesh(renderer_t *rend, const mesh_t *mesh, const material_t *material, int effects) { render_item_t *item; const material_t default_material = MATERIAL_DEFAULT; float alpha; if (mesh == NULL) return; material = material ?: &default_material; if (!(effects & EFFECT_GRID_ONLY)) { item = calloc(1, sizeof(*item)); item->type = ITEM_MESH; item->mesh = mesh_copy(mesh); item->material = *material; item->effects = effects | rend->settings.effects; item->effects &= ~(EFFECT_GRID | EFFECT_EDGES); // With EFFECT_RENDER_POS we need to remove some effects. if (item->effects & EFFECT_RENDER_POS) item->effects &= ~(EFFECT_SEMI_TRANSPARENT | EFFECT_SEE_BACK | EFFECT_MARCHING_CUBES); DL_APPEND(rend->items, item); } if (effects & EFFECT_GRID_ONLY) effects |= EFFECT_GRID; if (effects & EFFECT_GRID) { alpha = 0.1; item = calloc(1, sizeof(*item)); item->type = ITEM_MESH; item->mesh = mesh_copy(mesh); item->effects = EFFECT_GRID | EFFECT_BORDERS; item->material = *material; vec4_set(item->material.base_color, 0, 0, 0, alpha); DL_APPEND(rend->items, item); } if (effects & EFFECT_EDGES) { alpha = 0.2; item = calloc(1, sizeof(*item)); item->type = ITEM_MESH; item->mesh = mesh_copy(mesh); item->effects = EFFECT_EDGES | EFFECT_BORDERS; item->material = *material; vec4_set(item->material.base_color, 0, 0, 0, alpha); DL_APPEND(rend->items, item); } } static void render_model_item(renderer_t *rend, const render_item_t *item, const float viewport[4]) { float proj[4][4]; const float (*proj_mat)[4][4]; const float (*view_mat)[4][4]; float light[3]; if (item->proj_screen) { mat4_ortho(proj, 0, viewport[2], 0, viewport[3], -128, +128); proj_mat = &proj; view_mat = &mat4_identity; } else { proj_mat = &rend->proj_mat; view_mat = &rend->view_mat; } if (!(item->effects & EFFECT_WIREFRAME)) get_light_dir(rend, light); model3d_render(item->model3d, item->mat, *view_mat, *proj_mat, item->color, item->tex, light, item->clip_box, item->effects); } static void render_grid_item(renderer_t *rend, const render_item_t *item) { int x, y, n; float model_mat[4][4]; n = 3; for (y = -n; y < n; y++) for (x = -n; x < n; x++) { mat4_copy(item->mat, model_mat); mat4_translate(model_mat, x + 0.5, y + 0.5, 0, model_mat); model3d_render(item->model3d, model_mat, rend->view_mat, rend->proj_mat, item->color, NULL, NULL, item->clip_box, item->effects); } } void render_grid(renderer_t *rend, const float plane[4][4], const uint8_t color[4], const float clip_box[4][4]) { render_item_t *item = calloc(1, sizeof(*item)); item->type = ITEM_GRID; mat4_copy(plane, item->mat); mat4_iscale(item->mat, 1024, 1024, 1); mat4_itranslate(item->mat, 0, 0, 0.01); item->model3d = g_rect_model; copy_color(color, item->color); item->effects = EFFECT_GRID; if (clip_box) mat4_copy(clip_box, item->clip_box); DL_APPEND(rend->items, item); } void render_img(renderer_t *rend, texture_t *tex, const float mat[4][4], int effects) { render_item_t *item = calloc(1, sizeof(*item)); item->type = ITEM_MODEL3D; mat ? mat4_copy(mat, item->mat) : mat4_set_identity(item->mat); item->proj_screen = !mat || (effects & EFFECT_PROJ_SCREEN); item->tex = texture_copy(tex); item->model3d = g_rect_model; copy_color(NULL, item->color); item->effects = effects; DL_APPEND(rend->items, item); } void render_img2(renderer_t *rend, const uint8_t *data, int w, int h, int bpp, const float mat[4][4], int effects) { // Experimental for the moment! // Same as render_img, but we flip the texture! render_item_t *item = calloc(1, sizeof(*item)); item->type = ITEM_MODEL3D; mat ? mat4_copy(mat, item->mat) : mat4_set_identity(item->mat); mat4_iscale(item->mat, 1, -1, 1); item->proj_screen = effects & EFFECT_PROJ_SCREEN; item->tex = texture_new_from_buf(data, w, h, bpp, (effects & EFFECT_ANTIALIASING) ? 0 : TF_NEAREST); item->model3d = g_rect_model; copy_color(NULL, item->color); item->effects = effects; DL_APPEND(rend->items, item); } void render_rect(renderer_t *rend, const float plane[4][4], int effects) { render_item_t *item = calloc(1, sizeof(*item)); assert((effects & EFFECT_STRIP) == effects); item->type = ITEM_MODEL3D; mat4_copy(plane, item->mat); item->model3d = g_wire_rect_model; copy_color(NULL, item->color); item->proj_screen = true; item->effects = effects; DL_APPEND(rend->items, item); } // Return a plane whose u vector is the line ab. static void line_create_plane(const float a[3], const float b[3], float out[4][4]) { mat4_set_identity(out); vec3_copy(a, out[3]); vec3_sub(b, a, out[0]); } void render_line(renderer_t *rend, const float a[3], const float b[3], const uint8_t color[4], int effects) { render_item_t *item = calloc(1, sizeof(*item)); item->type = ITEM_MODEL3D; item->model3d = g_line_model; line_create_plane(a, b, item->mat); copy_color(color, item->color); mat4_itranslate(item->mat, 0.5, 0, 0); item->proj_screen = effects & EFFECT_PROJ_SCREEN; DL_APPEND(rend->items, item); } void render_box(renderer_t *rend, const float box[4][4], const uint8_t color[4], int effects) { render_item_t *item = calloc(1, sizeof(*item)); assert((effects & (EFFECT_STRIP | EFFECT_WIREFRAME | EFFECT_SEE_BACK | EFFECT_GRID)) == effects); item->type = ITEM_MODEL3D; mat4_copy(box, item->mat); copy_color(color, item->color); item->effects = effects; item->model3d = (effects & EFFECT_WIREFRAME) ? g_wire_cube_model : g_cube_model; DL_APPEND(rend->items, item); } void render_sphere(renderer_t *rend, const float mat[4][4]) { render_item_t *item = calloc(1, sizeof(*item)); item->type = ITEM_MODEL3D; mat4_copy(mat, item->mat); item->model3d = g_sphere_model; DL_APPEND(rend->items, item); } static float item_sort_value(const render_item_t *a) { // First, non transparent full models (like the image box). if ((a->type == ITEM_MODEL3D) && !(a->effects & EFFECT_WIREFRAME) && !(a->tex) && (a->color[3] == 255)) return 0; // Then all the non transparent meshes. if (a->type == ITEM_MESH && a->material.base_color[3] == 1) return 2; // Then all the transparent meshes. if (a->type == ITEM_MESH && a->material.base_color[3] < 1) return 4; // Then the grids. if (a->type == ITEM_GRID) return 5; // Then all the rest. return 10; } static int item_sort_cmp(const render_item_t *a, const render_item_t *b) { return cmp(item_sort_value(a), item_sort_value(b)); } static void render_shadow_map(renderer_t *rend, float shadow_mvp[4][4]) { render_item_t *item; float rect[6], light_dir[3]; int effects; // Create a renderer looking at the scene from the light. compute_shadow_map_box(rend, rect); float bias_mat[4][4] = {{0.5, 0.0, 0.0, 0.0}, {0.0, 0.5, 0.0, 0.0}, {0.0, 0.0, 0.5, 0.0}, {0.5, 0.5, 0.5, 1.0}}; float ret[4][4]; renderer_t srend = {}; get_light_dir(rend, light_dir); mat4_lookat(srend.view_mat, light_dir, VEC(0, 0, 0), VEC(0, 1, 0)); mat4_ortho(srend.proj_mat, rect[0], rect[1], rect[2], rect[3], rect[4], rect[5]); // Generate the depth buffer. if (!g_shadow_map_fbo) { GL(glGenFramebuffers(1, &g_shadow_map_fbo)); GL(glBindFramebuffer(GL_FRAMEBUFFER, g_shadow_map_fbo)); #ifndef GLES2 GL(glDrawBuffer(GL_NONE)); GL(glReadBuffer(GL_NONE)); #endif g_shadow_map = texture_new_surface(2048, 2048, 0); GL(glBindTexture(GL_TEXTURE_2D, g_shadow_map->tex)); GL(glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 2048, 2048, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0)); GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, g_shadow_map->tex, 0)); } GL(glBindFramebuffer(GL_FRAMEBUFFER, g_shadow_map_fbo)); GL(glViewport(0, 0, 2048, 2048)); GL(glClear(GL_DEPTH_BUFFER_BIT)); DL_FOREACH(rend->items, item) { if (item->type == ITEM_MESH) { effects = (item->effects & EFFECT_MARCHING_CUBES); effects |= EFFECT_SHADOW_MAP; render_mesh_(&srend, item->mesh, &item->material, effects, NULL); } } mat4_copy(bias_mat, ret); mat4_imul(ret, srend.proj_mat); mat4_imul(ret, srend.view_mat); mat4_copy(ret, shadow_mvp); } static void render_background(renderer_t *rend, const uint8_t col[4]) { gl_shader_t *shader; typedef struct { int8_t pos[3] __attribute__((aligned(4))); float color[4] __attribute__((aligned(4))); } vertex_t; vertex_t vertices[4]; float c1[4], c2[4]; if (!col || col[3] == 0) { GL(glClearColor(0, 0, 0, 0)); GL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); return; } GL(glClear(GL_DEPTH_BUFFER_BIT)); // Add a small gradient to the color. vec4_set(c1, col[0] / 255., col[1] / 255., col[2] / 255., col[3] / 255.); vec4_set(c2, col[0] / 255., col[1] / 255., col[2] / 255., col[3] / 255.); vec3_iadd(c1, VEC(+0.2, +0.2, +0.2)); vec3_iadd(c2, VEC(-0.2, -0.2, -0.2)); vertices[0] = (vertex_t){{-1, -1, 0}, {c1[0], c1[1], c1[2], c1[3]}}; vertices[1] = (vertex_t){{+1, -1, 0}, {c1[0], c1[1], c1[2], c1[3]}}; vertices[2] = (vertex_t){{+1, +1, 0}, {c2[0], c2[1], c2[2], c2[3]}}; vertices[3] = (vertex_t){{-1, +1, 0}, {c2[0], c2[1], c2[2], c2[3]}}; shader = shader_get("background", NULL, ATTR_NAMES, shader_init); GL(glUseProgram(shader->prog)); GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_index_buffer)); GL(glBindBuffer(GL_ARRAY_BUFFER, g_background_array_buffer)); GL(glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_DYNAMIC_DRAW)); GL(glEnableVertexAttribArray(0)); GL(glVertexAttribPointer(0, 3, GL_BYTE, false, sizeof(vertex_t), (void*)(intptr_t)offsetof(vertex_t, pos))); GL(glEnableVertexAttribArray(4)); GL(glVertexAttribPointer(4, 4, GL_FLOAT, false, sizeof(vertex_t), (void*)(intptr_t)offsetof(vertex_t, color))); GL(glDepthMask(false)); GL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0)); GL(glDepthMask(true)); } void render_submit(renderer_t *rend, const float viewport[4], const uint8_t clear_color[4]) { render_item_t *item, *tmp; float shadow_mvp[4][4]; const float s = rend->scale; bool shadow = rend->settings.shadow && !(rend->settings.effects & (EFFECT_RENDER_POS | EFFECT_SHADOW_MAP)); if (shadow) { GL(glDisable(GL_SCISSOR_TEST)); render_shadow_map(rend, shadow_mvp); } GL(glBindFramebuffer(GL_FRAMEBUFFER, rend->fbo)); GL(glEnable(GL_SCISSOR_TEST)); GL(glViewport(viewport[0] * s, viewport[1] * s, viewport[2] * s, viewport[3] * s)); GL(glScissor(viewport[0] * s, viewport[1] * s, viewport[2] * s, viewport[3] * s)); GL(glLineWidth(rend->scale)); render_background(rend, clear_color); DL_SORT(rend->items, item_sort_cmp); DL_FOREACH_SAFE(rend->items, item, tmp) { switch (item->type) { case ITEM_MESH: render_mesh_(rend, item->mesh, &item->material, item->effects, shadow_mvp); mesh_delete(item->mesh); break; case ITEM_MODEL3D: render_model_item(rend, item, viewport); break; case ITEM_GRID: render_grid_item(rend, item); break; default: assert(false); } DL_DELETE(rend->items, item); texture_delete(item->tex); free(item); } assert(rend->items == NULL); } void render_on_low_memory(renderer_t *rend) { cache_clear(g_items_cache); } goxel-0.11.0/src/render.h000066400000000000000000000076701435762723100151520ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef RENDER_H #define RENDER_H #include #include enum { EFFECT_RENDER_POS = 1 << 1, EFFECT_BORDERS = 1 << 3, EFFECT_SEMI_TRANSPARENT = 1 << 5, EFFECT_SEE_BACK = 1 << 6, EFFECT_MARCHING_CUBES = 1 << 7, EFFECT_SHADOW_MAP = 1 << 8, EFFECT_MC_SMOOTH = 1 << 9, // For render box. EFFECT_NO_SHADING = 1 << 10, EFFECT_STRIP = 1 << 11, EFFECT_WIREFRAME = 1 << 12, EFFECT_GRID = 1 << 13, EFFECT_EDGES = 1 << 14, EFFECT_GRID_ONLY = 1 << 15, EFFECT_PROJ_SCREEN = 1 << 16, // Image project in screen. EFFECT_ANTIALIASING = 1 << 17, EFFECT_UNLIT = 1 << 18, }; typedef struct { float ambient; float smoothness; float shadow; int effects; float occlusion_strength; } render_settings_t; typedef struct renderer renderer_t; typedef struct render_item_t render_item_t; struct renderer { float view_mat[4][4]; float proj_mat[4][4]; int fbo; // The renderer target framebuffer. float scale; // For retina display. struct { float pitch; float yaw; bool fixed; // If set, then the light moves with the view. float intensity; } light; render_settings_t settings; render_item_t *items; }; void render_init(void); void render_deinit(void); void render_mesh(renderer_t *rend, const mesh_t *mesh, const material_t *material, int effects); void render_grid(renderer_t *rend, const float plane[4][4], const uint8_t color[4], const float clip_box[4][4]); void render_line(renderer_t *rend, const float a[3], const float b[3], const uint8_t color[4], int effects); void render_box(renderer_t *rend, const float box[4][4], const uint8_t color[4], int effects); void render_sphere(renderer_t *rend, const float mat[4][4]); void render_img(renderer_t *rend, texture_t *tex, const float mat[4][4], int efffects); /* * Function: render_img2 * Render an image directly from it's pixel data. * * XXX: this is experimental: eventually I think we should remove render_img * and only user render_img2 (renamed to render_img). */ void render_img2(renderer_t *rend, const uint8_t *data, int w, int h, int bpp, const float mat[4][4], int effects); void render_rect(renderer_t *rend, const float plane[4][4], int effects); // Flushes all the queued render items. Actually calls opengl. // rect: the viewport rect (passed to glViewport). // clear_color: clear the screen with this first. void render_submit(renderer_t *rend, const float viewport[4], const uint8_t clear_color[4]); // Compute the light direction in the model coordinates (toward the light) void render_get_light_dir(const renderer_t *rend, float out[3]); // Ugly function that return the position of the block at a given id // when the mesh is rendered with render_mesh. void render_get_block_pos(renderer_t *rend, const mesh_t *mesh, int id, int pos[3]); // Attempt to release some memory. void render_on_low_memory(renderer_t *rend); #endif // RENDER_H goxel-0.11.0/src/shader_cache.c000066400000000000000000000046611435762723100162540ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "shader_cache.h" typedef struct { char key[256]; gl_shader_t *shader; } shader_t; static shader_t g_shaders[16] = {}; gl_shader_t *shader_get(const char *name, const shader_define_t *defines, const char **attr_names, void (*on_created)(gl_shader_t *s)) { int i; shader_t *s = NULL; const char *code; char key[256]; char path[128]; char pre[256] = {}; const shader_define_t *define; // Create the key of the form: // _define1_define2 strcpy(key, name); for (define = defines; define && define->name; define++) { if (define->set) { strcat(key, "_"); strcat(key, define->name); } } for (i = 0; i < ARRAY_SIZE(g_shaders); i++) { s = &g_shaders[i]; if (!*s->key) break; if (strcmp(s->key, key) == 0) return s->shader; } assert(i < ARRAY_SIZE(g_shaders)); strcpy(s->key, key); sprintf(path, "asset://data/shaders/%s.glsl", name); code = assets_get(path, NULL); assert(code); for (define = defines; define && define->name; define++) { if (define->set) sprintf(pre + strlen(pre), "#define %s\n", define->name); } s->shader = gl_shader_create(code, code, pre, attr_names); if (on_created) on_created(s->shader); return s->shader; } /* * Function: shaders_release_all * Remove all the shaders from the cache. */ void shaders_release_all(void) { int i; shader_t *s = NULL; for (i = 0; i < ARRAY_SIZE(g_shaders); i++) { s = &g_shaders[i]; if (!*s->key) break; gl_shader_delete(s->shader); memset(s, 0, sizeof(*s)); } } goxel-0.11.0/src/shader_cache.h000066400000000000000000000031571435762723100162600ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef SHADER_CACHE_H #define SHADER_CACHE_H #include "goxel.h" typedef struct { const char *name; bool set; } shader_define_t; /* * Function: shader_get * Retreive a cached shader * * Probably need to change this api soon. * * Properties: * name - Name of one of the shaders in the resources. * defines - Array of , terminated by an empty one. * Can be NULL. * attr_names - NULL terminated list of attribute names that will be binded. * on_created - If set, called the first time the shader has been created. */ gl_shader_t *shader_get(const char *name, const shader_define_t *defines, const char **attr_names, void (*on_created)(gl_shader_t *s)); /* * Function: shaders_release_all * Remove all the shaders from the cache. */ void shaders_release_all(void); #endif // SHADER_CACHE goxel-0.11.0/src/shape.c000066400000000000000000000063221435762723100147570ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "shape.h" #include static float min(float x, float y) { return x < y ? x : y; } static float max(float x, float y) { return x > y ? x : y; } static float max3(float x, float y, float z) { return max(x, max(y, z)); } static float vec2_norm(const float v[static 2]) { return sqrt(v[0] * v[0] + v[1] * v[1]); } static float vec3_norm(const float v[static 3]) { return sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); } #define VEC(...) ((float[]){__VA_ARGS__}) shape_t shape_sphere; shape_t shape_cube; shape_t shape_cylinder; static float sphere_func(const float p[3], const float s[3], float smoothness) { float d = vec3_norm(p); float r; if (p[0] == 0 && p[1] == 0 && p[2] == 0) return max3(s[0], s[1], s[2]); r = s[0] * s[1] * s[2] / vec3_norm(VEC(s[1] * s[2] * p[0] / d, s[0] * s[2] * p[1] / d, s[0] * s[1] * p[2] / d)); return r - d; } static float cube_func(const float p[3], const float s[3], float sm) { int i; float min_v = INFINITY; float ret = INFINITY, v; // Check if we are outside the max cube: if (p[0] < -s[0] - sm || p[0] >= +s[0] + sm || p[1] < -s[1] - sm || p[1] >= +s[1] + sm || p[2] < -s[2] - sm || p[2] >= +s[2] + sm) return -INFINITY; // Or inside the min cube: if (p[0] >= -s[0] + sm && p[0] < +s[0] - sm && p[1] >= -s[1] + sm && p[1] < +s[1] - sm && p[2] >= -s[2] + sm && p[2] < +s[2] - sm) return +INFINITY; for (i = 0; i < 3; i++) { if (p[i]) { v = s[i] / fabs(p[i]); if (v < min_v) { min_v = v; ret = s[i] - fabs(p[i]); } } } return ret; } static float cylinder_func(const float p[3], const float s[3], float smoothness) { float d = vec2_norm(p); float rz, r; rz = s[2] - fabs(p[2]); if (p[0] == 0 && p[1] == 0) return min(rz, max3(s[0], s[1], s[2])); // Ellipse polar form relative to center: // r(θ) = a b / √((b cosΘ)² + (a sinΘ)²) r = s[0] * s[1] / vec2_norm(VEC(s[1] * p[0] / d, s[0] * p[1] / d)); return min(rz, r - d); } void shapes_init(void) { shape_sphere = (shape_t){ .id = "sphere", .func = sphere_func, }; shape_cube = (shape_t){ .id = "cube", .func = cube_func, }; shape_cylinder = (shape_t){ .id = "cylinder", .func = cylinder_func, }; } goxel-0.11.0/src/shape.h000066400000000000000000000021541435762723100147630ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* * Define the 3d shape we can use for the mesh operations. * * TODO: need to explain how that works. */ #ifndef SHAPE_H #define SHAPE_H typedef struct shape { const char *id; float (*func)(const float p[3], const float s[3], float smoothness); } shape_t; void shapes_init(void); extern shape_t shape_sphere; extern shape_t shape_cube; extern shape_t shape_cylinder; #endif // SHAPE_H goxel-0.11.0/src/system.c000066400000000000000000000165021435762723100152040ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "system.h" #include "noc_file_dialog.h" #include #include #include #include #include #include #ifndef PATH_MAX #define PATH_MAX 1024 #endif // The global system instance. sys_callbacks_t sys_callbacks = {}; #if defined(__unix__) && !defined(__EMSCRIPTEN__) && !defined(ANDROID) #define NOC_FILE_DIALOG_GTK #define NOC_FILE_DIALOG_IMPLEMENTATION #include "noc_file_dialog.h" #include #include static const char *get_user_dir(void *user) { static char ret[PATH_MAX] = ""; const char *home; if (!*ret) { home = getenv("XDG_CONFIG_HOME"); if (home) { snprintf(ret, sizeof(ret), "%s/goxel", home); } else { home = getenv("HOME"); if (!home) home = getpwuid(getuid())->pw_dir; snprintf(ret, sizeof(ret), "%s/.config/goxel", home); } } return ret; } static const char *get_clipboard_text(void* user) { GtkClipboard *cb; static gchar *text = NULL; gtk_init_check(NULL, NULL); g_free(text); cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); text = gtk_clipboard_wait_for_text(cb); return text; } static void set_clipboard_text(void *user, const char *text) { GtkClipboard *cb; gtk_init_check(NULL, NULL); cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); gtk_clipboard_set_can_store(cb, NULL, 0); gtk_clipboard_set_text(cb, text, -1); gtk_clipboard_store(cb); } static void init_unix(void) __attribute__((constructor)); static void init_unix(void) { sys_callbacks.get_user_dir = get_user_dir; sys_callbacks.get_clipboard_text = get_clipboard_text; sys_callbacks.set_clipboard_text = set_clipboard_text; } #endif #ifdef WIN32 #define NOC_FILE_DIALOG_WIN32 #define NOC_FILE_DIALOG_IMPLEMENTATION #include "noc_file_dialog.h" // Defined in utils. int utf_16_to_8(const wchar_t *in16, char *out8, size_t size8); // On mingw mkdir takes only one argument! #define mkdir(p, m) mkdir(p) const char *get_user_dir(void *user) { static char ret[MAX_PATH * 3 + 128] = {0}; wchar_t knownpath_16[MAX_PATH]; HRESULT hResult; if (!ret[0]) { hResult = SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, knownpath_16); if (hResult == S_OK) { utf_16_to_8(knownpath_16, ret, MAX_PATH * 3); strcat(ret, "\\Goxel\\"); } } return ret; } static void init_win(void) __attribute__((constructor)); static void init_win(void) { sys_callbacks.get_user_dir = get_user_dir; } #endif #ifdef __APPLE__ #include #if TARGET_OS_MAC const char *sys_get_save_path(const char *filters, const char *default_name) { return noc_file_dialog_open(NOC_FILE_DIALOG_SAVE, filters, NULL, default_name); } void sys_on_saved(const char *path) { LOG_I("Saved %s", path); } #endif #endif void sys_log(const char *msg) { if (sys_callbacks.log) { sys_callbacks.log(sys_callbacks.user, msg); } else { printf("%s\n", msg); fflush(stdout); } } // List all the files in a directory. int sys_list_dir(const char *dirpath, int (*callback)(const char *dirpath, const char *name, void *user), void *user) { DIR *dir; struct dirent *dirent; dir = opendir(dirpath); if (!dir) return -1; while ((dirent = readdir(dir))) { if (dirent->d_name[0] == '.') continue; if (callback(dirpath, dirent->d_name, user) != 0) break; } closedir(dir); return 0; } int sys_delete_file(const char *path) { return remove(path); } double sys_get_time(void) { struct timeval now; gettimeofday(&now, NULL); return (double)now.tv_sec + now.tv_usec / 1000000.0; } int sys_make_dir(const char *path) { char tmp[PATH_MAX]; char *p; strcpy(tmp, path); for (p = tmp + 1; *p; p++) { if (*p != '/') continue; *p = '\0'; if ((mkdir(tmp, S_IRWXU) != 0) && (errno != EEXIST)) return -1; *p = '/'; } return 0; } int sys_get_screen_framebuffer(void) { return 0; } void sys_set_window_title(const char *title) { static char buf[1024] = {}; if (strcmp(buf, title) == 0) return; snprintf(buf, sizeof(buf), "%s", title); if (sys_callbacks.set_window_title) sys_callbacks.set_window_title(sys_callbacks.user, title); } /* * Function: sys_get_user_dir * Return the user config directory for goxel * * On linux, this should be $HOME/.config/goxel. */ const char *sys_get_user_dir(void) { if (sys_callbacks.get_user_dir) return sys_callbacks.get_user_dir(sys_callbacks.user); return NULL; } const char *sys_get_clipboard_text(void* user) { if (sys_callbacks.get_clipboard_text) return sys_callbacks.get_clipboard_text(sys_callbacks.user); return NULL; } void sys_set_clipboard_text(void *user, const char *text) { if (sys_callbacks.set_clipboard_text) sys_callbacks.set_clipboard_text(sys_callbacks.user, text); } /* * Function: sys_show_keyboard * Show a virtual keyboard if needed. */ void sys_show_keyboard(bool has_text) { if (!sys_callbacks.show_keyboard) return; sys_callbacks.show_keyboard(sys_callbacks.user, has_text); } /* * Function: sys_save_to_photos * Save a png file to the system photo album. */ void sys_save_to_photos(const uint8_t *data, int size, void (*on_finished)(int r)) { FILE *file; const char *path; size_t r; if (sys_callbacks.save_to_photos) return sys_callbacks.save_to_photos(sys_callbacks.user, data, size, on_finished); // Default implementation. path = noc_file_dialog_open(NOC_FILE_DIALOG_SAVE, "png\0*.png\0", NULL, "untitled.png"); if (!path) { if (on_finished) on_finished(1); return; } file = fopen(path, "wb"); if (!file) { if (on_finished) on_finished(-1); return; } r = fwrite(data, size, 1, file); fclose(file); if (on_finished) on_finished(r == size ? 0 : -1); } #ifdef NOC_FILE_DIALOG_IMPLEMENTATION const char *sys_get_save_path(const char *filters, const char *default_name) { return noc_file_dialog_open(NOC_FILE_DIALOG_SAVE, filters, NULL, default_name); } void sys_on_saved(const char *path) { LOG_I("Saved %s", path); } #endif #ifdef ANDROID const char *sys_get_save_path(const char *filters, const char *default_name) { return NULL; } void sys_on_saved(const char *path) { LOG_I("Saved %s", path); } #endif goxel-0.11.0/src/system.h000066400000000000000000000072711435762723100152140ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* * Section: System * Some system related functions. All the things that might depend on the * operating system, not relying on libc, should go there. */ #ifndef SYSTEM_H #define SYSTEM_H #include #include /* * Global structure that hold pointers to system functions. Need to be * set at init time. */ typedef struct { void *user; void (*log)(void *user, const char *msg); void (*set_window_title)(void *user, const char *title); const char *(*get_user_dir)(void *user); const char *(*get_clipboard_text)(void* user); void (*set_clipboard_text)(void *user, const char *text); void (*show_keyboard)(void *user, bool has_text); void (*save_to_photos)(void *user, const uint8_t *data, int size, void (*on_finished)(int r)); } sys_callbacks_t; extern sys_callbacks_t sys_callbacks; /* * Function: sys_log * Write a log message to output. * * Note: this should never be called directly, use the LOG_ macros instead. */ void sys_log(const char *msg); /* * Function: sys_list_dir * List all the files in a directory. * * Parameters: * dir - Path of the directory we want to list. * callback - Function called once per entry. * user - User data passed to the callback. * * Return: * The number of files found. */ int sys_list_dir(const char *dir, int (*callback)(const char *dir, const char *name, void *user), void *user); /* * Function: sys_delete_file * Delete a file from the system. */ int sys_delete_file(const char *path); /* * Function: sys_get_user_dir * Return the user config directory for goxel * * On linux, this should be $HOME/.config/goxel. */ const char *sys_get_user_dir(void); /* * Function: sys_make_dir * Create all the directories parent of a given file path if they do not * exist yet. * * For example, sys_make_dir("/a/b/c.txt") will create /a/ and /a/b/. */ int sys_make_dir(const char *path); const char *sys_get_clipboard_text(void* user); void sys_set_clipboard_text(void *user, const char *text); int sys_get_screen_framebuffer(void); /* * Function: sys_get_time * Return the unix time (seconds since Jan 01 1970). */ double sys_get_time(void); // Unix time. /* * Function: sys_set_window_title * Set the window title. */ void sys_set_window_title(const char *title); /* * Function: sys_show_keyboard * Show a virtual keyboard if needed. */ void sys_show_keyboard(bool has_text); /* * Function: sys_save_to_photo * Save a png file to the system photo album. */ void sys_save_to_photos(const uint8_t *data, int size, void (*on_finished)(int r)); /* * Function: sys_get_save_path * Get the path where to save an image. By default this opens a file dialog. */ const char *sys_get_save_path(const char *filters, const char *default_name); /* * Function: sys_on_saved * Called after we saved a file */ void sys_on_saved(const char *path); #endif // SYSTEM_H goxel-0.11.0/src/tests.c000066400000000000000000000135441435762723100150250ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "utils/b64.h" #define TEST(cond) \ do { \ if (!(cond)) { \ LOG_E("Test fail: %s (%s: %d)", __func__, __FILE__, __LINE__); \ exit(-1); \ } \ } while(0) static void test_file(const char *b64_data, uint32_t crc32) { FILE *file; size_t data_size; uint8_t *data; int err; if (DEFINED(WIN32)) return; // Don't test on Windows for the moment! data = calloc(b64_decode(b64_data, NULL), 1); data_size = b64_decode(b64_data, data); file = fopen("/tmp/goxel_test.gox", "w"); fwrite(data, data_size, 1, file); fclose(file); free(data); err = goxel_import_file("/tmp/goxel_test.gox", NULL); TEST(err == 0); TEST(mesh_crc32(goxel.image->active_layer->mesh) == crc32); image_delete(goxel.image); goxel.image = image_new(); } static void test_load_file_v2(void) { // Load a simple file. const char *b64_data = "R09YIAIAAABJTUcgAAAAAAAAAABCTDE2LAEAAIlQTkcNChoKAAAADUlIRFIA" "AABAAAAAQAgGAAAAqmlx3gAAAPNJREFUeF5j/A8EDAwMjAwUgO+MjP85//8n" "14z/A2k/E8MwABQEPgMjJAEwjFjAxDDCAROjyvf/lIYB43cVss0YaPuHRQr4" "z3mH7EJ8tAwY8WXAaACM9FpgNAWMpoCRHQKjLcHRMmC0DBgtA0Z0CIwWgqOF" "4GghOFoIjhaCIzkERmuB0VpgtBYYrQVGa4HRWmAEh8BoNThaDY5Wg6PV4Gg1" "OFoNjlaDIzcERtsBo+2A0XbAaDtgtB0w2g4YbQeMtgNGbAiMNoRGG0KjDaHR" "htBoQ2i0ITTaEBptCI02hEZqCIy2BEdbgqMtwdGW4GhLcCSHAACDDx/OAZLa" "WgAAAABJRU5ErkJgggAAAABMQVlSmgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAA" "AAAAAAQAAABuYW1lCgAAAGJhY2tncm91bmQDAAAAbWF0QAAAAAAAgD8AAAAA" "AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAA" "AAAAAAAAAAAAgD8CAAAAaWQEAAAAAQAAAAcAAABiYXNlX2lkBAAAAAAAAAAA" "AAAA"; test_file(b64_data, 0xc7c4c9ff); } static void test_load_file_v1_with_preview(void) { // Load a simple file in v1 of goxel format, with embedded preview, // as generated by the mobile version 0.7.1. const char *b64_data = "R09YIAEAAABJTUcgAAAAAAAAAABQUkVWPAUAAIlQTkcNChoKAAAADUlIRFIA" "AACAAAAAgAgGAAAAwz5hywAABQNJREFUeF5jGAWjITAaAqMhMBoCoyEwGgKj" "ITAaAqMhMBoCoyEwGgKjITAaAqMhMBoCoyEwGgKjITAaAqMhMBoCoyEwGgKj" "ITAaAqMhMBoCoyEwGgKjITAaAqMhMBoCoyEwGgKjITAaAqMhMBoCoyEwGgKj" "ITAaAqMhMBoCoyEwGgKjITAaAqMhMBoCoyEwGgKjITAaAqMhMBoCoyEwGgKj" "ITAaAqMhMBoCoyEwGgKjITAaAqMhMBoCoyEwGgKjITAaAqMhMBoCoyEwGgKj" "ITAaAqMhMBoCoyEwGgKjITAaAqMhMBoCoyEwGgKjITAaAqMhMBoCoyEwGgKj" "ITAaAqMhMDhCQIeNzT6Yi6t+ND5GYAhU8fPvP6Cl9R+EuyQl9yszMNgPx2Bg" "Hk3dqCGgxsRkP1dO7oG2sLACI1AKhGU4ORU8+PgSvv38yXD99++DwynMGEcT" "ACIEirm59/vJyztghAkjIphOvHt3YObz5w33GBiGRUIYLQGAsa0ELN5nAXO9" "kZiYAjjyQRGOjJFSBKg08BxGpcGITwAhvLz1TYqKC3g5ORkYYJGOpViEVQcg" "moWFhcFCUNBBg4XF4d6XLw/eMzA8HKolKdNIrwL+//7d8O7vX5RgQI5sGBuu" "AJpIOIAJhvHfPwdgADoM5TAc8Qng2Y8fDH137jAcef2agZmZmQGjUYSlOvj6" "5w/Dgrt3Gfa+fDnk8w8LwygAh8CWV68Yrn//zhAqLs4gyMGBNVQYgYnh2b9/" "DAtv3GD4O0zCbcT3AiwZGP4jxyWoURQhL8+gx8sLaQ9CJVnZ2BjWPXzIcPHt" "W5SoP83A4PBuCPcIRnwVwGdpiRKhoJy9FBjRix4/ZvgBbRt8BlYNfRcuYEQ+" "j74+w7sh3h0c8SWAj48PuAT4ePw4wx+03A2qCJxlZBgOP3mCkkjYgNUEj4EB" "A5uEBMPChQuHdBiOtgGgUcsPLAl+AxPAJ2BCgMX2DyBjDzDy2ZGiHxT5Qh4e" "DMMFjCYApJhkFRZmAFUJ327dwigNQMqE3N3BuZ5hGIERPxD09u3bA7Kysgmw" "OGXm4mLgkJUFc0FVAiuQxQks8vltbFAi//fv3wy7d+92+Pr168OhnB5G5wKg" "sWdpablfWFgYZVAHVCWwff7MIGRsjBLHL168OHDmzJkGYOIZ8vMBo3MB0Kh9" "8uTJQhATORGASgNeYGkAGiCCpYB79+4d2Ldvn+P3798fDoeaYDQBIMUiKEeD" "qgQuLi4FEAZJcQAHhUAJAFTk79q1y+H69euNDMMIjFYBOCITViXw8fExvHz5" "8sDevXsdGUbByAoBYHVgr6mpObokbDThj4bAaAiMhsBoCIyGwGgIjIbAaAiM" "hsBoCIyGwGgIjIbAaAiMhsBoCIyGwGgIjIbAaAiMhsBoCIyGwGgIjIbAaAiM" "hsBoCIyGwGgIjIbAaAiMhsBoCIyGwGgIjIbAaAiMhsBoCIyGwGgIjIbAaAiM" "hsBoCIyGwGgIjIbAaAiMhsBoCIyGwGgIjIbAaAiMhsBoCIyGwGgIjIbAaAiM" "hsBoCIyGwGgIjIbAaAiMhsBoCIyGwGgIjIbAaAiMhsBoCIyGwGgIjIbAaAiM" "hsBoCIyGwGgIjIbAaAiMhsBoCIyGwGgIjIbAaAiMhsBoCIyGwGgIjIbAaAiM" "hsBoCIyGwGgIjIbAaAiMhsBoCIyGwGgIjIbAaAiMhsBoCIyGwGgIkBgCADB4" "2BRvDISwAAAAAElFTkSuQmCCAAAAAEJMMTb1AAAAiVBORw0KGgoAAAANSUhE" "UgAAAEAAAABACAYAAACqaXHeAAAAvElEQVR4XmMYBaMhMBoCoyEwGgKjITAa" "AqMhMBoCoyEwGgKjITAaAqMhMBoCoyEwGgKjITAaAqMhMBoCoyEwGgKjITAa" "AqMhMBoCoyEwGgKjITAaAqMhMBoCIz0E/kMBueFAqf7RFDgaAqMhMLAhsI+B" "4T8Ik+sKSvWPxv9oCIyGwGgIjIbAaAiMhsBoCIyGwGgIjIbAaAiMhsBoCIyG" "wGgIjIbAaAiMhsBoCIyGwGgIjIbAaAiMhgCVQgAAwAEW5Yj9s+cAAAAASUVO" "RK5CYIIAAAAATEFZUpoAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAA" "bmFtZQoAAABiYWNrZ3JvdW5kAwAAAG1hdEAAAAAAAIA/AAAAAAAAAAAAAAAA" "AAAAAAAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAA" "AIA/AgAAAGlkBAAAAAEAAAAHAAAAYmFzZV9pZAQAAAAAAAAAAAAAAA=="; test_file(b64_data, 0xb5e8d973); } static void test_load_corrupt(void) { FILE *file; int err; if (DEFINED(WIN32)) return; // Don't test on Windows for the moment! file = fopen("/tmp/goxel_test.gox", "w"); fclose(file); err = goxel_import_file("/tmp/goxel_test.gox", NULL); TEST(err != 0); } void tests_run(void) { test_load_file_v2(); test_load_file_v1_with_preview(); test_load_corrupt(); } goxel-0.11.0/src/theme.c000066400000000000000000000151711435762723100147630ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include "utils/ini.h" #ifndef THEME_ITEM_HEIGHT # define THEME_ITEM_HEIGHT 18 #endif #ifndef THEME_ICON_HEIGHT # define THEME_ICON_HEIGHT 32 #endif theme_group_info_t THEME_GROUP_INFOS[THEME_GROUP_COUNT] = { [THEME_GROUP_BASE] = { .name = "base", .colors = { [THEME_COLOR_BACKGROUND] = true, [THEME_COLOR_OUTLINE] = true, [THEME_COLOR_INNER] = true, [THEME_COLOR_INNER_SELECTED] = true, [THEME_COLOR_TEXT] = true, [THEME_COLOR_TEXT_SELECTED] = true, }, }, [THEME_GROUP_WIDGET] = { .name = "widget", .parent = THEME_GROUP_BASE, .colors = { [THEME_COLOR_OUTLINE] = true, [THEME_COLOR_INNER] = true, [THEME_COLOR_INNER_SELECTED] = true, [THEME_COLOR_TEXT] = true, [THEME_COLOR_TEXT_SELECTED] = true, }, }, [THEME_GROUP_TAB] = { .name = "tab", .parent = THEME_GROUP_BASE, .colors = { [THEME_COLOR_BACKGROUND] = true, [THEME_COLOR_INNER] = true, [THEME_COLOR_INNER_SELECTED] = true, [THEME_COLOR_TEXT] = true, [THEME_COLOR_TEXT_SELECTED] = true, }, }, [THEME_GROUP_MENU] = { .name = "menu", .parent = THEME_GROUP_BASE, .colors = { [THEME_COLOR_BACKGROUND] = true, [THEME_COLOR_INNER] = true, [THEME_COLOR_TEXT] = true, }, }, }; theme_color_info_t THEME_COLOR_INFOS[THEME_COLOR_COUNT] = { [THEME_COLOR_BACKGROUND] = {.name = "background"}, [THEME_COLOR_OUTLINE] = {.name = "outline"}, [THEME_COLOR_INNER] = {.name = "inner"}, [THEME_COLOR_INNER_SELECTED] = {.name = "inner_selected"}, [THEME_COLOR_TEXT] = {.name = "text"}, [THEME_COLOR_TEXT_SELECTED] = {.name = "text_selected"}, }; static theme_t g_base_theme = { .name = "Unnamed", .sizes = { .item_height = THEME_ITEM_HEIGHT, .icons_height = THEME_ICON_HEIGHT, .item_padding_h = 4, .item_rounding = 0, .item_spacing_h = 4, .item_spacing_v = 4, .item_inner_spacing_h = 6, }, }; static theme_t *g_themes = NULL; // List of all the themes. static theme_t g_theme = {}; // Current theme. static uint32_t tohex(const uint8_t c[4]) { return (int)c[0] << 24 | (int)c[1] << 16 | (int)c[2] << 8 | (int)c[3] << 0; } static void parse_color(const char *s, uint8_t out[4]) { uint32_t v; v = strtoul(s + 1, NULL, 16); out[0] = (v >> 24) & 0xff; out[1] = (v >> 16) & 0xff; out[2] = (v >> 8) & 0xff; out[3] = (v >> 0) & 0xff; } static int theme_ini_handler(void *user, const char *section, const char *name, const char *value, int lineno) { theme_t *theme = user; int group, i; if (strcmp(section, "theme") == 0) { if (strcmp(name, "name") == 0) strncpy(theme->name, value, sizeof(theme->name) - 1); } for (group = 0; group < THEME_GROUP_COUNT; group++) { if (strcmp(section, THEME_GROUP_INFOS[group].name) != 0) continue; for (i = 0; i < THEME_COLOR_COUNT; i++) { if (strcmp(name, THEME_COLOR_INFOS[i].name) == 0) { parse_color(value, theme->groups[group].colors[i]); } } } return 0; } static int on_theme(int i, const char *path, void *user) { const char *data; theme_t *theme = calloc(1, sizeof(*theme)); *theme = g_base_theme; data = assets_get(path, NULL); ini_parse_string(data, theme_ini_handler, theme); DL_APPEND(g_themes, theme); if (strcmp(theme->name, GOXEL_DEFAULT_THEME) == 0) g_theme = *theme; return 0; } static int on_theme2(const char *dir, const char *name, void *user) { char *data, *path; asprintf(&path, "%s/%s", dir, name); theme_t *theme = calloc(1, sizeof(*theme)); *theme = g_base_theme; data = read_file(path, NULL); ini_parse_string(data, theme_ini_handler, theme); DL_APPEND(g_themes, theme); free(path); free(data); return 0; } static void themes_init(void) { // Load all the themes. char *dir; assets_list("data/themes/", NULL, on_theme); asprintf(&dir, "%s/themes", sys_get_user_dir()); sys_list_dir(dir, on_theme2, NULL); free(dir); } theme_t *theme_get(void) { if (!g_themes) themes_init(); return &g_theme; } theme_t *theme_get_list(void) { if (!g_themes) themes_init(); return g_themes; } void theme_set(const char *name) { theme_t *theme; if (!g_themes) themes_init(); DL_FOREACH(g_themes, theme) { if (strcmp(theme->name, name) == 0) g_theme = *theme; } } void theme_revert_default(void) { theme_t *theme; DL_FOREACH(g_themes, theme) { if (strcmp(theme->name, "default") == 0) g_theme = *theme; } } void theme_save(void) { char *path; FILE *file; const theme_t *t = &g_theme; int group, i; asprintf(&path, "%s/themes/default.ini", sys_get_user_dir()); sys_make_dir(path); file = fopen(path, "w"); fprintf(file, "[sizes]\n"); #define X(n) \ fprintf(file, #n "=%d\n", t->sizes.n); THEME_SIZES(X) #undef X for (group = 0; group < THEME_GROUP_COUNT; group++) { fprintf(file, "\n"); fprintf(file, "[%s]\n", THEME_GROUP_INFOS[group].name); for (i = 0; i < THEME_COLOR_COUNT; i++) { if (!t->groups[group].colors[i][3]) continue; fprintf(file, "%s=#%X\n", THEME_COLOR_INFOS[i].name, tohex( t->groups[group].colors[i])); } } fclose(file); free(path); } void theme_get_color(int g, int color, bool sel, uint8_t out[4]) { const theme_t *theme = theme_get(); if (sel) color++; while (g && !theme->groups[g].colors[color][3]) g = THEME_GROUP_INFOS[g].parent; memcpy(out, theme->groups[g].colors[color], 4); } goxel-0.11.0/src/theme.h000066400000000000000000000067261435762723100147760ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef THEME_H #define THEME_H #include #include /* * Section: Theme * * Theme structures and functions used to set goxel ui colors. * The theme is split into groups representing different part of the gui: * the widgets, the tab, the menus, etc. * * For each group we can specify a set of colors: * - Background * - Outline * - Inner * - Inner selected * - Text * - Text selected * * If a color is not set in a group, we can get it from its parent group. * * The theme also keep track of the item sizes, but this is not supposed to * be editable so the code is a bit different. */ /* * Enum: THEME_GROUP * Enum all the theme elements groups. */ enum { THEME_GROUP_BASE, THEME_GROUP_WIDGET, THEME_GROUP_TAB, THEME_GROUP_MENU, THEME_GROUP_COUNT }; /* * Enum: THEME_COLOR * Enum of all the theme colors. */ enum { THEME_COLOR_BACKGROUND, THEME_COLOR_OUTLINE, THEME_COLOR_INNER, THEME_COLOR_INNER_SELECTED, THEME_COLOR_TEXT, THEME_COLOR_TEXT_SELECTED, THEME_COLOR_COUNT }; /* * Type: theme_group_info_t * Informations about a given theme group, that can be used for a theme * editor. * * Attributes: * name - Name of this group (id). * parent - Index of the parent group. * colors - Bool array of all the colors we can set in this group. */ typedef struct { const char *name; int parent; bool colors[THEME_COLOR_COUNT]; } theme_group_info_t; extern theme_group_info_t THEME_GROUP_INFOS[THEME_GROUP_COUNT]; /* * Type: theme_color_info_t * Informations about a given theme color type, that can be used for a theme * editor. * * Attributes: * name - Name of this color (id). */ typedef struct { const char *name; } theme_color_info_t; extern theme_color_info_t THEME_COLOR_INFOS[THEME_COLOR_COUNT]; /* * Type: theme_group_t * Contains all the colors set for a given group. */ typedef struct { uint8_t colors[THEME_COLOR_COUNT][4]; } theme_group_t; /* * Macro: THEME_SIZES * X macro to list all the themes size attributes. */ #define THEME_SIZES(X) \ X(item_height) \ X(icons_height) \ X(item_padding_h) \ X(item_rounding) \ X(item_spacing_h) \ X(item_spacing_v) \ X(item_inner_spacing_h) typedef struct theme theme_t; struct theme { char name[64]; struct { #define X(attr) int attr; THEME_SIZES(X) #undef X } sizes; theme_group_t groups[THEME_GROUP_COUNT]; theme_t *prev, *next; // Global list of themes. }; // Return the current theme. theme_t *theme_get(void); theme_t *theme_get_list(void); void theme_revert_default(void); void theme_save(void); void theme_get_color(int group, int color, bool selected, uint8_t out[4]); void theme_set(const char *name); #endif // THEME_H goxel-0.11.0/src/tools.c000066400000000000000000000156061435762723100150240ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" static const tool_t *g_tools[TOOL_COUNT] = {}; static void a_tool_set(void *data) { if (goxel.tool_mesh) { mesh_delete(goxel.tool_mesh); goxel.tool_mesh = NULL; } goxel.tool = (tool_t*)data; } void tool_register_(tool_t *tool) { action_t action; action = (action_t) { .id = tool->action_id, .default_shortcut = tool->default_shortcut, .help = "set tool", .cfunc_data = a_tool_set, .data = (void*)tool, .flags = ACTION_CAN_EDIT_SHORTCUT, }; action_register(&action, tool->action_idx); g_tools[tool->id] = tool; } const tool_t *tool_get(int id) { return g_tools[id]; } static int pick_color_gesture(gesture3d_t *gest, void *user) { cursor_t *curs = &goxel.cursor; const mesh_t *mesh = goxel_get_layers_mesh(goxel.image); int pi[3] = {floor(curs->pos[0]), floor(curs->pos[1]), floor(curs->pos[2])}; uint8_t color[4]; curs->snap_mask = SNAP_MESH; curs->snap_offset = -0.5; goxel_set_help_text("Click on a voxel to pick the color"); if (!curs->snaped) return 0; mesh_get_at(mesh, NULL, pi, color); color[3] = 255; goxel_set_help_text("pick: %d %d %d", color[0], color[1], color[2]); if (curs->flags & CURSOR_PRESSED) vec4_copy(color, goxel.painter.color); return 0; } static gesture3d_t g_pick_color_gesture = { .type = GESTURE_HOVER, .callback = pick_color_gesture, .buttons = CURSOR_CTRL, }; int tool_iter(tool_t *tool, const painter_t *painter, const float viewport[4]) { assert(tool); if ( (tool->flags & TOOL_REQUIRE_CAN_EDIT) && !image_layer_can_edit(goxel.image, goxel.image->active_layer)) { goxel_set_help_text("Cannot edit this layer"); return 0; } tool->state = tool->iter_fn(tool, painter, viewport); if (tool->flags & TOOL_ALLOW_PICK_COLOR) gesture3d(&g_pick_color_gesture, &goxel.cursor, NULL); return tool->state; } int tool_gui(tool_t *tool) { if (!tool->gui_fn) return 0; return tool->gui_fn(tool); } static bool snap_button(const char *label, int s, float w) { bool v = goxel.snap_mask & s; if (gui_selectable(label, &v, NULL, w)) { set_flag(&goxel.snap_mask, s, v); return true; } return false; } int tool_gui_snap(void) { float w, v; gui_text("Snap on"); w = gui_get_avail_width() / 2.0 - 1; gui_group_begin(NULL); snap_button("Mesh", SNAP_MESH, w); gui_same_line(); snap_button("Plane", SNAP_PLANE, w); if (!box_is_null(goxel.selection)) { snap_button("Sel In", SNAP_SELECTION_IN, w); gui_same_line(); snap_button("Sel out", SNAP_SELECTION_OUT, w); } if (!box_is_null(goxel.image->box)) snap_button("Image box", SNAP_IMAGE_BOX, -1); v = goxel.snap_offset; if (gui_input_float("Offset", &v, 0.1, -1, +1, "%.1f")) goxel.snap_offset = clamp(v, -1, +1); gui_group_end(); return 0; } static bool mask_mode_button(const char *label, int s, float w) { bool v = goxel.mask_mode == s; if (gui_selectable(label, &v, NULL, w)) { goxel.mask_mode = s; return true; } return false; } int tool_gui_mask_mode(void) { float w; gui_text("Mask"); w = gui_get_avail_width() / 3.0 - 1; gui_group_begin(NULL); mask_mode_button("Set", MODE_REPLACE, w); gui_same_line(); mask_mode_button("Add", MODE_OVER, w); gui_same_line(); mask_mode_button("Sub", MODE_SUB, w); gui_group_end(); return 0; } // XXX: replace this. static void auto_grid(int nb, int i, int col) { if ((i + 1) % col != 0) gui_same_line(); } int tool_gui_shape(const shape_t **shape) { struct { const char *name; shape_t *shape; int icon; } shapes[] = { {"Sphere", &shape_sphere, ICON_SHAPE_SPHERE}, {"Cube", &shape_cube, ICON_SHAPE_CUBE}, {"Cylinder", &shape_cylinder, ICON_SHAPE_CYLINDER}, }; shape = shape ?: &goxel.painter.shape; int i, ret = 0; bool v; gui_text("Shape"); gui_group_begin(NULL); for (i = 0; i < (int)ARRAY_SIZE(shapes); i++) { v = *shape == shapes[i].shape; if (gui_selectable_icon(shapes[i].name, &v, shapes[i].icon)) { *shape = shapes[i].shape; ret = 1; } auto_grid(ARRAY_SIZE(shapes), i, 4); } gui_group_end(); return ret; } int tool_gui_radius(void) { int i; i = goxel.tool_radius * 2; if (gui_input_int("Size", &i, 1, 128)) { i = clamp(i, 1, 128); goxel.tool_radius = i / 2.0; } return 0; } int tool_gui_smoothness(void) { bool s; s = goxel.painter.smoothness; if (gui_checkbox("Antialiased", &s, NULL)) { goxel.painter.smoothness = s ? 1 : 0; } return 0; } int tool_gui_color(void) { float alpha; gui_color_small("Color", goxel.painter.color); if (goxel.painter.mode == MODE_PAINT) { alpha = goxel.painter.color[3] / 255.; if (gui_input_float("Alpha", &alpha, 0.1, 0, 1, "%.1f")) goxel.painter.color[3] = alpha * 255; } return 0; } int tool_gui_symmetry(void) { float w; int i; bool v; const char *labels_u[] = {"X", "Y", "Z"}; const char *labels_l[] = {"x", "y", "z"}; w = gui_get_avail_width() / 3.0 - 1; gui_group_begin("Symmetry"); for (i = 0; i < 3; i++) { v = (goxel.painter.symmetry >> i) & 0x1; if (gui_selectable(labels_u[i], &v, NULL, w)) set_flag(&goxel.painter.symmetry, 1 << i, v); if (i < 2) gui_same_line(); } for (i = 0; i < 3; i++) { gui_input_float(labels_l[i], &goxel.painter.symmetry_origin[i], 0.5, -FLT_MAX, +FLT_MAX, "%.1f"); } gui_group_end(); return 0; } int tool_gui_drag_mode(int *mode) { float w; int ret = 0; bool b; w = gui_get_avail_width() / 2.0 - 1; gui_group_begin("Drag mode"); b = *mode == 0; if (gui_selectable("Move", &b, NULL, w)) { *mode = 0; ret = 1; } gui_same_line(); b = *mode == 1; if (gui_selectable("Resize", &b, NULL, w)) { *mode = 1; ret = 1; } gui_group_end(); return ret; } goxel-0.11.0/src/tools.h000066400000000000000000000050701435762723100150230ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef TOOLS_H #define TOOLS_H #include "shape.h" #include "mesh_utils.h" enum { TOOL_NONE = 0, TOOL_BRUSH, TOOL_SHAPE, TOOL_LINE, TOOL_LASER, TOOL_SET_PLANE, TOOL_MOVE, TOOL_PICK_COLOR, TOOL_SELECTION, TOOL_PROCEDURAL, TOOL_EXTRUDE, TOOL_FUZZY_SELECT, TOOL_COUNT }; enum { // Tools flags. TOOL_REQUIRE_CAN_EDIT = 1 << 0, // Set to tools that can edit the layer. TOOL_REQUIRE_CAN_MOVE = 1 << 1, // Set to tools that can move the layer. TOOL_ALLOW_PICK_COLOR = 1 << 2, // Ctrl switches to pick color tool. TOOL_SHOW_MASK = 1 << 3, }; // Tools typedef struct tool tool_t; struct tool { int id; const char *action_id; int action_idx; int (*iter_fn)(tool_t *tool, const painter_t *painter, const float viewport[4]); int (*gui_fn)(tool_t *tool); const char *default_shortcut; int state; // XXX: to be removed I guess. int flags; const char *name; }; #define TOOL_REGISTER(id_, name_, klass_, ...) \ static klass_ GOX_tool_##id_ = {\ .tool = { \ .action_idx = ACTION_tool_set_##name_, \ .id = id_, .action_id = "tool_set_" #name_, __VA_ARGS__ \ } \ }; \ static void GOX_register_tool_##tool_(void) __attribute__((constructor)); \ static void GOX_register_tool_##tool_(void) { \ tool_register_(&GOX_tool_##id_.tool); \ } void tool_register_(tool_t *tool); const tool_t *tool_get(int id); int tool_iter(tool_t *tool, const painter_t *painter, const float viewport[4]); int tool_gui(tool_t *tool); int tool_gui_snap(void); int tool_gui_mask_mode(void); int tool_gui_shape(const shape_t **shape); int tool_gui_radius(void); int tool_gui_smoothness(void); int tool_gui_color(void); int tool_gui_symmetry(void); int tool_gui_drag_mode(int *mode); #endif // TOOLS_H goxel-0.11.0/src/tools/000077500000000000000000000000001435762723100146505ustar00rootroot00000000000000goxel-0.11.0/src/tools/brush.c000066400000000000000000000171651435762723100161510ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" typedef struct { tool_t tool; mesh_t *mesh_orig; // Original mesh. mesh_t *mesh; // Mesh containing only the tool path. // Gesture start and last pos (should we put it in the 3d gesture?) float start_pos[3]; float last_pos[3]; // Cache of the last operation. // XXX: could we remove this? struct { float pos[3]; bool pressed; int mode; uint64_t mesh_key; } last_op; struct { gesture3d_t drag; gesture3d_t hover; } gestures; } tool_brush_t; static bool check_can_skip(tool_brush_t *brush, const cursor_t *curs, int mode) { mesh_t *mesh = goxel.tool_mesh; const bool pressed = curs->flags & CURSOR_PRESSED; if ( pressed == brush->last_op.pressed && mode == brush->last_op.mode && brush->last_op.mesh_key == mesh_get_key(mesh) && vec3_equal(curs->pos, brush->last_op.pos)) { return true; } brush->last_op.pressed = pressed; brush->last_op.mode = mode; brush->last_op.mesh_key = mesh_get_key(mesh); vec3_copy(curs->pos, brush->last_op.pos); return false; } static void get_box(const float p0[3], const float p1[3], const float n[3], float r, const float plane[4][4], float out[4][4]) { float rot[4][4], box[4][4]; float v[3]; if (p1 == NULL) { bbox_from_extents(box, p0, r, r, r); box_swap_axis(box, 2, 0, 1, box); mat4_copy(box, out); return; } if (r == 0) { bbox_from_points(box, p0, p1); bbox_grow(box, 0.5, 0.5, 0.5, box); // Apply the plane rotation. mat4_copy(plane, rot); vec4_set(rot[3], 0, 0, 0, 1); mat4_imul(box, rot); mat4_copy(box, out); return; } // Create a box for a line: int i; const float AXES[][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; mat4_set_identity(box); vec3_mix(p0, p1, 0.5, box[3]); vec3_sub(p1, box[3], box[2]); for (i = 0; i < 3; i++) { vec3_cross(box[2], AXES[i], box[0]); if (vec3_norm2(box[0]) > 0) break; } if (i == 3) { mat4_copy(box, out); return; } vec3_normalize(box[0], v); vec3_mul(v, r, box[0]); vec3_cross(box[2], box[0], v); vec3_normalize(v, v); vec3_mul(v, r, box[1]); mat4_copy(box, out); } static int on_drag(gesture3d_t *gest, void *user) { tool_brush_t *brush = USER_GET(user, 0); painter_t painter = *(painter_t*)USER_GET(user, 1); float box[4][4]; cursor_t *curs = gest->cursor; bool shift = curs->flags & CURSOR_SHIFT; float r = goxel.tool_radius; int nb, i; float pos[3]; if (gest->state == GESTURE_BEGIN) { mesh_set(brush->mesh_orig, goxel.image->active_layer->mesh); brush->last_op.mode = 0; // Discard last op. vec3_copy(curs->pos, brush->last_pos); image_history_push(goxel.image); mesh_clear(brush->mesh); if (shift) { painter.shape = &shape_cylinder; painter.mode = MODE_MAX; vec4_set(painter.color, 255, 255, 255, 255); get_box(brush->start_pos, curs->pos, curs->normal, r, NULL, box); mesh_op(brush->mesh, &painter, box); } } painter = *(painter_t*)USER_GET(user, 1); if ( (gest->state == GESTURE_UPDATE) && (check_can_skip(brush, curs, painter.mode))) { return 0; } painter.mode = MODE_MAX; vec4_set(painter.color, 255, 255, 255, 255); // Render several times if the space between the current pos // and the last pos is larger than the size of the tool shape. nb = ceil(vec3_dist(curs->pos, brush->last_pos) / (2 * r)); nb = max(nb, 1); for (i = 0; i < nb; i++) { vec3_mix(brush->last_pos, curs->pos, (i + 1.0) / nb, pos); get_box(pos, NULL, curs->normal, r, NULL, box); mesh_op(brush->mesh, &painter, box); } painter = *(painter_t*)USER_GET(user, 1); if (!goxel.tool_mesh) goxel.tool_mesh = mesh_new(); mesh_set(goxel.tool_mesh, brush->mesh_orig); mesh_merge(goxel.tool_mesh, brush->mesh, painter.mode, painter.color); vec3_copy(curs->pos, brush->start_pos); brush->last_op.mesh_key = mesh_get_key(goxel.tool_mesh); if (gest->state == GESTURE_END) { mesh_set(goxel.image->active_layer->mesh, goxel.tool_mesh); mesh_set(brush->mesh_orig, goxel.tool_mesh); mesh_delete(goxel.tool_mesh); goxel.tool_mesh = NULL; } vec3_copy(curs->pos, brush->last_pos); return 0; } static int on_hover(gesture3d_t *gest, void *user) { mesh_t *mesh = goxel.image->active_layer->mesh; tool_brush_t *brush = USER_GET(user, 0); const painter_t *painter = USER_GET(user, 1); cursor_t *curs = gest->cursor; float box[4][4]; bool shift = curs->flags & CURSOR_SHIFT; if (gest->state == GESTURE_END || !curs->snaped) { mesh_delete(goxel.tool_mesh); goxel.tool_mesh = NULL; return 0; } if (shift) render_line(&goxel.rend, brush->start_pos, curs->pos, NULL, 0); if (goxel.tool_mesh && check_can_skip(brush, curs, painter->mode)) return 0; get_box(curs->pos, NULL, curs->normal, goxel.tool_radius, NULL, box); if (!goxel.tool_mesh) goxel.tool_mesh = mesh_new(); mesh_set(goxel.tool_mesh, mesh); mesh_op(goxel.tool_mesh, painter, box); brush->last_op.mesh_key = mesh_get_key(mesh); return 0; } static int iter(tool_t *tool, const painter_t *painter, const float viewport[4]) { tool_brush_t *brush = (tool_brush_t*)tool; cursor_t *curs = &goxel.cursor; // XXX: for the moment we force rounded positions for the brush tool // to make things easier. curs->snap_mask |= SNAP_ROUNDED; if (!brush->mesh_orig) brush->mesh_orig = mesh_copy(goxel.image->active_layer->mesh); if (!brush->mesh) brush->mesh = mesh_new(); if (!brush->gestures.drag.type) { brush->gestures.drag = (gesture3d_t) { .type = GESTURE_DRAG, .callback = on_drag, }; brush->gestures.hover = (gesture3d_t) { .type = GESTURE_HOVER, .callback = on_hover, }; } curs->snap_offset = goxel.snap_offset * goxel.tool_radius + ((painter->mode == MODE_OVER) ? 0.5 : -0.5); gesture3d(&brush->gestures.hover, curs, USER_PASS(brush, painter)); gesture3d(&brush->gestures.drag, curs, USER_PASS(brush, painter)); return tool->state; } static int gui(tool_t *tool) { tool_gui_color(); tool_gui_radius(); tool_gui_smoothness(); tool_gui_snap(); tool_gui_shape(NULL); tool_gui_symmetry(); return 0; } TOOL_REGISTER(TOOL_BRUSH, brush, tool_brush_t, .name = "Brush", .iter_fn = iter, .gui_fn = gui, .flags = TOOL_REQUIRE_CAN_EDIT | TOOL_ALLOW_PICK_COLOR, .default_shortcut = "B" ) goxel-0.11.0/src/tools/color_picker.c000066400000000000000000000034451435762723100174750ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" typedef struct { tool_t tool; } tool_pick_color_t; int tool_color_picker_iter(tool_t *tool, const painter_t *painter, const float viewport[4]) { uint8_t color[4]; const mesh_t *mesh = goxel_get_layers_mesh(goxel.image); cursor_t *curs = &goxel.cursor; int pi[3] = {floor(curs->pos[0]), floor(curs->pos[1]), floor(curs->pos[2])}; curs->snap_mask = SNAP_MESH; curs->snap_offset = -0.5; goxel_set_help_text("Click on a voxel to pick the color"); if (!curs->snaped) return 0; mesh_get_at(mesh, NULL, pi, color); color[3] = 255; goxel_set_help_text("%d %d %d", color[0], color[1], color[2]); if (curs->flags & CURSOR_PRESSED) vec4_copy(color, goxel.painter.color); return 0; } static int gui(tool_t *tool) { tool_gui_color(); return 0; } TOOL_REGISTER(TOOL_PICK_COLOR, pick_color, tool_pick_color_t, .name = "Color Picker", .iter_fn = tool_color_picker_iter, .gui_fn = gui, .default_shortcut = "C", ) goxel-0.11.0/src/tools/extrude.c000066400000000000000000000132061435762723100164760ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" typedef struct { tool_t tool; mesh_t *mesh_orig; mesh_t *mesh; int snap_face; int last_delta; struct { gesture3d_t drag; } gestures; } tool_extrude_t; static int select_cond(void *user, const mesh_t *mesh, const int base_pos[3], const int new_pos[3], mesh_accessor_t *mesh_accessor) { int snap_face = *((int*)user); int p[3], n[3]; // Only consider voxel in the snap plane. memcpy(n, FACES_NORMALS[snap_face], sizeof(n)); p[0] = new_pos[0] - base_pos[0]; p[1] = new_pos[1] - base_pos[1]; p[2] = new_pos[2] - base_pos[2]; if (p[0] * n[0] + p[1] * n[1] + p[2] * n[2]) return 0; // Also ignore if the face is not visible. p[0] = new_pos[0] + FACES_NORMALS[snap_face][0]; p[1] = new_pos[1] + FACES_NORMALS[snap_face][1]; p[2] = new_pos[2] + FACES_NORMALS[snap_face][2]; if (mesh_get_alpha_at(mesh, mesh_accessor, p)) return 0; return 255; } // Get the face index from the normal. // XXX: used in a few other places! static int get_face(const float n[3]) { int f; const int *n2; for (f = 0; f < 6; f++) { n2 = FACES_NORMALS[f]; if (vec3_dot(n, VEC(n2[0], n2[1], n2[2])) > 0.5) return f; } return -1; } // XXX: this code is just too ugly. Needs a lot of cleanup. // The problem is that we should use some generic functions to handle // box resize, since we do it a lot, and the code is never very clear. static int on_drag(gesture3d_t *gest, void *user) { tool_extrude_t *tool = (tool_extrude_t*)user; mesh_t *mesh = goxel.image->active_layer->mesh; mesh_t *tmp_mesh; cursor_t *curs = gest->cursor; float face_plane[4][4]; float n[3], pos[3], v[3], box[4][4]; int pi[3]; float delta; if (gest->state == GESTURE_BEGIN) { tool->snap_face = get_face(curs->normal); tmp_mesh = mesh_new(); tool->mesh = mesh_copy(mesh); pi[0] = floor(curs->pos[0]); pi[1] = floor(curs->pos[1]); pi[2] = floor(curs->pos[2]); mesh_select(mesh, pi, select_cond, &tool->snap_face, tmp_mesh); mesh_merge(tool->mesh, tmp_mesh, MODE_MULT_ALPHA, NULL); mesh_delete(tmp_mesh); mesh_set(tool->mesh_orig, mesh); image_history_push(goxel.image); // XXX: to remove: this is duplicated from selection tool. mesh_get_box(tool->mesh, true, box); mat4_mul(box, FACES_MATS[tool->snap_face], face_plane); vec3_normalize(face_plane[0], v); plane_from_vectors(goxel.tool_plane, curs->pos, curs->normal, v); tool->last_delta = 0; } mesh_get_box(tool->mesh, true, box); // XXX: have some generic way to resize boxes, since we use it all the // time! mat4_mul(box, FACES_MATS[tool->snap_face], face_plane); vec3_normalize(face_plane[2], n); // XXX: Is there a better way to compute the delta?? vec3_sub(curs->pos, goxel.tool_plane[3], v); vec3_project(v, n, v); delta = vec3_dot(n, v); // render_box(&goxel.rend, &box, NULL, EFFECT_WIREFRAME); // Skip if we didn't move. if (round(delta) == tool->last_delta) goto end; tool->last_delta = round(delta); vec3_sub(curs->pos, goxel.tool_plane[3], v); vec3_project(v, n, v); vec3_add(goxel.tool_plane[3], v, pos); pos[0] = round(pos[0]); pos[1] = round(pos[1]); pos[2] = round(pos[2]); mesh_set(mesh, tool->mesh_orig); tmp_mesh = mesh_copy(tool->mesh); if (delta >= 1) { vec3_iaddk(face_plane[3], n, -0.5); box_move_face(box, tool->snap_face, pos, box); mesh_extrude(tmp_mesh, face_plane, box); mesh_merge(mesh, tmp_mesh, MODE_OVER, NULL); } if (delta < 0.5) { box_move_face(box, FACES_OPPOSITES[tool->snap_face], pos, box); vec3_imul(face_plane[2], -1.0); vec3_iaddk(face_plane[3], n, -0.5); mesh_extrude(tmp_mesh, face_plane, box); mesh_merge(mesh, tmp_mesh, MODE_SUB, NULL); } mesh_delete(tmp_mesh); end: if (gest->state == GESTURE_END) { mesh_delete(tool->mesh); mat4_copy(plane_null, goxel.tool_plane); } return 0; } static int iter(tool_t *tool_, const painter_t *painter, const float viewport[4]) { tool_extrude_t *tool = (tool_extrude_t*)tool_; cursor_t *curs = &goxel.cursor; curs->snap_offset = -0.5; curs->snap_mask &= ~SNAP_ROUNDED; if (!tool->mesh_orig) tool->mesh_orig = mesh_new(); if (!tool->gestures.drag.type) { tool->gestures.drag = (gesture3d_t) { .type = GESTURE_DRAG, .callback = on_drag, }; } gesture3d(&tool->gestures.drag, curs, tool); return 0; } static int gui(tool_t *tool) { return 0; } TOOL_REGISTER(TOOL_EXTRUDE, extrude, tool_extrude_t, .name = "Extrude", .iter_fn = iter, .gui_fn = gui, .flags = TOOL_REQUIRE_CAN_EDIT, ) goxel-0.11.0/src/tools/fuzzy_select.c000066400000000000000000000077421435762723100175540ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" typedef struct { tool_t tool; int threshold; struct { gesture3d_t click; } gestures; } tool_fuzzy_select_t; static int select_cond(void *user, const mesh_t *mesh, const int base_pos[3], const int new_pos[3], mesh_accessor_t *mesh_accessor) { tool_fuzzy_select_t *tool = (void*)user; uint8_t v0[4], v1[4]; int d; mesh_get_at(mesh, mesh_accessor, base_pos, v0); mesh_get_at(mesh, mesh_accessor, new_pos, v1); if (!v0[3] || !v1[3]) return 0; d = max3(abs(v0[0] - v1[0]), abs(v0[1] - v1[1]), abs(v0[2] - v1[2])); return d <= tool->threshold ? 255 : 0; } static int on_click(gesture3d_t *gest, void *user) { mesh_t *mesh = goxel.image->active_layer->mesh; mesh_t *sel; int pi[3]; cursor_t *curs = gest->cursor; tool_fuzzy_select_t *tool = (void*)user; pi[0] = floor(curs->pos[0]); pi[1] = floor(curs->pos[1]); pi[2] = floor(curs->pos[2]); sel = mesh_new(); mesh_select(mesh, pi, select_cond, tool, sel); if (goxel.mask == NULL) goxel.mask = mesh_new(); mesh_merge(goxel.mask, sel, goxel.mask_mode ?: MODE_REPLACE, NULL); mesh_delete(sel); return 0; } static int iter(tool_t *tool_, const painter_t *painter, const float viewport[4]) { cursor_t *curs = &goxel.cursor; tool_fuzzy_select_t *tool = (void*)tool_; curs->snap_offset = -0.5; curs->snap_mask &= ~SNAP_ROUNDED; if (!tool->gestures.click.type) { tool->gestures.click = (gesture3d_t) { .type = GESTURE_CLICK, .callback = on_click, }; } gesture3d(&tool->gestures.click, curs, tool); return 0; } static layer_t *cut_as_new_layer(image_t *img, layer_t *layer, const mesh_t *mask) { layer_t *new_layer; new_layer = image_duplicate_layer(img, layer); mesh_merge(new_layer->mesh, mask, MODE_INTERSECT, NULL); mesh_merge(layer->mesh, mask, MODE_SUB, NULL); return new_layer; } static int gui(tool_t *tool_) { tool_fuzzy_select_t *tool = (void*)tool_; bool use_color = tool->threshold < 255; if (gui_checkbox("Use color", &use_color, "Stop at different color")) { tool->threshold = use_color ? 0 : 255; } if (use_color) { gui_input_int("Threshold", &tool->threshold, 1, 254); } tool_gui_mask_mode(); if (mesh_is_empty(goxel.mask)) return 0; mesh_t *mesh = goxel.image->active_layer->mesh; gui_group_begin(NULL); if (gui_button("Clear", 1, 0)) { image_history_push(goxel.image); mesh_merge(mesh, goxel.mask, MODE_SUB, NULL); } if (gui_button("Fill", 1, 0)) { image_history_push(goxel.image); mesh_merge(mesh, goxel.mask, MODE_OVER, goxel.painter.color); } if (gui_button("Cut as new layer", 1, 0)) { image_history_push(goxel.image); cut_as_new_layer(goxel.image, goxel.image->active_layer, goxel.mask); } gui_group_end(); return 0; } TOOL_REGISTER(TOOL_FUZZY_SELECT, fuzzy_select, tool_fuzzy_select_t, .name = "Fuzzy Select", .iter_fn = iter, .gui_fn = gui, .flags = TOOL_REQUIRE_CAN_EDIT | TOOL_SHOW_MASK, ) goxel-0.11.0/src/tools/laser.c000066400000000000000000000061671435762723100161340ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" typedef struct { tool_t tool; float box[4][4]; struct { gesture3d_t drag; gesture3d_t hover; } gestures; } tool_laser_t; static int on_drag(gesture3d_t *gest, void *user) { tool_laser_t *laser = (tool_laser_t*)USER_GET(user, 0); painter_t painter = *(painter_t*)USER_GET(user, 1); mesh_t *mesh = goxel.image->active_layer->mesh; painter.mode = MODE_SUB_CLAMP; painter.shape = &shape_cylinder; vec4_set(painter.color, 255, 255, 255, 255); if (gest->state == GESTURE_BEGIN) image_history_push(goxel.image); mesh_op(mesh, &painter, laser->box); return 0; } static int iter(tool_t *tool, const painter_t *painter, const float viewport[4]) { tool_laser_t *laser = (tool_laser_t*)tool; cursor_t *curs = &goxel.cursor; curs->snap_mask = SNAP_CAMERA; curs->snap_offset = 0; float v[4]; float view_mat_inv[4][4] = {}; camera_t *camera = goxel.image->active_camera; if (!laser->gestures.drag.type) { laser->gestures.drag = (gesture3d_t) { .type = GESTURE_DRAG, .callback = on_drag, }; } if (curs->snaped & SNAP_CAMERA) { // Create the tool box from the camera along the visible ray. mat4_set_identity(laser->box); mat4_invert(camera->view_mat, view_mat_inv); mat4_mul_vec4(view_mat_inv, VEC(1, 0, 0, 0), v); vec3_copy(v, laser->box[0]); mat4_mul_vec4(view_mat_inv, VEC(0, 1, 0, 0), v); vec3_copy(v, laser->box[1]); mat4_mul_vec4(view_mat_inv, VEC(0, 0, 1, 0), v); vec3_copy(v, laser->box[2]); vec3_neg(curs->normal, laser->box[2]); vec3_copy(curs->pos, laser->box[3]); // Just a large value for the size of the laser box. mat4_itranslate(laser->box, 0, 0, -1024); mat4_iscale(laser->box, goxel.tool_radius, goxel.tool_radius, 1024); render_box(&goxel.rend, laser->box, NULL, EFFECT_WIREFRAME); } gesture3d(&laser->gestures.drag, curs, USER_PASS(laser, painter)); return tool->state; } static int gui(tool_t *tool) { tool_gui_radius(); tool_gui_smoothness(); tool_gui_symmetry(); return 0; } TOOL_REGISTER(TOOL_LASER, laser, tool_laser_t, .name = "Laser", .iter_fn = iter, .gui_fn = gui, .flags = TOOL_REQUIRE_CAN_EDIT, .default_shortcut = "L", ) goxel-0.11.0/src/tools/line.c000066400000000000000000000126141435762723100157470ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" typedef struct { tool_t tool; mesh_t *mesh_orig; // Original mesh. mesh_t *mesh; // Mesh containing only the tool path. float start_pos[3]; struct { gesture3d_t drag; gesture3d_t hover; } gestures; } tool_line_t; // XXX: same as in brush.c. static void get_box(const float p0[3], const float p1[3], const float n[3], float r, const float plane[4][4], float out[4][4]) { float rot[4][4], box[4][4]; float v[3]; if (p1 && vec3_dist(p0, p1) < 0.5) p1 = NULL; if (p1 == NULL) { bbox_from_extents(box, p0, r, r, r); box_swap_axis(box, 2, 0, 1, box); mat4_copy(box, out); return; } if (r == 0) { bbox_from_points(box, p0, p1); bbox_grow(box, 0.5, 0.5, 0.5, box); // Apply the plane rotation. mat4_copy(plane, rot); vec4_set(rot[3], 0, 0, 0, 1); mat4_imul(box, rot); mat4_copy(box, out); return; } // Create a box for a line: int i; const float AXES[][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; mat4_set_identity(box); vec3_mix(p0, p1, 0.5, box[3]); vec3_sub(p1, box[3], box[2]); for (i = 0; i < 3; i++) { vec3_cross(box[2], AXES[i], box[0]); if (vec3_norm2(box[0]) > 0) break; } if (i == 3) { mat4_copy(box, out); return; } vec3_normalize(box[0], v); vec3_mul(v, r, box[0]); vec3_cross(box[2], box[0], v); vec3_normalize(v, v); vec3_mul(v, r, box[1]); mat4_copy(box, out); } static int on_drag(gesture3d_t *gest, void *user) { tool_line_t *tool = USER_GET(user, 0); painter_t painter; const float radius = goxel.tool_radius; cursor_t *curs = gest->cursor; float box[4][4]; if (gest->state == GESTURE_BEGIN) { vec3_copy(curs->pos, tool->start_pos); assert(tool->mesh_orig); mesh_set(tool->mesh_orig, goxel.image->active_layer->mesh); image_history_push(goxel.image); } painter = *(painter_t*)USER_GET(user, 1); painter.mode = MODE_MAX; vec4_set(painter.color, 255, 255, 255, 255); get_box(tool->start_pos, curs->pos, curs->normal, radius, NULL, box); mesh_clear(tool->mesh); mesh_op(tool->mesh, &painter, box); painter = *(painter_t*)USER_GET(user, 1); if (!goxel.tool_mesh) goxel.tool_mesh = mesh_new(); mesh_set(goxel.tool_mesh, tool->mesh_orig); mesh_merge(goxel.tool_mesh, tool->mesh, painter.mode, painter.color); if (gest->state == GESTURE_END) { mesh_set(goxel.image->active_layer->mesh, goxel.tool_mesh); mesh_set(tool->mesh_orig, goxel.tool_mesh); mesh_delete(goxel.tool_mesh); goxel.tool_mesh = NULL; } return 0; } static int on_hover(gesture3d_t *gest, void *user) { mesh_t *mesh = goxel.image->active_layer->mesh; const painter_t *painter = USER_GET(user, 1); cursor_t *curs = gest->cursor; float box[4][4]; if (gest->state == GESTURE_END) { mesh_delete(goxel.tool_mesh); goxel.tool_mesh = NULL; return 0; } get_box(curs->pos, NULL, curs->normal, goxel.tool_radius, NULL, box); if (!goxel.tool_mesh) goxel.tool_mesh = mesh_new(); mesh_set(goxel.tool_mesh, mesh); mesh_op(goxel.tool_mesh, painter, box); return 0; } static int iter(tool_t *tool_, const painter_t *painter, const float viewport[4]) { tool_line_t *tool = (void*)tool_; cursor_t *curs = &goxel.cursor; // XXX: for the moment we force rounded positions for the brush tool // to make things easier. curs->snap_mask |= SNAP_ROUNDED; if (!tool->mesh_orig) tool->mesh_orig = mesh_copy(goxel.image->active_layer->mesh); if (!tool->mesh) tool->mesh = mesh_new(); if (!tool->gestures.drag.type) { tool->gestures.drag = (gesture3d_t) { .type = GESTURE_DRAG, .callback = on_drag, }; tool->gestures.hover = (gesture3d_t) { .type = GESTURE_HOVER, .callback = on_hover, }; } curs->snap_offset = goxel.snap_offset * goxel.tool_radius + ((painter->mode == MODE_OVER) ? 0.5 : -0.5); gesture3d(&tool->gestures.hover, curs, USER_PASS(tool, painter)); gesture3d(&tool->gestures.drag, curs, USER_PASS(tool, painter)); return 0; } static int gui(tool_t *tool) { tool_gui_color(); tool_gui_radius(); tool_gui_smoothness(); tool_gui_snap(); tool_gui_shape(NULL); tool_gui_symmetry(); return 0; } TOOL_REGISTER(TOOL_LINE, line, tool_line_t, .name = "Line", .iter_fn = iter, .gui_fn = gui, .flags = TOOL_REQUIRE_CAN_EDIT | TOOL_ALLOW_PICK_COLOR, ) goxel-0.11.0/src/tools/move.c000066400000000000000000000073521435762723100157710ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" enum { DRAG_MOVE = 0, DRAG_RESIZE, }; typedef struct { tool_t tool; } tool_move_t; static void do_move(layer_t *layer, const float mat[4][4]) { float m[4][4] = MAT4_IDENTITY; if (mat4_equal(mat, mat4_identity)) return; // Change referential to the mesh origin. // XXX: maybe this should be done in mesh_move directy?? mat4_itranslate(m, -0.5, -0.5, -0.5); mat4_imul(m, mat); mat4_itranslate(m, +0.5, +0.5, +0.5); if (layer->base_id || layer->image || layer->shape) { mat4_mul(mat, layer->mat, layer->mat); layer->base_mesh_key = 0; } else { mesh_move(layer->mesh, m); if (!box_is_null(layer->box)) { mat4_mul(mat, layer->box, layer->box); box_get_bbox(layer->box, layer->box); } } } static int iter(tool_t *tool, const painter_t *painter, const float viewport[4]) { float transf[4][4]; bool first; layer_t *layer = goxel.image->active_layer; if (box_edit(SNAP_LAYER_OUT, goxel.tool_drag_mode, transf, &first)) { if (first) image_history_push(goxel.image); do_move(layer, transf); } return 0; } static int gui(tool_t *tool) { layer_t *layer; float mat[4][4] = MAT4_IDENTITY, v; int i; layer = goxel.image->active_layer; if (layer->shape) { tool_gui_drag_mode(&goxel.tool_drag_mode); } else { goxel.tool_drag_mode = DRAG_MOVE; } gui_group_begin(NULL); i = 0; if (gui_input_int("Move X", &i, 0, 0)) mat4_itranslate(mat, i, 0, 0); i = 0; if (gui_input_int("Move Y", &i, 0, 0)) mat4_itranslate(mat, 0, i, 0); i = 0; if (gui_input_int("Move Z", &i, 0, 0)) mat4_itranslate(mat, 0, 0, i); gui_group_end(); gui_group_begin(NULL); i = 0; if (gui_input_int("Rot X", &i, 0, 0)) mat4_irotate(mat, i * M_PI / 2, 1, 0, 0); i = 0; if (gui_input_int("Rot Y", &i, 0, 0)) mat4_irotate(mat, i * M_PI / 2, 0, 1, 0); i = 0; if (gui_input_int("Rot Z", &i, 0, 0)) mat4_irotate(mat, i * M_PI / 2, 0, 0, 1); gui_group_end(); if (layer->image && gui_input_int("Scale", &i, 0, 0)) { v = pow(2, i); mat4_iscale(mat, v, v, v); } gui_group_begin(NULL); if (gui_button("flip X", -1, 0)) mat4_iscale(mat, -1, 1, 1); if (gui_button("flip Y", -1, 0)) mat4_iscale(mat, 1, -1, 1); if (gui_button("flip Z", -1, 0)) mat4_iscale(mat, 1, 1, -1); gui_group_end(); gui_group_begin(NULL); if (gui_button("Scale up", -1, 0)) mat4_iscale(mat, 2, 2, 2); if (gui_button("Scale down", -1, 0)) mat4_iscale(mat, 0.5, 0.5, 0.5); gui_group_end(); if (memcmp(&mat, &mat4_identity, sizeof(mat))) { image_history_push(goxel.image); do_move(layer, mat); } return 0; } TOOL_REGISTER(TOOL_MOVE, move, tool_move_t, .name = "Move", .iter_fn = iter, .gui_fn = gui, .flags = TOOL_REQUIRE_CAN_MOVE, .default_shortcut = "M", ) goxel-0.11.0/src/tools/plane.c000066400000000000000000000101621435762723100161130ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017-2022 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" typedef struct { tool_t tool; int move_mode; } tool_plane_t; static int iter(tool_t *tool, const painter_t *painter, const float viewport[4]) { cursor_t *curs = &goxel.cursor; curs->snap_mask = SNAP_MESH; curs->snap_offset = 0; goxel_set_help_text("Click on the mesh to set plane."); if (curs->snaped && (curs->flags & CURSOR_PRESSED)) { curs->pos[0] = round(curs->pos[0]); curs->pos[1] = round(curs->pos[1]); curs->pos[2] = round(curs->pos[2]); plane_from_normal(goxel.plane, curs->pos, curs->normal); mat4_itranslate(goxel.plane, 0, 0, -1); goxel.snap_mask |= SNAP_PLANE; } return 0; } static void mat4_apply_quat(float mat[4][4], const float quat[4]) { float rot[3][3]; int i, j; quat_to_mat3(quat, rot); for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) mat[i][j] = rot[i][j]; } /* * Algo provided by sariug * Note: we could probably make it much faster by checking the mesh blocks * first instead of the voxels. */ static void cut(bool above) { const uint8_t color[4] = {0, 0, 0, 0}; int vp[3]; float p[3], p_vec[3], d; mesh_t *mesh = goxel.image->active_layer->mesh; mesh_iterator_t iter; mesh_accessor_t accessor; image_history_push(goxel.image); iter = mesh_get_iterator(mesh, MESH_ITER_VOXELS | MESH_ITER_SKIP_EMPTY); accessor = mesh_get_accessor(mesh); while (mesh_iter(&iter, vp)) { vec3_set(p, vp[0] + 0.5, vp[1] + 0.5, vp[2] + 0.5); vec3_sub(p, goxel.plane[3], p_vec); vec3_normalize(p_vec, p_vec); d = vec3_dot(p_vec, goxel.plane[2]) * (above ? +1 : -1); if (d > 0) mesh_set_at(mesh, &accessor, vp, color); } } static int gui(tool_t *tool_) { int i; bool v; float rot[3][3]; float quat[4]; tool_plane_t *tool = (tool_plane_t*)tool_; v = goxel.snap_mask & SNAP_PLANE; if (gui_checkbox("Visible", &v, NULL)) { set_flag(&goxel.snap_mask, SNAP_PLANE, v); } gui_combo("Move", &tool->move_mode, (const char*[]) { "Relative", "Absolute"}, 2); switch (tool->move_mode) { case 0: gui_group_begin(NULL); i = 0; if (gui_input_int("Move", &i, 0, 0)) mat4_itranslate(goxel.plane, 0, 0, -i); i = 0; if (gui_input_int("Rot X", &i, 0, 0)) mat4_irotate(goxel.plane, i * M_PI / 2, 1, 0, 0); i = 0; if (gui_input_int("Rot Y", &i, 0, 0)) mat4_irotate(goxel.plane, i * M_PI / 2, 0, 1, 0); gui_group_end(); break; case 1: gui_group_begin("Origin"); gui_input_float("X", &goxel.plane[3][0], 1.0, 0, 0, NULL); gui_input_float("Y", &goxel.plane[3][1], 1.0, 0, 0, NULL); gui_input_float("Z", &goxel.plane[3][2], 1.0, 0, 0, NULL); gui_group_end(); mat4_to_mat3(goxel.plane, rot); mat3_to_quat(rot, quat); if (gui_quat("Rotation", quat)) { mat4_apply_quat(goxel.plane, quat); } break; } if (gui_button("Cut Above", 1, 0)) { cut(true); } if (gui_button("Cut Below", 1, 0)) { cut(false); } return 0; } TOOL_REGISTER(TOOL_SET_PLANE, plane, tool_plane_t, .name = "plane", .iter_fn = iter, .gui_fn = gui, .default_shortcut = "P" ) goxel-0.11.0/src/tools/selection.c000066400000000000000000000136661435762723100170150ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" enum { DRAG_RESIZE, DRAG_MOVE, }; static int g_drag_mode = 0; typedef struct { tool_t tool; int snap_face; float start_pos[3]; struct { gesture3d_t hover; gesture3d_t drag; } gestures; } tool_selection_t; static void get_box(const float p0[3], const float p1[3], const float n[3], float r, const float plane[4][4], float out[4][4]) { float rot[4][4], box[4][4]; float v[3]; if (p1 == NULL) { bbox_from_extents(box, p0, r, r, r); box_swap_axis(box, 2, 0, 1, box); mat4_copy(box, out); return; } if (r == 0) { bbox_from_points(box, p0, p1); bbox_grow(box, 0.5, 0.5, 0.5, box); // Apply the plane rotation. mat4_copy(plane, rot); vec4_set(rot[3], 0, 0, 0, 1); mat4_imul(box, rot); mat4_copy(box, out); return; } // Create a box for a line: int i; const float AXES[][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; mat4_set_identity(box); vec3_mix(p0, p1, 0.5, box[3]); vec3_sub(p1, box[3], box[2]); for (i = 0; i < 3; i++) { vec3_cross(box[2], AXES[i], box[0]); if (vec3_norm2(box[0]) > 0) break; } if (i == 3) { mat4_copy(box, out); return; } vec3_normalize(box[0], v); vec3_mul(v, r, box[0]); vec3_cross(box[2], box[0], v); vec3_normalize(v, v); vec3_mul(v, r, box[1]); mat4_copy(box, out); } static int on_hover(gesture3d_t *gest, void *user) { float box[4][4]; cursor_t *curs = gest->cursor; uint8_t box_color[4] = {255, 255, 0, 255}; goxel_set_help_text("Click and drag to set selection."); get_box(curs->pos, curs->pos, curs->normal, 0, goxel.plane, box); render_box(&goxel.rend, box, box_color, EFFECT_WIREFRAME); return 0; } static int on_drag(gesture3d_t *gest, void *user) { tool_selection_t *tool = user; cursor_t *curs = gest->cursor; if (gest->state == GESTURE_BEGIN) vec3_copy(curs->pos, tool->start_pos); curs->snap_mask &= ~(SNAP_SELECTION_IN | SNAP_SELECTION_OUT); goxel_set_help_text("Drag."); get_box(tool->start_pos, curs->pos, curs->normal, 0, goxel.plane, goxel.selection); return 0; } // XXX: this is very close to tool_shape_iter. static int iter(tool_t *tool, const painter_t *painter, const float viewport[4]) { float transf[4][4]; tool_selection_t *selection = (tool_selection_t*)tool; cursor_t *curs = &goxel.cursor; curs->snap_mask |= SNAP_ROUNDED; curs->snap_mask &= ~(SNAP_SELECTION_IN | SNAP_SELECTION_OUT); curs->snap_offset = 0.5; curs->snap_mask |= SNAP_SELECTION_OUT; if (!selection->gestures.drag.type) { selection->gestures.hover = (gesture3d_t) { .type = GESTURE_HOVER, .callback = on_hover, }; selection->gestures.drag = (gesture3d_t) { .type = GESTURE_DRAG, .callback = on_drag, }; } if (box_edit(SNAP_SELECTION_OUT, g_drag_mode == DRAG_RESIZE ? 1 : 0, transf, NULL)) { mat4_mul(transf, goxel.selection, goxel.selection); return 0; } if (gesture3d(&selection->gestures.drag, curs, selection)) goto end; if (gesture3d(&selection->gestures.hover, curs, selection)) goto end; end: return tool->state; } static float get_magnitude(float box[4][4], int axis_index) { return box[0][axis_index] + box[1][axis_index] + box[2][axis_index]; } static int gui(tool_t *tool) { float x_mag, y_mag, z_mag; int x, y, z, w, h, d; float (*box)[4][4] = &goxel.selection; if (box_is_null(*box)) return 0; gui_text("Drag mode"); gui_combo("##drag_mode", &g_drag_mode, (const char*[]) {"Resize", "Move"}, 2); gui_group_begin(NULL); if (gui_action_button(ACTION_reset_selection, "Reset", 1.0)) { gui_group_end(); return 0; } gui_action_button(ACTION_fill_selection, "Fill", 1.0); gui_action_button(ACTION_layer_clear, "Clear", 1.0); gui_action_button(ACTION_add_selection, "Add", 0.5); gui_same_line(); gui_action_button(ACTION_sub_selection, "Sub", 1.0); gui_action_button(ACTION_cut_as_new_layer, "Cut as new layer", 1.0); gui_group_end(); x_mag = fabs(get_magnitude(*box, 0)); y_mag = fabs(get_magnitude(*box, 1)); z_mag = fabs(get_magnitude(*box, 2)); w = round(x_mag * 2); h = round(y_mag * 2); d = round(z_mag * 2); x = round((*box)[3][0] - x_mag); y = round((*box)[3][1] - y_mag); z = round((*box)[3][2] - z_mag); gui_group_begin("Origin"); gui_input_int("x", &x, 0, 0); gui_input_int("y", &y, 0, 0); gui_input_int("z", &z, 0, 0); gui_group_end(); gui_group_begin("Size"); gui_input_int("w", &w, 1, 2048); gui_input_int("h", &h, 1, 2048); gui_input_int("d", &d, 1, 2048); gui_group_end(); bbox_from_extents(*box, VEC(x + w / 2., y + h / 2., z + d / 2.), w / 2., h / 2., d / 2.); return 0; } TOOL_REGISTER(TOOL_SELECTION, selection, tool_selection_t, .name = "Selection", .iter_fn = iter, .gui_fn = gui, .default_shortcut = "R", .flags = TOOL_SHOW_MASK, ) goxel-0.11.0/src/tools/shape.c000066400000000000000000000102111435762723100161070ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017-2022 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" typedef struct { tool_t tool; float start_pos[3]; mesh_t *mesh_orig; bool planar; // Stay on the original plane. struct { gesture3d_t drag; gesture3d_t hover; } gestures; } tool_shape_t; static void get_box(const float p0[3], const float p1[3], const float n[3], float out[4][4]) { float box[4][4]; if (p1 == NULL) { bbox_from_extents(box, p0, 0, 0, 0); box_swap_axis(box, 2, 0, 1, box); mat4_copy(box, out); return; } bbox_from_points(box, p0, p1); bbox_grow(box, 0.5, 0.5, 0.5, box); mat4_copy(box, out); } static int on_hover(gesture3d_t *gest, void *user) { float box[4][4]; cursor_t *curs = gest->cursor; uint8_t box_color[4] = {255, 255, 0, 255}; goxel_set_help_text("Click and drag to draw."); get_box(curs->pos, curs->pos, curs->normal, box); render_box(&goxel.rend, box, box_color, EFFECT_WIREFRAME); return 0; } static int on_drag(gesture3d_t *gest, void *user) { tool_shape_t *shape = USER_GET(user, 0); const painter_t *painter = USER_GET(user, 1); mesh_t *layer_mesh = goxel.image->active_layer->mesh; float box[4][4], pos[3]; cursor_t *curs = gest->cursor; if (gest->state == GESTURE_BEGIN) { mesh_set(shape->mesh_orig, layer_mesh); vec3_copy(curs->pos, shape->start_pos); image_history_push(goxel.image); if (shape->planar) { vec3_addk(curs->pos, curs->normal, -curs->snap_offset, pos); plane_from_normal(goxel.tool_plane, pos, curs->normal); } } goxel_set_help_text("Drag."); get_box(shape->start_pos, curs->pos, curs->normal, box); if (!goxel.tool_mesh) goxel.tool_mesh = mesh_new(); mesh_set(goxel.tool_mesh, shape->mesh_orig); mesh_op(goxel.tool_mesh, painter, box); if (gest->state == GESTURE_END) { mesh_set(layer_mesh, goxel.tool_mesh); mesh_delete(goxel.tool_mesh); goxel.tool_mesh = NULL; mat4_copy(plane_null, goxel.tool_plane); } return 0; } static int iter(tool_t *tool, const painter_t *painter, const float viewport[4]) { tool_shape_t *shape = (tool_shape_t*)tool; cursor_t *curs = &goxel.cursor; curs->snap_mask |= SNAP_ROUNDED; curs->snap_offset = (painter->mode == MODE_OVER) ? 0.5 : -0.5; if (!shape->mesh_orig) shape->mesh_orig = mesh_copy(goxel.image->active_layer->mesh); if (!shape->gestures.drag.type) { shape->gestures.drag = (gesture3d_t) { .type = GESTURE_DRAG, .callback = on_drag, }; shape->gestures.hover = (gesture3d_t) { .type = GESTURE_HOVER, .callback = on_hover, }; } gesture3d(&shape->gestures.drag, curs, USER_PASS(shape, painter)); gesture3d(&shape->gestures.hover, curs, USER_PASS(shape, painter)); return tool->state; } static int gui(tool_t *tool) { tool_shape_t *tool_shape = (void*)tool; tool_gui_color(); tool_gui_smoothness(); gui_checkbox("Planar", &tool_shape->planar, "Stay on original plane"); tool_gui_snap(); tool_gui_shape(NULL); tool_gui_symmetry(); return 0; } TOOL_REGISTER(TOOL_SHAPE, shape, tool_shape_t, .name = "Shape", .iter_fn = iter, .gui_fn = gui, .flags = TOOL_REQUIRE_CAN_EDIT | TOOL_ALLOW_PICK_COLOR, .default_shortcut = "S", ) goxel-0.11.0/src/utils.c000066400000000000000000000124651435762723100150240ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" #include #include #include #include #include #ifndef LOG_TIME # define LOG_TIME 1 #endif static double get_log_time() { static double origin = 0; double time; time = sys_get_time(); if (!origin) origin = time; return time - origin; } void dolog(int level, const char *msg, const char *func, const char *file, int line, ...) { const bool use_colors = !DEFINED(__APPLE__) && !DEFINED(__EMSCRIPTEN__); char *msg_formatted, *full_msg; const char *format; char time_str[32] = ""; va_list args; va_start(args, line); vasprintf(&msg_formatted, msg, args); va_end(args); if (use_colors && level >= GOX_LOG_WARN) { format = "\e[33;31m%s%-60s\e[m %s (%s:%d)"; } else { format = "%s%-60s %s (%s:%d)"; } if (DEFINED(LOG_TIME)) sprintf(time_str, "%.3f: ", get_log_time()); file = file + max(0, (int)strlen(file) - 20); // Truncate file path. asprintf(&full_msg, format, time_str, msg_formatted, func, file, line); sys_log(full_msg); free(msg_formatted); free(full_msg); } double get_unix_time(void) { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec + tv.tv_usec / 1000.0 / 1000.0; } char *read_file(const char *path, int *size) { FILE *file; char *ret = NULL; long read_size __attribute__((unused)); int size_default; size = size ?: &size_default; // Allow to pass NULL as size; file = fopen(path, "rb"); if (!file) return NULL; fseek(file, 0, SEEK_END); *size = (int)ftell(file); fseek(file, 0, SEEK_SET); ret = malloc(*size + 1); read_size = fread(ret, *size, 1, file); assert(read_size == 1 || *size == 0); ret[*size] = '\0'; fclose(file); return ret; } bool str_endswith(const char *str, const char *end) { if (!str || !end) return false; if (strlen(str) < strlen(end)) return false; const char *start = str + strlen(str) - strlen(end); return strcmp(start, end) == 0; } bool str_startswith(const char *s1, const char *s2) { if (!s1 || !s2) return false; if (strlen(s1) < strlen(s2)) return false; return strncmp(s1, s2, strlen(s2)) == 0; } // Like gluUnproject. void unproject(const float win[3], const float model[4][4], const float proj[4][4], const float viewport[4], float out[3]) { float inv[4][4]; float p[4]; mat4_mul(proj, model, inv); mat4_invert(inv, inv); vec4_set(p, (win[0] - viewport[0]) / viewport[2] * 2 - 1, (win[1] - viewport[1]) / viewport[3] * 2 - 1, 2 * win[2] - 1, 1); mat4_mul_vec4(inv, p, p); if (p[3]) vec3_imul(p, 1 / p[3]); vec3_copy(p, out); } int unix_to_dtf(double t, int *iy, int *im, int *id, int *h, int *m, int *s) { time_t time = (int)t; struct tm *tm; tm = localtime(&time); if (!tm) return -1; *iy = tm->tm_year + 1900; *im = tm->tm_mon + 1; *id = tm->tm_mday; *h = tm->tm_hour; *m = tm->tm_min; *s = tm->tm_sec; return 0; } // From blender source code. int utf_16_to_8(const wchar_t *in16, char *out8, size_t size8) { char *out8end = out8 + size8; wchar_t u = 0; int err = 0; if (!size8 || !in16 || !out8) return -1; out8end--; for (; out8 < out8end && (u = *in16); in16++, out8++) { if (u < 0x0080) { *out8 = u; } else if (u < 0x0800) { if (out8 + 1 >= out8end) break; *out8++ = (0x3 << 6) | (0x1F & (u >> 6)); *out8 = (0x1 << 7) | (0x3F & (u)); } else if (u < 0xD800 || u >= 0xE000) { if (out8 + 2 >= out8end) break; *out8++ = (0x7 << 5) | (0xF & (u >> 12)); *out8++ = (0x1 << 7) | (0x3F & (u >> 6)); *out8 = (0x1 << 7) | (0x3F & (u)); } else if (u < 0xDC00) { wchar_t u2 = *++in16; if (!u2) break; if (u2 >= 0xDC00 && u2 < 0xE000) { if (out8 + 3 >= out8end) break; else { unsigned int uc = 0x10000 + (u2 - 0xDC00) + ((u - 0xD800) << 10); *out8++ = (0xF << 4) | (0x7 & (uc >> 18)); *out8++ = (0x1 << 7) | (0x3F & (uc >> 12)); *out8++ = (0x1 << 7) | (0x3F & (uc >> 6)); *out8 = (0x1 << 7) | (0x3F & (uc)); } } else { out8--; err = -1; } } else if (u < 0xE000) { out8--; err = -1; } } *out8 = *out8end = 0; if (*in16) err = -1; return err; } goxel-0.11.0/src/utils/000077500000000000000000000000001435762723100146505ustar00rootroot00000000000000goxel-0.11.0/src/utils/b64.c000066400000000000000000000041021435762723100154040ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "b64.h" #include #include /* Function: b64_decode * Decode a base64 string * * Parameters: * src - A base 64 encoded string. * dest - Buffer that will receive the decoded value or NULL. If set to * NULL the function just returns the size of the decoded data. * * Return: * The size of the decoded data. */ int b64_decode(const char *src, void *dest) { const char TABLE[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int len = strlen(src); uint8_t *p = dest; #define b64_value(c) ((strchr(TABLE, c) ?: TABLE) - TABLE) #define isbase64(c) (c && strchr(TABLE, c)) if (*src == 0) return 0; if (!p) return ((len + 3) / 4) * 3; do { char a = b64_value(src[0]); char b = b64_value(src[1]); char c = b64_value(src[2]); char d = b64_value(src[3]); *p++ = (a << 2) | (b >> 4); *p++ = (b << 4) | (c >> 2); *p++ = (c << 6) | d; if (!isbase64(src[1])) { p -= 2; break; } else if (!isbase64(src[2])) { p -= 2; break; } else if (!isbase64(src[3])) { p--; break; } src += 4; while (*src && (*src == 13 || *src == 10)) src++; } while (len -= 4); return p - (uint8_t*)dest; } goxel-0.11.0/src/utils/b64.h000066400000000000000000000020751435762723100154200ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* * Function: b64_decode * Decode a base64 string * * Parameters: * src - A base 64 encoded string. * dest - Buffer that will receive the decoded value or NULL. If set to * NULL the function just returns the size of the decoded data. * * Return: * The size of the decoded data. */ int b64_decode(const char *src, void *dest); goxel-0.11.0/src/utils/box.c000066400000000000000000000040661435762723100156120ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "utils/box.h" static bool box_intersect_box_(const float b1[4][4], const float b2[4][4]) { float inv[4][4], box[4][4], vertices[8][3]; int i, p; // The six planes equations: const int P[6][4] = { {-1, 0, 0, -1}, {1, 0, 0, -1}, {0, -1, 0, -1}, {0, 1, 0, -1}, {0, 0, -1, -1}, {0, 0, 1, -1} }; if (!mat4_invert(b1, inv)) return false; mat4_mul(inv, b2, box); box_get_vertices(box, vertices); for (p = 0; p < 6; p++) { for (i = 0; i < 8; i++) { if ( P[p][0] * vertices[i][0] + P[p][1] * vertices[i][1] + P[p][2] * vertices[i][2] + P[p][3] * 1 < 0) { break; } } if (i == 8) // All the points are outside a clipping plane. return false; } return true; } bool box_intersect_box(const float b1[4][4], const float b2[4][4]) { return box_intersect_box_(b1, b2) || box_intersect_box_(b2, b1); } void box_union(const float a[4][4], const float b[4][4], float out[4][4]) { float verts[16][3]; if (box_is_null(a)) { mat4_copy(b, out); return; } if (box_is_null(b)) { mat4_copy(a, out); return; } box_get_vertices(a, verts + 0); box_get_vertices(b, verts + 8); bbox_from_npoints(out, 16, verts); } goxel-0.11.0/src/utils/box.h000066400000000000000000000211401435762723100156070ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef BOX_H #define BOX_H #include "utils/vec.h" #include static float min(float x, float y) { return x < y ? x : y; } static float max(float x, float y) { return x > y ? x : y; } // A Box is represented as the 4x4 matrix that transforms the unit cube into // the box. static inline bool box_is_bbox(const float b[4][4]) { int i, j; for (i = 0; i < 3; i++) for (j = 0; j < 4; j++) { if (mat4_identity[i][j] == 0 && b[i][j] != 0) return false; } return true; } static inline void bbox_from_extents(float box[4][4], const float pos[3], float hw, float hh, float hd) { mat4_set_identity(box); vec3_copy(pos, box[3]); box[0][0] = hw; box[1][1] = hh; box[2][2] = hd; } static inline bool box_is_null(const float b[4][4]) { return b[3][3] == 0; } static inline void bbox_from_aabb(float box[4][4], const int aabb[2][3]) { const float pos[3] = {(aabb[1][0] + aabb[0][0]) / 2.f, (aabb[1][1] + aabb[0][1]) / 2.f, (aabb[1][2] + aabb[0][2]) / 2.f}; const float size[3] = {(float)(aabb[1][0] - aabb[0][0]), (float)(aabb[1][1] - aabb[0][1]), (float)(aabb[1][2] - aabb[0][2])}; bbox_from_extents(box, pos, size[0] / 2, size[1] / 2, size[2] / 2); } static inline void bbox_to_aabb(const float b[4][4], int aabb[2][3]) { aabb[0][0] = round(b[3][0] - b[0][0]); aabb[0][1] = round(b[3][1] - b[1][1]); aabb[0][2] = round(b[3][2] - b[2][2]); aabb[1][0] = round(b[3][0] + b[0][0]); aabb[1][1] = round(b[3][1] + b[1][1]); aabb[1][2] = round(b[3][2] + b[2][2]); } // XXX: remove? static inline void bbox_from_points( float box[4][4], const float a[3], const float b[3]) { float v0[3], v1[3], mid[3]; v0[0] = min(a[0], b[0]); v0[1] = min(a[1], b[1]); v0[2] = min(a[2], b[2]); v1[0] = max(a[0], b[0]); v1[1] = max(a[1], b[1]); v1[2] = max(a[2], b[2]); vec3_mix(v0, v1, 0.5, mid); bbox_from_extents(box, mid, (v1[0] - v0[0]) / 2, (v1[1] - v0[1]) / 2, (v1[2] - v0[2]) / 2); } static inline void bbox_from_npoints( float box[4][4], int n, const float (*points)[3]) { assert(n >= 1); int i; float v0[3], v1[3], mid[3]; vec3_copy(points[0], v0); vec3_copy(points[0], v1); for (i = 1; i < n; i++) { v0[0] = min(v0[0], points[i][0]); v0[1] = min(v0[1], points[i][1]); v0[2] = min(v0[2], points[i][2]); v1[0] = max(v1[0], points[i][0]); v1[1] = max(v1[1], points[i][1]); v1[2] = max(v1[2], points[i][2]); } vec3_mix(v0, v1, 0.5, mid); bbox_from_extents(box, mid, (v1[0] - v0[0]) / 2, (v1[1] - v0[1]) / 2, (v1[2] - v0[2]) / 2); } static inline bool bbox_contains(const float a[4][4], const float b[4][4]) { assert(box_is_bbox(a)); assert(box_is_bbox(b)); float a0[3], a1[3], b0[3], b1[3]; vec3_set(a0, a[3][0] - a[0][0], a[3][1] - a[1][1], a[3][2] - a[2][2]); vec3_set(a1, a[3][0] + a[0][0], a[3][1] + a[1][1], a[3][2] + a[2][2]); vec3_set(b0, b[3][0] - b[0][0], b[3][1] - b[1][1], b[3][2] - b[2][2]); vec3_set(b1, b[3][0] + b[0][0], b[3][1] + b[1][1], b[3][2] + b[2][2]); return (a0[0] <= b0[0] && a1[0] >= b1[0] && a0[1] <= b0[1] && a1[1] >= b1[1] && a0[2] <= b0[2] && a1[2] >= b1[2]); } static inline bool box_contains(const float a[4][4], const float b[4][4]) { const float PS[8][3] = { {-1, -1, +1}, {+1, -1, +1}, {+1, +1, +1}, {-1, +1, +1}, {-1, -1, -1}, {+1, -1, -1}, {+1, +1, -1}, {-1, +1, -1}, }; float p[3]; int i; float imat[4][4]; mat4_invert(a, imat); for (i = 0; i < 8; i++) { mat4_mul_vec3(b, PS[i], p); mat4_mul_vec3(imat, p, p); if ( p[0] < -1 || p[0] > 1 || p[1] < -1 || p[1] > 1 || p[2] < -1 || p[2] > 1) return false; } return true; } static inline bool bbox_contains_vec(const float b[4][4], const float v[3]) { assert(box_is_bbox(b)); float b0[3], b1[3]; vec3_set(b0, b[3][0] - b[0][0], b[3][1] - b[1][1], b[3][2] - b[2][2]); vec3_set(b1, b[3][0] + b[0][0], b[3][1] + b[1][1], b[3][2] + b[2][2]); return (b0[0] <= v[0] && b1[0] > v[0] && b0[1] <= v[1] && b1[1] > v[1] && b0[2] <= v[2] && b1[2] > v[2]); } static inline void box_get_bbox(const float b[4][4], float out[4][4]) { float p[8][3] = { {-1, -1, +1}, {+1, -1, +1}, {+1, +1, +1}, {-1, +1, +1}, {-1, -1, -1}, {+1, -1, -1}, {+1, +1, -1}, {-1, +1, -1}, }; int i; for (i = 0; i < 8; i++) { mat4_mul_vec3(b, p[i], p[i]); } bbox_from_npoints(out, 8, p); } static inline void bbox_grow(const float b[4][4], float x, float y, float z, float out[4][4]) { mat4_copy(b, out); out[0][0] += x; out[1][1] += y; out[2][2] += z; } static inline void box_get_size(const float b[4][4], float out[3]) { float v[3][4] = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}}; int i; for (i = 0; i < 3; i++) { mat4_mul_vec4(b, v[i], v[i]); out[i] = vec3_norm(v[i]); } } static inline void box_swap_axis(const float b[4][4], int x, int y, int z, float out[4][4]) { float m[4][4]; assert(x >= 0 && x <= 2); assert(y >= 0 && y <= 2); assert(z >= 0 && z <= 2); mat4_copy(b, m); mat4_copy(m, out); vec4_copy(m[x], out[0]); vec4_copy(m[y], out[1]); vec4_copy(m[z], out[2]); } // Create a new box with the 4 points opposit to the face f and the // new point. static inline void box_move_face( const float b[4][4], int f, const float p[3], float out[4][4]) { const float PS[8][3] = { {-1, -1, -1}, {+1, -1, -1}, {+1, -1, +1}, {-1, -1, +1}, {-1, +1, -1}, {+1, +1, -1}, {+1, +1, +1}, {-1, +1, +1}, }; const int FS[6][4] = { {0, 1, 2, 3}, {5, 4, 7, 6}, {0, 4, 5, 1}, {2, 6, 7, 3}, {1, 5, 6, 2}, {0, 3, 7, 4} }; const int FO[6] = {1, 0, 3, 2, 5, 4}; float ps[5][3]; int i; // XXX: for the moment we only support bbox, but we could make the // function generic. assert(box_is_bbox(b)); f = FO[f]; for (i = 0; i < 4; i++) mat4_mul_vec3(b, PS[FS[f][i]], ps[i]); vec3_copy(p, ps[4]); bbox_from_npoints(out, 5, ps); } static inline float box_get_volume(const float box[4][4]) { // The volume is the determinant of the 3x3 matrix of the box // time 8 (because the unit cube has a volume of 8). const float *v = &box[0][0]; float a, b, c, d, e, f, g, h, i; a = v[0]; b = v[1]; c = v[2]; d = v[4]; e = v[5]; f = v[6]; g = v[8]; h = v[9]; i = v[10]; return 8 * fabs(a*e*i + b*f*g + c*d*h - c*e*g - b*d*i - a*f*h); } static inline void box_get_vertices(const float box[4][4], float vertices[8][3]) { int i; const float P[8][3] = { {-1, -1, -1}, {+1, -1, -1}, {+1, -1, +1}, {-1, -1, +1}, {-1, +1, -1}, {+1, +1, -1}, {+1, +1, +1}, {-1, +1, +1}, }; for (i = 0; i < 8; i++) { mat4_mul_vec3(box, P[i], vertices[i]); } } bool box_intersect_box(const float b1[4][4], const float b2[4][4]); static inline bool box_intersect_aabb(const float box[4][4], const int aabb[2][3]) { float b2[4][4]; bbox_from_aabb(b2, aabb); return box_intersect_box(box, b2); } /* * Function: box_union * Return a box that constains two other ones. */ void box_union(const float a[4][4], const float b[4][4], float out[4][4]); #endif // BOX_H goxel-0.11.0/src/utils/cache.c000066400000000000000000000054371435762723100160700ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "cache.h" #include "uthash.h" #include #include typedef struct item item_t; struct item { UT_hash_handle hh; char key[256]; void *data; int cost; uint64_t last_used; int (*delfunc)(void *data); }; struct cache { item_t *items; uint64_t clock; int size; int max_size; }; cache_t *cache_create(int size) { cache_t *cache = calloc(1, sizeof(*cache)); cache->max_size = size; return cache; } static void cleanup(cache_t *cache) { item_t *item; while (cache->size >= cache->max_size) { assert(cache->items); item = cache->items; HASH_DEL(cache->items, item); assert(item != cache->items); item->delfunc(item->data); cache->size -= item->cost; free(item); } } void cache_add(cache_t *cache, const void *key, int len, void *data, int cost, int (*delfunc)(void *data)) { item_t *item = calloc(1, sizeof(*item)); assert(len <= sizeof(item->key)); memcpy(item->key, key, len); item->data = data; item->cost = cost; item->last_used = cache->clock++; item->delfunc = delfunc; HASH_ADD(hh, cache->items, key, len, item); cache->size += cost; if (cache->size >= cache->max_size) cleanup(cache); } void *cache_get(cache_t *cache, const void *key, int keylen) { item_t *item; HASH_FIND(hh, cache->items, key, keylen, item); if (!item) return NULL; item->last_used = cache->clock++; // Reinsert item on top of the hash list so that it stays sorted. HASH_DEL(cache->items, item); HASH_ADD(hh, cache->items, key, keylen, item); return item->data; } void cache_clear(cache_t *cache) { item_t *item; while ((item = cache->items)) { HASH_DEL(cache->items, item); item->delfunc(item->data); cache->size -= item->cost; free(item); } assert(cache->size == 0); } /* * Function: cache_delete * Delete a cache. */ void cache_delete(cache_t *cache) { cache_clear(cache); free(cache); } goxel-0.11.0/src/utils/cache.h000066400000000000000000000041751435762723100160730ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef CACHE_H #define CACHE_H // Generic data cache structure. // Allow to cache blocks merge operations. typedef struct cache cache_t; /* * Function: cache_create * Create a new cache with a given max size (in byte). */ cache_t *cache_create(int size); /* * Function: cache_add * Add an item into the cache. * * Parameters: * cache - A cache_t instance. * key - Unique key data for the cache item. * keylen - Size of the key data. * data - Pointer to the item data. The cache takes ownership. * cost - Cost of the data used to compute the cache usage. * It doesn't have to be the size. * delfunc - Function that the cache can use to free the data. */ void cache_add(cache_t *cache, const void *key, int keylen, void *data, int cost, int (*delfunc)(void *data)); /* * Function: cache_get * Retreive an item from the cache. * * Parameters: * cache - A cache_t instance. * key - Unique key data for the item. * keylen - Sizeo of the key data. * * Returns: * The data owned by the cache, or NULL if no item with this key is in * the cache. */ void *cache_get(cache_t *cache, const void *key, int keylen); /* * Function: cache_clear * Delete all the cached items. */ void cache_clear(cache_t *cache); /* * Function: cache_delete * Delete a cache. */ void cache_delete(cache_t *cache); #endif // CACHE_H goxel-0.11.0/src/utils/color.c000066400000000000000000000054611435762723100161400ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "color.h" #include #include static float min3(float x, float y, float z) { if (y < x) x = y; if (z < x) x = z; return x; } static float max3(float x, float y, float z) { if (y > x) x = y; if (z > x) x = z; return x; } void hsl_to_rgb_f(const float hsl[3], float rgb[3]) { float r = 0, g = 0, b = 0, c, x, m; const float h = hsl[0] / 60, s = hsl[1], l = hsl[2]; c = (1 - fabs(2 * l - 1)) * s; x = c * (1 - fabs(fmod(h, 2) - 1)); if (h < 1) {r = c; g = x; b = 0;} else if (h < 2) {r = x; g = c; b = 0;} else if (h < 3) {r = 0; g = c; b = x;} else if (h < 4) {r = 0; g = x; b = c;} else if (h < 5) {r = x; g = 0; b = c;} else if (h < 6) {r = c; g = 0; b = x;} m = l - 0.5 * c; rgb[0] = r + m; rgb[1] = g + m; rgb[2] = b + m; } void rgb_to_hsl_f(const float rgb[3], float hsl[3]) { float h = 0, s, v, m, c, l; const float r = rgb[0], g = rgb[1], b = rgb[2]; v = max3(r, g, b); m = min3(r, g, b); l = (v + m) / 2; c = v - m; if (c == 0) { hsl[0] = 0; hsl[1] = 0; hsl[2] = l; return; } if (v == r) {h = (g - b) / c + (g < b ? 6 : 0);} else if (v == g) {h = (b - r) / c + 2;} else if (v == b) {h = (r - g) / c + 4;} h *= 60; s = (l > 0.5) ? c / (2 - v - m) : c / (v + m); hsl[0] = h; hsl[1] = s; hsl[2] = l; } void hsl_to_rgb(const uint8_t hsl[3], uint8_t rgb[3]) { // XXX: use an optimized function that use int operations. float hsl_f[3] = {hsl[0] / 255. * 360, hsl[1] / 255., hsl[2] / 255.}; float rgb_f[3]; hsl_to_rgb_f(hsl_f, rgb_f); rgb[0] = round(rgb_f[0] * 255); rgb[1] = round(rgb_f[1] * 255); rgb[2] = round(rgb_f[2] * 255); } void rgb_to_hsl(const uint8_t rgb[3], uint8_t hsl[3]) { // XXX: use an optimized function that use int operations. float rgb_f[3] = {rgb[0] / 255., rgb[1] / 255., rgb[2] / 255.}; float hsl_f[3]; rgb_to_hsl_f(rgb_f, hsl_f); hsl[0] = round(hsl_f[0] * 255 / 360); hsl[1] = round(hsl_f[1] * 255); hsl[2] = round(hsl_f[2] * 255); } goxel-0.11.0/src/utils/color.h000066400000000000000000000017741435762723100161500ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef COLOR_H #define COLOR_H #include void hsl_to_rgb(const uint8_t hsl[3], uint8_t rgb[3]); void rgb_to_hsl(const uint8_t rgb[3], uint8_t hsl[3]); void hsl_to_rgb_f(const float hsl[3], float rgb[3]); void rgb_to_hsl_f(const float rgb[3], float hsl[3]); #endif // COLOR_H goxel-0.11.0/src/utils/gl.c000066400000000000000000000262351435762723100154260ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "utils/gl.h" #include #include #include #include #ifndef LOG_E # define LOG_E(...) #endif __attribute__((unused)) static const char* get_gl_error_text(int code) { switch (code) { case GL_INVALID_ENUM: return "GL_INVALID_ENUM"; case GL_INVALID_FRAMEBUFFER_OPERATION: return "GL_INVALID_FRAMEBUFFER_OPERATION"; case GL_INVALID_VALUE: return "GL_INVALID_VALUE"; case GL_INVALID_OPERATION: return "GL_INVALID_OPERATION"; case GL_OUT_OF_MEMORY: return "GL_OUT_OF_MEMORY"; default: return "undefined error"; } } int gl_check_errors(const char *file, int line) { int errors = 0; while (true) { GLenum x = glGetError(); if (x == GL_NO_ERROR) return errors; LOG_E("%s:%d: OpenGL error: %d (%s)\n", file, line, x, get_gl_error_text(x)); errors++; } } static int compile_shader(int shader, const char *code, const char *include1, const char *include2) { int status, len; char *log; // Common header we add to all the shaders. #ifndef GLES2 const char *pre = "#define highp\n#define mediump\n#define lowp\n"; #else const char *pre = ""; #endif const char *sources[] = {pre, include1, include2, "#line 0\n", code}; assert(code); glShaderSource(shader, 5, (const char**)&sources, NULL); glCompileShader(shader); glGetShaderiv(shader, GL_COMPILE_STATUS, &status); if (status != GL_TRUE) { glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len); log = malloc(len + 1); LOG_E("Compile shader error:"); glGetShaderInfoLog(shader, len, &len, log); LOG_E("%s", log); LOG_E("%s", code); free(log); assert(false); } return 0; } static void gl_delete_prog(int prog) { int i; GLuint shaders[2]; GLint count; if (DEBUG) { GL(glGetProgramiv(prog, GL_ATTACHED_SHADERS, &count)); assert(count == 2); } GL(glGetAttachedShaders(prog, 2, NULL, shaders)); for (i = 0; i < 2; i++) GL(glDeleteShader(shaders[i])); GL(glDeleteProgram(prog)); } /* * Function: gl_gen_fbo * Helper function to generate an OpenGL framebuffer object with an * associated texture. * * Parameters: * w - Width of the fbo. * h - Height of the fbo. * format - GL_RGBA or GL_DEPTH_COMPONENT. * out_fbo - The created fbo. * out_tex - The created texture. */ int gl_gen_fbo(int w, int h, GLenum format, int msaa, GLuint *out, GLuint *out_tex) { assert(format == GL_RGBA || format == GL_DEPTH_COMPONENT); assert(msaa == 1); // For the moment. GLuint fbo, color, tex = 0, depth, internal_format; internal_format = (format != GL_DEPTH_COMPONENT) ? GL_UNSIGNED_BYTE : GL_UNSIGNED_INT; GL(glGenFramebuffers(1, &fbo)); GL(glBindFramebuffer(GL_FRAMEBUFFER, fbo)); GL(glGenTextures(1, &tex)); GL(glActiveTexture(GL_TEXTURE0)); GL(glBindTexture(GL_TEXTURE_2D, tex)); GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); GL(glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0, format, internal_format, NULL)); #ifndef GLES2 if (format != GL_DEPTH_COMPONENT) { // Create color render buffer. GL(glGenRenderbuffers(1, &color)); GL(glBindRenderbuffer(GL_RENDERBUFFER, color)); glRenderbufferStorage(GL_RENDERBUFFER, format, w, h); GL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, color)); // Create depth/stencil render buffer GL(glGenRenderbuffers(1, &depth)); GL(glBindRenderbuffer(GL_RENDERBUFFER, depth)); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, w, h); GL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depth)); // Attach texture. if (tex) GL(glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0)); } else { GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex, 0)); } #else (void)color; if (format != GL_DEPTH_COMPONENT) { if (gl_has_extension("GL_OES_packed_depth_stencil")) { // Create depth/stencil buffer. GL(glGenRenderbuffers(1, &depth)); GL(glBindRenderbuffer(GL_RENDERBUFFER, depth)); GL(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, w, h)); GL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth)); GL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depth)); } else { // This path should only be for WebGL. GL(glGenRenderbuffers(1, &depth)); GL(glBindRenderbuffer(GL_RENDERBUFFER, depth)); GL(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, w, h)); GL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth)); /* XXX: no stencil for the moment, it doesn't seem to work! GL(glGenRenderbuffers(1, &stencil)); GL(glBindRenderbuffer(GL_RENDERBUFFER, stencil)); GL(glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, w, h)); GL(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil)); */ } if (tex) GL(glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0)); } else { GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_EXT, GL_COMPARE_REF_TO_TEXTURE_EXT)); GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex, 0)); } #endif assert( glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); *out = fbo; if (tex) *out_tex = tex; return 0; } bool gl_has_extension(const char *ext) { const char *str; GL(str = (const char*)glGetString(GL_EXTENSIONS)); return strstr(str, ext); } /* * Function: gl_shader_create * Helper function that compiles an opengl shader. * * Parameters: * vert - The vertex shader code. * frag - The fragment shader code. * include - Extra includes added to both shaders. * attr_names - NULL terminated list of attribute names that will be binded. * * Return: * A new gl_shader_t instance. */ gl_shader_t *gl_shader_create(const char *vert, const char *frag, const char *include, const char **attr_names) { int i, status, len, count; int vertex_shader, fragment_shader; char log[1024]; gl_shader_t *shader; GLint prog; gl_uniform_t *uni; vertex_shader = glCreateShader(GL_VERTEX_SHADER); include = include ? : ""; assert(vertex_shader); if (compile_shader(vertex_shader, vert, "#define VERTEX_SHADER\n", include)) return NULL; fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); assert(fragment_shader); if (compile_shader(fragment_shader, frag, "#define FRAGMENT_SHADER\n", include)) return NULL; prog = glCreateProgram(); glAttachShader(prog, vertex_shader); glAttachShader(prog, fragment_shader); // Set all the attributes names if specified. if (attr_names) { for (i = 0; attr_names[i]; i++) { glBindAttribLocation(prog, i, attr_names[i]); } } glLinkProgram(prog); glGetProgramiv(prog, GL_LINK_STATUS, &status); if (status != GL_TRUE) { LOG_E("Link Error"); glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &len); glGetProgramInfoLog(prog, sizeof(log), NULL, log); LOG_E("%s", log); return NULL; } shader = calloc(1, sizeof(*shader)); shader->prog = prog; GL(glGetProgramiv(shader->prog, GL_ACTIVE_UNIFORMS, &count)); for (i = 0; i < count; i++) { uni = &shader->uniforms[i]; GL(glGetActiveUniform(shader->prog, i, sizeof(uni->name), NULL, &uni->size, &uni->type, uni->name)); // Special case for array uniforms: remove the '[0]' if (uni->size > 1) { assert(uni->type == GL_FLOAT); *strchr(uni->name, '[') = '\0'; } GL(uni->loc = glGetUniformLocation(shader->prog, uni->name)); } return shader; } void gl_shader_delete(gl_shader_t *shader) { if (!shader) return; gl_delete_prog(shader->prog); free(shader); } bool gl_has_uniform(gl_shader_t *shader, const char *name) { gl_uniform_t *uni; for (uni = &shader->uniforms[0]; uni->size; uni++) { if (strcmp(uni->name, name) == 0) return true; } return false; } void gl_update_uniform(gl_shader_t *shader, const char *name, ...) { gl_uniform_t *uni; va_list args; for (uni = &shader->uniforms[0]; uni->size; uni++) { if (strcmp(uni->name, name) == 0) break; } if (!uni->size) return; // No such uniform. va_start(args, name); switch (uni->type) { case GL_INT: case GL_SAMPLER_2D: GL(glUniform1i(uni->loc, va_arg(args, int))); break; case GL_FLOAT: GL(glUniform1f(uni->loc, va_arg(args, double))); break; case GL_FLOAT_VEC2: GL(glUniform2fv(uni->loc, 1, va_arg(args, const float*))); break; case GL_FLOAT_VEC3: GL(glUniform3fv(uni->loc, 1, va_arg(args, const float*))); break; case GL_FLOAT_VEC4: GL(glUniform4fv(uni->loc, 1, va_arg(args, const float*))); break; case GL_FLOAT_MAT4: GL(glUniformMatrix4fv(uni->loc, 1, 0, va_arg(args, const float*))); break; default: assert(false); } va_end(args); } goxel-0.11.0/src/utils/gl.h000066400000000000000000000064301435762723100154260ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef GL_H #define GL_H #include // Set the DEBUG macro if needed. #ifndef DEBUG # if !defined(NDEBUG) # define DEBUG 1 # else # define DEBUG 0 # endif #endif // Include OpenGL properly. #define GL_GLEXT_PROTOTYPES #ifdef WIN32 # include # include "GL/glew.h" #endif #ifdef __APPLE__ # include "TargetConditionals.h" # if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR # define GLES2 1 # include # include # else # include # endif #else # ifdef GLES2 # include # include # else # include # endif #endif // GL macro that automatically checks for errors in debug mode. #if DEBUG # define GL(line) ({ \ line; \ if (gl_check_errors(__FILE__, __LINE__)) assert(false); \ }) #else # define GL(line) line #endif typedef struct gl_uniform { char name[64]; GLint size; GLenum type; GLint loc; } gl_uniform_t; typedef struct gl_shader { GLint prog; gl_uniform_t uniforms[32]; } gl_shader_t; int gl_check_errors(const char *file, int line); /* * Function: gl_has_extension * Check whether an OpenGL extension is available. */ bool gl_has_extension(const char *extension); /* * Function: gl_gen_fbo * Helper function to generate an OpenGL framebuffer object with an * associated texture. * * Parameters: * w - Width of the fbo. * h - Height of the fbo. * format - GL_RGBA or GL_DEPTH_COMPONENT. * out_fbo - The created fbo. * out_tex - The created texture. */ int gl_gen_fbo(int w, int h, GLenum format, int msaa, GLuint *out_fbo, GLuint *out_tex); /* * Function: gl_shader_create * Helper function that compiles an opengl shader. * * Parameters: * vert - The vertex shader code. * frag - The fragment shader code. * include - Extra includes added to both shaders. * attr_names - NULL terminated list of attribute names that will be binded. * * Return: * A new gl_shader_t instance. */ gl_shader_t *gl_shader_create(const char *vert, const char *frag, const char *include, const char **attr_names); void gl_shader_delete(gl_shader_t *shader); bool gl_has_uniform(gl_shader_t *shader, const char *name); void gl_update_uniform(gl_shader_t *shader, const char *name, ...); #endif // GL_H goxel-0.11.0/src/utils/img.c000066400000000000000000000112241435762723100155700ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "img.h" #include #ifndef HAVE_LIBPNG # define HAVE_LIBPNG 0 #endif // Prevent warnings in stb code. #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #pragma GCC diagnostic ignored "-Wunused-function" #ifdef WIN32 #pragma GCC diagnostic ignored "-Wmisleading-indentation" #endif #endif #define STB_IMAGE_STATIC #define STB_IMAGE_WRITE_STATIC #define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION #define STBI_ONLY_PNG #define STBI_ONLY_JPEG #define STBI_ONLY_BMP #define STBI_NO_GIF #include "stb_image.h" #include "stb_image_write.h" #if HAVE_LIBPNG #include #endif #ifdef __GNUC__ #pragma GCC diagnostic pop #endif static char *read_file(const char *path, int *size) { FILE *file; char *ret = NULL; long read_size __attribute__((unused)); int size_default; size = size ?: &size_default; // Allow to pass NULL as size; *size = 0; file = fopen(path, "rb"); if (!file) return NULL; fseek(file, 0, SEEK_END); *size = (int)ftell(file); fseek(file, 0, SEEK_SET); ret = malloc(*size + 1); read_size = fread(ret, *size, 1, file); assert(read_size == 1 || *size == 0); ret[*size] = '\0'; fclose(file); return ret; } uint8_t *img_read_from_mem(const char *data, int size, int *w, int *h, int *bpp) { assert(*bpp >= 0 && *bpp <= 4); return stbi_load_from_memory((uint8_t*)data, size, w, h, bpp, *bpp); } uint8_t *img_read(const char *path, int *width, int *height, int *bpp) { int size; char *data; uint8_t *img; data = read_file(path, &size); if (!data) LOG_E("Cannot open image %s", path); assert(data); img = img_read_from_mem(data, size, width, height, bpp); free(data); return img; } #if !HAVE_LIBPNG void img_write(const uint8_t *img, int w, int h, int bpp, const char *path) { stbi_write_png(path, w, h, bpp, img, 0); } #else void img_write(const uint8_t *img, int w, int h, int bpp, const char *path) { int i; FILE *fp; png_structp png_ptr; png_infop info_ptr; fp = fopen(path, "wb"); if (!fp) { LOG_E("Cannot open %s", path); return; } png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!png_ptr) { // With ubuntu 19.04, libpng seems to fail! LOG_E("Libpng error: fallback to stb-img"); fclose(fp); stbi_write_png(path, w, h, bpp, img, 0); return; } info_ptr = png_create_info_struct(png_ptr); if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_write_struct(&png_ptr, &info_ptr); fclose(fp); return; } png_init_io(png_ptr, fp); png_set_IHDR(png_ptr, info_ptr, w, h, 8, bpp == 3 ? PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); png_write_info(png_ptr, info_ptr); for (i = 0; i < h; i++) png_write_row(png_ptr, (png_bytep)(img + i * w * bpp)); png_write_end(png_ptr, info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr); fclose(fp); } #endif uint8_t *img_write_to_mem(const uint8_t *img, int w, int h, int bpp, int *size) { return stbi_write_png_to_mem((void*)img, 0, w, h, bpp, size); } void img_downsample(const uint8_t *img, int w, int h, int bpp, uint8_t *out) { #define IX(x, y, k) ((((size_t)y) * w + (x)) * bpp + (k)) int i, j, k; assert(w % 2 == 0 && h % 2 == 0); for (i = 0; i < h; i += 2) for (j = 0; j < w; j += 2) for (k = 0; k < bpp; k++) { out[(i * w / 4 + j / 2) * bpp + k] = ( img[IX(j + 0, i + 0, k)] + img[IX(j + 0, i + 1, k)] + img[IX(j + 1, i + 0, k)] + img[IX(j + 1, i + 1, k)]) / 4; } #undef IX } goxel-0.11.0/src/utils/img.h000066400000000000000000000032141435762723100155750ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* * File: img.h * A few 2d image manipulation helper functions. */ #ifndef IMG_H #define IMG_H #include /* * Function: img_read * Read an image from a file. */ uint8_t *img_read(const char *path, int *width, int *height, int *bpp); /* * Function: img_read_from_mem * Read an image from memory. */ uint8_t *img_read_from_mem(const char *data, int size, int *w, int *h, int *bpp); /* * Function: img_write * Write an image to a file. */ void img_write(const uint8_t *img, int w, int h, int bpp, const char *path); /* * Function: img_write_to_mem * Write an image to memory. */ uint8_t *img_write_to_mem(const uint8_t *img, int w, int h, int bpp, int *size); /* * Function: img_downsample * Downsample an image by half, using interpolation. */ void img_downsample(const uint8_t *img, int w, int h, int bpp, uint8_t *out); #endif // IMG_H goxel-0.11.0/src/utils/ini.c000066400000000000000000000015771435762723100156050ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-truncation" #include "ini.h" #include "../../ext_src/inih/ini.c" #pragma GCC diagnostic pop goxel-0.11.0/src/utils/ini.h000066400000000000000000000015151435762723100156020ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ // Just include ini.h file, with proper defines. #define INI_HANDLER_LINENO 1 #include "../../ext_src/inih/ini.h" goxel-0.11.0/src/utils/json.c000066400000000000000000000101501435762723100157620ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "json.h" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpointer-to-int-cast" #include "../../ext_src/json/json.c" #include "../../ext_src/json/json-builder.c" #pragma GCC diagnostic pop #include #include static size_t base64_encode(const uint8_t *data, size_t len, char *buf) { const char table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'}; const int mod_table[] = {0, 2, 1}; uint32_t a, b, c, triple; int i, j; size_t out_len = 4 * ((len + 2) / 3); if (!buf) return out_len; for (i = 0, j = 0; i < len;) { a = i < len ? data[i++] : 0; b = i < len ? data[i++] : 0; c = i < len ? data[i++] : 0; triple = (a << 0x10) + (b << 0x08) + c; buf[j++] = table[(triple >> 3 * 6) & 0x3F]; buf[j++] = table[(triple >> 2 * 6) & 0x3F]; buf[j++] = table[(triple >> 1 * 6) & 0x3F]; buf[j++] = table[(triple >> 0 * 6) & 0x3F]; } for (i = 0; i < mod_table[len % 3]; i++) buf[out_len - 1 - i] = '='; return out_len; } json_value *json_object_push_int(json_value *obj, const json_char *name, json_int_t v) { return json_object_push(obj, name, json_integer_new(v)); } json_value *json_object_push_string(json_value *obj, const json_char *name, const json_char *v) { return json_object_push(obj, name, json_string_new(v)); } json_value *json_object_push_bool(json_value *obj, const json_char *name, bool v) { return json_object_push(obj, name, json_boolean_new(v)); } json_value *json_object_push_float(json_value *obj, const json_char *name, double v) { return json_object_push(obj, name, json_double_new(v)); } json_value *json_data_new(const void *data, uint32_t len, const char *mime) { char *string; if (!mime) mime = "application/octet-stream"; string = calloc(strlen("data:") + strlen(mime) + strlen(";base64,") + base64_encode(data, len, NULL) + 1, 1); sprintf(string, "data:%s;base64,", mime); base64_encode(data, len, string + strlen(string)); return json_string_new_nocopy(strlen(string), string); } json_value *json_int_array_new(const int *v, int nb) { int i; json_value *array = json_array_new(nb); for (i = 0; i < nb; i++) { json_array_push(array, json_integer_new(v[i])); } return array; } json_value *json_float_array_new(const float *v, int nb) { int i; json_value *array = json_array_new(nb); for (i = 0; i < nb; i++) { json_array_push(array, json_double_new(v[i])); } return array; } int json_index(json_value *value) { int i; assert(value->parent); assert(value->parent->type == json_array); for (i = 0; i < value->parent->u.array.length; i++) { if (value->parent->u.array.values[i] == value) return i; } assert(false); return -1; } goxel-0.11.0/src/utils/json.h000066400000000000000000000031401435762723100157700ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef JSON_H #define JSON_H #include "../../ext_src/json/json.h" #include "../../ext_src/json/json-builder.h" #include // Some extra helper functions. json_value *json_object_push_int(json_value *obj, const json_char *name, json_int_t v); json_value *json_object_push_string(json_value *obj, const json_char *name, const json_char *v); json_value *json_object_push_bool(json_value *obj, const json_char *name, bool v); json_value *json_object_push_float(json_value *obj, const json_char *name, double v); json_value *json_data_new(const void *data, uint32_t len, const char *mime); json_value *json_int_array_new(const int *v, int nb); json_value *json_float_array_new(const float *v, int nb); int json_index(json_value *v); #endif // JSON_H goxel-0.11.0/src/utils/mustache.c000066400000000000000000000122661435762723100166340ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef _GNU_SOURCE # define _GNU_SOURCE #endif #include "mustache.h" #include "utlist.h" #include #include #include #include #ifdef WIN32 # include #else # include #endif #include enum { M_TYPE_DICT, M_TYPE_LIST, M_TYPE_STR, }; struct mustache { char type; char *key; union { char *s; }; mustache_t *next, *prev, *children, *parent; }; static mustache_t *create_(mustache_t *m, const char *key, int type) { mustache_t *ret = calloc(1, sizeof(*ret)); ret->parent = m; ret->key = key ? strdup(key) : NULL; ret->type = type; if (m) DL_APPEND(m->children, ret); return ret; } mustache_t *mustache_root(void) { mustache_t *ret = calloc(1, sizeof(*ret)); ret->type = M_TYPE_DICT; return ret; } mustache_t *mustache_add_dict(mustache_t *m, const char *key) { return create_(m, key, M_TYPE_DICT); } mustache_t *mustache_add_list(mustache_t *m, const char *key) { return create_(m, key, M_TYPE_LIST); } void mustache_add_str(mustache_t *m, const char *key, const char *fmt, ...) { va_list args; int r; mustache_t *ret; ret = create_(m, key, M_TYPE_STR); va_start(args, fmt); if (fmt) { r = vasprintf(&ret->s, fmt, args); (void)r; // Ignore errors. } va_end(args); } void mustache_free(mustache_t *m) { mustache_t *c, *tmp; DL_FOREACH_SAFE(m->children, c, tmp) mustache_free(c); if (m->type == M_TYPE_STR) free(m->s); free(m->key); free(m); } const mustache_t *get_elem(const mustache_t *m, const char *key) { mustache_t *c; if (key[0] == '#') key++; DL_FOREACH(m->children, c) { if (c->key && strcmp(key, c->key) == 0) return c; } return NULL; } static int render_(const mustache_t *tree, const mustache_t *m, char *out) { int i = 0; mustache_t tmp; const mustache_t *c; const mustache_t *elem = NULL; if (tree->key) elem = get_elem(m, tree->key); // Some text. if (tree->type == M_TYPE_STR && !tree->key) { if (out) for (i = 0; i < strlen(tree->s); i++) *out++ = tree->s[i]; return strlen(tree->s); } if (tree->key && tree->key[0] == '/') return 0; // A list if (tree->key && tree->key[0] == '#') { if (!elem) return 0; tmp = *tree; tmp.type = M_TYPE_LIST; tmp.key = NULL; if (elem->type == M_TYPE_LIST) { DL_FOREACH(elem->children, c) { assert(c->type == M_TYPE_DICT); i += render_(&tmp, c, out ? out + i : NULL); } } if (elem->type == M_TYPE_DICT) { i += render_(&tmp, elem, out); } return i; } // A variable if (tree->type == M_TYPE_STR && tree->key) { if (!elem) return 0; if (out) for (i = 0; i < strlen(elem->s); i++) *out++ = elem->s[i]; return strlen(elem->s); } if (tree->children) { DL_FOREACH(tree->children, c) { i += render_(c, m, out ? out + i : NULL); } if (!tree->parent) { if (out) out[i] = '\0'; } return i; } return 0; } int mustache_render(const mustache_t *m, const char *templ, char *out) { regex_t reg; regmatch_t matches[2]; mustache_t *tree; char key[128]; int r, len; regcomp(®, "\\{\\{([#/]?[[:alnum:]_]+)\\}\\}", REG_EXTENDED); // Create the template tree. tree = mustache_add_list(NULL, NULL); while (templ) { r = regexec(®, templ, 2, matches, 0); if (r == REG_NOMATCH) { // No more tags. mustache_add_str(tree, NULL, templ); break; } if (matches[0].rm_so) mustache_add_str(tree, NULL, "%.*s", matches[0].rm_so, templ); len = matches[1].rm_eo - matches[1].rm_so; strncpy(key, templ + matches[1].rm_so, len); key[len] = '\0'; mustache_add_str(tree, key, NULL); if (key[0] == '/') { r = asprintf(&tree->s, "%.*s", (int)(templ - tree->s), tree->s); (void)r; // Ignore errors. tree = tree->parent; } templ += matches[0].rm_eo; if (key[0] == '#') { tree = tree->children->prev; tree->s = (char*)templ; } } regfree(®); assert(!tree->parent); // Apply the parsed tree to the given dict. r = render_(tree, m, out); mustache_free(tree); return r; } goxel-0.11.0/src/utils/mustache.h000066400000000000000000000023421435762723100166330ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ // Basic mustache templates support // Check povray.c for an example of usage. #ifndef MUSTACHE_H #define MUSTACHE_H typedef struct mustache mustache_t; mustache_t *mustache_root(void); mustache_t *mustache_add_dict(mustache_t *m, const char *key); mustache_t *mustache_add_list(mustache_t *m, const char *key); void mustache_add_str(mustache_t *m, const char *key, const char *fmt, ...); int mustache_render(const mustache_t *m, const char *templ, char *out); void mustache_free(mustache_t *m); #endif // MUSTACHE_H goxel-0.11.0/src/utils/plane.h000066400000000000000000000075411435762723100161270ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "goxel.h" /* A plane is defined as the 4x4 matrix to transform from the plane local * coordinate into global coordinates: * * * n * ^ v * | ^ . . . . . * | / . * | / . * |/ . * +---------> u * P * * Here the plane defined by the point P and vectors u and v with normal n, * will have a matrix like this: * * [ux uy yz 0] * [vx vy vz 0] * [nx ny nz 0] * [px py pz 1] * * This representation has several advantages: we can access the plane unitary * vectors, normal, and origin without any computation. I used an union so * that those values can be access directly as u, v, n, and p. For the * vec4 version we can also use u4, v4, n4, and p4. * * It is also trivial to transform a point in the plane into world * coordinates, simply by using matrix computation. * */ static const float plane_null[4][4] = {}; static inline void plane_from_vectors(float plane[4][4], const float pos[3], const float u[3], const float v[3]) { mat4_set_identity(plane); vec3_copy(u, plane[0]); vec3_copy(v, plane[1]); vec3_cross(u, v, plane[2]); vec3_copy(pos, plane[3]); } static inline bool plane_is_null(const float p[4][4]) { return p[3][3] == 0; } // Check if a plane intersect a line. // if out is set, it receive the position of the intersection in the // plane local coordinates. Apply the plane matrix on it to get the // object coordinate position. static inline bool plane_line_intersection(const float plane[4][4], const float p[3], const float n[3], float out[3]) { float v[3], m[4][4]; mat4_set_identity(m); vec3_copy(plane[0], m[0]); vec3_copy(plane[1], m[1]); vec3_copy(n, m[2]); if (!mat4_invert(m, m)) return false; if (out) { vec3_sub(p, plane[3], v); mat4_mul_vec3(m, v, out); out[2] = 0; } return true; } static inline void plane_from_normal(float plane[4][4], const float pos[3], const float n[3]) { int i; const float AXES[][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; mat4_set_identity(plane); vec3_copy(pos, plane[3]); vec3_normalize(n, plane[2]); for (i = 0; i < 3; i++) { vec3_cross(plane[2], AXES[i], plane[0]); if (vec3_norm2(plane[0]) > 0) break; } vec3_cross(plane[2], plane[0], plane[1]); } static inline bool plane_triangle_intersection(const float plane[4][4], const float triangle[3][3], float segs[2][3]) { int i; float pinv[4][4], tri[3][3], r0, r1; // Turn triangle into plane local coordinates. if (!mat4_invert(plane, pinv)) return false; for (i = 0; i < 3; i++) mat4_mul_vec3(pinv, triangle[i], tri[i]); for (i = 0; i < 3; i++) { if (tri[i][2] != tri[(i + 1) % 3][2] && tri[i][2] != tri[(i + 2) % 3][2]) break; } if (i == 3) return false; r0 = -tri[i][2] / (tri[(i + 1) % 3][2] - tri[i][2]); r1 = -tri[i][2] / (tri[(i + 2) % 3][2] - tri[i][2]); vec3_mix(triangle[i], triangle[(i + 1) % 3], r0, segs[0]); vec3_mix(triangle[i], triangle[(i + 2) % 3], r1, segs[1]); return true; } goxel-0.11.0/src/utils/sound.c000066400000000000000000000107711435762723100161520ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* Basic sound support. * * The code is probably overcomplicated, because this is adapted from * some old code I used for video games, that supported much more features, * like music, effects, ogg files... * * This is disabled by default. */ #ifndef SOUND_H #define SOUND_H #include "sound.h" #include "uthash.h" #include #ifdef SOUND // Abstraction used to represent any kind of sound sources: wav, sfxr, mod. typedef struct sound_source { void *data; int rate, channels, size; int (*read)(struct sound_source *source, void *data, int size); void (*delete)(struct sound_source *source); void (*reset)(struct sound_source *source); } sound_source_t; typedef struct sound_backend sound_backend_t; typedef struct sound { UT_hash_handle hh; int state; sound_source_t *source; sound_backend_t *backend; } sound_t; static sound_t *g_sounds = NULL; static bool g_enabled = true; // Functions defined by the backend. void sound_backend_init(void); sound_backend_t *sound_backend_create(sound_source_t *source); void sound_backend_play_sound(sound_t *sound, float volume, float pitch); void sound_backend_stop_sound(sound_t *sound); int sound_backend_iter_sound(sound_t *sound); void sound_backend_iter(void); void sound_init(void) { sound_backend_init(); } bool sound_is_enabled(void) { return g_enabled; } void sound_set_enabled(bool v) { g_enabled = v; } typedef struct { void *buffer; int size; int pos; } wav_t; static int wav_read(sound_source_t *source, void *out, int size) { wav_t *wav = source->data; if (wav->size - wav->pos < size) size = wav->size - wav->pos; if (out) memcpy(out, wav->buffer + wav->pos, size); wav->pos += size; return size; } static void wav_reset(sound_source_t *source) { wav_t *wav = source->data; wav->pos = 0; } static void wav_delete(sound_source_t *source) { wav_t *wav = source->data; free(wav->buffer); free(wav); free(source); } static sound_source_t *wav_create(const char *data) { sound_source_t *ret = calloc(1, sizeof(*ret)); wav_t *wav = calloc(1, sizeof(*wav)); assert(data); ret->size = wav->size = *(uint32_t*)(data + 40); ret->rate = *(uint32_t*)(data + 24); ret->channels = *(uint16_t*)(data + 22); wav->buffer = malloc(wav->size); memcpy(wav->buffer, data + 44, wav->size); ret->data = wav; ret->read = wav_read; ret->reset = wav_reset; ret->delete = wav_delete; return ret; } void sound_register(const char *name, const char *wav) { sound_t *sound; HASH_FIND_STR(g_sounds, name, sound); assert(!sound); sound = calloc(1, sizeof(*sound)); sound->source = wav_create(wav); assert(sound->source); sound->backend = sound_backend_create(sound->source); HASH_ADD_KEYPTR(hh, g_sounds, name, strlen(name), sound); } void sound_play(const char *name, float volume, float pitch) { sound_t *sound; if (!g_enabled) return; HASH_FIND_STR(g_sounds, name, sound); assert(sound); sound->source->reset(sound->source); sound_backend_stop_sound(sound); sound->state = 1; sound_backend_play_sound(sound, volume, pitch); } void sound_iter(void) { sound_t *sound, *tmp; HASH_ITER(hh, g_sounds, sound, tmp) { sound->state = sound_backend_iter_sound(sound); } sound_backend_iter(); } // For the moment the only backend we support is OpenAL. #include "sound_openal.inl" #else // Dummy API when we compile without sound support. void sound_init(void) {} void sound_register(const char *name, const char *wav_data) {} void sound_play(const char *name, float volume, float pitch) {} void sound_iter(void) {} bool sound_is_enabled(void) { return false; } void sound_set_enabled(bool v) {} #endif #endif // SOUND_H goxel-0.11.0/src/utils/sound.h000066400000000000000000000017271435762723100161600ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include void sound_init(void); void sound_register(const char *name, const char *wav_data); void sound_play(const char *name, float volume, float pitch); void sound_iter(void); bool sound_is_enabled(void); void sound_set_enabled(bool v); goxel-0.11.0/src/utils/sound_openal.inl000066400000000000000000000122231435762723100200420ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2017 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifdef __APPLE__ # include # include #else # include # include #endif #define SAMPLING_BUFFER_SIZE (1024 * 32) #define BUFFERS_NB 2 #if DEBUG static const char *get_error_name(ALenum r) { # define C(x) case x: return #x; break; switch (r) { C(AL_INVALID_NAME) C(AL_INVALID_ENUM) C(AL_INVALID_VALUE) C(AL_INVALID_OPERATION) C(AL_OUT_OF_MEMORY) default: return "unknown error"; } # undef C } # define AL(x) do { \ x; \ ALenum err_ = alGetError(); \ if (err_ != AL_NO_ERROR) \ LOG_E("AL error: %s", get_error_name(err_)); \ assert(err_ == AL_NO_ERROR); \ } while (0); #else // ! DEBUG # define AL(x) x #endif struct sound_backend { int format; int rate; ALuint source; ALuint buffers[BUFFERS_NB]; int buffers_start; // Index of the first buffer int buffers_count; // Number of buffers in the queue }; static struct { ALCdevice* device; ALCcontext* context; } global = {0}; sound_backend_t *sound_backend_create(sound_source_t *source) { sound_backend_t *sound = calloc(1, sizeof(*sound)); AL(alGenBuffers(BUFFERS_NB, sound->buffers)); AL(alGenSources(1, &sound->source)); sound->format = (source->channels == 1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16; sound->rate = source->rate; return sound; } void sound_backend_delete(sound_backend_t *b) { ALint i, nb; ALuint buff; AL(alSourceStop(b->source)); AL(alGetSourcei(b->source, AL_BUFFERS_PROCESSED, &nb)); assert(nb <= b->buffers_count); for (i = 0; i < nb; i++) { // If I don't use a temp variable for the buffer name, then I have // some strange bugs on iOS where alSourceUnqueueBuffers modifies the // values of the buffers! buff = b->buffers[b->buffers_start]; AL(alSourceUnqueueBuffers(b->source, 1, &buff)); b->buffers_start = (b->buffers_start + 1) % BUFFERS_NB; b->buffers_count--; } AL(alDeleteBuffers(BUFFERS_NB, b->buffers)); AL(alDeleteSources(1, &b->source)); free(b); } void sound_backend_init() { assert(!global.device); assert(!global.context); global.device = alcOpenDevice(NULL); global.context = alcCreateContext(global.device, NULL); AL(alcMakeContextCurrent(global.context)); } void sound_backend_release() { alcMakeContextCurrent(NULL); alcDestroyContext(global.context); global.context = NULL; alcCloseDevice(global.device); global.device = NULL; } void sound_backend_stop_sound(sound_t *sound) { AL(alSourceStop(sound->backend->source)); } void sound_backend_play_sound(sound_t *sound, float volume, float pitch) { assert(pitch >= 0.5 && pitch <= 2.0); AL(alSourcef(sound->backend->source, AL_GAIN, volume)); AL(alSourcef(sound->backend->source, AL_PITCH, pitch)); } int sound_backend_iter_sound(sound_t *sound) { ALint nb, i; int size; static char buffer[SAMPLING_BUFFER_SIZE]; ALuint buff; sound_backend_t *b = sound->backend; assert(b->buffers_count <= BUFFERS_NB); AL(alGetSourcei(b->source, AL_BUFFERS_PROCESSED, &nb)); assert(nb <= b->buffers_count); for (i = 0; i < nb; i++) { // If I don't use a temp variable for the buffer name, then I have // some strange bugs on iOS where alSourceUnqueueBuffers modifies the // values of the buffers! buff = b->buffers[b->buffers_start]; AL(alSourceUnqueueBuffers(b->source, 1, &buff)); b->buffers_start = (b->buffers_start + 1) % BUFFERS_NB; b->buffers_count--; } if (b->buffers_count == BUFFERS_NB) return 1; size = sound->source->read(sound->source, buffer, SAMPLING_BUFFER_SIZE); assert(size <= SAMPLING_BUFFER_SIZE); if (size == 0) { return b->buffers_count == 0 ? 0 : 1; } i = (b->buffers_start + b->buffers_count) % BUFFERS_NB; b->buffers_count++; AL(alBufferData(b->buffers[i], b->format, buffer, size, b->rate)); AL(alSourceQueueBuffers(b->source, 1, &b->buffers[i])); if (b->buffers_count == 1) { AL(alSourcePlay(b->source)); } return 1; } void sound_backend_iter(void) { } goxel-0.11.0/src/utils/texture.c000066400000000000000000000130071435762723100165150ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2015 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #include "texture.h" #include "utils/gl.h" #include #include #include // Return the next power of 2 larger or equal to x. static int next_pow2(int x) { x--; x |= x >> 1; x |= x >> 2; x |= x >> 4; x |= x >> 8; x |= x >> 16; x++; return x; } static bool is_pow2(int x) { return x == next_pow2(x); } static void texture_create_empty(texture_t *tex) { assert(tex->flags & TF_HAS_TEX); GL(glGenTextures(1, &tex->tex)); GL(glActiveTexture(GL_TEXTURE0)); GL(glBindTexture(GL_TEXTURE_2D, tex->tex)); if (!(tex->flags & TF_NEAREST)) { GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (tex->flags & TF_MIPMAP)? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR)); } else { GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)); GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); } GL(glTexImage2D(GL_TEXTURE_2D, 0, tex->format, tex->tex_w, tex->tex_h, 0, tex->format, GL_UNSIGNED_BYTE, NULL)); } static void blit(const uint8_t *src, int src_w, int src_h, int bpp, uint8_t *dst, int dst_w, int dst_h) { int i, j; for (i = 0; i < src_h; i++) for (j = 0; j < src_w; j++) { memcpy(&dst[(i * dst_w + j) * bpp], &src[(i * src_w + j) * bpp], bpp); } } void texture_set_data(texture_t *tex, const uint8_t *data, int w, int h, int bpp) { uint8_t *buf = NULL; assert(tex->tex); if (!is_pow2(w) || !is_pow2(h)) { buf = calloc(bpp, tex->tex_w * tex->tex_h); blit(data, w, h, bpp, buf, tex->tex_w, tex->tex_h); data = buf; } GL(glBindTexture(GL_TEXTURE_2D, tex->tex)); GL(glTexImage2D(GL_TEXTURE_2D, 0, tex->format, tex->tex_w, tex->tex_h, 0, tex->format, GL_UNSIGNED_BYTE, data)); free(buf); if (tex->flags & TF_MIPMAP) GL(glGenerateMipmap(GL_TEXTURE_2D)); } texture_t *texture_new_from_buf(const uint8_t *data, int w, int h, int bpp, int flags) { texture_t *tex; tex = calloc(1, sizeof(*tex)); tex->tex_w = next_pow2(w); tex->tex_h = next_pow2(h); tex->w = w; tex->h = h; tex->flags = TF_HAS_TEX | flags; tex->format = (int[]){0, 0, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA}[bpp]; texture_create_empty(tex); texture_set_data(tex, data, w, h, bpp); tex->ref = 1; return tex; } texture_t *texture_new_surface(int w, int h, int flags) { texture_t *tex; tex = calloc(1, sizeof(*tex)); tex->tex_w = next_pow2(w); tex->tex_h = next_pow2(h); tex->w = w; tex->h = h; tex->flags = flags | TF_HAS_TEX; tex->format = (flags & TF_RGB) ? GL_RGB : GL_RGBA; texture_create_empty(tex); tex->ref = 1; return tex; } texture_t *texture_new_buffer(int w, int h, int flags) { texture_t *tex; tex = calloc(1, sizeof(*tex)); tex->format = (flags & TF_RGB) ? GL_RGB : GL_RGBA; tex->tex_w = next_pow2(w); tex->tex_h = next_pow2(h); tex->w = w; tex->h = h; tex->flags = flags | TF_HAS_FB | TF_HAS_TEX; gl_gen_fbo(tex->tex_w, tex->tex_h, tex->format, 1, &tex->framebuffer, &tex->tex); tex->ref = 1; return tex; } void texture_delete(texture_t *tex) { if (!tex) return; tex->ref--; if (tex->ref > 0) return; free(tex->path); if (tex->framebuffer) { GL(glBindFramebuffer(GL_FRAMEBUFFER, tex->framebuffer)); if (tex->depth) GL(glDeleteRenderbuffers(1, &tex->depth)); if (tex->stencil) GL(glDeleteRenderbuffers(1, &tex->stencil)); GL(glDeleteFramebuffers(1, &tex->framebuffer)); } if (tex->tex) GL(glDeleteTextures(1, &tex->tex)); free(tex); } texture_t *texture_copy(texture_t *tex) { // XXX: since texture are immutable, we just increase the ref counter. if (tex) tex->ref++; return tex; } void texture_get_data(const texture_t *tex, int w, int h, int bpp, uint8_t *buf) { uint8_t *tmp; size_t i, j; tmp = calloc(w * h, 4); GL(glBindFramebuffer(GL_FRAMEBUFFER, tex->framebuffer)); GL(glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, tmp)); // Flip output y and remove alpha if needed. for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { memcpy(&buf[(i * w + j) * bpp], &tmp[((h - i - 1) * w + j) * 4], bpp); } } free(tmp); } /* void texture_save_to_file(const texture_t *tex, const char *path) { uint8_t *data; int w, h; LOG_I("save texture to %s", path); w = tex->tex_w; h = tex->tex_h; data = calloc(w * h, 4); texture_get_data(tex, w, h, 4, data); img_write(data, w, h, 4, path); free(data); } */ goxel-0.11.0/src/utils/texture.h000066400000000000000000000040341435762723100165220ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #ifndef TEXTURE_H #define TEXTURE_H #include #include enum { TF_DEPTH = 1 << 0, TF_STENCIL = 1 << 1, TF_MIPMAP = 1 << 2, TF_KEEP = 1 << 3, TF_RGB = 1 << 4, TF_RGB_565 = 1 << 5, TF_HAS_TEX = 1 << 6, TF_HAS_FB = 1 << 7, TF_NEAREST = 1 << 8, }; // Type: texture_t // Reresent a 2d texture. typedef struct texture texture_t; struct texture { int ref; // For reference copy. char *path; // Only for image textures. int format; uint32_t tex; int tex_w, tex_h; // The actual OpenGL texture size. int x, y, w, h; // Position of the sub texture. int flags; // This is only used for buffer textures. uint32_t framebuffer, depth, stencil; }; texture_t *texture_new_from_buf(const uint8_t *data, int w, int h, int bpp, int flags); texture_t *texture_new_surface(int w, int h, int flags); texture_t *texture_new_buffer(int w, int h, int flags); void texture_get_data(const texture_t *tex, int w, int h, int bpp, uint8_t *buf); texture_t *texture_copy(texture_t *tex); void texture_delete(texture_t *tex); void texture_set_data(texture_t *tex, const uint8_t *data, int w, int h, int bpp); #endif // TEXTURE_H goxel-0.11.0/src/utils/vec.c000066400000000000000000000117351435762723100156000ustar00rootroot00000000000000/* Copyright (c) 2019 Guillaume Chereau * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #include "vec.h" #include static const int EUL_ORDERS[][4] = { // i, j, k, n {0, 1, 2, 0}, // XYZ {0, 2, 1, 1}, // XZY {1, 0, 2, 1}, // YXZ {1, 2, 0, 0}, // YZX {2, 0, 1, 0}, // ZXY {2, 1, 0, 1} // ZYX }; void mat3_normalize_(const float m[3][3], float out[3][3]) { int i; for (i = 0; i < 3; i++) vec3_normalize(m[i], out[i]); } void mat3_to_eul2(const float m[3][3], int order, float e1[3], float e2[3]) { const int *r = EUL_ORDERS[order]; int i = r[0], j = r[1], k = r[2]; int parity = r[3]; float cy = hypot(m[i][i], m[i][j]); float n[3][3]; mat3_normalize_(m, n); if (cy > 16.0f * FLT_EPSILON) { e1[i] = atan2(m[j][k], m[k][k]); e1[j] = atan2(-m[i][k], cy); e1[k] = atan2(m[i][j], m[i][i]); e2[i] = atan2(-m[j][k], -m[k][k]); e2[j] = atan2(-m[i][k], -cy); e2[k] = atan2(-m[i][j], -m[i][i]); } else { e1[i] = atan2(-m[k][j], m[j][j]); e1[j] = atan2(-m[i][k], cy); e1[k] = 0.0; vec3_copy(e1, e2); } if (parity) { vec3_imul(e1, -1); vec3_imul(e2, -1); } } void mat3_to_eul(const float m[3][3], int order, float e[3]) { float e1[3], e2[3]; mat3_to_eul2(m, order, e1, e2); // Pick best. if ( fabs(e1[0]) + fabs(e1[1]) + fabs(e1[2]) > fabs(e2[0]) + fabs(e2[1]) + fabs(e2[2])) { vec3_copy(e2, e); } else { vec3_copy(e1, e); } } void mat3_to_quat(const float m[3][3], float quat[4]) { float t; if (m[2][2] < 0) { if (m[0][0] > m[1][1]) { t = 1 + m[0][0] - m[1][1] - m[2][2]; quat[0] = m[1][2] - m[2][1]; quat[1] = t; quat[2] = m[0][1] + m[1][0]; quat[3] = m[2][0] + m[0][2]; } else { t = 1 - m[0][0] + m[1][1] - m[2][2]; quat[0] = m[2][0] - m[0][2]; quat[1] = m[0][1] + m[1][0]; quat[2] = t; quat[3] = m[1][2] + m[2][1]; } } else { if (m[0][0] < -m[1][1]) { t = 1 - m[0][0] - m[1][1] + m[2][2]; quat[0] = m[0][1] - m[1][0]; quat[1] = m[2][0] + m[0][2]; quat[2] = m[1][2] + m[2][1]; quat[3] = t; } else { t = 1 + m[0][0] + m[1][1] + m[2][2]; quat[0] = t; quat[1] = m[1][2] - m[2][1]; quat[2] = m[2][0] - m[0][2]; quat[3] = m[0][1] - m[1][0]; } } vec4_mul(quat, 0.5 / sqrt(t), quat); } void quat_to_mat3(const float q[4], float m[3][3]) { float q0, q1, q2, q3, qda, qdb, qdc, qaa, qab, qac, qbb, qbc, qcc; q0 = M_SQRT2 * q[0]; q1 = M_SQRT2 * q[1]; q2 = M_SQRT2 * q[2]; q3 = M_SQRT2 * q[3]; qda = q0 * q1; qdb = q0 * q2; qdc = q0 * q3; qaa = q1 * q1; qab = q1 * q2; qac = q1 * q3; qbb = q2 * q2; qbc = q2 * q3; qcc = q3 * q3; m[0][0] = (1.0 - qbb - qcc); m[0][1] = (qdc + qab); m[0][2] = (-qdb + qac); m[1][0] = (-qdc + qab); m[1][1] = (1.0 - qaa - qcc); m[1][2] = (qda + qbc); m[2][0] = (qdb + qac); m[2][1] = (-qda + qbc); m[2][2] = (1.0 - qaa - qbb); } void eul_to_quat(const float e[3], int order, float q[4]) { const int *r = EUL_ORDERS[order]; int i = r[0], j = r[1], k = r[2]; int parity = r[3]; double a[3]; double ti, tj, th, ci, cj, ch, si, sj, sh, cc, cs, sc, ss; ti = e[i] * 0.5f; tj = e[j] * (parity ? -0.5f : 0.5f); th = e[k] * 0.5f; ci = cos(ti); cj = cos(tj); ch = cos(th); si = sin(ti); sj = sin(tj); sh = sin(th); cc = ci * ch; cs = ci * sh; sc = si * ch; ss = si * sh; a[i] = cj * sc - sj * cs; a[j] = cj * ss + sj * cc; a[k] = cj * cs - sj * sc; q[0] = cj * cc + sj * ss; q[1] = a[0]; q[2] = a[1]; q[3] = a[2]; if (parity) q[j + 1] = -q[j + 1]; } goxel-0.11.0/src/utils/vec.h000066400000000000000000000471141435762723100156050ustar00rootroot00000000000000/* Copyright (c) 2016 Guillaume Chereau * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #ifndef VEC_H_ #define VEC_H_ #include #include enum { EULER_ORDER_DEFAULT = 0, // XYZ. EULER_ORDER_XYZ = 0, EULER_ORDER_XZY, EULER_ORDER_YXZ, EULER_ORDER_YZX, EULER_ORDER_ZXY, EULER_ORDER_ZYX }; #define MAT4_IDENTITY {{1, 0, 0, 0}, \ {0, 1, 0, 0}, \ {0, 0, 1, 0}, \ {0, 0, 0, 1}} #define DECL static inline #define VEC(...) ((float[]){__VA_ARGS__}) #define QUAT(w, x, y, z) ((float[]){w, x, y, z}) #define VEC2_SPLIT(v) (v)[0], (v)[1] #define VEC3_SPLIT(v) (v)[0], (v)[1], (v)[2] #define VEC4_SPLIT(v) (v)[0], (v)[1], (v)[2], (v)[3] static const float vec3_zero[] = {0, 0, 0}; static const float vec4_zero[] = {0, 0, 0, 0}; static const float mat4_identity[4][4] = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}; static const float mat4_zero[4][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}; static const float quat_identity[4] = {1, 0, 0, 0}; // S macro for C99 static argument array size. #ifndef __cplusplus #define S static #else #define S #endif DECL void vec2_set(float v[S 2], float x, float y) { v[0] = x; v[1] = y; } /* * Macro: vec3_set * Set a 3 sized array values. */ #define vec3_set(v, x, y, z) do { \ (v)[0] = (x); (v)[1] = (y); (v)[2] = (z); } while(0) /* * Macro: vec4_set * Set a 4 sized array values. */ #define vec4_set(v, x, y, z, w) do { \ (v)[0] = (x); (v)[1] = (y); (v)[2] = (z); (v)[3] = (w); } while(0) DECL void mat4_set(float m[4][4], float a00, float a01, float a02, float a03, float a10, float a11, float a12, float a13, float a20, float a21, float a22, float a23, float a30, float a31, float a32, float a33) { vec4_set(m[0], a00, a01, a02, a03); vec4_set(m[1], a10, a11, a12, a13); vec4_set(m[2], a20, a21, a22, a23); vec4_set(m[3], a30, a31, a32, a33); } DECL void vec2_copy(const float a[S 2], float out[S 2]) { out[0] = a[0]; out[1] = a[1]; } DECL void vec3_copy(const float a[S 3], float out[S 3]) { out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; } /* * Macro: vec4_copy * Copy a 4 sized array into an other one. */ #define vec4_copy(a, b) do { \ (b)[0] = (a)[0]; (b)[1] = (a)[1]; (b)[2] = (a)[2]; (b)[3] = (a)[3]; \ } while (0) DECL bool vec2_equal(const float a[S 2], const float b[S 2]) { return a[0] == b[0] && a[1] == b[1]; } DECL bool vec3_equal(const float a[S 3], const float b[S 3]) { return a[0] == b[0] && a[1] == b[1] && a[2] == b[2]; } /* * Macro: vec4_equal * Test whether two 4 sized vectors are equal. */ #define vec4_equal(a, b) ({ \ (a)[0] == (b)[0] && \ (a)[1] == (b)[1] && \ (a)[2] == (b)[2] && \ (a)[3] == (b)[3]; }) DECL void vec2_add(const float a[S 2], const float b[S 2], float out[S 2]) { out[0] = a[0] + b[0]; out[1] = a[1] + b[1]; } DECL void vec3_add(const float a[S 3], const float b[S 3], float out[S 3]) { out[0] = a[0] + b[0]; out[1] = a[1] + b[1]; out[2] = a[2] + b[2]; } DECL void vec3_iadd(float a[S 3], const float b[S 3]) { vec3_add(a, b, a); } DECL void vec3_addk(const float a[S 3], const float b[S 3], float k, float out[S 3]) { out[0] = a[0] + b[0] * k; out[1] = a[1] + b[1] * k; out[2] = a[2] + b[2] * k; } DECL void vec3_iaddk(float a[S 3], const float b[S 3], float k) { vec3_addk(a, b, k, a); } DECL void vec2_sub(const float a[S 2], const float b[S 2], float out[S 2]) { out[0] = a[0] - b[0]; out[1] = a[1] - b[1]; } DECL void vec3_sub(const float a[S 3], const float b[S 3], float out[S 3]) { out[0] = a[0] - b[0]; out[1] = a[1] - b[1]; out[2] = a[2] - b[2]; } DECL void vec3_isub(float a[S 3], const float b[S 3]) { vec3_sub(a, b, a); } DECL void vec2_mul(const float a[S 2], float k, float out[S 2]) { out[0] = a[0] * k; out[1] = a[1] * k; } DECL void vec3_mul(const float a[S 3], float k, float out[S 3]) { out[0] = a[0] * k; out[1] = a[1] * k; out[2] = a[2] * k; } DECL void vec4_mul(const float a[S 4], float k, float out[S 4]) { out[0] = a[0] * k; out[1] = a[1] * k; out[2] = a[2] * k; out[3] = a[3] * k; } DECL void vec3_imul(float a[S 3], float k) { vec3_mul(a, k, a); } DECL void vec3_neg(const float a[S 3], float out[S 3]) { vec3_mul(a, -1, out); } DECL float vec2_dot(const float a[S 2], const float b[S 2]) { return a[0] * b[0] + a[1] * b[1]; } DECL float vec3_dot(const float a[S 3], const float b[S 3]) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; } DECL float vec2_norm2(const float a[S 2]) { return vec2_dot(a, a); } DECL float vec3_norm2(const float a[S 3]) { return vec3_dot(a, a); } DECL float vec2_norm(const float a[S 2]) { return sqrt(vec2_norm2(a)); } DECL void vec2_normalize(const float a[S 2], float out[S 2]) { vec2_mul(a, 1 / vec2_norm(a), out); } DECL float vec3_norm(const float a[S 3]) { return sqrt(vec3_norm2(a)); } DECL void vec3_normalize(const float a[S 3], float out[S 3]) { vec3_mul(a, 1 / vec3_norm(a), out); } DECL float vec2_dist2(const float a[S 2], const float b[S 2]) { float u[2]; vec2_sub(a, b, u); return vec2_norm2(u); } DECL float vec2_dist(const float a[S 2], const float b[S 2]) { return sqrt(vec2_dist2(a, b)); } DECL float vec3_dist2(const float a[S 3], const float b[S 3]) { float d[3]; vec3_sub(a, b, d); return vec3_norm2(d); } DECL float vec3_dist(const float a[S 3], const float b[S 3]) { return sqrt(vec3_dist2(a, b)); } DECL void vec2_mix(const float a[S 2], const float b[S 2], float t, float out[S 2]) { out[0] = a[0] * (1 - t) + b[0] * t; out[1] = a[1] * (1 - t) + b[1] * t; } DECL void vec3_mix(const float a[S 3], const float b[S 3], float t, float out[S 3]) { out[0] = a[0] * (1 - t) + b[0] * t; out[1] = a[1] * (1 - t) + b[1] * t; out[2] = a[2] * (1 - t) + b[2] * t; } DECL void vec3_lerp(const float a[S 3], const float b[S 3], float t, float out[S 3]) { vec3_mix(a, b, t, out); } DECL bool vec3_lerp_const(const float a[S 3], const float b[S 3], float d, float out[S 3]) { float u[3]; float d2 = vec3_dist2(a, b); if (d2 < d * d) { vec3_copy(b, out); return true; } vec3_sub(b, a, u); vec3_normalize(u, u); vec3_addk(a, u, d, out); return false; } DECL bool vec3_ilerp_const(float a[S 3], const float b[S 3], float d) { return vec3_lerp_const(a, b, d, a); } DECL void vec3_project(const float a[S 3], const float b[S 3], float out[S 3]) { vec3_mul(b, vec3_dot(a, b) / vec3_dot(b, b), out); } DECL float vec2_cross(const float a[S 2], const float b[S 2]) { return a[0] * b[1] - a[1] * b[0]; } DECL void vec3_cross(const float a[S 3], const float b[S 3], float out[S 3]) { out[0] = a[1] * b[2] - a[2] * b[1]; out[1] = a[2] * b[0] - a[0] * b[2]; out[2] = a[0] * b[1] - a[1] * b[0]; } DECL void mat4_copy(const float m[S 4][4], float out[S 4][4]) { int i, j; for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) out[i][j] = m[i][j]; } DECL void mat4_mul_vec4(const float m[S 4][4], const float v[S 4], float out[S 4]) { float ret[4] = {}; int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { ret[i] += m[j][i] * v[j]; } } vec4_copy(ret, out); } DECL void mat4_mul_vec3(const float m[S 4][4], const float v[S 3], float out[S 3]) { float v4[4] = {v[0], v[1], v[2], 1.0f}; mat4_mul_vec4(m, v4, v4); vec3_copy(v4, out); } DECL void mat4_translate(const float m[S 4][4], float x, float y, float z, float out[S 4][4]) { float tmp[4][4]; int i; mat4_copy(m, tmp); #define M(row,col) tmp[(row)][(col)] for (i = 0; i < 4; i++) { M(4 - 1, i) += M(0, i) * x + M(1, i) * y + M(2, i) * z; } #undef M mat4_copy(tmp, out); } DECL void mat4_itranslate(float m[S 4][4], float x, float y, float z) { mat4_translate(m, x, y, z, m); } DECL void mat4_scale(const float m[S 4][4], float x, float y, float z, float out[S 4][4]) { int i; float tmp[4][4]; mat4_copy(m, tmp); for (i = 0; i < 4; i++) { tmp[0][i] *= x; tmp[1][i] *= y; tmp[2][i] *= z; } mat4_copy(tmp, out); } DECL void mat4_iscale(float m[S 4][4], float x, float y, float z) { mat4_scale(m, x, y, z, m); } DECL bool mat4_invert(const float mat[S 4][4], float out[S 4][4]) { float det; int i; const float *m = (const float*)mat; float inv[16]; #define M(i, j, k) m[i] * m[j] * m[k] inv[0] = M(5, 10, 15) - M(5, 11, 14) - M(9, 6, 15) + M(9, 7, 14) + M(13, 6, 11) - M(13, 7, 10); inv[4] = -M(4, 10, 15) + M( 4, 11, 14) + M( 8, 6, 15) - M(8, 7, 14) - M(12, 6, 11) + M(12, 7, 10); inv[8] = M(4, 9, 15) - M( 4, 11, 13) - M(8, 5, 15) + M(8, 7, 13) + M(12, 5, 11) - M(12, 7, 9); inv[12] = -M(4, 9, 14) + M(4, 10, 13) + M(8, 5, 14) - M(8, 6, 13) - M(12, 5, 10) + M(12, 6, 9); inv[1] = -M(1, 10, 15) + M(1, 11, 14) + M(9, 2, 15) - M(9, 3, 14) - M(13, 2, 11) + M(13, 3, 10); inv[5] = M(0, 10, 15) - M(0, 11, 14) - M(8, 2, 15) + M(8, 3, 14) + M(12, 2, 11) - M(12, 3, 10); inv[9] = -M(0, 9, 15) + M(0, 11, 13) + M(8, 1, 15) - M(8, 3, 13) - M(12, 1, 11) + M(12, 3, 9); inv[13] = M(0, 9, 14) - M(0, 10, 13) - M(8, 1, 14) + M(8, 2, 13) + M(12, 1, 10) - M(12, 2, 9); inv[2] = M(1, 6, 15) - M(1, 7, 14) - M(5, 2, 15) + M(5, 3, 14) + M(13, 2, 7) - M(13, 3, 6); inv[6] = -M(0, 6, 15) + M(0, 7, 14) + M(4, 2, 15) - M(4, 3, 14) - M(12, 2, 7) + M(12, 3, 6); inv[10] = M(0, 5, 15) - M(0, 7, 13) - M(4, 1, 15) + M(4, 3, 13) + M(12, 1, 7) - M(12, 3, 5); inv[14] = -M(0, 5, 14) + M(0, 6, 13) + M(4, 1, 14) - M(4, 2, 13) - M(12, 1, 6) + M(12, 2, 5); inv[3] = -M(1, 6, 11) + M(1, 7, 10) + M(5, 2, 11) - M(5, 3, 10) - M(9, 2, 7) + M(9, 3, 6); inv[7] = M(0, 6, 11) - M(0, 7, 10) - M(4, 2, 11) + M(4, 3, 10) + M(8, 2, 7) - M(8, 3, 6); inv[11] = -M(0, 5, 11) + M(0, 7, 9) + M(4, 1, 11) - M(4, 3, 9) - M(8, 1, 7) + M(8, 3, 5); inv[15] = M(0, 5, 10) - M(0, 6, 9) - M(4, 1, 10) + M(4, 2, 9) + M(8, 1, 6) - M(8, 2, 5); #undef M det = m[0] * inv[0] + m[1] * inv[4] + m[2] * inv[8] + m[3] * inv[12]; if (det == 0) return false; det = 1.0 / det; for (i = 0; i < 16; i++) out[i / 4][i % 4] = inv[i] * det; return true; } DECL void mat4_igrow(float m[S 4][4], float x, float y, float z) { // XXX: need to optimize this. float s[3]; float v[3][4] = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}}; int i; for (i = 0; i < 3; i++) { mat4_mul_vec4(m, v[i], v[i]); s[i] = vec3_norm(v[i]); } s[0] = (2 * x + s[0]) / s[0]; s[1] = (2 * y + s[1]) / s[1]; s[2] = (2 * z + s[2]) / s[2]; mat4_iscale(m, s[0], s[1], s[2]); } DECL void mat4_mul(const float a[S 4][4], const float b[S 4][4], float out[S 4][4]) { int i, j, k; float ret[4][4] = {}; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { ret[j][i] = 0.0; for (k = 0; k < 4; ++k) { ret[j][i] += a[k][i] * b[j][k]; } } } mat4_copy(ret, out); } DECL void mat4_imul(float a[S 4][4], const float b[S 4][4]) { mat4_mul(a, b, a); } DECL void mat4_ortho(float m[S 4][4], float left, float right, float bottom, float top, float nearval, float farval) { float tx = -(right + left) / (right - left); float ty = -(top + bottom) / (top - bottom); float tz = -(farval + nearval) / (farval - nearval); const float ret[4][4] = { {2 / (right - left), 0, 0, 0}, {0, 2 / (top - bottom), 0, 0}, {0, 0, -2 / (farval - nearval), 0}, {tx, ty, tz, 1}, }; mat4_copy(ret, m); } DECL void mat4_perspective(float m[S 4][4], float fovy, float aspect, float nearval, float farval) { float radian = fovy * M_PI / 180.f; float f = 1.f / tan(radian / 2.f); const float ret[4][4] = { {f / aspect, 0.f, 0.f, 0.f}, {0.f, f, 0.f, 0.f}, {0.f, 0.f, (farval + nearval) / (nearval - farval), -1.f}, {0.f, 0.f, 2.f * farval * nearval / (nearval - farval), 0.f}, }; mat4_copy(ret, m); } DECL void mat4_transpose(const float m[S 4][4], float out[S 4][4]) { int i, j; float ret[4][4] = {}; for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) ret[i][j] = m[j][i]; mat4_copy(ret, out); } DECL void mat4_set_identity(float m[S 4][4]) { mat4_copy(mat4_identity, m); } // Similar to gluLookAt DECL void mat4_lookat(float m[S 4][4], const float eye[S 3], const float center[S 3], const float up[S 3]) { float f[3], s[3], u[3], ret[4][4]; mat4_set_identity(ret); vec3_sub(center, eye, f); vec3_normalize(f, f); vec3_cross(f, up, s); vec3_normalize(s, s); vec3_cross(s, f, u); vec3_normalize(u, u); vec3_copy(s, ret[0]); vec3_copy(u, ret[1]); vec3_neg(f, ret[2]); mat4_transpose(ret, ret); mat4_translate(ret, -eye[0], -eye[1], -eye[2], ret); mat4_copy(ret, m); } DECL void quat_set_identity(float q[S 4]) { q[0] = 1; q[1] = 0; q[2] = 0; q[3] = 0; } DECL void quat_copy(const float q[S 4], float out[S 4]) { out[0] = q[0]; out[1] = q[1]; out[2] = q[2]; out[3] = q[3]; } DECL void quat_from_axis(float quat[S 4], float a, float x, float y, float z); DECL void quat_to_mat4(const float q[S 4], float out[S 4][4]); DECL void mat4_rotate(const float m[S 4][4], float a, float x, float y, float z, float out[S 4][4]) { if (a == 0.0) { mat4_copy(m, out); return; } float tmp[4][4]; float s = sin(a); float c = cos(a); mat4_set_identity(tmp); #define M(row,col) tmp[col][row] if (x == 1.0 && y == 0.0 && z == 0.0) { M(1,1) = c; M(2,2) = c; M(1,2) = -s; M(2,1) = s; } else if (x == 0.0 && y == 1.0 && z == 0.0) { M(0, 0) = c; M(2, 2) = c; M(0, 2) = s; M(2, 0) = -s; } else if (x == 0.0 && y == 0.0 && z == 1.0) { M(0, 0) = c; M(1, 1) = c; M(0, 1) = -s; M(1, 0) = s; } else { float quat[4]; quat_from_axis(quat, a, x, y, z); quat_to_mat4(quat, tmp); } #undef M mat4_mul(m, tmp, out); } DECL void mat4_irotate(float m[S 4][4], float a, float x, float y, float z) { mat4_rotate(m, a, x, y, z, m); } DECL bool mat4_equal(const float a[S 4][4], const float b[S 4][4]) { int i, j; for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) if (a[i][j] != b[i][j]) return false; return true; } DECL void mat4_to_mat3(const float m[S 4][4], float out[3][3]) { int i, j; for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) out[i][j] = m[i][j]; } DECL void quat_from_axis(float quat[S 4], float a, float x, float y, float z) { float sin_angle; float vn[3] = {x, y, z}; a *= 0.5f; vec3_normalize(vn, vn); sin_angle = sin(a); quat[0] = cos(a); quat[1] = vn[0] * sin_angle; quat[2] = vn[1] * sin_angle; quat[3] = vn[2] * sin_angle; } DECL void quat_to_mat4(const float q[S 4], float out[S 4][4]) { float w, x, y, z; w = q[0]; x = q[1]; y = q[2]; z = q[3]; const float ret[4][4] = { {1-2*y*y-2*z*z, 2*x*y+2*z*w, 2*x*z-2*y*w, 0}, { 2*x*y-2*z*w, 1-2*x*x-2*z*z, 2*y*z+2*x*w, 0}, { 2*x*z+2*y*w, 2*y*z-2*x*w, 1-2*x*x-2*y*y, 0}, { 0, 0, 0, 1}}; mat4_copy(ret, out); } DECL void quat_conjugate(const float q[S 4], float out[S 4]) { out[0] = q[0]; out[1] = -q[1]; out[2] = -q[2]; out[3] = -q[3]; } DECL void quat_mul(const float a[S 4], const float b[S 4], float out[S 4]) { out[0] = a[0] * b[0] - a[1] * b[1] - a[2] * b[2] - a[3] * b[3]; out[1] = a[0] * b[1] + a[1] * b[0] + a[2] * b[3] - a[3] * b[2]; out[2] = a[0] * b[2] + a[2] * b[0] + a[3] * b[1] - a[1] * b[3]; out[3] = a[0] * b[3] + a[3] * b[0] + a[1] * b[2] - a[2] * b[1]; } DECL void quat_imul(float a[S 4], const float b[S 4]) { quat_mul(a, b, a); } DECL void quat_rotate(const float q[S 4], float a, float x, float y, float z, float out[S 4]) { float other[4]; quat_from_axis(other, a, x, y, z); quat_mul(q, other, out); } DECL void quat_irotate(float q[S 4], float a, float x, float y, float z) { quat_rotate(q, a, x, y, z, q); } DECL void quat_mul_vec4(const float q[S 4], const float v[S 4], float out[S 4]) { float m[4][4]; quat_to_mat4(q, m); mat4_mul_vec4(m, v, out); } DECL void mat4_mul_quat(const float mat[S 4][4], const float q[S 4], float out[S 4][4]) { float qm[4][4]; quat_to_mat4(q, qm); mat4_mul(mat, qm, out); } DECL void mat4_imul_quat(float mat[S 4][4], const float q[S 4]) { mat4_mul_quat(mat, q, mat); } void mat3_to_eul(const float m[S 3][3], int order, float e[S 3]); void mat3_to_eul2(const float m[S 3][3], int order, float e1[S 3], float e2[S 3]); void mat3_to_quat(const float m[S 3][3], float quat[S 4]); void quat_to_mat3(const float q[S 4], float out[S 3][3]); DECL void quat_to_eul(const float q[S 4], int order, float e[S 3]) { float m[3][3]; quat_to_mat3(q, m); mat3_to_eul(m, order, e); } DECL void quat_to_eul2(const float q[S 4], int order, float e1[S 3], float e2[S 3]) { float m[3][3]; quat_to_mat3(q, m); mat3_to_eul2(m, order, e1, e2); } void eul_to_quat(const float e[S 3], int order, float out[S 4]); DECL void quat_normalize(const float q[S 4], float out[S 4]) { float n = sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]); out[0] = q[0] / n; out[1] = q[1] / n; out[2] = q[2] / n; out[3] = q[3] / n; } #undef S #endif // VEC_H_ goxel-0.11.0/src/xxhash.c000066400000000000000000000014311435762723100151560ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2019 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ #define XXH_NO_LONG_LONG #include "../ext_src/xxhash/xxhash.c" goxel-0.11.0/src/yocto.cpp000066400000000000000000000034371435762723100153600ustar00rootroot00000000000000/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* * This file is just there to compile all the needed yocto-gl sources, so * that we keeps a clean build system. */ #ifndef YOCTO # define YOCTO 1 #endif #if YOCTO #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wcomma" #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #ifndef __clang__ #pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wparentheses" #pragma GCC diagnostic ignored "-Wreturn-type" #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif #include #include #include #define YOCTO_EMBREE 0 #define STB_IMAGE_STATIC #define STB_IMAGE_WRITE_STATIC // Fix compilation on Windows. #ifdef NOMINMAX #undef NOMINMAX #endif #include "../ext_src/yocto/yocto_bvh.cpp" #include "../ext_src/yocto/yocto_image.cpp" #include "../ext_src/yocto/yocto_scene.cpp" #include "../ext_src/yocto/yocto_shape.cpp" #include "../ext_src/yocto/yocto_trace.cpp" #pragma GCC diagnostic pop #endif // YOCTO goxel-0.11.0/svg/000077500000000000000000000000001435762723100135205ustar00rootroot00000000000000goxel-0.11.0/svg/icons.svg000066400000000000000000003600601435762723100153610ustar00rootroot00000000000000 image/svg+xml goxel-0.11.0/tools/000077500000000000000000000000001435762723100140615ustar00rootroot00000000000000goxel-0.11.0/tools/create_assets.py000077500000000000000000000076351435762723100172760ustar00rootroot00000000000000#!/usr/bin/python3 # Goxel 3D voxels editor # # copyright (c) 2016 Guillaume Chereau # # Goxel is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # Goxel is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # goxel. If not, see . # Read all the files in 'data', and create assets.inl with all the data. For # text file, we try to keep the data as a string, for binary files we store it # into a uint8_t array. from collections import namedtuple import os import sys if os.path.basename(os.path.dirname(__file__)) != "tools": print("Should be run from goxel root directory") sys.exit(-1) TYPES = { "png": { "text": False, }, "goxcf": { "text": True, }, "gpl": { "text": True, }, "pov": { "text": True, }, "ttf": { "text": False }, "wav": { "text": False }, "ini": { "text": True }, "glsl": { "text": True }, "gox": { "text": False }, "lua": { "text": True }, } GROUPS = ['fonts', 'icons', 'images', 'other', 'palettes', 'progs', 'shaders', 'sounds', 'themes', 'samples', 'mobile'] TEMPLATE = '{{.path = "{path}", .size = {size}, .data =\n{data}\n}},' File = namedtuple('File', 'path name data size') HEADER = """/* Goxel 3D voxels editor * * copyright (c) 2018 Guillaume Chereau * * Goxel is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * Goxel is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * You should have received a copy of the GNU General Public License along with * goxel. If not, see . */ /* This file is autogenerated by tools/create_assets.py */ """ def list_files(group): ret = [] for root, dirs, files in os.walk("data/%s" % group): for f in files: if any(f.endswith('.' + x) for x in TYPES): ret.append(os.path.join(root, f)) return sorted(ret, key=lambda x: x.upper()) def encode_str(data): data = data.decode() ret = ' "' for c in data: if c == '\n': ret += '\\n"\n "' continue if c == '"': c = '\\"' if c == '\\': c = '\\\\' ret += c ret += '"' return ret def encode_bin(data): ret = "(const uint8_t[]){\n" line = "" for i, c in enumerate(data): line += "{},".format(c) if len(line) >= 70 or i == len(data) - 1: ret += " " + line + "\n" line = "" ret += "}" return ret; def create_file(f): data = open(f, 'rb').read() size = len(data) name = f.replace('/', '_').replace('.', '_').replace('-', '_') ext = f.split(".")[-1] if TYPES[ext]['text']: size += 1 # So that we NULL terminate the string. data = encode_str(data) else: data = encode_bin(data) return File(f, name, data, size) for group in GROUPS: files = [] for f in list_files(group): files.append(create_file(f)) if not files: continue out = open("src/assets/%s.inl" % group, "w") print(HEADER, file=out) for f in files: print(TEMPLATE.format(**f._asdict()), file=out) print("\n\n", file=out) goxel-0.11.0/tools/create_font.py000077500000000000000000000027511435762723100167340ustar00rootroot00000000000000#!/usr/bin/python #encoding: utf-8 # Goxel 3D voxels editor # # copyright (c) 2018 Guillaume Chereau # # Goxel is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # Goxel is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # goxel. If not, see . # ************************************************************************ # Generate a small font file by removing all unwanted characters from a base # font. import fontforge import unicodedata PATH = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf" CHARS = (u"abcdefghijklmnopqrstuvwxyz" u"ABCDEFGHIJKLMNOPQRSTUVWXYZ" u"0123456789" u" ?!\"#$%&'()*+,-./°¯[]^:<>{}@_=±" u"◀▶▲▼▴▾●©" ) font = fontforge.open(PATH) for g in font: u = font[g].unicode if u == -1: continue u = unichr(u) if u not in CHARS: continue font.selection[ord(u)] = True font.selection.invert() for i in font.selection.byGlyphs: font.removeGlyph(i) font.generate("data/fonts/DejaVuSans-light.ttf") goxel-0.11.0/tools/create_icons.py000077500000000000000000000036741435762723100171060ustar00rootroot00000000000000#!/usr/bin/python3 # Goxel 3D voxels editor # # copyright (c) 2018 Guillaume Chereau # # Goxel is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # Goxel is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # goxel. If not, see . # ************************************************************************ # Create the icon atlas image from all the icons svg files import itertools import PIL.Image from shutil import copyfile import os import subprocess import re # Use inkscape to convert the svg into one big png file. subprocess.check_output([ 'inkscape', './svg/icons.svg', '--export-area-page', '--export-dpi=192', '--export-png=/tmp/icons.png']) src_img = PIL.Image.open('/tmp/icons.png') ret_img = PIL.Image.new('RGBA', (512, 512)) for x, y in itertools.product(range(8), range(8)): img = src_img.crop((x * 46 + 2, y * 46 + 2, x * 46 + 46, y * 46 + 46)) # Make the image white in the special range. if y >= 2 and y < 5: tmp = PIL.Image.new('RGBA', (44, 44), (255, 255, 255, 255)) tmp.putalpha(img.split()[3]) img = tmp ret_img.paste(img, (64 * x + 10, 64 * y + 10)) ret_img.save('data/images/icons.png') # Also create the application icons (in data/icons) if not os.path.exists('data/icons'): os.makedirs('data/icons') base = PIL.Image.open('icon.png').convert('RGBA') for size in [16, 24, 32, 48, 64, 128, 256]: img = base.resize((size, size), PIL.Image.BILINEAR) img.save('data/icons/icon%d.png' % size)